linux/sound/soc/codecs/sta350.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system
 *
 * Copyright: 2014 Raumfeld GmbH
 * Author: Sven Brandau <[email protected]>
 *
 * based on code from:
 *	Raumfeld GmbH
 *	  Johannes Stezenbach <[email protected]>
 *	Wolfson Microelectronics PLC.
 *	  Mark Brown <[email protected]>
 *	Freescale Semiconductor, Inc.
 *	  Timur Tabi <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/gpio/consumer.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include <sound/tlv.h>

#include <sound/sta350.h>
#include "sta350.h"

#define STA350_RATES

#define STA350_FORMATS

/* Power-up register defaults */
static const struct reg_default sta350_regs[] =;

static const struct regmap_range sta350_write_regs_range[] =;

static const struct regmap_range sta350_read_regs_range[] =;

static const struct regmap_range sta350_volatile_regs_range[] =;

static const struct regmap_access_table sta350_write_regs =;

static const struct regmap_access_table sta350_read_regs =;

static const struct regmap_access_table sta350_volatile_regs =;

/* regulator power supply names */
static const char * const sta350_supply_names[] =;

/* codec private data */
struct sta350_priv {};

static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12750, 50, 1);
static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1);
static const DECLARE_TLV_DB_SCALE(tone_tlv, -1200, 200, 0);

static const char * const sta350_drc_ac[] =;
static const char * const sta350_auto_gc_mode[] =;
static const char * const sta350_auto_xo_mode[] =;
static const char * const sta350_binary_output[] =;
static const char * const sta350_limiter_select[] =;
static const char * const sta350_limiter_attack_rate[] =;
static const char * const sta350_limiter_release_rate[] =;
static const char * const sta350_noise_shaper_type[] =;

static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_attack_tlv,
	0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0),
	8, 16, TLV_DB_SCALE_ITEM(300, 100, 0),
);

static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_release_tlv,
	0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
	1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0),
	2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0),
	3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0),
	8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0),
);

static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_attack_tlv,
	0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0),
	8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0),
	14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0),
);

static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_release_tlv,
	0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
	1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0),
	3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0),
	5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0),
	13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0),
);

static SOC_ENUM_SINGLE_DECL(sta350_drc_ac_enum,
			    STA350_CONFD, STA350_CONFD_DRC_SHIFT,
			    sta350_drc_ac);
static SOC_ENUM_SINGLE_DECL(sta350_noise_shaper_enum,
			    STA350_CONFE, STA350_CONFE_NSBW_SHIFT,
			    sta350_noise_shaper_type);
static SOC_ENUM_SINGLE_DECL(sta350_auto_gc_enum,
			    STA350_AUTO1, STA350_AUTO1_AMGC_SHIFT,
			    sta350_auto_gc_mode);
static SOC_ENUM_SINGLE_DECL(sta350_auto_xo_enum,
			    STA350_AUTO2, STA350_AUTO2_XO_SHIFT,
			    sta350_auto_xo_mode);
static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch1_enum,
			    STA350_C1CFG, STA350_CxCFG_BO_SHIFT,
			    sta350_binary_output);
static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch2_enum,
			    STA350_C2CFG, STA350_CxCFG_BO_SHIFT,
			    sta350_binary_output);
static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch3_enum,
			    STA350_C3CFG, STA350_CxCFG_BO_SHIFT,
			    sta350_binary_output);
static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch1_enum,
			    STA350_C1CFG, STA350_CxCFG_LS_SHIFT,
			    sta350_limiter_select);
static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch2_enum,
			    STA350_C2CFG, STA350_CxCFG_LS_SHIFT,
			    sta350_limiter_select);
static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch3_enum,
			    STA350_C3CFG, STA350_CxCFG_LS_SHIFT,
			    sta350_limiter_select);
static SOC_ENUM_SINGLE_DECL(sta350_limiter1_attack_rate_enum,
			    STA350_L1AR, STA350_LxA_SHIFT,
			    sta350_limiter_attack_rate);
static SOC_ENUM_SINGLE_DECL(sta350_limiter2_attack_rate_enum,
			    STA350_L2AR, STA350_LxA_SHIFT,
			    sta350_limiter_attack_rate);
