Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 170331
b: refs/heads/master
c: 3911a4c
h: refs/heads/master
i:
  170329: f046a53
  170327: b54719a
v: v3
  • Loading branch information
Jaroslav Kysela authored and Takashi Iwai committed Nov 16, 2009
1 parent 9fb6d6a commit 15a9e11
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 51 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: 2dca0bba70ce3c233be152e384580c134935332d
refs/heads/master: 3911a4c19e927738766003839aa447becbdbaa27
32 changes: 17 additions & 15 deletions trunk/sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
mutex_init(&codec->control_mutex);
init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32);
snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 60);
snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16);
snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
if (codec->bus->modelname) {
Expand Down Expand Up @@ -1517,18 +1517,20 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
EXPORT_SYMBOL_HDA(snd_hda_find_mixer_ctl);

/* Add a control element and assign to the codec */
int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl)
int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid,
struct snd_kcontrol *kctl)
{
int err;
struct snd_kcontrol **knewp;
struct hda_nid_item *item;

err = snd_ctl_add(codec->bus->card, kctl);
if (err < 0)
return err;
knewp = snd_array_new(&codec->mixers);
if (!knewp)
item = snd_array_new(&codec->mixers);
if (!item)
return -ENOMEM;
*knewp = kctl;
item->kctl = kctl;
item->nid = nid;
return 0;
}
EXPORT_SYMBOL_HDA(snd_hda_ctl_add);
Expand All @@ -1537,9 +1539,9 @@ EXPORT_SYMBOL_HDA(snd_hda_ctl_add);
void snd_hda_ctls_clear(struct hda_codec *codec)
{
int i;
struct snd_kcontrol **kctls = codec->mixers.list;
struct hda_nid_item *items = codec->mixers.list;
for (i = 0; i < codec->mixers.used; i++)
snd_ctl_remove(codec->bus->card, kctls[i]);
snd_ctl_remove(codec->bus->card, items[i].kctl);
snd_array_free(&codec->mixers);
}

Expand Down Expand Up @@ -1645,7 +1647,7 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
kctl = snd_ctl_make_virtual_master(name, tlv);
if (!kctl)
return -ENOMEM;
err = snd_hda_ctl_add(codec, kctl);
err = snd_hda_ctl_add(codec, 0, kctl);
if (err < 0)
return err;

Expand Down Expand Up @@ -2139,7 +2141,7 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
return -ENOMEM;
kctl->id.index = idx;
kctl->private_value = nid;
err = snd_hda_ctl_add(codec, kctl);
err = snd_hda_ctl_add(codec, nid, kctl);
if (err < 0)
return err;
}
Expand Down Expand Up @@ -2184,8 +2186,8 @@ int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
if (!mout->dig_out_nid)
return 0;
/* ATTENTION: here mout is passed as private_data, instead of codec */
return snd_hda_ctl_add(codec,
snd_ctl_new1(&spdif_share_sw, mout));
return snd_hda_ctl_add(codec, mout->dig_out_nid,
snd_ctl_new1(&spdif_share_sw, mout));
}
EXPORT_SYMBOL_HDA(snd_hda_create_spdif_share_sw);

Expand Down Expand Up @@ -2289,7 +2291,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
if (!kctl)
return -ENOMEM;
kctl->private_value = nid;
err = snd_hda_ctl_add(codec, kctl);
err = snd_hda_ctl_add(codec, nid, kctl);
if (err < 0)
return err;
}
Expand Down Expand Up @@ -3165,15 +3167,15 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
kctl = snd_ctl_new1(knew, codec);
if (!kctl)
return -ENOMEM;
err = snd_hda_ctl_add(codec, kctl);
err = snd_hda_ctl_add(codec, 0, kctl);
if (err < 0) {
if (!codec->addr)
return err;
kctl = snd_ctl_new1(knew, codec);
if (!kctl)
return -ENOMEM;
kctl->id.device = codec->addr;
err = snd_hda_ctl_add(codec, kctl);
err = snd_hda_ctl_add(codec, 0, kctl);
if (err < 0)
return err;
}
Expand Down
17 changes: 11 additions & 6 deletions trunk/sound/pci/hda/hda_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,8 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
if (is_loopback)
add_input_loopback(codec, node->nid, HDA_INPUT, index);
snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
err = snd_hda_ctl_add(codec, node->nid,
snd_ctl_new1(&knew, codec));
if (err < 0)
return err;
created = 1;
Expand All @@ -737,7 +738,8 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
if (is_loopback)
add_input_loopback(codec, node->nid, HDA_OUTPUT, 0);
snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
err = snd_hda_ctl_add(codec, node->nid,
snd_ctl_new1(&knew, codec));
if (err < 0)
return err;
created = 1;
Expand All @@ -751,15 +753,17 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node,
(node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) {
knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT);
snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index);
err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
err = snd_hda_ctl_add(codec, node->nid,
snd_ctl_new1(&knew, codec));
if (err < 0)
return err;
created = 1;
} else if ((node->wid_caps & AC_WCAP_OUT_AMP) &&
(node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) {
knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT);
snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);
err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
err = snd_hda_ctl_add(codec, node->nid,
snd_ctl_new1(&knew, codec));
if (err < 0)
return err;
created = 1;
Expand Down Expand Up @@ -857,7 +861,7 @@ static int build_input_controls(struct hda_codec *codec)
}

