linux/sound/soc/codecs/tlv320aic31xx.c

// SPDX-License-Identifier: GPL-2.0
/*
 * ALSA SoC TLV320AIC31xx CODEC Driver
 *
 * Copyright (C) 2014-2017 Texas Instruments Incorporated - https://www.ti.com/
 *	Jyri Sarha <[email protected]>
 *
 * Based on ground work by: Ajit Kulkarni <[email protected]>
 *
 * The TLV320AIC31xx series of audio codecs are low-power, highly integrated
 * high performance codecs which provides a stereo DAC, a mono ADC,
 * and mono/stereo Class-D speaker driver.
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>
#include <linux/acpi.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include <dt-bindings/sound/tlv320aic31xx.h>

#include "tlv320aic31xx.h"

static int aic31xx_set_jack(struct snd_soc_component *component,
                            struct snd_soc_jack *jack, void *data);

static const struct reg_default aic31xx_reg_defaults[] =;

static bool aic31xx_volatile(struct device *dev, unsigned int reg)
{}

static bool aic31xx_writeable(struct device *dev, unsigned int reg)
{}

static const struct regmap_range_cfg aic31xx_ranges[] =;

static const struct regmap_config aic31xx_i2c_regmap =;

static const char * const aic31xx_supply_names[] =;

#define AIC31XX_NUM_SUPPLIES

struct aic31xx_disable_nb {};

struct aic31xx_priv {};

struct aic31xx_rate_divs {};

/* ADC dividers can be disabled by configuring them to 0 */
static const struct aic31xx_rate_divs aic31xx_divs[] =;

static const char * const ldac_in_text[] =;

static const char * const rdac_in_text[] =;

static SOC_ENUM_SINGLE_DECL(ldac_in_enum, AIC31XX_DACSETUP, 4, ldac_in_text);

static SOC_ENUM_SINGLE_DECL(rdac_in_enum, AIC31XX_DACSETUP, 2, rdac_in_text);

static const char * const mic_select_text[] =;

static SOC_ENUM_SINGLE_DECL(mic1lp_p_enum, AIC31XX_MICPGAPI, 6,
	mic_select_text);
static SOC_ENUM_SINGLE_DECL(mic1rp_p_enum, AIC31XX_MICPGAPI, 4,
	mic_select_text);
static SOC_ENUM_SINGLE_DECL(mic1lm_p_enum, AIC31XX_MICPGAPI, 2,
	mic_select_text);

static SOC_ENUM_SINGLE_DECL(mic1lm_m_enum, AIC31XX_MICPGAMI, 4,
	mic_select_text);

static const char * const hp_poweron_time_text[] =;

static SOC_ENUM_SINGLE_DECL(hp_poweron_time_enum, AIC31XX_HPPOP, 3,
	hp_poweron_time_text);

static const char * const hp_rampup_step_text[] =;

static SOC_ENUM_SINGLE_DECL(hp_rampup_step_enum, AIC31XX_HPPOP, 1,
	hp_rampup_step_text);

static const char * const vol_soft_step_mode_text[] =;

static SOC_ENUM_SINGLE_DECL(vol_soft_step_mode_enum, AIC31XX_DACSETUP, 0,
	vol_soft_step_mode_text);

static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6350, 50, 0);
static const DECLARE_TLV_DB_SCALE(adc_fgain_tlv, 0, 10, 0);
static const DECLARE_TLV_DB_SCALE(adc_cgain_tlv, -2000, 50, 0);
static const DECLARE_TLV_DB_SCALE(mic_pga_tlv, 0, 50, 0);
static const DECLARE_TLV_DB_SCALE(hp_drv_tlv, 0, 100, 0);
static const DECLARE_TLV_DB_SCALE(class_D_drv_tlv, 600, 600, 0);
static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -6350, 50, 0);
static const DECLARE_TLV_DB_SCALE(sp_vol_tlv, -6350, 50, 0);

/*
 * controls to be exported to the user space
 */
static const struct snd_kcontrol_new common31xx_snd_controls[] =;

static const struct snd_kcontrol_new aic31xx_snd_controls[] =;

static const struct snd_kcontrol_new aic311x_snd_controls[] =;

static const struct snd_kcontrol_new aic310x_snd_controls[] =;

static const struct snd_kcontrol_new ldac_in_control =;

static const struct snd_kcontrol_new rdac_in_control =;

static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg,
			     unsigned int mask, unsigned int wbits, int sleep,
			     int count)
{}

#define WIDGET_BIT(reg, shift)

static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w,
				    struct snd_kcontrol *kcontrol, int event)
{}

static const struct snd_kcontrol_new aic31xx_left_output_switches[] =;

static const struct snd_kcontrol_new aic31xx_right_output_switches[] =;

