linux/sound/soc/codecs/alc5632.c

// SPDX-License-Identifier: GPL-2.0-only
/*
* alc5632.c  --  ALC5632 ALSA SoC Audio Codec
*
* Copyright (C) 2011 The AC100 Kernel Team <[email protected]>
*
* Authors:  Leon Romanovsky <[email protected]>
*           Andrey Danin <[email protected]>
*           Ilya Petrov <[email protected]>
*           Marc Dietrich <[email protected]>
*
* Based on alc5623.c by Arnaud Patard
*/

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/tlv.h>
#include <sound/soc.h>
#include <sound/initval.h>

#include "alc5632.h"

/*
 * ALC5632 register cache
 */
static const struct reg_default alc5632_reg_defaults[] =;

/* codec private data */
struct alc5632_priv {};

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

static inline int alc5632_reset(struct regmap *map)
{}

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

/*
 * ALC5632 Controls
 */

/* -34.5db min scale, 1.5db steps, no mute */
static const DECLARE_TLV_DB_SCALE(vol_tlv, -3450, 150, 0);
/* -46.5db min scale, 1.5db steps, no mute */
static const DECLARE_TLV_DB_SCALE(hp_tlv, -4650, 150, 0);
/* -16.5db min scale, 1.5db steps, no mute */
static const DECLARE_TLV_DB_SCALE(adc_rec_tlv, -1650, 150, 0);
static const DECLARE_TLV_DB_RANGE(boost_tlv,
	0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0),
	1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0)
);
/* 0db min scale, 6 db steps, no mute */
static const DECLARE_TLV_DB_SCALE(dig_tlv, 0, 600, 0);
/* 0db min scalem 0.75db steps, no mute */
static const DECLARE_TLV_DB_SCALE(vdac_tlv, -3525, 75, 0);

static const struct snd_kcontrol_new alc5632_vol_snd_controls[] =;

static const struct snd_kcontrol_new alc5632_snd_controls[] =;

/*
 * DAPM Controls
 */
static const struct snd_kcontrol_new alc5632_hp_mixer_controls[] =;

static const struct snd_kcontrol_new alc5632_hpl_mixer_controls[] =;

static const struct snd_kcontrol_new alc5632_hpr_mixer_controls[] =;

static const struct snd_kcontrol_new alc5632_mono_mixer_controls[] =;

static const struct snd_kcontrol_new alc5632_speaker_mixer_controls[] =;

/* Left Record Mixer */
static const struct snd_kcontrol_new alc5632_captureL_mixer_controls[] =;

/* Right Record Mixer */
static const struct snd_kcontrol_new alc5632_captureR_mixer_controls[] =;

/* Dmic Mixer */
static const struct snd_kcontrol_new alc5632_dmicl_mixer_controls[] =;
static const struct snd_kcontrol_new alc5632_dmicr_mixer_controls[] =;

static const char * const alc5632_spk_n_sour_sel[] =;
static const char * const alc5632_hpl_out_input_sel[] =;
static const char * const alc5632_hpr_out_input_sel[] =;
static const char * const alc5632_spkout_input_sel[] =;
static const char * const alc5632_aux_out_input_sel[] =;
static const char * const alc5632_adcr_func_sel[] =;
static const char * const alc5632_i2s_out_sel[] =;

/* auxout output mux */
static SOC_ENUM_SINGLE_DECL(alc5632_aux_out_input_enum,
			    ALC5632_OUTPUT_MIXER_CTRL, 6,
			    alc5632_aux_out_input_sel);
static const struct snd_kcontrol_new alc5632_auxout_mux_controls =;

/* speaker output mux */
static SOC_ENUM_SINGLE_DECL(alc5632_spkout_input_enum,
			    ALC5632_OUTPUT_MIXER_CTRL, 10,
			    alc5632_spkout_input_sel);
static const struct snd_kcontrol_new alc5632_spkout_mux_controls =;

