From ba2ec87dadb21865b4d6698da6ca3e4dcb5c71ba Mon Sep 17 00:00:00 2001 From: Manish Dewangan Date: Thu, 5 May 2016 12:27:40 +0530 Subject: [PATCH] ASoC: msm: add support for packed 24 bit Changes to support packed 24 bit (SNDRV_PCM_FORMAT_S24_3LE). CRs-Fixed: 1011048 Change-Id: I5c49091d6bbff98ed8665446fffdba08446073cd Signed-off-by: Manish Dewangan --- sound/soc/msm/msm-dai-fe.c | 63 ++++++++++++++-------- sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c | 4 ++ sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c | 14 +++-- sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c | 17 ++++-- sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c | 40 +++++++++----- 5 files changed, 97 insertions(+), 41 deletions(-) diff --git a/sound/soc/msm/msm-dai-fe.c b/sound/soc/msm/msm-dai-fe.c index 36f4e8ab4b94..e98e31c77e7a 100644 --- a/sound/soc/msm/msm-dai-fe.c +++ b/sound/soc/msm/msm-dai-fe.c @@ -93,7 +93,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000| SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -105,7 +106,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000| SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE| + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 4, .rate_min = 8000, @@ -122,7 +124,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000| SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -134,7 +137,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000| SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -203,7 +207,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 6, .rate_min = 8000, @@ -232,7 +237,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -250,7 +256,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -262,7 +269,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_48000| SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE| + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -279,7 +287,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -291,7 +300,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_48000| SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -308,7 +318,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -326,7 +337,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -338,7 +350,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_48000| SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2004,7 +2017,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000| SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2203,7 +2217,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2221,7 +2236,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2239,7 +2255,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2257,7 +2274,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2275,7 +2293,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2293,7 +2312,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2311,7 +2331,8 @@ static struct snd_soc_dai_driver msm_fe_dais[] = { .rates = (SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .channels_min = 1, .channels_max = 8, .rate_min = 8000, diff --git a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c index 2b3609f7230c..b0cd4a635968 100755 --- a/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c @@ -710,6 +710,10 @@ static int msm_compr_send_media_format_block(struct snd_compr_stream *cstream, bit_width = 24; sample_word_size = 32; break; + case SNDRV_PCM_FORMAT_S24_3LE: + bit_width = 24; + sample_word_size = 24; + break; case SNDRV_PCM_FORMAT_S16_LE: default: bit_width = 16; diff --git a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c index f773061921fd..615f7dc2e8d5 100644 --- a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c @@ -1151,6 +1151,7 @@ static int msm_dai_q6_spdif_hw_params(struct snd_pcm_substream *substream, dai_data->spdif_port.cfg.bit_width = 16; break; case SNDRV_PCM_FORMAT_S24_LE: + case SNDRV_PCM_FORMAT_S24_3LE: dai_data->spdif_port.cfg.bit_width = 24; break; default: @@ -1368,6 +1369,7 @@ static int msm_dai_q6_cdc_hw_params(struct snd_pcm_hw_params *params, dai_data->port_config.i2s.bit_width = 16; break; case SNDRV_PCM_FORMAT_S24_LE: + case SNDRV_PCM_FORMAT_S24_3LE: dai_data->port_config.i2s.bit_width = 24; break; default: @@ -1447,6 +1449,7 @@ static int msm_dai_q6_slim_bus_hw_params(struct snd_pcm_hw_params *params, dai_data->port_config.slim_sch.bit_width = 16; break; case SNDRV_PCM_FORMAT_S24_LE: + case SNDRV_PCM_FORMAT_S24_3LE: dai_data->port_config.slim_sch.bit_width = 24; break; case SNDRV_PCM_FORMAT_S32_LE: @@ -2799,7 +2802,8 @@ static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = { SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE, + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE, .channels_min = 1, .channels_max = 8, .rate_min = 8000, @@ -2818,7 +2822,8 @@ static struct snd_soc_dai_driver msm_dai_q6_slimbus_tx_dai[] = { SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE, + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE, .channels_min = 1, .channels_max = 2, .rate_min = 8000, @@ -3324,6 +3329,7 @@ static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream, dai_data->bitwidth = 16; break; case SNDRV_PCM_FORMAT_S24_LE: + case SNDRV_PCM_FORMAT_S24_3LE: dai_data->port_config.i2s.bit_width = 24; dai_data->bitwidth = 24; break; @@ -3475,7 +3481,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_dai[] = { .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE, + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE, .rate_min = 8000, .rate_max = 48000, }, @@ -5567,6 +5574,7 @@ static int msm_dai_q6_tdm_hw_params(struct snd_pcm_substream *substream, dai_data->bitwidth = 16; break; case SNDRV_PCM_FORMAT_S24_LE: + case SNDRV_PCM_FORMAT_S24_3LE: dai_data->bitwidth = 24; break; case SNDRV_PCM_FORMAT_S32_LE: diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c index 7dfa5044ab56..cf40f07a9f23 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c @@ -65,7 +65,8 @@ static struct snd_pcm_hardware msm_pcm_hardware_capture = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .rates = SNDRV_PCM_RATE_8000_48000, .rate_min = 8000, .rate_max = 48000, @@ -87,7 +88,8 @@ static struct snd_pcm_hardware msm_pcm_hardware_playback = { SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), .formats = (SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE), + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S24_3LE), .rates = SNDRV_PCM_RATE_8000_192000, .rate_min = 8000, .rate_max = 192000, @@ -314,6 +316,10 @@ static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream) bits_per_sample = 24; sample_word_size = 32; break; + case SNDRV_PCM_FORMAT_S24_3LE: + bits_per_sample = 24; + sample_word_size = 24; + break; case SNDRV_PCM_FORMAT_S16_LE: default: bits_per_sample = 16; @@ -392,7 +398,8 @@ static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) pr_debug("%s:perf_mode=%d periods=%d\n", __func__, pdata->perf_mode, runtime->periods); params = &soc_prtd->dpcm[substream->stream].hw_params; - if (params_format(params) == SNDRV_PCM_FORMAT_S24_LE) + if ((params_format(params) == SNDRV_PCM_FORMAT_S24_LE) || + (params_format(params) == SNDRV_PCM_FORMAT_S24_3LE)) bits_per_sample = 24; /* ULL mode is not supported in capture path */ @@ -455,6 +462,10 @@ static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) bits_per_sample = 24; sample_word_size = 32; break; + case SNDRV_PCM_FORMAT_S24_3LE: + bits_per_sample = 24; + sample_word_size = 24; + break; case SNDRV_PCM_FORMAT_S16_LE: default: bits_per_sample = 16; diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c index f5a99e78ee8c..5c047eb02c4b 100644 --- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c @@ -104,6 +104,22 @@ static struct msm_pcm_route_bdai_pp_params static int msm_routing_send_device_pp_params(int port_id, int copp_idx); +static int msm_routing_get_bit_width(unsigned int format) +{ + int bit_width; + + switch (format) { + case SNDRV_PCM_FORMAT_S24_LE: + case SNDRV_PCM_FORMAT_S24_3LE: + bit_width = 24; + break; + case SNDRV_PCM_FORMAT_S16_LE: + default: + bit_width = 16; + } + return bit_width; +} + static bool msm_is_fractional_resample_needed(int input_sr, int output_sr) { bool rc = false; @@ -769,11 +785,8 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode, int app_type, app_type_idx, copp_idx, acdb_dev_id; channels = msm_bedais[i].channel; - if (msm_bedais[i].format == SNDRV_PCM_FORMAT_S16_LE) - bit_width = 16; - else if (msm_bedais[i].format == - SNDRV_PCM_FORMAT_S24_LE) - bit_width = 24; + bit_width = msm_routing_get_bit_width( + msm_bedais[i].format); app_type = (stream_type == SNDRV_PCM_STREAM_PLAYBACK) ? fe_dai_app_type_cfg[fe_id].app_type : 0; if (app_type) { @@ -921,11 +934,9 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode, channels = msm_bedais[i].channel; msm_bedais[i].compr_passthr_mode = LEGACY_PCM; - if (msm_bedais[i].format == SNDRV_PCM_FORMAT_S16_LE) - bits_per_sample = 16; - else if (msm_bedais[i].format == - SNDRV_PCM_FORMAT_S24_LE) - bits_per_sample = 24; + + bits_per_sample = msm_routing_get_bit_width( + msm_bedais[i].format); app_type = (stream_type == SNDRV_PCM_STREAM_PLAYBACK) ? fe_dai_app_type_cfg[fedai_id].app_type : 0; @@ -1145,8 +1156,9 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) fdai->event_info.priv_data); fdai->be_srate = 0; /* might not need it */ } - if (msm_bedais[reg].format == SNDRV_PCM_FORMAT_S24_LE) - bits_per_sample = 24; + + bits_per_sample = msm_routing_get_bit_width( + msm_bedais[reg].format); app_type = (session_type == SESSION_TYPE_RX) ? fe_dai_app_type_cfg[val].app_type : 0; @@ -9562,8 +9574,8 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream) fdai->event_info.priv_data); fdai->be_srate = 0; /* might not need it */ } - if (bedai->format == SNDRV_PCM_FORMAT_S24_LE) - bits_per_sample = 24; + bits_per_sample = msm_routing_get_bit_width( + bedai->format); app_type = playback ? fe_dai_app_type_cfg[i].app_type : 0;