2 * HD-audio codec core device
5 #include <linux/init.h>
6 #include <linux/device.h>
7 #include <linux/slab.h>
8 #include <linux/module.h>
9 #include <linux/export.h>
10 #include <linux/pm_runtime.h>
11 #include <sound/hdaudio.h>
12 #include <sound/hda_regmap.h>
13 #include <sound/pcm.h>
16 static void setup_fg_nodes(struct hdac_device
*codec
);
17 static int get_codec_vendor_name(struct hdac_device
*codec
);
19 static void default_release(struct device
*dev
)
21 snd_hdac_device_exit(container_of(dev
, struct hdac_device
, dev
));
25 * snd_hdac_device_init - initialize the HD-audio codec base device
26 * @codec: device to initialize
28 * @name: device name string
29 * @addr: codec address
31 * Returns zero for success or a negative error code.
33 * This function increments the runtime PM counter and marks it active.
34 * The caller needs to turn it off appropriately later.
36 * The caller needs to set the device's release op properly by itself.
38 int snd_hdac_device_init(struct hdac_device
*codec
, struct hdac_bus
*bus
,
39 const char *name
, unsigned int addr
)
46 device_initialize(dev
);
47 dev
->parent
= bus
->dev
;
48 dev
->bus
= &snd_hda_bus_type
;
49 dev
->release
= default_release
;
50 dev
->groups
= hdac_dev_attr_groups
;
51 dev_set_name(dev
, "%s", name
);
52 device_enable_async_suspend(dev
);
56 codec
->type
= HDA_DEV_CORE
;
57 pm_runtime_set_active(&codec
->dev
);
58 pm_runtime_get_noresume(&codec
->dev
);
59 atomic_set(&codec
->in_pm
, 0);
61 err
= snd_hdac_bus_add_device(bus
, codec
);
66 codec
->vendor_id
= snd_hdac_read_parm(codec
, AC_NODE_ROOT
,
68 if (codec
->vendor_id
== -1) {
69 /* read again, hopefully the access method was corrected
72 codec
->vendor_id
= snd_hdac_read_parm(codec
, AC_NODE_ROOT
,
76 codec
->subsystem_id
= snd_hdac_read_parm(codec
, AC_NODE_ROOT
,
78 codec
->revision_id
= snd_hdac_read_parm(codec
, AC_NODE_ROOT
,
81 setup_fg_nodes(codec
);
82 if (!codec
->afg
&& !codec
->mfg
) {
83 dev_err(dev
, "no AFG or MFG node found\n");
88 fg
= codec
->afg
? codec
->afg
: codec
->mfg
;
90 err
= snd_hdac_refresh_widgets(codec
);
94 codec
->power_caps
= snd_hdac_read_parm(codec
, fg
, AC_PAR_POWER_STATE
);
95 /* reread ssid if not set by parameter */
96 if (codec
->subsystem_id
== -1 || codec
->subsystem_id
== 0)
97 snd_hdac_read(codec
, fg
, AC_VERB_GET_SUBSYSTEM_ID
, 0,
98 &codec
->subsystem_id
);
100 err
= get_codec_vendor_name(codec
);
104 codec
->chip_name
= kasprintf(GFP_KERNEL
, "ID %x",
105 codec
->vendor_id
& 0xffff);
106 if (!codec
->chip_name
) {
114 put_device(&codec
->dev
);
117 EXPORT_SYMBOL_GPL(snd_hdac_device_init
);
120 * snd_hdac_device_exit - clean up the HD-audio codec base device
121 * @codec: device to clean up
123 void snd_hdac_device_exit(struct hdac_device
*codec
)
125 pm_runtime_put_noidle(&codec
->dev
);
126 snd_hdac_bus_remove_device(codec
->bus
, codec
);
127 kfree(codec
->vendor_name
);
128 kfree(codec
->chip_name
);
130 EXPORT_SYMBOL_GPL(snd_hdac_device_exit
);
133 * snd_hdac_device_register - register the hd-audio codec base device
134 * codec: the device to register
136 int snd_hdac_device_register(struct hdac_device
*codec
)
140 err
= device_add(&codec
->dev
);
143 err
= hda_widget_sysfs_init(codec
);
145 device_del(&codec
->dev
);
151 EXPORT_SYMBOL_GPL(snd_hdac_device_register
);
154 * snd_hdac_device_unregister - unregister the hd-audio codec base device
155 * codec: the device to unregister
157 void snd_hdac_device_unregister(struct hdac_device
*codec
)
159 if (device_is_registered(&codec
->dev
)) {
160 hda_widget_sysfs_exit(codec
);
161 device_del(&codec
->dev
);
164 EXPORT_SYMBOL_GPL(snd_hdac_device_unregister
);
167 * snd_hdac_make_cmd - compose a 32bit command word to be sent to the
168 * HD-audio controller
169 * @codec: the codec object
170 * @nid: NID to encode
171 * @verb: verb to encode
172 * @parm: parameter to encode
174 * Return an encoded command verb or -1 for error.
176 unsigned int snd_hdac_make_cmd(struct hdac_device
*codec
, hda_nid_t nid
,
177 unsigned int verb
, unsigned int parm
)
182 if ((addr
& ~0xf) || (nid
& ~0x7f) ||
183 (verb
& ~0xfff) || (parm
& ~0xffff)) {
184 dev_err(&codec
->dev
, "out of range cmd %x:%x:%x:%x\n",
185 addr
, nid
, verb
, parm
);
190 val
|= (u32
)nid
<< 20;
195 EXPORT_SYMBOL_GPL(snd_hdac_make_cmd
);
198 * snd_hdac_exec_verb - execute an encoded verb
199 * @codec: the codec object
200 * @cmd: encoded verb to execute
201 * @flags: optional flags, pass zero for default
202 * @res: the pointer to store the result, NULL if running async
204 * Returns zero if successful, or a negative error code.
206 * This calls the exec_verb op when set in hdac_codec. If not,
207 * call the default snd_hdac_bus_exec_verb().
209 int snd_hdac_exec_verb(struct hdac_device
*codec
, unsigned int cmd
,
210 unsigned int flags
, unsigned int *res
)
212 if (codec
->exec_verb
)
213 return codec
->exec_verb(codec
, cmd
, flags
, res
);
214 return snd_hdac_bus_exec_verb(codec
->bus
, codec
->addr
, cmd
, res
);
216 EXPORT_SYMBOL_GPL(snd_hdac_exec_verb
);
220 * snd_hdac_read - execute a verb
221 * @codec: the codec object
222 * @nid: NID to execute a verb
223 * @verb: verb to execute
224 * @parm: parameter for a verb
225 * @res: the pointer to store the result, NULL if running async
227 * Returns zero if successful, or a negative error code.
229 int snd_hdac_read(struct hdac_device
*codec
, hda_nid_t nid
,
230 unsigned int verb
, unsigned int parm
, unsigned int *res
)
232 unsigned int cmd
= snd_hdac_make_cmd(codec
, nid
, verb
, parm
);
234 return snd_hdac_exec_verb(codec
, cmd
, 0, res
);
236 EXPORT_SYMBOL_GPL(snd_hdac_read
);
239 * _snd_hdac_read_parm - read a parmeter
241 * This function returns zero or an error unlike snd_hdac_read_parm().
243 int _snd_hdac_read_parm(struct hdac_device
*codec
, hda_nid_t nid
, int parm
,
248 cmd
= snd_hdac_regmap_encode_verb(nid
, AC_VERB_PARAMETERS
) | parm
;
249 return snd_hdac_regmap_read_raw(codec
, cmd
, res
);
251 EXPORT_SYMBOL_GPL(_snd_hdac_read_parm
);
254 * snd_hdac_read_parm_uncached - read a codec parameter without caching
255 * @codec: the codec object
256 * @nid: NID to read a parameter
257 * @parm: parameter to read
259 * Returns -1 for error. If you need to distinguish the error more
260 * strictly, use snd_hdac_read() directly.
262 int snd_hdac_read_parm_uncached(struct hdac_device
*codec
, hda_nid_t nid
,
268 regcache_cache_bypass(codec
->regmap
, true);
269 val
= snd_hdac_read_parm(codec
, nid
, parm
);
271 regcache_cache_bypass(codec
->regmap
, false);
274 EXPORT_SYMBOL_GPL(snd_hdac_read_parm_uncached
);
277 * snd_hdac_override_parm - override read-only parameters
278 * @codec: the codec object
279 * @nid: NID for the parameter
280 * @parm: the parameter to change
281 * @val: the parameter value to overwrite
283 int snd_hdac_override_parm(struct hdac_device
*codec
, hda_nid_t nid
,
284 unsigned int parm
, unsigned int val
)
286 unsigned int verb
= (AC_VERB_PARAMETERS
<< 8) | (nid
<< 20) | parm
;
292 codec
->caps_overwriting
= true;
293 err
= snd_hdac_regmap_write_raw(codec
, verb
, val
);
294 codec
->caps_overwriting
= false;
297 EXPORT_SYMBOL_GPL(snd_hdac_override_parm
);
300 * snd_hdac_get_sub_nodes - get start NID and number of subtree nodes
301 * @codec: the codec object
302 * @nid: NID to inspect
303 * @start_id: the pointer to store the starting NID
305 * Returns the number of subtree nodes or zero if not found.
306 * This function reads parameters always without caching.
308 int snd_hdac_get_sub_nodes(struct hdac_device
*codec
, hda_nid_t nid
,
313 parm
= snd_hdac_read_parm_uncached(codec
, nid
, AC_PAR_NODE_COUNT
);
318 *start_id
= (parm
>> 16) & 0x7fff;
319 return (int)(parm
& 0x7fff);
321 EXPORT_SYMBOL_GPL(snd_hdac_get_sub_nodes
);
324 * look for an AFG and MFG nodes
326 static void setup_fg_nodes(struct hdac_device
*codec
)
328 int i
, total_nodes
, function_id
;
331 total_nodes
= snd_hdac_get_sub_nodes(codec
, AC_NODE_ROOT
, &nid
);
332 for (i
= 0; i
< total_nodes
; i
++, nid
++) {
333 function_id
= snd_hdac_read_parm(codec
, nid
,
334 AC_PAR_FUNCTION_TYPE
);
335 switch (function_id
& 0xff) {
336 case AC_GRP_AUDIO_FUNCTION
:
338 codec
->afg_function_id
= function_id
& 0xff;
339 codec
->afg_unsol
= (function_id
>> 8) & 1;
341 case AC_GRP_MODEM_FUNCTION
:
343 codec
->mfg_function_id
= function_id
& 0xff;
344 codec
->mfg_unsol
= (function_id
>> 8) & 1;
353 * snd_hdac_refresh_widgets - Reset the widget start/end nodes
354 * @codec: the codec object
356 int snd_hdac_refresh_widgets(struct hdac_device
*codec
)
361 nums
= snd_hdac_get_sub_nodes(codec
, codec
->afg
, &start_nid
);
362 if (!start_nid
|| nums
<= 0 || nums
>= 0xff) {
363 dev_err(&codec
->dev
, "cannot read sub nodes for FG 0x%02x\n",
368 codec
->num_nodes
= nums
;
369 codec
->start_nid
= start_nid
;
370 codec
->end_nid
= start_nid
+ nums
;
373 EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets
);
375 /* return CONNLIST_LEN parameter of the given widget */
376 static unsigned int get_num_conns(struct hdac_device
*codec
, hda_nid_t nid
)
378 unsigned int wcaps
= get_wcaps(codec
, nid
);
381 if (!(wcaps
& AC_WCAP_CONN_LIST
) &&
382 get_wcaps_type(wcaps
) != AC_WID_VOL_KNB
)
385 parm
= snd_hdac_read_parm(codec
, nid
, AC_PAR_CONNLIST_LEN
);
392 * snd_hdac_get_connections - get a widget connection list
393 * @codec: the codec object
395 * @conn_list: the array to store the results, can be NULL
396 * @max_conns: the max size of the given array
398 * Returns the number of connected widgets, zero for no connection, or a
399 * negative error code. When the number of elements don't fit with the
400 * given array size, it returns -ENOSPC.
402 * When @conn_list is NULL, it just checks the number of connections.
404 int snd_hdac_get_connections(struct hdac_device
*codec
, hda_nid_t nid
,
405 hda_nid_t
*conn_list
, int max_conns
)
408 int i
, conn_len
, conns
, err
;
409 unsigned int shift
, num_elems
, mask
;
413 parm
= get_num_conns(codec
, nid
);
417 if (parm
& AC_CLIST_LONG
) {
426 conn_len
= parm
& AC_CLIST_LENGTH
;
427 mask
= (1 << (shift
-1)) - 1;
430 return 0; /* no connection */
433 /* single connection */
434 err
= snd_hdac_read(codec
, nid
, AC_VERB_GET_CONNECT_LIST
, 0,
439 conn_list
[0] = parm
& mask
;
443 /* multi connection */
446 for (i
= 0; i
< conn_len
; i
++) {
450 if (i
% num_elems
== 0) {
451 err
= snd_hdac_read(codec
, nid
,
452 AC_VERB_GET_CONNECT_LIST
, i
,
457 range_val
= !!(parm
& (1 << (shift
-1))); /* ranges */
459 if (val
== 0 && null_count
++) { /* no second chance */
461 "invalid CONNECT_LIST verb %x[%i]:%x\n",
467 /* ranges between the previous and this one */
468 if (!prev_nid
|| prev_nid
>= val
) {
469 dev_warn(&codec
->dev
,
470 "invalid dep_range_val %x:%x\n",
474 for (n
= prev_nid
+ 1; n
<= val
; n
++) {
476 if (conns
>= max_conns
)
478 conn_list
[conns
] = n
;
484 if (conns
>= max_conns
)
486 conn_list
[conns
] = val
;
494 EXPORT_SYMBOL_GPL(snd_hdac_get_connections
);
498 * snd_hdac_power_up - power up the codec
499 * @codec: the codec object
501 * This function calls the runtime PM helper to power up the given codec.
502 * Unlike snd_hdac_power_up_pm(), you should call this only for the code
503 * path that isn't included in PM path. Otherwise it gets stuck.
505 * Returns zero if successful, or a negative error code.
507 int snd_hdac_power_up(struct hdac_device
*codec
)
509 return pm_runtime_get_sync(&codec
->dev
);
511 EXPORT_SYMBOL_GPL(snd_hdac_power_up
);
514 * snd_hdac_power_down - power down the codec
515 * @codec: the codec object
517 * Returns zero if successful, or a negative error code.
519 int snd_hdac_power_down(struct hdac_device
*codec
)
521 struct device
*dev
= &codec
->dev
;
523 pm_runtime_mark_last_busy(dev
);
524 return pm_runtime_put_autosuspend(dev
);
526 EXPORT_SYMBOL_GPL(snd_hdac_power_down
);
529 * snd_hdac_power_up_pm - power up the codec
530 * @codec: the codec object
532 * This function can be called in a recursive code path like init code
533 * which may be called by PM suspend/resume again. OTOH, if a power-up
534 * call must wake up the sleeper (e.g. in a kctl callback), use
535 * snd_hdac_power_up() instead.
537 * Returns zero if successful, or a negative error code.
539 int snd_hdac_power_up_pm(struct hdac_device
*codec
)
541 if (!atomic_inc_not_zero(&codec
->in_pm
))
542 return snd_hdac_power_up(codec
);
545 EXPORT_SYMBOL_GPL(snd_hdac_power_up_pm
);
548 * snd_hdac_power_down_pm - power down the codec
549 * @codec: the codec object
551 * Like snd_hdac_power_up_pm(), this function is used in a recursive
552 * code path like init code which may be called by PM suspend/resume again.
554 * Returns zero if successful, or a negative error code.
556 int snd_hdac_power_down_pm(struct hdac_device
*codec
)
558 if (atomic_dec_if_positive(&codec
->in_pm
) < 0)
559 return snd_hdac_power_down(codec
);
562 EXPORT_SYMBOL_GPL(snd_hdac_power_down_pm
);
566 * Enable/disable the link power for a codec.
568 int snd_hdac_link_power(struct hdac_device
*codec
, bool enable
)
570 if (!codec
->link_power_control
)
573 if (codec
->bus
->ops
->link_power
)
574 return codec
->bus
->ops
->link_power(codec
->bus
, enable
);
578 EXPORT_SYMBOL_GPL(snd_hdac_link_power
);
580 /* codec vendor labels */
581 struct hda_vendor_id
{
586 static struct hda_vendor_id hda_vendor_ids
[] = {
588 { 0x1013, "Cirrus Logic" },
589 { 0x1057, "Motorola" },
590 { 0x1095, "Silicon Image" },
591 { 0x10de, "Nvidia" },
592 { 0x10ec, "Realtek" },
593 { 0x1102, "Creative" },
597 { 0x11d4, "Analog Devices" },
598 { 0x13f6, "C-Media" },
599 { 0x14f1, "Conexant" },
600 { 0x17e8, "Chrontel" },
602 { 0x1aec, "Wolfson Microelectronics" },
604 { 0x434d, "C-Media" },
606 { 0x8384, "SigmaTel" },
610 /* store the codec vendor name */
611 static int get_codec_vendor_name(struct hdac_device
*codec
)
613 const struct hda_vendor_id
*c
;
614 u16 vendor_id
= codec
->vendor_id
>> 16;
616 for (c
= hda_vendor_ids
; c
->id
; c
++) {
617 if (c
->id
== vendor_id
) {
618 codec
->vendor_name
= kstrdup(c
->name
, GFP_KERNEL
);
619 return codec
->vendor_name
? 0 : -ENOMEM
;
623 codec
->vendor_name
= kasprintf(GFP_KERNEL
, "Generic %04x", vendor_id
);
624 return codec
->vendor_name
? 0 : -ENOMEM
;
630 struct hda_rate_tbl
{
632 unsigned int alsa_bits
;
633 unsigned int hda_fmt
;
636 /* rate = base * mult / div */
637 #define HDA_RATE(base, mult, div) \
638 (AC_FMT_BASE_##base##K | (((mult) - 1) << AC_FMT_MULT_SHIFT) | \
639 (((div) - 1) << AC_FMT_DIV_SHIFT))
641 static struct hda_rate_tbl rate_bits
[] = {
642 /* rate in Hz, ALSA rate bitmask, HDA format value */
644 /* autodetected value used in snd_hda_query_supported_pcm */
645 { 8000, SNDRV_PCM_RATE_8000
, HDA_RATE(48, 1, 6) },
646 { 11025, SNDRV_PCM_RATE_11025
, HDA_RATE(44, 1, 4) },
647 { 16000, SNDRV_PCM_RATE_16000
, HDA_RATE(48, 1, 3) },
648 { 22050, SNDRV_PCM_RATE_22050
, HDA_RATE(44, 1, 2) },
649 { 32000, SNDRV_PCM_RATE_32000
, HDA_RATE(48, 2, 3) },
650 { 44100, SNDRV_PCM_RATE_44100
, HDA_RATE(44, 1, 1) },
651 { 48000, SNDRV_PCM_RATE_48000
, HDA_RATE(48, 1, 1) },
652 { 88200, SNDRV_PCM_RATE_88200
, HDA_RATE(44, 2, 1) },
653 { 96000, SNDRV_PCM_RATE_96000
, HDA_RATE(48, 2, 1) },
654 { 176400, SNDRV_PCM_RATE_176400
, HDA_RATE(44, 4, 1) },
655 { 192000, SNDRV_PCM_RATE_192000
, HDA_RATE(48, 4, 1) },
656 #define AC_PAR_PCM_RATE_BITS 11
657 /* up to bits 10, 384kHZ isn't supported properly */
659 /* not autodetected value */
660 { 9600, SNDRV_PCM_RATE_KNOT
, HDA_RATE(48, 1, 5) },
662 { 0 } /* terminator */
666 * snd_hdac_calc_stream_format - calculate the format bitset
667 * @rate: the sample rate
668 * @channels: the number of channels
669 * @format: the PCM format (SNDRV_PCM_FORMAT_XXX)
670 * @maxbps: the max. bps
671 * @spdif_ctls: HD-audio SPDIF status bits (0 if irrelevant)
673 * Calculate the format bitset from the given rate, channels and th PCM format.
675 * Return zero if invalid.
677 unsigned int snd_hdac_calc_stream_format(unsigned int rate
,
678 unsigned int channels
,
681 unsigned short spdif_ctls
)
684 unsigned int val
= 0;
686 for (i
= 0; rate_bits
[i
].hz
; i
++)
687 if (rate_bits
[i
].hz
== rate
) {
688 val
= rate_bits
[i
].hda_fmt
;
691 if (!rate_bits
[i
].hz
)
694 if (channels
== 0 || channels
> 8)
698 switch (snd_pcm_format_width(format
)) {
700 val
|= AC_FMT_BITS_8
;
703 val
|= AC_FMT_BITS_16
;
708 if (maxbps
>= 32 || format
== SNDRV_PCM_FORMAT_FLOAT_LE
)
709 val
|= AC_FMT_BITS_32
;
710 else if (maxbps
>= 24)
711 val
|= AC_FMT_BITS_24
;
713 val
|= AC_FMT_BITS_20
;
719 if (spdif_ctls
& AC_DIG1_NONAUDIO
)
720 val
|= AC_FMT_TYPE_NON_PCM
;
724 EXPORT_SYMBOL_GPL(snd_hdac_calc_stream_format
);
726 static unsigned int query_pcm_param(struct hdac_device
*codec
, hda_nid_t nid
)
728 unsigned int val
= 0;
730 if (nid
!= codec
->afg
&&
731 (get_wcaps(codec
, nid
) & AC_WCAP_FORMAT_OVRD
))
732 val
= snd_hdac_read_parm(codec
, nid
, AC_PAR_PCM
);
733 if (!val
|| val
== -1)
734 val
= snd_hdac_read_parm(codec
, codec
->afg
, AC_PAR_PCM
);
735 if (!val
|| val
== -1)
740 static unsigned int query_stream_param(struct hdac_device
*codec
, hda_nid_t nid
)
742 unsigned int streams
= snd_hdac_read_parm(codec
, nid
, AC_PAR_STREAM
);
744 if (!streams
|| streams
== -1)
745 streams
= snd_hdac_read_parm(codec
, codec
->afg
, AC_PAR_STREAM
);
746 if (!streams
|| streams
== -1)
752 * snd_hdac_query_supported_pcm - query the supported PCM rates and formats
753 * @codec: the codec object
755 * @ratesp: the pointer to store the detected rate bitflags
756 * @formatsp: the pointer to store the detected formats
757 * @bpsp: the pointer to store the detected format widths
759 * Queries the supported PCM rates and formats. The NULL @ratesp, @formatsp
760 * or @bsps argument is ignored.
762 * Returns 0 if successful, otherwise a negative error code.
764 int snd_hdac_query_supported_pcm(struct hdac_device
*codec
, hda_nid_t nid
,
765 u32
*ratesp
, u64
*formatsp
, unsigned int *bpsp
)
767 unsigned int i
, val
, wcaps
;
769 wcaps
= get_wcaps(codec
, nid
);
770 val
= query_pcm_param(codec
, nid
);
774 for (i
= 0; i
< AC_PAR_PCM_RATE_BITS
; i
++) {
776 rates
|= rate_bits
[i
].alsa_bits
;
780 "rates == 0 (nid=0x%x, val=0x%x, ovrd=%i)\n",
782 (wcaps
& AC_WCAP_FORMAT_OVRD
) ? 1 : 0);
788 if (formatsp
|| bpsp
) {
790 unsigned int streams
, bps
;
792 streams
= query_stream_param(codec
, nid
);
797 if (streams
& AC_SUPFMT_PCM
) {
798 if (val
& AC_SUPPCM_BITS_8
) {
799 formats
|= SNDRV_PCM_FMTBIT_U8
;
802 if (val
& AC_SUPPCM_BITS_16
) {
803 formats
|= SNDRV_PCM_FMTBIT_S16_LE
;
806 if (wcaps
& AC_WCAP_DIGITAL
) {
807 if (val
& AC_SUPPCM_BITS_32
)
808 formats
|= SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE
;
809 if (val
& (AC_SUPPCM_BITS_20
|AC_SUPPCM_BITS_24
))
810 formats
|= SNDRV_PCM_FMTBIT_S32_LE
;
811 if (val
& AC_SUPPCM_BITS_24
)
813 else if (val
& AC_SUPPCM_BITS_20
)
815 } else if (val
& (AC_SUPPCM_BITS_20
|AC_SUPPCM_BITS_24
|
816 AC_SUPPCM_BITS_32
)) {
817 formats
|= SNDRV_PCM_FMTBIT_S32_LE
;
818 if (val
& AC_SUPPCM_BITS_32
)
820 else if (val
& AC_SUPPCM_BITS_24
)
822 else if (val
& AC_SUPPCM_BITS_20
)
826 #if 0 /* FIXME: CS4206 doesn't work, which is the only codec supporting float */
827 if (streams
& AC_SUPFMT_FLOAT32
) {
828 formats
|= SNDRV_PCM_FMTBIT_FLOAT_LE
;
833 if (streams
== AC_SUPFMT_AC3
) {
834 /* should be exclusive */
835 /* temporary hack: we have still no proper support
836 * for the direct AC3 stream...
838 formats
|= SNDRV_PCM_FMTBIT_U8
;
843 "formats == 0 (nid=0x%x, val=0x%x, ovrd=%i, streams=0x%x)\n",
845 (wcaps
& AC_WCAP_FORMAT_OVRD
) ? 1 : 0,
857 EXPORT_SYMBOL_GPL(snd_hdac_query_supported_pcm
);
860 * snd_hdac_is_supported_format - Check the validity of the format
861 * @codec: the codec object
863 * @format: the HD-audio format value to check
865 * Check whether the given node supports the format value.
867 * Returns true if supported, false if not.
869 bool snd_hdac_is_supported_format(struct hdac_device
*codec
, hda_nid_t nid
,
873 unsigned int val
= 0, rate
, stream
;
875 val
= query_pcm_param(codec
, nid
);
879 rate
= format
& 0xff00;
880 for (i
= 0; i
< AC_PAR_PCM_RATE_BITS
; i
++)
881 if (rate_bits
[i
].hda_fmt
== rate
) {
886 if (i
>= AC_PAR_PCM_RATE_BITS
)
889 stream
= query_stream_param(codec
, nid
);
893 if (stream
& AC_SUPFMT_PCM
) {
894 switch (format
& 0xf0) {
896 if (!(val
& AC_SUPPCM_BITS_8
))
900 if (!(val
& AC_SUPPCM_BITS_16
))
904 if (!(val
& AC_SUPPCM_BITS_20
))
908 if (!(val
& AC_SUPPCM_BITS_24
))
912 if (!(val
& AC_SUPPCM_BITS_32
))
919 /* FIXME: check for float32 and AC3? */
924 EXPORT_SYMBOL_GPL(snd_hdac_is_supported_format
);