linux/sound/pci/hda/patch_cirrus.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * HD audio interface patch for Cirrus Logic CS420x chip
 *
 * Copyright (c) 2009 Takashi Iwai <[email protected]>
 */

#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <sound/core.h>
#include <linux/pci.h>
#include <sound/tlv.h>
#include <sound/hda_codec.h>
#include "hda_local.h"
#include "hda_auto_parser.h"
#include "hda_jack.h"
#include "hda_generic.h"

/*
 */

struct cs_spec {};

/* available models with CS420x */
enum {};

/* CS421x boards */
enum {};

/* Vendor-specific processing widget */
#define CS420X_VENDOR_NID
#define CS_DIG_OUT1_PIN_NID
#define CS_DIG_OUT2_PIN_NID
#define CS_DMIC1_PIN_NID
#define CS_DMIC2_PIN_NID

/* coef indices */
#define IDX_SPDIF_STAT
#define IDX_SPDIF_CTL
#define IDX_ADC_CFG
/* SZC bitmask, 4 modes below:
 * 0 = immediate,
 * 1 = digital immediate, analog zero-cross
 * 2 = digtail & analog soft-ramp
 * 3 = digital soft-ramp, analog zero-cross
 */
#define CS_COEF_ADC_SZC_MASK
#define CS_COEF_ADC_MIC_SZC_MODE
#define CS_COEF_ADC_LI_SZC_MODE
/* PGA mode: 0 = differential, 1 = signle-ended */
#define CS_COEF_ADC_MIC_PGA_MODE
#define CS_COEF_ADC_LI_PGA_MODE
#define IDX_DAC_CFG
/* SZC bitmask, 4 modes below:
 * 0 = Immediate
 * 1 = zero-cross
 * 2 = soft-ramp
 * 3 = soft-ramp on zero-cross
 */
#define CS_COEF_DAC_HP_SZC_MODE
#define CS_COEF_DAC_LO_SZC_MODE
#define CS_COEF_DAC_SPK_SZC_MODE

#define IDX_BEEP_CFG
/* 0x0008 - test reg key */
/* 0x0009 - 0x0014 -> 12 test regs */
/* 0x0015 - visibility reg */

/* Cirrus Logic CS4208 */
#define CS4208_VENDOR_NID

/*
 * Cirrus Logic CS4210
 *
 * 1 DAC => HP(sense) / Speakers,
 * 1 ADC <= LineIn(sense) / MicIn / DMicIn,
 * 1 SPDIF OUT => SPDIF Trasmitter(sense)
 */
#define CS4210_DAC_NID
#define CS4210_ADC_NID
#define CS4210_VENDOR_NID
#define CS421X_DMIC_PIN_NID
#define CS421X_SPDIF_PIN_NID

#define CS421X_IDX_DEV_CFG
#define CS421X_IDX_ADC_CFG
#define CS421X_IDX_DAC_CFG
#define CS421X_IDX_SPK_CTL

/* Cirrus Logic CS4213 is like CS4210 but does not have SPDIF input/output */
#define CS4213_VENDOR_NID


static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)
{}

static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx,
				      unsigned int coef)
{}

/*
 * auto-mute and auto-mic switching
 * CS421x auto-output redirecting
 * HP/SPK/SPDIF
 */

static void cs_automute(struct hda_codec *codec)
{}

static bool is_active_pin(struct hda_codec *codec, hda_nid_t nid)
{}

static void init_input_coef(struct hda_codec *codec)
{}

static const struct hda_verb cs_coef_init_verbs[] =;

static const struct hda_verb cs4208_coef_init_verbs[] =;

/* Errata: CS4207 rev C0/C1/C2 Silicon
 *
 * http://www.cirrus.com/en/pubs/errata/ER880C3.pdf
 *
 * 6. At high temperature (TA > +85°C), the digital supply current (IVD)
 * may be excessive (up to an additional 200 μA), which is most easily
 * observed while the part is being held in reset (RESET# active low).
 *
 * Root Cause: At initial powerup of the device, the logic that drives
 * the clock and write enable to the S/PDIF SRC RAMs is not properly
 * initialized.
 * Certain random patterns will cause a steady leakage current in those
 * RAM cells. The issue will resolve once the SRCs are used (turned on).
 *
 * Workaround: The following verb sequence briefly turns on the S/PDIF SRC
 * blocks, which will alleviate the issue.
 */

static const struct hda_verb cs_errata_init_verbs[] =;

/* SPDIF setup */
static void init_digital_coef(struct hda_codec *codec)
{}

static int cs_init(struct hda_codec *codec)
{}

static int cs_build_controls(struct hda_codec *codec)
{}

#define cs_free

static const struct hda_codec_ops cs_patch_ops =;

static int cs_parse_auto_config(struct hda_codec *codec)
{}

static const struct hda_model_fixup cs420x_models[] =;

static const struct snd_pci_quirk cs420x_fixup_tbl[] =;

static const struct hda_pintbl mbp53_pincfgs[] =;

