···175 */176177struct getset_keycode_data {178- unsigned int scancode;179- unsigned int keycode;180 int error;181};182···183{184 struct getset_keycode_data *d = data;185186- d->error = input_get_keycode(handle->dev, d->scancode, &d->keycode);187188 return d->error == 0; /* stop as soon as we successfully get one */189}190191int getkeycode(unsigned int scancode)192{193- struct getset_keycode_data d = { scancode, 0, -ENODEV };000000000194195 input_handler_for_each_handle(&kbd_handler, &d, getkeycode_helper);196197- return d.error ?: d.keycode;198}199200static int setkeycode_helper(struct input_handle *handle, void *data)201{202 struct getset_keycode_data *d = data;203204- d->error = input_set_keycode(handle->dev, d->scancode, d->keycode);205206 return d->error == 0; /* stop as soon as we successfully set one */207}208209int setkeycode(unsigned int scancode, unsigned int keycode)210{211- struct getset_keycode_data d = { scancode, keycode, -ENODEV };000000000212213 input_handler_for_each_handle(&kbd_handler, &d, setkeycode_helper);214
···175 */176177struct getset_keycode_data {178+ struct input_keymap_entry ke;0179 int error;180};181···184{185 struct getset_keycode_data *d = data;186187+ d->error = input_get_keycode(handle->dev, &d->ke);188189 return d->error == 0; /* stop as soon as we successfully get one */190}191192int getkeycode(unsigned int scancode)193{194+ struct getset_keycode_data d = {195+ .ke = {196+ .flags = 0,197+ .len = sizeof(scancode),198+ .keycode = 0,199+ },200+ .error = -ENODEV,201+ };202+203+ memcpy(d.ke.scancode, &scancode, sizeof(scancode));204205 input_handler_for_each_handle(&kbd_handler, &d, getkeycode_helper);206207+ return d.error ?: d.ke.keycode;208}209210static int setkeycode_helper(struct input_handle *handle, void *data)211{212 struct getset_keycode_data *d = data;213214+ d->error = input_set_keycode(handle->dev, &d->ke);215216 return d->error == 0; /* stop as soon as we successfully set one */217}218219int setkeycode(unsigned int scancode, unsigned int keycode)220{221+ struct getset_keycode_data d = {222+ .ke = {223+ .flags = 0,224+ .len = sizeof(scancode),225+ .keycode = keycode,226+ },227+ .error = -ENODEV,228+ };229+230+ memcpy(d.ke.scancode, &scancode, sizeof(scancode));231232 input_handler_for_each_handle(&kbd_handler, &d, setkeycode_helper);233
+12-3
drivers/char/sysrq.c
···566static bool sysrq_down;567static int sysrq_alt_use;568static int sysrq_alt;0569570static bool sysrq_filter(struct input_handle *handle, unsigned int type,571 unsigned int code, int value)572{00000573 if (type != EV_KEY)574 goto out;575···607 }608609out:610- return sysrq_down;000611}612613static int sysrq_connect(struct input_handler *handler,···661}662663/*664- * We are matching on KEY_LEFTALT insteard of KEY_SYSRQ because not all665- * keyboards have SysRq ikey predefined and so user may add it to keymap666 * later, but we expect all such keyboards to have left alt.667 */668static const struct input_device_id sysrq_ids[] = {
···566static bool sysrq_down;567static int sysrq_alt_use;568static int sysrq_alt;569+static DEFINE_SPINLOCK(sysrq_event_lock);570571static bool sysrq_filter(struct input_handle *handle, unsigned int type,572 unsigned int code, int value)573{574+ bool suppress;575+576+ /* We are called with interrupts disabled, just take the lock */577+ spin_lock(&sysrq_event_lock);578+579 if (type != EV_KEY)580 goto out;581···601 }602603out:604+ suppress = sysrq_down;605+ spin_unlock(&sysrq_event_lock);606+607+ return suppress;608}609610static int sysrq_connect(struct input_handler *handler,···652}653654/*655+ * We are matching on KEY_LEFTALT instead of KEY_SYSRQ because not all656+ * keyboards have SysRq key predefined and so user may add it to keymap657 * later, but we expect all such keyboards to have left alt.658 */659static const struct input_device_id sysrq_ids[] = {
···171 if (code == ABS_MT_SLOT) {172 /*173 * "Stage" the event; we'll flush it later, when we174- * get actiual touch data.175 */176 if (*pval >= 0 && *pval < dev->mtsize)177 dev->slot = *pval;···188 pold = &mtslot->abs[code - ABS_MT_FIRST];189 } else {190 /*191- * Bypass filtering for multitouch events when192 * not employing slots.193 */194 pold = NULL;···634 spin_unlock_irq(&dev->event_lock);635}636637-static int input_fetch_keycode(struct input_dev *dev, int scancode)0000000000000000000000000000000000000000638{639 switch (dev->keycodesize) {640- case 1:641- return ((u8 *)dev->keycode)[scancode];642643- case 2:644- return ((u16 *)dev->keycode)[scancode];645646- default:647- return ((u32 *)dev->keycode)[scancode];648 }649}650651static int input_default_getkeycode(struct input_dev *dev,652- unsigned int scancode,653- unsigned int *keycode)654{000655 if (!dev->keycodesize)656 return -EINVAL;657658- if (scancode >= dev->keycodemax)00000000659 return -EINVAL;660661- *keycode = input_fetch_keycode(dev, scancode);000662663 return 0;664}665666static int input_default_setkeycode(struct input_dev *dev,667- unsigned int scancode,668- unsigned int keycode)669{670- int old_keycode;0671 int i;672-673- if (scancode >= dev->keycodemax)674- return -EINVAL;675676 if (!dev->keycodesize)677 return -EINVAL;678679- if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))000000000000680 return -EINVAL;681682 switch (dev->keycodesize) {683 case 1: {684 u8 *k = (u8 *)dev->keycode;685- old_keycode = k[scancode];686- k[scancode] = keycode;687 break;688 }689 case 2: {690 u16 *k = (u16 *)dev->keycode;691- old_keycode = k[scancode];692- k[scancode] = keycode;693 break;694 }695 default: {696 u32 *k = (u32 *)dev->keycode;697- old_keycode = k[scancode];698- k[scancode] = keycode;699 break;700 }701 }702703- __clear_bit(old_keycode, dev->keybit);704- __set_bit(keycode, dev->keybit);705706 for (i = 0; i < dev->keycodemax; i++) {707- if (input_fetch_keycode(dev, i) == old_keycode) {708- __set_bit(old_keycode, dev->keybit);709 break; /* Setting the bit twice is useless, so break */710 }711 }···779/**780 * input_get_keycode - retrieve keycode currently mapped to a given scancode781 * @dev: input device which keymap is being queried782- * @scancode: scancode (or its equivalent for device in question) for which783- * keycode is needed784- * @keycode: result785 *786 * This function should be called by anyone interested in retrieving current787- * keymap. Presently keyboard and evdev handlers use it.788 */789-int input_get_keycode(struct input_dev *dev,790- unsigned int scancode, unsigned int *keycode)791{792 unsigned long flags;793 int retval;794795 spin_lock_irqsave(&dev->event_lock, flags);796- retval = dev->getkeycode(dev, scancode, keycode);797- spin_unlock_irqrestore(&dev->event_lock, flags);798000000000000000799 return retval;800}801EXPORT_SYMBOL(input_get_keycode);802803/**804- * input_get_keycode - assign new keycode to a given scancode805 * @dev: input device which keymap is being updated806- * @scancode: scancode (or its equivalent for device in question)807- * @keycode: new keycode to be assigned to the scancode808 *809 * This function should be called by anyone needing to update current810 * keymap. Presently keyboard and evdev handlers use it.811 */812int input_set_keycode(struct input_dev *dev,813- unsigned int scancode, unsigned int keycode)814{815 unsigned long flags;816 unsigned int old_keycode;817 int retval;818819- if (keycode > KEY_MAX)820 return -EINVAL;821822 spin_lock_irqsave(&dev->event_lock, flags);823824- retval = dev->getkeycode(dev, scancode, &old_keycode);825- if (retval)826- goto out;000827828- retval = dev->setkeycode(dev, scancode, keycode);000000000000000000000829 if (retval)830 goto out;831···1697 *1698 * This function allocates all necessary memory for MT slot handling in the1699 * input device, and adds ABS_MT_SLOT to the device capabilities. All slots1700- * are initially marked as unused iby setting ABS_MT_TRACKING_ID to -1.1701 */1702int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)1703{···1855 dev->rep[REP_PERIOD] = 33;1856 }18571858- if (!dev->getkeycode)1859- dev->getkeycode = input_default_getkeycode;18601861- if (!dev->setkeycode)1862- dev->setkeycode = input_default_setkeycode;18631864 dev_set_name(&dev->dev, "input%ld",1865 (unsigned long) atomic_inc_return(&input_no) - 1);
···171 if (code == ABS_MT_SLOT) {172 /*173 * "Stage" the event; we'll flush it later, when we174+ * get actual touch data.175 */176 if (*pval >= 0 && *pval < dev->mtsize)177 dev->slot = *pval;···188 pold = &mtslot->abs[code - ABS_MT_FIRST];189 } else {190 /*191+ * Bypass filtering for multi-touch events when192 * not employing slots.193 */194 pold = NULL;···634 spin_unlock_irq(&dev->event_lock);635}636637+/**638+ * input_scancode_to_scalar() - converts scancode in &struct input_keymap_entry639+ * @ke: keymap entry containing scancode to be converted.640+ * @scancode: pointer to the location where converted scancode should641+ * be stored.642+ *643+ * This function is used to convert scancode stored in &struct keymap_entry644+ * into scalar form understood by legacy keymap handling methods. These645+ * methods expect scancodes to be represented as 'unsigned int'.646+ */647+int input_scancode_to_scalar(const struct input_keymap_entry *ke,648+ unsigned int *scancode)649+{650+ switch (ke->len) {651+ case 1:652+ *scancode = *((u8 *)ke->scancode);653+ break;654+655+ case 2:656+ *scancode = *((u16 *)ke->scancode);657+ break;658+659+ case 4:660+ *scancode = *((u32 *)ke->scancode);661+ break;662+663+ default:664+ return -EINVAL;665+ }666+667+ return 0;668+}669+EXPORT_SYMBOL(input_scancode_to_scalar);670+671+/*672+ * Those routines handle the default case where no [gs]etkeycode() is673+ * defined. In this case, an array indexed by the scancode is used.674+ */675+676+static unsigned int input_fetch_keycode(struct input_dev *dev,677+ unsigned int index)678{679 switch (dev->keycodesize) {680+ case 1:681+ return ((u8 *)dev->keycode)[index];682683+ case 2:684+ return ((u16 *)dev->keycode)[index];685686+ default:687+ return ((u32 *)dev->keycode)[index];688 }689}690691static int input_default_getkeycode(struct input_dev *dev,692+ struct input_keymap_entry *ke)0693{694+ unsigned int index;695+ int error;696+697 if (!dev->keycodesize)698 return -EINVAL;699700+ if (ke->flags & INPUT_KEYMAP_BY_INDEX)701+ index = ke->index;702+ else {703+ error = input_scancode_to_scalar(ke, &index);704+ if (error)705+ return error;706+ }707+708+ if (index >= dev->keycodemax)709 return -EINVAL;710711+ ke->keycode = input_fetch_keycode(dev, index);712+ ke->index = index;713+ ke->len = sizeof(index);714+ memcpy(ke->scancode, &index, sizeof(index));715716 return 0;717}718719static int input_default_setkeycode(struct input_dev *dev,720+ const struct input_keymap_entry *ke,721+ unsigned int *old_keycode)722{723+ unsigned int index;724+ int error;725 int i;000726727 if (!dev->keycodesize)728 return -EINVAL;729730+ if (ke->flags & INPUT_KEYMAP_BY_INDEX) {731+ index = ke->index;732+ } else {733+ error = input_scancode_to_scalar(ke, &index);734+ if (error)735+ return error;736+ }737+738+ if (index >= dev->keycodemax)739+ return -EINVAL;740+741+ if (dev->keycodesize < sizeof(dev->keycode) &&742+ (ke->keycode >> (dev->keycodesize * 8)))743 return -EINVAL;744745 switch (dev->keycodesize) {746 case 1: {747 u8 *k = (u8 *)dev->keycode;748+ *old_keycode = k[index];749+ k[index] = ke->keycode;750 break;751 }752 case 2: {753 u16 *k = (u16 *)dev->keycode;754+ *old_keycode = k[index];755+ k[index] = ke->keycode;756 break;757 }758 default: {759 u32 *k = (u32 *)dev->keycode;760+ *old_keycode = k[index];761+ k[index] = ke->keycode;762 break;763 }764 }765766+ __clear_bit(*old_keycode, dev->keybit);767+ __set_bit(ke->keycode, dev->keybit);768769 for (i = 0; i < dev->keycodemax; i++) {770+ if (input_fetch_keycode(dev, i) == *old_keycode) {771+ __set_bit(*old_keycode, dev->keybit);772 break; /* Setting the bit twice is useless, so break */773 }774 }···716/**717 * input_get_keycode - retrieve keycode currently mapped to a given scancode718 * @dev: input device which keymap is being queried719+ * @ke: keymap entry00720 *721 * This function should be called by anyone interested in retrieving current722+ * keymap. Presently evdev handlers use it.723 */724+int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)0725{726 unsigned long flags;727 int retval;728729 spin_lock_irqsave(&dev->event_lock, flags);00730731+ if (dev->getkeycode) {732+ /*733+ * Support for legacy drivers, that don't implement the new734+ * ioctls735+ */736+ u32 scancode = ke->index;737+738+ memcpy(ke->scancode, &scancode, sizeof(scancode));739+ ke->len = sizeof(scancode);740+ retval = dev->getkeycode(dev, scancode, &ke->keycode);741+ } else {742+ retval = dev->getkeycode_new(dev, ke);743+ }744+745+ spin_unlock_irqrestore(&dev->event_lock, flags);746 return retval;747}748EXPORT_SYMBOL(input_get_keycode);749750/**751+ * input_set_keycode - attribute a keycode to a given scancode752 * @dev: input device which keymap is being updated753+ * @ke: new keymap entry0754 *755 * This function should be called by anyone needing to update current756 * keymap. Presently keyboard and evdev handlers use it.757 */758int input_set_keycode(struct input_dev *dev,759+ const struct input_keymap_entry *ke)760{761 unsigned long flags;762 unsigned int old_keycode;763 int retval;764765+ if (ke->keycode > KEY_MAX)766 return -EINVAL;767768 spin_lock_irqsave(&dev->event_lock, flags);769770+ if (dev->setkeycode) {771+ /*772+ * Support for legacy drivers, that don't implement the new773+ * ioctls774+ */775+ unsigned int scancode;776777+ retval = input_scancode_to_scalar(ke, &scancode);778+ if (retval)779+ goto out;780+781+ /*782+ * We need to know the old scancode, in order to generate a783+ * keyup effect, if the set operation happens successfully784+ */785+ if (!dev->getkeycode) {786+ retval = -EINVAL;787+ goto out;788+ }789+790+ retval = dev->getkeycode(dev, scancode, &old_keycode);791+ if (retval)792+ goto out;793+794+ retval = dev->setkeycode(dev, scancode, ke->keycode);795+ } else {796+ retval = dev->setkeycode_new(dev, ke, &old_keycode);797+ }798+799 if (retval)800 goto out;801···1601 *1602 * This function allocates all necessary memory for MT slot handling in the1603 * input device, and adds ABS_MT_SLOT to the device capabilities. All slots1604+ * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1.1605 */1606int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)1607{···1759 dev->rep[REP_PERIOD] = 33;1760 }17611762+ if (!dev->getkeycode && !dev->getkeycode_new)1763+ dev->getkeycode_new = input_default_getkeycode;17641765+ if (!dev->setkeycode && !dev->setkeycode_new)1766+ dev->setkeycode_new = input_default_setkeycode;17671768 dev_set_name(&dev->dev, "input%ld",1769 (unsigned long) atomic_inc_return(&input_no) - 1);
+19
drivers/input/keyboard/Kconfig
···327 To compile this driver as a module, choose M here: the328 module will be called newtonkbd.3290000000000330config KEYBOARD_OPENCORES331 tristate "OpenCores Keyboard Controller"332 help···433434 To compile this driver as a module, choose M here: the435 module will be called omap-keypad.000000000436437config KEYBOARD_TWL4030438 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
···327 To compile this driver as a module, choose M here: the328 module will be called newtonkbd.329330+config KEYBOARD_NOMADIK331+ tristate "ST-Ericsson Nomadik SKE keyboard"332+ depends on PLAT_NOMADIK333+ help334+ Say Y here if you want to use a keypad provided on the SKE controller335+ used on the Ux500 and Nomadik platforms336+337+ To compile this driver as a module, choose M here: the338+ module will be called nmk-ske-keypad.339+340config KEYBOARD_OPENCORES341 tristate "OpenCores Keyboard Controller"342 help···423424 To compile this driver as a module, choose M here: the425 module will be called omap-keypad.426+427+config KEYBOARD_OMAP4428+ tristate "TI OMAP4 keypad support"429+ depends on ARCH_OMAP4430+ help431+ Say Y here if you want to use the OMAP4 keypad.432+433+ To compile this driver as a module, choose M here: the434+ module will be called omap4-keypad.435436config KEYBOARD_TWL4030437 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
···1+/*2+ * OMAP4 Keypad Driver3+ *4+ * Copyright (C) 2010 Texas Instruments5+ *6+ * Author: Abraham Arce <x0066660@ti.com>7+ * Initial Code: Syed Rafiuddin <rafiuddin.syed@ti.com>8+ *9+ * This program is free software; you can redistribute it and/or modify10+ * it under the terms of the GNU General Public License as published by11+ * the Free Software Foundation; either version 2 of the License, or12+ * (at your option) any later version.13+ *14+ * This program is distributed in the hope that it will be useful,15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17+ * GNU General Public License for more details.18+ *19+ * You should have received a copy of the GNU General Public License20+ * along with this program; if not, write to the Free Software21+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA22+ */23+24+#include <linux/module.h>25+#include <linux/init.h>26+#include <linux/interrupt.h>27+#include <linux/platform_device.h>28+#include <linux/errno.h>29+#include <linux/io.h>30+#include <linux/input.h>31+#include <linux/slab.h>32+33+#include <plat/omap4-keypad.h>34+35+/* OMAP4 registers */36+#define OMAP4_KBD_REVISION 0x0037+#define OMAP4_KBD_SYSCONFIG 0x1038+#define OMAP4_KBD_SYSSTATUS 0x1439+#define OMAP4_KBD_IRQSTATUS 0x1840+#define OMAP4_KBD_IRQENABLE 0x1C41+#define OMAP4_KBD_WAKEUPENABLE 0x2042+#define OMAP4_KBD_PENDING 0x2443+#define OMAP4_KBD_CTRL 0x2844+#define OMAP4_KBD_DEBOUNCINGTIME 0x2C45+#define OMAP4_KBD_LONGKEYTIME 0x3046+#define OMAP4_KBD_TIMEOUT 0x3447+#define OMAP4_KBD_STATEMACHINE 0x3848+#define OMAP4_KBD_ROWINPUTS 0x3C49+#define OMAP4_KBD_COLUMNOUTPUTS 0x4050+#define OMAP4_KBD_FULLCODE31_0 0x4451+#define OMAP4_KBD_FULLCODE63_32 0x4852+53+/* OMAP4 bit definitions */54+#define OMAP4_DEF_IRQENABLE_EVENTEN (1 << 0)55+#define OMAP4_DEF_IRQENABLE_LONGKEY (1 << 1)56+#define OMAP4_DEF_IRQENABLE_TIMEOUTEN (1 << 2)57+#define OMAP4_DEF_WUP_EVENT_ENA (1 << 0)58+#define OMAP4_DEF_WUP_LONG_KEY_ENA (1 << 1)59+#define OMAP4_DEF_CTRL_NOSOFTMODE (1 << 1)60+#define OMAP4_DEF_CTRLPTVVALUE (1 << 2)61+#define OMAP4_DEF_CTRLPTV (1 << 1)62+63+/* OMAP4 values */64+#define OMAP4_VAL_IRQDISABLE 0x0065+#define OMAP4_VAL_DEBOUNCINGTIME 0x0766+#define OMAP4_VAL_FUNCTIONALCFG 0x1E67+68+#define OMAP4_MASK_IRQSTATUSDISABLE 0xFFFF69+70+struct omap4_keypad {71+ struct input_dev *input;72+73+ void __iomem *base;74+ int irq;75+76+ unsigned int rows;77+ unsigned int cols;78+ unsigned int row_shift;79+ unsigned char key_state[8];80+ unsigned short keymap[];81+};82+83+static void __devinit omap4_keypad_config(struct omap4_keypad *keypad_data)84+{85+ __raw_writel(OMAP4_VAL_FUNCTIONALCFG,86+ keypad_data->base + OMAP4_KBD_CTRL);87+ __raw_writel(OMAP4_VAL_DEBOUNCINGTIME,88+ keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME);89+ __raw_writel(OMAP4_VAL_IRQDISABLE,90+ keypad_data->base + OMAP4_KBD_IRQSTATUS);91+ __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY,92+ keypad_data->base + OMAP4_KBD_IRQENABLE);93+ __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA,94+ keypad_data->base + OMAP4_KBD_WAKEUPENABLE);95+}96+97+/* Interrupt handler */98+static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)99+{100+ struct omap4_keypad *keypad_data = dev_id;101+ struct input_dev *input_dev = keypad_data->input;102+ unsigned char key_state[ARRAY_SIZE(keypad_data->key_state)];103+ unsigned int col, row, code, changed;104+ u32 *new_state = (u32 *) key_state;105+106+ /* Disable interrupts */107+ __raw_writel(OMAP4_VAL_IRQDISABLE,108+ keypad_data->base + OMAP4_KBD_IRQENABLE);109+110+ *new_state = __raw_readl(keypad_data->base + OMAP4_KBD_FULLCODE31_0);111+ *(new_state + 1) = __raw_readl(keypad_data->base112+ + OMAP4_KBD_FULLCODE63_32);113+114+ for (row = 0; row < keypad_data->rows; row++) {115+ changed = key_state[row] ^ keypad_data->key_state[row];116+ if (!changed)117+ continue;118+119+ for (col = 0; col < keypad_data->cols; col++) {120+ if (changed & (1 << col)) {121+ code = MATRIX_SCAN_CODE(row, col,122+ keypad_data->row_shift);123+ input_event(input_dev, EV_MSC, MSC_SCAN, code);124+ input_report_key(input_dev,125+ keypad_data->keymap[code],126+ key_state[row] & (1 << col));127+ }128+ }129+ }130+131+ input_sync(input_dev);132+133+ memcpy(keypad_data->key_state, key_state,134+ sizeof(keypad_data->key_state));135+136+ /* clear pending interrupts */137+ __raw_writel(__raw_readl(keypad_data->base + OMAP4_KBD_IRQSTATUS),138+ keypad_data->base + OMAP4_KBD_IRQSTATUS);139+140+ /* enable interrupts */141+ __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY,142+ keypad_data->base + OMAP4_KBD_IRQENABLE);143+144+ return IRQ_HANDLED;145+}146+147+static int __devinit omap4_keypad_probe(struct platform_device *pdev)148+{149+ const struct omap4_keypad_platform_data *pdata;150+ struct omap4_keypad *keypad_data;151+ struct input_dev *input_dev;152+ struct resource *res;153+ resource_size_t size;154+ unsigned int row_shift, max_keys;155+ int irq;156+ int error;157+158+ /* platform data */159+ pdata = pdev->dev.platform_data;160+ if (!pdata) {161+ dev_err(&pdev->dev, "no platform data defined\n");162+ return -EINVAL;163+ }164+165+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);166+ if (!res) {167+ dev_err(&pdev->dev, "no base address specified\n");168+ return -EINVAL;169+ }170+171+ irq = platform_get_irq(pdev, 0);172+ if (!irq) {173+ dev_err(&pdev->dev, "no keyboard irq assigned\n");174+ return -EINVAL;175+ }176+177+ if (!pdata->keymap_data) {178+ dev_err(&pdev->dev, "no keymap data defined\n");179+ return -EINVAL;180+ }181+182+ row_shift = get_count_order(pdata->cols);183+ max_keys = pdata->rows << row_shift;184+185+ keypad_data = kzalloc(sizeof(struct omap4_keypad) +186+ max_keys * sizeof(keypad_data->keymap[0]),187+ GFP_KERNEL);188+ if (!keypad_data) {189+ dev_err(&pdev->dev, "keypad_data memory allocation failed\n");190+ return -ENOMEM;191+ }192+193+ size = resource_size(res);194+195+ res = request_mem_region(res->start, size, pdev->name);196+ if (!res) {197+ dev_err(&pdev->dev, "can't request mem region\n");198+ error = -EBUSY;199+ goto err_free_keypad;200+ }201+202+ keypad_data->base = ioremap(res->start, resource_size(res));203+ if (!keypad_data->base) {204+ dev_err(&pdev->dev, "can't ioremap mem resource\n");205+ error = -ENOMEM;206+ goto err_release_mem;207+ }208+209+ keypad_data->irq = irq;210+ keypad_data->row_shift = row_shift;211+ keypad_data->rows = pdata->rows;212+ keypad_data->cols = pdata->cols;213+214+ /* input device allocation */215+ keypad_data->input = input_dev = input_allocate_device();216+ if (!input_dev) {217+ error = -ENOMEM;218+ goto err_unmap;219+ }220+221+ input_dev->name = pdev->name;222+ input_dev->dev.parent = &pdev->dev;223+ input_dev->id.bustype = BUS_HOST;224+ input_dev->id.vendor = 0x0001;225+ input_dev->id.product = 0x0001;226+ input_dev->id.version = 0x0001;227+228+ input_dev->keycode = keypad_data->keymap;229+ input_dev->keycodesize = sizeof(keypad_data->keymap[0]);230+ input_dev->keycodemax = max_keys;231+232+ __set_bit(EV_KEY, input_dev->evbit);233+ __set_bit(EV_REP, input_dev->evbit);234+235+ input_set_capability(input_dev, EV_MSC, MSC_SCAN);236+237+ input_set_drvdata(input_dev, keypad_data);238+239+ matrix_keypad_build_keymap(pdata->keymap_data, row_shift,240+ input_dev->keycode, input_dev->keybit);241+242+ omap4_keypad_config(keypad_data);243+244+ error = request_irq(keypad_data->irq, omap4_keypad_interrupt,245+ IRQF_TRIGGER_RISING,246+ "omap4-keypad", keypad_data);247+ if (error) {248+ dev_err(&pdev->dev, "failed to register interrupt\n");249+ goto err_free_input;250+ }251+252+ error = input_register_device(keypad_data->input);253+ if (error < 0) {254+ dev_err(&pdev->dev, "failed to register input device\n");255+ goto err_free_irq;256+ }257+258+259+ platform_set_drvdata(pdev, keypad_data);260+ return 0;261+262+err_free_irq:263+ free_irq(keypad_data->irq, keypad_data);264+err_free_input:265+ input_free_device(input_dev);266+err_unmap:267+ iounmap(keypad_data->base);268+err_release_mem:269+ release_mem_region(res->start, size);270+err_free_keypad:271+ kfree(keypad_data);272+ return error;273+}274+275+static int __devexit omap4_keypad_remove(struct platform_device *pdev)276+{277+ struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);278+ struct resource *res;279+280+ free_irq(keypad_data->irq, keypad_data);281+ input_unregister_device(keypad_data->input);282+283+ iounmap(keypad_data->base);284+285+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);286+ release_mem_region(res->start, resource_size(res));287+288+ kfree(keypad_data);289+ platform_set_drvdata(pdev, NULL);290+291+ return 0;292+}293+294+static struct platform_driver omap4_keypad_driver = {295+ .probe = omap4_keypad_probe,296+ .remove = __devexit_p(omap4_keypad_remove),297+ .driver = {298+ .name = "omap4-keypad",299+ .owner = THIS_MODULE,300+ },301+};302+303+static int __init omap4_keypad_init(void)304+{305+ return platform_driver_register(&omap4_keypad_driver);306+}307+module_init(omap4_keypad_init);308+309+static void __exit omap4_keypad_exit(void)310+{311+ platform_driver_unregister(&omap4_keypad_driver);312+}313+module_exit(omap4_keypad_exit);314+315+MODULE_AUTHOR("Texas Instruments");316+MODULE_DESCRIPTION("OMAP4 Keypad Driver");317+MODULE_LICENSE("GPL");318+MODULE_ALIAS("platform:omap4-keypad");
+3-4
drivers/input/keyboard/twl4030_keypad.c
···406 if (error) {407 dev_info(kp->dbg_dev, "request_irq failed for irq no=%d\n",408 kp->irq);409- goto err3;410 }411412 /* Enable KP and TO interrupts now. */413 reg = (u8) ~(KEYP_IMR1_KP | KEYP_IMR1_TO);414 if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) {415 error = -EIO;416- goto err4;417 }418419 platform_set_drvdata(pdev, kp);420 return 0;421422-err4:423 /* mask all events - we don't care about the result */424 (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1);425-err3:426 free_irq(kp->irq, NULL);427err2:428 input_unregister_device(input);
···406 if (error) {407 dev_info(kp->dbg_dev, "request_irq failed for irq no=%d\n",408 kp->irq);409+ goto err2;410 }411412 /* Enable KP and TO interrupts now. */413 reg = (u8) ~(KEYP_IMR1_KP | KEYP_IMR1_TO);414 if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) {415 error = -EIO;416+ goto err3;417 }418419 platform_set_drvdata(pdev, kp);420 return 0;421422+err3:423 /* mask all events - we don't care about the result */424 (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1);0425 free_irq(kp->irq, NULL);426err2:427 input_unregister_device(input);
+10
drivers/input/misc/Kconfig
···22 To compile this driver as a module, choose M here: the module23 will be called 88pm860x_onkey.24000000000025config INPUT_AD714X26 tristate "Analog Devices AD714x Capacitance Touch Sensor"27 help
···22 To compile this driver as a module, choose M here: the module23 will be called 88pm860x_onkey.2425+config INPUT_AB8500_PONKEY26+ tristate "AB8500 Pon (PowerOn) Key"27+ depends on AB8500_CORE28+ help29+ Say Y here to use the PowerOn Key for ST-Ericsson's AB850030+ Mix-Sig PMIC.31+32+ To compile this driver as a module, choose M here: the module33+ will be called ab8500-ponkey.34+35config INPUT_AD714X36 tristate "Analog Devices AD714x Capacitance Touch Sensor"37 help
+1
drivers/input/misc/Makefile
···5# Each configuration option enables a list of files.67obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o08obj-$(CONFIG_INPUT_AD714X) += ad714x.o9obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o10obj-$(CONFIG_INPUT_AD714X_SPI) += ad714x-spi.o
···5# Each configuration option enables a list of files.67obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o8+obj-$(CONFIG_INPUT_AB8500_PONKEY) += ab8500-ponkey.o9obj-$(CONFIG_INPUT_AD714X) += ad714x.o10obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o11obj-$(CONFIG_INPUT_AD714X_SPI) += ad714x-spi.o
···866 spin_lock_init(&mousedev->client_lock);867 mutex_init(&mousedev->mutex);868 lockdep_set_subclass(&mousedev->mutex,869- minor == MOUSEDEV_MIX ? MOUSEDEV_MIX : 0);870 init_waitqueue_head(&mousedev->wait);871872 if (minor == MOUSEDEV_MIX)
···866 spin_lock_init(&mousedev->client_lock);867 mutex_init(&mousedev->mutex);868 lockdep_set_subclass(&mousedev->mutex,869+ minor == MOUSEDEV_MIX ? SINGLE_DEPTH_NESTING : 0);870 init_waitqueue_head(&mousedev->wait);871872 if (minor == MOUSEDEV_MIX)
+9
drivers/input/serio/Kconfig
···226 To compile this driver as a module, choose M here;227 the module will be called ams_delta_serio.228000000000229endif
···226 To compile this driver as a module, choose M here;227 the module will be called ams_delta_serio.228229+config SERIO_PS2MULT230+ tristate "TQC PS/2 multiplexer"231+ help232+ Say Y here if you have the PS/2 line multiplexer like the one233+ present on TQC boads.234+235+ To compile this driver as a module, choose M here: the236+ module will be called ps2mult.237+238endif
···1+/*2+ * TQC PS/2 Multiplexer driver3+ *4+ * Copyright (C) 2010 Dmitry Eremin-Solenikov5+ *6+ * This program is free software; you can redistribute it and/or modify it7+ * under the terms of the GNU General Public License version 2 as published by8+ * the Free Software Foundation.9+ */10+11+12+#include <linux/kernel.h>13+#include <linux/slab.h>14+#include <linux/module.h>15+#include <linux/serio.h>16+17+MODULE_AUTHOR("Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>");18+MODULE_DESCRIPTION("TQC PS/2 Multiplexer driver");19+MODULE_LICENSE("GPL");20+21+#define PS2MULT_KB_SELECTOR 0xA022+#define PS2MULT_MS_SELECTOR 0xA123+#define PS2MULT_ESCAPE 0x7D24+#define PS2MULT_BSYNC 0x7E25+#define PS2MULT_SESSION_START 0x5526+#define PS2MULT_SESSION_END 0x5627+28+struct ps2mult_port {29+ struct serio *serio;30+ unsigned char sel;31+ bool registered;32+};33+34+#define PS2MULT_NUM_PORTS 235+#define PS2MULT_KBD_PORT 036+#define PS2MULT_MOUSE_PORT 137+38+struct ps2mult {39+ struct serio *mx_serio;40+ struct ps2mult_port ports[PS2MULT_NUM_PORTS];41+42+ spinlock_t lock;43+ struct ps2mult_port *in_port;44+ struct ps2mult_port *out_port;45+ bool escape;46+};47+48+/* First MUST come PS2MULT_NUM_PORTS selectors */49+static const unsigned char ps2mult_controls[] = {50+ PS2MULT_KB_SELECTOR, PS2MULT_MS_SELECTOR,51+ PS2MULT_ESCAPE, PS2MULT_BSYNC,52+ PS2MULT_SESSION_START, PS2MULT_SESSION_END,53+};54+55+static const struct serio_device_id ps2mult_serio_ids[] = {56+ {57+ .type = SERIO_RS232,58+ .proto = SERIO_PS2MULT,59+ .id = SERIO_ANY,60+ .extra = SERIO_ANY,61+ },62+ { 0 }63+};64+65+MODULE_DEVICE_TABLE(serio, ps2mult_serio_ids);66+67+static void ps2mult_select_port(struct ps2mult *psm, struct ps2mult_port *port)68+{69+ struct serio *mx_serio = psm->mx_serio;70+71+ serio_write(mx_serio, port->sel);72+ psm->out_port = port;73+ dev_dbg(&mx_serio->dev, "switched to sel %02x\n", port->sel);74+}75+76+static int ps2mult_serio_write(struct serio *serio, unsigned char data)77+{78+ struct serio *mx_port = serio->parent;79+ struct ps2mult *psm = serio_get_drvdata(mx_port);80+ struct ps2mult_port *port = serio->port_data;81+ bool need_escape;82+ unsigned long flags;83+84+ spin_lock_irqsave(&psm->lock, flags);85+86+ if (psm->out_port != port)87+ ps2mult_select_port(psm, port);88+89+ need_escape = memchr(ps2mult_controls, data, sizeof(ps2mult_controls));90+91+ dev_dbg(&serio->dev,92+ "write: %s%02x\n", need_escape ? "ESC " : "", data);93+94+ if (need_escape)95+ serio_write(mx_port, PS2MULT_ESCAPE);96+97+ serio_write(mx_port, data);98+99+ spin_unlock_irqrestore(&psm->lock, flags);100+101+ return 0;102+}103+104+static int ps2mult_serio_start(struct serio *serio)105+{106+ struct ps2mult *psm = serio_get_drvdata(serio->parent);107+ struct ps2mult_port *port = serio->port_data;108+ unsigned long flags;109+110+ spin_lock_irqsave(&psm->lock, flags);111+ port->registered = true;112+ spin_unlock_irqrestore(&psm->lock, flags);113+114+ return 0;115+}116+117+static void ps2mult_serio_stop(struct serio *serio)118+{119+ struct ps2mult *psm = serio_get_drvdata(serio->parent);120+ struct ps2mult_port *port = serio->port_data;121+ unsigned long flags;122+123+ spin_lock_irqsave(&psm->lock, flags);124+ port->registered = false;125+ spin_unlock_irqrestore(&psm->lock, flags);126+}127+128+static int ps2mult_create_port(struct ps2mult *psm, int i)129+{130+ struct serio *mx_serio = psm->mx_serio;131+ struct serio *serio;132+133+ serio = kzalloc(sizeof(struct serio), GFP_KERNEL);134+ if (!serio)135+ return -ENOMEM;136+137+ strlcpy(serio->name, "TQC PS/2 Multiplexer", sizeof(serio->name));138+ snprintf(serio->phys, sizeof(serio->phys),139+ "%s/port%d", mx_serio->phys, i);140+ serio->id.type = SERIO_8042;141+ serio->write = ps2mult_serio_write;142+ serio->start = ps2mult_serio_start;143+ serio->stop = ps2mult_serio_stop;144+ serio->parent = psm->mx_serio;145+ serio->port_data = &psm->ports[i];146+147+ psm->ports[i].serio = serio;148+149+ return 0;150+}151+152+static void ps2mult_reset(struct ps2mult *psm)153+{154+ unsigned long flags;155+156+ spin_lock_irqsave(&psm->lock, flags);157+158+ serio_write(psm->mx_serio, PS2MULT_SESSION_END);159+ serio_write(psm->mx_serio, PS2MULT_SESSION_START);160+161+ ps2mult_select_port(psm, &psm->ports[PS2MULT_KBD_PORT]);162+163+ spin_unlock_irqrestore(&psm->lock, flags);164+}165+166+static int ps2mult_connect(struct serio *serio, struct serio_driver *drv)167+{168+ struct ps2mult *psm;169+ int i;170+ int error;171+172+ if (!serio->write)173+ return -EINVAL;174+175+ psm = kzalloc(sizeof(*psm), GFP_KERNEL);176+ if (!psm)177+ return -ENOMEM;178+179+ spin_lock_init(&psm->lock);180+ psm->mx_serio = serio;181+182+ for (i = 0; i < PS2MULT_NUM_PORTS; i++) {183+ psm->ports[i].sel = ps2mult_controls[i];184+ error = ps2mult_create_port(psm, i);185+ if (error)186+ goto err_out;187+ }188+189+ psm->in_port = psm->out_port = &psm->ports[PS2MULT_KBD_PORT];190+191+ serio_set_drvdata(serio, psm);192+ error = serio_open(serio, drv);193+ if (error)194+ goto err_out;195+196+ ps2mult_reset(psm);197+198+ for (i = 0; i < PS2MULT_NUM_PORTS; i++) {199+ struct serio *s = psm->ports[i].serio;200+201+ dev_info(&serio->dev, "%s port at %s\n", s->name, serio->phys);202+ serio_register_port(s);203+ }204+205+ return 0;206+207+err_out:208+ while (--i >= 0)209+ kfree(psm->ports[i].serio);210+ kfree(serio);211+ return error;212+}213+214+static void ps2mult_disconnect(struct serio *serio)215+{216+ struct ps2mult *psm = serio_get_drvdata(serio);217+218+ /* Note that serio core already take care of children ports */219+ serio_write(serio, PS2MULT_SESSION_END);220+ serio_close(serio);221+ kfree(psm);222+223+ serio_set_drvdata(serio, NULL);224+}225+226+static int ps2mult_reconnect(struct serio *serio)227+{228+ struct ps2mult *psm = serio_get_drvdata(serio);229+230+ ps2mult_reset(psm);231+232+ return 0;233+}234+235+static irqreturn_t ps2mult_interrupt(struct serio *serio,236+ unsigned char data, unsigned int dfl)237+{238+ struct ps2mult *psm = serio_get_drvdata(serio);239+ struct ps2mult_port *in_port;240+ unsigned long flags;241+242+ dev_dbg(&serio->dev, "Received %02x flags %02x\n", data, dfl);243+244+ spin_lock_irqsave(&psm->lock, flags);245+246+ if (psm->escape) {247+ psm->escape = false;248+ in_port = psm->in_port;249+ if (in_port->registered)250+ serio_interrupt(in_port->serio, data, dfl);251+ goto out;252+ }253+254+ switch (data) {255+ case PS2MULT_ESCAPE:256+ dev_dbg(&serio->dev, "ESCAPE\n");257+ psm->escape = true;258+ break;259+260+ case PS2MULT_BSYNC:261+ dev_dbg(&serio->dev, "BSYNC\n");262+ psm->in_port = psm->out_port;263+ break;264+265+ case PS2MULT_SESSION_START:266+ dev_dbg(&serio->dev, "SS\n");267+ break;268+269+ case PS2MULT_SESSION_END:270+ dev_dbg(&serio->dev, "SE\n");271+ break;272+273+ case PS2MULT_KB_SELECTOR:274+ dev_dbg(&serio->dev, "KB\n");275+ psm->in_port = &psm->ports[PS2MULT_KBD_PORT];276+ break;277+278+ case PS2MULT_MS_SELECTOR:279+ dev_dbg(&serio->dev, "MS\n");280+ psm->in_port = &psm->ports[PS2MULT_MOUSE_PORT];281+ break;282+283+ default:284+ in_port = psm->in_port;285+ if (in_port->registered)286+ serio_interrupt(in_port->serio, data, dfl);287+ break;288+ }289+290+ out:291+ spin_unlock_irqrestore(&psm->lock, flags);292+ return IRQ_HANDLED;293+}294+295+static struct serio_driver ps2mult_drv = {296+ .driver = {297+ .name = "ps2mult",298+ },299+ .description = "TQC PS/2 Multiplexer driver",300+ .id_table = ps2mult_serio_ids,301+ .interrupt = ps2mult_interrupt,302+ .connect = ps2mult_connect,303+ .disconnect = ps2mult_disconnect,304+ .reconnect = ps2mult_reconnect,305+};306+307+static int __init ps2mult_init(void)308+{309+ return serio_register_driver(&ps2mult_drv);310+}311+312+static void __exit ps2mult_exit(void)313+{314+ serio_unregister_driver(&ps2mult_drv);315+}316+317+module_init(ps2mult_init);318+module_exit(ps2mult_exit);
+81-44
drivers/input/serio/serio.c
···37#include <linux/slab.h>38#include <linux/kthread.h>39#include <linux/mutex.h>40-#include <linux/freezer.h>4142MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");43MODULE_DESCRIPTION("Serio abstraction core");···55static void serio_add_port(struct serio *serio);56static int serio_reconnect_port(struct serio *serio);57static void serio_disconnect_port(struct serio *serio);58-static void serio_reconnect_chain(struct serio *serio);59static void serio_attach_driver(struct serio_driver *drv);6061static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)···151enum serio_event_type {152 SERIO_RESCAN_PORT,153 SERIO_RECONNECT_PORT,154- SERIO_RECONNECT_CHAIN,155 SERIO_REGISTER_PORT,156 SERIO_ATTACH_DRIVER,157};···291 serio_find_driver(event->object);292 break;293294- case SERIO_RECONNECT_CHAIN:295- serio_reconnect_chain(event->object);296 break;297298 case SERIO_ATTACH_DRIVER:···329}330331/*332- * Destroy child serio port (if any) that has not been fully registered yet.333 *334- * Note that we rely on the fact that port can have only one child and therefore335- * only one child registration request can be pending. Additionally, children336- * are registered by driver's connect() handler so there can't be a grandchild337- * pending registration together with a child.338 */339static struct serio *serio_get_pending_child(struct serio *parent)340{···446 if (!strncmp(buf, "none", count)) {447 serio_disconnect_port(serio);448 } else if (!strncmp(buf, "reconnect", count)) {449- serio_reconnect_chain(serio);450 } else if (!strncmp(buf, "rescan", count)) {451 serio_disconnect_port(serio);452 serio_find_driver(serio);···513 __module_get(THIS_MODULE);514515 INIT_LIST_HEAD(&serio->node);00516 spin_lock_init(&serio->lock);517 mutex_init(&serio->drv_mutex);518 device_initialize(&serio->dev);···537 */538static void serio_add_port(struct serio *serio)539{0540 int error;541542- if (serio->parent) {543- serio_pause_rx(serio->parent);544- serio->parent->child = serio;545- serio_continue_rx(serio->parent);546 }547548 list_add_tail(&serio->node, &serio_list);···559}560561/*562- * serio_destroy_port() completes deregistration process and removes563 * port from the system564 */565static void serio_destroy_port(struct serio *serio)566{567 struct serio *child;568569- child = serio_get_pending_child(serio);570- if (child) {571 serio_remove_pending_events(child);572 put_device(&child->dev);573 }···576577 if (serio->parent) {578 serio_pause_rx(serio->parent);579- serio->parent->child = NULL;580 serio_continue_rx(serio->parent);581 serio->parent = NULL;582 }···608}609610/*611- * Reconnect serio port and all its children (re-initialize attached devices)0612 */613-static void serio_reconnect_chain(struct serio *serio)614{000615 do {616- if (serio_reconnect_port(serio)) {617- /* Ok, old children are now gone, we are done */618- break;00000000619 }620- serio = serio->child;621- } while (serio);0000000000000000622}623624/*625 * serio_disconnect_port() unbinds a port from its driver. As a side effect626- * all child ports are unbound and destroyed.627 */628static void serio_disconnect_port(struct serio *serio)629{630- struct serio *s, *parent;631632- if (serio->child) {0000000000633 /*634- * Children ports should be disconnected and destroyed635- * first, staring with the leaf one, since we don't want636- * to do recursion637 */638- for (s = serio; s->child; s = s->child)639- /* empty */;640-641- do {642- parent = s->parent;643644 device_release_driver(&s->dev);645 serio_destroy_port(s);646- } while ((s = parent) != serio);00647 }648649 /*650- * Ok, no children left, now disconnect this port651 */652 device_release_driver(&serio->dev);653}···696697void serio_reconnect(struct serio *serio)698{699- serio_queue_event(serio, NULL, SERIO_RECONNECT_CHAIN);700}701EXPORT_SYMBOL(serio_reconnect);702···724EXPORT_SYMBOL(serio_unregister_port);725726/*727- * Safely unregisters child port if one is present.728 */729void serio_unregister_child_port(struct serio *serio)730{00731 mutex_lock(&serio_mutex);732- if (serio->child) {733- serio_disconnect_port(serio->child);734- serio_destroy_port(serio->child);735 }736 mutex_unlock(&serio_mutex);737}
···37#include <linux/slab.h>38#include <linux/kthread.h>39#include <linux/mutex.h>04041MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");42MODULE_DESCRIPTION("Serio abstraction core");···56static void serio_add_port(struct serio *serio);57static int serio_reconnect_port(struct serio *serio);58static void serio_disconnect_port(struct serio *serio);59+static void serio_reconnect_subtree(struct serio *serio);60static void serio_attach_driver(struct serio_driver *drv);6162static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)···152enum serio_event_type {153 SERIO_RESCAN_PORT,154 SERIO_RECONNECT_PORT,155+ SERIO_RECONNECT_SUBTREE,156 SERIO_REGISTER_PORT,157 SERIO_ATTACH_DRIVER,158};···292 serio_find_driver(event->object);293 break;294295+ case SERIO_RECONNECT_SUBTREE:296+ serio_reconnect_subtree(event->object);297 break;298299 case SERIO_ATTACH_DRIVER:···330}331332/*333+ * Locate child serio port (if any) that has not been fully registered yet.334 *335+ * Children are registered by driver's connect() handler so there can't be a336+ * grandchild pending registration together with a child.00337 */338static struct serio *serio_get_pending_child(struct serio *parent)339{···449 if (!strncmp(buf, "none", count)) {450 serio_disconnect_port(serio);451 } else if (!strncmp(buf, "reconnect", count)) {452+ serio_reconnect_subtree(serio);453 } else if (!strncmp(buf, "rescan", count)) {454 serio_disconnect_port(serio);455 serio_find_driver(serio);···516 __module_get(THIS_MODULE);517518 INIT_LIST_HEAD(&serio->node);519+ INIT_LIST_HEAD(&serio->child_node);520+ INIT_LIST_HEAD(&serio->children);521 spin_lock_init(&serio->lock);522 mutex_init(&serio->drv_mutex);523 device_initialize(&serio->dev);···538 */539static void serio_add_port(struct serio *serio)540{541+ struct serio *parent = serio->parent;542 int error;543544+ if (parent) {545+ serio_pause_rx(parent);546+ list_add_tail(&serio->child_node, &parent->children);547+ serio_continue_rx(parent);548 }549550 list_add_tail(&serio->node, &serio_list);···559}560561/*562+ * serio_destroy_port() completes unregistration process and removes563 * port from the system564 */565static void serio_destroy_port(struct serio *serio)566{567 struct serio *child;568569+ while ((child = serio_get_pending_child(serio)) != NULL) {0570 serio_remove_pending_events(child);571 put_device(&child->dev);572 }···577578 if (serio->parent) {579 serio_pause_rx(serio->parent);580+ list_del_init(&serio->child_node);581 serio_continue_rx(serio->parent);582 serio->parent = NULL;583 }···609}610611/*612+ * Reconnect serio port and all its children (re-initialize attached613+ * devices).614 */615+static void serio_reconnect_subtree(struct serio *root)616{617+ struct serio *s = root;618+ int error;619+620 do {621+ error = serio_reconnect_port(s);622+ if (!error) {623+ /*624+ * Reconnect was successful, move on to do the625+ * first child.626+ */627+ if (!list_empty(&s->children)) {628+ s = list_first_entry(&s->children,629+ struct serio, child_node);630+ continue;631+ }632 }633+634+ /*635+ * Either it was a leaf node or reconnect failed and it636+ * became a leaf node. Continue reconnecting starting with637+ * the next sibling of the parent node.638+ */639+ while (s != root) {640+ struct serio *parent = s->parent;641+642+ if (!list_is_last(&s->child_node, &parent->children)) {643+ s = list_entry(s->child_node.next,644+ struct serio, child_node);645+ break;646+ }647+648+ s = parent;649+ }650+ } while (s != root);651}652653/*654 * serio_disconnect_port() unbinds a port from its driver. As a side effect655+ * all children ports are unbound and destroyed.656 */657static void serio_disconnect_port(struct serio *serio)658{659+ struct serio *s = serio;660661+ /*662+ * Children ports should be disconnected and destroyed663+ * first; we travel the tree in depth-first order.664+ */665+ while (!list_empty(&serio->children)) {666+667+ /* Locate a leaf */668+ while (!list_empty(&s->children))669+ s = list_first_entry(&s->children,670+ struct serio, child_node);671+672 /*673+ * Prune this leaf node unless it is the one we674+ * started with.0675 */676+ if (s != serio) {677+ struct serio *parent = s->parent;000678679 device_release_driver(&s->dev);680 serio_destroy_port(s);681+682+ s = parent;683+ }684 }685686 /*687+ * OK, no children left, now disconnect this port.688 */689 device_release_driver(&serio->dev);690}···661662void serio_reconnect(struct serio *serio)663{664+ serio_queue_event(serio, NULL, SERIO_RECONNECT_SUBTREE);665}666EXPORT_SYMBOL(serio_reconnect);667···689EXPORT_SYMBOL(serio_unregister_port);690691/*692+ * Safely unregisters children ports if they are present.693 */694void serio_unregister_child_port(struct serio *serio)695{696+ struct serio *s, *next;697+698 mutex_lock(&serio_mutex);699+ list_for_each_entry_safe(s, next, &serio->children, child_node) {700+ serio_disconnect_port(s);701+ serio_destroy_port(s);702 }703 mutex_unlock(&serio_mutex);704}
+65-16
drivers/input/sparse-keymap.c
···22MODULE_LICENSE("GPL v2");23MODULE_VERSION("0.1");24000000000000000000000000000000025/**26 * sparse_keymap_entry_from_scancode - perform sparse keymap lookup27 * @dev: Input device using sparse keymap···95}96EXPORT_SYMBOL(sparse_keymap_entry_from_keycode);97000000000000000098static int sparse_keymap_getkeycode(struct input_dev *dev,99- unsigned int scancode,100- unsigned int *keycode)101{102 const struct key_entry *key;103104 if (dev->keycode) {105- key = sparse_keymap_entry_from_scancode(dev, scancode);106 if (key && key->type == KE_KEY) {107- *keycode = key->keycode;00000108 return 0;109 }110 }···133}134135static int sparse_keymap_setkeycode(struct input_dev *dev,136- unsigned int scancode,137- unsigned int keycode)138{139 struct key_entry *key;140- int old_keycode;141142 if (dev->keycode) {143- key = sparse_keymap_entry_from_scancode(dev, scancode);144 if (key && key->type == KE_KEY) {145- old_keycode = key->keycode;146- key->keycode = keycode;147- set_bit(keycode, dev->keybit);148- if (!sparse_keymap_entry_from_keycode(dev, old_keycode))149- clear_bit(old_keycode, dev->keybit);150 return 0;151 }152 }···209210 dev->keycode = map;211 dev->keycodemax = map_size;212- dev->getkeycode = sparse_keymap_getkeycode;213- dev->setkeycode = sparse_keymap_setkeycode;214215 return 0;216217 err_out:218 kfree(map);219 return error;220-221}222EXPORT_SYMBOL(sparse_keymap_setup);223
···49 To compile this driver as a module, choose M here: the50 module will be called gtco.510000000000052config TABLET_USB_KBTAB53 tristate "KB Gear JamStudio tablet support (USB)"54 depends on USB_ARCH_HAS_HCD
···49 To compile this driver as a module, choose M here: the50 module will be called gtco.5152+config TABLET_USB_HANWANG53+ tristate "Hanwang Art Master III tablet support (USB)"54+ depends on USB_ARCH_HAS_HCD55+ select USB56+ help57+ Say Y here if you want to use the USB version of the Hanwang Art58+ Master III tablet.59+60+ To compile this driver as a module, choose M here: the61+ module will be called hanwang.62+63config TABLET_USB_KBTAB64 tristate "KB Gear JamStudio tablet support (USB)"65 depends on USB_ARCH_HAS_HCD
···21#define WACOM_PKGLEN_INTUOS 1022#define WACOM_PKGLEN_TPC1FG 523#define WACOM_PKGLEN_TPC2FG 1424+#define WACOM_PKGLEN_BBTOUCH 202526/* device IDs */27#define STYLUS_DEVICE_ID 0x02···37#define WACOM_REPORT_TPC1FG 638#define WACOM_REPORT_TPC2FG 133940+/* device quirks */41+#define WACOM_QUIRK_MULTI_INPUT 0x000142+#define WACOM_QUIRK_BBTOUCH_LOWRES 0x000243+44+/* largest reported tracking id */45+#define MAX_TRACKING_ID 0xfff46+47enum {48 PENPARTNER = 0,49 GRAPHIRE,···44 PTU,45 PL,46 DTU,47+ BAMBOO_PT,48 INTUOS,49 INTUOS3S,50 INTUOS3,···73 int y_phy;74 unsigned char unit;75 unsigned char unitExpo;76+ int x_fuzz;77+ int y_fuzz;78+ int pressure_fuzz;79+ int distance_fuzz;80+ unsigned quirks;81};8283struct wacom_shared {···86 int id[3];87 __u32 serial[2];88 int last_finger;89+ int trk_id;90 struct wacom_features features;91 struct wacom_shared *shared;92 struct input_dev *input;
+34
drivers/input/touchscreen/Kconfig
···98 To compile this driver as a module, choose M here: the99 module will be called h3600_ts_input.100000000000000101config TOUCHSCREEN_CY8CTMG110102 tristate "cy8ctmg110 touchscreen"103 depends on I2C···226 To compile this driver as a module, choose M here: the227 module will be called wacom_w8001.2280000000000229config TOUCHSCREEN_MCS5000230 tristate "MELFAS MCS-5000 touchscreen"231 depends on I2C···271272 To compile this driver as a module, choose M here: the273 module will be called inexio.000000000000274275config TOUCHSCREEN_MK712276 tristate "ICS MicroClock MK712 touchscreen"
···98 To compile this driver as a module, choose M here: the99 module will be called h3600_ts_input.100101+config TOUCHSCREEN_BU21013102+ tristate "BU21013 based touch panel controllers"103+ depends on I2C104+ help105+ Say Y here if you have a bu21013 touchscreen connected to106+ your system.107+108+ If unsure, say N.109+110+ To compile this driver as a module, choose M here: the111+ module will be called bu21013_ts.112+113config TOUCHSCREEN_CY8CTMG110114 tristate "cy8ctmg110 touchscreen"115 depends on I2C···214 To compile this driver as a module, choose M here: the215 module will be called wacom_w8001.216217+config TOUCHSCREEN_LPC32XX218+ tristate "LPC32XX touchscreen controller"219+ depends on ARCH_LPC32XX220+ help221+ Say Y here if you have a LPC32XX device and want222+ to support the built-in touchscreen.223+224+ To compile this driver as a module, choose M here: the225+ module will be called lpc32xx_ts.226+227config TOUCHSCREEN_MCS5000228 tristate "MELFAS MCS-5000 touchscreen"229 depends on I2C···249250 To compile this driver as a module, choose M here: the251 module will be called inexio.252+253+config TOUCHSCREEN_INTEL_MID254+ tristate "Intel MID platform resistive touchscreen"255+ depends on INTEL_SCU_IPC256+ help257+ Say Y here if you have a Intel MID based touchscreen in258+ your system.259+260+ If unsure, say N.261+262+ To compile this driver as a module, choose M here: the263+ module will be called intel_mid_touch.264265config TOUCHSCREEN_MK712266 tristate "ICS MicroClock MK712 touchscreen"
···2 * Wacom W8001 penabled serial touchscreen driver3 *4 * Copyright (c) 2008 Jaya Kumar05 *6 * This file is subject to the terms and conditions of the GNU General Public7 * License. See the file COPYING in the main directory of this archive for···31#define W8001_LEAD_BYTE 0x8032#define W8001_TAB_MASK 0x4033#define W8001_TAB_BYTE 0x400003435#define W8001_QUERY_PACKET 0x203637#define W8001_CMD_START '1'38#define W8001_CMD_QUERY '*'00000000003940struct w8001_coord {41 u8 rdy;···60 u16 pen_pressure;61 u8 tilt_x;62 u8 tilt_y;00000000063};6465/*···85 unsigned char response[W8001_MAX_LENGTH];86 unsigned char data[W8001_MAX_LENGTH];87 char phys[32];00088};8990static void parse_data(u8 *data, struct w8001_coord *coord)···114 coord->tilt_y = data[8] & 0x7F;115}1160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000117static irqreturn_t w8001_interrupt(struct serio *serio,118 unsigned char data, unsigned int flags)119{120 struct w8001 *w8001 = serio_get_drvdata(serio);121- struct input_dev *dev = w8001->dev;122 struct w8001_coord coord;123 unsigned char tmp;124···218 }219 break;220221- case 8:00000000222 tmp = w8001->data[0] & W8001_TAB_MASK;223 if (unlikely(tmp == W8001_TAB_BYTE))224 break;2250000226 w8001->idx = 0;227 parse_data(w8001->data, &coord);228- input_report_abs(dev, ABS_X, coord.x);229- input_report_abs(dev, ABS_Y, coord.y);230- input_report_abs(dev, ABS_PRESSURE, coord.pen_pressure);231- input_report_key(dev, BTN_TOUCH, coord.tsw);232- input_sync(dev);233 break;234235- case 10:00000236 w8001->idx = 0;237 memcpy(w8001->response, w8001->data, W8001_MAX_LENGTH);238 w8001->response_type = W8001_QUERY_PACKET;239 complete(&w8001->cmd_done);000000240 break;241 }242···299 input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0);300 input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0);30100000000000000000000000000000000302 return w8001_command(w8001, W8001_CMD_START, false);303}304···372 w8001->serio = serio;373 w8001->id = serio->id.id;374 w8001->dev = input_dev;0375 init_completion(&w8001->cmd_done);376 snprintf(w8001->phys, sizeof(w8001->phys), "%s/input0", serio->phys);377···386387 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);388 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);0000389390 serio_set_drvdata(serio, w8001);391 err = serio_open(serio, drv);
···2 * Wacom W8001 penabled serial touchscreen driver3 *4 * Copyright (c) 2008 Jaya Kumar5+ * Copyright (c) 2010 Red Hat, Inc.6 *7 * This file is subject to the terms and conditions of the GNU General Public8 * License. See the file COPYING in the main directory of this archive for···30#define W8001_LEAD_BYTE 0x8031#define W8001_TAB_MASK 0x4032#define W8001_TAB_BYTE 0x4033+/* set in first byte of touch data packets */34+#define W8001_TOUCH_MASK (0x10 | W8001_LEAD_MASK)35+#define W8001_TOUCH_BYTE (0x10 | W8001_LEAD_BYTE)3637#define W8001_QUERY_PACKET 0x203839#define W8001_CMD_START '1'40#define W8001_CMD_QUERY '*'41+#define W8001_CMD_TOUCHQUERY '%'42+43+/* length of data packets in bytes, depends on device. */44+#define W8001_PKTLEN_TOUCH93 545+#define W8001_PKTLEN_TOUCH9A 746+#define W8001_PKTLEN_TPCPEN 947+#define W8001_PKTLEN_TPCCTL 11 /* control packet */48+#define W8001_PKTLEN_TOUCH2FG 1349+50+#define MAX_TRACKING_ID 0xFF /* arbitrarily chosen */5152struct w8001_coord {53 u8 rdy;···46 u16 pen_pressure;47 u8 tilt_x;48 u8 tilt_y;49+};50+51+/* touch query reply packet */52+struct w8001_touch_query {53+ u8 panel_res;54+ u8 capacity_res;55+ u8 sensor_id;56+ u16 x;57+ u16 y;58};5960/*···62 unsigned char response[W8001_MAX_LENGTH];63 unsigned char data[W8001_MAX_LENGTH];64 char phys[32];65+ int type;66+ unsigned int pktlen;67+ int trkid[2];68};6970static void parse_data(u8 *data, struct w8001_coord *coord)···88 coord->tilt_y = data[8] & 0x7F;89}9091+static void parse_touch(struct w8001 *w8001)92+{93+ static int trkid;94+ struct input_dev *dev = w8001->dev;95+ unsigned char *data = w8001->data;96+ int i;97+98+ for (i = 0; i < 2; i++) {99+ input_mt_slot(dev, i);100+101+ if (data[0] & (1 << i)) {102+ int x = (data[6 * i + 1] << 7) | (data[6 * i + 2]);103+ int y = (data[6 * i + 3] << 7) | (data[6 * i + 4]);104+ /* data[5,6] and [11,12] is finger capacity */105+106+ input_report_abs(dev, ABS_MT_POSITION_X, x);107+ input_report_abs(dev, ABS_MT_POSITION_Y, y);108+ input_report_abs(dev, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);109+ if (w8001->trkid[i] < 0)110+ w8001->trkid[i] = trkid++ & MAX_TRACKING_ID;111+ } else {112+ w8001->trkid[i] = -1;113+ }114+ input_report_abs(dev, ABS_MT_TRACKING_ID, w8001->trkid[i]);115+ }116+117+ input_sync(dev);118+}119+120+static void parse_touchquery(u8 *data, struct w8001_touch_query *query)121+{122+ memset(query, 0, sizeof(*query));123+124+ query->panel_res = data[1];125+ query->sensor_id = data[2] & 0x7;126+ query->capacity_res = data[7];127+128+ query->x = data[3] << 9;129+ query->x |= data[4] << 2;130+ query->x |= (data[2] >> 5) & 0x3;131+132+ query->y = data[5] << 9;133+ query->y |= data[6] << 2;134+ query->y |= (data[2] >> 3) & 0x3;135+}136+137+static void report_pen_events(struct w8001 *w8001, struct w8001_coord *coord)138+{139+ struct input_dev *dev = w8001->dev;140+141+ /*142+ * We have 1 bit for proximity (rdy) and 3 bits for tip, side,143+ * side2/eraser. If rdy && f2 are set, this can be either pen + side2,144+ * or eraser. assume145+ * - if dev is already in proximity and f2 is toggled → pen + side2146+ * - if dev comes into proximity with f2 set → eraser147+ * If f2 disappears after assuming eraser, fake proximity out for148+ * eraser and in for pen.149+ */150+151+ if (!w8001->type) {152+ w8001->type = coord->f2 ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;153+ } else if (w8001->type == BTN_TOOL_RUBBER) {154+ if (!coord->f2) {155+ input_report_abs(dev, ABS_PRESSURE, 0);156+ input_report_key(dev, BTN_TOUCH, 0);157+ input_report_key(dev, BTN_STYLUS, 0);158+ input_report_key(dev, BTN_STYLUS2, 0);159+ input_report_key(dev, BTN_TOOL_RUBBER, 0);160+ input_sync(dev);161+ w8001->type = BTN_TOOL_PEN;162+ }163+ } else {164+ input_report_key(dev, BTN_STYLUS2, coord->f2);165+ }166+167+ input_report_abs(dev, ABS_X, coord->x);168+ input_report_abs(dev, ABS_Y, coord->y);169+ input_report_abs(dev, ABS_PRESSURE, coord->pen_pressure);170+ input_report_key(dev, BTN_TOUCH, coord->tsw);171+ input_report_key(dev, BTN_STYLUS, coord->f1);172+ input_report_key(dev, w8001->type, coord->rdy);173+ input_sync(dev);174+175+ if (!coord->rdy)176+ w8001->type = 0;177+}178+179static irqreturn_t w8001_interrupt(struct serio *serio,180 unsigned char data, unsigned int flags)181{182 struct w8001 *w8001 = serio_get_drvdata(serio);0183 struct w8001_coord coord;184 unsigned char tmp;185···105 }106 break;107108+ case W8001_PKTLEN_TOUCH93 - 1:109+ case W8001_PKTLEN_TOUCH9A - 1:110+ /* ignore one-finger touch packet. */111+ if (w8001->pktlen == w8001->idx)112+ w8001->idx = 0;113+ break;114+115+ /* Pen coordinates packet */116+ case W8001_PKTLEN_TPCPEN - 1:117 tmp = w8001->data[0] & W8001_TAB_MASK;118 if (unlikely(tmp == W8001_TAB_BYTE))119 break;120121+ tmp = (w8001->data[0] & W8001_TOUCH_BYTE);122+ if (tmp == W8001_TOUCH_BYTE)123+ break;124+125 w8001->idx = 0;126 parse_data(w8001->data, &coord);127+ report_pen_events(w8001, &coord);0000128 break;129130+ /* control packet */131+ case W8001_PKTLEN_TPCCTL - 1:132+ tmp = (w8001->data[0] & W8001_TOUCH_MASK);133+ if (tmp == W8001_TOUCH_BYTE)134+ break;135+136 w8001->idx = 0;137 memcpy(w8001->response, w8001->data, W8001_MAX_LENGTH);138 w8001->response_type = W8001_QUERY_PACKET;139 complete(&w8001->cmd_done);140+ break;141+142+ /* 2 finger touch packet */143+ case W8001_PKTLEN_TOUCH2FG - 1:144+ w8001->idx = 0;145+ parse_touch(w8001);146 break;147 }148···167 input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0);168 input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0);169170+ error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);171+ if (!error) {172+ struct w8001_touch_query touch;173+174+ parse_touchquery(w8001->response, &touch);175+176+ switch (touch.sensor_id) {177+ case 0:178+ case 2:179+ w8001->pktlen = W8001_PKTLEN_TOUCH93;180+ break;181+ case 1:182+ case 3:183+ case 4:184+ w8001->pktlen = W8001_PKTLEN_TOUCH9A;185+ break;186+ case 5:187+ w8001->pktlen = W8001_PKTLEN_TOUCH2FG;188+189+ input_mt_create_slots(dev, 2);190+ input_set_abs_params(dev, ABS_MT_TRACKING_ID,191+ 0, MAX_TRACKING_ID, 0, 0);192+ input_set_abs_params(dev, ABS_MT_POSITION_X,193+ 0, touch.x, 0, 0);194+ input_set_abs_params(dev, ABS_MT_POSITION_Y,195+ 0, touch.y, 0, 0);196+ input_set_abs_params(dev, ABS_MT_TOOL_TYPE,197+ 0, 0, 0, 0);198+ break;199+ }200+ }201+202 return w8001_command(w8001, W8001_CMD_START, false);203}204···208 w8001->serio = serio;209 w8001->id = serio->id.id;210 w8001->dev = input_dev;211+ w8001->trkid[0] = w8001->trkid[1] = -1;212 init_completion(&w8001->cmd_done);213 snprintf(w8001->phys, sizeof(w8001->phys), "%s/input0", serio->phys);214···221222 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);223 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);224+ input_dev->keybit[BIT_WORD(BTN_TOOL_PEN)] |= BIT_MASK(BTN_TOOL_PEN);225+ input_dev->keybit[BIT_WORD(BTN_TOOL_RUBBER)] |= BIT_MASK(BTN_TOOL_RUBBER);226+ input_dev->keybit[BIT_WORD(BTN_STYLUS)] |= BIT_MASK(BTN_STYLUS);227+ input_dev->keybit[BIT_WORD(BTN_STYLUS2)] |= BIT_MASK(BTN_STYLUS2);228229 serio_set_drvdata(serio, w8001);230 err = serio_open(serio, drv);
+14-4
drivers/input/touchscreen/wm97xx-core.c
···125{126 int power_adc = 0, auxval;127 u16 power = 0;00128129 /* get codec */130 mutex_lock(&wm->codec_mutex);···145146 /* Turn polling mode on to read AUX ADC */147 wm->pen_probably_down = 1;148- wm->codec->poll_sample(wm, adcsel, &auxval);00149150 if (power_adc)151 wm97xx_reg_write(wm, AC97_EXTENDED_MID, power | 0x8000);···156157 wm->pen_probably_down = 0;1580000000159 mutex_unlock(&wm->codec_mutex);160- return auxval & 0xfff;161}162EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc);163···695 touch_reg_err:696 platform_device_put(wm->touch_dev);697 touch_err:698- platform_device_unregister(wm->battery_dev);699- wm->battery_dev = NULL;700 batt_reg_err:701 platform_device_put(wm->battery_dev);702 batt_err:
···125{126 int power_adc = 0, auxval;127 u16 power = 0;128+ int rc = 0;129+ int timeout = 0;130131 /* get codec */132 mutex_lock(&wm->codec_mutex);···143144 /* Turn polling mode on to read AUX ADC */145 wm->pen_probably_down = 1;146+147+ while (rc != RC_VALID && timeout++ < 5)148+ rc = wm->codec->poll_sample(wm, adcsel, &auxval);149150 if (power_adc)151 wm97xx_reg_write(wm, AC97_EXTENDED_MID, power | 0x8000);···152153 wm->pen_probably_down = 0;154155+ if (timeout >= 5) {156+ dev_err(wm->dev,157+ "timeout reading auxadc %d, disabling digitiser\n",158+ adcsel);159+ wm->codec->dig_enable(wm, false);160+ }161+162 mutex_unlock(&wm->codec_mutex);163+ return (rc == RC_VALID ? auxval & 0xfff : -EBUSY);164}165EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc);166···684 touch_reg_err:685 platform_device_put(wm->touch_dev);686 touch_err:687+ platform_device_del(wm->battery_dev);0688 batt_reg_err:689 platform_device_put(wm->battery_dev);690 batt_err:
+263-132
drivers/media/IR/ir-keytable.c
···25#define IR_KEYPRESS_TIMEOUT 2502627/**0000000000000000000000000000000000000000028 * ir_resize_table() - resizes a scancode table if necessary29 * @rc_tab: the ir_scancode_table to resize030 * @return: zero on success or a negative error code31 *32 * This routine will shrink the ir_scancode_table if it has lots of33 * unused entries and grow it if it is full.34 */35-static int ir_resize_table(struct ir_scancode_table *rc_tab)36{37 unsigned int oldalloc = rc_tab->alloc;38 unsigned int newalloc = oldalloc;···99 if (newalloc == oldalloc)100 return 0;101102- newscan = kmalloc(newalloc, GFP_ATOMIC);103 if (!newscan) {104 IR_dprintk(1, "Failed to kmalloc %u bytes\n", newalloc);105 return -ENOMEM;···114}115116/**117- * ir_do_setkeycode() - internal function to set a keycode in the118- * scancode->keycode table119 * @dev: the struct input_dev device descriptor120- * @rc_tab: the struct ir_scancode_table to set the keycode in121- * @scancode: the scancode for the ir command122- * @keycode: the keycode for the ir command123- * @resize: whether the keytable may be shrunk124- * @return: -EINVAL if the keycode could not be inserted, otherwise zero.125 *126- * This routine is used internally to manipulate the scancode->keycode table.127- * The caller has to hold @rc_tab->lock.128 */129-static int ir_do_setkeycode(struct input_dev *dev,130- struct ir_scancode_table *rc_tab,131- unsigned scancode, unsigned keycode,132- bool resize)00000000000000000000000000000000000000000000000000000000133{134 unsigned int i;135- int old_keycode = KEY_RESERVED;136- struct ir_input_dev *ir_dev = input_get_drvdata(dev);137138 /*139 * Unfortunately, some hardware-based IR decoders don't provide···194 * the provided IR with another one, it is needed to allow loading195 * IR tables from other remotes. So,196 */197- if (ir_dev->props && ir_dev->props->scanmask) {198 scancode &= ir_dev->props->scanmask;199- }200201 /* First check if we already have a mapping for this ir command */202 for (i = 0; i < rc_tab->len; i++) {000203 /* Keytable is sorted from lowest to highest scancode */204- if (rc_tab->scan[i].scancode > scancode)205 break;206- else if (rc_tab->scan[i].scancode < scancode)207- continue;208-209- old_keycode = rc_tab->scan[i].keycode;210- rc_tab->scan[i].keycode = keycode;211-212- /* Did the user wish to remove the mapping? */213- if (keycode == KEY_RESERVED || keycode == KEY_UNKNOWN) {214- IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",215- i, scancode);216- rc_tab->len--;217- memmove(&rc_tab->scan[i], &rc_tab->scan[i + 1],218- (rc_tab->len - i) * sizeof(struct ir_scancode));219- }220-221- /* Possibly shrink the keytable, failure is not a problem */222- ir_resize_table(rc_tab);223- break;224 }225226- if (old_keycode == KEY_RESERVED && keycode != KEY_RESERVED) {227- /* No previous mapping found, we might need to grow the table */228- if (resize && ir_resize_table(rc_tab))229- return -ENOMEM;0230231- IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n",232- i, scancode, keycode);233-234- /* i is the proper index to insert our new keycode */235 memmove(&rc_tab->scan[i + 1], &rc_tab->scan[i],236 (rc_tab->len - i) * sizeof(struct ir_scancode));237- rc_tab->scan[i].scancode = scancode;238- rc_tab->scan[i].keycode = keycode;239- rc_tab->len++;240- set_bit(keycode, dev->keybit);241- } else {242- IR_dprintk(1, "#%d: Replacing scan 0x%04x with key 0x%04x\n",243- i, scancode, keycode);244- /* A previous mapping was updated... */245- clear_bit(old_keycode, dev->keybit);246- /* ...but another scancode might use the same keycode */247- for (i = 0; i < rc_tab->len; i++) {248- if (rc_tab->scan[i].keycode == old_keycode) {249- set_bit(old_keycode, dev->keybit);250- break;251- }252- }253- }254255- return 0;256}257258/**···234 * This routine is used to handle evdev EVIOCSKEY ioctl.235 */236static int ir_setkeycode(struct input_dev *dev,237- unsigned int scancode, unsigned int keycode)0238{239- int rc;240- unsigned long flags;241 struct ir_input_dev *ir_dev = input_get_drvdata(dev);242 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;0000243244 spin_lock_irqsave(&rc_tab->lock, flags);245- rc = ir_do_setkeycode(dev, rc_tab, scancode, keycode, true);000000000000000000000246 spin_unlock_irqrestore(&rc_tab->lock, flags);247- return rc;248}249250/**···276 * @dev: the struct input_dev device descriptor277 * @to: the struct ir_scancode_table to copy entries to278 * @from: the struct ir_scancode_table to copy entries from279- * @return: -EINVAL if all keycodes could not be inserted, otherwise zero.280 *281 * This routine is used to handle table initialization.282 */283-static int ir_setkeytable(struct input_dev *dev,284- struct ir_scancode_table *to,285 const struct ir_scancode_table *from)286{287- struct ir_input_dev *ir_dev = input_get_drvdata(dev);288 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;289- unsigned long flags;290- unsigned int i;291- int rc = 0;292293- spin_lock_irqsave(&rc_tab->lock, flags);0000000294 for (i = 0; i < from->size; i++) {295- rc = ir_do_setkeycode(dev, to, from->scan[i].scancode,296- from->scan[i].keycode, false);297- if (rc)0298 break;0000299 }300- spin_unlock_irqrestore(&rc_tab->lock, flags);000301 return rc;00000000000000000000000000000302}303304/**···352 * This routine is used to handle evdev EVIOCGKEY ioctl.353 */354static int ir_getkeycode(struct input_dev *dev,355- unsigned int scancode, unsigned int *keycode)356{357- int start, end, mid;358- unsigned long flags;359- int key = KEY_RESERVED;360 struct ir_input_dev *ir_dev = input_get_drvdata(dev);361 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;00000362363 spin_lock_irqsave(&rc_tab->lock, flags);364- start = 0;365- end = rc_tab->len - 1;366- while (start <= end) {367- mid = (start + end) / 2;368- if (rc_tab->scan[mid].scancode < scancode)369- start = mid + 1;370- else if (rc_tab->scan[mid].scancode > scancode)371- end = mid - 1;372- else {373- key = rc_tab->scan[mid].keycode;374- break;375- }376 }00000000000000000377 spin_unlock_irqrestore(&rc_tab->lock, flags);378-379- if (key == KEY_RESERVED)380- IR_dprintk(1, "unknown key for scancode 0x%04x\n",381- scancode);382-383- *keycode = key;384- return 0;385}386387/**···406 */407u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)408{409- int keycode;0000410411- ir_getkeycode(dev, scancode, &keycode);0000000412 if (keycode != KEY_RESERVED)413 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",414 dev->name, scancode, keycode);0415 return keycode;416}417EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);···603 goto out_dev;604 }605606- input_dev->getkeycode = ir_getkeycode;607- input_dev->setkeycode = ir_setkeycode;608 input_set_drvdata(input_dev, ir_dev);609 ir_dev->input_dev = input_dev;610···612 spin_lock_init(&ir_dev->keylock);613 setup_timer(&ir_dev->timer_keyup, ir_timer_keyup, (unsigned long)ir_dev);614615- ir_dev->rc_tab.name = rc_tab->name;616- ir_dev->rc_tab.ir_type = rc_tab->ir_type;617- ir_dev->rc_tab.alloc = roundup_pow_of_two(rc_tab->size *618- sizeof(struct ir_scancode));619- ir_dev->rc_tab.scan = kmalloc(ir_dev->rc_tab.alloc, GFP_KERNEL);620- ir_dev->rc_tab.size = ir_dev->rc_tab.alloc / sizeof(struct ir_scancode);621 if (props) {622 ir_dev->props = props;623 if (props->open)···620 input_dev->close = ir_close;621 }622623- if (!ir_dev->rc_tab.scan) {624- rc = -ENOMEM;625- goto out_name;626- }627-628- IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",629- ir_dev->rc_tab.size, ir_dev->rc_tab.alloc);630-631 set_bit(EV_KEY, input_dev->evbit);632 set_bit(EV_REP, input_dev->evbit);633 set_bit(EV_MSC, input_dev->evbit);634 set_bit(MSC_SCAN, input_dev->mscbit);635636- if (ir_setkeytable(input_dev, &ir_dev->rc_tab, rc_tab)) {637- rc = -ENOMEM;638- goto out_table;639- }640641 rc = ir_register_class(input_dev);642 if (rc < 0)···650out_event:651 ir_unregister_class(input_dev);652out_table:653- kfree(ir_dev->rc_tab.scan);654out_name:655 kfree(ir_dev->driver_name);656out_dev:···668void ir_input_unregister(struct input_dev *input_dev)669{670 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);671- struct ir_scancode_table *rc_tab;672673 if (!ir_dev)674 return;···679 if (ir_dev->props->driver_type == RC_DRIVER_IR_RAW)680 ir_raw_event_unregister(input_dev);681682- rc_tab = &ir_dev->rc_tab;683- rc_tab->size = 0;684- kfree(rc_tab->scan);685- rc_tab->scan = NULL;686687 ir_unregister_class(input_dev);688
···25#define IR_KEYPRESS_TIMEOUT 2502627/**28+ * ir_create_table() - initializes a scancode table29+ * @rc_tab: the ir_scancode_table to initialize30+ * @name: name to assign to the table31+ * @ir_type: ir type to assign to the new table32+ * @size: initial size of the table33+ * @return: zero on success or a negative error code34+ *35+ * This routine will initialize the ir_scancode_table and will allocate36+ * memory to hold at least the specified number elements.37+ */38+static int ir_create_table(struct ir_scancode_table *rc_tab,39+ const char *name, u64 ir_type, size_t size)40+{41+ rc_tab->name = name;42+ rc_tab->ir_type = ir_type;43+ rc_tab->alloc = roundup_pow_of_two(size * sizeof(struct ir_scancode));44+ rc_tab->size = rc_tab->alloc / sizeof(struct ir_scancode);45+ rc_tab->scan = kmalloc(rc_tab->alloc, GFP_KERNEL);46+ if (!rc_tab->scan)47+ return -ENOMEM;48+49+ IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",50+ rc_tab->size, rc_tab->alloc);51+ return 0;52+}53+54+/**55+ * ir_free_table() - frees memory allocated by a scancode table56+ * @rc_tab: the table whose mappings need to be freed57+ *58+ * This routine will free memory alloctaed for key mappings used by given59+ * scancode table.60+ */61+static void ir_free_table(struct ir_scancode_table *rc_tab)62+{63+ rc_tab->size = 0;64+ kfree(rc_tab->scan);65+ rc_tab->scan = NULL;66+}67+68+/**69 * ir_resize_table() - resizes a scancode table if necessary70 * @rc_tab: the ir_scancode_table to resize71+ * @gfp_flags: gfp flags to use when allocating memory72 * @return: zero on success or a negative error code73 *74 * This routine will shrink the ir_scancode_table if it has lots of75 * unused entries and grow it if it is full.76 */77+static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags)78{79 unsigned int oldalloc = rc_tab->alloc;80 unsigned int newalloc = oldalloc;···57 if (newalloc == oldalloc)58 return 0;5960+ newscan = kmalloc(newalloc, gfp_flags);61 if (!newscan) {62 IR_dprintk(1, "Failed to kmalloc %u bytes\n", newalloc);63 return -ENOMEM;···72}7374/**75+ * ir_update_mapping() - set a keycode in the scancode->keycode table076 * @dev: the struct input_dev device descriptor77+ * @rc_tab: scancode table to be adjusted78+ * @index: index of the mapping that needs to be updated79+ * @keycode: the desired keycode80+ * @return: previous keycode assigned to the mapping081 *82+ * This routine is used to update scancode->keycopde mapping at given83+ * position.84 */85+static unsigned int ir_update_mapping(struct input_dev *dev,86+ struct ir_scancode_table *rc_tab,87+ unsigned int index,88+ unsigned int new_keycode)89+{90+ int old_keycode = rc_tab->scan[index].keycode;91+ int i;92+93+ /* Did the user wish to remove the mapping? */94+ if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) {95+ IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",96+ index, rc_tab->scan[index].scancode);97+ rc_tab->len--;98+ memmove(&rc_tab->scan[index], &rc_tab->scan[index+ 1],99+ (rc_tab->len - index) * sizeof(struct ir_scancode));100+ } else {101+ IR_dprintk(1, "#%d: %s scan 0x%04x with key 0x%04x\n",102+ index,103+ old_keycode == KEY_RESERVED ? "New" : "Replacing",104+ rc_tab->scan[index].scancode, new_keycode);105+ rc_tab->scan[index].keycode = new_keycode;106+ __set_bit(new_keycode, dev->keybit);107+ }108+109+ if (old_keycode != KEY_RESERVED) {110+ /* A previous mapping was updated... */111+ __clear_bit(old_keycode, dev->keybit);112+ /* ... but another scancode might use the same keycode */113+ for (i = 0; i < rc_tab->len; i++) {114+ if (rc_tab->scan[i].keycode == old_keycode) {115+ __set_bit(old_keycode, dev->keybit);116+ break;117+ }118+ }119+120+ /* Possibly shrink the keytable, failure is not a problem */121+ ir_resize_table(rc_tab, GFP_ATOMIC);122+ }123+124+ return old_keycode;125+}126+127+/**128+ * ir_locate_scancode() - set a keycode in the scancode->keycode table129+ * @ir_dev: the struct ir_input_dev device descriptor130+ * @rc_tab: scancode table to be searched131+ * @scancode: the desired scancode132+ * @resize: controls whether we allowed to resize the table to133+ * accomodate not yet present scancodes134+ * @return: index of the mapping containing scancode in question135+ * or -1U in case of failure.136+ *137+ * This routine is used to locate given scancode in ir_scancode_table.138+ * If scancode is not yet present the routine will allocate a new slot139+ * for it.140+ */141+static unsigned int ir_establish_scancode(struct ir_input_dev *ir_dev,142+ struct ir_scancode_table *rc_tab,143+ unsigned int scancode,144+ bool resize)145{146 unsigned int i;00147148 /*149 * Unfortunately, some hardware-based IR decoders don't provide···100 * the provided IR with another one, it is needed to allow loading101 * IR tables from other remotes. So,102 */103+ if (ir_dev->props && ir_dev->props->scanmask)104 scancode &= ir_dev->props->scanmask;0105106 /* First check if we already have a mapping for this ir command */107 for (i = 0; i < rc_tab->len; i++) {108+ if (rc_tab->scan[i].scancode == scancode)109+ return i;110+111 /* Keytable is sorted from lowest to highest scancode */112+ if (rc_tab->scan[i].scancode >= scancode)113 break;000000000000000000114 }115116+ /* No previous mapping found, we might need to grow the table */117+ if (rc_tab->size == rc_tab->len) {118+ if (!resize || ir_resize_table(rc_tab, GFP_ATOMIC))119+ return -1U;120+ }121122+ /* i is the proper index to insert our new keycode */123+ if (i < rc_tab->len)00124 memmove(&rc_tab->scan[i + 1], &rc_tab->scan[i],125 (rc_tab->len - i) * sizeof(struct ir_scancode));126+ rc_tab->scan[i].scancode = scancode;127+ rc_tab->scan[i].keycode = KEY_RESERVED;128+ rc_tab->len++;00000000000000129130+ return i;131}132133/**···171 * This routine is used to handle evdev EVIOCSKEY ioctl.172 */173static int ir_setkeycode(struct input_dev *dev,174+ const struct input_keymap_entry *ke,175+ unsigned int *old_keycode)176{00177 struct ir_input_dev *ir_dev = input_get_drvdata(dev);178 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;179+ unsigned int index;180+ unsigned int scancode;181+ int retval;182+ unsigned long flags;183184 spin_lock_irqsave(&rc_tab->lock, flags);185+186+ if (ke->flags & INPUT_KEYMAP_BY_INDEX) {187+ index = ke->index;188+ if (index >= rc_tab->len) {189+ retval = -EINVAL;190+ goto out;191+ }192+ } else {193+ retval = input_scancode_to_scalar(ke, &scancode);194+ if (retval)195+ goto out;196+197+ index = ir_establish_scancode(ir_dev, rc_tab, scancode, true);198+ if (index >= rc_tab->len) {199+ retval = -ENOMEM;200+ goto out;201+ }202+ }203+204+ *old_keycode = ir_update_mapping(dev, rc_tab, index, ke->keycode);205+206+out:207 spin_unlock_irqrestore(&rc_tab->lock, flags);208+ return retval;209}210211/**···189 * @dev: the struct input_dev device descriptor190 * @to: the struct ir_scancode_table to copy entries to191 * @from: the struct ir_scancode_table to copy entries from192+ * @return: -ENOMEM if all keycodes could not be inserted, otherwise zero.193 *194 * This routine is used to handle table initialization.195 */196+static int ir_setkeytable(struct ir_input_dev *ir_dev,0197 const struct ir_scancode_table *from)198{0199 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;200+ unsigned int i, index;201+ int rc;0202203+ rc = ir_create_table(&ir_dev->rc_tab,204+ from->name, from->ir_type, from->size);205+ if (rc)206+ return rc;207+208+ IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",209+ rc_tab->size, rc_tab->alloc);210+211 for (i = 0; i < from->size; i++) {212+ index = ir_establish_scancode(ir_dev, rc_tab,213+ from->scan[i].scancode, false);214+ if (index >= rc_tab->len) {215+ rc = -ENOMEM;216 break;217+ }218+219+ ir_update_mapping(ir_dev->input_dev, rc_tab, index,220+ from->scan[i].keycode);221 }222+223+ if (rc)224+ ir_free_table(rc_tab);225+226 return rc;227+}228+229+/**230+ * ir_lookup_by_scancode() - locate mapping by scancode231+ * @rc_tab: the &struct ir_scancode_table to search232+ * @scancode: scancode to look for in the table233+ * @return: index in the table, -1U if not found234+ *235+ * This routine performs binary search in RC keykeymap table for236+ * given scancode.237+ */238+static unsigned int ir_lookup_by_scancode(const struct ir_scancode_table *rc_tab,239+ unsigned int scancode)240+{241+ unsigned int start = 0;242+ unsigned int end = rc_tab->len - 1;243+ unsigned int mid;244+245+ while (start <= end) {246+ mid = (start + end) / 2;247+ if (rc_tab->scan[mid].scancode < scancode)248+ start = mid + 1;249+ else if (rc_tab->scan[mid].scancode > scancode)250+ end = mid - 1;251+ else252+ return mid;253+ }254+255+ return -1U;256}257258/**···224 * This routine is used to handle evdev EVIOCGKEY ioctl.225 */226static int ir_getkeycode(struct input_dev *dev,227+ struct input_keymap_entry *ke)228{000229 struct ir_input_dev *ir_dev = input_get_drvdata(dev);230 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;231+ struct ir_scancode *entry;232+ unsigned long flags;233+ unsigned int index;234+ unsigned int scancode;235+ int retval;236237 spin_lock_irqsave(&rc_tab->lock, flags);238+239+ if (ke->flags & INPUT_KEYMAP_BY_INDEX) {240+ index = ke->index;241+ } else {242+ retval = input_scancode_to_scalar(ke, &scancode);243+ if (retval)244+ goto out;245+246+ index = ir_lookup_by_scancode(rc_tab, scancode);000247 }248+249+ if (index >= rc_tab->len) {250+ if (!(ke->flags & INPUT_KEYMAP_BY_INDEX))251+ IR_dprintk(1, "unknown key for scancode 0x%04x\n",252+ scancode);253+ retval = -EINVAL;254+ goto out;255+ }256+257+ entry = &rc_tab->scan[index];258+259+ ke->index = index;260+ ke->keycode = entry->keycode;261+ ke->len = sizeof(entry->scancode);262+ memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode));263+264+out:265 spin_unlock_irqrestore(&rc_tab->lock, flags);266+ return retval;000000267}268269/**···268 */269u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)270{271+ struct ir_input_dev *ir_dev = input_get_drvdata(dev);272+ struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;273+ unsigned int keycode;274+ unsigned int index;275+ unsigned long flags;276277+ spin_lock_irqsave(&rc_tab->lock, flags);278+279+ index = ir_lookup_by_scancode(rc_tab, scancode);280+ keycode = index < rc_tab->len ?281+ rc_tab->scan[index].keycode : KEY_RESERVED;282+283+ spin_unlock_irqrestore(&rc_tab->lock, flags);284+285 if (keycode != KEY_RESERVED)286 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",287 dev->name, scancode, keycode);288+289 return keycode;290}291EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);···453 goto out_dev;454 }455456+ input_dev->getkeycode_new = ir_getkeycode;457+ input_dev->setkeycode_new = ir_setkeycode;458 input_set_drvdata(input_dev, ir_dev);459 ir_dev->input_dev = input_dev;460···462 spin_lock_init(&ir_dev->keylock);463 setup_timer(&ir_dev->timer_keyup, ir_timer_keyup, (unsigned long)ir_dev);464000000465 if (props) {466 ir_dev->props = props;467 if (props->open)···476 input_dev->close = ir_close;477 }47800000000479 set_bit(EV_KEY, input_dev->evbit);480 set_bit(EV_REP, input_dev->evbit);481 set_bit(EV_MSC, input_dev->evbit);482 set_bit(MSC_SCAN, input_dev->mscbit);483484+ rc = ir_setkeytable(ir_dev, rc_tab);485+ if (rc)486+ goto out_name;0487488 rc = ir_register_class(input_dev);489 if (rc < 0)···515out_event:516 ir_unregister_class(input_dev);517out_table:518+ ir_free_table(&ir_dev->rc_tab);519out_name:520 kfree(ir_dev->driver_name);521out_dev:···533void ir_input_unregister(struct input_dev *input_dev)534{535 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);0536537 if (!ir_dev)538 return;···545 if (ir_dev->props->driver_type == RC_DRIVER_IR_RAW)546 ir_raw_event_unregister(input_dev);547548+ ir_free_table(&ir_dev->rc_tab);000549550 ir_unregister_class(input_dev);551
···1-config TOUCHSCREEN_INTEL_MID2- tristate "Intel MID platform resistive touchscreen"3- depends on INTEL_SCU_IPC4- default y5- help6- Say Y here if you have a Intel MID based touchscreen7- If unsure, say N.
···34 * Protocol version.35 */3637-#define EV_VERSION 0x0100003839/*40 * IOCTLs (0x00 - 0x7f)···56 __s32 resolution;57};5800000000000000000000000059#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */60#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */61#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */62#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */63-#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */64-#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */06566#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */67#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */68#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */6970-#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */71#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */72#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */73#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */7475#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */76-#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */77-#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */7879#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */80#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */···1113 * @keycodemax: size of keycode table1114 * @keycodesize: size of elements in keycode table1115 * @keycode: map of scancodes to keycodes for this device01116 * @setkeycode: optional method to alter current keymap, used to implement1117 * sparse keymaps. If not supplied default mechanism will be used.1118 * The method is being called while holding event_lock and thus must1119 * not sleep1120- * @getkeycode: optional method to retrieve current keymap. If not supplied1121- * default mechanism will be used. The method is being called while1122- * holding event_lock and thus must not sleep1123 * @ff: force feedback structure associated with the device if device1124 * supports force feedback effects1125 * @repeat_key: stores key code of the last key pressed; used to implement···1193 unsigned int keycodemax;1194 unsigned int keycodesize;1195 void *keycode;01196 int (*setkeycode)(struct input_dev *dev,1197 unsigned int scancode, unsigned int keycode);1198 int (*getkeycode)(struct input_dev *dev,1199 unsigned int scancode, unsigned int *keycode);0000012001201 struct ff_device *ff;1202···1509INPUT_GENERATE_ABS_ACCESSORS(flat, flat)1510INPUT_GENERATE_ABS_ACCESSORS(res, resolution)15111512-int input_get_keycode(struct input_dev *dev,1513- unsigned int scancode, unsigned int *keycode);001514int input_set_keycode(struct input_dev *dev,1515- unsigned int scancode, unsigned int keycode);15161517extern struct class input_class;1518
···34 * Protocol version.35 */3637+#define EV_VERSION 0x0100013839/*40 * IOCTLs (0x00 - 0x7f)···56 __s32 resolution;57};5859+/**60+ * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls61+ * @scancode: scancode represented in machine-endian form.62+ * @len: length of the scancode that resides in @scancode buffer.63+ * @index: index in the keymap, may be used instead of scancode64+ * @flags: allows to specify how kernel should handle the request. For65+ * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel66+ * should perform lookup in keymap by @index instead of @scancode67+ * @keycode: key code assigned to this scancode68+ *69+ * The structure is used to retrieve and modify keymap data. Users have70+ * option of performing lookup either by @scancode itself or by @index71+ * in keymap entry. EVIOCGKEYCODE will also return scancode or index72+ * (depending on which element was used to perform lookup).73+ */74+struct input_keymap_entry {75+#define INPUT_KEYMAP_BY_INDEX (1 << 0)76+ __u8 flags;77+ __u8 len;78+ __u16 index;79+ __u32 keycode;80+ __u8 scancode[32];81+};82+83#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */84#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */85#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */86#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */87+88+#define EVIOCGKEYCODE _IOR('E', 0x04, struct input_keymap_entry) /* get keycode */89+#define EVIOCSKEYCODE _IOW('E', 0x04, struct input_keymap_entry) /* set keycode */9091#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */92#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */93#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */9495+#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */96#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */97#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */98#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */99100#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */101+#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */102+#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */103104#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */105#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */···1088 * @keycodemax: size of keycode table1089 * @keycodesize: size of elements in keycode table1090 * @keycode: map of scancodes to keycodes for this device1091+ * @getkeycode: optional legacy method to retrieve current keymap.1092 * @setkeycode: optional method to alter current keymap, used to implement1093 * sparse keymaps. If not supplied default mechanism will be used.1094 * The method is being called while holding event_lock and thus must1095 * not sleep1096+ * @getkeycode_new: transition method1097+ * @setkeycode_new: transition method01098 * @ff: force feedback structure associated with the device if device1099 * supports force feedback effects1100 * @repeat_key: stores key code of the last key pressed; used to implement···1168 unsigned int keycodemax;1169 unsigned int keycodesize;1170 void *keycode;1171+1172 int (*setkeycode)(struct input_dev *dev,1173 unsigned int scancode, unsigned int keycode);1174 int (*getkeycode)(struct input_dev *dev,1175 unsigned int scancode, unsigned int *keycode);1176+ int (*setkeycode_new)(struct input_dev *dev,1177+ const struct input_keymap_entry *ke,1178+ unsigned int *old_keycode);1179+ int (*getkeycode_new)(struct input_dev *dev,1180+ struct input_keymap_entry *ke);11811182 struct ff_device *ff;1183···1478INPUT_GENERATE_ABS_ACCESSORS(flat, flat)1479INPUT_GENERATE_ABS_ACCESSORS(res, resolution)14801481+int input_scancode_to_scalar(const struct input_keymap_entry *ke,1482+ unsigned int *scancode);1483+1484+int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);1485int input_set_keycode(struct input_dev *dev,1486+ const struct input_keymap_entry *ke);14871488extern struct class input_class;1489
+44
include/linux/input/bu21013.h
···00000000000000000000000000000000000000000000
···1+/*2+ * Copyright (C) ST-Ericsson SA 20103+ * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson4+ * License terms:GNU General Public License (GPL) version 25+ */6+7+#ifndef _BU21013_H8+#define _BU21013_H9+10+/**11+ * struct bu21013_platform_device - Handle the platform data12+ * @cs_en: pointer to the cs enable function13+ * @cs_dis: pointer to the cs disable function14+ * @irq_read_val: pointer to read the pen irq value function15+ * @x_max_res: xmax resolution16+ * @y_max_res: ymax resolution17+ * @touch_x_max: touch x max18+ * @touch_y_max: touch y max19+ * @cs_pin: chip select pin20+ * @irq: irq pin21+ * @ext_clk: external clock flag22+ * @x_flip: x flip flag23+ * @y_flip: y flip flag24+ * @wakeup: wakeup flag25+ *26+ * This is used to handle the platform data27+ */28+struct bu21013_platform_device {29+ int (*cs_en)(int reset_pin);30+ int (*cs_dis)(int reset_pin);31+ int (*irq_read_val)(void);32+ int x_max_res;33+ int y_max_res;34+ int touch_x_max;35+ int touch_y_max;36+ unsigned int cs_pin;37+ unsigned int irq;38+ bool ext_clk;39+ bool x_flip;40+ bool y_flip;41+ bool wakeup;42+};43+44+#endif
+6-4
include/linux/serio.h
···41 int (*start)(struct serio *);42 void (*stop)(struct serio *);4344- struct serio *parent, *child;0045 unsigned int depth; /* level of nesting in serio hierarchy */4647 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */···56#define to_serio_port(d) container_of(d, struct serio, dev)5758struct serio_driver {59- void *private;60- char *description;6162- struct serio_device_id *id_table;63 bool manual_bind;6465 void (*write_wakeup)(struct serio *);···198#define SERIO_W8001 0x39199#define SERIO_DYNAPRO 0x3a200#define SERIO_HAMPSHIRE 0x3b0201202#endif
···41 int (*start)(struct serio *);42 void (*stop)(struct serio *);4344+ struct serio *parent;45+ struct list_head child_node; /* Entry in parent->children list */46+ struct list_head children;47 unsigned int depth; /* level of nesting in serio hierarchy */4849 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */···54#define to_serio_port(d) container_of(d, struct serio, dev)5556struct serio_driver {57+ const char *description;05859+ const struct serio_device_id *id_table;60 bool manual_bind;6162 void (*write_wakeup)(struct serio *);···197#define SERIO_W8001 0x39198#define SERIO_DYNAPRO 0x3a199#define SERIO_HAMPSHIRE 0x3b200+#define SERIO_PS2MULT 0x3c201202#endif
+1-1
include/media/rc-map.h
···35 unsigned int len; /* Used number of entries */36 unsigned int alloc; /* Size of *scan in bytes */37 u64 ir_type;38- char *name;39 spinlock_t lock;40};41
···35 unsigned int len; /* Used number of entries */36 unsigned int alloc; /* Size of *scan in bytes */37 u64 ir_type;38+ const char *name;39 spinlock_t lock;40};41