linux/sound/soc/codecs/tlv320aic23.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * ALSA SoC TLV320AIC23 codec driver
 *
 * Author:      Arun KS, <[email protected]>
 * Copyright:   (C) 2008 Mistral Solutions Pvt Ltd.,
 *
 * Based on sound/soc/codecs/wm8731.c by Richard Purdie
 *
 * Notes:
 *  The AIC23 is a driver for a low power stereo audio
 *  codec tlv320aic23
 *
 *  The machine layer should disable unsupported inputs/outputs by
 *  snd_soc_dapm_disable_pin(codec, "LHPOUT"), etc.
 */

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

#include "tlv320aic23.h"

/*
 * AIC23 register cache
 */
static const struct reg_default tlv320aic23_reg[] =;

const struct regmap_config tlv320aic23_regmap =;
EXPORT_SYMBOL();

static const char *rec_src_text[] =;
static const char *deemph_text[] =;

static SOC_ENUM_SINGLE_DECL(rec_src_enum,
			    TLV320AIC23_ANLG, 2, rec_src_text);

static const struct snd_kcontrol_new tlv320aic23_rec_src_mux_controls =;

static SOC_ENUM_SINGLE_DECL(tlv320aic23_deemph,
			    TLV320AIC23_DIGT, 1, deemph_text);

static const DECLARE_TLV_DB_SCALE(out_gain_tlv, -12100, 100, 0);
static const DECLARE_TLV_DB_SCALE(input_gain_tlv, -1725, 75, 0);
static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0);

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

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

static const struct snd_kcontrol_new tlv320aic23_snd_controls[] =;

/* PGA Mixer controls for Line and Mic switch */
static const struct snd_kcontrol_new tlv320aic23_output_mixer_controls[] =;

static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] =;

static const struct snd_soc_dapm_route tlv320aic23_intercon[] =;

/* AIC23 driver data */
struct aic23 {};

/*
 * Common Crystals used
 * 11.2896 Mhz /128 = *88.2k  /192 = 58.8k
 * 12.0000 Mhz /125 = *96k    /136 = 88.235K
 * 12.2880 Mhz /128 = *96k    /192 = 64k
 * 16.9344 Mhz /128 = 132.3k /192 = *88.2k
 * 18.4320 Mhz /128 = 144k   /192 = *96k
 */

/*
 * Normal BOSR 0-256/2 = 128, 1-384/2 = 192
 * USB BOSR 0-250/2 = 125, 1-272/2 = 136
 */
static const int bosr_usb_divisor_table[] =;
#define LOWER_GROUP
#define UPPER_GROUP
static const unsigned short sr_valid_mask[] =;
/*
 * Every divisor is a factor of 11*12
 */
#define SR_MULT
#define A(x)
static const unsigned char sr_adc_mult_table[] =;
static const unsigned char sr_dac_mult_table[] =;

static unsigned get_score(int adc, int adc_l, int adc_h, int need_adc,
		int dac, int dac_l, int dac_h, int need_dac)
{}

static int find_rate(int mclk, u32 need_adc, u32 need_dac)
{}

#ifdef DEBUG
static void get_current_sample_rates(struct snd_soc_component *component, int mclk,
		u32 *sample_rate_adc, u32 *sample_rate_dac)
{
	int src = snd_soc_component_read(component, TLV320AIC23_SRATE);
	int sr = (src >> 2) & 0x0f;
	int val = (mclk / bosr_usb_divisor_table[src & 3]);
	int adc = (val * sr_adc_mult_table[sr]) / SR_MULT;
	int dac = (val * sr_dac_mult_table[sr]) / SR_MULT;
	if (src & TLV320AIC23_CLKIN_HALF) {
		adc >>= 1;
		dac >>= 1;
	}
	*sample_rate_adc = adc;
	*sample_rate_dac = dac;
}
#endif

static int set_sample_rate_control(struct snd_soc_component *component, int mclk,
		u32 sample_rate_adc, u32 sample_rate_dac)
{}

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

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

static void tlv320aic23_shutdown(struct snd_pcm_substream *substream,
				 struct snd_soc_dai *dai)
{}

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

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

static int tlv320aic23_set_dai_sysclk(struct snd_soc_dai *codec_dai,
				      int clk_id, unsigned int freq, int dir)
{}

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

#define AIC23_RATES
#define AIC23_FORMATS

static const struct snd_soc_dai_ops tlv320aic23_dai_ops =;

static struct snd_soc_dai_driver tlv320aic23_dai =;

static int tlv320aic23_resume(struct snd_soc_component *component)
{}

static int tlv320aic23_component_probe(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver soc_component_dev_tlv320aic23 =;

int tlv320aic23_probe(struct device *dev, struct regmap *regmap)
{}
EXPORT_SYMBOL();

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