linux/sound/soc/codecs/rt5640.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * rt5640.c  --  RT5640/RT5639 ALSA SoC audio codec driver
 *
 * Copyright 2011 Realtek Semiconductor Corp.
 * Author: Johnny Hsu <[email protected]>
 * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/acpi.h>
#include <sound/core.h>
#include <sound/jack.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 "rl6231.h"
#include "rt5640.h"

#define RT5640_DEVICE_ID

#define RT5640_PR_RANGE_BASE
#define RT5640_PR_SPACING

#define RT5640_PR_BASE

static const struct regmap_range_cfg rt5640_ranges[] =;

static const struct reg_sequence init_list[] =;

static const struct reg_default rt5640_reg[] =;

static int rt5640_reset(struct snd_soc_component *component)
{}

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

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

static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0);
static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000);
static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);

/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
static const DECLARE_TLV_DB_RANGE(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 rt5640_data_select[] =;

static SOC_ENUM_SINGLE_DECL(rt5640_if1_dac_enum, RT5640_DIG_INF_DATA,
			    RT5640_IF1_DAC_SEL_SFT, rt5640_data_select);

static SOC_ENUM_SINGLE_DECL(rt5640_if1_adc_enum, RT5640_DIG_INF_DATA,
			    RT5640_IF1_ADC_SEL_SFT, rt5640_data_select);

static SOC_ENUM_SINGLE_DECL(rt5640_if2_dac_enum, RT5640_DIG_INF_DATA,
			    RT5640_IF2_DAC_SEL_SFT, rt5640_data_select);

static SOC_ENUM_SINGLE_DECL(rt5640_if2_adc_enum, RT5640_DIG_INF_DATA,
			    RT5640_IF2_ADC_SEL_SFT, rt5640_data_select);

/* Class D speaker gain ratio */
static const char * const rt5640_clsd_spk_ratio[] =;

static SOC_ENUM_SINGLE_DECL(rt5640_clsd_spk_ratio_enum, RT5640_CLS_D_OUT,
			    RT5640_CLSD_RATIO_SFT, rt5640_clsd_spk_ratio);

static const struct snd_kcontrol_new rt5640_snd_controls[] =;

static const struct snd_kcontrol_new rt5640_specific_snd_controls[] =;

/**
 * set_dmic_clk - Set parameter of dmic.
 *
 * @w: DAPM widget.
 * @kcontrol: The kcontrol of this widget.
 * @event: Event id.
 *
 */
static int set_dmic_clk(struct snd_soc_dapm_widget *w,
	struct snd_kcontrol *kcontrol, int event)
{}

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

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

static const struct snd_kcontrol_new rt5640_sto_adc_r_mix[] =;

static const struct snd_kcontrol_new rt5640_mono_adc_l_mix[] =;

static const struct snd_kcontrol_new rt5640_mono_adc_r_mix[] =;

static const struct snd_kcontrol_new rt5640_dac_l_mix[] =;

static const struct snd_kcontrol_new rt5640_dac_r_mix[] =;

static const struct snd_kcontrol_new rt5640_sto_dac_l_mix[] =;

static const struct snd_kcontrol_new rt5640_sto_dac_r_mix[] =;

static const struct snd_kcontrol_new rt5639_sto_dac_l_mix[] =;

static const struct snd_kcontrol_new rt5639_sto_dac_r_mix[] =;

static const struct snd_kcontrol_new rt5640_mono_dac_l_mix[] =;

static const struct snd_kcontrol_new rt5640_mono_dac_r_mix[] =;

static const struct snd_kcontrol_new rt5640_dig_l_mix[] =;

static const struct snd_kcontrol_new rt5640_dig_r_mix[] =;

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

static const struct snd_kcontrol_new rt5640_rec_r_mix[] =;

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

static const struct snd_kcontrol_new rt5640_spk_r_mix[] =;

static const struct snd_kcontrol_new rt5640_out_l_mix[] =;

static const struct snd_kcontrol_new rt5640_out_r_mix[] =;

static const struct snd_kcontrol_new rt5639_out_l_mix[] =;

static const struct snd_kcontrol_new rt5639_out_r_mix[] =;

static const struct snd_kcontrol_new rt5640_spo_l_mix[] =;

static const struct snd_kcontrol_new rt5640_spo_r_mix[] =;

static const struct snd_kcontrol_new rt5640_hpo_mix[] =;

static const struct snd_kcontrol_new rt5639_hpo_mix[] =;

static const struct snd_kcontrol_new rt5640_lout_mix[] =;

static const struct snd_kcontrol_new rt5640_mono_mix[] =;

static const struct snd_kcontrol_new spk_l_enable_control =;

static const struct snd_kcontrol_new spk_r_enable_control =;

static const struct snd_kcontrol_new hp_l_enable_control =;

static const struct snd_kcontrol_new hp_r_enable_control =;

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

static SOC_ENUM_SINGLE_DECL(rt5640_stereo_adc1_enum, RT5640_STO_ADC_MIXER,
			    RT5640_ADC_1_SRC_SFT, rt5640_stereo_adc1_src);

static const struct snd_kcontrol_new rt5640_sto_adc_1_mux =;

static const char * const rt5640_stereo_adc2_src[] =;

static SOC_ENUM_SINGLE_DECL(rt5640_stereo_adc2_enum, RT5640_STO_ADC_MIXER,
			    RT5640_ADC_2_SRC_SFT, rt5640_stereo_adc2_src);

static const struct snd_kcontrol_new rt5640_sto_adc_2_mux =;

/* Mono ADC source */
static const char * const rt5640_mono_adc_l1_src[] =;

static SOC_ENUM_SINGLE_DECL(rt5640_mono_adc_l1_enum, RT5640_MONO_ADC_MIXER,
			    RT5640_MONO_ADC_L1_SRC_SFT, rt5640_mono_adc_l1_src);

static const struct snd_kcontrol_new rt5640_mono_adc_l1_mux =;

static const char * const rt5640_mono_adc_l2_src[] =;

static SOC_ENUM_SINGLE_DECL(rt5640_mono_adc_l2_enum, RT5640_MONO_ADC_MIXER,
			    RT5640_MONO_ADC_L2_SRC_SFT, rt5640_mono_adc_l2_src);

static const struct snd_kcontrol_new rt5640_mono_adc_l2_mux =;

static const char * const rt5640_mono_adc_r1_src[] =;

static SOC_ENUM_SINGLE_DECL(rt5640_mono_adc_r1_enum, RT5640_MONO_ADC_MIXER,
			    RT5640_MONO_ADC_R1_SRC_SFT, rt5640_mono_adc_r1_src);

static const struct snd_kcontrol_new rt5640_mono_adc_r1_mux =;

static const char * const rt5640_mono_adc_r2_src[] =;

static SOC_ENUM_SINGLE_DECL(rt5640_mono_adc_r2_enum, RT5640_MONO_ADC_MIXER,
			    RT5640_MONO_ADC_R2_SRC_SFT, rt5640_mono_adc_r2_src);

static const struct snd_kcontrol_new rt5640_mono_adc_r2_mux =;

/* DAC2 channel source */
static const char * const rt5640_dac_l2_src[] =;

static int rt5640_dac_l2_values[] =;

static SOC_VALUE_ENUM_SINGLE_DECL(rt5640_dac_l2_enum,
				  RT5640_DSP_PATH2, RT5640_DAC_L2_SEL_SFT,
				  0x3, rt5640_dac_l2_src, rt5640_dac_l2_values);

static const struct snd_kcontrol_new rt5640_dac_l2_mux =;

static const char * const rt5640_dac_r2_src[] =;

static int rt5640_dac_r2_values[] =;

static SOC_VALUE_ENUM_SINGLE_DECL(rt5640_dac_r2_enum,
				  RT5640_DSP_PATH2, RT5640_DAC_R2_SEL_SFT,
				  0x3, rt5640_dac_r2_src, rt5640_dac_r2_values);

static const struct snd_kcontrol_new rt5640_dac_r2_mux =;

/* digital interface and iis interface map */
static const char * const rt5640_dai_iis_map[] =;

static int rt5640_dai_iis_map_values[] =;

static SOC_VALUE_ENUM_SINGLE_DECL(rt5640_dai_iis_map_enum,
				  RT5640_I2S1_SDP, RT5640_I2S_IF_SFT,
				  0x7, rt5640_dai_iis_map,
				  rt5640_dai_iis_map_values);

static const struct snd_kcontrol_new rt5640_dai_mux =;

/* SDI select */
static const char * const rt5640_sdi_sel[] =;

static SOC_ENUM_SINGLE_DECL(rt5640_sdi_sel_enum, RT5640_I2S2_SDP,
			    RT5640_I2S2_SDI_SFT, rt5640_sdi_sel);

static const struct snd_kcontrol_new rt5640_sdi_mux =;

static void hp_amp_power_on(struct snd_soc_component *component)
{}

static void rt5640_pmu_depop(struct snd_soc_component *component)
{}

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

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

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

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

static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] =;

