CFR: ACPI Dock driver
Mitsuru IWASAKI
iwasaki at jp.FreeBSD.org
Wed Apr 12 16:21:57 UTC 2006
Hi, Thanks for your comments. Patches for acpi_dock.c are attached.
One thing,
> * There also might be an acpi_GetReference() helper function to use. (I
> think I wrote one)
Sorry, I can't get this. Could you point this out in detail?
Thanks!
-------------- next part --------------
--- acpi_dock.c.20060410 Mon Apr 10 03:34:35 2006
+++ acpi_dock.c Thu Apr 13 01:06:04 2006
@@ -143,36 +143,21 @@
acpi_dock_execute_lck(device_t dev, int lock)
{
ACPI_HANDLE h;
- ACPI_OBJECT argobj;
- ACPI_OBJECT_LIST args;
- ACPI_STATUS status;
h = acpi_get_handle(dev);
-
- argobj.Type = ACPI_TYPE_INTEGER;
- argobj.Integer.Value = lock;
- args.Count = 1;
- args.Pointer = &argobj;
- status = AcpiEvaluateObject(h, "_LCK", &args, NULL);
+ acpi_SetInteger(h, "_LCK", lock);
}
static int
acpi_dock_execute_ejx(device_t dev, int eject, int state)
{
ACPI_HANDLE h;
- ACPI_OBJECT argobj;
- ACPI_OBJECT_LIST args;
ACPI_STATUS status;
char ejx[5];
h = acpi_get_handle(dev);
-
- argobj.Type = ACPI_TYPE_INTEGER;
- argobj.Integer.Value = eject;
- args.Count = 1;
- args.Pointer = &argobj;
snprintf(ejx, sizeof(ejx), "_EJ%d", state);
- status = AcpiEvaluateObject(h, ejx, &args, NULL);
+ status = acpi_SetInteger(h, ejx, eject);
if (ACPI_SUCCESS(status)) {
return (0);
@@ -228,7 +213,9 @@
device_enable(dev);
}
+ mtx_lock(&Giant);
device_probe_and_attach(dev);
+ mtx_unlock(&Giant);
}
static ACPI_STATUS
@@ -247,7 +234,15 @@
ACPI_VPRINT(dock_dev, acpi_device_get_parent_softc(dock_dev),
"inserting device for %s\n", acpi_name(handle));
-#if (ACPI_CA_VERSION <= 0x20041119)
+#if 0
+ /*
+ * If the system boot up w/o Docking, the devices under the dock
+ * still un-initialized, also control methods such as _INI, _STA
+ * are not executed.
+ * Normal devices are initialized at booting by calling
+ * AcpiInitializeObjects(), however the devices under the dock
+ * need to be initialized here on the scheme of ACPICA.
+ */
ACPI_INIT_WALK_INFO Info;
AcpiNsWalkNamespace(ACPI_TYPE_ANY, handle,
@@ -262,7 +257,7 @@
goto out;
}
- timeout(acpi_dock_attach_later, (caddr_t)dev, hz*3);
+ AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_dock_attach_later, dev);
out:
return (AE_OK);
@@ -285,6 +280,8 @@
struct acpi_dock_softc *sc;
ACPI_HANDLE h;
+ ACPI_SERIAL_ASSERT(dock);
+
sc = device_get_softc(dev);
h = acpi_get_handle(dev);
@@ -313,8 +310,6 @@
{
device_t dock_dev, dev;
ACPI_HANDLE dock_handle;
- ACPI_OBJECT argobj;
- ACPI_OBJECT_LIST args;
dock_dev = *(device_t *)context;
dock_handle = acpi_get_handle(dock_dev);
@@ -333,12 +328,7 @@
mtx_unlock(&Giant);
}
- argobj.Type = ACPI_TYPE_INTEGER;
- argobj.Integer.Value = 0;
- args.Count = 1;
- args.Pointer = &argobj;
- AcpiEvaluateObject(handle, "_EJ0", &args, NULL);
-
+ acpi_SetInteger(handle, "_EJ0", 0);
out:
return (AE_OK);
}
@@ -359,6 +349,8 @@
{
struct acpi_dock_softc *sc;
+ ACPI_SERIAL_ASSERT(dock);
+
sc = device_get_softc(dev);
if (acpi_dock_status == ACPI_DOCK_STATUS_DOCKED ||
acpi_dock_status == ACPI_DOCK_STATUS_UNKNOWN) {
@@ -392,6 +384,8 @@
{
struct acpi_dock_softc *sc;
+ ACPI_SERIAL_ASSERT(dock);
+
sc = device_get_softc(dev);
acpi_dock_get_info(dev);
@@ -399,7 +393,7 @@
* If the _STA indicates 'present' and 'functioning',
* the system is docked.
*/
- if (sc->_sta & 0x9) {
+ if (ACPI_DEVICE_PRESENT(sc->_sta)) {
acpi_dock_insert(dev);
}
if (sc->_sta == 0x0) {
@@ -420,6 +414,7 @@
ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
"got notification %#x\n", notify);
+ ACPI_SERIAL_BEGIN(dock);
switch (notify) {
case ACPI_DOCK_NOTIFY_BUS_CHECK:
case ACPI_DOCK_NOTIFY_DEVICE_CHECK:
@@ -434,6 +429,7 @@
device_printf(dev, "unknown notify %#x\n", notify);
break;
}
+ ACPI_SERIAL_END(dock);
}
/*
@@ -530,9 +526,10 @@
sc->status = ACPI_DOCK_STATUS_UNKNOWN;
AcpiEvaluateObject(h, "_INI", NULL, NULL);
- acpi_dock_device_check(dev);
ACPI_SERIAL_BEGIN(dock);
+
+ acpi_dock_device_check(dev);
/* Get the sysctl tree */
sc->sysctl_ctx = device_get_sysctl_ctx(dev);
More information about the freebsd-current
mailing list