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

Commit e0d44204 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm: remove pcm_i2S_sel_vt_address from machine driver"

parents 13c086dc 49e9a408
Loading
Loading
Loading
Loading
+1 −163
Original line number Original line Diff line number Diff line
@@ -116,19 +116,6 @@ enum {
	AUX_PCM_MAX,
	AUX_PCM_MAX,
};
};


enum {
	PCM_I2S_SEL_PRIM = 0,
	PCM_I2S_SEL_SEC,
	PCM_I2S_SEL_TERT,
	PCM_I2S_SEL_QUAT,
	PCM_I2S_SEL_MAX,
};

struct mi2s_aux_pcm_common_conf {
	struct mutex lock;
	void *pcm_i2s_sel_vt_addr;
};

struct mi2s_conf {
struct mi2s_conf {
	struct mutex lock;
	struct mutex lock;
	u32 ref_cnt;
	u32 ref_cnt;
@@ -142,11 +129,6 @@ static u32 mi2s_ebit_clk[MI2S_MAX] = {
	Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT
	Q6AFE_LPASS_CLK_ID_QUAD_MI2S_EBIT
};
};


struct auxpcm_conf {
	struct mutex lock;
	u32 ref_cnt;
};

struct dev_config {
struct dev_config {
	u32 sample_rate;
	u32 sample_rate;
	u32 bit_format;
	u32 bit_format;
@@ -584,9 +566,7 @@ static struct afe_clk_set mi2s_clk[MI2S_MAX] = {
	}
	}
};
};


static struct mi2s_aux_pcm_common_conf mi2s_auxpcm_conf[PCM_I2S_SEL_MAX];
static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
static struct mi2s_conf mi2s_intf_conf[MI2S_MAX];
static struct auxpcm_conf auxpcm_intf_conf[AUX_PCM_MAX];


static int slim_get_sample_rate_val(int sample_rate)
static int slim_get_sample_rate_val(int sample_rate)
{
{
@@ -4116,83 +4096,6 @@ static int msm_wcn_hw_params(struct snd_pcm_substream *substream,
	return ret;
	return ret;
}
}


static int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream)
{
	int ret = 0;
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
	int index = cpu_dai->id - 1;

	dev_dbg(rtd->card->dev,
		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
		__func__, substream->name, substream->stream,
		cpu_dai->name, cpu_dai->id);

	if (index < PRIM_AUX_PCM || index > QUAT_AUX_PCM) {
		ret = -EINVAL;
		dev_err(rtd->card->dev,
			"%s: CPU DAI id (%d) out of range\n",
			__func__, cpu_dai->id);
		goto err;
	}

	mutex_lock(&auxpcm_intf_conf[index].lock);
	if (++auxpcm_intf_conf[index].ref_cnt == 1) {
		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {
			mutex_lock(&mi2s_auxpcm_conf[index].lock);
			iowrite32(1,
				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
		} else {
			dev_err(rtd->card->dev,
				"%s lpaif_tert_muxsel_virt_addr is NULL\n",
				__func__);
			ret = -EINVAL;
		}
	}
	if (ret < 0)
		auxpcm_intf_conf[index].ref_cnt--;

	mutex_unlock(&auxpcm_intf_conf[index].lock);

err:
	return ret;
}

static void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	int index = rtd->cpu_dai->id - 1;

	dev_dbg(rtd->card->dev,
		"%s: substream = %s  stream = %d, dai name %s, dai ID %d\n",
		__func__,
		substream->name, substream->stream,
		rtd->cpu_dai->name, rtd->cpu_dai->id);

	if (index < PRIM_AUX_PCM || index > QUAT_AUX_PCM) {
		dev_err(rtd->card->dev,
			"%s: CPU DAI id (%d) out of range\n",
			__func__, rtd->cpu_dai->id);
		return;
	}

	mutex_lock(&auxpcm_intf_conf[index].lock);
	if (--auxpcm_intf_conf[index].ref_cnt == 0) {
		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {
			mutex_lock(&mi2s_auxpcm_conf[index].lock);
			iowrite32(0,
				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
		} else {
			dev_err(rtd->card->dev,
				"%s lpaif_tert_muxsel_virt_addr is NULL\n",
				__func__);
		}
	}
	mutex_unlock(&auxpcm_intf_conf[index].lock);
}

static int msm_get_port_id(int be_id)
static int msm_get_port_id(int be_id)
{
{
	int afe_port_id;
	int afe_port_id;
@@ -4723,18 +4626,7 @@ static int msm_mi2s_snd_startup(struct snd_pcm_substream *substream)
				__func__, ret);
				__func__, ret);
			goto clean_up;
			goto clean_up;
		}
		}
		if (mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr != NULL) {

			mutex_lock(&mi2s_auxpcm_conf[index].lock);
			iowrite32(0,
				mi2s_auxpcm_conf[index].pcm_i2s_sel_vt_addr);
			mutex_unlock(&mi2s_auxpcm_conf[index].lock);
		} else {
			dev_err(rtd->card->dev,
				"%s lpaif_muxsel_virt_addr is NULL for dai %d\n",
				__func__, index);
			ret = -EINVAL;
			goto clk_off;
		}
		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",
