ASoC: qcom: q6asm-dai: add support to wma decoder

Qualcomm DSPs also supports the wma decoder, so add support for wma
decoder and convert the snd_codec_params to qdsp format.

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200316055221.1944464-6-vkoul@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Vinod Koul 2020-03-16 11:22:17 +05:30 committed by Mark Brown
parent 97163eadf1
commit 40519a1c02
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 66 additions and 1 deletions

View File

@ -629,10 +629,13 @@ static int q6asm_dai_compr_set_params(struct snd_compr_stream *stream,
int dir = stream->direction;
struct q6asm_dai_data *pdata;
struct q6asm_flac_cfg flac_cfg;
struct q6asm_wma_cfg wma_cfg;
unsigned int wma_v9 = 0;
struct device *dev = c->dev;
int ret;
union snd_codec_options *codec_options;
struct snd_dec_flac *flac;
struct snd_dec_wma *wma;
codec_options = &(prtd->codec_param.codec.options);
@ -694,6 +697,67 @@ static int q6asm_dai_compr_set_params(struct snd_compr_stream *stream,
return -EIO;
}
break;
case SND_AUDIOCODEC_WMA:
wma = &codec_options->wma_d;
memset(&wma_cfg, 0x0, sizeof(struct q6asm_wma_cfg));
wma_cfg.sample_rate = params->codec.sample_rate;
wma_cfg.num_channels = params->codec.ch_in;
wma_cfg.bytes_per_sec = params->codec.bit_rate / 8;
wma_cfg.block_align = params->codec.align;
wma_cfg.bits_per_sample = prtd->bits_per_sample;
wma_cfg.enc_options = wma->encoder_option;
wma_cfg.adv_enc_options = wma->adv_encoder_option;
wma_cfg.adv_enc_options2 = wma->adv_encoder_option2;
if (wma_cfg.num_channels == 1)
wma_cfg.channel_mask = 4; /* Mono Center */
else if (wma_cfg.num_channels == 2)
wma_cfg.channel_mask = 3; /* Stereo FL/FR */
else
return -EINVAL;
/* check the codec profile */
switch (params->codec.profile) {
case SND_AUDIOPROFILE_WMA9:
wma_cfg.fmtag = 0x161;
wma_v9 = 1;
break;
case SND_AUDIOPROFILE_WMA10:
wma_cfg.fmtag = 0x166;
break;
case SND_AUDIOPROFILE_WMA9_PRO:
wma_cfg.fmtag = 0x162;
break;
case SND_AUDIOPROFILE_WMA9_LOSSLESS:
wma_cfg.fmtag = 0x163;
break;
case SND_AUDIOPROFILE_WMA10_LOSSLESS:
wma_cfg.fmtag = 0x167;
break;
default:
dev_err(dev, "Unknown WMA profile:%x\n",
params->codec.profile);
return -EIO;
}
if (wma_v9)
ret = q6asm_stream_media_format_block_wma_v9(
prtd->audio_client, &wma_cfg);
else
ret = q6asm_stream_media_format_block_wma_v10(
prtd->audio_client, &wma_cfg);
if (ret < 0) {
dev_err(dev, "WMA9 CMD failed:%d\n", ret);
return -EIO;
}
default:
break;
}
@ -793,9 +857,10 @@ static int q6asm_dai_compr_get_caps(struct snd_compr_stream *stream,
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 = 2;
caps->num_codecs = 3;
caps->codecs[0] = SND_AUDIOCODEC_MP3;
caps->codecs[1] = SND_AUDIOCODEC_FLAC;
caps->codecs[2] = SND_AUDIOCODEC_WMA;
return 0;
}