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

Commit de8c1157 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: codec: add hwdep node for digital codec on msm8909w"

parents 7a18da56 83d40dfa
Loading
Loading
Loading
Loading
+90 −1
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@
#define CF_MIN_3DB_75HZ			0x1
#define CF_MIN_3DB_150HZ		0x2

#define MSM_DIG_CDC_VERSION_ENTRY_SIZE 32

static unsigned long rx_digital_gain_reg[] = {
	MSM89XX_CDC_CORE_RX1_VOL_CTL_B2_CTL,
	MSM89XX_CDC_CORE_RX2_VOL_CTL_B2_CTL,
@@ -1023,11 +1025,85 @@ static void msm_digit_cdc_update_digit_regulator(
	dev_err(msm_cdc->dev, "Error: regulator not found:%s\n", name);
}

static ssize_t msm_dig_codec_version_read(struct snd_info_entry *entry,
					   void *file_private_data,
					   struct file *file,
					   char __user *buf, size_t count,
					   loff_t pos)
{
	char buffer[MSM_DIG_CDC_VERSION_ENTRY_SIZE];
	int len = 0;

	len = snprintf(buffer, sizeof(buffer), "MSM8909_1_0\n");

	return simple_read_from_buffer(buf, count, &pos, buffer, len);
}

static struct snd_info_entry_ops msm_dig_codec_info_ops = {
	.read = msm_dig_codec_version_read,
};

/*
 * msm_dig_codec_info_create_codec_entry - creates msm digital codec module
 * @codec_root: The parent directory
 * @codec: Codec instance
 *
 * Creates msm digital codec module and version entry under the given
 * parent directory.
 *
 * Return: 0 on success or negative error code on failure.
 */
int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
					   struct snd_soc_codec *codec)
{
	struct snd_info_entry *version_entry;
	struct msm_dig_priv *msm_dig_cdc;
	struct snd_soc_card *card;

	if (!codec_root || !codec)
		return -EINVAL;

	msm_dig_cdc = snd_soc_codec_get_drvdata(codec);
	card = codec->component.card;
	msm_dig_cdc->entry = snd_register_module_info(codec_root->module,
							     "msm_digital_codec",
							     codec_root);
	if (!msm_dig_cdc->entry) {
		dev_dbg(codec->dev, "%s: failed to create msm-digital entry\n",
			__func__);
		return -ENOMEM;
	}

	version_entry = snd_info_create_card_entry(card->snd_card,
						   "version",
						   msm_dig_cdc->entry);
	if (!version_entry) {
		dev_dbg(codec->dev,
			"%s: failed to create msm-digital version entry\n",
			__func__);
		return -ENOMEM;
	}

	version_entry->private_data = msm_dig_cdc;
	version_entry->size = MSM_DIG_CDC_VERSION_ENTRY_SIZE;
	version_entry->content = SNDRV_INFO_CONTENT_DATA;
	version_entry->c.ops = &msm_dig_codec_info_ops;

	if (snd_info_register(version_entry) < 0) {
		snd_info_free_entry(version_entry);
		return -ENOMEM;
	}
	msm_dig_cdc->version_entry = version_entry;

	return 0;
}
EXPORT_SYMBOL(msm_dig_codec_info_create_codec_entry);

static int msm_dig_cdc_soc_probe(struct snd_soc_codec *codec)
{
	struct msm_dig_priv *msm_dig_cdc = dev_get_drvdata(codec->dev);
	struct snd_soc_dapm_context *dapm = &codec->dapm;
	int i;
	int i, ret = 0;

	msm_dig_cdc->codec = codec;

@@ -1054,6 +1130,19 @@ static int msm_dig_cdc_soc_probe(struct snd_soc_codec *codec)
	atomic_set(&msm_dig_cdc->on_demand_list[ON_DEMAND_DIGIT].ref,
		   0);

	msm_dig_cdc->fw_data = devm_kzalloc(codec->dev,
					   sizeof(*(msm_dig_cdc->fw_data)),
					   GFP_KERNEL);
	if (!msm_dig_cdc->fw_data)
		return -ENOMEM;

	ret = wcd_cal_create_hwdep(msm_dig_cdc->fw_data,
		WCD9XXX_CODEC_HWDEP_NODE, codec);
	if (ret < 0) {
		dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
		return ret;
	}

	snd_soc_dapm_ignore_suspend(dapm, "AIF1 Playback");
	snd_soc_dapm_ignore_suspend(dapm, "AIF1 Capture");
	snd_soc_dapm_ignore_suspend(dapm, "ADC1_IN");
+9 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/workqueue.h>
#include <linux/notifier.h>
#include <sound/apr_audio-v2.h>
#include "wcdcal-hwdep.h"

#define HPHL_PA_DISABLE (0x01 << 1)
#define HPHR_PA_DISABLE (0x01 << 2)
@@ -109,8 +110,6 @@ struct msm_dig_priv {
	s32 dmic_1_2_clk_cnt;
	bool dec_active[NUM_DECIMATORS];
	int version;
	/* Entry for version info */
	struct snd_info_entry *entry;
	char __iomem *dig_base;
	struct regmap *regmap;
	struct notifier_block nblock;
@@ -121,6 +120,11 @@ struct msm_dig_priv {
	struct on_demand_supply on_demand_list[ON_DEMAND_SUPPLIES_MAX];
	u32 num_of_supplies;
	struct regulator_bulk_data *supplies;
	/* cal info for codec */
	struct fw_info *fw_data;
	/* Entry for version info */
	struct snd_info_entry *entry;
	struct snd_info_entry *version_entry;
};

struct msm_cdc_pdata {
@@ -146,6 +150,7 @@ struct msm_asoc_mach_data {
	struct device_node *pdm_gpio_p; /* used by pinctrl API */
	struct device_node *dmic_gpio_p; /* used by pinctrl API */
	struct snd_soc_codec *codec;
	struct snd_info_entry *codec_root;
	int mclk_freq;
	bool native_clk_set;
	int lb_mode;
@@ -169,4 +174,6 @@ struct msm_asoc_mach_data {

extern int msm_digcdc_mclk_enable(struct snd_soc_codec *codec,
			int mclk_enable, bool dapm);
int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
					  struct snd_soc_codec *codec);
#endif
+16 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ static atomic_t quat_mi2s_clk_ref;
static atomic_t quin_mi2s_clk_ref;
static atomic_t auxpcm_mi2s_clk_ref;

static struct snd_info_entry *codec_root;

static int msm_enable_dig_cdc_clk(struct snd_soc_codec *codec, int enable,
					bool dapm);
static int msm_mclk_event(struct snd_soc_dapm_widget *w,
@@ -1201,6 +1203,8 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
	struct snd_soc_codec *codec = rtd->codec;
	struct snd_soc_dapm_context *dapm = &codec->dapm;
	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
	struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card);
	struct snd_card *card;

	pr_debug("%s(),dev_name%s\n", __func__, dev_name(cpu_dai->dev));

@@ -1218,6 +1222,18 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)

	snd_soc_dapm_sync(dapm);

	card = rtd->card->snd_card;
	if (!codec_root) {
		codec_root = snd_register_module_info(card->module, "codecs",
						      card->proc_root);
		if (codec_root)
			msm_dig_codec_info_create_codec_entry(codec_root,
							      codec);
		else
			pr_debug("%s: Cannot create codecs module entry\n",
				 __func__);
	}
	pdata->codec_root = codec_root;
	return 0;
}