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

Commit 2e20219b authored by Santosh Mardi's avatar Santosh Mardi Committed by Simmi Pateriya
Browse files

ASoC: msm8952: add support for dynamic wsa881x detection on 3.18



Add support in machine driver to be able to parse device tree
for all possible wsa881x that are supported in the target,
find out from ALSA core about how many wsa881x out of the list
of devices passed from device tree are present in the target and
already registered with ALSA as codec, and eventually register
those wsa881x devices (which are present) as AUX codec to be used
with the sound card.

Change-Id: I69a5cf7d542178aca97eb0dd91e5b35e23467c93
Signed-off-by: default avatarSimmi Pateriya <simmip@codeaurora.org>
parent 97f2b08f
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@
#define HS_STARTWORK_TIMEOUT        4000

#define Q6AFE_LPASS_OSR_CLK_9_P600_MHZ	0x927C00
#define MAX_AUX_CODECS		4

enum btsco_rates {
	RATE_8KHZ_ID,
@@ -284,6 +285,11 @@ struct msm8952_asoc_mach_data {
	void __iomem *vaddr_gpio_mux_quin_ctl;
};

struct msm895x_auxcodec_prefix_map {
	char codec_name[50];
	char codec_prefix[25];
};

static inline int param_is_mask(int p)
{
	return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
@@ -304,16 +310,31 @@ int msm895x_wsa881x_init(struct snd_soc_component *component)
	struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
	struct snd_soc_card *card = codec->component.card;
	struct msm8952_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
	struct msm895x_auxcodec_prefix_map codec_prefix_map[MAX_AUX_CODECS] = {
	{ "wsa881x.20170211", "SpkrRight" },
	{ "wsa881x.20170212", "SpkrLeft" },
	{ "wsa881x.21170213", "SpkrRight" },
	{ "wsa881x.21170214", "SpkrLeft" } };
	u8 i;

	if (!codec) {
		pr_err("%s codec is NULL\n", __func__);
		return -EINVAL;
	}
	if (!strcmp(codec->component.name, "wsa881x.20170212")) {

	for (i = 0; i < MAX_AUX_CODECS; i++) {
		if (!strcmp(component->name, codec_prefix_map[i].codec_name))
			break;
	}
	if (i >= MAX_AUX_CODECS) {
		pr_err("%s: could not find prefix map\n" , __func__);
		return -EINVAL;
	}
	if (!strcmp(codec_prefix_map[i].codec_prefix, "SpkrLeft")) {
		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")) {
	} else if (!strcmp(codec_prefix_map[i].codec_prefix, "SpkrRight")) {
		wsa881x_set_channel_map(codec, &spkright_ports[0],
				WSA881X_MAX_SWR_PORTS, &ch_mask[0],
				&ch_rate[0]);
@@ -2236,7 +2257,7 @@ static int msm8952_asoc_machine_probe(struct platform_device *pdev)
	card = populate_snd_card_dailinks(&pdev->dev);
	if (!card) {
		dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
		ret = -EINVAL;
		ret = -EPROBE_DEFER;
		goto err;
	}
	card->dev = &pdev->dev;