/*-
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Gregoire Sutre.
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
/*
* ACPI Fujitsu Driver.
*
* Together with fujhk(4), this driver provides support for the ACPI devices
* FUJ02B1 and FUJ02E3 that are commonly found in Fujitsu LifeBooks. The
* driver does not support all features of these devices, in particular
* volume control is not implemented.
*
* Information regarding the behavior of these devices was obtained from the
* source code of the Linux and FreeBSD drivers, as well as from experiments on
* a Fujitsu LifeBook P7120.
*
* The FUJ02B1 device is used to control the brightness level of the internal
* display, the state (on/off) of the internal pointer, and the volume level of
* the internal speakers or headphones.
*
* The FUJ02B1 device provides the following methods (or only a subset):
*
* GSIF supported hotkey status bits (bitmask for GHKS)
* GHKS active hotkeys (bit field)
* {G,S}BLL get/set the brightness level of the internal display
* {G,S}VOL get/set the volume level of the internal speakers
* {G,S}MOU get/set the switch state of the internal pointer
* RBLL brightness radix (number of brightness levels)
* RVOL volume radix (number of volume levels)
*
* Notifications are delivered to the FUJ02B1 device when functions hotkeys
* (brightness, pointer) are released. However, these notifications seem to be
* purely informative: the BIOS already made the hardware changes corresponding
* to the hotkey.
*
* Each bit in the value returned by GHKS remains set until the corresponding
* get method (GBLL, GMOU or GVOL) is called.
*
* The FUJ02E3 device manages the laptop hotkeys (such as the `Eco' button) and
* provides additional services (such as backlight on/off control) through the
* FUNC method.
*
* The FUJ02E3 device provides the following methods (or only a subset):
*
* GIRB get next hotkey code from buffer
* FUNC general-purpose method (four arguments)
*
* Notifications are delivered to the FUJ02E3 device when hotkeys are pressed
* and when they are released. The BIOS stores the corresponding codes in a
* FIFO buffer, that can be read with the GIRB method.
*/
/*
* On some LifeBook models, a call to the SMOU method is required to make the
* internal pointer work after resume. On the P7120, the internal pointer is
* always enabled after resume. If it was disabled before suspend, the BIOS
* apparently believes that it is still disabled after resume.
*
* To prevent these problems, we disable the internal pointer on suspend and
* enable it on resume.
*/
static bool
fujitsu_bp_suspend(device_t self, const pmf_qual_t *qual)
{
struct fujitsu_bp_softc *sc = device_private(self);
if (!(sc->sc_caps & FUJITSU_BP_CAP_SMOU))
return ENODEV;
rv = acpi_eval_set_integer(hdl, "SMOU", val);
if (ACPI_FAILURE(rv)) {
aprint_error_dev(sc->sc_dev, "failed to evaluate %s.%s: %s\n",
acpi_name(hdl), "SMOU", AcpiFormatException(rv));
return EIO;
}
return 0;
}
/*
* fujitusu_bp_cap:
*
* Returns true if and only if (a) the object handle.path exists and
* (b) this object is a method or has the given type.
*/
static bool
fujitsu_bp_cap(ACPI_HANDLE handle, const char *path, ACPI_OBJECT_TYPE type)
{
ACPI_HANDLE hdl;
ACPI_OBJECT_TYPE typ;
KASSERT(handle != NULL);
if (ACPI_FAILURE(AcpiGetHandle(handle, path, &hdl)))
return false;
if (ACPI_FAILURE(AcpiGetType(hdl, &typ)))
return false;
if (typ != ACPI_TYPE_METHOD && typ != type)
return false;
return true;
}
MODULE(MODULE_CLASS_DRIVER, fujbp, NULL);
#ifdef _MODULE
#include "ioconf.c"
#endif
static int
fujbp_modcmd(modcmd_t cmd, void *aux)
{
int rv = 0;