static const struct hda_pintbl mbp55_pincfgs[] =;

static const struct hda_pintbl imac27_pincfgs[] =;

static const struct hda_pintbl mbp101_pincfgs[] =;

static const struct hda_pintbl mba42_pincfgs[] =;

static const struct hda_pintbl mba6_pincfgs[] =;

static void cs420x_fixup_gpio_13(struct hda_codec *codec,
				 const struct hda_fixup *fix, int action)
{}

static void cs420x_fixup_gpio_23(struct hda_codec *codec,
				 const struct hda_fixup *fix, int action)
{}

static const struct hda_fixup cs420x_fixups[] =;

static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid)
{}

static int patch_cs420x(struct hda_codec *codec)
{}

/*
 * CS4208 support:
 * Its layout is no longer compatible with CS4206/CS4207
 */
enum {};

static const struct hda_model_fixup cs4208_models[] =;

static const struct snd_pci_quirk cs4208_fixup_tbl[] =;

/* codec SSID matching */
static const struct snd_pci_quirk cs4208_mac_fixup_tbl[] =;

static void cs4208_fixup_gpio0(struct hda_codec *codec,
			       const struct hda_fixup *fix, int action)
{}

static const struct hda_fixup cs4208_fixups[];

/* remap the fixup from codec SSID and apply it */
static void cs4208_fixup_mac(struct hda_codec *codec,
			     const struct hda_fixup *fix, int action)
{}

/* MacMini 7,1 has the inverted jack detection */
static void cs4208_fixup_macmini(struct hda_codec *codec,
				 const struct hda_fixup *fix, int action)
{}

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

/* hook the SPDIF switch */
static void cs4208_fixup_spdif_switch(struct hda_codec *codec,
				      const struct hda_fixup *fix, int action)
{}

static const struct hda_fixup cs4208_fixups[] =;

/* correct the 0dB offset of input pins */
static void cs4208_fix_amp_caps(struct hda_codec *codec, hda_nid_t adc)
{}

static int patch_cs4208(struct hda_codec *codec)
{}

/*
 * Cirrus Logic CS4210
 *
 * 1 DAC => HP(sense) / Speakers,
 * 1 ADC <= LineIn(sense) / MicIn / DMicIn,
 * 1 SPDIF OUT => SPDIF Trasmitter(sense)
 */

/* CS4210 board names */
static const struct hda_model_fixup cs421x_models[] =;

static const struct snd_pci_quirk cs421x_fixup_tbl[] =;

/* CS4210 board pinconfigs */
/* Default CS4210 (CDB4210)*/
static const struct hda_pintbl cdb4210_pincfgs[] =;

/* Stumpy ChromeBox */
static const struct hda_pintbl stumpy_pincfgs[] =;

/* Setup GPIO/SENSE for each board (if used) */
static void cs421x_fixup_sense_b(struct hda_codec *codec,
				 const struct hda_fixup *fix, int action)
{}

static const struct hda_fixup cs421x_fixups[] =;

static const struct hda_verb cs421x_coef_init_verbs[] =;

/* Errata: CS4210 rev A1 Silicon
 *
 * http://www.cirrus.com/en/pubs/errata/
 *
 * Description:
 * 1. Performance degredation is present in the ADC.
 * 2. Speaker output is not completely muted upon HP detect.
 * 3. Noise is present when clipping occurs on the amplified
 *    speaker outputs.
 *
 * Workaround:
 * The following verb sequence written to the registers during
 * initialization will correct the issues listed above.
 */

static const struct hda_verb cs421x_coef_init_verbs_A1_silicon_fixes[] =;

/* Speaker Amp Gain is controlled by the vendor widget's coef 4 */
static const DECLARE_TLV_DB_SCALE(cs421x_speaker_boost_db_scale, 900, 300, 0);

static int cs421x_boost_vol_info(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_info *uinfo)
{}

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

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

static const struct snd_kcontrol_new cs421x_speaker_boost_ctl =;

static void cs4210_pinmux_init(struct hda_codec *codec)
{}

static void cs4210_spdif_automute(struct hda_codec *codec,
				  struct hda_jack_callback *tbl)
{}

static void parse_cs421x_digital(struct hda_codec *codec)
{}

static int cs421x_init(struct hda_codec *codec)
{}

static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac)
{}

static int cs421x_parse_auto_config(struct hda_codec *codec)
{}

/*
 *	Manage PDREF, when transitioning to D3hot
 *	(DAC,ADC) -> D3, PDREF=1, AFG->D3
 */
static int cs421x_suspend(struct hda_codec *codec)
{}

static const struct hda_codec_ops cs421x_patch_ops =;

static int patch_cs4210(struct hda_codec *codec)
{}

static int patch_cs4213(struct hda_codec *codec)
{}

/*
 * patch entries
 */
static const struct hda_device_id snd_hda_id_cirrus[] =;
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_cirrus);

MODULE_LICENSE();
MODULE_DESCRIPTION();

static struct hda_codec_driver cirrus_driver =;

module_hda_codec_driver();