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

Commit 5a1700f5 authored by Bhalchandra Gajare's avatar Bhalchandra Gajare Committed by Matt Wagantall
Browse files

ASoC: Fix slave port setup for lookahead bufferring



The slimbus slave port on the codec needs to be configured in order to
establish slimbus data path for look ahead bufferring. Fix existing
functionality to reuse generic slave port setup.

Change-Id: I095dd65437ec482278da4ad9cd812106bbeed9b3
Signed-off-by: default avatarBhalchandra Gajare <gajare@codeaurora.org>
parent 87afe3b4
Loading
Loading
Loading
Loading
+79 −69
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ enum {
#define TOMTOM_BIT_ADJ_SHIFT_PORT1_6 4
#define TOMTOM_BIT_ADJ_SHIFT_PORT7_10 5

#define TOMTOM_MAD_MASTER_SLIM_TX 140
#define TOMTOM_HPH_PA_SETTLE_COMP_ON 5000
#define TOMTOM_HPH_PA_SETTLE_COMP_OFF 13000
#define TOMTOM_HPH_PA_RAMP_DELAY 30000
@@ -5475,7 +5474,14 @@ static int tomtom_set_channel_map(struct snd_soc_dai *dai,
			list_add_tail(&core->tx_chs[TOMTOM_TX12].list,
			&dai_data->wcd9xxx_ch_list);
		}

		/* Reserve TX13 for MAD data channel */
		dai_data = &tomtom->dai[AIF4_MAD_TX];
		if (dai_data)
			list_add_tail(&core->tx_chs[TOMTOM_TX13].list,
				      &dai_data->wcd9xxx_ch_list);
	}

	return 0;
}

@@ -5879,7 +5885,8 @@ static int tomtom_hw_params(struct snd_pcm_substream *substream,

	switch (substream->stream) {
	case SNDRV_PCM_STREAM_CAPTURE:
		if (dai->id != AIF4_VIFEED) {
		if (dai->id != AIF4_VIFEED &&
		    dai->id != AIF4_MAD_TX) {
			ret = tomtom_set_decimator_rate(dai, tx_fs_rate,
							   params_rate(params));
			if (ret < 0) {
@@ -6354,64 +6361,91 @@ out_vi:
	return ret;
}

static int tomtom_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
					  int event)
/* __tomtom_codec_enable_slimtx: Enable the slimbus slave port
 *				 for TX path
 * @codec: Handle to the codec for which the slave port is to be
 *	   enabled.
 * @dai_data: The dai specific data for dai which is enabled.
 */
static int __tomtom_codec_enable_slimtx(struct snd_soc_codec *codec,
		int event, struct wcd9xxx_codec_dai_data *dai_data)
{
	struct wcd9xxx *core;
	struct tomtom_priv *tomtom_p = snd_soc_codec_get_drvdata(codec);
	struct wcd9xxx_codec_dai_data *dai;
	int ret = 0;
	struct wcd9xxx_ch *ch;

	dai = &tomtom_p->dai[AIF4_MAD_TX];
	core = dev_get_drvdata(codec->dev->parent);
	pr_debug("%s: Set MAD Channel MAP to TX12\n", __func__);
	if (event) {
		list_add_tail(&core->tx_chs[TOMTOM_TX13].list,
			      &dai->wcd9xxx_ch_list);
		tomtom_codec_enable_int_port(dai, codec);
		(void) tomtom_codec_enable_slim_chmask(dai, true);
		dai->rate = 16000;
		dai->bit_width = 16;
		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
					      16000, 16,
					      &dai->grph);
	} else {
		ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
						dai->grph);
		pr_debug("%s: wcd9xxx_close_slim_sch_tx rc = 0x%x\n",
			 __func__, ret);
		ret = tomtom_codec_enable_slim_chmask(dai, false);

	switch (event) {
	case SND_SOC_DAPM_POST_PMU:
		dai_data->bus_down_in_recovery = false;
		tomtom_codec_enable_int_port(dai_data, codec);
		(void) tomtom_codec_enable_slim_chmask(dai_data, true);
		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai_data->wcd9xxx_ch_list,
					      dai_data->rate,
					      dai_data->bit_width,
					      &dai_data->grph);
		break;
	case SND_SOC_DAPM_POST_PMD:
		ret = wcd9xxx_close_slim_sch_tx(core,
						&dai_data->wcd9xxx_ch_list,
						dai_data->grph);
		if (!dai_data->bus_down_in_recovery)
			ret = tomtom_codec_enable_slim_chmask(dai_data, false);
		if (ret < 0) {
			ret = wcd9xxx_disconnect_port(core,
						      &dai->wcd9xxx_ch_list,
						      dai->grph);
			pr_debug("%s: Disconnect RX port, ret = %d\n",
					&dai_data->wcd9xxx_ch_list,
					dai_data->grph);
			dev_dbg(codec->dev,
				"%s: Disconnect TX port, ret = %d\n",
				 __func__, ret);
		}
		list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
			if (ch->ch_num == TOMTOM_MAD_MASTER_SLIM_TX) {
				list_del_init(&core->tx_chs[TOMTOM_TX13].list);

		dai_data->bus_down_in_recovery = false;
		break;
	}
		}
	}

	return ret;
}

