Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178161151
D57767.1796155825.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D57767.1796155825.diff
View Options
diff --git a/sys/dev/usb/video/uvideo.c b/sys/dev/usb/video/uvideo.c
--- a/sys/dev/usb/video/uvideo.c
+++ b/sys/dev/usb/video/uvideo.c
@@ -51,6 +51,13 @@
#include <dev/video/video.h>
#include "video_if.h"
+#include "opt_acpi.h"
+
+#ifdef DEV_ACPI
+#include <sys/sbuf.h>
+#include <contrib/dev/acpica/include/acpi.h>
+#include <dev/acpica/acpivar.h>
+#endif
#define USB_DEBUG_VAR uvideo_debug
#include <dev/usb/usb_debug.h>
@@ -236,6 +243,14 @@
const struct uvideo_quirk *sc_quirk;
+#ifdef DEV_ACPI
+ ACPI_HANDLE sc_acpihandle;
+ uint8_t sc_pld[ACPI_PLD_BUFFER_SIZE];
+ size_t sc_pld_len;
+ char sc_acpiname[256];
+ struct sysctl_ctx_list sc_acpi_ctx; /*This should not be needed. Framework BUG!*/
+#endif
+
void (*sc_decode_stream_header)(
struct uvideo_softc *, uint8_t *, int);
};
@@ -632,6 +647,9 @@
DRIVER_MODULE(uvideo, uhub, uvideo_driver, NULL, NULL);
MODULE_DEPEND(uvideo, usb, 1, 1, 1);
MODULE_DEPEND(uvideo, video, 1, 1, 1);
+#ifdef DEV_ACPI
+MODULE_DEPEND(uvideo, acpi, 1, 1, 1);
+#endif
MODULE_VERSION(uvideo, 1);
USB_PNP_HOST_INFO(uvideo_devs);
@@ -730,6 +748,90 @@
return (usbd_lookup_id_by_uaa(uvideo_devs, sizeof(uvideo_devs), uaa));
}
+#ifdef DEV_ACPI
+static int acpi_uvideo_info_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ struct uvideo_softc *sc = oidp->oid_arg1;
+ struct sbuf sb;
+ int error;
+
+ sbuf_new_for_sysctl(&sb, NULL, 256, req);
+
+ acpi_get_pld_info(&sb, sc->sc_pld, sc->sc_pld_len);
+ error = sbuf_finish(&sb);
+ sbuf_delete(&sb);
+ return (error);
+}
+
+static void uvideo_acpi_attach(device_t dev, int port, int iface_index)
+{
+ ACPI_HANDLE ah;
+ ACPI_HANDLE devah = acpi_get_handle(dev);
+ ACPI_BUFFER buf;
+ struct uvideo_softc *sc = device_get_softc(dev);
+ ACPI_INTEGER camadr ;
+ struct sysctl_ctx_list *ctx; /* = device_get_sysctl_ctx(dev)*/
+ struct sysctl_oid_list *tree = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
+
+ /*
+ * For a function within a composite USB device, the ACPI
+ * address is the sum of the USB port number and the first
+ * interface number of the function.
+ *
+ * See "ACPI namespace hierarchy and _ADR for embedded
+ * USB devices" in the Microsoft ACPI firmware guidelines.
+ */
+ camadr = port + iface_index;
+
+ if (devah == NULL)
+ return;
+
+ if (ACPI_SUCCESS(acpi_find_child_by_adr(devah, &ah, camadr)) && ah){
+ sc->sc_acpihandle = ah;
+ /* Bug workaround.*/
+ sysctl_ctx_init(&sc->sc_acpi_ctx);
+ ctx = &sc->sc_acpi_ctx;
+
+ buf.Pointer = sc->sc_acpiname;
+ buf.Length = sizeof(sc->sc_acpiname);
+ if(ACPI_SUCCESS(AcpiGetName(ah, ACPI_FULL_PATHNAME, &buf))) {
+ SYSCTL_ADD_STRING(ctx, tree, OID_AUTO, "acpi_handle",
+ CTLFLAG_RD|CTLFLAG_MPSAFE,
+ sc->sc_acpiname, buf.Length, "Camera Handle");
+ }
+
+ sc->sc_pld_len = acpi_add_pld_sysctl(ah, ctx, tree, sc->sc_pld);
+ if (sc->sc_pld_len >= ACPI_PLD_REV1_BUFFER_SIZE)
+ SYSCTL_ADD_PROC(ctx, tree, OID_AUTO, "info",
+ CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ sc, 0, acpi_uvideo_info_sysctl, "A", "camera information");
+ }
+}
+
+static int uvideo_acpi_detach(device_t dev)
+{
+ /*Bug workaround*/
+ struct uvideo_softc *sc = device_get_softc(dev);
+ int error;
+
+ if (sc->sc_acpihandle == NULL)
+ return (0);
+
+ error = sysctl_ctx_free(&sc->sc_acpi_ctx);
+ if (error == 0)
+ sc->sc_acpihandle = NULL;
+
+ return (error);
+}
+#else
+static void uvideo_acpi_attach(device_t dev, int port, int iface_index)
+{
+}
+static int uvideo_acpi_detach(device_t dev)
+{
+ return (0);
+}
+#endif
static int
uvideo_attach(device_t dev)
{
@@ -867,6 +969,8 @@
goto detach;
}
+ uvideo_acpi_attach(dev, uaa->port, uaa->info.bIfaceNum);
+
return (0);
detach:
@@ -878,6 +982,11 @@
uvideo_detach(device_t dev)
{
struct uvideo_softc *sc = device_get_softc(dev);
+ int error;
+
+ if ((error = uvideo_acpi_detach(dev)) != 0) {
+ return (error);
+ }
sc->sc_dying = 1;
@@ -899,6 +1008,7 @@
mtx_destroy(&sc->sc_mtx);
+
return (0);
}
diff --git a/sys/modules/usb/uvideo/Makefile b/sys/modules/usb/uvideo/Makefile
--- a/sys/modules/usb/uvideo/Makefile
+++ b/sys/modules/usb/uvideo/Makefile
@@ -6,6 +6,7 @@
SRCS= opt_bus.h opt_usb.h device_if.h \
bus_if.h usb_if.h usbdevs.h \
video_if.h \
+ opt_acpi.h acpi_if.h\
uvideo.c
.include <bsd.kmod.mk>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 1, 8:10 PM (1 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42107094
Default Alt Text
D57767.1796155825.diff (4 KB)
Attached To
Mode
D57767: uvideo: bind ACPI handle.
Attached
Detach File
Event Timeline