Lines Matching +full:codec +full:- +full:0

1 // SPDX-License-Identifier: GPL-2.0-only
3 * HD-audio codec core device
19 static void setup_fg_nodes(struct hdac_device *codec);
20 static int get_codec_vendor_name(struct hdac_device *codec);
28 * snd_hdac_device_init - initialize the HD-audio codec base device
29 * @codec: device to initialize
32 * @addr: codec address
41 int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, in snd_hdac_device_init() argument
48 dev = &codec->dev; in snd_hdac_device_init()
50 dev->parent = bus->dev; in snd_hdac_device_init()
51 dev->bus = &snd_hda_bus_type; in snd_hdac_device_init()
52 dev->release = default_release; in snd_hdac_device_init()
53 dev->groups = hdac_dev_attr_groups; in snd_hdac_device_init()
57 codec->bus = bus; in snd_hdac_device_init()
58 codec->addr = addr; in snd_hdac_device_init()
59 codec->type = HDA_DEV_CORE; in snd_hdac_device_init()
60 mutex_init(&codec->widget_lock); in snd_hdac_device_init()
61 mutex_init(&codec->regmap_lock); in snd_hdac_device_init()
62 pm_runtime_set_active(&codec->dev); in snd_hdac_device_init()
63 pm_runtime_get_noresume(&codec->dev); in snd_hdac_device_init()
64 atomic_set(&codec->in_pm, 0); in snd_hdac_device_init()
66 err = snd_hdac_bus_add_device(bus, codec); in snd_hdac_device_init()
67 if (err < 0) in snd_hdac_device_init()
71 codec->vendor_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, in snd_hdac_device_init()
73 if (codec->vendor_id == -1) { in snd_hdac_device_init()
77 codec->vendor_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, in snd_hdac_device_init()
81 codec->subsystem_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, in snd_hdac_device_init()
83 codec->revision_id = snd_hdac_read_parm(codec, AC_NODE_ROOT, in snd_hdac_device_init()
86 setup_fg_nodes(codec); in snd_hdac_device_init()
87 if (!codec->afg && !codec->mfg) { in snd_hdac_device_init()
89 err = -ENODEV; in snd_hdac_device_init()
93 fg = codec->afg ? codec->afg : codec->mfg; in snd_hdac_device_init()
95 err = snd_hdac_refresh_widgets(codec); in snd_hdac_device_init()
96 if (err < 0) in snd_hdac_device_init()
99 codec->power_caps = snd_hdac_read_parm(codec, fg, AC_PAR_POWER_STATE); in snd_hdac_device_init()
101 if (codec->subsystem_id == -1 || codec->subsystem_id == 0) in snd_hdac_device_init()
102 snd_hdac_read(codec, fg, AC_VERB_GET_SUBSYSTEM_ID, 0, in snd_hdac_device_init()
103 &codec->subsystem_id); in snd_hdac_device_init()
105 err = get_codec_vendor_name(codec); in snd_hdac_device_init()
106 if (err < 0) in snd_hdac_device_init()
109 codec->chip_name = kasprintf(GFP_KERNEL, "ID %x", in snd_hdac_device_init()
110 codec->vendor_id & 0xffff); in snd_hdac_device_init()
111 if (!codec->chip_name) { in snd_hdac_device_init()
112 err = -ENOMEM; in snd_hdac_device_init()
116 return 0; in snd_hdac_device_init()
119 put_device(&codec->dev); in snd_hdac_device_init()
125 * snd_hdac_device_exit - clean up the HD-audio codec base device
126 * @codec: device to clean up
128 void snd_hdac_device_exit(struct hdac_device *codec) in snd_hdac_device_exit() argument
130 pm_runtime_put_noidle(&codec->dev); in snd_hdac_device_exit()
132 pm_runtime_set_suspended(&codec->dev); in snd_hdac_device_exit()
133 snd_hdac_bus_remove_device(codec->bus, codec); in snd_hdac_device_exit()
134 kfree(codec->vendor_name); in snd_hdac_device_exit()
135 kfree(codec->chip_name); in snd_hdac_device_exit()
140 * snd_hdac_device_register - register the hd-audio codec base device
141 * @codec: the device to register
143 int snd_hdac_device_register(struct hdac_device *codec) in snd_hdac_device_register() argument
147 err = device_add(&codec->dev); in snd_hdac_device_register()
148 if (err < 0) in snd_hdac_device_register()
150 mutex_lock(&codec->widget_lock); in snd_hdac_device_register()
151 err = hda_widget_sysfs_init(codec); in snd_hdac_device_register()
152 mutex_unlock(&codec->widget_lock); in snd_hdac_device_register()
153 if (err < 0) { in snd_hdac_device_register()
154 device_del(&codec->dev); in snd_hdac_device_register()
158 return 0; in snd_hdac_device_register()
163 * snd_hdac_device_unregister - unregister the hd-audio codec base device
164 * @codec: the device to unregister
166 void snd_hdac_device_unregister(struct hdac_device *codec) in snd_hdac_device_unregister() argument
168 if (device_is_registered(&codec->dev)) { in snd_hdac_device_unregister()
169 mutex_lock(&codec->widget_lock); in snd_hdac_device_unregister()
170 hda_widget_sysfs_exit(codec); in snd_hdac_device_unregister()
171 mutex_unlock(&codec->widget_lock); in snd_hdac_device_unregister()
172 device_del(&codec->dev); in snd_hdac_device_unregister()
173 snd_hdac_bus_remove_device(codec->bus, codec); in snd_hdac_device_unregister()
179 * snd_hdac_device_set_chip_name - set/update the codec name
180 * @codec: the HDAC device
183 * Returns 0 if the name is set or updated, or a negative error code.
185 int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name) in snd_hdac_device_set_chip_name() argument
190 return 0; in snd_hdac_device_set_chip_name()
193 return -ENOMEM; in snd_hdac_device_set_chip_name()
194 kfree(codec->chip_name); in snd_hdac_device_set_chip_name()
195 codec->chip_name = newname; in snd_hdac_device_set_chip_name()
196 return 0; in snd_hdac_device_set_chip_name()
201 * snd_hdac_codec_modalias - give the module alias name
202 * @codec: HDAC device
208 int snd_hdac_codec_modalias(const struct hdac_device *codec, char *buf, size_t size) in snd_hdac_codec_modalias() argument
211 codec->vendor_id, codec->revision_id, codec->type); in snd_hdac_codec_modalias()
216 * snd_hdac_make_cmd - compose a 32bit command word to be sent to the
217 * HD-audio controller
218 * @codec: the codec object
223 * Return an encoded command verb or -1 for error.
225 static unsigned int snd_hdac_make_cmd(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_make_cmd() argument
230 addr = codec->addr; in snd_hdac_make_cmd()
231 if ((addr & ~0xf) || (nid & ~0x7f) || in snd_hdac_make_cmd()
232 (verb & ~0xfff) || (parm & ~0xffff)) { in snd_hdac_make_cmd()
233 dev_err(&codec->dev, "out of range cmd %x:%x:%x:%x\n", in snd_hdac_make_cmd()
235 return -1; in snd_hdac_make_cmd()
246 * snd_hdac_exec_verb - execute an encoded verb
247 * @codec: the codec object
257 int snd_hdac_exec_verb(struct hdac_device *codec, unsigned int cmd, in snd_hdac_exec_verb() argument
260 if (codec->exec_verb) in snd_hdac_exec_verb()
261 return codec->exec_verb(codec, cmd, flags, res); in snd_hdac_exec_verb()
262 return snd_hdac_bus_exec_verb(codec->bus, codec->addr, cmd, res); in snd_hdac_exec_verb()
267 * snd_hdac_read - execute a verb
268 * @codec: the codec object
276 int snd_hdac_read(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_read() argument
279 unsigned int cmd = snd_hdac_make_cmd(codec, nid, verb, parm); in snd_hdac_read()
281 return snd_hdac_exec_verb(codec, cmd, 0, res); in snd_hdac_read()
286 * _snd_hdac_read_parm - read a parmeter
287 * @codec: the codec object
294 int _snd_hdac_read_parm(struct hdac_device *codec, hda_nid_t nid, int parm, in _snd_hdac_read_parm() argument
300 return snd_hdac_regmap_read_raw(codec, cmd, res); in _snd_hdac_read_parm()
305 * snd_hdac_read_parm_uncached - read a codec parameter without caching
306 * @codec: the codec object
310 * Returns -1 for error. If you need to distinguish the error more
313 int snd_hdac_read_parm_uncached(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_read_parm_uncached() argument
319 if (snd_hdac_regmap_read_raw_uncached(codec, cmd, &val) < 0) in snd_hdac_read_parm_uncached()
320 return -1; in snd_hdac_read_parm_uncached()
326 * snd_hdac_override_parm - override read-only parameters
327 * @codec: the codec object
332 int snd_hdac_override_parm(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_override_parm() argument
338 if (!codec->regmap) in snd_hdac_override_parm()
339 return -EINVAL; in snd_hdac_override_parm()
341 codec->caps_overwriting = true; in snd_hdac_override_parm()
342 err = snd_hdac_regmap_write_raw(codec, verb, val); in snd_hdac_override_parm()
343 codec->caps_overwriting = false; in snd_hdac_override_parm()
349 * snd_hdac_get_sub_nodes - get start NID and number of subtree nodes
350 * @codec: the codec object
357 int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_get_sub_nodes() argument
362 parm = snd_hdac_read_parm_uncached(codec, nid, AC_PAR_NODE_COUNT); in snd_hdac_get_sub_nodes()
363 if (parm == -1) { in snd_hdac_get_sub_nodes()
364 *start_id = 0; in snd_hdac_get_sub_nodes()
365 return 0; in snd_hdac_get_sub_nodes()
367 *start_id = (parm >> 16) & 0x7fff; in snd_hdac_get_sub_nodes()
368 return (int)(parm & 0x7fff); in snd_hdac_get_sub_nodes()
375 static void setup_fg_nodes(struct hdac_device *codec) in setup_fg_nodes() argument
380 total_nodes = snd_hdac_get_sub_nodes(codec, AC_NODE_ROOT, &nid); in setup_fg_nodes()
381 for (i = 0; i < total_nodes; i++, nid++) { in setup_fg_nodes()
382 function_id = snd_hdac_read_parm(codec, nid, in setup_fg_nodes()
384 switch (function_id & 0xff) { in setup_fg_nodes()
386 codec->afg = nid; in setup_fg_nodes()
387 codec->afg_function_id = function_id & 0xff; in setup_fg_nodes()
388 codec->afg_unsol = (function_id >> 8) & 1; in setup_fg_nodes()
391 codec->mfg = nid; in setup_fg_nodes()
392 codec->mfg_function_id = function_id & 0xff; in setup_fg_nodes()
393 codec->mfg_unsol = (function_id >> 8) & 1; in setup_fg_nodes()
402 * snd_hdac_refresh_widgets - Reset the widget start/end nodes
403 * @codec: the codec object
405 int snd_hdac_refresh_widgets(struct hdac_device *codec) in snd_hdac_refresh_widgets() argument
408 int nums, err = 0; in snd_hdac_refresh_widgets()
414 mutex_lock(&codec->widget_lock); in snd_hdac_refresh_widgets()
415 nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid); in snd_hdac_refresh_widgets()
416 if (!start_nid || nums <= 0 || nums >= 0xff) { in snd_hdac_refresh_widgets()
417 dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n", in snd_hdac_refresh_widgets()
418 codec->afg); in snd_hdac_refresh_widgets()
419 err = -EINVAL; in snd_hdac_refresh_widgets()
423 err = hda_widget_sysfs_reinit(codec, start_nid, nums); in snd_hdac_refresh_widgets()
424 if (err < 0) in snd_hdac_refresh_widgets()
427 codec->num_nodes = nums; in snd_hdac_refresh_widgets()
428 codec->start_nid = start_nid; in snd_hdac_refresh_widgets()
429 codec->end_nid = start_nid + nums; in snd_hdac_refresh_widgets()
431 mutex_unlock(&codec->widget_lock); in snd_hdac_refresh_widgets()
437 static unsigned int get_num_conns(struct hdac_device *codec, hda_nid_t nid) in get_num_conns() argument
439 unsigned int wcaps = get_wcaps(codec, nid); in get_num_conns()
444 return 0; in get_num_conns()
446 parm = snd_hdac_read_parm(codec, nid, AC_PAR_CONNLIST_LEN); in get_num_conns()
447 if (parm == -1) in get_num_conns()
448 parm = 0; in get_num_conns()
453 * snd_hdac_get_connections - get a widget connection list
454 * @codec: the codec object
461 * given array size, it returns -ENOSPC.
465 int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_get_connections() argument
472 int null_count = 0; in snd_hdac_get_connections()
474 parm = get_num_conns(codec, nid); in snd_hdac_get_connections()
476 return 0; in snd_hdac_get_connections()
488 mask = (1 << (shift-1)) - 1; in snd_hdac_get_connections()
491 return 0; /* no connection */ in snd_hdac_get_connections()
495 err = snd_hdac_read(codec, nid, AC_VERB_GET_CONNECT_LIST, 0, in snd_hdac_get_connections()
497 if (err < 0) in snd_hdac_get_connections()
500 conn_list[0] = parm & mask; in snd_hdac_get_connections()
505 conns = 0; in snd_hdac_get_connections()
506 prev_nid = 0; in snd_hdac_get_connections()
507 for (i = 0; i < conn_len; i++) { in snd_hdac_get_connections()
511 if (i % num_elems == 0) { in snd_hdac_get_connections()
512 err = snd_hdac_read(codec, nid, in snd_hdac_get_connections()
515 if (err < 0) in snd_hdac_get_connections()
516 return -EIO; in snd_hdac_get_connections()
518 range_val = !!(parm & (1 << (shift-1))); /* ranges */ in snd_hdac_get_connections()
520 if (val == 0 && null_count++) { /* no second chance */ in snd_hdac_get_connections()
521 dev_dbg(&codec->dev, in snd_hdac_get_connections()
524 return 0; in snd_hdac_get_connections()
530 dev_warn(&codec->dev, in snd_hdac_get_connections()
538 return -ENOSPC; in snd_hdac_get_connections()
546 return -ENOSPC; in snd_hdac_get_connections()
559 * snd_hdac_power_up - power up the codec
560 * @codec: the codec object
562 * This function calls the runtime PM helper to power up the given codec.
568 int snd_hdac_power_up(struct hdac_device *codec) in snd_hdac_power_up() argument
570 return pm_runtime_get_sync(&codec->dev); in snd_hdac_power_up()
575 * snd_hdac_power_down - power down the codec
576 * @codec: the codec object
580 int snd_hdac_power_down(struct hdac_device *codec) in snd_hdac_power_down() argument
582 struct device *dev = &codec->dev; in snd_hdac_power_down()
590 * snd_hdac_power_up_pm - power up the codec
591 * @codec: the codec object
594 * which may be called by PM suspend/resume again. OTOH, if a power-up
600 int snd_hdac_power_up_pm(struct hdac_device *codec) in snd_hdac_power_up_pm() argument
602 if (!atomic_inc_not_zero(&codec->in_pm)) in snd_hdac_power_up_pm()
603 return snd_hdac_power_up(codec); in snd_hdac_power_up_pm()
604 return 0; in snd_hdac_power_up_pm()
609 * already powered up. Returns -1 if not powered up, 1 if incremented
610 * or 0 if unchanged. Only used in hdac_regmap.c
612 int snd_hdac_keep_power_up(struct hdac_device *codec) in snd_hdac_keep_power_up() argument
614 if (!atomic_inc_not_zero(&codec->in_pm)) { in snd_hdac_keep_power_up()
615 int ret = pm_runtime_get_if_active(&codec->dev); in snd_hdac_keep_power_up()
617 return -1; in snd_hdac_keep_power_up()
618 if (ret < 0) in snd_hdac_keep_power_up()
619 return 0; in snd_hdac_keep_power_up()
625 * snd_hdac_power_down_pm - power down the codec
626 * @codec: the codec object
633 int snd_hdac_power_down_pm(struct hdac_device *codec) in snd_hdac_power_down_pm() argument
635 if (atomic_dec_if_positive(&codec->in_pm) < 0) in snd_hdac_power_down_pm()
636 return snd_hdac_power_down(codec); in snd_hdac_power_down_pm()
637 return 0; in snd_hdac_power_down_pm()
642 /* codec vendor labels */
649 { 0x0014, "Loongson" },
650 { 0x1002, "ATI" },
651 { 0x1013, "Cirrus Logic" },
652 { 0x1057, "Motorola" },
653 { 0x1095, "Silicon Image" },
654 { 0x10de, "Nvidia" },
655 { 0x10ec, "Realtek" },
656 { 0x1102, "Creative" },
657 { 0x1106, "VIA" },
658 { 0x111d, "IDT" },
659 { 0x11c1, "LSI" },
660 { 0x11d4, "Analog Devices" },
661 { 0x13f6, "C-Media" },
662 { 0x14f1, "Conexant" },
663 { 0x17e8, "Chrontel" },
664 { 0x1854, "LG" },
665 { 0x19e5, "Huawei" },
666 { 0x1aec, "Wolfson Microelectronics" },
667 { 0x1af4, "QEMU" },
668 { 0x1fa8, "Senarytech" },
669 { 0x434d, "C-Media" },
670 { 0x8086, "Intel" },
671 { 0x8384, "SigmaTel" },
675 /* store the codec vendor name */
676 static int get_codec_vendor_name(struct hdac_device *codec) in get_codec_vendor_name() argument
679 u16 vendor_id = codec->vendor_id >> 16; in get_codec_vendor_name()
681 for (c = hda_vendor_ids; c->id; c++) { in get_codec_vendor_name()
682 if (c->id == vendor_id) { in get_codec_vendor_name()
683 codec->vendor_name = kstrdup(c->name, GFP_KERNEL); in get_codec_vendor_name()
684 return codec->vendor_name ? 0 : -ENOMEM; in get_codec_vendor_name()
688 codec->vendor_name = kasprintf(GFP_KERNEL, "Generic %04x", vendor_id); in get_codec_vendor_name()
689 return codec->vendor_name ? 0 : -ENOMEM; in get_codec_vendor_name()
703 (AC_FMT_BASE_##base##K | (((mult) - 1) << AC_FMT_MULT_SHIFT) | \
704 (((div) - 1) << AC_FMT_DIV_SHIFT))
727 { 0 } /* terminator */
755 * snd_hdac_stream_format_bits - obtain bits per sample value.
768 memset(&params, 0, sizeof(params)); in snd_hdac_stream_format_bits()
782 * snd_hdac_stream_format - convert format parameters to SDxFMT value.
791 unsigned int val = 0; in snd_hdac_stream_format()
794 for (i = 0; rate_bits[i].hz; i++) { in snd_hdac_stream_format()
802 return 0; in snd_hdac_stream_format()
804 if (channels == 0 || channels > 8) in snd_hdac_stream_format()
805 return 0; in snd_hdac_stream_format()
806 val |= channels - 1; in snd_hdac_stream_format()
825 return 0; in snd_hdac_stream_format()
833 * snd_hdac_spdif_stream_format - convert format parameters to SDxFMT value.
837 * @spdif_ctls: HD-audio SPDIF status bits (0 if irrelevant).
853 static unsigned int query_pcm_param(struct hdac_device *codec, hda_nid_t nid) in query_pcm_param() argument
855 unsigned int val = 0; in query_pcm_param()
857 if (nid != codec->afg && in query_pcm_param()
858 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) in query_pcm_param()
859 val = snd_hdac_read_parm(codec, nid, AC_PAR_PCM); in query_pcm_param()
860 if (!val || val == -1) in query_pcm_param()
861 val = snd_hdac_read_parm(codec, codec->afg, AC_PAR_PCM); in query_pcm_param()
862 if (!val || val == -1) in query_pcm_param()
863 return 0; in query_pcm_param()
867 static unsigned int query_stream_param(struct hdac_device *codec, hda_nid_t nid) in query_stream_param() argument
869 unsigned int streams = snd_hdac_read_parm(codec, nid, AC_PAR_STREAM); in query_stream_param()
871 if (!streams || streams == -1) in query_stream_param()
872 streams = snd_hdac_read_parm(codec, codec->afg, AC_PAR_STREAM); in query_stream_param()
873 if (!streams || streams == -1) in query_stream_param()
874 return 0; in query_stream_param()
879 * snd_hdac_query_supported_pcm - query the supported PCM rates and formats
880 * @codec: the codec object
890 * Returns 0 if successful, otherwise a negative error code.
892 int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_query_supported_pcm() argument
898 wcaps = get_wcaps(codec, nid); in snd_hdac_query_supported_pcm()
899 val = query_pcm_param(codec, nid); in snd_hdac_query_supported_pcm()
902 u32 rates = 0; in snd_hdac_query_supported_pcm()
903 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) { in snd_hdac_query_supported_pcm()
907 if (rates == 0) { in snd_hdac_query_supported_pcm()
908 dev_err(&codec->dev, in snd_hdac_query_supported_pcm()
909 "rates == 0 (nid=0x%x, val=0x%x, ovrd=%i)\n", in snd_hdac_query_supported_pcm()
911 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0); in snd_hdac_query_supported_pcm()
912 return -EIO; in snd_hdac_query_supported_pcm()
919 u32 subformats = 0; in snd_hdac_query_supported_pcm()
920 u64 formats = 0; in snd_hdac_query_supported_pcm()
922 streams = query_stream_param(codec, nid); in snd_hdac_query_supported_pcm()
924 return -EIO; in snd_hdac_query_supported_pcm()
926 bps = 0; in snd_hdac_query_supported_pcm()
956 #if 0 /* FIXME: CS4206 doesn't work, which is the only codec supporting float */ in snd_hdac_query_supported_pcm()
971 if (formats == 0) { in snd_hdac_query_supported_pcm()
972 dev_err(&codec->dev, in snd_hdac_query_supported_pcm()
973 "formats == 0 (nid=0x%x, val=0x%x, ovrd=%i, streams=0x%x)\n", in snd_hdac_query_supported_pcm()
975 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0, in snd_hdac_query_supported_pcm()
977 return -EIO; in snd_hdac_query_supported_pcm()
987 return 0; in snd_hdac_query_supported_pcm()
992 * snd_hdac_is_supported_format - Check the validity of the format
993 * @codec: the codec object
995 * @format: the HD-audio format value to check
1001 bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid, in snd_hdac_is_supported_format() argument
1005 unsigned int val = 0, rate, stream; in snd_hdac_is_supported_format()
1007 val = query_pcm_param(codec, nid); in snd_hdac_is_supported_format()
1011 rate = format & 0xff00; in snd_hdac_is_supported_format()
1012 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) in snd_hdac_is_supported_format()
1021 stream = query_stream_param(codec, nid); in snd_hdac_is_supported_format()
1026 switch (format & 0xf0) { in snd_hdac_is_supported_format()
1027 case 0x00: in snd_hdac_is_supported_format()
1031 case 0x10: in snd_hdac_is_supported_format()
1035 case 0x20: in snd_hdac_is_supported_format()
1039 case 0x30: in snd_hdac_is_supported_format()
1043 case 0x40: in snd_hdac_is_supported_format()
1065 return -1; in codec_read()
1079 * snd_hdac_codec_read - send a command and get the response
1088 * Returns the obtained response value, or -1 for an error.
1098 * snd_hdac_codec_write - send a single command without waiting for response
1107 * Returns 0 if successful, or a negative error code.
1117 * snd_hdac_check_power_state - check whether the actual power state matches
1129 unsigned int state = codec_read(hdac, nid, 0, in snd_hdac_check_power_state()
1130 AC_VERB_GET_POWER_STATE, 0); in snd_hdac_check_power_state()
1134 state = (state >> 4) & 0x0f; in snd_hdac_check_power_state()
1139 * snd_hdac_sync_power_state - wait until actual power state matches
1142 * @codec: the HDAC device
1146 * Return power state or PS_ERROR if codec rejects GET verb.
1148 unsigned int snd_hdac_sync_power_state(struct hdac_device *codec, in snd_hdac_sync_power_state() argument
1154 for (count = 0; count < 500; count++) { in snd_hdac_sync_power_state()
1155 state = snd_hdac_codec_read(codec, nid, 0, in snd_hdac_sync_power_state()
1156 AC_VERB_GET_POWER_STATE, 0); in snd_hdac_sync_power_state()
1161 actual_state = (state >> 4) & 0x0f; in snd_hdac_sync_power_state()
1166 /* wait until the codec reachs to the target state */ in snd_hdac_sync_power_state()