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

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

Merge "asoc: bolero: Add codec entry for bolero for rtac support"

parents e58c940b 21c8b228
Loading
Loading
Loading
Loading
+93 −0
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@
#include "bolero-cdc.h"
#include "internal.h"

#define BOLERO_VERSION_1_0 0x0001
#define BOLERO_VERSION_ENTRY_SIZE 32

static struct snd_soc_codec_driver bolero;

/* MCLK_MUX table for all macros */
@@ -389,6 +392,95 @@ int bolero_request_clock(struct device *dev, u16 macro_id,
}
EXPORT_SYMBOL(bolero_request_clock);

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

	priv = (struct bolero_priv *) entry->private_data;
	if (!priv) {
		pr_err("%s: bolero priv is null\n", __func__);
		return -EINVAL;
	}

	switch (priv->version) {
	case BOLERO_VERSION_1_0:
		len = snprintf(buffer, sizeof(buffer), "BOLERO_1_0\n");
		break;
	default:
		len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
	}

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

static struct snd_info_entry_ops bolero_info_ops = {
	.read = bolero_version_read,
};

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

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

	priv = snd_soc_codec_get_drvdata(codec);
	if (priv->entry) {
		dev_dbg(priv->dev,
			"%s:bolero module already created\n", __func__);
		return 0;
	}
	card = codec->component.card;
	priv->entry = snd_info_create_subdir(codec_root->module,
					     "bolero", codec_root);
	if (!priv->entry) {
		dev_dbg(codec->dev, "%s: failed to create bolero entry\n",
			__func__);
		return -ENOMEM;
	}
	version_entry = snd_info_create_card_entry(card->snd_card,
						   "version",
						   priv->entry);
	if (!version_entry) {
		dev_err(codec->dev, "%s: failed to create bolero version entry\n",
			__func__);
		return -ENOMEM;
	}

	version_entry->private_data = priv;
	version_entry->size = BOLERO_VERSION_ENTRY_SIZE;
	version_entry->content = SNDRV_INFO_CONTENT_DATA;
	version_entry->c.ops = &bolero_info_ops;

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

	return 0;
}
EXPORT_SYMBOL(bolero_info_create_codec_entry);

static int bolero_soc_codec_probe(struct snd_soc_codec *codec)
{
	struct bolero_priv *priv = dev_get_drvdata(codec->dev);
@@ -407,6 +499,7 @@ static int bolero_soc_codec_probe(struct snd_soc_codec *codec)
		}
	}
	priv->codec = codec;
	priv->version = BOLERO_VERSION_1_0;
	dev_dbg(codec->dev, "%s: bolero soc codec probe success\n", __func__);
err:
	return ret;
+11 −0
Original line number Diff line number Diff line
@@ -49,6 +49,9 @@ struct device *bolero_get_device_ptr(struct device *dev, u16 macro_id);
int bolero_request_clock(struct device *dev, u16 macro_id,
			 enum mclk_mux mclk_mux_id,
			 bool enable);
int bolero_info_create_codec_entry(
		struct snd_info_entry *codec_root,
		struct snd_soc_codec *codec);
#else
static inline int bolero_register_macro(struct device *dev,
					u16 macro_id,
@@ -66,11 +69,19 @@ static inline struct device *bolero_get_device_ptr(struct device *dev,
{
	return NULL;
}

static inline int bolero_request_clock(struct device *dev, u16 macro_id,
				       enum mclk_mux mclk_mux_id,
				       bool enable)
{
	return 0;
}

static int bolero_info_create_codec_entry(
		struct snd_info_entry *codec_root,
		struct snd_soc_codec *codec)
{
	return 0;
}
#endif /* CONFIG_SND_SOC_BOLERO */
#endif /* BOLERO_CDC_H */
+5 −0
Original line number Diff line number Diff line
@@ -37,6 +37,11 @@ struct bolero_priv {
	u16 child_num;
	u16 current_mclk_mux_macro[MAX_MACRO];
	struct work_struct bolero_add_child_devices_work;
	u32 version;

	/* Entry for version info */
	struct snd_info_entry *entry;
	struct snd_info_entry *version_entry;

	int (*read_dev)(struct bolero_priv *priv,
			u16 macro_id, u16 reg, u8 *val);
+9 −7
Original line number Diff line number Diff line
@@ -443,7 +443,7 @@ int wsa_macro_set_spkr_mode(struct snd_soc_codec *codec, int mode)
		return -EINVAL;

	switch (mode) {
	case SPKR_MODE_1:
	case WSA_MACRO_SPKR_MODE_1:
		regs = wsa_macro_spkr_mode1;
		size = ARRAY_SIZE(wsa_macro_spkr_mode1);
		break;
@@ -1168,7 +1168,8 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w,
	case SND_SOC_DAPM_POST_PMU:
		wsa_macro_config_compander(codec, w->shift, event);
		/* apply gain after int clk is enabled */
		if ((wsa_priv->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
		if ((wsa_priv->spkr_gain_offset ==
			WSA_MACRO_GAIN_OFFSET_M1P5_DB) &&
		    (wsa_priv->comp_enabled[WSA_MACRO_COMP1] ||
		     wsa_priv->comp_enabled[WSA_MACRO_COMP2]) &&
		    (gain_reg == BOLERO_CDC_WSA_RX0_RX_VOL_CTL ||
@@ -1194,7 +1195,8 @@ static int wsa_macro_enable_interpolator(struct snd_soc_dapm_widget *w,
	case SND_SOC_DAPM_POST_PMD:
		wsa_macro_config_compander(codec, w->shift, event);
		wsa_macro_enable_prim_interpolator(codec, reg, event);
		if ((wsa_priv->spkr_gain_offset == RX_GAIN_OFFSET_M1P5_DB) &&
		if ((wsa_priv->spkr_gain_offset ==
			WSA_MACRO_GAIN_OFFSET_M1P5_DB) &&
		    (wsa_priv->comp_enabled[WSA_MACRO_COMP1] ||
		     wsa_priv->comp_enabled[WSA_MACRO_COMP2]) &&
		    (gain_reg == BOLERO_CDC_WSA_RX0_RX_VOL_CTL ||
@@ -1229,8 +1231,8 @@ static int wsa_macro_config_ear_spkr_gain(struct snd_soc_codec *codec,
	int comp_gain_offset, val;

	switch (wsa_priv->spkr_mode) {
	/* Compander gain in SPKR_MODE1 case is 12 dB */
	case SPKR_MODE_1:
	/* Compander gain in WSA_MACRO_SPKR_MODE1 case is 12 dB */
	case WSA_MACRO_SPKR_MODE_1:
		comp_gain_offset = -12;
		break;
	/* Default case compander gain is 15 dB */
@@ -1938,7 +1940,7 @@ static int wsa_macro_init(struct snd_soc_codec *codec)
	}

	wsa_priv->codec = codec;
	wsa_priv->spkr_gain_offset = RX_GAIN_OFFSET_0_DB;
	wsa_priv->spkr_gain_offset = WSA_MACRO_GAIN_OFFSET_0_DB;
	wsa_macro_init_reg(codec);

	return 0;
@@ -1975,7 +1977,7 @@ static void wsa_macro_add_child_devices(struct work_struct *work)
			__func__);
		return;
	}
	if (!!wsa_priv->dev || !wsa_priv->dev->of_node) {
	if (!wsa_priv->dev || !wsa_priv->dev->of_node) {
		dev_err(wsa_priv->dev,
			"%s: DT node for wsa_priv does not exist\n", __func__);
		return;
+4 −4
Original line number Diff line number Diff line
@@ -17,14 +17,14 @@
 * for a given speaker mode
 */
enum {
	SPKR_MODE_DEFAULT,
	SPKR_MODE_1,          /* COMP Gain = 12dB, Smartboost Max = 5.5V */
	WSA_MACRO_SPKR_MODE_DEFAULT,
	WSA_MACRO_SPKR_MODE_1, /* COMP Gain = 12dB, Smartboost Max = 5.5V */
};

/* Rx path gain offsets */
enum {
	RX_GAIN_OFFSET_M1P5_DB,
	RX_GAIN_OFFSET_0_DB,
	WSA_MACRO_GAIN_OFFSET_M1P5_DB,
	WSA_MACRO_GAIN_OFFSET_0_DB,
};