mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
To: Alexey Klimov <alexey.klimov@linaro.org>,
	Vinod Koul <vkoul@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Srinivas Kandagatla <srini@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: Patrick Lai <plai@qti.qualcomm.com>,
	Annemarie Porter <annemari@quicinc.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	kernel@oss.qualcomm.com,
	Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Subject: Re: [PATCH RFC 2/2] ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback
Date: Wed, 18 Jun 2025 13:34:04 +0100	[thread overview]
Message-ID: <c4d934c1-0218-4147-882f-279795bcd1f4@oss.qualcomm.com> (raw)
In-Reply-To: <20250616-opus_codec_rfc_v1-v1-2-1f70b0a41a70@linaro.org>



On 6/16/25 4:26 PM, Alexey Klimov wrote:
> Add support for OPUS module, OPUS format ID, media format payload struct
> and make it all recognizable by audioreach compress playback path.
> 
> At this moment this only supports raw or plain OPUS packets not
> encapsulated in container (for instance OGG container). For this usecase
> each OPUS packet needs to be prepended with 4-bytes long length field
> which is expected to be done by userspace applications. This is
> Qualcomm DSP specific requirement.
> > This patch is based on earlier work done by
> Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

Thanks for picking this up Alexey,

Same, co-dev by should be good attribute for such things.