static const struct snd_soc_dapm_widget rt5640_specific_dapm_widgets[] =;

static const struct snd_soc_dapm_widget rt5639_specific_dapm_widgets[] =;

static const struct snd_soc_dapm_route rt5640_dapm_routes[] =;

static const struct snd_soc_dapm_route rt5640_specific_dapm_routes[] =;

static const struct snd_soc_dapm_route rt5639_specific_dapm_routes[] =;

static int get_sdp_info(struct snd_soc_component *component, int dai_id)
{}

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

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

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

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

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

int rt5640_dmic_enable(struct snd_soc_component *component,
		       bool dmic1_data_pin, bool dmic2_data_pin)
{}
EXPORT_SYMBOL_GPL();

int rt5640_sel_asrc_clk_src(struct snd_soc_component *component,
		unsigned int filter_mask, unsigned int clk_src)
{}
EXPORT_SYMBOL_GPL();

void rt5640_enable_micbias1_for_ovcd(struct snd_soc_component *component)
{}
EXPORT_SYMBOL_GPL();

void rt5640_disable_micbias1_for_ovcd(struct snd_soc_component *component)
{}
EXPORT_SYMBOL_GPL();

static void rt5640_enable_micbias1_ovcd_irq(struct snd_soc_component *component)
{}

static void rt5640_disable_micbias1_ovcd_irq(struct snd_soc_component *component)
{}

