public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Add raw OPUS codec support for compress offload
@ 2025-09-17  7:32 Alexey Klimov
  2025-09-17  7:32 ` [PATCH v3 1/3] ALSA: compress: add raw opus codec define and opus decoder structs Alexey Klimov
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Alexey Klimov @ 2025-09-17  7:32 UTC (permalink / raw)
  To: Vinod Koul, Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla,
	Liam Girdwood, Mark Brown
  Cc: Patrick Lai, Annemarie Porter, srinivas.kandagatla, linux-sound,
	linux-kernel, linux-arm-msm, Krzysztof Kozlowski, kernel,
	Ekansh Gupta, Alexey Klimov, Pierre-Louis Bossart

This series adds support in kernel to recognise raw (or plain) OPUS
codec playback for compress offloading. At this point this series
doesn't deal with OPUS packets packed in any kind of containers (OGG or
others) and focuses on adding missing bits for pure OPUS packets.

The second patch adds its usage in Qualcomm Audio DSP code. To correctly
recognise raw OPUS packets by qdsp6, each packets needs to be prepended
with 4-bytes field that contains length of a raw OPUS packet.
It is expected to be useful for usecases when OPUS packets are streamed
over network and they are not encapsulated in a container. Userspace
application that will use the compress API has to manually add such
4-bytes long field to each OPUS packet.

This is tested on sm8750-mtp. It is expected that next hardware revisions
will also support raw OPUS codec offloading.

Dependencies are:
-- hardware with DSP that supports decoding OPUS packets (>= Qualcomm sm8750);
-- adsp fastrpc;
-- explicitly setting format in sm8750 soundcard driver
https://lore.kernel.org/linux-sound/20250911154340.2798304-1-alexey.klimov@linaro.org/
-- running adsprpcd tool with support for Audio PD and DSP libraries
loading support (or its alternative);
-- tinycompress fcplay tool that will prepare raw opus packets and
do the required addition of length field;
-- mfc module in topology compress-playback path, that module is
expected to parse channel mapping and do the required things to
map streams/channels to physically-present output channels on backend.

The userspace tinycompress tool with support for raw OPUS compress
playback is located here:
https://github.com/laklimov/tinycompress_opus
branch: opus_v3_workinprogress

The userspace tool is not expected that it is ready and still needs
some work, for instance recognition that it runs on Qualcomm hardware.
More like working PoC.

Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
---
Changes in v3:
- back to define version member as __u8 in snd_dec_opus and reading it in audioreach_set_compr_media_format()
as suggested by Takashi;
- new patch, bumping compress API minor version as suggested by Vinod and Takashi;
- Link to v2: https://lore.kernel.org/r/20250910-opus_codec_rfc_v1-v2-0-35fb6536df6b@linaro.org

Changes in v2 (as suggested by Vinod):
- opus decoder struct: switch version memeber to be union to allow reading it
 as a byte or two 4-bits fields;
- audioreach_set_compr_media_format: read version byte.
- Link to v1: https://lore.kernel.org/r/20250820-opus_codec_rfc_v1-v1-0-54d5c7560856@linaro.org

Changes since RFC (mostly as suggetsed by Srini):
- added struct snd_dec_opus_ch_map to struct snd_dec_opus;
- changed tags;
- reworked comments for struct snd_dec_opus;
In qcom audioreach patch:
- corrected how {stream_count,coupled_count} is ejected from mcfg->codec;
- stopped dealing with channel mapping parsing (this is internal struct for
  decoder on audio DSP side);
- used sizeof(*opus_cfg) for payload size;
Tinycompress/fcplay:
- small updates to match kernel structs.
- Link to RFC: https://lore.kernel.org/r/20250616-opus_codec_rfc_v1-v1-0-1f70b0a41a70@linaro.org

---
Alexey Klimov (3):
      ALSA: compress: add raw opus codec define and opus decoder structs
      ALSA: compress_offload: increase SNDRV_COMPRESS_VERSION minor version by 1
      ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback

 include/uapi/sound/compress_offload.h |  2 +-
 include/uapi/sound/compress_params.h  | 43 ++++++++++++++++++++++++++++++++++-
 sound/soc/qcom/qdsp6/audioreach.c     | 27 ++++++++++++++++++++++
 sound/soc/qcom/qdsp6/audioreach.h     | 17 ++++++++++++++
 sound/soc/qcom/qdsp6/q6apm-dai.c      |  3 ++-
 sound/soc/qcom/qdsp6/q6apm.c          |  3 +++
 6 files changed, 92 insertions(+), 3 deletions(-)
---
base-commit: 05af764719214d6568adb55c8749dec295228da8
change-id: 20250616-opus_codec_rfc_v1-b60bd308893b

Best regards,
-- 
Alexey Klimov <alexey.klimov@linaro.org>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3 1/3] ALSA: compress: add raw opus codec define and opus decoder structs
  2025-09-17  7:32 [PATCH v3 0/3] Add raw OPUS codec support for compress offload Alexey Klimov
@ 2025-09-17  7:32 ` Alexey Klimov
  2025-09-18  5:08   ` Vinod Koul
  2025-09-17  7:32 ` [PATCH v3 2/3] ALSA: compress_offload: increase SNDRV_COMPRESS_VERSION minor version by 1 Alexey Klimov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Alexey Klimov @ 2025-09-17  7:32 UTC (permalink / raw)
  To: Vinod Koul, Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla,
	Liam Girdwood, Mark Brown
  Cc: Patrick Lai, Annemarie Porter, srinivas.kandagatla, linux-sound,
	linux-kernel, linux-arm-msm, Krzysztof Kozlowski, kernel,
	Ekansh Gupta, Alexey Klimov, Pierre-Louis Bossart

