mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:04:51 +01:00
ASoC: qcom: qdsp6/audioreach: add support for offloading raw opus playback
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> Acked-by: Mark Brown <broonie@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
b07d2514b9
commit
fc87f70bd1
4 changed files with 49 additions and 1 deletions
|
|
@ -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,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue