X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sound%2Fpci%2Fhda%2Fhda_codec.c;h=0dbeeaf6113af4c36aa1a55077a3096bf45b44ac;hb=89de09a9ba9ce293228b1f1aa3c68b5af33a70ce;hp=20f7762f714444a8ed5e516977cb0ac4bd4487bd;hpb=e3e3679cfc1c6689e035f6d69606253b1eda63ca;p=linux-2.6 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 20f7762f71..0dbeeaf611 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -288,7 +288,7 @@ static int init_unsol_queue(struct hda_bus *bus) { struct hda_bus_unsolicited *unsol; - unsol = kcalloc(1, sizeof(*unsol), GFP_KERNEL); + unsol = kzalloc(sizeof(*unsol), GFP_KERNEL); if (! unsol) { snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); return -ENOMEM; @@ -358,7 +358,7 @@ int snd_hda_bus_new(snd_card_t *card, const struct hda_bus_template *temp, if (busp) *busp = NULL; - bus = kcalloc(1, sizeof(*bus), GFP_KERNEL); + bus = kzalloc(sizeof(*bus), GFP_KERNEL); if (bus == NULL) { snd_printk(KERN_ERR "can't allocate struct hda_bus\n"); return -ENOMEM; @@ -493,7 +493,7 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, return -EBUSY; } - codec = kcalloc(1, sizeof(*codec), GFP_KERNEL); + codec = kzalloc(sizeof(*codec), GFP_KERNEL); if (codec == NULL) { snd_printk(KERN_ERR "can't allocate struct hda_codec\n"); return -ENOMEM; @@ -518,6 +518,13 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, return -ENODEV; } + if (! codec->subsystem_id) { + hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; + codec->subsystem_id = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_SUBSYSTEM_ID, + 0); + } + codec->preset = find_codec_preset(codec); if (! *bus->card->mixername) snd_hda_get_codec_name(codec, bus->card->mixername, @@ -813,6 +820,51 @@ int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return change; } +/* + * bound volume controls + * + * bind multiple volumes (# indices, from 0) + */ + +#define AMP_VAL_IDX_SHIFT 19 +#define AMP_VAL_IDX_MASK (0x0f<<19) + +int snd_hda_mixer_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + unsigned long pval; + int err; + + down(&codec->spdif_mutex); /* reuse spdif_mutex */ + pval = kcontrol->private_value; + kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ + err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); + kcontrol->private_value = pval; + up(&codec->spdif_mutex); + return err; +} + +int snd_hda_mixer_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + unsigned long pval; + int i, indices, err = 0, change = 0; + + down(&codec->spdif_mutex); /* reuse spdif_mutex */ + pval = kcontrol->private_value; + indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; + for (i = 0; i < indices; i++) { + kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT); + err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); + if (err < 0) + break; + change |= err; + } + kcontrol->private_value = pval; + up(&codec->spdif_mutex); + return err < 0 ? err : change; +} + /* * SPDIF out controls */