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

Commit 8976fa2c authored by Rohit Kumar's avatar Rohit Kumar Committed by Laxminath Kasam
Browse files

ASoC: msm: Add support for INT5_MI2S vi feedback



Add VI feedback support for INT5_MI2S port.
Also, fix stream name of INT5_MI2S capture dai link.

CRs-Fixed: 1094763
Change-Id: I631f11b650d572b05f52f7c422fd4c134fcf676e
Signed-off-by: default avatarRohit Kumar <rohitkr@codeaurora.org>
parent ba9ce1c9
Loading
Loading
Loading
Loading
+66 −3
Original line number Diff line number Diff line
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -52,6 +52,11 @@ enum {
	ENC_FMT_APTX_HD = ASM_MEDIA_FMT_APTX_HD,
};

enum {
	SPKR_1,
	SPKR_2,
};

static const struct afe_clk_set lpass_clk_set_default = {
	AFE_API_VERSION_CLOCK_SET,
	Q6AFE_LPASS_CLK_ID_PRI_PCM_IBIT,
@@ -176,6 +181,7 @@ struct msm_dai_q6_dai_data {
	u16 afe_in_bitformat;
	struct afe_enc_config enc_config;
	union afe_port_config port_config;
	u16 vi_feed_mono;
};

struct msm_dai_q6_spdif_dai_data {
@@ -231,8 +237,14 @@ static const char *const mi2s_format[] = {
	"Compr-60958"
};

static const char *const mi2s_vi_feed_mono[] = {
	"Left",
	"Right",
};

static const struct soc_enum mi2s_config_enum[] = {
	SOC_ENUM_SINGLE_EXT(4, mi2s_format),
	SOC_ENUM_SINGLE_EXT(2, mi2s_vi_feed_mono),
};

static const char *const sb_format[] = {
@@ -3346,6 +3358,26 @@ static int msm_dai_q6_mi2s_format_get(struct snd_kcontrol *kcontrol,
	return 0;
}

static int msm_dai_q6_mi2s_vi_feed_mono_put(struct snd_kcontrol *kcontrol,
				      struct snd_ctl_elem_value *ucontrol)
{
	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
	int value = ucontrol->value.integer.value[0];

	dai_data->vi_feed_mono = value;
	pr_debug("%s: value = %d\n", __func__, value);
	return 0;
}

static int msm_dai_q6_mi2s_vi_feed_mono_get(struct snd_kcontrol *kcontrol,
				      struct snd_ctl_elem_value *ucontrol)
{
	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;

	ucontrol->value.integer.value[0] = dai_data->vi_feed_mono;
	return 0;
}

static const struct snd_kcontrol_new mi2s_config_controls[] = {
	SOC_ENUM_EXT("PRI MI2S RX Format", mi2s_config_enum[0],
		     msm_dai_q6_mi2s_format_get,
@@ -3380,6 +3412,15 @@ static const struct snd_kcontrol_new mi2s_config_controls[] = {
	SOC_ENUM_EXT("SENARY MI2S TX Format", mi2s_config_enum[0],
		     msm_dai_q6_mi2s_format_get,
		     msm_dai_q6_mi2s_format_put),
	SOC_ENUM_EXT("INT5 MI2S TX Format", mi2s_config_enum[0],
		     msm_dai_q6_mi2s_format_get,
		     msm_dai_q6_mi2s_format_put),
};

static const struct snd_kcontrol_new mi2s_vi_feed_controls[] = {
	SOC_ENUM_EXT("INT5 MI2S VI MONO", mi2s_config_enum[1],
		     msm_dai_q6_mi2s_vi_feed_mono_get,
		     msm_dai_q6_mi2s_vi_feed_mono_put),
};

static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
@@ -3391,6 +3432,7 @@ static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
	struct snd_kcontrol *kcontrol = NULL;
	int rc = 0;
	const struct snd_kcontrol_new *ctrl = NULL;
	const struct snd_kcontrol_new *vi_feed_ctrl = NULL;

	dai->id = mi2s_pdata->intf_id;

@@ -3433,6 +3475,8 @@ static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
			ctrl = &mi2s_config_controls[9];
		if (dai->id == MSM_SENARY_MI2S)
			ctrl = &mi2s_config_controls[10];
		if (dai->id == MSM_INT5_MI2S)
			ctrl = &mi2s_config_controls[11];
	}

	if (ctrl) {
@@ -3448,6 +3492,21 @@ static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
				__func__, dai->name);
		}
	}

	if (dai->id == MSM_INT5_MI2S)
		vi_feed_ctrl = &mi2s_vi_feed_controls[0];

	if (vi_feed_ctrl) {
		rc = snd_ctl_add(dai->component->card->snd_card,
				snd_ctl_new1(vi_feed_ctrl,
				&mi2s_dai_data->tx_dai.mi2s_dai_data));

		if (IS_ERR_VALUE(rc)) {
			dev_err(dai->dev, "%s: err add TX vi feed channel ctl DAI = %s\n",
				__func__, dai->name);
		}
	}

	rc = msm_dai_q6_dai_add_route(dai);
rtn:
	return rc;
@@ -3695,8 +3754,12 @@ static int msm_dai_q6_mi2s_hw_params(struct snd_pcm_substream *substream,
		case AFE_PORT_I2S_QUAD01:
		case AFE_PORT_I2S_6CHS:
		case AFE_PORT_I2S_8CHS:
			if (dai_data->vi_feed_mono == SPKR_1)
				dai_data->port_config.i2s.channel_mode =
							AFE_PORT_I2S_SD0;
			else
				dai_data->port_config.i2s.channel_mode =
							AFE_PORT_I2S_SD1;
			break;
		case AFE_PORT_I2S_QUAD23:
			dai_data->port_config.i2s.channel_mode =
+50 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -8386,6 +8386,14 @@ static const char * const mi2s_rx_vi_fb_tx_mux_text[] = {
	"ZERO", "SENARY_TX"
};
static const char * const int4_mi2s_rx_vi_fb_tx_mono_mux_text[] = {
	"ZERO", "INT5_MI2S_TX"
};
static const char * const int4_mi2s_rx_vi_fb_tx_stereo_mux_text[] = {
	"ZERO", "INT5_MI2S_TX"
};
static const int const slim0_rx_vi_fb_tx_lch_value[] = {
	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_SLIMBUS_4_TX
};
@@ -8398,6 +8406,14 @@ static const int const mi2s_rx_vi_fb_tx_value[] = {
	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_SENARY_MI2S_TX
};
static const int const int4_mi2s_rx_vi_fb_tx_mono_ch_value[] = {
	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_INT5_MI2S_TX
};
static const int const int4_mi2s_rx_vi_fb_tx_stereo_ch_value[] = {
	MSM_BACKEND_DAI_MAX, MSM_BACKEND_DAI_INT5_MI2S_TX
};
static const struct soc_enum slim0_rx_vi_fb_lch_mux_enum =
	SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_SLIMBUS_0_RX, 0, 0,
	ARRAY_SIZE(slim0_rx_vi_fb_tx_lch_mux_text),
@@ -8413,6 +8429,18 @@ static const struct soc_enum mi2s_rx_vi_fb_mux_enum =
	ARRAY_SIZE(mi2s_rx_vi_fb_tx_mux_text),
	mi2s_rx_vi_fb_tx_mux_text, mi2s_rx_vi_fb_tx_value);
static const struct soc_enum int4_mi2s_rx_vi_fb_mono_ch_mux_enum =
	SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_INT4_MI2S_RX, 0, 0,
	ARRAY_SIZE(int4_mi2s_rx_vi_fb_tx_mono_mux_text),
	int4_mi2s_rx_vi_fb_tx_mono_mux_text,
	int4_mi2s_rx_vi_fb_tx_mono_ch_value);
static const struct soc_enum int4_mi2s_rx_vi_fb_stereo_ch_mux_enum =
	SOC_VALUE_ENUM_DOUBLE(0, MSM_BACKEND_DAI_INT4_MI2S_RX, 0, 0,
	ARRAY_SIZE(int4_mi2s_rx_vi_fb_tx_stereo_mux_text),
	int4_mi2s_rx_vi_fb_tx_stereo_mux_text,
	int4_mi2s_rx_vi_fb_tx_stereo_ch_value);
static const struct snd_kcontrol_new slim0_rx_vi_fb_lch_mux =
	SOC_DAPM_ENUM_EXT("SLIM0_RX_VI_FB_LCH_MUX",
	slim0_rx_vi_fb_lch_mux_enum, spkr_prot_get_vi_lch_port,
@@ -8428,6 +8456,16 @@ static const struct snd_kcontrol_new mi2s_rx_vi_fb_mux =
	mi2s_rx_vi_fb_mux_enum, spkr_prot_get_vi_lch_port,
	spkr_prot_put_vi_lch_port);
static const struct snd_kcontrol_new int4_mi2s_rx_vi_fb_mono_ch_mux =
	SOC_DAPM_ENUM_EXT("INT4_MI2S_RX_VI_FB_MONO_CH_MUX",
	int4_mi2s_rx_vi_fb_mono_ch_mux_enum, spkr_prot_get_vi_lch_port,
	spkr_prot_put_vi_lch_port);
static const struct snd_kcontrol_new int4_mi2s_rx_vi_fb_stereo_ch_mux =
	SOC_DAPM_ENUM_EXT("INT4_MI2S_RX_VI_FB_STEREO_CH_MUX",
	int4_mi2s_rx_vi_fb_stereo_ch_mux_enum, spkr_prot_get_vi_rch_port,
	spkr_prot_put_vi_rch_port);
static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
	/* Frontend AIF */
	/* Widget name equals to Front-End DAI name<Need confirmation>,
@@ -8986,6 +9024,8 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
				0, 0, 0, 0),
	SND_SOC_DAPM_AIF_IN("SENARY_TX", "Senary_mi2s Capture",
				0, 0, 0, 0),
	SND_SOC_DAPM_AIF_IN("INT5_MI2S_TX", "INT5 MI2S Capture",
				0, 0, 0, 0),
	SND_SOC_DAPM_AIF_IN("SLIMBUS_5_TX", "Slimbus5 Capture", 0, 0, 0, 0),
	SND_SOC_DAPM_AIF_OUT("AUX_PCM_RX", "AUX PCM Playback", 0, 0, 0, 0),
@@ -9433,6 +9473,10 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
				&slim0_rx_vi_fb_rch_mux),
	SND_SOC_DAPM_MUX("PRI_MI2S_RX_VI_FB_MUX", SND_SOC_NOPM, 0, 0,
				&mi2s_rx_vi_fb_mux),
	SND_SOC_DAPM_MUX("INT4_MI2S_RX_VI_FB_MONO_CH_MUX", SND_SOC_NOPM, 0, 0,
				&int4_mi2s_rx_vi_fb_mono_ch_mux),
	SND_SOC_DAPM_MUX("INT4_MI2S_RX_VI_FB_STEREO_CH_MUX", SND_SOC_NOPM, 0, 0,
				&int4_mi2s_rx_vi_fb_stereo_ch_mux),
	SND_SOC_DAPM_MUX("VOC_EXT_EC MUX", SND_SOC_NOPM, 0, 0,
			 &voc_ext_ec_mux),
@@ -11439,6 +11483,7 @@ static const struct snd_soc_dapm_route intercon[] = {
	{"TERT_MI2S_TX", NULL, "BE_IN"},
	{"INT2_MI2S_TX", NULL, "BE_IN"},
	{"INT3_MI2S_TX", NULL, "BE_IN"},
	{"INT5_MI2S_TX", NULL, "BE_IN"},
	{"SEC_MI2S_TX", NULL, "BE_IN"},
	{"SENARY_MI2S_TX", NULL, "BE_IN" },
	{"SLIMBUS_0_TX", NULL, "BE_IN" },
@@ -11468,9 +11513,13 @@ static const struct snd_soc_dapm_route intercon[] = {
	{"SLIM0_RX_VI_FB_LCH_MUX", "SLIM4_TX", "SLIMBUS_4_TX"},
	{"SLIM0_RX_VI_FB_RCH_MUX", "SLIM4_TX", "SLIMBUS_4_TX"},
	{"PRI_MI2S_RX_VI_FB_MUX", "SENARY_TX", "SENARY_TX"},
	{"INT4_MI2S_RX_VI_FB_MONO_CH_MUX", "INT5_MI2S_TX", "INT5_MI2S_TX"},
	{"INT4_MI2S_RX_VI_FB_STEREO_CH_MUX", "INT5_MI2S_TX", "INT5_MI2S_TX"},
	{"SLIMBUS_0_RX", NULL, "SLIM0_RX_VI_FB_LCH_MUX"},
	{"SLIMBUS_0_RX", NULL, "SLIM0_RX_VI_FB_RCH_MUX"},
	{"PRI_MI2S_RX", NULL, "PRI_MI2S_RX_VI_FB_MUX"},
	{"INT4_MI2S_RX", NULL, "INT4_MI2S_RX_VI_FB_MONO_CH_MUX"},
	{"INT4_MI2S_RX", NULL, "INT4_MI2S_RX_VI_FB_STEREO_CH_MUX"},
	{"PRI_TDM_TX_0", NULL, "BE_IN"},
	{"SEC_TDM_TX_0", NULL, "BE_IN"},
	{"TERT_TDM_TX_0", NULL, "BE_IN"},
+2 −2
Original line number Diff line number Diff line
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -2247,7 +2247,7 @@ static struct snd_soc_dai_link msm_int_dai[] = {
	},
	{/* hw:x,35 */
		.name = LPASS_BE_INT5_MI2S_TX,
		.stream_name = "INT5_mi2s Capture",
		.stream_name = "INT5 MI2S Capture",
		.cpu_dai_name = "msm-dai-q6-mi2s.12",
		.platform_name = "msm-pcm-hostless",
		.codec_name = "msm_sdw_codec",