Commit c0c87738 authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by Mark Brown

ASoC: q6dsp: q6apm-dai: Add compress DAI and codec caps get callbacks

Add q6apm get compress DAI capabilities and codec capabilities callbacks
to support compress offload playback.
Co-developed-by: default avatarMohammad Rafi Shaik <quic_mohs@quicinc.com>
Signed-off-by: default avatarMohammad Rafi Shaik <quic_mohs@quicinc.com>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230619101653.9750-9-srinivas.kandagatla@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 88b60bf0
......@@ -30,8 +30,25 @@
#define BUFFER_BYTES_MIN (PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE)
#define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024)
#define COMPR_PLAYBACK_MAX_NUM_FRAGMENTS (16 * 4)
#define COMPR_PLAYBACK_MIN_FRAGMENT_SIZE (8 * 1024)
#define COMPR_PLAYBACK_MIN_NUM_FRAGMENTS (4)
#define SID_MASK_DEFAULT 0xF
static const struct snd_compr_codec_caps q6apm_compr_caps = {
.num_descriptors = 1,
.descriptor[0].max_ch = 2,
.descriptor[0].sample_rates = { 8000, 11025, 12000, 16000, 22050,
24000, 32000, 44100, 48000, 88200,
96000, 176400, 192000 },
.descriptor[0].num_sample_rates = 13,
.descriptor[0].bit_rate[0] = 320,
.descriptor[0].bit_rate[1] = 128,
.descriptor[0].num_bitrates = 2,
.descriptor[0].profiles = 0,
.descriptor[0].modes = SND_AUDIOCHANMODE_MP3_STEREO,
.descriptor[0].formats = 0,
};
enum stream_state {
Q6APM_STREAM_IDLE = 0,
Q6APM_STREAM_STOPPED,
......@@ -41,6 +58,7 @@ enum stream_state {
struct q6apm_dai_rtd {
struct snd_pcm_substream *substream;
struct snd_compr_stream *cstream;
struct snd_codec codec;
struct snd_compr_params codec_param;
struct snd_dma_buffer dma_buffer;
phys_addr_t phys;
......@@ -54,6 +72,7 @@ struct q6apm_dai_rtd {
uint16_t bits_per_sample;
uint16_t source; /* Encoding source bit mask */
uint16_t session_id;
bool next_track;
enum stream_state state;
struct q6apm_graph *graph;
spinlock_t lock;
......@@ -517,9 +536,43 @@ static int q6apm_dai_compr_free(struct snd_soc_component *component,
return 0;
}
static int q6apm_dai_compr_get_caps(struct snd_soc_component *component,
struct snd_compr_stream *stream,
struct snd_compr_caps *caps)
{
caps->direction = SND_COMPRESS_PLAYBACK;
caps->min_fragment_size = COMPR_PLAYBACK_MIN_FRAGMENT_SIZE;
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->codecs[0] = SND_AUDIOCODEC_MP3;
caps->codecs[1] = SND_AUDIOCODEC_AAC;
caps->codecs[2] = SND_AUDIOCODEC_FLAC;
return 0;
}
static int q6apm_dai_compr_get_codec_caps(struct snd_soc_component *component,
struct snd_compr_stream *stream,
struct snd_compr_codec_caps *codec)
{
switch (codec->codec) {
case SND_AUDIOCODEC_MP3:
*codec = q6apm_compr_caps;
break;
default:
break;
}
return 0;
}
static const struct snd_compress_ops q6apm_dai_compress_ops = {
.open = q6apm_dai_compr_open,
.free = q6apm_dai_compr_free,
.get_caps = q6apm_dai_compr_get_caps,
.get_codec_caps = q6apm_dai_compr_get_codec_caps,
};
static const struct snd_soc_component_driver q6apm_fe_dai_component = {
......
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