thinkpad_acpi.h
来自「linux 内核源代码」· C头文件 代码 · 共 607 行 · 第 1/2 页
H
607 行
/* * thinkpad_acpi.h - ThinkPad ACPI Extras * * * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net> * Copyright (C) 2006-2007 Henrique de Moraes Holschuh <hmh@hmh.eng.br> * * 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., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */#ifndef __THINKPAD_ACPI_H__#define __THINKPAD_ACPI_H__#include <linux/kernel.h>#include <linux/module.h>#include <linux/init.h>#include <linux/types.h>#include <linux/string.h>#include <linux/list.h>#include <linux/mutex.h>#include <linux/nvram.h>#include <linux/proc_fs.h>#include <linux/sysfs.h>#include <linux/backlight.h>#include <linux/fb.h>#include <linux/platform_device.h>#include <linux/hwmon.h>#include <linux/hwmon-sysfs.h>#include <linux/input.h>#include <asm/uaccess.h>#include <linux/dmi.h>#include <linux/jiffies.h>#include <linux/workqueue.h>#include <acpi/acpi_drivers.h>#include <acpi/acnamesp.h>#include <linux/pci_ids.h>/**************************************************************************** * Main driver */#define IBM_NAME "thinkpad"#define IBM_DESC "ThinkPad ACPI Extras"#define IBM_FILE IBM_NAME "_acpi"#define IBM_URL "http://ibm-acpi.sf.net/"#define IBM_MAIL "ibm-acpi-devel@lists.sourceforge.net"#define IBM_PROC_DIR "ibm"#define IBM_ACPI_EVENT_PREFIX "ibm"#define IBM_DRVR_NAME IBM_FILE#define IBM_HWMON_DRVR_NAME IBM_NAME "_hwmon"#define IBM_LOG IBM_FILE ": "#define IBM_ERR KERN_ERR IBM_LOG#define IBM_NOTICE KERN_NOTICE IBM_LOG#define IBM_INFO KERN_INFO IBM_LOG#define IBM_DEBUG KERN_DEBUG IBM_LOG#define IBM_MAX_ACPI_ARGS 3/* ThinkPad CMOS commands */#define TP_CMOS_VOLUME_DOWN 0#define TP_CMOS_VOLUME_UP 1#define TP_CMOS_VOLUME_MUTE 2#define TP_CMOS_BRIGHTNESS_UP 4#define TP_CMOS_BRIGHTNESS_DOWN 5/* ThinkPad CMOS NVRAM constants */#define TP_NVRAM_ADDR_BRIGHTNESS 0x5e#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x0f#define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")#define strlencmp(a,b) (strncmp((a), (b), strlen(b)))/* Debugging */#define TPACPI_DBG_ALL 0xffff#define TPACPI_DBG_ALL 0xffff#define TPACPI_DBG_INIT 0x0001#define TPACPI_DBG_EXIT 0x0002#define dbg_printk(a_dbg_level, format, arg...) \ do { if (dbg_level & a_dbg_level) \ printk(IBM_DEBUG "%s: " format, __func__ , ## arg); } while (0)#ifdef CONFIG_THINKPAD_ACPI_DEBUG#define vdbg_printk(a_dbg_level, format, arg...) \ dbg_printk(a_dbg_level, format, ## arg)static const char *str_supported(int is_supported);#else#define vdbg_printk(a_dbg_level, format, arg...)#endif/* Input IDs */#define TPACPI_HKEY_INPUT_VENDOR PCI_VENDOR_ID_IBM#define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */#define TPACPI_HKEY_INPUT_VERSION 0x4101/* ACPI HIDs */#define IBM_HKEY_HID "IBM0068"/* ACPI helpers */static int __must_check acpi_evalf(acpi_handle handle, void *res, char *method, char *fmt, ...);static int __must_check acpi_ec_read(int i, u8 * p);static int __must_check acpi_ec_write(int i, u8 v);static int __must_check _sta(acpi_handle handle);/* ACPI handles */static acpi_handle root_handle; /* root namespace */static acpi_handle ec_handle; /* EC */static acpi_handle ecrd_handle, ecwr_handle; /* 570 EC access */static acpi_handle cmos_handle, hkey_handle; /* basic thinkpad handles */static void drv_acpi_handle_init(char *name, acpi_handle *handle, acpi_handle parent, char **paths, int num_paths, char **path);#define IBM_ACPIHANDLE_INIT(object) \ drv_acpi_handle_init(#object, &object##_handle, *object##_parent, \ object##_paths, ARRAY_SIZE(object##_paths), &object##_path)/* ThinkPad ACPI helpers */static int issue_thinkpad_cmos_command(int cmos_cmd);/* procfs support */static struct proc_dir_entry *proc_dir;/* procfs helpers */static int dispatch_procfs_read(char *page, char **start, off_t off, int count, int *eof, void *data);static int dispatch_procfs_write(struct file *file, const char __user * userbuf, unsigned long count, void *data);static char *next_cmd(char **cmds);/* sysfs support */struct attribute_set { unsigned int members, max_members; struct attribute_group group;};static struct attribute_set *create_attr_set(unsigned int max_members, const char* name);#define destroy_attr_set(_set) \ kfree(_set);static int add_to_attr_set(struct attribute_set* s, struct attribute *attr);static int add_many_to_attr_set(struct attribute_set* s, struct attribute **attr, unsigned int count);#define register_attr_set_with_sysfs(_attr_set, _kobj) \ sysfs_create_group(_kobj, &_attr_set->group)static void delete_attr_set(struct attribute_set* s, struct kobject *kobj);static int parse_strtoul(const char *buf, unsigned long max, unsigned long *value);/* Device model */static struct platform_device *tpacpi_pdev;static struct platform_device *tpacpi_sensors_pdev;static struct device *tpacpi_hwmon;static struct platform_driver tpacpi_pdriver;static struct input_dev *tpacpi_inputdev;static int tpacpi_create_driver_attributes(struct device_driver *drv);static void tpacpi_remove_driver_attributes(struct device_driver *drv);/* Module */static int experimental;static u32 dbg_level;static int force_load;static unsigned int hotkey_report_mode;static int thinkpad_acpi_module_init(void);static void thinkpad_acpi_module_exit(void);/**************************************************************************** * Subdrivers */struct ibm_struct;struct tp_acpi_drv_struct { const struct acpi_device_id *hid; struct acpi_driver *driver; void (*notify) (struct ibm_struct *, u32); acpi_handle *handle; u32 type; struct acpi_device *device;};struct ibm_struct { char *name; int (*read) (char *); int (*write) (char *); void (*exit) (void); void (*resume) (void); struct list_head all_drivers; struct tp_acpi_drv_struct *acpi; struct { u8 acpi_driver_registered:1; u8 acpi_notify_installed:1; u8 proc_created:1; u8 init_called:1; u8 experimental:1; } flags;};struct ibm_init_struct { char param[32]; int (*init) (struct ibm_init_struct *); struct ibm_struct *data;};static struct {#ifdef CONFIG_THINKPAD_ACPI_BAY u32 bay_status:1; u32 bay_eject:1; u32 bay_status2:1; u32 bay_eject2:1;#endif u32 bluetooth:1; u32 hotkey:1; u32 hotkey_mask:1; u32 hotkey_wlsw:1; u32 light:1; u32 light_status:1; u32 bright_16levels:1; u32 wan:1; u32 fan_ctrl_status_undef:1; u32 input_device_registered:1; u32 platform_drv_registered:1; u32 platform_drv_attrs_registered:1; u32 sensors_pdrv_registered:1; u32 sensors_pdrv_attrs_registered:1; u32 sensors_pdev_attrs_registered:1;} tp_features;struct thinkpad_id_data { unsigned int vendor; /* ThinkPad vendor: * PCI_VENDOR_ID_IBM/PCI_VENDOR_ID_LENOVO */ char *bios_version_str; /* Something like 1ZET51WW (1.03z) */ char *ec_version_str; /* Something like 1ZHT51WW-1.04a */ u16 bios_model; /* Big Endian, TP-1Y = 0x5931, 0 = unknown */ u16 ec_model; char *model_str;};static struct thinkpad_id_data thinkpad_id;static struct list_head tpacpi_all_drivers;static struct ibm_init_struct ibms_init[];static int set_ibm_param(const char *val, struct kernel_param *kp);static int ibm_init(struct ibm_init_struct *iibm);static void ibm_exit(struct ibm_struct *ibm);/* * procfs master subdriver */static int thinkpad_acpi_driver_init(struct ibm_init_struct *iibm);static int thinkpad_acpi_driver_read(char *p);/* * Bay subdriver */#ifdef CONFIG_THINKPAD_ACPI_BAYstatic acpi_handle bay_handle, bay_ej_handle;static acpi_handle bay2_handle, bay2_ej_handle;static int bay_init(struct ibm_init_struct *iibm);static void bay_notify(struct ibm_struct *ibm, u32 event);static int bay_read(char *p);static int bay_write(char *buf);#endif /* CONFIG_THINKPAD_ACPI_BAY */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?