Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262148AbVBJPvn (ORCPT ); Thu, 10 Feb 2005 10:51:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262147AbVBJPvn (ORCPT ); Thu, 10 Feb 2005 10:51:43 -0500 Received: from sd291.sivit.org ([194.146.225.122]:6560 "EHLO sd291.sivit.org") by vger.kernel.org with ESMTP id S262148AbVBJPpa (ORCPT ); Thu, 10 Feb 2005 10:45:30 -0500 Date: Thu, 10 Feb 2005 16:47:06 +0100 From: Stelian Pop To: Linux Kernel Mailing List Cc: Andrew Morton , Linus Torvalds Subject: [PATCH 4/5] sonypi: fold the contents of sonypi.h into sonypi.c Message-ID: <20050210154705.GI3493@crusoe.alcove-fr> Reply-To: Stelian Pop Mail-Followup-To: Stelian Pop , Linux Kernel Mailing List , Andrew Morton , Linus Torvalds Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4.1i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 28521 Lines: 879 =================================================================== Fold the contents of sonypi.h into sonypi.c making some structures static. Partly-from: Adrian Bunk Suggested-by: Dmitry Torokhov Signed-off-by: Stelian Pop =================================================================== sonypi.c | 387 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sonypi.h | 432 --------------------------------------------------------------- 2 files changed, 384 insertions(+), 435 deletions(-) =================================================================== Index: drivers/char/sonypi.c =================================================================== --- a/drivers/char/sonypi.c (revision 26557) +++ b/drivers/char/sonypi.c (revision 26558) @@ -45,14 +45,16 @@ #include #include #include +#include #include #include #include -#include "sonypi.h" #include +#define SONYPI_DRIVER_VERSION "1.26" + MODULE_AUTHOR("Stelian Pop "); MODULE_DESCRIPTION("Sony Programmable I/O Control Device driver"); MODULE_LICENSE("GPL"); @@ -92,7 +94,386 @@ module_param(useinput, int, 0444); MODULE_PARM_DESC(useinput, "set this if you would like sonypi to feed events to the input subsystem"); -static struct sonypi_device sonypi_device; +#define SONYPI_DEVICE_MODEL_TYPE1 1 +#define SONYPI_DEVICE_MODEL_TYPE2 2 + +/* type1 models use those */ +#define SONYPI_IRQ_PORT 0x8034 +#define SONYPI_IRQ_SHIFT 22 +#define SONYPI_BASE 0x50 +#define SONYPI_G10A (SONYPI_BASE+0x14) +#define SONYPI_TYPE1_REGION_SIZE 0x08 +#define SONYPI_TYPE1_EVTYPE_OFFSET 0x04 + +/* type2 series specifics */ +#define SONYPI_SIRQ 0x9b +#define SONYPI_SLOB 0x9c +#define SONYPI_SHIB 0x9d +#define SONYPI_TYPE2_REGION_SIZE 0x20 +#define SONYPI_TYPE2_EVTYPE_OFFSET 0x12 + +/* battery / brightness addresses */ +#define SONYPI_BAT_FLAGS 0x81 +#define SONYPI_LCD_LIGHT 0x96 +#define SONYPI_BAT1_PCTRM 0xa0 +#define SONYPI_BAT1_LEFT 0xa2 +#define SONYPI_BAT1_MAXRT 0xa4 +#define SONYPI_BAT2_PCTRM 0xa8 +#define SONYPI_BAT2_LEFT 0xaa +#define SONYPI_BAT2_MAXRT 0xac +#define SONYPI_BAT1_MAXTK 0xb0 +#define SONYPI_BAT1_FULL 0xb2 +#define SONYPI_BAT2_MAXTK 0xb8 +#define SONYPI_BAT2_FULL 0xba + +/* ioports used for brightness and type2 events */ +#define SONYPI_DATA_IOPORT 0x62 +#define SONYPI_CST_IOPORT 0x66 + +/* The set of possible ioports */ +struct sonypi_ioport_list { + u16 port1; + u16 port2; +}; + +static struct sonypi_ioport_list sonypi_type1_ioport_list[] = { + { 0x10c0, 0x10c4 }, /* looks like the default on C1Vx */ + { 0x1080, 0x1084 }, + { 0x1090, 0x1094 }, + { 0x10a0, 0x10a4 }, + { 0x10b0, 0x10b4 }, + { 0x0, 0x0 } +}; + +static struct sonypi_ioport_list sonypi_type2_ioport_list[] = { + { 0x1080, 0x1084 }, + { 0x10a0, 0x10a4 }, + { 0x10c0, 0x10c4 }, + { 0x10e0, 0x10e4 }, + { 0x0, 0x0 } +}; + +/* The set of possible interrupts */ +struct sonypi_irq_list { + u16 irq; + u16 bits; +}; + +static struct sonypi_irq_list sonypi_type1_irq_list[] = { + { 11, 0x2 }, /* IRQ 11, GO22=0,GO23=1 in AML */ + { 10, 0x1 }, /* IRQ 10, GO22=1,GO23=0 in AML */ + { 5, 0x0 }, /* IRQ 5, GO22=0,GO23=0 in AML */ + { 0, 0x3 } /* no IRQ, GO22=1,GO23=1 in AML */ +}; + +static struct sonypi_irq_list sonypi_type2_irq_list[] = { + { 11, 0x80 }, /* IRQ 11, 0x80 in SIRQ in AML */ + { 10, 0x40 }, /* IRQ 10, 0x40 in SIRQ in AML */ + { 9, 0x20 }, /* IRQ 9, 0x20 in SIRQ in AML */ + { 6, 0x10 }, /* IRQ 6, 0x10 in SIRQ in AML */ + { 0, 0x00 } /* no IRQ, 0x00 in SIRQ in AML */ +}; + +#define SONYPI_CAMERA_BRIGHTNESS 0 +#define SONYPI_CAMERA_CONTRAST 1 +#define SONYPI_CAMERA_HUE 2 +#define SONYPI_CAMERA_COLOR 3 +#define SONYPI_CAMERA_SHARPNESS 4 + +#define SONYPI_CAMERA_PICTURE 5 +#define SONYPI_CAMERA_EXPOSURE_MASK 0xC +#define SONYPI_CAMERA_WHITE_BALANCE_MASK 0x3 +#define SONYPI_CAMERA_PICTURE_MODE_MASK 0x30 +#define SONYPI_CAMERA_MUTE_MASK 0x40 + +/* the rest don't need a loop until not 0xff */ +#define SONYPI_CAMERA_AGC 6 +#define SONYPI_CAMERA_AGC_MASK 0x30 +#define SONYPI_CAMERA_SHUTTER_MASK 0x7 + +#define SONYPI_CAMERA_SHUTDOWN_REQUEST 7 +#define SONYPI_CAMERA_CONTROL 0x10 + +#define SONYPI_CAMERA_STATUS 7 +#define SONYPI_CAMERA_STATUS_READY 0x2 +#define SONYPI_CAMERA_STATUS_POSITION 0x4 + +#define SONYPI_DIRECTION_BACKWARDS 0x4 + +#define SONYPI_CAMERA_REVISION 8 +#define SONYPI_CAMERA_ROMVERSION 9 + +/* Event masks */ +#define SONYPI_JOGGER_MASK 0x00000001 +#define SONYPI_CAPTURE_MASK 0x00000002 +#define SONYPI_FNKEY_MASK 0x00000004 +#define SONYPI_BLUETOOTH_MASK 0x00000008 +#define SONYPI_PKEY_MASK 0x00000010 +#define SONYPI_BACK_MASK 0x00000020 +#define SONYPI_HELP_MASK 0x00000040 +#define SONYPI_LID_MASK 0x00000080 +#define SONYPI_ZOOM_MASK 0x00000100 +#define SONYPI_THUMBPHRASE_MASK 0x00000200 +#define SONYPI_MEYE_MASK 0x00000400 +#define SONYPI_MEMORYSTICK_MASK 0x00000800 +#define SONYPI_BATTERY_MASK 0x00001000 + +struct sonypi_event { + u8 data; + u8 event; +}; + +/* The set of possible button release events */ +static struct sonypi_event sonypi_releaseev[] = { + { 0x00, SONYPI_EVENT_ANYBUTTON_RELEASED }, + { 0, 0 } +}; + +/* The set of possible jogger events */ +static struct sonypi_event sonypi_joggerev[] = { + { 0x1f, SONYPI_EVENT_JOGDIAL_UP }, + { 0x01, SONYPI_EVENT_JOGDIAL_DOWN }, + { 0x5f, SONYPI_EVENT_JOGDIAL_UP_PRESSED }, + { 0x41, SONYPI_EVENT_JOGDIAL_DOWN_PRESSED }, + { 0x1e, SONYPI_EVENT_JOGDIAL_FAST_UP }, + { 0x02, SONYPI_EVENT_JOGDIAL_FAST_DOWN }, + { 0x5e, SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED }, + { 0x42, SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED }, + { 0x1d, SONYPI_EVENT_JOGDIAL_VFAST_UP }, + { 0x03, SONYPI_EVENT_JOGDIAL_VFAST_DOWN }, + { 0x5d, SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED }, + { 0x43, SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED }, + { 0x40, SONYPI_EVENT_JOGDIAL_PRESSED }, + { 0, 0 } +}; + +/* The set of possible capture button events */ +static struct sonypi_event sonypi_captureev[] = { + { 0x05, SONYPI_EVENT_CAPTURE_PARTIALPRESSED }, + { 0x07, SONYPI_EVENT_CAPTURE_PRESSED }, + { 0x01, SONYPI_EVENT_CAPTURE_PARTIALRELEASED }, + { 0, 0 } +}; + +/* The set of possible fnkeys events */ +static struct sonypi_event sonypi_fnkeyev[] = { + { 0x10, SONYPI_EVENT_FNKEY_ESC }, + { 0x11, SONYPI_EVENT_FNKEY_F1 }, + { 0x12, SONYPI_EVENT_FNKEY_F2 }, + { 0x13, SONYPI_EVENT_FNKEY_F3 }, + { 0x14, SONYPI_EVENT_FNKEY_F4 }, + { 0x15, SONYPI_EVENT_FNKEY_F5 }, + { 0x16, SONYPI_EVENT_FNKEY_F6 }, + { 0x17, SONYPI_EVENT_FNKEY_F7 }, + { 0x18, SONYPI_EVENT_FNKEY_F8 }, + { 0x19, SONYPI_EVENT_FNKEY_F9 }, + { 0x1a, SONYPI_EVENT_FNKEY_F10 }, + { 0x1b, SONYPI_EVENT_FNKEY_F11 }, + { 0x1c, SONYPI_EVENT_FNKEY_F12 }, + { 0x1f, SONYPI_EVENT_FNKEY_RELEASED }, + { 0x21, SONYPI_EVENT_FNKEY_1 }, + { 0x22, SONYPI_EVENT_FNKEY_2 }, + { 0x31, SONYPI_EVENT_FNKEY_D }, + { 0x32, SONYPI_EVENT_FNKEY_E }, + { 0x33, SONYPI_EVENT_FNKEY_F }, + { 0x34, SONYPI_EVENT_FNKEY_S }, + { 0x35, SONYPI_EVENT_FNKEY_B }, + { 0x36, SONYPI_EVENT_FNKEY_ONLY }, + { 0, 0 } +}; + +/* The set of possible program key events */ +static struct sonypi_event sonypi_pkeyev[] = { + { 0x01, SONYPI_EVENT_PKEY_P1 }, + { 0x02, SONYPI_EVENT_PKEY_P2 }, + { 0x04, SONYPI_EVENT_PKEY_P3 }, + { 0x5c, SONYPI_EVENT_PKEY_P1 }, + { 0, 0 } +}; + +/* The set of possible bluetooth events */ +static struct sonypi_event sonypi_blueev[] = { + { 0x55, SONYPI_EVENT_BLUETOOTH_PRESSED }, + { 0x59, SONYPI_EVENT_BLUETOOTH_ON }, + { 0x5a, SONYPI_EVENT_BLUETOOTH_OFF }, + { 0, 0 } +}; + +/* The set of possible back button events */ +static struct sonypi_event sonypi_backev[] = { + { 0x20, SONYPI_EVENT_BACK_PRESSED }, + { 0, 0 } +}; + +/* The set of possible help button events */ +static struct sonypi_event sonypi_helpev[] = { + { 0x3b, SONYPI_EVENT_HELP_PRESSED }, + { 0, 0 } +}; + + +/* The set of possible lid events */ +static struct sonypi_event sonypi_lidev[] = { + { 0x51, SONYPI_EVENT_LID_CLOSED }, + { 0x50, SONYPI_EVENT_LID_OPENED }, + { 0, 0 } +}; + +/* The set of possible zoom events */ +static struct sonypi_event sonypi_zoomev[] = { + { 0x39, SONYPI_EVENT_ZOOM_PRESSED }, + { 0, 0 } +}; + +/* The set of possible thumbphrase events */ +static struct sonypi_event sonypi_thumbphraseev[] = { + { 0x3a, SONYPI_EVENT_THUMBPHRASE_PRESSED }, + { 0, 0 } +}; + +/* The set of possible motioneye camera events */ +static struct sonypi_event sonypi_meyeev[] = { + { 0x00, SONYPI_EVENT_MEYE_FACE }, + { 0x01, SONYPI_EVENT_MEYE_OPPOSITE }, + { 0, 0 } +}; + +/* The set of possible memorystick events */ +static struct sonypi_event sonypi_memorystickev[] = { + { 0x53, SONYPI_EVENT_MEMORYSTICK_INSERT }, + { 0x54, SONYPI_EVENT_MEMORYSTICK_EJECT }, + { 0, 0 } +}; + +/* The set of possible battery events */ +static struct sonypi_event sonypi_batteryev[] = { + { 0x20, SONYPI_EVENT_BATTERY_INSERT }, + { 0x30, SONYPI_EVENT_BATTERY_REMOVE }, + { 0, 0 } +}; + +static struct sonypi_eventtypes { + int model; + u8 data; + unsigned long mask; + struct sonypi_event * events; +} sonypi_eventtypes[] = { + { SONYPI_DEVICE_MODEL_TYPE1, 0, 0xffffffff, sonypi_releaseev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x70, SONYPI_MEYE_MASK, sonypi_meyeev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_LID_MASK, sonypi_lidev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x60, SONYPI_CAPTURE_MASK, sonypi_captureev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x10, SONYPI_JOGGER_MASK, sonypi_joggerev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x20, SONYPI_FNKEY_MASK, sonypi_fnkeyev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_BLUETOOTH_MASK, sonypi_blueev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_PKEY_MASK, sonypi_pkeyev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_BATTERY_MASK, sonypi_batteryev }, + + { SONYPI_DEVICE_MODEL_TYPE2, 0, 0xffffffff, sonypi_releaseev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x38, SONYPI_LID_MASK, sonypi_lidev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_JOGGER_MASK, sonypi_joggerev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x61, SONYPI_CAPTURE_MASK, sonypi_captureev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_HELP_MASK, sonypi_helpev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_HELP_MASK, sonypi_helpev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_ZOOM_MASK, sonypi_zoomev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x20, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev }, + + { 0 } +}; + +#define SONYPI_BUF_SIZE 128 + +/* The name of the devices for the input device drivers */ +#define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial" +#define SONYPI_KEY_INPUTNAME "Sony Vaio Keys" + +/* Correspondance table between sonypi events and input layer events */ +static struct { + int sonypiev; + int inputev; +} sonypi_inputkeys[] = { + { SONYPI_EVENT_CAPTURE_PRESSED, KEY_CAMERA }, + { SONYPI_EVENT_FNKEY_ONLY, KEY_FN }, + { SONYPI_EVENT_FNKEY_ESC, KEY_FN_ESC }, + { SONYPI_EVENT_FNKEY_F1, KEY_FN_F1 }, + { SONYPI_EVENT_FNKEY_F2, KEY_FN_F2 }, + { SONYPI_EVENT_FNKEY_F3, KEY_FN_F3 }, + { SONYPI_EVENT_FNKEY_F4, KEY_FN_F4 }, + { SONYPI_EVENT_FNKEY_F5, KEY_FN_F5 }, + { SONYPI_EVENT_FNKEY_F6, KEY_FN_F6 }, + { SONYPI_EVENT_FNKEY_F7, KEY_FN_F7 }, + { SONYPI_EVENT_FNKEY_F8, KEY_FN_F8 }, + { SONYPI_EVENT_FNKEY_F9, KEY_FN_F9 }, + { SONYPI_EVENT_FNKEY_F10, KEY_FN_F10 }, + { SONYPI_EVENT_FNKEY_F11, KEY_FN_F11 }, + { SONYPI_EVENT_FNKEY_F12, KEY_FN_F12 }, + { SONYPI_EVENT_FNKEY_1, KEY_FN_1 }, + { SONYPI_EVENT_FNKEY_2, KEY_FN_2 }, + { SONYPI_EVENT_FNKEY_D, KEY_FN_D }, + { SONYPI_EVENT_FNKEY_E, KEY_FN_E }, + { SONYPI_EVENT_FNKEY_F, KEY_FN_F }, + { SONYPI_EVENT_FNKEY_S, KEY_FN_S }, + { SONYPI_EVENT_FNKEY_B, KEY_FN_B }, + { SONYPI_EVENT_BLUETOOTH_PRESSED, KEY_BLUE }, + { SONYPI_EVENT_BLUETOOTH_ON, KEY_BLUE }, + { SONYPI_EVENT_PKEY_P1, KEY_PROG1 }, + { SONYPI_EVENT_PKEY_P2, KEY_PROG2 }, + { SONYPI_EVENT_PKEY_P3, KEY_PROG3 }, + { SONYPI_EVENT_BACK_PRESSED, KEY_BACK }, + { SONYPI_EVENT_HELP_PRESSED, KEY_HELP }, + { SONYPI_EVENT_ZOOM_PRESSED, KEY_ZOOM }, + { SONYPI_EVENT_THUMBPHRASE_PRESSED, BTN_THUMB }, + { 0, 0 }, +}; + +static struct sonypi_device { + struct pci_dev *dev; + struct platform_device *pdev; + u16 irq; + u16 bits; + u16 ioport1; + u16 ioport2; + u16 region_size; + u16 evtype_offset; + int camera_power; + int bluetooth_power; + struct semaphore lock; + struct kfifo *fifo; + spinlock_t fifo_lock; + wait_queue_head_t fifo_proc_list; + struct fasync_struct *fifo_async; + int open_count; + int model; + struct input_dev input_jog_dev; + struct input_dev input_key_dev; + struct work_struct input_work; + struct kfifo *input_fifo; + spinlock_t input_fifo_lock; +} sonypi_device; + +#define ITERATIONS_LONG 10000 +#define ITERATIONS_SHORT 10 + +#define wait_on_command(quiet, command, iterations) { \ + unsigned int n = iterations; \ + while (--n && (command)) \ + udelay(1); \ + if (!n && (verbose || !quiet)) \ + printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __FUNCTION__, __LINE__); \ +} + +#ifdef CONFIG_ACPI +#define SONYPI_ACPI_ACTIVE (!acpi_disabled) +#else +#define SONYPI_ACPI_ACTIVE 0 +#endif /* CONFIG_ACPI */ static int sonypi_ec_write(u8 addr, u8 value) { @@ -645,7 +1026,7 @@ static struct file_operations sonypi_mis .ioctl = sonypi_misc_ioctl, }; -struct miscdevice sonypi_misc_device = { +static struct miscdevice sonypi_misc_device = { .minor = MISC_DYNAMIC_MINOR, .name = "sonypi", .fops = &sonypi_misc_fops, Index: drivers/char/sonypi.h =================================================================== --- a/drivers/char/sonypi.h (revision 26557) +++ /dev/null (revision 26558) @@ -1,432 +0,0 @@ -/* - * Sony Programmable I/O Control Device driver for VAIO - * - * Copyright (C) 2001-2005 Stelian Pop - * - * Copyright (C) 2001-2002 Alc?ve - * - * Copyright (C) 2001 Michael Ashley - * - * Copyright (C) 2001 Junichi Morita - * - * Copyright (C) 2000 Takaya Kinjo - * - * Copyright (C) 2000 Andrew Tridgell - * - * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef _SONYPI_PRIV_H_ -#define _SONYPI_PRIV_H_ - -#ifdef __KERNEL__ - -#define SONYPI_DRIVER_VERSION "1.26" - -#define SONYPI_DEVICE_MODEL_TYPE1 1 -#define SONYPI_DEVICE_MODEL_TYPE2 2 - -#include -#include -#include -#include -#include -#include -#include - -/* type1 models use those */ -#define SONYPI_IRQ_PORT 0x8034 -#define SONYPI_IRQ_SHIFT 22 -#define SONYPI_BASE 0x50 -#define SONYPI_G10A (SONYPI_BASE+0x14) -#define SONYPI_TYPE1_REGION_SIZE 0x08 -#define SONYPI_TYPE1_EVTYPE_OFFSET 0x04 - -/* type2 series specifics */ -#define SONYPI_SIRQ 0x9b -#define SONYPI_SLOB 0x9c -#define SONYPI_SHIB 0x9d -#define SONYPI_TYPE2_REGION_SIZE 0x20 -#define SONYPI_TYPE2_EVTYPE_OFFSET 0x12 - -/* battery / brightness addresses */ -#define SONYPI_BAT_FLAGS 0x81 -#define SONYPI_LCD_LIGHT 0x96 -#define SONYPI_BAT1_PCTRM 0xa0 -#define SONYPI_BAT1_LEFT 0xa2 -#define SONYPI_BAT1_MAXRT 0xa4 -#define SONYPI_BAT2_PCTRM 0xa8 -#define SONYPI_BAT2_LEFT 0xaa -#define SONYPI_BAT2_MAXRT 0xac -#define SONYPI_BAT1_MAXTK 0xb0 -#define SONYPI_BAT1_FULL 0xb2 -#define SONYPI_BAT2_MAXTK 0xb8 -#define SONYPI_BAT2_FULL 0xba - -/* ioports used for brightness and type2 events */ -#define SONYPI_DATA_IOPORT 0x62 -#define SONYPI_CST_IOPORT 0x66 - -/* The set of possible ioports */ -struct sonypi_ioport_list { - u16 port1; - u16 port2; -}; - -static struct sonypi_ioport_list sonypi_type1_ioport_list[] = { - { 0x10c0, 0x10c4 }, /* looks like the default on C1Vx */ - { 0x1080, 0x1084 }, - { 0x1090, 0x1094 }, - { 0x10a0, 0x10a4 }, - { 0x10b0, 0x10b4 }, - { 0x0, 0x0 } -}; - -static struct sonypi_ioport_list sonypi_type2_ioport_list[] = { - { 0x1080, 0x1084 }, - { 0x10a0, 0x10a4 }, - { 0x10c0, 0x10c4 }, - { 0x10e0, 0x10e4 }, - { 0x0, 0x0 } -}; - -/* The set of possible interrupts */ -struct sonypi_irq_list { - u16 irq; - u16 bits; -}; - -static struct sonypi_irq_list sonypi_type1_irq_list[] = { - { 11, 0x2 }, /* IRQ 11, GO22=0,GO23=1 in AML */ - { 10, 0x1 }, /* IRQ 10, GO22=1,GO23=0 in AML */ - { 5, 0x0 }, /* IRQ 5, GO22=0,GO23=0 in AML */ - { 0, 0x3 } /* no IRQ, GO22=1,GO23=1 in AML */ -}; - -static struct sonypi_irq_list sonypi_type2_irq_list[] = { - { 11, 0x80 }, /* IRQ 11, 0x80 in SIRQ in AML */ - { 10, 0x40 }, /* IRQ 10, 0x40 in SIRQ in AML */ - { 9, 0x20 }, /* IRQ 9, 0x20 in SIRQ in AML */ - { 6, 0x10 }, /* IRQ 6, 0x10 in SIRQ in AML */ - { 0, 0x00 } /* no IRQ, 0x00 in SIRQ in AML */ -}; - -#define SONYPI_CAMERA_BRIGHTNESS 0 -#define SONYPI_CAMERA_CONTRAST 1 -#define SONYPI_CAMERA_HUE 2 -#define SONYPI_CAMERA_COLOR 3 -#define SONYPI_CAMERA_SHARPNESS 4 - -#define SONYPI_CAMERA_PICTURE 5 -#define SONYPI_CAMERA_EXPOSURE_MASK 0xC -#define SONYPI_CAMERA_WHITE_BALANCE_MASK 0x3 -#define SONYPI_CAMERA_PICTURE_MODE_MASK 0x30 -#define SONYPI_CAMERA_MUTE_MASK 0x40 - -/* the rest don't need a loop until not 0xff */ -#define SONYPI_CAMERA_AGC 6 -#define SONYPI_CAMERA_AGC_MASK 0x30 -#define SONYPI_CAMERA_SHUTTER_MASK 0x7 - -#define SONYPI_CAMERA_SHUTDOWN_REQUEST 7 -#define SONYPI_CAMERA_CONTROL 0x10 - -#define SONYPI_CAMERA_STATUS 7 -#define SONYPI_CAMERA_STATUS_READY 0x2 -#define SONYPI_CAMERA_STATUS_POSITION 0x4 - -#define SONYPI_DIRECTION_BACKWARDS 0x4 - -#define SONYPI_CAMERA_REVISION 8 -#define SONYPI_CAMERA_ROMVERSION 9 - -/* Event masks */ -#define SONYPI_JOGGER_MASK 0x00000001 -#define SONYPI_CAPTURE_MASK 0x00000002 -#define SONYPI_FNKEY_MASK 0x00000004 -#define SONYPI_BLUETOOTH_MASK 0x00000008 -#define SONYPI_PKEY_MASK 0x00000010 -#define SONYPI_BACK_MASK 0x00000020 -#define SONYPI_HELP_MASK 0x00000040 -#define SONYPI_LID_MASK 0x00000080 -#define SONYPI_ZOOM_MASK 0x00000100 -#define SONYPI_THUMBPHRASE_MASK 0x00000200 -#define SONYPI_MEYE_MASK 0x00000400 -#define SONYPI_MEMORYSTICK_MASK 0x00000800 -#define SONYPI_BATTERY_MASK 0x00001000 - -struct sonypi_event { - u8 data; - u8 event; -}; - -/* The set of possible button release events */ -static struct sonypi_event sonypi_releaseev[] = { - { 0x00, SONYPI_EVENT_ANYBUTTON_RELEASED }, - { 0, 0 } -}; - -/* The set of possible jogger events */ -static struct sonypi_event sonypi_joggerev[] = { - { 0x1f, SONYPI_EVENT_JOGDIAL_UP }, - { 0x01, SONYPI_EVENT_JOGDIAL_DOWN }, - { 0x5f, SONYPI_EVENT_JOGDIAL_UP_PRESSED }, - { 0x41, SONYPI_EVENT_JOGDIAL_DOWN_PRESSED }, - { 0x1e, SONYPI_EVENT_JOGDIAL_FAST_UP }, - { 0x02, SONYPI_EVENT_JOGDIAL_FAST_DOWN }, - { 0x5e, SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED }, - { 0x42, SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED }, - { 0x1d, SONYPI_EVENT_JOGDIAL_VFAST_UP }, - { 0x03, SONYPI_EVENT_JOGDIAL_VFAST_DOWN }, - { 0x5d, SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED }, - { 0x43, SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED }, - { 0x40, SONYPI_EVENT_JOGDIAL_PRESSED }, - { 0, 0 } -}; - -/* The set of possible capture button events */ -static struct sonypi_event sonypi_captureev[] = { - { 0x05, SONYPI_EVENT_CAPTURE_PARTIALPRESSED }, - { 0x07, SONYPI_EVENT_CAPTURE_PRESSED }, - { 0x01, SONYPI_EVENT_CAPTURE_PARTIALRELEASED }, - { 0, 0 } -}; - -/* The set of possible fnkeys events */ -static struct sonypi_event sonypi_fnkeyev[] = { - { 0x10, SONYPI_EVENT_FNKEY_ESC }, - { 0x11, SONYPI_EVENT_FNKEY_F1 }, - { 0x12, SONYPI_EVENT_FNKEY_F2 }, - { 0x13, SONYPI_EVENT_FNKEY_F3 }, - { 0x14, SONYPI_EVENT_FNKEY_F4 }, - { 0x15, SONYPI_EVENT_FNKEY_F5 }, - { 0x16, SONYPI_EVENT_FNKEY_F6 }, - { 0x17, SONYPI_EVENT_FNKEY_F7 }, - { 0x18, SONYPI_EVENT_FNKEY_F8 }, - { 0x19, SONYPI_EVENT_FNKEY_F9 }, - { 0x1a, SONYPI_EVENT_FNKEY_F10 }, - { 0x1b, SONYPI_EVENT_FNKEY_F11 }, - { 0x1c, SONYPI_EVENT_FNKEY_F12 }, - { 0x1f, SONYPI_EVENT_FNKEY_RELEASED }, - { 0x21, SONYPI_EVENT_FNKEY_1 }, - { 0x22, SONYPI_EVENT_FNKEY_2 }, - { 0x31, SONYPI_EVENT_FNKEY_D }, - { 0x32, SONYPI_EVENT_FNKEY_E }, - { 0x33, SONYPI_EVENT_FNKEY_F }, - { 0x34, SONYPI_EVENT_FNKEY_S }, - { 0x35, SONYPI_EVENT_FNKEY_B }, - { 0x36, SONYPI_EVENT_FNKEY_ONLY }, - { 0, 0 } -}; - -/* The set of possible program key events */ -static struct sonypi_event sonypi_pkeyev[] = { - { 0x01, SONYPI_EVENT_PKEY_P1 }, - { 0x02, SONYPI_EVENT_PKEY_P2 }, - { 0x04, SONYPI_EVENT_PKEY_P3 }, - { 0x5c, SONYPI_EVENT_PKEY_P1 }, - { 0, 0 } -}; - -/* The set of possible bluetooth events */ -static struct sonypi_event sonypi_blueev[] = { - { 0x55, SONYPI_EVENT_BLUETOOTH_PRESSED }, - { 0x59, SONYPI_EVENT_BLUETOOTH_ON }, - { 0x5a, SONYPI_EVENT_BLUETOOTH_OFF }, - { 0, 0 } -}; - -/* The set of possible back button events */ -static struct sonypi_event sonypi_backev[] = { - { 0x20, SONYPI_EVENT_BACK_PRESSED }, - { 0, 0 } -}; - -/* The set of possible help button events */ -static struct sonypi_event sonypi_helpev[] = { - { 0x3b, SONYPI_EVENT_HELP_PRESSED }, - { 0, 0 } -}; - - -/* The set of possible lid events */ -static struct sonypi_event sonypi_lidev[] = { - { 0x51, SONYPI_EVENT_LID_CLOSED }, - { 0x50, SONYPI_EVENT_LID_OPENED }, - { 0, 0 } -}; - -/* The set of possible zoom events */ -static struct sonypi_event sonypi_zoomev[] = { - { 0x39, SONYPI_EVENT_ZOOM_PRESSED }, - { 0, 0 } -}; - -/* The set of possible thumbphrase events */ -static struct sonypi_event sonypi_thumbphraseev[] = { - { 0x3a, SONYPI_EVENT_THUMBPHRASE_PRESSED }, - { 0, 0 } -}; - -/* The set of possible motioneye camera events */ -static struct sonypi_event sonypi_meyeev[] = { - { 0x00, SONYPI_EVENT_MEYE_FACE }, - { 0x01, SONYPI_EVENT_MEYE_OPPOSITE }, - { 0, 0 } -}; - -/* The set of possible memorystick events */ -static struct sonypi_event sonypi_memorystickev[] = { - { 0x53, SONYPI_EVENT_MEMORYSTICK_INSERT }, - { 0x54, SONYPI_EVENT_MEMORYSTICK_EJECT }, - { 0, 0 } -}; - -/* The set of possible battery events */ -static struct sonypi_event sonypi_batteryev[] = { - { 0x20, SONYPI_EVENT_BATTERY_INSERT }, - { 0x30, SONYPI_EVENT_BATTERY_REMOVE }, - { 0, 0 } -}; - -struct sonypi_eventtypes { - int model; - u8 data; - unsigned long mask; - struct sonypi_event * events; -} sonypi_eventtypes[] = { - { SONYPI_DEVICE_MODEL_TYPE1, 0, 0xffffffff, sonypi_releaseev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x70, SONYPI_MEYE_MASK, sonypi_meyeev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_LID_MASK, sonypi_lidev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x60, SONYPI_CAPTURE_MASK, sonypi_captureev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x10, SONYPI_JOGGER_MASK, sonypi_joggerev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x20, SONYPI_FNKEY_MASK, sonypi_fnkeyev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_BLUETOOTH_MASK, sonypi_blueev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_PKEY_MASK, sonypi_pkeyev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev }, - { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_BATTERY_MASK, sonypi_batteryev }, - - { SONYPI_DEVICE_MODEL_TYPE2, 0, 0xffffffff, sonypi_releaseev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x38, SONYPI_LID_MASK, sonypi_lidev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_JOGGER_MASK, sonypi_joggerev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x61, SONYPI_CAPTURE_MASK, sonypi_captureev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_HELP_MASK, sonypi_helpev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_HELP_MASK, sonypi_helpev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_ZOOM_MASK, sonypi_zoomev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x20, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev }, - { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev }, - - { 0 } -}; - -#define SONYPI_BUF_SIZE 128 - -/* The name of the devices for the input device drivers */ -#define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial" -#define SONYPI_KEY_INPUTNAME "Sony Vaio Keys" - -/* Correspondance table between sonypi events and input layer events */ -struct { - int sonypiev; - int inputev; -} sonypi_inputkeys[] = { - { SONYPI_EVENT_CAPTURE_PRESSED, KEY_CAMERA }, - { SONYPI_EVENT_FNKEY_ONLY, KEY_FN }, - { SONYPI_EVENT_FNKEY_ESC, KEY_FN_ESC }, - { SONYPI_EVENT_FNKEY_F1, KEY_FN_F1 }, - { SONYPI_EVENT_FNKEY_F2, KEY_FN_F2 }, - { SONYPI_EVENT_FNKEY_F3, KEY_FN_F3 }, - { SONYPI_EVENT_FNKEY_F4, KEY_FN_F4 }, - { SONYPI_EVENT_FNKEY_F5, KEY_FN_F5 }, - { SONYPI_EVENT_FNKEY_F6, KEY_FN_F6 }, - { SONYPI_EVENT_FNKEY_F7, KEY_FN_F7 }, - { SONYPI_EVENT_FNKEY_F8, KEY_FN_F8 }, - { SONYPI_EVENT_FNKEY_F9, KEY_FN_F9 }, - { SONYPI_EVENT_FNKEY_F10, KEY_FN_F10 }, - { SONYPI_EVENT_FNKEY_F11, KEY_FN_F11 }, - { SONYPI_EVENT_FNKEY_F12, KEY_FN_F12 }, - { SONYPI_EVENT_FNKEY_1, KEY_FN_1 }, - { SONYPI_EVENT_FNKEY_2, KEY_FN_2 }, - { SONYPI_EVENT_FNKEY_D, KEY_FN_D }, - { SONYPI_EVENT_FNKEY_E, KEY_FN_E }, - { SONYPI_EVENT_FNKEY_F, KEY_FN_F }, - { SONYPI_EVENT_FNKEY_S, KEY_FN_S }, - { SONYPI_EVENT_FNKEY_B, KEY_FN_B }, - { SONYPI_EVENT_BLUETOOTH_PRESSED, KEY_BLUE }, - { SONYPI_EVENT_BLUETOOTH_ON, KEY_BLUE }, - { SONYPI_EVENT_PKEY_P1, KEY_PROG1 }, - { SONYPI_EVENT_PKEY_P2, KEY_PROG2 }, - { SONYPI_EVENT_PKEY_P3, KEY_PROG3 }, - { SONYPI_EVENT_BACK_PRESSED, KEY_BACK }, - { SONYPI_EVENT_HELP_PRESSED, KEY_HELP }, - { SONYPI_EVENT_ZOOM_PRESSED, KEY_ZOOM }, - { SONYPI_EVENT_THUMBPHRASE_PRESSED, BTN_THUMB }, - { 0, 0 }, -}; - -struct sonypi_device { - struct pci_dev *dev; - struct platform_device *pdev; - u16 irq; - u16 bits; - u16 ioport1; - u16 ioport2; - u16 region_size; - u16 evtype_offset; - int camera_power; - int bluetooth_power; - struct semaphore lock; - struct kfifo *fifo; - spinlock_t fifo_lock; - wait_queue_head_t fifo_proc_list; - struct fasync_struct *fifo_async; - int open_count; - int model; - struct input_dev input_jog_dev; - struct input_dev input_key_dev; - struct work_struct input_work; - struct kfifo *input_fifo; - spinlock_t input_fifo_lock; -}; - -#define ITERATIONS_LONG 10000 -#define ITERATIONS_SHORT 10 - -#define wait_on_command(quiet, command, iterations) { \ - unsigned int n = iterations; \ - while (--n && (command)) \ - udelay(1); \ - if (!n && (verbose || !quiet)) \ - printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __FUNCTION__, __LINE__); \ -} - -#ifdef CONFIG_ACPI -#define SONYPI_ACPI_ACTIVE (!acpi_disabled) -#else -#define SONYPI_ACPI_ACTIVE 0 -#endif /* CONFIG_ACPI */ - -#endif /* __KERNEL__ */ - -#endif /* _SONYPI_PRIV_H_ */ -- Stelian Pop - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/