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

Commit e4ddb5ad authored by Sudheer Papothi's avatar Sudheer Papothi
Browse files

ASoC: msm8996: Runtime detection of auxiliary codec on 8996



wsa881x is defined as auxiliary codec on 8996 target and has
two variants. Add runtime detection support based on unique
device id of wsa881x codec variant.

Change-Id: Ic785a114fe8ab608662a4625d89d342147b4556e
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent 8f275c1c
Loading
Loading
Loading
Loading
+35 −30
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ static void *def_codec_mbhc_cal(void);
static void *def_tasha_mbhc_cal(void);
static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,
					int enable, bool dapm);
static int msm8996_wsa881x_init(struct snd_soc_component *component);

static struct wcd_mbhc_config wcd_mbhc_cfg = {
	.read_fw_bin = false,
@@ -1377,36 +1378,6 @@ static int msm8996_codec_event_cb(struct snd_soc_codec *codec,
	}
}

static int msm8996_wsa881x_init(struct snd_soc_component *component)
{
	u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {100, 101, 102, 106};
	u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {103, 104, 105, 107};
	unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
	unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
	struct snd_soc_codec *codec = snd_soc_component_to_codec(component);

	if (!codec->component.name) {
		pr_err("%s codec_name is NULL\n", __func__);
		return -EINVAL;
	}
	dev_dbg(codec->dev, "%s codec_name: %s\n", __func__,
		codec->component.name);
	if (!strcmp(codec->component.name, "wsa881x.20170212")) {
		wsa881x_set_channel_map(codec, &spkleft_ports[0],
				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
				&ch_rate[0]);
	} else if (!strcmp(codec->component.name, "wsa881x.20170211")) {
		wsa881x_set_channel_map(codec, &spkright_ports[0],
				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
				&ch_rate[0]);
	} else {
		dev_err(codec->dev, "%s: wrong codec name %s\n", __func__,
			codec->component.name);
		return -EINVAL;
	}
	return 0;
}

static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
{
	int err;
@@ -3157,6 +3128,40 @@ static struct snd_soc_codec_conf msm8996_codec_conf[] = {
	},
};

static int msm8996_wsa881x_init(struct snd_soc_component *component)
{
	u8 spkleft_ports[WSA881X_MAX_SWR_PORTS] = {100, 101, 102, 106};
	u8 spkright_ports[WSA881X_MAX_SWR_PORTS] = {103, 104, 105, 107};
	unsigned int ch_rate[WSA881X_MAX_SWR_PORTS] = {2400, 600, 300, 1200};
	unsigned int ch_mask[WSA881X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
	struct snd_soc_codec *codec = snd_soc_component_to_codec(component);

	if (!codec) {
		pr_err("%s codec is NULL\n", __func__);
		return -EINVAL;
	}

	if (component->dev->of_node == msm8996_aux_dev[0].codec_of_node) {
		dev_dbg(codec->dev, "%s: setting left ch map to codec %s\n",
			__func__, codec->component.name);
		wsa881x_set_channel_map(codec, &spkleft_ports[0],
				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
				&ch_rate[0]);
	} else if (component->dev->of_node ==
		   msm8996_aux_dev[1].codec_of_node) {
		dev_dbg(codec->dev, "%s: setting right ch map to codec %s\n",
			__func__, codec->component.name);
		wsa881x_set_channel_map(codec, &spkright_ports[0],
				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
				&ch_rate[0]);
	} else {
		dev_err(codec->dev, "%s: wrong codec name %s\n", __func__,
			codec->component.name);
		return -EINVAL;
	}
	return 0;
}

struct snd_soc_card snd_soc_card_tomtom_msm8996 = {
	.name		= "msm8996-tomtom-snd-card",
};