void devinfo_add_subtree(HalDevice *parent, di_node_t node, gboolean is_root) { HalDevice *d; di_node_t root_node, child_node; HAL_INFO (("add_subtree: %s", di_node_name (node))); root_node = node; do { d = devinfo_add_node (parent, node); if ((d != NULL) && (child_node = di_child_node (node)) != DI_NODE_NIL) { devinfo_add_subtree (d, child_node, FALSE); } node = di_sibling_node (node); } while ((node != DI_NODE_NIL) && (!is_root || di_parent_node (node) == root_node)); }
static void drvctl_dev_add(gchar *name) { HalDevice *parent, *d; gchar pdevnode[512]; if (drvctl_find_parent (name, pdevnode) == FALSE) { HAL_INFO (("dev_add: name=%s orphan", name)); parent = NULL; } else { parent = hal_device_store_match_key_value_string ( hald_get_gdl(), "netbsd.device", pdevnode); if (parent == NULL) HAL_INFO (("dev_add: name=%s but netbsd.device=%s not found",name, pdevnode)); } d = devinfo_add_node (parent, name); if (d == NULL) HAL_WARNING (("dev_add: couldn't add %s node (parent=%p)", name, parent)); hotplug_event_process_queue (); }
HalDevice * devinfo_audio_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) { HalDevice *d = NULL, *mixer, *dsp; prop_dictionary_t dict; const char *driver, *parent_udi; char *childnode; int16_t unit; char *audioctl; struct audio_device audiodev; int fd; if (drvctl_find_device (devnode, &dict) == FALSE || dict == NULL) return NULL; if (prop_dictionary_get_int16 (dict, "device-unit", &unit) == false || prop_dictionary_get_cstring_nocopy (dict, "device-driver", &driver) == false) { prop_object_release (dict); return NULL; } if (strcmp (driver, "audio") != 0) { prop_object_release (dict); return NULL; } audioctl = g_strdup_printf (_PATH_AUDIOCTL "%d", unit); fd = open (audioctl, O_RDONLY); if (fd < 0) { HAL_WARNING (("couldn't open %s: %s", audioctl, strerror(errno))); goto done; } if (ioctl (fd, AUDIO_GETDEV, &audiodev) == -1) { HAL_WARNING (("couldn't query %s: %s", audioctl, strerror(errno))); goto done; } d = hal_device_new (); devinfo_set_default_properties (d, parent, devnode, devfs_path); hal_device_add_capability (d, "sound"); hal_device_property_set_string (d, "info.category", "sound"); hal_device_property_set_string (d, "info.subsystem", "sound"); hal_device_property_set_int (d, "sound.card", unit); hal_device_property_set_string (d, "sound.card_id", audiodev.name); hal_device_property_set_string (d, "netbsd.sound.hardware", audiodev.config); parent_udi = hal_device_property_get_string (parent, "info.udi"); if (parent_udi) hal_device_property_set_string (d, "sound.originating_device", parent_udi); devinfo_add_enqueue (d, devfs_path, &devinfo_audio_handler); childnode = g_strdup_printf ("oss_mixer_%d", unit); devinfo_add_node (d, childnode); g_free (childnode); childnode = g_strdup_printf ("oss_dsp_%d", unit); devinfo_add_node (d, childnode); g_free (childnode); done: if (dict) prop_object_release (dict); if (audioctl) g_free (audioctl); if (fd >= 0) close (fd); return d; }