Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 119375
b: refs/heads/master
c: c879c63
h: refs/heads/master
i:
  119373: 0230262
  119371: 382301d
  119367: bc16ac3
  119359: e5a961e
v: v3
  • Loading branch information
Takashi Iwai committed Nov 21, 2008
1 parent 53959d2 commit 5f15ecf
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a39c4ad1089be34d8dc66e926e93a52c44993a0a
refs/heads/master: c879c634c928223765cf50103ddaf32f2a55fed0
1 change: 1 addition & 0 deletions trunk/Documentation/sound/alsa/ALSA-Configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
ref Reference board
dell-m4-1 Dell desktops
dell-m4-2 Dell desktops
dell-m4-3 Dell desktops

STAC92HD73*
ref Reference board
Expand Down
8 changes: 8 additions & 0 deletions trunk/sound/pci/hda/hda_beep.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ static void snd_hda_generate_beep(struct work_struct *work)
container_of(work, struct hda_beep, beep_work);
struct hda_codec *codec = beep->codec;

if (!beep->enabled)
return;

/* generate tone */
snd_hda_codec_write_cache(codec, beep->nid, 0,
AC_VERB_SET_BEEP_CONTROL, beep->tone);
Expand Down Expand Up @@ -85,6 +88,10 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
snprintf(beep->phys, sizeof(beep->phys),
"card%d/codec#%d/beep0", codec->bus->card->number, codec->addr);
input_dev = input_allocate_device();
if (!input_dev) {
kfree(beep);
return -ENOMEM;
}

/* setup digital beep device */
input_dev->name = "HDA Digital PCBeep";
Expand Down Expand Up @@ -115,6 +122,7 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
beep->nid = nid;
beep->dev = input_dev;
beep->codec = codec;
beep->enabled = 1;
codec->beep = beep;

INIT_WORK(&beep->beep_work, &snd_hda_generate_beep);
Expand Down
1 change: 1 addition & 0 deletions trunk/sound/pci/hda/hda_beep.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct hda_beep {
char phys[32];
int tone;
int nid;
int enabled;
struct work_struct beep_work; /* scheduled task for beep event */
};

Expand Down
142 changes: 118 additions & 24 deletions trunk/sound/pci/hda/patch_sigmatel.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
#include "hda_beep.h"

#define NUM_CONTROL_ALLOC 32

#define STAC_VREF_EVENT 0x00
#define STAC_INSERT_EVENT 0x10
#define STAC_PWR_EVENT 0x20
#define STAC_HP_EVENT 0x30
#define STAC_VREF_EVENT 0x40

enum {
STAC_REF,
Expand Down Expand Up @@ -82,6 +84,7 @@ enum {
STAC_92HD71BXX_REF,
STAC_DELL_M4_1,
STAC_DELL_M4_2,
STAC_DELL_M4_3,
STAC_HP_M4,
STAC_92HD71BXX_MODELS
};
Expand Down Expand Up @@ -135,6 +138,7 @@ struct sigmatel_spec {
unsigned int num_mixers;

int board_config;
unsigned int eapd_switch: 1;
unsigned int surr_switch: 1;
unsigned int line_switch: 1;
unsigned int mic_switch: 1;
Expand Down Expand Up @@ -1626,6 +1630,8 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
"unknown Dell", STAC_DELL_M6),
SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
"unknown Dell", STAC_DELL_M6),
SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
"Dell Studio 15", STAC_DELL_M6),
{} /* terminator */
};

Expand Down Expand Up @@ -1668,24 +1674,36 @@ static unsigned int dell_m4_2_pin_configs[11] = {
0x40f000f0, 0x044413b0, 0x044413b0,
};

static unsigned int dell_m4_3_pin_configs[11] = {
0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
0x40f000f0, 0x044413b0, 0x044413b0,
};

static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
[STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
[STAC_DELL_M4_1] = dell_m4_1_pin_configs,
[STAC_DELL_M4_2] = dell_m4_2_pin_configs,
[STAC_DELL_M4_3] = dell_m4_3_pin_configs,
[STAC_HP_M4] = NULL,
};

