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

Commit 3daed8c7 authored by Xiaoyu Ye's avatar Xiaoyu Ye Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: msm: add support for MI2S slave mode on SDM845



MI2S slave mode requires both bit format and clock mode to
be modified. Current SDM845 machine driver only modifies bit
format. Add support to modify clock ID for MI2S in slave mode
on SDM845.

Change-Id: I952705b062f4556e33ad76f5c0a69d18ed5cdd1a
Signed-off-by: default avatarXiaoyu Ye <benyxy@codeaurora.org>
parent 509d2944
Loading
Loading
Loading
Loading
+12 −6
Original line number Original line Diff line number Diff line
@@ -134,6 +134,13 @@ struct mi2s_conf {
	u32 msm_is_mi2s_master;
	u32 msm_is_mi2s_master;
};
};


static u32 mi2s_ebit_clk[MI2S_MAX] = {
	Q6AFE_LPASS_CLK_ID_PRI_MI2S_EBIT,
	Q6AFE_LPASS_CLK_ID_SEC_MI2S_EBIT,
	Q6AFE_LPASS_CLK_ID_TER_MI2S_EBIT,
	Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT
};

struct auxpcm_conf {
struct auxpcm_conf {
	struct mutex lock;
	struct mutex lock;
	u32 ref_cnt;
	u32 ref_cnt;
@@ -4176,9 +4183,6 @@ static void update_mi2s_clk_val(int dai_id, int stream)
		mi2s_clk[dai_id].clk_freq_in_hz =
		mi2s_clk[dai_id].clk_freq_in_hz =
		    mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
		    mi2s_tx_cfg[dai_id].sample_rate * 2 * bit_per_sample;
	}
	}

	if (!mi2s_intf_conf[dai_id].msm_is_mi2s_master)
		mi2s_clk[dai_id].clk_freq_in_hz = 0;
}
}


static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
static int msm_mi2s_set_sclk(struct snd_pcm_substream *substream, bool enable)
@@ -4529,6 +4533,11 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
	 */
	 */
	mutex_lock(&mi2s_intf_conf[index].lock);
	mutex_lock(&mi2s_intf_conf[index].lock);
	if (++mi2s_intf_conf[index].ref_cnt == 1) {
	if (++mi2s_intf_conf[index].ref_cnt == 1) {
		/* Check if msm needs to provide the clock to the interface */
		if (!mi2s_intf_conf[index].msm_is_mi2s_master) {
			mi2s_clk[index].clk_id = mi2s_ebit_clk[index];
			fmt = SND_SOC_DAIFMT_CBM_CFM;
		}
		ret = msm_mi2s_set_sclk(substream, true);
		ret = msm_mi2s_set_sclk(substream, true);
		if (ret < 0) {
		if (ret < 0) {
			dev_err(rtd->card->dev,
			dev_err(rtd->card->dev,
@@ -4548,9 +4557,6 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
			ret = -EINVAL;
			ret = -EINVAL;
			goto clk_off;
			goto clk_off;
		}
		}
		/* Check if msm needs to provide the clock to the interface */
		if (!mi2s_intf_conf[index].msm_is_mi2s_master)
			fmt = SND_SOC_DAIFMT_CBM_CFM;
		ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
		ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
		if (ret < 0) {
		if (ret < 0) {
			pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",
			pr_err("%s: set fmt cpu dai failed for MI2S (%d), err:%d\n",