Adds a raw opus codec define and raw opus decoder structs.
This is for raw OPUS packets not packed in any type of container
(for instance OGG container). The decoder struct fields are
taken from corresponding RFC document: RFC 7845 Section 5.

Cc: Srinivas Kandagatla <srini@kernel.org>
Cc: Vinod Koul <vkoul@kernel.org>
Co-developed-by: Annemarie Porter <annemari@quicinc.com>
Signed-off-by: Annemarie Porter <annemari@quicinc.com>
Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
---
 include/uapi/sound/compress_params.h | 43 +++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/include/uapi/sound/compress_params.h b/include/uapi/sound/compress_params.h
index bc7648a30746f4632ecf6695868e79550a431dfa..faf4fa911f7fc2830c3ae42b93650fe40d8a776b 100644
--- a/include/uapi/sound/compress_params.h
+++ b/include/uapi/sound/compress_params.h
@@ -43,7 +43,8 @@
 #define SND_AUDIOCODEC_BESPOKE               ((__u32) 0x0000000E)
 #define SND_AUDIOCODEC_ALAC                  ((__u32) 0x0000000F)
 #define SND_AUDIOCODEC_APE                   ((__u32) 0x00000010)
-#define SND_AUDIOCODEC_MAX                   SND_AUDIOCODEC_APE
+#define SND_AUDIOCODEC_OPUS_RAW              ((__u32) 0x00000011)
+#define SND_AUDIOCODEC_MAX                   SND_AUDIOCODEC_OPUS_RAW
 
 /*
  * Profile and modes are listed with bit masks. This allows for a
@@ -324,6 +325,45 @@ struct snd_dec_ape {
 	__u32 seek_table_present;
 } __attribute__((packed, aligned(4)));
 
+/**
+ * struct snd_dec_opus - Opus decoder parameters (raw opus packets)
+ * @version: Usually should be '1' but can be split into major (4 upper bits)
+ * and minor (4 lower bits) sub-fields.
+ * @num_channels: Number of output channels.
+ * @pre_skip: Number of samples to discard at 48 kHz.
+ * @sample_rate: Sample rate of original input.
+ * @output_gain: Gain to apply when decoding (in Q7.8 format).
+ * @mapping_family: Order and meaning of output channels. Only values 0 and 1
+ * are expected; values 2..255 are not recommended for playback.
+ *
+ * Optional channel mapping table. Describes mapping of opus streams to decoded
+ * channels.
+ * @struct snd_dec_opus_ch_map
+ *	@stream_count: Number of streams encoded in each Ogg packet.
+ *	@coupled_count: Number of streams whose decoders are used for two
+ *		channels.
+ *	@channel_map: describes which decoded channel to be used for each one.
+ *		See RFC doc for details.
+ *		This supports only mapping families 0 and 1, therefore max
+ *		number of channels is 8.
+ *
+ * These options were extracted from RFC7845 Section 5.
+ */
+
+struct snd_dec_opus {
+	__u8 version;
+	__u8 num_channels;
+	__u16 pre_skip;
+	__u32 sample_rate;
+	__u16 output_gain;
+	__u8 mapping_family;
+	struct snd_dec_opus_ch_map {
+		__u8 stream_count;
+		__u8 coupled_count;
+		__u8 channel_map[8];
+	} chan_map;
+} __attribute__((packed, aligned(4)));
+
 union snd_codec_options {
 	struct snd_enc_wma wma;
 	struct snd_enc_vorbis vorbis;
@@ -334,6 +374,7 @@ union snd_codec_options {
 	struct snd_dec_wma wma_d;
 	struct snd_dec_alac alac_d;
 	struct snd_dec_ape ape_d;
+	struct snd_dec_opus opus_d;
 	struct {
 		__u32 out_sample_rate;
 	} src_d;

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 2/3] ALSA: compress_offload: increase SNDRV_COMPRESS_VERSION minor version by 1
  2025-09-17  7:32 [PATCH v3 0/3] Add raw OPUS codec support for compress offload Alexey Klimov
  2025-09-17  7:32 ` [PATCH v3 1/3] ALSA: compress: add raw opus codec define and opus decoder structs Alexey Klimov
@ 2025-09-17  7:32 ` Alexey Klimov
  2025-09-18  5:09   ` Vinod Koul
  2025-09-17  7:32 ` [PATCH v3 3/3] ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback Alexey Klimov
  2025-09-19 13:00 ` [PATCH v3 0/3] Add raw OPUS codec support for compress offload Takashi Iwai
  3 siblings, 1 reply; 9+ messages in thread
From: Alexey Klimov @ 2025-09-17  7:32 UTC (permalink / raw)
  To: Vinod Koul, Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla,
	Liam Girdwood, Mark Brown
  Cc: Patrick Lai, Annemarie Porter, srinivas.kandagatla, linux-sound,
	linux-kernel, linux-arm-msm, Krzysztof Kozlowski, kernel,
	Ekansh Gupta, Alexey Klimov, Pierre-Louis Bossart

Since addition of raw opus codec support we need to update
compress API minor version by one.
Bump the SNDRV_COMPRESS_VERSION to 0.4.1.

Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
---
 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 26f756cc2e6215fe99bbac4f4a32ceb475068ec4..b610683fd8dbe4cb60489874fe94aca167ac7abb 100644
--- a/include/uapi/sound/compress_offload.h
+++ b/include/uapi/sound/compress_offload.h
@@ -13,7 +13,7 @@
 #include <sound/asound.h>
 #include <sound/compress_params.h>
 
-#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 4, 0)
+#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 4, 1)
 /**
  * struct snd_compressed_buffer - compressed buffer
  * @fragment_size: size of buffer fragment in bytes

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v3 3/3] ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback
  2025-09-17  7:32 [PATCH v3 0/3] Add raw OPUS codec support for compress offload Alexey Klimov
  2025-09-17  7:32 ` [PATCH v3 1/3] ALSA: compress: add raw opus codec define and opus decoder structs Alexey Klimov
  2025-09-17  7:32 ` [PATCH v3 2/3] ALSA: compress_offload: increase SNDRV_COMPRESS_VERSION minor version by 1 Alexey Klimov
@ 2025-09-17  7:32 ` Alexey Klimov
  2025-09-17 11:39   ` Mark Brown
  2025-09-19 13:00 ` [PATCH v3 0/3] Add raw OPUS codec support for compress offload Takashi Iwai
  3 siblings, 1 reply; 9+ messages in thread
From: Alexey Klimov @ 2025-09-17  7:32 UTC (permalink / raw)
  To: Vinod Koul, Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla,
	Liam Girdwood, Mark Brown
  Cc: Patrick Lai, Annemarie Porter, srinivas.kandagatla, linux-sound,
	linux-kernel, linux-arm-msm, Krzysztof Kozlowski, kernel,
	Ekansh Gupta, Alexey Klimov, Pierre-Louis Bossart

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.

Cc: Annemarie Porter <annemari@quicinc.com>
Cc: Vinod Koul <vkoul@kernel.org>
Co-developed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
---
 sound/soc/qcom/qdsp6/audioreach.c | 27 +++++++++++++++++++++++++++
 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, 49 insertions(+), 1 deletion(-)

diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
index bbfd51db879766445fa0fea564659fabd06b59ad..7e9c48ad0b88213fd39eab222c104a8e41c583da 100644
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -883,6 +883,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:
@@ -925,6 +926,32 @@ 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(*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.chan_map.stream_count;
+		opus_cfg->coupled_count = mcfg->codec.options.opus_d.chan_map.coupled_count;
+		memcpy(opus_cfg->channel_mapping, mcfg->codec.options.opus_d.chan_map.channel_map,
+		       sizeof(opus_cfg->channel_mapping));
+		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 790fba96e34db0fc9d5c90504747174f56b65b32..d1b60b36468a86301601b61a7f8e7f6051561c3e 100644
--- a/sound/soc/qcom/qdsp6/audioreach.h
+++ b/sound/soc/qcom/qdsp6/audioreach.h
@@ -31,6 +31,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
@@ -257,6 +258,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 09da26f712a6ada97196090d760b91bc2dc2a732..4ecaff45c51860cddc631725953ba7dfa84eeb50 100644
--- a/sound/soc/qcom/qdsp6/q6apm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
@@ -551,10 +551,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;
 	}

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 3/3] ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback
  2025-09-17  7:32 ` [PATCH v3 3/3] ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback Alexey Klimov
@ 2025-09-17 11:39   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2025-09-17 11:39 UTC (permalink / raw)
  To: Alexey Klimov
  Cc: Vinod Koul, Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla,
	Liam Girdwood, Patrick Lai, Annemarie Porter, srinivas.kandagatla,
	linux-sound, linux-kernel, linux-arm-msm, Krzysztof Kozlowski,
	kernel, Ekansh Gupta, Pierre-Louis Bossart

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

On Wed, Sep 17, 2025 at 08:32:52AM +0100, 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.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/3] ALSA: compress: add raw opus codec define and opus decoder structs
  2025-09-17  7:32 ` [PATCH v3 1/3] ALSA: compress: add raw opus codec define and opus decoder structs Alexey Klimov