@@ -4792,11 +4684,6 @@ static struct snd_soc_ops msm_mi2s_be_ops = {
	.shutdown = msm_mi2s_snd_shutdown,
	.shutdown = msm_mi2s_snd_shutdown,
};
};


static struct snd_soc_ops msm_aux_pcm_be_ops = {
	.startup = msm_aux_pcm_snd_startup,
	.shutdown = msm_aux_pcm_snd_shutdown,
};

static struct snd_soc_ops msm_be_ops = {
static struct snd_soc_ops msm_be_ops = {
	.hw_params = msm_snd_hw_params,
	.hw_params = msm_snd_hw_params,
};
};
@@ -6085,7 +5972,6 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_pmdown_time = 1,
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
		.ignore_suspend = 1,
		.ops = &msm_aux_pcm_be_ops,
	},
	},
	{
	{
		.name = LPASS_BE_AUXPCM_TX,
		.name = LPASS_BE_AUXPCM_TX,
@@ -6100,7 +5986,6 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_pmdown_time = 1,
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
		.ignore_suspend = 1,
		.ops = &msm_aux_pcm_be_ops,
	},
	},
	/* Secondary AUX PCM Backend DAI Links */
	/* Secondary AUX PCM Backend DAI Links */
	{
	{
@@ -6116,7 +6001,6 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_pmdown_time = 1,
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
		.ignore_suspend = 1,
		.ops = &msm_aux_pcm_be_ops,
	},
	},
	{
	{
		.name = LPASS_BE_SEC_AUXPCM_TX,
		.name = LPASS_BE_SEC_AUXPCM_TX,
@@ -6131,7 +6015,6 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_suspend = 1,
		.ignore_suspend = 1,
		.ignore_pmdown_time = 1,
		.ignore_pmdown_time = 1,
		.ops = &msm_aux_pcm_be_ops,
	},
	},
	/* Tertiary AUX PCM Backend DAI Links */
	/* Tertiary AUX PCM Backend DAI Links */
	{
	{
@@ -6147,7 +6030,6 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_pmdown_time = 1,
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
		.ignore_suspend = 1,
		.ops = &msm_aux_pcm_be_ops,
	},
	},
	{
	{
		.name = LPASS_BE_TERT_AUXPCM_TX,
		.name = LPASS_BE_TERT_AUXPCM_TX,
@@ -6162,7 +6044,6 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_suspend = 1,
		.ignore_suspend = 1,
		.ignore_pmdown_time = 1,
		.ignore_pmdown_time = 1,
		.ops = &msm_aux_pcm_be_ops,
	},
	},
	/* Quaternary AUX PCM Backend DAI Links */
	/* Quaternary AUX PCM Backend DAI Links */
	{
	{
@@ -6178,7 +6059,6 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_pmdown_time = 1,
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
		.ignore_suspend = 1,
		.ops = &msm_aux_pcm_be_ops,
	},
	},
	{
	{
		.name = LPASS_BE_QUAT_AUXPCM_TX,
		.name = LPASS_BE_QUAT_AUXPCM_TX,
@@ -6193,7 +6073,6 @@ static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_suspend = 1,
		.ignore_suspend = 1,
		.ignore_pmdown_time = 1,
		.ignore_pmdown_time = 1,
		.ops = &msm_aux_pcm_be_ops,
	},
	},
};
};


