From patchwork Tue Jul 21 17:00:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 11676253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87A5A13B1 for ; Tue, 21 Jul 2020 17:01:16 +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 1DB8A2073A for ; Tue, 21 Jul 2020 17:01:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="oQke/1zZ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xUCw3RVo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DB8A2073A 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 A264415F9; Tue, 21 Jul 2020 19:00:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A264415F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1595350874; bh=kzmAqPPxibceeYYrnSClV1X0tTj1jQnUEjOh7vlv9v4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oQke/1zZjXEcfptABLBdOzI6hHwF2c8HNsFMxy17YruJli2ZAr5tlfoxsSQoV5c80 DwtavLqhrqvk+p7F61fzJTKrcdcSDVK5TddPH5ZRtKxKaqrSNYpy28+m1Gm7C+vvMF 7ry2mqO2X40Jx7pEtly4LAkuveozniqaG17YQjs0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 44A24F802BD; Tue, 21 Jul 2020 19:00:26 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 45D8FF8028C; Tue, 21 Jul 2020 19:00:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (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 1BF8AF800CE for ; Tue, 21 Jul 2020 19:00:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1BF8AF800CE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xUCw3RVo" Received: by mail-wm1-x341.google.com with SMTP id 17so3605280wmo.1 for ; Tue, 21 Jul 2020 10:00:15 -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=29yfJ1iVy+Hi6g3ZFLKBYwMLLHqUdPID3gr+X5nhlQE=; b=xUCw3RVo9rgBVXxyK05KyzX+F+UEoCmKIdZ/zHQJDYM2hP4Z+669hm5koy0s34lI2B IV9kS+QFWRnLLNHlCEmI6QiCgV0euvZmz6ldotibeSGKE/ScbaHBTGNckYjtF9vKq0Wv 8njmiz3BcPLCGI/e3NZ4Zi7TuzbsFwqOky/dKWuXgZVtHsIagRXvYQl/bXzhlYP991a0 yOdi5hpvIoZJDqDCEDX+C0Aue50qp1MaeYxGtQP0dMZItXbB2/2ev5CUcEEyShXOry6L hsdOdLFc5HArkLtNWcd8JrPQ2cKrzrWNZesGbEqLp2wsu6IaIH95o4JJUDfsNnXjzFjy EoHw== 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=29yfJ1iVy+Hi6g3ZFLKBYwMLLHqUdPID3gr+X5nhlQE=; b=olb+d7fABzwW7dzQdP4bHTrNBLbKhb68+QymUvCLqgMgk3aBhYOrIQUREnwKOULIkn iedzr+Z/49SLT7+eMzrcJRq4V2mvSkHOjrPXwXnnnp2UGE6FY/KW6sZEWBiXINJHqpZE sRHCmkGXVM/eCJ48IuYKyPdqwFVW/0GSzg73Cwh7x9VGlb3T3rWOSJJ/LHCwGSPNNboa qJqTwhk+oKQv2vQgGKeDkJcEyK/pcFBrMYo9QxKL8RNa2d6fjsTPIlaIBaBDvfD8Y316 CNY0Yur0MRh3DMinVWVA0o4ogndRVViMYOUT6bFQEj2vjj5hLpUffgOKQK5QMNsqEDyl wMfQ== X-Gm-Message-State: AOAM531OAl6MRKUSx+amL5bgUMy4b/GhonsPZ/M1xVoB9Mn7VLP1vu8M 2WnwQKlSaJYVrxlypD7NZPG3smKncx8= X-Google-Smtp-Source: ABdhPJxd9qOgR1HG0URRCj3/zigqsoR04LiAQhM1WvcGVT/Zw5yPyzOn4ePe9YMuRmMcbgOc/oKw+w== X-Received: by 2002:a05:600c:414f:: with SMTP id h15mr5200889wmm.82.1595350813907; Tue, 21 Jul 2020 10:00:13 -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 h11sm15526327wrb.68.2020.07.21.10.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 10:00:13 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [RFC PATCH v2 1/6] ALSA: compress: move codec parameter check to a function Date: Tue, 21 Jul 2020 18:00:02 +0100 Message-Id: <20200721170007.4554-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> References: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ckeepax@opensource.cirrus.com, 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" Move codec parameter checking to dedicated function so that other callers do not duplicate it. This is in preparedness for adding snd_compr_set_codec_params() support. Signed-off-by: Srinivas Kandagatla --- sound/core/compress_offload.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 0e53f6f31916..af5824113246 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -566,6 +566,18 @@ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream, return 0; } +static int snd_compress_check_codec_params(struct snd_codec *codec) +{ + /* now codec parameters */ + if (codec->id == 0 || codec->id > SND_AUDIOCODEC_MAX) + return -EINVAL; + + if (codec->ch_in == 0 || codec->ch_out == 0) + return -EINVAL; + + return 0; +} + static int snd_compress_check_input(struct snd_compr_params *params) { /* first let's check the buffer parameter's */ @@ -574,14 +586,8 @@ static int snd_compress_check_input(struct snd_compr_params *params) params->buffer.fragments == 0) return -EINVAL; - /* now codec parameters */ - if (params->codec.id == 0 || params->codec.id > SND_AUDIOCODEC_MAX) - return -EINVAL; + return snd_compress_check_codec_params(¶ms->codec); - if (params->codec.ch_in == 0 || params->codec.ch_out == 0) - return -EINVAL; - - return 0; } static int From patchwork Tue Jul 21 17:00:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 11676251 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF98113B1 for ; Tue, 21 Jul 2020 17:01:11 +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 762952073A for ; Tue, 21 Jul 2020 17:01:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="DhUoOmOZ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TZagcxsv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 762952073A 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 EE4BB1607; Tue, 21 Jul 2020 19:00:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EE4BB1607 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1595350870; bh=YMnAksjozOvtrXHj901rcOAgbXaE3yeQCEv80kWAZN0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DhUoOmOZI0Vc91k8zdGpdOs1/rcXU3+sboXVu8PqTehYt20C4DlsmYiuzJrYIxzv6 Lx0U6Vg2eU8tt0oRTf93XUEoN/Z7P26YCvs+AG22Fc3pHjhyAnvksd1BJ+D/NWcIR9 ryj0Kad4Kh+X0+z2HvrDXCv5cCHQD+rljt8PpgWo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 79DF7F80212; Tue, 21 Jul 2020 19:00:23 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id B1F25F8028D; Tue, 21 Jul 2020 19:00:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (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 86ECBF80087 for ; Tue, 21 Jul 2020 19:00:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 86ECBF80087 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TZagcxsv" Received: by mail-wm1-x343.google.com with SMTP id q15so3530951wmj.2 for ; Tue, 21 Jul 2020 10:00:15 -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=4rU3b/gziRzoNApIuUQOhBISC1QXxPCmKcl+VrCyHfM=; b=TZagcxsvvNWcs1yVY+CL7AodCrhUI/pwmVvVHQ9kkofoOakLyDuKZtIFEtBtRO9dgP cJOjbRXbeXx9+8Xw9m64/gA039nNk9U6Z7cX1Qc/HXOypUPEvFYyhVhAlekkTaH0l9St 8sFwOc6zbcKRy/fkJWbpQBFZBAzBoQY9Lo/X9CrMfcyShVCa7tCF5Ynnu/Mat1fss7WX Cbc8tUPGjA3a0HkOX2kamp+Ljuea6rSkwUmvQxJSGV0qbDoQ3yfzT26J0YKaKQvi3dkh 2sXJ2sE/kryAhEghs/yRO58y13MmX424/RNqLBodl/gijjcF9h+QncDOikOoeAJ0dDuF mcPA== 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=4rU3b/gziRzoNApIuUQOhBISC1QXxPCmKcl+VrCyHfM=; b=Tomf6xL8F7NM8xwrbzTUwuTdWdQwI1s1oSbB+8Hh9V2E/54NrsVoog9psuzWSV9eyZ sgLf76XQqZ8W2j9aAKFbmWI1x4XiTs61worWGA0mWM9RHc9n0LE33A/dG1FnRxww74fz eLrCf9ki2QGKIQWxiP48a2jl0q7jzIwrawvUj9ljtDecz9B6rYqVKy1cY3sKoRQ7vRrH swlZ2LL6j4020oYpJOLXMhdJr1rRcVG2qygJx+awbsd7CPe9GwCnDTZhyTDVCjo2EZ8B avTyxZHw9PsCRb3IV0gdEePuKlB7RVIAFXImELrIRnfFO59TmtBZICv0OZyVwwkuavZ1 iITg== X-Gm-Message-State: AOAM533CWopxScXYwa+QZoUlugKvT9o0l5U8Bf7K1tDRNoLqBBwKOXWM W22yXX1WmtOJt9L1hv5g7l0Rhw== X-Google-Smtp-Source: ABdhPJx0378L3JEh/bfdLm1mDah0uO18+EojpgndTJjXLnsvs9BnTrzTyeSkmbdU9xwu4rDx2IOyBg== X-Received: by 2002:a1c:7d56:: with SMTP id y83mr5150904wmc.154.1595350814996; Tue, 21 Jul 2020 10:00:14 -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 h11sm15526327wrb.68.2020.07.21.10.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 10:00:14 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [RFC PATCH v2 2/6] ALSA: compress: add new ioctl for setting codec parameters Date: Tue, 21 Jul 2020 18:00:03 +0100 Message-Id: <20200721170007.4554-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> References: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ckeepax@opensource.cirrus.com, 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" For gapless playback it is possible that each track can have different codec profile with same decoder, for example we have WMA album, we may have different tracks as WMA v9, WMA v10 and so on Or if DSP's like QDSP have abililty to switch decoders on single stream for each track, then this call could be used to set new codec parameters. Existing code does not allow to change this profile while doing gapless playback. This patch adds new SNDRV_COMPRESS_SET_CODEC_PARAMS IOCTL to allow userspace to set this new parameters required for new codec profile. Signed-off-by: Srinivas Kandagatla --- .../sound/designs/compress-offload.rst | 6 ++++ include/sound/compress_driver.h | 5 +++ include/uapi/sound/compress_offload.h | 1 + sound/core/compress_offload.c | 34 +++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/Documentation/sound/designs/compress-offload.rst b/Documentation/sound/designs/compress-offload.rst index 935f325dbc77..305ccc7bfdd9 100644 --- a/Documentation/sound/designs/compress-offload.rst +++ b/Documentation/sound/designs/compress-offload.rst @@ -128,6 +128,12 @@ set_params cases decoders will ignore other fields, while encoders will strictly comply to the settings +set_codec_params + This routine is very much simillar to set_params but exculding stream + information. Only codec related information is set as part of this. + It is used in gapless playback where its required to change decoder + or its parameters for next track. This is optional. + get_params This routines returns the actual settings used by the DSP. Changes to the settings should remain the exception. diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h index 70cbc5095e72..d9c00bcfce9b 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h @@ -93,6 +93,9 @@ struct snd_compr_stream { * @set_params: Sets the compressed stream parameters, mandatory * This can be called in during stream creation only to set codec params * and the stream properties + * @set_codec_params: Sets the compressed stream codec parameters, Optional + * This can be called in during gapless next track codec change only to set + * codec params * @get_params: retrieve the codec parameters, mandatory * @set_metadata: Set the metadata values for a stream * @get_metadata: retrieves the requested metadata values from stream @@ -112,6 +115,8 @@ struct snd_compr_ops { int (*free)(struct snd_compr_stream *stream); int (*set_params)(struct snd_compr_stream *stream, struct snd_compr_params *params); + int (*set_codec_params)(struct snd_compr_stream *stream, + struct snd_codec *params); int (*get_params)(struct snd_compr_stream *stream, struct snd_codec *params); int (*set_metadata)(struct snd_compr_stream *stream, diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index 7184265c0b0d..c46286113a4b 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -172,6 +172,7 @@ struct snd_compr_metadata { struct snd_compr_metadata) #define SNDRV_COMPRESS_GET_METADATA _IOWR('C', 0x15,\ struct snd_compr_metadata) +#define SNDRV_COMPRESS_SET_CODEC_PARAMS _IOW('C', 0x16, struct snd_codec) #define SNDRV_COMPRESS_TSTAMP _IOR('C', 0x20, struct snd_compr_tstamp) #define SNDRV_COMPRESS_AVAIL _IOR('C', 0x21, struct snd_compr_avail) #define SNDRV_COMPRESS_PAUSE _IO('C', 0x30) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index af5824113246..184722643c97 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -590,6 +590,37 @@ static int snd_compress_check_input(struct snd_compr_params *params) } +static int snd_compr_set_codec_params(struct snd_compr_stream *stream, + unsigned long arg) +{ + struct snd_codec *params; + int retval; + + if (!stream->ops->set_codec_params) + return -EPERM; + + if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) + return -EPERM; + + /* codec params can be only set when next track has been signalled */ + if (stream->next_track == false) + return -EPERM; + + params = memdup_user((void __user *)arg, sizeof(*params)); + if (IS_ERR(params)) + return PTR_ERR(params); + + retval = snd_compress_check_codec_params(params); + if (retval) + goto out; + + retval = stream->ops->set_codec_params(stream, params); + +out: + kfree(params); + return retval; +} + static int snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) { @@ -973,6 +1004,9 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) case _IOC_NR(SNDRV_COMPRESS_GET_PARAMS): retval = snd_compr_get_params(stream, arg); break; + case _IOC_NR(SNDRV_COMPRESS_SET_CODEC_PARAMS): + retval = snd_compr_set_codec_params(stream, arg); + break; case _IOC_NR(SNDRV_COMPRESS_SET_METADATA): retval = snd_compr_set_metadata(stream, arg); break; From patchwork Tue Jul 21 17:00:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 11676255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E2C31510 for ; Tue, 21 Jul 2020 17:02:03 +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 B81832065D for ; Tue, 21 Jul 2020 17:02:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="dkCfS4nD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AbnVVS1e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B81832065D 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 4E7F61677; Tue, 21 Jul 2020 19:01:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4E7F61677 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1595350921; bh=LxhNlFgwErGjD/Okb3KP+IQQpvW9uORXRny2Mwjqjs8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=dkCfS4nDn9n3/ZcGyS+t/37qBsU93Wo7FvN0Z4cGF2E/6gD93c9Of4pqbRSNSWm3f XtCtyXrWX0gYYrggJkivg4mpL2w5pFYt1HnWbdy+5XGu8m1fVe1PxbrAfdsS3s08Bf VGtAs7E+QsgbTKXUA+/RUHl01cPP+PmJx7Ig/gXo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A828BF802C2; Tue, 21 Jul 2020 19:00:29 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 77D37F802C2; Tue, 21 Jul 2020 19:00:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (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 B2BF3F8024A for ; Tue, 21 Jul 2020 19:00:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B2BF3F8024A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AbnVVS1e" Received: by mail-wm1-x343.google.com with SMTP id 9so130393wmj.5 for ; Tue, 21 Jul 2020 10:00:17 -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=cX30zM4NBo9NgJKdwCaDNO5IgDHp7txiav7RhZ1wYnQ=; b=AbnVVS1ePUqx9ZPvRol7dMY9NmY2pLxSYSuFxd7YPIgzDHhZ3v8kpF1QZ3NJtL6kIK i0Y2uIL8P6oqP1sjFslcqU+M0EmVuj8Rbq6mJWXcOwrA7OHTLIkG5vL0V2q1S6L1g2+O G4YFGPSucmloC+6HSvQRDkY3sYdb44fR62hM1u/eLxMTAfkUzXeDTSw+B92btBFVLoNH Sj0oZOseF9TALG3GGtnYqm1bneG0Z34Bti25JMNs3oYDo9DpwSj69TRKxNa/fZaPbzOj GPnkiOuHr2yLQIiFAVkS2OGDmbMaGnNjQ7ENLTtWXJUZi/aXos7jg0pOzXhnz0x63/nk Fnqg== 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=cX30zM4NBo9NgJKdwCaDNO5IgDHp7txiav7RhZ1wYnQ=; b=YBZRoGGjYcyr2OBNGgJigNoaCbRUIKAUpBXvgiHN+0zVI9cV6/FXkjXqXqP8bk3MD8 JWZnonzvjytyDOS6IP/x7EJZm9RMFeioxvG4NrcUMGSiYMvAQE/+W0HFS7AhOgoPApYF uzGR4AYtLhYczjjcAUyzgeIL6clFaavEe2rudkYLzuZkwCG5ivTn1K79aqXMyik3quw1 PW/Vkgrm3mJHtpwOLsLykRFuZEs4ARivQMlncNfpAcjZoSlGu9vq6Sd0tIKU5MtnWtHl U07BO9RWWyV3Z9PuSDLsUcdeF/1x4u4npGK2o18JJ1WuAqNTRm+KrqJ9h+Th64rKgTbV 7ZbA== X-Gm-Message-State: AOAM532geZ6TIg/GHE0sXLZjqWOAQAn31SGIqCmuNGg+ndBXloKHDztK LGheaspoFfRLsw8TZc52ivQlyg== X-Google-Smtp-Source: ABdhPJxXHRQU8c3AC4+4CNVvMYSBeNRcIY6fllLgC7+JpgeWNr20AAE6+Lrw5aOotX5A5Ot5n8tUMA== X-Received: by 2002:a7b:c5c5:: with SMTP id n5mr4872179wmk.103.1595350816319; Tue, 21 Jul 2020 10:00:16 -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 h11sm15526327wrb.68.2020.07.21.10.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 10:00:15 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [RFC PATCH v2 3/6] ALSA: compress: add flags to snd_compr_caps to expose dsp caps Date: Tue, 21 Jul 2020 18:00:04 +0100 Message-Id: <20200721170007.4554-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> References: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ckeepax@opensource.cirrus.com, 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" Some of the DSPs like Qualcomm QDSP has ablity to change decoders dynamically on a single stream, This could be used for features like Cross Fade or gapless with different codec profile tracks. Exposing such features in flags variable of compress caps descriptor would provide userspace more flexibity in usings dsp features. For now only one flag of switching decoders is added which is used in subsequent patches. Signed-off-by: Srinivas Kandagatla --- include/uapi/sound/compress_offload.h | 7 ++++++- sound/core/compress_offload.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index c46286113a4b..43c78cdf492c 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -88,6 +88,9 @@ enum snd_compr_direction { SND_COMPRESS_CAPTURE }; +/* DSP can switch decoder in a single Stream while doing gapless */ +#define SND_COMPR_CAP_FLAGS_DSP_CAN_SWITCH_DECODER ((__u32) 0x00000001) + /** * struct snd_compr_caps - caps descriptor * @codecs: pointer to array of codecs @@ -97,6 +100,7 @@ enum snd_compr_direction { * @min_fragments: min fragments supported by DSP * @max_fragments: max fragments supported by DSP * @num_codecs: number of codecs supported + * @flags: flags to expose various DSP capabilities * @reserved: reserved field */ struct snd_compr_caps { @@ -107,7 +111,8 @@ struct snd_compr_caps { __u32 min_fragments; __u32 max_fragments; __u32 codecs[MAX_NUM_CODECS]; - __u32 reserved[11]; + __u32 flags; + __u32 reserved[10]; } __attribute__((packed, aligned(4))); /** diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 184722643c97..abebd5fee2d2 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -590,12 +590,32 @@ static int snd_compress_check_input(struct snd_compr_params *params) } +static bool snd_compr_can_dsp_switch_decoder(struct snd_compr_stream *stream) +{ + struct snd_compr_caps caps; + + if (!stream->ops->get_caps) + return false; + + memset(&caps, 0, sizeof(caps)); + if (stream->ops->get_caps(stream, &caps)) + return false; + + if (caps.flags & SND_COMPR_CAP_FLAGS_DSP_CAN_SWITCH_DECODER) + return true; + + return false; +} + static int snd_compr_set_codec_params(struct snd_compr_stream *stream, unsigned long arg) { struct snd_codec *params; int retval; + if (!snd_compr_can_dsp_switch_decoder(stream)) + return -ENOTSUPP; + if (!stream->ops->set_codec_params) return -EPERM; From patchwork Tue Jul 21 17:00:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 11676257 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 643951510 for ; Tue, 21 Jul 2020 17:02:40 +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 EED492065D for ; Tue, 21 Jul 2020 17:02:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="iu3cwr+K"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rGgImTH6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EED492065D 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 87A401657; Tue, 21 Jul 2020 19:01:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 87A401657 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1595350958; bh=xhLor8CYJrgNP5t1vjU3+SfxOeWL7tn5m6G8kkRfHvQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iu3cwr+KmKyJ6HcUBFmyTXWYpJb8enZ+TQoCaolHRtjyuoR6HyzIgLRVxOi6wuHAB pjp0vflum5Ox1quChk+CC/0FJwS5crwDZqcy40A+n+znSLJEKQWJKm1kYfnavwYzMt SgwvdJxzbW0j2xlcD0ZaVjvhX5WQ6Iu0fp82K2RE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E5D9FF802C4; Tue, 21 Jul 2020 19:00:32 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id B494FF802DB; Tue, 21 Jul 2020 19:00:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (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 EEF93F80268 for ; Tue, 21 Jul 2020 19:00:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EEF93F80268 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rGgImTH6" Received: by mail-wm1-x342.google.com with SMTP id c80so3545339wme.0 for ; Tue, 21 Jul 2020 10:00:18 -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=ZOraVd74qzG1/9gtwasj7hNZRlKbVxl3mVRj5ZSF7Dw=; b=rGgImTH6cRW3JnhKIdeBbGCqvYhutbzFSz7mlRlsdNbijsdwAga1FeJyh4NCPezpJP w3E0eicyoEm4KyHIDU7BT17bprfX97UBJ7cZoZboy8dxVYTHW4B3YPI/b4zNtjijmThJ TnYB1luKSwCroAcp/7ifYGxWOP8Zy0L/0eycR5j5p5AqWdOLx002RpjAq9Q+CXe5oN+E gfcbJ6D4xy0hmDwFyNdjATtWz5U+x9qARq0vEwWu+oB6Qas0dcNOejAO2Pczk0W22uEY PdToiMO/G89MgtVzzrLyyVLVlwz0DNLexhNvsvC/2xvnqwus7c/TUH+NH7LbIZVLVnIt Izkg== 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=ZOraVd74qzG1/9gtwasj7hNZRlKbVxl3mVRj5ZSF7Dw=; b=OVOLhha8P2ED9C1muAKo5IYiv6ZOrIQicIOwwANmpTezmDojwv3DnUnYYLZwCodlRO 2Q0XXkixzyf+BqZtlmVpxXhE6BWcRMJzUdF2PtLGlzzmf6Fm53xn8bxLRrIjOgvXMdcr F4WsN55ElKJ5Ui3W8WNgUM5eRK98jjLK/yLjicALtebAihkjad0T1TP9tZsEhUb9gay6 MPzH3GFJtEcI7o6bwR/VQY/BV19pkV/FDo18ZA/+2AmBQCAxFsteEQOyF7AZYEIm4ozn 2xGq7dAtOX/lHLp4X8iV5EzwAx6oe3QpBKqiKOtE0s8DjBwtCLL+d69yTZxUUuevQCFI 0e0w== X-Gm-Message-State: AOAM532LLCxRF+Hhhjjfdg43RIyr7ZX43PwykARMh3uBZLBUJ0cxoldm gVLL18h61CDR+DN7S63h7gJPwF6c1xU= X-Google-Smtp-Source: ABdhPJyanh2NBymOjVnC1OieVwWUIGSxUVOyeKt8tkHvdgFZRJPKcaXzfWkcjFu5fSmyt990bVvV4g== X-Received: by 2002:a1c:e382:: with SMTP id a124mr491428wmh.11.1595350817574; Tue, 21 Jul 2020 10:00:17 -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 h11sm15526327wrb.68.2020.07.21.10.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 10:00:16 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [RFC PATCH v2 4/6] ASoC: compress: add snd_soc_dai_compr_set_codec_params() Date: Tue, 21 Jul 2020 18:00:05 +0100 Message-Id: <20200721170007.4554-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> References: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ckeepax@opensource.cirrus.com, 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" Add corresponding ASoC changes to support gapless playback of tracks which have different codec profile with or without same decoder. Signed-off-by: Srinivas Kandagatla --- include/sound/soc-component.h | 3 +++ include/sound/soc-dai.h | 5 +++++ sound/soc/soc-compress.c | 30 ++++++++++++++++++++++++++++++ sound/soc/soc-dai.c | 14 ++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index 5663891148e3..1e69c54ed0b9 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -36,6 +36,9 @@ struct snd_compress_ops { int (*get_params)(struct snd_soc_component *component, struct snd_compr_stream *stream, struct snd_codec *params); + int (*set_codec_params)(struct snd_soc_component *component, + struct snd_compr_stream *stream, + struct snd_codec *params); int (*set_metadata)(struct snd_soc_component *component, struct snd_compr_stream *stream, struct snd_compr_metadata *metadata); diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 212257e84fac..526794ee555b 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -192,6 +192,9 @@ int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai, int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai, struct snd_compr_stream *cstream, struct snd_compr_params *params); +int snd_soc_dai_compr_set_codec_params(struct snd_soc_dai *dai, + struct snd_compr_stream *cstream, + struct snd_codec *codec); int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai, struct snd_compr_stream *cstream, struct snd_codec *params); @@ -292,6 +295,8 @@ struct snd_soc_cdai_ops { struct snd_soc_dai *); int (*set_params)(struct snd_compr_stream *, struct snd_compr_params *, struct snd_soc_dai *); + int (*set_codec_params)(struct snd_compr_stream *, + struct snd_codec *, struct snd_soc_dai *); int (*get_params)(struct snd_compr_stream *, struct snd_codec *, struct snd_soc_dai *); int (*set_metadata)(struct snd_compr_stream *, diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 4984b6a2c370..e549e0197aca 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c @@ -518,6 +518,34 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, return ret; } +static int soc_compr_set_codec_params(struct snd_compr_stream *cstream, + struct snd_codec *codec) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_soc_component *component; + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); + int i, ret; + + mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); + + ret = snd_soc_dai_compr_set_codec_params(cpu_dai, cstream, codec); + if (ret < 0) + goto err; + + for_each_rtd_components(rtd, i, component) { + if (!component->driver->compress_ops || + !component->driver->compress_ops->set_codec_params) + continue; + + ret = component->driver->compress_ops->set_codec_params(component, cstream, + codec); + break; + } +err: + mutex_unlock(&rtd->card->pcm_mutex); + return ret; +} + static int soc_compr_get_params(struct snd_compr_stream *cstream, struct snd_codec *params) { @@ -728,6 +756,7 @@ static struct snd_compr_ops soc_compr_ops = { .open = soc_compr_open, .free = soc_compr_free, .set_params = soc_compr_set_params, + .set_codec_params = soc_compr_set_codec_params, .set_metadata = soc_compr_set_metadata, .get_metadata = soc_compr_get_metadata, .get_params = soc_compr_get_params, @@ -744,6 +773,7 @@ static struct snd_compr_ops soc_compr_dyn_ops = { .free = soc_compr_free_fe, .set_params = soc_compr_set_params_fe, .get_params = soc_compr_get_params, + .set_codec_params = soc_compr_set_codec_params, .set_metadata = soc_compr_set_metadata, .get_metadata = soc_compr_get_metadata, .trigger = soc_compr_trigger_fe, diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index b05e18b63a1c..06481d0278b8 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -594,6 +594,20 @@ int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai, } EXPORT_SYMBOL_GPL(snd_soc_dai_compr_get_params); +int snd_soc_dai_compr_set_codec_params(struct snd_soc_dai *dai, + struct snd_compr_stream *cstream, + struct snd_codec *codec) +{ int ret = 0; + + if (dai->driver->cops && + dai->driver->cops->set_codec_params) + ret = dai->driver->cops->set_codec_params(cstream, codec, dai); + + return soc_dai_ret(dai, ret); + +} +EXPORT_SYMBOL_GPL(snd_soc_dai_compr_set_codec_params); + int snd_soc_dai_compr_ack(struct snd_soc_dai *dai, struct snd_compr_stream *cstream, size_t bytes) From patchwork Tue Jul 21 17:00:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 11676265 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9F2113B1 for ; Tue, 21 Jul 2020 17:04:26 +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 6D3B72073A for ; Tue, 21 Jul 2020 17:04:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="plgaYqEw"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Kzq8l1ru" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D3B72073A 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 E2B6F1674; Tue, 21 Jul 2020 19:03:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E2B6F1674 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1595351065; bh=ZvNtzmmv7B2fMy00Bj6NniL/ps8CeqQdJtMduJdtyCw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=plgaYqEw/ns5h69KlB0XOsusZPR9QrViY5fbYwvsA0+YRxz2xaxEDuf2f1ksKZueA kDRBiD9ZLoMp21uaiJzc/cER6Vmuia5h7rFbsiZlZYsgyrvfmGvMM96sQP4mA7dZT1 jNzL5H1u4qw/OooCMDyI5+fD9uUt54HigXJgvmnY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 80F87F802F9; Tue, 21 Jul 2020 19:00:39 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id C07E3F802DF; Tue, 21 Jul 2020 19:00:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (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 9BCD4F80290 for ; Tue, 21 Jul 2020 19:00:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9BCD4F80290 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Kzq8l1ru" Received: by mail-wr1-x441.google.com with SMTP id z2so21945592wrp.2 for ; Tue, 21 Jul 2020 10:00:20 -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=N5toOmofPdb0aWS/cX/qzEMNy/7jWKTdvFfToimNqFU=; b=Kzq8l1ruaR/AWJfmVIxoYH5oXrF5Sxh/oc8OT2Uxk1ov+20yL2zNArmg7vqcO3L5PG vs649aolZ4zpeUNir7Ehmv0T8LNiuU3IoP3UyjStqsLIuG8s2SDH3Qc4W1yIVCpqFv8f 9lMcSu2l6pd9SGkOtmvjItozqFa8nS4r9xHOWoZdK0xyaM1w7ZgmbeEG6JhHfz4ZYqwi DCK+tA0fS3+g2RHdWiSHXWA8FAdv6pdOf+6BbpU7G3wSzjYOkPt7+shZ08MdRhvbhnVY HLwHWveVus3acSOh3u5DuUv9BkxsQQCOwspjfcs3cyV7SapecFjqhmIJtTxOqG1XYbxs ltOg== 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=N5toOmofPdb0aWS/cX/qzEMNy/7jWKTdvFfToimNqFU=; b=syzgJwOImq6J0H0PPiIUDG8jJvgJoW0T1MUz9BMFek65XtD5o7NxQPFGDS0GiPo/Fv SOiWwLoGl349blyHexpbMU8Xh7DkjQ/lsLb49JOPClgUz15bz3HjvqirOBHckVphSNzH qtA6H1vFQfC20hM+j5Uq3gl6Z5dEvTGPJG5vLUzSp3rhdKRmvPSSAumzofbxMQ8uCrRZ hrVkjHHYs368/zp106U6cvXQpYQXK1uz3k4ohD3lRqmeKcvhqeTLqu5Q7uIMGAiReffk 724ujhFeKxPxcRhKeiGa1aGXOJXJGS2iqjwvhRtnqZ6mfFQLFv23Ip2BQxs7aN/Ld7Rj xdWw== X-Gm-Message-State: AOAM530s0+titP4GzDtvBRoYvKn0wl5KmTio3Low8thzB6a+i1RlATsb Xjj847PAiaE67yx8Vx44xUp17g== X-Google-Smtp-Source: ABdhPJzYS7aFCBBkC+2BxK07/ub7QVn25hX1kQwkGqFLdWhA/Y2ltFfJ8Z8GQ5+nOdxb5nnanwOPQg== X-Received: by 2002:a5d:664e:: with SMTP id f14mr27519445wrw.6.1595350819283; Tue, 21 Jul 2020 10:00:19 -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 h11sm15526327wrb.68.2020.07.21.10.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 10:00:18 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [RFC PATCH v2 5/6] ALSA: compress: bump the version Date: Tue, 21 Jul 2020 18:00:06 +0100 Message-Id: <20200721170007.4554-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> References: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ckeepax@opensource.cirrus.com, 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" Now that we have added support for new IOCTL and flags to struct snd_compr_caps, bump up the version to 0,2,1 to help users find it. Signed-off-by: Srinivas Kandagatla --- include/uapi/sound/compress_offload.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h index 43c78cdf492c..0d407b57a1d4 100644 --- a/include/uapi/sound/compress_offload.h +++ b/include/uapi/sound/compress_offload.h @@ -31,7 +31,7 @@ #include -#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 2, 0) +#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 2, 1) /** * struct snd_compressed_buffer - compressed buffer * @fragment_size: size of buffer fragment in bytes From patchwork Tue Jul 21 17:00:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 11676263 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF095159A for ; Tue, 21 Jul 2020 17:03:47 +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 75C552073A for ; Tue, 21 Jul 2020 17:03:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Ss++wyHf"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nmH+p02U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75C552073A 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 F290F1669; Tue, 21 Jul 2020 19:02:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F290F1669 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1595351026; bh=zsagIlIanPFpEyOP9rYo3Qxro3m7Vong3MGwGyVKzbg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ss++wyHfFyKK6EIPyc2DttHZvkbFHh0ug7l5I0dQuoV62vQccmiRalmY+xW/E0dfX c7hVFaREq+CFhSKzk+3y4mtVGEGrphC5gf7DyhrNEFYWZsTk8JI+bcDaT/h/KkrF5T CibeIuDWZh3jnSFQhjk2qSa4FOEHboA8LnaMg6Zo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A18FBF802E7; Tue, 21 Jul 2020 19:00:38 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6EA87F800CE; Tue, 21 Jul 2020 19:00:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 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 E5FF4F800CE for ; Tue, 21 Jul 2020 19:00:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E5FF4F800CE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nmH+p02U" Received: by mail-wr1-x442.google.com with SMTP id o11so21903760wrv.9 for ; Tue, 21 Jul 2020 10:00:21 -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=zAD/7xPPoJF64yaCntuggxRA+ZJ8WHNmGopHS69UMKw=; b=nmH+p02UiIUVCenN/Sk7WaDAvRMuPBMbiWgg0viEISI8LAsuH4XSELcKuXFlo4E1jG 3Ba38x4iQ1l2M+mHUXYoEFuvl6hUqCKceiKb6umj+bXwai6455HJcrCifX4F4L5xSvla hOQNlYvdTlE2zqU9p/kqPaBWD1XdHWZ5ivnmwrtNADm45lM4oGP0a95FGH4F/jJ3/dkx Znz1H27E1mv6SMM699FO6lQE7Syy2Gm+8DY5uhpQMZgHO8JPx1PX2jVOXnezZWbnolce sLsgyiEM6QNFvsMv3D+wimiCt+M4b2lpsMeGNaErObzykdrflmIRoYl21sKkKvpvDAVW M8ZA== 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=zAD/7xPPoJF64yaCntuggxRA+ZJ8WHNmGopHS69UMKw=; b=eVwmr8TGlD5Slow4SBKeeGTJFdWyPE00jB0Pr85/fgjB8IoDAnI7EnbRy6GNlpDVY9 xhCnWJ+P7W3/TDod1xqH/4DQna4lmWJabKlwAsmNN+CEMQc2l7wslR+2pAafeTGF9OzF ObIwohj7rGoiVwwdwbXP1igNlXrAkseax8ncRTioICGL/xZ1u0fkiMZyBXVdi0Kno7KS 3RKCClDq+hxwEExijOcRyFZ3W2jKP3cMPJqLC0gH6SZpEyaZb/s/sZTKZEM+IW6LvGvN fF+jyCbwEa6el7ST+EULd2hTYL6sMAKGty48KyCvf9I4jzV/n8i57AXyvI8rr4Nvb71C 61ew== X-Gm-Message-State: AOAM533SuLTO8UWG1KwiQLP3nDrYzTg/HeiS2rnqTjNl0FsDdnMeItoZ 6pZrEJn5WiPlSg9p2JzTh9hBbQ== X-Google-Smtp-Source: ABdhPJycW1Xaq3CU8qG7QJBKBhsJckOLmd/4VRs8/GBxAiRAaiByjeY3LRfYRQRK2YrDLo6uukpb1Q== X-Received: by 2002:adf:ec90:: with SMTP id z16mr27509083wrn.52.1595350820384; Tue, 21 Jul 2020 10:00:20 -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 h11sm15526327wrb.68.2020.07.21.10.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 10:00:19 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [RFC PATCH v2 6/6] ASoC: q6asm-dai: add support to set_codec_params Date: Tue, 21 Jul 2020 18:00:07 +0100 Message-Id: <20200721170007.4554-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> References: <20200721170007.4554-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ckeepax@opensource.cirrus.com, 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" Make use of new set_codec_params callback to allow decoder switching during gapless playback. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6asm-dai.c | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c index b5c719682919..a8cfb1996614 100644 --- a/sound/soc/qcom/qdsp6/q6asm-dai.c +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c @@ -876,6 +876,37 @@ static int __q6asm_dai_compr_set_codec_params(struct snd_soc_component *componen return 0; } +static int q6asm_dai_compr_set_codec_params(struct snd_soc_component *component, + struct snd_compr_stream *stream, + struct snd_codec *codec) +{ + struct snd_compr_runtime *runtime = stream->runtime; + struct q6asm_dai_rtd *prtd = runtime->private_data; + int ret; + + ret = q6asm_open_write(prtd->audio_client, prtd->next_track_stream_id, + codec->id, codec->profile, prtd->bits_per_sample, + true); + if (ret < 0) { + pr_err("q6asm_open_write failed\n"); + return ret; + } + + ret = __q6asm_dai_compr_set_codec_params(component, stream, codec, + prtd->next_track_stream_id); + if (ret < 0) { + pr_err("q6asm_open_write failed\n"); + return ret; + } + + ret = q6asm_stream_remove_initial_silence(prtd->audio_client, + prtd->next_track_stream_id, + prtd->initial_samples_drop); + prtd->next_track_stream_id = 0; + + return ret; +} + static int q6asm_dai_compr_set_params(struct snd_soc_component *component, struct snd_compr_stream *stream, struct snd_compr_params *params) @@ -1144,6 +1175,7 @@ static int q6asm_dai_compr_get_caps(struct snd_soc_component *component, caps->max_fragment_size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE; caps->min_fragments = COMPR_PLAYBACK_MIN_NUM_FRAGMENTS; caps->max_fragments = COMPR_PLAYBACK_MAX_NUM_FRAGMENTS; + caps->flags = SND_COMPR_CAP_FLAGS_DSP_CAN_SWITCH_DECODER; caps->num_codecs = 5; caps->codecs[0] = SND_AUDIOCODEC_MP3; caps->codecs[1] = SND_AUDIOCODEC_FLAC; @@ -1173,6 +1205,7 @@ static struct snd_compress_ops q6asm_dai_compress_ops = { .open = q6asm_dai_compr_open, .free = q6asm_dai_compr_free, .set_params = q6asm_dai_compr_set_params, + .set_codec_params = q6asm_dai_compr_set_codec_params, .set_metadata = q6asm_dai_compr_set_metadata, .pointer = q6asm_dai_compr_pointer, .trigger = q6asm_dai_compr_trigger,