@ 2025-09-18  5:08   ` Vinod Koul
  2025-10-15 16:36     ` Alexey Klimov
  0 siblings, 1 reply; 9+ messages in thread
From: Vinod Koul @ 2025-09-18  5:08 UTC (permalink / raw)
  To: Alexey Klimov
  Cc: Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla, Liam Girdwood,
	Mark Brown, Patrick Lai, Annemarie Porter, srinivas.kandagatla,
	linux-sound, linux-kernel, linux-arm-msm, Krzysztof Kozlowski,
	kernel, Ekansh Gupta, Pierre-Louis Bossart

On 17-09-25, 08:32, Alexey Klimov wrote:
> Adds a raw opus codec define and raw opus decoder structs.
> This is for raw OPUS packets not packed in any type of container
> (for instance OGG container). The decoder struct fields are
> taken from corresponding RFC document: RFC 7845 Section 5.
> 
> Cc: Srinivas Kandagatla <srini@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Co-developed-by: Annemarie Porter <annemari@quicinc.com>
> Signed-off-by: Annemarie Porter <annemari@quicinc.com>
> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
> ---
>  include/uapi/sound/compress_params.h | 43 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/include/uapi/sound/compress_params.h b/include/uapi/sound/compress_params.h
> index bc7648a30746f4632ecf6695868e79550a431dfa..faf4fa911f7fc2830c3ae42b93650fe40d8a776b 100644
> --- a/include/uapi/sound/compress_params.h
> +++ b/include/uapi/sound/compress_params.h
> @@ -43,7 +43,8 @@
>  #define SND_AUDIOCODEC_BESPOKE               ((__u32) 0x0000000E)
>  #define SND_AUDIOCODEC_ALAC                  ((__u32) 0x0000000F)
>  #define SND_AUDIOCODEC_APE                   ((__u32) 0x00000010)
> -#define SND_AUDIOCODEC_MAX                   SND_AUDIOCODEC_APE
> +#define SND_AUDIOCODEC_OPUS_RAW              ((__u32) 0x00000011)
> +#define SND_AUDIOCODEC_MAX                   SND_AUDIOCODEC_OPUS_RAW
>  
>  /*
>   * Profile and modes are listed with bit masks. This allows for a
> @@ -324,6 +325,45 @@ struct snd_dec_ape {
>  	__u32 seek_table_present;
>  } __attribute__((packed, aligned(4)));
>  
> +/**
> + * struct snd_dec_opus - Opus decoder parameters (raw opus packets)
> + * @version: Usually should be '1' but can be split into major (4 upper bits)
> + * and minor (4 lower bits) sub-fields.

Please clarify, if that should be 1.0 so a value of 0x10

> + * @num_channels: Number of output channels.
> + * @pre_skip: Number of samples to discard at 48 kHz.
> + * @sample_rate: Sample rate of original input.
> + * @output_gain: Gain to apply when decoding (in Q7.8 format).
> + * @mapping_family: Order and meaning of output channels. Only values 0 and 1
> + * are expected; values 2..255 are not recommended for playback.
> + *
> + * Optional channel mapping table. Describes mapping of opus streams to decoded
> + * channels.
> + * @struct snd_dec_opus_ch_map
> + *	@stream_count: Number of streams encoded in each Ogg packet.
> + *	@coupled_count: Number of streams whose decoders are used for two
> + *		channels.
> + *	@channel_map: describes which decoded channel to be used for each one.
> + *		See RFC doc for details.
> + *		This supports only mapping families 0 and 1, therefore max
> + *		number of channels is 8.
> + *
> + * These options were extracted from RFC7845 Section 5.
> + */
> +
> +struct snd_dec_opus {
> +	__u8 version;
> +	__u8 num_channels;
> +	__u16 pre_skip;
> +	__u32 sample_rate;
> +	__u16 output_gain;
> +	__u8 mapping_family;
> +	struct snd_dec_opus_ch_map {
> +		__u8 stream_count;
> +		__u8 coupled_count;
> +		__u8 channel_map[8];
> +	} chan_map;
> +} __attribute__((packed, aligned(4)));
> +
>  union snd_codec_options {
>  	struct snd_enc_wma wma;
>  	struct snd_enc_vorbis vorbis;
> @@ -334,6 +374,7 @@ union snd_codec_options {
>  	struct snd_dec_wma wma_d;
>  	struct snd_dec_alac alac_d;
>  	struct snd_dec_ape ape_d;
> +	struct snd_dec_opus opus_d;
>  	struct {
>  		__u32 out_sample_rate;
>  	} src_d;
> 
> -- 
> 2.47.3

-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 2/3] ALSA: compress_offload: increase SNDRV_COMPRESS_VERSION minor version by 1
  2025-09-17  7:32 ` [PATCH v3 2/3] ALSA: compress_offload: increase SNDRV_COMPRESS_VERSION minor version by 1 Alexey Klimov
@ 2025-09-18  5:09   ` Vinod Koul
  0 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2025-09-18  5:09 UTC (permalink / raw)
  To: Alexey Klimov
  Cc: Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla, Liam Girdwood,
	Mark Brown, Patrick Lai, Annemarie Porter, srinivas.kandagatla,
	linux-sound, linux-kernel, linux-arm-msm, Krzysztof Kozlowski,
	kernel, Ekansh Gupta, Pierre-Louis Bossart

On 17-09-25, 08:32, Alexey Klimov wrote:
> Since addition of raw opus codec support we need to update
> compress API minor version by one.
> Bump the SNDRV_COMPRESS_VERSION to 0.4.1.

Acked-by: Vinod Koul <vkoul@kernel.org>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 0/3] Add raw OPUS codec support for compress offload
  2025-09-17  7:32 [PATCH v3 0/3] Add raw OPUS codec support for compress offload Alexey Klimov
                   ` (2 preceding siblings ...)
  2025-09-17  7:32 ` [PATCH v3 3/3] ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback Alexey Klimov
