Lines Matching +full:audio +full:- +full:widgets
1 // SPDX-License-Identifier: GPL-2.0
3 * sysfs support for HD-audio core device
25 return sprintf(buf, "0x%x\n", codec->type); \
36 codec->type ? codec->type : ""); \
82 * /sys/bus/hdaudioC0D0/widgets/04/caps
98 struct device *dev = kobj_to_dev(kobj->parent->parent); in get_codec_nid()
102 ret = kstrtoint(kobj->name, 16, &nid); in get_codec_nid()
117 if (!wid_attr->show) in widget_attr_show()
118 return -EIO; in widget_attr_show()
122 return wid_attr->show(codec, nid, wid_attr, buf); in widget_attr_show()
133 if (!wid_attr->store) in widget_attr_store()
134 return -EIO; in widget_attr_store()
138 return wid_attr->store(codec, nid, wid_attr, buf, count); in widget_attr_store()
190 if (nid == codec->afg || nid == codec->mfg) in has_pcm_cap()
222 if (nid != codec->afg && !(get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) in amp_in_caps_show()
231 if (nid != codec->afg && !(get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) in amp_out_caps_show()
240 if (nid != codec->afg && !(get_wcaps(codec, nid) & AC_WCAP_POWER)) in power_caps_show()
322 struct hdac_widget_tree *tree = codec->widgets; in widget_tree_free()
327 free_widget_node(tree->afg, &widget_afg_group); in widget_tree_free()
328 if (tree->nodes) { in widget_tree_free()
329 for (p = tree->nodes; *p; p++) in widget_tree_free()
331 kfree(tree->nodes); in widget_tree_free()
333 kobject_put(tree->root); in widget_tree_free()
335 codec->widgets = NULL; in widget_tree_free()
346 return -ENOMEM; in add_widget_node()
367 tree = codec->widgets = kzalloc(sizeof(*tree), GFP_KERNEL); in widget_tree_create()
369 return -ENOMEM; in widget_tree_create()
371 tree->root = kobject_create_and_add("widgets", &codec->dev.kobj); in widget_tree_create()
372 if (!tree->root) in widget_tree_create()
373 return -ENOMEM; in widget_tree_create()
375 tree->nodes = kcalloc(codec->num_nodes + 1, sizeof(*tree->nodes), in widget_tree_create()
377 if (!tree->nodes) in widget_tree_create()
378 return -ENOMEM; in widget_tree_create()
380 for (i = 0, nid = codec->start_nid; i < codec->num_nodes; i++, nid++) { in widget_tree_create()
381 err = add_widget_node(tree->root, nid, &widget_node_group, in widget_tree_create()
382 &tree->nodes[i]); in widget_tree_create()
387 if (codec->afg) { in widget_tree_create()
388 err = add_widget_node(tree->root, codec->afg, in widget_tree_create()
389 &widget_afg_group, &tree->afg); in widget_tree_create()
394 kobject_uevent(tree->root, KOBJ_CHANGE); in widget_tree_create()
398 /* call with codec->widget_lock held */
403 if (codec->widgets) in hda_widget_sysfs_init()
415 /* call with codec->widget_lock held */
421 /* call with codec->widget_lock held */
430 if (!codec->widgets) in hda_widget_sysfs_reinit()
433 tree = kmemdup(codec->widgets, sizeof(*tree), GFP_KERNEL); in hda_widget_sysfs_reinit()
435 return -ENOMEM; in hda_widget_sysfs_reinit()
437 tree->nodes = kcalloc(num_nodes + 1, sizeof(*tree->nodes), GFP_KERNEL); in hda_widget_sysfs_reinit()
438 if (!tree->nodes) { in hda_widget_sysfs_reinit()
440 return -ENOMEM; in hda_widget_sysfs_reinit()
443 /* prune non-existing nodes */ in hda_widget_sysfs_reinit()
444 for (i = 0, nid = codec->start_nid; i < codec->num_nodes; i++, nid++) { in hda_widget_sysfs_reinit()
446 free_widget_node(codec->widgets->nodes[i], in hda_widget_sysfs_reinit()
452 if (nid < codec->start_nid || nid >= codec->end_nid) in hda_widget_sysfs_reinit()
453 add_widget_node(tree->root, nid, &widget_node_group, in hda_widget_sysfs_reinit()
454 &tree->nodes[i]); in hda_widget_sysfs_reinit()
456 tree->nodes[i] = in hda_widget_sysfs_reinit()
457 codec->widgets->nodes[nid - codec->start_nid]; in hda_widget_sysfs_reinit()
461 kfree(codec->widgets->nodes); in hda_widget_sysfs_reinit()
462 kfree(codec->widgets); in hda_widget_sysfs_reinit()
463 codec->widgets = tree; in hda_widget_sysfs_reinit()
465 kobject_uevent(tree->root, KOBJ_CHANGE); in hda_widget_sysfs_reinit()