/*
 * tomtom_codec_enable_slimtx_mad: Callback function that will be invoked
 *	to setup the slave port for MAD.
 * @codec: Handle to the codec
 * @event: Indicates whether to enable or disable the slave port
 */
static int tomtom_codec_enable_slimtx_mad(struct snd_soc_codec *codec,
					  u8 event)
{
	struct tomtom_priv *tomtom_p = snd_soc_codec_get_drvdata(codec);
	struct wcd9xxx_codec_dai_data *dai;
	int dapm_event = SND_SOC_DAPM_POST_PMU;

	dai = &tomtom_p->dai[AIF4_MAD_TX];

	if (event == 0)
		dapm_event = SND_SOC_DAPM_POST_PMD;

	dev_dbg(codec->dev,
		"%s: mad_channel, event = 0x%x\n",
		 __func__, event);
	return __tomtom_codec_enable_slimtx(codec, dapm_event, dai);
}

/*
 * tomtom_codec_enable_slimtx: DAPM widget allback for TX widgets
 * @w: widget for which this callback is invoked
 * @kcontrol: kcontrol associated with this widget
 * @event: DAPM supplied event indicating enable/disable
 */
static int tomtom_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
				     struct snd_kcontrol *kcontrol,
				     int event)
{
	struct wcd9xxx *core;
	struct snd_soc_codec *codec = w->codec;
	struct tomtom_priv *tomtom_p = snd_soc_codec_get_drvdata(codec);
	u32  ret = 0;
	struct wcd9xxx_codec_dai_data *dai;

	core = dev_get_drvdata(codec->dev->parent);

	pr_debug("%s: event called! codec name %s num_dai %d stream name %s\n",
	dev_dbg(codec->dev, "%s: event called! codec name %s num_dai %d stream name %s\n",
		__func__, w->codec->component.name,
		w->codec->component.num_dai, w->sname);

@@ -6419,36 +6453,12 @@ static int tomtom_codec_enable_slimtx(struct snd_soc_dapm_widget *w,
	if (tomtom_p->intf_type != WCD9XXX_INTERFACE_TYPE_SLIMBUS)
		return 0;

	pr_debug("%s(): w->name %s event %d w->shift %d\n",
	dev_dbg(codec->dev,
		"%s(): w->name %s event %d w->shift %d\n",
		__func__, w->name, event, w->shift);

	dai = &tomtom_p->dai[w->shift];
	switch (event) {
	case SND_SOC_DAPM_POST_PMU:
		dai->bus_down_in_recovery = false;
		tomtom_codec_enable_int_port(dai, codec);
		(void) tomtom_codec_enable_slim_chmask(dai, true);
		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
					      dai->rate, dai->bit_width,
					      &dai->grph);
		break;
	case SND_SOC_DAPM_POST_PMD:
		ret = wcd9xxx_close_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
						dai->grph);
		if (!dai->bus_down_in_recovery)
			ret = tomtom_codec_enable_slim_chmask(dai, false);
		if (ret < 0) {
			ret = wcd9xxx_disconnect_port(core,
						      &dai->wcd9xxx_ch_list,
						      dai->grph);
			pr_debug("%s: Disconnect RX port, ret = %d\n",
				 __func__, ret);
		}

		dai->bus_down_in_recovery = false;
		break;
	}
	return ret;
	return __tomtom_codec_enable_slimtx(codec, event, dai);
}

static int tomtom_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
@@ -8657,8 +8667,8 @@ static int tomtom_cpe_err_irq_control(struct snd_soc_codec *codec,
static const struct wcd_cpe_cdc_cb cpe_cb = {
	.cdc_clk_en = tomtom_codec_internal_rco_ctrl,
	.cpe_clk_en = tomtom_codec_fll_enable,
	.slimtx_lab_en = tomtom_codec_enable_slimtx_mad,
	.cdc_ext_clk = tomtom_codec_mclk_enable,
	.lab_cdc_ch_ctl = tomtom_codec_enable_slimtx_mad,
	.cdc_ext_clk = tomtom_codec_ext_clk_en,
	.bus_vote_bw = tomtom_codec_vote_max_bw,
	.cpe_err_irq_control = tomtom_cpe_err_irq_control,
};
+5 −5
Original line number Diff line number Diff line
@@ -3007,8 +3007,8 @@ static int slim_master_read_enable(void *core_handle,
		goto exit;
	}

	if (core->cpe_cdc_cb->slimtx_lab_en)
		core->cpe_cdc_cb->slimtx_lab_en(codec, 1);
	if (core->cpe_cdc_cb->lab_cdc_ch_ctl)
		core->cpe_cdc_cb->lab_cdc_ch_ctl(codec, 1);
	else {
		pr_err("%s: Failed to enable codec slave port\n",
			__func__);
@@ -3044,7 +3044,7 @@ static int slim_master_read_enable(void *core_handle,
	return 0;

fail_slim_open:
	core->cpe_cdc_cb->slimtx_lab_en(codec, 0);
	core->cpe_cdc_cb->lab_cdc_ch_ctl(codec, 0);
fail_mclk:
	core->cpe_cdc_cb->cdc_ext_clk(codec, false, false);
exit:
@@ -3099,8 +3099,8 @@ static int wcd_cpe_lsm_stop_lab(void *core_handle,
	lab_s = &session->lab;
	WCD_CPE_GRAB_LOCK(&session->lsm_lock, "lsm");
	/* This seqeunce should be followed strictly for closing sequence */
	if (core->cpe_cdc_cb->slimtx_lab_en)
		core->cpe_cdc_cb->slimtx_lab_en(codec, 0);
	if (core->cpe_cdc_cb->lab_cdc_ch_ctl)
		core->cpe_cdc_cb->lab_cdc_ch_ctl(codec, 0);
	else
		pr_err("%s: Failed to disable codec slave port\n",
			__func__);
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ struct wcd_cpe_cdc_cb {
	/* callback for FLL setup for codec */
	int (*cpe_clk_en) (struct snd_soc_codec *, bool);
	int (*cdc_ext_clk)(struct snd_soc_codec *codec, int enable, bool dapm);
	int (*slimtx_lab_en)(struct snd_soc_codec *codec, int event);
	int (*lab_cdc_ch_ctl)(struct snd_soc_codec *codec, u8 event);
	int (*bus_vote_bw)(struct snd_soc_codec *codec,
			   bool vote);