Message ID | 20250616-opus_codec_rfc_v1-v1-0-1f70b0a41a70@linaro.org |
---|---|
Headers | show |
Series | Add raw OPUS codec support for compress offload | expand |
On 6/16/25 4:26 PM, Alexey Klimov wrote: > Adds a raw opus codec define and raw opus decoder struct. > 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. > > This is based on earlier work done by > Annemarie Porter <annemari@quicinc.com> > May be co-dev by would be good option. > 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> > --- > include/uapi/sound/compress_params.h | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/include/uapi/sound/compress_params.h b/include/uapi/sound/compress_params.h > index bc7648a30746f4632ecf6695868e79550a431dfa..f80989f7bdd2f1bfad843b1dc30fa263e083d17a 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,23 @@ struct snd_dec_ape { > __u32 seek_table_present; > } __attribute__((packed, aligned(4))); > > +/* > + * RFC with info on below OPUS decoder fields: > + * https://www.rfc-editor.org/rfc/rfc7845#section-5 > + */ > +struct snd_dec_opus { > + __u8 version; /* must be 1 */ > + __u8 num_channels; > + __u16 pre_skip; > + __u32 sample_rate; > + __u16 output_gain; /* in Q7.8 format */ > + __u8 mapping_family; This is where optional Channel Mapping Table starts in the structure. Should this all these channel mapping memnbers go into a dedicated struct snd_dec_opus_ch_map? > + __u8 stream_count; /* part of channel mapping */ > + __u8 coupled_count; /* part of channel mapping */ Comments are bit misleading. Either we document them in detail or point to the rfc which has this documented in more detail. > + __u8 channel_map; Channel Mapping is (8*C bits), one octet per output channel. The way this is represented/split in this struct is confusing should it be just channel_map[8] > + __u8 reserved[7]; /* space for channel mapping */ Any reason only 7? > +} __attribute__((packed, aligned(4))); > + > union snd_codec_options { > struct snd_enc_wma wma; > struct snd_enc_vorbis vorbis; > @@ -334,6 +352,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; >
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 (>=sm8750); -- adsp fastrpc for sm8750; -- explicitly setting format in sm8750 soundcard driver; -- 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. The userspace tinycompress tool with support for raw OPUS compress playback is located here: https://github.com/laklimov/tinycompress_opus branch: opus_v3_workinprogress It is not expected that it is ready and still needs some work. More like PoC. Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> --- Alexey Klimov (2): ALSA: compress: add raw opus codec define and struct snd_dec_opus ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback include/uapi/sound/compress_params.h | 21 ++++++++++++++++++++- 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 +++ 5 files changed, 75 insertions(+), 2 deletions(-) --- base-commit: 050f8ad7b58d9079455af171ac279c4b9b828c11 change-id: 20250616-opus_codec_rfc_v1-b60bd308893b Best regards,