Lines Matching +full:vref +full:- +full:p

1 // SPDX-License-Identifier: GPL-2.0-or-later
27 #define codec_in_pm(codec) snd_hdac_is_in_pm(&codec->core)
28 #define hda_codec_is_power_on(codec) snd_hdac_is_power_on(&codec->core)
30 ((codec)->core.power_caps & AC_PWRST_EPSS)
32 ((codec)->core.power_caps & AC_PWRST_CLKSTOP)
35 * Send and receive a verb - passed to exec_verb override for hdac_device
41 struct hda_bus *bus = codec->bus; in codec_exec_verb()
45 return -1; in codec_exec_verb()
49 mutex_lock(&bus->core.cmd_mutex); in codec_exec_verb()
51 bus->no_response_fallback = 1; in codec_exec_verb()
52 err = snd_hdac_bus_exec_verb_unlocked(&bus->core, codec->core.addr, in codec_exec_verb()
54 bus->no_response_fallback = 0; in codec_exec_verb()
55 mutex_unlock(&bus->core.cmd_mutex); in codec_exec_verb()
57 if (!codec_in_pm(codec) && res && err == -EAGAIN) { in codec_exec_verb()
58 if (bus->response_reset) { in codec_exec_verb()
65 /* clear reset-flag when the communication gets recovered */ in codec_exec_verb()
67 bus->response_reset = 0; in codec_exec_verb()
72 * snd_hda_sequence_write - sequence writes
81 for (; seq->nid; seq++) in snd_hda_sequence_write()
82 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param); in snd_hda_sequence_write()
98 struct hda_conn_list *p; in lookup_conn_list() local
99 list_for_each_entry(p, &codec->conn_list, list) { in lookup_conn_list()
100 if (p->nid == nid) in lookup_conn_list()
101 return p; in lookup_conn_list()
109 struct hda_conn_list *p; in add_conn_list() local
111 p = kmalloc(struct_size(p, conns, len), GFP_KERNEL); in add_conn_list()
112 if (!p) in add_conn_list()
113 return -ENOMEM; in add_conn_list()
114 p->len = len; in add_conn_list()
115 p->nid = nid; in add_conn_list()
116 memcpy(p->conns, list, len * sizeof(hda_nid_t)); in add_conn_list()
117 list_add(&p->list, &codec->conn_list); in add_conn_list()
123 while (!list_empty(&codec->conn_list)) { in remove_conn_list()
124 struct hda_conn_list *p; in remove_conn_list() local
125 p = list_first_entry(&codec->conn_list, typeof(*p), list); in remove_conn_list()
126 list_del(&p->list); in remove_conn_list()
127 kfree(p); in remove_conn_list()
139 if (len == -ENOSPC) { in read_and_add_raw_conns()
143 return -ENOMEM; in read_and_add_raw_conns()
154 * snd_hda_get_conn_list - get connection list
175 const struct hda_conn_list *p; in snd_hda_get_conn_list() local
177 /* if the connection-list is already cached, read it */ in snd_hda_get_conn_list()
178 p = lookup_conn_list(codec, nid); in snd_hda_get_conn_list()
179 if (p) { in snd_hda_get_conn_list()
181 *listp = p->conns; in snd_hda_get_conn_list()
182 return p->len; in snd_hda_get_conn_list()
185 return -EINVAL; in snd_hda_get_conn_list()
196 * snd_hda_get_connections - copy connection list
217 return -EINVAL; in snd_hda_get_connections()
227 * snd_hda_override_conn_list - add/modify the connection-list to cache
233 * Add or modify the given connection-list to the cache. If the corresponding
241 struct hda_conn_list *p; in snd_hda_override_conn_list() local
243 p = lookup_conn_list(codec, nid); in snd_hda_override_conn_list()
244 if (p) { in snd_hda_override_conn_list()
245 list_del(&p->list); in snd_hda_override_conn_list()
246 kfree(p); in snd_hda_override_conn_list()
254 * snd_hda_get_conn_index - get the connection index of the given NID
262 * Otherwise it returns -1.
275 return -1; in snd_hda_get_conn_index()
278 return -1; in snd_hda_get_conn_index()
288 return -1; in snd_hda_get_conn_index()
293 * snd_hda_get_num_devices - get DEVLIST_LEN parameter of the given widget
305 if (!codec->dp_mst || !(wcaps & AC_WCAP_DIGITAL) || in snd_hda_get_num_devices()
309 parm = snd_hdac_read_parm_uncached(&codec->core, nid, AC_PAR_DEVLIST_LEN); in snd_hda_get_num_devices()
310 if (parm == -1) in snd_hda_get_num_devices()
317 * snd_hda_get_devices - copy device list without cache
333 if (!parm) /* not multi-stream capable */ in snd_hda_get_devices()
341 if (snd_hdac_read(&codec->core, nid, in snd_hda_get_devices()
357 * snd_hda_get_dev_select - get device entry select on the pin
368 if (!codec->dp_mst) in snd_hda_get_dev_select()
376 * snd_hda_set_dev_select - set device entry select on the pin
388 if (!codec->dp_mst) in snd_hda_set_dev_select()
404 return -EINVAL; in snd_hda_set_dev_select()
421 codec->wcaps = kmalloc_array(codec->core.num_nodes, 4, GFP_KERNEL); in read_widget_caps()
422 if (!codec->wcaps) in read_widget_caps()
423 return -ENOMEM; in read_widget_caps()
424 nid = codec->core.start_nid; in read_widget_caps()
425 for (i = 0; i < codec->core.num_nodes; i++, nid++) in read_widget_caps()
426 codec->wcaps[i] = snd_hdac_read_parm_uncached(&codec->core, in read_widget_caps()
431 /* read all pin default configurations and save codec->init_pins */
442 pin = snd_array_new(&codec->init_pins); in read_pin_defaults()
444 return -ENOMEM; in read_pin_defaults()
445 pin->nid = nid; in read_pin_defaults()
446 pin->cfg = snd_hda_codec_read(codec, nid, 0, in read_pin_defaults()
452 pin->ctrl = snd_hda_codec_read(codec, nid, 0, in read_pin_defaults()
468 if (pin->nid == nid) in look_up_pincfg()
488 return -EINVAL; in snd_hda_add_pincfg()
495 return -ENOMEM; in snd_hda_add_pincfg()
496 pin->nid = nid; in snd_hda_add_pincfg()
498 pin->cfg = cfg; in snd_hda_add_pincfg()
503 * snd_hda_codec_set_pincfg - Override a pin default configuration
515 return snd_hda_add_pincfg(codec, &codec->driver_pins, nid, cfg); in snd_hda_codec_set_pincfg()
520 * snd_hda_codec_get_pincfg - Obtain a pin-default configuration
535 mutex_lock(&codec->user_mutex); in snd_hda_codec_get_pincfg()
536 pin = look_up_pincfg(codec, &codec->user_pins, nid); in snd_hda_codec_get_pincfg()
538 cfg = pin->cfg; in snd_hda_codec_get_pincfg()
539 mutex_unlock(&codec->user_mutex); in snd_hda_codec_get_pincfg()
544 pin = look_up_pincfg(codec, &codec->driver_pins, nid); in snd_hda_codec_get_pincfg()
546 return pin->cfg; in snd_hda_codec_get_pincfg()
547 pin = look_up_pincfg(codec, &codec->init_pins, nid); in snd_hda_codec_get_pincfg()
549 return pin->cfg; in snd_hda_codec_get_pincfg()
555 * snd_hda_codec_set_pin_target - remember the current pinctl target value
569 pin = look_up_pincfg(codec, &codec->init_pins, nid); in snd_hda_codec_set_pin_target()
571 return -EINVAL; in snd_hda_codec_set_pin_target()
572 pin->target = val; in snd_hda_codec_set_pin_target()
578 * snd_hda_codec_get_pin_target - return the current pinctl target value
586 pin = look_up_pincfg(codec, &codec->init_pins, nid); in snd_hda_codec_get_pin_target()
589 return pin->target; in snd_hda_codec_get_pin_target()
594 * snd_hda_shutup_pins - Shut up all pins
608 if (codec->bus->shutdown) in snd_hda_shutup_pins()
610 snd_array_for_each(&codec->init_pins, i, pin) { in snd_hda_shutup_pins()
612 snd_hda_codec_read(codec, pin->nid, 0, in snd_hda_shutup_pins()
615 codec->pins_shutup = 1; in snd_hda_shutup_pins()
626 if (!codec->pins_shutup) in restore_shutup_pins()
628 if (codec->bus->shutdown) in restore_shutup_pins()
630 snd_array_for_each(&codec->init_pins, i, pin) { in restore_shutup_pins()
631 snd_hda_codec_write(codec, pin->nid, 0, in restore_shutup_pins()
633 pin->ctrl); in restore_shutup_pins()
635 codec->pins_shutup = 0; in restore_shutup_pins()
644 /* for non-polling trigger: we need nothing if already powered on */ in hda_jackpoll_work()
645 if (!codec->jackpoll_interval && snd_hdac_is_power_on(&codec->core)) in hda_jackpoll_work()
648 /* the power-up/down sequence triggers the runtime resume */ in hda_jackpoll_work()
651 if (codec->jackpoll_interval) { in hda_jackpoll_work()
657 if (!codec->jackpoll_interval) in hda_jackpoll_work()
660 schedule_delayed_work(&codec->jackpoll_work, in hda_jackpoll_work()
661 codec->jackpoll_interval); in hda_jackpoll_work()
667 snd_array_free(&codec->driver_pins); in free_init_pincfgs()
669 snd_array_free(&codec->user_pins); in free_init_pincfgs()
671 snd_array_free(&codec->init_pins); in free_init_pincfgs()
675 * audio-converter setup caches
690 struct hda_cvt_setup *p; in get_hda_cvt_setup() local
693 snd_array_for_each(&codec->cvt_setups, i, p) { in get_hda_cvt_setup()
694 if (p->nid == nid) in get_hda_cvt_setup()
695 return p; in get_hda_cvt_setup()
697 p = snd_array_new(&codec->cvt_setups); in get_hda_cvt_setup()
698 if (p) in get_hda_cvt_setup()
699 p->nid = nid; in get_hda_cvt_setup()
700 return p; in get_hda_cvt_setup()
708 if (refcount_dec_and_test(&pcm->codec->pcm_ref)) in snd_hda_codec_pcm_put()
709 wake_up(&pcm->codec->remove_sleep); in snd_hda_codec_pcm_put()
723 pcm->codec = codec; in snd_hda_codec_pcm_new()
725 pcm->name = kvasprintf(GFP_KERNEL, fmt, args); in snd_hda_codec_pcm_new()
727 if (!pcm->name) { in snd_hda_codec_pcm_new()
732 list_add_tail(&pcm->list, &codec->pcm_list_head); in snd_hda_codec_pcm_new()
733 refcount_inc(&codec->pcm_ref); in snd_hda_codec_pcm_new()
745 list_for_each_entry(pcm, &codec->pcm_list_head, list) { in snd_hda_codec_disconnect_pcms()
746 if (pcm->disconnected) in snd_hda_codec_disconnect_pcms()
748 if (pcm->pcm) in snd_hda_codec_disconnect_pcms()
749 snd_device_disconnect(codec->card, pcm->pcm); in snd_hda_codec_disconnect_pcms()
751 pcm->disconnected = 1; in snd_hda_codec_disconnect_pcms()
759 list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list) { in codec_release_pcms()
760 list_del(&pcm->list); in codec_release_pcms()
761 if (pcm->pcm) in codec_release_pcms()
762 snd_device_free(pcm->codec->card, pcm->pcm); in codec_release_pcms()
763 clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits); in codec_release_pcms()
764 kfree(pcm->name); in codec_release_pcms()
770 * snd_hda_codec_cleanup_for_unbind - Prepare codec for removal
775 if (codec->core.registered) { in snd_hda_codec_cleanup_for_unbind()
779 codec->core.registered = 0; in snd_hda_codec_cleanup_for_unbind()
783 cancel_delayed_work_sync(&codec->jackpoll_work); in snd_hda_codec_cleanup_for_unbind()
784 if (!codec->in_freeing) in snd_hda_codec_cleanup_for_unbind()
788 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops)); in snd_hda_codec_cleanup_for_unbind()
790 codec->proc_widget_hook = NULL; in snd_hda_codec_cleanup_for_unbind()
791 codec->spec = NULL; in snd_hda_codec_cleanup_for_unbind()
794 snd_array_free(&codec->driver_pins); in snd_hda_codec_cleanup_for_unbind()
795 snd_array_free(&codec->cvt_setups); in snd_hda_codec_cleanup_for_unbind()
796 snd_array_free(&codec->spdif_out); in snd_hda_codec_cleanup_for_unbind()
797 snd_array_free(&codec->verbs); in snd_hda_codec_cleanup_for_unbind()
798 codec->preset = NULL; in snd_hda_codec_cleanup_for_unbind()
799 codec->follower_dig_outs = NULL; in snd_hda_codec_cleanup_for_unbind()
800 codec->spdif_status_reset = 0; in snd_hda_codec_cleanup_for_unbind()
801 snd_array_free(&codec->mixers); in snd_hda_codec_cleanup_for_unbind()
802 snd_array_free(&codec->nids); in snd_hda_codec_cleanup_for_unbind()
804 snd_hdac_regmap_exit(&codec->core); in snd_hda_codec_cleanup_for_unbind()
805 codec->configured = 0; in snd_hda_codec_cleanup_for_unbind()
806 refcount_set(&codec->pcm_ref, 1); /* reset refcount */ in snd_hda_codec_cleanup_for_unbind()
816 if (codec->display_power_control) in snd_hda_codec_display_power()
817 snd_hdac_display_power(&codec->bus->core, codec->addr, enable); in snd_hda_codec_display_power()
821 * snd_hda_codec_register - Finalize codec initialization
828 if (codec->core.registered) in snd_hda_codec_register()
835 codec->core.registered = 1; in snd_hda_codec_register()
842 snd_hda_codec_register(device->device_data); in snd_hda_codec_dev_register()
847 * snd_hda_codec_unregister - Unregister specified codec device
852 codec->in_freeing = 1; in snd_hda_codec_unregister()
858 if (codec->core.type == HDA_DEV_LEGACY) in snd_hda_codec_unregister()
859 snd_hdac_device_unregister(&codec->core); in snd_hda_codec_unregister()
863 * In the case of ASoC HD-audio bus, the device refcount is released in in snd_hda_codec_unregister()
866 if (codec->core.type == HDA_DEV_LEGACY) in snd_hda_codec_unregister()
873 snd_hda_codec_unregister(device->device_data); in snd_hda_codec_dev_free()
882 snd_hdac_device_exit(&codec->core); in snd_hda_codec_dev_release()
884 kfree(codec->modelname); in snd_hda_codec_dev_release()
885 kfree(codec->wcaps); in snd_hda_codec_dev_release()
892 * snd_hda_codec_device_init - allocate HDA codec device
909 return ERR_PTR(-EINVAL); in snd_hda_codec_device_init()
911 return ERR_PTR(-EINVAL); in snd_hda_codec_device_init()
915 return ERR_PTR(-ENOMEM); in snd_hda_codec_device_init()
921 err = snd_hdac_device_init(&codec->core, &bus->core, name, codec_addr); in snd_hda_codec_device_init()
927 codec->bus = bus; in snd_hda_codec_device_init()
928 codec->depop_delay = -1; in snd_hda_codec_device_init()
929 codec->fixup_id = HDA_FIXUP_ID_NOT_SET; in snd_hda_codec_device_init()
930 codec->core.dev.release = snd_hda_codec_dev_release; in snd_hda_codec_device_init()
931 codec->core.exec_verb = codec_exec_verb; in snd_hda_codec_device_init()
932 codec->core.type = HDA_DEV_LEGACY; in snd_hda_codec_device_init()
934 mutex_init(&codec->spdif_mutex); in snd_hda_codec_device_init()
935 mutex_init(&codec->control_mutex); in snd_hda_codec_device_init()
936 snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); in snd_hda_codec_device_init()
937 snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32); in snd_hda_codec_device_init()
938 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); in snd_hda_codec_device_init()
939 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); in snd_hda_codec_device_init()
940 snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); in snd_hda_codec_device_init()
941 snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); in snd_hda_codec_device_init()
942 snd_array_init(&codec->jacktbl, sizeof(struct hda_jack_tbl), 16); in snd_hda_codec_device_init()
943 snd_array_init(&codec->verbs, sizeof(struct hda_verb *), 8); in snd_hda_codec_device_init()
944 INIT_LIST_HEAD(&codec->conn_list); in snd_hda_codec_device_init()
945 INIT_LIST_HEAD(&codec->pcm_list_head); in snd_hda_codec_device_init()
946 INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work); in snd_hda_codec_device_init()
947 refcount_set(&codec->pcm_ref, 1); in snd_hda_codec_device_init()
948 init_waitqueue_head(&codec->remove_sleep); in snd_hda_codec_device_init()
955 * snd_hda_codec_new - create a HDA codec
970 card->number, codec_addr); in snd_hda_codec_new()
995 dev_dbg(card->dev, "%s: entry\n", __func__); in snd_hda_codec_device_new()
998 return -EINVAL; in snd_hda_codec_device_new()
1000 return -EINVAL; in snd_hda_codec_device_new()
1002 codec->card = card; in snd_hda_codec_device_new()
1003 codec->addr = codec_addr; in snd_hda_codec_device_new()
1006 codec->power_jiffies = jiffies; in snd_hda_codec_device_new()
1011 if (codec->bus->modelname) { in snd_hda_codec_device_new()
1012 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); in snd_hda_codec_device_new()
1013 if (!codec->modelname) in snd_hda_codec_device_new()
1014 return -ENOMEM; in snd_hda_codec_device_new()
1017 fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in snd_hda_codec_device_new()
1025 /* power-up all before initialization */ in snd_hda_codec_device_new()
1027 codec->core.dev.power.power_state = PMSG_ON; in snd_hda_codec_device_new()
1033 sprintf(component, "HDA:%08x,%08x,%08x", codec->core.vendor_id, in snd_hda_codec_device_new()
1034 codec->core.subsystem_id, codec->core.revision_id); in snd_hda_codec_device_new()
1046 if (codec->core.dev.power.runtime_auto) in snd_hda_codec_device_new()
1047 pm_runtime_forbid(&codec->core.dev); in snd_hda_codec_device_new()
1050 pm_runtime_get_noresume(&codec->core.dev); in snd_hda_codec_device_new()
1058 * snd_hda_codec_update_widgets - Refresh widget caps and pin defaults
1069 err = snd_hdac_refresh_widgets(&codec->core); in snd_hda_codec_update_widgets()
1076 kfree(codec->wcaps); in snd_hda_codec_update_widgets()
1077 fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in snd_hda_codec_update_widgets()
1082 snd_array_free(&codec->init_pins); in snd_hda_codec_update_widgets()
1089 /* update the stream-id if changed */
1091 struct hda_cvt_setup *p, hda_nid_t nid, in update_pcm_stream_id() argument
1096 if (p->stream_tag != stream_tag || p->channel_id != channel_id) { in update_pcm_stream_id()
1103 p->stream_tag = stream_tag; in update_pcm_stream_id()
1104 p->channel_id = channel_id; in update_pcm_stream_id()
1108 /* update the format-id if changed */
1109 static void update_pcm_format(struct hda_codec *codec, struct hda_cvt_setup *p, in update_pcm_format() argument
1114 if (p->format_id != format) { in update_pcm_format()
1123 p->format_id = format; in update_pcm_format()
1128 * snd_hda_codec_setup_stream - set up the codec for streaming
1140 struct hda_cvt_setup *p; in snd_hda_codec_setup_stream() local
1150 p = get_hda_cvt_setup(codec, nid); in snd_hda_codec_setup_stream()
1151 if (!p) in snd_hda_codec_setup_stream()
1154 if (codec->patch_ops.stream_pm) in snd_hda_codec_setup_stream()
1155 codec->patch_ops.stream_pm(codec, nid, true); in snd_hda_codec_setup_stream()
1156 if (codec->pcm_format_first) in snd_hda_codec_setup_stream()
1157 update_pcm_format(codec, p, nid, format); in snd_hda_codec_setup_stream()
1158 update_pcm_stream_id(codec, p, nid, stream_tag, channel_id); in snd_hda_codec_setup_stream()
1159 if (!codec->pcm_format_first) in snd_hda_codec_setup_stream()
1160 update_pcm_format(codec, p, nid, format); in snd_hda_codec_setup_stream()
1162 p->active = 1; in snd_hda_codec_setup_stream()
1163 p->dirty = 0; in snd_hda_codec_setup_stream()
1165 /* make other inactive cvts with the same stream-tag dirty */ in snd_hda_codec_setup_stream()
1167 list_for_each_codec(c, codec->bus) { in snd_hda_codec_setup_stream()
1168 snd_array_for_each(&c->cvt_setups, i, p) { in snd_hda_codec_setup_stream()
1169 if (!p->active && p->stream_tag == stream_tag && in snd_hda_codec_setup_stream()
1170 get_wcaps_type(get_wcaps(c, p->nid)) == type) in snd_hda_codec_setup_stream()
1171 p->dirty = 1; in snd_hda_codec_setup_stream()
1181 * __snd_hda_codec_cleanup_stream - clean up the codec for closing
1189 struct hda_cvt_setup *p; in __snd_hda_codec_cleanup_stream() local
1194 if (codec->no_sticky_stream) in __snd_hda_codec_cleanup_stream()
1198 p = get_hda_cvt_setup(codec, nid); in __snd_hda_codec_cleanup_stream()
1199 if (p) { in __snd_hda_codec_cleanup_stream()
1201 * actual clean-ups will be done later in in __snd_hda_codec_cleanup_stream()
1205 really_cleanup_stream(codec, p); in __snd_hda_codec_cleanup_stream()
1207 p->active = 0; in __snd_hda_codec_cleanup_stream()
1215 hda_nid_t nid = q->nid; in really_cleanup_stream()
1216 if (q->stream_tag || q->channel_id) in really_cleanup_stream()
1218 if (q->format_id) in really_cleanup_stream()
1222 q->nid = nid; in really_cleanup_stream()
1223 if (codec->patch_ops.stream_pm) in really_cleanup_stream()
1224 codec->patch_ops.stream_pm(codec, nid, false); in really_cleanup_stream()
1231 struct hda_cvt_setup *p; in purify_inactive_streams() local
1234 list_for_each_codec(c, codec->bus) { in purify_inactive_streams()
1235 snd_array_for_each(&c->cvt_setups, i, p) { in purify_inactive_streams()
1236 if (p->dirty) in purify_inactive_streams()
1237 really_cleanup_stream(c, p); in purify_inactive_streams()
1246 struct hda_cvt_setup *p; in hda_cleanup_all_streams() local
1249 snd_array_for_each(&codec->cvt_setups, i, p) { in hda_cleanup_all_streams()
1250 if (p->stream_tag) in hda_cleanup_all_streams()
1251 really_cleanup_stream(codec, p); in hda_cleanup_all_streams()
1261 * query_amp_caps - query AMP capabilities
1262 * @codec: the HD-auio codec
1275 nid = codec->core.afg; in query_amp_caps()
1283 * snd_hda_check_amp_caps - query AMP capabilities
1284 * @codec: the HD-audio codec
1304 * snd_hda_override_amp_caps - Override the AMP capabilities
1324 return snd_hdac_override_parm(&codec->core, nid, parm, caps); in snd_hda_override_amp_caps()
1341 * snd_hda_codec_amp_update - update the AMP mono value
1342 * @codec: HD-audio codec
1357 return snd_hdac_regmap_update_raw(&codec->core, cmd, mask, val); in snd_hda_codec_amp_update()
1362 * snd_hda_codec_amp_stereo - update the AMP stereo values
1363 * @codec: HD-audio codec
1388 * snd_hda_codec_amp_init - initialize the AMP value
1406 if (!codec->core.regmap) in snd_hda_codec_amp_init()
1407 return -EINVAL; in snd_hda_codec_amp_init()
1408 return snd_hdac_regmap_update_raw_once(&codec->core, cmd, mask, val); in snd_hda_codec_amp_init()
1413 * snd_hda_codec_amp_init_stereo - initialize the stereo AMP value
1444 caps -= ofs; in get_amp_max_value()
1449 * snd_hda_mixer_amp_volume_info - Info callback for a standard AMP mixer
1465 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_hda_mixer_amp_volume_info()
1466 uinfo->count = chs == 3 ? 2 : 1; in snd_hda_mixer_amp_volume_info()
1467 uinfo->value.integer.min = 0; in snd_hda_mixer_amp_volume_info()
1468 uinfo->value.integer.max = get_amp_max_value(codec, nid, dir, ofs); in snd_hda_mixer_amp_volume_info()
1469 if (!uinfo->value.integer.max) { in snd_hda_mixer_amp_volume_info()
1472 nid, kcontrol->id.name); in snd_hda_mixer_amp_volume_info()
1473 return -EINVAL; in snd_hda_mixer_amp_volume_info()
1488 val -= ofs; in read_amp_value()
1512 * snd_hda_mixer_amp_volume_get - Get callback for a standard AMP mixer volume
1528 long *valp = ucontrol->value.integer.value; in snd_hda_mixer_amp_volume_get()
1539 * snd_hda_mixer_amp_volume_put - Put callback for a standard AMP mixer volume
1555 long *valp = ucontrol->value.integer.value; in snd_hda_mixer_amp_volume_put()
1581 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); in get_ctl_amp_tlv()
1593 * snd_hda_mixer_amp_tlv - TLV callback for a standard AMP mixer volume
1608 return -ENOMEM; in snd_hda_mixer_amp_tlv()
1611 return -EFAULT; in snd_hda_mixer_amp_tlv()
1617 * snd_hda_set_vmaster_tlv - Set TLV for a virtual master control
1618 * @codec: HD-audio codec
1639 tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = -nums * step; in snd_hda_set_vmaster_tlv()
1656 return snd_ctl_find_id(codec->card, &id); in find_mixer_ctl()
1660 * snd_hda_find_mixer_ctl - Find a mixer control element with the given name
1661 * @codec: HD-audio codec
1682 return -EBUSY; in find_empty_mixer_ctl_idx()
1686 * snd_hda_ctl_add - Add a control element and assign to the codec
1687 * @codec: HD-audio codec
1693 * by this function so that a proper clean-up works at the free or
1696 * If non-zero @nid is passed, the NID is assigned to the control element.
1702 * specifies if kctl->private_value is a HDA amplifier value.
1711 if (kctl->id.subdevice & HDA_SUBDEV_AMP_FLAG) { in snd_hda_ctl_add()
1714 nid = get_amp_nid_(kctl->private_value); in snd_hda_ctl_add()
1716 if ((kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) != 0 && nid == 0) in snd_hda_ctl_add()
1717 nid = kctl->id.subdevice & 0xffff; in snd_hda_ctl_add()
1718 if (kctl->id.subdevice & (HDA_SUBDEV_NID_FLAG|HDA_SUBDEV_AMP_FLAG)) in snd_hda_ctl_add()
1719 kctl->id.subdevice = 0; in snd_hda_ctl_add()
1720 err = snd_ctl_add(codec->card, kctl); in snd_hda_ctl_add()
1723 item = snd_array_new(&codec->mixers); in snd_hda_ctl_add()
1725 return -ENOMEM; in snd_hda_ctl_add()
1726 item->kctl = kctl; in snd_hda_ctl_add()
1727 item->nid = nid; in snd_hda_ctl_add()
1728 item->flags = flags; in snd_hda_ctl_add()
1734 * snd_hda_add_nid - Assign a NID to a control element
1735 * @codec: HD-audio codec
1742 * NID:KCTL mapping - for example "Capture Source" selector.
1750 item = snd_array_new(&codec->nids); in snd_hda_add_nid()
1752 return -ENOMEM; in snd_hda_add_nid()
1753 item->kctl = kctl; in snd_hda_add_nid()
1754 item->index = index; in snd_hda_add_nid()
1755 item->nid = nid; in snd_hda_add_nid()
1759 kctl->id.name, kctl->id.index, index); in snd_hda_add_nid()
1760 return -EINVAL; in snd_hda_add_nid()
1765 * snd_hda_ctls_clear - Clear all controls assigned to the given codec
1766 * @codec: HD-audio codec
1771 struct hda_nid_item *items = codec->mixers.list; in snd_hda_ctls_clear()
1773 down_write(&codec->card->controls_rwsem); in snd_hda_ctls_clear()
1774 for (i = 0; i < codec->mixers.used; i++) in snd_hda_ctls_clear()
1775 snd_ctl_remove(codec->card, items[i].kctl); in snd_hda_ctls_clear()
1776 up_write(&codec->card->controls_rwsem); in snd_hda_ctls_clear()
1777 snd_array_free(&codec->mixers); in snd_hda_ctls_clear()
1778 snd_array_free(&codec->nids); in snd_hda_ctls_clear()
1782 * snd_hda_lock_devices - pseudo device locking
1785 * toggle card->shutdown to allow/disallow the device access (as a hack)
1789 struct snd_card *card = bus->card; in snd_hda_lock_devices()
1792 spin_lock(&card->files_lock); in snd_hda_lock_devices()
1793 if (card->shutdown) in snd_hda_lock_devices()
1795 card->shutdown = 1; in snd_hda_lock_devices()
1796 if (!list_empty(&card->ctl_files)) in snd_hda_lock_devices()
1801 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_lock_devices()
1802 if (!cpcm->pcm) in snd_hda_lock_devices()
1804 if (cpcm->pcm->streams[0].substream_opened || in snd_hda_lock_devices()
1805 cpcm->pcm->streams[1].substream_opened) in snd_hda_lock_devices()
1809 spin_unlock(&card->files_lock); in snd_hda_lock_devices()
1813 card->shutdown = 0; in snd_hda_lock_devices()
1815 spin_unlock(&card->files_lock); in snd_hda_lock_devices()
1816 return -EINVAL; in snd_hda_lock_devices()
1821 * snd_hda_unlock_devices - pseudo device unlocking
1826 struct snd_card *card = bus->card; in snd_hda_unlock_devices()
1828 spin_lock(&card->files_lock); in snd_hda_unlock_devices()
1829 card->shutdown = 0; in snd_hda_unlock_devices()
1830 spin_unlock(&card->files_lock); in snd_hda_unlock_devices()
1835 * snd_hda_codec_reset - Clear all objects assigned to the codec
1836 * @codec: HD-audio codec
1841 * When a device is being used, it returns -EBSY. If successfully freed,
1846 struct hda_bus *bus = codec->bus; in snd_hda_codec_reset()
1849 return -EBUSY; in snd_hda_codec_reset()
1869 items = codec->mixers.list; in map_followers()
1870 for (i = 0; i < codec->mixers.used; i++) { in map_followers()
1872 if (!sctl || sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER) in map_followers()
1875 char tmpname[sizeof(sctl->id.name)]; in map_followers()
1882 if (!strcmp(sctl->id.name, name)) { in map_followers()
1899 /* call kctl->put with the given value(s) */
1905 return -ENOMEM; in put_kctl_with_value()
1906 ucontrol->value.integer.value[0] = val; in put_kctl_with_value()
1907 ucontrol->value.integer.value[1] = val; in put_kctl_with_value()
1908 kctl->put(kctl, ucontrol); in put_kctl_with_value()
1929 if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { in init_follower_0dB()
1930 if (kctl->tlv.c != snd_hda_mixer_amp_tlv) { in init_follower_0dB()
1931 codec_err(arg->codec, in init_follower_0dB()
1933 kctl->id.name, kctl->id.index); in init_follower_0dB()
1938 } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) in init_follower_0dB()
1939 tlv = kctl->tlv.p; in init_follower_0dB()
1948 if (arg->step && arg->step != step) { in init_follower_0dB()
1949 codec_err(arg->codec, in init_follower_0dB()
1951 arg->step, step); in init_follower_0dB()
1955 arg->step = step; in init_follower_0dB()
1956 val = -tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] / step; in init_follower_0dB()
1980 * __snd_hda_add_vmaster - create a virtual master control and add followers
1981 * @codec: HD-audio codec
1993 * @followers is a NULL-terminated array of strings, each of which is a
2017 return -ENOMEM; in __snd_hda_add_vmaster()
2018 kctl->vd[0].access |= access; in __snd_hda_add_vmaster()
2050 hook->hook(hook->codec, enabled); in vmaster_hook()
2054 * snd_hda_add_vmaster_hook - Add a vmaster hw specific hook
2063 if (!hook->hook || !hook->sw_kctl) in snd_hda_add_vmaster_hook()
2065 hook->codec = codec; in snd_hda_add_vmaster_hook()
2066 snd_ctl_add_vmaster_hook(hook->sw_kctl, vmaster_hook, hook); in snd_hda_add_vmaster_hook()
2072 * snd_hda_sync_vmaster_hook - Sync vmaster hook
2080 if (!hook->hook || !hook->codec) in snd_hda_sync_vmaster_hook()
2085 if (hook->codec->bus->shutdown) in snd_hda_sync_vmaster_hook()
2087 snd_ctl_sync_vmaster_hook(hook->sw_kctl); in snd_hda_sync_vmaster_hook()
2093 * snd_hda_mixer_amp_switch_info - Info callback for a standard AMP mixer switch
2105 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_hda_mixer_amp_switch_info()
2106 uinfo->count = chs == 3 ? 2 : 1; in snd_hda_mixer_amp_switch_info()
2107 uinfo->value.integer.min = 0; in snd_hda_mixer_amp_switch_info()
2108 uinfo->value.integer.max = 1; in snd_hda_mixer_amp_switch_info()
2114 * snd_hda_mixer_amp_switch_get - Get callback for a standard AMP mixer switch
2129 long *valp = ucontrol->value.integer.value; in snd_hda_mixer_amp_switch_get()
2142 * snd_hda_mixer_amp_switch_put - Put callback for a standard AMP mixer switch
2157 long *valp = ucontrol->value.integer.value; in snd_hda_mixer_amp_switch_put()
2182 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_hda_spdif_mask_info()
2183 uinfo->count = 1; in snd_hda_spdif_mask_info()
2190 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | in snd_hda_spdif_cmask_get()
2194 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY | in snd_hda_spdif_cmask_get()
2202 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | in snd_hda_spdif_pmask_get()
2212 int idx = kcontrol->private_value; in snd_hda_spdif_default_get()
2215 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_default_get()
2216 return -EINVAL; in snd_hda_spdif_default_get()
2217 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_default_get()
2218 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_default_get()
2219 ucontrol->value.iec958.status[0] = spdif->status & 0xff; in snd_hda_spdif_default_get()
2220 ucontrol->value.iec958.status[1] = (spdif->status >> 8) & 0xff; in snd_hda_spdif_default_get()
2221 ucontrol->value.iec958.status[2] = (spdif->status >> 16) & 0xff; in snd_hda_spdif_default_get()
2222 ucontrol->value.iec958.status[3] = (spdif->status >> 24) & 0xff; in snd_hda_spdif_default_get()
2223 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_default_get()
2287 snd_hdac_regmap_update(&codec->core, nid, AC_VERB_SET_DIGI_CONVERT_1, in set_dig_out()
2289 d = codec->follower_dig_outs; in set_dig_out()
2293 snd_hdac_regmap_update(&codec->core, *d, in set_dig_out()
2303 if (dig1 != -1) { in set_dig_out_convert()
2307 if (dig2 != -1) { in set_dig_out_convert()
2318 int idx = kcontrol->private_value; in snd_hda_spdif_default_put()
2324 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_default_put()
2325 return -EINVAL; in snd_hda_spdif_default_put()
2326 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_default_put()
2327 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_default_put()
2328 nid = spdif->nid; in snd_hda_spdif_default_put()
2329 spdif->status = ucontrol->value.iec958.status[0] | in snd_hda_spdif_default_put()
2330 ((unsigned int)ucontrol->value.iec958.status[1] << 8) | in snd_hda_spdif_default_put()
2331 ((unsigned int)ucontrol->value.iec958.status[2] << 16) | in snd_hda_spdif_default_put()
2332 ((unsigned int)ucontrol->value.iec958.status[3] << 24); in snd_hda_spdif_default_put()
2333 val = convert_from_spdif_status(spdif->status); in snd_hda_spdif_default_put()
2334 val |= spdif->ctls & 1; in snd_hda_spdif_default_put()
2335 change = spdif->ctls != val; in snd_hda_spdif_default_put()
2336 spdif->ctls = val; in snd_hda_spdif_default_put()
2337 if (change && nid != (u16)-1) in snd_hda_spdif_default_put()
2339 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_default_put()
2349 int idx = kcontrol->private_value; in snd_hda_spdif_out_switch_get()
2352 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_out_switch_get()
2353 return -EINVAL; in snd_hda_spdif_out_switch_get()
2354 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_get()
2355 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_out_switch_get()
2356 ucontrol->value.integer.value[0] = spdif->ctls & AC_DIG1_ENABLE; in snd_hda_spdif_out_switch_get()
2357 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_get()
2376 int idx = kcontrol->private_value; in snd_hda_spdif_out_switch_put()
2382 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_out_switch_put()
2383 return -EINVAL; in snd_hda_spdif_out_switch_put()
2384 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_put()
2385 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_out_switch_put()
2386 nid = spdif->nid; in snd_hda_spdif_out_switch_put()
2387 val = spdif->ctls & ~AC_DIG1_ENABLE; in snd_hda_spdif_out_switch_put()
2388 if (ucontrol->value.integer.value[0]) in snd_hda_spdif_out_switch_put()
2390 change = spdif->ctls != val; in snd_hda_spdif_out_switch_put()
2391 spdif->ctls = val; in snd_hda_spdif_out_switch_put()
2392 if (change && nid != (u16)-1) in snd_hda_spdif_out_switch_put()
2393 set_spdif_ctls(codec, nid, val & 0xff, -1); in snd_hda_spdif_out_switch_put()
2394 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_put()
2431 * snd_hda_create_dig_out_ctls - create Output SPDIF-related controls
2453 struct hda_bus *bus = codec->bus; in snd_hda_create_dig_out_ctls()
2455 if (bus->primary_dig_out_type == HDA_PCM_TYPE_HDMI && in snd_hda_create_dig_out_ctls()
2458 } else if (bus->primary_dig_out_type == HDA_PCM_TYPE_SPDIF && in snd_hda_create_dig_out_ctls()
2461 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { in snd_hda_create_dig_out_ctls()
2462 kctl = find_mixer_ctl(codec, dig_mix->name, 0, 0); in snd_hda_create_dig_out_ctls()
2465 kctl->id.index = spdif_index; in snd_hda_create_dig_out_ctls()
2467 bus->primary_dig_out_type = HDA_PCM_TYPE_HDMI; in snd_hda_create_dig_out_ctls()
2469 if (!bus->primary_dig_out_type) in snd_hda_create_dig_out_ctls()
2470 bus->primary_dig_out_type = type; in snd_hda_create_dig_out_ctls()
2475 return -EBUSY; in snd_hda_create_dig_out_ctls()
2477 spdif = snd_array_new(&codec->spdif_out); in snd_hda_create_dig_out_ctls()
2479 return -ENOMEM; in snd_hda_create_dig_out_ctls()
2480 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { in snd_hda_create_dig_out_ctls()
2483 return -ENOMEM; in snd_hda_create_dig_out_ctls()
2484 kctl->id.index = idx; in snd_hda_create_dig_out_ctls()
2485 kctl->private_value = codec->spdif_out.used - 1; in snd_hda_create_dig_out_ctls()
2490 spdif->nid = cvt_nid; in snd_hda_create_dig_out_ctls()
2491 snd_hdac_regmap_read(&codec->core, cvt_nid, in snd_hda_create_dig_out_ctls()
2493 spdif->ctls = val; in snd_hda_create_dig_out_ctls()
2494 spdif->status = convert_to_spdif_status(spdif->ctls); in snd_hda_create_dig_out_ctls()
2500 * snd_hda_spdif_out_of_nid - get the hda_spdif_out entry from the given NID
2512 snd_array_for_each(&codec->spdif_out, i, spdif) { in snd_hda_spdif_out_of_nid()
2513 if (spdif->nid == nid) in snd_hda_spdif_out_of_nid()
2521 * snd_hda_spdif_ctls_unassign - Unassign the given SPDIF ctl
2531 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_ctls_unassign()
2533 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_ctls_unassign()
2534 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_ctls_unassign()
2535 spdif->nid = (u16)-1; in snd_hda_spdif_ctls_unassign()
2536 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_ctls_unassign()
2541 * snd_hda_spdif_ctls_assign - Assign the SPDIF controls to the given NID
2553 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_ctls_assign()
2555 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_ctls_assign()
2556 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_ctls_assign()
2557 if (spdif->nid != nid) { in snd_hda_spdif_ctls_assign()
2558 spdif->nid = nid; in snd_hda_spdif_ctls_assign()
2559 val = spdif->ctls; in snd_hda_spdif_ctls_assign()
2562 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_ctls_assign()
2573 ucontrol->value.integer.value[0] = mout->share_spdif; in spdif_share_sw_get()
2581 mout->share_spdif = !!ucontrol->value.integer.value[0]; in spdif_share_sw_put()
2594 * snd_hda_create_spdif_share_sw - create Default PCM switch
2596 * @mout: multi-out instance
2603 if (!mout->dig_out_nid) in snd_hda_create_spdif_share_sw()
2608 return -ENOMEM; in snd_hda_create_spdif_share_sw()
2610 return snd_hda_ctl_add(codec, mout->dig_out_nid, kctl); in snd_hda_create_spdif_share_sw()
2625 ucontrol->value.integer.value[0] = codec->spdif_in_enable; in snd_hda_spdif_in_switch_get()
2633 hda_nid_t nid = kcontrol->private_value; in snd_hda_spdif_in_switch_put()
2634 unsigned int val = !!ucontrol->value.integer.value[0]; in snd_hda_spdif_in_switch_put()
2637 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_in_switch_put()
2638 change = codec->spdif_in_enable != val; in snd_hda_spdif_in_switch_put()
2640 codec->spdif_in_enable = val; in snd_hda_spdif_in_switch_put()
2641 snd_hdac_regmap_write(&codec->core, nid, in snd_hda_spdif_in_switch_put()
2644 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_in_switch_put()
2652 hda_nid_t nid = kcontrol->private_value; in snd_hda_spdif_in_status_get()
2656 snd_hdac_regmap_read(&codec->core, nid, in snd_hda_spdif_in_status_get()
2659 ucontrol->value.iec958.status[0] = sbits; in snd_hda_spdif_in_status_get()
2660 ucontrol->value.iec958.status[1] = sbits >> 8; in snd_hda_spdif_in_status_get()
2661 ucontrol->value.iec958.status[2] = sbits >> 16; in snd_hda_spdif_in_status_get()
2662 ucontrol->value.iec958.status[3] = sbits >> 24; in snd_hda_spdif_in_status_get()
2685 * snd_hda_create_spdif_in_ctls - create Input SPDIF-related controls
2704 return -EBUSY; in snd_hda_create_spdif_in_ctls()
2706 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { in snd_hda_create_spdif_in_ctls()
2709 return -ENOMEM; in snd_hda_create_spdif_in_ctls()
2710 kctl->private_value = nid; in snd_hda_create_spdif_in_ctls()
2715 codec->spdif_in_enable = in snd_hda_create_spdif_in_ctls()
2724 * snd_hda_codec_set_power_to_all - Set the power state to all widgets
2743 if (codec->power_filter) { in snd_hda_codec_set_power_to_all()
2744 state = codec->power_filter(codec, nid, power_state); in snd_hda_codec_set_power_to_all()
2755 * snd_hda_codec_eapd_power_filter - A power filter callback for EAPD
2767 if (nid == codec->core.afg || nid == codec->core.mfg) in snd_hda_codec_eapd_power_filter()
2787 hda_nid_t fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in hda_set_power_state()
2792 /* this delay seems necessary to avoid click noise at power-down */ in hda_set_power_state()
2794 if (codec->depop_delay < 0) in hda_set_power_state()
2796 else if (codec->depop_delay > 0) in hda_set_power_state()
2797 msleep(codec->depop_delay); in hda_set_power_state()
2803 if (codec->patch_ops.set_power_state) in hda_set_power_state()
2804 codec->patch_ops.set_power_state(codec, fg, in hda_set_power_state()
2808 if (codec->power_filter) in hda_set_power_state()
2809 state = codec->power_filter(codec, fg, state); in hda_set_power_state()
2832 if (!codec->power_filter) in sync_power_up_states()
2840 target = codec->power_filter(codec, nid, AC_PWRST_D0); in sync_power_up_states()
2853 if (codec->init_verbs.list) in hda_exec_init_verbs()
2854 snd_hda_sequence_write(codec, codec->init_verbs.list); in hda_exec_init_verbs()
2864 unsigned long delta = jiffies - codec->power_jiffies; in update_power_acct()
2867 codec->power_on_acct += delta; in update_power_acct()
2869 codec->power_off_acct += delta; in update_power_acct()
2870 codec->power_jiffies += delta; in update_power_acct()
2879 * call suspend and power-down; used both from PM and power-save
2886 snd_hdac_enter_pm(&codec->core); in hda_call_codec_suspend()
2887 if (codec->patch_ops.suspend) in hda_call_codec_suspend()
2888 codec->patch_ops.suspend(codec); in hda_call_codec_suspend()
2892 snd_hdac_leave_pm(&codec->core); in hda_call_codec_suspend()
2897 * kick up codec; used both from PM and power-save
2901 snd_hdac_enter_pm(&codec->core); in hda_call_codec_resume()
2902 if (codec->core.regmap) in hda_call_codec_resume()
2903 regcache_mark_dirty(codec->core.regmap); in hda_call_codec_resume()
2905 codec->power_jiffies = jiffies; in hda_call_codec_resume()
2911 if (codec->patch_ops.resume) in hda_call_codec_resume()
2912 codec->patch_ops.resume(codec); in hda_call_codec_resume()
2914 if (codec->patch_ops.init) in hda_call_codec_resume()
2915 codec->patch_ops.init(codec); in hda_call_codec_resume()
2919 if (codec->jackpoll_interval) in hda_call_codec_resume()
2920 hda_jackpoll_work(&codec->jackpoll_work.work); in hda_call_codec_resume()
2923 codec->core.dev.power.power_state = PMSG_ON; in hda_call_codec_resume()
2924 snd_hdac_leave_pm(&codec->core); in hda_call_codec_resume()
2933 if (!codec->card) in hda_codec_runtime_suspend()
2936 cancel_delayed_work_sync(&codec->jackpoll_work); in hda_codec_runtime_suspend()
2939 if (codec->link_down_at_suspend || in hda_codec_runtime_suspend()
2942 snd_hdac_codec_link_down(&codec->core); in hda_codec_runtime_suspend()
2945 if (codec->bus->jackpoll_in_suspend && in hda_codec_runtime_suspend()
2946 (dev->power.power_state.event != PM_EVENT_SUSPEND)) in hda_codec_runtime_suspend()
2947 schedule_delayed_work(&codec->jackpoll_work, in hda_codec_runtime_suspend()
2948 codec->jackpoll_interval); in hda_codec_runtime_suspend()
2957 if (!codec->card) in hda_codec_runtime_resume()
2961 snd_hdac_codec_link_up(&codec->core); in hda_codec_runtime_resume()
2974 cancel_delayed_work_sync(&codec->jackpoll_work); in hda_codec_pm_prepare()
2975 dev->power.power_state = PMSG_SUSPEND; in hda_codec_pm_prepare()
2983 /* If no other pm-functions are called between prepare() and complete() */ in hda_codec_pm_complete()
2984 if (dev->power.power_state.event == PM_EVENT_SUSPEND) in hda_codec_pm_complete()
2985 dev->power.power_state = PMSG_RESUME; in hda_codec_pm_complete()
2987 if (pm_runtime_suspended(dev) && (codec->jackpoll_interval || in hda_codec_pm_complete()
2988 hda_codec_need_resume(codec) || codec->forced_resume)) in hda_codec_pm_complete()
2994 dev->power.power_state = PMSG_SUSPEND; in hda_codec_pm_suspend()
3000 dev->power.power_state = PMSG_RESUME; in hda_codec_pm_resume()
3008 cancel_delayed_work_sync(&codec->jackpoll_work); in hda_codec_pm_freeze()
3009 dev->power.power_state = PMSG_FREEZE; in hda_codec_pm_freeze()
3015 dev->power.power_state = PMSG_THAW; in hda_codec_pm_thaw()
3021 dev->power.power_state = PMSG_RESTORE; in hda_codec_pm_restore()
3048 if (!codec->core.registered) in snd_hda_codec_shutdown()
3051 cancel_delayed_work_sync(&codec->jackpoll_work); in snd_hda_codec_shutdown()
3052 list_for_each_entry(cpcm, &codec->pcm_list_head, list) in snd_hda_codec_shutdown()
3053 snd_pcm_suspend_all(cpcm->pcm); in snd_hda_codec_shutdown()
3067 list_for_each_entry(pcm, &codec->pcm_list_head, list) { in add_std_chmaps()
3069 struct hda_pcm_stream *hinfo = &pcm->stream[str]; in add_std_chmaps()
3073 if (!pcm->pcm || pcm->own_chmap || !hinfo->substreams) in add_std_chmaps()
3075 elem = hinfo->chmap ? hinfo->chmap : snd_pcm_std_chmaps; in add_std_chmaps()
3076 err = snd_pcm_add_chmap_ctls(pcm->pcm, str, elem, in add_std_chmaps()
3077 hinfo->channels_max, in add_std_chmaps()
3081 chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; in add_std_chmaps()
3088 * since HD-audio supports only stereo, odd number channels are omitted
3105 if (codec->patch_ops.init) in snd_hda_codec_build_controls()
3106 err = codec->patch_ops.init(codec); in snd_hda_codec_build_controls()
3107 if (!err && codec->patch_ops.build_controls) in snd_hda_codec_build_controls()
3108 err = codec->patch_ops.build_controls(codec); in snd_hda_codec_build_controls()
3117 if (codec->jackpoll_interval) in snd_hda_codec_build_controls()
3118 hda_jackpoll_work(&codec->jackpoll_work.work); in snd_hda_codec_build_controls()
3142 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in hda_pcm_default_prepare()
3150 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in hda_pcm_default_cleanup()
3160 if (info->nid && (!info->rates || !info->formats)) { in set_pcm_default_values()
3161 err = snd_hda_query_supported_pcm(codec, info->nid, in set_pcm_default_values()
3162 info->rates ? NULL : &info->rates, in set_pcm_default_values()
3163 info->formats ? NULL : &info->formats, in set_pcm_default_values()
3164 info->maxbps ? NULL : &info->maxbps); in set_pcm_default_values()
3168 if (info->ops.open == NULL) in set_pcm_default_values()
3169 info->ops.open = hda_pcm_default_open_close; in set_pcm_default_values()
3170 if (info->ops.close == NULL) in set_pcm_default_values()
3171 info->ops.close = hda_pcm_default_open_close; in set_pcm_default_values()
3172 if (info->ops.prepare == NULL) { in set_pcm_default_values()
3173 if (snd_BUG_ON(!info->nid)) in set_pcm_default_values()
3174 return -EINVAL; in set_pcm_default_values()
3175 info->ops.prepare = hda_pcm_default_prepare; in set_pcm_default_values()
3177 if (info->ops.cleanup == NULL) { in set_pcm_default_values()
3178 if (snd_BUG_ON(!info->nid)) in set_pcm_default_values()
3179 return -EINVAL; in set_pcm_default_values()
3180 info->ops.cleanup = hda_pcm_default_cleanup; in set_pcm_default_values()
3189 * snd_hda_codec_prepare - Prepare a stream
3206 mutex_lock(&codec->bus->prepare_mutex); in snd_hda_codec_prepare()
3207 if (hinfo->ops.prepare) in snd_hda_codec_prepare()
3208 ret = hinfo->ops.prepare(hinfo, codec, stream, format, in snd_hda_codec_prepare()
3211 ret = -ENODEV; in snd_hda_codec_prepare()
3214 mutex_unlock(&codec->bus->prepare_mutex); in snd_hda_codec_prepare()
3220 * snd_hda_codec_cleanup - Clean up stream resources
3231 mutex_lock(&codec->bus->prepare_mutex); in snd_hda_codec_cleanup()
3232 if (hinfo->ops.cleanup) in snd_hda_codec_cleanup()
3233 hinfo->ops.cleanup(hinfo, codec, substream); in snd_hda_codec_cleanup()
3234 mutex_unlock(&codec->bus->prepare_mutex); in snd_hda_codec_cleanup()
3253 [HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 }, in get_empty_pcm_device()
3254 [HDA_PCM_TYPE_SPDIF] = { 1, -1 }, in get_empty_pcm_device()
3255 [HDA_PCM_TYPE_HDMI] = { 3, 7, 8, 9, -1 }, in get_empty_pcm_device()
3256 [HDA_PCM_TYPE_MODEM] = { 6, -1 }, in get_empty_pcm_device()
3261 dev_err(bus->card->dev, "Invalid PCM type %d\n", type); in get_empty_pcm_device()
3262 return -EINVAL; in get_empty_pcm_device()
3270 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) in get_empty_pcm_device()
3275 /* non-fixed slots starting from 10 */ in get_empty_pcm_device()
3277 if (!test_and_set_bit(i, bus->pcm_dev_bits)) in get_empty_pcm_device()
3282 dev_warn(bus->card->dev, "Too many %s devices\n", in get_empty_pcm_device()
3285 dev_warn(bus->card->dev, in get_empty_pcm_device()
3288 return -EAGAIN; in get_empty_pcm_device()
3297 if (!list_empty(&codec->pcm_list_head)) in snd_hda_codec_parse_pcms()
3300 if (!codec->patch_ops.build_pcms) in snd_hda_codec_parse_pcms()
3303 err = codec->patch_ops.build_pcms(codec); in snd_hda_codec_parse_pcms()
3306 codec->core.addr, err); in snd_hda_codec_parse_pcms()
3310 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_codec_parse_pcms()
3314 struct hda_pcm_stream *info = &cpcm->stream[stream]; in snd_hda_codec_parse_pcms()
3316 if (!info->substreams) in snd_hda_codec_parse_pcms()
3322 cpcm->name); in snd_hda_codec_parse_pcms()
3335 struct hda_bus *bus = codec->bus; in snd_hda_codec_build_pcms()
3344 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_codec_build_pcms()
3345 if (cpcm->pcm) in snd_hda_codec_build_pcms()
3347 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams) in snd_hda_codec_build_pcms()
3350 dev = get_empty_pcm_device(bus, cpcm->pcm_type); in snd_hda_codec_build_pcms()
3352 cpcm->device = SNDRV_PCM_INVALID_DEVICE; in snd_hda_codec_build_pcms()
3355 cpcm->device = dev; in snd_hda_codec_build_pcms()
3360 dev, codec->core.addr); in snd_hda_codec_build_pcms()
3369 * snd_hda_add_new_ctls - create controls from the array
3383 for (; knew->name; knew++) { in snd_hda_add_new_ctls()
3386 if (knew->iface == (__force snd_ctl_elem_iface_t)-1) in snd_hda_add_new_ctls()
3391 return -ENOMEM; in snd_hda_add_new_ctls()
3393 kctl->id.device = addr; in snd_hda_add_new_ctls()
3395 kctl->id.index = idx; in snd_hda_add_new_ctls()
3403 if (!addr && codec->core.addr) in snd_hda_add_new_ctls()
3404 addr = codec->core.addr; in snd_hda_add_new_ctls()
3405 else if (!idx && !knew->index) { in snd_hda_add_new_ctls()
3407 knew->name, 0); in snd_hda_add_new_ctls()
3420 * snd_hda_codec_set_power_save - Configure codec's runtime PM
3428 if (delay == 0 && codec->auto_runtime_pm) in snd_hda_codec_set_power_save()
3445 * snd_hda_set_power_save - reprogram autosuspend for the given delay
3446 * @bus: HD-audio bus
3461 * snd_hda_check_amp_list_power - Check the amp list and update the power
3462 * @codec: HD-audio codec
3467 * check the current AMP status, and update the power-status according
3477 const struct hda_amp_list *p; in snd_hda_check_amp_list_power() local
3480 if (!check->amplist) in snd_hda_check_amp_list_power()
3482 for (p = check->amplist; p->nid; p++) { in snd_hda_check_amp_list_power()
3483 if (p->nid == nid) in snd_hda_check_amp_list_power()
3486 if (!p->nid) in snd_hda_check_amp_list_power()
3489 for (p = check->amplist; p->nid; p++) { in snd_hda_check_amp_list_power()
3491 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, in snd_hda_check_amp_list_power()
3492 p->idx); in snd_hda_check_amp_list_power()
3494 if (!check->power_on) { in snd_hda_check_amp_list_power()
3495 check->power_on = 1; in snd_hda_check_amp_list_power()
3502 if (check->power_on) { in snd_hda_check_amp_list_power()
3503 check->power_on = 0; in snd_hda_check_amp_list_power()
3516 * snd_hda_input_mux_info - Info callback helper for the input-mux enum
3525 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in snd_hda_input_mux_info()
3526 uinfo->count = 1; in snd_hda_input_mux_info()
3527 uinfo->value.enumerated.items = imux->num_items; in snd_hda_input_mux_info()
3528 if (!imux->num_items) in snd_hda_input_mux_info()
3530 index = uinfo->value.enumerated.item; in snd_hda_input_mux_info()
3531 if (index >= imux->num_items) in snd_hda_input_mux_info()
3532 index = imux->num_items - 1; in snd_hda_input_mux_info()
3533 strcpy(uinfo->value.enumerated.name, imux->items[index].label); in snd_hda_input_mux_info()
3539 * snd_hda_input_mux_put - Put callback helper for the input-mux enum
3554 if (!imux->num_items) in snd_hda_input_mux_put()
3556 idx = ucontrol->value.enumerated.item[0]; in snd_hda_input_mux_put()
3557 if (idx >= imux->num_items) in snd_hda_input_mux_put()
3558 idx = imux->num_items - 1; in snd_hda_input_mux_put()
3562 imux->items[idx].index); in snd_hda_input_mux_put()
3570 * snd_hda_enum_helper_info - Helper for simple enum ctls
3597 * Multi-channel / digital-out PCM helper functions
3617 reset = codec->spdif_status_reset && in setup_dig_out_stream()
3618 (spdif->ctls & AC_DIG1_ENABLE) && in setup_dig_out_stream()
3625 spdif->ctls & ~AC_DIG1_ENABLE & 0xff, in setup_dig_out_stream()
3626 -1); in setup_dig_out_stream()
3628 if (codec->follower_dig_outs) { in setup_dig_out_stream()
3630 for (d = codec->follower_dig_outs; *d; d++) in setup_dig_out_stream()
3637 spdif->ctls & 0xff, -1); in setup_dig_out_stream()
3643 if (codec->follower_dig_outs) { in cleanup_dig_out_stream()
3645 for (d = codec->follower_dig_outs; *d; d++) in cleanup_dig_out_stream()
3651 * snd_hda_multi_out_dig_open - open the digital out in the exclusive mode
3658 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_open()
3659 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP) in snd_hda_multi_out_dig_open()
3661 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_dig_open()
3662 mout->dig_out_used = HDA_DIG_EXCLUSIVE; in snd_hda_multi_out_dig_open()
3663 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_open()
3669 * snd_hda_multi_out_dig_prepare - prepare the digital out stream
3682 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_prepare()
3683 setup_dig_out_stream(codec, mout->dig_out_nid, stream_tag, format); in snd_hda_multi_out_dig_prepare()
3684 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_prepare()
3690 * snd_hda_multi_out_dig_cleanup - clean-up the digital out stream
3697 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_cleanup()
3698 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_dig_cleanup()
3699 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_cleanup()
3705 * snd_hda_multi_out_dig_close - release the digital out stream
3712 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_close()
3713 mout->dig_out_used = 0; in snd_hda_multi_out_dig_close()
3714 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_close()
3720 * snd_hda_multi_out_analog_open - open analog outputs
3726 * Open analog outputs and set up the hw-constraints.
3735 struct snd_pcm_runtime *runtime = substream->runtime; in snd_hda_multi_out_analog_open()
3736 runtime->hw.channels_max = mout->max_channels; in snd_hda_multi_out_analog_open()
3737 if (mout->dig_out_nid) { in snd_hda_multi_out_analog_open()
3738 if (!mout->analog_rates) { in snd_hda_multi_out_analog_open()
3739 mout->analog_rates = hinfo->rates; in snd_hda_multi_out_analog_open()
3740 mout->analog_formats = hinfo->formats; in snd_hda_multi_out_analog_open()
3741 mout->analog_maxbps = hinfo->maxbps; in snd_hda_multi_out_analog_open()
3743 runtime->hw.rates = mout->analog_rates; in snd_hda_multi_out_analog_open()
3744 runtime->hw.formats = mout->analog_formats; in snd_hda_multi_out_analog_open()
3745 hinfo->maxbps = mout->analog_maxbps; in snd_hda_multi_out_analog_open()
3747 if (!mout->spdif_rates) { in snd_hda_multi_out_analog_open()
3748 snd_hda_query_supported_pcm(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_open()
3749 &mout->spdif_rates, in snd_hda_multi_out_analog_open()
3750 &mout->spdif_formats, in snd_hda_multi_out_analog_open()
3751 &mout->spdif_maxbps); in snd_hda_multi_out_analog_open()
3753 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_open()
3754 if (mout->share_spdif) { in snd_hda_multi_out_analog_open()
3755 if ((runtime->hw.rates & mout->spdif_rates) && in snd_hda_multi_out_analog_open()
3756 (runtime->hw.formats & mout->spdif_formats)) { in snd_hda_multi_out_analog_open()
3757 runtime->hw.rates &= mout->spdif_rates; in snd_hda_multi_out_analog_open()
3758 runtime->hw.formats &= mout->spdif_formats; in snd_hda_multi_out_analog_open()
3759 if (mout->spdif_maxbps < hinfo->maxbps) in snd_hda_multi_out_analog_open()
3760 hinfo->maxbps = mout->spdif_maxbps; in snd_hda_multi_out_analog_open()
3762 mout->share_spdif = 0; in snd_hda_multi_out_analog_open()
3766 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_open()
3768 return snd_pcm_hw_constraint_step(substream->runtime, 0, in snd_hda_multi_out_analog_open()
3774 * snd_hda_multi_out_analog_prepare - Preapre the analog outputs.
3790 const hda_nid_t *nids = mout->dac_nids; in snd_hda_multi_out_analog_prepare()
3791 int chs = substream->runtime->channels; in snd_hda_multi_out_analog_prepare()
3795 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_prepare()
3796 spdif = snd_hda_spdif_out_of_nid(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_prepare()
3797 if (mout->dig_out_nid && mout->share_spdif && in snd_hda_multi_out_analog_prepare()
3798 mout->dig_out_used != HDA_DIG_EXCLUSIVE) { in snd_hda_multi_out_analog_prepare()
3800 snd_hda_is_supported_format(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_prepare()
3802 !(spdif->status & IEC958_AES0_NONAUDIO)) { in snd_hda_multi_out_analog_prepare()
3803 mout->dig_out_used = HDA_DIG_ANALOG_DUP; in snd_hda_multi_out_analog_prepare()
3804 setup_dig_out_stream(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_prepare()
3807 mout->dig_out_used = 0; in snd_hda_multi_out_analog_prepare()
3808 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_prepare()
3811 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_prepare()
3816 if (!mout->no_share_stream && in snd_hda_multi_out_analog_prepare()
3817 mout->hp_nid && mout->hp_nid != nids[HDA_FRONT]) in snd_hda_multi_out_analog_prepare()
3819 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, in snd_hda_multi_out_analog_prepare()
3822 for (i = 0; i < ARRAY_SIZE(mout->hp_out_nid); i++) in snd_hda_multi_out_analog_prepare()
3823 if (!mout->no_share_stream && mout->hp_out_nid[i]) in snd_hda_multi_out_analog_prepare()
3825 mout->hp_out_nid[i], in snd_hda_multi_out_analog_prepare()
3829 for (i = 1; i < mout->num_dacs; i++) { in snd_hda_multi_out_analog_prepare()
3833 else if (!mout->no_share_stream) /* copy front */ in snd_hda_multi_out_analog_prepare()
3839 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) { in snd_hda_multi_out_analog_prepare()
3841 if (!mout->extra_out_nid[i]) in snd_hda_multi_out_analog_prepare()
3845 else if (!mout->no_share_stream) in snd_hda_multi_out_analog_prepare()
3847 snd_hda_codec_setup_stream(codec, mout->extra_out_nid[i], in snd_hda_multi_out_analog_prepare()
3856 * snd_hda_multi_out_analog_cleanup - clean up the setting for analog out
3863 const hda_nid_t *nids = mout->dac_nids; in snd_hda_multi_out_analog_cleanup()
3866 for (i = 0; i < mout->num_dacs; i++) in snd_hda_multi_out_analog_cleanup()
3868 if (mout->hp_nid) in snd_hda_multi_out_analog_cleanup()
3869 snd_hda_codec_cleanup_stream(codec, mout->hp_nid); in snd_hda_multi_out_analog_cleanup()
3870 for (i = 0; i < ARRAY_SIZE(mout->hp_out_nid); i++) in snd_hda_multi_out_analog_cleanup()
3871 if (mout->hp_out_nid[i]) in snd_hda_multi_out_analog_cleanup()
3873 mout->hp_out_nid[i]); in snd_hda_multi_out_analog_cleanup()
3874 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) in snd_hda_multi_out_analog_cleanup()
3875 if (mout->extra_out_nid[i]) in snd_hda_multi_out_analog_cleanup()
3877 mout->extra_out_nid[i]); in snd_hda_multi_out_analog_cleanup()
3878 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_cleanup()
3879 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) { in snd_hda_multi_out_analog_cleanup()
3880 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_cleanup()
3881 mout->dig_out_used = 0; in snd_hda_multi_out_analog_cleanup()
3883 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_cleanup()
3889 * snd_hda_get_default_vref - Get the default (mic) VREF pin bits
3893 * Guess the suitable VREF pin bits to be set as the pin-control value.
3918 * snd_hda_correct_pin_ctl - correct the pin ctl value for matching with the pin cap
3951 unsigned int vcap, vref; in snd_hda_correct_pin_ctl() local
3954 vref = val & AC_PINCTL_VREFEN; in snd_hda_correct_pin_ctl()
3956 if (vref == cap_lists[i][0] && in snd_hda_correct_pin_ctl()
3958 if (i == ARRAY_SIZE(cap_lists) - 1) in snd_hda_correct_pin_ctl()
3959 vref = AC_PINCTL_VREF_HIZ; in snd_hda_correct_pin_ctl()
3961 vref = cap_lists[i + 1][0]; in snd_hda_correct_pin_ctl()
3965 val |= vref; in snd_hda_correct_pin_ctl()
3974 * _snd_hda_set_pin_ctl - Helper to set pin ctl value
4001 * snd_hda_add_imux_item - Add an item to input_mux
4010 * to type_idx when non-NULL pointer is given.
4017 if (imux->num_items >= HDA_MAX_NUM_INPUTS) { in snd_hda_add_imux_item()
4019 return -EINVAL; in snd_hda_add_imux_item()
4021 for (i = 0; i < imux->num_items; i++) { in snd_hda_add_imux_item()
4022 if (!strncmp(label, imux->items[i].label, strlen(label))) in snd_hda_add_imux_item()
4028 snprintf(imux->items[imux->num_items].label, in snd_hda_add_imux_item()
4029 sizeof(imux->items[imux->num_items].label), in snd_hda_add_imux_item()
4032 strscpy(imux->items[imux->num_items].label, label, in snd_hda_add_imux_item()
4033 sizeof(imux->items[imux->num_items].label)); in snd_hda_add_imux_item()
4034 imux->items[imux->num_items].index = index; in snd_hda_add_imux_item()
4035 imux->num_items++; in snd_hda_add_imux_item()
4041 * snd_hda_bus_reset_codecs - Reset the bus
4042 * @bus: HD-audio bus
4050 if (current_work() != &codec->jackpoll_work.work) in snd_hda_bus_reset_codecs()
4051 cancel_delayed_work_sync(&codec->jackpoll_work); in snd_hda_bus_reset_codecs()
4062 * snd_print_pcm_bits - Print the supported PCM fmt bits to the string buffer
4076 j += scnprintf(buf + j, buflen - j, " %d", bits[i]); in snd_print_pcm_bits()