static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
[STAC_92HD71BXX_REF] = "ref",
[STAC_DELL_M4_1] = "dell-m4-1",
[STAC_DELL_M4_2] = "dell-m4-2",
[STAC_DELL_M4_3] = "dell-m4-3",
[STAC_HP_M4] = "hp-m4",
};

static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
/* SigmaTel reference board */
SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
"DFI LanParty", STAC_92HD71BXX_REF),
SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
"HP dv5", STAC_HP_M4),
SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
"HP dv7", STAC_HP_M4),
SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
"unknown HP", STAC_HP_M4),
SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
Expand All @@ -1710,6 +1728,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
"unknown Dell", STAC_DELL_M4_2),
SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
"unknown Dell", STAC_DELL_M4_2),
SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
"unknown Dell", STAC_DELL_M4_3),
{} /* terminator */
};

Expand Down Expand Up @@ -2587,8 +2607,10 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
};

/* add dynamic controls */
static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
int idx, const char *name, unsigned long val)
static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
struct snd_kcontrol_new *ktemp,
int idx, const char *name,
unsigned long val)
{
struct snd_kcontrol_new *knew;

Expand All @@ -2607,20 +2629,29 @@ static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
}

knew = &spec->kctl_alloc[spec->num_kctl_used];
*knew = stac92xx_control_templates[type];
*knew = *ktemp;
knew->index = idx;
knew->name = kstrdup(name, GFP_KERNEL);
if (! knew->name)
if (!knew->name)
return -ENOMEM;
knew->private_value = val;
spec->num_kctl_used++;
return 0;
}

static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
int type, int idx, const char *name,
unsigned long val)
{
return stac92xx_add_control_temp(spec,
&stac92xx_control_templates[type],
idx, name, val);
}


/* add dynamic controls */
static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
const char *name, unsigned long val)
static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
const char *name, unsigned long val)
{
return stac92xx_add_control_idx(spec, type, 0, name, val);
}
Expand Down Expand Up @@ -3062,6 +3093,43 @@ static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
return 0;
}

#ifdef CONFIG_SND_HDA_INPUT_BEEP
#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info

static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
ucontrol->value.integer.value[0] = codec->beep->enabled;
return 0;
}

static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
int enabled = !!ucontrol->value.integer.value[0];
if (codec->beep->enabled != enabled) {
codec->beep->enabled = enabled;
return 1;
}
return 0;
}

static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.info = stac92xx_dig_beep_switch_info,
.get = stac92xx_dig_beep_switch_get,
.put = stac92xx_dig_beep_switch_put,
};

static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
{
return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
0, "PC Beep Playback Switch", 0);
}
#endif

static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
{
struct sigmatel_spec *spec = codec->spec;
Expand Down Expand Up @@ -3368,13 +3436,22 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
#ifdef CONFIG_SND_HDA_INPUT_BEEP
if (spec->digbeep_nid > 0) {
hda_nid_t nid = spec->digbeep_nid;
unsigned int caps;

err = stac92xx_auto_create_beep_ctls(codec, nid);
if (err < 0)
return err;
err = snd_hda_attach_beep_device(codec, nid);
if (err < 0)
return err;
/* if no beep switch is available, make its own one */
caps = query_amp_caps(codec, nid, HDA_OUTPUT);
if (codec->beep &&
!((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
err = stac92xx_beep_switch_ctl(codec);
if (err < 0)
return err;
}
}
#endif

Expand Down Expand Up @@ -3838,7 +3915,7 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
for (i = 0; i < cfg->speaker_outs; i++)
stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
AC_PINCTL_OUT_EN);
if (spec->eapd_mask)
if (spec->eapd_mask && spec->eapd_switch)
stac_gpio_set(codec, spec->gpio_mask,
spec->gpio_dir, spec->gpio_data &
~spec->eapd_mask);
Expand All @@ -3853,7 +3930,7 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
for (i = 0; i < cfg->speaker_outs; i++)
stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
AC_PINCTL_OUT_EN);
if (spec->eapd_mask)
if (spec->eapd_mask && spec->eapd_switch)
stac_gpio_set(codec, spec->gpio_mask,
spec->gpio_dir, spec->gpio_data |
spec->eapd_mask);
Expand Down Expand Up @@ -4180,6 +4257,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
spec->num_smuxes = 0;
spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
spec->eapd_switch = 0;
spec->num_amps = 1;

if (!spec->init)
Expand Down Expand Up @@ -4211,6 +4289,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
default:
spec->num_dmics = STAC92HD73XX_NUM_DMICS;
spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
spec->eapd_switch = 1;
}
if (spec->board_config > STAC_92HD73XX_REF) {
/* GPIO0 High = Enable EAPD */
Expand Down Expand Up @@ -4356,7 +4435,13 @@ static int stac92hd71xx_resume(struct hda_codec *codec)

static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
{
struct sigmatel_spec *spec = codec->spec;

stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
if (spec->eapd_mask)
stac_gpio_set(codec, spec->gpio_mask,
spec->gpio_dir, spec->gpio_data &
~spec->eapd_mask);
return 0;
};

Expand Down Expand Up @@ -4419,6 +4504,13 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
stac92xx_set_config_regs(codec);
}