/* create input MUX if multiple sources are available */
err = snd_hda_ctl_add(codec, snd_ctl_new1(&cap_sel, codec));
err = snd_hda_ctl_add(codec, 0, snd_ctl_new1(&cap_sel, codec));
if (err < 0)
return err;

Expand All @@ -875,7 +879,8 @@ static int build_input_controls(struct hda_codec *codec)
HDA_CODEC_VOLUME(name, adc_node->nid,
spec->input_mux.items[i].index,
HDA_INPUT);
err = snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
err = snd_hda_ctl_add(codec, adc_node->nid,
snd_ctl_new1(&knew, codec));
if (err < 0)
return err;
}
Expand Down
11 changes: 9 additions & 2 deletions trunk/sound/pci/hda/hda_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,13 @@ int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
unsigned int caps);
u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid);

int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl);
struct hda_nid_item {
struct snd_kcontrol *kctl;
hda_nid_t nid;
};

int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid,
struct snd_kcontrol *kctl);
void snd_hda_ctls_clear(struct hda_codec *codec);

/*
Expand Down Expand Up @@ -514,7 +520,8 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
* AMP control callbacks
*/
/* retrieve parameters from private_value */
#define get_amp_nid(kc) ((kc)->private_value & 0xffff)
#define get_amp_nid_(pv) ((pv) & 0xffff)
#define get_amp_nid(kc) get_amp_nid_((kc)->private_value)
#define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3)
#define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1)
#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
Expand Down
55 changes: 40 additions & 15 deletions trunk/sound/pci/hda/hda_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,41 @@ static const char *get_wid_type_name(unsigned int wid_value)
return "UNKNOWN Widget";
}

static void print_nid_mixers(struct snd_info_buffer *buffer,
struct hda_codec *codec, hda_nid_t nid)
{
int i;
struct hda_nid_item *items = codec->mixers.list;
struct snd_kcontrol *kctl;
for (i = 0; i < codec->mixers.used; i++) {
if (items[i].nid == nid) {
kctl = items[i].kctl;
snd_iprintf(buffer,
" Control: name=\"%s\", index=%i, device=%i\n",
kctl->id.name, kctl->id.index, kctl->id.device);
}
}
}

static void print_nid_pcms(struct snd_info_buffer *buffer,
struct hda_codec *codec, hda_nid_t nid)
{
int pcm, type;
struct hda_pcm *cpcm;
for (pcm = 0; pcm < codec->num_pcms; pcm++) {
cpcm = &codec->pcm_info[pcm];
for (type = 0; type < 2; type++) {
if (cpcm->stream[type].nid != nid || cpcm->pcm == NULL)
continue;
snd_iprintf(buffer, " Device: name=\"%s\", "
"type=\"%s\", device=%i\n",
cpcm->name,
snd_hda_pcm_type_name[cpcm->pcm_type],
cpcm->pcm->device);
}
}
}