/* headphone left output mux */
static SOC_ENUM_SINGLE_DECL(alc5632_hpl_out_input_enum,
			    ALC5632_OUTPUT_MIXER_CTRL, 9,
			    alc5632_hpl_out_input_sel);
static const struct snd_kcontrol_new alc5632_hpl_out_mux_controls =;

/* headphone right output mux */
static SOC_ENUM_SINGLE_DECL(alc5632_hpr_out_input_enum,
			    ALC5632_OUTPUT_MIXER_CTRL, 8,
			    alc5632_hpr_out_input_sel);
static const struct snd_kcontrol_new alc5632_hpr_out_mux_controls =;

/* speaker output N select */
static SOC_ENUM_SINGLE_DECL(alc5632_spk_n_sour_enum,
			    ALC5632_OUTPUT_MIXER_CTRL, 14,
			    alc5632_spk_n_sour_sel);
static const struct snd_kcontrol_new alc5632_spkoutn_mux_controls =;

/* speaker amplifier */
static const char *alc5632_amp_names[] =;
static SOC_ENUM_SINGLE_DECL(alc5632_amp_enum,
			    ALC5632_OUTPUT_MIXER_CTRL, 13,
			    alc5632_amp_names);
static const struct snd_kcontrol_new alc5632_amp_mux_controls =;

/* ADC output select */
static SOC_ENUM_SINGLE_DECL(alc5632_adcr_func_enum,
			    ALC5632_DAC_FUNC_SELECT, 5,
			    alc5632_adcr_func_sel);
static const struct snd_kcontrol_new alc5632_adcr_func_controls =;

/* I2S out select */
static SOC_ENUM_SINGLE_DECL(alc5632_i2s_out_enum,
			    ALC5632_I2S_OUT_CTL, 5,
			    alc5632_i2s_out_sel);
static const struct snd_kcontrol_new alc5632_i2s_out_controls =;

static const struct snd_soc_dapm_widget alc5632_dapm_widgets[] =;


static const struct snd_soc_dapm_route alc5632_dapm_routes[] =;

/* PLL divisors */
struct _pll_div {};

/* Note : pll code from original alc5632 driver. Not sure of how good it is */
/* useful only for master mode */
static const struct _pll_div codec_master_pll_div[] =;

/* FOUT = MCLK*(N+2)/((M+2)*(K+2))
   N: bit 15:8 (div 2 .. div 257)
   K: bit  6:4 typical 2
   M: bit  3:0 (div 2 .. div 17)

   same as for 5623 - thanks!
*/

static const struct _pll_div codec_slave_pll_div[] =;

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

struct _coeff_div {};

/* codec hifi mclk (after PLL) clock divider coefficients */
/* values inspired from column BCLK=32Fs of Appendix A table */
static const struct _coeff_div coeff_div[] =;

static int get_coeff(struct snd_soc_component *component, int rate)
{}

/*
 * Clock after PLL and dividers
 */
static int alc5632_set_dai_sysclk(struct snd_soc_dai *codec_dai,
		int clk_id, unsigned int freq, int dir)
{}

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

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

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

#define ALC5632_ADD2_POWER_EN

#define ALC5632_ADD3_POWER_EN

#define ALC5632_ADD1_POWER_EN

static void enable_power_depop(struct snd_soc_component *component)
{}

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

#define ALC5632_FORMATS

static const struct snd_soc_dai_ops alc5632_dai_ops =;

static struct snd_soc_dai_driver alc5632_dai =;

#ifdef CONFIG_PM
static int alc5632_resume(struct snd_soc_component *component)
{}
#else
#define alc5632_resume
#endif

static int alc5632_probe(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver soc_component_device_alc5632 =;

static const struct regmap_config alc5632_regmap =;

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

/*
 * alc5632 2 wire address is determined by A1 pin
 * state during powerup.
 *    low  = 0x1a
 *    high = 0x1b
 */
static int alc5632_i2c_probe(struct i2c_client *client)
{}

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

/* i2c codec control layer */
static struct i2c_driver alc5632_i2c_driver =;

module_i2c_driver();

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