Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57777f2d authored by Manish Dewangan's avatar Manish Dewangan
Browse files

ASoC: msm8x16-wcd: 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: default avatarManish Dewangan <manish@codeaurora.org>
parent d695054d
Loading
Loading
Loading
Loading
+44 −22
Original line number Diff line number Diff line
@@ -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,
@@ -220,7 +225,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,
@@ -232,7 +238,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 +257,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 +270,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 +288,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 +301,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 +319,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 +338,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 +351,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,
@@ -1977,7 +1991,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,
@@ -2176,7 +2191,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,
@@ -2194,7 +2210,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,
@@ -2212,7 +2229,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,
@@ -2230,7 +2248,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,
@@ -2248,7 +2267,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,
@@ -2266,7 +2286,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,
@@ -2284,7 +2305,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,
+4 −0
Original line number Diff line number Diff line
@@ -703,6 +703,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;
+11 −3
Original line number Diff line number Diff line
@@ -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:
@@ -2602,7 +2605,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,
@@ -2621,7 +2625,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,
@@ -3086,6 +3091,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;
@@ -3238,7 +3244,8 @@ static struct snd_soc_dai_driver msm_dai_q6_mi2s_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,
			.rate_min =     8000,
			.rate_max =     192000,
		},
@@ -5306,6 +5313,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:
+14 −3
Original line number Diff line number Diff line
@@ -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,
@@ -310,6 +312,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;
@@ -388,7 +394,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 */
@@ -451,6 +458,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;
+26 −14
Original line number Diff line number Diff line
@@ -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;
@@ -763,11 +779,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) {
@@ -915,11 +928,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;
@@ -1139,8 +1150,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;
@@ -8978,8 +8990,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;