/*
* Universal Interface for Intel High Definition Audio Codec
*
* HD audio interface patch for VIA VT17xx/VT18xx/VT20xx codec
*
* (C) 2006-2009 VIA Technology, Inc.
* (C) 2006-2008 Takashi Iwai <tiwai@suse.de>
*
* This driver is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This driver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* * * * * * * * * * * * * * Release History * * * * * * * * * * * * * * * * */
/* */
/* 2006-03-03 Lydia Wang Create the basic patch to support VT1708 codec */
/* 2006-03-14 Lydia Wang Modify hard code for some pin widget nid */
/* 2006-08-02 Lydia Wang Add support to VT1709 codec */
/* 2006-09-08 Lydia Wang Fix internal loopback recording source select bug */
/* 2007-09-12 Lydia Wang Add EAPD enable during driver initialization */
/* 2007-09-17 Lydia Wang Add VT1708B codec support */
/* 2007-11-14 Lydia Wang Add VT1708A codec HP and CD pin connect config */
/* 2008-02-03 Lydia Wang Fix Rear channels and Back channels inverse issue */
/* 2008-03-06 Lydia Wang Add VT1702 codec and VT1708S codec support */
/* 2008-04-09 Lydia Wang Add mute front speaker when HP plugin */
/* 2008-04-09 Lydia Wang Add Independent HP feature */
/* 2008-05-28 Lydia Wang Add second S/PDIF Out support for VT1702 */
/* 2008-09-15 Logan Li Add VT1708S Mic Boost workaround/backdoor */
/* 2009-02-16 Logan Li Add support for VT1718S */
/* 2009-03-13 Logan Li Add support for VT1716S */
/* 2009-04-14 Lydai Wang Add support for VT1828S and VT2020 */
/* 2009-07-08 Lydia Wang Add support for VT2002P */
/* 2009-07-21 Lydia Wang Add support for VT1812 */
/* 2009-09-19 Lydia Wang Add support for VT1818S */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <sound/core.h>
#include <sound/asoundef.h>
#include "hda_codec.h"
#include "hda_local.h"
#include "hda_auto_parser.h"
#include "hda_jack.h"
#include "hda_generic.h"
/* Pin Widget NID */
#define VT1708_HP_PIN_NID 0x20
#define VT1708_CD_PIN_NID 0x24
enum VIA_HDA_CODEC {
UNKNOWN = -1,
VT1708,
VT1709_10CH,
VT1709_6CH,
VT1708B_8CH,
VT1708B_4CH,
VT1708S,
VT1708BCE,
VT1702,
VT1718S,
VT1716S,
VT2002P,
VT1812,
VT1802,
VT1705CF,
VT1808,
CODEC_TYPES,
};
#define VT2002P_COMPATIBLE(spec) \
((spec)->codec_type == VT2002P ||\
(spec)->codec_type == VT1812 ||\
(spec)->codec_type == VT1802)
struct via_spec {
struct hda_gen_spec gen;
/* codec parameterization */
const struct snd_kcontrol_new *mixers[6];
unsigned int num_mixers;
const struct hda_verb *init_verbs[5];
unsigned int num_iverbs;
/* HP mode source */
unsigned int dmic_enabled;
enum VIA_HDA_CODEC codec_type;
/* analog low-power control */
bool alc_mode;
/* work to check hp jack state */
int hp_work_active;
int vt1708_jack_detect;
unsigned int beep_amp;
};
static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec);
static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
struct hda_codec *codec,
struct snd_pcm_substream *substream,
int action);
static const struct hda_codec_ops via_patch_ops; /* defined below */
static struct via_spec *via_new_spec(struct hda_codec *codec)
{
struct via_spec *spec;
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (spec == NULL)
return NULL;
codec->spec = spec;
snd_hda_gen_spec_init(&spec->gen);
spec->codec_type<