[alsa-devel] [PATCH v3 1/2] ASoC: codecs: Add support for AK5558 ADC driver

Mark Brown broonie at kernel.org
Mon Feb 12 13:02:13 CET 2018


On Mon, Feb 05, 2018 at 07:01:54PM +0200, Daniel Baluta wrote:
> AK5558 is a 32-bit, 768 kHZ sampling, differential input ADC
> for digital audio systems.

> --- /dev/null
> +++ b/sound/soc/codecs/ak5558.c
> @@ -0,0 +1,618 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Audio driver for AK5558 ADC

Please don't mix C++ and C style comments - just make the entire comment
C++.

> +static const char * const tdm_texts[] = {
> +	"Off", "TDM128",  "TDM256", "TDM512",
> +};

This looks like it should be a set_tdm_slot() operation, and indeed
set_tdm_slot() appears to be implemented and duplicate this.

> +static const char * const dsdon_texts[] = {
> +	"PCM", "DSD",
> +};

This looks like it's setting the DAI format?

> +	SND_SOC_DAPM_MUX("AK5558 Ch1 Enable", SND_SOC_NOPM, 0, 0,
> +			 &ak5558_channel1_mux_control),

On/off controls should be switches not muxes, though if this is just
selecting which channels are active (rather than a mute) I'd not expect
it to be a control at all - the board can say if inputs are disabled.

> +static int ak5558_set_mcki(struct snd_soc_codec *codec, int fs, int rclk)
> +{
> +	u8  mode;
> +
> +	mode = snd_soc_read(codec, AK5558_02_CONTROL1);
> +	mode &= ~AK5558_CKS;
> +	mode |= AK5558_CKS_AUTO;
> +
> +	snd_soc_update_bits(codec, AK5558_02_CONTROL1, AK5558_CKS, mode);
> +
> +	return 0;
> +}

This appears to just ignore the parameters?

> +static int ak5558_set_dai_mute(struct snd_soc_dai *dai, int mute)
> +{
> +	struct snd_soc_codec *codec = dai->codec;
> +	struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec);
> +	int ndt = 0;
> +
> +	if (!mute)
> +		return 0;
> +
> +	if (ak5558->fs != 0)
> +		ndt = 583000 / ak5558->fs;
> +
> +	msleep(max(ndt, 5));
> +
> +	return 0;
> +}

This doesn't appear to interact with the device at all.

> +static int ak5558_set_bias_level(struct snd_soc_codec *codec,
> +				 enum snd_soc_bias_level level)
> +{
> +	switch (level) {
> +	case SND_SOC_BIAS_ON:
> +	case SND_SOC_BIAS_PREPARE:
> +	case SND_SOC_BIAS_STANDBY:
> +		break;
> +	case SND_SOC_BIAS_OFF:
> +		snd_soc_write(codec, AK5558_00_POWER_MANAGEMENT1, 0x00);
> +		break;
> +	}

I'd expect there to be symmetry here - if we disable things when
transitioning to _OFF we should enable them when transitioning out.

> +	reg = snd_soc_read(codec, AK5558_03_CONTROL2);
> +	reg &= ~AK5558_MODE_BITS;
> +	reg |= tdm_mode;
> +	snd_soc_write(codec, AK5558_03_CONTROL2, reg);

snd_soc_update_bits().
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20180212/ab41d774/attachment.sig>


More information about the Alsa-devel mailing list