if (spec->board_config > STAC_92HD71BXX_REF) {
/* GPIO0 = EAPD */
spec->gpio_mask = 0x01;
spec->gpio_dir = 0x01;
spec->gpio_data = 0x01;
}

switch (codec->vendor_id) {
case 0x111d76b6: /* 4 Port without Analog Mixer */
case 0x111d76b7:
Expand All @@ -4429,10 +4521,10 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
break;
case 0x111d7608: /* 5 Port with Analog Mixer */
switch (codec->subsystem_id) {
case 0x103c361a:
switch (spec->board_config) {
case STAC_HP_M4:
/* Enable VREF power saving on GPIO1 detect */
snd_hda_codec_write(codec, codec->afg, 0,
snd_hda_codec_write_cache(codec, codec->afg, 0,
AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
snd_hda_codec_write_cache(codec, codec->afg, 0,
AC_VERB_SET_UNSOLICITED_ENABLE,
Expand Down Expand Up @@ -4478,13 +4570,6 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
spec->aloopback_mask = 0x50;
spec->aloopback_shift = 0;

if (spec->board_config > STAC_92HD71BXX_REF) {
/* GPIO0 = EAPD */
spec->gpio_mask = 0x01;
spec->gpio_dir = 0x01;
spec->gpio_data = 0x01;
}

spec->powerdown_adcs = 1;
spec->digbeep_nid = 0x26;
spec->mux_nids = stac92hd71bxx_mux_nids;
Expand All @@ -4499,14 +4584,21 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)

switch (spec->board_config) {
case STAC_HP_M4:
spec->num_dmics = 0;
spec->num_smuxes = 0;
spec->num_dmuxes = 0;

/* enable internal microphone */
stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
stac92xx_auto_set_pinctl(codec, 0x0e,
AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
/* fallthru */
case STAC_DELL_M4_2:
spec->num_dmics = 0;
spec->num_smuxes = 0;
spec->num_dmuxes = 0;
break;
case STAC_DELL_M4_1:
case STAC_DELL_M4_3:
spec->num_dmics = 1;
spec->num_smuxes = 0;
spec->num_dmuxes = 0;
break;
default:
spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
Expand Down Expand Up @@ -4743,6 +4835,7 @@ static int patch_stac927x(struct hda_codec *codec)
spec->num_pwrs = 0;
spec->aloopback_mask = 0x40;
spec->aloopback_shift = 0;
spec->eapd_switch = 1;

err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
if (!err) {
Expand Down Expand Up @@ -4823,6 +4916,7 @@ static int patch_stac9205(struct hda_codec *codec)

spec->aloopback_mask = 0x40;
spec->aloopback_shift = 0;
spec->eapd_switch = 1;
spec->multiout.dac_nids = spec->dac_nids;

switch (spec->board_config){
Expand All @@ -4832,7 +4926,7 @@ static int patch_stac9205(struct hda_codec *codec)
stac92xx_set_config_reg(codec, 0x20, 0x1c410030);

/* Enable unsol response for GPIO4/Dock HP connection */
snd_hda_codec_write(codec, codec->afg, 0,
snd_hda_codec_write_cache(codec, codec->afg, 0,
AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
snd_hda_codec_write_cache(codec, codec->afg, 0,
AC_VERB_SET_UNSOLICITED_ENABLE,
Expand Down
Loading

0 comments on commit 5f15ecf

Please sign in to comment.