@ 2025-09-19 13:00 ` Takashi Iwai
  3 siblings, 0 replies; 9+ messages in thread
From: Takashi Iwai @ 2025-09-19 13:00 UTC (permalink / raw)
  To: Alexey Klimov
  Cc: Vinod Koul, Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla,
	Liam Girdwood, Mark Brown, Patrick Lai, Annemarie Porter,
	srinivas.kandagatla, linux-sound, linux-kernel, linux-arm-msm,
	Krzysztof Kozlowski, kernel, Ekansh Gupta, Pierre-Louis Bossart

On Wed, 17 Sep 2025 09:32:49 +0200,
Alexey Klimov wrote:
> 
> This series adds support in kernel to recognise raw (or plain) OPUS
> codec playback for compress offloading. At this point this series
> doesn't deal with OPUS packets packed in any kind of containers (OGG or
> others) and focuses on adding missing bits for pure OPUS packets.
> 
> The second patch adds its usage in Qualcomm Audio DSP code. To correctly
> recognise raw OPUS packets by qdsp6, each packets needs to be prepended
> with 4-bytes field that contains length of a raw OPUS packet.
> It is expected to be useful for usecases when OPUS packets are streamed
> over network and they are not encapsulated in a container. Userspace
> application that will use the compress API has to manually add such
> 4-bytes long field to each OPUS packet.
> 
> This is tested on sm8750-mtp. It is expected that next hardware revisions
> will also support raw OPUS codec offloading.
> 
> Dependencies are:
> -- hardware with DSP that supports decoding OPUS packets (>= Qualcomm sm8750);
> -- adsp fastrpc;
> -- explicitly setting format in sm8750 soundcard driver
> https://lore.kernel.org/linux-sound/20250911154340.2798304-1-alexey.klimov@linaro.org/
> -- running adsprpcd tool with support for Audio PD and DSP libraries
> loading support (or its alternative);
> -- tinycompress fcplay tool that will prepare raw opus packets and
> do the required addition of length field;
> -- mfc module in topology compress-playback path, that module is
> expected to parse channel mapping and do the required things to
> map streams/channels to physically-present output channels on backend.
> 
> The userspace tinycompress tool with support for raw OPUS compress
> playback is located here:
> https://github.com/laklimov/tinycompress_opus
> branch: opus_v3_workinprogress
> 
> The userspace tool is not expected that it is ready and still needs
> some work, for instance recognition that it runs on Qualcomm hardware.
> More like working PoC.
> 
> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>

Applied now to for-next branch for 6.18.
For further improvements, please submit on top of that.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3 1/3] ALSA: compress: add raw opus codec define and opus decoder structs
  2025-09-18  5:08   ` Vinod Koul
