Commit baddcee9 authored by Vinod Koul's avatar Vinod Koul Committed by Mark Brown

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

Qualcomm DSPs also support the flac decoder, so add support for FLAC
decoder and convert the snd_dec_flac params to qdsp format.
Co-developed-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20191115102705.649976-4-vkoul@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 51d2584a
...@@ -626,8 +626,14 @@ static int q6asm_dai_compr_set_params(struct snd_compr_stream *stream, ...@@ -626,8 +626,14 @@ static int q6asm_dai_compr_set_params(struct snd_compr_stream *stream,
struct snd_soc_component *c = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_soc_component *c = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
int dir = stream->direction; int dir = stream->direction;
struct q6asm_dai_data *pdata; struct q6asm_dai_data *pdata;
struct q6asm_flac_cfg flac_cfg;
struct device *dev = c->dev; struct device *dev = c->dev;
int ret; int ret;
union snd_codec_options *codec_options;
struct snd_dec_flac *flac;
codec_options = &(prtd->codec_param.codec.options);
memcpy(&prtd->codec_param, params, sizeof(*params)); memcpy(&prtd->codec_param, params, sizeof(*params));
...@@ -664,6 +670,32 @@ static int q6asm_dai_compr_set_params(struct snd_compr_stream *stream, ...@@ -664,6 +670,32 @@ static int q6asm_dai_compr_set_params(struct snd_compr_stream *stream,
return ret; return ret;
} }
switch (params->codec.id) {
case SND_AUDIOCODEC_FLAC:
memset(&flac_cfg, 0x0, sizeof(struct q6asm_flac_cfg));
flac = &codec_options->flac_d;
flac_cfg.ch_cfg = params->codec.ch_in;
flac_cfg.sample_rate = params->codec.sample_rate;
flac_cfg.stream_info_present = 1;
flac_cfg.sample_size = flac->sample_size;
flac_cfg.min_blk_size = flac->min_blk_size;
flac_cfg.max_blk_size = flac->max_blk_size;
flac_cfg.max_frame_size = flac->max_frame_size;
flac_cfg.min_frame_size = flac->min_frame_size;
ret = q6asm_stream_media_format_block_flac(prtd->audio_client,
&flac_cfg);
if (ret < 0) {
dev_err(dev, "FLAC CMD Format block failed:%d\n", ret);
return -EIO;
}
break;
default:
break;
}
ret = q6asm_map_memory_regions(dir, prtd->audio_client, prtd->phys, ret = q6asm_map_memory_regions(dir, prtd->audio_client, prtd->phys,
(prtd->pcm_size / prtd->periods), (prtd->pcm_size / prtd->periods),
prtd->periods); prtd->periods);
...@@ -759,8 +791,9 @@ static int q6asm_dai_compr_get_caps(struct snd_compr_stream *stream, ...@@ -759,8 +791,9 @@ static int q6asm_dai_compr_get_caps(struct snd_compr_stream *stream,
caps->max_fragment_size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE; caps->max_fragment_size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE;
caps->min_fragments = COMPR_PLAYBACK_MIN_NUM_FRAGMENTS; caps->min_fragments = COMPR_PLAYBACK_MIN_NUM_FRAGMENTS;
caps->max_fragments = COMPR_PLAYBACK_MAX_NUM_FRAGMENTS; caps->max_fragments = COMPR_PLAYBACK_MAX_NUM_FRAGMENTS;
caps->num_codecs = 1; caps->num_codecs = 2;
caps->codecs[0] = SND_AUDIOCODEC_MP3; caps->codecs[0] = SND_AUDIOCODEC_MP3;
caps->codecs[1] = SND_AUDIOCODEC_FLAC;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment