Commit 332edc2f authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6:
  staging: pcc_acpi: delete obsolete driver
parents f8aea200 f81db820
......@@ -43,8 +43,6 @@ source "drivers/staging/echo/Kconfig"
source "drivers/staging/at76_usb/Kconfig"
source "drivers/staging/pcc-acpi/Kconfig"
source "drivers/staging/poch/Kconfig"
endif # STAGING
......@@ -13,5 +13,4 @@ obj-$(CONFIG_W35UND) += winbond/
obj-$(CONFIG_PRISM2_USB) += wlan-ng/
obj-$(CONFIG_ECHO) += echo/
obj-$(CONFIG_USB_ATMEL) += at76_usb/
obj-$(CONFIG_PCC_ACPI) += pcc-acpi/
obj-$(CONFIG_POCH) += poch/
config PCC_ACPI
tristate "Panasonic ACPI Hotkey support"
depends on ACPI
default n
---help---
This driver provides support for Panasonic hotkeys through the
ACPI interface. This works for the Panasonic R1 (N variant),
R2, R3, T2, W2, and Y2 laptops.
To compile this driver as a module, choose M here. The module
will be called pcc-acpi.
obj-$(CONFIG_PCC_ACPI) += pcc-acpi.o
TODO:
- Lindent fixes
- checkpatch.pl fixes
- verify that the acpi interface is correct
- remove /proc dependancy if needed (not sure yet.)
Please send any patches for this driver to Greg Kroah-Hartman <greg@kroah.com>
/*
* Panasonic HotKey and lcd brightness control Extra driver
* (C) 2004 Hiroshi Miura <miura@da-cha.org>
* (C) 2004 NTT DATA Intellilink Co. http://www.intellilink.co.jp/
* (C) YOKOTA Hiroshi <yokota (at) netlab. is. tsukuba. ac. jp>
* (C) 2004 David Bronaugh <dbronaugh>
*
* derived from toshiba_acpi.c, Copyright (C) 2002-2004 John Belmonte
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* publicshed by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*---------------------------------------------------------------------------
*
* ChangeLog:
*
* Nov.04, 2006 Hiroshi Miura <miura@da-cha.org>
* -v0.9 remove warning about section reference.
* remove acpi_os_free
* add /proc/acpi/pcc/brightness interface to
* allow HAL to access.
* merge dbronaugh's enhancement
* Aug.17, 2004 David Bronaugh (dbronaugh)
* - Added screen brightness setting interface
* Thanks to the FreeBSD crew
* (acpi_panasonic.c authors)
* for the ideas I needed to accomplish it
*
* May.29, 2006 Hiroshi Miura <miura@da-cha.org>
* -v0.8.4 follow to change keyinput structure
* thanks Fabian Yamaguchi <fabs@cs.tu-berlin.de>,
* Jacob Bower <jacob.bower@ic.ac.uk> and
* Hiroshi Yokota for providing solutions.
*
* Oct.02, 2004 Hiroshi Miura <miura@da-cha.org>
* -v0.8.2 merge code of YOKOTA Hiroshi
* <yokota@netlab.is.tsukuba.ac.jp>.
* Add sticky key mode interface.
* Refactoring acpi_pcc_generete_keyinput().
*
* Sep.15, 2004 Hiroshi Miura <miura@da-cha.org>
* -v0.8 Generate key input event on input subsystem.
* This is based on yet another driver
* written by Ryuta Nakanishi.
*
* Sep.10, 2004 Hiroshi Miura <miura@da-cha.org>
* -v0.7 Change proc interface functions using seq_file
* facility as same as other ACPI drivers.
*
* Aug.28, 2004 Hiroshi Miura <miura@da-cha.org>
* -v0.6.4 Fix a silly error with status checking
*
* Aug.25, 2004 Hiroshi Miura <miura@da-cha.org>
* -v0.6.3 replace read_acpi_int by standard
* function acpi_evaluate_integer
* some clean up and make smart copyright notice.
* fix return value of pcc_acpi_get_key()
* fix checking return value of acpi_bus_register_driver()
*
* Aug.22, 2004 David Bronaugh <dbronaugh@linuxboxen.org>
* -v0.6.2 Add check on ACPI data (num_sifr)
* Coding style cleanups, better error messages/handling
* Fixed an off-by-one error in memory allocation
*
* Aug.21, 2004 David Bronaugh <dbronaugh@linuxboxen.org>
* -v0.6.1 Fix a silly error with status checking
*
* Aug.20, 2004 David Bronaugh <dbronaugh@linuxboxen.org>
* - v0.6 Correct brightness controls to reflect reality
* based on information gleaned by Hiroshi Miura
* and discussions with Hiroshi Miura
*
* Aug.10, 2004 Hiroshi Miura <miura@da-cha.org>
* - v0.5 support LCD brightness control
* based on the disclosed information by MEI.
*
* Jul.25, 2004 Hiroshi Miura <miura@da-cha.org>
* - v0.4 first post version
* add function to retrive SIFR
*
* Jul.24, 2004 Hiroshi Miura <miura@da-cha.org>
* - v0.3 get proper status of hotkey
*
* Jul.22, 2004 Hiroshi Miura <miura@da-cha.org>
* - v0.2 add HotKey handler
*
* Jul.17, 2004 Hiroshi Miura <miura@da-cha.org>
* - v0.1 start from toshiba_acpi driver written by John Belmonte
*
*/
#define ACPI_PCC_VERSION "0.9+hy"
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/ctype.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
/*************************************************************************
* "seq" file template definition.
*/
/* "seq" initializer */
#define SEQ_OPEN_FS(_open_func_name_, _show_func_name_) \
static int _open_func_name_(struct inode *inode, struct file *file) \
{ \
return single_open(file, _show_func_name_, PDE(inode)->data); \
}
/*-------------------------------------------------------------------------
* "seq" fops template for read-only files.
*/
#define SEQ_FILEOPS_R(_open_func_name_) \
{ \
.open = _open_func_name_, \
.read = seq_read, \
.llseek = seq_lseek, \
.release = single_release, \
}
/*------------------------------------------------------------------------
* "seq" fops template for read-write files.
*/
#define SEQ_FILEOPS_RW(_open_func_name_, _write_func_name_) \
{ \
.open = _open_func_name_ , \
.read = seq_read, \
.write = _write_func_name_, \
.llseek = seq_lseek, \
.release = single_release, \
}
/*
* "seq" file template definition ended.
***************************************************************************
*/
#ifndef ACPI_HOTKEY_COMPONENT
#define ACPI_HOTKEY_COMPONENT 0x10000000
#endif
#define _COMPONENT ACPI_HOTKEY_COMPONENT
ACPI_MODULE_NAME("pcc_acpi");
MODULE_AUTHOR("Hiroshi Miura, Hiroshi Yokota");
MODULE_DESCRIPTION("ACPI HotKey driver for Panasonic Let's Note laptops");
MODULE_LICENSE("GPL");
#define LOGPREFIX "pcc_acpi: "
/****************************************************
* Define ACPI PATHs
****************************************************/
/* Lets note hotkeys */
#define METHOD_HKEY_QUERY "HINF"
#define METHOD_HKEY_SQTY "SQTY"
#define METHOD_HKEY_SINF "SINF"
#define METHOD_HKEY_SSET "SSET"
#define HKEY_NOTIFY 0x80
/* for brightness control */
#define LCD_MAX_BRIGHTNESS 255
/* This may be magical -- beware */
#define LCD_BRIGHTNESS_INCREMENT 17
/* Registers of SINF */
#define SINF_LCD_BRIGHTNESS 4
/*******************************************************************
*
* definitions for /proc/ interface
*
*******************************************************************/
#define ACPI_PCC_DRIVER_NAME "pcc_acpi"
#define ACPI_PCC_DEVICE_NAME "PCCExtra"
#define ACPI_PCC_CLASS "pcc"
#define PROC_PCC ACPI_PCC_CLASS
#define ACPI_PCC_INPUT_PHYS "panasonic/hkey0"
/* This is transitional definition */
#ifndef KEY_BATT
# define KEY_BATT 227
#endif
#define PROC_STR_MAX_LEN 8
#define BUS_PCC_HOTKEY BUS_I8042 /*0x1a*/ /* FIXME: BUS_I8042? */
/* Fn+F4/F5 confricts with Shift+F1/F2 */
/* This hack avoids key number confrict */
#define PCC_KEYINPUT_MODE (0)
/* LCD_TYPEs: 0 = Normal, 1 = Semi-transparent
ENV_STATEs: Normal temp=0x01, High temp=0x81, N/A=0x00
*/
enum SINF_BITS { SINF_NUM_BATTERIES = 0,
SINF_LCD_TYPE,
SINF_AC_MAX_BRIGHT,
SINF_AC_MIN_BRIGHT,
SINF_AC_CUR_BRIGHT,
/* 4 = R1 only handle SINF_AC_CUR_BRIGHT
* as SINF_CUR_BRIGHT and don't know AC state */
SINF_DC_MAX_BRIGHT,
SINF_DC_MIN_BRIGHT,
SINF_DC_CUR_BRIGHT,
SINF_MUTE,
SINF_RESERVED,
SINF_ENV_STATE, /* 10 */
SINF_STICKY_KEY = 0x80,
};
static struct acpi_device_id pcc_device_ids[] = {
{"MAT0012", 0},
{"MAT0013", 0},
{"MAT0018", 0},
{"MAT0019", 0},
{"", 0},
};
MODULE_DEVICE_TABLE(acpi, pcc_device_ids);
static int __devinit acpi_pcc_hotkey_add(struct acpi_device *device);
static int __devexit acpi_pcc_hotkey_remove(struct acpi_device *device,
int type);
static int acpi_pcc_hotkey_resume(struct acpi_device *device);
static struct acpi_driver acpi_pcc_driver = {
.name = ACPI_PCC_DRIVER_NAME,
.class = ACPI_PCC_CLASS,
.ids = pcc_device_ids,
.ops = {
.add = acpi_pcc_hotkey_add,
.remove = __devexit_p(acpi_pcc_hotkey_remove),
#ifdef CONFIG_PM
/*.suspend = acpi_pcc_hotkey_suspend,*/
.resume = acpi_pcc_hotkey_resume,
#endif
},
};
struct acpi_hotkey {
acpi_handle handle;
struct acpi_device *device;
struct proc_dir_entry *proc_dir_entry;
unsigned long num_sifr;
unsigned long status;
struct input_dev *input_dev;
int sticky_mode;
};
struct pcc_keyinput {
struct acpi_hotkey *hotkey;
int key_mode;
};
/* *************************************************************************
Hotkey driver core
************************************************************************* */
/* -------------------------------------------------------------------------
method access functions
------------------------------------------------------------------------- */
static int acpi_pcc_write_sset(struct acpi_hotkey *hotkey, int func, int val)
{
union acpi_object in_objs[] = {
{ .integer.type = ACPI_TYPE_INTEGER,
.integer.value = func, },
{ .integer.type = ACPI_TYPE_INTEGER,
.integer.value = val, },
};
struct acpi_object_list params = {
.count = ARRAY_SIZE(in_objs),
.pointer = in_objs,
};
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_pcc_write_sset");
status = acpi_evaluate_object(hotkey->handle, METHOD_HKEY_SSET,
&params, NULL);
return_VALUE(status == AE_OK ? AE_OK : AE_ERROR);
}
static inline int acpi_pcc_get_sqty(struct acpi_device *device)
{
unsigned long s;
acpi_status status;
ACPI_FUNCTION_TRACE("acpi_pcc_get_sqty");
status = acpi_evaluate_integer(device->handle, METHOD_HKEY_SQTY,
NULL, &s);
if (ACPI_SUCCESS(status)) {
return_VALUE(s);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"evaluation error HKEY.SQTY\n"));
return_VALUE(-EINVAL);
}
}
static int acpi_pcc_retrieve_biosdata(struct acpi_hotkey *hotkey, u32 *sinf)
{
acpi_status status;
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
union acpi_object *hkey = NULL;
int i;
ACPI_FUNCTION_TRACE("acpi_pcc_retrieve_biosdata");
status = acpi_evaluate_object(hotkey->handle, METHOD_HKEY_SINF, 0,
&buffer);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"evaluation error HKEY.SINF\n"));
status = AE_ERROR;
return_VALUE(status);
}
hkey = buffer.pointer;
if (!hkey || (hkey->type != ACPI_TYPE_PACKAGE)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid HKEY.SINF\n"));
goto free_buffer;
}
if (hotkey->num_sifr < hkey->package.count) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"SQTY reports bad SINF length\n"));
status = AE_ERROR;
goto free_buffer;
}
for (i = 0; i < hkey->package.count; i++) {
union acpi_object *element = &(hkey->package.elements[i]);
if (likely(element->type == ACPI_TYPE_INTEGER)) {
sinf[i] = element->integer.value;
} else {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Invalid HKEY.SINF data\n"));
status = AE_ERROR;
break;
}
}
sinf[hkey->package.count] = -1;
free_buffer:
kfree(buffer.pointer);
return_VALUE(status == AE_OK ? AE_OK : AE_ERROR);
}
static int acpi_pcc_read_sinf_field(struct seq_file *seq, int field)
{
struct acpi_hotkey *hotkey = (struct acpi_hotkey *) seq->private;
u32 sinf[hotkey->num_sifr + 1];
ACPI_FUNCTION_TRACE("acpi_pcc_read_sinf_field");
if (ACPI_SUCCESS(acpi_pcc_retrieve_biosdata(hotkey, sinf)))
seq_printf(seq, "%u\n", sinf[field]);
else
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Couldn't retrieve BIOS data\n"));
return_VALUE(AE_OK);
}
/* -------------------------------------------------------------------------
user interface functions
------------------------------------------------------------------------- */
/* read methods */
/* Sinf read methods */
#define PCC_SINF_READ_F(_name_, FUNC) \
static int _name_(struct seq_file *seq, void *offset) \
{ \
return_VALUE(ACPI_SUCCESS(acpi_pcc_read_sinf_field(seq, \
(FUNC))) \
? 0 : -EINVAL); \
}
PCC_SINF_READ_F(acpi_pcc_numbatteries_show, SINF_NUM_BATTERIES);
PCC_SINF_READ_F(acpi_pcc_lcdtype_show, SINF_LCD_TYPE);
PCC_SINF_READ_F(acpi_pcc_ac_brightness_max_show, SINF_AC_MAX_BRIGHT);
PCC_SINF_READ_F(acpi_pcc_ac_brightness_min_show, SINF_AC_MIN_BRIGHT);
PCC_SINF_READ_F(acpi_pcc_ac_brightness_show, SINF_AC_CUR_BRIGHT);
PCC_SINF_READ_F(acpi_pcc_dc_brightness_max_show, SINF_DC_MAX_BRIGHT);
PCC_SINF_READ_F(acpi_pcc_dc_brightness_min_show, SINF_DC_MIN_BRIGHT);
PCC_SINF_READ_F(acpi_pcc_dc_brightness_show, SINF_DC_CUR_BRIGHT);
PCC_SINF_READ_F(acpi_pcc_brightness_show, SINF_AC_CUR_BRIGHT);
PCC_SINF_READ_F(acpi_pcc_mute_show, SINF_MUTE);
static int acpi_pcc_sticky_key_show(struct seq_file *seq, void *offset)
{
struct acpi_hotkey *hotkey = seq->private;
ACPI_FUNCTION_TRACE("acpi_pcc_sticky_key_show");
if (!hotkey || !hotkey->device)
return_VALUE(-EINVAL);
seq_printf(seq, "%d\n", hotkey->sticky_mode);
return_VALUE(0);
}
static int acpi_pcc_keyinput_show(struct seq_file *seq, void *offset)
{
struct acpi_hotkey *hotkey = seq->private;
struct input_dev *hotk_input_dev = hotkey->input_dev;
struct pcc_keyinput *keyinput = input_get_drvdata(hotk_input_dev);
ACPI_FUNCTION_TRACE("acpi_pcc_keyinput_show");
seq_printf(seq, "%d\n", keyinput->key_mode);
return_VALUE(0);
}
static int acpi_pcc_version_show(struct seq_file *seq, void *offset)
{
struct acpi_hotkey *hotkey = seq->private;
ACPI_FUNCTION_TRACE("acpi_pcc_version_show");
if (!hotkey || !hotkey->device)
return_VALUE(-EINVAL);
seq_printf(seq, "%s version %s\n", ACPI_PCC_DRIVER_NAME,
ACPI_PCC_VERSION);
seq_printf(seq, "%li functions\n", hotkey->num_sifr);
return_VALUE(0);
}
/* write methods */
static ssize_t acpi_pcc_write_single_flag(struct file *file,
const char __user *buffer,
size_t count,
int sinf_func)
{
struct seq_file *seq = file->private_data;
struct acpi_hotkey *hotkey = seq->private;
char write_string[PROC_STR_MAX_LEN];
u32 val;
ACPI_FUNCTION_TRACE("acpi_pcc_write_single_flag");
if (!hotkey || (count > sizeof(write_string) - 1))
return_VALUE(-EINVAL);
if (copy_from_user(write_string, buffer, count))
return_VALUE(-EFAULT);
write_string[count] = '\0';
if ((sscanf(write_string, "%3i", &val) == 1) &&
(val == 0 || val == 1))
acpi_pcc_write_sset(hotkey, sinf_func, val);
return_VALUE(count);
}
static unsigned long acpi_pcc_write_brightness(struct file *file,
const char __user *buffer,
size_t count,
int min_index, int max_index,
int cur_index)
{
struct seq_file *seq = (struct seq_file *)file->private_data;
struct acpi_hotkey *hotkey = (struct acpi_hotkey *)seq->private;
char write_string[PROC_STR_MAX_LEN];
u32 bright;
u32 sinf[hotkey->num_sifr + 1];
ACPI_FUNCTION_TRACE("acpi_pcc_write_brightness");
if (!hotkey || (count > sizeof(write_string) - 1))
return_VALUE(-EINVAL);
if (copy_from_user(write_string, buffer, count))
return_VALUE(-EFAULT);
write_string[count] = '\0';
if (ACPI_FAILURE(acpi_pcc_retrieve_biosdata(hotkey, sinf))) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Couldn't retrieve BIOS data\n"));
goto end;
}
if ((sscanf(write_string, "%4i", &bright) == 1) &&
(bright >= sinf[min_index]) &&
(bright <= sinf[max_index]))
acpi_pcc_write_sset(hotkey, cur_index, bright);
end:
return_VALUE(count);
}
static ssize_t acpi_pcc_write_ac_brightness(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
{
return_VALUE(acpi_pcc_write_brightness(file, buffer, count,
SINF_AC_MIN_BRIGHT,
SINF_AC_MAX_BRIGHT,
SINF_AC_CUR_BRIGHT));
}
static ssize_t acpi_pcc_write_dc_brightness(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
{
return_VALUE(acpi_pcc_write_brightness(file, buffer, count,
SINF_DC_MIN_BRIGHT,
SINF_DC_MAX_BRIGHT,
SINF_DC_CUR_BRIGHT));
}
static ssize_t acpi_pcc_write_no_brightness(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
{
return acpi_pcc_write_brightness(file, buffer, count,
SINF_AC_MIN_BRIGHT,
SINF_AC_MAX_BRIGHT,
SINF_AC_CUR_BRIGHT);
}
static ssize_t acpi_pcc_write_mute(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
{
return_VALUE(acpi_pcc_write_single_flag(file, buffer, count,
SINF_MUTE));
}
static ssize_t acpi_pcc_write_sticky_key(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
{
struct seq_file *seq = (struct seq_file *)file->private_data;
struct acpi_hotkey *hotkey = (struct acpi_hotkey *)seq->private;
char write_string[PROC_STR_MAX_LEN];
int mode;
ACPI_FUNCTION_TRACE("acpi_pcc_write_sticky_key");
if (!hotkey || (count > sizeof(write_string) - 1))
return_VALUE(-EINVAL);
if (copy_from_user(write_string, buffer, count))
return_VALUE(-EFAULT);
write_string[count] = '\0';
if ((sscanf(write_string, "%3i", &mode) == 1) &&
(mode == 0 || mode == 1)) {
acpi_pcc_write_sset(hotkey, SINF_STICKY_KEY, mode);
hotkey->sticky_mode = mode;
}
return_VALUE(count);
}
static ssize_t acpi_pcc_write_keyinput(struct file *file,
const char __user *buffer,
size_t count, loff_t *ppos)
{
struct seq_file *seq = (struct seq_file *)file->private_data;
struct acpi_hotkey *hotkey = (struct acpi_hotkey *)seq->private;
struct pcc_keyinput *keyinput;
char write_string[PROC_STR_MAX_LEN];
int key_mode;
ACPI_FUNCTION_TRACE("acpi_pcc_write_keyinput");
if (!hotkey || (count > (sizeof(write_string) - 1)))
return_VALUE(-EINVAL);
if (copy_from_user(write_string, buffer, count))
return_VALUE(-EFAULT);
write_string[count] = '\0';
if ((sscanf(write_string, "%4i", &key_mode) == 1) &&
(key_mode == 0 || key_mode == 1)) {
keyinput = input_get_drvdata(hotkey->input_dev);
keyinput->key_mode = key_mode;
}
return_VALUE(count);
}
/* -------------------------------------------------------------------------
hotkey driver
------------------------------------------------------------------------- */
static void acpi_pcc_generete_keyinput(struct acpi_hotkey *hotkey)
{
struct input_dev *hotk_input_dev = hotkey->input_dev;
struct pcc_keyinput *keyinput = input_get_drvdata(hotk_input_dev);
int hinf = hotkey->status;
int key_code, hkey_num;
const int key_map[] = {
/* 0 */ -1,
/* 1 */ KEY_BRIGHTNESSDOWN,
/* 2 */ KEY_BRIGHTNESSUP,
/* 3 */ -1, /* vga/lcd switch event is not occur on
hotkey driver. */
/* 4 */ KEY_MUTE,
/* 5 */ KEY_VOLUMEDOWN,
/* 6 */ KEY_VOLUMEUP,
/* 7 */ KEY_SLEEP,
/* 8 */ -1, /* Change CPU boost: do nothing */
/* 9 */ KEY_BATT,
/* 10 */ KEY_SUSPEND,
};
ACPI_FUNCTION_TRACE("acpi_pcc_generete_keyinput");
if (keyinput->key_mode == 0)
return_VOID;
hkey_num = hinf & 0xf;
if ((0 > hkey_num) ||
(hkey_num > ARRAY_SIZE(key_map))) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"hotkey number out of range: %d\n",
hkey_num));
return_VOID;
}