2 * Universal Interface for Intel High Definition Audio Codec
4 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This driver is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <sound/driver.h>
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <linux/moduleparam.h>
28 #include <linux/mutex.h>
29 #include <sound/core.h>
30 #include "hda_codec.h"
31 #include <sound/asoundef.h>
32 #include <sound/tlv.h>
33 #include <sound/initval.h>
34 #include "hda_local.h"
37 MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
38 MODULE_DESCRIPTION("Universal interface for High Definition Audio Codec");
39 MODULE_LICENSE("GPL");
43 * vendor / preset table
46 struct hda_vendor_id {
51 /* codec vendor labels */
52 static struct hda_vendor_id hda_vendor_ids[] = {
53 { 0x10ec, "Realtek" },
54 { 0x11d4, "Analog Devices" },
55 { 0x13f6, "C-Media" },
56 { 0x434d, "C-Media" },
57 { 0x8384, "SigmaTel" },
62 #include "hda_patch.h"
66 * snd_hda_codec_read - send a command and get the response
67 * @codec: the HDA codec
68 * @nid: NID to send the command
69 * @direct: direct flag
70 * @verb: the verb to send
71 * @parm: the parameter for the verb
73 * Send a single command and read the corresponding response.
75 * Returns the obtained response value, or -1 for an error.
77 unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int direct,
78 unsigned int verb, unsigned int parm)
81 mutex_lock(&codec->bus->cmd_mutex);
82 if (! codec->bus->ops.command(codec, nid, direct, verb, parm))
83 res = codec->bus->ops.get_response(codec);
85 res = (unsigned int)-1;
86 mutex_unlock(&codec->bus->cmd_mutex);
90 EXPORT_SYMBOL(snd_hda_codec_read);
93 * snd_hda_codec_write - send a single command without waiting for response
94 * @codec: the HDA codec
95 * @nid: NID to send the command
96 * @direct: direct flag
97 * @verb: the verb to send
98 * @parm: the parameter for the verb
100 * Send a single command without waiting for response.
102 * Returns 0 if successful, or a negative error code.
104 int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
105 unsigned int verb, unsigned int parm)
108 mutex_lock(&codec->bus->cmd_mutex);
109 err = codec->bus->ops.command(codec, nid, direct, verb, parm);
110 mutex_unlock(&codec->bus->cmd_mutex);
114 EXPORT_SYMBOL(snd_hda_codec_write);
117 * snd_hda_sequence_write - sequence writes
118 * @codec: the HDA codec
119 * @seq: VERB array to send
121 * Send the commands sequentially from the given array.
122 * The array must be terminated with NID=0.
124 void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq)
126 for (; seq->nid; seq++)
127 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param);
130 EXPORT_SYMBOL(snd_hda_sequence_write);
133 * snd_hda_get_sub_nodes - get the range of sub nodes
134 * @codec: the HDA codec
136 * @start_id: the pointer to store the start NID
138 * Parse the NID and store the start NID of its sub-nodes.
139 * Returns the number of sub-nodes.
141 int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *start_id)
145 parm = snd_hda_param_read(codec, nid, AC_PAR_NODE_COUNT);
146 *start_id = (parm >> 16) & 0x7fff;
147 return (int)(parm & 0x7fff);
150 EXPORT_SYMBOL(snd_hda_get_sub_nodes);
153 * snd_hda_get_connections - get connection list
154 * @codec: the HDA codec
156 * @conn_list: connection list array
157 * @max_conns: max. number of connections to store
159 * Parses the connection list of the given widget and stores the list
162 * Returns the number of connections, or a negative error code.
164 int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
165 hda_nid_t *conn_list, int max_conns)
168 int i, conn_len, conns;
169 unsigned int shift, num_elems, mask;
172 snd_assert(conn_list && max_conns > 0, return -EINVAL);
174 parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN);
175 if (parm & AC_CLIST_LONG) {
184 conn_len = parm & AC_CLIST_LENGTH;
185 mask = (1 << (shift-1)) - 1;
188 return 0; /* no connection */
191 /* single connection */
192 parm = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_LIST, 0);
193 conn_list[0] = parm & mask;
197 /* multi connection */
200 for (i = 0; i < conn_len; i++) {
204 if (i % num_elems == 0)
205 parm = snd_hda_codec_read(codec, nid, 0,
206 AC_VERB_GET_CONNECT_LIST, i);
207 range_val = !! (parm & (1 << (shift-1))); /* ranges */
211 /* ranges between the previous and this one */
212 if (! prev_nid || prev_nid >= val) {
213 snd_printk(KERN_WARNING "hda_codec: invalid dep_range_val %x:%x\n", prev_nid, val);
216 for (n = prev_nid + 1; n <= val; n++) {
217 if (conns >= max_conns) {
218 snd_printk(KERN_ERR "Too many connections\n");
221 conn_list[conns++] = n;
224 if (conns >= max_conns) {
225 snd_printk(KERN_ERR "Too many connections\n");
228 conn_list[conns++] = val;
237 * snd_hda_queue_unsol_event - add an unsolicited event to queue
239 * @res: unsolicited event (lower 32bit of RIRB entry)
240 * @res_ex: codec addr and flags (upper 32bit or RIRB entry)
242 * Adds the given event to the queue. The events are processed in
243 * the workqueue asynchronously. Call this function in the interrupt
244 * hanlder when RIRB receives an unsolicited event.
246 * Returns 0 if successful, or a negative error code.
248 int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
250 struct hda_bus_unsolicited *unsol;
253 if ((unsol = bus->unsol) == NULL)
256 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE;
260 unsol->queue[wp] = res;
261 unsol->queue[wp + 1] = res_ex;
263 queue_work(unsol->workq, &unsol->work);
268 EXPORT_SYMBOL(snd_hda_queue_unsol_event);
271 * process queueud unsolicited events
273 static void process_unsol_events(void *data)
275 struct hda_bus *bus = data;
276 struct hda_bus_unsolicited *unsol = bus->unsol;
277 struct hda_codec *codec;
278 unsigned int rp, caddr, res;
280 while (unsol->rp != unsol->wp) {
281 rp = (unsol->rp + 1) % HDA_UNSOL_QUEUE_SIZE;
284 res = unsol->queue[rp];
285 caddr = unsol->queue[rp + 1];
286 if (! (caddr & (1 << 4))) /* no unsolicited event? */
288 codec = bus->caddr_tbl[caddr & 0x0f];
289 if (codec && codec->patch_ops.unsol_event)
290 codec->patch_ops.unsol_event(codec, res);
295 * initialize unsolicited queue
297 static int init_unsol_queue(struct hda_bus *bus)
299 struct hda_bus_unsolicited *unsol;
301 if (bus->unsol) /* already initialized */
304 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
306 snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n");
309 unsol->workq = create_singlethread_workqueue("hda_codec");
310 if (! unsol->workq) {
311 snd_printk(KERN_ERR "hda_codec: can't create workqueue\n");
315 INIT_WORK(&unsol->work, process_unsol_events, bus);
323 static void snd_hda_codec_free(struct hda_codec *codec);
325 static int snd_hda_bus_free(struct hda_bus *bus)
327 struct list_head *p, *n;
332 destroy_workqueue(bus->unsol->workq);
335 list_for_each_safe(p, n, &bus->codec_list) {
336 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
337 snd_hda_codec_free(codec);
339 if (bus->ops.private_free)
340 bus->ops.private_free(bus);
345 static int snd_hda_bus_dev_free(struct snd_device *device)
347 struct hda_bus *bus = device->device_data;
348 return snd_hda_bus_free(bus);
352 * snd_hda_bus_new - create a HDA bus
353 * @card: the card entry
354 * @temp: the template for hda_bus information
355 * @busp: the pointer to store the created bus instance
357 * Returns 0 if successful, or a negative error code.
359 int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
360 struct hda_bus **busp)
364 static struct snd_device_ops dev_ops = {
365 .dev_free = snd_hda_bus_dev_free,
368 snd_assert(temp, return -EINVAL);
369 snd_assert(temp->ops.command && temp->ops.get_response, return -EINVAL);
374 bus = kzalloc(sizeof(*bus), GFP_KERNEL);
376 snd_printk(KERN_ERR "can't allocate struct hda_bus\n");
381 bus->private_data = temp->private_data;
382 bus->pci = temp->pci;
383 bus->modelname = temp->modelname;
384 bus->ops = temp->ops;
386 mutex_init(&bus->cmd_mutex);
387 INIT_LIST_HEAD(&bus->codec_list);
389 if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) {
390 snd_hda_bus_free(bus);
398 EXPORT_SYMBOL(snd_hda_bus_new);
401 * find a matching codec preset
403 static const struct hda_codec_preset *find_codec_preset(struct hda_codec *codec)
405 const struct hda_codec_preset **tbl, *preset;
407 for (tbl = hda_preset_tables; *tbl; tbl++) {
408 for (preset = *tbl; preset->id; preset++) {
409 u32 mask = preset->mask;
412 if (preset->id == (codec->vendor_id & mask) &&
414 preset->rev == codec->revision_id))
422 * snd_hda_get_codec_name - store the codec name
424 void snd_hda_get_codec_name(struct hda_codec *codec,
425 char *name, int namelen)
427 const struct hda_vendor_id *c;
428 const char *vendor = NULL;
429 u16 vendor_id = codec->vendor_id >> 16;
432 for (c = hda_vendor_ids; c->id; c++) {
433 if (c->id == vendor_id) {
439 sprintf(tmp, "Generic %04x", vendor_id);
442 if (codec->preset && codec->preset->name)
443 snprintf(name, namelen, "%s %s", vendor, codec->preset->name);
445 snprintf(name, namelen, "%s ID %x", vendor, codec->vendor_id & 0xffff);
449 * look for an AFG and MFG nodes
451 static void setup_fg_nodes(struct hda_codec *codec)
456 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
457 for (i = 0; i < total_nodes; i++, nid++) {
458 switch((snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE) & 0xff)) {
459 case AC_GRP_AUDIO_FUNCTION:
462 case AC_GRP_MODEM_FUNCTION:
472 * read widget caps for each widget and store in cache
474 static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
479 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node,
481 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL);
484 nid = codec->start_nid;
485 for (i = 0; i < codec->num_nodes; i++, nid++)
486 codec->wcaps[i] = snd_hda_param_read(codec, nid,
487 AC_PAR_AUDIO_WIDGET_CAP);
495 static void snd_hda_codec_free(struct hda_codec *codec)
499 list_del(&codec->list);
500 codec->bus->caddr_tbl[codec->addr] = NULL;
501 if (codec->patch_ops.free)
502 codec->patch_ops.free(codec);
503 kfree(codec->amp_info);
508 static void init_amp_hash(struct hda_codec *codec);
511 * snd_hda_codec_new - create a HDA codec
512 * @bus: the bus to assign
513 * @codec_addr: the codec address
514 * @codecp: the pointer to store the generated codec
516 * Returns 0 if successful, or a negative error code.
518 int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
519 struct hda_codec **codecp)
521 struct hda_codec *codec;
525 snd_assert(bus, return -EINVAL);
526 snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL);
528 if (bus->caddr_tbl[codec_addr]) {
529 snd_printk(KERN_ERR "hda_codec: address 0x%x is already occupied\n", codec_addr);
533 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
535 snd_printk(KERN_ERR "can't allocate struct hda_codec\n");
540 codec->addr = codec_addr;
541 mutex_init(&codec->spdif_mutex);
542 init_amp_hash(codec);
544 list_add_tail(&codec->list, &bus->codec_list);
545 bus->caddr_tbl[codec_addr] = codec;
547 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_VENDOR_ID);
548 if (codec->vendor_id == -1)
549 /* read again, hopefully the access method was corrected
550 * in the last read...
552 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
554 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_SUBSYSTEM_ID);
555 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_REV_ID);
557 setup_fg_nodes(codec);
558 if (! codec->afg && ! codec->mfg) {
559 snd_printdd("hda_codec: no AFG or MFG node found\n");
560 snd_hda_codec_free(codec);
564 if (read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg) < 0) {
565 snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
566 snd_hda_codec_free(codec);
570 if (! codec->subsystem_id) {
571 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
572 codec->subsystem_id = snd_hda_codec_read(codec, nid, 0,
573 AC_VERB_GET_SUBSYSTEM_ID,
577 codec->preset = find_codec_preset(codec);
578 if (! *bus->card->mixername)
579 snd_hda_get_codec_name(codec, bus->card->mixername,
580 sizeof(bus->card->mixername));
582 if (codec->preset && codec->preset->patch)
583 err = codec->preset->patch(codec);
585 err = snd_hda_parse_generic_codec(codec);
587 snd_hda_codec_free(codec);
591 if (codec->patch_ops.unsol_event)
592 init_unsol_queue(bus);
594 snd_hda_codec_proc_new(codec);
596 sprintf(component, "HDA:%08x", codec->vendor_id);
597 snd_component_add(codec->bus->card, component);
604 EXPORT_SYMBOL(snd_hda_codec_new);
607 * snd_hda_codec_setup_stream - set up the codec for streaming
608 * @codec: the CODEC to set up
609 * @nid: the NID to set up
610 * @stream_tag: stream tag to pass, it's between 0x1 and 0xf.
611 * @channel_id: channel id to pass, zero based.
612 * @format: stream format.
614 void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag,
615 int channel_id, int format)
620 snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
621 nid, stream_tag, channel_id, format);
622 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID,
623 (stream_tag << 4) | channel_id);
625 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
628 EXPORT_SYMBOL(snd_hda_codec_setup_stream);
631 * amp access functions
634 /* FIXME: more better hash key? */
635 #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))
636 #define INFO_AMP_CAPS (1<<0)
637 #define INFO_AMP_VOL(ch) (1 << (1 + (ch)))
639 /* initialize the hash table */
640 static void init_amp_hash(struct hda_codec *codec)
642 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash));
643 codec->num_amp_entries = 0;
644 codec->amp_info_size = 0;
645 codec->amp_info = NULL;
648 /* query the hash. allocate an entry if not found. */
649 static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key)
651 u16 idx = key % (u16)ARRAY_SIZE(codec->amp_hash);
652 u16 cur = codec->amp_hash[idx];
653 struct hda_amp_info *info;
655 while (cur != 0xffff) {
656 info = &codec->amp_info[cur];
657 if (info->key == key)
662 /* add a new hash entry */
663 if (codec->num_amp_entries >= codec->amp_info_size) {
664 /* reallocate the array */
665 int new_size = codec->amp_info_size + 64;
666 struct hda_amp_info *new_info = kcalloc(new_size, sizeof(struct hda_amp_info),
669 snd_printk(KERN_ERR "hda_codec: can't malloc amp_info\n");
672 if (codec->amp_info) {
673 memcpy(new_info, codec->amp_info,
674 codec->amp_info_size * sizeof(struct hda_amp_info));
675 kfree(codec->amp_info);
677 codec->amp_info_size = new_size;
678 codec->amp_info = new_info;
680 cur = codec->num_amp_entries++;
681 info = &codec->amp_info[cur];
683 info->status = 0; /* not initialized yet */
684 info->next = codec->amp_hash[idx];
685 codec->amp_hash[idx] = cur;
691 * query AMP capabilities for the given widget and direction
693 static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
695 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, 0));
699 if (! (info->status & INFO_AMP_CAPS)) {
700 if (! (get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD))
702 info->amp_caps = snd_hda_param_read(codec, nid, direction == HDA_OUTPUT ?
703 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
704 info->status |= INFO_AMP_CAPS;
706 return info->amp_caps;
710 * read the current volume to info
711 * if the cache exists, read the cache value.
713 static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
714 hda_nid_t nid, int ch, int direction, int index)
718 if (info->status & INFO_AMP_VOL(ch))
719 return info->vol[ch];
721 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT;
722 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
724 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm);
725 info->vol[ch] = val & 0xff;
726 info->status |= INFO_AMP_VOL(ch);
727 return info->vol[ch];
731 * write the current volume in info to the h/w and update the cache
733 static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
734 hda_nid_t nid, int ch, int direction, int index, int val)
738 parm = ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT;
739 parm |= direction == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT;
740 parm |= index << AC_AMP_SET_INDEX_SHIFT;
742 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm);
747 * read AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit.
749 int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
750 int direction, int index)
752 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index));
755 return get_vol_mute(codec, info, nid, ch, direction, index);
759 * update the AMP value, mask = bit mask to set, val = the value
761 int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
762 int direction, int idx, int mask, int val)
764 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));
769 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
770 if (info->vol[ch] == val && ! codec->in_resume)
772 put_vol_mute(codec, info, nid, ch, direction, idx, val);
778 * AMP control callbacks
780 /* retrieve parameters from private_value */
781 #define get_amp_nid(kc) ((kc)->private_value & 0xffff)
782 #define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3)
783 #define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1)
784 #define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
787 int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
789 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
790 u16 nid = get_amp_nid(kcontrol);
791 u8 chs = get_amp_channels(kcontrol);
792 int dir = get_amp_direction(kcontrol);
795 caps = query_amp_caps(codec, nid, dir);
796 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; /* num steps */
798 printk(KERN_WARNING "hda_codec: num_steps = 0 for NID=0x%x\n", nid);
801 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
802 uinfo->count = chs == 3 ? 2 : 1;
803 uinfo->value.integer.min = 0;
804 uinfo->value.integer.max = caps;
808 int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
810 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
811 hda_nid_t nid = get_amp_nid(kcontrol);
812 int chs = get_amp_channels(kcontrol);
813 int dir = get_amp_direction(kcontrol);
814 int idx = get_amp_index(kcontrol);
815 long *valp = ucontrol->value.integer.value;
818 *valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x7f;
820 *valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x7f;
824 int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
826 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
827 hda_nid_t nid = get_amp_nid(kcontrol);
828 int chs = get_amp_channels(kcontrol);
829 int dir = get_amp_direction(kcontrol);
830 int idx = get_amp_index(kcontrol);
831 long *valp = ucontrol->value.integer.value;
835 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
840 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
845 int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
846 unsigned int size, unsigned int __user *_tlv)
848 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
849 hda_nid_t nid = get_amp_nid(kcontrol);
850 int dir = get_amp_direction(kcontrol);
851 u32 caps, val1, val2;
853 if (size < 4 * sizeof(unsigned int))
855 caps = query_amp_caps(codec, nid, dir);
856 val2 = (((caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT) + 1) * 25;
857 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
858 val1 = ((int)val1) * ((int)val2);
859 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
861 if (put_user(2 * sizeof(unsigned int), _tlv + 1))
863 if (put_user(val1, _tlv + 2))
865 if (put_user(val2, _tlv + 3))
871 int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
873 int chs = get_amp_channels(kcontrol);
875 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
876 uinfo->count = chs == 3 ? 2 : 1;
877 uinfo->value.integer.min = 0;
878 uinfo->value.integer.max = 1;
882 int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
884 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
885 hda_nid_t nid = get_amp_nid(kcontrol);
886 int chs = get_amp_channels(kcontrol);
887 int dir = get_amp_direction(kcontrol);
888 int idx = get_amp_index(kcontrol);
889 long *valp = ucontrol->value.integer.value;
892 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x80) ? 0 : 1;
894 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x80) ? 0 : 1;
898 int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
900 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
901 hda_nid_t nid = get_amp_nid(kcontrol);
902 int chs = get_amp_channels(kcontrol);
903 int dir = get_amp_direction(kcontrol);
904 int idx = get_amp_index(kcontrol);
905 long *valp = ucontrol->value.integer.value;
909 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
910 0x80, *valp ? 0 : 0x80);
914 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
915 0x80, *valp ? 0 : 0x80);
921 * bound volume controls
923 * bind multiple volumes (# indices, from 0)
926 #define AMP_VAL_IDX_SHIFT 19
927 #define AMP_VAL_IDX_MASK (0x0f<<19)
929 int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
931 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
935 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
936 pval = kcontrol->private_value;
937 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
938 err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
939 kcontrol->private_value = pval;
940 mutex_unlock(&codec->spdif_mutex);
944 int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
946 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
948 int i, indices, err = 0, change = 0;
950 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
951 pval = kcontrol->private_value;
952 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
953 for (i = 0; i < indices; i++) {
954 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
955 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
960 kcontrol->private_value = pval;
961 mutex_unlock(&codec->spdif_mutex);
962 return err < 0 ? err : change;
969 static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
971 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
976 static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
978 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
979 IEC958_AES0_NONAUDIO |
980 IEC958_AES0_CON_EMPHASIS_5015 |
981 IEC958_AES0_CON_NOT_COPYRIGHT;
982 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY |
983 IEC958_AES1_CON_ORIGINAL;
987 static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
989 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
990 IEC958_AES0_NONAUDIO |
991 IEC958_AES0_PRO_EMPHASIS_5015;
995 static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
997 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
999 ucontrol->value.iec958.status[0] = codec->spdif_status & 0xff;
1000 ucontrol->value.iec958.status[1] = (codec->spdif_status >> 8) & 0xff;
1001 ucontrol->value.iec958.status[2] = (codec->spdif_status >> 16) & 0xff;
1002 ucontrol->value.iec958.status[3] = (codec->spdif_status >> 24) & 0xff;
1007 /* convert from SPDIF status bits to HDA SPDIF bits
1008 * bit 0 (DigEn) is always set zero (to be filled later)
1010 static unsigned short convert_from_spdif_status(unsigned int sbits)
1012 unsigned short val = 0;
1014 if (sbits & IEC958_AES0_PROFESSIONAL)
1016 if (sbits & IEC958_AES0_NONAUDIO)
1018 if (sbits & IEC958_AES0_PROFESSIONAL) {
1019 if ((sbits & IEC958_AES0_PRO_EMPHASIS) == IEC958_AES0_PRO_EMPHASIS_5015)
1022 if ((sbits & IEC958_AES0_CON_EMPHASIS) == IEC958_AES0_CON_EMPHASIS_5015)
1024 if (! (sbits & IEC958_AES0_CON_NOT_COPYRIGHT))
1026 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))
1028 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);
1033 /* convert to SPDIF status bits from HDA SPDIF bits
1035 static unsigned int convert_to_spdif_status(unsigned short val)
1037 unsigned int sbits = 0;
1040 sbits |= IEC958_AES0_NONAUDIO;
1042 sbits |= IEC958_AES0_PROFESSIONAL;
1043 if (sbits & IEC958_AES0_PROFESSIONAL) {
1044 if (sbits & (1 << 3))
1045 sbits |= IEC958_AES0_PRO_EMPHASIS_5015;
1048 sbits |= IEC958_AES0_CON_EMPHASIS_5015;
1049 if (! (val & (1 << 4)))
1050 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT;
1052 sbits |= (IEC958_AES1_CON_ORIGINAL << 8);
1053 sbits |= val & (0x7f << 8);
1058 static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1060 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1061 hda_nid_t nid = kcontrol->private_value;
1065 mutex_lock(&codec->spdif_mutex);
1066 codec->spdif_status = ucontrol->value.iec958.status[0] |
1067 ((unsigned int)ucontrol->value.iec958.status[1] << 8) |
1068 ((unsigned int)ucontrol->value.iec958.status[2] << 16) |
1069 ((unsigned int)ucontrol->value.iec958.status[3] << 24);
1070 val = convert_from_spdif_status(codec->spdif_status);
1071 val |= codec->spdif_ctls & 1;
1072 change = codec->spdif_ctls != val;
1073 codec->spdif_ctls = val;
1075 if (change || codec->in_resume) {
1076 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff);
1077 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2, val >> 8);
1080 mutex_unlock(&codec->spdif_mutex);
1084 static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1086 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1088 uinfo->value.integer.min = 0;
1089 uinfo->value.integer.max = 1;
1093 static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1095 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1097 ucontrol->value.integer.value[0] = codec->spdif_ctls & 1;
1101 static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1103 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1104 hda_nid_t nid = kcontrol->private_value;
1108 mutex_lock(&codec->spdif_mutex);
1109 val = codec->spdif_ctls & ~1;
1110 if (ucontrol->value.integer.value[0])
1112 change = codec->spdif_ctls != val;
1113 if (change || codec->in_resume) {
1114 codec->spdif_ctls = val;
1115 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff);
1116 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1117 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT |
1118 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80));
1120 mutex_unlock(&codec->spdif_mutex);
1124 static struct snd_kcontrol_new dig_mixes[] = {
1126 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1128 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK),
1129 .info = snd_hda_spdif_mask_info,
1130 .get = snd_hda_spdif_cmask_get,
1133 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1135 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK),
1136 .info = snd_hda_spdif_mask_info,
1137 .get = snd_hda_spdif_pmask_get,
1140 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1141 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
1142 .info = snd_hda_spdif_mask_info,
1143 .get = snd_hda_spdif_default_get,
1144 .put = snd_hda_spdif_default_put,
1147 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1148 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH),
1149 .info = snd_hda_spdif_out_switch_info,
1150 .get = snd_hda_spdif_out_switch_get,
1151 .put = snd_hda_spdif_out_switch_put,
1157 * snd_hda_create_spdif_out_ctls - create Output SPDIF-related controls
1158 * @codec: the HDA codec
1159 * @nid: audio out widget NID
1161 * Creates controls related with the SPDIF output.
1162 * Called from each patch supporting the SPDIF out.
1164 * Returns 0 if successful, or a negative error code.
1166 int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1169 struct snd_kcontrol *kctl;
1170 struct snd_kcontrol_new *dig_mix;
1172 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
1173 kctl = snd_ctl_new1(dig_mix, codec);
1174 kctl->private_value = nid;
1175 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0)
1178 codec->spdif_ctls = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0);
1179 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);
1187 #define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info
1189 static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1191 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1193 ucontrol->value.integer.value[0] = codec->spdif_in_enable;
1197 static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1200 hda_nid_t nid = kcontrol->private_value;
1201 unsigned int val = !!ucontrol->value.integer.value[0];
1204 mutex_lock(&codec->spdif_mutex);
1205 change = codec->spdif_in_enable != val;
1206 if (change || codec->in_resume) {
1207 codec->spdif_in_enable = val;
1208 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val);
1210 mutex_unlock(&codec->spdif_mutex);
1214 static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1216 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1217 hda_nid_t nid = kcontrol->private_value;
1221 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0);
1222 sbits = convert_to_spdif_status(val);
1223 ucontrol->value.iec958.status[0] = sbits;
1224 ucontrol->value.iec958.status[1] = sbits >> 8;
1225 ucontrol->value.iec958.status[2] = sbits >> 16;
1226 ucontrol->value.iec958.status[3] = sbits >> 24;
1230 static struct snd_kcontrol_new dig_in_ctls[] = {
1232 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1233 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),
1234 .info = snd_hda_spdif_in_switch_info,
1235 .get = snd_hda_spdif_in_switch_get,
1236 .put = snd_hda_spdif_in_switch_put,
1239 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1241 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT),
1242 .info = snd_hda_spdif_mask_info,
1243 .get = snd_hda_spdif_in_status_get,
1249 * snd_hda_create_spdif_in_ctls - create Input SPDIF-related controls
1250 * @codec: the HDA codec
1251 * @nid: audio in widget NID
1253 * Creates controls related with the SPDIF input.
1254 * Called from each patch supporting the SPDIF in.
1256 * Returns 0 if successful, or a negative error code.
1258 int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1261 struct snd_kcontrol *kctl;
1262 struct snd_kcontrol_new *dig_mix;
1264 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1265 kctl = snd_ctl_new1(dig_mix, codec);
1266 kctl->private_value = nid;
1267 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0)
1270 codec->spdif_in_enable = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) & 1;
1276 * set power state of the codec
1278 static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
1279 unsigned int power_state)
1281 hda_nid_t nid, nid_start;
1284 snd_hda_codec_write(codec, fg, 0, AC_VERB_SET_POWER_STATE,
1287 nodes = snd_hda_get_sub_nodes(codec, fg, &nid_start);
1288 for (nid = nid_start; nid < nodes + nid_start; nid++) {
1289 if (get_wcaps(codec, nid) & AC_WCAP_POWER)
1290 snd_hda_codec_write(codec, nid, 0,
1291 AC_VERB_SET_POWER_STATE,
1295 if (power_state == AC_PWRST_D0)
1301 * snd_hda_build_controls - build mixer controls
1304 * Creates mixer controls for each codec included in the bus.
1306 * Returns 0 if successful, otherwise a negative error code.
1308 int snd_hda_build_controls(struct hda_bus *bus)
1310 struct list_head *p;
1312 /* build controls */
1313 list_for_each(p, &bus->codec_list) {
1314 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1316 if (! codec->patch_ops.build_controls)
1318 err = codec->patch_ops.build_controls(codec);
1324 list_for_each(p, &bus->codec_list) {
1325 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1327 hda_set_power_state(codec,
1328 codec->afg ? codec->afg : codec->mfg,
1330 if (! codec->patch_ops.init)
1332 err = codec->patch_ops.init(codec);
1339 EXPORT_SYMBOL(snd_hda_build_controls);
1344 struct hda_rate_tbl {
1346 unsigned int alsa_bits;
1347 unsigned int hda_fmt;
1350 static struct hda_rate_tbl rate_bits[] = {
1351 /* rate in Hz, ALSA rate bitmask, HDA format value */
1353 /* autodetected value used in snd_hda_query_supported_pcm */
1354 { 8000, SNDRV_PCM_RATE_8000, 0x0500 }, /* 1/6 x 48 */
1355 { 11025, SNDRV_PCM_RATE_11025, 0x4300 }, /* 1/4 x 44 */
1356 { 16000, SNDRV_PCM_RATE_16000, 0x0200 }, /* 1/3 x 48 */
1357 { 22050, SNDRV_PCM_RATE_22050, 0x4100 }, /* 1/2 x 44 */
1358 { 32000, SNDRV_PCM_RATE_32000, 0x0a00 }, /* 2/3 x 48 */
1359 { 44100, SNDRV_PCM_RATE_44100, 0x4000 }, /* 44 */
1360 { 48000, SNDRV_PCM_RATE_48000, 0x0000 }, /* 48 */
1361 { 88200, SNDRV_PCM_RATE_88200, 0x4800 }, /* 2 x 44 */
1362 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */
1363 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */
1364 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */
1366 /* not autodetected value */
1367 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
1369 { 0 } /* terminator */
1373 * snd_hda_calc_stream_format - calculate format bitset
1374 * @rate: the sample rate
1375 * @channels: the number of channels
1376 * @format: the PCM format (SNDRV_PCM_FORMAT_XXX)
1377 * @maxbps: the max. bps
1379 * Calculate the format bitset from the given rate, channels and th PCM format.
1381 * Return zero if invalid.
1383 unsigned int snd_hda_calc_stream_format(unsigned int rate,
1384 unsigned int channels,
1385 unsigned int format,
1386 unsigned int maxbps)
1389 unsigned int val = 0;
1391 for (i = 0; rate_bits[i].hz; i++)
1392 if (rate_bits[i].hz == rate) {
1393 val = rate_bits[i].hda_fmt;
1396 if (! rate_bits[i].hz) {
1397 snd_printdd("invalid rate %d\n", rate);
1401 if (channels == 0 || channels > 8) {
1402 snd_printdd("invalid channels %d\n", channels);
1405 val |= channels - 1;
1407 switch (snd_pcm_format_width(format)) {
1408 case 8: val |= 0x00; break;
1409 case 16: val |= 0x10; break;
1415 else if (maxbps >= 24)
1421 snd_printdd("invalid format width %d\n", snd_pcm_format_width(format));
1428 EXPORT_SYMBOL(snd_hda_calc_stream_format);
1431 * snd_hda_query_supported_pcm - query the supported PCM rates and formats
1432 * @codec: the HDA codec
1433 * @nid: NID to query
1434 * @ratesp: the pointer to store the detected rate bitflags
1435 * @formatsp: the pointer to store the detected formats
1436 * @bpsp: the pointer to store the detected format widths
1438 * Queries the supported PCM rates and formats. The NULL @ratesp, @formatsp
1439 * or @bsps argument is ignored.
1441 * Returns 0 if successful, otherwise a negative error code.
1443 int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1444 u32 *ratesp, u64 *formatsp, unsigned int *bpsp)
1447 unsigned int val, streams;
1450 if (nid != codec->afg &&
1451 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) {
1452 val = snd_hda_param_read(codec, nid, AC_PAR_PCM);
1457 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1461 for (i = 0; rate_bits[i].hz; i++) {
1463 rates |= rate_bits[i].alsa_bits;
1468 if (formatsp || bpsp) {
1473 wcaps = get_wcaps(codec, nid);
1474 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1478 streams = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM);
1484 if (streams & AC_SUPFMT_PCM) {
1485 if (val & AC_SUPPCM_BITS_8) {
1486 formats |= SNDRV_PCM_FMTBIT_U8;
1489 if (val & AC_SUPPCM_BITS_16) {
1490 formats |= SNDRV_PCM_FMTBIT_S16_LE;
1493 if (wcaps & AC_WCAP_DIGITAL) {
1494 if (val & AC_SUPPCM_BITS_32)
1495 formats |= SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE;
1496 if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24))
1497 formats |= SNDRV_PCM_FMTBIT_S32_LE;
1498 if (val & AC_SUPPCM_BITS_24)
1500 else if (val & AC_SUPPCM_BITS_20)
1502 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|AC_SUPPCM_BITS_32)) {
1503 formats |= SNDRV_PCM_FMTBIT_S32_LE;
1504 if (val & AC_SUPPCM_BITS_32)
1506 else if (val & AC_SUPPCM_BITS_20)
1508 else if (val & AC_SUPPCM_BITS_24)
1512 else if (streams == AC_SUPFMT_FLOAT32) { /* should be exclusive */
1513 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE;
1515 } else if (streams == AC_SUPFMT_AC3) { /* should be exclusive */
1516 /* temporary hack: we have still no proper support
1517 * for the direct AC3 stream...
1519 formats |= SNDRV_PCM_FMTBIT_U8;
1523 *formatsp = formats;
1532 * snd_hda_is_supported_format - check whether the given node supports the format val
1534 * Returns 1 if supported, 0 if not.
1536 int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
1537 unsigned int format)
1540 unsigned int val = 0, rate, stream;
1542 if (nid != codec->afg &&
1543 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) {
1544 val = snd_hda_param_read(codec, nid, AC_PAR_PCM);
1549 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1554 rate = format & 0xff00;
1555 for (i = 0; rate_bits[i].hz; i++)
1556 if (rate_bits[i].hda_fmt == rate) {
1561 if (! rate_bits[i].hz)
1564 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1567 if (! stream && nid != codec->afg)
1568 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM);
1569 if (! stream || stream == -1)
1572 if (stream & AC_SUPFMT_PCM) {
1573 switch (format & 0xf0) {
1575 if (! (val & AC_SUPPCM_BITS_8))
1579 if (! (val & AC_SUPPCM_BITS_16))
1583 if (! (val & AC_SUPPCM_BITS_20))
1587 if (! (val & AC_SUPPCM_BITS_24))
1591 if (! (val & AC_SUPPCM_BITS_32))
1598 /* FIXME: check for float32 and AC3? */
1607 static int hda_pcm_default_open_close(struct hda_pcm_stream *hinfo,
1608 struct hda_codec *codec,
1609 struct snd_pcm_substream *substream)
1614 static int hda_pcm_default_prepare(struct hda_pcm_stream *hinfo,
1615 struct hda_codec *codec,
1616 unsigned int stream_tag,
1617 unsigned int format,
1618 struct snd_pcm_substream *substream)
1620 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format);
1624 static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
1625 struct hda_codec *codec,
1626 struct snd_pcm_substream *substream)
1628 snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0);
1632 static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream *info)
1635 /* query support PCM information from the given NID */
1636 if (! info->rates || ! info->formats)
1637 snd_hda_query_supported_pcm(codec, info->nid,
1638 info->rates ? NULL : &info->rates,
1639 info->formats ? NULL : &info->formats,
1640 info->maxbps ? NULL : &info->maxbps);
1642 if (info->ops.open == NULL)
1643 info->ops.open = hda_pcm_default_open_close;
1644 if (info->ops.close == NULL)
1645 info->ops.close = hda_pcm_default_open_close;
1646 if (info->ops.prepare == NULL) {
1647 snd_assert(info->nid, return -EINVAL);
1648 info->ops.prepare = hda_pcm_default_prepare;
1650 if (info->ops.cleanup == NULL) {
1651 snd_assert(info->nid, return -EINVAL);
1652 info->ops.cleanup = hda_pcm_default_cleanup;
1658 * snd_hda_build_pcms - build PCM information
1661 * Create PCM information for each codec included in the bus.
1663 * The build_pcms codec patch is requested to set up codec->num_pcms and
1664 * codec->pcm_info properly. The array is referred by the top-level driver
1665 * to create its PCM instances.
1666 * The allocated codec->pcm_info should be released in codec->patch_ops.free
1669 * At least, substreams, channels_min and channels_max must be filled for
1670 * each stream. substreams = 0 indicates that the stream doesn't exist.
1671 * When rates and/or formats are zero, the supported values are queried
1672 * from the given nid. The nid is used also by the default ops.prepare
1673 * and ops.cleanup callbacks.
1675 * The driver needs to call ops.open in its open callback. Similarly,
1676 * ops.close is supposed to be called in the close callback.
1677 * ops.prepare should be called in the prepare or hw_params callback
1678 * with the proper parameters for set up.
1679 * ops.cleanup should be called in hw_free for clean up of streams.
1681 * This function returns 0 if successfull, or a negative error code.
1683 int snd_hda_build_pcms(struct hda_bus *bus)
1685 struct list_head *p;
1687 list_for_each(p, &bus->codec_list) {
1688 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1689 unsigned int pcm, s;
1691 if (! codec->patch_ops.build_pcms)
1693 err = codec->patch_ops.build_pcms(codec);
1696 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
1697 for (s = 0; s < 2; s++) {
1698 struct hda_pcm_stream *info;
1699 info = &codec->pcm_info[pcm].stream[s];
1700 if (! info->substreams)
1702 err = set_pcm_default_values(codec, info);
1711 EXPORT_SYMBOL(snd_hda_build_pcms);
1714 * snd_hda_check_board_config - compare the current codec with the config table
1715 * @codec: the HDA codec
1716 * @tbl: configuration table, terminated by null entries
1718 * Compares the modelname or PCI subsystem id of the current codec with the
1719 * given configuration table. If a matching entry is found, returns its
1720 * config value (supposed to be 0 or positive).
1722 * If no entries are matching, the function returns a negative value.
1724 int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl)
1726 const struct hda_board_config *c;
1728 if (codec->bus->modelname) {
1729 for (c = tbl; c->modelname || c->pci_subvendor; c++) {
1731 ! strcmp(codec->bus->modelname, c->modelname)) {
1732 snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname);
1738 if (codec->bus->pci) {
1739 u16 subsystem_vendor, subsystem_device;
1740 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
1741 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device);
1742 for (c = tbl; c->modelname || c->pci_subvendor; c++) {
1743 if (c->pci_subvendor == subsystem_vendor &&
1744 (! c->pci_subdevice /* all match */||
1745 (c->pci_subdevice == subsystem_device))) {
1746 snd_printdd(KERN_INFO "hda_codec: PCI %x:%x, codec config %d is selected\n",
1747 subsystem_vendor, subsystem_device, c->config);
1756 * snd_hda_add_new_ctls - create controls from the array
1757 * @codec: the HDA codec
1758 * @knew: the array of struct snd_kcontrol_new
1760 * This helper function creates and add new controls in the given array.
1761 * The array must be terminated with an empty entry as terminator.
1763 * Returns 0 if successful, or a negative error code.
1765 int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
1769 for (; knew->name; knew++) {
1770 struct snd_kcontrol *kctl;
1771 kctl = snd_ctl_new1(knew, codec);
1774 err = snd_ctl_add(codec->bus->card, kctl);
1778 kctl = snd_ctl_new1(knew, codec);
1781 kctl->id.device = codec->addr;
1782 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0)
1791 * Channel mode helper
1793 int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo,
1794 const struct hda_channel_mode *chmode, int num_chmodes)
1796 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1798 uinfo->value.enumerated.items = num_chmodes;
1799 if (uinfo->value.enumerated.item >= num_chmodes)
1800 uinfo->value.enumerated.item = num_chmodes - 1;
1801 sprintf(uinfo->value.enumerated.name, "%dch",
1802 chmode[uinfo->value.enumerated.item].channels);
1806 int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol,
1807 const struct hda_channel_mode *chmode, int num_chmodes,
1812 for (i = 0; i < num_chmodes; i++) {
1813 if (max_channels == chmode[i].channels) {
1814 ucontrol->value.enumerated.item[0] = i;
1821 int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol,
1822 const struct hda_channel_mode *chmode, int num_chmodes,
1827 mode = ucontrol->value.enumerated.item[0];
1828 snd_assert(mode < num_chmodes, return -EINVAL);
1829 if (*max_channelsp == chmode[mode].channels && ! codec->in_resume)
1831 /* change the current channel setting */
1832 *max_channelsp = chmode[mode].channels;
1833 if (chmode[mode].sequence)
1834 snd_hda_sequence_write(codec, chmode[mode].sequence);
1841 int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo)
1845 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1847 uinfo->value.enumerated.items = imux->num_items;
1848 index = uinfo->value.enumerated.item;
1849 if (index >= imux->num_items)
1850 index = imux->num_items - 1;
1851 strcpy(uinfo->value.enumerated.name, imux->items[index].label);
1855 int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux,
1856 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid,
1857 unsigned int *cur_val)
1861 idx = ucontrol->value.enumerated.item[0];
1862 if (idx >= imux->num_items)
1863 idx = imux->num_items - 1;
1864 if (*cur_val == idx && ! codec->in_resume)
1866 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
1867 imux->items[idx].index);
1874 * Multi-channel / digital-out PCM helper functions
1878 * open the digital out in the exclusive mode
1880 int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout)
1882 mutex_lock(&codec->spdif_mutex);
1883 if (mout->dig_out_used) {
1884 mutex_unlock(&codec->spdif_mutex);
1885 return -EBUSY; /* already being used */
1887 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
1888 mutex_unlock(&codec->spdif_mutex);
1893 * release the digital out
1895 int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout)
1897 mutex_lock(&codec->spdif_mutex);
1898 mout->dig_out_used = 0;
1899 mutex_unlock(&codec->spdif_mutex);
1904 * set up more restrictions for analog out
1906 int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout,
1907 struct snd_pcm_substream *substream)
1909 substream->runtime->hw.channels_max = mout->max_channels;
1910 return snd_pcm_hw_constraint_step(substream->runtime, 0,
1911 SNDRV_PCM_HW_PARAM_CHANNELS, 2);
1915 * set up the i/o for analog out
1916 * when the digital out is available, copy the front out to digital out, too.
1918 int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout,
1919 unsigned int stream_tag,
1920 unsigned int format,
1921 struct snd_pcm_substream *substream)
1923 hda_nid_t *nids = mout->dac_nids;
1924 int chs = substream->runtime->channels;
1927 mutex_lock(&codec->spdif_mutex);
1928 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
1930 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) &&
1931 ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) {
1932 mout->dig_out_used = HDA_DIG_ANALOG_DUP;
1933 /* setup digital receiver */
1934 snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
1935 stream_tag, 0, format);
1937 mout->dig_out_used = 0;
1938 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
1941 mutex_unlock(&codec->spdif_mutex);
1944 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format);
1945 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT])
1946 /* headphone out will just decode front left/right (stereo) */
1947 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format);
1948 /* extra outputs copied from front */
1949 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
1950 if (mout->extra_out_nid[i])
1951 snd_hda_codec_setup_stream(codec,
1952 mout->extra_out_nid[i],
1953 stream_tag, 0, format);
1956 for (i = 1; i < mout->num_dacs; i++) {
1957 if (chs >= (i + 1) * 2) /* independent out */
1958 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2,
1960 else /* copy front */
1961 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0,
1968 * clean up the setting for analog out
1970 int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_out *mout)
1972 hda_nid_t *nids = mout->dac_nids;
1975 for (i = 0; i < mout->num_dacs; i++)
1976 snd_hda_codec_setup_stream(codec, nids[i], 0, 0, 0);
1978 snd_hda_codec_setup_stream(codec, mout->hp_nid, 0, 0, 0);
1979 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
1980 if (mout->extra_out_nid[i])
1981 snd_hda_codec_setup_stream(codec,
1982 mout->extra_out_nid[i],
1984 mutex_lock(&codec->spdif_mutex);
1985 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) {
1986 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
1987 mout->dig_out_used = 0;
1989 mutex_unlock(&codec->spdif_mutex);
1994 * Helper for automatic ping configuration
1997 static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
1999 for (; *list; list++)
2006 * Parse all pin widgets and store the useful pin nids to cfg
2008 * The number of line-outs or any primary output is stored in line_outs,
2009 * and the corresponding output pins are assigned to line_out_pins[],
2010 * in the order of front, rear, CLFE, side, ...
2012 * If more extra outputs (speaker and headphone) are found, the pins are
2013 * assisnged to hp_pin and speaker_pins[], respectively. If no line-out jack
2014 * is detected, one of speaker of HP pins is assigned as the primary
2015 * output, i.e. to line_out_pins[0]. So, line_outs is always positive
2016 * if any analog output exists.
2018 * The analog input pins are assigned to input_pins array.
2019 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
2022 int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg,
2023 hda_nid_t *ignore_nids)
2025 hda_nid_t nid, nid_start;
2027 short seq, assoc_line_out, sequences[ARRAY_SIZE(cfg->line_out_pins)];
2029 memset(cfg, 0, sizeof(*cfg));
2031 memset(sequences, 0, sizeof(sequences));
2034 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start);
2035 for (nid = nid_start; nid < nodes + nid_start; nid++) {
2036 unsigned int wid_caps = get_wcaps(codec, nid);
2037 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2038 unsigned int def_conf;
2041 /* read all default configuration for pin complex */
2042 if (wid_type != AC_WID_PIN)
2044 /* ignore the given nids (e.g. pc-beep returns error) */
2045 if (ignore_nids && is_in_nid_list(nid, ignore_nids))
2048 def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
2049 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2051 loc = get_defcfg_location(def_conf);
2052 switch (get_defcfg_device(def_conf)) {
2053 case AC_JACK_LINE_OUT:
2054 seq = get_defcfg_sequence(def_conf);
2055 assoc = get_defcfg_association(def_conf);
2058 if (! assoc_line_out)
2059 assoc_line_out = assoc;
2060 else if (assoc_line_out != assoc)
2062 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins))
2064 cfg->line_out_pins[cfg->line_outs] = nid;
2065 sequences[cfg->line_outs] = seq;
2068 case AC_JACK_SPEAKER:
2069 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
2071 cfg->speaker_pins[cfg->speaker_outs] = nid;
2072 cfg->speaker_outs++;
2074 case AC_JACK_HP_OUT:
2077 case AC_JACK_MIC_IN:
2078 if (loc == AC_JACK_LOC_FRONT)
2079 cfg->input_pins[AUTO_PIN_FRONT_MIC] = nid;
2081 cfg->input_pins[AUTO_PIN_MIC] = nid;
2083 case AC_JACK_LINE_IN:
2084 if (loc == AC_JACK_LOC_FRONT)
2085 cfg->input_pins[AUTO_PIN_FRONT_LINE] = nid;
2087 cfg->input_pins[AUTO_PIN_LINE] = nid;
2090 cfg->input_pins[AUTO_PIN_CD] = nid;
2093 cfg->input_pins[AUTO_PIN_AUX] = nid;
2095 case AC_JACK_SPDIF_OUT:
2096 cfg->dig_out_pin = nid;
2098 case AC_JACK_SPDIF_IN:
2099 cfg->dig_in_pin = nid;
2104 /* sort by sequence */
2105 for (i = 0; i < cfg->line_outs; i++)
2106 for (j = i + 1; j < cfg->line_outs; j++)
2107 if (sequences[i] > sequences[j]) {
2109 sequences[i] = sequences[j];
2111 nid = cfg->line_out_pins[i];
2112 cfg->line_out_pins[i] = cfg->line_out_pins[j];
2113 cfg->line_out_pins[j] = nid;
2116 /* Reorder the surround channels
2117 * ALSA sequence is front/surr/clfe/side
2119 * 4-ch: front/surr => OK as it is
2120 * 6-ch: front/clfe/surr
2121 * 8-ch: front/clfe/side/surr
2123 switch (cfg->line_outs) {
2125 nid = cfg->line_out_pins[1];
2126 cfg->line_out_pins[1] = cfg->line_out_pins[2];
2127 cfg->line_out_pins[2] = nid;
2130 nid = cfg->line_out_pins[1];
2131 cfg->line_out_pins[1] = cfg->line_out_pins[3];
2132 cfg->line_out_pins[3] = cfg->line_out_pins[2];
2133 cfg->line_out_pins[2] = nid;
2138 * debug prints of the parsed results
2140 snd_printd("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2141 cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1],
2142 cfg->line_out_pins[2], cfg->line_out_pins[3],
2143 cfg->line_out_pins[4]);
2144 snd_printd(" speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2145 cfg->speaker_outs, cfg->speaker_pins[0],
2146 cfg->speaker_pins[1], cfg->speaker_pins[2],
2147 cfg->speaker_pins[3], cfg->speaker_pins[4]);
2148 snd_printd(" hp=0x%x, dig_out=0x%x, din_in=0x%x\n",
2149 cfg->hp_pin, cfg->dig_out_pin, cfg->dig_in_pin);
2150 snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x,"
2151 " cd=0x%x, aux=0x%x\n",
2152 cfg->input_pins[AUTO_PIN_MIC],
2153 cfg->input_pins[AUTO_PIN_FRONT_MIC],
2154 cfg->input_pins[AUTO_PIN_LINE],
2155 cfg->input_pins[AUTO_PIN_FRONT_LINE],
2156 cfg->input_pins[AUTO_PIN_CD],
2157 cfg->input_pins[AUTO_PIN_AUX]);
2160 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
2161 * as a primary output
2163 if (! cfg->line_outs) {
2164 if (cfg->speaker_outs) {
2165 cfg->line_outs = cfg->speaker_outs;
2166 memcpy(cfg->line_out_pins, cfg->speaker_pins,
2167 sizeof(cfg->speaker_pins));
2168 cfg->speaker_outs = 0;
2169 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
2170 } else if (cfg->hp_pin) {
2172 cfg->line_out_pins[0] = cfg->hp_pin;
2180 /* labels for input pins */
2181 const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
2182 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
2192 * snd_hda_suspend - suspend the codecs
2194 * @state: suspsend state
2196 * Returns 0 if successful.
2198 int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2200 struct list_head *p;
2202 /* FIXME: should handle power widget capabilities */
2203 list_for_each(p, &bus->codec_list) {
2204 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
2205 if (codec->patch_ops.suspend)
2206 codec->patch_ops.suspend(codec, state);
2207 hda_set_power_state(codec,
2208 codec->afg ? codec->afg : codec->mfg,
2214 EXPORT_SYMBOL(snd_hda_suspend);
2217 * snd_hda_resume - resume the codecs
2219 * @state: resume state
2221 * Returns 0 if successful.
2223 int snd_hda_resume(struct hda_bus *bus)
2225 struct list_head *p;
2227 list_for_each(p, &bus->codec_list) {
2228 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
2229 hda_set_power_state(codec,
2230 codec->afg ? codec->afg : codec->mfg,
2232 if (codec->patch_ops.resume)
2233 codec->patch_ops.resume(codec);
2238 EXPORT_SYMBOL(snd_hda_resume);
2241 * snd_hda_resume_ctls - resume controls in the new control list
2242 * @codec: the HDA codec
2243 * @knew: the array of struct snd_kcontrol_new
2245 * This function resumes the mixer controls in the struct snd_kcontrol_new array,
2246 * originally for snd_hda_add_new_ctls().
2247 * The array must be terminated with an empty entry as terminator.
2249 int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
2251 struct snd_ctl_elem_value *val;
2253 val = kmalloc(sizeof(*val), GFP_KERNEL);
2256 codec->in_resume = 1;
2257 for (; knew->name; knew++) {
2259 count = knew->count ? knew->count : 1;
2260 for (i = 0; i < count; i++) {
2261 memset(val, 0, sizeof(*val));
2262 val->id.iface = knew->iface;
2263 val->id.device = knew->device;
2264 val->id.subdevice = knew->subdevice;
2265 strcpy(val->id.name, knew->name);
2266 val->id.index = knew->index ? knew->index : i;
2267 /* Assume that get callback reads only from cache,
2268 * not accessing to the real hardware
2270 if (snd_ctl_elem_read(codec->bus->card, val) < 0)
2272 snd_ctl_elem_write(codec->bus->card, NULL, val);
2275 codec->in_resume = 0;
2281 * snd_hda_resume_spdif_out - resume the digital out
2282 * @codec: the HDA codec
2284 int snd_hda_resume_spdif_out(struct hda_codec *codec)
2286 return snd_hda_resume_ctls(codec, dig_mixes);
2290 * snd_hda_resume_spdif_in - resume the digital in
2291 * @codec: the HDA codec
2293 int snd_hda_resume_spdif_in(struct hda_codec *codec)
2295 return snd_hda_resume_ctls(codec, dig_in_ctls);
2303 static int __init alsa_hda_init(void)
2308 static void __exit alsa_hda_exit(void)
2312 module_init(alsa_hda_init)
2313 module_exit(alsa_hda_exit)