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

Commit b2ae9111 authored by Alexy Joseph's avatar Alexy Joseph
Browse files

ASoC: msm: qdsp6v2: Add support for setting channel map per mask



Add api to enable setting the input stream's channel map based on
its channel mask

Change-Id: I19cff5bf8aed9d35b3d2e6a65e4ab37ad627dc40
Signed-off-by: default avatarAlexy Joseph <alexyj@codeaurora.org>
parent 59857935
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -350,7 +350,8 @@ int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,

int q6asm_media_format_block_pcm_format_support_v2(struct audio_client *ac,
				uint32_t rate, uint32_t channels,
				uint16_t bits_per_sample, int stream_id);
				uint16_t bits_per_sample, int stream_id,
				bool use_default_chmap, char *channel_map);

int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
			uint32_t rate, uint32_t channels,
+5 −1
Original line number Diff line number Diff line
@@ -590,6 +590,8 @@ static int msm_compr_send_media_format_block(struct snd_compr_stream *cstream,
	struct asm_flac_cfg flac_cfg;
	int ret = 0;
	uint16_t bit_width = 16;
	bool use_default_chmap = true;
	char *chmap = NULL;

	switch (prtd->codec) {
	case FORMAT_LINEAR_PCM:
@@ -600,7 +602,9 @@ static int msm_compr_send_media_format_block(struct snd_compr_stream *cstream,
							prtd->audio_client,
							prtd->sample_rate,
							prtd->num_channels,
							bit_width, stream_id);
							bit_width, stream_id,
							use_default_chmap,
							chmap);
		if (ret < 0)
			pr_err("%s: CMD Format block failed\n", __func__);

+24 −9
Original line number Diff line number Diff line
@@ -2874,7 +2874,6 @@ static int q6asm_map_channels(u8 *channel_mapping, uint32_t channels)
		return -EINVAL;
	}
	return 0;

}

int q6asm_enable_sbrps(struct audio_client *ac,
@@ -3200,7 +3199,8 @@ fail_cmd:

static int __q6asm_media_format_block_pcm(struct audio_client *ac,
				uint32_t rate, uint32_t channels,
				uint16_t bits_per_sample, int stream_id)
				uint16_t bits_per_sample, int stream_id,
				bool use_default_chmap, char *channel_map)
{
	struct asm_multi_channel_pcm_fmt_blk_v2 fmt;
	u8 *channel_mapping;
@@ -3235,10 +3235,16 @@ static int __q6asm_media_format_block_pcm(struct audio_client *ac,

	memset(channel_mapping, 0, PCM_FORMAT_MAX_NUM_CHANNEL);

	if (use_default_chmap) {
		if (q6asm_map_channels(channel_mapping, channels)) {
		pr_err("%s: map channels failed %d\n", __func__, channels);
			pr_err("%s: map channels failed %d\n",
				__func__, channels);
			return -EINVAL;
		}
	} else {
		memcpy(channel_mapping, channel_map,
			 PCM_FORMAT_MAX_NUM_CHANNEL);
	}

	rc = apr_send_pkt(ac->apr, (uint32_t *) &fmt);
	if (rc < 0) {
@@ -3265,7 +3271,8 @@ int q6asm_media_format_block_pcm(struct audio_client *ac,
				uint32_t rate, uint32_t channels)
{
	return __q6asm_media_format_block_pcm(ac, rate,
				channels, 16, ac->stream_id);
				channels, 16, ac->stream_id,
				true, NULL);
}

int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,
@@ -3273,15 +3280,23 @@ int q6asm_media_format_block_pcm_format_support(struct audio_client *ac,
				uint16_t bits_per_sample)
{
	return __q6asm_media_format_block_pcm(ac, rate,
				channels, bits_per_sample, ac->stream_id);
				channels, bits_per_sample, ac->stream_id,
				true, NULL);
}

int q6asm_media_format_block_pcm_format_support_v2(struct audio_client *ac,
				uint32_t rate, uint32_t channels,
				uint16_t bits_per_sample, int stream_id)
				uint16_t bits_per_sample, int stream_id,
				bool use_default_chmap, char *channel_map)
{
	if (!use_default_chmap && (channel_map == NULL)) {
		pr_err("%s: No valid chan map and can't use default\n",
			__func__);
		return -EINVAL;
	}
	return __q6asm_media_format_block_pcm(ac, rate,
				channels, bits_per_sample, stream_id);
				channels, bits_per_sample, stream_id,
				use_default_chmap, channel_map);
}

static int __q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,