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

Commit 18ff677c authored by Ashish Jain's avatar Ashish Jain Committed by Surendar karka
Browse files

ASoc: msm: Enable support for 32 bit format and 384Khz



Add support for 32 bit data format (SNDRV_PCM_FORMAT_S32_LE)
and sampling rate of 384Khz. Also update platform drivers
to use latest version of pcm media format command
ASM_MEDIA_FMT_MULTI_CHANNEL_PCM_V4.

CRs-Fixed: 2129947
Change-Id: I6b7ea860a398a7e4dd5f7e23ac3906ff0c6f2b3e
Signed-off-by: default avatarAshish Jain <ashishj@codeaurora.org>
parent b2dba212
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -822,6 +822,10 @@ static int msm_compr_send_media_format_block(struct snd_compr_stream *cstream,
		}

		switch (prtd->codec_param.codec.format) {
		case SNDRV_PCM_FORMAT_S32_LE:
			bit_width = 32;
			sample_word_size = 32;
			break;
		case SNDRV_PCM_FORMAT_S24_LE:
			bit_width = 24;
			sample_word_size = 32;
@@ -836,14 +840,16 @@ static int msm_compr_send_media_format_block(struct snd_compr_stream *cstream,
			sample_word_size = 16;
			break;
		}
		ret = q6asm_media_format_block_pcm_format_support_v3(
		ret = q6asm_media_format_block_pcm_format_support_v4(
							prtd->audio_client,
							prtd->sample_rate,
							prtd->num_channels,
							bit_width, stream_id,
							use_default_chmap,
							chmap,
							sample_word_size);
							sample_word_size,
							ASM_LITTLE_ENDIAN,
							DEFAULT_QF);
		if (ret < 0)
			pr_err("%s: CMD Format block failed\n", __func__);

@@ -1117,7 +1123,7 @@ static int msm_compr_configure_dsp_for_playback
	} else {
		pr_debug("%s: stream_id %d bits_per_sample %d\n",
				__func__, ac->stream_id, bits_per_sample);
		ret = q6asm_stream_open_write_v3(ac,
		ret = q6asm_stream_open_write_v4(ac,
				prtd->codec, bits_per_sample,
				ac->stream_id,
				prtd->gapless_state.use_dsp_gapless_mode);
@@ -2332,7 +2338,7 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)

		pr_debug("%s: open_write stream_id %d bits_per_sample %d",
				__func__, stream_id, bits_per_sample);
		rc = q6asm_stream_open_write_v3(prtd->audio_client,
		rc = q6asm_stream_open_write_v4(prtd->audio_client,
				prtd->codec, bits_per_sample,
				stream_id,
				prtd->gapless_state.use_dsp_gapless_mode);
+28 −13
Original line number Diff line number Diff line
@@ -68,10 +68,11 @@ static struct snd_pcm_hardware msm_pcm_hardware_capture = {
				SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
	.formats =              (SNDRV_PCM_FMTBIT_S16_LE |
				SNDRV_PCM_FMTBIT_S24_LE |
				SNDRV_PCM_FMTBIT_S24_3LE),
	.rates =                SNDRV_PCM_RATE_8000_48000,
				SNDRV_PCM_FMTBIT_S24_3LE |
				SNDRV_PCM_FMTBIT_S32_LE),
	.rates =                SNDRV_PCM_RATE_8000_384000,
	.rate_min =             8000,
	.rate_max =             48000,
	.rate_max =             384000,
	.channels_min =         1,
	.channels_max =         4,
	.buffer_bytes_max =     CAPTURE_MAX_NUM_PERIODS *
@@ -91,10 +92,11 @@ static struct snd_pcm_hardware msm_pcm_hardware_playback = {
				SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
	.formats =              (SNDRV_PCM_FMTBIT_S16_LE |
				SNDRV_PCM_FMTBIT_S24_LE |
				SNDRV_PCM_FMTBIT_S24_3LE),
	.rates =                SNDRV_PCM_RATE_8000_192000,
				SNDRV_PCM_FMTBIT_S24_3LE |
				SNDRV_PCM_FMTBIT_S32_LE),
	.rates =                SNDRV_PCM_RATE_8000_384000,
	.rate_min =             8000,
	.rate_max =             192000,
	.rate_max =             384000,
	.channels_min =         1,
	.channels_max =         8,
	.buffer_bytes_max =     PLAYBACK_MAX_NUM_PERIODS *
@@ -109,7 +111,7 @@ static struct snd_pcm_hardware msm_pcm_hardware_playback = {
/* Conventional and unconventional sample rate supported */
static unsigned int supported_sample_rates[] = {
	8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
	88200, 96000, 176400, 192000
	88200, 96000, 176400, 192000, 384000
};

static struct snd_pcm_hw_constraint_list constraints_sample_rates = {
@@ -321,6 +323,10 @@ static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream)
	pr_debug("%s: perf: %x\n", __func__, prtd->audio_client->perf_mode);

	switch (params_format(params)) {
	case SNDRV_PCM_FORMAT_S32_LE:
		bits_per_sample = 32;
		sample_word_size = 32;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
		bits_per_sample = 24;
		sample_word_size = 32;
@@ -336,7 +342,7 @@ static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream)
		break;
	}

	ret = q6asm_open_write_v3(prtd->audio_client,
	ret = q6asm_open_write_v4(prtd->audio_client,
				  FORMAT_LINEAR_PCM, bits_per_sample);

	if (ret < 0) {
@@ -361,11 +367,12 @@ static int msm_pcm_playback_prepare(struct snd_pcm_substream *substream)
		return ret;
	}

	ret = q6asm_media_format_block_multi_ch_pcm_v3(
	ret = q6asm_media_format_block_multi_ch_pcm_v4(
				prtd->audio_client, runtime->rate,
				runtime->channels, !prtd->set_channel_map,
				prtd->channel_map, bits_per_sample,
				sample_word_size);
				sample_word_size, ASM_LITTLE_ENDIAN,
				DEFAULT_QF);
	if (ret < 0)
		pr_info("%s: CMD Format block failed\n", __func__);

@@ -410,6 +417,8 @@ static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
		if ((params_format(params) == SNDRV_PCM_FORMAT_S24_LE) ||
			(params_format(params) == SNDRV_PCM_FORMAT_S24_3LE))
			bits_per_sample = 24;
		else if (params_format(params) == SNDRV_PCM_FORMAT_S32_LE)
			bits_per_sample = 32;

		/* ULL mode is not supported in capture path */
		if (pdata->perf_mode_set == LEGACY_PCM_MODE)
@@ -421,7 +430,7 @@ static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
				__func__, params_channels(params),
				prtd->audio_client->perf_mode);

		ret = q6asm_open_read_v3(prtd->audio_client, FORMAT_LINEAR_PCM,
		ret = q6asm_open_read_v4(prtd->audio_client, FORMAT_LINEAR_PCM,
				bits_per_sample);
		if (ret < 0) {
			pr_err("%s: q6asm_open_read failed\n", __func__);
@@ -467,6 +476,10 @@ static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
		return 0;

	switch (runtime->format) {
	case SNDRV_PCM_FORMAT_S32_LE:
		bits_per_sample = 32;
		sample_word_size = 32;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
		bits_per_sample = 24;
		sample_word_size = 32;
@@ -485,11 +498,13 @@ static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream)
	pr_debug("%s: Samp_rate = %d Channel = %d bit width = %d, word size = %d\n",
			__func__, prtd->samp_rate, prtd->channel_mode,
			bits_per_sample, sample_word_size);
	ret = q6asm_enc_cfg_blk_pcm_format_support_v3(prtd->audio_client,
	ret = q6asm_enc_cfg_blk_pcm_format_support_v4(prtd->audio_client,
						      prtd->samp_rate,
						      prtd->channel_mode,
						      bits_per_sample,
						      sample_word_size);
						      sample_word_size,
						      ASM_LITTLE_ENDIAN,
						      DEFAULT_QF);
	if (ret < 0)
		pr_debug("%s: cmd cfg pcm was block failed", __func__);

+2 −2
Original line number Diff line number Diff line
@@ -59,11 +59,11 @@ struct msm_audio_in_frame_info {

#define PLAYBACK_MIN_NUM_PERIODS    2
#define PLAYBACK_MAX_NUM_PERIODS    8
#define PLAYBACK_MAX_PERIOD_SIZE    61440
#define PLAYBACK_MAX_PERIOD_SIZE    122880
#define PLAYBACK_MIN_PERIOD_SIZE    128
#define CAPTURE_MIN_NUM_PERIODS     2
#define CAPTURE_MAX_NUM_PERIODS     8
#define CAPTURE_MAX_PERIOD_SIZE     61440
#define CAPTURE_MAX_PERIOD_SIZE     122880
#define CAPTURE_MIN_PERIOD_SIZE     320

struct msm_audio {