···175175 */176176177177struct getset_keycode_data {178178- unsigned int scancode;179179- unsigned int keycode;178178+ struct input_keymap_entry ke;180179 int error;181180};182181···183184{184185 struct getset_keycode_data *d = data;185186186186- d->error = input_get_keycode(handle->dev, d->scancode, &d->keycode);187187+ d->error = input_get_keycode(handle->dev, &d->ke);187188188189 return d->error == 0; /* stop as soon as we successfully get one */189190}190191191192int getkeycode(unsigned int scancode)192193{193193- struct getset_keycode_data d = { scancode, 0, -ENODEV };194194+ struct getset_keycode_data d = {195195+ .ke = {196196+ .flags = 0,197197+ .len = sizeof(scancode),198198+ .keycode = 0,199199+ },200200+ .error = -ENODEV,201201+ };202202+203203+ memcpy(d.ke.scancode, &scancode, sizeof(scancode));194204195205 input_handler_for_each_handle(&kbd_handler, &d, getkeycode_helper);196206197197- return d.error ?: d.keycode;207207+ return d.error ?: d.ke.keycode;198208}199209200210static int setkeycode_helper(struct input_handle *handle, void *data)201211{202212 struct getset_keycode_data *d = data;203213204204- d->error = input_set_keycode(handle->dev, d->scancode, d->keycode);214214+ d->error = input_set_keycode(handle->dev, &d->ke);205215206216 return d->error == 0; /* stop as soon as we successfully set one */207217}208218209219int setkeycode(unsigned int scancode, unsigned int keycode)210220{211211- struct getset_keycode_data d = { scancode, keycode, -ENODEV };221221+ struct getset_keycode_data d = {222222+ .ke = {223223+ .flags = 0,224224+ .len = sizeof(scancode),225225+ .keycode = keycode,226226+ },227227+ .error = -ENODEV,228228+ };229229+230230+ memcpy(d.ke.scancode, &scancode, sizeof(scancode));212231213232 input_handler_for_each_handle(&kbd_handler, &d, setkeycode_helper);214233
+12-3
drivers/char/sysrq.c
···566566static bool sysrq_down;567567static int sysrq_alt_use;568568static int sysrq_alt;569569+static DEFINE_SPINLOCK(sysrq_event_lock);569570570571static bool sysrq_filter(struct input_handle *handle, unsigned int type,571572 unsigned int code, int value)572573{574574+ bool suppress;575575+576576+ /* We are called with interrupts disabled, just take the lock */577577+ spin_lock(&sysrq_event_lock);578578+573579 if (type != EV_KEY)574580 goto out;575581···607601 }608602609603out:610610- return sysrq_down;604604+ suppress = sysrq_down;605605+ spin_unlock(&sysrq_event_lock);606606+607607+ return suppress;611608}612609613610static int sysrq_connect(struct input_handler *handler,···661652}662653663654/*664664- * We are matching on KEY_LEFTALT insteard of KEY_SYSRQ because not all665665- * keyboards have SysRq ikey predefined and so user may add it to keymap655655+ * We are matching on KEY_LEFTALT instead of KEY_SYSRQ because not all656656+ * keyboards have SysRq key predefined and so user may add it to keymap666657 * later, but we expect all such keyboards to have left alt.667658 */668659static const struct input_device_id sysrq_ids[] = {
+5
drivers/hid/hid-core.c
···17661766 hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST)17671767 return true;17681768 break;17691769+ case USB_VENDOR_ID_HANWANG:17701770+ if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST &&17711771+ hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST)17721772+ return true;17731773+ break;17691774 }1770177517711776 if (hdev->type == HID_TYPE_USBMOUSE &&
···171171 if (code == ABS_MT_SLOT) {172172 /*173173 * "Stage" the event; we'll flush it later, when we174174- * get actiual touch data.174174+ * get actual touch data.175175 */176176 if (*pval >= 0 && *pval < dev->mtsize)177177 dev->slot = *pval;···188188 pold = &mtslot->abs[code - ABS_MT_FIRST];189189 } else {190190 /*191191- * Bypass filtering for multitouch events when191191+ * Bypass filtering for multi-touch events when192192 * not employing slots.193193 */194194 pold = NULL;···634634 spin_unlock_irq(&dev->event_lock);635635}636636637637-static int input_fetch_keycode(struct input_dev *dev, int scancode)637637+/**638638+ * input_scancode_to_scalar() - converts scancode in &struct input_keymap_entry639639+ * @ke: keymap entry containing scancode to be converted.640640+ * @scancode: pointer to the location where converted scancode should641641+ * be stored.642642+ *643643+ * This function is used to convert scancode stored in &struct keymap_entry644644+ * into scalar form understood by legacy keymap handling methods. These645645+ * methods expect scancodes to be represented as 'unsigned int'.646646+ */647647+int input_scancode_to_scalar(const struct input_keymap_entry *ke,648648+ unsigned int *scancode)649649+{650650+ switch (ke->len) {651651+ case 1:652652+ *scancode = *((u8 *)ke->scancode);653653+ break;654654+655655+ case 2:656656+ *scancode = *((u16 *)ke->scancode);657657+ break;658658+659659+ case 4:660660+ *scancode = *((u32 *)ke->scancode);661661+ break;662662+663663+ default:664664+ return -EINVAL;665665+ }666666+667667+ return 0;668668+}669669+EXPORT_SYMBOL(input_scancode_to_scalar);670670+671671+/*672672+ * Those routines handle the default case where no [gs]etkeycode() is673673+ * defined. In this case, an array indexed by the scancode is used.674674+ */675675+676676+static unsigned int input_fetch_keycode(struct input_dev *dev,677677+ unsigned int index)638678{639679 switch (dev->keycodesize) {640640- case 1:641641- return ((u8 *)dev->keycode)[scancode];680680+ case 1:681681+ return ((u8 *)dev->keycode)[index];642682643643- case 2:644644- return ((u16 *)dev->keycode)[scancode];683683+ case 2:684684+ return ((u16 *)dev->keycode)[index];645685646646- default:647647- return ((u32 *)dev->keycode)[scancode];686686+ default:687687+ return ((u32 *)dev->keycode)[index];648688 }649689}650690651691static int input_default_getkeycode(struct input_dev *dev,652652- unsigned int scancode,653653- unsigned int *keycode)692692+ struct input_keymap_entry *ke)654693{694694+ unsigned int index;695695+ int error;696696+655697 if (!dev->keycodesize)656698 return -EINVAL;657699658658- if (scancode >= dev->keycodemax)700700+ if (ke->flags & INPUT_KEYMAP_BY_INDEX)701701+ index = ke->index;702702+ else {703703+ error = input_scancode_to_scalar(ke, &index);704704+ if (error)705705+ return error;706706+ }707707+708708+ if (index >= dev->keycodemax)659709 return -EINVAL;660710661661- *keycode = input_fetch_keycode(dev, scancode);711711+ ke->keycode = input_fetch_keycode(dev, index);712712+ ke->index = index;713713+ ke->len = sizeof(index);714714+ memcpy(ke->scancode, &index, sizeof(index));662715663716 return 0;664717}665718666719static int input_default_setkeycode(struct input_dev *dev,667667- unsigned int scancode,668668- unsigned int keycode)720720+ const struct input_keymap_entry *ke,721721+ unsigned int *old_keycode)669722{670670- int old_keycode;723723+ unsigned int index;724724+ int error;671725 int i;672672-673673- if (scancode >= dev->keycodemax)674674- return -EINVAL;675726676727 if (!dev->keycodesize)677728 return -EINVAL;678729679679- if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))730730+ if (ke->flags & INPUT_KEYMAP_BY_INDEX) {731731+ index = ke->index;732732+ } else {733733+ error = input_scancode_to_scalar(ke, &index);734734+ if (error)735735+ return error;736736+ }737737+738738+ if (index >= dev->keycodemax)739739+ return -EINVAL;740740+741741+ if (dev->keycodesize < sizeof(dev->keycode) &&742742+ (ke->keycode >> (dev->keycodesize * 8)))680743 return -EINVAL;681744682745 switch (dev->keycodesize) {683746 case 1: {684747 u8 *k = (u8 *)dev->keycode;685685- old_keycode = k[scancode];686686- k[scancode] = keycode;748748+ *old_keycode = k[index];749749+ k[index] = ke->keycode;687750 break;688751 }689752 case 2: {690753 u16 *k = (u16 *)dev->keycode;691691- old_keycode = k[scancode];692692- k[scancode] = keycode;754754+ *old_keycode = k[index];755755+ k[index] = ke->keycode;693756 break;694757 }695758 default: {696759 u32 *k = (u32 *)dev->keycode;697697- old_keycode = k[scancode];698698- k[scancode] = keycode;760760+ *old_keycode = k[index];761761+ k[index] = ke->keycode;699762 break;700763 }701764 }702765703703- __clear_bit(old_keycode, dev->keybit);704704- __set_bit(keycode, dev->keybit);766766+ __clear_bit(*old_keycode, dev->keybit);767767+ __set_bit(ke->keycode, dev->keybit);705768706769 for (i = 0; i < dev->keycodemax; i++) {707707- if (input_fetch_keycode(dev, i) == old_keycode) {708708- __set_bit(old_keycode, dev->keybit);770770+ if (input_fetch_keycode(dev, i) == *old_keycode) {771771+ __set_bit(*old_keycode, dev->keybit);709772 break; /* Setting the bit twice is useless, so break */710773 }711774 }···779716/**780717 * input_get_keycode - retrieve keycode currently mapped to a given scancode781718 * @dev: input device which keymap is being queried782782- * @scancode: scancode (or its equivalent for device in question) for which783783- * keycode is needed784784- * @keycode: result719719+ * @ke: keymap entry785720 *786721 * This function should be called by anyone interested in retrieving current787787- * keymap. Presently keyboard and evdev handlers use it.722722+ * keymap. Presently evdev handlers use it.788723 */789789-int input_get_keycode(struct input_dev *dev,790790- unsigned int scancode, unsigned int *keycode)724724+int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)791725{792726 unsigned long flags;793727 int retval;794728795729 spin_lock_irqsave(&dev->event_lock, flags);796796- retval = dev->getkeycode(dev, scancode, keycode);797797- spin_unlock_irqrestore(&dev->event_lock, flags);798730731731+ if (dev->getkeycode) {732732+ /*733733+ * Support for legacy drivers, that don't implement the new734734+ * ioctls735735+ */736736+ u32 scancode = ke->index;737737+738738+ memcpy(ke->scancode, &scancode, sizeof(scancode));739739+ ke->len = sizeof(scancode);740740+ retval = dev->getkeycode(dev, scancode, &ke->keycode);741741+ } else {742742+ retval = dev->getkeycode_new(dev, ke);743743+ }744744+745745+ spin_unlock_irqrestore(&dev->event_lock, flags);799746 return retval;800747}801748EXPORT_SYMBOL(input_get_keycode);802749803750/**804804- * input_get_keycode - assign new keycode to a given scancode751751+ * input_set_keycode - attribute a keycode to a given scancode805752 * @dev: input device which keymap is being updated806806- * @scancode: scancode (or its equivalent for device in question)807807- * @keycode: new keycode to be assigned to the scancode753753+ * @ke: new keymap entry808754 *809755 * This function should be called by anyone needing to update current810756 * keymap. Presently keyboard and evdev handlers use it.811757 */812758int input_set_keycode(struct input_dev *dev,813813- unsigned int scancode, unsigned int keycode)759759+ const struct input_keymap_entry *ke)814760{815761 unsigned long flags;816762 unsigned int old_keycode;817763 int retval;818764819819- if (keycode > KEY_MAX)765765+ if (ke->keycode > KEY_MAX)820766 return -EINVAL;821767822768 spin_lock_irqsave(&dev->event_lock, flags);823769824824- retval = dev->getkeycode(dev, scancode, &old_keycode);825825- if (retval)826826- goto out;770770+ if (dev->setkeycode) {771771+ /*772772+ * Support for legacy drivers, that don't implement the new773773+ * ioctls774774+ */775775+ unsigned int scancode;827776828828- retval = dev->setkeycode(dev, scancode, keycode);777777+ retval = input_scancode_to_scalar(ke, &scancode);778778+ if (retval)779779+ goto out;780780+781781+ /*782782+ * We need to know the old scancode, in order to generate a783783+ * keyup effect, if the set operation happens successfully784784+ */785785+ if (!dev->getkeycode) {786786+ retval = -EINVAL;787787+ goto out;788788+ }789789+790790+ retval = dev->getkeycode(dev, scancode, &old_keycode);791791+ if (retval)792792+ goto out;793793+794794+ retval = dev->setkeycode(dev, scancode, ke->keycode);795795+ } else {796796+ retval = dev->setkeycode_new(dev, ke, &old_keycode);797797+ }798798+829799 if (retval)830800 goto out;831801···16971601 *16981602 * This function allocates all necessary memory for MT slot handling in the16991603 * input device, and adds ABS_MT_SLOT to the device capabilities. All slots17001700- * are initially marked as unused iby setting ABS_MT_TRACKING_ID to -1.16041604+ * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1.17011605 */17021606int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)17031607{···18551759 dev->rep[REP_PERIOD] = 33;18561760 }1857176118581858- if (!dev->getkeycode)18591859- dev->getkeycode = input_default_getkeycode;17621762+ if (!dev->getkeycode && !dev->getkeycode_new)17631763+ dev->getkeycode_new = input_default_getkeycode;1860176418611861- if (!dev->setkeycode)18621862- dev->setkeycode = input_default_setkeycode;17651765+ if (!dev->setkeycode && !dev->setkeycode_new)17661766+ dev->setkeycode_new = input_default_setkeycode;1863176718641768 dev_set_name(&dev->dev, "input%ld",18651769 (unsigned long) atomic_inc_return(&input_no) - 1);
+19
drivers/input/keyboard/Kconfig
···327327 To compile this driver as a module, choose M here: the328328 module will be called newtonkbd.329329330330+config KEYBOARD_NOMADIK331331+ tristate "ST-Ericsson Nomadik SKE keyboard"332332+ depends on PLAT_NOMADIK333333+ help334334+ Say Y here if you want to use a keypad provided on the SKE controller335335+ used on the Ux500 and Nomadik platforms336336+337337+ To compile this driver as a module, choose M here: the338338+ module will be called nmk-ske-keypad.339339+330340config KEYBOARD_OPENCORES331341 tristate "OpenCores Keyboard Controller"332342 help···433423434424 To compile this driver as a module, choose M here: the435425 module will be called omap-keypad.426426+427427+config KEYBOARD_OMAP4428428+ tristate "TI OMAP4 keypad support"429429+ depends on ARCH_OMAP4430430+ help431431+ Say Y here if you want to use the OMAP4 keypad.432432+433433+ To compile this driver as a module, choose M here: the434434+ module will be called omap4-keypad.436435437436config KEYBOARD_TWL4030438437 tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
···11+/*22+ * Copyright (C) ST-Ericsson SA 201033+ *44+ * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson55+ * Author: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson66+ *77+ * License terms:GNU General Public License (GPL) version 288+ *99+ * Keypad controller driver for the SKE (Scroll Key Encoder) module used in1010+ * the Nomadik 8815 and Ux500 platforms.1111+ */1212+1313+#include <linux/platform_device.h>1414+#include <linux/interrupt.h>1515+#include <linux/spinlock.h>1616+#include <linux/io.h>1717+#include <linux/delay.h>1818+#include <linux/input.h>1919+#include <linux/slab.h>2020+#include <linux/clk.h>2121+2222+#include <plat/ske.h>2323+2424+/* SKE_CR bits */2525+#define SKE_KPMLT (0x1 << 6)2626+#define SKE_KPCN (0x7 << 3)2727+#define SKE_KPASEN (0x1 << 2)2828+#define SKE_KPASON (0x1 << 7)2929+3030+/* SKE_IMSC bits */3131+#define SKE_KPIMA (0x1 << 2)3232+3333+/* SKE_ICR bits */3434+#define SKE_KPICS (0x1 << 3)3535+#define SKE_KPICA (0x1 << 2)3636+3737+/* SKE_RIS bits */3838+#define SKE_KPRISA (0x1 << 2)3939+4040+#define SKE_KEYPAD_ROW_SHIFT 34141+#define SKE_KPD_KEYMAP_SIZE (8 * 8)4242+4343+/* keypad auto scan registers */4444+#define SKE_ASR0 0x204545+#define SKE_ASR1 0x244646+#define SKE_ASR2 0x284747+#define SKE_ASR3 0x2C4848+4949+#define SKE_NUM_ASRX_REGISTERS (4)5050+5151+/**5252+ * struct ske_keypad - data structure used by keypad driver5353+ * @irq: irq no5454+ * @reg_base: ske regsiters base address5555+ * @input: pointer to input device object5656+ * @board: keypad platform device5757+ * @keymap: matrix scan code table for keycodes5858+ * @clk: clock structure pointer5959+ */6060+struct ske_keypad {6161+ int irq;6262+ void __iomem *reg_base;6363+ struct input_dev *input;6464+ const struct ske_keypad_platform_data *board;6565+ unsigned short keymap[SKE_KPD_KEYMAP_SIZE];6666+ struct clk *clk;6767+ spinlock_t ske_keypad_lock;6868+};6969+7070+static void ske_keypad_set_bits(struct ske_keypad *keypad, u16 addr,7171+ u8 mask, u8 data)7272+{7373+ u32 ret;7474+7575+ spin_lock(&keypad->ske_keypad_lock);7676+7777+ ret = readl(keypad->reg_base + addr);7878+ ret &= ~mask;7979+ ret |= data;8080+ writel(ret, keypad->reg_base + addr);8181+8282+ spin_unlock(&keypad->ske_keypad_lock);8383+}8484+8585+/*8686+ * ske_keypad_chip_init: init keypad controller configuration8787+ *8888+ * Enable Multi key press detection, auto scan mode8989+ */9090+static int __devinit ske_keypad_chip_init(struct ske_keypad *keypad)9191+{9292+ u32 value;9393+ int timeout = 50;9494+9595+ /* check SKE_RIS to be 0 */9696+ while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--)9797+ cpu_relax();9898+9999+ if (!timeout)100100+ return -EINVAL;101101+102102+ /*103103+ * set debounce value104104+ * keypad dbounce is configured in DBCR[15:8]105105+ * dbounce value in steps of 32/32.768 ms106106+ */107107+ spin_lock(&keypad->ske_keypad_lock);108108+ value = readl(keypad->reg_base + SKE_DBCR);109109+ value = value & 0xff;110110+ value |= ((keypad->board->debounce_ms * 32000)/32768) << 8;111111+ writel(value, keypad->reg_base + SKE_DBCR);112112+ spin_unlock(&keypad->ske_keypad_lock);113113+114114+ /* enable multi key detection */115115+ ske_keypad_set_bits(keypad, SKE_CR, 0x0, SKE_KPMLT);116116+117117+ /*118118+ * set up the number of columns119119+ * KPCN[5:3] defines no. of keypad columns to be auto scanned120120+ */121121+ value = (keypad->board->kcol - 1) << 3;122122+ ske_keypad_set_bits(keypad, SKE_CR, SKE_KPCN, value);123123+124124+ /* clear keypad interrupt for auto(and pending SW) scans */125125+ ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA | SKE_KPICS);126126+127127+ /* un-mask keypad interrupts */128128+ ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);129129+130130+ /* enable automatic scan */131131+ ske_keypad_set_bits(keypad, SKE_CR, 0x0, SKE_KPASEN);132132+133133+ return 0;134134+}135135+136136+static void ske_keypad_read_data(struct ske_keypad *keypad)137137+{138138+ struct input_dev *input = keypad->input;139139+ u16 status;140140+ int col = 0, row = 0, code;141141+ int ske_asr, ske_ris, key_pressed, i;142142+143143+ /*144144+ * Read the auto scan registers145145+ *146146+ * Each SKE_ASRx (x=0 to x=3) contains two row values.147147+ * lower byte contains row value for column 2*x,148148+ * upper byte contains row value for column 2*x + 1149149+ */150150+ for (i = 0; i < SKE_NUM_ASRX_REGISTERS; i++) {151151+ ske_asr = readl(keypad->reg_base + SKE_ASR0 + (4 * i));152152+ if (!ske_asr)153153+ continue;154154+155155+ /* now that ASRx is zero, find out the column x and row y*/156156+ if (ske_asr & 0xff) {157157+ col = i * 2;158158+ status = ske_asr & 0xff;159159+ } else {160160+ col = (i * 2) + 1;161161+ status = (ske_asr & 0xff00) >> 8;162162+ }163163+164164+ /* find out the row */165165+ row = __ffs(status);166166+167167+ code = MATRIX_SCAN_CODE(row, col, SKE_KEYPAD_ROW_SHIFT);168168+ ske_ris = readl(keypad->reg_base + SKE_RIS);169169+ key_pressed = ske_ris & SKE_KPRISA;170170+171171+ input_event(input, EV_MSC, MSC_SCAN, code);172172+ input_report_key(input, keypad->keymap[code], key_pressed);173173+ input_sync(input);174174+ }175175+}176176+177177+static irqreturn_t ske_keypad_irq(int irq, void *dev_id)178178+{179179+ struct ske_keypad *keypad = dev_id;180180+ int retries = 20;181181+182182+ /* disable auto scan interrupt; mask the interrupt generated */183183+ ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);184184+ ske_keypad_set_bits(keypad, SKE_ICR, 0x0, SKE_KPICA);185185+186186+ while ((readl(keypad->reg_base + SKE_CR) & SKE_KPASON) && --retries)187187+ msleep(5);188188+189189+ if (retries) {190190+ /* SKEx registers are stable and can be read */191191+ ske_keypad_read_data(keypad);192192+ }193193+194194+ /* enable auto scan interrupts */195195+ ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);196196+197197+ return IRQ_HANDLED;198198+}199199+200200+static int __devinit ske_keypad_probe(struct platform_device *pdev)201201+{202202+ const struct ske_keypad_platform_data *plat = pdev->dev.platform_data;203203+ struct ske_keypad *keypad;204204+ struct input_dev *input;205205+ struct resource *res;206206+ int irq;207207+ int error;208208+209209+ if (!plat) {210210+ dev_err(&pdev->dev, "invalid keypad platform data\n");211211+ return -EINVAL;212212+ }213213+214214+ irq = platform_get_irq(pdev, 0);215215+ if (irq < 0) {216216+ dev_err(&pdev->dev, "failed to get keypad irq\n");217217+ return -EINVAL;218218+ }219219+220220+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);221221+ if (!res) {222222+ dev_err(&pdev->dev, "missing platform resources\n");223223+ return -EINVAL;224224+ }225225+226226+ keypad = kzalloc(sizeof(struct ske_keypad), GFP_KERNEL);227227+ input = input_allocate_device();228228+ if (!keypad || !input) {229229+ dev_err(&pdev->dev, "failed to allocate keypad memory\n");230230+ error = -ENOMEM;231231+ goto err_free_mem;232232+ }233233+234234+ keypad->irq = irq;235235+ keypad->board = plat;236236+ keypad->input = input;237237+ spin_lock_init(&keypad->ske_keypad_lock);238238+239239+ if (!request_mem_region(res->start, resource_size(res), pdev->name)) {240240+ dev_err(&pdev->dev, "failed to request I/O memory\n");241241+ error = -EBUSY;242242+ goto err_free_mem;243243+ }244244+245245+ keypad->reg_base = ioremap(res->start, resource_size(res));246246+ if (!keypad->reg_base) {247247+ dev_err(&pdev->dev, "failed to remap I/O memory\n");248248+ error = -ENXIO;249249+ goto err_free_mem_region;250250+ }251251+252252+ keypad->clk = clk_get(&pdev->dev, NULL);253253+ if (IS_ERR(keypad->clk)) {254254+ dev_err(&pdev->dev, "failed to get clk\n");255255+ error = PTR_ERR(keypad->clk);256256+ goto err_iounmap;257257+ }258258+259259+ input->id.bustype = BUS_HOST;260260+ input->name = "ux500-ske-keypad";261261+ input->dev.parent = &pdev->dev;262262+263263+ input->keycode = keypad->keymap;264264+ input->keycodesize = sizeof(keypad->keymap[0]);265265+ input->keycodemax = ARRAY_SIZE(keypad->keymap);266266+267267+ input_set_capability(input, EV_MSC, MSC_SCAN);268268+269269+ __set_bit(EV_KEY, input->evbit);270270+ if (!plat->no_autorepeat)271271+ __set_bit(EV_REP, input->evbit);272272+273273+ matrix_keypad_build_keymap(plat->keymap_data, SKE_KEYPAD_ROW_SHIFT,274274+ input->keycode, input->keybit);275275+276276+ clk_enable(keypad->clk);277277+278278+ /* go through board initialization helpers */279279+ if (keypad->board->init)280280+ keypad->board->init();281281+282282+ error = ske_keypad_chip_init(keypad);283283+ if (error) {284284+ dev_err(&pdev->dev, "unable to init keypad hardware\n");285285+ goto err_clk_disable;286286+ }287287+288288+ error = request_threaded_irq(keypad->irq, NULL, ske_keypad_irq,289289+ IRQF_ONESHOT, "ske-keypad", keypad);290290+ if (error) {291291+ dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq);292292+ goto err_clk_disable;293293+ }294294+295295+ error = input_register_device(input);296296+ if (error) {297297+ dev_err(&pdev->dev,298298+ "unable to register input device: %d\n", error);299299+ goto err_free_irq;300300+ }301301+302302+ if (plat->wakeup_enable)303303+ device_init_wakeup(&pdev->dev, true);304304+305305+ platform_set_drvdata(pdev, keypad);306306+307307+ return 0;308308+309309+err_free_irq:310310+ free_irq(keypad->irq, keypad);311311+err_clk_disable:312312+ clk_disable(keypad->clk);313313+ clk_put(keypad->clk);314314+err_iounmap:315315+ iounmap(keypad->reg_base);316316+err_free_mem_region:317317+ release_mem_region(res->start, resource_size(res));318318+err_free_mem:319319+ input_free_device(input);320320+ kfree(keypad);321321+ return error;322322+}323323+324324+static int __devexit ske_keypad_remove(struct platform_device *pdev)325325+{326326+ struct ske_keypad *keypad = platform_get_drvdata(pdev);327327+ struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);328328+329329+ free_irq(keypad->irq, keypad);330330+331331+ input_unregister_device(keypad->input);332332+333333+ clk_disable(keypad->clk);334334+ clk_put(keypad->clk);335335+336336+ if (keypad->board->exit)337337+ keypad->board->exit();338338+339339+ iounmap(keypad->reg_base);340340+ release_mem_region(res->start, resource_size(res));341341+ kfree(keypad);342342+343343+ return 0;344344+}345345+346346+#ifdef CONFIG_PM347347+static int ske_keypad_suspend(struct device *dev)348348+{349349+ struct platform_device *pdev = to_platform_device(dev);350350+ struct ske_keypad *keypad = platform_get_drvdata(pdev);351351+ int irq = platform_get_irq(pdev, 0);352352+353353+ if (device_may_wakeup(dev))354354+ enable_irq_wake(irq);355355+ else356356+ ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);357357+358358+ return 0;359359+}360360+361361+static int ske_keypad_resume(struct device *dev)362362+{363363+ struct platform_device *pdev = to_platform_device(dev);364364+ struct ske_keypad *keypad = platform_get_drvdata(pdev);365365+ int irq = platform_get_irq(pdev, 0);366366+367367+ if (device_may_wakeup(dev))368368+ disable_irq_wake(irq);369369+ else370370+ ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);371371+372372+ return 0;373373+}374374+375375+static const struct dev_pm_ops ske_keypad_dev_pm_ops = {376376+ .suspend = ske_keypad_suspend,377377+ .resume = ske_keypad_resume,378378+};379379+#endif380380+381381+struct platform_driver ske_keypad_driver = {382382+ .driver = {383383+ .name = "nmk-ske-keypad",384384+ .owner = THIS_MODULE,385385+#ifdef CONFIG_PM386386+ .pm = &ske_keypad_dev_pm_ops,387387+#endif388388+ },389389+ .probe = ske_keypad_probe,390390+ .remove = __devexit_p(ske_keypad_remove),391391+};392392+393393+static int __init ske_keypad_init(void)394394+{395395+ return platform_driver_probe(&ske_keypad_driver, ske_keypad_probe);396396+}397397+module_init(ske_keypad_init);398398+399399+static void __exit ske_keypad_exit(void)400400+{401401+ platform_driver_unregister(&ske_keypad_driver);402402+}403403+module_exit(ske_keypad_exit);404404+405405+MODULE_LICENSE("GPL v2");406406+MODULE_AUTHOR("Naveen Kumar <naveen.gaddipati@stericsson.com> / Sundar Iyer <sundar.iyer@stericsson.com>");407407+MODULE_DESCRIPTION("Nomadik Scroll-Key-Encoder Keypad Driver");408408+MODULE_ALIAS("platform:nomadik-ske-keypad");
+318
drivers/input/keyboard/omap4-keypad.c
···11+/*22+ * OMAP4 Keypad Driver33+ *44+ * Copyright (C) 2010 Texas Instruments55+ *66+ * Author: Abraham Arce <x0066660@ti.com>77+ * Initial Code: Syed Rafiuddin <rafiuddin.syed@ti.com>88+ *99+ * This program is free software; you can redistribute it and/or modify1010+ * it under the terms of the GNU General Public License as published by1111+ * the Free Software Foundation; either version 2 of the License, or1212+ * (at your option) any later version.1313+ *1414+ * This program is distributed in the hope that it will be useful,1515+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1616+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1717+ * GNU General Public License for more details.1818+ *1919+ * You should have received a copy of the GNU General Public License2020+ * along with this program; if not, write to the Free Software2121+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2222+ */2323+2424+#include <linux/module.h>2525+#include <linux/init.h>2626+#include <linux/interrupt.h>2727+#include <linux/platform_device.h>2828+#include <linux/errno.h>2929+#include <linux/io.h>3030+#include <linux/input.h>3131+#include <linux/slab.h>3232+3333+#include <plat/omap4-keypad.h>3434+3535+/* OMAP4 registers */3636+#define OMAP4_KBD_REVISION 0x003737+#define OMAP4_KBD_SYSCONFIG 0x103838+#define OMAP4_KBD_SYSSTATUS 0x143939+#define OMAP4_KBD_IRQSTATUS 0x184040+#define OMAP4_KBD_IRQENABLE 0x1C4141+#define OMAP4_KBD_WAKEUPENABLE 0x204242+#define OMAP4_KBD_PENDING 0x244343+#define OMAP4_KBD_CTRL 0x284444+#define OMAP4_KBD_DEBOUNCINGTIME 0x2C4545+#define OMAP4_KBD_LONGKEYTIME 0x304646+#define OMAP4_KBD_TIMEOUT 0x344747+#define OMAP4_KBD_STATEMACHINE 0x384848+#define OMAP4_KBD_ROWINPUTS 0x3C4949+#define OMAP4_KBD_COLUMNOUTPUTS 0x405050+#define OMAP4_KBD_FULLCODE31_0 0x445151+#define OMAP4_KBD_FULLCODE63_32 0x485252+5353+/* OMAP4 bit definitions */5454+#define OMAP4_DEF_IRQENABLE_EVENTEN (1 << 0)5555+#define OMAP4_DEF_IRQENABLE_LONGKEY (1 << 1)5656+#define OMAP4_DEF_IRQENABLE_TIMEOUTEN (1 << 2)5757+#define OMAP4_DEF_WUP_EVENT_ENA (1 << 0)5858+#define OMAP4_DEF_WUP_LONG_KEY_ENA (1 << 1)5959+#define OMAP4_DEF_CTRL_NOSOFTMODE (1 << 1)6060+#define OMAP4_DEF_CTRLPTVVALUE (1 << 2)6161+#define OMAP4_DEF_CTRLPTV (1 << 1)6262+6363+/* OMAP4 values */6464+#define OMAP4_VAL_IRQDISABLE 0x006565+#define OMAP4_VAL_DEBOUNCINGTIME 0x076666+#define OMAP4_VAL_FUNCTIONALCFG 0x1E6767+6868+#define OMAP4_MASK_IRQSTATUSDISABLE 0xFFFF6969+7070+struct omap4_keypad {7171+ struct input_dev *input;7272+7373+ void __iomem *base;7474+ int irq;7575+7676+ unsigned int rows;7777+ unsigned int cols;7878+ unsigned int row_shift;7979+ unsigned char key_state[8];8080+ unsigned short keymap[];8181+};8282+8383+static void __devinit omap4_keypad_config(struct omap4_keypad *keypad_data)8484+{8585+ __raw_writel(OMAP4_VAL_FUNCTIONALCFG,8686+ keypad_data->base + OMAP4_KBD_CTRL);8787+ __raw_writel(OMAP4_VAL_DEBOUNCINGTIME,8888+ keypad_data->base + OMAP4_KBD_DEBOUNCINGTIME);8989+ __raw_writel(OMAP4_VAL_IRQDISABLE,9090+ keypad_data->base + OMAP4_KBD_IRQSTATUS);9191+ __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY,9292+ keypad_data->base + OMAP4_KBD_IRQENABLE);9393+ __raw_writel(OMAP4_DEF_WUP_EVENT_ENA | OMAP4_DEF_WUP_LONG_KEY_ENA,9494+ keypad_data->base + OMAP4_KBD_WAKEUPENABLE);9595+}9696+9797+/* Interrupt handler */9898+static irqreturn_t omap4_keypad_interrupt(int irq, void *dev_id)9999+{100100+ struct omap4_keypad *keypad_data = dev_id;101101+ struct input_dev *input_dev = keypad_data->input;102102+ unsigned char key_state[ARRAY_SIZE(keypad_data->key_state)];103103+ unsigned int col, row, code, changed;104104+ u32 *new_state = (u32 *) key_state;105105+106106+ /* Disable interrupts */107107+ __raw_writel(OMAP4_VAL_IRQDISABLE,108108+ keypad_data->base + OMAP4_KBD_IRQENABLE);109109+110110+ *new_state = __raw_readl(keypad_data->base + OMAP4_KBD_FULLCODE31_0);111111+ *(new_state + 1) = __raw_readl(keypad_data->base112112+ + OMAP4_KBD_FULLCODE63_32);113113+114114+ for (row = 0; row < keypad_data->rows; row++) {115115+ changed = key_state[row] ^ keypad_data->key_state[row];116116+ if (!changed)117117+ continue;118118+119119+ for (col = 0; col < keypad_data->cols; col++) {120120+ if (changed & (1 << col)) {121121+ code = MATRIX_SCAN_CODE(row, col,122122+ keypad_data->row_shift);123123+ input_event(input_dev, EV_MSC, MSC_SCAN, code);124124+ input_report_key(input_dev,125125+ keypad_data->keymap[code],126126+ key_state[row] & (1 << col));127127+ }128128+ }129129+ }130130+131131+ input_sync(input_dev);132132+133133+ memcpy(keypad_data->key_state, key_state,134134+ sizeof(keypad_data->key_state));135135+136136+ /* clear pending interrupts */137137+ __raw_writel(__raw_readl(keypad_data->base + OMAP4_KBD_IRQSTATUS),138138+ keypad_data->base + OMAP4_KBD_IRQSTATUS);139139+140140+ /* enable interrupts */141141+ __raw_writel(OMAP4_DEF_IRQENABLE_EVENTEN | OMAP4_DEF_IRQENABLE_LONGKEY,142142+ keypad_data->base + OMAP4_KBD_IRQENABLE);143143+144144+ return IRQ_HANDLED;145145+}146146+147147+static int __devinit omap4_keypad_probe(struct platform_device *pdev)148148+{149149+ const struct omap4_keypad_platform_data *pdata;150150+ struct omap4_keypad *keypad_data;151151+ struct input_dev *input_dev;152152+ struct resource *res;153153+ resource_size_t size;154154+ unsigned int row_shift, max_keys;155155+ int irq;156156+ int error;157157+158158+ /* platform data */159159+ pdata = pdev->dev.platform_data;160160+ if (!pdata) {161161+ dev_err(&pdev->dev, "no platform data defined\n");162162+ return -EINVAL;163163+ }164164+165165+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);166166+ if (!res) {167167+ dev_err(&pdev->dev, "no base address specified\n");168168+ return -EINVAL;169169+ }170170+171171+ irq = platform_get_irq(pdev, 0);172172+ if (!irq) {173173+ dev_err(&pdev->dev, "no keyboard irq assigned\n");174174+ return -EINVAL;175175+ }176176+177177+ if (!pdata->keymap_data) {178178+ dev_err(&pdev->dev, "no keymap data defined\n");179179+ return -EINVAL;180180+ }181181+182182+ row_shift = get_count_order(pdata->cols);183183+ max_keys = pdata->rows << row_shift;184184+185185+ keypad_data = kzalloc(sizeof(struct omap4_keypad) +186186+ max_keys * sizeof(keypad_data->keymap[0]),187187+ GFP_KERNEL);188188+ if (!keypad_data) {189189+ dev_err(&pdev->dev, "keypad_data memory allocation failed\n");190190+ return -ENOMEM;191191+ }192192+193193+ size = resource_size(res);194194+195195+ res = request_mem_region(res->start, size, pdev->name);196196+ if (!res) {197197+ dev_err(&pdev->dev, "can't request mem region\n");198198+ error = -EBUSY;199199+ goto err_free_keypad;200200+ }201201+202202+ keypad_data->base = ioremap(res->start, resource_size(res));203203+ if (!keypad_data->base) {204204+ dev_err(&pdev->dev, "can't ioremap mem resource\n");205205+ error = -ENOMEM;206206+ goto err_release_mem;207207+ }208208+209209+ keypad_data->irq = irq;210210+ keypad_data->row_shift = row_shift;211211+ keypad_data->rows = pdata->rows;212212+ keypad_data->cols = pdata->cols;213213+214214+ /* input device allocation */215215+ keypad_data->input = input_dev = input_allocate_device();216216+ if (!input_dev) {217217+ error = -ENOMEM;218218+ goto err_unmap;219219+ }220220+221221+ input_dev->name = pdev->name;222222+ input_dev->dev.parent = &pdev->dev;223223+ input_dev->id.bustype = BUS_HOST;224224+ input_dev->id.vendor = 0x0001;225225+ input_dev->id.product = 0x0001;226226+ input_dev->id.version = 0x0001;227227+228228+ input_dev->keycode = keypad_data->keymap;229229+ input_dev->keycodesize = sizeof(keypad_data->keymap[0]);230230+ input_dev->keycodemax = max_keys;231231+232232+ __set_bit(EV_KEY, input_dev->evbit);233233+ __set_bit(EV_REP, input_dev->evbit);234234+235235+ input_set_capability(input_dev, EV_MSC, MSC_SCAN);236236+237237+ input_set_drvdata(input_dev, keypad_data);238238+239239+ matrix_keypad_build_keymap(pdata->keymap_data, row_shift,240240+ input_dev->keycode, input_dev->keybit);241241+242242+ omap4_keypad_config(keypad_data);243243+244244+ error = request_irq(keypad_data->irq, omap4_keypad_interrupt,245245+ IRQF_TRIGGER_RISING,246246+ "omap4-keypad", keypad_data);247247+ if (error) {248248+ dev_err(&pdev->dev, "failed to register interrupt\n");249249+ goto err_free_input;250250+ }251251+252252+ error = input_register_device(keypad_data->input);253253+ if (error < 0) {254254+ dev_err(&pdev->dev, "failed to register input device\n");255255+ goto err_free_irq;256256+ }257257+258258+259259+ platform_set_drvdata(pdev, keypad_data);260260+ return 0;261261+262262+err_free_irq:263263+ free_irq(keypad_data->irq, keypad_data);264264+err_free_input:265265+ input_free_device(input_dev);266266+err_unmap:267267+ iounmap(keypad_data->base);268268+err_release_mem:269269+ release_mem_region(res->start, size);270270+err_free_keypad:271271+ kfree(keypad_data);272272+ return error;273273+}274274+275275+static int __devexit omap4_keypad_remove(struct platform_device *pdev)276276+{277277+ struct omap4_keypad *keypad_data = platform_get_drvdata(pdev);278278+ struct resource *res;279279+280280+ free_irq(keypad_data->irq, keypad_data);281281+ input_unregister_device(keypad_data->input);282282+283283+ iounmap(keypad_data->base);284284+285285+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);286286+ release_mem_region(res->start, resource_size(res));287287+288288+ kfree(keypad_data);289289+ platform_set_drvdata(pdev, NULL);290290+291291+ return 0;292292+}293293+294294+static struct platform_driver omap4_keypad_driver = {295295+ .probe = omap4_keypad_probe,296296+ .remove = __devexit_p(omap4_keypad_remove),297297+ .driver = {298298+ .name = "omap4-keypad",299299+ .owner = THIS_MODULE,300300+ },301301+};302302+303303+static int __init omap4_keypad_init(void)304304+{305305+ return platform_driver_register(&omap4_keypad_driver);306306+}307307+module_init(omap4_keypad_init);308308+309309+static void __exit omap4_keypad_exit(void)310310+{311311+ platform_driver_unregister(&omap4_keypad_driver);312312+}313313+module_exit(omap4_keypad_exit);314314+315315+MODULE_AUTHOR("Texas Instruments");316316+MODULE_DESCRIPTION("OMAP4 Keypad Driver");317317+MODULE_LICENSE("GPL");318318+MODULE_ALIAS("platform:omap4-keypad");
+3-4
drivers/input/keyboard/twl4030_keypad.c
···406406 if (error) {407407 dev_info(kp->dbg_dev, "request_irq failed for irq no=%d\n",408408 kp->irq);409409- goto err3;409409+ goto err2;410410 }411411412412 /* Enable KP and TO interrupts now. */413413 reg = (u8) ~(KEYP_IMR1_KP | KEYP_IMR1_TO);414414 if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) {415415 error = -EIO;416416- goto err4;416416+ goto err3;417417 }418418419419 platform_set_drvdata(pdev, kp);420420 return 0;421421422422-err4:422422+err3:423423 /* mask all events - we don't care about the result */424424 (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1);425425-err3:426425 free_irq(kp->irq, NULL);427426err2:428427 input_unregister_device(input);
+10
drivers/input/misc/Kconfig
···2222 To compile this driver as a module, choose M here: the module2323 will be called 88pm860x_onkey.24242525+config INPUT_AB8500_PONKEY2626+ tristate "AB8500 Pon (PowerOn) Key"2727+ depends on AB8500_CORE2828+ help2929+ Say Y here to use the PowerOn Key for ST-Ericsson's AB85003030+ Mix-Sig PMIC.3131+3232+ To compile this driver as a module, choose M here: the module3333+ will be called ab8500-ponkey.3434+2535config INPUT_AD714X2636 tristate "Analog Devices AD714x Capacitance Touch Sensor"2737 help
+1
drivers/input/misc/Makefile
···55# Each configuration option enables a list of files.6677obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o88+obj-$(CONFIG_INPUT_AB8500_PONKEY) += ab8500-ponkey.o89obj-$(CONFIG_INPUT_AD714X) += ad714x.o910obj-$(CONFIG_INPUT_AD714X_I2C) += ad714x-i2c.o1011obj-$(CONFIG_INPUT_AD714X_SPI) += ad714x-spi.o
+157
drivers/input/misc/ab8500-ponkey.c
···11+/*22+ * Copyright (C) ST-Ericsson SA 201033+ *44+ * License Terms: GNU General Public License v255+ * Author: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson66+ *77+ * AB8500 Power-On Key handler88+ */99+1010+#include <linux/kernel.h>1111+#include <linux/module.h>1212+#include <linux/platform_device.h>1313+#include <linux/input.h>1414+#include <linux/interrupt.h>1515+#include <linux/mfd/ab8500.h>1616+#include <linux/slab.h>1717+1818+/**1919+ * struct ab8500_ponkey - ab8500 ponkey information2020+ * @input_dev: pointer to input device2121+ * @ab8500: ab8500 parent2222+ * @irq_dbf: irq number for falling transition2323+ * @irq_dbr: irq number for rising transition2424+ */2525+struct ab8500_ponkey {2626+ struct input_dev *idev;2727+ struct ab8500 *ab8500;2828+ int irq_dbf;2929+ int irq_dbr;3030+};3131+3232+/* AB8500 gives us an interrupt when ONKEY is held */3333+static irqreturn_t ab8500_ponkey_handler(int irq, void *data)3434+{3535+ struct ab8500_ponkey *ponkey = data;3636+3737+ if (irq == ponkey->irq_dbf)3838+ input_report_key(ponkey->idev, KEY_POWER, true);3939+ else if (irq == ponkey->irq_dbr)4040+ input_report_key(ponkey->idev, KEY_POWER, false);4141+4242+ input_sync(ponkey->idev);4343+4444+ return IRQ_HANDLED;4545+}4646+4747+static int __devinit ab8500_ponkey_probe(struct platform_device *pdev)4848+{4949+ struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);5050+ struct ab8500_ponkey *ponkey;5151+ struct input_dev *input;5252+ int irq_dbf, irq_dbr;5353+ int error;5454+5555+ irq_dbf = platform_get_irq_byname(pdev, "ONKEY_DBF");5656+ if (irq_dbf < 0) {5757+ dev_err(&pdev->dev, "No IRQ for ONKEY_DBF, error=%d\n", irq_dbf);5858+ return irq_dbf;5959+ }6060+6161+ irq_dbr = platform_get_irq_byname(pdev, "ONKEY_DBR");6262+ if (irq_dbr < 0) {6363+ dev_err(&pdev->dev, "No IRQ for ONKEY_DBR, error=%d\n", irq_dbr);6464+ return irq_dbr;6565+ }6666+6767+ ponkey = kzalloc(sizeof(struct ab8500_ponkey), GFP_KERNEL);6868+ input = input_allocate_device();6969+ if (!ponkey || !input) {7070+ error = -ENOMEM;7171+ goto err_free_mem;7272+ }7373+7474+ ponkey->idev = input;7575+ ponkey->ab8500 = ab8500;7676+ ponkey->irq_dbf = irq_dbf;7777+ ponkey->irq_dbr = irq_dbr;7878+7979+ input->name = "AB8500 POn(PowerOn) Key";8080+ input->dev.parent = &pdev->dev;8181+8282+ input_set_capability(input, EV_KEY, KEY_POWER);8383+8484+ error = request_any_context_irq(ponkey->irq_dbf, ab8500_ponkey_handler,8585+ 0, "ab8500-ponkey-dbf", ponkey);8686+ if (error < 0) {8787+ dev_err(ab8500->dev, "Failed to request dbf IRQ#%d: %d\n",8888+ ponkey->irq_dbf, error);8989+ goto err_free_mem;9090+ }9191+9292+ error = request_any_context_irq(ponkey->irq_dbr, ab8500_ponkey_handler,9393+ 0, "ab8500-ponkey-dbr", ponkey);9494+ if (error < 0) {9595+ dev_err(ab8500->dev, "Failed to request dbr IRQ#%d: %d\n",9696+ ponkey->irq_dbr, error);9797+ goto err_free_dbf_irq;9898+ }9999+100100+ error = input_register_device(ponkey->idev);101101+ if (error) {102102+ dev_err(ab8500->dev, "Can't register input device: %d\n", error);103103+ goto err_free_dbr_irq;104104+ }105105+106106+ platform_set_drvdata(pdev, ponkey);107107+ return 0;108108+109109+err_free_dbr_irq:110110+ free_irq(ponkey->irq_dbr, ponkey);111111+err_free_dbf_irq:112112+ free_irq(ponkey->irq_dbf, ponkey);113113+err_free_mem:114114+ input_free_device(input);115115+ kfree(ponkey);116116+117117+ return error;118118+}119119+120120+static int __devexit ab8500_ponkey_remove(struct platform_device *pdev)121121+{122122+ struct ab8500_ponkey *ponkey = platform_get_drvdata(pdev);123123+124124+ free_irq(ponkey->irq_dbf, ponkey);125125+ free_irq(ponkey->irq_dbr, ponkey);126126+ input_unregister_device(ponkey->idev);127127+ kfree(ponkey);128128+129129+ platform_set_drvdata(pdev, NULL);130130+131131+ return 0;132132+}133133+134134+static struct platform_driver ab8500_ponkey_driver = {135135+ .driver = {136136+ .name = "ab8500-poweron-key",137137+ .owner = THIS_MODULE,138138+ },139139+ .probe = ab8500_ponkey_probe,140140+ .remove = __devexit_p(ab8500_ponkey_remove),141141+};142142+143143+static int __init ab8500_ponkey_init(void)144144+{145145+ return platform_driver_register(&ab8500_ponkey_driver);146146+}147147+module_init(ab8500_ponkey_init);148148+149149+static void __exit ab8500_ponkey_exit(void)150150+{151151+ platform_driver_unregister(&ab8500_ponkey_driver);152152+}153153+module_exit(ab8500_ponkey_exit);154154+155155+MODULE_LICENSE("GPL v2");156156+MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");157157+MODULE_DESCRIPTION("ST-Ericsson AB8500 Power-ON(Pon) Key driver");
+62-25
drivers/input/misc/ati_remote2.c
···483483}484484485485static int ati_remote2_getkeycode(struct input_dev *idev,486486- unsigned int scancode, unsigned int *keycode)486486+ struct input_keymap_entry *ke)487487{488488 struct ati_remote2 *ar2 = input_get_drvdata(idev);489489 unsigned int mode;490490- int index;490490+ int offset;491491+ unsigned int index;492492+ unsigned int scancode;491493492492- mode = scancode >> 8;493493- if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))494494- return -EINVAL;494494+ if (ke->flags & INPUT_KEYMAP_BY_INDEX) {495495+ index = ke->index;496496+ if (index >= ATI_REMOTE2_MODES *497497+ ARRAY_SIZE(ati_remote2_key_table))498498+ return -EINVAL;495499496496- index = ati_remote2_lookup(scancode & 0xFF);497497- if (index < 0)498498- return -EINVAL;500500+ mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);501501+ offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);502502+ scancode = (mode << 8) + ati_remote2_key_table[offset].hw_code;503503+ } else {504504+ if (input_scancode_to_scalar(ke, &scancode))505505+ return -EINVAL;499506500500- *keycode = ar2->keycode[mode][index];507507+ mode = scancode >> 8;508508+ if (mode > ATI_REMOTE2_PC)509509+ return -EINVAL;510510+511511+ offset = ati_remote2_lookup(scancode & 0xff);512512+ if (offset < 0)513513+ return -EINVAL;514514+515515+ index = mode * ARRAY_SIZE(ati_remote2_key_table) + offset;516516+ }517517+518518+ ke->keycode = ar2->keycode[mode][offset];519519+ ke->len = sizeof(scancode);520520+ memcpy(&ke->scancode, &scancode, sizeof(scancode));521521+ ke->index = index;522522+501523 return 0;502524}503525504526static int ati_remote2_setkeycode(struct input_dev *idev,505505- unsigned int scancode, unsigned int keycode)527527+ const struct input_keymap_entry *ke,528528+ unsigned int *old_keycode)506529{507530 struct ati_remote2 *ar2 = input_get_drvdata(idev);508508- unsigned int mode, old_keycode;509509- int index;531531+ unsigned int mode;532532+ int offset;533533+ unsigned int index;534534+ unsigned int scancode;510535511511- mode = scancode >> 8;512512- if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))513513- return -EINVAL;536536+ if (ke->flags & INPUT_KEYMAP_BY_INDEX) {537537+ if (ke->index >= ATI_REMOTE2_MODES *538538+ ARRAY_SIZE(ati_remote2_key_table))539539+ return -EINVAL;514540515515- index = ati_remote2_lookup(scancode & 0xFF);516516- if (index < 0)517517- return -EINVAL;541541+ mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);542542+ offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);543543+ } else {544544+ if (input_scancode_to_scalar(ke, &scancode))545545+ return -EINVAL;518546519519- old_keycode = ar2->keycode[mode][index];520520- ar2->keycode[mode][index] = keycode;521521- __set_bit(keycode, idev->keybit);547547+ mode = scancode >> 8;548548+ if (mode > ATI_REMOTE2_PC)549549+ return -EINVAL;550550+551551+ offset = ati_remote2_lookup(scancode & 0xff);552552+ if (offset < 0)553553+ return -EINVAL;554554+ }555555+556556+ *old_keycode = ar2->keycode[mode][offset];557557+ ar2->keycode[mode][offset] = ke->keycode;558558+ __set_bit(ke->keycode, idev->keybit);522559523560 for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {524561 for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {525525- if (ar2->keycode[mode][index] == old_keycode)562562+ if (ar2->keycode[mode][index] == *old_keycode)526563 return 0;527564 }528565 }529566530530- __clear_bit(old_keycode, idev->keybit);567567+ __clear_bit(*old_keycode, idev->keybit);531568532569 return 0;533570}···612575 idev->open = ati_remote2_open;613576 idev->close = ati_remote2_close;614577615615- idev->getkeycode = ati_remote2_getkeycode;616616- idev->setkeycode = ati_remote2_setkeycode;578578+ idev->getkeycode_new = ati_remote2_getkeycode;579579+ idev->setkeycode_new = ati_remote2_setkeycode;617580618581 idev->name = ar2->name;619582 idev->phys = ar2->phys;
···866866 spin_lock_init(&mousedev->client_lock);867867 mutex_init(&mousedev->mutex);868868 lockdep_set_subclass(&mousedev->mutex,869869- minor == MOUSEDEV_MIX ? MOUSEDEV_MIX : 0);869869+ minor == MOUSEDEV_MIX ? SINGLE_DEPTH_NESTING : 0);870870 init_waitqueue_head(&mousedev->wait);871871872872 if (minor == MOUSEDEV_MIX)
+9
drivers/input/serio/Kconfig
···226226 To compile this driver as a module, choose M here;227227 the module will be called ams_delta_serio.228228229229+config SERIO_PS2MULT230230+ tristate "TQC PS/2 multiplexer"231231+ help232232+ Say Y here if you have the PS/2 line multiplexer like the one233233+ present on TQC boads.234234+235235+ To compile this driver as a module, choose M here: the236236+ module will be called ps2mult.237237+229238endif
···11+/*22+ * TQC PS/2 Multiplexer driver33+ *44+ * Copyright (C) 2010 Dmitry Eremin-Solenikov55+ *66+ * This program is free software; you can redistribute it and/or modify it77+ * under the terms of the GNU General Public License version 2 as published by88+ * the Free Software Foundation.99+ */1010+1111+1212+#include <linux/kernel.h>1313+#include <linux/slab.h>1414+#include <linux/module.h>1515+#include <linux/serio.h>1616+1717+MODULE_AUTHOR("Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>");1818+MODULE_DESCRIPTION("TQC PS/2 Multiplexer driver");1919+MODULE_LICENSE("GPL");2020+2121+#define PS2MULT_KB_SELECTOR 0xA02222+#define PS2MULT_MS_SELECTOR 0xA12323+#define PS2MULT_ESCAPE 0x7D2424+#define PS2MULT_BSYNC 0x7E2525+#define PS2MULT_SESSION_START 0x552626+#define PS2MULT_SESSION_END 0x562727+2828+struct ps2mult_port {2929+ struct serio *serio;3030+ unsigned char sel;3131+ bool registered;3232+};3333+3434+#define PS2MULT_NUM_PORTS 23535+#define PS2MULT_KBD_PORT 03636+#define PS2MULT_MOUSE_PORT 13737+3838+struct ps2mult {3939+ struct serio *mx_serio;4040+ struct ps2mult_port ports[PS2MULT_NUM_PORTS];4141+4242+ spinlock_t lock;4343+ struct ps2mult_port *in_port;4444+ struct ps2mult_port *out_port;4545+ bool escape;4646+};4747+4848+/* First MUST come PS2MULT_NUM_PORTS selectors */4949+static const unsigned char ps2mult_controls[] = {5050+ PS2MULT_KB_SELECTOR, PS2MULT_MS_SELECTOR,5151+ PS2MULT_ESCAPE, PS2MULT_BSYNC,5252+ PS2MULT_SESSION_START, PS2MULT_SESSION_END,5353+};5454+5555+static const struct serio_device_id ps2mult_serio_ids[] = {5656+ {5757+ .type = SERIO_RS232,5858+ .proto = SERIO_PS2MULT,5959+ .id = SERIO_ANY,6060+ .extra = SERIO_ANY,6161+ },6262+ { 0 }6363+};6464+6565+MODULE_DEVICE_TABLE(serio, ps2mult_serio_ids);6666+6767+static void ps2mult_select_port(struct ps2mult *psm, struct ps2mult_port *port)6868+{6969+ struct serio *mx_serio = psm->mx_serio;7070+7171+ serio_write(mx_serio, port->sel);7272+ psm->out_port = port;7373+ dev_dbg(&mx_serio->dev, "switched to sel %02x\n", port->sel);7474+}7575+7676+static int ps2mult_serio_write(struct serio *serio, unsigned char data)7777+{7878+ struct serio *mx_port = serio->parent;7979+ struct ps2mult *psm = serio_get_drvdata(mx_port);8080+ struct ps2mult_port *port = serio->port_data;8181+ bool need_escape;8282+ unsigned long flags;8383+8484+ spin_lock_irqsave(&psm->lock, flags);8585+8686+ if (psm->out_port != port)8787+ ps2mult_select_port(psm, port);8888+8989+ need_escape = memchr(ps2mult_controls, data, sizeof(ps2mult_controls));9090+9191+ dev_dbg(&serio->dev,9292+ "write: %s%02x\n", need_escape ? "ESC " : "", data);9393+9494+ if (need_escape)9595+ serio_write(mx_port, PS2MULT_ESCAPE);9696+9797+ serio_write(mx_port, data);9898+9999+ spin_unlock_irqrestore(&psm->lock, flags);100100+101101+ return 0;102102+}103103+104104+static int ps2mult_serio_start(struct serio *serio)105105+{106106+ struct ps2mult *psm = serio_get_drvdata(serio->parent);107107+ struct ps2mult_port *port = serio->port_data;108108+ unsigned long flags;109109+110110+ spin_lock_irqsave(&psm->lock, flags);111111+ port->registered = true;112112+ spin_unlock_irqrestore(&psm->lock, flags);113113+114114+ return 0;115115+}116116+117117+static void ps2mult_serio_stop(struct serio *serio)118118+{119119+ struct ps2mult *psm = serio_get_drvdata(serio->parent);120120+ struct ps2mult_port *port = serio->port_data;121121+ unsigned long flags;122122+123123+ spin_lock_irqsave(&psm->lock, flags);124124+ port->registered = false;125125+ spin_unlock_irqrestore(&psm->lock, flags);126126+}127127+128128+static int ps2mult_create_port(struct ps2mult *psm, int i)129129+{130130+ struct serio *mx_serio = psm->mx_serio;131131+ struct serio *serio;132132+133133+ serio = kzalloc(sizeof(struct serio), GFP_KERNEL);134134+ if (!serio)135135+ return -ENOMEM;136136+137137+ strlcpy(serio->name, "TQC PS/2 Multiplexer", sizeof(serio->name));138138+ snprintf(serio->phys, sizeof(serio->phys),139139+ "%s/port%d", mx_serio->phys, i);140140+ serio->id.type = SERIO_8042;141141+ serio->write = ps2mult_serio_write;142142+ serio->start = ps2mult_serio_start;143143+ serio->stop = ps2mult_serio_stop;144144+ serio->parent = psm->mx_serio;145145+ serio->port_data = &psm->ports[i];146146+147147+ psm->ports[i].serio = serio;148148+149149+ return 0;150150+}151151+152152+static void ps2mult_reset(struct ps2mult *psm)153153+{154154+ unsigned long flags;155155+156156+ spin_lock_irqsave(&psm->lock, flags);157157+158158+ serio_write(psm->mx_serio, PS2MULT_SESSION_END);159159+ serio_write(psm->mx_serio, PS2MULT_SESSION_START);160160+161161+ ps2mult_select_port(psm, &psm->ports[PS2MULT_KBD_PORT]);162162+163163+ spin_unlock_irqrestore(&psm->lock, flags);164164+}165165+166166+static int ps2mult_connect(struct serio *serio, struct serio_driver *drv)167167+{168168+ struct ps2mult *psm;169169+ int i;170170+ int error;171171+172172+ if (!serio->write)173173+ return -EINVAL;174174+175175+ psm = kzalloc(sizeof(*psm), GFP_KERNEL);176176+ if (!psm)177177+ return -ENOMEM;178178+179179+ spin_lock_init(&psm->lock);180180+ psm->mx_serio = serio;181181+182182+ for (i = 0; i < PS2MULT_NUM_PORTS; i++) {183183+ psm->ports[i].sel = ps2mult_controls[i];184184+ error = ps2mult_create_port(psm, i);185185+ if (error)186186+ goto err_out;187187+ }188188+189189+ psm->in_port = psm->out_port = &psm->ports[PS2MULT_KBD_PORT];190190+191191+ serio_set_drvdata(serio, psm);192192+ error = serio_open(serio, drv);193193+ if (error)194194+ goto err_out;195195+196196+ ps2mult_reset(psm);197197+198198+ for (i = 0; i < PS2MULT_NUM_PORTS; i++) {199199+ struct serio *s = psm->ports[i].serio;200200+201201+ dev_info(&serio->dev, "%s port at %s\n", s->name, serio->phys);202202+ serio_register_port(s);203203+ }204204+205205+ return 0;206206+207207+err_out:208208+ while (--i >= 0)209209+ kfree(psm->ports[i].serio);210210+ kfree(serio);211211+ return error;212212+}213213+214214+static void ps2mult_disconnect(struct serio *serio)215215+{216216+ struct ps2mult *psm = serio_get_drvdata(serio);217217+218218+ /* Note that serio core already take care of children ports */219219+ serio_write(serio, PS2MULT_SESSION_END);220220+ serio_close(serio);221221+ kfree(psm);222222+223223+ serio_set_drvdata(serio, NULL);224224+}225225+226226+static int ps2mult_reconnect(struct serio *serio)227227+{228228+ struct ps2mult *psm = serio_get_drvdata(serio);229229+230230+ ps2mult_reset(psm);231231+232232+ return 0;233233+}234234+235235+static irqreturn_t ps2mult_interrupt(struct serio *serio,236236+ unsigned char data, unsigned int dfl)237237+{238238+ struct ps2mult *psm = serio_get_drvdata(serio);239239+ struct ps2mult_port *in_port;240240+ unsigned long flags;241241+242242+ dev_dbg(&serio->dev, "Received %02x flags %02x\n", data, dfl);243243+244244+ spin_lock_irqsave(&psm->lock, flags);245245+246246+ if (psm->escape) {247247+ psm->escape = false;248248+ in_port = psm->in_port;249249+ if (in_port->registered)250250+ serio_interrupt(in_port->serio, data, dfl);251251+ goto out;252252+ }253253+254254+ switch (data) {255255+ case PS2MULT_ESCAPE:256256+ dev_dbg(&serio->dev, "ESCAPE\n");257257+ psm->escape = true;258258+ break;259259+260260+ case PS2MULT_BSYNC:261261+ dev_dbg(&serio->dev, "BSYNC\n");262262+ psm->in_port = psm->out_port;263263+ break;264264+265265+ case PS2MULT_SESSION_START:266266+ dev_dbg(&serio->dev, "SS\n");267267+ break;268268+269269+ case PS2MULT_SESSION_END:270270+ dev_dbg(&serio->dev, "SE\n");271271+ break;272272+273273+ case PS2MULT_KB_SELECTOR:274274+ dev_dbg(&serio->dev, "KB\n");275275+ psm->in_port = &psm->ports[PS2MULT_KBD_PORT];276276+ break;277277+278278+ case PS2MULT_MS_SELECTOR:279279+ dev_dbg(&serio->dev, "MS\n");280280+ psm->in_port = &psm->ports[PS2MULT_MOUSE_PORT];281281+ break;282282+283283+ default:284284+ in_port = psm->in_port;285285+ if (in_port->registered)286286+ serio_interrupt(in_port->serio, data, dfl);287287+ break;288288+ }289289+290290+ out:291291+ spin_unlock_irqrestore(&psm->lock, flags);292292+ return IRQ_HANDLED;293293+}294294+295295+static struct serio_driver ps2mult_drv = {296296+ .driver = {297297+ .name = "ps2mult",298298+ },299299+ .description = "TQC PS/2 Multiplexer driver",300300+ .id_table = ps2mult_serio_ids,301301+ .interrupt = ps2mult_interrupt,302302+ .connect = ps2mult_connect,303303+ .disconnect = ps2mult_disconnect,304304+ .reconnect = ps2mult_reconnect,305305+};306306+307307+static int __init ps2mult_init(void)308308+{309309+ return serio_register_driver(&ps2mult_drv);310310+}311311+312312+static void __exit ps2mult_exit(void)313313+{314314+ serio_unregister_driver(&ps2mult_drv);315315+}316316+317317+module_init(ps2mult_init);318318+module_exit(ps2mult_exit);
+81-44
drivers/input/serio/serio.c
···3737#include <linux/slab.h>3838#include <linux/kthread.h>3939#include <linux/mutex.h>4040-#include <linux/freezer.h>41404241MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");4342MODULE_DESCRIPTION("Serio abstraction core");···5556static void serio_add_port(struct serio *serio);5657static int serio_reconnect_port(struct serio *serio);5758static void serio_disconnect_port(struct serio *serio);5858-static void serio_reconnect_chain(struct serio *serio);5959+static void serio_reconnect_subtree(struct serio *serio);5960static void serio_attach_driver(struct serio_driver *drv);60616162static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)···151152enum serio_event_type {152153 SERIO_RESCAN_PORT,153154 SERIO_RECONNECT_PORT,154154- SERIO_RECONNECT_CHAIN,155155+ SERIO_RECONNECT_SUBTREE,155156 SERIO_REGISTER_PORT,156157 SERIO_ATTACH_DRIVER,157158};···291292 serio_find_driver(event->object);292293 break;293294294294- case SERIO_RECONNECT_CHAIN:295295- serio_reconnect_chain(event->object);295295+ case SERIO_RECONNECT_SUBTREE:296296+ serio_reconnect_subtree(event->object);296297 break;297298298299 case SERIO_ATTACH_DRIVER:···329330}330331331332/*332332- * Destroy child serio port (if any) that has not been fully registered yet.333333+ * Locate child serio port (if any) that has not been fully registered yet.333334 *334334- * Note that we rely on the fact that port can have only one child and therefore335335- * only one child registration request can be pending. Additionally, children336336- * are registered by driver's connect() handler so there can't be a grandchild337337- * pending registration together with a child.335335+ * Children are registered by driver's connect() handler so there can't be a336336+ * grandchild pending registration together with a child.338337 */339338static struct serio *serio_get_pending_child(struct serio *parent)340339{···446449 if (!strncmp(buf, "none", count)) {447450 serio_disconnect_port(serio);448451 } else if (!strncmp(buf, "reconnect", count)) {449449- serio_reconnect_chain(serio);452452+ serio_reconnect_subtree(serio);450453 } else if (!strncmp(buf, "rescan", count)) {451454 serio_disconnect_port(serio);452455 serio_find_driver(serio);···513516 __module_get(THIS_MODULE);514517515518 INIT_LIST_HEAD(&serio->node);519519+ INIT_LIST_HEAD(&serio->child_node);520520+ INIT_LIST_HEAD(&serio->children);516521 spin_lock_init(&serio->lock);517522 mutex_init(&serio->drv_mutex);518523 device_initialize(&serio->dev);···537538 */538539static void serio_add_port(struct serio *serio)539540{541541+ struct serio *parent = serio->parent;540542 int error;541543542542- if (serio->parent) {543543- serio_pause_rx(serio->parent);544544- serio->parent->child = serio;545545- serio_continue_rx(serio->parent);544544+ if (parent) {545545+ serio_pause_rx(parent);546546+ list_add_tail(&serio->child_node, &parent->children);547547+ serio_continue_rx(parent);546548 }547549548550 list_add_tail(&serio->node, &serio_list);···559559}560560561561/*562562- * serio_destroy_port() completes deregistration process and removes562562+ * serio_destroy_port() completes unregistration process and removes563563 * port from the system564564 */565565static void serio_destroy_port(struct serio *serio)566566{567567 struct serio *child;568568569569- child = serio_get_pending_child(serio);570570- if (child) {569569+ while ((child = serio_get_pending_child(serio)) != NULL) {571570 serio_remove_pending_events(child);572571 put_device(&child->dev);573572 }···576577577578 if (serio->parent) {578579 serio_pause_rx(serio->parent);579579- serio->parent->child = NULL;580580+ list_del_init(&serio->child_node);580581 serio_continue_rx(serio->parent);581582 serio->parent = NULL;582583 }···608609}609610610611/*611611- * Reconnect serio port and all its children (re-initialize attached devices)612612+ * Reconnect serio port and all its children (re-initialize attached613613+ * devices).612614 */613613-static void serio_reconnect_chain(struct serio *serio)615615+static void serio_reconnect_subtree(struct serio *root)614616{617617+ struct serio *s = root;618618+ int error;619619+615620 do {616616- if (serio_reconnect_port(serio)) {617617- /* Ok, old children are now gone, we are done */618618- break;621621+ error = serio_reconnect_port(s);622622+ if (!error) {623623+ /*624624+ * Reconnect was successful, move on to do the625625+ * first child.626626+ */627627+ if (!list_empty(&s->children)) {628628+ s = list_first_entry(&s->children,629629+ struct serio, child_node);630630+ continue;631631+ }619632 }620620- serio = serio->child;621621- } while (serio);633633+634634+ /*635635+ * Either it was a leaf node or reconnect failed and it636636+ * became a leaf node. Continue reconnecting starting with637637+ * the next sibling of the parent node.638638+ */639639+ while (s != root) {640640+ struct serio *parent = s->parent;641641+642642+ if (!list_is_last(&s->child_node, &parent->children)) {643643+ s = list_entry(s->child_node.next,644644+ struct serio, child_node);645645+ break;646646+ }647647+648648+ s = parent;649649+ }650650+ } while (s != root);622651}623652624653/*625654 * serio_disconnect_port() unbinds a port from its driver. As a side effect626626- * all child ports are unbound and destroyed.655655+ * all children ports are unbound and destroyed.627656 */628657static void serio_disconnect_port(struct serio *serio)629658{630630- struct serio *s, *parent;659659+ struct serio *s = serio;631660632632- if (serio->child) {661661+ /*662662+ * Children ports should be disconnected and destroyed663663+ * first; we travel the tree in depth-first order.664664+ */665665+ while (!list_empty(&serio->children)) {666666+667667+ /* Locate a leaf */668668+ while (!list_empty(&s->children))669669+ s = list_first_entry(&s->children,670670+ struct serio, child_node);671671+633672 /*634634- * Children ports should be disconnected and destroyed635635- * first, staring with the leaf one, since we don't want636636- * to do recursion673673+ * Prune this leaf node unless it is the one we674674+ * started with.637675 */638638- for (s = serio; s->child; s = s->child)639639- /* empty */;640640-641641- do {642642- parent = s->parent;676676+ if (s != serio) {677677+ struct serio *parent = s->parent;643678644679 device_release_driver(&s->dev);645680 serio_destroy_port(s);646646- } while ((s = parent) != serio);681681+682682+ s = parent;683683+ }647684 }648685649686 /*650650- * Ok, no children left, now disconnect this port687687+ * OK, no children left, now disconnect this port.651688 */652689 device_release_driver(&serio->dev);653690}···696661697662void serio_reconnect(struct serio *serio)698663{699699- serio_queue_event(serio, NULL, SERIO_RECONNECT_CHAIN);664664+ serio_queue_event(serio, NULL, SERIO_RECONNECT_SUBTREE);700665}701666EXPORT_SYMBOL(serio_reconnect);702667···724689EXPORT_SYMBOL(serio_unregister_port);725690726691/*727727- * Safely unregisters child port if one is present.692692+ * Safely unregisters children ports if they are present.728693 */729694void serio_unregister_child_port(struct serio *serio)730695{696696+ struct serio *s, *next;697697+731698 mutex_lock(&serio_mutex);732732- if (serio->child) {733733- serio_disconnect_port(serio->child);734734- serio_destroy_port(serio->child);699699+ list_for_each_entry_safe(s, next, &serio->children, child_node) {700700+ serio_disconnect_port(s);701701+ serio_destroy_port(s);735702 }736703 mutex_unlock(&serio_mutex);737704}
+65-16
drivers/input/sparse-keymap.c
···2222MODULE_LICENSE("GPL v2");2323MODULE_VERSION("0.1");24242525+static unsigned int sparse_keymap_get_key_index(struct input_dev *dev,2626+ const struct key_entry *k)2727+{2828+ struct key_entry *key;2929+ unsigned int idx = 0;3030+3131+ for (key = dev->keycode; key->type != KE_END; key++) {3232+ if (key->type == KE_KEY) {3333+ if (key == k)3434+ break;3535+ idx++;3636+ }3737+ }3838+3939+ return idx;4040+}4141+4242+static struct key_entry *sparse_keymap_entry_by_index(struct input_dev *dev,4343+ unsigned int index)4444+{4545+ struct key_entry *key;4646+ unsigned int key_cnt = 0;4747+4848+ for (key = dev->keycode; key->type != KE_END; key++)4949+ if (key->type == KE_KEY)5050+ if (key_cnt++ == index)5151+ return key;5252+5353+ return NULL;5454+}5555+2556/**2657 * sparse_keymap_entry_from_scancode - perform sparse keymap lookup2758 * @dev: Input device using sparse keymap···9564}9665EXPORT_SYMBOL(sparse_keymap_entry_from_keycode);97666767+static struct key_entry *sparse_keymap_locate(struct input_dev *dev,6868+ const struct input_keymap_entry *ke)6969+{7070+ struct key_entry *key;7171+ unsigned int scancode;7272+7373+ if (ke->flags & INPUT_KEYMAP_BY_INDEX)7474+ key = sparse_keymap_entry_by_index(dev, ke->index);7575+ else if (input_scancode_to_scalar(ke, &scancode) == 0)7676+ key = sparse_keymap_entry_from_scancode(dev, scancode);7777+ else7878+ key = NULL;7979+8080+ return key;8181+}8282+9883static int sparse_keymap_getkeycode(struct input_dev *dev,9999- unsigned int scancode,100100- unsigned int *keycode)8484+ struct input_keymap_entry *ke)10185{10286 const struct key_entry *key;1038710488 if (dev->keycode) {105105- key = sparse_keymap_entry_from_scancode(dev, scancode);8989+ key = sparse_keymap_locate(dev, ke);10690 if (key && key->type == KE_KEY) {107107- *keycode = key->keycode;9191+ ke->keycode = key->keycode;9292+ if (!(ke->flags & INPUT_KEYMAP_BY_INDEX))9393+ ke->index =9494+ sparse_keymap_get_key_index(dev, key);9595+ ke->len = sizeof(key->code);9696+ memcpy(ke->scancode, &key->code, sizeof(key->code));10897 return 0;10998 }11099 }···13382}1348313584static int sparse_keymap_setkeycode(struct input_dev *dev,136136- unsigned int scancode,137137- unsigned int keycode)8585+ const struct input_keymap_entry *ke,8686+ unsigned int *old_keycode)13887{13988 struct key_entry *key;140140- int old_keycode;1418914290 if (dev->keycode) {143143- key = sparse_keymap_entry_from_scancode(dev, scancode);9191+ key = sparse_keymap_locate(dev, ke);14492 if (key && key->type == KE_KEY) {145145- old_keycode = key->keycode;146146- key->keycode = keycode;147147- set_bit(keycode, dev->keybit);148148- if (!sparse_keymap_entry_from_keycode(dev, old_keycode))149149- clear_bit(old_keycode, dev->keybit);9393+ *old_keycode = key->keycode;9494+ key->keycode = ke->keycode;9595+ set_bit(ke->keycode, dev->keybit);9696+ if (!sparse_keymap_entry_from_keycode(dev, *old_keycode))9797+ clear_bit(*old_keycode, dev->keybit);15098 return 0;15199 }152100 }···209159210160 dev->keycode = map;211161 dev->keycodemax = map_size;212212- dev->getkeycode = sparse_keymap_getkeycode;213213- dev->setkeycode = sparse_keymap_setkeycode;162162+ dev->getkeycode_new = sparse_keymap_getkeycode;163163+ dev->setkeycode_new = sparse_keymap_setkeycode;214164215165 return 0;216166217167 err_out:218168 kfree(map);219169 return error;220220-221170}222171EXPORT_SYMBOL(sparse_keymap_setup);223172
+11
drivers/input/tablet/Kconfig
···4949 To compile this driver as a module, choose M here: the5050 module will be called gtco.51515252+config TABLET_USB_HANWANG5353+ tristate "Hanwang Art Master III tablet support (USB)"5454+ depends on USB_ARCH_HAS_HCD5555+ select USB5656+ help5757+ Say Y here if you want to use the USB version of the Hanwang Art5858+ Master III tablet.5959+6060+ To compile this driver as a module, choose M here: the6161+ module will be called hanwang.6262+5263config TABLET_USB_KBTAB5364 tristate "KB Gear JamStudio tablet support (USB)"5465 depends on USB_ARCH_HAS_HCD
···120120121121out:122122 mutex_unlock(&wacom->lock);123123- if (retval)124124- usb_autopm_put_interface(wacom->intf);123123+ usb_autopm_put_interface(wacom->intf);125124 return retval;126125}127126128127static void wacom_close(struct input_dev *dev)129128{130129 struct wacom *wacom = input_get_drvdata(dev);130130+ int autopm_error;131131+132132+ autopm_error = usb_autopm_get_interface(wacom->intf);131133132134 mutex_lock(&wacom->lock);133135 usb_kill_urb(wacom->irq);···137135 wacom->intf->needs_remote_wakeup = 0;138136 mutex_unlock(&wacom->lock);139137140140- usb_autopm_put_interface(wacom->intf);138138+ if (!autopm_error)139139+ usb_autopm_put_interface(wacom->intf);141140}142141143142static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc,···199196 features->pktlen = WACOM_PKGLEN_TPC2FG;200197 features->device_type = BTN_TOOL_TRIPLETAP;201198 }202202- features->x_max =203203- get_unaligned_le16(&report[i + 3]);204204- features->x_phy =205205- get_unaligned_le16(&report[i + 6]);206206- features->unit = report[i + 9];207207- features->unitExpo = report[i + 11];208208- i += 12;199199+ if (features->type == BAMBOO_PT) {200200+ /* need to reset back */201201+ features->pktlen = WACOM_PKGLEN_BBTOUCH;202202+ features->device_type = BTN_TOOL_TRIPLETAP;203203+ features->x_phy =204204+ get_unaligned_le16(&report[i + 5]);205205+ features->x_max =206206+ get_unaligned_le16(&report[i + 8]);207207+ i += 15;208208+ } else {209209+ features->x_max =210210+ get_unaligned_le16(&report[i + 3]);211211+ features->x_phy =212212+ get_unaligned_le16(&report[i + 6]);213213+ features->unit = report[i + 9];214214+ features->unitExpo = report[i + 11];215215+ i += 12;216216+ }209217 } else if (pen) {210218 /* penabled only accepts exact bytes of data */211219 if (features->type == TABLETPC2FG)212220 features->pktlen = WACOM_PKGLEN_GRAPHIRE;221221+ if (features->type == BAMBOO_PT)222222+ features->pktlen = WACOM_PKGLEN_BBFUN;213223 features->device_type = BTN_TOOL_PEN;214224 features->x_max =215225 get_unaligned_le16(&report[i + 3]);···251235 features->y_phy =252236 get_unaligned_le16(&report[i + 6]);253237 i += 7;238238+ } else if (features->type == BAMBOO_PT) {239239+ /* need to reset back */240240+ features->pktlen = WACOM_PKGLEN_BBTOUCH;241241+ features->device_type = BTN_TOOL_TRIPLETAP;242242+ features->y_phy =243243+ get_unaligned_le16(&report[i + 3]);244244+ features->y_max =245245+ get_unaligned_le16(&report[i + 6]);246246+ i += 12;254247 } else {255248 features->y_max =256249 features->x_max;···271246 /* penabled only accepts exact bytes of data */272247 if (features->type == TABLETPC2FG)273248 features->pktlen = WACOM_PKGLEN_GRAPHIRE;249249+ if (features->type == BAMBOO_PT)250250+ features->pktlen = WACOM_PKGLEN_BBFUN;274251 features->device_type = BTN_TOOL_PEN;275252 features->y_max =276253 get_unaligned_le16(&report[i + 3]);···323296 if (!rep_data)324297 return error;325298326326- /* ask to report tablet data if it is 2FGT or not a Tablet PC */327327- if (features->device_type == BTN_TOOL_TRIPLETAP) {299299+ /* ask to report tablet data if it is 2FGT Tablet PC or300300+ * not a Tablet PC */301301+ if (features->type == TABLETPC2FG) {328302 do {329303 rep_data[0] = 3;330304 rep_data[1] = 4;···337309 WAC_HID_FEATURE_REPORT, report_id,338310 rep_data, 3);339311 } while ((error < 0 || rep_data[1] != 4) && limit++ < 5);340340- } else if (features->type != TABLETPC && features->type != TABLETPC2FG) {312312+ } else if (features->type != TABLETPC) {341313 do {342314 rep_data[0] = 2;343315 rep_data[1] = 2;···362334 struct usb_host_interface *interface = intf->cur_altsetting;363335 struct hid_descriptor *hid_desc;364336365365- /* default device to penabled */337337+ /* default features */366338 features->device_type = BTN_TOOL_PEN;339339+ features->x_fuzz = 4;340340+ features->y_fuzz = 4;341341+ features->pressure_fuzz = 0;342342+ features->distance_fuzz = 0;367343368368- /* only Tablet PCs need to retrieve the info */369369- if ((features->type != TABLETPC) && (features->type != TABLETPC2FG))344344+ /* only Tablet PCs and Bamboo P&T need to retrieve the info */345345+ if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&346346+ (features->type != BAMBOO_PT))370347 goto out;371348372349 if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {···385352 error = wacom_parse_hid(intf, hid_desc, features);386353 if (error)387354 goto out;388388-389389- /* touch device found but size is not defined. use default */390390- if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) {391391- features->x_max = 1023;392392- features->y_max = 1023;393393- }394355395356 out:396357 return error;···521494 if (error)522495 goto fail2;523496497497+ wacom_setup_device_quirks(features);498498+524499 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));525500526526- if (features->type == TABLETPC || features->type == TABLETPC2FG) {501501+ if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {527502 /* Append the device type to the name */528503 strlcat(wacom_wac->name,529504 features->device_type == BTN_TOOL_PEN ?
+239-14
drivers/input/tablet/wacom_wac.c
···857857 return retval;858858}859859860860+static int wacom_bpt_touch(struct wacom_wac *wacom)861861+{862862+ struct wacom_features *features = &wacom->features;863863+ struct input_dev *input = wacom->input;864864+ unsigned char *data = wacom->data;865865+ int sp = 0, sx = 0, sy = 0, count = 0;866866+ int i;867867+868868+ for (i = 0; i < 2; i++) {869869+ int p = data[9 * i + 2];870870+ input_mt_slot(input, i);871871+ /*872872+ * Touch events need to be disabled while stylus is873873+ * in proximity because user's hand is resting on touchpad874874+ * and sending unwanted events. User expects tablet buttons875875+ * to continue working though.876876+ */877877+ if (p && !wacom->shared->stylus_in_proximity) {878878+ int x = get_unaligned_be16(&data[9 * i + 3]) & 0x7ff;879879+ int y = get_unaligned_be16(&data[9 * i + 5]) & 0x7ff;880880+ if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {881881+ x <<= 5;882882+ y <<= 5;883883+ }884884+ input_report_abs(input, ABS_MT_PRESSURE, p);885885+ input_report_abs(input, ABS_MT_POSITION_X, x);886886+ input_report_abs(input, ABS_MT_POSITION_Y, y);887887+ if (wacom->id[i] < 0)888888+ wacom->id[i] = wacom->trk_id++ & MAX_TRACKING_ID;889889+ if (!count++)890890+ sp = p, sx = x, sy = y;891891+ } else {892892+ wacom->id[i] = -1;893893+ }894894+ input_report_abs(input, ABS_MT_TRACKING_ID, wacom->id[i]);895895+ }896896+897897+ input_report_key(input, BTN_TOUCH, count > 0);898898+ input_report_key(input, BTN_TOOL_FINGER, count == 1);899899+ input_report_key(input, BTN_TOOL_DOUBLETAP, count == 2);900900+901901+ input_report_abs(input, ABS_PRESSURE, sp);902902+ input_report_abs(input, ABS_X, sx);903903+ input_report_abs(input, ABS_Y, sy);904904+905905+ input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);906906+ input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);907907+ input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);908908+ input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);909909+910910+ input_sync(input);911911+912912+ return 0;913913+}914914+915915+static int wacom_bpt_pen(struct wacom_wac *wacom)916916+{917917+ struct input_dev *input = wacom->input;918918+ unsigned char *data = wacom->data;919919+ int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;920920+921921+ /*922922+ * Similar to Graphire protocol, data[1] & 0x20 is proximity and923923+ * data[1] & 0x18 is tool ID. 0x30 is safety check to ignore924924+ * 2 unused tool ID's.925925+ */926926+ prox = (data[1] & 0x30) == 0x30;927927+928928+ /*929929+ * All reports shared between PEN and RUBBER tool must be930930+ * forced to a known starting value (zero) when transitioning to931931+ * out-of-prox.932932+ *933933+ * If not reset then, to userspace, it will look like lost events934934+ * if new tool comes in-prox with same values as previous tool sent.935935+ *936936+ * Hardware does report zero in most out-of-prox cases but not all.937937+ */938938+ if (prox) {939939+ if (!wacom->shared->stylus_in_proximity) {940940+ if (data[1] & 0x08) {941941+ wacom->tool[0] = BTN_TOOL_RUBBER;942942+ wacom->id[0] = ERASER_DEVICE_ID;943943+ } else {944944+ wacom->tool[0] = BTN_TOOL_PEN;945945+ wacom->id[0] = STYLUS_DEVICE_ID;946946+ }947947+ wacom->shared->stylus_in_proximity = true;948948+ }949949+ x = le16_to_cpup((__le16 *)&data[2]);950950+ y = le16_to_cpup((__le16 *)&data[4]);951951+ p = le16_to_cpup((__le16 *)&data[6]);952952+ d = data[8];953953+ pen = data[1] & 0x01;954954+ btn1 = data[1] & 0x02;955955+ btn2 = data[1] & 0x04;956956+ }957957+958958+ input_report_key(input, BTN_TOUCH, pen);959959+ input_report_key(input, BTN_STYLUS, btn1);960960+ input_report_key(input, BTN_STYLUS2, btn2);961961+962962+ input_report_abs(input, ABS_X, x);963963+ input_report_abs(input, ABS_Y, y);964964+ input_report_abs(input, ABS_PRESSURE, p);965965+ input_report_abs(input, ABS_DISTANCE, d);966966+967967+ if (!prox) {968968+ wacom->id[0] = 0;969969+ wacom->shared->stylus_in_proximity = false;970970+ }971971+972972+ input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */973973+ input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */974974+975975+ return 1;976976+}977977+978978+static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)979979+{980980+ if (len == WACOM_PKGLEN_BBTOUCH)981981+ return wacom_bpt_touch(wacom);982982+ else if (len == WACOM_PKGLEN_BBFUN)983983+ return wacom_bpt_pen(wacom);984984+985985+ return 0;986986+}987987+860988void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)861989{862990 bool sync;···1030902 sync = wacom_tpc_irq(wacom_wac, len);1031903 break;1032904905905+ case BAMBOO_PT:906906+ sync = wacom_bpt_irq(wacom_wac, len);907907+ break;908908+1033909 default:1034910 sync = false;1035911 break;···1043911 input_sync(wacom_wac->input);1044912}104591310461046-static void wacom_setup_intuos(struct wacom_wac *wacom_wac)914914+static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)1047915{1048916 struct input_dev *input_dev = wacom_wac->input;10499171050918 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);10511051- input_set_capability(input_dev, EV_REL, REL_WHEEL);10521052-10531053- __set_bit(BTN_LEFT, input_dev->keybit);10541054- __set_bit(BTN_RIGHT, input_dev->keybit);10551055- __set_bit(BTN_MIDDLE, input_dev->keybit);10561056- __set_bit(BTN_SIDE, input_dev->keybit);10571057- __set_bit(BTN_EXTRA, input_dev->keybit);10589191059920 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);1060921 __set_bit(BTN_TOOL_PEN, input_dev->keybit);10611061- __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);1062922 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);1063923 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);1064924 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);10651065- __set_bit(BTN_TOOL_LENS, input_dev->keybit);1066925 __set_bit(BTN_STYLUS, input_dev->keybit);1067926 __set_bit(BTN_STYLUS2, input_dev->keybit);1068927···1062939 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);1063940 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);1064941 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);942942+}943943+944944+static void wacom_setup_intuos(struct wacom_wac *wacom_wac)945945+{946946+ struct input_dev *input_dev = wacom_wac->input;947947+948948+ input_set_capability(input_dev, EV_REL, REL_WHEEL);949949+950950+ wacom_setup_cintiq(wacom_wac);951951+952952+ __set_bit(BTN_LEFT, input_dev->keybit);953953+ __set_bit(BTN_RIGHT, input_dev->keybit);954954+ __set_bit(BTN_MIDDLE, input_dev->keybit);955955+ __set_bit(BTN_SIDE, input_dev->keybit);956956+ __set_bit(BTN_EXTRA, input_dev->keybit);957957+ __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);958958+ __set_bit(BTN_TOOL_LENS, input_dev->keybit);959959+1065960 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);1066961 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);962962+}963963+964964+void wacom_setup_device_quirks(struct wacom_features *features)965965+{966966+967967+ /* touch device found but size is not defined. use default */968968+ if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) {969969+ features->x_max = 1023;970970+ features->y_max = 1023;971971+ }972972+973973+ /* these device have multiple inputs */974974+ if (features->type == TABLETPC || features->type == TABLETPC2FG ||975975+ features->type == BAMBOO_PT)976976+ features->quirks |= WACOM_QUIRK_MULTI_INPUT;977977+978978+ /* quirks for bamboo touch */979979+ if (features->type == BAMBOO_PT &&980980+ features->device_type == BTN_TOOL_TRIPLETAP) {981981+ features->x_max <<= 5;982982+ features->y_max <<= 5;983983+ features->x_fuzz <<= 5;984984+ features->y_fuzz <<= 5;985985+ features->pressure_max = 256;986986+ features->pressure_fuzz = 16;987987+ features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;988988+ }1067989}10689901069991void wacom_setup_input_capabilities(struct input_dev *input_dev,···11219531122954 __set_bit(BTN_TOUCH, input_dev->keybit);112395511241124- input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0);11251125- input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0);11261126- input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0);956956+ input_set_abs_params(input_dev, ABS_X, 0, features->x_max,957957+ features->x_fuzz, 0);958958+ input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,959959+ features->y_fuzz, 0);960960+ input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,961961+ features->pressure_fuzz, 0);11279621128963 __set_bit(ABS_MISC, input_dev->absbit);1129964···11761005 __set_bit(BTN_9, input_dev->keybit);11771006 /* fall through */1178100710081008+ case CINTIQ:10091009+ for (i = 0; i < 8; i++)10101010+ __set_bit(BTN_0 + i, input_dev->keybit);10111011+ __set_bit(BTN_TOOL_FINGER, input_dev->keybit);10121012+10131013+ input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);10141014+ input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);10151015+ input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);10161016+ wacom_setup_cintiq(wacom_wac);10171017+ break;10181018+11791019 case INTUOS3:11801020 case INTUOS3L:11811181- case CINTIQ:11821021 __set_bit(BTN_4, input_dev->keybit);11831022 __set_bit(BTN_5, input_dev->keybit);11841023 __set_bit(BTN_6, input_dev->keybit);···1258107712591078 case PENPARTNER:12601079 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);10801080+ break;10811081+10821082+ case BAMBOO_PT:10831083+ __clear_bit(ABS_MISC, input_dev->absbit);10841084+10851085+ if (features->device_type == BTN_TOOL_TRIPLETAP) {10861086+ __set_bit(BTN_LEFT, input_dev->keybit);10871087+ __set_bit(BTN_FORWARD, input_dev->keybit);10881088+ __set_bit(BTN_BACK, input_dev->keybit);10891089+ __set_bit(BTN_RIGHT, input_dev->keybit);10901090+10911091+ __set_bit(BTN_TOOL_FINGER, input_dev->keybit);10921092+ __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);10931093+10941094+ input_mt_create_slots(input_dev, 2);10951095+ input_set_abs_params(input_dev, ABS_MT_POSITION_X,10961096+ 0, features->x_max,10971097+ features->x_fuzz, 0);10981098+ input_set_abs_params(input_dev, ABS_MT_POSITION_Y,10991099+ 0, features->y_max,11001100+ features->y_fuzz, 0);11011101+ input_set_abs_params(input_dev, ABS_MT_PRESSURE,11021102+ 0, features->pressure_max,11031103+ features->pressure_fuzz, 0);11041104+ input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0,11051105+ MAX_TRACKING_ID, 0, 0);11061106+ } else if (features->device_type == BTN_TOOL_PEN) {11071107+ __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);11081108+ __set_bit(BTN_TOOL_PEN, input_dev->keybit);11091109+ __set_bit(BTN_STYLUS, input_dev->keybit);11101110+ __set_bit(BTN_STYLUS2, input_dev->keybit);11111111+ }12611112 break;12621113 }12631114}···14281215 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };14291216static const struct wacom_features wacom_features_0x47 =14301217 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };12181218+static struct wacom_features wacom_features_0xD0 =12191219+ { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };12201220+static struct wacom_features wacom_features_0xD1 =12211221+ { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };12221222+static struct wacom_features wacom_features_0xD2 =12231223+ { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };12241224+static struct wacom_features wacom_features_0xD3 =12251225+ { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };1431122614321227#define USB_DEVICE_WACOM(prod) \14331228 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \···15001279 { USB_DEVICE_WACOM(0xC6) },15011280 { USB_DEVICE_WACOM(0xC7) },15021281 { USB_DEVICE_WACOM(0xCE) },12821282+ { USB_DEVICE_WACOM(0xD0) },12831283+ { USB_DEVICE_WACOM(0xD1) },12841284+ { USB_DEVICE_WACOM(0xD2) },12851285+ { USB_DEVICE_WACOM(0xD3) },15031286 { USB_DEVICE_WACOM(0xF0) },15041287 { USB_DEVICE_WACOM(0xCC) },15051288 { USB_DEVICE_WACOM(0x90) },
+15
drivers/input/tablet/wacom_wac.h
···2121#define WACOM_PKGLEN_INTUOS 102222#define WACOM_PKGLEN_TPC1FG 52323#define WACOM_PKGLEN_TPC2FG 142424+#define WACOM_PKGLEN_BBTOUCH 2024252526/* device IDs */2627#define STYLUS_DEVICE_ID 0x02···3837#define WACOM_REPORT_TPC1FG 63938#define WACOM_REPORT_TPC2FG 1340394040+/* device quirks */4141+#define WACOM_QUIRK_MULTI_INPUT 0x00014242+#define WACOM_QUIRK_BBTOUCH_LOWRES 0x00024343+4444+/* largest reported tracking id */4545+#define MAX_TRACKING_ID 0xfff4646+4147enum {4248 PENPARTNER = 0,4349 GRAPHIRE,···5244 PTU,5345 PL,5446 DTU,4747+ BAMBOO_PT,5548 INTUOS,5649 INTUOS3S,5750 INTUOS3,···8273 int y_phy;8374 unsigned char unit;8475 unsigned char unitExpo;7676+ int x_fuzz;7777+ int y_fuzz;7878+ int pressure_fuzz;7979+ int distance_fuzz;8080+ unsigned quirks;8581};86828783struct wacom_shared {···10086 int id[3];10187 __u32 serial[2];10288 int last_finger;8989+ int trk_id;10390 struct wacom_features features;10491 struct wacom_shared *shared;10592 struct input_dev *input;
+34
drivers/input/touchscreen/Kconfig
···9898 To compile this driver as a module, choose M here: the9999 module will be called h3600_ts_input.100100101101+config TOUCHSCREEN_BU21013102102+ tristate "BU21013 based touch panel controllers"103103+ depends on I2C104104+ help105105+ Say Y here if you have a bu21013 touchscreen connected to106106+ your system.107107+108108+ If unsure, say N.109109+110110+ To compile this driver as a module, choose M here: the111111+ module will be called bu21013_ts.112112+101113config TOUCHSCREEN_CY8CTMG110102114 tristate "cy8ctmg110 touchscreen"103115 depends on I2C···226214 To compile this driver as a module, choose M here: the227215 module will be called wacom_w8001.228216217217+config TOUCHSCREEN_LPC32XX218218+ tristate "LPC32XX touchscreen controller"219219+ depends on ARCH_LPC32XX220220+ help221221+ Say Y here if you have a LPC32XX device and want222222+ to support the built-in touchscreen.223223+224224+ To compile this driver as a module, choose M here: the225225+ module will be called lpc32xx_ts.226226+229227config TOUCHSCREEN_MCS5000230228 tristate "MELFAS MCS-5000 touchscreen"231229 depends on I2C···271249272250 To compile this driver as a module, choose M here: the273251 module will be called inexio.252252+253253+config TOUCHSCREEN_INTEL_MID254254+ tristate "Intel MID platform resistive touchscreen"255255+ depends on INTEL_SCU_IPC256256+ help257257+ Say Y here if you have a Intel MID based touchscreen in258258+ your system.259259+260260+ If unsure, say N.261261+262262+ To compile this driver as a module, choose M here: the263263+ module will be called intel_mid_touch.274264275265config TOUCHSCREEN_MK712276266 tristate "ICS MicroClock MK712 touchscreen"
···22 * Wacom W8001 penabled serial touchscreen driver33 *44 * Copyright (c) 2008 Jaya Kumar55+ * Copyright (c) 2010 Red Hat, Inc.56 *67 * This file is subject to the terms and conditions of the GNU General Public78 * License. See the file COPYING in the main directory of this archive for···3130#define W8001_LEAD_BYTE 0x803231#define W8001_TAB_MASK 0x403332#define W8001_TAB_BYTE 0x403333+/* set in first byte of touch data packets */3434+#define W8001_TOUCH_MASK (0x10 | W8001_LEAD_MASK)3535+#define W8001_TOUCH_BYTE (0x10 | W8001_LEAD_BYTE)34363537#define W8001_QUERY_PACKET 0x2036383739#define W8001_CMD_START '1'3840#define W8001_CMD_QUERY '*'4141+#define W8001_CMD_TOUCHQUERY '%'4242+4343+/* length of data packets in bytes, depends on device. */4444+#define W8001_PKTLEN_TOUCH93 54545+#define W8001_PKTLEN_TOUCH9A 74646+#define W8001_PKTLEN_TPCPEN 94747+#define W8001_PKTLEN_TPCCTL 11 /* control packet */4848+#define W8001_PKTLEN_TOUCH2FG 134949+5050+#define MAX_TRACKING_ID 0xFF /* arbitrarily chosen */39514052struct w8001_coord {4153 u8 rdy;···6046 u16 pen_pressure;6147 u8 tilt_x;6248 u8 tilt_y;4949+};5050+5151+/* touch query reply packet */5252+struct w8001_touch_query {5353+ u8 panel_res;5454+ u8 capacity_res;5555+ u8 sensor_id;5656+ u16 x;5757+ u16 y;6358};64596560/*···8562 unsigned char response[W8001_MAX_LENGTH];8663 unsigned char data[W8001_MAX_LENGTH];8764 char phys[32];6565+ int type;6666+ unsigned int pktlen;6767+ int trkid[2];8868};89699070static void parse_data(u8 *data, struct w8001_coord *coord)···11488 coord->tilt_y = data[8] & 0x7F;11589}116909191+static void parse_touch(struct w8001 *w8001)9292+{9393+ static int trkid;9494+ struct input_dev *dev = w8001->dev;9595+ unsigned char *data = w8001->data;9696+ int i;9797+9898+ for (i = 0; i < 2; i++) {9999+ input_mt_slot(dev, i);100100+101101+ if (data[0] & (1 << i)) {102102+ int x = (data[6 * i + 1] << 7) | (data[6 * i + 2]);103103+ int y = (data[6 * i + 3] << 7) | (data[6 * i + 4]);104104+ /* data[5,6] and [11,12] is finger capacity */105105+106106+ input_report_abs(dev, ABS_MT_POSITION_X, x);107107+ input_report_abs(dev, ABS_MT_POSITION_Y, y);108108+ input_report_abs(dev, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);109109+ if (w8001->trkid[i] < 0)110110+ w8001->trkid[i] = trkid++ & MAX_TRACKING_ID;111111+ } else {112112+ w8001->trkid[i] = -1;113113+ }114114+ input_report_abs(dev, ABS_MT_TRACKING_ID, w8001->trkid[i]);115115+ }116116+117117+ input_sync(dev);118118+}119119+120120+static void parse_touchquery(u8 *data, struct w8001_touch_query *query)121121+{122122+ memset(query, 0, sizeof(*query));123123+124124+ query->panel_res = data[1];125125+ query->sensor_id = data[2] & 0x7;126126+ query->capacity_res = data[7];127127+128128+ query->x = data[3] << 9;129129+ query->x |= data[4] << 2;130130+ query->x |= (data[2] >> 5) & 0x3;131131+132132+ query->y = data[5] << 9;133133+ query->y |= data[6] << 2;134134+ query->y |= (data[2] >> 3) & 0x3;135135+}136136+137137+static void report_pen_events(struct w8001 *w8001, struct w8001_coord *coord)138138+{139139+ struct input_dev *dev = w8001->dev;140140+141141+ /*142142+ * We have 1 bit for proximity (rdy) and 3 bits for tip, side,143143+ * side2/eraser. If rdy && f2 are set, this can be either pen + side2,144144+ * or eraser. assume145145+ * - if dev is already in proximity and f2 is toggled → pen + side2146146+ * - if dev comes into proximity with f2 set → eraser147147+ * If f2 disappears after assuming eraser, fake proximity out for148148+ * eraser and in for pen.149149+ */150150+151151+ if (!w8001->type) {152152+ w8001->type = coord->f2 ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;153153+ } else if (w8001->type == BTN_TOOL_RUBBER) {154154+ if (!coord->f2) {155155+ input_report_abs(dev, ABS_PRESSURE, 0);156156+ input_report_key(dev, BTN_TOUCH, 0);157157+ input_report_key(dev, BTN_STYLUS, 0);158158+ input_report_key(dev, BTN_STYLUS2, 0);159159+ input_report_key(dev, BTN_TOOL_RUBBER, 0);160160+ input_sync(dev);161161+ w8001->type = BTN_TOOL_PEN;162162+ }163163+ } else {164164+ input_report_key(dev, BTN_STYLUS2, coord->f2);165165+ }166166+167167+ input_report_abs(dev, ABS_X, coord->x);168168+ input_report_abs(dev, ABS_Y, coord->y);169169+ input_report_abs(dev, ABS_PRESSURE, coord->pen_pressure);170170+ input_report_key(dev, BTN_TOUCH, coord->tsw);171171+ input_report_key(dev, BTN_STYLUS, coord->f1);172172+ input_report_key(dev, w8001->type, coord->rdy);173173+ input_sync(dev);174174+175175+ if (!coord->rdy)176176+ w8001->type = 0;177177+}178178+117179static irqreturn_t w8001_interrupt(struct serio *serio,118180 unsigned char data, unsigned int flags)119181{120182 struct w8001 *w8001 = serio_get_drvdata(serio);121121- struct input_dev *dev = w8001->dev;122183 struct w8001_coord coord;123184 unsigned char tmp;124185···218105 }219106 break;220107221221- case 8:108108+ case W8001_PKTLEN_TOUCH93 - 1:109109+ case W8001_PKTLEN_TOUCH9A - 1:110110+ /* ignore one-finger touch packet. */111111+ if (w8001->pktlen == w8001->idx)112112+ w8001->idx = 0;113113+ break;114114+115115+ /* Pen coordinates packet */116116+ case W8001_PKTLEN_TPCPEN - 1:222117 tmp = w8001->data[0] & W8001_TAB_MASK;223118 if (unlikely(tmp == W8001_TAB_BYTE))224119 break;225120121121+ tmp = (w8001->data[0] & W8001_TOUCH_BYTE);122122+ if (tmp == W8001_TOUCH_BYTE)123123+ break;124124+226125 w8001->idx = 0;227126 parse_data(w8001->data, &coord);228228- input_report_abs(dev, ABS_X, coord.x);229229- input_report_abs(dev, ABS_Y, coord.y);230230- input_report_abs(dev, ABS_PRESSURE, coord.pen_pressure);231231- input_report_key(dev, BTN_TOUCH, coord.tsw);232232- input_sync(dev);127127+ report_pen_events(w8001, &coord);233128 break;234129235235- case 10:130130+ /* control packet */131131+ case W8001_PKTLEN_TPCCTL - 1:132132+ tmp = (w8001->data[0] & W8001_TOUCH_MASK);133133+ if (tmp == W8001_TOUCH_BYTE)134134+ break;135135+236136 w8001->idx = 0;237137 memcpy(w8001->response, w8001->data, W8001_MAX_LENGTH);238138 w8001->response_type = W8001_QUERY_PACKET;239139 complete(&w8001->cmd_done);140140+ break;141141+142142+ /* 2 finger touch packet */143143+ case W8001_PKTLEN_TOUCH2FG - 1:144144+ w8001->idx = 0;145145+ parse_touch(w8001);240146 break;241147 }242148···299167 input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0);300168 input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0);301169170170+ error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);171171+ if (!error) {172172+ struct w8001_touch_query touch;173173+174174+ parse_touchquery(w8001->response, &touch);175175+176176+ switch (touch.sensor_id) {177177+ case 0:178178+ case 2:179179+ w8001->pktlen = W8001_PKTLEN_TOUCH93;180180+ break;181181+ case 1:182182+ case 3:183183+ case 4:184184+ w8001->pktlen = W8001_PKTLEN_TOUCH9A;185185+ break;186186+ case 5:187187+ w8001->pktlen = W8001_PKTLEN_TOUCH2FG;188188+189189+ input_mt_create_slots(dev, 2);190190+ input_set_abs_params(dev, ABS_MT_TRACKING_ID,191191+ 0, MAX_TRACKING_ID, 0, 0);192192+ input_set_abs_params(dev, ABS_MT_POSITION_X,193193+ 0, touch.x, 0, 0);194194+ input_set_abs_params(dev, ABS_MT_POSITION_Y,195195+ 0, touch.y, 0, 0);196196+ input_set_abs_params(dev, ABS_MT_TOOL_TYPE,197197+ 0, 0, 0, 0);198198+ break;199199+ }200200+ }201201+302202 return w8001_command(w8001, W8001_CMD_START, false);303203}304204···372208 w8001->serio = serio;373209 w8001->id = serio->id.id;374210 w8001->dev = input_dev;211211+ w8001->trkid[0] = w8001->trkid[1] = -1;375212 init_completion(&w8001->cmd_done);376213 snprintf(w8001->phys, sizeof(w8001->phys), "%s/input0", serio->phys);377214···386221387222 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);388223 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);224224+ input_dev->keybit[BIT_WORD(BTN_TOOL_PEN)] |= BIT_MASK(BTN_TOOL_PEN);225225+ input_dev->keybit[BIT_WORD(BTN_TOOL_RUBBER)] |= BIT_MASK(BTN_TOOL_RUBBER);226226+ input_dev->keybit[BIT_WORD(BTN_STYLUS)] |= BIT_MASK(BTN_STYLUS);227227+ input_dev->keybit[BIT_WORD(BTN_STYLUS2)] |= BIT_MASK(BTN_STYLUS2);389228390229 serio_set_drvdata(serio, w8001);391230 err = serio_open(serio, drv);
+14-4
drivers/input/touchscreen/wm97xx-core.c
···125125{126126 int power_adc = 0, auxval;127127 u16 power = 0;128128+ int rc = 0;129129+ int timeout = 0;128130129131 /* get codec */130132 mutex_lock(&wm->codec_mutex);···145143146144 /* Turn polling mode on to read AUX ADC */147145 wm->pen_probably_down = 1;148148- wm->codec->poll_sample(wm, adcsel, &auxval);146146+147147+ while (rc != RC_VALID && timeout++ < 5)148148+ rc = wm->codec->poll_sample(wm, adcsel, &auxval);149149150150 if (power_adc)151151 wm97xx_reg_write(wm, AC97_EXTENDED_MID, power | 0x8000);···156152157153 wm->pen_probably_down = 0;158154155155+ if (timeout >= 5) {156156+ dev_err(wm->dev,157157+ "timeout reading auxadc %d, disabling digitiser\n",158158+ adcsel);159159+ wm->codec->dig_enable(wm, false);160160+ }161161+159162 mutex_unlock(&wm->codec_mutex);160160- return auxval & 0xfff;163163+ return (rc == RC_VALID ? auxval & 0xfff : -EBUSY);161164}162165EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc);163166···695684 touch_reg_err:696685 platform_device_put(wm->touch_dev);697686 touch_err:698698- platform_device_unregister(wm->battery_dev);699699- wm->battery_dev = NULL;687687+ platform_device_del(wm->battery_dev);700688 batt_reg_err:701689 platform_device_put(wm->battery_dev);702690 batt_err:
+263-132
drivers/media/IR/ir-keytable.c
···2525#define IR_KEYPRESS_TIMEOUT 25026262727/**2828+ * ir_create_table() - initializes a scancode table2929+ * @rc_tab: the ir_scancode_table to initialize3030+ * @name: name to assign to the table3131+ * @ir_type: ir type to assign to the new table3232+ * @size: initial size of the table3333+ * @return: zero on success or a negative error code3434+ *3535+ * This routine will initialize the ir_scancode_table and will allocate3636+ * memory to hold at least the specified number elements.3737+ */3838+static int ir_create_table(struct ir_scancode_table *rc_tab,3939+ const char *name, u64 ir_type, size_t size)4040+{4141+ rc_tab->name = name;4242+ rc_tab->ir_type = ir_type;4343+ rc_tab->alloc = roundup_pow_of_two(size * sizeof(struct ir_scancode));4444+ rc_tab->size = rc_tab->alloc / sizeof(struct ir_scancode);4545+ rc_tab->scan = kmalloc(rc_tab->alloc, GFP_KERNEL);4646+ if (!rc_tab->scan)4747+ return -ENOMEM;4848+4949+ IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",5050+ rc_tab->size, rc_tab->alloc);5151+ return 0;5252+}5353+5454+/**5555+ * ir_free_table() - frees memory allocated by a scancode table5656+ * @rc_tab: the table whose mappings need to be freed5757+ *5858+ * This routine will free memory alloctaed for key mappings used by given5959+ * scancode table.6060+ */6161+static void ir_free_table(struct ir_scancode_table *rc_tab)6262+{6363+ rc_tab->size = 0;6464+ kfree(rc_tab->scan);6565+ rc_tab->scan = NULL;6666+}6767+6868+/**2869 * ir_resize_table() - resizes a scancode table if necessary2970 * @rc_tab: the ir_scancode_table to resize7171+ * @gfp_flags: gfp flags to use when allocating memory3072 * @return: zero on success or a negative error code3173 *3274 * This routine will shrink the ir_scancode_table if it has lots of3375 * unused entries and grow it if it is full.3476 */3535-static int ir_resize_table(struct ir_scancode_table *rc_tab)7777+static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags)3678{3779 unsigned int oldalloc = rc_tab->alloc;3880 unsigned int newalloc = oldalloc;···9957 if (newalloc == oldalloc)10058 return 0;10159102102- newscan = kmalloc(newalloc, GFP_ATOMIC);6060+ newscan = kmalloc(newalloc, gfp_flags);10361 if (!newscan) {10462 IR_dprintk(1, "Failed to kmalloc %u bytes\n", newalloc);10563 return -ENOMEM;···11472}1157311674/**117117- * ir_do_setkeycode() - internal function to set a keycode in the118118- * scancode->keycode table7575+ * ir_update_mapping() - set a keycode in the scancode->keycode table11976 * @dev: the struct input_dev device descriptor120120- * @rc_tab: the struct ir_scancode_table to set the keycode in121121- * @scancode: the scancode for the ir command122122- * @keycode: the keycode for the ir command123123- * @resize: whether the keytable may be shrunk124124- * @return: -EINVAL if the keycode could not be inserted, otherwise zero.7777+ * @rc_tab: scancode table to be adjusted7878+ * @index: index of the mapping that needs to be updated7979+ * @keycode: the desired keycode8080+ * @return: previous keycode assigned to the mapping12581 *126126- * This routine is used internally to manipulate the scancode->keycode table.127127- * The caller has to hold @rc_tab->lock.8282+ * This routine is used to update scancode->keycopde mapping at given8383+ * position.12884 */129129-static int ir_do_setkeycode(struct input_dev *dev,130130- struct ir_scancode_table *rc_tab,131131- unsigned scancode, unsigned keycode,132132- bool resize)8585+static unsigned int ir_update_mapping(struct input_dev *dev,8686+ struct ir_scancode_table *rc_tab,8787+ unsigned int index,8888+ unsigned int new_keycode)8989+{9090+ int old_keycode = rc_tab->scan[index].keycode;9191+ int i;9292+9393+ /* Did the user wish to remove the mapping? */9494+ if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) {9595+ IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",9696+ index, rc_tab->scan[index].scancode);9797+ rc_tab->len--;9898+ memmove(&rc_tab->scan[index], &rc_tab->scan[index+ 1],9999+ (rc_tab->len - index) * sizeof(struct ir_scancode));100100+ } else {101101+ IR_dprintk(1, "#%d: %s scan 0x%04x with key 0x%04x\n",102102+ index,103103+ old_keycode == KEY_RESERVED ? "New" : "Replacing",104104+ rc_tab->scan[index].scancode, new_keycode);105105+ rc_tab->scan[index].keycode = new_keycode;106106+ __set_bit(new_keycode, dev->keybit);107107+ }108108+109109+ if (old_keycode != KEY_RESERVED) {110110+ /* A previous mapping was updated... */111111+ __clear_bit(old_keycode, dev->keybit);112112+ /* ... but another scancode might use the same keycode */113113+ for (i = 0; i < rc_tab->len; i++) {114114+ if (rc_tab->scan[i].keycode == old_keycode) {115115+ __set_bit(old_keycode, dev->keybit);116116+ break;117117+ }118118+ }119119+120120+ /* Possibly shrink the keytable, failure is not a problem */121121+ ir_resize_table(rc_tab, GFP_ATOMIC);122122+ }123123+124124+ return old_keycode;125125+}126126+127127+/**128128+ * ir_locate_scancode() - set a keycode in the scancode->keycode table129129+ * @ir_dev: the struct ir_input_dev device descriptor130130+ * @rc_tab: scancode table to be searched131131+ * @scancode: the desired scancode132132+ * @resize: controls whether we allowed to resize the table to133133+ * accomodate not yet present scancodes134134+ * @return: index of the mapping containing scancode in question135135+ * or -1U in case of failure.136136+ *137137+ * This routine is used to locate given scancode in ir_scancode_table.138138+ * If scancode is not yet present the routine will allocate a new slot139139+ * for it.140140+ */141141+static unsigned int ir_establish_scancode(struct ir_input_dev *ir_dev,142142+ struct ir_scancode_table *rc_tab,143143+ unsigned int scancode,144144+ bool resize)133145{134146 unsigned int i;135135- int old_keycode = KEY_RESERVED;136136- struct ir_input_dev *ir_dev = input_get_drvdata(dev);137147138148 /*139149 * Unfortunately, some hardware-based IR decoders don't provide···194100 * the provided IR with another one, it is needed to allow loading195101 * IR tables from other remotes. So,196102 */197197- if (ir_dev->props && ir_dev->props->scanmask) {103103+ if (ir_dev->props && ir_dev->props->scanmask)198104 scancode &= ir_dev->props->scanmask;199199- }200105201106 /* First check if we already have a mapping for this ir command */202107 for (i = 0; i < rc_tab->len; i++) {108108+ if (rc_tab->scan[i].scancode == scancode)109109+ return i;110110+203111 /* Keytable is sorted from lowest to highest scancode */204204- if (rc_tab->scan[i].scancode > scancode)112112+ if (rc_tab->scan[i].scancode >= scancode)205113 break;206206- else if (rc_tab->scan[i].scancode < scancode)207207- continue;208208-209209- old_keycode = rc_tab->scan[i].keycode;210210- rc_tab->scan[i].keycode = keycode;211211-212212- /* Did the user wish to remove the mapping? */213213- if (keycode == KEY_RESERVED || keycode == KEY_UNKNOWN) {214214- IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",215215- i, scancode);216216- rc_tab->len--;217217- memmove(&rc_tab->scan[i], &rc_tab->scan[i + 1],218218- (rc_tab->len - i) * sizeof(struct ir_scancode));219219- }220220-221221- /* Possibly shrink the keytable, failure is not a problem */222222- ir_resize_table(rc_tab);223223- break;224114 }225115226226- if (old_keycode == KEY_RESERVED && keycode != KEY_RESERVED) {227227- /* No previous mapping found, we might need to grow the table */228228- if (resize && ir_resize_table(rc_tab))229229- return -ENOMEM;116116+ /* No previous mapping found, we might need to grow the table */117117+ if (rc_tab->size == rc_tab->len) {118118+ if (!resize || ir_resize_table(rc_tab, GFP_ATOMIC))119119+ return -1U;120120+ }230121231231- IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n",232232- i, scancode, keycode);233233-234234- /* i is the proper index to insert our new keycode */122122+ /* i is the proper index to insert our new keycode */123123+ if (i < rc_tab->len)235124 memmove(&rc_tab->scan[i + 1], &rc_tab->scan[i],236125 (rc_tab->len - i) * sizeof(struct ir_scancode));237237- rc_tab->scan[i].scancode = scancode;238238- rc_tab->scan[i].keycode = keycode;239239- rc_tab->len++;240240- set_bit(keycode, dev->keybit);241241- } else {242242- IR_dprintk(1, "#%d: Replacing scan 0x%04x with key 0x%04x\n",243243- i, scancode, keycode);244244- /* A previous mapping was updated... */245245- clear_bit(old_keycode, dev->keybit);246246- /* ...but another scancode might use the same keycode */247247- for (i = 0; i < rc_tab->len; i++) {248248- if (rc_tab->scan[i].keycode == old_keycode) {249249- set_bit(old_keycode, dev->keybit);250250- break;251251- }252252- }253253- }126126+ rc_tab->scan[i].scancode = scancode;127127+ rc_tab->scan[i].keycode = KEY_RESERVED;128128+ rc_tab->len++;254129255255- return 0;130130+ return i;256131}257132258133/**···234171 * This routine is used to handle evdev EVIOCSKEY ioctl.235172 */236173static int ir_setkeycode(struct input_dev *dev,237237- unsigned int scancode, unsigned int keycode)174174+ const struct input_keymap_entry *ke,175175+ unsigned int *old_keycode)238176{239239- int rc;240240- unsigned long flags;241177 struct ir_input_dev *ir_dev = input_get_drvdata(dev);242178 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;179179+ unsigned int index;180180+ unsigned int scancode;181181+ int retval;182182+ unsigned long flags;243183244184 spin_lock_irqsave(&rc_tab->lock, flags);245245- rc = ir_do_setkeycode(dev, rc_tab, scancode, keycode, true);185185+186186+ if (ke->flags & INPUT_KEYMAP_BY_INDEX) {187187+ index = ke->index;188188+ if (index >= rc_tab->len) {189189+ retval = -EINVAL;190190+ goto out;191191+ }192192+ } else {193193+ retval = input_scancode_to_scalar(ke, &scancode);194194+ if (retval)195195+ goto out;196196+197197+ index = ir_establish_scancode(ir_dev, rc_tab, scancode, true);198198+ if (index >= rc_tab->len) {199199+ retval = -ENOMEM;200200+ goto out;201201+ }202202+ }203203+204204+ *old_keycode = ir_update_mapping(dev, rc_tab, index, ke->keycode);205205+206206+out:246207 spin_unlock_irqrestore(&rc_tab->lock, flags);247247- return rc;208208+ return retval;248209}249210250211/**···276189 * @dev: the struct input_dev device descriptor277190 * @to: the struct ir_scancode_table to copy entries to278191 * @from: the struct ir_scancode_table to copy entries from279279- * @return: -EINVAL if all keycodes could not be inserted, otherwise zero.192192+ * @return: -ENOMEM if all keycodes could not be inserted, otherwise zero.280193 *281194 * This routine is used to handle table initialization.282195 */283283-static int ir_setkeytable(struct input_dev *dev,284284- struct ir_scancode_table *to,196196+static int ir_setkeytable(struct ir_input_dev *ir_dev,285197 const struct ir_scancode_table *from)286198{287287- struct ir_input_dev *ir_dev = input_get_drvdata(dev);288199 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;289289- unsigned long flags;290290- unsigned int i;291291- int rc = 0;200200+ unsigned int i, index;201201+ int rc;292202293293- spin_lock_irqsave(&rc_tab->lock, flags);203203+ rc = ir_create_table(&ir_dev->rc_tab,204204+ from->name, from->ir_type, from->size);205205+ if (rc)206206+ return rc;207207+208208+ IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",209209+ rc_tab->size, rc_tab->alloc);210210+294211 for (i = 0; i < from->size; i++) {295295- rc = ir_do_setkeycode(dev, to, from->scan[i].scancode,296296- from->scan[i].keycode, false);297297- if (rc)212212+ index = ir_establish_scancode(ir_dev, rc_tab,213213+ from->scan[i].scancode, false);214214+ if (index >= rc_tab->len) {215215+ rc = -ENOMEM;298216 break;217217+ }218218+219219+ ir_update_mapping(ir_dev->input_dev, rc_tab, index,220220+ from->scan[i].keycode);299221 }300300- spin_unlock_irqrestore(&rc_tab->lock, flags);222222+223223+ if (rc)224224+ ir_free_table(rc_tab);225225+301226 return rc;227227+}228228+229229+/**230230+ * ir_lookup_by_scancode() - locate mapping by scancode231231+ * @rc_tab: the &struct ir_scancode_table to search232232+ * @scancode: scancode to look for in the table233233+ * @return: index in the table, -1U if not found234234+ *235235+ * This routine performs binary search in RC keykeymap table for236236+ * given scancode.237237+ */238238+static unsigned int ir_lookup_by_scancode(const struct ir_scancode_table *rc_tab,239239+ unsigned int scancode)240240+{241241+ unsigned int start = 0;242242+ unsigned int end = rc_tab->len - 1;243243+ unsigned int mid;244244+245245+ while (start <= end) {246246+ mid = (start + end) / 2;247247+ if (rc_tab->scan[mid].scancode < scancode)248248+ start = mid + 1;249249+ else if (rc_tab->scan[mid].scancode > scancode)250250+ end = mid - 1;251251+ else252252+ return mid;253253+ }254254+255255+ return -1U;302256}303257304258/**···352224 * This routine is used to handle evdev EVIOCGKEY ioctl.353225 */354226static int ir_getkeycode(struct input_dev *dev,355355- unsigned int scancode, unsigned int *keycode)227227+ struct input_keymap_entry *ke)356228{357357- int start, end, mid;358358- unsigned long flags;359359- int key = KEY_RESERVED;360229 struct ir_input_dev *ir_dev = input_get_drvdata(dev);361230 struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;231231+ struct ir_scancode *entry;232232+ unsigned long flags;233233+ unsigned int index;234234+ unsigned int scancode;235235+ int retval;362236363237 spin_lock_irqsave(&rc_tab->lock, flags);364364- start = 0;365365- end = rc_tab->len - 1;366366- while (start <= end) {367367- mid = (start + end) / 2;368368- if (rc_tab->scan[mid].scancode < scancode)369369- start = mid + 1;370370- else if (rc_tab->scan[mid].scancode > scancode)371371- end = mid - 1;372372- else {373373- key = rc_tab->scan[mid].keycode;374374- break;375375- }238238+239239+ if (ke->flags & INPUT_KEYMAP_BY_INDEX) {240240+ index = ke->index;241241+ } else {242242+ retval = input_scancode_to_scalar(ke, &scancode);243243+ if (retval)244244+ goto out;245245+246246+ index = ir_lookup_by_scancode(rc_tab, scancode);376247 }248248+249249+ if (index >= rc_tab->len) {250250+ if (!(ke->flags & INPUT_KEYMAP_BY_INDEX))251251+ IR_dprintk(1, "unknown key for scancode 0x%04x\n",252252+ scancode);253253+ retval = -EINVAL;254254+ goto out;255255+ }256256+257257+ entry = &rc_tab->scan[index];258258+259259+ ke->index = index;260260+ ke->keycode = entry->keycode;261261+ ke->len = sizeof(entry->scancode);262262+ memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode));263263+264264+out:377265 spin_unlock_irqrestore(&rc_tab->lock, flags);378378-379379- if (key == KEY_RESERVED)380380- IR_dprintk(1, "unknown key for scancode 0x%04x\n",381381- scancode);382382-383383- *keycode = key;384384- return 0;266266+ return retval;385267}386268387269/**···406268 */407269u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)408270{409409- int keycode;271271+ struct ir_input_dev *ir_dev = input_get_drvdata(dev);272272+ struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;273273+ unsigned int keycode;274274+ unsigned int index;275275+ unsigned long flags;410276411411- ir_getkeycode(dev, scancode, &keycode);277277+ spin_lock_irqsave(&rc_tab->lock, flags);278278+279279+ index = ir_lookup_by_scancode(rc_tab, scancode);280280+ keycode = index < rc_tab->len ?281281+ rc_tab->scan[index].keycode : KEY_RESERVED;282282+283283+ spin_unlock_irqrestore(&rc_tab->lock, flags);284284+412285 if (keycode != KEY_RESERVED)413286 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",414287 dev->name, scancode, keycode);288288+415289 return keycode;416290}417291EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);···603453 goto out_dev;604454 }605455606606- input_dev->getkeycode = ir_getkeycode;607607- input_dev->setkeycode = ir_setkeycode;456456+ input_dev->getkeycode_new = ir_getkeycode;457457+ input_dev->setkeycode_new = ir_setkeycode;608458 input_set_drvdata(input_dev, ir_dev);609459 ir_dev->input_dev = input_dev;610460···612462 spin_lock_init(&ir_dev->keylock);613463 setup_timer(&ir_dev->timer_keyup, ir_timer_keyup, (unsigned long)ir_dev);614464615615- ir_dev->rc_tab.name = rc_tab->name;616616- ir_dev->rc_tab.ir_type = rc_tab->ir_type;617617- ir_dev->rc_tab.alloc = roundup_pow_of_two(rc_tab->size *618618- sizeof(struct ir_scancode));619619- ir_dev->rc_tab.scan = kmalloc(ir_dev->rc_tab.alloc, GFP_KERNEL);620620- ir_dev->rc_tab.size = ir_dev->rc_tab.alloc / sizeof(struct ir_scancode);621465 if (props) {622466 ir_dev->props = props;623467 if (props->open)···620476 input_dev->close = ir_close;621477 }622478623623- if (!ir_dev->rc_tab.scan) {624624- rc = -ENOMEM;625625- goto out_name;626626- }627627-628628- IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",629629- ir_dev->rc_tab.size, ir_dev->rc_tab.alloc);630630-631479 set_bit(EV_KEY, input_dev->evbit);632480 set_bit(EV_REP, input_dev->evbit);633481 set_bit(EV_MSC, input_dev->evbit);634482 set_bit(MSC_SCAN, input_dev->mscbit);635483636636- if (ir_setkeytable(input_dev, &ir_dev->rc_tab, rc_tab)) {637637- rc = -ENOMEM;638638- goto out_table;639639- }484484+ rc = ir_setkeytable(ir_dev, rc_tab);485485+ if (rc)486486+ goto out_name;640487641488 rc = ir_register_class(input_dev);642489 if (rc < 0)···650515out_event:651516 ir_unregister_class(input_dev);652517out_table:653653- kfree(ir_dev->rc_tab.scan);518518+ ir_free_table(&ir_dev->rc_tab);654519out_name:655520 kfree(ir_dev->driver_name);656521out_dev:···668533void ir_input_unregister(struct input_dev *input_dev)669534{670535 struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);671671- struct ir_scancode_table *rc_tab;672536673537 if (!ir_dev)674538 return;···679545 if (ir_dev->props->driver_type == RC_DRIVER_IR_RAW)680546 ir_raw_event_unregister(input_dev);681547682682- rc_tab = &ir_dev->rc_tab;683683- rc_tab->size = 0;684684- kfree(rc_tab->scan);685685- rc_tab->scan = NULL;548548+ ir_free_table(&ir_dev->rc_tab);686549687550 ir_unregister_class(input_dev);688551
···11-config TOUCHSCREEN_INTEL_MID22- tristate "Intel MID platform resistive touchscreen"33- depends on INTEL_SCU_IPC44- default y55- help66- Say Y here if you have a Intel MID based touchscreen77- If unsure, say N.
···3434 * Protocol version.3535 */36363737-#define EV_VERSION 0x0100003737+#define EV_VERSION 0x01000138383939/*4040 * IOCTLs (0x00 - 0x7f)···5656 __s32 resolution;5757};58585959+/**6060+ * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls6161+ * @scancode: scancode represented in machine-endian form.6262+ * @len: length of the scancode that resides in @scancode buffer.6363+ * @index: index in the keymap, may be used instead of scancode6464+ * @flags: allows to specify how kernel should handle the request. For6565+ * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel6666+ * should perform lookup in keymap by @index instead of @scancode6767+ * @keycode: key code assigned to this scancode6868+ *6969+ * The structure is used to retrieve and modify keymap data. Users have7070+ * option of performing lookup either by @scancode itself or by @index7171+ * in keymap entry. EVIOCGKEYCODE will also return scancode or index7272+ * (depending on which element was used to perform lookup).7373+ */7474+struct input_keymap_entry {7575+#define INPUT_KEYMAP_BY_INDEX (1 << 0)7676+ __u8 flags;7777+ __u8 len;7878+ __u16 index;7979+ __u32 keycode;8080+ __u8 scancode[32];8181+};8282+5983#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */6084#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */6185#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */6286#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */6363-#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */6464-#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */8787+8888+#define EVIOCGKEYCODE _IOR('E', 0x04, struct input_keymap_entry) /* get keycode */8989+#define EVIOCSKEYCODE _IOW('E', 0x04, struct input_keymap_entry) /* set keycode */65906691#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */6792#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */6893#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */69947070-#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */9595+#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */7196#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */7297#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */7398#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */749975100#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */7676-#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */7777-#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */101101+#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */102102+#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */7810379104#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */80105#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */···11131088 * @keycodemax: size of keycode table11141089 * @keycodesize: size of elements in keycode table11151090 * @keycode: map of scancodes to keycodes for this device10911091+ * @getkeycode: optional legacy method to retrieve current keymap.11161092 * @setkeycode: optional method to alter current keymap, used to implement11171093 * sparse keymaps. If not supplied default mechanism will be used.11181094 * The method is being called while holding event_lock and thus must11191095 * not sleep11201120- * @getkeycode: optional method to retrieve current keymap. If not supplied11211121- * default mechanism will be used. The method is being called while11221122- * holding event_lock and thus must not sleep10961096+ * @getkeycode_new: transition method10971097+ * @setkeycode_new: transition method11231098 * @ff: force feedback structure associated with the device if device11241099 * supports force feedback effects11251100 * @repeat_key: stores key code of the last key pressed; used to implement···11931168 unsigned int keycodemax;11941169 unsigned int keycodesize;11951170 void *keycode;11711171+11961172 int (*setkeycode)(struct input_dev *dev,11971173 unsigned int scancode, unsigned int keycode);11981174 int (*getkeycode)(struct input_dev *dev,11991175 unsigned int scancode, unsigned int *keycode);11761176+ int (*setkeycode_new)(struct input_dev *dev,11771177+ const struct input_keymap_entry *ke,11781178+ unsigned int *old_keycode);11791179+ int (*getkeycode_new)(struct input_dev *dev,11801180+ struct input_keymap_entry *ke);1200118112011182 struct ff_device *ff;12021183···15091478INPUT_GENERATE_ABS_ACCESSORS(flat, flat)15101479INPUT_GENERATE_ABS_ACCESSORS(res, resolution)1511148015121512-int input_get_keycode(struct input_dev *dev,15131513- unsigned int scancode, unsigned int *keycode);14811481+int input_scancode_to_scalar(const struct input_keymap_entry *ke,14821482+ unsigned int *scancode);14831483+14841484+int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);15141485int input_set_keycode(struct input_dev *dev,15151515- unsigned int scancode, unsigned int keycode);14861486+ const struct input_keymap_entry *ke);1516148715171488extern struct class input_class;15181489
+44
include/linux/input/bu21013.h
···11+/*22+ * Copyright (C) ST-Ericsson SA 201033+ * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson44+ * License terms:GNU General Public License (GPL) version 255+ */66+77+#ifndef _BU21013_H88+#define _BU21013_H99+1010+/**1111+ * struct bu21013_platform_device - Handle the platform data1212+ * @cs_en: pointer to the cs enable function1313+ * @cs_dis: pointer to the cs disable function1414+ * @irq_read_val: pointer to read the pen irq value function1515+ * @x_max_res: xmax resolution1616+ * @y_max_res: ymax resolution1717+ * @touch_x_max: touch x max1818+ * @touch_y_max: touch y max1919+ * @cs_pin: chip select pin2020+ * @irq: irq pin2121+ * @ext_clk: external clock flag2222+ * @x_flip: x flip flag2323+ * @y_flip: y flip flag2424+ * @wakeup: wakeup flag2525+ *2626+ * This is used to handle the platform data2727+ */2828+struct bu21013_platform_device {2929+ int (*cs_en)(int reset_pin);3030+ int (*cs_dis)(int reset_pin);3131+ int (*irq_read_val)(void);3232+ int x_max_res;3333+ int y_max_res;3434+ int touch_x_max;3535+ int touch_y_max;3636+ unsigned int cs_pin;3737+ unsigned int irq;3838+ bool ext_clk;3939+ bool x_flip;4040+ bool y_flip;4141+ bool wakeup;4242+};4343+4444+#endif
+6-4
include/linux/serio.h
···4141 int (*start)(struct serio *);4242 void (*stop)(struct serio *);43434444- struct serio *parent, *child;4444+ struct serio *parent;4545+ struct list_head child_node; /* Entry in parent->children list */4646+ struct list_head children;4547 unsigned int depth; /* level of nesting in serio hierarchy */46484749 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */···5654#define to_serio_port(d) container_of(d, struct serio, dev)57555856struct serio_driver {5959- void *private;6060- char *description;5757+ const char *description;61586262- struct serio_device_id *id_table;5959+ const struct serio_device_id *id_table;6360 bool manual_bind;64616562 void (*write_wakeup)(struct serio *);···198197#define SERIO_W8001 0x39199198#define SERIO_DYNAPRO 0x3a200199#define SERIO_HAMPSHIRE 0x3b200200+#define SERIO_PS2MULT 0x3c201201202202#endif
+1-1
include/media/rc-map.h
···3535 unsigned int len; /* Used number of entries */3636 unsigned int alloc; /* Size of *scan in bytes */3737 u64 ir_type;3838- char *name;3838+ const char *name;3939 spinlock_t lock;4040};4141