static SOC_ENUM_SINGLE_DECL(sta350_limiter1_release_rate_enum,
			    STA350_L1AR, STA350_LxR_SHIFT,
			    sta350_limiter_release_rate);
static SOC_ENUM_SINGLE_DECL(sta350_limiter2_release_rate_enum,
			    STA350_L2AR, STA350_LxR_SHIFT,
			    sta350_limiter_release_rate);

/*
 * byte array controls for setting biquad, mixer, scaling coefficients;
 * for biquads all five coefficients need to be set in one go,
 * mixer and pre/postscale coefs can be set individually;
 * each coef is 24bit, the bytes are ordered in the same way
 * as given in the STA350 data sheet (big endian; b1, b2, a1, a2, b0)
 */

static int sta350_coefficient_info(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_info *uinfo)
{}

static int sta350_coefficient_get(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
{}

static int sta350_coefficient_put(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
{}

static int sta350_sync_coef_shadow(struct snd_soc_component *component)
{}

static int sta350_cache_sync(struct snd_soc_component *component)
{}

#define SINGLE_COEF(xname, index)

#define BIQUAD_COEFS(xname, index)

static const struct snd_kcontrol_new sta350_snd_controls[] =;

static const struct snd_soc_dapm_widget sta350_dapm_widgets[] =;

static const struct snd_soc_dapm_route sta350_dapm_routes[] =;

/* MCLK interpolation ratio per fs */
static struct {} interpolation_ratios[] =;

/* MCLK to fs clock ratios */
static int mcs_ratio_table[3][6] =;

/**
 * sta350_set_dai_sysclk - configure MCLK
 * @codec_dai: the codec DAI
 * @clk_id: the clock ID (ignored)
 * @freq: the MCLK input frequency
 * @dir: the clock direction (ignored)
 *
 * The value of MCLK is used to determine which sample rates are supported
 * by the STA350, based on the mcs_ratio_table.
 *
 * This function must be called by the machine driver's 'startup' function,
 * otherwise the list of supported sample rates will not be available in
 * time for ALSA.
 */
static int sta350_set_dai_sysclk(struct snd_soc_dai *codec_dai,
				 int clk_id, unsigned int freq, int dir)
{}

/**
 * sta350_set_dai_fmt - configure the codec for the selected audio format
 * @codec_dai: the codec DAI
 * @fmt: a SND_SOC_DAIFMT_x value indicating the data format
 *
 * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the
 * codec accordingly.
 */
static int sta350_set_dai_fmt(struct snd_soc_dai *codec_dai,
			      unsigned int fmt)
{}

/**
 * sta350_hw_params - program the STA350 with the given hardware parameters.
 * @substream: the audio stream
 * @params: the hardware parameters to set
 * @dai: the SOC DAI (ignored)
 *
 * This function programs the hardware with the values provided.
 * Specifically, the sample rate and the data format.
 */
static int sta350_hw_params(struct snd_pcm_substream *substream,
			    struct snd_pcm_hw_params *params,
			    struct snd_soc_dai *dai)
{}

static int sta350_startup_sequence(struct sta350_priv *sta350)
{}

/**
 * sta350_set_bias_level - DAPM callback
 * @component: the component device
 * @level: DAPM power level
 *
 * This is called by ALSA to put the component into low power mode
 * or to wake it up.  If the component is powered off completely
 * all registers must be restored after power on.
 */
static int sta350_set_bias_level(struct snd_soc_component *component,
				 enum snd_soc_bias_level level)
{}

static const struct snd_soc_dai_ops sta350_dai_ops =;

static struct snd_soc_dai_driver sta350_dai =;

static int sta350_probe(struct snd_soc_component *component)
{}

static void sta350_remove(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver sta350_component =;

static const struct regmap_config sta350_regmap =;

#ifdef CONFIG_OF
static const struct of_device_id st350_dt_ids[] =;
MODULE_DEVICE_TABLE(of, st350_dt_ids);

static const char * const sta350_ffx_modes[] =;

static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350)
{}
#endif

static int sta350_i2c_probe(struct i2c_client *i2c)
{}

static void sta350_i2c_remove(struct i2c_client *client)
{}

static const struct i2c_device_id sta350_i2c_id[] =;
MODULE_DEVICE_TABLE(i2c, sta350_i2c_id);

static struct i2c_driver sta350_i2c_driver =;

module_i2c_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();