static const struct snd_kcontrol_new dac31xx_left_output_switches[] =;

static const struct snd_kcontrol_new dac31xx_right_output_switches[] =;

static const struct snd_kcontrol_new p_term_mic1lp =;

static const struct snd_kcontrol_new p_term_mic1rp =;

static const struct snd_kcontrol_new p_term_mic1lm =;

static const struct snd_kcontrol_new m_term_mic1lm =;

static const struct snd_kcontrol_new aic31xx_dapm_hpl_switch =;

static const struct snd_kcontrol_new aic31xx_dapm_hpr_switch =;

static const struct snd_kcontrol_new aic31xx_dapm_spl_switch =;

static const struct snd_kcontrol_new aic31xx_dapm_spr_switch =;

static int mic_bias_event(struct snd_soc_dapm_widget *w,
			  struct snd_kcontrol *kcontrol, int event)
{}

static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] =;

static const struct snd_soc_dapm_widget dac31xx_dapm_widgets[] =;

static const struct snd_soc_dapm_widget aic31xx_dapm_widgets[] =;

static const struct snd_soc_dapm_widget aic311x_dapm_widgets[] =;

/* AIC3100 and AIC3120 have only mono class-D amplifier */
static const struct snd_soc_dapm_widget aic310x_dapm_widgets[] =;

static const struct snd_soc_dapm_route
common31xx_audio_map[] =;

static const struct snd_soc_dapm_route
dac31xx_audio_map[] =;

static const struct snd_soc_dapm_route
aic31xx_audio_map[] =;

static const struct snd_soc_dapm_route
aic311x_audio_map[] =;

static const struct snd_soc_dapm_route
aic310x_audio_map[] =;

/*
 * Always connected DAPM routes for codec clock master modes.
 * If the codec is the master on the I2S bus, we need to power up components
 * to have valid DAC_CLK.
 *
 * In order to have the I2S clocks on the bus either the DACs/ADC need to be
 * enabled, or the P0/R29/D2 (Keep bclk/wclk in power down) need to be set.
 *
 * Otherwise the codec will not generate clocks on the bus.
 */
static const struct snd_soc_dapm_route
common31xx_cm_audio_map[] =;

static const struct snd_soc_dapm_route
aic31xx_cm_audio_map[] =;

static int aic31xx_add_controls(struct snd_soc_component *component)
{}

static int aic31xx_add_widgets(struct snd_soc_component *component)
{}

static int aic31xx_setup_pll(struct snd_soc_component *component,
			     struct snd_pcm_hw_params *params)
{}

static int aic31xx_hw_params(struct snd_pcm_substream *substream,
			     struct snd_pcm_hw_params *params,
			     struct snd_soc_dai *dai)
{}

static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute,
			    int direction)
{}

static int aic31xx_clock_master_routes(struct snd_soc_component *component,
				       unsigned int fmt)
{}

static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai,
			       unsigned int fmt)
{}

static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
				  int clk_id, unsigned int freq, int dir)
{}

static int aic31xx_regulator_event(struct notifier_block *nb,
				   unsigned long event, void *data)
{}

static int aic31xx_reset(struct aic31xx_priv *aic31xx)
{}

static void aic31xx_clk_on(struct snd_soc_component *component)
{}

static void aic31xx_clk_off(struct snd_soc_component *component)
{}

static int aic31xx_power_on(struct snd_soc_component *component)
{}

static void aic31xx_power_off(struct snd_soc_component *component)
{}

static int aic31xx_set_bias_level(struct snd_soc_component *component,
				  enum snd_soc_bias_level level)
{}

static int aic31xx_set_jack(struct snd_soc_component *component,
			    struct snd_soc_jack *jack, void *data)
{}

static int aic31xx_codec_probe(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver soc_codec_driver_aic31xx =;

static const struct snd_soc_dai_ops aic31xx_dai_ops =;

static struct snd_soc_dai_driver dac31xx_dai_driver[] =;

static struct snd_soc_dai_driver aic31xx_dai_driver[] =;

#if defined(CONFIG_OF)
static const struct of_device_id tlv320aic31xx_of_match[] =;
MODULE_DEVICE_TABLE(of, tlv320aic31xx_of_match);
#endif /* CONFIG_OF */

#ifdef CONFIG_ACPI
static const struct acpi_device_id aic31xx_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, aic31xx_acpi_match);
#endif

static irqreturn_t aic31xx_irq(int irq, void *data)
{}

static void aic31xx_configure_ocmv(struct aic31xx_priv *priv)
{}

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

static int aic31xx_i2c_probe(struct i2c_client *i2c)
{}

static struct i2c_driver aic31xx_i2c_driver =;
module_i2c_driver();

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