2004-11-11 22:54:58 +00:00
|
|
|
/*-
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2005-03-02 09:22:34 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2004-11-11 22:54:58 +00:00
|
|
|
#include "opt_acpi.h"
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/bus.h>
|
2009-06-05 18:44:36 +00:00
|
|
|
|
|
|
|
#include <contrib/dev/acpica/include/acpi.h>
|
|
|
|
|
2004-11-11 22:54:58 +00:00
|
|
|
#include "acpi_if.h"
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <dev/acpica/acpivar.h>
|
|
|
|
#include <sys/sysctl.h>
|
2004-12-13 23:31:46 +00:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_OEM
|
|
|
|
ACPI_MODULE_NAME("Sony")
|
|
|
|
|
2004-11-29 16:40:30 +00:00
|
|
|
#define ACPI_SONY_GET_BRIGHTNESS "GBRT"
|
|
|
|
#define ACPI_SONY_SET_BRIGHTNESS "SBRT"
|
|
|
|
#define ACPI_SONY_GET_PID "GPID"
|
2004-12-13 23:31:46 +00:00
|
|
|
|
2004-11-11 22:54:58 +00:00
|
|
|
/*
|
|
|
|
* SNY5001
|
|
|
|
* [GS]BRT [GS]PBR [GS]CTR [GS]PCR [GS]CMI [CDPW GCDP]? GWDP PWAK PWRN
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-11-29 16:40:30 +00:00
|
|
|
struct acpi_sony_softc {
|
2004-11-15 05:12:17 +00:00
|
|
|
int pid;
|
2004-11-11 22:54:58 +00:00
|
|
|
};
|
2004-11-29 16:40:30 +00:00
|
|
|
static struct acpi_sony_name_list
|
2004-11-11 22:54:58 +00:00
|
|
|
{
|
2004-11-15 05:12:17 +00:00
|
|
|
char *nodename;
|
|
|
|
char *getmethod;
|
|
|
|
char *setmethod;
|
|
|
|
char *comment;
|
2004-11-29 16:40:30 +00:00
|
|
|
} acpi_sony_oids[] = {
|
2004-11-15 05:12:17 +00:00
|
|
|
{ "brightness", "GBRT", "SBRT", "Display Brightness"},
|
|
|
|
{ "ctr", "GCTR", "SCTR", "??"},
|
|
|
|
{ "pcr", "GPCR", "SPCR", "???"},
|
2004-11-11 22:54:58 +00:00
|
|
|
#if 0
|
2004-11-15 05:12:17 +00:00
|
|
|
{ "cmi", "GCMI", "SCMI", "????"},
|
2004-11-11 22:54:58 +00:00
|
|
|
#endif
|
2004-11-15 05:12:17 +00:00
|
|
|
{ "wdp", "GWDP", NULL, "?????"},
|
2006-11-01 03:45:24 +00:00
|
|
|
{ "cdp", "GCDP", "CDPW", "CD Power"}, /*shares [\GL03]&0x8 flag*/
|
2008-05-20 06:32:07 +00:00
|
|
|
{ "azp", "GAZP", "AZPW", "Audio Power"},
|
2006-11-01 03:45:24 +00:00
|
|
|
{ NULL, NULL, NULL }
|
2004-11-11 22:54:58 +00:00
|
|
|
};
|
|
|
|
|
2004-11-29 16:40:30 +00:00
|
|
|
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);
|
2004-11-11 22:54:58 +00:00
|
|
|
|
2004-11-29 16:40:30 +00:00
|
|
|
static device_method_t acpi_sony_methods[] = {
|
2004-11-11 22:54:58 +00:00
|
|
|
/* Device interface */
|
2004-11-29 16:40:30 +00:00
|
|
|
DEVMETHOD(device_probe, acpi_sony_probe),
|
|
|
|
DEVMETHOD(device_attach, acpi_sony_attach),
|
|
|
|
DEVMETHOD(device_detach, acpi_sony_detach),
|
2004-11-11 22:54:58 +00:00
|
|
|
|
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
|
2004-11-29 16:40:30 +00:00
|
|
|
static driver_t acpi_sony_driver = {
|
|
|
|
"acpi_sony",
|
|
|
|
acpi_sony_methods,
|
|
|
|
sizeof(struct acpi_sony_softc),
|
2004-11-11 22:54:58 +00:00
|
|
|
};
|
|
|
|
|
2004-11-29 16:40:30 +00:00
|
|
|
static devclass_t acpi_sony_devclass;
|
2004-11-11 22:54:58 +00:00
|
|
|
|
2004-11-29 16:40:30 +00:00
|
|
|
DRIVER_MODULE(acpi_sony, acpi, acpi_sony_driver, acpi_sony_devclass,
|
2004-11-11 22:54:58 +00:00
|
|
|
0, 0);
|
2004-11-29 16:40:30 +00:00
|
|
|
MODULE_DEPEND(acpi_sony, acpi, 1, 1, 1);
|
2004-11-11 22:54:58 +00:00
|
|
|
static char *sny_id[] = {"SNY5001", NULL};
|
|
|
|
|
|
|
|
static int
|
2004-11-29 16:40:30 +00:00
|
|
|
acpi_sony_probe(device_t dev)
|
2004-11-11 22:54:58 +00:00
|
|
|
{
|
2009-05-12 23:22:58 +00:00
|
|
|
int ret = ENXIO;
|
2004-11-11 22:54:58 +00:00
|
|
|
|
|
|
|
if (ACPI_ID_PROBE(device_get_parent(dev), dev, sny_id)) {
|
|
|
|
device_set_desc(dev, "Sony notebook controller");
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-11-29 16:40:30 +00:00
|
|
|
acpi_sony_attach(device_t dev)
|
2004-11-11 22:54:58 +00:00
|
|
|
{
|
2004-11-29 16:40:30 +00:00
|
|
|
struct acpi_sony_softc *sc;
|
2004-11-11 22:54:58 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
2004-11-29 16:40:30 +00:00
|
|
|
acpi_GetInteger(acpi_get_handle(dev), ACPI_SONY_GET_PID, &sc->pid);
|
2004-11-11 22:54:58 +00:00
|
|
|
device_printf(dev, "PID %x\n", sc->pid);
|
2004-11-29 16:40:30 +00:00
|
|
|
for (i = 0 ; acpi_sony_oids[i].nodename != NULL; i++){
|
2004-11-11 22:54:58 +00:00
|
|
|
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
2004-11-13 23:39:56 +00:00
|
|
|
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
|
2004-11-29 16:40:30 +00:00
|
|
|
i, acpi_sony_oids[i].nodename , CTLTYPE_INT |
|
|
|
|
((acpi_sony_oids[i].setmethod)? CTLFLAG_RW: CTLFLAG_RD),
|
|
|
|
dev, i, sysctl_acpi_sony_gen_handler, "I",
|
|
|
|
acpi_sony_oids[i].comment);
|
2004-11-11 22:54:58 +00:00
|
|
|
}
|
2004-11-15 05:12:17 +00:00
|
|
|
return (0);
|
2004-11-11 22:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-11-29 16:40:30 +00:00
|
|
|
acpi_sony_detach(device_t dev)
|
2004-11-11 22:54:58 +00:00
|
|
|
{
|
2004-11-15 20:08:44 +00:00
|
|
|
return (0);
|
2004-11-11 22:54:58 +00:00
|
|
|
}
|
2004-11-15 05:12:17 +00:00
|
|
|
|
2004-11-11 22:54:58 +00:00
|
|
|
#if 0
|
|
|
|
static int
|
2004-11-29 16:40:30 +00:00
|
|
|
acpi_sony_suspend(device_t dev)
|
2004-11-11 22:54:58 +00:00
|
|
|
{
|
2004-11-29 16:40:30 +00:00
|
|
|
struct acpi_sony_softc *sc = device_get_softc(dev);
|
2004-11-15 05:12:17 +00:00
|
|
|
return (0);
|
2004-11-11 22:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-11-29 16:40:30 +00:00
|
|
|
acpi_sony_resume(device_t dev)
|
2004-11-11 22:54:58 +00:00
|
|
|
{
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
2004-11-29 16:40:30 +00:00
|
|
|
sysctl_acpi_sony_gen_handler(SYSCTL_HANDLER_ARGS)
|
2004-11-11 22:54:58 +00:00
|
|
|
{
|
|
|
|
device_t dev = arg1;
|
|
|
|
int function = oidp->oid_arg2;
|
|
|
|
int error = 0, val;
|
|
|
|
|
2004-11-15 05:12:17 +00:00
|
|
|
acpi_GetInteger(acpi_get_handle(dev),
|
2004-11-29 16:40:30 +00:00
|
|
|
acpi_sony_oids[function].getmethod, &val);
|
2004-11-11 22:54:58 +00:00
|
|
|
error = sysctl_handle_int(oidp, &val, 0, req);
|
2004-11-29 16:40:30 +00:00
|
|
|
if (error || !req->newptr || !acpi_sony_oids[function].setmethod)
|
2004-11-15 05:12:17 +00:00
|
|
|
return (error);
|
|
|
|
acpi_SetInteger(acpi_get_handle(dev),
|
2004-11-29 16:40:30 +00:00
|
|
|
acpi_sony_oids[function].setmethod, val);
|
2004-11-15 05:12:17 +00:00
|
|
|
return (0);
|
2004-11-11 22:54:58 +00:00
|
|
|
}
|