After discussions with Nate, repo copy the acpi assist drivers from
i386 to dev/acpi_support. In theory, these devices could be found other than in i386 machines only as amd64 becomes more popular. These drivers don't appear to do anything i386 specific, so move them to dev/acpi_support. Move config lines to files so that those architectures that don't support kernel modules can build them into the kernel. At the same time, rename acpi_snc to acpi_sony to follow the lead of all the other specialty devices.
This commit is contained in:
parent
b42dda8abf
commit
c2aed5122b
@ -272,6 +272,10 @@ dev/aac/aac_disk.c optional aac
|
||||
dev/aac/aac_pci.c optional aac pci
|
||||
dev/aac/aac_cam.c optional aacp aac
|
||||
dev/aac/aac_linux.c optional aac compat_linux
|
||||
dev/acpi_support/acpi_asus.c optional acpi acpi_asus
|
||||
dev/acpi_support/acpi_panasonic.c optional acpi acpi_panasonic
|
||||
dev/acpi_support/acpi_sony.c optional acpi acpi_sony
|
||||
dev/acpi_support/acpi_toshiba.c optional acpi acpi_toshiba
|
||||
dev/acpica/acpi.c optional acpi
|
||||
dev/acpica/acpi_acad.c optional acpi
|
||||
dev/acpica/acpi_battery.c optional acpi
|
||||
@ -300,7 +304,6 @@ dev/acpica/Osd/OsdSchedule.c optional acpi
|
||||
dev/acpica/Osd/OsdStream.c optional acpi
|
||||
dev/acpica/Osd/OsdSynch.c optional acpi
|
||||
dev/acpica/Osd/OsdTable.c optional acpi
|
||||
dev/acpica/acpi_snc.c optional acpi_snc acpi
|
||||
dev/acpica/acpi_video.c optional acpi_video acpi
|
||||
dev/adlink/adlink.c optional adlink
|
||||
dev/advansys/adv_eisa.c optional adv eisa
|
||||
|
@ -192,10 +192,7 @@ geom/geom_mbr.c standard
|
||||
geom/geom_mbr_enc.c standard
|
||||
dev/acpica/acpi_if.m standard
|
||||
i386/acpica/OsdEnvironment.c optional acpi
|
||||
i386/acpica/acpi_asus.c optional acpi_asus acpi
|
||||
i386/acpica/acpi_machdep.c optional acpi
|
||||
i386/acpica/acpi_panasonic.c optional acpi_panasonic acpi
|
||||
i386/acpica/acpi_toshiba.c optional acpi_toshiba acpi
|
||||
i386/acpica/acpi_wakeup.c optional acpi
|
||||
acpi_wakecode.h optional acpi \
|
||||
dependency "$S/i386/acpica/acpi_wakecode.S" \
|
||||
|
@ -1,168 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 Takanori Watanabe
|
||||
* 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 AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/bus.h>
|
||||
#include "acpi.h"
|
||||
#include "acpi_if.h"
|
||||
#include <sys/module.h>
|
||||
#include <dev/acpica/acpivar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#define ACPI_SNC_GET_BRIGHTNESS "GBRT"
|
||||
#define ACPI_SNC_SET_BRIGHTNESS "SBRT"
|
||||
#define ACPI_SNC_GET_PID "GPID"
|
||||
/*
|
||||
* SNY5001
|
||||
* [GS]BRT [GS]PBR [GS]CTR [GS]PCR [GS]CMI [CDPW GCDP]? GWDP PWAK PWRN
|
||||
*
|
||||
*/
|
||||
|
||||
struct acpi_snc_softc {
|
||||
int pid;
|
||||
};
|
||||
static struct acpi_snc_name_list
|
||||
{
|
||||
char *nodename;
|
||||
char *getmethod;
|
||||
char *setmethod;
|
||||
char *comment;
|
||||
}acpi_snc_oids[] = {
|
||||
{ "brightness", "GBRT", "SBRT", "Display Brightness"},
|
||||
{ "ctr", "GCTR", "SCTR", "??"},
|
||||
{ "pcr", "GPCR", "SPCR", "???"},
|
||||
#if 0
|
||||
{ "cmi", "GCMI", "SCMI", "????"},
|
||||
#endif
|
||||
{ "wdp", "GWDP", NULL, "?????"},
|
||||
{ "cdp", "GCDP", "CDPW", "??????"}, /*shares [\GL03]&0x8 flag*/
|
||||
{NULL, NULL,NULL}
|
||||
};
|
||||
|
||||
static int acpi_snc_probe(device_t dev);
|
||||
static int acpi_snc_attach(device_t dev);
|
||||
static int acpi_snc_detach(device_t dev);
|
||||
static int sysctl_acpi_snc_gen_handler(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
static device_method_t acpi_snc_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, acpi_snc_probe),
|
||||
DEVMETHOD(device_attach, acpi_snc_attach),
|
||||
DEVMETHOD(device_detach, acpi_snc_detach),
|
||||
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static driver_t acpi_snc_driver = {
|
||||
"acpi_snc",
|
||||
acpi_snc_methods,
|
||||
sizeof(struct acpi_snc_softc),
|
||||
};
|
||||
|
||||
static devclass_t acpi_snc_devclass;
|
||||
|
||||
DRIVER_MODULE(acpi_snc, acpi, acpi_snc_driver, acpi_snc_devclass,
|
||||
0, 0);
|
||||
MODULE_DEPEND(acpi_snc, acpi, 1, 1, 1);
|
||||
static char *sny_id[] = {"SNY5001", NULL};
|
||||
|
||||
static int
|
||||
acpi_snc_probe(device_t dev)
|
||||
{
|
||||
struct acpi_snc_softc *sc;
|
||||
int ret = ENXIO;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
if (ACPI_ID_PROBE(device_get_parent(dev), dev, sny_id)) {
|
||||
device_set_desc(dev, "Sony notebook controller");
|
||||
ret = 0;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_snc_attach(device_t dev)
|
||||
{
|
||||
struct acpi_snc_softc *sc;
|
||||
int i;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
acpi_GetInteger(acpi_get_handle(dev), ACPI_SNC_GET_PID, &sc->pid);
|
||||
device_printf(dev, "PID %x\n", sc->pid);
|
||||
for (i = 0 ; acpi_snc_oids[i].nodename != NULL; i++){
|
||||
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
||||
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
|
||||
i, acpi_snc_oids[i].nodename , CTLTYPE_INT |
|
||||
((acpi_snc_oids[i].setmethod)? CTLFLAG_RW: CTLFLAG_RD),
|
||||
dev, i, sysctl_acpi_snc_gen_handler, "I",
|
||||
acpi_snc_oids[i].comment);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_snc_detach(device_t dev)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
#if 0
|
||||
static int
|
||||
acpi_snc_suspend(device_t dev)
|
||||
{
|
||||
struct acpi_snc_softc *sc = device_get_softc(dev);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_snc_resume(device_t dev)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
sysctl_acpi_snc_gen_handler(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
device_t dev = arg1;
|
||||
int function = oidp->oid_arg2;
|
||||
int error = 0, val;
|
||||
|
||||
|
||||
acpi_GetInteger(acpi_get_handle(dev), acpi_snc_oids[function].getmethod, &val);
|
||||
error = sysctl_handle_int(oidp, &val, 0, req);
|
||||
|
||||
if (error || !req->newptr || !acpi_snc_oids[function].setmethod)
|
||||
return error;
|
||||
|
||||
acpi_SetInteger(acpi_get_handle(dev), acpi_snc_oids[function].setmethod, val);
|
||||
return 0;
|
||||
|
||||
}
|
@ -1,659 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 Philip Paeps <philip@FreeBSD.org>
|
||||
* 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 AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Driver for extra ACPI-controlled gadgets (hotkeys, leds, etc) found on
|
||||
* recent Asus (and Medion) laptops. Inspired by the acpi4asus project which
|
||||
* implements these features in the Linux kernel.
|
||||
*
|
||||
* <http://sourceforge.net/projects/acpi4asus/>
|
||||
*
|
||||
* Currently should support most features, but could use some more testing.
|
||||
* Particularly the display-switching stuff is a bit hairy. If you have an
|
||||
* Asus laptop which doesn't appear to be supported, or strange things happen
|
||||
* when using this driver, please report to <acpi@FreeBSD.org>.
|
||||
*/
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/sbuf.h>
|
||||
|
||||
#include "acpi.h"
|
||||
#include <dev/acpica/acpivar.h>
|
||||
#include <dev/led/led.h>
|
||||
|
||||
#define _COMPONENT ACPI_ASUS
|
||||
ACPI_MODULE_NAME("ASUS")
|
||||
|
||||
struct acpi_asus_model {
|
||||
char *name;
|
||||
|
||||
char *mled_set;
|
||||
char *tled_set;
|
||||
char *wled_set;
|
||||
|
||||
char *brn_get;
|
||||
char *brn_set;
|
||||
char *brn_up;
|
||||
char *brn_dn;
|
||||
|
||||
char *lcd_get;
|
||||
char *lcd_set;
|
||||
|
||||
char *disp_get;
|
||||
char *disp_set;
|
||||
};
|
||||
|
||||
struct acpi_asus_led {
|
||||
struct cdev *cdev;
|
||||
device_t dev;
|
||||
enum {
|
||||
ACPI_ASUS_LED_MLED,
|
||||
ACPI_ASUS_LED_TLED,
|
||||
ACPI_ASUS_LED_WLED,
|
||||
} type;
|
||||
};
|
||||
|
||||
struct acpi_asus_softc {
|
||||
device_t dev;
|
||||
ACPI_HANDLE handle;
|
||||
|
||||
struct acpi_asus_model *model;
|
||||
struct sysctl_ctx_list sysctl_ctx;
|
||||
struct sysctl_oid *sysctl_tree;
|
||||
|
||||
struct acpi_asus_led s_mled;
|
||||
struct acpi_asus_led s_tled;
|
||||
struct acpi_asus_led s_wled;
|
||||
|
||||
int s_brn;
|
||||
int s_disp;
|
||||
int s_lcd;
|
||||
};
|
||||
|
||||
/*
|
||||
* We can identify Asus laptops from the string they return
|
||||
* as a result of calling the ATK0100 'INIT' method.
|
||||
*/
|
||||
static struct acpi_asus_model acpi_asus_models[] = {
|
||||
{
|
||||
.name = "L2D",
|
||||
.mled_set = "MLED",
|
||||
.wled_set = "WLED",
|
||||
.brn_up = "\\Q0E",
|
||||
.brn_dn = "\\Q0F",
|
||||
.lcd_get = "\\SGP0",
|
||||
.lcd_set = "\\Q10"
|
||||
},
|
||||
{
|
||||
.name = "L3C",
|
||||
.mled_set = "MLED",
|
||||
.wled_set = "WLED",
|
||||
.brn_get = "GPLV",
|
||||
.brn_set = "SPLV",
|
||||
.lcd_get = "\\GL32",
|
||||
.lcd_set = "\\_SB.PCI0.PX40.ECD0._Q10"
|
||||
},
|
||||
{
|
||||
.name = "L3D",
|
||||
.mled_set = "MLED",
|
||||
.wled_set = "WLED",
|
||||
.brn_get = "GPLV",
|
||||
.brn_set = "SPLV",
|
||||
.lcd_get = "\\BKLG",
|
||||
.lcd_set = "\\Q10"
|
||||
},
|
||||
{
|
||||
.name = "L3H",
|
||||
.mled_set = "MLED",
|
||||
.wled_set = "WLED",
|
||||
.brn_get = "GPLV",
|
||||
.brn_set = "SPLV",
|
||||
.lcd_get = "\\_SB.PCI0.PM.PBC",
|
||||
.lcd_set = "EHK",
|
||||
.disp_get = "\\_SB.INFB",
|
||||
.disp_set = "SDSP"
|
||||
},
|
||||
{
|
||||
.name = "L4R",
|
||||
.mled_set = "MLED",
|
||||
.wled_set = "WLED",
|
||||
.brn_get = "GPLV",
|
||||
.brn_set = "SPLV",
|
||||
.lcd_get = "\\_SB.PCI0.SBSM.SEO4",
|
||||
.lcd_set = "\\_SB.PCI0.SBRG.EC0._Q10",
|
||||
.disp_get = "\\_SB.PCI0.P0P1.VGA.GETD",
|
||||
.disp_set = "SDSP"
|
||||
},
|
||||
{
|
||||
.name = "L8L"
|
||||
/* Only has hotkeys, apparantly */
|
||||
},
|
||||
{
|
||||
.name = "M1A",
|
||||
.mled_set = "MLED",
|
||||
.brn_up = "\\_SB.PCI0.PX40.EC0.Q0E",
|
||||
.brn_dn = "\\_SB.PCI0.PX40.EC0.Q0F",
|
||||
.lcd_get = "\\PNOF",
|
||||
.lcd_set = "\\_SB.PCI0.PX40.EC0.Q10"
|
||||
},
|
||||
{
|
||||
.name = "M2E",
|
||||
.mled_set = "MLED",
|
||||
.wled_set = "WLED",
|
||||
.brn_get = "GPLV",
|
||||
.brn_set = "SPLV",
|
||||
.lcd_get = "\\GP06",
|
||||
.lcd_set = "\\Q10"
|
||||
},
|
||||
{
|
||||
.name = "M6N",
|
||||
.mled_set = "MLED",
|
||||
.wled_set = "WLED",
|
||||
.lcd_set = "\\_SB.PCI0.SBRG.EC0._Q10",
|
||||
.lcd_get = "\\_SB.BKLT",
|
||||
.brn_set = "SPLV",
|
||||
.brn_get = "GPLV",
|
||||
.disp_set = "SDSP",
|
||||
.disp_get = "\\SSTE"
|
||||
},
|
||||
{
|
||||
.name = "M6R",
|
||||
.mled_set = "MLED",
|
||||
.wled_set = "WLED",
|
||||
.brn_get = "GPLV",
|
||||
.brn_set = "SPLV",
|
||||
.lcd_get = "\\_SB.PCI0.SBSM.SEO4",
|
||||
.lcd_set = "\\_SB.PCI0.SBRG.EC0._Q10",
|
||||
.disp_get = "\\SSTE",
|
||||
.disp_set = "SDSP"
|
||||
},
|
||||
|
||||
{ .name = NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* Samsung P30/P35 laptops have an Asus ATK0100 gadget interface,
|
||||
* but they can't be probed quite the same way as Asus laptops.
|
||||
*/
|
||||
static struct acpi_asus_model acpi_samsung_models[] = {
|
||||
{
|
||||
.name = "P30",
|
||||
.wled_set = "WLED",
|
||||
.brn_up = "\\_SB.PCI0.LPCB.EC0._Q68",
|
||||
.brn_dn = "\\_SB.PCI0.LPCB.EC0._Q69",
|
||||
.lcd_get = "\\BKLT",
|
||||
.lcd_set = "\\_SB.PCI0.LPCB.EC0._Q0E"
|
||||
},
|
||||
|
||||
{ .name = NULL }
|
||||
};
|
||||
|
||||
ACPI_SERIAL_DECL(asus, "ACPI ASUS extras");
|
||||
|
||||
/* Function prototypes */
|
||||
static int acpi_asus_probe(device_t dev);
|
||||
static int acpi_asus_attach(device_t dev);
|
||||
static int acpi_asus_detach(device_t dev);
|
||||
|
||||
static void acpi_asus_led(struct acpi_asus_led *led, int state);
|
||||
|
||||
static int acpi_asus_sysctl_brn(SYSCTL_HANDLER_ARGS);
|
||||
static int acpi_asus_sysctl_lcd(SYSCTL_HANDLER_ARGS);
|
||||
static int acpi_asus_sysctl_disp(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
static void acpi_asus_notify(ACPI_HANDLE h, UINT32 notify, void *context);
|
||||
|
||||
static device_method_t acpi_asus_methods[] = {
|
||||
DEVMETHOD(device_probe, acpi_asus_probe),
|
||||
DEVMETHOD(device_attach, acpi_asus_attach),
|
||||
DEVMETHOD(device_detach, acpi_asus_detach),
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static driver_t acpi_asus_driver = {
|
||||
"acpi_asus",
|
||||
acpi_asus_methods,
|
||||
sizeof(struct acpi_asus_softc)
|
||||
};
|
||||
|
||||
static devclass_t acpi_asus_devclass;
|
||||
|
||||
DRIVER_MODULE(acpi_asus, acpi, acpi_asus_driver, acpi_asus_devclass, 0, 0);
|
||||
MODULE_DEPEND(acpi_asus, acpi, 1, 1, 1);
|
||||
|
||||
static int
|
||||
acpi_asus_probe(device_t dev)
|
||||
{
|
||||
struct acpi_asus_model *model;
|
||||
struct acpi_asus_softc *sc;
|
||||
struct sbuf *sb;
|
||||
ACPI_BUFFER Buf;
|
||||
ACPI_OBJECT Arg, *Obj;
|
||||
ACPI_OBJECT_LIST Args;
|
||||
static char *asus_ids[] = { "ATK0100", NULL };
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
if (acpi_disabled("asus") ||
|
||||
ACPI_ID_PROBE(device_get_parent(dev), dev, asus_ids) == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->dev = dev;
|
||||
sc->handle = acpi_get_handle(dev);
|
||||
|
||||
Arg.Type = ACPI_TYPE_INTEGER;
|
||||
Arg.Integer.Value = 0;
|
||||
|
||||
Args.Count = 1;
|
||||
Args.Pointer = &Arg;
|
||||
|
||||
Buf.Pointer = NULL;
|
||||
Buf.Length = ACPI_ALLOCATE_BUFFER;
|
||||
|
||||
AcpiEvaluateObject(sc->handle, "INIT", &Args, &Buf);
|
||||
Obj = Buf.Pointer;
|
||||
|
||||
/*
|
||||
* The Samsung P30 returns a null-pointer from INIT, we
|
||||
* can identify it from the 'ODEM' string in the DSDT.
|
||||
*/
|
||||
if (Obj->String.Pointer == NULL) {
|
||||
ACPI_STATUS status;
|
||||
ACPI_TABLE_HEADER th;
|
||||
|
||||
status = AcpiGetTableHeader(ACPI_TABLE_DSDT, 1, &th);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
device_printf(dev, "Unsupported (Samsung?) laptop\n");
|
||||
AcpiOsFree(Buf.Pointer);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
if (strncmp("ODEM", th.OemTableId, 4) == 0) {
|
||||
sc->model = &acpi_samsung_models[0];
|
||||
device_set_desc(dev, "Samsung P30 Laptop Extras");
|
||||
AcpiOsFree(Buf.Pointer);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
|
||||
if (sb == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
/*
|
||||
* Asus laptops are simply identified by name, easy!
|
||||
*/
|
||||
for (model = acpi_asus_models; model->name != NULL; model++)
|
||||
if (strncmp(Obj->String.Pointer, model->name, 3) == 0) {
|
||||
sbuf_printf(sb, "Asus %s Laptop Extras", model->name);
|
||||
sbuf_finish(sb);
|
||||
|
||||
sc->model = model;
|
||||
device_set_desc(dev, sbuf_data(sb));
|
||||
|
||||
sbuf_delete(sb);
|
||||
AcpiOsFree(Buf.Pointer);
|
||||
return (0);
|
||||
}
|
||||
|
||||
sbuf_printf(sb, "Unsupported Asus laptop: %s\n", Obj->String.Pointer);
|
||||
sbuf_finish(sb);
|
||||
|
||||
device_printf(dev, sbuf_data(sb));
|
||||
|
||||
sbuf_delete(sb);
|
||||
AcpiOsFree(Buf.Pointer);
|
||||
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_asus_attach(device_t dev)
|
||||
{
|
||||
struct acpi_asus_softc *sc;
|
||||
struct acpi_softc *acpi_sc;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
acpi_sc = acpi_device_get_parent_softc(dev);
|
||||
|
||||
/* Build sysctl tree */
|
||||
sysctl_ctx_init(&sc->sysctl_ctx);
|
||||
sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree),
|
||||
OID_AUTO, "asus", CTLFLAG_RD, 0, "");
|
||||
|
||||
/* Attach leds */
|
||||
if (sc->model->mled_set) {
|
||||
sc->s_mled.dev = dev;
|
||||
sc->s_mled.type = ACPI_ASUS_LED_MLED;
|
||||
sc->s_mled.cdev =
|
||||
led_create((led_t *)acpi_asus_led, &sc->s_mled, "mled");
|
||||
}
|
||||
|
||||
if (sc->model->tled_set) {
|
||||
sc->s_tled.dev = dev;
|
||||
sc->s_tled.type = ACPI_ASUS_LED_TLED;
|
||||
sc->s_tled.cdev =
|
||||
led_create((led_t *)acpi_asus_led, &sc->s_tled, "tled");
|
||||
}
|
||||
|
||||
if (sc->model->wled_set) {
|
||||
sc->s_wled.dev = dev;
|
||||
sc->s_wled.type = ACPI_ASUS_LED_WLED;
|
||||
sc->s_wled.cdev =
|
||||
led_create((led_t *)acpi_asus_led, &sc->s_wled, "wled");
|
||||
}
|
||||
|
||||
/* Attach brightness for GPLV/SPLV models */
|
||||
if (sc->model->brn_get && ACPI_SUCCESS(acpi_GetInteger(sc->handle,
|
||||
sc->model->brn_get, &sc->s_brn)))
|
||||
SYSCTL_ADD_PROC(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
|
||||
"lcd_brightness", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
|
||||
acpi_asus_sysctl_brn, "I", "brightness of the lcd panel");
|
||||
|
||||
/* Attach brightness for other models */
|
||||
if (sc->model->brn_up &&
|
||||
ACPI_SUCCESS(AcpiEvaluateObject(sc->handle, sc->model->brn_up,
|
||||
NULL, NULL)) &&
|
||||
ACPI_SUCCESS(AcpiEvaluateObject(sc->handle, sc->model->brn_dn,
|
||||
NULL, NULL)))
|
||||
SYSCTL_ADD_PROC(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
|
||||
"lcd_brightness", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
|
||||
acpi_asus_sysctl_brn, "I", "brightness of the lcd panel");
|
||||
|
||||
/* Attach display switching */
|
||||
if (sc->model->disp_get && ACPI_SUCCESS(acpi_GetInteger(sc->handle,
|
||||
sc->model->disp_get, &sc->s_disp)))
|
||||
SYSCTL_ADD_PROC(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
|
||||
"video_output", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
|
||||
acpi_asus_sysctl_disp, "I", "display output state");
|
||||
|
||||
/* Attach LCD state, easy for most models... */
|
||||
if (sc->model->lcd_get && strncmp(sc->model->name, "L3H", 3) != 0 &&
|
||||
ACPI_SUCCESS(acpi_GetInteger(sc->handle, sc->model->lcd_get,
|
||||
&sc->s_lcd))) {
|
||||
SYSCTL_ADD_PROC(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
|
||||
"lcd_backlight", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
|
||||
acpi_asus_sysctl_lcd, "I", "state of the lcd backlight");
|
||||
} else if (sc->model->lcd_get) {
|
||||
ACPI_BUFFER Buf;
|
||||
ACPI_OBJECT Arg[2], Obj;
|
||||
ACPI_OBJECT_LIST Args;
|
||||
|
||||
/* ...a nightmare for the L3H */
|
||||
Arg[0].Type = ACPI_TYPE_INTEGER;
|
||||
Arg[0].Integer.Value = 0x02;
|
||||
Arg[1].Type = ACPI_TYPE_INTEGER;
|
||||
Arg[1].Integer.Value = 0x03;
|
||||
|
||||
Args.Count = 2;
|
||||
Args.Pointer = Arg;
|
||||
|
||||
Buf.Length = sizeof(Obj);
|
||||
Buf.Pointer = &Obj;
|
||||
|
||||
if (ACPI_SUCCESS(AcpiEvaluateObject(sc->handle,
|
||||
sc->model->lcd_get, &Args, &Buf)) &&
|
||||
Obj.Type == ACPI_TYPE_INTEGER) {
|
||||
sc->s_lcd = Obj.Integer.Value >> 8;
|
||||
|
||||
SYSCTL_ADD_PROC(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
|
||||
"lcd_backlight", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
|
||||
acpi_asus_sysctl_lcd, "I",
|
||||
"state of the lcd backlight");
|
||||
}
|
||||
}
|
||||
|
||||
/* Activate hotkeys */
|
||||
AcpiEvaluateObject(sc->handle, "BSTS", NULL, NULL);
|
||||
|
||||
/* Handle notifies */
|
||||
AcpiInstallNotifyHandler(sc->handle, ACPI_SYSTEM_NOTIFY,
|
||||
acpi_asus_notify, dev);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_asus_detach(device_t dev)
|
||||
{
|
||||
struct acpi_asus_softc *sc;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
/* Turn the lights off */
|
||||
if (sc->model->mled_set)
|
||||
led_destroy(sc->s_mled.cdev);
|
||||
|
||||
if (sc->model->tled_set)
|
||||
led_destroy(sc->s_tled.cdev);
|
||||
|
||||
if (sc->model->wled_set)
|
||||
led_destroy(sc->s_wled.cdev);
|
||||
|
||||
/* Remove notify handler */
|
||||
AcpiRemoveNotifyHandler(sc->handle, ACPI_SYSTEM_NOTIFY,
|
||||
acpi_asus_notify);
|
||||
|
||||
/* Free sysctl tree */
|
||||
sysctl_ctx_free(&sc->sysctl_ctx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_asus_led(struct acpi_asus_led *led, int state)
|
||||
{
|
||||
struct acpi_asus_softc *sc;
|
||||
char *method;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
sc = device_get_softc(led->dev);
|
||||
|
||||
switch (led->type) {
|
||||
case ACPI_ASUS_LED_MLED:
|
||||
method = sc->model->mled_set;
|
||||
|
||||
/* Note: inverted */
|
||||
state = !state;
|
||||
break;
|
||||
case ACPI_ASUS_LED_TLED:
|
||||
method = sc->model->tled_set;
|
||||
break;
|
||||
case ACPI_ASUS_LED_WLED:
|
||||
method = sc->model->wled_set;
|
||||
break;
|
||||
default:
|
||||
printf("acpi_asus_led: invalid LED type %d\n",
|
||||
(int)led->type);
|
||||
return;
|
||||
}
|
||||
|
||||
acpi_SetInteger(sc->handle, method, state);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_asus_sysctl_brn(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct acpi_asus_softc *sc;
|
||||
int brn, err;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
sc = (struct acpi_asus_softc *)oidp->oid_arg1;
|
||||
ACPI_SERIAL_BEGIN(asus);
|
||||
|
||||
/* Sanity check */
|
||||
brn = sc->s_brn;
|
||||
err = sysctl_handle_int(oidp, &brn, 0, req);
|
||||
|
||||
if (err != 0 || req->newptr == NULL)
|
||||
goto out;
|
||||
|
||||
if (brn < 0 || brn > 15) {
|
||||
err = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Keep track and update */
|
||||
sc->s_brn = brn;
|
||||
|
||||
if (sc->model->brn_set)
|
||||
acpi_SetInteger(sc->handle, sc->model->brn_set, brn);
|
||||
else {
|
||||
brn -= sc->s_brn;
|
||||
|
||||
while (brn != 0) {
|
||||
AcpiEvaluateObject(sc->handle, (brn > 0) ?
|
||||
sc->model->brn_up : sc->model->brn_dn,
|
||||
NULL, NULL);
|
||||
(brn > 0) ? brn-- : brn++;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
ACPI_SERIAL_END(asus);
|
||||
return (err);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_asus_sysctl_lcd(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct acpi_asus_softc *sc;
|
||||
int lcd, err;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
sc = (struct acpi_asus_softc *)oidp->oid_arg1;
|
||||
ACPI_SERIAL_BEGIN(asus);
|
||||
|
||||
/* Sanity check */
|
||||
lcd = sc->s_lcd;
|
||||
err = sysctl_handle_int(oidp, &lcd, 0, req);
|
||||
|
||||
if (err != 0 || req->newptr == NULL)
|
||||
goto out;
|
||||
|
||||
if (lcd < 0 || lcd > 1) {
|
||||
err = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Keep track and update */
|
||||
sc->s_lcd = lcd;
|
||||
|
||||
/* Most models just need a lcd_set evaluated, the L3H is trickier */
|
||||
if (strncmp(sc->model->name, "L3H", 3) != 0)
|
||||
AcpiEvaluateObject(sc->handle, sc->model->lcd_set, NULL, NULL);
|
||||
else
|
||||
acpi_SetInteger(sc->handle, sc->model->lcd_set, 0x7);
|
||||
|
||||
out:
|
||||
ACPI_SERIAL_END(asus);
|
||||
return (err);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_asus_sysctl_disp(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct acpi_asus_softc *sc;
|
||||
int disp, err;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
sc = (struct acpi_asus_softc *)oidp->oid_arg1;
|
||||
|
||||
/* Sanity check */
|
||||
ACPI_SERIAL_BEGIN(asus);
|
||||
disp = sc->s_disp;
|
||||
err = sysctl_handle_int(oidp, &disp, 0, req);
|
||||
|
||||
if (err != 0 || req->newptr == NULL)
|
||||
goto out;
|
||||
|
||||
if (disp < 0 || disp > 7) {
|
||||
err = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Keep track and update */
|
||||
sc->s_disp = disp;
|
||||
acpi_SetInteger(sc->handle, sc->model->disp_set, disp);
|
||||
|
||||
out:
|
||||
ACPI_SERIAL_END(asus);
|
||||
return (err);
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_asus_notify(ACPI_HANDLE h, UINT32 notify, void *context)
|
||||
{
|
||||
struct acpi_asus_softc *sc;
|
||||
struct acpi_softc *acpi_sc;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
sc = device_get_softc((device_t)context);
|
||||
acpi_sc = acpi_device_get_parent_softc(sc->dev);
|
||||
|
||||
ACPI_SERIAL_BEGIN(asus);
|
||||
if ((notify & ~0x10) <= 15) {
|
||||
sc->s_brn = notify & ~0x10;
|
||||
ACPI_VPRINT(sc->dev, acpi_sc, "Brightness increased\n");
|
||||
} else if ((notify & ~0x20) <= 15) {
|
||||
sc->s_brn = notify & ~0x20;
|
||||
ACPI_VPRINT(sc->dev, acpi_sc, "Brightness decreased\n");
|
||||
} else if (notify == 0x33) {
|
||||
sc->s_lcd = 1;
|
||||
ACPI_VPRINT(sc->dev, acpi_sc, "LCD turned on\n");
|
||||
} else if (notify == 0x34) {
|
||||
sc->s_lcd = 0;
|
||||
ACPI_VPRINT(sc->dev, acpi_sc, "LCD turned off\n");
|
||||
} else {
|
||||
/* Notify devd(8) */
|
||||
acpi_UserNotify("ASUS", h, notify);
|
||||
}
|
||||
ACPI_SERIAL_END(asus);
|
||||
}
|
@ -1,489 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2003 OGAWA Takaya <t-ogawa@triaez.kaisei.org>
|
||||
* Copyright (c) 2004 Yoshihiro TAKAHASHI <nyan@FreeBSD.org>
|
||||
* 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 AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/power.h>
|
||||
|
||||
#include "acpi.h"
|
||||
#include <dev/acpica/acpivar.h>
|
||||
|
||||
/* Debug */
|
||||
#undef ACPI_PANASONIC_DEBUG
|
||||
|
||||
/* Operations */
|
||||
#define HKEY_SET 0
|
||||
#define HKEY_GET 1
|
||||
|
||||
/* Functions */
|
||||
#define HKEY_REG_LCD_BRIGHTNESS_MAX_AC 0x02
|
||||
#define HKEY_REG_LCD_BRIGHTNESS_MIN_AC 0x03
|
||||
#define HKEY_REG_LCD_BRIGHTNESS_AC 0x04
|
||||
#define HKEY_REG_LCD_BRIGHTNESS_MAX_DC 0x05
|
||||
#define HKEY_REG_LCD_BRIGHTNESS_MIN_DC 0x06
|
||||
#define HKEY_REG_LCD_BRIGHTNESS_DC 0x07
|
||||
#define HKEY_REG_SOUND_MUTE 0x08
|
||||
|
||||
/* Field definitions */
|
||||
#define HKEY_LCD_BRIGHTNESS_BITS 4
|
||||
#define HKEY_LCD_BRIGHTNESS_DIV ((1 << HKEY_LCD_BRIGHTNESS_BITS) - 1)
|
||||
|
||||
struct acpi_panasonic_softc {
|
||||
device_t dev;
|
||||
ACPI_HANDLE handle;
|
||||
|
||||
struct sysctl_ctx_list sysctl_ctx;
|
||||
struct sysctl_oid *sysctl_tree;
|
||||
|
||||
eventhandler_tag power_evh;
|
||||
};
|
||||
|
||||
/* Prototype for HKEY functions for getting/setting a value. */
|
||||
typedef int hkey_fn_t(ACPI_HANDLE, int, UINT32 *);
|
||||
|
||||
static int acpi_panasonic_probe(device_t dev);
|
||||
static int acpi_panasonic_attach(device_t dev);
|
||||
static int acpi_panasonic_detach(device_t dev);
|
||||
static int acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS);
|
||||
static ACPI_INTEGER acpi_panasonic_sinf(ACPI_HANDLE h, ACPI_INTEGER index);
|
||||
static void acpi_panasonic_sset(ACPI_HANDLE h, ACPI_INTEGER index,
|
||||
ACPI_INTEGER val);
|
||||
static int acpi_panasonic_hkey_event(struct acpi_panasonic_softc *sc,
|
||||
ACPI_HANDLE h, UINT32 *arg);
|
||||
static void acpi_panasonic_hkey_action(struct acpi_panasonic_softc *sc,
|
||||
ACPI_HANDLE h, UINT32 key);
|
||||
static void acpi_panasonic_notify(ACPI_HANDLE h, UINT32 notify,
|
||||
void *context);
|
||||
static void acpi_panasonic_power_profile(void *arg);
|
||||
|
||||
static hkey_fn_t hkey_lcd_brightness_max;
|
||||
static hkey_fn_t hkey_lcd_brightness_min;
|
||||
static hkey_fn_t hkey_lcd_brightness;
|
||||
static hkey_fn_t hkey_sound_mute;
|
||||
ACPI_SERIAL_DECL(panasonic, "ACPI Panasonic extras");
|
||||
|
||||
/* Table of sysctl names and HKEY functions to call. */
|
||||
static struct {
|
||||
char *name;
|
||||
hkey_fn_t *handler;
|
||||
} sysctl_table[] = {
|
||||
/* name, handler */
|
||||
{"lcd_brightness_max", hkey_lcd_brightness_max},
|
||||
{"lcd_brightness_min", hkey_lcd_brightness_min},
|
||||
{"lcd_brightness", hkey_lcd_brightness},
|
||||
{"sound_mute", hkey_sound_mute},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static device_method_t acpi_panasonic_methods[] = {
|
||||
DEVMETHOD(device_probe, acpi_panasonic_probe),
|
||||
DEVMETHOD(device_attach, acpi_panasonic_attach),
|
||||
DEVMETHOD(device_detach, acpi_panasonic_detach),
|
||||
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static driver_t acpi_panasonic_driver = {
|
||||
"acpi_panasonic",
|
||||
acpi_panasonic_methods,
|
||||
sizeof(struct acpi_panasonic_softc),
|
||||
};
|
||||
|
||||
static devclass_t acpi_panasonic_devclass;
|
||||
|
||||
DRIVER_MODULE(acpi_panasonic, acpi, acpi_panasonic_driver,
|
||||
acpi_panasonic_devclass, 0, 0);
|
||||
MODULE_DEPEND(acpi_panasonic, acpi, 1, 1, 1);
|
||||
|
||||
static int
|
||||
acpi_panasonic_probe(device_t dev)
|
||||
{
|
||||
static char *mat_ids[] = { "MAT0019", NULL };
|
||||
|
||||
if (acpi_disabled("panasonic") ||
|
||||
ACPI_ID_PROBE(device_get_parent(dev), dev, mat_ids) == NULL ||
|
||||
device_get_unit(dev) != 0)
|
||||
return (ENXIO);
|
||||
|
||||
device_set_desc(dev, "Panasonic Notebook Hotkeys");
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_panasonic_attach(device_t dev)
|
||||
{
|
||||
struct acpi_panasonic_softc *sc;
|
||||
struct acpi_softc *acpi_sc;
|
||||
ACPI_STATUS status;
|
||||
int i;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->dev = dev;
|
||||
sc->handle = acpi_get_handle(dev);
|
||||
|
||||
acpi_sc = acpi_device_get_parent_softc(dev);
|
||||
|
||||
/* Build sysctl tree */
|
||||
sysctl_ctx_init(&sc->sysctl_ctx);
|
||||
sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO,
|
||||
"panasonic", CTLFLAG_RD, 0, "");
|
||||
for (i = 0; sysctl_table[i].name != NULL; i++) {
|
||||
SYSCTL_ADD_PROC(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
|
||||
sysctl_table[i].name,
|
||||
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY,
|
||||
sc, i, acpi_panasonic_sysctl, "I", "");
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Activate hotkeys */
|
||||
status = AcpiEvaluateObject(sc->handle, "", NULL, NULL);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
device_printf(dev, "enable FN keys failed\n");
|
||||
sysctl_ctx_free(&sc->sysctl_ctx);
|
||||
return (ENXIO);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Handle notifies */
|
||||
status = AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
|
||||
acpi_panasonic_notify, sc);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
device_printf(dev, "couldn't install notify handler - %s\n",
|
||||
AcpiFormatException(status));
|
||||
sysctl_ctx_free(&sc->sysctl_ctx);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/* Install power profile event handler */
|
||||
sc->power_evh = EVENTHANDLER_REGISTER(power_profile_change,
|
||||
acpi_panasonic_power_profile, sc->handle, 0);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_panasonic_detach(device_t dev)
|
||||
{
|
||||
struct acpi_panasonic_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
/* Remove power profile event handler */
|
||||
EVENTHANDLER_DEREGISTER(power_profile_change, sc->power_evh);
|
||||
|
||||
/* Remove notify handler */
|
||||
AcpiRemoveNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
|
||||
acpi_panasonic_notify);
|
||||
|
||||
/* Free sysctl tree */
|
||||
sysctl_ctx_free(&sc->sysctl_ctx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct acpi_panasonic_softc *sc;
|
||||
UINT32 arg;
|
||||
int function, error;
|
||||
hkey_fn_t *handler;
|
||||
|
||||
sc = (struct acpi_panasonic_softc *)oidp->oid_arg1;
|
||||
function = oidp->oid_arg2;
|
||||
handler = sysctl_table[function].handler;
|
||||
|
||||
/* Get the current value from the appropriate function. */
|
||||
ACPI_SERIAL_BEGIN(panasonic);
|
||||
error = handler(sc->handle, HKEY_GET, &arg);
|
||||
if (error != 0)
|
||||
goto out;
|
||||
|
||||
/* Send the current value to the user and return if no new value. */
|
||||
error = sysctl_handle_int(oidp, &arg, 0, req);
|
||||
if (error != 0 || req->newptr == NULL)
|
||||
goto out;
|
||||
|
||||
/* Set the new value via the appropriate function. */
|
||||
error = handler(sc->handle, HKEY_SET, &arg);
|
||||
|
||||
out:
|
||||
ACPI_SERIAL_END(panasonic);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static ACPI_INTEGER
|
||||
acpi_panasonic_sinf(ACPI_HANDLE h, ACPI_INTEGER index)
|
||||
{
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_OBJECT *res;
|
||||
ACPI_INTEGER ret;
|
||||
|
||||
ACPI_SERIAL_ASSERT(panasonic);
|
||||
ret = -1;
|
||||
buf.Length = ACPI_ALLOCATE_BUFFER;
|
||||
buf.Pointer = NULL;
|
||||
AcpiEvaluateObject(h, "SINF", NULL, &buf);
|
||||
res = (ACPI_OBJECT *)buf.Pointer;
|
||||
if (res->Type == ACPI_TYPE_PACKAGE)
|
||||
ret = res->Package.Elements[index].Integer.Value;
|
||||
AcpiOsFree(buf.Pointer);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_panasonic_sset(ACPI_HANDLE h, ACPI_INTEGER index, ACPI_INTEGER val)
|
||||
{
|
||||
ACPI_OBJECT_LIST args;
|
||||
ACPI_OBJECT obj[2];
|
||||
|
||||
ACPI_SERIAL_ASSERT(panasonic);
|
||||
obj[0].Type = ACPI_TYPE_INTEGER;
|
||||
obj[0].Integer.Value = index;
|
||||
obj[1].Type = ACPI_TYPE_INTEGER;
|
||||
obj[1].Integer.Value = val;
|
||||
args.Count = 2;
|
||||
args.Pointer = obj;
|
||||
AcpiEvaluateObject(h, "SSET", &args, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
hkey_lcd_brightness_max(ACPI_HANDLE h, int op, UINT32 *val)
|
||||
{
|
||||
int reg;
|
||||
|
||||
ACPI_SERIAL_ASSERT(panasonic);
|
||||
reg = (power_profile_get_state() == POWER_PROFILE_PERFORMANCE) ?
|
||||
HKEY_REG_LCD_BRIGHTNESS_MAX_AC : HKEY_REG_LCD_BRIGHTNESS_MAX_DC;
|
||||
|
||||
switch (op) {
|
||||
case HKEY_SET:
|
||||
return (EPERM);
|
||||
break;
|
||||
case HKEY_GET:
|
||||
*val = acpi_panasonic_sinf(h, reg);
|
||||
break;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
hkey_lcd_brightness_min(ACPI_HANDLE h, int op, UINT32 *val)
|
||||
{
|
||||
int reg;
|
||||
|
||||
ACPI_SERIAL_ASSERT(panasonic);
|
||||
reg = (power_profile_get_state() == POWER_PROFILE_PERFORMANCE) ?
|
||||
HKEY_REG_LCD_BRIGHTNESS_MIN_AC : HKEY_REG_LCD_BRIGHTNESS_MIN_DC;
|
||||
|
||||
switch (op) {
|
||||
case HKEY_SET:
|
||||
return (EPERM);
|
||||
break;
|
||||
case HKEY_GET:
|
||||
*val = acpi_panasonic_sinf(h, reg);
|
||||
break;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
hkey_lcd_brightness(ACPI_HANDLE h, int op, UINT32 *val)
|
||||
{
|
||||
int reg;
|
||||
UINT32 max, min;
|
||||
|
||||
reg = (power_profile_get_state() == POWER_PROFILE_PERFORMANCE) ?
|
||||
HKEY_REG_LCD_BRIGHTNESS_AC : HKEY_REG_LCD_BRIGHTNESS_DC;
|
||||
|
||||
ACPI_SERIAL_ASSERT(panasonic);
|
||||
switch (op) {
|
||||
case HKEY_SET:
|
||||
hkey_lcd_brightness_max(h, HKEY_GET, &max);
|
||||
hkey_lcd_brightness_min(h, HKEY_GET, &min);
|
||||
if (*val < min || *val > max)
|
||||
return (EINVAL);
|
||||
acpi_panasonic_sset(h, reg, *val);
|
||||
break;
|
||||
case HKEY_GET:
|
||||
*val = acpi_panasonic_sinf(h, reg);
|
||||
break;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
hkey_sound_mute(ACPI_HANDLE h, int op, UINT32 *val)
|
||||
{
|
||||
|
||||
ACPI_SERIAL_ASSERT(panasonic);
|
||||
switch (op) {
|
||||
case HKEY_SET:
|
||||
if (*val != 0 && *val != 1)
|
||||
return (EINVAL);
|
||||
acpi_panasonic_sset(h, HKEY_REG_SOUND_MUTE, *val);
|
||||
break;
|
||||
case HKEY_GET:
|
||||
*val = acpi_panasonic_sinf(h, HKEY_REG_SOUND_MUTE);
|
||||
break;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_panasonic_hkey_event(struct acpi_panasonic_softc *sc, ACPI_HANDLE h,
|
||||
UINT32 *arg)
|
||||
{
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_OBJECT *res;
|
||||
ACPI_INTEGER val;
|
||||
int status;
|
||||
|
||||
ACPI_SERIAL_ASSERT(panasonic);
|
||||
status = ENXIO;
|
||||
|
||||
buf.Length = ACPI_ALLOCATE_BUFFER;
|
||||
buf.Pointer = NULL;
|
||||
AcpiEvaluateObject(h, "HINF", NULL, &buf);
|
||||
res = (ACPI_OBJECT *)buf.Pointer;
|
||||
if (res->Type != ACPI_TYPE_INTEGER) {
|
||||
device_printf(sc->dev, "HINF returned non-integer\n");
|
||||
goto end;
|
||||
}
|
||||
val = res->Integer.Value;
|
||||
#ifdef ACPI_PANASONIC_DEBUG
|
||||
device_printf(sc->dev, "%s button Fn+F%d\n",
|
||||
(val & 0x80) ? "Pressed" : "Released",
|
||||
(int)(val & 0x7f));
|
||||
#endif
|
||||
if ((val & 0x7f) > 0 && (val & 0x7f) < 11) {
|
||||
*arg = val;
|
||||
status = 0;
|
||||
}
|
||||
end:
|
||||
if (buf.Pointer)
|
||||
AcpiOsFree(buf.Pointer);
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_panasonic_hkey_action(struct acpi_panasonic_softc *sc, ACPI_HANDLE h,
|
||||
UINT32 key)
|
||||
{
|
||||
int arg, max, min;
|
||||
|
||||
ACPI_SERIAL_ASSERT(panasonic);
|
||||
switch (key) {
|
||||
case 1:
|
||||
/* Decrease LCD brightness. */
|
||||
hkey_lcd_brightness_max(h, HKEY_GET, &max);
|
||||
hkey_lcd_brightness_min(h, HKEY_GET, &min);
|
||||
hkey_lcd_brightness(h, HKEY_GET, &arg);
|
||||
arg -= max / HKEY_LCD_BRIGHTNESS_DIV;
|
||||
if (arg < min)
|
||||
arg = min;
|
||||
else if (arg > max)
|
||||
arg = max;
|
||||
hkey_lcd_brightness(h, HKEY_SET, &arg);
|
||||
break;
|
||||
case 2:
|
||||
/* Increase LCD brightness. */
|
||||
hkey_lcd_brightness_max(h, HKEY_GET, &max);
|
||||
hkey_lcd_brightness_min(h, HKEY_GET, &min);
|
||||
hkey_lcd_brightness(h, HKEY_GET, &arg);
|
||||
arg += max / HKEY_LCD_BRIGHTNESS_DIV;
|
||||
if (arg < min)
|
||||
arg = min;
|
||||
else if (arg > max)
|
||||
arg = max;
|
||||
hkey_lcd_brightness(h, HKEY_SET, &arg);
|
||||
break;
|
||||
case 4:
|
||||
/* Toggle sound mute. */
|
||||
hkey_sound_mute(h, HKEY_GET, &arg);
|
||||
if (arg)
|
||||
arg = 0;
|
||||
else
|
||||
arg = 1;
|
||||
hkey_sound_mute(h, HKEY_SET, &arg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_panasonic_notify(ACPI_HANDLE h, UINT32 notify, void *context)
|
||||
{
|
||||
struct acpi_panasonic_softc *sc;
|
||||
UINT32 key;
|
||||
|
||||
sc = (struct acpi_panasonic_softc *)context;
|
||||
|
||||
switch (notify) {
|
||||
case 0x80:
|
||||
ACPI_SERIAL_BEGIN(panasonic);
|
||||
if (acpi_panasonic_hkey_event(sc, h, &key) == 0) {
|
||||
acpi_panasonic_hkey_action(sc, h, key);
|
||||
acpi_UserNotify("Panasonic", h, (uint8_t)key);
|
||||
}
|
||||
ACPI_SERIAL_END(panasonic);
|
||||
break;
|
||||
default:
|
||||
device_printf(sc->dev, "unknown notify: %#x\n", notify);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_panasonic_power_profile(void *arg)
|
||||
{
|
||||
ACPI_HANDLE handle;
|
||||
UINT32 brightness;
|
||||
|
||||
handle = (ACPI_HANDLE)arg;
|
||||
|
||||
/* Reset current brightness according to new power state. */
|
||||
ACPI_SERIAL_BEGIN(panasonic);
|
||||
hkey_lcd_brightness(handle, HKEY_GET, &brightness);
|
||||
hkey_lcd_brightness(handle, HKEY_SET, &brightness);
|
||||
ACPI_SERIAL_END(panasonic);
|
||||
}
|
@ -1,562 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2003 Hiroyuki Aizu <aizu@navi.org>
|
||||
* 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 AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_acpi.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include "acpi.h"
|
||||
#include <dev/acpica/acpivar.h>
|
||||
|
||||
/*
|
||||
* Toshiba HCI interface definitions
|
||||
*
|
||||
* HCI is Toshiba's "Hardware Control Interface" which is supposed to
|
||||
* be uniform across all their models. Ideally we would just call
|
||||
* dedicated ACPI methods instead of using this primitive interface.
|
||||
* However, the ACPI methods seem to be incomplete in some areas (for
|
||||
* example they allow setting, but not reading, the LCD brightness
|
||||
* value), so this is still useful.
|
||||
*/
|
||||
|
||||
#define METHOD_HCI "GHCI"
|
||||
#define METHOD_HCI_ENABLE "ENAB"
|
||||
#define METHOD_VIDEO "DSSX"
|
||||
|
||||
/* Operations */
|
||||
#define HCI_SET 0xFF00
|
||||
#define HCI_GET 0xFE00
|
||||
|
||||
/* Return codes */
|
||||
#define HCI_SUCCESS 0x0000
|
||||
#define HCI_FAILURE 0x1000
|
||||
#define HCI_NOT_SUPPORTED 0x8000
|
||||
#define HCI_EMPTY 0x8C00
|
||||
|
||||
/* Functions */
|
||||
#define HCI_REG_LCD_BACKLIGHT 0x0002
|
||||
#define HCI_REG_FAN 0x0004
|
||||
#define HCI_REG_SYSTEM_EVENT 0x0016
|
||||
#define HCI_REG_VIDEO_OUTPUT 0x001C
|
||||
#define HCI_REG_HOTKEY_EVENT 0x001E
|
||||
#define HCI_REG_LCD_BRIGHTNESS 0x002A
|
||||
#define HCI_REG_CPU_SPEED 0x0032
|
||||
|
||||
/* Field definitions */
|
||||
#define HCI_FAN_SHIFT 7
|
||||
#define HCI_LCD_BRIGHTNESS_BITS 3
|
||||
#define HCI_LCD_BRIGHTNESS_SHIFT (16 - HCI_LCD_BRIGHTNESS_BITS)
|
||||
#define HCI_LCD_BRIGHTNESS_MAX ((1 << HCI_LCD_BRIGHTNESS_BITS) - 1)
|
||||
#define HCI_VIDEO_OUTPUT_FLAG 0x0100
|
||||
#define HCI_VIDEO_OUTPUT_LCD 0x1
|
||||
#define HCI_VIDEO_OUTPUT_CRT 0x2
|
||||
#define HCI_VIDEO_OUTPUT_TV 0x4
|
||||
#define HCI_CPU_SPEED_BITS 3
|
||||
#define HCI_CPU_SPEED_SHIFT (16 - HCI_CPU_SPEED_BITS)
|
||||
#define HCI_CPU_SPEED_MAX ((1 << HCI_CPU_SPEED_BITS) - 1)
|
||||
|
||||
/* Key press/release events. */
|
||||
#define FN_F1_PRESS 0x013B
|
||||
#define FN_F1_RELEASE 0x01BB
|
||||
#define FN_F2_PRESS 0x013C
|
||||
#define FN_F2_RELEASE 0x01BC
|
||||
#define FN_F3_PRESS 0x013D
|
||||
#define FN_F3_RELEASE 0x01BD
|
||||
#define FN_F4_PRESS 0x013E
|
||||
#define FN_F4_RELEASE 0x01BE
|
||||
#define FN_F5_PRESS 0x013F
|
||||
#define FN_F5_RELEASE 0x01BF
|
||||
#define FN_F6_PRESS 0x0140
|
||||
#define FN_F6_RELEASE 0x01C0
|
||||
#define FN_F7_PRESS 0x0141
|
||||
#define FN_F7_RELEASE 0x01C1
|
||||
#define FN_F8_PRESS 0x0142
|
||||
#define FN_F8_RELEASE 0x01C2
|
||||
#define FN_F9_PRESS 0x0143
|
||||
#define FN_F9_RELEASE 0x01C3
|
||||
#define FN_BS_PRESS 0x010E
|
||||
#define FN_BS_RELEASE 0x018E
|
||||
#define FN_ESC_PRESS 0x0101
|
||||
#define FN_ESC_RELEASE 0x0181
|
||||
#define FN_KNJ_PRESS 0x0129
|
||||
#define FN_KNJ_RELEASE 0x01A9
|
||||
|
||||
/* HCI register definitions. */
|
||||
#define HCI_WORDS 6 /* Number of registers */
|
||||
#define HCI_REG_AX 0 /* Operation, then return value */
|
||||
#define HCI_REG_BX 1 /* Function */
|
||||
#define HCI_REG_CX 2 /* Argument (in or out) */
|
||||
#define HCI_REG_DX 3 /* Unused? */
|
||||
#define HCI_REG_SI 4 /* Unused? */
|
||||
#define HCI_REG_DI 5 /* Unused? */
|
||||
|
||||
struct acpi_toshiba_softc {
|
||||
device_t dev;
|
||||
ACPI_HANDLE handle;
|
||||
ACPI_HANDLE video_handle;
|
||||
struct sysctl_ctx_list sysctl_ctx;
|
||||
struct sysctl_oid *sysctl_tree;
|
||||
};
|
||||
|
||||
/* Prototype for HCI functions for getting/setting a value. */
|
||||
typedef int hci_fn_t(ACPI_HANDLE, int, UINT32 *);
|
||||
|
||||
static int acpi_toshiba_probe(device_t dev);
|
||||
static int acpi_toshiba_attach(device_t dev);
|
||||
static int acpi_toshiba_detach(device_t dev);
|
||||
static int acpi_toshiba_sysctl(SYSCTL_HANDLER_ARGS);
|
||||
static hci_fn_t hci_force_fan;
|
||||
static hci_fn_t hci_video_output;
|
||||
static hci_fn_t hci_lcd_brightness;
|
||||
static hci_fn_t hci_lcd_backlight;
|
||||
static hci_fn_t hci_cpu_speed;
|
||||
static int hci_call(ACPI_HANDLE h, int op, int function, UINT32 *arg);
|
||||
static void hci_key_action(struct acpi_toshiba_softc *sc, ACPI_HANDLE h,
|
||||
UINT32 key);
|
||||
static void acpi_toshiba_notify(ACPI_HANDLE h, UINT32 notify,
|
||||
void *context);
|
||||
static int acpi_toshiba_video_probe(device_t dev);
|
||||
static int acpi_toshiba_video_attach(device_t dev);
|
||||
|
||||
ACPI_SERIAL_DECL(toshiba, "ACPI Toshiba Extras");
|
||||
|
||||
/* Table of sysctl names and HCI functions to call. */
|
||||
static struct {
|
||||
char *name;
|
||||
hci_fn_t *handler;
|
||||
} sysctl_table[] = {
|
||||
/* name, handler */
|
||||
{"force_fan", hci_force_fan},
|
||||
{"video_output", hci_video_output},
|
||||
{"lcd_brightness", hci_lcd_brightness},
|
||||
{"lcd_backlight", hci_lcd_backlight},
|
||||
{"cpu_speed", hci_cpu_speed},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static device_method_t acpi_toshiba_methods[] = {
|
||||
DEVMETHOD(device_probe, acpi_toshiba_probe),
|
||||
DEVMETHOD(device_attach, acpi_toshiba_attach),
|
||||
DEVMETHOD(device_detach, acpi_toshiba_detach),
|
||||
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static driver_t acpi_toshiba_driver = {
|
||||
"acpi_toshiba",
|
||||
acpi_toshiba_methods,
|
||||
sizeof(struct acpi_toshiba_softc),
|
||||
};
|
||||
|
||||
static devclass_t acpi_toshiba_devclass;
|
||||
DRIVER_MODULE(acpi_toshiba, acpi, acpi_toshiba_driver, acpi_toshiba_devclass,
|
||||
0, 0);
|
||||
MODULE_DEPEND(acpi_toshiba, acpi, 1, 1, 1);
|
||||
|
||||
static device_method_t acpi_toshiba_video_methods[] = {
|
||||
DEVMETHOD(device_probe, acpi_toshiba_video_probe),
|
||||
DEVMETHOD(device_attach, acpi_toshiba_video_attach),
|
||||
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static driver_t acpi_toshiba_video_driver = {
|
||||
"acpi_toshiba_video",
|
||||
acpi_toshiba_video_methods,
|
||||
0,
|
||||
};
|
||||
|
||||
static devclass_t acpi_toshiba_video_devclass;
|
||||
DRIVER_MODULE(acpi_toshiba_video, acpi, acpi_toshiba_video_driver,
|
||||
acpi_toshiba_video_devclass, 0, 0);
|
||||
MODULE_DEPEND(acpi_toshiba_video, acpi, 1, 1, 1);
|
||||
|
||||
static int enable_fn_keys = 1;
|
||||
TUNABLE_INT("hw.acpi.toshiba.enable_fn_keys", &enable_fn_keys);
|
||||
|
||||
/*
|
||||
* HID Model
|
||||
* -------------------------------------
|
||||
* TOS6200 Libretto L Series
|
||||
* Dynabook Satellite 2455
|
||||
* Dynabook SS 3500
|
||||
* TOS6207 Dynabook SS2110 Series
|
||||
*/
|
||||
static int
|
||||
acpi_toshiba_probe(device_t dev)
|
||||
{
|
||||
static char *tosh_ids[] = { "TOS6200", "TOS6207", NULL };
|
||||
|
||||
if (acpi_disabled("toshiba") ||
|
||||
ACPI_ID_PROBE(device_get_parent(dev), dev, tosh_ids) == NULL ||
|
||||
device_get_unit(dev) != 0)
|
||||
return (ENXIO);
|
||||
|
||||
device_set_desc(dev, "Toshiba HCI Extras");
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_toshiba_attach(device_t dev)
|
||||
{
|
||||
struct acpi_toshiba_softc *sc;
|
||||
struct acpi_softc *acpi_sc;
|
||||
ACPI_STATUS status;
|
||||
int i;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->dev = dev;
|
||||
sc->handle = acpi_get_handle(dev);
|
||||
|
||||
acpi_sc = acpi_device_get_parent_softc(dev);
|
||||
sysctl_ctx_init(&sc->sysctl_ctx);
|
||||
sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(acpi_sc->acpi_sysctl_tree), OID_AUTO,
|
||||
"toshiba", CTLFLAG_RD, 0, "");
|
||||
|
||||
for (i = 0; sysctl_table[i].name != NULL; i++) {
|
||||
SYSCTL_ADD_PROC(&sc->sysctl_ctx,
|
||||
SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO,
|
||||
sysctl_table[i].name,
|
||||
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY,
|
||||
sc, i, acpi_toshiba_sysctl, "I", "");
|
||||
}
|
||||
|
||||
if (enable_fn_keys != 0) {
|
||||
status = AcpiEvaluateObject(sc->handle, METHOD_HCI_ENABLE,
|
||||
NULL, NULL);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
device_printf(dev, "enable FN keys failed\n");
|
||||
sysctl_ctx_free(&sc->sysctl_ctx);
|
||||
return (ENXIO);
|
||||
}
|
||||
AcpiInstallNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
|
||||
acpi_toshiba_notify, sc);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_toshiba_detach(device_t dev)
|
||||
{
|
||||
struct acpi_toshiba_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (enable_fn_keys != 0) {
|
||||
AcpiRemoveNotifyHandler(sc->handle, ACPI_DEVICE_NOTIFY,
|
||||
acpi_toshiba_notify);
|
||||
}
|
||||
sysctl_ctx_free(&sc->sysctl_ctx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_toshiba_sysctl(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct acpi_toshiba_softc *sc;
|
||||
UINT32 arg;
|
||||
int function, error = 0;
|
||||
hci_fn_t *handler;
|
||||
|
||||
sc = (struct acpi_toshiba_softc *)oidp->oid_arg1;
|
||||
function = oidp->oid_arg2;
|
||||
handler = sysctl_table[function].handler;
|
||||
|
||||
/* Get the current value from the appropriate function. */
|
||||
ACPI_SERIAL_BEGIN(toshiba);
|
||||
error = handler(sc->handle, HCI_GET, &arg);
|
||||
if (error != 0)
|
||||
goto out;
|
||||
|
||||
/* Send the current value to the user and return if no new value. */
|
||||
error = sysctl_handle_int(oidp, &arg, 0, req);
|
||||
if (error != 0 || req->newptr == NULL)
|
||||
goto out;
|
||||
|
||||
/* Set the new value via the appropriate function. */
|
||||
error = handler(sc->handle, HCI_SET, &arg);
|
||||
|
||||
out:
|
||||
ACPI_SERIAL_END(toshiba);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
hci_force_fan(ACPI_HANDLE h, int op, UINT32 *state)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ACPI_SERIAL_ASSERT(toshiba);
|
||||
if (op == HCI_SET) {
|
||||
if (*state < 0 || *state > 1)
|
||||
return (EINVAL);
|
||||
*state <<= HCI_FAN_SHIFT;
|
||||
}
|
||||
ret = hci_call(h, op, HCI_REG_FAN, state);
|
||||
if (ret == 0 && op == HCI_GET)
|
||||
*state >>= HCI_FAN_SHIFT;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
hci_video_output(ACPI_HANDLE h, int op, UINT32 *video_output)
|
||||
{
|
||||
int ret;
|
||||
ACPI_STATUS status;
|
||||
|
||||
ACPI_SERIAL_ASSERT(toshiba);
|
||||
if (op == HCI_SET) {
|
||||
if (*video_output < 1 || *video_output > 7)
|
||||
return (EINVAL);
|
||||
if (h == NULL)
|
||||
return (ENXIO);
|
||||
*video_output |= HCI_VIDEO_OUTPUT_FLAG;
|
||||
status = acpi_SetInteger(h, METHOD_VIDEO, *video_output);
|
||||
if (ACPI_SUCCESS(status))
|
||||
ret = 0;
|
||||
else
|
||||
ret = ENXIO;
|
||||
} else {
|
||||
ret = hci_call(h, op, HCI_REG_VIDEO_OUTPUT, video_output);
|
||||
if (ret == 0)
|
||||
*video_output &= 0xff;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
hci_lcd_brightness(ACPI_HANDLE h, int op, UINT32 *brightness)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ACPI_SERIAL_ASSERT(toshiba);
|
||||
if (op == HCI_SET) {
|
||||
if (*brightness < 0 || *brightness > HCI_LCD_BRIGHTNESS_MAX)
|
||||
return (EINVAL);
|
||||
*brightness <<= HCI_LCD_BRIGHTNESS_SHIFT;
|
||||
}
|
||||
ret = hci_call(h, op, HCI_REG_LCD_BRIGHTNESS, brightness);
|
||||
if (ret == 0 && op == HCI_GET)
|
||||
*brightness >>= HCI_LCD_BRIGHTNESS_SHIFT;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
hci_lcd_backlight(ACPI_HANDLE h, int op, UINT32 *backlight)
|
||||
{
|
||||
|
||||
ACPI_SERIAL_ASSERT(toshiba);
|
||||
if (op == HCI_SET) {
|
||||
if (*backlight < 0 || *backlight > 1)
|
||||
return (EINVAL);
|
||||
}
|
||||
return (hci_call(h, op, HCI_REG_LCD_BACKLIGHT, backlight));
|
||||
}
|
||||
|
||||
static int
|
||||
hci_cpu_speed(ACPI_HANDLE h, int op, UINT32 *speed)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ACPI_SERIAL_ASSERT(toshiba);
|
||||
if (op == HCI_SET) {
|
||||
if (*speed < 0 || *speed > HCI_CPU_SPEED_MAX)
|
||||
return (EINVAL);
|
||||
*speed <<= HCI_CPU_SPEED_SHIFT;
|
||||
}
|
||||
ret = hci_call(h, op, HCI_REG_CPU_SPEED, speed);
|
||||
if (ret == 0 && op == HCI_GET)
|
||||
*speed >>= HCI_CPU_SPEED_SHIFT;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
hci_call(ACPI_HANDLE h, int op, int function, UINT32 *arg)
|
||||
{
|
||||
ACPI_OBJECT_LIST args;
|
||||
ACPI_BUFFER results;
|
||||
ACPI_OBJECT obj[HCI_WORDS];
|
||||
ACPI_OBJECT *res;
|
||||
int status, i, ret;
|
||||
|
||||
ACPI_SERIAL_ASSERT(toshiba);
|
||||
status = ENXIO;
|
||||
|
||||
for (i = 0; i < HCI_WORDS; i++) {
|
||||
obj[i].Type = ACPI_TYPE_INTEGER;
|
||||
obj[i].Integer.Value = 0;
|
||||
}
|
||||
obj[HCI_REG_AX].Integer.Value = op;
|
||||
obj[HCI_REG_BX].Integer.Value = function;
|
||||
if (op == HCI_SET)
|
||||
obj[HCI_REG_CX].Integer.Value = *arg;
|
||||
|
||||
args.Count = HCI_WORDS;
|
||||
args.Pointer = obj;
|
||||
results.Pointer = NULL;
|
||||
results.Length = ACPI_ALLOCATE_BUFFER;
|
||||
if (ACPI_FAILURE(AcpiEvaluateObject(h, METHOD_HCI, &args, &results)))
|
||||
goto end;
|
||||
res = (ACPI_OBJECT *)results.Pointer;
|
||||
if (!ACPI_PKG_VALID(res, HCI_WORDS)) {
|
||||
printf("toshiba: invalid package!\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
acpi_PkgInt32(res, HCI_REG_AX, &ret);
|
||||
if (ret == HCI_SUCCESS) {
|
||||
if (op == HCI_GET)
|
||||
acpi_PkgInt32(res, HCI_REG_CX, arg);
|
||||
status = 0;
|
||||
} else if (function == HCI_REG_SYSTEM_EVENT && op == HCI_GET &&
|
||||
ret == HCI_NOT_SUPPORTED) {
|
||||
/*
|
||||
* Sometimes system events are disabled without us requesting
|
||||
* it. This workaround attempts to re-enable them.
|
||||
*
|
||||
* XXX This call probably shouldn't be recursive. Queueing
|
||||
* a task via AcpiOsQueueForExecution() might be better.
|
||||
*/
|
||||
i = 1;
|
||||
hci_call(h, HCI_SET, HCI_REG_SYSTEM_EVENT, &i);
|
||||
}
|
||||
|
||||
end:
|
||||
if (results.Pointer != NULL)
|
||||
AcpiOsFree(results.Pointer);
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform a few actions based on the keypress. Users can extend this
|
||||
* functionality by reading the keystrokes we send to devd(8).
|
||||
*/
|
||||
static void
|
||||
hci_key_action(struct acpi_toshiba_softc *sc, ACPI_HANDLE h, UINT32 key)
|
||||
{
|
||||
UINT32 arg;
|
||||
|
||||
ACPI_SERIAL_ASSERT(toshiba);
|
||||
switch (key) {
|
||||
case FN_F6_RELEASE:
|
||||
/* Decrease LCD brightness. */
|
||||
hci_lcd_brightness(h, HCI_GET, &arg);
|
||||
if (arg-- == 0)
|
||||
arg = 0;
|
||||
else
|
||||
hci_lcd_brightness(h, HCI_SET, &arg);
|
||||
break;
|
||||
case FN_F7_RELEASE:
|
||||
/* Increase LCD brightness. */
|
||||
hci_lcd_brightness(h, HCI_GET, &arg);
|
||||
if (arg++ == 7)
|
||||
arg = 7;
|
||||
else
|
||||
hci_lcd_brightness(h, HCI_SET, &arg);
|
||||
break;
|
||||
case FN_F5_RELEASE:
|
||||
/* Cycle through video outputs. */
|
||||
hci_video_output(h, HCI_GET, &arg);
|
||||
arg = (arg + 1) % 7;
|
||||
hci_video_output(sc->video_handle, HCI_SET, &arg);
|
||||
break;
|
||||
case FN_F8_RELEASE:
|
||||
/* Toggle LCD backlight. */
|
||||
hci_lcd_backlight(h, HCI_GET, &arg);
|
||||
arg = (arg != 0) ? 0 : 1;
|
||||
hci_lcd_backlight(h, HCI_SET, &arg);
|
||||
break;
|
||||
case FN_ESC_RELEASE:
|
||||
/* Toggle forcing fan on. */
|
||||
hci_force_fan(h, HCI_GET, &arg);
|
||||
arg = (arg != 0) ? 0 : 1;
|
||||
hci_force_fan(h, HCI_SET, &arg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
acpi_toshiba_notify(ACPI_HANDLE h, UINT32 notify, void *context)
|
||||
{
|
||||
struct acpi_toshiba_softc *sc;
|
||||
UINT32 key;
|
||||
|
||||
sc = (struct acpi_toshiba_softc *)context;
|
||||
|
||||
if (notify == 0x80) {
|
||||
ACPI_SERIAL_BEGIN(toshiba);
|
||||
while (hci_call(h, HCI_GET, HCI_REG_SYSTEM_EVENT, &key) == 0) {
|
||||
hci_key_action(sc, h, key);
|
||||
acpi_UserNotify("TOSHIBA", h, (uint8_t)key);
|
||||
}
|
||||
ACPI_SERIAL_END(toshiba);
|
||||
} else
|
||||
device_printf(sc->dev, "unknown notify: 0x%x\n", notify);
|
||||
}
|
||||
|
||||
/*
|
||||
* Toshiba video pseudo-device to provide the DSSX method.
|
||||
*
|
||||
* HID Model
|
||||
* -------------------------------------
|
||||
* TOS6201 Libretto L Series
|
||||
*/
|
||||
static int
|
||||
acpi_toshiba_video_probe(device_t dev)
|
||||
{
|
||||
static char *vid_ids[] = { "TOS6201", NULL };
|
||||
|
||||
if (acpi_disabled("toshiba") ||
|
||||
ACPI_ID_PROBE(device_get_parent(dev), dev, vid_ids) == NULL ||
|
||||
device_get_unit(dev) != 0)
|
||||
return (ENXIO);
|
||||
|
||||
device_quiet(dev);
|
||||
device_set_desc(dev, "Toshiba Video");
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_toshiba_video_attach(device_t dev)
|
||||
{
|
||||
struct acpi_toshiba_softc *sc;
|
||||
|
||||
sc = devclass_get_softc(acpi_toshiba_devclass, 0);
|
||||
if (sc == NULL)
|
||||
return (ENXIO);
|
||||
sc->video_handle = acpi_get_handle(dev);
|
||||
return (0);
|
||||
}
|
@ -8,6 +8,6 @@
|
||||
.error "The ACPI module is only for i386"
|
||||
.endif
|
||||
|
||||
SUBDIR= acpi acpi_asus acpi_panasonic acpi_snc acpi_toshiba acpi_video
|
||||
SUBDIR= acpi acpi_asus acpi_panasonic acpi_sony acpi_toshiba acpi_video
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -1,6 +1,6 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../../i386/acpica
|
||||
.PATH: ${.CURDIR}/../../../dev/acpi_support
|
||||
|
||||
KMOD= acpi_asus
|
||||
WARNS?= 2
|
||||
|
@ -1,6 +1,6 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../../i386/acpica
|
||||
.PATH: ${.CURDIR}/../../../dev/acpi_support
|
||||
|
||||
KMOD= acpi_panasonic
|
||||
WARNS?= 2
|
||||
|
9
sys/modules/acpi/acpi_sony/Makefile
Normal file
9
sys/modules/acpi/acpi_sony/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../../dev/acpi_support
|
||||
|
||||
KMOD= acpi_sony
|
||||
CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica
|
||||
SRCS= acpi_sony.c opt_acpi.h device_if.h bus_if.h acpi_if.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
@ -1,6 +1,6 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../../i386/acpica
|
||||
.PATH: ${.CURDIR}/../../../dev/acpi_support
|
||||
|
||||
KMOD= acpi_toshiba
|
||||
WARNS?= 2
|
||||
|
Loading…
Reference in New Issue
Block a user