linux/sound/soc/codecs/wm8960.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * wm8960.c  --  WM8960 ALSA SoC Audio driver
 *
 * Copyright 2007-11 Wolfson Microelectronics, plc
 *
 * Author: Liam Girdwood
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/clk.h>
#include <linux/i2c.h>
#include <linux/acpi.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include <sound/wm8960.h>

#include "wm8960.h"

/* R25 - Power 1 */
#define WM8960_VMID_MASK
#define WM8960_VREF

/* R26 - Power 2 */
#define WM8960_PWR2_LOUT1
#define WM8960_PWR2_ROUT1
#define WM8960_PWR2_OUT3

/* R28 - Anti-pop 1 */
#define WM8960_POBCTRL
#define WM8960_BUFDCOPEN
#define WM8960_BUFIOEN
#define WM8960_SOFT_ST
#define WM8960_HPSTBY

/* R29 - Anti-pop 2 */
#define WM8960_DISOP
#define WM8960_DRES_MASK

#define WM8960_DSCH_TOUT

static bool is_pll_freq_available(unsigned int source, unsigned int target);
static int wm8960_set_pll(struct snd_soc_component *component,
		unsigned int freq_in, unsigned int freq_out);
/*
 * wm8960 register cache
 * We can't read the WM8960 register space when we are
 * using 2 wire for device control, so we cache them instead.
 */
static const struct reg_default wm8960_reg_defaults[] =;

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

#define WM8960_NUM_SUPPLIES
static const char *wm8960_supply_names[WM8960_NUM_SUPPLIES] =;

struct wm8960_priv {};

#define wm8960_reset(c)

/* enumerated controls */
static const char *wm8960_polarity[] =;
static const char *wm8960_3d_upper_cutoff[] =;
static const char *wm8960_3d_lower_cutoff[] =;
static const char *wm8960_alcfunc[] =;
static const char *wm8960_alcmode[] =;
static const char *wm8960_adc_data_output_sel[] =;
static const char *wm8960_dmonomix[] =;
static const char *wm8960_dacslope[] =;

static const struct soc_enum wm8960_enum[] =;

static const int deemph_settings[] =;

static int wm8960_set_deemph(struct snd_soc_component *component)
{}

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

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

static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1);
static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1725, 75, 0);
static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1);
static const DECLARE_TLV_DB_SCALE(bypass_tlv, -2100, 300, 0);
static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
static const DECLARE_TLV_DB_SCALE(lineinboost_tlv, -1500, 300, 1);
static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(micboost_tlv,
	0, 1, TLV_DB_SCALE_ITEM(0, 1300, 0),
	2, 3, TLV_DB_SCALE_ITEM(2000, 900, 0),
);

static const struct snd_kcontrol_new wm8960_snd_controls[] =;

static const struct snd_kcontrol_new wm8960_lin_boost[] =;

static const struct snd_kcontrol_new wm8960_lin[] =;

static const struct snd_kcontrol_new wm8960_rin_boost[] =;

static const struct snd_kcontrol_new wm8960_rin[] =;

static const struct snd_kcontrol_new wm8960_loutput_mixer[] =;

static const struct snd_kcontrol_new wm8960_routput_mixer[] =;

static const struct snd_kcontrol_new wm8960_mono_out[] =;

static const struct snd_soc_dapm_widget wm8960_dapm_widgets[] =;

static const struct snd_soc_dapm_widget wm8960_dapm_widgets_out3[] =;

/* Represent OUT3 as a PGA so that it gets turned on with LOUT1/ROUT1 */
static const struct snd_soc_dapm_widget wm8960_dapm_widgets_capless[] =;

static const struct snd_soc_dapm_route audio_paths[] =;

static const struct snd_soc_dapm_route audio_paths_out3[] =;

static const struct snd_soc_dapm_route audio_paths_capless[] =;

static int wm8960_add_widgets(struct snd_soc_component *component)
{}

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