> 
> Cc: Annemarie Porter <annemari@quicinc.com>
> Cc: Srinivas Kandagatla <srini@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
> ---
>  sound/soc/qcom/qdsp6/audioreach.c | 33 +++++++++++++++++++++++++++++++++
>  sound/soc/qcom/qdsp6/audioreach.h | 17 +++++++++++++++++
>  sound/soc/qcom/qdsp6/q6apm-dai.c  |  3 ++-
>  sound/soc/qcom/qdsp6/q6apm.c      |  3 +++
>  4 files changed, 55 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
> index 4ebaaf736fb98a5a8a58d06416b3ace2504856e1..09e3a4da945d61b6915bf8b6f382c25ae94c5888 100644
> --- a/sound/soc/qcom/qdsp6/audioreach.c
> +++ b/sound/soc/qcom/qdsp6/audioreach.c
> @@ -859,6 +859,7 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr,
>  	struct payload_media_fmt_aac_t *aac_cfg;
>  	struct payload_media_fmt_pcm *mp3_cfg;
>  	struct payload_media_fmt_flac_t *flac_cfg;
> +	struct payload_media_fmt_opus_t *opus_cfg;
>  
>  	switch (mcfg->fmt) {
>  	case SND_AUDIOCODEC_MP3:
> @@ -901,6 +902,38 @@ static int audioreach_set_compr_media_format(struct media_format *media_fmt_hdr,
>  		flac_cfg->min_frame_size = mcfg->codec.options.flac_d.min_frame_size;
>  		flac_cfg->max_frame_size = mcfg->codec.options.flac_d.max_frame_size;
>  		break;
> +	case SND_AUDIOCODEC_OPUS_RAW:
> +		media_fmt_hdr->data_format = DATA_FORMAT_RAW_COMPRESSED;
> +		media_fmt_hdr->fmt_id = MEDIA_FMT_ID_OPUS;
> +		media_fmt_hdr->payload_size = sizeof(struct payload_media_fmt_opus_t);

maybe sizeof(*opus_cfg)?

> +		p = p + sizeof(*media_fmt_hdr);
> +		opus_cfg = p;
> +		/* raw opus packets prepended with 4 bytes of length */
> +		opus_cfg->bitstream_format = 1;
> +		/*
> +		 * payload_type:
> +		 * 0 -- read metadata from opus stream;
> +		 * 1 -- metadata is provided by filling in the struct here.
> +		 */
> +		opus_cfg->payload_type = 1;
> +		opus_cfg->version = mcfg->codec.options.opus_d.version;
> +		opus_cfg->num_channels = mcfg->codec.options.opus_d.num_channels;
> +		opus_cfg->pre_skip = mcfg->codec.options.opus_d.pre_skip;
> +		opus_cfg->sample_rate = mcfg->codec.options.opus_d.sample_rate;
> +		opus_cfg->output_gain = mcfg->codec.options.opus_d.output_gain;
> +		opus_cfg->mapping_family = mcfg->codec.options.opus_d.mapping_family;
> +		opus_cfg->stream_count = mcfg->codec.options.opus_d.stream_count;
> +		opus_cfg->coupled_count = mcfg->codec.options.opus_d.coupled_count;
> +
> +		if (mcfg->codec.options.opus_d.num_channels == 1) {
> +			opus_cfg->channel_mapping[0] = PCM_CHANNEL_FL;
> +		} else if (mcfg->codec.options.opus_d.num_channels == 2) {
> +			opus_cfg->channel_mapping[0] = PCM_CHANNEL_FL;
> +			opus_cfg->channel_mapping[1] = PCM_CHANNEL_FR;
> +		}

Pl use audioreach_set_default_channel_mapping() to fill in the channel
mapping data.

Why are we not using channel mapping info from the snd_dec_opus struct here?


> +
> +		opus_cfg->reserved[0] = opus_cfg->reserved[1] = opus_cfg->reserved[2] = 0;
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h
> index 61a69df4f50f6cc90b56697c272ade6f1411bbf2..512ea24fd402c95f98db790313b756a5ba3dcca1 100644
> --- a/sound/soc/qcom/qdsp6/audioreach.h
> +++ b/sound/soc/qcom/qdsp6/audioreach.h
> @@ -29,6 +29,7 @@ struct q6apm_graph;
>  #define MODULE_ID_MP3_DECODE		0x0700103B
>  #define MODULE_ID_GAPLESS		0x0700104D
>  #define MODULE_ID_DISPLAY_PORT_SINK	0x07001069
> +#define MODULE_ID_OPUS_DEC		0x07001174
>  
>  #define APM_CMD_GET_SPF_STATE		0x01001021
>  #define APM_CMD_RSP_GET_SPF_STATE	0x02001007
> @@ -255,6 +256,22 @@ struct payload_media_fmt_aac_t {
>  	uint32_t sample_rate;
>  } __packed;
>  
> +#define MEDIA_FMT_ID_OPUS	0x09001039
> +struct payload_media_fmt_opus_t {
> +	uint16_t bitstream_format;
> +	uint16_t payload_type;
> +	uint8_t version;
> +	uint8_t num_channels;
> +	uint16_t pre_skip;
> +	uint32_t sample_rate;
> +	uint16_t output_gain;
> +	uint8_t mapping_family;
> +	uint8_t stream_count;
> +	uint8_t coupled_count;
> +	uint8_t channel_mapping[8];
> +	uint8_t reserved[3];
> +} __packed;
> +
>  #define DATA_CMD_WR_SH_MEM_EP_EOS			0x04001002
>  #define WR_SH_MEM_EP_EOS_POLICY_LAST	1
>  #define WR_SH_MEM_EP_EOS_POLICY_EACH	2
> diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c
> index 2cd522108221a2ec5c7bbbb63f7d4ae4f8001cf6..7da91ed297f4a5ed39ca0747804cabd579634b50 100644
> --- a/sound/soc/qcom/qdsp6/q6apm-dai.c
> +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
> @@ -550,10 +550,11 @@ static int q6apm_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->num_codecs = 3;
> +	caps->num_codecs = 4;
>  	caps->codecs[0] = SND_AUDIOCODEC_MP3;
>  	caps->codecs[1] = SND_AUDIOCODEC_AAC;
>  	caps->codecs[2] = SND_AUDIOCODEC_FLAC;
> +	caps->codecs[3] = SND_AUDIOCODEC_OPUS_RAW;
>  
>  	return 0;
>  }
> diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c
> index b4ffa0f0b188e2c32fdfb863b9130d1d11e578dd..0e667a7eb5467bdd65326099132e8ba9dfefa21e 100644
> --- a/sound/soc/qcom/qdsp6/q6apm.c
> +++ b/sound/soc/qcom/qdsp6/q6apm.c
> @@ -354,6 +354,9 @@ int q6apm_set_real_module_id(struct device *dev, struct q6apm_graph *graph,
>  	case SND_AUDIOCODEC_FLAC:
>  		module_id = MODULE_ID_FLAC_DEC;
>  		break;
> +	case SND_AUDIOCODEC_OPUS_RAW:
> +		module_id = MODULE_ID_OPUS_DEC;
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> 


  reply	other threads:[~2025-06-18 12:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 15:26 [PATCH RFC 0/2] Add raw OPUS codec support for compress offload Alexey Klimov
2025-06-16 15:26 ` [PATCH RFC 1/2] ALSA: compress: add raw opus codec define and struct snd_dec_opus Alexey Klimov
2025-06-18 12:33   ` Srinivas Kandagatla
2025-08-20 17:59     ` Alexey Klimov
2025-06-16 15:26 ` [PATCH RFC 2/2] ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback Alexey Klimov
2025-06-18 12:34   ` Srinivas Kandagatla [this message]
2025-07-03 14:33     ` Alexey Klimov
2025-08-20 18:04       ` Alexey Klimov
2025-08-20 17:56     ` Alexey Klimov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4d934c1-0218-4147-882f-279795bcd1f4@oss.qualcomm.com \
    --to=srinivas.kandagatla@oss.qualcomm.com \
    --cc=alexey.klimov@linaro.org \
    --cc=annemari@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=ekansh.gupta@oss.qualcomm.com \
    --cc=kernel@oss.qualcomm.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=plai@qti.qualcomm.com \
    --cc=srini@kernel.org \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®