linux/sound/soc/codecs/rt5663.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * rt5663.c  --  RT5663 ALSA SoC audio codec driver
 *
 * Copyright 2016 Realtek Semiconductor Corp.
 * Author: Jack Yu <[email protected]>
 */
#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/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/acpi.h>
#include <linux/regulator/consumer.h>
#include <linux/workqueue.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/jack.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include <sound/tlv.h>

#include "rt5663.h"
#include "rl6231.h"

#define RT5663_DEVICE_ID_2
#define RT5663_DEVICE_ID_1

#define RT5663_POWER_ON_DELAY_MS
#define RT5663_SUPPLY_CURRENT_UA

enum {};

struct impedance_mapping_table {};

static const char *const rt5663_supply_names[] =;

struct rt5663_priv {};

static const struct reg_sequence rt5663_patch_list[] =;

static const struct reg_default rt5663_v2_reg[] =;

static const struct reg_default rt5663_reg[] =;

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

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

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

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

static const DECLARE_TLV_DB_SCALE(rt5663_hp_vol_tlv, -2400, 150, 0);
static const DECLARE_TLV_DB_SCALE(rt5663_v2_hp_vol_tlv, -2250, 150, 0);
static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);

/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
static const DECLARE_TLV_DB_RANGE(in_bst_tlv,
	0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
	1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
	2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
	3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
	6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
	7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
	8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
);

/* Interface data select */
static const char * const rt5663_if1_adc_data_select[] =;

static SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2,
	RT5663_DATA_SWAP_ADCDAT1_SHIFT, rt5663_if1_adc_data_select);

static void rt5663_enable_push_button_irq(struct snd_soc_component *component,
	bool enable)
{}

/**
 * rt5663_v2_jack_detect - Detect headset.
 * @component: SoC audio component device.
 * @jack_insert: Jack insert or not.
 *
 * Detect whether is headset or not when jack inserted.
 *
 * Returns detect status.
 */

static int rt5663_v2_jack_detect(struct snd_soc_component *component, int jack_insert)
{}

/**
 * rt5663_jack_detect - Detect headset.
 * @component: SoC audio component device.
 * @jack_insert: Jack insert or not.
 *
 * Detect whether is headset or not when jack inserted.
 *
 * Returns detect status.
 */
static int rt5663_jack_detect(struct snd_soc_component *component, int jack_insert)
{}

static int rt5663_impedance_sensing(struct snd_soc_component *component)
{}

static int rt5663_button_detect(struct snd_soc_component *component)
{}

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

static int rt5663_set_jack_detect(struct snd_soc_component *component,
	struct snd_soc_jack *hs_jack, void *data)
{}

static bool rt5663_check_jd_status(struct snd_soc_component *component)
{}

static void rt5663_jack_detect_work(struct work_struct *work)
{}

static void rt5663_jd_unplug_work(struct work_struct *work)
{}

static const struct snd_kcontrol_new rt5663_snd_controls[] =;

static const struct snd_kcontrol_new rt5663_v2_specific_controls[] =;

static const struct snd_kcontrol_new rt5663_specific_controls[] =;

static const struct snd_kcontrol_new rt5663_hpvol_controls[] =;

static int rt5663_is_sys_clk_from_pll(struct snd_soc_dapm_widget *w,
	struct snd_soc_dapm_widget *sink)
{}

static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w,
	struct snd_soc_dapm_widget *sink)
{}

static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source,
	struct snd_soc_dapm_widget *sink)
{}

/**
 * rt5663_sel_asrc_clk_src - select ASRC clock source for a set of filters
 * @component: SoC audio component device.
 * @filter_mask: mask of filters.
 * @clk_src: clock source
 *
 * The ASRC function is for asynchronous MCLK and LRCK. Also, since RT5663 can
 * only support standard 32fs or 64fs i2s format, ASRC should be enabled to
 * support special i2s clock format such as Intel's 100fs(100 * sampling rate).
 * ASRC function will track i2s clock and generate a corresponding system clock
 * for codec. This function provides an API to select the clock source for a
 * set of filters specified by the mask. And the codec driver will turn on ASRC
 * for these filters if ASRC is selected as their clock source.
 */
int rt5663_sel_asrc_clk_src(struct snd_soc_component *component,
		unsigned int filter_mask, unsigned int clk_src)
{}
EXPORT_SYMBOL_GPL();

/* Analog Mixer */
static const struct snd_kcontrol_new rt5663_recmix1l[] =;

