summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmcneill <jmcneill@pkgsrc.org>2008-11-27 22:19:10 +0000
committerjmcneill <jmcneill@pkgsrc.org>2008-11-27 22:19:10 +0000
commit18c125b049dd478bd833ffa8628ee2691bd9015c (patch)
tree5afe661a13bbfcb3976b2e2d22866da6f7c77ee6
parent471372cd30748ed0fbcff15f377e49d23d8a0232 (diff)
downloadpkgsrc-18c125b049dd478bd833ffa8628ee2691bd9015c.tar.gz
hald-netbsd: add v4l2 support, bump PKGREVISION
-rw-r--r--sysutils/hal/Makefile4
-rw-r--r--sysutils/hal/files/hald-netbsd/Makefile.am2
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo.c2
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo_video.c125
-rw-r--r--sysutils/hal/files/hald-netbsd/devinfo_video.h36
5 files changed, 166 insertions, 3 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile
index 058dadf923c..193653a32a6 100644
--- a/sysutils/hal/Makefile
+++ b/sysutils/hal/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.13 2008/11/27 16:07:14 jmcneill Exp $
+# $NetBSD: Makefile,v 1.14 2008/11/27 22:19:10 jmcneill Exp $
#
DISTNAME= hal-0.5.11
-PKGREVISION= 9
+PKGREVISION= 10
CATEGORIES= sysutils
MASTER_SITES= http://hal.freedesktop.org/releases/
EXTRACT_SUFX= .tar.bz2
diff --git a/sysutils/hal/files/hald-netbsd/Makefile.am b/sysutils/hal/files/hald-netbsd/Makefile.am
index d2250175a4f..95adf63394b 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_audio.c \
+ devinfo.c devinfo_misc.c devinfo_audio.c devinfo_video.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 ae508ef6a58..9e894b80571 100644
--- a/sysutils/hal/files/hald-netbsd/devinfo.c
+++ b/sysutils/hal/files/hald-netbsd/devinfo.c
@@ -29,6 +29,7 @@
#include "hotplug.h"
#include "devinfo.h"
#include "devinfo_audio.h"
+#include "devinfo_video.h"
#include "devinfo_pci.h"
#include "devinfo_storage.h"
#include "devinfo_usb.h"
@@ -151,6 +152,7 @@ static DevinfoDevHandler *devinfo_handlers[] = {
&devinfo_audio_handler,
&devinfo_audio_mixer_handler,
&devinfo_audio_dsp_handler,
+ &devinfo_video_handler,
&devinfo_default_handler,
NULL
};
diff --git a/sysutils/hal/files/hald-netbsd/devinfo_video.c b/sysutils/hal/files/hald-netbsd/devinfo_video.c
new file mode 100644
index 00000000000..83250658950
--- /dev/null
+++ b/sysutils/hal/files/hald-netbsd/devinfo_video.c
@@ -0,0 +1,125 @@
+/* $NetBSD: devinfo_video.c,v 1.1 2008/11/27 22:19:10 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/videoio.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_video.h"
+#include "drvctl.h"
+
+HalDevice *devinfo_video_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type);
+
+DevinfoDevHandler devinfo_video_handler = {
+ devinfo_video_add,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+HalDevice *
+devinfo_video_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type)
+{
+ HalDevice *d = NULL;
+ prop_dictionary_t dict;
+ const char *driver, *parent_udi;
+ char *videodev;
+ int16_t unit;
+ struct v4l2_capability caps;
+ 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;
+ }
+
+ prop_object_release (dict);
+
+ if (strcmp (driver, "video") != 0)
+ return NULL;
+
+ videodev = g_strdup_printf ("/dev/video%d", unit);
+ fd = open (videodev, O_RDONLY);
+ if (fd < 0) {
+ HAL_WARNING (("couldn't open %s: %s", videodev, strerror(errno)));
+ goto done;
+ }
+
+ if (ioctl (fd, VIDIOC_QUERYCAP, &caps) == -1) {
+ HAL_WARNING (("couldn't query %s: %s", videodev, strerror(errno)));
+ close (fd);
+ goto done;
+ }
+
+ close (fd);
+
+ d = hal_device_new ();
+
+ devinfo_set_default_properties (d, parent, devnode, devfs_path);
+ hal_device_add_capability (d, "video4linux");
+ if (caps.capabilities & V4L2_CAP_VIDEO_CAPTURE)
+ hal_device_add_capability (d, "video4linux.video_capture");
+ hal_device_property_set_string (d, "info.category", "video4linux");
+ hal_device_property_set_string (d, "info.subsystem", "video4linux");
+
+ hal_device_property_set_string (d, "video4linux.device", videodev);
+ hal_device_property_set_int (d, "video4linux.version", 2);
+ hal_device_property_set_string (d, "info.product", caps.card);
+
+ devinfo_add_enqueue (d, devfs_path, &devinfo_video_handler);
+
+done:
+ if (videodev)
+ g_free (videodev);
+
+ return d;
+}
diff --git a/sysutils/hal/files/hald-netbsd/devinfo_video.h b/sysutils/hal/files/hald-netbsd/devinfo_video.h
new file mode 100644
index 00000000000..d9828ce2b83
--- /dev/null
+++ b/sysutils/hal/files/hald-netbsd/devinfo_video.h
@@ -0,0 +1,36 @@
+/* $NetBSD: devinfo_video.h,v 1.1 2008/11/27 22:19:10 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_VIDEO_H
+#define DEVINFO_VIDEO_H
+
+#include "devinfo.h"
+
+extern DevinfoDevHandler devinfo_video_handler;
+
+#endif /* DEVINFO_VIDEO_H */