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

Commit ca5e93ad authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "asoc: machine driver and bring up changes for holi."

parents cb97be6e d6f2eaa4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ endif
ifeq ($(CONFIG_ARCH_LAHAINA), y)
include $(srctree)/techpack/audio/config/lahainaauto.conf
endif
ifeq ($(CONFIG_ARCH_HOLI), y)
include $(srctree)/techpack/audio/config/holiauto.conf
endif
endif

# Use USERINCLUDE when you must reference the UAPI directories only.
@@ -51,6 +54,10 @@ ifeq ($(CONFIG_ARCH_LAHAINA), y)
LINUXINCLUDE    += \
                -include $(srctree)/techpack/audio/config/lahainaautoconf.h
endif
ifeq ($(CONFIG_ARCH_HOLI), y)
LINUXINCLUDE    += \
                -include $(srctree)/techpack/audio/config/holiautoconf.h
endif

obj-y += soc/
obj-y += dsp/
+8 −0
Original line number Diff line number Diff line
@@ -136,6 +136,11 @@ ifdef CONFIG_SND_SOC_LAHAINA
	MACHINE_OBJS += lahaina.o
endif

# for HOLI sound card driver
ifdef CONFIG_SND_SOC_HOLI
	MACHINE_OBJS += holi.o
endif

ifdef CONFIG_SND_SOC_LITO
	MACHINE_OBJS += kona.o
endif
@@ -254,6 +259,9 @@ machine_dlkm-y := $(MACHINE_OBJS)
obj-$(CONFIG_SND_SOC_LAHAINA) += machine_dlkm.o
machine_dlkm-y := $(MACHINE_OBJS)

obj-$(CONFIG_SND_SOC_HOLI) += machine_dlkm.o
machine_dlkm-y := $(MACHINE_OBJS)

obj-$(CONFIG_SND_SOC_LITO) += machine_dlkm.o
machine_dlkm-y := $(MACHINE_OBJS)

+58 −13
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@
#include "wcd937x.h"
#include "internal.h"

#define DRV_NAME "wcd937x_codec"

#define WCD9370_VARIANT 0
#define WCD9375_VARIANT 5
#define WCD937X_VARIANT_ENTRY_SIZE 32
@@ -40,6 +38,18 @@

#define NUM_ATTEMPTS 5

#define WCD937X_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
			SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\
			SNDRV_PCM_RATE_384000)
/* Fractional Rates */
#define WCD937X_FRAC_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\
			SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800)

#define WCD937X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
		SNDRV_PCM_FMTBIT_S24_LE |\
		SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE)

