linux/sound/soc/codecs/nau8821.c

// SPDX-License-Identifier: GPL-2.0-only
//
// nau8821.c -- Nuvoton NAU88L21 audio codec driver
//
// Copyright 2021 Nuvoton Technology Corp.
// Author: John Hsu <[email protected]>
// Co-author: Seven Lee <[email protected]>
//

#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dmi.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/math64.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include "nau8821.h"

#define NAU8821_JD_ACTIVE_HIGH

static int nau8821_quirk;
static int quirk_override =;
module_param_named(quirk, quirk_override, uint, 0444);
MODULE_PARM_DESC();

#define NAU_FREF_MAX
#define NAU_FVCO_MAX
#define NAU_FVCO_MIN

#define NAU8821_BUTTON

/* the maximum frequency of CLK_ADC and CLK_DAC */
#define CLK_DA_AD_MAX

static int nau8821_configure_sysclk(struct nau8821 *nau8821,
	int clk_id, unsigned int freq);
static bool nau8821_is_jack_inserted(struct regmap *regmap);

struct nau8821_fll {};

struct nau8821_fll_attr {};

/* scaling for mclk from sysclk_src output */
static const struct nau8821_fll_attr mclk_src_scaling[] =;

/* ratio for input clk freq */
static const struct nau8821_fll_attr fll_ratio[] =;

static const struct nau8821_fll_attr fll_pre_scalar[] =;

/* over sampling rate */
struct nau8821_osr_attr {};

static const struct nau8821_osr_attr osr_dac_sel[] =;

static const struct nau8821_osr_attr osr_adc_sel[] =;

struct nau8821_dmic_speed {};

static const struct nau8821_dmic_speed dmic_speed_sel[] =;

static const struct reg_default nau8821_reg_defaults[] =;

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

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

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

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

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

static const char * const nau8821_adc_decimation[] =;

static const struct soc_enum nau8821_adc_decimation_enum =;

static const char * const nau8821_dac_oversampl[] =;

static const struct soc_enum nau8821_dac_oversampl_enum =;

static const char * const nau8821_adc_drc_noise_gate[] =;

static const struct soc_enum nau8821_adc_drc_noise_gate_enum =;

static const char * const nau8821_adc_drc_expansion_slope[] =;

static const struct soc_enum nau8821_adc_drc_expansion_slope_enum =;

static const char * const nau8821_adc_drc_lower_region[] =;

static const struct soc_enum nau8821_adc_drc_lower_region_enum =;

static const char * const nau8821_higher_region[] =;

static const struct soc_enum nau8821_higher_region_enum =;

static const char * const nau8821_limiter_slope[] =;

static const struct soc_enum nau8821_limiter_slope_enum =;

static const char * const nau8821_detection_attack_time[] =;

static const struct soc_enum nau8821_detection_attack_time_enum =;

static const char * const nau8821_detection_release_time[] =;

static const struct soc_enum nau8821_detection_release_time_enum =;

static const char * const nau8821_attack_time[] =;

static const struct soc_enum nau8821_attack_time_enum =;

static const char * const nau8821_decay_time[] =;

static const struct soc_enum nau8821_decay_time_enum =;

static const DECLARE_TLV_DB_MINMAX_MUTE(adc_vol_tlv, -6600, 2400);
static const DECLARE_TLV_DB_MINMAX_MUTE(sidetone_vol_tlv, -4200, 0);
static const DECLARE_TLV_DB_MINMAX(hp_vol_tlv, -900, 0);
static const DECLARE_TLV_DB_SCALE(playback_vol_tlv, -6600, 50, 1);
static const DECLARE_TLV_DB_MINMAX(fepga_gain_tlv, -100, 3600);
static const DECLARE_TLV_DB_MINMAX_MUTE(crosstalk_vol_tlv, -7000, 2400);
static const DECLARE_TLV_DB_MINMAX(drc_knee4_tlv, -9800, -3500);
static const DECLARE_TLV_DB_MINMAX(drc_knee3_tlv, -8100, -1800);

static const struct snd_kcontrol_new nau8821_controls[] =;

static const struct snd_kcontrol_new nau8821_dmic_mode_switch =;

static int dmic_clock_control(struct snd_soc_dapm_widget *w,
		struct snd_kcontrol *k, int  event)
{}

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

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

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

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