static const struct snd_kcontrol_new rt5663_recmix1r[] =;

/* Digital Mixer */
static const struct snd_kcontrol_new rt5663_sto1_adc_l_mix[] =;

static const struct snd_kcontrol_new rt5663_sto1_adc_r_mix[] =;

static const struct snd_kcontrol_new rt5663_adda_l_mix[] =;

static const struct snd_kcontrol_new rt5663_adda_r_mix[] =;

static const struct snd_kcontrol_new rt5663_sto1_dac_l_mix[] =;

static const struct snd_kcontrol_new rt5663_sto1_dac_r_mix[] =;

/* Out Switch */
static const struct snd_kcontrol_new rt5663_hpo_switch =;

/* Stereo ADC source */
static const char * const rt5663_sto1_adc_src[] =;

static SOC_ENUM_SINGLE_DECL(rt5663_sto1_adcl_enum, RT5663_STO1_ADC_MIXER,
	RT5663_STO1_ADC_L_SRC_SHIFT, rt5663_sto1_adc_src);

static const struct snd_kcontrol_new rt5663_sto1_adcl_mux =;

static SOC_ENUM_SINGLE_DECL(rt5663_sto1_adcr_enum, RT5663_STO1_ADC_MIXER,
	RT5663_STO1_ADC_R_SRC_SHIFT, rt5663_sto1_adc_src);

static const struct snd_kcontrol_new rt5663_sto1_adcr_mux =;

/* RT5663: Analog DACL1 input source */
static const char * const rt5663_alg_dacl_src[] =;

static SOC_ENUM_SINGLE_DECL(rt5663_alg_dacl_enum, RT5663_BYPASS_STO_DAC,
	RT5663_DACL1_SRC_SHIFT, rt5663_alg_dacl_src);

static const struct snd_kcontrol_new rt5663_alg_dacl_mux =;

/* RT5663: Analog DACR1 input source */
static const char * const rt5663_alg_dacr_src[] =;

static SOC_ENUM_SINGLE_DECL(rt5663_alg_dacr_enum, RT5663_BYPASS_STO_DAC,
	RT5663_DACR1_SRC_SHIFT, rt5663_alg_dacr_src);

static const struct snd_kcontrol_new rt5663_alg_dacr_mux =;

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

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

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

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

static const struct snd_soc_dapm_widget rt5663_dapm_widgets[] =;

static const struct snd_soc_dapm_widget rt5663_v2_specific_dapm_widgets[] =;

static const struct snd_soc_dapm_widget rt5663_specific_dapm_widgets[] =;

static const struct snd_soc_dapm_route rt5663_dapm_routes[] =;

static const struct snd_soc_dapm_route rt5663_v2_specific_dapm_routes[] =;

static const struct snd_soc_dapm_route rt5663_specific_dapm_routes[] =;

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

static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{}

static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
	unsigned int freq, int dir)
{}

static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
			unsigned int freq_in, unsigned int freq_out)
{}

static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
	unsigned int rx_mask, int slots, int slot_width)
{}

static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
{}

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

static int rt5663_probe(struct snd_soc_component *component)
{}

static void rt5663_remove(struct snd_soc_component *component)
{}

#ifdef CONFIG_PM
static int rt5663_suspend(struct snd_soc_component *component)
{}

static int rt5663_resume(struct snd_soc_component *component)
{}
#else
#define rt5663_suspend
#define rt5663_resume
#endif

#define RT5663_STEREO_RATES
#define RT5663_FORMATS

static const struct snd_soc_dai_ops rt5663_aif_dai_ops =;

static struct snd_soc_dai_driver rt5663_dai[] =;

static const struct snd_soc_component_driver soc_component_dev_rt5663 =;

static const struct regmap_config rt5663_v2_regmap =;

static const struct regmap_config rt5663_regmap =;

static const struct regmap_config temp_regmap =;

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

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

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

static void rt5663_v2_calibrate(struct rt5663_priv *rt5663)
{}

static void rt5663_calibrate(struct rt5663_priv *rt5663)
{}

static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev)
{}

static int rt5663_i2c_probe(struct i2c_client *i2c)
{}

static void rt5663_i2c_remove(struct i2c_client *i2c)
{}

static void rt5663_i2c_shutdown(struct i2c_client *client)
{}

static struct i2c_driver rt5663_i2c_driver =;
module_i2c_driver();

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