• Home
  • Raw
  • Download

Lines Matching +full:spdif +full:- +full:connection

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()
86 /* connection list element */
99 list_for_each_entry(p, &codec->conn_list, list) { in lookup_conn_list()
100 if (p->nid == nid) in lookup_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()
125 p = list_first_entry(&codec->conn_list, typeof(*p), list); in remove_conn_list()
126 list_del(&p->list); in remove_conn_list()
131 /* read the connection and add to the cache */
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
159 * Parses the connection list of the given widget and stores the pointer
177 /* if the connection-list is already cached, read it */ 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
199 * @conn_list: connection list array; when NULL, checks only the size
202 * Parses the connection list of the given widget and stores the list
217 return -EINVAL; in snd_hda_get_connections()
227 * snd_hda_override_conn_list - add/modify the connection-list to cache
230 * @len: number of connection list entries
231 * @list: the list of connection entries
233 * Add or modify the given connection-list to the cache. If the corresponding
245 list_del(&p->list); in snd_hda_override_conn_list()
254 * snd_hda_get_conn_index - get the connection index of the given NID
260 * Parses the connection list of the widget @mux and checks whether the
261 * widget @nid is present. If it is, return the connection index.
262 * Otherwise it returns -1.
275 return -1; in snd_hda_get_conn_index()
277 codec_dbg(codec, "too deep connection for 0x%x\n", nid); 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
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()
697 p = snd_array_new(&codec->cvt_setups); in get_hda_cvt_setup()
699 p->nid = nid; in get_hda_cvt_setup()
710 if (pcm->pcm) in release_pcm()
711 snd_device_free(pcm->codec->card, pcm->pcm); in release_pcm()
712 clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits); in release_pcm()
713 kfree(pcm->name); in release_pcm()
719 kref_put(&pcm->kref, release_pcm); in snd_hda_codec_pcm_put()
733 pcm->codec = codec; in snd_hda_codec_pcm_new()
734 kref_init(&pcm->kref); in snd_hda_codec_pcm_new()
736 pcm->name = kvasprintf(GFP_KERNEL, fmt, args); in snd_hda_codec_pcm_new()
738 if (!pcm->name) { in snd_hda_codec_pcm_new()
743 list_add_tail(&pcm->list, &codec->pcm_list_head); in snd_hda_codec_pcm_new()
755 list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list) { in codec_release_pcms()
756 list_del_init(&pcm->list); in codec_release_pcms()
757 if (pcm->pcm) in codec_release_pcms()
758 snd_device_disconnect(codec->card, pcm->pcm); in codec_release_pcms()
765 if (codec->registered) { in snd_hda_codec_cleanup_for_unbind()
769 codec->registered = 0; in snd_hda_codec_cleanup_for_unbind()
772 cancel_delayed_work_sync(&codec->jackpoll_work); in snd_hda_codec_cleanup_for_unbind()
773 if (!codec->in_freeing) in snd_hda_codec_cleanup_for_unbind()
777 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops)); in snd_hda_codec_cleanup_for_unbind()
779 codec->proc_widget_hook = NULL; in snd_hda_codec_cleanup_for_unbind()
780 codec->spec = NULL; in snd_hda_codec_cleanup_for_unbind()
783 snd_array_free(&codec->driver_pins); in snd_hda_codec_cleanup_for_unbind()
784 snd_array_free(&codec->cvt_setups); in snd_hda_codec_cleanup_for_unbind()
785 snd_array_free(&codec->spdif_out); in snd_hda_codec_cleanup_for_unbind()
786 snd_array_free(&codec->verbs); in snd_hda_codec_cleanup_for_unbind()
787 codec->preset = NULL; in snd_hda_codec_cleanup_for_unbind()
788 codec->follower_dig_outs = NULL; in snd_hda_codec_cleanup_for_unbind()
789 codec->spdif_status_reset = 0; in snd_hda_codec_cleanup_for_unbind()
790 snd_array_free(&codec->mixers); in snd_hda_codec_cleanup_for_unbind()
791 snd_array_free(&codec->nids); in snd_hda_codec_cleanup_for_unbind()
793 snd_hdac_regmap_exit(&codec->core); in snd_hda_codec_cleanup_for_unbind()
794 codec->configured = 0; in snd_hda_codec_cleanup_for_unbind()
804 if (codec->display_power_control) in codec_display_power()
805 snd_hdac_display_power(&codec->bus->core, codec->addr, enable); in codec_display_power()
811 if (codec->registered) in snd_hda_codec_register()
818 codec->registered = 1; in snd_hda_codec_register()
824 snd_hda_codec_register(device->device_data); in snd_hda_codec_dev_register()
830 struct hda_codec *codec = device->device_data; in snd_hda_codec_dev_free()
832 codec->in_freeing = 1; in snd_hda_codec_dev_free()
838 if (codec->core.type == HDA_DEV_LEGACY) in snd_hda_codec_dev_free()
839 snd_hdac_device_unregister(&codec->core); in snd_hda_codec_dev_free()
843 * In the case of ASoC HD-audio bus, the device refcount is released in in snd_hda_codec_dev_free()
846 if (codec->core.type == HDA_DEV_LEGACY) in snd_hda_codec_dev_free()
857 snd_hdac_device_exit(&codec->core); in snd_hda_codec_dev_release()
859 kfree(codec->modelname); in snd_hda_codec_dev_release()
860 kfree(codec->wcaps); in snd_hda_codec_dev_release()
863 * In the case of ASoC HD-audio, hda_codec is device managed. in snd_hda_codec_dev_release()
866 if (codec->core.type == HDA_DEV_LEGACY) in snd_hda_codec_dev_release()
879 dev_dbg(card->dev, "%s: entry\n", __func__); in snd_hda_codec_device_init()
882 return -EINVAL; in snd_hda_codec_device_init()
884 return -EINVAL; in snd_hda_codec_device_init()
888 return -ENOMEM; in snd_hda_codec_device_init()
890 sprintf(name, "hdaudioC%dD%d", card->number, codec_addr); in snd_hda_codec_device_init()
891 err = snd_hdac_device_init(&codec->core, &bus->core, name, codec_addr); in snd_hda_codec_device_init()
897 codec->core.type = HDA_DEV_LEGACY; in snd_hda_codec_device_init()
904 * snd_hda_codec_new - create a HDA codec
936 dev_dbg(card->dev, "%s: entry\n", __func__); in snd_hda_codec_device_new()
939 return -EINVAL; in snd_hda_codec_device_new()
941 return -EINVAL; in snd_hda_codec_device_new()
943 codec->core.dev.release = snd_hda_codec_dev_release; in snd_hda_codec_device_new()
944 codec->core.exec_verb = codec_exec_verb; in snd_hda_codec_device_new()
946 codec->bus = bus; in snd_hda_codec_device_new()
947 codec->card = card; in snd_hda_codec_device_new()
948 codec->addr = codec_addr; in snd_hda_codec_device_new()
949 mutex_init(&codec->spdif_mutex); in snd_hda_codec_device_new()
950 mutex_init(&codec->control_mutex); in snd_hda_codec_device_new()
951 snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); in snd_hda_codec_device_new()
952 snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32); in snd_hda_codec_device_new()
953 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); in snd_hda_codec_device_new()
954 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); in snd_hda_codec_device_new()
955 snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); in snd_hda_codec_device_new()
956 snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); in snd_hda_codec_device_new()
957 snd_array_init(&codec->jacktbl, sizeof(struct hda_jack_tbl), 16); in snd_hda_codec_device_new()
958 snd_array_init(&codec->verbs, sizeof(struct hda_verb *), 8); in snd_hda_codec_device_new()
959 INIT_LIST_HEAD(&codec->conn_list); in snd_hda_codec_device_new()
960 INIT_LIST_HEAD(&codec->pcm_list_head); in snd_hda_codec_device_new()
962 INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work); in snd_hda_codec_device_new()
963 codec->depop_delay = -1; in snd_hda_codec_device_new()
964 codec->fixup_id = HDA_FIXUP_ID_NOT_SET; in snd_hda_codec_device_new()
967 codec->power_jiffies = jiffies; in snd_hda_codec_device_new()
972 if (codec->bus->modelname) { in snd_hda_codec_device_new()
973 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); in snd_hda_codec_device_new()
974 if (!codec->modelname) { in snd_hda_codec_device_new()
975 err = -ENOMEM; in snd_hda_codec_device_new()
980 fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in snd_hda_codec_device_new()
988 /* power-up all before initialization */ in snd_hda_codec_device_new()
990 codec->core.dev.power.power_state = PMSG_ON; in snd_hda_codec_device_new()
996 sprintf(component, "HDA:%08x,%08x,%08x", codec->core.vendor_id, in snd_hda_codec_device_new()
997 codec->core.subsystem_id, codec->core.revision_id); in snd_hda_codec_device_new()
1005 pm_runtime_forbid(&codec->core.dev); in snd_hda_codec_device_new()
1016 * snd_hda_codec_update_widgets - Refresh widget caps and pin defaults
1027 err = snd_hdac_refresh_widgets(&codec->core); in snd_hda_codec_update_widgets()
1034 kfree(codec->wcaps); in snd_hda_codec_update_widgets()
1035 fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in snd_hda_codec_update_widgets()
1040 snd_array_free(&codec->init_pins); in snd_hda_codec_update_widgets()
1047 /* update the stream-id if changed */
1054 if (p->stream_tag != stream_tag || p->channel_id != channel_id) { in update_pcm_stream_id()
1061 p->stream_tag = stream_tag; in update_pcm_stream_id()
1062 p->channel_id = channel_id; in update_pcm_stream_id()
1066 /* update the format-id if changed */
1072 if (p->format_id != format) { in update_pcm_format()
1081 p->format_id = format; in update_pcm_format()
1086 * snd_hda_codec_setup_stream - set up the codec for streaming
1112 if (codec->patch_ops.stream_pm) in snd_hda_codec_setup_stream()
1113 codec->patch_ops.stream_pm(codec, nid, true); in snd_hda_codec_setup_stream()
1114 if (codec->pcm_format_first) in snd_hda_codec_setup_stream()
1117 if (!codec->pcm_format_first) in snd_hda_codec_setup_stream()
1120 p->active = 1; in snd_hda_codec_setup_stream()
1121 p->dirty = 0; in snd_hda_codec_setup_stream()
1123 /* make other inactive cvts with the same stream-tag dirty */ in snd_hda_codec_setup_stream()
1125 list_for_each_codec(c, codec->bus) { in snd_hda_codec_setup_stream()
1126 snd_array_for_each(&c->cvt_setups, i, p) { in snd_hda_codec_setup_stream()
1127 if (!p->active && p->stream_tag == stream_tag && in snd_hda_codec_setup_stream()
1128 get_wcaps_type(get_wcaps(c, p->nid)) == type) in snd_hda_codec_setup_stream()
1129 p->dirty = 1; in snd_hda_codec_setup_stream()
1139 * __snd_hda_codec_cleanup_stream - clean up the codec for closing
1152 if (codec->no_sticky_stream) in __snd_hda_codec_cleanup_stream()
1159 * actual clean-ups will be done later in in __snd_hda_codec_cleanup_stream()
1165 p->active = 0; in __snd_hda_codec_cleanup_stream()
1173 hda_nid_t nid = q->nid; in really_cleanup_stream()
1174 if (q->stream_tag || q->channel_id) in really_cleanup_stream()
1176 if (q->format_id) in really_cleanup_stream()
1180 q->nid = nid; in really_cleanup_stream()
1181 if (codec->patch_ops.stream_pm) in really_cleanup_stream()
1182 codec->patch_ops.stream_pm(codec, nid, false); in really_cleanup_stream()
1192 list_for_each_codec(c, codec->bus) { in purify_inactive_streams()
1193 snd_array_for_each(&c->cvt_setups, i, p) { in purify_inactive_streams()
1194 if (p->dirty) in purify_inactive_streams()
1207 snd_array_for_each(&codec->cvt_setups, i, p) { in hda_cleanup_all_streams()
1208 if (p->stream_tag) in hda_cleanup_all_streams()
1219 * query_amp_caps - query AMP capabilities
1220 * @codec: the HD-auio codec
1233 nid = codec->core.afg; in query_amp_caps()
1241 * snd_hda_check_amp_caps - query AMP capabilities
1242 * @codec: the HD-audio codec
1262 * snd_hda_override_amp_caps - Override the AMP capabilities
1282 return snd_hdac_override_parm(&codec->core, nid, parm, caps); in snd_hda_override_amp_caps()
1299 * snd_hda_codec_amp_update - update the AMP mono value
1300 * @codec: HD-audio codec
1315 return snd_hdac_regmap_update_raw(&codec->core, cmd, mask, val); in snd_hda_codec_amp_update()
1320 * snd_hda_codec_amp_stereo - update the AMP stereo values
1321 * @codec: HD-audio codec
1346 * snd_hda_codec_amp_init - initialize the AMP value
1364 if (!codec->core.regmap) in snd_hda_codec_amp_init()
1365 return -EINVAL; in snd_hda_codec_amp_init()
1366 return snd_hdac_regmap_update_raw_once(&codec->core, cmd, mask, val); in snd_hda_codec_amp_init()
1371 * snd_hda_codec_amp_init_stereo - initialize the stereo AMP value
1402 caps -= ofs; in get_amp_max_value()
1407 * snd_hda_mixer_amp_volume_info - Info callback for a standard AMP mixer
1423 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_hda_mixer_amp_volume_info()
1424 uinfo->count = chs == 3 ? 2 : 1; in snd_hda_mixer_amp_volume_info()
1425 uinfo->value.integer.min = 0; in snd_hda_mixer_amp_volume_info()
1426 uinfo->value.integer.max = get_amp_max_value(codec, nid, dir, ofs); in snd_hda_mixer_amp_volume_info()
1427 if (!uinfo->value.integer.max) { in snd_hda_mixer_amp_volume_info()
1430 nid, kcontrol->id.name); in snd_hda_mixer_amp_volume_info()
1431 return -EINVAL; in snd_hda_mixer_amp_volume_info()
1446 val -= ofs; in read_amp_value()
1470 * snd_hda_mixer_amp_volume_get - Get callback for a standard AMP mixer volume
1486 long *valp = ucontrol->value.integer.value; in snd_hda_mixer_amp_volume_get()
1497 * snd_hda_mixer_amp_volume_put - Put callback for a standard AMP mixer volume
1513 long *valp = ucontrol->value.integer.value; in snd_hda_mixer_amp_volume_put()
1539 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); in get_ctl_amp_tlv()
1551 * snd_hda_mixer_amp_tlv - TLV callback for a standard AMP mixer volume
1566 return -ENOMEM; in snd_hda_mixer_amp_tlv()
1569 return -EFAULT; in snd_hda_mixer_amp_tlv()
1575 * snd_hda_set_vmaster_tlv - Set TLV for a virtual master control
1576 * @codec: HD-audio codec
1597 tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = -nums * step; in snd_hda_set_vmaster_tlv()
1614 return snd_ctl_find_id(codec->card, &id); in find_mixer_ctl()
1618 * snd_hda_find_mixer_ctl - Find a mixer control element with the given name
1619 * @codec: HD-audio codec
1640 return -EBUSY; in find_empty_mixer_ctl_idx()
1644 * snd_hda_ctl_add - Add a control element and assign to the codec
1645 * @codec: HD-audio codec
1651 * by this function so that a proper clean-up works at the free or
1654 * If non-zero @nid is passed, the NID is assigned to the control element.
1660 * specifies if kctl->private_value is a HDA amplifier value.
1669 if (kctl->id.subdevice & HDA_SUBDEV_AMP_FLAG) { in snd_hda_ctl_add()
1672 nid = get_amp_nid_(kctl->private_value); in snd_hda_ctl_add()
1674 if ((kctl->id.subdevice & HDA_SUBDEV_NID_FLAG) != 0 && nid == 0) in snd_hda_ctl_add()
1675 nid = kctl->id.subdevice & 0xffff; in snd_hda_ctl_add()
1676 if (kctl->id.subdevice & (HDA_SUBDEV_NID_FLAG|HDA_SUBDEV_AMP_FLAG)) in snd_hda_ctl_add()
1677 kctl->id.subdevice = 0; in snd_hda_ctl_add()
1678 err = snd_ctl_add(codec->card, kctl); in snd_hda_ctl_add()
1681 item = snd_array_new(&codec->mixers); in snd_hda_ctl_add()
1683 return -ENOMEM; in snd_hda_ctl_add()
1684 item->kctl = kctl; in snd_hda_ctl_add()
1685 item->nid = nid; in snd_hda_ctl_add()
1686 item->flags = flags; in snd_hda_ctl_add()
1692 * snd_hda_add_nid - Assign a NID to a control element
1693 * @codec: HD-audio codec
1700 * NID:KCTL mapping - for example "Capture Source" selector.
1708 item = snd_array_new(&codec->nids); in snd_hda_add_nid()
1710 return -ENOMEM; in snd_hda_add_nid()
1711 item->kctl = kctl; in snd_hda_add_nid()
1712 item->index = index; in snd_hda_add_nid()
1713 item->nid = nid; in snd_hda_add_nid()
1717 kctl->id.name, kctl->id.index, index); in snd_hda_add_nid()
1718 return -EINVAL; in snd_hda_add_nid()
1723 * snd_hda_ctls_clear - Clear all controls assigned to the given codec
1724 * @codec: HD-audio codec
1729 struct hda_nid_item *items = codec->mixers.list; in snd_hda_ctls_clear()
1731 down_write(&codec->card->controls_rwsem); in snd_hda_ctls_clear()
1732 for (i = 0; i < codec->mixers.used; i++) in snd_hda_ctls_clear()
1733 snd_ctl_remove(codec->card, items[i].kctl); in snd_hda_ctls_clear()
1734 up_write(&codec->card->controls_rwsem); in snd_hda_ctls_clear()
1735 snd_array_free(&codec->mixers); in snd_hda_ctls_clear()
1736 snd_array_free(&codec->nids); in snd_hda_ctls_clear()
1740 * snd_hda_lock_devices - pseudo device locking
1743 * toggle card->shutdown to allow/disallow the device access (as a hack)
1747 struct snd_card *card = bus->card; in snd_hda_lock_devices()
1750 spin_lock(&card->files_lock); in snd_hda_lock_devices()
1751 if (card->shutdown) in snd_hda_lock_devices()
1753 card->shutdown = 1; in snd_hda_lock_devices()
1754 if (!list_empty(&card->ctl_files)) in snd_hda_lock_devices()
1759 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_lock_devices()
1760 if (!cpcm->pcm) in snd_hda_lock_devices()
1762 if (cpcm->pcm->streams[0].substream_opened || in snd_hda_lock_devices()
1763 cpcm->pcm->streams[1].substream_opened) in snd_hda_lock_devices()
1767 spin_unlock(&card->files_lock); in snd_hda_lock_devices()
1771 card->shutdown = 0; in snd_hda_lock_devices()
1773 spin_unlock(&card->files_lock); in snd_hda_lock_devices()
1774 return -EINVAL; in snd_hda_lock_devices()
1779 * snd_hda_unlock_devices - pseudo device unlocking
1784 struct snd_card *card = bus->card; in snd_hda_unlock_devices()
1786 spin_lock(&card->files_lock); in snd_hda_unlock_devices()
1787 card->shutdown = 0; in snd_hda_unlock_devices()
1788 spin_unlock(&card->files_lock); in snd_hda_unlock_devices()
1793 * snd_hda_codec_reset - Clear all objects assigned to the codec
1794 * @codec: HD-audio codec
1799 * When a device is being used, it returns -EBSY. If successfully freed,
1804 struct hda_bus *bus = codec->bus; in snd_hda_codec_reset()
1807 return -EBUSY; in snd_hda_codec_reset()
1827 items = codec->mixers.list; in map_followers()
1828 for (i = 0; i < codec->mixers.used; i++) { in map_followers()
1830 if (!sctl || sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER) in map_followers()
1833 char tmpname[sizeof(sctl->id.name)]; in map_followers()
1840 if (!strcmp(sctl->id.name, name)) { in map_followers()
1857 /* call kctl->put with the given value(s) */
1863 return -ENOMEM; in put_kctl_with_value()
1864 ucontrol->value.integer.value[0] = val; in put_kctl_with_value()
1865 ucontrol->value.integer.value[1] = val; in put_kctl_with_value()
1866 kctl->put(kctl, ucontrol); in put_kctl_with_value()
1887 if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { in init_follower_0dB()
1888 if (kctl->tlv.c != snd_hda_mixer_amp_tlv) { in init_follower_0dB()
1889 codec_err(arg->codec, in init_follower_0dB()
1891 kctl->id.name, kctl->id.index); in init_follower_0dB()
1896 } else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) in init_follower_0dB()
1897 tlv = kctl->tlv.p; in init_follower_0dB()
1906 if (arg->step && arg->step != step) { in init_follower_0dB()
1907 codec_err(arg->codec, in init_follower_0dB()
1909 arg->step, step); in init_follower_0dB()
1913 arg->step = step; in init_follower_0dB()
1914 val = -tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] / step; in init_follower_0dB()
1938 * __snd_hda_add_vmaster - create a virtual master control and add followers
1939 * @codec: HD-audio codec
1950 * @followers is a NULL-terminated array of strings, each of which is a
1974 return -ENOMEM; in __snd_hda_add_vmaster()
2002 * mute-LED control using vmaster
2018 ucontrol->value.enumerated.item[0] = hook->mute_mode; in vmaster_mute_mode_get()
2026 unsigned int old_mode = hook->mute_mode; in vmaster_mute_mode_put()
2028 hook->mute_mode = ucontrol->value.enumerated.item[0]; in vmaster_mute_mode_put()
2029 if (hook->mute_mode > HDA_VMUTE_FOLLOW_MASTER) in vmaster_mute_mode_put()
2030 hook->mute_mode = HDA_VMUTE_FOLLOW_MASTER; in vmaster_mute_mode_put()
2031 if (old_mode == hook->mute_mode) in vmaster_mute_mode_put()
2039 .name = "Mute-LED Mode",
2050 if (hook->mute_mode != HDA_VMUTE_FOLLOW_MASTER) in vmaster_hook()
2051 enabled = hook->mute_mode; in vmaster_hook()
2052 hook->hook(hook->codec, enabled); in vmaster_hook()
2056 * snd_hda_add_vmaster_hook - Add a vmaster hook for mute-LED
2061 * Add a mute-LED hook with the given vmaster switch kctl.
2062 * When @expose_enum_ctl is set, "Mute-LED Mode" control is automatically
2071 if (!hook->hook || !hook->sw_kctl) in snd_hda_add_vmaster_hook()
2073 hook->codec = codec; in snd_hda_add_vmaster_hook()
2074 hook->mute_mode = HDA_VMUTE_FOLLOW_MASTER; in snd_hda_add_vmaster_hook()
2075 snd_ctl_add_vmaster_hook(hook->sw_kctl, vmaster_hook, hook); in snd_hda_add_vmaster_hook()
2080 return -ENOMEM; in snd_hda_add_vmaster_hook()
2086 * snd_hda_sync_vmaster_hook - Sync vmaster hook
2094 if (!hook->hook || !hook->codec) in snd_hda_sync_vmaster_hook()
2099 if (hook->codec->bus->shutdown) in snd_hda_sync_vmaster_hook()
2101 snd_ctl_sync_vmaster_hook(hook->sw_kctl); in snd_hda_sync_vmaster_hook()
2107 * snd_hda_mixer_amp_switch_info - Info callback for a standard AMP mixer switch
2119 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_hda_mixer_amp_switch_info()
2120 uinfo->count = chs == 3 ? 2 : 1; in snd_hda_mixer_amp_switch_info()
2121 uinfo->value.integer.min = 0; in snd_hda_mixer_amp_switch_info()
2122 uinfo->value.integer.max = 1; in snd_hda_mixer_amp_switch_info()
2128 * snd_hda_mixer_amp_switch_get - Get callback for a standard AMP mixer switch
2143 long *valp = ucontrol->value.integer.value; in snd_hda_mixer_amp_switch_get()
2156 * snd_hda_mixer_amp_switch_put - Put callback for a standard AMP mixer switch
2171 long *valp = ucontrol->value.integer.value; in snd_hda_mixer_amp_switch_put()
2190 * SPDIF out controls
2196 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_hda_spdif_mask_info()
2197 uinfo->count = 1; in snd_hda_spdif_mask_info()
2204 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | in snd_hda_spdif_cmask_get()
2208 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY | in snd_hda_spdif_cmask_get()
2216 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | in snd_hda_spdif_pmask_get()
2226 int idx = kcontrol->private_value; in snd_hda_spdif_default_get()
2227 struct hda_spdif_out *spdif; in snd_hda_spdif_default_get() local
2229 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_default_get()
2230 return -EINVAL; in snd_hda_spdif_default_get()
2231 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_default_get()
2232 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_default_get()
2233 ucontrol->value.iec958.status[0] = spdif->status & 0xff; in snd_hda_spdif_default_get()
2234 ucontrol->value.iec958.status[1] = (spdif->status >> 8) & 0xff; in snd_hda_spdif_default_get()
2235 ucontrol->value.iec958.status[2] = (spdif->status >> 16) & 0xff; in snd_hda_spdif_default_get()
2236 ucontrol->value.iec958.status[3] = (spdif->status >> 24) & 0xff; in snd_hda_spdif_default_get()
2237 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_default_get()
2242 /* convert from SPDIF status bits to HDA SPDIF bits
2270 /* convert to SPDIF status bits from HDA SPDIF bits
2301 snd_hdac_regmap_update(&codec->core, nid, AC_VERB_SET_DIGI_CONVERT_1, in set_dig_out()
2303 d = codec->follower_dig_outs; in set_dig_out()
2307 snd_hdac_regmap_update(&codec->core, *d, in set_dig_out()
2317 if (dig1 != -1) { in set_dig_out_convert()
2321 if (dig2 != -1) { in set_dig_out_convert()
2332 int idx = kcontrol->private_value; in snd_hda_spdif_default_put()
2333 struct hda_spdif_out *spdif; in snd_hda_spdif_default_put() local
2338 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_default_put()
2339 return -EINVAL; in snd_hda_spdif_default_put()
2340 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_default_put()
2341 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_default_put()
2342 nid = spdif->nid; in snd_hda_spdif_default_put()
2343 spdif->status = ucontrol->value.iec958.status[0] | in snd_hda_spdif_default_put()
2344 ((unsigned int)ucontrol->value.iec958.status[1] << 8) | in snd_hda_spdif_default_put()
2345 ((unsigned int)ucontrol->value.iec958.status[2] << 16) | in snd_hda_spdif_default_put()
2346 ((unsigned int)ucontrol->value.iec958.status[3] << 24); in snd_hda_spdif_default_put()
2347 val = convert_from_spdif_status(spdif->status); in snd_hda_spdif_default_put()
2348 val |= spdif->ctls & 1; in snd_hda_spdif_default_put()
2349 change = spdif->ctls != val; in snd_hda_spdif_default_put()
2350 spdif->ctls = val; in snd_hda_spdif_default_put()
2351 if (change && nid != (u16)-1) in snd_hda_spdif_default_put()
2353 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_default_put()
2363 int idx = kcontrol->private_value; in snd_hda_spdif_out_switch_get()
2364 struct hda_spdif_out *spdif; in snd_hda_spdif_out_switch_get() local
2366 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_out_switch_get()
2367 return -EINVAL; in snd_hda_spdif_out_switch_get()
2368 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_get()
2369 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_out_switch_get()
2370 ucontrol->value.integer.value[0] = spdif->ctls & AC_DIG1_ENABLE; in snd_hda_spdif_out_switch_get()
2371 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_get()
2390 int idx = kcontrol->private_value; in snd_hda_spdif_out_switch_put()
2391 struct hda_spdif_out *spdif; in snd_hda_spdif_out_switch_put() local
2396 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_out_switch_put()
2397 return -EINVAL; in snd_hda_spdif_out_switch_put()
2398 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_put()
2399 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_out_switch_put()
2400 nid = spdif->nid; in snd_hda_spdif_out_switch_put()
2401 val = spdif->ctls & ~AC_DIG1_ENABLE; in snd_hda_spdif_out_switch_put()
2402 if (ucontrol->value.integer.value[0]) in snd_hda_spdif_out_switch_put()
2404 change = spdif->ctls != val; in snd_hda_spdif_out_switch_put()
2405 spdif->ctls = val; in snd_hda_spdif_out_switch_put()
2406 if (change && nid != (u16)-1) in snd_hda_spdif_out_switch_put()
2407 set_spdif_ctls(codec, nid, val & 0xff, -1); in snd_hda_spdif_out_switch_put()
2408 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_put()
2445 * snd_hda_create_dig_out_ctls - create Output SPDIF-related controls
2466 struct hda_spdif_out *spdif; in snd_hda_create_dig_out_ctls() local
2467 struct hda_bus *bus = codec->bus; in snd_hda_create_dig_out_ctls()
2469 if (bus->primary_dig_out_type == HDA_PCM_TYPE_HDMI && in snd_hda_create_dig_out_ctls()
2472 } else if (bus->primary_dig_out_type == HDA_PCM_TYPE_SPDIF && in snd_hda_create_dig_out_ctls()
2474 /* suppose a single SPDIF device */ in snd_hda_create_dig_out_ctls()
2475 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { in snd_hda_create_dig_out_ctls()
2476 kctl = find_mixer_ctl(codec, dig_mix->name, 0, 0); in snd_hda_create_dig_out_ctls()
2479 kctl->id.index = spdif_index; in snd_hda_create_dig_out_ctls()
2481 bus->primary_dig_out_type = HDA_PCM_TYPE_HDMI; in snd_hda_create_dig_out_ctls()
2483 if (!bus->primary_dig_out_type) in snd_hda_create_dig_out_ctls()
2484 bus->primary_dig_out_type = type; in snd_hda_create_dig_out_ctls()
2489 return -EBUSY; in snd_hda_create_dig_out_ctls()
2491 spdif = snd_array_new(&codec->spdif_out); in snd_hda_create_dig_out_ctls()
2492 if (!spdif) in snd_hda_create_dig_out_ctls()
2493 return -ENOMEM; in snd_hda_create_dig_out_ctls()
2494 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { in snd_hda_create_dig_out_ctls()
2497 return -ENOMEM; in snd_hda_create_dig_out_ctls()
2498 kctl->id.index = idx; in snd_hda_create_dig_out_ctls()
2499 kctl->private_value = codec->spdif_out.used - 1; in snd_hda_create_dig_out_ctls()
2504 spdif->nid = cvt_nid; in snd_hda_create_dig_out_ctls()
2505 snd_hdac_regmap_read(&codec->core, cvt_nid, in snd_hda_create_dig_out_ctls()
2507 spdif->ctls = val; in snd_hda_create_dig_out_ctls()
2508 spdif->status = convert_to_spdif_status(spdif->ctls); in snd_hda_create_dig_out_ctls()
2514 * snd_hda_spdif_out_of_nid - get the hda_spdif_out entry from the given NID
2523 struct hda_spdif_out *spdif; in snd_hda_spdif_out_of_nid() local
2526 snd_array_for_each(&codec->spdif_out, i, spdif) { in snd_hda_spdif_out_of_nid()
2527 if (spdif->nid == nid) in snd_hda_spdif_out_of_nid()
2528 return spdif; in snd_hda_spdif_out_of_nid()
2535 * snd_hda_spdif_ctls_unassign - Unassign the given SPDIF ctl
2537 * @idx: the SPDIF ctl index
2539 * Unassign the widget from the given SPDIF control.
2543 struct hda_spdif_out *spdif; in snd_hda_spdif_ctls_unassign() local
2545 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_ctls_unassign()
2547 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_ctls_unassign()
2548 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_ctls_unassign()
2549 spdif->nid = (u16)-1; in snd_hda_spdif_ctls_unassign()
2550 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_ctls_unassign()
2555 * snd_hda_spdif_ctls_assign - Assign the SPDIF controls to the given NID
2557 * @idx: the SPDIF ctl idx
2560 * Assign the widget to the SPDIF control with the given index.
2564 struct hda_spdif_out *spdif; in snd_hda_spdif_ctls_assign() local
2567 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_ctls_assign()
2569 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_ctls_assign()
2570 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_ctls_assign()
2571 if (spdif->nid != nid) { in snd_hda_spdif_ctls_assign()
2572 spdif->nid = nid; in snd_hda_spdif_ctls_assign()
2573 val = spdif->ctls; in snd_hda_spdif_ctls_assign()
2576 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_ctls_assign()
2581 * SPDIF sharing with analog output
2587 ucontrol->value.integer.value[0] = mout->share_spdif; in spdif_share_sw_get()
2595 mout->share_spdif = !!ucontrol->value.integer.value[0]; in spdif_share_sw_put()
2608 * snd_hda_create_spdif_share_sw - create Default PCM switch
2610 * @mout: multi-out instance
2617 if (!mout->dig_out_nid) in snd_hda_create_spdif_share_sw()
2622 return -ENOMEM; in snd_hda_create_spdif_share_sw()
2624 return snd_hda_ctl_add(codec, mout->dig_out_nid, kctl); in snd_hda_create_spdif_share_sw()
2629 * SPDIF input
2639 ucontrol->value.integer.value[0] = codec->spdif_in_enable; in snd_hda_spdif_in_switch_get()
2647 hda_nid_t nid = kcontrol->private_value; in snd_hda_spdif_in_switch_put()
2648 unsigned int val = !!ucontrol->value.integer.value[0]; in snd_hda_spdif_in_switch_put()
2651 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_in_switch_put()
2652 change = codec->spdif_in_enable != val; in snd_hda_spdif_in_switch_put()
2654 codec->spdif_in_enable = val; in snd_hda_spdif_in_switch_put()
2655 snd_hdac_regmap_write(&codec->core, nid, in snd_hda_spdif_in_switch_put()
2658 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_in_switch_put()
2666 hda_nid_t nid = kcontrol->private_value; in snd_hda_spdif_in_status_get()
2670 snd_hdac_regmap_read(&codec->core, nid, in snd_hda_spdif_in_status_get()
2673 ucontrol->value.iec958.status[0] = sbits; in snd_hda_spdif_in_status_get()
2674 ucontrol->value.iec958.status[1] = sbits >> 8; in snd_hda_spdif_in_status_get()
2675 ucontrol->value.iec958.status[2] = sbits >> 16; in snd_hda_spdif_in_status_get()
2676 ucontrol->value.iec958.status[3] = sbits >> 24; in snd_hda_spdif_in_status_get()
2699 * snd_hda_create_spdif_in_ctls - create Input SPDIF-related controls
2703 * Creates controls related with the SPDIF input.
2704 * Called from each patch supporting the SPDIF in.
2718 return -EBUSY; in snd_hda_create_spdif_in_ctls()
2720 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { in snd_hda_create_spdif_in_ctls()
2723 return -ENOMEM; in snd_hda_create_spdif_in_ctls()
2724 kctl->private_value = nid; in snd_hda_create_spdif_in_ctls()
2729 codec->spdif_in_enable = in snd_hda_create_spdif_in_ctls()
2738 * snd_hda_codec_set_power_to_all - Set the power state to all widgets
2757 if (codec->power_filter) { in snd_hda_codec_set_power_to_all()
2758 state = codec->power_filter(codec, nid, power_state); in snd_hda_codec_set_power_to_all()
2769 * snd_hda_codec_eapd_power_filter - A power filter callback for EAPD
2781 if (nid == codec->core.afg || nid == codec->core.mfg) in snd_hda_codec_eapd_power_filter()
2801 hda_nid_t fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in hda_set_power_state()
2806 /* this delay seems necessary to avoid click noise at power-down */ in hda_set_power_state()
2808 if (codec->depop_delay < 0) in hda_set_power_state()
2810 else if (codec->depop_delay > 0) in hda_set_power_state()
2811 msleep(codec->depop_delay); in hda_set_power_state()
2817 if (codec->patch_ops.set_power_state) in hda_set_power_state()
2818 codec->patch_ops.set_power_state(codec, fg, in hda_set_power_state()
2822 if (codec->power_filter) in hda_set_power_state()
2823 state = codec->power_filter(codec, fg, state); in hda_set_power_state()
2846 if (!codec->power_filter) in sync_power_up_states()
2854 target = codec->power_filter(codec, nid, AC_PWRST_D0); in sync_power_up_states()
2867 if (codec->init_verbs.list) in hda_exec_init_verbs()
2868 snd_hda_sequence_write(codec, codec->init_verbs.list); in hda_exec_init_verbs()
2878 unsigned long delta = jiffies - codec->power_jiffies; in update_power_acct()
2881 codec->power_on_acct += delta; in update_power_acct()
2883 codec->power_off_acct += delta; in update_power_acct()
2884 codec->power_jiffies += delta; in update_power_acct()
2893 * call suspend and power-down; used both from PM and power-save
2900 snd_hdac_enter_pm(&codec->core); in hda_call_codec_suspend()
2901 if (codec->patch_ops.suspend) in hda_call_codec_suspend()
2902 codec->patch_ops.suspend(codec); in hda_call_codec_suspend()
2906 snd_hdac_leave_pm(&codec->core); in hda_call_codec_suspend()
2911 * kick up codec; used both from PM and power-save
2915 snd_hdac_enter_pm(&codec->core); in hda_call_codec_resume()
2916 if (codec->core.regmap) in hda_call_codec_resume()
2917 regcache_mark_dirty(codec->core.regmap); in hda_call_codec_resume()
2919 codec->power_jiffies = jiffies; in hda_call_codec_resume()
2925 if (codec->patch_ops.resume) in hda_call_codec_resume()
2926 codec->patch_ops.resume(codec); in hda_call_codec_resume()
2928 if (codec->patch_ops.init) in hda_call_codec_resume()
2929 codec->patch_ops.init(codec); in hda_call_codec_resume()
2933 if (codec->jackpoll_interval) in hda_call_codec_resume()
2934 hda_jackpoll_work(&codec->jackpoll_work.work); in hda_call_codec_resume()
2937 codec->core.dev.power.power_state = PMSG_ON; in hda_call_codec_resume()
2938 snd_hdac_leave_pm(&codec->core); in hda_call_codec_resume()
2947 if (!codec->card) in hda_codec_runtime_suspend()
2950 cancel_delayed_work_sync(&codec->jackpoll_work); in hda_codec_runtime_suspend()
2952 if (codec->link_down_at_suspend || in hda_codec_runtime_suspend()
2955 snd_hdac_codec_link_down(&codec->core); in hda_codec_runtime_suspend()
2965 if (!codec->card) in hda_codec_runtime_resume()
2969 snd_hdac_codec_link_up(&codec->core); in hda_codec_runtime_resume()
2980 dev->power.power_state = PMSG_SUSPEND; in hda_codec_pm_prepare()
2988 /* If no other pm-functions are called between prepare() and complete() */ in hda_codec_pm_complete()
2989 if (dev->power.power_state.event == PM_EVENT_SUSPEND) in hda_codec_pm_complete()
2990 dev->power.power_state = PMSG_RESUME; in hda_codec_pm_complete()
2992 if (pm_runtime_suspended(dev) && (codec->jackpoll_interval || in hda_codec_pm_complete()
2993 hda_codec_need_resume(codec) || codec->forced_resume)) in hda_codec_pm_complete()
2999 dev->power.power_state = PMSG_SUSPEND; in hda_codec_pm_suspend()
3005 dev->power.power_state = PMSG_RESUME; in hda_codec_pm_resume()
3011 dev->power.power_state = PMSG_FREEZE; in hda_codec_pm_freeze()
3017 dev->power.power_state = PMSG_THAW; in hda_codec_pm_thaw()
3023 dev->power.power_state = PMSG_RESTORE; in hda_codec_pm_restore()
3052 list_for_each_entry(pcm, &codec->pcm_list_head, list) { in add_std_chmaps()
3054 struct hda_pcm_stream *hinfo = &pcm->stream[str]; in add_std_chmaps()
3058 if (!pcm->pcm || pcm->own_chmap || !hinfo->substreams) in add_std_chmaps()
3060 elem = hinfo->chmap ? hinfo->chmap : snd_pcm_std_chmaps; in add_std_chmaps()
3061 err = snd_pcm_add_chmap_ctls(pcm->pcm, str, elem, in add_std_chmaps()
3062 hinfo->channels_max, in add_std_chmaps()
3066 chmap->channel_mask = SND_PCM_CHMAP_MASK_2468; in add_std_chmaps()
3073 * since HD-audio supports only stereo, odd number channels are omitted
3090 if (codec->patch_ops.init) in snd_hda_codec_build_controls()
3091 err = codec->patch_ops.init(codec); in snd_hda_codec_build_controls()
3092 if (!err && codec->patch_ops.build_controls) in snd_hda_codec_build_controls()
3093 err = codec->patch_ops.build_controls(codec); in snd_hda_codec_build_controls()
3102 if (codec->jackpoll_interval) in snd_hda_codec_build_controls()
3103 hda_jackpoll_work(&codec->jackpoll_work.work); in snd_hda_codec_build_controls()
3127 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in hda_pcm_default_prepare()
3135 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in hda_pcm_default_cleanup()
3145 if (info->nid && (!info->rates || !info->formats)) { in set_pcm_default_values()
3146 err = snd_hda_query_supported_pcm(codec, info->nid, in set_pcm_default_values()
3147 info->rates ? NULL : &info->rates, in set_pcm_default_values()
3148 info->formats ? NULL : &info->formats, in set_pcm_default_values()
3149 info->maxbps ? NULL : &info->maxbps); in set_pcm_default_values()
3153 if (info->ops.open == NULL) in set_pcm_default_values()
3154 info->ops.open = hda_pcm_default_open_close; in set_pcm_default_values()
3155 if (info->ops.close == NULL) in set_pcm_default_values()
3156 info->ops.close = hda_pcm_default_open_close; in set_pcm_default_values()
3157 if (info->ops.prepare == NULL) { in set_pcm_default_values()
3158 if (snd_BUG_ON(!info->nid)) in set_pcm_default_values()
3159 return -EINVAL; in set_pcm_default_values()
3160 info->ops.prepare = hda_pcm_default_prepare; in set_pcm_default_values()
3162 if (info->ops.cleanup == NULL) { in set_pcm_default_values()
3163 if (snd_BUG_ON(!info->nid)) in set_pcm_default_values()
3164 return -EINVAL; in set_pcm_default_values()
3165 info->ops.cleanup = hda_pcm_default_cleanup; in set_pcm_default_values()
3174 * snd_hda_codec_prepare - Prepare a stream
3191 mutex_lock(&codec->bus->prepare_mutex); in snd_hda_codec_prepare()
3192 if (hinfo->ops.prepare) in snd_hda_codec_prepare()
3193 ret = hinfo->ops.prepare(hinfo, codec, stream, format, in snd_hda_codec_prepare()
3196 ret = -ENODEV; in snd_hda_codec_prepare()
3199 mutex_unlock(&codec->bus->prepare_mutex); in snd_hda_codec_prepare()
3205 * snd_hda_codec_cleanup - Clean up stream resources
3216 mutex_lock(&codec->bus->prepare_mutex); in snd_hda_codec_cleanup()
3217 if (hinfo->ops.cleanup) in snd_hda_codec_cleanup()
3218 hinfo->ops.cleanup(hinfo, codec, substream); in snd_hda_codec_cleanup()
3219 mutex_unlock(&codec->bus->prepare_mutex); in snd_hda_codec_cleanup()
3225 "Audio", "SPDIF", "HDMI", "Modem"
3238 [HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 }, in get_empty_pcm_device()
3239 [HDA_PCM_TYPE_SPDIF] = { 1, -1 }, in get_empty_pcm_device()
3240 [HDA_PCM_TYPE_HDMI] = { 3, 7, 8, 9, -1 }, in get_empty_pcm_device()
3241 [HDA_PCM_TYPE_MODEM] = { 6, -1 }, in get_empty_pcm_device()
3246 dev_err(bus->card->dev, "Invalid PCM type %d\n", type); in get_empty_pcm_device()
3247 return -EINVAL; in get_empty_pcm_device()
3255 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) in get_empty_pcm_device()
3260 /* non-fixed slots starting from 10 */ in get_empty_pcm_device()
3262 if (!test_and_set_bit(i, bus->pcm_dev_bits)) in get_empty_pcm_device()
3267 dev_warn(bus->card->dev, "Too many %s devices\n", in get_empty_pcm_device()
3270 dev_warn(bus->card->dev, in get_empty_pcm_device()
3273 return -EAGAIN; in get_empty_pcm_device()
3282 if (!list_empty(&codec->pcm_list_head)) in snd_hda_codec_parse_pcms()
3285 if (!codec->patch_ops.build_pcms) in snd_hda_codec_parse_pcms()
3288 err = codec->patch_ops.build_pcms(codec); in snd_hda_codec_parse_pcms()
3291 codec->core.addr, err); in snd_hda_codec_parse_pcms()
3295 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_codec_parse_pcms()
3299 struct hda_pcm_stream *info = &cpcm->stream[stream]; in snd_hda_codec_parse_pcms()
3301 if (!info->substreams) in snd_hda_codec_parse_pcms()
3307 cpcm->name); in snd_hda_codec_parse_pcms()
3320 struct hda_bus *bus = codec->bus; in snd_hda_codec_build_pcms()
3329 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_codec_build_pcms()
3330 if (cpcm->pcm) in snd_hda_codec_build_pcms()
3332 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams) in snd_hda_codec_build_pcms()
3335 dev = get_empty_pcm_device(bus, cpcm->pcm_type); in snd_hda_codec_build_pcms()
3337 cpcm->device = SNDRV_PCM_INVALID_DEVICE; in snd_hda_codec_build_pcms()
3340 cpcm->device = dev; in snd_hda_codec_build_pcms()
3345 dev, codec->core.addr); in snd_hda_codec_build_pcms()
3354 * snd_hda_add_new_ctls - create controls from the array
3368 for (; knew->name; knew++) { in snd_hda_add_new_ctls()
3371 if (knew->iface == (__force snd_ctl_elem_iface_t)-1) in snd_hda_add_new_ctls()
3376 return -ENOMEM; in snd_hda_add_new_ctls()
3378 kctl->id.device = addr; in snd_hda_add_new_ctls()
3380 kctl->id.index = idx; in snd_hda_add_new_ctls()
3388 if (!addr && codec->core.addr) in snd_hda_add_new_ctls()
3389 addr = codec->core.addr; in snd_hda_add_new_ctls()
3390 else if (!idx && !knew->index) { in snd_hda_add_new_ctls()
3392 knew->name, 0); in snd_hda_add_new_ctls()
3408 if (delay == 0 && codec->auto_runtime_pm) in codec_set_power_save()
3424 * snd_hda_set_power_save - reprogram autosuspend for the given delay
3425 * @bus: HD-audio bus
3440 * snd_hda_check_amp_list_power - Check the amp list and update the power
3441 * @codec: HD-audio codec
3446 * check the current AMP status, and update the power-status according
3459 if (!check->amplist) in snd_hda_check_amp_list_power()
3461 for (p = check->amplist; p->nid; p++) { in snd_hda_check_amp_list_power()
3462 if (p->nid == nid) in snd_hda_check_amp_list_power()
3465 if (!p->nid) in snd_hda_check_amp_list_power()
3468 for (p = check->amplist; p->nid; p++) { in snd_hda_check_amp_list_power()
3470 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, in snd_hda_check_amp_list_power()
3471 p->idx); in snd_hda_check_amp_list_power()
3473 if (!check->power_on) { in snd_hda_check_amp_list_power()
3474 check->power_on = 1; in snd_hda_check_amp_list_power()
3481 if (check->power_on) { in snd_hda_check_amp_list_power()
3482 check->power_on = 0; in snd_hda_check_amp_list_power()
3495 * snd_hda_input_mux_info_info - Info callback helper for the input-mux enum
3504 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in snd_hda_input_mux_info()
3505 uinfo->count = 1; in snd_hda_input_mux_info()
3506 uinfo->value.enumerated.items = imux->num_items; in snd_hda_input_mux_info()
3507 if (!imux->num_items) in snd_hda_input_mux_info()
3509 index = uinfo->value.enumerated.item; in snd_hda_input_mux_info()
3510 if (index >= imux->num_items) in snd_hda_input_mux_info()
3511 index = imux->num_items - 1; in snd_hda_input_mux_info()
3512 strcpy(uinfo->value.enumerated.name, imux->items[index].label); in snd_hda_input_mux_info()
3518 * snd_hda_input_mux_info_put - Put callback helper for the input-mux enum
3533 if (!imux->num_items) in snd_hda_input_mux_put()
3535 idx = ucontrol->value.enumerated.item[0]; in snd_hda_input_mux_put()
3536 if (idx >= imux->num_items) in snd_hda_input_mux_put()
3537 idx = imux->num_items - 1; in snd_hda_input_mux_put()
3541 imux->items[idx].index); in snd_hda_input_mux_put()
3549 * snd_hda_enum_helper_info - Helper for simple enum ctls
3576 * Multi-channel / digital-out PCM helper functions
3579 /* setup SPDIF output stream */
3583 struct hda_spdif_out *spdif; in setup_dig_out_stream() local
3587 spdif = snd_hda_spdif_out_of_nid(codec, nid); in setup_dig_out_stream()
3591 if (WARN_ON(spdif == NULL)) in setup_dig_out_stream()
3596 reset = codec->spdif_status_reset && in setup_dig_out_stream()
3597 (spdif->ctls & AC_DIG1_ENABLE) && in setup_dig_out_stream()
3600 /* turn off SPDIF if needed; otherwise the IEC958 bits won't be in setup_dig_out_stream()
3604 spdif->ctls & ~AC_DIG1_ENABLE & 0xff, in setup_dig_out_stream()
3605 -1); in setup_dig_out_stream()
3607 if (codec->follower_dig_outs) { in setup_dig_out_stream()
3609 for (d = codec->follower_dig_outs; *d; d++) in setup_dig_out_stream()
3616 spdif->ctls & 0xff, -1); in setup_dig_out_stream()
3622 if (codec->follower_dig_outs) { in cleanup_dig_out_stream()
3624 for (d = codec->follower_dig_outs; *d; d++) in cleanup_dig_out_stream()
3630 * snd_hda_multi_out_dig_open - open the digital out in the exclusive mode
3637 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_open()
3638 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP) in snd_hda_multi_out_dig_open()
3640 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_dig_open()
3641 mout->dig_out_used = HDA_DIG_EXCLUSIVE; in snd_hda_multi_out_dig_open()
3642 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_open()
3648 * snd_hda_multi_out_dig_prepare - prepare the digital out stream
3661 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_prepare()
3662 setup_dig_out_stream(codec, mout->dig_out_nid, stream_tag, format); in snd_hda_multi_out_dig_prepare()
3663 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_prepare()
3669 * snd_hda_multi_out_dig_cleanup - clean-up the digital out stream
3676 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_cleanup()
3677 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_dig_cleanup()
3678 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_cleanup()
3684 * snd_hda_multi_out_dig_close - release the digital out stream
3691 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_close()
3692 mout->dig_out_used = 0; in snd_hda_multi_out_dig_close()
3693 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_close()
3699 * snd_hda_multi_out_analog_open - open analog outputs
3705 * Open analog outputs and set up the hw-constraints.
3714 struct snd_pcm_runtime *runtime = substream->runtime; in snd_hda_multi_out_analog_open()
3715 runtime->hw.channels_max = mout->max_channels; in snd_hda_multi_out_analog_open()
3716 if (mout->dig_out_nid) { in snd_hda_multi_out_analog_open()
3717 if (!mout->analog_rates) { in snd_hda_multi_out_analog_open()
3718 mout->analog_rates = hinfo->rates; in snd_hda_multi_out_analog_open()
3719 mout->analog_formats = hinfo->formats; in snd_hda_multi_out_analog_open()
3720 mout->analog_maxbps = hinfo->maxbps; in snd_hda_multi_out_analog_open()
3722 runtime->hw.rates = mout->analog_rates; in snd_hda_multi_out_analog_open()
3723 runtime->hw.formats = mout->analog_formats; in snd_hda_multi_out_analog_open()
3724 hinfo->maxbps = mout->analog_maxbps; in snd_hda_multi_out_analog_open()
3726 if (!mout->spdif_rates) { in snd_hda_multi_out_analog_open()
3727 snd_hda_query_supported_pcm(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_open()
3728 &mout->spdif_rates, in snd_hda_multi_out_analog_open()
3729 &mout->spdif_formats, in snd_hda_multi_out_analog_open()
3730 &mout->spdif_maxbps); in snd_hda_multi_out_analog_open()
3732 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_open()
3733 if (mout->share_spdif) { in snd_hda_multi_out_analog_open()
3734 if ((runtime->hw.rates & mout->spdif_rates) && in snd_hda_multi_out_analog_open()
3735 (runtime->hw.formats & mout->spdif_formats)) { in snd_hda_multi_out_analog_open()
3736 runtime->hw.rates &= mout->spdif_rates; in snd_hda_multi_out_analog_open()
3737 runtime->hw.formats &= mout->spdif_formats; in snd_hda_multi_out_analog_open()
3738 if (mout->spdif_maxbps < hinfo->maxbps) in snd_hda_multi_out_analog_open()
3739 hinfo->maxbps = mout->spdif_maxbps; in snd_hda_multi_out_analog_open()
3741 mout->share_spdif = 0; in snd_hda_multi_out_analog_open()
3745 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_open()
3747 return snd_pcm_hw_constraint_step(substream->runtime, 0, in snd_hda_multi_out_analog_open()
3753 * snd_hda_multi_out_analog_prepare - Preapre the analog outputs.
3769 const hda_nid_t *nids = mout->dac_nids; in snd_hda_multi_out_analog_prepare()
3770 int chs = substream->runtime->channels; in snd_hda_multi_out_analog_prepare()
3771 struct hda_spdif_out *spdif; in snd_hda_multi_out_analog_prepare() local
3774 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_prepare()
3775 spdif = snd_hda_spdif_out_of_nid(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_prepare()
3776 if (mout->dig_out_nid && mout->share_spdif && in snd_hda_multi_out_analog_prepare()
3777 mout->dig_out_used != HDA_DIG_EXCLUSIVE) { in snd_hda_multi_out_analog_prepare()
3778 if (chs == 2 && spdif != NULL && in snd_hda_multi_out_analog_prepare()
3779 snd_hda_is_supported_format(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_prepare()
3781 !(spdif->status & IEC958_AES0_NONAUDIO)) { in snd_hda_multi_out_analog_prepare()
3782 mout->dig_out_used = HDA_DIG_ANALOG_DUP; in snd_hda_multi_out_analog_prepare()
3783 setup_dig_out_stream(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_prepare()
3786 mout->dig_out_used = 0; in snd_hda_multi_out_analog_prepare()
3787 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_prepare()
3790 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_prepare()
3795 if (!mout->no_share_stream && in snd_hda_multi_out_analog_prepare()
3796 mout->hp_nid && mout->hp_nid != nids[HDA_FRONT]) in snd_hda_multi_out_analog_prepare()
3798 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, in snd_hda_multi_out_analog_prepare()
3801 for (i = 0; i < ARRAY_SIZE(mout->hp_out_nid); i++) in snd_hda_multi_out_analog_prepare()
3802 if (!mout->no_share_stream && mout->hp_out_nid[i]) in snd_hda_multi_out_analog_prepare()
3804 mout->hp_out_nid[i], in snd_hda_multi_out_analog_prepare()
3808 for (i = 1; i < mout->num_dacs; i++) { in snd_hda_multi_out_analog_prepare()
3812 else if (!mout->no_share_stream) /* copy front */ in snd_hda_multi_out_analog_prepare()
3818 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) { in snd_hda_multi_out_analog_prepare()
3820 if (!mout->extra_out_nid[i]) in snd_hda_multi_out_analog_prepare()
3824 else if (!mout->no_share_stream) in snd_hda_multi_out_analog_prepare()
3826 snd_hda_codec_setup_stream(codec, mout->extra_out_nid[i], in snd_hda_multi_out_analog_prepare()
3835 * snd_hda_multi_out_analog_cleanup - clean up the setting for analog out
3842 const hda_nid_t *nids = mout->dac_nids; in snd_hda_multi_out_analog_cleanup()
3845 for (i = 0; i < mout->num_dacs; i++) in snd_hda_multi_out_analog_cleanup()
3847 if (mout->hp_nid) in snd_hda_multi_out_analog_cleanup()
3848 snd_hda_codec_cleanup_stream(codec, mout->hp_nid); in snd_hda_multi_out_analog_cleanup()
3849 for (i = 0; i < ARRAY_SIZE(mout->hp_out_nid); i++) in snd_hda_multi_out_analog_cleanup()
3850 if (mout->hp_out_nid[i]) in snd_hda_multi_out_analog_cleanup()
3852 mout->hp_out_nid[i]); in snd_hda_multi_out_analog_cleanup()
3853 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) in snd_hda_multi_out_analog_cleanup()
3854 if (mout->extra_out_nid[i]) in snd_hda_multi_out_analog_cleanup()
3856 mout->extra_out_nid[i]); in snd_hda_multi_out_analog_cleanup()
3857 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_cleanup()
3858 if (mout->dig_out_nid && mout->dig_out_used == HDA_DIG_ANALOG_DUP) { in snd_hda_multi_out_analog_cleanup()
3859 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_cleanup()
3860 mout->dig_out_used = 0; in snd_hda_multi_out_analog_cleanup()
3862 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_cleanup()
3868 * snd_hda_get_default_vref - Get the default (mic) VREF pin bits
3872 * Guess the suitable VREF pin bits to be set as the pin-control value.
3897 * snd_hda_correct_pin_ctl - correct the pin ctl value for matching with the pin cap
3937 if (i == ARRAY_SIZE(cap_lists) - 1) in snd_hda_correct_pin_ctl()
3953 * _snd_hda_pin_ctl - Helper to set pin ctl value
3980 * snd_hda_add_imux_item - Add an item to input_mux
3989 * to type_idx when non-NULL pointer is given.
3996 if (imux->num_items >= HDA_MAX_NUM_INPUTS) { in snd_hda_add_imux_item()
3998 return -EINVAL; in snd_hda_add_imux_item()
4000 for (i = 0; i < imux->num_items; i++) { in snd_hda_add_imux_item()
4001 if (!strncmp(label, imux->items[i].label, strlen(label))) in snd_hda_add_imux_item()
4007 snprintf(imux->items[imux->num_items].label, in snd_hda_add_imux_item()
4008 sizeof(imux->items[imux->num_items].label), in snd_hda_add_imux_item()
4011 strlcpy(imux->items[imux->num_items].label, label, in snd_hda_add_imux_item()
4012 sizeof(imux->items[imux->num_items].label)); in snd_hda_add_imux_item()
4013 imux->items[imux->num_items].index = index; in snd_hda_add_imux_item()
4014 imux->num_items++; in snd_hda_add_imux_item()
4020 * snd_hda_bus_reset_codecs - Reset the bus
4021 * @bus: HD-audio bus
4029 if (current_work() != &codec->jackpoll_work.work) in snd_hda_bus_reset_codecs()
4030 cancel_delayed_work_sync(&codec->jackpoll_work); in snd_hda_bus_reset_codecs()
4041 * snd_print_pcm_bits - Print the supported PCM fmt bits to the string buffer
4055 j += scnprintf(buf + j, buflen - j, " %d", bits[i]); in snd_print_pcm_bits()