enum {
	CODEC_TX = 0,
	CODEC_RX,
@@ -91,12 +101,36 @@ static struct regmap_irq_chip wcd937x_regmap_irq_chip = {
	.mask_base = WCD937X_DIGITAL_INTR_MASK_0,
	.ack_base = WCD937X_DIGITAL_INTR_CLEAR_0,
	.use_ack = 1,
	.clear_ack = 1,
	.type_base = WCD937X_DIGITAL_INTR_LEVEL_0,
	.runtime_pm = false,
	.handle_post_irq = wcd937x_handle_post_irq,
	.irq_drv_data = NULL,
};

static struct snd_soc_dai_driver wcd937x_dai[] = {
	{
		.name = "wcd937x_cdc",
		.playback = {
			.stream_name = "WCD937X_AIF Playback",
			.rates = WCD937X_RATES | WCD937X_FRAC_RATES,
			.formats = WCD937X_FORMATS,
			.rate_max = 384000,
			.rate_min = 8000,
			.channels_min = 1,
			.channels_max = 4,
		},
		.capture = {
			.stream_name = "WCD937X_AIF Capture",
			.rates = WCD937X_RATES,
			.formats = WCD937X_FORMATS,
			.rate_max = 192000,
			.rate_min = 8000,
			.channels_min = 1,
			.channels_max = 4,
		},
	},
};

static int wcd937x_handle_post_irq(void *data)
{
	struct wcd937x_priv *wcd937x = data;
@@ -278,7 +312,7 @@ static int wcd937x_tx_connect_port(struct snd_soc_component *component,
	u8 ch_mask;
	u32 ch_rate;
	u8 ch_type = 0;
	int slave_port_idx;
	int slave_ch_idx;
	u8 num_port = 1;
	int ret = 0;

@@ -2224,15 +2258,15 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
				SND_SOC_DAPM_POST_PMD),

	/* micbias widgets*/
	SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
	SND_SOC_DAPM_SUPPLY("MIC BIAS1", SND_SOC_NOPM, 0, 0,
				wcd937x_codec_enable_micbias,
				SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
				SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
	SND_SOC_DAPM_SUPPLY("MIC BIAS2", SND_SOC_NOPM, 0, 0,
				wcd937x_codec_enable_micbias,
				SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
				SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
	SND_SOC_DAPM_SUPPLY("MIC BIAS3", SND_SOC_NOPM, 0, 0,
				wcd937x_codec_enable_micbias,
				SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
				SND_SOC_DAPM_POST_PMD),
@@ -2316,15 +2350,15 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
	SND_SOC_DAPM_OUTPUT("HPHR"),

	/* micbias pull up widgets*/
	SND_SOC_DAPM_MICBIAS_E("VA MIC BIAS1", SND_SOC_NOPM, 0, 0,
	SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, 0, 0,
				wcd937x_codec_enable_micbias_pullup,
				SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
				SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MICBIAS_E("VA MIC BIAS2", SND_SOC_NOPM, 0, 0,
	SND_SOC_DAPM_SUPPLY("VA MIC BIAS2", SND_SOC_NOPM, 0, 0,
				wcd937x_codec_enable_micbias_pullup,
				SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
				SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MICBIAS_E("VA MIC BIAS3", SND_SOC_NOPM, 0, 0,
	SND_SOC_DAPM_SUPPLY("VA MIC BIAS3", SND_SOC_NOPM, 0, 0,
				wcd937x_codec_enable_micbias_pullup,
				SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
				SND_SOC_DAPM_POST_PMD),
@@ -2576,19 +2610,25 @@ int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
		return 0;
	}
	card = component->card;
	priv->entry = snd_info_create_subdir(codec_root->module,
	priv->entry = snd_info_create_module_entry(codec_root->module,
					     "wcd937x", codec_root);
	if (!priv->entry) {
		dev_dbg(component->dev, "%s: failed to create wcd937x entry\n",
			__func__);
		return -ENOMEM;
	}
	priv->entry->mode = S_IFDIR | 0555;
	if (snd_info_register(priv->entry) < 0) {
		snd_info_free_entry(priv->entry);
		return -ENOMEM;
	}
	version_entry = snd_info_create_card_entry(card->snd_card,
						   "version",
						   priv->entry);
	if (!version_entry) {
		dev_dbg(component->dev, "%s: failed to create wcd937x version entry\n",
			__func__);
		snd_info_free_entry(priv->entry);
		return -ENOMEM;
	}

@@ -2599,6 +2639,7 @@ int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,

	if (snd_info_register(version_entry) < 0) {
		snd_info_free_entry(version_entry);
		snd_info_free_entry(priv->entry);
		return -ENOMEM;
	}
	priv->version_entry = version_entry;
@@ -2610,6 +2651,8 @@ int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
		dev_dbg(component->dev,
			"%s: failed to create wcd937x variant entry\n",
			__func__);
		snd_info_free_entry(version_entry);
		snd_info_free_entry(priv->entry);
		return -ENOMEM;
	}

@@ -2620,6 +2663,8 @@ int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,

	if (snd_info_register(variant_entry) < 0) {
		snd_info_free_entry(variant_entry);
		snd_info_free_entry(version_entry);
		snd_info_free_entry(priv->entry);
		return -ENOMEM;
	}
	priv->variant_entry = variant_entry;
@@ -2781,7 +2826,7 @@ static void wcd937x_soc_codec_remove(struct snd_soc_component *component)
}

static const struct snd_soc_component_driver soc_codec_dev_wcd937x = {
	.name = DRV_NAME,
	.name = WCD937X_DRV_NAME,
	.probe = wcd937x_soc_codec_probe,
	.remove = wcd937x_soc_codec_remove,
	.controls = wcd937x_snd_controls,
@@ -3185,7 +3230,7 @@ static int wcd937x_bind(struct device *dev)
	wcd_disable_irq(&wcd937x->irq_info, WCD937X_IRQ_AUX_PDM_WD_INT);

	ret = snd_soc_register_component(dev, &soc_codec_dev_wcd937x,
				     NULL, 0);
				     wcd937x_dai, ARRAY_SIZE(wcd937x_dai));
	if (ret) {
		dev_err(dev, "%s: Codec registration failed\n",
				__func__);
+9 −7
Original line number Diff line number Diff line
@@ -10,12 +10,14 @@
#define WCD937X_MAX_SLAVE_CH_TYPES 10
#define ZERO 0

struct swr_slave_ch_map {
#define WCD937X_DRV_NAME "wcd937x_codec"

struct wcd937x_swr_slave_ch_map {
	u8 ch_type;
	u8 index;
};

static const struct swr_slave_ch_map swr_slv_tx_ch_idx[] = {
static const struct wcd937x_swr_slave_ch_map wcd937x_swr_slv_tx_ch_idx[] = {
	{ADC1, 0},
	{ADC2, 1},
	{ADC3, 2},
@@ -28,7 +30,7 @@ static const struct swr_slave_ch_map swr_slv_tx_ch_idx[] = {
	{DMIC5, 9},
};

static int swr_master_ch_map[] = {
static int wcd937x_swr_master_ch_map[] = {
	ZERO,
	SWRM_TX1_CH1,
	SWRM_TX1_CH2,
@@ -54,14 +56,14 @@ static inline int wcd937x_slave_get_master_ch_val(int ch)
	int i;

	for (i = 0; i < WCD937X_MAX_SLAVE_CH_TYPES; i++)
		if (ch == swr_master_ch_map[i])
		if (ch == wcd937x_swr_master_ch_map[i])
			return i;
	return 0;
}

static inline int wcd937x_slave_get_master_ch(int idx)
{
	return swr_master_ch_map[idx];
	return wcd937x_swr_master_ch_map[idx];
}

static inline int wcd937x_slave_get_slave_ch_val(int ch)
@@ -69,8 +71,8 @@ static inline int wcd937x_slave_get_slave_ch_val(int ch)
	int i;

	for (i = 0; i < WCD937X_MAX_SLAVE_CH_TYPES; i++)
		if (ch == swr_slv_tx_ch_idx[i].ch_type)
			return swr_slv_tx_ch_idx[i].index;
		if (ch == wcd937x_swr_slv_tx_ch_idx[i].ch_type)
			return wcd937x_swr_slv_tx_ch_idx[i].index;

	return -EINVAL;
}
+106 −5
Original line number Diff line number Diff line
@@ -35,6 +35,19 @@
#define SPK_GAIN_12DB 4
#define WIDGET_NAME_MAX_SIZE 80

#define MAX_NAME_LEN 30
#define WSA881X_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
			SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\
			SNDRV_PCM_RATE_384000)
/* Fractional Rates */
#define WSA881X_FRAC_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\
				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800)

#define WSA881X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
			SNDRV_PCM_FMTBIT_S24_LE |\
			SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE)

/*
 * Private data Structure for wsa881x. All parameters related to
 * WSA881X codec needs to be defined here.
@@ -66,6 +79,9 @@ struct wsa881x_pdata {
	struct device_node *wsa_vi_gpio_p;
	struct device_node *wsa_clk_gpio_p;
	struct device_node *wsa_reset_gpio_p;
	char *wsa881x_name_prefix;
	struct snd_soc_dai_driver *dai_driver;
	struct snd_soc_component_driver *driver;
};

enum {
@@ -1190,7 +1206,8 @@ static void wsa881x_remove(struct snd_soc_component *component)
	mutex_destroy(&wsa881x->res_lock);
}

static const struct snd_soc_component_driver soc_component_dev_wsa881x = {
static const struct snd_soc_component_driver soc_codec_dev_wsa881x = {
	.name = "",
	.probe	= wsa881x_probe,
	.remove	= wsa881x_remove,

@@ -1205,6 +1222,21 @@ static const struct snd_soc_component_driver soc_component_dev_wsa881x = {
	.num_dapm_routes = ARRAY_SIZE(wsa881x_audio_map),
};

static struct snd_soc_dai_driver wsa_dai[] = {
	{
		.name = "",
		.playback = {
			.stream_name = "",
			.rates = WSA881X_RATES | WSA881X_FRAC_RATES,
			.formats = WSA881X_FORMATS,
			.rate_max = 192000,
			.rate_min = 8000,
			.channels_min = 1,
			.channels_max = 2,
			},
	},
};

static int wsa881x_reset(struct wsa881x_pdata *pdata, bool enable)
{
	int ret = 0;
@@ -1332,6 +1364,8 @@ static int wsa881x_i2c_probe(struct i2c_client *client,
	int wsa881x_index = 0;
	struct wsa881x_pdata *pdata = NULL;
	struct clk *wsa_mclk = NULL;
	char buffer[MAX_NAME_LEN];
	const char *wsa881x_name_prefix_of = NULL;

	ret = wsa881x_i2c_get_client_index(client, &wsa881x_index);
	if (ret != 0) {
@@ -1454,13 +1488,70 @@ static int wsa881x_i2c_probe(struct i2c_client *client,
		}
		wsa881x_presence_count++;
		wsa881x_probing_count++;
		ret = snd_soc_register_component(&client->dev,
					&soc_component_dev_wsa881x,
					NULL, 0);
		if (ret < 0)

		ret = of_property_read_string(client->dev.of_node,
				"qcom,wsa-prefix", &wsa881x_name_prefix_of);
		if (ret) {
			dev_err(&client->dev,
				"%s: Looking up %s property in node %s failed\n",
				__func__, "qcom,wsa-prefix",
				client->dev.of_node->full_name);
			goto err1;
		}

		pdata->driver = devm_kzalloc(&client->dev,
					sizeof(struct snd_soc_component_driver),
					GFP_KERNEL);
		if (!pdata->driver) {
			ret = -ENOMEM;
			goto err1;
		}

		memcpy(pdata->driver, &soc_codec_dev_wsa881x,
				sizeof(struct snd_soc_component_driver));

		pdata->dai_driver = devm_kzalloc(&client->dev,
					sizeof(struct snd_soc_dai_driver),
					GFP_KERNEL);
		if (!pdata->dai_driver) {
			ret = -ENOMEM;
			goto err_mem;
		}

		memcpy(pdata->dai_driver, wsa_dai,
			sizeof(struct snd_soc_dai_driver));

		snprintf(buffer, sizeof(buffer), "wsa-codec.%d", wsa881x_index);
		pdata->driver->name = kstrndup(buffer,
					       strlen(buffer), GFP_KERNEL);

		snprintf(buffer, sizeof(buffer), "wsa_rx%d", wsa881x_index);
		pdata->dai_driver->name =
				kstrndup(buffer, strlen(buffer), GFP_KERNEL);

		snprintf(buffer, sizeof(buffer),
			 "WSA881X_AIF%d Playback", wsa881x_index);
		pdata->dai_driver->playback.stream_name =
				kstrndup(buffer, strlen(buffer), GFP_KERNEL);

		/* Number of DAI's used is 1 */
		ret = snd_soc_register_component(&client->dev,
					pdata->driver, pdata->dai_driver, 1);

		pdata->status = WSA881X_STATUS_I2C;
	}
err_mem:
	 kfree(pdata->wsa881x_name_prefix);
	if (pdata->dai_driver) {
		kfree(pdata->dai_driver->name);
		kfree(pdata->dai_driver->playback.stream_name);
		kfree(pdata->dai_driver);
	}
	if (pdata->driver) {
		kfree(pdata->driver->name);
		kfree(pdata->driver);
	}

err1:
	wsa881x_reset(pdata, false);
err:
@@ -1472,6 +1563,16 @@ static int wsa881x_i2c_remove(struct i2c_client *client)
	struct wsa881x_pdata *wsa881x = client->dev.platform_data;

	snd_soc_unregister_component(&client->dev);
	kfree(wsa881x->wsa881x_name_prefix);
	if (wsa881x->dai_driver) {
		kfree(wsa881x->dai_driver->name);
		kfree(wsa881x->dai_driver->playback.stream_name);
		kfree(wsa881x->dai_driver);
	}
	if (wsa881x->driver) {
		kfree(wsa881x->driver->name);
		kfree(wsa881x->driver);
	}
	i2c_set_clientdata(client, NULL);
	kfree(wsa881x);
	return 0;
Loading