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

Commit 63873804 authored by Bala Kishore Pati's avatar Bala Kishore Pati
Browse files

ASoC: bg: Add check to send speaker init params to BG



Ensure to send speaker init params only when speaker is
connected to target.

Change-Id: I5ba0be58cfb292c2530148a588e3f006ac07ef29
Signed-off-by: default avatarBala Kishore Pati <balakishorepati@codeaurora.org>
parent 88827675
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2966,6 +2966,10 @@ Required properties:
			   with the glink client
- vdd-spkr-supply: BG codec supply's speaker regulator device tree node.

Optional properties:
- qcom,bg-speaker-connected: This flag will notify BG codec driver that speaker
			is connected to target or not. Based on this flag BG
			codec driver will send smart pa init params to BG.

Example:

+33 −19
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ struct bg_cdc_priv {
	bool bg_cal_updated;
	bool adsp_dev_up;
	bool bg_dev_up;
	bool bg_spk_connected;
	struct regulator *spkr_vreg;
	uint16_t num_sessions;
};
@@ -230,7 +231,7 @@ static int bg_cdc_cal(struct bg_cdc_priv *bg_cdc)
		bg_cdc->hwdep_spk_cal = NULL;

	if (bg_cdc->hwdep_mic_cal) {
		pr_debug("%s:mic cal size %d", __func__,
		pr_debug("%s:mic cal size %d\n", __func__,
				bg_cdc->hwdep_mic_cal->size);
		memcpy(init_params, &bg_cdc->hwdep_mic_cal->size,
				sizeof(bg_cdc->hwdep_mic_cal->size));
@@ -239,7 +240,8 @@ static int bg_cdc_cal(struct bg_cdc_priv *bg_cdc)
				bg_cdc->hwdep_mic_cal->size);
		init_params += bg_cdc->hwdep_mic_cal->size;
	} else {
		pr_debug("%s:default mic cal size %d", __func__, mic_blob_size);
		pr_debug("%s:default mic cal size %d\n", __func__,
				mic_blob_size);
		memcpy(init_params, &mic_blob_size,
			sizeof(mic_blob_size));
		init_params += sizeof(mic_blob_size);
@@ -247,8 +249,9 @@ static int bg_cdc_cal(struct bg_cdc_priv *bg_cdc)
		sizeof(app_mic_init_params));
		init_params += sizeof(app_mic_init_params);
	}
	if (bg_cdc->bg_spk_connected) {
		if (bg_cdc->hwdep_spk_cal) {
		pr_debug("%s: spk cal size %d", __func__,
			pr_debug("%s: spk cal size %d\n", __func__,
					bg_cdc->hwdep_spk_cal->size);
			memcpy(init_params, &bg_cdc->hwdep_spk_cal->size,
					sizeof(bg_cdc->hwdep_spk_cal->size));
@@ -256,7 +259,7 @@ static int bg_cdc_cal(struct bg_cdc_priv *bg_cdc)
			memcpy(init_params, bg_cdc->hwdep_spk_cal->data,
					bg_cdc->hwdep_spk_cal->size);
		} else {
		pr_debug("%s: default spk cal size %d", __func__,
			pr_debug("%s: default spk cal size %d\n", __func__,
					spk_blob_size);
			memcpy(init_params, &spk_blob_size,
				sizeof(spk_blob_size));
@@ -264,6 +267,8 @@ static int bg_cdc_cal(struct bg_cdc_priv *bg_cdc)
			memcpy(init_params, smart_pa_init_params,
				sizeof(smart_pa_init_params));
		}
	} else
		pr_debug("%s: spk not connected ignoring spk cal\n", __func__);
	rsp.buf_size = sizeof(struct graphite_basic_rsp_result);
	rsp.buf = kzalloc(rsp.buf_size, GFP_KERNEL);
	if (!rsp.buf) {
@@ -592,6 +597,10 @@ static int bg_cdc_hw_params(struct snd_pcm_substream *substream,
	}

	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
		if (!bg_cdc->bg_spk_connected) {
			pr_err("%s:speaker not connected\n", __func__);
			return -EINVAL;
		}
		bg_cdc->hw_params.rx_sample_rate = params_rate(params);
		bg_cdc->hw_params.rx_bit_width = params_width(params);
		bg_cdc->hw_params.rx_num_channels = params_channels(params);
@@ -1197,6 +1206,11 @@ static int bg_cdc_probe(struct platform_device *pdev)
		}
		dev_dbg(&pdev->dev, "%s: got regulator handle\n", __func__);
	}
	bg_cdc->bg_spk_connected = of_property_read_bool(pdev->dev.of_node,
						"qcom,bg-speaker-connected");
	if (!bg_cdc->bg_spk_connected)
		dev_info(&pdev->dev, "%s: speaker not connected to target %d\n",
			__func__, bg_cdc->bg_spk_connected);

	ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_bg_cdc,
					bg_cdc_dai, ARRAY_SIZE(bg_cdc_dai));