• Home
  • Raw
  • Download

Lines Matching full:codec

2  * Universal Interface for Intel High Definition Audio Codec
40 #define codec_in_pm(codec) snd_hdac_is_in_pm(&codec->core) argument
41 #define hda_codec_is_power_on(codec) snd_hdac_is_power_on(&codec->core) argument
42 #define codec_has_epss(codec) \ argument
43 ((codec)->core.power_caps & AC_PWRST_EPSS)
44 #define codec_has_clkstop(codec) \ argument
45 ((codec)->core.power_caps & AC_PWRST_CLKSTOP)
53 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in codec_exec_verb() local
54 struct hda_bus *bus = codec->bus; in codec_exec_verb()
61 snd_hda_power_up_pm(codec); in codec_exec_verb()
65 err = snd_hdac_bus_exec_verb_unlocked(&bus->core, codec->core.addr, in codec_exec_verb()
69 snd_hda_power_down_pm(codec); in codec_exec_verb()
70 if (!codec_in_pm(codec) && res && err == -EAGAIN) { in codec_exec_verb()
72 codec_dbg(codec, in codec_exec_verb()
79 if (!err || codec_in_pm(codec)) in codec_exec_verb()
86 * @codec: the HDA codec
92 void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq) in snd_hda_sequence_write() argument
95 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param); in snd_hda_sequence_write()
109 lookup_conn_list(struct hda_codec *codec, hda_nid_t nid) in lookup_conn_list() argument
112 list_for_each_entry(p, &codec->conn_list, list) { in lookup_conn_list()
119 static int add_conn_list(struct hda_codec *codec, hda_nid_t nid, int len, in add_conn_list() argument
130 list_add(&p->list, &codec->conn_list); in add_conn_list()
134 static void remove_conn_list(struct hda_codec *codec) in remove_conn_list() argument
136 while (!list_empty(&codec->conn_list)) { in remove_conn_list()
138 p = list_first_entry(&codec->conn_list, typeof(*p), list); in remove_conn_list()
145 static int read_and_add_raw_conns(struct hda_codec *codec, hda_nid_t nid) in read_and_add_raw_conns() argument
151 len = snd_hda_get_raw_connections(codec, nid, list, ARRAY_SIZE(list)); in read_and_add_raw_conns()
153 len = snd_hda_get_num_raw_conns(codec, nid); in read_and_add_raw_conns()
157 len = snd_hda_get_raw_connections(codec, nid, result, len); in read_and_add_raw_conns()
160 len = snd_hda_override_conn_list(codec, nid, len, result); in read_and_add_raw_conns()
168 * @codec: the HDA codec
181 int snd_hda_get_conn_list(struct hda_codec *codec, hda_nid_t nid, in snd_hda_get_conn_list() argument
191 p = lookup_conn_list(codec, nid); in snd_hda_get_conn_list()
200 err = read_and_add_raw_conns(codec, nid); in snd_hda_get_conn_list()
210 * @codec: the HDA codec
220 int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, in snd_hda_get_connections() argument
224 int len = snd_hda_get_conn_list(codec, nid, &list); in snd_hda_get_connections()
228 codec_err(codec, "Too many connections %d for NID 0x%x\n", in snd_hda_get_connections()
241 * @codec: the HDA codec
251 int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int len, in snd_hda_override_conn_list() argument
256 p = lookup_conn_list(codec, nid); in snd_hda_override_conn_list()
262 return add_conn_list(codec, nid, len, list); in snd_hda_override_conn_list()
268 * @codec: the HDA codec
277 int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux, in snd_hda_get_conn_index() argument
283 nums = snd_hda_get_conn_list(codec, mux, &conn); in snd_hda_get_conn_index()
290 codec_dbg(codec, "too deep connection for 0x%x\n", nid); in snd_hda_get_conn_index()
295 unsigned int type = get_wcaps_type(get_wcaps(codec, conn[i])); in snd_hda_get_conn_index()
298 if (snd_hda_get_conn_index(codec, conn[i], nid, recursive) >= 0) in snd_hda_get_conn_index()
307 * @codec: the HDA codec
313 unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid) in snd_hda_get_num_devices() argument
315 unsigned int wcaps = get_wcaps(codec, nid); in snd_hda_get_num_devices()
318 if (!codec->dp_mst || !(wcaps & AC_WCAP_DIGITAL) || in snd_hda_get_num_devices()
322 parm = snd_hdac_read_parm_uncached(&codec->core, nid, AC_PAR_DEVLIST_LEN); in snd_hda_get_num_devices()
331 * @codec: the HDA codec
339 int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid, in snd_hda_get_devices() argument
345 parm = snd_hda_get_num_devices(codec, nid); in snd_hda_get_devices()
354 if (snd_hdac_read(&codec->core, nid, in snd_hda_get_devices()
371 * @codec: the HDA codec
378 int snd_hda_get_dev_select(struct hda_codec *codec, hda_nid_t nid) in snd_hda_get_dev_select() argument
381 if (!codec->dp_mst) in snd_hda_get_dev_select()
384 return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DEVICE_SEL, 0); in snd_hda_get_dev_select()
390 * @codec: the HDA codec
396 int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid, int dev_id) in snd_hda_set_dev_select() argument
401 if (!codec->dp_mst) in snd_hda_set_dev_select()
405 num_devices = snd_hda_get_num_devices(codec, nid) + 1; in snd_hda_set_dev_select()
419 ret = snd_hda_codec_write(codec, nid, 0, in snd_hda_set_dev_select()
429 static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node) in read_widget_caps() argument
434 codec->wcaps = kmalloc_array(codec->core.num_nodes, 4, GFP_KERNEL); in read_widget_caps()
435 if (!codec->wcaps) in read_widget_caps()
437 nid = codec->core.start_nid; in read_widget_caps()
438 for (i = 0; i < codec->core.num_nodes; i++, nid++) in read_widget_caps()
439 codec->wcaps[i] = snd_hdac_read_parm_uncached(&codec->core, in read_widget_caps()
444 /* read all pin default configurations and save codec->init_pins */
445 static int read_pin_defaults(struct hda_codec *codec) in read_pin_defaults() argument
449 for_each_hda_codec_node(nid, codec) { in read_pin_defaults()
451 unsigned int wcaps = get_wcaps(codec, nid); in read_pin_defaults()
455 pin = snd_array_new(&codec->init_pins); in read_pin_defaults()
459 pin->cfg = snd_hda_codec_read(codec, nid, 0, in read_pin_defaults()
463 * fixme: if any codec is different, need fix here in read_pin_defaults()
465 pin->ctrl = snd_hda_codec_read(codec, nid, 0, in read_pin_defaults()
473 static struct hda_pincfg *look_up_pincfg(struct hda_codec *codec, in look_up_pincfg() argument
490 int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, in snd_hda_add_pincfg() argument
500 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) in snd_hda_add_pincfg()
504 pin = look_up_pincfg(codec, list, nid); in snd_hda_add_pincfg()
517 * @codec: the HDA codec
525 int snd_hda_codec_set_pincfg(struct hda_codec *codec, in snd_hda_codec_set_pincfg() argument
528 return snd_hda_add_pincfg(codec, &codec->driver_pins, nid, cfg); in snd_hda_codec_set_pincfg()
534 * @codec: the HDA codec
541 unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid) in snd_hda_codec_get_pincfg() argument
548 mutex_lock(&codec->user_mutex); in snd_hda_codec_get_pincfg()
549 pin = look_up_pincfg(codec, &codec->user_pins, nid); in snd_hda_codec_get_pincfg()
552 mutex_unlock(&codec->user_mutex); in snd_hda_codec_get_pincfg()
557 pin = look_up_pincfg(codec, &codec->driver_pins, nid); in snd_hda_codec_get_pincfg()
560 pin = look_up_pincfg(codec, &codec->init_pins, nid); in snd_hda_codec_get_pincfg()
569 * @codec: the HDA codec
577 int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid, in snd_hda_codec_set_pin_target() argument
582 pin = look_up_pincfg(codec, &codec->init_pins, nid); in snd_hda_codec_set_pin_target()
592 * @codec: the HDA codec
595 int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid) in snd_hda_codec_get_pin_target() argument
599 pin = look_up_pincfg(codec, &codec->init_pins, nid); in snd_hda_codec_get_pin_target()
608 * @codec: the HDA codec
613 void snd_hda_shutup_pins(struct hda_codec *codec) in snd_hda_shutup_pins() argument
621 if (codec->bus->shutdown) in snd_hda_shutup_pins()
623 snd_array_for_each(&codec->init_pins, i, pin) { in snd_hda_shutup_pins()
625 snd_hda_codec_read(codec, pin->nid, 0, in snd_hda_shutup_pins()
628 codec->pins_shutup = 1; in snd_hda_shutup_pins()
634 static void restore_shutup_pins(struct hda_codec *codec) in restore_shutup_pins() argument
639 if (!codec->pins_shutup) in restore_shutup_pins()
641 if (codec->bus->shutdown) in restore_shutup_pins()
643 snd_array_for_each(&codec->init_pins, i, pin) { in restore_shutup_pins()
644 snd_hda_codec_write(codec, pin->nid, 0, in restore_shutup_pins()
648 codec->pins_shutup = 0; in restore_shutup_pins()
654 struct hda_codec *codec = in hda_jackpoll_work() local
657 snd_hda_jack_set_dirty_all(codec); in hda_jackpoll_work()
658 snd_hda_jack_poll_all(codec); in hda_jackpoll_work()
660 if (!codec->jackpoll_interval) in hda_jackpoll_work()
663 schedule_delayed_work(&codec->jackpoll_work, in hda_jackpoll_work()
664 codec->jackpoll_interval); in hda_jackpoll_work()
668 static void free_init_pincfgs(struct hda_codec *codec) in free_init_pincfgs() argument
670 snd_array_free(&codec->driver_pins); in free_init_pincfgs()
672 snd_array_free(&codec->user_pins); in free_init_pincfgs()
674 snd_array_free(&codec->init_pins); in free_init_pincfgs()
691 get_hda_cvt_setup(struct hda_codec *codec, hda_nid_t nid) in get_hda_cvt_setup() argument
696 snd_array_for_each(&codec->cvt_setups, i, p) { in get_hda_cvt_setup()
700 p = snd_array_new(&codec->cvt_setups); in get_hda_cvt_setup()
714 snd_device_free(pcm->codec->card, pcm->pcm); in release_pcm()
715 clear_bit(pcm->device, pcm->codec->bus->pcm_dev_bits); in release_pcm()
726 struct hda_pcm *snd_hda_codec_pcm_new(struct hda_codec *codec, in snd_hda_codec_pcm_new() argument
736 pcm->codec = codec; in snd_hda_codec_pcm_new()
746 list_add_tail(&pcm->list, &codec->pcm_list_head); in snd_hda_codec_pcm_new()
752 * codec destructor
754 static void codec_release_pcms(struct hda_codec *codec) in codec_release_pcms() argument
758 list_for_each_entry_safe(pcm, n, &codec->pcm_list_head, list) { in codec_release_pcms()
761 snd_device_disconnect(codec->card, pcm->pcm); in codec_release_pcms()
766 void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec) in snd_hda_codec_cleanup_for_unbind() argument
768 if (codec->registered) { in snd_hda_codec_cleanup_for_unbind()
770 pm_runtime_get_noresume(hda_codec_dev(codec)); in snd_hda_codec_cleanup_for_unbind()
771 pm_runtime_disable(hda_codec_dev(codec)); in snd_hda_codec_cleanup_for_unbind()
772 codec->registered = 0; in snd_hda_codec_cleanup_for_unbind()
775 cancel_delayed_work_sync(&codec->jackpoll_work); in snd_hda_codec_cleanup_for_unbind()
776 if (!codec->in_freeing) in snd_hda_codec_cleanup_for_unbind()
777 snd_hda_ctls_clear(codec); in snd_hda_codec_cleanup_for_unbind()
778 codec_release_pcms(codec); in snd_hda_codec_cleanup_for_unbind()
779 snd_hda_detach_beep_device(codec); in snd_hda_codec_cleanup_for_unbind()
780 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops)); in snd_hda_codec_cleanup_for_unbind()
781 snd_hda_jack_tbl_clear(codec); in snd_hda_codec_cleanup_for_unbind()
782 codec->proc_widget_hook = NULL; in snd_hda_codec_cleanup_for_unbind()
783 codec->spec = NULL; in snd_hda_codec_cleanup_for_unbind()
786 snd_array_free(&codec->driver_pins); in snd_hda_codec_cleanup_for_unbind()
787 snd_array_free(&codec->cvt_setups); in snd_hda_codec_cleanup_for_unbind()
788 snd_array_free(&codec->spdif_out); in snd_hda_codec_cleanup_for_unbind()
789 snd_array_free(&codec->verbs); in snd_hda_codec_cleanup_for_unbind()
790 codec->preset = NULL; in snd_hda_codec_cleanup_for_unbind()
791 codec->slave_dig_outs = NULL; in snd_hda_codec_cleanup_for_unbind()
792 codec->spdif_status_reset = 0; in snd_hda_codec_cleanup_for_unbind()
793 snd_array_free(&codec->mixers); in snd_hda_codec_cleanup_for_unbind()
794 snd_array_free(&codec->nids); in snd_hda_codec_cleanup_for_unbind()
795 remove_conn_list(codec); in snd_hda_codec_cleanup_for_unbind()
796 snd_hdac_regmap_exit(&codec->core); in snd_hda_codec_cleanup_for_unbind()
799 static unsigned int hda_set_power_state(struct hda_codec *codec,
803 void snd_hda_codec_register(struct hda_codec *codec) in snd_hda_codec_register() argument
805 if (codec->registered) in snd_hda_codec_register()
807 if (device_is_registered(hda_codec_dev(codec))) { in snd_hda_codec_register()
808 snd_hda_register_beep_device(codec); in snd_hda_codec_register()
809 snd_hdac_link_power(&codec->core, true); in snd_hda_codec_register()
810 pm_runtime_enable(hda_codec_dev(codec)); in snd_hda_codec_register()
812 snd_hda_power_down(codec); in snd_hda_codec_register()
813 codec->registered = 1; in snd_hda_codec_register()
825 struct hda_codec *codec = device->device_data; in snd_hda_codec_dev_disconnect() local
827 snd_hda_detach_beep_device(codec); in snd_hda_codec_dev_disconnect()
833 struct hda_codec *codec = device->device_data; in snd_hda_codec_dev_free() local
835 codec->in_freeing = 1; in snd_hda_codec_dev_free()
836 snd_hdac_device_unregister(&codec->core); in snd_hda_codec_dev_free()
837 snd_hdac_link_power(&codec->core, false); in snd_hda_codec_dev_free()
838 put_device(hda_codec_dev(codec)); in snd_hda_codec_dev_free()
844 struct hda_codec *codec = dev_to_hda_codec(dev); in snd_hda_codec_dev_release() local
846 free_init_pincfgs(codec); in snd_hda_codec_dev_release()
847 snd_hdac_device_exit(&codec->core); in snd_hda_codec_dev_release()
848 snd_hda_sysfs_clear(codec); in snd_hda_codec_dev_release()
849 kfree(codec->modelname); in snd_hda_codec_dev_release()
850 kfree(codec->wcaps); in snd_hda_codec_dev_release()
851 kfree(codec); in snd_hda_codec_dev_release()
860 struct hda_codec *codec; in snd_hda_codec_device_init() local
870 codec = kzalloc(sizeof(*codec), GFP_KERNEL); in snd_hda_codec_device_init()
871 if (!codec) in snd_hda_codec_device_init()
875 err = snd_hdac_device_init(&codec->core, &bus->core, name, codec_addr); in snd_hda_codec_device_init()
877 kfree(codec); in snd_hda_codec_device_init()
881 codec->core.type = HDA_DEV_LEGACY; in snd_hda_codec_device_init()
882 *codecp = codec; in snd_hda_codec_device_init()
888 * snd_hda_codec_new - create a HDA codec
890 * @codec_addr: the codec address
891 * @codecp: the pointer to store the generated codec
909 unsigned int codec_addr, struct hda_codec *codec) in snd_hda_codec_device_new() argument
927 codec->core.dev.release = snd_hda_codec_dev_release; in snd_hda_codec_device_new()
928 codec->core.exec_verb = codec_exec_verb; in snd_hda_codec_device_new()
930 codec->bus = bus; in snd_hda_codec_device_new()
931 codec->card = card; in snd_hda_codec_device_new()
932 codec->addr = codec_addr; in snd_hda_codec_device_new()
933 mutex_init(&codec->spdif_mutex); in snd_hda_codec_device_new()
934 mutex_init(&codec->control_mutex); in snd_hda_codec_device_new()
935 snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); in snd_hda_codec_device_new()
936 snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32); in snd_hda_codec_device_new()
937 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); in snd_hda_codec_device_new()
938 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); in snd_hda_codec_device_new()
939 snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); in snd_hda_codec_device_new()
940 snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); in snd_hda_codec_device_new()
941 snd_array_init(&codec->jacktbl, sizeof(struct hda_jack_tbl), 16); in snd_hda_codec_device_new()
942 snd_array_init(&codec->verbs, sizeof(struct hda_verb *), 8); in snd_hda_codec_device_new()
943 INIT_LIST_HEAD(&codec->conn_list); in snd_hda_codec_device_new()
944 INIT_LIST_HEAD(&codec->pcm_list_head); in snd_hda_codec_device_new()
946 INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work); in snd_hda_codec_device_new()
947 codec->depop_delay = -1; in snd_hda_codec_device_new()
948 codec->fixup_id = HDA_FIXUP_ID_NOT_SET; in snd_hda_codec_device_new()
951 codec->power_jiffies = jiffies; in snd_hda_codec_device_new()
954 snd_hda_sysfs_init(codec); in snd_hda_codec_device_new()
956 if (codec->bus->modelname) { in snd_hda_codec_device_new()
957 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); in snd_hda_codec_device_new()
958 if (!codec->modelname) { in snd_hda_codec_device_new()
964 fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in snd_hda_codec_device_new()
965 err = read_widget_caps(codec, fg); in snd_hda_codec_device_new()
968 err = read_pin_defaults(codec); in snd_hda_codec_device_new()
973 hda_set_power_state(codec, AC_PWRST_D0); in snd_hda_codec_device_new()
974 codec->core.dev.power.power_state = PMSG_ON; in snd_hda_codec_device_new()
976 snd_hda_codec_proc_new(codec); in snd_hda_codec_device_new()
978 snd_hda_create_hwdep(codec); in snd_hda_codec_device_new()
980 sprintf(component, "HDA:%08x,%08x,%08x", codec->core.vendor_id, in snd_hda_codec_device_new()
981 codec->core.subsystem_id, codec->core.revision_id); in snd_hda_codec_device_new()
984 err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops); in snd_hda_codec_device_new()
991 put_device(hda_codec_dev(codec)); in snd_hda_codec_device_new()
998 * @codec: the HDA codec
1001 * the given codec.
1003 int snd_hda_codec_update_widgets(struct hda_codec *codec) in snd_hda_codec_update_widgets() argument
1008 err = snd_hdac_refresh_widgets(&codec->core, true); in snd_hda_codec_update_widgets()
1015 kfree(codec->wcaps); in snd_hda_codec_update_widgets()
1016 fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in snd_hda_codec_update_widgets()
1017 err = read_widget_caps(codec, fg); in snd_hda_codec_update_widgets()
1021 snd_array_free(&codec->init_pins); in snd_hda_codec_update_widgets()
1022 err = read_pin_defaults(codec); in snd_hda_codec_update_widgets()
1029 static void update_pcm_stream_id(struct hda_codec *codec, in update_pcm_stream_id() argument
1036 oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); in update_pcm_stream_id()
1039 snd_hda_codec_write(codec, nid, 0, in update_pcm_stream_id()
1048 static void update_pcm_format(struct hda_codec *codec, struct hda_cvt_setup *p, in update_pcm_format() argument
1054 oldval = snd_hda_codec_read(codec, nid, 0, in update_pcm_format()
1058 snd_hda_codec_write(codec, nid, 0, in update_pcm_format()
1067 * snd_hda_codec_setup_stream - set up the codec for streaming
1068 * @codec: the CODEC to set up
1074 void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, in snd_hda_codec_setup_stream() argument
1086 codec_dbg(codec, in snd_hda_codec_setup_stream()
1089 p = get_hda_cvt_setup(codec, nid); in snd_hda_codec_setup_stream()
1093 if (codec->patch_ops.stream_pm) in snd_hda_codec_setup_stream()
1094 codec->patch_ops.stream_pm(codec, nid, true); in snd_hda_codec_setup_stream()
1095 if (codec->pcm_format_first) in snd_hda_codec_setup_stream()
1096 update_pcm_format(codec, p, nid, format); in snd_hda_codec_setup_stream()
1097 update_pcm_stream_id(codec, p, nid, stream_tag, channel_id); in snd_hda_codec_setup_stream()
1098 if (!codec->pcm_format_first) in snd_hda_codec_setup_stream()
1099 update_pcm_format(codec, p, nid, format); in snd_hda_codec_setup_stream()
1105 type = get_wcaps_type(get_wcaps(codec, nid)); in snd_hda_codec_setup_stream()
1106 list_for_each_codec(c, codec->bus) { in snd_hda_codec_setup_stream()
1116 static void really_cleanup_stream(struct hda_codec *codec,
1120 * __snd_hda_codec_cleanup_stream - clean up the codec for closing
1121 * @codec: the CODEC to clean up
1125 void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid, in __snd_hda_codec_cleanup_stream() argument
1133 if (codec->no_sticky_stream) in __snd_hda_codec_cleanup_stream()
1136 codec_dbg(codec, "hda_codec_cleanup_stream: NID=0x%x\n", nid); in __snd_hda_codec_cleanup_stream()
1137 p = get_hda_cvt_setup(codec, nid); in __snd_hda_codec_cleanup_stream()
1144 really_cleanup_stream(codec, p); in __snd_hda_codec_cleanup_stream()
1151 static void really_cleanup_stream(struct hda_codec *codec, in really_cleanup_stream() argument
1156 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0); in really_cleanup_stream()
1158 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0 in really_cleanup_stream()
1162 if (codec->patch_ops.stream_pm) in really_cleanup_stream()
1163 codec->patch_ops.stream_pm(codec, nid, false); in really_cleanup_stream()
1167 static void purify_inactive_streams(struct hda_codec *codec) in purify_inactive_streams() argument
1173 list_for_each_codec(c, codec->bus) { in purify_inactive_streams()
1183 static void hda_cleanup_all_streams(struct hda_codec *codec) in hda_cleanup_all_streams() argument
1188 snd_array_for_each(&codec->cvt_setups, i, p) { in hda_cleanup_all_streams()
1190 really_cleanup_stream(codec, p); in hda_cleanup_all_streams()
1201 * @codec: the HD-auio codec
1211 u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) in query_amp_caps() argument
1213 if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) in query_amp_caps()
1214 nid = codec->core.afg; in query_amp_caps()
1215 return snd_hda_param_read(codec, nid, in query_amp_caps()
1223 * @codec: the HD-audio codec
1230 bool snd_hda_check_amp_caps(struct hda_codec *codec, hda_nid_t nid, in snd_hda_check_amp_caps() argument
1235 if (get_wcaps(codec, nid) & (1 << (dir + 1))) in snd_hda_check_amp_caps()
1236 if (query_amp_caps(codec, nid, dir) & bits) in snd_hda_check_amp_caps()
1244 * @codec: the CODEC to clean up
1255 int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, in snd_hda_override_amp_caps() argument
1260 snd_hda_override_wcaps(codec, nid, in snd_hda_override_amp_caps()
1261 get_wcaps(codec, nid) | AC_WCAP_AMP_OVRD); in snd_hda_override_amp_caps()
1263 return snd_hdac_override_parm(&codec->core, nid, parm, caps); in snd_hda_override_amp_caps()
1269 * @codec: HD-audio codec
1279 int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, in snd_hda_codec_amp_update() argument
1285 if ((query_amp_caps(codec, nid, dir) & in snd_hda_codec_amp_update()
1288 return snd_hdac_regmap_update_raw(&codec->core, cmd, mask, val); in snd_hda_codec_amp_update()
1294 * @codec: HD-audio codec
1304 int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid, in snd_hda_codec_amp_stereo() argument
1312 ret |= snd_hda_codec_amp_update(codec, nid, ch, direction, in snd_hda_codec_amp_stereo()
1320 * @codec: the HDA codec
1332 int snd_hda_codec_amp_init(struct hda_codec *codec, hda_nid_t nid, int ch, in snd_hda_codec_amp_init() argument
1337 if (!codec->core.regmap) in snd_hda_codec_amp_init()
1339 regcache_cache_only(codec->core.regmap, true); in snd_hda_codec_amp_init()
1340 orig = snd_hda_codec_amp_read(codec, nid, ch, dir, idx); in snd_hda_codec_amp_init()
1341 regcache_cache_only(codec->core.regmap, false); in snd_hda_codec_amp_init()
1344 return snd_hda_codec_amp_update(codec, nid, ch, dir, idx, mask, val); in snd_hda_codec_amp_init()
1350 * @codec: the HDA codec
1359 int snd_hda_codec_amp_init_stereo(struct hda_codec *codec, hda_nid_t nid, in snd_hda_codec_amp_init_stereo() argument
1367 ret |= snd_hda_codec_amp_init(codec, nid, ch, dir, in snd_hda_codec_amp_init_stereo()
1373 static u32 get_amp_max_value(struct hda_codec *codec, hda_nid_t nid, int dir, in get_amp_max_value() argument
1376 u32 caps = query_amp_caps(codec, nid, dir); in get_amp_max_value()
1395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_mixer_amp_volume_info() local
1404 uinfo->value.integer.max = get_amp_max_value(codec, nid, dir, ofs); in snd_hda_mixer_amp_volume_info()
1406 codec_warn(codec, in snd_hda_mixer_amp_volume_info()
1417 read_amp_value(struct hda_codec *codec, hda_nid_t nid, in read_amp_value() argument
1421 val = snd_hda_codec_amp_read(codec, nid, ch, dir, idx); in read_amp_value()
1431 update_amp_value(struct hda_codec *codec, hda_nid_t nid, in update_amp_value() argument
1440 maxval = get_amp_max_value(codec, nid, dir, 0); in update_amp_value()
1443 return snd_hda_codec_amp_update(codec, nid, ch, dir, idx, in update_amp_value()
1458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_mixer_amp_volume_get() local
1467 *valp++ = read_amp_value(codec, nid, 0, dir, idx, ofs); in snd_hda_mixer_amp_volume_get()
1469 *valp = read_amp_value(codec, nid, 1, dir, idx, ofs); in snd_hda_mixer_amp_volume_get()
1485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_mixer_amp_volume_put() local
1495 change = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp); in snd_hda_mixer_amp_volume_put()
1499 change |= update_amp_value(codec, nid, 1, dir, idx, ofs, *valp); in snd_hda_mixer_amp_volume_put()
1507 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in get_ctl_amp_tlv() local
1514 caps = query_amp_caps(codec, nid, dir); in get_ctl_amp_tlv()
1554 * @codec: HD-audio codec
1563 void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir, in snd_hda_set_vmaster_tlv() argument
1569 caps = query_amp_caps(codec, nid, dir); in snd_hda_set_vmaster_tlv()
1582 find_mixer_ctl(struct hda_codec *codec, const char *name, int dev, int idx) in find_mixer_ctl() argument
1592 return snd_ctl_find_id(codec->card, &id); in find_mixer_ctl()
1597 * @codec: HD-audio codec
1602 struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, in snd_hda_find_mixer_ctl() argument
1605 return find_mixer_ctl(codec, name, 0, 0); in snd_hda_find_mixer_ctl()
1609 static int find_empty_mixer_ctl_idx(struct hda_codec *codec, const char *name, in find_empty_mixer_ctl_idx() argument
1615 if (!find_mixer_ctl(codec, name, 0, idx)) in find_empty_mixer_ctl_idx()
1622 * snd_hda_ctl_add - Add a control element and assign to the codec
1623 * @codec: HD-audio codec
1627 * Add the given control element to an array inside the codec instance.
1628 * All control elements belonging to a codec are supposed to be added
1633 * The assignment is shown in the codec proc file.
1640 int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, in snd_hda_ctl_add() argument
1656 err = snd_ctl_add(codec->card, kctl); in snd_hda_ctl_add()
1659 item = snd_array_new(&codec->mixers); in snd_hda_ctl_add()
1671 * @codec: HD-audio codec
1676 * Add the given control element to an array inside the codec instance.
1680 int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl, in snd_hda_add_nid() argument
1686 item = snd_array_new(&codec->nids); in snd_hda_add_nid()
1694 codec_err(codec, "no NID for mapping control %s:%d:%d\n", in snd_hda_add_nid()
1701 * snd_hda_ctls_clear - Clear all controls assigned to the given codec
1702 * @codec: HD-audio codec
1704 void snd_hda_ctls_clear(struct hda_codec *codec) in snd_hda_ctls_clear() argument
1707 struct hda_nid_item *items = codec->mixers.list; in snd_hda_ctls_clear()
1708 for (i = 0; i < codec->mixers.used; i++) in snd_hda_ctls_clear()
1709 snd_ctl_remove(codec->card, items[i].kctl); in snd_hda_ctls_clear()
1710 snd_array_free(&codec->mixers); in snd_hda_ctls_clear()
1711 snd_array_free(&codec->nids); in snd_hda_ctls_clear()
1723 struct hda_codec *codec; in snd_hda_lock_devices() local
1732 list_for_each_codec(codec, bus) { in snd_hda_lock_devices()
1734 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_lock_devices()
1768 * snd_hda_codec_reset - Clear all objects assigned to the codec
1769 * @codec: HD-audio codec
1771 * This frees the all PCM and control elements assigned to the codec, and
1777 int snd_hda_codec_reset(struct hda_codec *codec) in snd_hda_codec_reset() argument
1779 struct hda_bus *bus = codec->bus; in snd_hda_codec_reset()
1785 snd_hdac_device_unregister(&codec->core); in snd_hda_codec_reset()
1795 static int map_slaves(struct hda_codec *codec, const char * const *slaves, in map_slaves() argument
1802 items = codec->mixers.list; in map_slaves()
1803 for (i = 0; i < codec->mixers.used; i++) { in map_slaves()
1816 err = func(codec, data, sctl); in map_slaves()
1826 static int check_slave_present(struct hda_codec *codec, in check_slave_present() argument
1847 struct hda_codec *codec; member
1864 codec_err(arg->codec, in init_slave_0dB()
1882 codec_err(arg->codec, in init_slave_0dB()
1906 static int add_slave(struct hda_codec *codec, in add_slave() argument
1914 * @codec: HD-audio codec
1931 int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, in __snd_hda_add_vmaster() argument
1942 err = map_slaves(codec, slaves, suffix, check_slave_present, NULL); in __snd_hda_add_vmaster()
1944 codec_dbg(codec, "No slave found for %s\n", name); in __snd_hda_add_vmaster()
1950 err = snd_hda_ctl_add(codec, 0, kctl); in __snd_hda_add_vmaster()
1954 err = map_slaves(codec, slaves, suffix, add_slave, kctl); in __snd_hda_add_vmaster()
1962 .codec = codec, in __snd_hda_add_vmaster()
2027 hook->hook(hook->codec, enabled); in vmaster_hook()
2032 * @codec: the HDA codec
2040 int snd_hda_add_vmaster_hook(struct hda_codec *codec, in snd_hda_add_vmaster_hook() argument
2048 hook->codec = codec; in snd_hda_add_vmaster_hook()
2056 return snd_hda_ctl_add(codec, 0, kctl); in snd_hda_add_vmaster_hook()
2069 if (!hook->hook || !hook->codec) in snd_hda_sync_vmaster_hook()
2074 if (hook->codec->bus->shutdown) in snd_hda_sync_vmaster_hook()
2113 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_mixer_amp_switch_get() local
2121 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & in snd_hda_mixer_amp_switch_get()
2124 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & in snd_hda_mixer_amp_switch_get()
2141 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_mixer_amp_switch_put() local
2150 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, in snd_hda_mixer_amp_switch_put()
2156 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, in snd_hda_mixer_amp_switch_put()
2159 hda_call_check_power_status(codec, nid); in snd_hda_mixer_amp_switch_put()
2200 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_spdif_default_get() local
2204 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_default_get()
2206 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_default_get()
2207 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_default_get()
2212 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_default_get()
2271 static void set_dig_out(struct hda_codec *codec, hda_nid_t nid, in set_dig_out() argument
2276 snd_hdac_regmap_update(&codec->core, nid, AC_VERB_SET_DIGI_CONVERT_1, in set_dig_out()
2278 d = codec->slave_dig_outs; in set_dig_out()
2282 snd_hdac_regmap_update(&codec->core, *d, in set_dig_out()
2286 static inline void set_dig_out_convert(struct hda_codec *codec, hda_nid_t nid, in set_dig_out_convert() argument
2300 set_dig_out(codec, nid, mask, val); in set_dig_out_convert()
2306 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_spdif_default_put() local
2313 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_default_put()
2315 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_default_put()
2316 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_default_put()
2327 set_dig_out_convert(codec, nid, val & 0xff, (val >> 8) & 0xff); in snd_hda_spdif_default_put()
2328 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_default_put()
2337 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_spdif_out_switch_get() local
2341 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_out_switch_get()
2343 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_get()
2344 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_out_switch_get()
2346 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_get()
2350 static inline void set_spdif_ctls(struct hda_codec *codec, hda_nid_t nid, in set_spdif_ctls() argument
2353 set_dig_out_convert(codec, nid, dig1, dig2); in set_spdif_ctls()
2355 if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) && in set_spdif_ctls()
2357 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, in set_spdif_ctls()
2364 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_spdif_out_switch_put() local
2371 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_out_switch_put()
2373 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_put()
2374 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_out_switch_put()
2382 set_spdif_ctls(codec, nid, val & 0xff, -1); in snd_hda_spdif_out_switch_put()
2383 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_out_switch_put()
2421 * @codec: the HDA codec
2430 int snd_hda_create_dig_out_ctls(struct hda_codec *codec, in snd_hda_create_dig_out_ctls() argument
2442 struct hda_bus *bus = codec->bus; in snd_hda_create_dig_out_ctls()
2451 kctl = find_mixer_ctl(codec, dig_mix->name, 0, 0); in snd_hda_create_dig_out_ctls()
2461 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch", idx); in snd_hda_create_dig_out_ctls()
2463 codec_err(codec, "too many IEC958 outputs\n"); in snd_hda_create_dig_out_ctls()
2466 spdif = snd_array_new(&codec->spdif_out); in snd_hda_create_dig_out_ctls()
2470 kctl = snd_ctl_new1(dig_mix, codec); in snd_hda_create_dig_out_ctls()
2474 kctl->private_value = codec->spdif_out.used - 1; in snd_hda_create_dig_out_ctls()
2475 err = snd_hda_ctl_add(codec, associated_nid, kctl); in snd_hda_create_dig_out_ctls()
2480 snd_hdac_regmap_read(&codec->core, cvt_nid, in snd_hda_create_dig_out_ctls()
2490 * @codec: the HDA codec
2495 struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec, in snd_hda_spdif_out_of_nid() argument
2501 snd_array_for_each(&codec->spdif_out, i, spdif) { in snd_hda_spdif_out_of_nid()
2511 * @codec: the HDA codec
2516 void snd_hda_spdif_ctls_unassign(struct hda_codec *codec, int idx) in snd_hda_spdif_ctls_unassign() argument
2520 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_ctls_unassign()
2522 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_ctls_unassign()
2523 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_ctls_unassign()
2525 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_ctls_unassign()
2531 * @codec: the HDA codec
2537 void snd_hda_spdif_ctls_assign(struct hda_codec *codec, int idx, hda_nid_t nid) in snd_hda_spdif_ctls_assign() argument
2542 if (WARN_ON(codec->spdif_out.used <= idx)) in snd_hda_spdif_ctls_assign()
2544 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_ctls_assign()
2545 spdif = snd_array_elem(&codec->spdif_out, idx); in snd_hda_spdif_ctls_assign()
2549 set_spdif_ctls(codec, nid, val & 0xff, (val >> 8) & 0xff); in snd_hda_spdif_ctls_assign()
2551 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_ctls_assign()
2584 * @codec: the HDA codec
2587 int snd_hda_create_spdif_share_sw(struct hda_codec *codec, in snd_hda_create_spdif_share_sw() argument
2598 /* ATTENTION: here mout is passed as private_data, instead of codec */ in snd_hda_create_spdif_share_sw()
2599 return snd_hda_ctl_add(codec, mout->dig_out_nid, kctl); in snd_hda_create_spdif_share_sw()
2612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_spdif_in_switch_get() local
2614 ucontrol->value.integer.value[0] = codec->spdif_in_enable; in snd_hda_spdif_in_switch_get()
2621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_spdif_in_switch_put() local
2626 mutex_lock(&codec->spdif_mutex); in snd_hda_spdif_in_switch_put()
2627 change = codec->spdif_in_enable != val; in snd_hda_spdif_in_switch_put()
2629 codec->spdif_in_enable = val; in snd_hda_spdif_in_switch_put()
2630 snd_hdac_regmap_write(&codec->core, nid, in snd_hda_spdif_in_switch_put()
2633 mutex_unlock(&codec->spdif_mutex); in snd_hda_spdif_in_switch_put()
2640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in snd_hda_spdif_in_status_get() local
2645 snd_hdac_regmap_read(&codec->core, nid, in snd_hda_spdif_in_status_get()
2675 * @codec: the HDA codec
2683 int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) in snd_hda_create_spdif_in_ctls() argument
2690 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Capture Switch", 0); in snd_hda_create_spdif_in_ctls()
2692 codec_err(codec, "too many IEC958 inputs\n"); in snd_hda_create_spdif_in_ctls()
2696 kctl = snd_ctl_new1(dig_mix, codec); in snd_hda_create_spdif_in_ctls()
2700 err = snd_hda_ctl_add(codec, nid, kctl); in snd_hda_create_spdif_in_ctls()
2704 codec->spdif_in_enable = in snd_hda_create_spdif_in_ctls()
2705 snd_hda_codec_read(codec, nid, 0, in snd_hda_create_spdif_in_ctls()
2714 * @codec: the HDA codec
2719 * If the codec has power_filter set, it evaluates the power state and
2722 void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg, in snd_hda_codec_set_power_to_all() argument
2727 for_each_hda_codec_node(nid, codec) { in snd_hda_codec_set_power_to_all()
2728 unsigned int wcaps = get_wcaps(codec, nid); in snd_hda_codec_set_power_to_all()
2732 if (codec->power_filter) { in snd_hda_codec_set_power_to_all()
2733 state = codec->power_filter(codec, nid, power_state); in snd_hda_codec_set_power_to_all()
2737 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in snd_hda_codec_set_power_to_all()
2745 * @codec: the HDA codec
2750 * This can be used a codec power_filter callback.
2752 unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec, in snd_hda_codec_eapd_power_filter() argument
2756 if (nid == codec->core.afg || nid == codec->core.mfg) in snd_hda_codec_eapd_power_filter()
2759 get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN && in snd_hda_codec_eapd_power_filter()
2760 (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)) { in snd_hda_codec_eapd_power_filter()
2761 int eapd = snd_hda_codec_read(codec, nid, 0, in snd_hda_codec_eapd_power_filter()
2771 * set power state of the codec, and return the power state
2773 static unsigned int hda_set_power_state(struct hda_codec *codec, in hda_set_power_state() argument
2776 hda_nid_t fg = codec->core.afg ? codec->core.afg : codec->core.mfg; in hda_set_power_state()
2783 if (codec->depop_delay < 0) in hda_set_power_state()
2784 msleep(codec_has_epss(codec) ? 10 : 100); in hda_set_power_state()
2785 else if (codec->depop_delay > 0) in hda_set_power_state()
2786 msleep(codec->depop_delay); in hda_set_power_state()
2792 if (codec->patch_ops.set_power_state) in hda_set_power_state()
2793 codec->patch_ops.set_power_state(codec, fg, in hda_set_power_state()
2797 if (codec->power_filter) in hda_set_power_state()
2798 state = codec->power_filter(codec, fg, state); in hda_set_power_state()
2800 snd_hda_codec_read(codec, fg, flags, in hda_set_power_state()
2803 snd_hda_codec_set_power_to_all(codec, fg, power_state); in hda_set_power_state()
2805 state = snd_hda_sync_power_state(codec, fg, power_state); in hda_set_power_state()
2814 * this is called at the end of codec parsing
2816 static void sync_power_up_states(struct hda_codec *codec) in sync_power_up_states() argument
2821 if (!codec->power_filter) in sync_power_up_states()
2824 for_each_hda_codec_node(nid, codec) { in sync_power_up_states()
2825 unsigned int wcaps = get_wcaps(codec, nid); in sync_power_up_states()
2829 target = codec->power_filter(codec, nid, AC_PWRST_D0); in sync_power_up_states()
2832 if (!snd_hda_check_power_state(codec, nid, target)) in sync_power_up_states()
2833 snd_hda_codec_write(codec, nid, 0, in sync_power_up_states()
2840 static void hda_exec_init_verbs(struct hda_codec *codec) in hda_exec_init_verbs() argument
2842 if (codec->init_verbs.list) in hda_exec_init_verbs()
2843 snd_hda_sequence_write(codec, codec->init_verbs.list); in hda_exec_init_verbs()
2846 static inline void hda_exec_init_verbs(struct hda_codec *codec) {} in hda_exec_init_verbs() argument
2851 static void update_power_acct(struct hda_codec *codec, bool on) in update_power_acct() argument
2853 unsigned long delta = jiffies - codec->power_jiffies; in update_power_acct()
2856 codec->power_on_acct += delta; in update_power_acct()
2858 codec->power_off_acct += delta; in update_power_acct()
2859 codec->power_jiffies += delta; in update_power_acct()
2862 void snd_hda_update_power_acct(struct hda_codec *codec) in snd_hda_update_power_acct() argument
2864 update_power_acct(codec, hda_codec_is_power_on(codec)); in snd_hda_update_power_acct()
2871 static unsigned int hda_call_codec_suspend(struct hda_codec *codec) in hda_call_codec_suspend() argument
2875 snd_hdac_enter_pm(&codec->core); in hda_call_codec_suspend()
2876 if (codec->patch_ops.suspend) in hda_call_codec_suspend()
2877 codec->patch_ops.suspend(codec); in hda_call_codec_suspend()
2878 hda_cleanup_all_streams(codec); in hda_call_codec_suspend()
2879 state = hda_set_power_state(codec, AC_PWRST_D3); in hda_call_codec_suspend()
2880 update_power_acct(codec, true); in hda_call_codec_suspend()
2881 snd_hdac_leave_pm(&codec->core); in hda_call_codec_suspend()
2886 * kick up codec; used both from PM and power-save
2888 static void hda_call_codec_resume(struct hda_codec *codec) in hda_call_codec_resume() argument
2890 snd_hdac_enter_pm(&codec->core); in hda_call_codec_resume()
2891 if (codec->core.regmap) in hda_call_codec_resume()
2892 regcache_mark_dirty(codec->core.regmap); in hda_call_codec_resume()
2894 codec->power_jiffies = jiffies; in hda_call_codec_resume()
2896 hda_set_power_state(codec, AC_PWRST_D0); in hda_call_codec_resume()
2897 restore_shutup_pins(codec); in hda_call_codec_resume()
2898 hda_exec_init_verbs(codec); in hda_call_codec_resume()
2899 snd_hda_jack_set_dirty_all(codec); in hda_call_codec_resume()
2900 if (codec->patch_ops.resume) in hda_call_codec_resume()
2901 codec->patch_ops.resume(codec); in hda_call_codec_resume()
2903 if (codec->patch_ops.init) in hda_call_codec_resume()
2904 codec->patch_ops.init(codec); in hda_call_codec_resume()
2905 if (codec->core.regmap) in hda_call_codec_resume()
2906 regcache_sync(codec->core.regmap); in hda_call_codec_resume()
2909 if (codec->jackpoll_interval) in hda_call_codec_resume()
2910 hda_jackpoll_work(&codec->jackpoll_work.work); in hda_call_codec_resume()
2912 snd_hda_jack_report_sync(codec); in hda_call_codec_resume()
2913 codec->core.dev.power.power_state = PMSG_ON; in hda_call_codec_resume()
2914 snd_hdac_leave_pm(&codec->core); in hda_call_codec_resume()
2919 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_runtime_suspend() local
2923 cancel_delayed_work_sync(&codec->jackpoll_work); in hda_codec_runtime_suspend()
2924 list_for_each_entry(pcm, &codec->pcm_list_head, list) in hda_codec_runtime_suspend()
2926 state = hda_call_codec_suspend(codec); in hda_codec_runtime_suspend()
2927 if (codec->link_down_at_suspend || in hda_codec_runtime_suspend()
2928 (codec_has_clkstop(codec) && codec_has_epss(codec) && in hda_codec_runtime_suspend()
2930 snd_hdac_codec_link_down(&codec->core); in hda_codec_runtime_suspend()
2931 snd_hdac_link_power(&codec->core, false); in hda_codec_runtime_suspend()
2937 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_runtime_resume() local
2939 snd_hdac_link_power(&codec->core, true); in hda_codec_runtime_resume()
2940 snd_hdac_codec_link_up(&codec->core); in hda_codec_runtime_resume()
2941 hda_call_codec_resume(codec); in hda_codec_runtime_resume()
2950 struct hda_codec *codec = dev_to_hda_codec(dev); in hda_codec_force_resume() local
2951 bool forced_resume = !codec->relaxed_resume; in hda_codec_force_resume()
3014 static int add_std_chmaps(struct hda_codec *codec) in add_std_chmaps() argument
3019 list_for_each_entry(pcm, &codec->pcm_list_head, list) { in add_std_chmaps()
3052 int snd_hda_codec_build_controls(struct hda_codec *codec) in snd_hda_codec_build_controls() argument
3055 hda_exec_init_verbs(codec); in snd_hda_codec_build_controls()
3057 if (codec->patch_ops.init) in snd_hda_codec_build_controls()
3058 err = codec->patch_ops.init(codec); in snd_hda_codec_build_controls()
3059 if (!err && codec->patch_ops.build_controls) in snd_hda_codec_build_controls()
3060 err = codec->patch_ops.build_controls(codec); in snd_hda_codec_build_controls()
3065 err = add_std_chmaps(codec); in snd_hda_codec_build_controls()
3069 if (codec->jackpoll_interval) in snd_hda_codec_build_controls()
3070 hda_jackpoll_work(&codec->jackpoll_work.work); in snd_hda_codec_build_controls()
3072 snd_hda_jack_report_sync(codec); /* call at the last init point */ in snd_hda_codec_build_controls()
3073 sync_power_up_states(codec); in snd_hda_codec_build_controls()
3082 struct hda_codec *codec, in hda_pcm_default_open_close() argument
3089 struct hda_codec *codec, in hda_pcm_default_prepare() argument
3094 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); in hda_pcm_default_prepare()
3099 struct hda_codec *codec, in hda_pcm_default_cleanup() argument
3102 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in hda_pcm_default_cleanup()
3106 static int set_pcm_default_values(struct hda_codec *codec, in set_pcm_default_values() argument
3113 err = snd_hda_query_supported_pcm(codec, info->nid, in set_pcm_default_values()
3138 * codec prepare/cleanup entries
3142 * @codec: the HDA codec
3148 * Calls the prepare callback set by the codec with the given arguments.
3151 int snd_hda_codec_prepare(struct hda_codec *codec, in snd_hda_codec_prepare() argument
3158 mutex_lock(&codec->bus->prepare_mutex); in snd_hda_codec_prepare()
3160 ret = hinfo->ops.prepare(hinfo, codec, stream, format, in snd_hda_codec_prepare()
3165 purify_inactive_streams(codec); in snd_hda_codec_prepare()
3166 mutex_unlock(&codec->bus->prepare_mutex); in snd_hda_codec_prepare()
3173 * @codec: the HDA codec
3177 * Calls the cleanup callback set by the codec with the given arguments.
3179 void snd_hda_codec_cleanup(struct hda_codec *codec, in snd_hda_codec_cleanup() argument
3183 mutex_lock(&codec->bus->prepare_mutex); in snd_hda_codec_cleanup()
3185 hinfo->ops.cleanup(hinfo, codec, substream); in snd_hda_codec_cleanup()
3186 mutex_unlock(&codec->bus->prepare_mutex); in snd_hda_codec_cleanup()
3243 /* call build_pcms ops of the given codec and set up the default parameters */
3244 int snd_hda_codec_parse_pcms(struct hda_codec *codec) in snd_hda_codec_parse_pcms() argument
3249 if (!list_empty(&codec->pcm_list_head)) in snd_hda_codec_parse_pcms()
3252 if (!codec->patch_ops.build_pcms) in snd_hda_codec_parse_pcms()
3255 err = codec->patch_ops.build_pcms(codec); in snd_hda_codec_parse_pcms()
3257 codec_err(codec, "cannot build PCMs for #%d (error %d)\n", in snd_hda_codec_parse_pcms()
3258 codec->core.addr, err); in snd_hda_codec_parse_pcms()
3262 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_codec_parse_pcms()
3270 err = set_pcm_default_values(codec, info); in snd_hda_codec_parse_pcms()
3272 codec_warn(codec, in snd_hda_codec_parse_pcms()
3284 /* assign all PCMs of the given codec */
3285 int snd_hda_codec_build_pcms(struct hda_codec *codec) in snd_hda_codec_build_pcms() argument
3287 struct hda_bus *bus = codec->bus; in snd_hda_codec_build_pcms()
3291 err = snd_hda_codec_parse_pcms(codec); in snd_hda_codec_build_pcms()
3296 list_for_each_entry(cpcm, &codec->pcm_list_head, list) { in snd_hda_codec_build_pcms()
3308 err = snd_hda_attach_pcm_stream(bus, codec, cpcm); in snd_hda_codec_build_pcms()
3310 codec_err(codec, in snd_hda_codec_build_pcms()
3311 "cannot attach PCM stream %d for codec #%d\n", in snd_hda_codec_build_pcms()
3312 dev, codec->core.addr); in snd_hda_codec_build_pcms()
3322 * @codec: the HDA codec
3330 int snd_hda_add_new_ctls(struct hda_codec *codec, in snd_hda_add_new_ctls() argument
3339 continue; /* skip this codec private value */ in snd_hda_add_new_ctls()
3341 kctl = snd_ctl_new1(knew, codec); in snd_hda_add_new_ctls()
3348 err = snd_hda_ctl_add(codec, 0, kctl); in snd_hda_add_new_ctls()
3352 * the codec addr; if it still fails (or it's the in snd_hda_add_new_ctls()
3353 * primary codec), then try another control index in snd_hda_add_new_ctls()
3355 if (!addr && codec->core.addr) in snd_hda_add_new_ctls()
3356 addr = codec->core.addr; in snd_hda_add_new_ctls()
3358 idx = find_empty_mixer_ctl_idx(codec, in snd_hda_add_new_ctls()
3371 static void codec_set_power_save(struct hda_codec *codec, int delay) in codec_set_power_save() argument
3373 struct device *dev = hda_codec_dev(codec); in codec_set_power_save()
3375 if (delay == 0 && codec->auto_runtime_pm) in codec_set_power_save()
3408 * @codec: HD-audio codec
3419 int snd_hda_check_amp_list_power(struct hda_codec *codec, in snd_hda_check_amp_list_power() argument
3437 v = snd_hda_codec_amp_read(codec, p->nid, ch, p->dir, in snd_hda_check_amp_list_power()
3442 snd_hda_power_up_pm(codec); in snd_hda_check_amp_list_power()
3450 snd_hda_power_down_pm(codec); in snd_hda_check_amp_list_power()
3486 * @codec: the HDA codec
3492 int snd_hda_input_mux_put(struct hda_codec *codec, in snd_hda_input_mux_put() argument
3507 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, in snd_hda_input_mux_put()
3547 static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid, in setup_dig_out_stream() argument
3554 spdif = snd_hda_spdif_out_of_nid(codec, nid); in setup_dig_out_stream()
3561 curr_fmt = snd_hda_codec_read(codec, nid, 0, in setup_dig_out_stream()
3563 reset = codec->spdif_status_reset && in setup_dig_out_stream()
3570 set_dig_out_convert(codec, nid, in setup_dig_out_stream()
3573 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); in setup_dig_out_stream()
3574 if (codec->slave_dig_outs) { in setup_dig_out_stream()
3576 for (d = codec->slave_dig_outs; *d; d++) in setup_dig_out_stream()
3577 snd_hda_codec_setup_stream(codec, *d, stream_tag, 0, in setup_dig_out_stream()
3582 set_dig_out_convert(codec, nid, in setup_dig_out_stream()
3586 static void cleanup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid) in cleanup_dig_out_stream() argument
3588 snd_hda_codec_cleanup_stream(codec, nid); in cleanup_dig_out_stream()
3589 if (codec->slave_dig_outs) { in cleanup_dig_out_stream()
3591 for (d = codec->slave_dig_outs; *d; d++) in cleanup_dig_out_stream()
3592 snd_hda_codec_cleanup_stream(codec, *d); in cleanup_dig_out_stream()
3598 * @codec: the HDA codec
3601 int snd_hda_multi_out_dig_open(struct hda_codec *codec, in snd_hda_multi_out_dig_open() argument
3604 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_open()
3607 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_dig_open()
3609 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_open()
3616 * @codec: the HDA codec
3622 int snd_hda_multi_out_dig_prepare(struct hda_codec *codec, in snd_hda_multi_out_dig_prepare() argument
3628 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_prepare()
3629 setup_dig_out_stream(codec, mout->dig_out_nid, stream_tag, format); in snd_hda_multi_out_dig_prepare()
3630 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_prepare()
3637 * @codec: the HDA codec
3640 int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec, in snd_hda_multi_out_dig_cleanup() argument
3643 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_cleanup()
3644 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_dig_cleanup()
3645 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_cleanup()
3652 * @codec: the HDA codec
3655 int snd_hda_multi_out_dig_close(struct hda_codec *codec, in snd_hda_multi_out_dig_close() argument
3658 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_dig_close()
3660 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_dig_close()
3667 * @codec: the HDA codec
3676 int snd_hda_multi_out_analog_open(struct hda_codec *codec, in snd_hda_multi_out_analog_open() argument
3694 snd_hda_query_supported_pcm(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_open()
3699 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_open()
3712 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_open()
3721 * @codec: the HDA codec
3730 int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, in snd_hda_multi_out_analog_prepare() argument
3741 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_prepare()
3742 spdif = snd_hda_spdif_out_of_nid(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_prepare()
3746 snd_hda_is_supported_format(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_prepare()
3750 setup_dig_out_stream(codec, mout->dig_out_nid, in snd_hda_multi_out_analog_prepare()
3754 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_prepare()
3757 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_prepare()
3760 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, in snd_hda_multi_out_analog_prepare()
3765 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, in snd_hda_multi_out_analog_prepare()
3770 snd_hda_codec_setup_stream(codec, in snd_hda_multi_out_analog_prepare()
3777 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, in snd_hda_multi_out_analog_prepare()
3780 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, in snd_hda_multi_out_analog_prepare()
3793 snd_hda_codec_setup_stream(codec, mout->extra_out_nid[i], in snd_hda_multi_out_analog_prepare()
3803 * @codec: the HDA codec
3806 int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, in snd_hda_multi_out_analog_cleanup() argument
3813 snd_hda_codec_cleanup_stream(codec, nids[i]); in snd_hda_multi_out_analog_cleanup()
3815 snd_hda_codec_cleanup_stream(codec, mout->hp_nid); in snd_hda_multi_out_analog_cleanup()
3818 snd_hda_codec_cleanup_stream(codec, in snd_hda_multi_out_analog_cleanup()
3822 snd_hda_codec_cleanup_stream(codec, in snd_hda_multi_out_analog_cleanup()
3824 mutex_lock(&codec->spdif_mutex); in snd_hda_multi_out_analog_cleanup()
3826 cleanup_dig_out_stream(codec, mout->dig_out_nid); in snd_hda_multi_out_analog_cleanup()
3829 mutex_unlock(&codec->spdif_mutex); in snd_hda_multi_out_analog_cleanup()
3836 * @codec: the HDA codec
3842 unsigned int snd_hda_get_default_vref(struct hda_codec *codec, hda_nid_t pin) in snd_hda_get_default_vref() argument
3846 oldval = snd_hda_codec_read(codec, pin, 0, in snd_hda_get_default_vref()
3848 pincap = snd_hda_query_pin_caps(codec, pin); in snd_hda_get_default_vref()
3865 * @codec: the HDA codec
3869 unsigned int snd_hda_correct_pin_ctl(struct hda_codec *codec, in snd_hda_correct_pin_ctl() argument
3882 cap = snd_hda_query_pin_caps(codec, pin); in snd_hda_correct_pin_ctl()
3921 * @codec: the HDA codec
3924 * @cached: access over codec pinctl cache or direct write
3932 int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, in _snd_hda_set_pin_ctl() argument
3935 val = snd_hda_correct_pin_ctl(codec, pin, val); in _snd_hda_set_pin_ctl()
3936 snd_hda_codec_set_pin_target(codec, pin, val); in _snd_hda_set_pin_ctl()
3938 return snd_hda_codec_write_cache(codec, pin, 0, in _snd_hda_set_pin_ctl()
3941 return snd_hda_codec_write(codec, pin, 0, in _snd_hda_set_pin_ctl()
3948 * @codec: the HDA codec
3958 int snd_hda_add_imux_item(struct hda_codec *codec, in snd_hda_add_imux_item() argument
3964 codec_err(codec, "hda_codec: Too many imux items!\n"); in snd_hda_add_imux_item()
3992 struct hda_codec *codec; in snd_hda_bus_reset_codecs() local
3994 list_for_each_codec(codec, bus) { in snd_hda_bus_reset_codecs()
3996 if (current_work() != &codec->jackpoll_work.work) in snd_hda_bus_reset_codecs()
3997 cancel_delayed_work_sync(&codec->jackpoll_work); in snd_hda_bus_reset_codecs()
3999 if (hda_codec_is_power_on(codec)) { in snd_hda_bus_reset_codecs()
4000 hda_call_codec_suspend(codec); in snd_hda_bus_reset_codecs()
4001 hda_call_codec_resume(codec); in snd_hda_bus_reset_codecs()
4028 MODULE_DESCRIPTION("HDA codec core");