Lines Matching +full:codec +full:- +full:analog +full:- +full:controls
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Universal Interface for Intel High Definition Audio Codec
28 #define codec_in_pm(codec) snd_hdac_is_in_pm(&codec->core)
29 #define hda_codec_is_power_on(codec) snd_hdac_is_power_on(&codec->core)
30 #define codec_has_epss(codec) \
31 ((codec)->core.power_caps & AC_PWRST_EPSS)
32 #define codec_has_clkstop(codec) \
33 ((codec)->core.power_caps & AC_PWRST_CLKSTOP)
35 static int call_exec_verb(struct hda_bus *bus, struct hda_codec *codec,
41 CLASS(snd_hda_power_pm, pm)(codec);
42 guard(mutex)(&bus->core.cmd_mutex);
44 bus->no_response_fallback = 1;
45 err = snd_hdac_bus_exec_verb_unlocked(&bus->core, codec->core.addr,
47 bus->no_response_fallback = 0;
52 * Send and receive a verb - passed to exec_verb override for hdac_device
57 struct hda_codec *codec = container_of(dev, struct hda_codec, core);
58 struct hda_bus *bus = codec->bus;
62 return -1;
65 err = call_exec_verb(bus, codec, cmd, flags, res);
66 if (!codec_in_pm(codec) && res && err == -EAGAIN) {
67 if (bus->response_reset) {
68 codec_dbg(codec,
74 /* clear reset-flag when the communication gets recovered */
75 if (!err || codec_in_pm(codec))
76 bus->response_reset = 0;
81 * snd_hda_sequence_write - sequence writes
82 * @codec: the HDA codec
88 void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq)
90 for (; seq->nid; seq++)
91 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param);
105 lookup_conn_list(struct hda_codec *codec, hda_nid_t nid)
108 list_for_each_entry(p, &codec->conn_list, list) {
109 if (p->nid == nid)
115 static int add_conn_list(struct hda_codec *codec, hda_nid_t nid, int len,
122 return -ENOMEM;
123 p->len = len;
124 p->nid = nid;
125 memcpy(p->conns, list, len * sizeof(hda_nid_t));
126 list_add(&p->list, &codec->conn_list);
130 static void remove_conn_list(struct hda_codec *codec)
132 while (!list_empty(&codec->conn_list)) {
134 p = list_first_entry(&codec->conn_list, typeof(*p), list);
135 list_del(&p->list);
141 static int read_and_add_raw_conns(struct hda_codec *codec, hda_nid_t nid)
147 len = snd_hda_get_raw_connections(codec, nid, list, ARRAY_SIZE(list));
148 if (len == -ENOSPC) {
149 len = snd_hda_get_num_raw_conns(codec, nid);
152 return -ENOMEM;
153 len = snd_hda_get_raw_connections(codec, nid, result, len);
156 len = snd_hda_override_conn_list(codec, nid, len, result);
163 * snd_hda_get_conn_list - get connection list
164 * @codec: the HDA codec
177 int snd_hda_get_conn_list(struct hda_codec *codec, hda_nid_t nid,
186 /* if the connection-list is already cached, read it */
187 p = lookup_conn_list(codec, nid);
190 *listp = p->conns;
191 return p->len;
194 return -EINVAL;
196 err = read_and_add_raw_conns(codec, nid);
205 * snd_hda_get_connections - copy connection list
206 * @codec: the HDA codec
216 int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
220 int len = snd_hda_get_conn_list(codec, nid, &list);
224 codec_err(codec, "Too many connections %d for NID 0x%x\n",
226 return -EINVAL;
236 * snd_hda_override_conn_list - add/modify the connection-list to cache
237 * @codec: the HDA codec
242 * Add or modify the given connection-list to the cache. If the corresponding
247 int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int len,
252 p = lookup_conn_list(codec, nid);
254 list_del(&p->list);
258 return add_conn_list(codec, nid, len, list);
263 * snd_hda_get_conn_index - get the connection index of the given NID
264 * @codec: the HDA codec
271 * Otherwise it returns -1.
273 int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
279 nums = snd_hda_get_conn_list(codec, mux, &conn);
284 return -1;
286 codec_dbg(codec, "too deep connection for 0x%x\n", nid);
287 return -1;
291 unsigned int type = get_wcaps_type(get_wcaps(codec, conn[i]));
294 if (snd_hda_get_conn_index(codec, conn[i], nid, recursive) >= 0)
297 return -1;
302 * snd_hda_get_num_devices - get DEVLIST_LEN parameter of the given widget
303 * @codec: the HDA codec
309 unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid)
311 unsigned int wcaps = get_wcaps(codec, nid);
314 if (!codec->dp_mst || !(wcaps & AC_WCAP_DIGITAL) ||
318 parm = snd_hdac_read_parm_uncached(&codec->core, nid, AC_PAR_DEVLIST_LEN);
319 if (parm == -1)
326 * snd_hda_get_devices - copy device list without cache
327 * @codec: the HDA codec
335 unsigned int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
340 parm = snd_hda_get_num_devices(codec, nid);
341 if (!parm) /* not multi-stream capable */
348 if (snd_hdac_read(&codec->core, nid,
364 * snd_hda_get_dev_select - get device entry select on the pin
365 * @codec: the HDA codec
372 int snd_hda_get_dev_select(struct hda_codec *codec, hda_nid_t nid)
375 if (!codec->dp_mst)
378 return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DEVICE_SEL, 0);
383 * snd_hda_set_dev_select - set device entry select on the pin
384 * @codec: the HDA codec
390 int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid, int dev_id)
395 if (!codec->dp_mst)
399 num_devices = snd_hda_get_num_devices(codec, nid) + 1;
411 return -EINVAL;
413 ret = snd_hda_codec_write(codec, nid, 0,
423 static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
428 codec->wcaps = kmalloc_array(codec->core.num_nodes, 4, GFP_KERNEL);
429 if (!codec->wcaps)
430 return -ENOMEM;
431 nid = codec->core.start_nid;
432 for (i = 0; i < codec->core.num_nodes; i++, nid++)
433 codec->wcaps[i] = snd_hdac_read_parm_uncached(&codec->core,
438 /* read all pin default configurations and save codec->init_pins */
439 static int read_pin_defaults(struct hda_codec *codec)
443 for_each_hda_codec_node(nid, codec) {
445 unsigned int wcaps = get_wcaps(codec, nid);
449 pin = snd_array_new(&codec->init_pins);
451 return -ENOMEM;
452 pin->nid = nid;
453 pin->cfg = snd_hda_codec_read(codec, nid, 0,
457 * fixme: if any codec is different, need fix here
459 pin->ctrl = snd_hda_codec_read(codec, nid, 0,
467 static struct hda_pincfg *look_up_pincfg(struct hda_codec *codec,
475 if (pin->nid == nid)
484 int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
489 pin = look_up_pincfg(codec, list, nid);
493 return -ENOMEM;
494 pin->nid = nid;
496 pin->cfg = cfg;
501 * snd_hda_codec_set_pincfg - Override a pin default configuration
502 * @codec: the HDA codec
510 int snd_hda_codec_set_pincfg(struct hda_codec *codec,
513 return snd_hda_add_pincfg(codec, &codec->driver_pins, nid, cfg);
518 * snd_hda_codec_get_pincfg - Obtain a pin-default configuration
519 * @codec: the HDA codec
526 unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid)
533 scoped_guard(mutex, &codec->user_mutex) {
534 pin = look_up_pincfg(codec, &codec->user_pins, nid);
536 cfg = pin->cfg;
542 pin = look_up_pincfg(codec, &codec->driver_pins, nid);
544 return pin->cfg;
545 pin = look_up_pincfg(codec, &codec->init_pins, nid);
547 return pin->cfg;
553 * snd_hda_codec_set_pin_target - remember the current pinctl target value
554 * @codec: the HDA codec
562 int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid,
567 pin = look_up_pincfg(codec, &codec->init_pins, nid);
569 return -EINVAL;
570 pin->target = val;
576 * snd_hda_codec_get_pin_target - return the current pinctl target value
577 * @codec: the HDA codec
580 int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid)
584 pin = look_up_pincfg(codec, &codec->init_pins, nid);
587 return pin->target;
592 * snd_hda_shutup_pins - Shut up all pins
593 * @codec: the HDA codec
595 * Clear all pin controls to shup up before suspend for avoiding click noise.
596 * The controls aren't cached so that they can be resumed properly.
598 void snd_hda_shutup_pins(struct hda_codec *codec)
606 if (codec->bus->shutdown)
608 snd_array_for_each(&codec->init_pins, i, pin) {
610 snd_hda_codec_read(codec, pin->nid, 0,
613 codec->pins_shutup = 1;
617 /* Restore the pin controls cleared previously via snd_hda_shutup_pins() */
618 static void restore_shutup_pins(struct hda_codec *codec)
623 if (!codec->pins_shutup)
625 if (codec->bus->shutdown)
627 snd_array_for_each(&codec->init_pins, i, pin) {
628 snd_hda_codec_write(codec, pin->nid, 0,
630 pin->ctrl);
632 codec->pins_shutup = 0;
637 struct hda_codec *codec =
640 if (!codec->jackpoll_interval)
643 /* the power-up/down sequence triggers the runtime resume */
644 CLASS(snd_hda_power, pm)(codec);
646 snd_hda_jack_set_dirty_all(codec);
647 snd_hda_jack_poll_all(codec);
648 schedule_delayed_work(&codec->jackpoll_work, codec->jackpoll_interval);
652 static void free_init_pincfgs(struct hda_codec *codec)
654 snd_array_free(&codec->driver_pins);
656 snd_array_free(&codec->user_pins);
658 snd_array_free(&codec->init_pins);
662 * audio-converter setup caches
675 get_hda_cvt_setup(struct hda_codec *codec, hda_nid_t nid)
680 snd_array_for_each(&codec->cvt_setups, i, p) {
681 if (p->nid == nid)
684 p = snd_array_new(&codec->cvt_setups);
686 p->nid = nid;
695 if (refcount_dec_and_test(&pcm->codec->pcm_ref))
696 wake_up(&pcm->codec->remove_sleep);
700 struct hda_pcm *snd_hda_codec_pcm_new(struct hda_codec *codec,
710 pcm->codec = codec;
712 pcm->name = kvasprintf(GFP_KERNEL, fmt, args);
714 if (!pcm->name) {
719 list_add_tail(&pcm->list, &codec->pcm_list_head);
720 refcount_inc(&codec->pcm_ref);
726 * codec destructor
728 void snd_hda_codec_disconnect_pcms(struct hda_codec *codec)
732 list_for_each_entry(pcm, &codec->pcm_list_head, list) {
733 if (pcm->disconnected)
735 if (pcm->pcm)
736 snd_device_disconnect(codec->card, pcm->pcm);
738 pcm->disconnected = 1;
742 static void codec_release_pcms(struct hda_codec *codec)
746 list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list) {
747 list_del(&pcm->list);
748 if (pcm->pcm)
749 snd_device_free(pcm->codec->card, pcm->pcm);
750 clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits);
751 kfree(pcm->name);
757 * snd_hda_codec_cleanup_for_unbind - Prepare codec for removal
758 * @codec: codec device to cleanup
760 void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
762 if (codec->core.registered) {
764 pm_runtime_get_noresume(hda_codec_dev(codec));
765 pm_runtime_disable(hda_codec_dev(codec));
766 codec->core.registered = 0;
769 snd_hda_codec_disconnect_pcms(codec);
770 cancel_delayed_work_sync(&codec->jackpoll_work);
771 if (!codec->in_freeing)
772 snd_hda_ctls_clear(codec);
773 codec_release_pcms(codec);
774 snd_hda_detach_beep_device(codec);
775 snd_hda_jack_tbl_clear(codec);
776 codec->proc_widget_hook = NULL;
777 codec->spec = NULL;
780 snd_array_free(&codec->driver_pins);
781 snd_array_free(&codec->cvt_setups);
782 snd_array_free(&codec->spdif_out);
783 snd_array_free(&codec->verbs);
784 codec->follower_dig_outs = NULL;
785 codec->spdif_status_reset = 0;
786 snd_array_free(&codec->mixers);
787 snd_array_free(&codec->nids);
788 remove_conn_list(codec);
789 snd_hdac_regmap_exit(&codec->core);
790 codec->configured = 0;
791 refcount_set(&codec->pcm_ref, 1); /* reset refcount */
795 static unsigned int hda_set_power_state(struct hda_codec *codec,
798 /* enable/disable display power per codec */
799 void snd_hda_codec_display_power(struct hda_codec *codec, bool enable)
801 if (codec->display_power_control)
802 snd_hdac_display_power(&codec->bus->core, codec->addr, enable);
806 * snd_hda_codec_register - Finalize codec initialization
807 * @codec: codec device to register
811 void snd_hda_codec_register(struct hda_codec *codec)
813 if (codec->core.registered)
815 if (device_is_registered(hda_codec_dev(codec))) {
816 snd_hda_codec_display_power(codec, true);
817 pm_runtime_enable(hda_codec_dev(codec));
819 snd_hda_power_down(codec);
820 codec->core.registered = 1;
827 snd_hda_codec_register(device->device_data);
832 * snd_hda_codec_unregister - Unregister specified codec device
833 * @codec: codec device to unregister
835 void snd_hda_codec_unregister(struct hda_codec *codec)
837 codec->in_freeing = 1;
843 if (codec->core.type == HDA_DEV_LEGACY)
844 snd_hdac_device_unregister(&codec->core);
845 snd_hda_codec_display_power(codec, false);
848 * In the case of ASoC HD-audio bus, the device refcount is released in
851 if (codec->core.type == HDA_DEV_LEGACY)
852 put_device(hda_codec_dev(codec));
858 snd_hda_codec_unregister(device->device_data);
864 struct hda_codec *codec = dev_to_hda_codec(dev);
866 free_init_pincfgs(codec);
867 snd_hdac_device_exit(&codec->core);
868 snd_hda_sysfs_clear(codec);
869 kfree(codec->modelname);
870 kfree(codec->wcaps);
871 kfree(codec);
877 * snd_hda_codec_device_init - allocate HDA codec device
878 * @bus: codec's parent bus
879 * @codec_addr: the codec address on the parent bus
882 * Returns newly allocated codec device or ERR_PTR() on failure.
890 struct hda_codec *codec;
894 return ERR_PTR(-EINVAL);
896 return ERR_PTR(-EINVAL);
898 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
899 if (!codec)
900 return ERR_PTR(-ENOMEM);
906 err = snd_hdac_device_init(&codec->core, &bus->core, name, codec_addr);
908 kfree(codec);
912 codec->bus = bus;
913 codec->depop_delay = -1;
914 codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
915 codec->core.dev.release = snd_hda_codec_dev_release;
916 codec->core.type = HDA_DEV_LEGACY;
918 mutex_init(&codec->spdif_mutex);
919 mutex_init(&codec->control_mutex);
920 snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32);
921 snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32);
922 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16);
923 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
924 snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8);
925 snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16);
926 snd_array_init(&codec->jacktbl, sizeof(struct hda_jack_tbl), 16);
927 snd_array_init(&codec->verbs, sizeof(struct hda_verb *), 8);
928 INIT_LIST_HEAD(&codec->conn_list);
929 INIT_LIST_HEAD(&codec->pcm_list_head);
930 INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work);
931 refcount_set(&codec->pcm_ref, 1);
932 init_waitqueue_head(&codec->remove_sleep);
934 return codec;
939 * snd_hda_codec_new - create a HDA codec
941 * @card: card for this codec
942 * @codec_addr: the codec address
943 * @codecp: the pointer to store the generated codec
950 struct hda_codec *codec;
953 codec = snd_hda_codec_device_init(bus, codec_addr, "hdaudioC%dD%d",
954 card->number, codec_addr);
955 if (IS_ERR(codec))
956 return PTR_ERR(codec);
957 *codecp = codec;
968 unsigned int codec_addr, struct hda_codec *codec,
979 dev_dbg(card->dev, "%s: entry\n", __func__);
982 return -EINVAL;
984 return -EINVAL;
986 codec->core.exec_verb = codec_exec_verb;
987 codec->card = card;
988 codec->addr = codec_addr;
990 codec->power_jiffies = jiffies;
992 snd_hda_sysfs_init(codec);
994 if (codec->bus->modelname) {
995 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
996 if (!codec->modelname)
997 return -ENOMEM;
1000 fg = codec->core.afg ? codec->core.afg : codec->core.mfg;
1001 err = read_widget_caps(codec, fg);
1004 err = read_pin_defaults(codec);
1008 /* power-up all before initialization */
1009 hda_set_power_state(codec, AC_PWRST_D0);
1010 codec->core.dev.power.power_state = PMSG_ON;
1012 snd_hda_codec_proc_new(codec);
1014 snd_hda_create_hwdep(codec);
1016 sprintf(component, "HDA:%08x,%08x,%08x", codec->core.vendor_id,
1017 codec->core.subsystem_id, codec->core.revision_id);
1022 err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);
1028 /* PM runtime needs to be enabled later after binding codec */
1029 if (codec->core.dev.power.runtime_auto)
1030 pm_runtime_forbid(&codec->core.dev);
1033 pm_runtime_get_noresume(&codec->core.dev);
1041 * snd_hda_codec_update_widgets - Refresh widget caps and pin defaults
1042 * @codec: the HDA codec
1045 * the given codec.
1047 int snd_hda_codec_update_widgets(struct hda_codec *codec)
1052 err = snd_hdac_refresh_widgets(&codec->core);
1059 kfree(codec->wcaps);
1060 fg = codec->core.afg ? codec->core.afg : codec->core.mfg;
1061 err = read_widget_caps(codec, fg);
1065 snd_array_free(&codec->init_pins);
1066 err = read_pin_defaults(codec);
1072 /* update the stream-id if changed */
1073 static void update_pcm_stream_id(struct hda_codec *codec,
1079 if (p->stream_tag != stream_tag || p->channel_id != channel_id) {
1080 oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
1083 snd_hda_codec_write(codec, nid, 0,
1086 p->stream_tag = stream_tag;
1087 p->channel_id = channel_id;
1091 /* update the format-id if changed */
1092 static void update_pcm_format(struct hda_codec *codec, struct hda_cvt_setup *p,
1097 if (p->format_id != format) {
1098 oldval = snd_hda_codec_read(codec, nid, 0,
1102 snd_hda_codec_write(codec, nid, 0,
1106 p->format_id = format;
1111 * snd_hda_codec_setup_stream - set up the codec for streaming
1112 * @codec: the CODEC to set up
1118 void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
1122 struct hda_codec_driver *driver = hda_codec_to_driver(codec);
1131 codec_dbg(codec,
1134 p = get_hda_cvt_setup(codec, nid);
1138 if (driver->ops->stream_pm)
1139 driver->ops->stream_pm(codec, nid, true);
1140 if (codec->pcm_format_first)
1141 update_pcm_format(codec, p, nid, format);
1142 update_pcm_stream_id(codec, p, nid, stream_tag, channel_id);
1143 if (!codec->pcm_format_first)
1144 update_pcm_format(codec, p, nid, format);
1146 p->active = 1;
1147 p->dirty = 0;
1149 /* make other inactive cvts with the same stream-tag dirty */
1150 type = get_wcaps_type(get_wcaps(codec, nid));
1151 list_for_each_codec(c, codec->bus) {
1152 snd_array_for_each(&c->cvt_setups, i, p) {
1153 if (!p->active && p->stream_tag == stream_tag &&
1154 get_wcaps_type(get_wcaps(c, p->nid)) == type)
1155 p->dirty = 1;
1161 static void really_cleanup_stream(struct hda_codec *codec,
1165 * __snd_hda_codec_cleanup_stream - clean up the codec for closing
1166 * @codec: the CODEC to clean up
1170 void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,
1178 if (codec->no_sticky_stream)
1181 codec_dbg(codec, "hda_codec_cleanup_stream: NID=0x%x\n", nid);
1182 p = get_hda_cvt_setup(codec, nid);
1185 * actual clean-ups will be done later in
1189 really_cleanup_stream(codec, p);
1191 p->active = 0;
1196 static void really_cleanup_stream(struct hda_codec *codec,
1199 struct hda_codec_driver *driver = hda_codec_to_driver(codec);
1200 hda_nid_t nid = q->nid;
1202 if (q->stream_tag || q->channel_id)
1203 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
1204 if (q->format_id)
1205 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0
1208 q->nid = nid;
1209 if (driver->ops->stream_pm)
1210 driver->ops->stream_pm(codec, nid, false);
1214 static void purify_inactive_streams(struct hda_codec *codec)
1220 list_for_each_codec(c, codec->bus) {
1221 snd_array_for_each(&c->cvt_setups, i, p) {
1222 if (p->dirty)
1229 static void hda_cleanup_all_streams(struct hda_codec *codec)
1234 snd_array_for_each(&codec->cvt_setups, i, p) {
1235 if (p->stream_tag)
1236 really_cleanup_stream(codec, p);
1245 * query_amp_caps - query AMP capabilities
1246 * @codec: the HD-auio codec
1256 u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
1258 if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD))
1259 nid = codec->core.afg;
1260 return snd_hda_param_read(codec, nid,
1267 * snd_hda_check_amp_caps - query AMP capabilities
1268 * @codec: the HD-audio codec
1275 bool snd_hda_check_amp_caps(struct hda_codec *codec, hda_nid_t nid,
1280 if (get_wcaps(codec, nid) & (1 << (dir + 1)))
1281 if (query_amp_caps(codec, nid, dir) & bits)
1288 * snd_hda_override_amp_caps - Override the AMP capabilities
1289 * @codec: the CODEC to clean up
1300 int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
1305 snd_hda_override_wcaps(codec, nid,
1306 get_wcaps(codec, nid) | AC_WCAP_AMP_OVRD);
1308 return snd_hdac_override_parm(&codec->core, nid, parm, caps);
1312 static unsigned int encode_amp(struct hda_codec *codec, hda_nid_t nid,
1318 if ((query_amp_caps(codec, nid, dir) &
1325 * snd_hda_codec_amp_update - update the AMP mono value
1326 * @codec: HD-audio codec
1336 int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid,
1339 unsigned int cmd = encode_amp(codec, nid, ch, dir, idx);
1341 return snd_hdac_regmap_update_raw(&codec->core, cmd, mask, val);
1346 * snd_hda_codec_amp_stereo - update the AMP stereo values
1347 * @codec: HD-audio codec
1357 int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
1365 ret |= snd_hda_codec_amp_update(codec, nid, ch, direction,
1372 * snd_hda_codec_amp_init - initialize the AMP value
1373 * @codec: the HDA codec
1385 int snd_hda_codec_amp_init(struct hda_codec *codec, hda_nid_t nid, int ch,
1388 unsigned int cmd = encode_amp(codec, nid, ch, dir, idx);
1390 if (!codec->core.regmap)
1391 return -EINVAL;
1392 return snd_hdac_regmap_update_raw_once(&codec->core, cmd, mask, val);
1397 * snd_hda_codec_amp_init_stereo - initialize the stereo AMP value
1398 * @codec: the HDA codec
1407 int snd_hda_codec_amp_init_stereo(struct hda_codec *codec, hda_nid_t nid,
1415 ret |= snd_hda_codec_amp_init(codec, nid, ch, dir,
1421 static u32 get_amp_max_value(struct hda_codec *codec, hda_nid_t nid, int dir,
1424 u32 caps = query_amp_caps(codec, nid, dir);
1428 caps -= ofs;
1433 * snd_hda_mixer_amp_volume_info - Info callback for a standard AMP mixer
1443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1449 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1450 uinfo->count = chs == 3 ? 2 : 1;
1451 uinfo->value.integer.min = 0;
1452 uinfo->value.integer.max = get_amp_max_value(codec, nid, dir, ofs);
1453 if (!uinfo->value.integer.max) {
1454 codec_warn(codec,
1456 nid, kcontrol->id.name);
1457 return -EINVAL;
1465 read_amp_value(struct hda_codec *codec, hda_nid_t nid,
1469 val = snd_hda_codec_amp_read(codec, nid, ch, dir, idx);
1472 val -= ofs;
1479 update_amp_value(struct hda_codec *codec, hda_nid_t nid,
1488 maxval = get_amp_max_value(codec, nid, dir, 0);
1490 return -EINVAL;
1491 return snd_hda_codec_amp_update(codec, nid, ch, dir, idx,
1496 * snd_hda_mixer_amp_volume_get - Get callback for a standard AMP mixer volume
1506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1512 long *valp = ucontrol->value.integer.value;
1515 *valp++ = read_amp_value(codec, nid, 0, dir, idx, ofs);
1517 *valp = read_amp_value(codec, nid, 1, dir, idx, ofs);
1523 * snd_hda_mixer_amp_volume_put - Put callback for a standard AMP mixer volume
1533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1539 long *valp = ucontrol->value.integer.value;
1544 err = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp);
1551 err = update_amp_value(codec, nid, 1, dir, idx, ofs, *valp);
1563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1570 caps = query_amp_caps(codec, nid, dir);
1573 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
1585 * snd_hda_mixer_amp_tlv - TLV callback for a standard AMP mixer volume
1600 return -ENOMEM;
1603 return -EFAULT;
1609 * snd_hda_set_vmaster_tlv - Set TLV for a virtual master control
1610 * @codec: HD-audio codec
1619 void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
1625 caps = query_amp_caps(codec, nid, dir);
1631 tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = -nums * step;
1638 find_mixer_ctl(struct hda_codec *codec, const char *name, int dev, int idx)
1648 return snd_ctl_find_id(codec->card, &id);
1652 * snd_hda_find_mixer_ctl - Find a mixer control element with the given name
1653 * @codec: HD-audio codec
1658 struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
1661 return find_mixer_ctl(codec, name, 0, 0);
1665 static int find_empty_mixer_ctl_idx(struct hda_codec *codec, const char *name,
1671 if (!find_mixer_ctl(codec, name, 0, idx))
1674 return -EBUSY;
1678 * snd_hda_ctl_add - Add a control element and assign to the codec
1679 * @codec: HD-audio codec
1683 * Add the given control element to an array inside the codec instance.
1684 * All control elements belonging to a codec are supposed to be added
1685 * by this function so that a proper clean-up works at the free or
1688 * If non-zero @nid is passed, the NID is assigned to the control element.
1689 * The assignment is shown in the codec proc file.
1694 * specifies if kctl->private_value is a HDA amplifier value.
1696 int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid,
1703 if (kctl->id.subdevice & HDA_SUBDEV_AMP_FLAG) {
1706 nid = get_amp_nid_(kctl->private_value);
1708 if ((kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) != 0 && nid == 0)
1709 nid = kctl->id.subdevice & 0xffff;
1710 if (kctl->id.subdevice & (HDA_SUBDEV_NID_FLAG|HDA_SUBDEV_AMP_FLAG))
1711 kctl->id.subdevice = 0;
1712 err = snd_ctl_add(codec->card, kctl);
1715 item = snd_array_new(&codec->mixers);
1717 return -ENOMEM;
1718 item->kctl = kctl;
1719 item->nid = nid;
1720 item->flags = flags;
1726 * snd_hda_ctls_clear - Clear all controls assigned to the given codec
1727 * @codec: HD-audio codec
1729 void snd_hda_ctls_clear(struct hda_codec *codec)
1732 struct hda_nid_item *items = codec->mixers.list;
1734 for (i = 0; i < codec->mixers.used; i++)
1735 snd_ctl_remove(codec->card, items[i].kctl);
1736 snd_array_free(&codec->mixers);
1737 snd_array_free(&codec->nids);
1741 * snd_hda_lock_devices - pseudo device locking
1744 * toggle card->shutdown to allow/disallow the device access (as a hack)
1748 struct snd_card *card = bus->card;
1749 struct hda_codec *codec;
1751 guard(spinlock)(&card->files_lock);
1752 if (card->shutdown)
1753 return -EINVAL;
1754 card->shutdown = 1;
1755 if (!list_empty(&card->ctl_files))
1758 list_for_each_codec(codec, bus) {
1760 list_for_each_entry(cpcm, &codec->pcm_list_head, list) {
1761 if (!cpcm->pcm)
1763 if (cpcm->pcm->streams[0].substream_opened ||
1764 cpcm->pcm->streams[1].substream_opened)
1771 card->shutdown = 0;
1772 return -EINVAL;
1777 * snd_hda_unlock_devices - pseudo device unlocking
1782 struct snd_card *card = bus->card;
1784 guard(spinlock)(&card->files_lock);
1785 card->shutdown = 0;
1790 * snd_hda_codec_reset - Clear all objects assigned to the codec
1791 * @codec: HD-audio codec
1793 * This frees the all PCM and control elements assigned to the codec, and
1796 * When a device is being used, it returns -EBSY. If successfully freed,
1799 int snd_hda_codec_reset(struct hda_codec *codec)
1801 struct hda_bus *bus = codec->bus;
1804 return -EBUSY;
1807 device_release_driver(hda_codec_dev(codec));
1817 static int map_followers(struct hda_codec *codec, const char * const *followers,
1824 items = codec->mixers.list;
1825 for (i = 0; i < codec->mixers.used; i++) {
1827 if (!sctl || sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER)
1830 char tmpname[sizeof(sctl->id.name)];
1837 if (!strcmp(sctl->id.name, name)) {
1838 err = func(codec, data, sctl);
1848 static int check_follower_present(struct hda_codec *codec,
1854 /* call kctl->put with the given value(s) */
1861 return -ENOMEM;
1862 ucontrol->value.integer.value[0] = val;
1863 ucontrol->value.integer.value[1] = val;
1864 kctl->put(kctl, ucontrol);
1869 struct hda_codec *codec;
1884 if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
1885 if (kctl->tlv.c != snd_hda_mixer_amp_tlv) {
1886 codec_err(arg->codec,
1888 kctl->id.name, kctl->id.index);
1893 } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)
1894 tlv = kctl->tlv.p;
1903 if (arg->step && arg->step != step) {
1904 codec_err(arg->codec,
1906 arg->step, step);
1910 arg->step = step;
1911 val = -tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] / step;
1928 static int add_follower(struct hda_codec *codec,
1935 * __snd_hda_add_vmaster - create a virtual master control and add followers
1936 * @codec: HD-audio codec
1948 * @followers is a NULL-terminated array of strings, each of which is a
1949 * follower control name. All controls with these names are assigned to
1954 int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1965 err = map_followers(codec, followers, suffix, check_follower_present, NULL);
1967 codec_dbg(codec, "No follower found for %s\n", name);
1972 return -ENOMEM;
1973 kctl->vd[0].access |= access;
1974 err = snd_hda_ctl_add(codec, 0, kctl);
1978 err = map_followers(codec, followers, suffix, add_follower, kctl);
1986 .codec = codec,
2005 hook->hook(hook->codec, enabled);
2009 * snd_hda_add_vmaster_hook - Add a vmaster hw specific hook
2010 * @codec: the HDA codec
2015 int snd_hda_add_vmaster_hook(struct hda_codec *codec,
2018 if (!hook->hook || !hook->sw_kctl)
2020 hook->codec = codec;
2021 snd_ctl_add_vmaster_hook(hook->sw_kctl, vmaster_hook, hook);
2027 * snd_hda_sync_vmaster_hook - Sync vmaster hook
2035 if (!hook->hook || !hook->codec)
2040 if (hook->codec->bus->shutdown)
2042 snd_ctl_sync_vmaster_hook(hook->sw_kctl);
2048 * snd_hda_mixer_amp_switch_info - Info callback for a standard AMP mixer switch
2060 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
2061 uinfo->count = chs == 3 ? 2 : 1;
2062 uinfo->value.integer.min = 0;
2063 uinfo->value.integer.max = 1;
2069 * snd_hda_mixer_amp_switch_get - Get callback for a standard AMP mixer switch
2079 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2084 long *valp = ucontrol->value.integer.value;
2087 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) &
2090 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) &
2097 * snd_hda_mixer_amp_switch_put - Put callback for a standard AMP mixer switch
2107 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2112 long *valp = ucontrol->value.integer.value;
2117 return -EINVAL;
2118 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
2125 return -EINVAL;
2126 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
2130 hda_call_check_power_status(codec, nid);
2136 * SPDIF out controls
2142 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
2143 uinfo->count = 1;
2150 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
2154 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY |
2162 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
2171 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2172 int idx = kcontrol->private_value;
2175 if (WARN_ON(codec->spdif_out.used <= idx))
2176 return -EINVAL;
2177 guard(mutex)(&codec->spdif_mutex);
2178 spdif = snd_array_elem(&codec->spdif_out, idx);
2179 ucontrol->value.iec958.status[0] = spdif->status & 0xff;
2180 ucontrol->value.iec958.status[1] = (spdif->status >> 8) & 0xff;
2181 ucontrol->value.iec958.status[2] = (spdif->status >> 16) & 0xff;
2182 ucontrol->value.iec958.status[3] = (spdif->status >> 24) & 0xff;
2241 static void set_dig_out(struct hda_codec *codec, hda_nid_t nid,
2246 snd_hdac_regmap_update(&codec->core, nid, AC_VERB_SET_DIGI_CONVERT_1,
2248 d = codec->follower_dig_outs;
2252 snd_hdac_regmap_update(&codec->core, *d,
2256 static inline void set_dig_out_convert(struct hda_codec *codec, hda_nid_t nid,
2262 if (dig1 != -1) {
2266 if (dig2 != -1) {
2270 set_dig_out(codec, nid, mask, val);
2276 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2277 int idx = kcontrol->private_value;
2283 if (WARN_ON(codec->spdif_out.used <= idx))
2284 return -EINVAL;
2285 guard(mutex)(&codec->spdif_mutex);
2286 spdif = snd_array_elem(&codec->spdif_out, idx);
2287 nid = spdif->nid;
2288 spdif->status = ucontrol->value.iec958.status[0] |
2289 ((unsigned int)ucontrol->value.iec958.status[1] << 8) |
2290 ((unsigned int)ucontrol->value.iec958.status[2] << 16) |
2291 ((unsigned int)ucontrol->value.iec958.status[3] << 24);
2292 val = convert_from_spdif_status(spdif->status);
2293 val |= spdif->ctls & 1;
2294 change = spdif->ctls != val;
2295 spdif->ctls = val;
2296 if (change && nid != (u16)-1)
2297 set_dig_out_convert(codec, nid, val & 0xff, (val >> 8) & 0xff);
2306 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2307 int idx = kcontrol->private_value;
2310 if (WARN_ON(codec->spdif_out.used <= idx))
2311 return -EINVAL;
2312 guard(mutex)(&codec->spdif_mutex);
2313 spdif = snd_array_elem(&codec->spdif_out, idx);
2314 ucontrol->value.integer.value[0] = spdif->ctls & AC_DIG1_ENABLE;
2318 static inline void set_spdif_ctls(struct hda_codec *codec, hda_nid_t nid,
2321 set_dig_out_convert(codec, nid, dig1, dig2);
2323 if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
2325 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2333 int idx = kcontrol->private_value;
2339 if (WARN_ON(codec->spdif_out.used <= idx))
2340 return -EINVAL;
2341 guard(mutex)(&codec->spdif_mutex);
2342 spdif = snd_array_elem(&codec->spdif_out, idx);
2343 nid = spdif->nid;
2344 val = spdif->ctls & ~AC_DIG1_ENABLE;
2345 if (ucontrol->value.integer.value[0])
2347 change = spdif->ctls != val;
2348 spdif->ctls = val;
2349 if (change && nid != (u16)-1)
2350 set_spdif_ctls(codec, nid, val & 0xff, -1);
2387 * snd_hda_create_dig_out_ctls - create Output SPDIF-related controls
2388 * @codec: the HDA codec
2392 * Creates controls related with the digital output.
2393 * Called from each codec driver supporting the digital out.
2397 int snd_hda_create_dig_out_ctls(struct hda_codec *codec,
2409 struct hda_bus *bus = codec->bus;
2411 if (bus->primary_dig_out_type == HDA_PCM_TYPE_HDMI &&
2414 } else if (bus->primary_dig_out_type == HDA_PCM_TYPE_SPDIF &&
2417 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
2420 kctl = find_mixer_ctl(codec, dig_mix->name, 0, 0);
2423 id = kctl->id;
2425 err = snd_ctl_rename_id(codec->card, &kctl->id, &id);
2429 bus->primary_dig_out_type = HDA_PCM_TYPE_HDMI;
2431 if (!bus->primary_dig_out_type)
2432 bus->primary_dig_out_type = type;
2434 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch", idx);
2436 codec_err(codec, "too many IEC958 outputs\n");
2437 return -EBUSY;
2439 spdif = snd_array_new(&codec->spdif_out);
2441 return -ENOMEM;
2442 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
2443 kctl = snd_ctl_new1(dig_mix, codec);
2445 return -ENOMEM;
2446 kctl->id.index = idx;
2447 kctl->private_value = codec->spdif_out.used - 1;
2448 err = snd_hda_ctl_add(codec, associated_nid, kctl);
2452 spdif->nid = cvt_nid;
2453 snd_hdac_regmap_read(&codec->core, cvt_nid,
2455 spdif->ctls = val;
2456 spdif->status = convert_to_spdif_status(spdif->ctls);
2462 * snd_hda_spdif_out_of_nid - get the hda_spdif_out entry from the given NID
2463 * @codec: the HDA codec
2468 struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec,
2474 snd_array_for_each(&codec->spdif_out, i, spdif) {
2475 if (spdif->nid == nid)
2483 * snd_hda_spdif_ctls_unassign - Unassign the given SPDIF ctl
2484 * @codec: the HDA codec
2489 void snd_hda_spdif_ctls_unassign(struct hda_codec *codec, int idx)
2493 if (WARN_ON(codec->spdif_out.used <= idx))
2495 guard(mutex)(&codec->spdif_mutex);
2496 spdif = snd_array_elem(&codec->spdif_out, idx);
2497 spdif->nid = (u16)-1;
2502 * snd_hda_spdif_ctls_assign - Assign the SPDIF controls to the given NID
2503 * @codec: the HDA codec
2509 void snd_hda_spdif_ctls_assign(struct hda_codec *codec, int idx, hda_nid_t nid)
2514 if (WARN_ON(codec->spdif_out.used <= idx))
2516 guard(mutex)(&codec->spdif_mutex);
2517 spdif = snd_array_elem(&codec->spdif_out, idx);
2518 if (spdif->nid != nid) {
2519 spdif->nid = nid;
2520 val = spdif->ctls;
2521 set_spdif_ctls(codec, nid, val & 0xff, (val >> 8) & 0xff);
2527 * SPDIF sharing with analog output
2533 ucontrol->value.integer.value[0] = mout->share_spdif;
2541 mout->share_spdif = !!ucontrol->value.integer.value[0];
2554 * snd_hda_create_spdif_share_sw - create Default PCM switch
2555 * @codec: the HDA codec
2556 * @mout: multi-out instance
2558 int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
2563 if (!mout->dig_out_nid)
2568 return -ENOMEM;
2569 /* ATTENTION: here mout is passed as private_data, instead of codec */
2570 return snd_hda_ctl_add(codec, mout->dig_out_nid, kctl);
2583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2585 ucontrol->value.integer.value[0] = codec->spdif_in_enable;
2592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2593 hda_nid_t nid = kcontrol->private_value;
2594 unsigned int val = !!ucontrol->value.integer.value[0];
2597 guard(mutex)(&codec->spdif_mutex);
2598 change = codec->spdif_in_enable != val;
2600 codec->spdif_in_enable = val;
2601 snd_hdac_regmap_write(&codec->core, nid,
2610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2611 hda_nid_t nid = kcontrol->private_value;
2615 snd_hdac_regmap_read(&codec->core, nid,
2618 ucontrol->value.iec958.status[0] = sbits;
2619 ucontrol->value.iec958.status[1] = sbits >> 8;
2620 ucontrol->value.iec958.status[2] = sbits >> 16;
2621 ucontrol->value.iec958.status[3] = sbits >> 24;
2644 * snd_hda_create_spdif_in_ctls - create Input SPDIF-related controls
2645 * @codec: the HDA codec
2648 * Creates controls related with the SPDIF input.
2649 * Called from each codec driver supporting the SPDIF in.
2653 int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
2660 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Capture Switch", 0);
2662 codec_err(codec, "too many IEC958 inputs\n");
2663 return -EBUSY;
2665 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
2666 kctl = snd_ctl_new1(dig_mix, codec);
2668 return -ENOMEM;
2669 kctl->private_value = nid;
2670 err = snd_hda_ctl_add(codec, nid, kctl);
2674 codec->spdif_in_enable =
2675 snd_hda_codec_read(codec, nid, 0,
2683 * snd_hda_codec_set_power_to_all - Set the power state to all widgets
2684 * @codec: the HDA codec
2689 * If the codec has power_filter set, it evaluates the power state and
2692 void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg,
2697 for_each_hda_codec_node(nid, codec) {
2698 unsigned int wcaps = get_wcaps(codec, nid);
2702 if (codec->power_filter) {
2703 state = codec->power_filter(codec, nid, power_state);
2707 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE,
2714 * snd_hda_codec_eapd_power_filter - A power filter callback for EAPD
2715 * @codec: the HDA codec
2719 * Don't power down the widget if it controls eapd and EAPD_BTLENABLE is set.
2720 * This can be used a codec power_filter callback.
2722 unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec,
2726 if (nid == codec->core.afg || nid == codec->core.mfg)
2729 get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN &&
2730 (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) {
2731 int eapd = snd_hda_codec_read(codec, nid, 0,
2741 * set power state of the codec, and return the power state
2743 static unsigned int hda_set_power_state(struct hda_codec *codec,
2746 struct hda_codec_driver *driver = hda_codec_to_driver(codec);
2747 hda_nid_t fg = codec->core.afg ? codec->core.afg : codec->core.mfg;
2752 /* this delay seems necessary to avoid click noise at power-down */
2754 if (codec->depop_delay < 0)
2755 msleep(codec_has_epss(codec) ? 10 : 100);
2756 else if (codec->depop_delay > 0)
2757 msleep(codec->depop_delay);
2764 if (driver && driver->ops && driver->ops->set_power_state)
2765 driver->ops->set_power_state(codec, fg, power_state);
2768 if (codec->power_filter)
2769 state = codec->power_filter(codec, fg, state);
2771 snd_hda_codec_read(codec, fg, flags,
2774 snd_hda_codec_set_power_to_all(codec, fg, power_state);
2776 state = snd_hda_sync_power_state(codec, fg, power_state);
2785 * this is called at the end of codec parsing
2787 static void sync_power_up_states(struct hda_codec *codec)
2792 if (!codec->power_filter)
2795 for_each_hda_codec_node(nid, codec) {
2796 unsigned int wcaps = get_wcaps(codec, nid);
2800 target = codec->power_filter(codec, nid, AC_PWRST_D0);
2803 if (!snd_hda_check_power_state(codec, nid, target))
2804 snd_hda_codec_write(codec, nid, 0,
2811 static void hda_exec_init_verbs(struct hda_codec *codec)
2813 if (codec->init_verbs.list)
2814 snd_hda_sequence_write(codec, codec->init_verbs.list);
2817 static inline void hda_exec_init_verbs(struct hda_codec *codec) {}
2821 static void update_power_acct(struct hda_codec *codec, bool on)
2823 unsigned long delta = jiffies - codec->power_jiffies;
2826 codec->power_on_acct += delta;
2828 codec->power_off_acct += delta;
2829 codec->power_jiffies += delta;
2832 void snd_hda_update_power_acct(struct hda_codec *codec)
2834 update_power_acct(codec, hda_codec_is_power_on(codec));
2838 * call suspend and power-down; used both from PM and power-save
2841 static unsigned int hda_call_codec_suspend(struct hda_codec *codec)
2843 struct hda_codec_driver *driver = hda_codec_to_driver(codec);
2846 snd_hdac_enter_pm(&codec->core);
2847 if (driver->ops->suspend)
2848 driver->ops->suspend(codec);
2849 if (!codec->no_stream_clean_at_suspend)
2850 hda_cleanup_all_streams(codec);
2851 state = hda_set_power_state(codec, AC_PWRST_D3);
2852 update_power_acct(codec, true);
2853 snd_hdac_leave_pm(&codec->core);
2858 * kick up codec; used both from PM and power-save
2860 static void hda_call_codec_resume(struct hda_codec *codec)
2862 struct hda_codec_driver *driver = hda_codec_to_driver(codec);
2864 snd_hdac_enter_pm(&codec->core);
2865 if (codec->core.regmap)
2866 regcache_mark_dirty(codec->core.regmap);
2868 codec->power_jiffies = jiffies;
2870 hda_set_power_state(codec, AC_PWRST_D0);
2871 restore_shutup_pins(codec);
2872 hda_exec_init_verbs(codec);
2873 snd_hda_jack_set_dirty_all(codec);
2874 if (driver->ops->resume)
2875 driver->ops->resume(codec);
2877 snd_hda_codec_init(codec);
2878 snd_hda_regmap_sync(codec);
2881 snd_hda_jack_report_sync(codec);
2882 codec->core.dev.power.power_state = PMSG_ON;
2883 snd_hdac_leave_pm(&codec->core);
2884 if (codec->jackpoll_interval)
2885 schedule_delayed_work(&codec->jackpoll_work,
2886 codec->jackpoll_interval);
2891 struct hda_codec *codec = dev_to_hda_codec(dev);
2895 if (!codec->card)
2898 state = hda_call_codec_suspend(codec);
2899 if (codec->link_down_at_suspend ||
2900 (codec_has_clkstop(codec) && codec_has_epss(codec) &&
2902 snd_hdac_codec_link_down(&codec->core);
2903 snd_hda_codec_display_power(codec, false);
2910 struct hda_codec *codec = dev_to_hda_codec(dev);
2913 if (!codec->card)
2916 snd_hda_codec_display_power(codec, true);
2917 snd_hdac_codec_link_up(&codec->core);
2918 hda_call_codec_resume(codec);
2925 struct hda_codec *codec = dev_to_hda_codec(dev);
2927 if (codec->jackpoll_interval && !codec->bus->jackpoll_in_suspend)
2928 return -EBUSY;
2934 struct hda_codec *codec = dev_to_hda_codec(dev);
2936 cancel_delayed_work_sync(&codec->jackpoll_work);
2937 dev->power.power_state = PMSG_SUSPEND;
2943 struct hda_codec *codec = dev_to_hda_codec(dev);
2945 /* If no other pm-functions are called between prepare() and complete() */
2946 if (dev->power.power_state.event == PM_EVENT_SUSPEND)
2947 dev->power.power_state = PMSG_RESUME;
2949 if (pm_runtime_suspended(dev) && (codec->jackpoll_interval ||
2950 hda_codec_need_resume(codec) || codec->forced_resume))
2956 dev->power.power_state = PMSG_SUSPEND;
2962 dev->power.power_state = PMSG_RESUME;
2968 struct hda_codec *codec = dev_to_hda_codec(dev);
2970 cancel_delayed_work_sync(&codec->jackpoll_work);
2971 dev->power.power_state = PMSG_FREEZE;
2977 dev->power.power_state = PMSG_THAW;
2983 dev->power.power_state = PMSG_RESTORE;
3001 /* suspend the codec at shutdown; called from driver's shutdown callback */
3002 void snd_hda_codec_shutdown(struct hda_codec *codec)
3006 /* Skip the shutdown if codec is not registered */
3007 if (!codec->core.registered)
3010 codec->jackpoll_interval = 0; /* don't poll any longer */
3011 cancel_delayed_work_sync(&codec->jackpoll_work);
3012 list_for_each_entry(cpcm, &codec->pcm_list_head, list)
3013 snd_pcm_suspend_all(cpcm->pcm);
3015 pm_runtime_force_suspend(hda_codec_dev(codec));
3016 pm_runtime_disable(hda_codec_dev(codec));
3022 static int add_std_chmaps(struct hda_codec *codec)
3027 list_for_each_entry(pcm, &codec->pcm_list_head, list) {
3029 struct hda_pcm_stream *hinfo = &pcm->stream[str];
3033 if (!pcm->pcm || pcm->own_chmap || !hinfo->substreams)
3035 elem = hinfo->chmap ? hinfo->chmap : snd_pcm_std_chmaps;
3036 err = snd_pcm_add_chmap_ctls(pcm->pcm, str, elem,
3037 hinfo->channels_max,
3041 chmap->channel_mask = SND_PCM_CHMAP_MASK_2468;
3048 * since HD-audio supports only stereo, odd number channels are omitted
3060 int snd_hda_codec_build_controls(struct hda_codec *codec)
3062 struct hda_codec_driver *driver = hda_codec_to_driver(codec);
3065 hda_exec_init_verbs(codec);
3067 err = snd_hda_codec_init(codec);
3071 if (driver->ops->build_controls) {
3072 err = driver->ops->build_controls(codec);
3078 err = add_std_chmaps(codec);
3082 snd_hda_jack_report_sync(codec); /* call at the last init point */
3083 if (codec->jackpoll_interval)
3084 schedule_delayed_work(&codec->jackpoll_work,
3085 codec->jackpoll_interval);
3087 sync_power_up_states(codec);
3096 struct hda_codec *codec,
3103 struct hda_codec *codec,
3108 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format);
3113 struct hda_codec *codec,
3116 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
3120 static int set_pcm_default_values(struct hda_codec *codec,
3126 if (info->nid && (!info->rates || !info->formats)) {
3127 err = snd_hda_query_supported_pcm(codec, info->nid,
3128 info->rates ? NULL : &info->rates,
3129 info->formats ? NULL : &info->formats,
3130 info->subformats ? NULL : &info->subformats,
3131 info->maxbps ? NULL : &info->maxbps);
3135 if (info->ops.open == NULL)
3136 info->ops.open = hda_pcm_default_open_close;
3137 if (info->ops.close == NULL)
3138 info->ops.close = hda_pcm_default_open_close;
3139 if (info->ops.prepare == NULL) {
3140 if (snd_BUG_ON(!info->nid))
3141 return -EINVAL;
3142 info->ops.prepare = hda_pcm_default_prepare;
3144 if (info->ops.cleanup == NULL) {
3145 if (snd_BUG_ON(!info->nid))
3146 return -EINVAL;
3147 info->ops.cleanup = hda_pcm_default_cleanup;
3153 * codec prepare/cleanup entries
3156 * snd_hda_codec_prepare - Prepare a stream
3157 * @codec: the HDA codec
3163 * Calls the prepare callback set by the codec with the given arguments.
3166 int snd_hda_codec_prepare(struct hda_codec *codec,
3174 guard(mutex)(&codec->bus->prepare_mutex);
3175 if (hinfo->ops.prepare)
3176 ret = hinfo->ops.prepare(hinfo, codec, stream, format,
3179 ret = -ENODEV;
3181 purify_inactive_streams(codec);
3187 * snd_hda_codec_cleanup - Clean up stream resources
3188 * @codec: the HDA codec
3192 * Calls the cleanup callback set by the codec with the given arguments.
3194 void snd_hda_codec_cleanup(struct hda_codec *codec,
3198 guard(mutex)(&codec->bus->prepare_mutex);
3199 if (hinfo->ops.cleanup)
3200 hinfo->ops.cleanup(hinfo, codec, substream);
3219 [HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 },
3220 [HDA_PCM_TYPE_SPDIF] = { 1, -1 },
3221 [HDA_PCM_TYPE_HDMI] = { 3, 7, 8, 9, -1 },
3222 [HDA_PCM_TYPE_MODEM] = { 6, -1 },
3227 dev_err(bus->card->dev, "Invalid PCM type %d\n", type);
3228 return -EINVAL;
3236 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits))
3241 /* non-fixed slots starting from 10 */
3243 if (!test_and_set_bit(i, bus->pcm_dev_bits))
3248 dev_warn(bus->card->dev, "Too many %s devices\n",
3251 dev_warn(bus->card->dev,
3254 return -EAGAIN;
3257 /* call build_pcms ops of the given codec and set up the default parameters */
3258 int snd_hda_codec_parse_pcms(struct hda_codec *codec)
3260 struct hda_codec_driver *driver = hda_codec_to_driver(codec);
3264 if (!list_empty(&codec->pcm_list_head))
3267 if (!driver->ops->build_pcms)
3270 err = driver->ops->build_pcms(codec);
3272 codec_err(codec, "cannot build PCMs for #%d (error %d)\n",
3273 codec->core.addr, err);
3277 list_for_each_entry(cpcm, &codec->pcm_list_head, list) {
3281 struct hda_pcm_stream *info = &cpcm->stream[stream];
3283 if (!info->substreams)
3285 err = set_pcm_default_values(codec, info);
3287 codec_warn(codec,
3289 cpcm->name);
3299 /* assign all PCMs of the given codec */
3300 int snd_hda_codec_build_pcms(struct hda_codec *codec)
3302 struct hda_bus *bus = codec->bus;
3306 err = snd_hda_codec_parse_pcms(codec);
3311 list_for_each_entry(cpcm, &codec->pcm_list_head, list) {
3312 if (cpcm->pcm)
3314 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
3317 dev = get_empty_pcm_device(bus, cpcm->pcm_type);
3319 cpcm->device = SNDRV_PCM_INVALID_DEVICE;
3322 cpcm->device = dev;
3323 err = snd_hda_attach_pcm_stream(bus, codec, cpcm);
3325 codec_err(codec,
3326 "cannot attach PCM stream %d for codec #%d\n",
3327 dev, codec->core.addr);
3336 * snd_hda_add_new_ctls - create controls from the array
3337 * @codec: the HDA codec
3340 * This helper function creates and add new controls in the given array.
3345 int snd_hda_add_new_ctls(struct hda_codec *codec,
3350 for (; knew->name; knew++) {
3353 if (knew->iface == (__force snd_ctl_elem_iface_t)-1)
3354 continue; /* skip this codec private value */
3356 kctl = snd_ctl_new1(knew, codec);
3358 return -ENOMEM;
3364 if (addr > 0 && codec->ctl_dev_id)
3365 kctl->id.device = addr;
3367 kctl->id.index = idx;
3368 err = snd_hda_ctl_add(codec, 0, kctl);
3372 * the codec addr; if it still fails (or it's the
3373 * primary codec), then try another control index
3375 if (!addr && codec->core.addr) {
3376 addr = codec->core.addr;
3377 if (!codec->ctl_dev_id)
3379 } else if (!idx && !knew->index) {
3380 idx = find_empty_mixer_ctl_idx(codec,
3381 knew->name, 0);
3393 * snd_hda_codec_set_power_save - Configure codec's runtime PM
3394 * @codec: codec device to configure
3397 void snd_hda_codec_set_power_save(struct hda_codec *codec, int delay)
3399 struct device *dev = hda_codec_dev(codec);
3401 if (delay == 0 && codec->auto_runtime_pm)
3418 * snd_hda_set_power_save - reprogram autosuspend for the given delay
3419 * @bus: HD-audio bus
3434 * snd_hda_check_amp_list_power - Check the amp list and update the power
3435 * @codec: HD-audio codec
3440 * check the current AMP status, and update the power-status according
3446 int snd_hda_check_amp_list_power(struct hda_codec *codec,
3453 if (!check->amplist)
3455 for (p = check->amplist; p->nid; p++) {
3456 if (p->nid == nid)
3459 if (!p->nid)
3462 for (p = check->amplist; p->nid; p++) {
3464 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir,
3465 p->idx);
3467 if (!check->power_on) {
3468 check->power_on = 1;
3469 snd_hda_power_up_pm(codec);
3475 if (check->power_on) {
3476 check->power_on = 0;
3477 snd_hda_power_down_pm(codec);
3488 * snd_hda_input_mux_info - Info callback helper for the input-mux enum
3497 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3498 uinfo->count = 1;
3499 uinfo->value.enumerated.items = imux->num_items;
3500 if (!imux->num_items)
3502 index = uinfo->value.enumerated.item;
3503 if (index >= imux->num_items)
3504 index = imux->num_items - 1;
3505 strscpy(uinfo->value.enumerated.name, imux->items[index].label);
3511 * snd_hda_input_mux_put - Put callback helper for the input-mux enum
3512 * @codec: the HDA codec
3518 int snd_hda_input_mux_put(struct hda_codec *codec,
3526 if (!imux->num_items)
3528 idx = ucontrol->value.enumerated.item[0];
3529 if (idx >= imux->num_items)
3530 idx = imux->num_items - 1;
3533 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
3534 imux->items[idx].index);
3542 * snd_hda_enum_helper_info - Helper for simple enum ctls
3569 * Multi-channel / digital-out PCM helper functions
3573 static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
3580 spdif = snd_hda_spdif_out_of_nid(codec, nid);
3587 curr_fmt = snd_hda_codec_read(codec, nid, 0,
3589 reset = codec->spdif_status_reset &&
3590 (spdif->ctls & AC_DIG1_ENABLE) &&
3596 set_dig_out_convert(codec, nid,
3597 spdif->ctls & ~AC_DIG1_ENABLE & 0xff,
3598 -1);
3599 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
3600 if (codec->follower_dig_outs) {
3602 for (d = codec->follower_dig_outs; *d; d++)
3603 snd_hda_codec_setup_stream(codec, *d, stream_tag, 0,
3608 set_dig_out_convert(codec, nid,
3609 spdif->ctls & 0xff, -1);
3612 static void cleanup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid)
3614 snd_hda_codec_cleanup_stream(codec, nid);
3615 if (codec->follower_dig_outs) {
3617 for (d = codec->follower_dig_outs; *d; d++)
3618 snd_hda_codec_cleanup_stream(codec, *d);
3623 * snd_hda_multi_out_dig_open - open the digital out in the exclusive mode
3624 * @codec: the HDA codec
3627 int snd_hda_multi_out_dig_open(struct hda_codec *codec,
3630 guard(mutex)(&codec->spdif_mutex);
3631 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP)
3632 /* already opened as analog dup; reset it once */
3633 cleanup_dig_out_stream(codec, mout->dig_out_nid);
3634 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
3640 * snd_hda_multi_out_dig_prepare - prepare the digital out stream
3641 * @codec: the HDA codec
3647 int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
3653 guard(mutex)(&codec->spdif_mutex);
3654 setup_dig_out_stream(codec, mout->dig_out_nid, stream_tag, format);
3660 * snd_hda_multi_out_dig_cleanup - clean-up the digital out stream
3661 * @codec: the HDA codec
3664 int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
3667 guard(mutex)(&codec->spdif_mutex);
3668 cleanup_dig_out_stream(codec, mout->dig_out_nid);
3674 * snd_hda_multi_out_dig_close - release the digital out stream
3675 * @codec: the HDA codec
3678 int snd_hda_multi_out_dig_close(struct hda_codec *codec,
3681 guard(mutex)(&codec->spdif_mutex);
3682 mout->dig_out_used = 0;
3688 * snd_hda_multi_out_analog_open - open analog outputs
3689 * @codec: the HDA codec
3694 * Open analog outputs and set up the hw-constraints.
3698 int snd_hda_multi_out_analog_open(struct hda_codec *codec,
3703 struct snd_pcm_runtime *runtime = substream->runtime;
3704 runtime->hw.channels_max = mout->max_channels;
3705 if (mout->dig_out_nid) {
3706 if (!mout->analog_rates) {
3707 mout->analog_rates = hinfo->rates;
3708 mout->analog_formats = hinfo->formats;
3709 mout->analog_maxbps = hinfo->maxbps;
3711 runtime->hw.rates = mout->analog_rates;
3712 runtime->hw.formats = mout->analog_formats;
3713 hinfo->maxbps = mout->analog_maxbps;
3715 if (!mout->spdif_rates) {
3716 snd_hda_query_supported_pcm(codec, mout->dig_out_nid,
3717 &mout->spdif_rates,
3718 &mout->spdif_formats,
3720 &mout->spdif_maxbps);
3722 guard(mutex)(&codec->spdif_mutex);
3723 if (mout->share_spdif) {
3724 if ((runtime->hw.rates & mout->spdif_rates) &&
3725 (runtime->hw.formats & mout->spdif_formats)) {
3726 runtime->hw.rates &= mout->spdif_rates;
3727 runtime->hw.formats &= mout->spdif_formats;
3728 if (mout->spdif_maxbps < hinfo->maxbps)
3729 hinfo->maxbps = mout->spdif_maxbps;
3731 mout->share_spdif = 0;
3736 return snd_pcm_hw_constraint_step(substream->runtime, 0,
3742 * snd_hda_multi_out_analog_prepare - Preapre the analog outputs.
3743 * @codec: the HDA codec
3749 * Set up the i/o for analog out.
3752 int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
3758 const hda_nid_t *nids = mout->dac_nids;
3759 int chs = substream->runtime->channels;
3763 scoped_guard(mutex, &codec->spdif_mutex) {
3764 spdif = snd_hda_spdif_out_of_nid(codec, mout->dig_out_nid);
3765 if (mout->dig_out_nid && mout->share_spdif &&
3766 mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
3768 snd_hda_is_supported_format(codec, mout->dig_out_nid,
3770 !(spdif->status & IEC958_AES0_NONAUDIO)) {
3771 mout->dig_out_used = HDA_DIG_ANALOG_DUP;
3772 setup_dig_out_stream(codec, mout->dig_out_nid,
3775 mout->dig_out_used = 0;
3776 cleanup_dig_out_stream(codec, mout->dig_out_nid);
3782 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag,
3784 if (!mout->no_share_stream &&
3785 mout->hp_nid && mout->hp_nid != nids[HDA_FRONT])
3787 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag,
3790 for (i = 0; i < ARRAY_SIZE(mout->hp_out_nid); i++)
3791 if (!mout->no_share_stream && mout->hp_out_nid[i])
3792 snd_hda_codec_setup_stream(codec,
3793 mout->hp_out_nid[i],
3797 for (i = 1; i < mout->num_dacs; i++) {
3799 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
3801 else if (!mout->no_share_stream) /* copy front */
3802 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
3807 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) {
3809 if (!mout->extra_out_nid[i])
3813 else if (!mout->no_share_stream)
3815 snd_hda_codec_setup_stream(codec, mout->extra_out_nid[i],
3824 * snd_hda_multi_out_analog_cleanup - clean up the setting for analog out
3825 * @codec: the HDA codec
3828 int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
3831 const hda_nid_t *nids = mout->dac_nids;
3834 for (i = 0; i < mout->num_dacs; i++)
3835 snd_hda_codec_cleanup_stream(codec, nids[i]);
3836 if (mout->hp_nid)
3837 snd_hda_codec_cleanup_stream(codec, mout->hp_nid);
3838 for (i = 0; i < ARRAY_SIZE(mout->hp_out_nid); i++)
3839 if (mout->hp_out_nid[i])
3840 snd_hda_codec_cleanup_stream(codec,
3841 mout->hp_out_nid[i]);
3842 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
3843 if (mout->extra_out_nid[i])
3844 snd_hda_codec_cleanup_stream(codec,
3845 mout->extra_out_nid[i]);
3846 guard(mutex)(&codec->spdif_mutex);
3847 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) {
3848 cleanup_dig_out_stream(codec, mout->dig_out_nid);
3849 mout->dig_out_used = 0;
3856 * snd_hda_get_default_vref - Get the default (mic) VREF pin bits
3857 * @codec: the HDA codec
3860 * Guess the suitable VREF pin bits to be set as the pin-control value.
3863 unsigned int snd_hda_get_default_vref(struct hda_codec *codec, hda_nid_t pin)
3867 oldval = snd_hda_codec_read(codec, pin, 0,
3869 pincap = snd_hda_query_pin_caps(codec, pin);
3885 * snd_hda_correct_pin_ctl - correct the pin ctl value for matching with the pin cap
3886 * @codec: the HDA codec
3890 unsigned int snd_hda_correct_pin_ctl(struct hda_codec *codec,
3903 cap = snd_hda_query_pin_caps(codec, pin);
3925 if (i == ARRAY_SIZE(cap_lists) - 1)
3941 * _snd_hda_set_pin_ctl - Helper to set pin ctl value
3942 * @codec: the HDA codec
3945 * @cached: access over codec pinctl cache or direct write
3953 int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin,
3956 val = snd_hda_correct_pin_ctl(codec, pin, val);
3957 snd_hda_codec_set_pin_target(codec, pin, val);
3959 return snd_hda_codec_write_cache(codec, pin, 0,
3962 return snd_hda_codec_write(codec, pin, 0,
3968 * snd_hda_add_imux_item - Add an item to input_mux
3969 * @codec: the HDA codec
3977 * to type_idx when non-NULL pointer is given.
3979 int snd_hda_add_imux_item(struct hda_codec *codec,
3984 if (imux->num_items >= HDA_MAX_NUM_INPUTS) {
3985 codec_err(codec, "hda_codec: Too many imux items!\n");
3986 return -EINVAL;
3988 for (i = 0; i < imux->num_items; i++) {
3989 if (!strncmp(label, imux->items[i].label, strlen(label)))
3995 snprintf(imux->items[imux->num_items].label,
3996 sizeof(imux->items[imux->num_items].label),
3999 strscpy(imux->items[imux->num_items].label, label,
4000 sizeof(imux->items[imux->num_items].label));
4001 imux->items[imux->num_items].index = index;
4002 imux->num_items++;
4008 * snd_hda_bus_reset_codecs - Reset the bus
4009 * @bus: HD-audio bus
4013 struct hda_codec *codec;
4015 list_for_each_codec(codec, bus) {
4017 if (current_work() != &codec->jackpoll_work.work)
4018 cancel_delayed_work_sync(&codec->jackpoll_work);
4019 if (hda_codec_is_power_on(codec)) {
4020 hda_call_codec_suspend(codec);
4021 hda_call_codec_resume(codec);
4027 * snd_print_pcm_bits - Print the supported PCM fmt bits to the string buffer
4041 j += scnprintf(buf + j, buflen - j, " %d", bits[i]);
4047 MODULE_DESCRIPTION("HDA codec core");