• Home
  • Raw
  • Download

Lines Matching +full:device +full:- +full:tree

1 // SPDX-License-Identifier: GPL-2.0
3 * sysfs support for HD-audio core device
8 #include <linux/device.h>
20 static ssize_t type##_show(struct device *dev, \
25 return sprintf(buf, "0x%x\n", codec->type); \
30 static ssize_t type##_show(struct device *dev, \
36 codec->type ? codec->type : ""); \
49 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, in modalias_show()
79 * Widget tree sysfs
81 * This is a tree showing the attributes of each widget. It appears like
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() local
325 if (!tree) 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()
334 kfree(tree); in widget_tree_free()
335 codec->widgets = NULL; in widget_tree_free()
346 return -ENOMEM; in add_widget_node()
365 struct hdac_widget_tree *tree; in widget_tree_create() local
369 tree = codec->widgets = kzalloc(sizeof(*tree), GFP_KERNEL); in widget_tree_create()
370 if (!tree) in widget_tree_create()
371 return -ENOMEM; in widget_tree_create()
373 tree->root = kobject_create_and_add("widgets", &codec->dev.kobj); in widget_tree_create()
374 if (!tree->root) in widget_tree_create()
375 return -ENOMEM; in widget_tree_create()
377 tree->nodes = kcalloc(codec->num_nodes + 1, sizeof(*tree->nodes), in widget_tree_create()
379 if (!tree->nodes) in widget_tree_create()
380 return -ENOMEM; in widget_tree_create()
382 for (i = 0, nid = codec->start_nid; i < codec->num_nodes; i++, nid++) { in widget_tree_create()
383 err = add_widget_node(tree->root, nid, &widget_node_group, in widget_tree_create()
384 &tree->nodes[i]); in widget_tree_create()
389 if (codec->afg) { in widget_tree_create()
390 err = add_widget_node(tree->root, codec->afg, in widget_tree_create()
391 &widget_afg_group, &tree->afg); in widget_tree_create()
396 kobject_uevent(tree->root, KOBJ_CHANGE); in widget_tree_create()
400 /* call with codec->widget_lock held */
405 if (codec->widgets) in hda_widget_sysfs_init()
417 /* call with codec->widget_lock held */
423 /* call with codec->widget_lock held */
427 struct hdac_widget_tree *tree; in hda_widget_sysfs_reinit() local
432 if (!codec->widgets) in hda_widget_sysfs_reinit()
435 tree = kmemdup(codec->widgets, sizeof(*tree), GFP_KERNEL); in hda_widget_sysfs_reinit()
436 if (!tree) in hda_widget_sysfs_reinit()
437 return -ENOMEM; in hda_widget_sysfs_reinit()
439 tree->nodes = kcalloc(num_nodes + 1, sizeof(*tree->nodes), GFP_KERNEL); in hda_widget_sysfs_reinit()
440 if (!tree->nodes) { in hda_widget_sysfs_reinit()
441 kfree(tree); in hda_widget_sysfs_reinit()
442 return -ENOMEM; in hda_widget_sysfs_reinit()
445 /* prune non-existing nodes */ in hda_widget_sysfs_reinit()
446 for (i = 0, nid = codec->start_nid; i < codec->num_nodes; i++, nid++) { in hda_widget_sysfs_reinit()
448 free_widget_node(codec->widgets->nodes[i], in hda_widget_sysfs_reinit()
454 if (nid < codec->start_nid || nid >= codec->end_nid) in hda_widget_sysfs_reinit()
455 add_widget_node(tree->root, nid, &widget_node_group, in hda_widget_sysfs_reinit()
456 &tree->nodes[i]); in hda_widget_sysfs_reinit()
458 tree->nodes[i] = in hda_widget_sysfs_reinit()
459 codec->widgets->nodes[nid - codec->start_nid]; in hda_widget_sysfs_reinit()
462 /* replace with the new tree */ in hda_widget_sysfs_reinit()
463 kfree(codec->widgets->nodes); in hda_widget_sysfs_reinit()
464 kfree(codec->widgets); in hda_widget_sysfs_reinit()
465 codec->widgets = tree; in hda_widget_sysfs_reinit()
467 kobject_uevent(tree->root, KOBJ_CHANGE); in hda_widget_sysfs_reinit()