static int system_clock_control(struct snd_soc_dapm_widget *w,
				struct snd_kcontrol *k, int  event)
{}

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

static const struct snd_soc_dapm_widget nau8821_dapm_widgets[] =;

static const struct snd_soc_dapm_route nau8821_dapm_routes[] =;

static const struct nau8821_osr_attr *
nau8821_get_osr(struct nau8821 *nau8821, int stream)
{}

static int nau8821_dai_startup(struct snd_pcm_substream *substream,
			       struct snd_soc_dai *dai)
{}

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

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

static int nau8821_digital_mute(struct snd_soc_dai *dai, int mute,
		int direction)
{}

static const struct snd_soc_dai_ops nau8821_dai_ops =;

#define NAU8821_RATES
#define NAU8821_FORMATS

static struct snd_soc_dai_driver nau8821_dai =;


static bool nau8821_is_jack_inserted(struct regmap *regmap)
{}

static void nau8821_int_status_clear_all(struct regmap *regmap)
{}

static void nau8821_eject_jack(struct nau8821 *nau8821)
{}

static void nau8821_jdet_work(struct work_struct *work)
{}

/* Enable interruptions with internal clock. */
static void nau8821_setup_inserted_irq(struct nau8821 *nau8821)
{}

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

static const struct regmap_config nau8821_regmap_config =;

static int nau8821_component_probe(struct snd_soc_component *component)
{}

/**
 * nau8821_calc_fll_param - Calculate FLL parameters.
 * @fll_in: external clock provided to codec.
 * @fs: sampling rate.
 * @fll_param: Pointer to structure of FLL parameters.
 *
 * Calculate FLL parameters to configure codec.
 *
 * Returns 0 for success or negative error code.
 */
static int nau8821_calc_fll_param(unsigned int fll_in,
	unsigned int fs, struct nau8821_fll *fll_param)
{}

static void nau8821_fll_apply(struct nau8821 *nau8821,
		struct nau8821_fll *fll_param)
{}

/**
 * nau8821_set_fll - FLL configuration of nau8821
 * @component:  codec component
 * @pll_id:  PLL requested
 * @source:  clock source
 * @freq_in:  frequency of input clock source
 * @freq_out:  must be 256*Fs in order to achieve the best performance
 *
 * The FLL function can select BCLK or MCLK as the input clock source.
 *
 * Returns 0 if the parameters have been applied successfully
 * or negative error code.
 */
static int nau8821_set_fll(struct snd_soc_component *component,
	int pll_id, int source, unsigned int freq_in, unsigned int freq_out)
{}

static void nau8821_configure_mclk_as_sysclk(struct regmap *regmap)
{}

static int nau8821_configure_sysclk(struct nau8821 *nau8821,
	int clk_id, unsigned int freq)
{}

static int nau8821_set_sysclk(struct snd_soc_component *component, int clk_id,
	int source, unsigned int freq, int dir)
{}

static int nau8821_resume_setup(struct nau8821 *nau8821)
{}

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

static int __maybe_unused nau8821_suspend(struct snd_soc_component *component)
{}

static int __maybe_unused nau8821_resume(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver nau8821_component_driver =;

/**
 * nau8821_enable_jack_detect - Specify a jack for event reporting
 *
 * @component:  component to register the jack with
 * @jack: jack to use to report headset and button events on
 *
 * After this function has been called the headset insert/remove and button
 * events will be routed to the given jack.  Jack can be null to stop
 * reporting.
 */
int nau8821_enable_jack_detect(struct snd_soc_component *component,
	struct snd_soc_jack *jack)
{}
EXPORT_SYMBOL_GPL();

static void nau8821_reset_chip(struct regmap *regmap)
{}

static void nau8821_print_device_properties(struct nau8821 *nau8821)
{}

static int nau8821_read_device_properties(struct device *dev,
	struct nau8821 *nau8821)
{}

static void nau8821_init_regs(struct nau8821 *nau8821)
{}

static int nau8821_setup_irq(struct nau8821 *nau8821)
{}

/* Please keep this list alphabetically sorted */
static const struct dmi_system_id nau8821_quirk_table[] =;

static void nau8821_check_quirks(void)
{}

static int nau8821_i2c_probe(struct i2c_client *i2c)
{}

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

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

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

static struct i2c_driver nau8821_driver =;
module_i2c_driver();

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