@@ -6823,41 +6702,15 @@ static int msm_init_wsa_dev(struct platform_device *pdev,


static void msm_i2s_auxpcm_init(struct platform_device *pdev)
static void msm_i2s_auxpcm_init(struct platform_device *pdev)
{
{
	struct resource *muxsel;
	int count;
	int count;
	u32 mi2s_master_slave[MI2S_MAX];
	u32 mi2s_master_slave[MI2S_MAX];
	int ret;
	int ret;
	char *str[PCM_I2S_SEL_MAX] = {
		"lpaif_pri_mode_muxsel",
		"lpaif_sec_mode_muxsel",
		"lpaif_tert_mode_muxsel",
		"lpaif_quat_mode_muxsel"
	};


	for (count = 0; count < MI2S_MAX; count++) {
	for (count = 0; count < MI2S_MAX; count++) {
		mutex_init(&mi2s_intf_conf[count].lock);
		mutex_init(&mi2s_intf_conf[count].lock);
		mi2s_intf_conf[count].ref_cnt = 0;
		mi2s_intf_conf[count].ref_cnt = 0;
	}
	}


	for (count = 0; count < AUX_PCM_MAX; count++) {
		mutex_init(&auxpcm_intf_conf[count].lock);
		auxpcm_intf_conf[count].ref_cnt = 0;
	}

	for (count = 0; count < PCM_I2S_SEL_MAX; count++) {
		mutex_init(&mi2s_auxpcm_conf[count].lock);
		mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr = NULL;
	}

	for (count = 0; count < PCM_I2S_SEL_MAX; count++) {
		muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
						      str[count]);
		if (muxsel) {
			mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr
				= ioremap(muxsel->start, resource_size(muxsel));
		}
	}

	ret = of_property_read_u32_array(pdev->dev.of_node,
	ret = of_property_read_u32_array(pdev->dev.of_node,
			"qcom,msm-mi2s-master",
			"qcom,msm-mi2s-master",
			mi2s_master_slave, MI2S_MAX);
			mi2s_master_slave, MI2S_MAX);
@@ -6876,21 +6729,6 @@ static void msm_i2s_auxpcm_deinit(void)
{
{
	int count;
	int count;


	for (count = 0; count < PCM_I2S_SEL_MAX; count++) {
		if (mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr !=
		    NULL) {
			iounmap(
			mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr);
			mi2s_auxpcm_conf[count].pcm_i2s_sel_vt_addr = NULL;
		}
		mutex_destroy(&mi2s_auxpcm_conf[count].lock);
	}

	for (count = 0; count < AUX_PCM_MAX; count++) {
		mutex_destroy(&auxpcm_intf_conf[count].lock);
		auxpcm_intf_conf[count].ref_cnt = 0;
	}

	for (count = 0; count < MI2S_MAX; count++) {
	for (count = 0; count < MI2S_MAX; count++) {
		mutex_destroy(&mi2s_intf_conf[count].lock);
		mutex_destroy(&mi2s_intf_conf[count].lock);
		mi2s_intf_conf[count].ref_cnt = 0;
		mi2s_intf_conf[count].ref_cnt = 0;