@ 2025-10-15 16:36     ` Alexey Klimov
  0 siblings, 0 replies; 9+ messages in thread
From: Alexey Klimov @ 2025-10-15 16:36 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Jaroslav Kysela, Takashi Iwai, Srinivas Kandagatla, Liam Girdwood,
	Mark Brown, Patrick Lai, Annemarie Porter, srinivas.kandagatla,
	linux-sound, linux-kernel, linux-arm-msm, Krzysztof Kozlowski,
	kernel, Ekansh Gupta, Pierre-Louis Bossart

On Thu Sep 18, 2025 at 6:08 AM BST, Vinod Koul wrote:
> On 17-09-25, 08:32, Alexey Klimov wrote:
>> Adds a raw opus codec define and raw opus decoder structs.
>> This is for raw OPUS packets not packed in any type of container
>> (for instance OGG container). The decoder struct fields are
>> taken from corresponding RFC document: RFC 7845 Section 5.
>> 
>> Cc: Srinivas Kandagatla <srini@kernel.org>
>> Cc: Vinod Koul <vkoul@kernel.org>
>> Co-developed-by: Annemarie Porter <annemari@quicinc.com>
>> Signed-off-by: Annemarie Porter <annemari@quicinc.com>
>> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
>> ---
>>  include/uapi/sound/compress_params.h | 43 +++++++++++++++++++++++++++++++++++-
>>  1 file changed, 42 insertions(+), 1 deletion(-)
>> 
>> diff --git a/include/uapi/sound/compress_params.h b/include/uapi/sound/compress_params.h
>> index bc7648a30746f4632ecf6695868e79550a431dfa..faf4fa911f7fc2830c3ae42b93650fe40d8a776b 100644
>> --- a/include/uapi/sound/compress_params.h
>> +++ b/include/uapi/sound/compress_params.h
>> @@ -43,7 +43,8 @@
>>  #define SND_AUDIOCODEC_BESPOKE               ((__u32) 0x0000000E)
>>  #define SND_AUDIOCODEC_ALAC                  ((__u32) 0x0000000F)
>>  #define SND_AUDIOCODEC_APE                   ((__u32) 0x00000010)
>> -#define SND_AUDIOCODEC_MAX                   SND_AUDIOCODEC_APE
>> +#define SND_AUDIOCODEC_OPUS_RAW              ((__u32) 0x00000011)
>> +#define SND_AUDIOCODEC_MAX                   SND_AUDIOCODEC_OPUS_RAW
>>  
>>  /*
>>   * Profile and modes are listed with bit masks. This allows for a
>> @@ -324,6 +325,45 @@ struct snd_dec_ape {
>>  	__u32 seek_table_present;
>>  } __attribute__((packed, aligned(4)));
>>  
>> +/**
>> + * struct snd_dec_opus - Opus decoder parameters (raw opus packets)
>> + * @version: Usually should be '1' but can be split into major (4 upper bits)
>> + * and minor (4 lower bits) sub-fields.
>
> Please clarify, if that should be 1.0 so a value of 0x10

Sorry for the delay.
So the spec says that the value must be '1' for 8-bit field for that
version of specification which it seems it should be 0x1.
The spliting into two 4-bit fields is for backward compatibility and
in such case any version in minor fields will be accepted (15 or less).
Anything starting with version 16 or 0x10 is treated as incompatible
version for this version of spec.

Well, at least that's how I understand the spec.
Value 0x10 in this case seems to signal incompatibility unless I am
missing something?

Thanks,
Alexey




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-10-15 16:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17  7:32 [PATCH v3 0/3] Add raw OPUS codec support for compress offload Alexey Klimov
2025-09-17  7:32 ` [PATCH v3 1/3] ALSA: compress: add raw opus codec define and opus decoder structs Alexey Klimov
2025-09-18  5:08   ` Vinod Koul
2025-10-15 16:36     ` Alexey Klimov
2025-09-17  7:32 ` [PATCH v3 2/3] ALSA: compress_offload: increase SNDRV_COMPRESS_VERSION minor version by 1 Alexey Klimov
2025-09-18  5:09   ` Vinod Koul
2025-09-17  7:32 ` [PATCH v3 3/3] ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback Alexey Klimov
2025-09-17 11:39   ` Mark Brown
2025-09-19 13:00 ` [PATCH v3 0/3] Add raw OPUS codec support for compress offload Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox