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

Commit feb36c5f authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branches 'asoc/topic/ak4613', 'asoc/topic/ak4642',...

Merge remote-tracking branches 'asoc/topic/ak4613', 'asoc/topic/ak4642', 'asoc/topic/atmel', 'asoc/topic/cs35l34' and 'asoc/topic/cs35l35' into asoc-next
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@ Required properties:
    (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
    (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
    for further information relating to interrupt properties)
    for further information relating to interrupt properties)


 - cirrus,boost-ind-nanohenry: Inductor value for boost converter. The value is
    in nH and they can be values of 1000nH, 1200nH, 1500nH, and 2200nH.

Optional properties:
Optional properties:
  - reset-gpios : gpio used to reset the amplifier
  - reset-gpios : gpio used to reset the amplifier


+2 −0
Original line number Original line Diff line number Diff line
@@ -99,6 +99,8 @@ struct cs35l35_platform_data {
	bool shared_bst;
	bool shared_bst;
	/* Specifies this amp is using an external boost supply */
	/* Specifies this amp is using an external boost supply */
	bool ext_bst;
	bool ext_bst;
	/* Inductor Value */
	int boost_ind;
	/* ClassH Algorithm */
	/* ClassH Algorithm */
	struct classh_cfg classh_algo;
	struct classh_cfg classh_algo;
	/* Monitor Config */
	/* Monitor Config */
+2 −4
Original line number Original line Diff line number Diff line
@@ -83,8 +83,7 @@ struct atmel_pcm_dma_params {
#define ssc_readx(base, reg)            (__raw_readl((base) + (reg)))
#define ssc_readx(base, reg)            (__raw_readl((base) + (reg)))
#define ssc_writex(base, reg, value)    __raw_writel((value), (base) + (reg))
#define ssc_writex(base, reg, value)    __raw_writel((value), (base) + (reg))


#if defined(CONFIG_SND_ATMEL_SOC_PDC) || \
#if IS_ENABLED(CONFIG_SND_ATMEL_SOC_PDC)
	defined(CONFIG_SND_ATMEL_SOC_PDC_MODULE)
int atmel_pcm_pdc_platform_register(struct device *dev);
int atmel_pcm_pdc_platform_register(struct device *dev);
void atmel_pcm_pdc_platform_unregister(struct device *dev);
void atmel_pcm_pdc_platform_unregister(struct device *dev);
#else
#else
@@ -97,8 +96,7 @@ static inline void atmel_pcm_pdc_platform_unregister(struct device *dev)
}
}
#endif
#endif


#if defined(CONFIG_SND_ATMEL_SOC_DMA) || \
#if IS_ENABLED(CONFIG_SND_ATMEL_SOC_DMA)
	defined(CONFIG_SND_ATMEL_SOC_DMA_MODULE)
int atmel_pcm_dma_platform_register(struct device *dev);
int atmel_pcm_dma_platform_register(struct device *dev);
void atmel_pcm_dma_platform_unregister(struct device *dev);
void atmel_pcm_dma_platform_unregister(struct device *dev);
#else
#else
+78 −15
Original line number Original line Diff line number Diff line
@@ -94,6 +94,8 @@ struct ak4613_interface {
struct ak4613_priv {
struct ak4613_priv {
	struct mutex lock;
	struct mutex lock;
	const struct ak4613_interface *iface;
	const struct ak4613_interface *iface;
	struct snd_pcm_hw_constraint_list constraint;
	unsigned int sysclk;


	unsigned int fmt;
	unsigned int fmt;
	u8 oc;
	u8 oc;
@@ -139,9 +141,7 @@ static const struct reg_default ak4613_reg[] = {
#define AUDIO_IFACE(b, fmt) { b, SND_SOC_DAIFMT_##fmt }
#define AUDIO_IFACE(b, fmt) { b, SND_SOC_DAIFMT_##fmt }
static const struct ak4613_interface ak4613_iface[] = {
static const struct ak4613_interface ak4613_iface[] = {
	/* capture */				/* playback */
	/* capture */				/* playback */
	[0] = {	AUDIO_IFACE(24, LEFT_J),	AUDIO_IFACE(16, RIGHT_J) },
	/* [0] - [2] are not supported */
	[1] = {	AUDIO_IFACE(24, LEFT_J),	AUDIO_IFACE(20, RIGHT_J) },
	[2] = {	AUDIO_IFACE(24, LEFT_J),	AUDIO_IFACE(24, RIGHT_J) },
	[3] = {	AUDIO_IFACE(24, LEFT_J),	AUDIO_IFACE(24, LEFT_J) },
	[3] = {	AUDIO_IFACE(24, LEFT_J),	AUDIO_IFACE(24, LEFT_J) },
	[4] = {	AUDIO_IFACE(24, I2S),		AUDIO_IFACE(24, I2S) },
	[4] = {	AUDIO_IFACE(24, I2S),		AUDIO_IFACE(24, I2S) },
};
};
@@ -254,6 +254,74 @@ static void ak4613_dai_shutdown(struct snd_pcm_substream *substream,
	mutex_unlock(&priv->lock);
	mutex_unlock(&priv->lock);
}
}


static void ak4613_hw_constraints(struct ak4613_priv *priv,
				  struct snd_pcm_runtime *runtime)
{
	static const unsigned int ak4613_rates[] = {
		 32000,
		 44100,
		 48000,
		 64000,
		 88200,
		 96000,
		176400,
		192000,
	};
	struct snd_pcm_hw_constraint_list *constraint = &priv->constraint;
	unsigned int fs;
	int i;

	constraint->list	= ak4613_rates;
	constraint->mask	= 0;
	constraint->count	= 0;

	/*
	 * Slave Mode
	 *	Normal: [32kHz, 48kHz] : 256fs,384fs or 512fs
	 *	Double: [64kHz, 96kHz] : 256fs
	 *	Quad  : [128kHz,192kHz]: 128fs
	 *
	 * Master mode
	 *	Normal: [32kHz, 48kHz] : 256fs or 512fs
	 *	Double: [64kHz, 96kHz] : 256fs
	 *	Quad  : [128kHz,192kHz]: 128fs
	*/
	for (i = 0; i < ARRAY_SIZE(ak4613_rates); i++) {
		/* minimum fs on each range */
		fs = (ak4613_rates[i] <= 96000) ? 256 : 128;

		if (priv->sysclk >= ak4613_rates[i] * fs)
			constraint->count = i + 1;
	}

	snd_pcm_hw_constraint_list(runtime, 0,
				SNDRV_PCM_HW_PARAM_RATE, constraint);
}

static int ak4613_dai_startup(struct snd_pcm_substream *substream,
			      struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec);

	priv->cnt++;

	ak4613_hw_constraints(priv, substream->runtime);

	return 0;
}

static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai,
				 int clk_id, unsigned int freq, int dir)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec);

	priv->sysclk = freq;

	return 0;
}

static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_codec *codec = dai->codec;
@@ -262,11 +330,9 @@ static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
	fmt &= SND_SOC_DAIFMT_FORMAT_MASK;
	fmt &= SND_SOC_DAIFMT_FORMAT_MASK;


	switch (fmt) {
	switch (fmt) {
	case SND_SOC_DAIFMT_RIGHT_J:
	case SND_SOC_DAIFMT_LEFT_J:
	case SND_SOC_DAIFMT_LEFT_J:
	case SND_SOC_DAIFMT_I2S:
	case SND_SOC_DAIFMT_I2S:
		priv->fmt = fmt;
		priv->fmt = fmt;

		break;
		break;
	default:
	default:
		return -EINVAL;
		return -EINVAL;
@@ -286,13 +352,8 @@ static bool ak4613_dai_fmt_matching(const struct ak4613_interface *iface,
	if (fmts->fmt != fmt)
	if (fmts->fmt != fmt)
		return false;
		return false;


	if (fmt == SND_SOC_DAIFMT_RIGHT_J) {
	if (fmts->width != width)
	if (fmts->width != width)
		return false;
		return false;
	} else {
		if (fmts->width < width)
			return false;
	}


	return true;
	return true;
}
}
@@ -319,6 +380,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
	case 48000:
	case 48000:
		ctrl2 = DFS_NORMAL_SPEED;
		ctrl2 = DFS_NORMAL_SPEED;
		break;
		break;
	case 64000:
	case 88200:
	case 88200:
	case 96000:
	case 96000:
		ctrl2 = DFS_DOUBLE_SPEED;
		ctrl2 = DFS_DOUBLE_SPEED;
@@ -358,7 +420,6 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream,
	if ((priv->iface == NULL) ||
	if ((priv->iface == NULL) ||
	    (priv->iface == iface)) {
	    (priv->iface == iface)) {
		priv->iface = iface;
		priv->iface = iface;
		priv->cnt++;
		ret = 0;
		ret = 0;
	}
	}
	mutex_unlock(&priv->lock);
	mutex_unlock(&priv->lock);
@@ -407,7 +468,9 @@ static int ak4613_set_bias_level(struct snd_soc_codec *codec,
}
}


static const struct snd_soc_dai_ops ak4613_dai_ops = {
static const struct snd_soc_dai_ops ak4613_dai_ops = {
	.startup	= ak4613_dai_startup,
	.shutdown	= ak4613_dai_shutdown,
	.shutdown	= ak4613_dai_shutdown,
	.set_sysclk	= ak4613_dai_set_sysclk,
	.set_fmt	= ak4613_dai_set_fmt,
	.set_fmt	= ak4613_dai_set_fmt,
	.hw_params	= ak4613_dai_hw_params,
	.hw_params	= ak4613_dai_hw_params,
};
};
@@ -420,8 +483,7 @@ static const struct snd_soc_dai_ops ak4613_dai_ops = {
				 SNDRV_PCM_RATE_96000  |\
				 SNDRV_PCM_RATE_96000  |\
				 SNDRV_PCM_RATE_176400 |\
				 SNDRV_PCM_RATE_176400 |\
				 SNDRV_PCM_RATE_192000)
				 SNDRV_PCM_RATE_192000)
#define AK4613_PCM_FMTBIT	(SNDRV_PCM_FMTBIT_S16_LE |\
#define AK4613_PCM_FMTBIT	(SNDRV_PCM_FMTBIT_S24_LE)
				 SNDRV_PCM_FMTBIT_S24_LE)


static struct snd_soc_dai_driver ak4613_dai = {
static struct snd_soc_dai_driver ak4613_dai = {
	.name = "ak4613-hifi",
	.name = "ak4613-hifi",
@@ -527,6 +589,7 @@ static int ak4613_i2c_probe(struct i2c_client *i2c,


	priv->iface		= NULL;
	priv->iface		= NULL;
	priv->cnt		= 0;
	priv->cnt		= 0;
	priv->sysclk		= 0;


	mutex_init(&priv->lock);
	mutex_init(&priv->lock);


+2 −2
Original line number Original line Diff line number Diff line
@@ -433,7 +433,7 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static int ak4642_set_mcko(struct snd_soc_codec *codec,
static int ak4642_set_mcko(struct snd_soc_codec *codec,
			   u32 frequency)
			   u32 frequency)
{
{
	u32 fs_list[] = {
	static const u32 fs_list[] = {
		[0] = 8000,
		[0] = 8000,
		[1] = 12000,
		[1] = 12000,
		[2] = 16000,
		[2] = 16000,
@@ -447,7 +447,7 @@ static int ak4642_set_mcko(struct snd_soc_codec *codec,
		[14] = 29400,
		[14] = 29400,
		[15] = 44100,
		[15] = 44100,
	};
	};
	u32 ps_list[] = {
	static const u32 ps_list[] = {
		[0] = 256,
		[0] = 256,
		[1] = 128,
		[1] = 128,
		[2] = 64,
		[2] = 64,
Loading