static struct {} alc_rates[] =;

/* -1 for reserved value */
static const int sysclk_divs[] =;

/* Multiply 256 for internal 256 div */
static const int dac_divs[] =;

/* Multiply 10 to eliminate decimials */
static const int bclk_divs[] =;

/**
 * wm8960_configure_sysclk - checks if there is a sysclk frequency available
 *	The sysclk must be chosen such that:
 *		- sysclk     = MCLK / sysclk_divs
 *		- lrclk      = sysclk / dac_divs
 *		- 10 * bclk  = sysclk / bclk_divs
 *
 * @wm8960: codec private data
 * @mclk: MCLK used to derive sysclk
 * @sysclk_idx: sysclk_divs index for found sysclk
 * @dac_idx: dac_divs index for found lrclk
 * @bclk_idx: bclk_divs index for found bclk
 *
 * Returns:
 *  -1, in case no sysclk frequency available found
 * >=0, in case we could derive bclk and lrclk from sysclk using
 *      (@sysclk_idx, @dac_idx, @bclk_idx) dividers
 */
static
int wm8960_configure_sysclk(struct wm8960_priv *wm8960, int mclk,
			    int *sysclk_idx, int *dac_idx, int *bclk_idx)
{}

/**
 * wm8960_configure_pll - checks if there is a PLL out frequency available
 *	The PLL out frequency must be chosen such that:
 *		- sysclk      = lrclk * dac_divs
 *		- freq_out    = sysclk * sysclk_divs
 *		- 10 * sysclk = bclk * bclk_divs
 *
 * 	If we cannot find an exact match for (sysclk, lrclk, bclk)
 * 	triplet, we relax the bclk such that bclk is chosen as the
 * 	closest available frequency greater than expected bclk.
 *
 * @component: component structure
 * @freq_in: input frequency used to derive freq out via PLL
 * @sysclk_idx: sysclk_divs index for found sysclk
 * @dac_idx: dac_divs index for found lrclk
 * @bclk_idx: bclk_divs index for found bclk
 *
 * Returns:
 * < 0, in case no PLL frequency out available was found
 * >=0, in case we could derive bclk, lrclk, sysclk from PLL out using
 *      (@sysclk_idx, @dac_idx, @bclk_idx) dividers
 */
static
int wm8960_configure_pll(struct snd_soc_component *component, int freq_in,
			 int *sysclk_idx, int *dac_idx, int *bclk_idx)
{}
static int wm8960_configure_clocking(struct snd_soc_component *component)
{}

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

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

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

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

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

/* PLL divisors */
struct _pll_div {};

static bool is_pll_freq_available(unsigned int source, unsigned int target)
{}

/* The size in bits of the pll divide multiplied by 10
 * to allow rounding later */
#define FIXED_PLL_SIZE

static int pll_factors(unsigned int source, unsigned int target,
		       struct _pll_div *pll_div)
{}

static int wm8960_set_pll(struct snd_soc_component *component,
		unsigned int freq_in, unsigned int freq_out)
{}

static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
		int source, unsigned int freq_in, unsigned int freq_out)
{}

static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
		int div_id, int div)
{}

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

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

#define WM8960_RATES

#define WM8960_FORMATS

static const struct snd_soc_dai_ops wm8960_dai_ops =;

static struct snd_soc_dai_driver wm8960_dai =;

static int wm8960_probe(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver soc_component_dev_wm8960 =;

static const struct regmap_config wm8960_regmap =;

static void wm8960_set_pdata_from_of(struct i2c_client *i2c,
				struct wm8960_data *pdata)
{}

static int wm8960_i2c_probe(struct i2c_client *i2c)
{}

static void wm8960_i2c_remove(struct i2c_client *client)
{}

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

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

#if defined(CONFIG_ACPI)
static const struct acpi_device_id wm8960_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, wm8960_acpi_match);
#endif

static struct i2c_driver wm8960_i2c_driver =;

module_i2c_driver();

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