static void rt5640_clear_micbias1_ovcd(struct snd_soc_component *component)
{}

static bool rt5640_micbias1_ovcd(struct snd_soc_component *component)
{}

static bool rt5640_jack_inserted(struct snd_soc_component *component)
{}

/* Jack detect and button-press timings */
#define JACK_SETTLE_TIME
#define JACK_DETECT_COUNT
#define JACK_DETECT_MAXCOUNT
#define JACK_UNPLUG_TIME
#define BP_POLL_TIME
#define BP_POLL_MAXCOUNT
#define BP_THRESHOLD

static void rt5640_start_button_press_work(struct snd_soc_component *component)
{}

static void rt5640_button_press_work(struct work_struct *work)
{}

int rt5640_detect_headset(struct snd_soc_component *component, struct gpio_desc *hp_det_gpio)
{}
EXPORT_SYMBOL_GPL();

static void rt5640_jack_work(struct work_struct *work)
{}

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

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

static void rt5640_disable_irq_and_cancel_work(void *data)
{}

void rt5640_set_ovcd_params(struct snd_soc_component *component)
{}
EXPORT_SYMBOL_GPL();

static void rt5640_disable_jack_detect(struct snd_soc_component *component)
{}

static void rt5640_enable_jack_detect(struct snd_soc_component *component,
				      struct snd_soc_jack *jack,
				      struct rt5640_set_jack_data *jack_data)
{}

static const struct snd_soc_dapm_route rt5640_hda_jack_dapm_routes[] =;

static void rt5640_enable_hda_jack_detect(
	struct snd_soc_component *component, struct snd_soc_jack *jack)
{}

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

static int rt5640_probe(struct snd_soc_component *component)
{}

static void rt5640_remove(struct snd_soc_component *component)
{}

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

static int rt5640_resume(struct snd_soc_component *component)
{}
#else
#define rt5640_suspend
#define rt5640_resume
#endif

#define RT5640_STEREO_RATES
#define RT5640_FORMATS

static const struct snd_soc_dai_ops rt5640_aif_dai_ops =;

static struct snd_soc_dai_driver rt5640_dai[] =;

static const struct snd_soc_component_driver soc_component_dev_rt5640 =;

static const struct regmap_config rt5640_regmap =;

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

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

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

static int rt5640_i2c_probe(struct i2c_client *i2c)
{}

static struct i2c_driver rt5640_i2c_driver =;
module_i2c_driver();

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