static void print_amp_caps(struct snd_info_buffer *buffer,
struct hda_codec *codec, hda_nid_t nid, int dir)
{
Expand Down Expand Up @@ -309,21 +344,7 @@ static void print_audio_io(struct snd_info_buffer *buffer,
struct hda_codec *codec, hda_nid_t nid,
unsigned int wid_type)
{
int pcm, conv;
for (pcm = 0; pcm < codec->num_pcms; pcm++) {
int type;
struct hda_pcm *cpcm = &codec->pcm_info[pcm];
for (type = 0; type < 2; type++) {
if (cpcm->stream[type].nid != nid || cpcm->pcm == NULL)
continue;
snd_iprintf(buffer, " Device: name=\"%s\", "
"type=\"%s\", device=%i\n",
cpcm->name,
snd_hda_pcm_type_name[cpcm->pcm_type],
cpcm->pcm->device);
}
}
conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
snd_iprintf(buffer,
" Converter: stream=%d, channel=%d\n",
(conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
Expand Down Expand Up @@ -471,6 +492,7 @@ static void print_gpio(struct snd_info_buffer *buffer,
(data & (1<<i)) ? 1 : 0,
(unsol & (1<<i)) ? 1 : 0);
/* FIXME: add GPO and GPI pin information */
print_nid_mixers(buffer, codec, nid);
}

static void print_codec_info(struct snd_info_entry *entry,
Expand Down Expand Up @@ -550,6 +572,9 @@ static void print_codec_info(struct snd_info_entry *entry,
snd_iprintf(buffer, " CP");
snd_iprintf(buffer, "\n");

print_nid_mixers(buffer, codec, nid);
print_nid_pcms(buffer, codec, nid);

/* volume knob is a special widget that always have connection
* list
*/
Expand Down
4 changes: 3 additions & 1 deletion trunk/sound/pci/hda/patch_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ static int ad198x_build_controls(struct hda_codec *codec)
if (!kctl)
return -ENOMEM;
kctl->private_value = spec->beep_amp;
err = snd_hda_ctl_add(codec, kctl);
err = snd_hda_ctl_add(codec,
get_amp_nid_(spec->beep_amp),
kctl);
if (err < 0)
return err;
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/sound/pci/hda/patch_ca0110.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static int _add_switch(struct hda_codec *codec, hda_nid_t nid, const char *pfx,
struct snd_kcontrol_new knew =
HDA_CODEC_MUTE_MONO(namestr, nid, chan, 0, type);
sprintf(namestr, "%s %s Switch", pfx, dirstr[dir]);
return snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec));
}

static int _add_volume(struct hda_codec *codec, hda_nid_t nid, const char *pfx,
Expand All @@ -155,7 +155,7 @@ static int _add_volume(struct hda_codec *codec, hda_nid_t nid, const char *pfx,
struct snd_kcontrol_new knew =
HDA_CODEC_VOLUME_MONO(namestr, nid, chan, 0, type);
sprintf(namestr, "%s %s Volume", pfx, dirstr[dir]);
return snd_hda_ctl_add(codec, snd_ctl_new1(&knew, codec));
return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec));
}

#define add_out_switch(codec, nid, pfx) _add_switch(codec, nid, pfx, 3, 0)
Expand Down
12 changes: 6 additions & 6 deletions trunk/sound/pci/hda/patch_cirrus.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ static int add_mute(struct hda_codec *codec, const char *name, int index,
knew.private_value = pval;
snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]);
*kctlp = snd_ctl_new1(&knew, codec);
return snd_hda_ctl_add(codec, *kctlp);
return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp);
}

static int add_volume(struct hda_codec *codec, const char *name,
Expand All @@ -513,7 +513,7 @@ static int add_volume(struct hda_codec *codec, const char *name,
knew.private_value = pval;
snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]);
*kctlp = snd_ctl_new1(&knew, codec);
return snd_hda_ctl_add(codec, *kctlp);
return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp);
}

static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac)
Expand All @@ -536,14 +536,14 @@ static int add_vmaster(struct hda_codec *codec, hda_nid_t dac)

spec->vmaster_sw =
snd_ctl_make_virtual_master("Master Playback Switch", NULL);
err = snd_hda_ctl_add(codec, spec->vmaster_sw);
err = snd_hda_ctl_add(codec, dac, spec->vmaster_sw);
if (err < 0)
return err;

snd_hda_set_vmaster_tlv(codec, dac, HDA_OUTPUT, tlv);
spec->vmaster_vol =
snd_ctl_make_virtual_master("Master Playback Volume", tlv);
err = snd_hda_ctl_add(codec, spec->vmaster_vol);
err = snd_hda_ctl_add(codec, dac, spec->vmaster_vol);
if (err < 0)
return err;
return 0;
Expand Down Expand Up @@ -756,13 +756,13 @@ static int build_input(struct hda_codec *codec)
if (!kctl)
return -ENOMEM;
kctl->private_value = (long)spec->capture_bind[i];
err = snd_hda_ctl_add(codec, kctl);
err = snd_hda_ctl_add(codec, 0, kctl);
if (err < 0)
return err;
}

if (spec->num_inputs > 1 && !spec->mic_detect) {
err = snd_hda_ctl_add(codec,
err = snd_hda_ctl_add(codec, 0,
snd_ctl_new1(&cs_capture_source, codec));
if (err < 0)
return err;
Expand Down
3 changes: 2 additions & 1 deletion trunk/sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,8 @@ static int alc_build_controls(struct hda_codec *codec)
if (!kctl)
return -ENOMEM;
kctl->private_value = spec->beep_amp;
err = snd_hda_ctl_add(codec, kctl);
err = snd_hda_ctl_add(codec,
get_amp_nid_(spec->beep_amp), kctl);
if (err < 0)
return err;
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/sound/pci/hda/patch_sigmatel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
if (!spec->auto_mic && spec->num_dmuxes > 0 &&
snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
stac_dmux_mixer.count = spec->num_dmuxes;
err = snd_hda_ctl_add(codec,
err = snd_hda_ctl_add(codec, 0,
snd_ctl_new1(&stac_dmux_mixer, codec));
if (err < 0)
return err;
Expand All @@ -1101,7 +1101,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
spec->spdif_mute = 1;
}
stac_smux_mixer.count = spec->num_smuxes;
err = snd_hda_ctl_add(codec,
err = snd_hda_ctl_add(codec, 0,
snd_ctl_new1(&stac_smux_mixer, codec));
if (err < 0)
return err;
Expand Down

0 comments on commit 15a9e11

Please sign in to comment.