From patchwork Thu Jun 11 12:41:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 192468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DE71C433DF for ; Thu, 11 Jun 2020 12:44:42 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25D652078D for ; Thu, 11 Jun 2020 12:44:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="FHJcPZPq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="V4h1Ca5n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25D652078D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 90DA21692; Thu, 11 Jun 2020 14:43:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 90DA21692 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591879480; bh=lOgsJP+8QmzeAyx4ajOTZd9m6uCeUnihaH/7WfP9ZRU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FHJcPZPqRof0+GLRNvQXeaT9ccci9aNNLgDoCQugnQnvDj2DM2oJSzHY4GpSk00Mf fyWu0PAVIu/HO0/CNIdPjJT4Zmhcu2ZgxWNYcr+4jmmbV9E2I+hPWQ9bvaYFGaYvap PzoKSJ42PumstBnbJ+8Y5t4xdmdpKBnxUrW8i3zw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CA684F802A1; Thu, 11 Jun 2020 14:42:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DE9BAF802A8; Thu, 11 Jun 2020 14:42:12 +0200 (CEST) Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3AD0DF8028C for ; Thu, 11 Jun 2020 14:42:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3AD0DF8028C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="V4h1Ca5n" Received: by mail-wr1-x442.google.com with SMTP id x14so6013662wrp.2 for ; Thu, 11 Jun 2020 05:42:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DNGruM6B9mSP+joziG19q2cWIhnj5b++piG0JMa2V6w=; b=V4h1Ca5nmbkGj2hladouj3f0enZ42GxqHryh272WGrCyPuT8xAqb5wtLULOLNDb+kC 4nQJutDNKmqUgli3yOe3RjfHFZaSVQ19vyaJsIfIPTBQY8Djk8nvgmc+cLynOwY483hE +j/KXAsI6qxCx/3+go7O4EV+4+zHdi9amag7lzmPK6C1Pc0f5/gueHRHXHCloSoGx5wE oQw5gZFdYR3DQEGt4IpZC6IyjcxKMBtvidnKZ4MoZXG42gGEyoM7bHwuHH5p0KoFSjTv JSKm5hl4tsRxMY0LiWiW2QKqLF2UTBI0Tz96AH8b2WczI3be44UTQa/le2UeX/qI5JgH Nw+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DNGruM6B9mSP+joziG19q2cWIhnj5b++piG0JMa2V6w=; b=KvzpUaWqnWVefhRL4u1yjRL+1/55uZyM1LHBBScRluP06X/tdE9Lv097wdg/HFjVam e4JlJ8Hlm7ft7Ig6Drexklr6paxgoK3x/M4QsFqo9U1ORDMcxdTtfx4I2RRq74Iggh3X 59i6kI5AOn8csYrq0/ihqpYBTm2qOpTtWM1Uj624ZizYaJdcYs+pwSu6B2GjT4NgAd5c P9yipBravnDV/5Xh1GeyeOi+P0EDWEy/9GF9YUSoV8ab+R/2kCyU6HcwELUt0KC3bXvp WpmMaktJVgJ5K4PXwueWyHXzWR//ZcfGeQSjI89w1gjK4bDynKeA09683twgIMUgj5mm Cm+g== X-Gm-Message-State: AOAM533IYRPYUSK4eQODGN+v6BRa4AeE4Rm3I1ipi9Crhnm6OednWRjB aflV7eRsF1BDfYnmNu2LWwaJLg== X-Google-Smtp-Source: ABdhPJz4z+o5PKHUFnC5aUpJgoVQGqDgO8B3X+8NJKRrokT1gn4IjQF8Z7a2PR+JqR94h+2kLxN8eA== X-Received: by 2002:a5d:5585:: with SMTP id i5mr9200628wrv.112.1591879325343; Thu, 11 Jun 2020 05:42:05 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id q13sm4810355wrn.84.2020.06.11.05.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 05:42:04 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 2/8] ASoC: q6asm: handle EOS correctly Date: Thu, 11 Jun 2020 13:41:53 +0100 Message-Id: <20200611124159.20742-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200611124159.20742-1-srinivas.kandagatla@linaro.org> References: <20200611124159.20742-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tiwai@suse.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, vkoul@kernel.org, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Successful send of EOS command does not indicate that EOS is actually finished, correct event to wait EOS is finished is EOS_RENDERED event. EOS_RENDERED means that the DSP has finished processing all the buffers for that particular session and stream. This patch fixes EOS handling! Fixes: 68fd8480bb7b ("ASoC: qdsp6: q6asm: Add support to audio stream apis") Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6asm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c index 0ce70a5c7d9e..e0983970cba9 100644 --- a/sound/soc/qcom/qdsp6/q6asm.c +++ b/sound/soc/qcom/qdsp6/q6asm.c @@ -25,6 +25,7 @@ #define ASM_STREAM_CMD_FLUSH 0x00010BCE #define ASM_SESSION_CMD_PAUSE 0x00010BD3 #define ASM_DATA_CMD_EOS 0x00010BDB +#define ASM_DATA_EVENT_RENDERED_EOS 0x00010C1C #define ASM_NULL_POPP_TOPOLOGY 0x00010C68 #define ASM_STREAM_CMD_FLUSH_READBUFS 0x00010C09 #define ASM_STREAM_CMD_SET_ENCDEC_PARAM 0x00010C10 @@ -622,9 +623,6 @@ static int32_t q6asm_stream_callback(struct apr_device *adev, case ASM_SESSION_CMD_SUSPEND: client_event = ASM_CLIENT_EVENT_CMD_SUSPEND_DONE; break; - case ASM_DATA_CMD_EOS: - client_event = ASM_CLIENT_EVENT_CMD_EOS_DONE; - break; case ASM_STREAM_CMD_FLUSH: client_event = ASM_CLIENT_EVENT_CMD_FLUSH_DONE; break; @@ -727,6 +725,9 @@ static int32_t q6asm_stream_callback(struct apr_device *adev, spin_unlock_irqrestore(&ac->lock, flags); } + break; + case ASM_DATA_EVENT_RENDERED_EOS: + client_event = ASM_CLIENT_EVENT_CMD_EOS_DONE; break; } From patchwork Thu Jun 11 12:41:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 192467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5F88C433E0 for ; Thu, 11 Jun 2020 12:45:34 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E50A2078D for ; Thu, 11 Jun 2020 12:45:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="c0L5AnH8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VdEQrWYs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E50A2078D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 01E5F1690; Thu, 11 Jun 2020 14:44:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 01E5F1690 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591879533; bh=OUWzDcuVY+yeBdYHgxu5A3ys+vhzUyAAAbYfSCUWKF8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=c0L5AnH8xm2L/p7zw31uEdo0v4ZsfLZyDWMnVhqIBZH2V69S5JVyPh0pE5AvVQt8m 9qEbDORIvuW1ERo0n8mqtBOv6ew5JgBQrdqaQB5UDZGx9Pngv4MdYa1BopYM1YCZc8 /6eh5aGDoo5Q1mJj2MDlSQZSAgon/T3BmI7r2Ixc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BDB1EF802D2; Thu, 11 Jun 2020 14:42:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4AB2EF802A9; Thu, 11 Jun 2020 14:42:16 +0200 (CEST) Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E198CF80291 for ; Thu, 11 Jun 2020 14:42:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E198CF80291 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VdEQrWYs" Received: by mail-wr1-x443.google.com with SMTP id r7so6032859wro.1 for ; Thu, 11 Jun 2020 05:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XmFQ91h0GZrG5WahISB8fgmLlciVJglL2OXgg5eRNY4=; b=VdEQrWYs2Uqc2Ff7VpJtv1mSFf9m6Ugbt1BOFmKKvAN6xEchlHWIOcLuP+mjyslQb9 foXUJjSZurXBRLrt8jabAIuejWX/fdwZKdtRrawNaGIz4SvUmGyJzHVpHIJh+16Cmdm3 66pfsdmIG6BgIKMocfQC0niEPRpxZ5W8xB6qJ9Ae2b/O+XP6SgDFEbSyd9PJQWSD7zTm 9aw9Vyc24x6+eDhFTcPLXyyjRBir5cq3qS5ec5nvz6/1uy6LxBZLYaso4NQ8C+SxYjqA 7IAUuJyZg9o8SAPF8PodoqQqvnAX512t3lrkTVYYN7qHKjDpBu1gXNH1eIP4l1jOvylo L+Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XmFQ91h0GZrG5WahISB8fgmLlciVJglL2OXgg5eRNY4=; b=cerkb2aweHLZ2ek9CdnAP+qRy0KSeb6bViziSgQ60kj9xOO/cnLLqL/rAjuKAPG5Zm YZ9rZRGLmj/Z9yHHcBvhYzysVMFT7endY8weBbuv12OYp1iCTCUCK2m8DvmNg0Brbjf3 07aEnTOzfV4oGGPV42R0Vk951/6JOxrgNhTBAwTjXbr414IbMSADuVchWckphDJBd37C 1Ix5i5HbghaJxRqbwpLVdRbPrFe4elJycX5S3a+LOw8zNB7Zg95Ci18l6b743vixKvvD UUqYPmdCdXb2dZyMTpNfxLlX1lxMwF6FZSQwsMgc+C+cinigQvjDgw+C3eluVwrpAAB/ bvXQ== X-Gm-Message-State: AOAM530GtKtNyKaU5NxL0ZwIsj6KnODS77jbCd9cJ5I8Z/2nlEJ6YHZd LRZwrpjl6FpSVEbAjk0uPJxg1oBfhCU= X-Google-Smtp-Source: ABdhPJxbLRxb3pVa6kGKVQjFbdxlVetJsMnut5Ck76cBOeP9CLWnh9yMeXxDXOKDLBn/O5OnCR4ROA== X-Received: by 2002:a05:6000:10cf:: with SMTP id b15mr9137648wrx.214.1591879326516; Thu, 11 Jun 2020 05:42:06 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id q13sm4810355wrn.84.2020.06.11.05.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 05:42:05 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 3/8] ASoC: q6asm: rename misleading session id variable Date: Thu, 11 Jun 2020 13:41:54 +0100 Message-Id: <20200611124159.20742-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200611124159.20742-1-srinivas.kandagatla@linaro.org> References: <20200611124159.20742-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tiwai@suse.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, vkoul@kernel.org, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Each q6asm session can have multiple streams, mixing usage of these names in variable are bit misleading to reader, so rename them accordingly. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6asm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c index e0983970cba9..51da3717a6a6 100644 --- a/sound/soc/qcom/qdsp6/q6asm.c +++ b/sound/soc/qcom/qdsp6/q6asm.c @@ -828,21 +828,21 @@ EXPORT_SYMBOL_GPL(q6asm_get_session_id); * @dev: Pointer to asm child device. * @cb: event callback. * @priv: private data associated with this client. - * @stream_id: stream id + * @session_id: session id * @perf_mode: performace mode for this client * * Return: Will be an error pointer on error or a valid audio client * on success. */ struct audio_client *q6asm_audio_client_alloc(struct device *dev, q6asm_cb cb, - void *priv, int stream_id, + void *priv, int session_id, int perf_mode) { struct q6asm *a = dev_get_drvdata(dev->parent); struct audio_client *ac; unsigned long flags; - ac = q6asm_get_audio_client(a, stream_id + 1); + ac = q6asm_get_audio_client(a, session_id + 1); if (ac) { dev_err(dev, "Audio Client already active\n"); return ac; @@ -853,9 +853,9 @@ struct audio_client *q6asm_audio_client_alloc(struct device *dev, q6asm_cb cb, return ERR_PTR(-ENOMEM); spin_lock_irqsave(&a->slock, flags); - a->session[stream_id + 1] = ac; + a->session[session_id + 1] = ac; spin_unlock_irqrestore(&a->slock, flags); - ac->session = stream_id + 1; + ac->session = session_id + 1; ac->cb = cb; ac->dev = dev; ac->q6asm = a; From patchwork Thu Jun 11 12:41:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 192466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01CA8C433E0 for ; Thu, 11 Jun 2020 12:47:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D6752078D for ; Thu, 11 Jun 2020 12:47:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="AaYTbXkt"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="s+lJoAWo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D6752078D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 100641679; Thu, 11 Jun 2020 14:46:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 100641679 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591879631; bh=uTmFuzq8ftfBCejonkdjTHFTnppNHZzRJMv3AWJkr3Q=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AaYTbXktolStQihwGoY5d1czwVn2bcoC0lnOngcpjjOZhI4D787A/Qrq9LoqXFV6e QKMgOmqPHxdZVH9SCs49z2RDvQ1jUjcB1XNNMw20pNeZ+2IiO8VrL7AXDquyi+R1fM OMosXVyXxXZEk/IhBEp7zopJB92ww0xC5GFJppP8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E2CECF802F9; Thu, 11 Jun 2020 14:42:24 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C490EF802DC; Thu, 11 Jun 2020 14:42:20 +0200 (CEST) Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7CEC5F802A2 for ; Thu, 11 Jun 2020 14:42:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7CEC5F802A2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="s+lJoAWo" Received: by mail-wm1-x344.google.com with SMTP id l26so4842322wme.3 for ; Thu, 11 Jun 2020 05:42:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lNnQU7nlgCvrEQswoURWL2iF3lzneMUM2jWkpbiMSAc=; b=s+lJoAWoRoGJECYvMbW8eS/y8a2BEeRfBiogjqYTcMstMMl7ZBj476aHb5zduSoo24 DhxTUxmMo+hA8OCL6ST7FXGEwcN948WQv+kRteqTdRgvasABBsCX9HF7QQqDrMATptLd d8ilNO/Nry4j3FAsUc63vIcwPGEi3DBOrQRczcS6WzdYa4vJEE6e1tGKRMYMtl1n92U4 LcZ2WVSXPPVOKlH6VMVJ3G8fqL/x45GHuWv/BomoGUWkx85bCl5KZLi5X7jwd5B4VFK7 bMuqc2z/GRX283M/5TNBML1rQSYQydNS8wDaOExtL6+0LgD6Pv0QxgVWhuERRDfltuJj 2j7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lNnQU7nlgCvrEQswoURWL2iF3lzneMUM2jWkpbiMSAc=; b=Ycxje6/MEM01exvex5IzlIUFoxfVYvaKRHVU56nibynOGUvRes427oxl4nVe4iPcdW RTJU5wlRHs3w4gAgoXah2IJLBJVLV8wbtFfDOK7jSFnAufdPZLT3hEjPJskAdqb6SF9M zX3+2l95TsNInA4kFGRszkdioq8yFR1ZZxv+1bI5l6+Lm74uzIieSQwWTjdWA1eZccYS KbroWppmuo7atFaD1Dc6Ybw9/ObklmfK+UyIKOZSQ4SdUlkNYZXsm+RiBfEMEqPG5rZE fXFSNpugKeBkfhK9DaVFzp86Ip7lw6fseiKg4/33/6W7kE5C1E+cP6WnpANKQW+uv5vL eU0A== X-Gm-Message-State: AOAM5335QBKO+dmFZq/yMOyLR5gSXCidW3jDDvq33HN+n4sy+TksCtnf 8gTFIZNwvkP1f4+HX6snzDylhQ== X-Google-Smtp-Source: ABdhPJz7eRsLXz/F+4yfNMex4BXcCn7ORtYkMIb8eBgCBk6GnfDF2bQvZjqBX4S5IMwWJr37i6aSMg== X-Received: by 2002:a1c:b386:: with SMTP id c128mr8469524wmf.133.1591879331058; Thu, 11 Jun 2020 05:42:11 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id q13sm4810355wrn.84.2020.06.11.05.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 05:42:10 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 7/8] ASoC: q6asm-dai: check available buffer size before sending Date: Thu, 11 Jun 2020 13:41:58 +0100 Message-Id: <20200611124159.20742-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200611124159.20742-1-srinivas.kandagatla@linaro.org> References: <20200611124159.20742-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tiwai@suse.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, vkoul@kernel.org, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This patch add simple check before sending data buffer to dsp which will ensure that we are not sending any buffers which are not already available. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6asm-dai.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c index 892411f81613..7aba3c07810b 100644 --- a/sound/soc/qcom/qdsp6/q6asm-dai.c +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c @@ -534,13 +534,12 @@ static void compress_event_handler(uint32_t opcode, uint32_t token, prtd->copied_total += bytes_written; snd_compr_fragment_elapsed(substream); - if (prtd->state != Q6ASM_STREAM_RUNNING) { + avail = prtd->bytes_received - prtd->bytes_sent; + if (prtd->state != Q6ASM_STREAM_RUNNING || avail <= 0) { spin_unlock_irqrestore(&prtd->lock, flags); break; } - avail = prtd->bytes_received - prtd->bytes_sent; - if (avail >= prtd->pcm_count) { q6asm_write_async(prtd->audio_client, prtd->stream_id, prtd->pcm_count, 0, 0, 0); From patchwork Thu Jun 11 12:41:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 192465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A3E3C433DF for ; Thu, 11 Jun 2020 12:48:06 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD9A020747 for ; Thu, 11 Jun 2020 12:48:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="OZ/pSChr"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zUczEBCh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD9A020747 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5B70F168F; Thu, 11 Jun 2020 14:47:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5B70F168F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591879684; bh=r6lGvB3s2rshRhYYdLrSqE29KZXfuvYlh6GNhXbEtyg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OZ/pSChr8c8WmPFjmHcEkg2H3jgdHQijeJTy5/yx09aD4QfmFoTSMZDkZ+jBiRCKF 1wOcgJOu6rRlsoxVqnzgDt3pWQ2yfKqvuYBsRPcN9C2l9uQkQ9/GwWYirq5leJVka/ WlIlu1RNLKAzhII3D3l06Wi3uAKRmebV5RDVF+pA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EBB76F80306; Thu, 11 Jun 2020 14:42:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 071CDF802E3; Thu, 11 Jun 2020 14:42:23 +0200 (CEST) Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BBE76F802BD for ; Thu, 11 Jun 2020 14:42:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BBE76F802BD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zUczEBCh" Received: by mail-wr1-x444.google.com with SMTP id r7so6033159wro.1 for ; Thu, 11 Jun 2020 05:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0iaTLKqtIL8DWUk/Ea8kKTBBPz/6PkEw/a931KtnLFc=; b=zUczEBChUUwZHT2y9ySJt1h7dVBb0LEw9r5//S1h6F4fWoxkLJoau/40zVwUrWsnpk JDjotTYzFtz9N2DSwP3ENPIOJFEumgrCgrZ5t6UpiyumnADn7QRvdISsWTfKGDSJfPQQ 0AniWhMBQgQCxlD5qe/mUiBK3QQmRWwGQYnpAIDpR91/bVgESxEaWljVf4E7UYGDAE4J fvlWL+/Y4TI/E4kiB0aih5sdsPKLcYDtnDBFtN9VQwLgAbFz8/LNiE2pcT4f525cZo/1 VoR0TRVOX4yTKEdbO8V9SwSaSvS9m2V38M0ahs//PwLBJN300nGy+x7txI5bXdIEBwty glIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0iaTLKqtIL8DWUk/Ea8kKTBBPz/6PkEw/a931KtnLFc=; b=hKL/OyPUbsZJSy5WSRTIL8mcuXiz577sHyVlxWh1wcDZgqmbrV8+8Po8uJ8nr5Jg7n JzyQ5HAG9Tc23e8+ApxA+l/0nhIIHs0267/uTOp/7Kg71sk/WY29y7k/Gr9K9q+hONxW ApbkAevR9WHlt9XzEdd7qfvB7PjUw6MVgcXkNQXrwA04olxUewOhto1r/HZPYK2esd7C CaKZXhVXNQfB9pZOae3D8QYMblw3z/KB/uV3kGVFPxytd3qtDcgUwV8gJTyPxj3V/uy+ Py+VV1tpLFomqq8+RlzXxE5zRg06bLtgzeobaFXNd7d4Gqz+MRrmULrz7g1W/TbQFW3l sXiw== X-Gm-Message-State: AOAM531k2SuSINKjDUuCNpxjFnbmnRx0pO5b0IiF9/Gy8QN2aBUNTLBX 3t96wyOAF5wvxSjGrDrF+UHtMQ== X-Google-Smtp-Source: ABdhPJz7ZNPReQj2HsAw5XGS9FL6huhrov1XnJBxu/pHO7FKy0P6cgVaxE/opwgqpHGEudbY8YDZLw== X-Received: by 2002:adf:f988:: with SMTP id f8mr10120025wrr.81.1591879332295; Thu, 11 Jun 2020 05:42:12 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id q13sm4810355wrn.84.2020.06.11.05.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 05:42:11 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH 8/8] ASoC: q6asm: allow to specify buffer offset in q6asm_write Date: Thu, 11 Jun 2020 13:41:59 +0100 Message-Id: <20200611124159.20742-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200611124159.20742-1-srinivas.kandagatla@linaro.org> References: <20200611124159.20742-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, tiwai@suse.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, vkoul@kernel.org, Srinivas Kandagatla X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" In usecase like gapless, its possible that next stream/track can start an offset where previous track ends, and this offset may not be at period boundary. So adding offset parameter to write function will provide ablity to send buffers with an offset inside period boundary. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6asm-dai.c | 15 +++++++++------ sound/soc/qcom/qdsp6/q6asm.c | 21 ++++++++++++++------- sound/soc/qcom/qdsp6/q6asm.h | 3 ++- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c index 7aba3c07810b..113929e79407 100644 --- a/sound/soc/qcom/qdsp6/q6asm-dai.c +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c @@ -187,7 +187,7 @@ static void event_handler(uint32_t opcode, uint32_t token, case ASM_CLIENT_EVENT_CMD_RUN_DONE: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) q6asm_write_async(prtd->audio_client, prtd->stream_id, - prtd->pcm_count, 0, 0, 0); + 0, prtd->pcm_count, 0, 0, 0); break; case ASM_CLIENT_EVENT_CMD_EOS_DONE: prtd->state = Q6ASM_STREAM_STOPPED; @@ -197,7 +197,7 @@ static void event_handler(uint32_t opcode, uint32_t token, snd_pcm_period_elapsed(substream); if (prtd->state == Q6ASM_STREAM_RUNNING) q6asm_write_async(prtd->audio_client, prtd->stream_id, - prtd->pcm_count, 0, 0, 0); + 0, prtd->pcm_count, 0, 0, 0); break; } @@ -509,14 +509,14 @@ static void compress_event_handler(uint32_t opcode, uint32_t token, struct snd_compr_stream *substream = prtd->cstream; unsigned long flags; uint64_t avail; - uint32_t bytes_written; + uint32_t bytes_written, offset; switch (opcode) { case ASM_CLIENT_EVENT_CMD_RUN_DONE: spin_lock_irqsave(&prtd->lock, flags); if (!prtd->bytes_sent) { q6asm_write_async(prtd->audio_client, prtd->stream_id, - prtd->pcm_count, 0, 0, 0); + 0, prtd->pcm_count, 0, 0, 0); prtd->bytes_sent += prtd->pcm_count; } @@ -532,7 +532,10 @@ static void compress_event_handler(uint32_t opcode, uint32_t token, bytes_written = token >> ASM_WRITE_TOKEN_LEN_SHIFT; prtd->copied_total += bytes_written; - snd_compr_fragment_elapsed(substream); + offset = prtd->copied_total % prtd->pcm_count; + + if (bytes_written && !offset) + snd_compr_fragment_elapsed(substream); avail = prtd->bytes_received - prtd->bytes_sent; if (prtd->state != Q6ASM_STREAM_RUNNING || avail <= 0) { @@ -542,7 +545,7 @@ static void compress_event_handler(uint32_t opcode, uint32_t token, if (avail >= prtd->pcm_count) { q6asm_write_async(prtd->audio_client, prtd->stream_id, - prtd->pcm_count, 0, 0, 0); + 0, prtd->pcm_count, 0, 0, 0); prtd->bytes_sent += prtd->pcm_count; } diff --git a/sound/soc/qcom/qdsp6/q6asm.c b/sound/soc/qcom/qdsp6/q6asm.c index 205453d1c1fc..8e3746ce4fa4 100644 --- a/sound/soc/qcom/qdsp6/q6asm.c +++ b/sound/soc/qcom/qdsp6/q6asm.c @@ -238,6 +238,7 @@ struct asm_session_cmd_run_v2 { struct audio_buffer { phys_addr_t phys; uint32_t size; /* size of buffer */ + uint32_t offset; }; struct audio_port_data { @@ -671,6 +672,7 @@ static int32_t q6asm_stream_callback(struct apr_device *adev, phys_addr_t phys; unsigned long flags; int token = hdr->token & ASM_WRITE_TOKEN_MASK; + struct audio_buffer *ab; spin_lock_irqsave(&ac->lock, flags); @@ -682,12 +684,13 @@ static int32_t q6asm_stream_callback(struct apr_device *adev, goto done; } - phys = port->buf[token].phys; + ab = &port->buf[token]; + phys = ab->phys + ab->offset; - if (lower_32_bits(phys) != result->opcode || + if (lower_32_bits(phys) != (result->opcode) || upper_32_bits(phys) != result->status) { dev_err(ac->dev, "Expected addr %pa\n", - &port->buf[token].phys); + &ab->phys + ab->offset); spin_unlock_irqrestore(&ac->lock, flags); ret = -EINVAL; goto done; @@ -1504,6 +1507,7 @@ EXPORT_SYMBOL_GPL(q6asm_open_read); * * @ac: audio client pointer * @stream_id: stream id + * @offset: offset in the period buffer * @len: length in bytes * @msw_ts: timestamp msw * @lsw_ts: timestamp lsw @@ -1511,8 +1515,9 @@ EXPORT_SYMBOL_GPL(q6asm_open_read); * * Return: Will be an negative value on error or zero on success */ -int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len, - uint32_t msw_ts, uint32_t lsw_ts, uint32_t wflags) +int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, + uint32_t offset, uint32_t len, uint32_t msw_ts, + uint32_t lsw_ts, uint32_t wflags) { struct asm_data_cmd_write_v2 *write; struct audio_port_data *port; @@ -1538,7 +1543,7 @@ int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len, ab = &port->buf[port->dsp_buf]; pkt->hdr.token = port->dsp_buf | (len << ASM_WRITE_TOKEN_LEN_SHIFT); pkt->hdr.opcode = ASM_DATA_CMD_WRITE_V2; - write->buf_addr_lsw = lower_32_bits(ab->phys); + write->buf_addr_lsw = lower_32_bits(ab->phys + offset); write->buf_addr_msw = upper_32_bits(ab->phys); write->buf_size = len; write->seq_id = port->dsp_buf; @@ -1549,7 +1554,9 @@ int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len, write->flags = wflags; - port->dsp_buf++; + ab->offset = offset; + if ((offset + len) == ab->size) + port->dsp_buf++; if (port->dsp_buf >= port->num_periods) port->dsp_buf = 0; diff --git a/sound/soc/qcom/qdsp6/q6asm.h b/sound/soc/qcom/qdsp6/q6asm.h index 0379580f0742..ad7e2f6f122f 100644 --- a/sound/soc/qcom/qdsp6/q6asm.h +++ b/sound/soc/qcom/qdsp6/q6asm.h @@ -96,7 +96,8 @@ struct audio_client *q6asm_audio_client_alloc(struct device *dev, q6asm_cb cb, void *priv, int session_id, int perf_mode); void q6asm_audio_client_free(struct audio_client *ac); -int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len, +int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, + uint32_t offset, uint32_t len, uint32_t msw_ts, uint32_t lsw_ts, uint32_t flags); int q6asm_open_write(struct audio_client *ac, uint32_t stream_id, uint32_t format, u32 codec_profile,