summaryrefslogtreecommitdiff
path: root/sysutils/hal/files
diff options
context:
space:
mode:
authorjmcneill <jmcneill>2008-11-27 16:07:14 +0000
committerjmcneill <jmcneill>2008-11-27 16:07:14 +0000
commit08c5f2a80f08035427730e14d19231748d00d99e (patch)
tree6fe16e5c1467daa5727116ffa7011c66649a909f /sysutils/hal/files
parentf77fc9b7e02fdb3ca12dbe0592d6ad7f6be8d46e (diff)
downloadpkgsrc-08c5f2a80f08035427730e14d19231748d00d99e.tar.gz
hald-netbsd: add audio support, bump PKGREVISION
Diffstat (limited to 'sysutils/hal/files')
-rw-r--r--sysutils/hal/files/hald-netbsd/Makefile.am2
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo.c4
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo_audio.c228
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo_audio.h38
-rw-r--r--sysutils/hal/files/hald-netbsd/drvctl.c8
5 files changed, 277 insertions, 3 deletions
diff --git a/sysutils/hal/files/hald-netbsd/Makefile.am b/sysutils/hal/files/hald-netbsd/Makefile.am
index 3ea4ef1421a..d2250175a4f 100644
--- a/sysutils/hal/files/hald-netbsd/Makefile.am
+++ b/sysutils/hal/files/hald-netbsd/Makefile.am
@@ -16,7 +16,7 @@ endif
libhald_netbsd_la_SOURCES = \
osspec.c drvctl.c envsys.c \
- devinfo.c devinfo_misc.c \
+ devinfo.c devinfo_misc.c devinfo_audio.c \
hotplug.c hal-file-monitor.c
# devinfo_pci.c devinfo_storage.c devinfo_usb.c
diff --git a/sysutils/hal/files/hald-netbsd/devinfo.c b/sysutils/hal/files/hald-netbsd/devinfo.c
index 4977dc53a98..ae508ef6a58 100644
--- a/sysutils/hal/files/hald-netbsd/devinfo.c
+++ b/sysutils/hal/files/hald-netbsd/devinfo.c
@@ -28,6 +28,7 @@
#include "osspec_netbsd.h"
#include "hotplug.h"
#include "devinfo.h"
+#include "devinfo_audio.h"
#include "devinfo_pci.h"
#include "devinfo_storage.h"
#include "devinfo_usb.h"
@@ -147,6 +148,9 @@ static DevinfoDevHandler *devinfo_handlers[] = {
&devinfo_pci_handler,
&devinfo_lofi_handler,
#endif
+ &devinfo_audio_handler,
+ &devinfo_audio_mixer_handler,
+ &devinfo_audio_dsp_handler,
&devinfo_default_handler,
NULL
};
diff --git a/sysutils/hal/files/hald-netbsd/devinfo_audio.c b/sysutils/hal/files/hald-netbsd/devinfo_audio.c
new file mode 100644
index 00000000000..ba72236a501
--- /dev/null
+++ b/sysutils/hal/files/hald-netbsd/devinfo_audio.c
@@ -0,0 +1,228 @@
+/* $NetBSD: devinfo_audio.c,v 1.1 2008/11/27 16:07:14 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/audioio.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <paths.h>
+#include <unistd.h>
+
+#include "../osspec.h"
+#include "../logger.h"
+#include "../hald.h"
+#include "../hald_dbus.h"
+#include "../device_info.h"
+#include "../util.h"
+#include "../ids.h"
+#include "hotplug.h"
+#include "devinfo.h"
+#include "devinfo_audio.h"
+#include "drvctl.h"
+
+HalDevice *devinfo_audio_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type);
+HalDevice *devinfo_audio_mixer_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type);
+HalDevice *devinfo_audio_dsp_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type);
+
+DevinfoDevHandler devinfo_audio_handler = {
+ devinfo_audio_add,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+DevinfoDevHandler devinfo_audio_mixer_handler = {
+ devinfo_audio_mixer_add,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+DevinfoDevHandler devinfo_audio_dsp_handler = {
+ devinfo_audio_dsp_add,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+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);
+
+ 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;
+}
+
+HalDevice *
+devinfo_audio_mixer_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
+{
+ HalDevice *d = NULL;
+ char *device_file, *parent_udi, *card_id;
+ int16_t unit;
+
+ if (strstr (devnode, "oss_mixer_") != devnode)
+ return NULL;
+
+ d = hal_device_new ();
+
+ devinfo_set_default_properties (d, parent, devnode, devfs_path);
+ hal_device_add_capability (d, "oss");
+ hal_device_property_set_string (d, "info.category", "oss");
+ hal_device_property_set_string (d, "info.subsystem", "sound");
+
+ card_id = hal_device_property_get_string (parent, "sound.card_id");
+ hal_device_property_set_string (d, "oss.card_id", card_id);
+ unit = hal_device_property_get_int (parent, "sound.card");
+ hal_device_property_set_int (d, "oss.card", unit);
+ hal_device_property_set_int (d, "oss.device", unit + 16);
+ hal_device_property_set_string (d, "oss.type", "mixer");
+
+ device_file = g_strdup_printf (_PATH_MIXER "%d", unit);
+ hal_device_property_set_string (d, "oss.device_file", device_file);
+ g_free (device_file);
+
+ 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_mixer_handler);
+
+ return d;
+}
+
+HalDevice *
+devinfo_audio_dsp_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
+{
+ HalDevice *d = NULL;
+ char *device_file, *parent_udi, *card_id;
+ int16_t unit;
+
+ if (strstr (devnode, "oss_dsp_") != devnode)
+ return NULL;
+
+ d = hal_device_new ();
+
+ devinfo_set_default_properties (d, parent, devnode, devfs_path);
+ hal_device_add_capability (d, "oss");
+ hal_device_property_set_string (d, "info.category", "oss");
+ hal_device_property_set_string (d, "info.subsystem", "sound");
+
+ card_id = hal_device_property_get_string (parent, "sound.card_id");
+ hal_device_property_set_string (d, "oss.card_id", card_id);
+ unit = hal_device_property_get_int (parent, "sound.card");
+ hal_device_property_set_int (d, "oss.card", unit);
+ hal_device_property_set_int (d, "oss.device", unit);
+ hal_device_property_set_string (d, "oss.type", "dsp");
+
+ device_file = g_strdup_printf (_PATH_SOUND "%d", unit);
+ hal_device_property_set_string (d, "oss.device_file", device_file);
+ g_free (device_file);
+
+ 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_dsp_handler);
+
+ return d;
+}
diff --git a/sysutils/hal/files/hald-netbsd/devinfo_audio.h b/sysutils/hal/files/hald-netbsd/devinfo_audio.h
new file mode 100644
index 00000000000..0c60623bcd1
--- /dev/null
+++ b/sysutils/hal/files/hald-netbsd/devinfo_audio.h
@@ -0,0 +1,38 @@
+/* $NetBSD: devinfo_audio.h,v 1.1 2008/11/27 16:07:14 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DEVINFO_AUDIO_H
+#define DEVINFO_AUDIO_H
+
+#include "devinfo.h"
+
+extern DevinfoDevHandler devinfo_audio_handler;
+extern DevinfoDevHandler devinfo_audio_mixer_handler;
+extern DevinfoDevHandler devinfo_audio_dsp_handler;
+
+#endif /* DEVINFO_AUDIO_H */
diff --git a/sysutils/hal/files/hald-netbsd/drvctl.c b/sysutils/hal/files/hald-netbsd/drvctl.c
index 32e816233aa..573aa27ad9f 100644
--- a/sysutils/hal/files/hald-netbsd/drvctl.c
+++ b/sysutils/hal/files/hald-netbsd/drvctl.c
@@ -208,8 +208,12 @@ drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties)
return FALSE;
}
- if (properties)
- *properties = prop_dictionary_get (results_dict, "drvctl-result-data");
+ if (properties) {
+ prop_dictionary_t result_data;
+ result_data = prop_dictionary_get (results_dict, "drvctl-result-data");
+ if (result_data)
+ *properties = prop_dictionary_copy (result_data);
+ }
prop_object_release (results_dict);