Index: acpi_sony.c =================================================================== --- acpi_sony.c (revision 248950) +++ acpi_sony.c (working copy) @@ -61,6 +61,8 @@ struct acpi_sony_softc { int pid; + device_t dev; + ACPI_HANDLE handle; }; static struct acpi_sony_name_list { @@ -84,10 +86,24 @@ { NULL, NULL, NULL } }; +/* Event Codes */ +#define SONY_EVENT_FNKEY 0x92 +#define SONY_EVENT_BRIGHTNESS_DOWN_PRESSED 0x85 +#define SONY_EVENT_BRIGHTNESS_DOWN_RELEASE 0x05 +#define SONY_EVENT_BRIGHTNESS_UP_PRESSED 0x86 +#define SONY_EVENT_BRIGHTNESS_UP_RELEASED 0x06 +#define SONY_EVENT_DISPLAYSWITCH_PRESSED 0x87 +#define SONY_EVENT_DISPLAYSWITCH_RELEASED 0x07 +#define SONY_NOTIFY_ZOOM_PRESSED 0x8a +#define SONY_NOTIFY_ZOOM_RELEASED 0x0a +#define SONY_NOTIFY_SUSPEND_PRESSED 0x8c +#define SONY_NOTIFY_SUSPEND_RELEASED 0x0c + static int acpi_sony_probe(device_t dev); static int acpi_sony_attach(device_t dev); static int acpi_sony_detach(device_t dev); static int sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS); +static void acpi_sony_notify(ACPI_HANDLE h, UINT32 notify, void *context); static device_method_t acpi_sony_methods[] = { /* Device interface */ @@ -130,7 +146,9 @@ int i; sc = device_get_softc(dev); - acpi_GetInteger(acpi_get_handle(dev), ACPI_SONY_GET_PID, &sc->pid); + sc->dev = dev; + sc->handle = acpi_get_handle(dev); + acpi_GetInteger(sc->handle, ACPI_SONY_GET_PID, &sc->pid); device_printf(dev, "PID %x\n", sc->pid); for (i = 0 ; acpi_sony_oids[i].nodename != NULL; i++){ SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), @@ -140,29 +158,45 @@ dev, i, sysctl_acpi_sony_gen_handler, "I", acpi_sony_oids[i].comment); } + + /* + * Initialize Fn keys, just in case we don't find a SNY6001 device. + */ + if (ACPI_SUCCESS(acpi_SetInteger(sc->handle, "SN02", 0x04))) + device_printf(dev, "1 \n"); + if (ACPI_SUCCESS(acpi_SetInteger(sc->handle, "SN07", 0x02))) + device_printf(dev, "2 \n"); + if (ACPI_SUCCESS(acpi_SetInteger(sc->handle, "SN02", 0x10))) + device_printf(dev, "3 \n"); + if (ACPI_SUCCESS(acpi_SetInteger(sc->handle, "SN07", 0x00))) + device_printf(dev, "4 \n"); + if (ACPI_SUCCESS(acpi_SetInteger(sc->handle, "SN03", 0x02))) + device_printf(dev, "5 \n"); + if (ACPI_SUCCESS(acpi_SetInteger(sc->handle, "SN07", 0x101))) + device_printf(dev, "6 \n"); + + /* + * Handle notifications. + */ + AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, + acpi_sony_notify, dev); return (0); } static int acpi_sony_detach(device_t dev) { - return (0); -} + struct acpi_sony_softc *sc; -#if 0 -static int -acpi_sony_suspend(device_t dev) -{ - struct acpi_sony_softc *sc = device_get_softc(dev); - return (0); -} + sc = device_get_softc(dev); -static int -acpi_sony_resume(device_t dev) -{ + /* + * Remove notify handler. + */ + AcpiRemoveNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY, + acpi_sony_notify); return (0); } -#endif static int sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS) @@ -180,3 +214,12 @@ acpi_sony_oids[function].setmethod, val); return (0); } + +static void +acpi_sony_notify(ACPI_HANDLE h, UINT32 notify, void *context) +{ + struct acpi_sony_softc *sc; + + sc = device_get_softc((device_t)context); + device_printf((device_t)context, "notify %x \n", notify); +}