You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (75 commits) Input: wacom - specify Cinitq supported tools Input: ab8500-ponkey - fix IRQ freeing in error path Input: adp5588-keys - use more obvious i2c_device_id name string Input: ad7877 - switch to using threaded IRQ Input: ad7877 - use attribute group to control visibility of attributes Input: serio - add support for PS2Mult multiplexer protocol Input: wacom - properly enable runtime PM Input: ad7877 - filter events where pressure is beyond the maximum Input: ad7877 - implement EV_KEY:BTN_TOUCH reporting Input: ad7877 - implement specified chip select behavior Input: hp680_ts_input - use cancel_delayed_work_sync() Input: mousedev - correct lockdep annotation Input: ads7846 - switch to using threaded IRQ Input: serio - support multiple child devices per single parent Input: synaptics - simplify pass-through port handling Input: add ROHM BU21013 touch panel controller support Input: omap4-keypad - wake-up on events & long presses Input: omap4-keypad - fix interrupt line configuration Input: omap4-keypad - SYSCONFIG register configuration Input: omap4-keypad - use platform device helpers ...
This commit is contained in:
@@ -98,6 +98,18 @@ config TOUCHSCREEN_BITSY
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called h3600_ts_input.
|
||||
|
||||
config TOUCHSCREEN_BU21013
|
||||
tristate "BU21013 based touch panel controllers"
|
||||
depends on I2C
|
||||
help
|
||||
Say Y here if you have a bu21013 touchscreen connected to
|
||||
your system.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called bu21013_ts.
|
||||
|
||||
config TOUCHSCREEN_CY8CTMG110
|
||||
tristate "cy8ctmg110 touchscreen"
|
||||
depends on I2C
|
||||
@@ -214,6 +226,16 @@ config TOUCHSCREEN_WACOM_W8001
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called wacom_w8001.
|
||||
|
||||
config TOUCHSCREEN_LPC32XX
|
||||
tristate "LPC32XX touchscreen controller"
|
||||
depends on ARCH_LPC32XX
|
||||
help
|
||||
Say Y here if you have a LPC32XX device and want
|
||||
to support the built-in touchscreen.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called lpc32xx_ts.
|
||||
|
||||
config TOUCHSCREEN_MCS5000
|
||||
tristate "MELFAS MCS-5000 touchscreen"
|
||||
depends on I2C
|
||||
@@ -250,6 +272,18 @@ config TOUCHSCREEN_INEXIO
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called inexio.
|
||||
|
||||
config TOUCHSCREEN_INTEL_MID
|
||||
tristate "Intel MID platform resistive touchscreen"
|
||||
depends on INTEL_SCU_IPC
|
||||
help
|
||||
Say Y here if you have a Intel MID based touchscreen in
|
||||
your system.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called intel_mid_touch.
|
||||
|
||||
config TOUCHSCREEN_MK712
|
||||
tristate "ICS MicroClock MK712 touchscreen"
|
||||
help
|
||||
|
||||
@@ -14,6 +14,7 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_DA9034) += da9034-ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o
|
||||
@@ -23,6 +24,8 @@ obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_LPC32XX) += lpc32xx_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_MC13783) += mc13783_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_MCS5000) += mcs5000_ts.o
|
||||
obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o
|
||||
|
||||
@@ -191,13 +191,12 @@ struct ad7877 {
|
||||
struct spi_message msg;
|
||||
|
||||
struct mutex mutex;
|
||||
unsigned disabled:1; /* P: mutex */
|
||||
unsigned gpio3:1; /* P: mutex */
|
||||
unsigned gpio4:1; /* P: mutex */
|
||||
bool disabled; /* P: mutex */
|
||||
bool gpio3; /* P: mutex */
|
||||
bool gpio4; /* P: mutex */
|
||||
|
||||
spinlock_t lock;
|
||||
struct timer_list timer; /* P: lock */
|
||||
unsigned pending:1; /* P: lock */
|
||||
|
||||
/*
|
||||
* DMA (thus cache coherency maintenance) requires the
|
||||
@@ -206,8 +205,8 @@ struct ad7877 {
|
||||
u16 conversion_data[AD7877_NR_SENSE] ____cacheline_aligned;
|
||||
};
|
||||
|
||||
static int gpio3;
|
||||
module_param(gpio3, int, 0);
|
||||
static bool gpio3;
|
||||
module_param(gpio3, bool, 0);
|
||||
MODULE_PARM_DESC(gpio3, "If gpio3 is set to 1 AUX3 acts as GPIO3");
|
||||
|
||||
/*
|
||||
@@ -230,6 +229,7 @@ static int ad7877_read(struct spi_device *spi, u16 reg)
|
||||
AD7877_READADD(reg));
|
||||
req->xfer[0].tx_buf = &req->command;
|
||||
req->xfer[0].len = 2;
|
||||
req->xfer[0].cs_change = 1;
|
||||
|
||||
req->xfer[1].rx_buf = &req->sample;
|
||||
req->xfer[1].len = 2;
|
||||
@@ -295,20 +295,25 @@ static int ad7877_read_adc(struct spi_device *spi, unsigned command)
|
||||
|
||||
req->xfer[0].tx_buf = &req->reset;
|
||||
req->xfer[0].len = 2;
|
||||
req->xfer[0].cs_change = 1;
|
||||
|
||||
req->xfer[1].tx_buf = &req->ref_on;
|
||||
req->xfer[1].len = 2;
|
||||
req->xfer[1].delay_usecs = ts->vref_delay_usecs;
|
||||
req->xfer[1].cs_change = 1;
|
||||
|
||||
req->xfer[2].tx_buf = &req->command;
|
||||
req->xfer[2].len = 2;
|
||||
req->xfer[2].delay_usecs = ts->vref_delay_usecs;
|
||||
req->xfer[2].cs_change = 1;
|
||||
|
||||
req->xfer[3].rx_buf = &req->sample;
|
||||
req->xfer[3].len = 2;
|
||||
req->xfer[3].cs_change = 1;
|
||||
|
||||
req->xfer[4].tx_buf = &ts->cmd_crtl2; /*REF OFF*/
|
||||
req->xfer[4].len = 2;
|
||||
req->xfer[4].cs_change = 1;
|
||||
|
||||
req->xfer[5].tx_buf = &ts->cmd_crtl1; /*DEFAULT*/
|
||||
req->xfer[5].len = 2;
|
||||
@@ -327,7 +332,7 @@ static int ad7877_read_adc(struct spi_device *spi, unsigned command)
|
||||
return status ? : sample;
|
||||
}
|
||||
|
||||
static void ad7877_rx(struct ad7877 *ts)
|
||||
static int ad7877_process_data(struct ad7877 *ts)
|
||||
{
|
||||
struct input_dev *input_dev = ts->input;
|
||||
unsigned Rt;
|
||||
@@ -354,11 +359,25 @@ static void ad7877_rx(struct ad7877 *ts)
|
||||
Rt /= z1;
|
||||
Rt = (Rt + 2047) >> 12;
|
||||
|
||||
/*
|
||||
* Sample found inconsistent, pressure is beyond
|
||||
* the maximum. Don't report it to user space.
|
||||
*/
|
||||
if (Rt > ts->pressure_max)
|
||||
return -EINVAL;
|
||||
|
||||
if (!timer_pending(&ts->timer))
|
||||
input_report_key(input_dev, BTN_TOUCH, 1);
|
||||
|
||||
input_report_abs(input_dev, ABS_X, x);
|
||||
input_report_abs(input_dev, ABS_Y, y);
|
||||
input_report_abs(input_dev, ABS_PRESSURE, Rt);
|
||||
input_sync(input_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static inline void ad7877_ts_event_release(struct ad7877 *ts)
|
||||
@@ -366,72 +385,56 @@ static inline void ad7877_ts_event_release(struct ad7877 *ts)
|
||||
struct input_dev *input_dev = ts->input;
|
||||
|
||||
input_report_abs(input_dev, ABS_PRESSURE, 0);
|
||||
input_report_key(input_dev, BTN_TOUCH, 0);
|
||||
input_sync(input_dev);
|
||||
}
|
||||
|
||||
static void ad7877_timer(unsigned long handle)
|
||||
{
|
||||
struct ad7877 *ts = (void *)handle;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&ts->lock, flags);
|
||||
ad7877_ts_event_release(ts);
|
||||
spin_unlock_irqrestore(&ts->lock, flags);
|
||||
}
|
||||
|
||||
static irqreturn_t ad7877_irq(int irq, void *handle)
|
||||
{
|
||||
struct ad7877 *ts = handle;
|
||||
unsigned long flags;
|
||||
int status;
|
||||
int error;
|
||||
|
||||
/*
|
||||
* The repeated conversion sequencer controlled by TMR kicked off
|
||||
* too fast. We ignore the last and process the sample sequence
|
||||
* currently in the queue. It can't be older than 9.4ms, and we
|
||||
* need to avoid that ts->msg doesn't get issued twice while in work.
|
||||
*/
|
||||
error = spi_sync(ts->spi, &ts->msg);
|
||||
if (error) {
|
||||
dev_err(&ts->spi->dev, "spi_sync --> %d\n", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&ts->lock, flags);
|
||||
if (!ts->pending) {
|
||||
ts->pending = 1;
|
||||
|
||||
status = spi_async(ts->spi, &ts->msg);
|
||||
if (status)
|
||||
dev_err(&ts->spi->dev, "spi_sync --> %d\n", status);
|
||||
}
|
||||
error = ad7877_process_data(ts);
|
||||
if (!error)
|
||||
mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
|
||||
spin_unlock_irqrestore(&ts->lock, flags);
|
||||
|
||||
out:
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void ad7877_callback(void *_ts)
|
||||
{
|
||||
struct ad7877 *ts = _ts;
|
||||
|
||||
spin_lock_irq(&ts->lock);
|
||||
|
||||
ad7877_rx(ts);
|
||||
ts->pending = 0;
|
||||
mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
|
||||
|
||||
spin_unlock_irq(&ts->lock);
|
||||
}
|
||||
|
||||
static void ad7877_disable(struct ad7877 *ts)
|
||||
{
|
||||
mutex_lock(&ts->mutex);
|
||||
|
||||
if (!ts->disabled) {
|
||||
ts->disabled = 1;
|
||||
ts->disabled = true;
|
||||
disable_irq(ts->spi->irq);
|
||||
|
||||
/* Wait for spi_async callback */
|
||||
while (ts->pending)
|
||||
msleep(1);
|
||||
|
||||
if (del_timer_sync(&ts->timer))
|
||||
ad7877_ts_event_release(ts);
|
||||
}
|
||||
|
||||
/* we know the chip's in lowpower mode since we always
|
||||
/*
|
||||
* We know the chip's in lowpower mode since we always
|
||||
* leave it that way after every request
|
||||
*/
|
||||
|
||||
@@ -443,7 +446,7 @@ static void ad7877_enable(struct ad7877 *ts)
|
||||
mutex_lock(&ts->mutex);
|
||||
|
||||
if (ts->disabled) {
|
||||
ts->disabled = 0;
|
||||
ts->disabled = false;
|
||||
enable_irq(ts->spi->irq);
|
||||
}
|
||||
|
||||
@@ -453,7 +456,7 @@ static void ad7877_enable(struct ad7877 *ts)
|
||||
#define SHOW(name) static ssize_t \
|
||||
name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
|
||||
{ \
|
||||
struct ad7877 *ts = dev_get_drvdata(dev); \
|
||||
struct ad7877 *ts = dev_get_drvdata(dev); \
|
||||
ssize_t v = ad7877_read_adc(ts->spi, \
|
||||
AD7877_READ_CHAN(name)); \
|
||||
if (v < 0) \
|
||||
@@ -473,7 +476,7 @@ SHOW(temp2)
|
||||
static ssize_t ad7877_disable_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ad7877 *ts = dev_get_drvdata(dev);
|
||||
struct ad7877 *ts = dev_get_drvdata(dev);
|
||||
|
||||
return sprintf(buf, "%u\n", ts->disabled);
|
||||
}
|
||||
@@ -503,7 +506,7 @@ static DEVICE_ATTR(disable, 0664, ad7877_disable_show, ad7877_disable_store);
|
||||
static ssize_t ad7877_dac_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ad7877 *ts = dev_get_drvdata(dev);
|
||||
struct ad7877 *ts = dev_get_drvdata(dev);
|
||||
|
||||
return sprintf(buf, "%u\n", ts->dac);
|
||||
}
|
||||
@@ -533,7 +536,7 @@ static DEVICE_ATTR(dac, 0664, ad7877_dac_show, ad7877_dac_store);
|
||||
static ssize_t ad7877_gpio3_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ad7877 *ts = dev_get_drvdata(dev);
|
||||
struct ad7877 *ts = dev_get_drvdata(dev);
|
||||
|
||||
return sprintf(buf, "%u\n", ts->gpio3);
|
||||
}
|
||||
@@ -564,7 +567,7 @@ static DEVICE_ATTR(gpio3, 0664, ad7877_gpio3_show, ad7877_gpio3_store);
|
||||
static ssize_t ad7877_gpio4_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ad7877 *ts = dev_get_drvdata(dev);
|
||||
struct ad7877 *ts = dev_get_drvdata(dev);
|
||||
|
||||
return sprintf(buf, "%u\n", ts->gpio4);
|
||||
}
|
||||
@@ -597,16 +600,35 @@ static struct attribute *ad7877_attributes[] = {
|
||||
&dev_attr_temp2.attr,
|
||||
&dev_attr_aux1.attr,
|
||||
&dev_attr_aux2.attr,
|
||||
&dev_attr_aux3.attr,
|
||||
&dev_attr_bat1.attr,
|
||||
&dev_attr_bat2.attr,
|
||||
&dev_attr_disable.attr,
|
||||
&dev_attr_dac.attr,
|
||||
&dev_attr_gpio3.attr,
|
||||
&dev_attr_gpio4.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static mode_t ad7877_attr_is_visible(struct kobject *kobj,
|
||||
struct attribute *attr, int n)
|
||||
{
|
||||
mode_t mode = attr->mode;
|
||||
|
||||
if (attr == &dev_attr_aux3.attr) {
|
||||
if (gpio3)
|
||||
mode = 0;
|
||||
} else if (attr == &dev_attr_gpio3.attr) {
|
||||
if (!gpio3)
|
||||
mode = 0;
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
static const struct attribute_group ad7877_attr_group = {
|
||||
.attrs = ad7877_attributes,
|
||||
.is_visible = ad7877_attr_is_visible,
|
||||
.attrs = ad7877_attributes,
|
||||
};
|
||||
|
||||
static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts)
|
||||
@@ -635,22 +657,25 @@ static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts)
|
||||
|
||||
spi_message_init(m);
|
||||
|
||||
m->complete = ad7877_callback;
|
||||
m->context = ts;
|
||||
|
||||
ts->xfer[0].tx_buf = &ts->cmd_crtl1;
|
||||
ts->xfer[0].len = 2;
|
||||
ts->xfer[0].cs_change = 1;
|
||||
|
||||
spi_message_add_tail(&ts->xfer[0], m);
|
||||
|
||||
ts->xfer[1].tx_buf = &ts->cmd_dummy; /* Send ZERO */
|
||||
ts->xfer[1].len = 2;
|
||||
ts->xfer[1].cs_change = 1;
|
||||
|
||||
spi_message_add_tail(&ts->xfer[1], m);
|
||||
|
||||
for (i = 0; i < 11; i++) {
|
||||
for (i = 0; i < AD7877_NR_SENSE; i++) {
|
||||
ts->xfer[i + 2].rx_buf = &ts->conversion_data[AD7877_SEQ_YPOS + i];
|
||||
ts->xfer[i + 2].len = 2;
|
||||
if (i < (AD7877_NR_SENSE - 1))
|
||||
ts->xfer[i + 2].cs_change = 1;
|
||||
spi_message_add_tail(&ts->xfer[i + 2], m);
|
||||
}
|
||||
}
|
||||
@@ -718,6 +743,8 @@ static int __devinit ad7877_probe(struct spi_device *spi)
|
||||
input_dev->phys = ts->phys;
|
||||
input_dev->dev.parent = &spi->dev;
|
||||
|
||||
__set_bit(EV_KEY, input_dev->evbit);
|
||||
__set_bit(BTN_TOUCH, input_dev->keybit);
|
||||
__set_bit(EV_ABS, input_dev->evbit);
|
||||
__set_bit(ABS_X, input_dev->absbit);
|
||||
__set_bit(ABS_Y, input_dev->absbit);
|
||||
@@ -752,8 +779,9 @@ static int __devinit ad7877_probe(struct spi_device *spi)
|
||||
|
||||
/* Request AD7877 /DAV GPIO interrupt */
|
||||
|
||||
err = request_irq(spi->irq, ad7877_irq, IRQF_TRIGGER_FALLING,
|
||||
spi->dev.driver->name, ts);
|
||||
err = request_threaded_irq(spi->irq, NULL, ad7877_irq,
|
||||
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
|
||||
spi->dev.driver->name, ts);
|
||||
if (err) {
|
||||
dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
|
||||
goto err_free_mem;
|
||||
@@ -763,20 +791,12 @@ static int __devinit ad7877_probe(struct spi_device *spi)
|
||||
if (err)
|
||||
goto err_free_irq;
|
||||
|
||||
err = device_create_file(&spi->dev,
|
||||
gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3);
|
||||
err = input_register_device(input_dev);
|
||||
if (err)
|
||||
goto err_remove_attr_group;
|
||||
|
||||
err = input_register_device(input_dev);
|
||||
if (err)
|
||||
goto err_remove_attr;
|
||||
|
||||
return 0;
|
||||
|
||||
err_remove_attr:
|
||||
device_remove_file(&spi->dev,
|
||||
gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3);
|
||||
err_remove_attr_group:
|
||||
sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group);
|
||||
err_free_irq:
|
||||
@@ -790,11 +810,9 @@ err_free_mem:
|
||||
|
||||
static int __devexit ad7877_remove(struct spi_device *spi)
|
||||
{
|
||||
struct ad7877 *ts = dev_get_drvdata(&spi->dev);
|
||||
struct ad7877 *ts = dev_get_drvdata(&spi->dev);
|
||||
|
||||
sysfs_remove_group(&spi->dev.kobj, &ad7877_attr_group);
|
||||
device_remove_file(&spi->dev,
|
||||
gpio3 ? &dev_attr_gpio3 : &dev_attr_aux3);
|
||||
|
||||
ad7877_disable(ts);
|
||||
free_irq(ts->spi->irq, ts);
|
||||
|
||||
+465
-439
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -206,9 +206,9 @@ static int __devinit cy8ctmg110_probe(struct i2c_client *client,
|
||||
input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
|
||||
|
||||
input_set_abs_params(input_dev, ABS_X,
|
||||
CY8CTMG110_X_MIN, CY8CTMG110_X_MAX, 0, 0);
|
||||
CY8CTMG110_X_MIN, CY8CTMG110_X_MAX, 4, 0);
|
||||
input_set_abs_params(input_dev, ABS_Y,
|
||||
CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 0, 0);
|
||||
CY8CTMG110_Y_MIN, CY8CTMG110_Y_MAX, 4, 0);
|
||||
|
||||
if (ts->reset_pin) {
|
||||
err = gpio_request(ts->reset_pin, NULL);
|
||||
|
||||
@@ -107,8 +107,7 @@ static int __init hp680_ts_init(void)
|
||||
return 0;
|
||||
|
||||
fail2: free_irq(HP680_TS_IRQ, NULL);
|
||||
cancel_delayed_work(&work);
|
||||
flush_scheduled_work();
|
||||
cancel_delayed_work_sync(&work);
|
||||
fail1: input_free_device(hp680_ts_dev);
|
||||
return err;
|
||||
}
|
||||
@@ -116,8 +115,7 @@ static int __init hp680_ts_init(void)
|
||||
static void __exit hp680_ts_exit(void)
|
||||
{
|
||||
free_irq(HP680_TS_IRQ, NULL);
|
||||
cancel_delayed_work(&work);
|
||||
flush_scheduled_work();
|
||||
cancel_delayed_work_sync(&work);
|
||||
input_unregister_device(hp680_ts_dev);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* LPC32xx built-in touchscreen driver
|
||||
*
|
||||
* Copyright (C) 2010 NXP Semiconductors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
/*
|
||||
* Touchscreen controller register offsets
|
||||
*/
|
||||
#define LPC32XX_TSC_STAT 0x00
|
||||
#define LPC32XX_TSC_SEL 0x04
|
||||
#define LPC32XX_TSC_CON 0x08
|
||||
#define LPC32XX_TSC_FIFO 0x0C
|
||||
#define LPC32XX_TSC_DTR 0x10
|
||||
#define LPC32XX_TSC_RTR 0x14
|
||||
#define LPC32XX_TSC_UTR 0x18
|
||||
#define LPC32XX_TSC_TTR 0x1C
|
||||
#define LPC32XX_TSC_DXP 0x20
|
||||
#define LPC32XX_TSC_MIN_X 0x24
|
||||
#define LPC32XX_TSC_MAX_X 0x28
|
||||
#define LPC32XX_TSC_MIN_Y 0x2C
|
||||
#define LPC32XX_TSC_MAX_Y 0x30
|
||||
#define LPC32XX_TSC_AUX_UTR 0x34
|
||||
#define LPC32XX_TSC_AUX_MIN 0x38
|
||||
#define LPC32XX_TSC_AUX_MAX 0x3C
|
||||
|
||||
#define LPC32XX_TSC_STAT_FIFO_OVRRN (1 << 8)
|
||||
#define LPC32XX_TSC_STAT_FIFO_EMPTY (1 << 7)
|
||||
|
||||
#define LPC32XX_TSC_SEL_DEFVAL 0x0284
|
||||
|
||||
#define LPC32XX_TSC_ADCCON_IRQ_TO_FIFO_4 (0x1 << 11)
|
||||
#define LPC32XX_TSC_ADCCON_X_SAMPLE_SIZE(s) ((10 - (s)) << 7)
|
||||
#define LPC32XX_TSC_ADCCON_Y_SAMPLE_SIZE(s) ((10 - (s)) << 4)
|
||||
#define LPC32XX_TSC_ADCCON_POWER_UP (1 << 2)
|
||||
#define LPC32XX_TSC_ADCCON_AUTO_EN (1 << 0)
|
||||
|
||||
#define LPC32XX_TSC_FIFO_TS_P_LEVEL (1 << 31)
|
||||
#define LPC32XX_TSC_FIFO_NORMALIZE_X_VAL(x) (((x) & 0x03FF0000) >> 16)
|
||||
#define LPC32XX_TSC_FIFO_NORMALIZE_Y_VAL(y) ((y) & 0x000003FF)
|
||||
|
||||
#define LPC32XX_TSC_ADCDAT_VALUE_MASK 0x000003FF
|
||||
|
||||
#define LPC32XX_TSC_MIN_XY_VAL 0x0
|
||||
#define LPC32XX_TSC_MAX_XY_VAL 0x3FF
|
||||
|
||||
#define MOD_NAME "ts-lpc32xx"
|
||||
|
||||
#define tsc_readl(dev, reg) \
|
||||
__raw_readl((dev)->tsc_base + (reg))
|
||||
#define tsc_writel(dev, reg, val) \
|
||||
__raw_writel((val), (dev)->tsc_base + (reg))
|
||||
|
||||
struct lpc32xx_tsc {
|
||||
struct input_dev *dev;
|
||||
void __iomem *tsc_base;
|
||||
int irq;
|
||||
struct clk *clk;
|
||||
};
|
||||
|
||||
static void lpc32xx_fifo_clear(struct lpc32xx_tsc *tsc)
|
||||
{
|
||||
while (!(tsc_readl(tsc, LPC32XX_TSC_STAT) &
|
||||
LPC32XX_TSC_STAT_FIFO_EMPTY))
|
||||
tsc_readl(tsc, LPC32XX_TSC_FIFO);
|
||||
}
|
||||
|
||||
static irqreturn_t lpc32xx_ts_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
u32 tmp, rv[4], xs[4], ys[4];
|
||||
int idx;
|
||||
struct lpc32xx_tsc *tsc = dev_id;
|
||||
struct input_dev *input = tsc->dev;
|
||||
|
||||
tmp = tsc_readl(tsc, LPC32XX_TSC_STAT);
|
||||
|
||||
if (tmp & LPC32XX_TSC_STAT_FIFO_OVRRN) {
|
||||
/* FIFO overflow - throw away samples */
|
||||
lpc32xx_fifo_clear(tsc);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gather and normalize 4 samples. Pen-up events may have less
|
||||
* than 4 samples, but its ok to pop 4 and let the last sample
|
||||
* pen status check drop the samples.
|
||||
*/
|
||||
idx = 0;
|
||||
while (idx < 4 &&
|
||||
!(tsc_readl(tsc, LPC32XX_TSC_STAT) &
|
||||
LPC32XX_TSC_STAT_FIFO_EMPTY)) {
|
||||
tmp = tsc_readl(tsc, LPC32XX_TSC_FIFO);
|
||||
xs[idx] = LPC32XX_TSC_ADCDAT_VALUE_MASK -
|
||||
LPC32XX_TSC_FIFO_NORMALIZE_X_VAL(tmp);
|
||||
ys[idx] = LPC32XX_TSC_ADCDAT_VALUE_MASK -
|
||||
LPC32XX_TSC_FIFO_NORMALIZE_Y_VAL(tmp);
|
||||
rv[idx] = tmp;
|
||||
idx++;
|
||||
}
|
||||
|
||||
/* Data is only valid if pen is still down in last sample */
|
||||
if (!(rv[3] & LPC32XX_TSC_FIFO_TS_P_LEVEL) && idx == 4) {
|
||||
/* Use average of 2nd and 3rd sample for position */
|
||||
input_report_abs(input, ABS_X, (xs[1] + xs[2]) / 2);
|
||||
input_report_abs(input, ABS_Y, (ys[1] + ys[2]) / 2);
|
||||
input_report_key(input, BTN_TOUCH, 1);
|
||||
} else {
|
||||
input_report_key(input, BTN_TOUCH, 0);
|
||||
}
|
||||
|
||||
input_sync(input);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void lpc32xx_stop_tsc(struct lpc32xx_tsc *tsc)
|
||||
{
|
||||
/* Disable auto mode */
|
||||
tsc_writel(tsc, LPC32XX_TSC_CON,
|
||||
tsc_readl(tsc, LPC32XX_TSC_CON) &
|
||||
~LPC32XX_TSC_ADCCON_AUTO_EN);
|
||||
|
||||
clk_disable(tsc->clk);
|
||||
}
|
||||
|
||||
static void lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
|
||||
{
|
||||
u32 tmp;
|
||||
|
||||
clk_enable(tsc->clk);
|
||||
|
||||
tmp = tsc_readl(tsc, LPC32XX_TSC_CON) & ~LPC32XX_TSC_ADCCON_POWER_UP;
|
||||
|
||||
/* Set the TSC FIFO depth to 4 samples @ 10-bits per sample (max) */
|
||||
tmp = LPC32XX_TSC_ADCCON_IRQ_TO_FIFO_4 |
|
||||
LPC32XX_TSC_ADCCON_X_SAMPLE_SIZE(10) |
|
||||
LPC32XX_TSC_ADCCON_Y_SAMPLE_SIZE(10);
|
||||
tsc_writel(tsc, LPC32XX_TSC_CON, tmp);
|
||||
|
||||
/* These values are all preset */
|
||||
tsc_writel(tsc, LPC32XX_TSC_SEL, LPC32XX_TSC_SEL_DEFVAL);
|
||||
tsc_writel(tsc, LPC32XX_TSC_MIN_X, LPC32XX_TSC_MIN_XY_VAL);
|
||||
tsc_writel(tsc, LPC32XX_TSC_MAX_X, LPC32XX_TSC_MAX_XY_VAL);
|
||||
tsc_writel(tsc, LPC32XX_TSC_MIN_Y, LPC32XX_TSC_MIN_XY_VAL);
|
||||
tsc_writel(tsc, LPC32XX_TSC_MAX_Y, LPC32XX_TSC_MAX_XY_VAL);
|
||||
|
||||
/* Aux support is not used */
|
||||
tsc_writel(tsc, LPC32XX_TSC_AUX_UTR, 0);
|
||||
tsc_writel(tsc, LPC32XX_TSC_AUX_MIN, 0);
|
||||
tsc_writel(tsc, LPC32XX_TSC_AUX_MAX, 0);
|
||||
|
||||
/*
|
||||
* Set sample rate to about 240Hz per X/Y pair. A single measurement
|
||||
* consists of 4 pairs which gives about a 60Hz sample rate based on
|
||||
* a stable 32768Hz clock source. Values are in clocks.
|
||||
* Rate is (32768 / (RTR + XCONV + RTR + YCONV + DXP + TTR + UTR) / 4
|
||||
*/
|
||||
tsc_writel(tsc, LPC32XX_TSC_RTR, 0x2);
|
||||
tsc_writel(tsc, LPC32XX_TSC_DTR, 0x2);
|
||||
tsc_writel(tsc, LPC32XX_TSC_TTR, 0x10);
|
||||
tsc_writel(tsc, LPC32XX_TSC_DXP, 0x4);
|
||||
tsc_writel(tsc, LPC32XX_TSC_UTR, 88);
|
||||
|
||||
lpc32xx_fifo_clear(tsc);
|
||||
|
||||
/* Enable automatic ts event capture */
|
||||
tsc_writel(tsc, LPC32XX_TSC_CON, tmp | LPC32XX_TSC_ADCCON_AUTO_EN);
|
||||
}
|
||||
|
||||
static int lpc32xx_ts_open(struct input_dev *dev)
|
||||
{
|
||||
struct lpc32xx_tsc *tsc = input_get_drvdata(dev);
|
||||
|
||||
lpc32xx_setup_tsc(tsc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lpc32xx_ts_close(struct input_dev *dev)
|
||||
{
|
||||
struct lpc32xx_tsc *tsc = input_get_drvdata(dev);
|
||||
|
||||
lpc32xx_stop_tsc(tsc);
|
||||
}
|
||||
|
||||
static int __devinit lpc32xx_ts_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct lpc32xx_tsc *tsc;
|
||||
struct input_dev *input;
|
||||
struct resource *res;
|
||||
resource_size_t size;
|
||||
int irq;
|
||||
int error;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res) {
|
||||
dev_err(&pdev->dev, "Can't get memory resource\n");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0) {
|
||||
dev_err(&pdev->dev, "Can't get interrupt resource\n");
|
||||
return irq;
|
||||
}
|
||||
|
||||
tsc = kzalloc(sizeof(*tsc), GFP_KERNEL);
|
||||
input = input_allocate_device();
|
||||
if (!tsc || !input) {
|
||||
dev_err(&pdev->dev, "failed allocating memory\n");
|
||||
error = -ENOMEM;
|
||||
goto err_free_mem;
|
||||
}
|
||||
|
||||
tsc->dev = input;
|
||||
tsc->irq = irq;
|
||||
|
||||
size = resource_size(res);
|
||||
|
||||
if (!request_mem_region(res->start, size, pdev->name)) {
|
||||
dev_err(&pdev->dev, "TSC registers are not free\n");
|
||||
error = -EBUSY;
|
||||
goto err_free_mem;
|
||||
}
|
||||
|
||||
tsc->tsc_base = ioremap(res->start, size);
|
||||
if (!tsc->tsc_base) {
|
||||
dev_err(&pdev->dev, "Can't map memory\n");
|
||||
error = -ENOMEM;
|
||||
goto err_release_mem;
|
||||
}
|
||||
|
||||
tsc->clk = clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(tsc->clk)) {
|
||||
dev_err(&pdev->dev, "failed getting clock\n");
|
||||
error = PTR_ERR(tsc->clk);
|
||||
goto err_unmap;
|
||||
}
|
||||
|
||||
input->name = MOD_NAME;
|
||||
input->phys = "lpc32xx/input0";
|
||||
input->id.bustype = BUS_HOST;
|
||||
input->id.vendor = 0x0001;
|
||||
input->id.product = 0x0002;
|
||||
input->id.version = 0x0100;
|
||||
input->dev.parent = &pdev->dev;
|
||||
input->open = lpc32xx_ts_open;
|
||||
input->close = lpc32xx_ts_close;
|
||||
|
||||
input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
|
||||
input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
|
||||
input_set_abs_params(input, ABS_X, LPC32XX_TSC_MIN_XY_VAL,
|
||||
LPC32XX_TSC_MAX_XY_VAL, 0, 0);
|
||||
input_set_abs_params(input, ABS_Y, LPC32XX_TSC_MIN_XY_VAL,
|
||||
LPC32XX_TSC_MAX_XY_VAL, 0, 0);
|
||||
|
||||
input_set_drvdata(input, tsc);
|
||||
|
||||
error = request_irq(tsc->irq, lpc32xx_ts_interrupt,
|
||||
IRQF_DISABLED, pdev->name, tsc);
|
||||
if (error) {
|
||||
dev_err(&pdev->dev, "failed requesting interrupt\n");
|
||||
goto err_put_clock;
|
||||
}
|
||||
|
||||
error = input_register_device(input);
|
||||
if (error) {
|
||||
dev_err(&pdev->dev, "failed registering input device\n");
|
||||
goto err_free_irq;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, tsc);
|
||||
device_init_wakeup(&pdev->dev, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
err_free_irq:
|
||||
free_irq(tsc->irq, tsc);
|
||||
err_put_clock:
|
||||
clk_put(tsc->clk);
|
||||
err_unmap:
|
||||
iounmap(tsc->tsc_base);
|
||||
err_release_mem:
|
||||
release_mem_region(res->start, size);
|
||||
err_free_mem:
|
||||
input_free_device(input);
|
||||
kfree(tsc);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static int __devexit lpc32xx_ts_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct lpc32xx_tsc *tsc = platform_get_drvdata(pdev);
|
||||
struct resource *res;
|
||||
|
||||
device_init_wakeup(&pdev->dev, 0);
|
||||
free_irq(tsc->irq, tsc);
|
||||
|
||||
input_unregister_device(tsc->dev);
|
||||
|
||||
clk_put(tsc->clk);
|
||||
|
||||
iounmap(tsc->tsc_base);
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
release_mem_region(res->start, resource_size(res));
|
||||
|
||||
kfree(tsc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int lpc32xx_ts_suspend(struct device *dev)
|
||||
{
|
||||
struct lpc32xx_tsc *tsc = dev_get_drvdata(dev);
|
||||
struct input_dev *input = tsc->dev;
|
||||
|
||||
/*
|
||||
* Suspend and resume can be called when the device hasn't been
|
||||
* enabled. If there are no users that have the device open, then
|
||||
* avoid calling the TSC stop and start functions as the TSC
|
||||
* isn't yet clocked.
|
||||
*/
|
||||
mutex_lock(&input->mutex);
|
||||
|
||||
if (input->users) {
|
||||
if (device_may_wakeup(dev))
|
||||
enable_irq_wake(tsc->irq);
|
||||
else
|
||||
lpc32xx_stop_tsc(tsc);
|
||||
}
|
||||
|
||||
mutex_unlock(&input->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lpc32xx_ts_resume(struct device *dev)
|
||||
{
|
||||
struct lpc32xx_tsc *tsc = dev_get_drvdata(dev);
|
||||
struct input_dev *input = tsc->dev;
|
||||
|
||||
mutex_lock(&input->mutex);
|
||||
|
||||
if (input->users) {
|
||||
if (device_may_wakeup(dev))
|
||||
disable_irq_wake(tsc->irq);
|
||||
else
|
||||
lpc32xx_setup_tsc(tsc);
|
||||
}
|
||||
|
||||
mutex_unlock(&input->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops lpc32xx_ts_pm_ops = {
|
||||
.suspend = lpc32xx_ts_suspend,
|
||||
.resume = lpc32xx_ts_resume,
|
||||
};
|
||||
#define LPC32XX_TS_PM_OPS (&lpc32xx_ts_pm_ops)
|
||||
#else
|
||||
#define LPC32XX_TS_PM_OPS NULL
|
||||
#endif
|
||||
|
||||
static struct platform_driver lpc32xx_ts_driver = {
|
||||
.probe = lpc32xx_ts_probe,
|
||||
.remove = __devexit_p(lpc32xx_ts_remove),
|
||||
.driver = {
|
||||
.name = MOD_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.pm = LPC32XX_TS_PM_OPS,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init lpc32xx_ts_init(void)
|
||||
{
|
||||
return platform_driver_register(&lpc32xx_ts_driver);
|
||||
}
|
||||
module_init(lpc32xx_ts_init);
|
||||
|
||||
static void __exit lpc32xx_ts_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&lpc32xx_ts_driver);
|
||||
}
|
||||
module_exit(lpc32xx_ts_exit);
|
||||
|
||||
MODULE_AUTHOR("Kevin Wells <kevin.wells@nxp.com");
|
||||
MODULE_DESCRIPTION("LPC32XX TSC Driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("platform:lpc32xx_ts");
|
||||
@@ -350,7 +350,7 @@ static int __devinit s3c2410ts_probe(struct platform_device *pdev)
|
||||
err_tcirq:
|
||||
free_irq(ts.irq_tc, ts.input);
|
||||
err_inputdev:
|
||||
input_unregister_device(ts.input);
|
||||
input_free_device(ts.input);
|
||||
err_iomap:
|
||||
iounmap(ts.io);
|
||||
err_clk:
|
||||
|
||||
@@ -268,7 +268,7 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
|
||||
struct stmpe_touch *ts;
|
||||
struct input_dev *idev;
|
||||
struct stmpe_ts_platform_data *ts_pdata = NULL;
|
||||
int ret = 0;
|
||||
int ret;
|
||||
int ts_irq;
|
||||
|
||||
ts_irq = platform_get_irq_byname(pdev, "FIFO_TH");
|
||||
@@ -276,12 +276,16 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
|
||||
return ts_irq;
|
||||
|
||||
ts = kzalloc(sizeof(*ts), GFP_KERNEL);
|
||||
if (!ts)
|
||||
if (!ts) {
|
||||
ret = -ENOMEM;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
idev = input_allocate_device();
|
||||
if (!idev)
|
||||
if (!idev) {
|
||||
ret = -ENOMEM;
|
||||
goto err_free_ts;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, ts);
|
||||
ts->stmpe = stmpe;
|
||||
@@ -361,7 +365,6 @@ static int __devexit stmpe_ts_remove(struct platform_device *pdev)
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
|
||||
input_unregister_device(ts->idev);
|
||||
input_free_device(ts->idev);
|
||||
|
||||
kfree(ts);
|
||||
|
||||
|
||||
@@ -335,6 +335,7 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
|
||||
dev_err(tsc->dev, "schedule failed");
|
||||
goto err2;
|
||||
}
|
||||
platform_set_drvdata(pdev, tps6507x_dev);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -358,7 +359,7 @@ static int __devexit tps6507x_ts_remove(struct platform_device *pdev)
|
||||
cancel_delayed_work_sync(&tsc->work);
|
||||
destroy_workqueue(tsc->wq);
|
||||
|
||||
input_free_device(input_dev);
|
||||
input_unregister_device(input_dev);
|
||||
|
||||
tps6507x_dev->ts = NULL;
|
||||
kfree(tsc);
|
||||
|
||||
@@ -265,7 +265,7 @@ static int __devinit tsc2007_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct tsc2007 *ts;
|
||||
struct tsc2007_platform_data *pdata = pdata = client->dev.platform_data;
|
||||
struct tsc2007_platform_data *pdata = client->dev.platform_data;
|
||||
struct input_dev *input_dev;
|
||||
int err;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Wacom W8001 penabled serial touchscreen driver
|
||||
*
|
||||
* Copyright (c) 2008 Jaya Kumar
|
||||
* Copyright (c) 2010 Red Hat, Inc.
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file COPYING in the main directory of this archive for
|
||||
@@ -30,11 +31,24 @@ MODULE_LICENSE("GPL");
|
||||
#define W8001_LEAD_BYTE 0x80
|
||||
#define W8001_TAB_MASK 0x40
|
||||
#define W8001_TAB_BYTE 0x40
|
||||
/* set in first byte of touch data packets */
|
||||
#define W8001_TOUCH_MASK (0x10 | W8001_LEAD_MASK)
|
||||
#define W8001_TOUCH_BYTE (0x10 | W8001_LEAD_BYTE)
|
||||
|
||||
#define W8001_QUERY_PACKET 0x20
|
||||
|
||||
#define W8001_CMD_START '1'
|
||||
#define W8001_CMD_QUERY '*'
|
||||
#define W8001_CMD_TOUCHQUERY '%'
|
||||
|
||||
/* length of data packets in bytes, depends on device. */
|
||||
#define W8001_PKTLEN_TOUCH93 5
|
||||
#define W8001_PKTLEN_TOUCH9A 7
|
||||
#define W8001_PKTLEN_TPCPEN 9
|
||||
#define W8001_PKTLEN_TPCCTL 11 /* control packet */
|
||||
#define W8001_PKTLEN_TOUCH2FG 13
|
||||
|
||||
#define MAX_TRACKING_ID 0xFF /* arbitrarily chosen */
|
||||
|
||||
struct w8001_coord {
|
||||
u8 rdy;
|
||||
@@ -48,6 +62,15 @@ struct w8001_coord {
|
||||
u8 tilt_y;
|
||||
};
|
||||
|
||||
/* touch query reply packet */
|
||||
struct w8001_touch_query {
|
||||
u8 panel_res;
|
||||
u8 capacity_res;
|
||||
u8 sensor_id;
|
||||
u16 x;
|
||||
u16 y;
|
||||
};
|
||||
|
||||
/*
|
||||
* Per-touchscreen data.
|
||||
*/
|
||||
@@ -62,6 +85,9 @@ struct w8001 {
|
||||
unsigned char response[W8001_MAX_LENGTH];
|
||||
unsigned char data[W8001_MAX_LENGTH];
|
||||
char phys[32];
|
||||
int type;
|
||||
unsigned int pktlen;
|
||||
int trkid[2];
|
||||
};
|
||||
|
||||
static void parse_data(u8 *data, struct w8001_coord *coord)
|
||||
@@ -88,11 +114,98 @@ static void parse_data(u8 *data, struct w8001_coord *coord)
|
||||
coord->tilt_y = data[8] & 0x7F;
|
||||
}
|
||||
|
||||
static void parse_touch(struct w8001 *w8001)
|
||||
{
|
||||
static int trkid;
|
||||
struct input_dev *dev = w8001->dev;
|
||||
unsigned char *data = w8001->data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
input_mt_slot(dev, i);
|
||||
|
||||
if (data[0] & (1 << i)) {
|
||||
int x = (data[6 * i + 1] << 7) | (data[6 * i + 2]);
|
||||
int y = (data[6 * i + 3] << 7) | (data[6 * i + 4]);
|
||||
/* data[5,6] and [11,12] is finger capacity */
|
||||
|
||||
input_report_abs(dev, ABS_MT_POSITION_X, x);
|
||||
input_report_abs(dev, ABS_MT_POSITION_Y, y);
|
||||
input_report_abs(dev, ABS_MT_TOOL_TYPE, MT_TOOL_FINGER);
|
||||
if (w8001->trkid[i] < 0)
|
||||
w8001->trkid[i] = trkid++ & MAX_TRACKING_ID;
|
||||
} else {
|
||||
w8001->trkid[i] = -1;
|
||||
}
|
||||
input_report_abs(dev, ABS_MT_TRACKING_ID, w8001->trkid[i]);
|
||||
}
|
||||
|
||||
input_sync(dev);
|
||||
}
|
||||
|
||||
static void parse_touchquery(u8 *data, struct w8001_touch_query *query)
|
||||
{
|
||||
memset(query, 0, sizeof(*query));
|
||||
|
||||
query->panel_res = data[1];
|
||||
query->sensor_id = data[2] & 0x7;
|
||||
query->capacity_res = data[7];
|
||||
|
||||
query->x = data[3] << 9;
|
||||
query->x |= data[4] << 2;
|
||||
query->x |= (data[2] >> 5) & 0x3;
|
||||
|
||||
query->y = data[5] << 9;
|
||||
query->y |= data[6] << 2;
|
||||
query->y |= (data[2] >> 3) & 0x3;
|
||||
}
|
||||
|
||||
static void report_pen_events(struct w8001 *w8001, struct w8001_coord *coord)
|
||||
{
|
||||
struct input_dev *dev = w8001->dev;
|
||||
|
||||
/*
|
||||
* We have 1 bit for proximity (rdy) and 3 bits for tip, side,
|
||||
* side2/eraser. If rdy && f2 are set, this can be either pen + side2,
|
||||
* or eraser. assume
|
||||
* - if dev is already in proximity and f2 is toggled → pen + side2
|
||||
* - if dev comes into proximity with f2 set → eraser
|
||||
* If f2 disappears after assuming eraser, fake proximity out for
|
||||
* eraser and in for pen.
|
||||
*/
|
||||
|
||||
if (!w8001->type) {
|
||||
w8001->type = coord->f2 ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
|
||||
} else if (w8001->type == BTN_TOOL_RUBBER) {
|
||||
if (!coord->f2) {
|
||||
input_report_abs(dev, ABS_PRESSURE, 0);
|
||||
input_report_key(dev, BTN_TOUCH, 0);
|
||||
input_report_key(dev, BTN_STYLUS, 0);
|
||||
input_report_key(dev, BTN_STYLUS2, 0);
|
||||
input_report_key(dev, BTN_TOOL_RUBBER, 0);
|
||||
input_sync(dev);
|
||||
w8001->type = BTN_TOOL_PEN;
|
||||
}
|
||||
} else {
|
||||
input_report_key(dev, BTN_STYLUS2, coord->f2);
|
||||
}
|
||||
|
||||
input_report_abs(dev, ABS_X, coord->x);
|
||||
input_report_abs(dev, ABS_Y, coord->y);
|
||||
input_report_abs(dev, ABS_PRESSURE, coord->pen_pressure);
|
||||
input_report_key(dev, BTN_TOUCH, coord->tsw);
|
||||
input_report_key(dev, BTN_STYLUS, coord->f1);
|
||||
input_report_key(dev, w8001->type, coord->rdy);
|
||||
input_sync(dev);
|
||||
|
||||
if (!coord->rdy)
|
||||
w8001->type = 0;
|
||||
}
|
||||
|
||||
static irqreturn_t w8001_interrupt(struct serio *serio,
|
||||
unsigned char data, unsigned int flags)
|
||||
{
|
||||
struct w8001 *w8001 = serio_get_drvdata(serio);
|
||||
struct input_dev *dev = w8001->dev;
|
||||
struct w8001_coord coord;
|
||||
unsigned char tmp;
|
||||
|
||||
@@ -105,26 +218,45 @@ static irqreturn_t w8001_interrupt(struct serio *serio,
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case W8001_PKTLEN_TOUCH93 - 1:
|
||||
case W8001_PKTLEN_TOUCH9A - 1:
|
||||
/* ignore one-finger touch packet. */
|
||||
if (w8001->pktlen == w8001->idx)
|
||||
w8001->idx = 0;
|
||||
break;
|
||||
|
||||
/* Pen coordinates packet */
|
||||
case W8001_PKTLEN_TPCPEN - 1:
|
||||
tmp = w8001->data[0] & W8001_TAB_MASK;
|
||||
if (unlikely(tmp == W8001_TAB_BYTE))
|
||||
break;
|
||||
|
||||
tmp = (w8001->data[0] & W8001_TOUCH_BYTE);
|
||||
if (tmp == W8001_TOUCH_BYTE)
|
||||
break;
|
||||
|
||||
w8001->idx = 0;
|
||||
parse_data(w8001->data, &coord);
|
||||
input_report_abs(dev, ABS_X, coord.x);
|
||||
input_report_abs(dev, ABS_Y, coord.y);
|
||||
input_report_abs(dev, ABS_PRESSURE, coord.pen_pressure);
|
||||
input_report_key(dev, BTN_TOUCH, coord.tsw);
|
||||
input_sync(dev);
|
||||
report_pen_events(w8001, &coord);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
/* control packet */
|
||||
case W8001_PKTLEN_TPCCTL - 1:
|
||||
tmp = (w8001->data[0] & W8001_TOUCH_MASK);
|
||||
if (tmp == W8001_TOUCH_BYTE)
|
||||
break;
|
||||
|
||||
w8001->idx = 0;
|
||||
memcpy(w8001->response, w8001->data, W8001_MAX_LENGTH);
|
||||
w8001->response_type = W8001_QUERY_PACKET;
|
||||
complete(&w8001->cmd_done);
|
||||
break;
|
||||
|
||||
/* 2 finger touch packet */
|
||||
case W8001_PKTLEN_TOUCH2FG - 1:
|
||||
w8001->idx = 0;
|
||||
parse_touch(w8001);
|
||||
break;
|
||||
}
|
||||
|
||||
return IRQ_HANDLED;
|
||||
@@ -167,6 +299,38 @@ static int w8001_setup(struct w8001 *w8001)
|
||||
input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0);
|
||||
input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0);
|
||||
|
||||
error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);
|
||||
if (!error) {
|
||||
struct w8001_touch_query touch;
|
||||
|
||||
parse_touchquery(w8001->response, &touch);
|
||||
|
||||
switch (touch.sensor_id) {
|
||||
case 0:
|
||||
case 2:
|
||||
w8001->pktlen = W8001_PKTLEN_TOUCH93;
|
||||
break;
|
||||
case 1:
|
||||
case 3:
|
||||
case 4:
|
||||
w8001->pktlen = W8001_PKTLEN_TOUCH9A;
|
||||
break;
|
||||
case 5:
|
||||
w8001->pktlen = W8001_PKTLEN_TOUCH2FG;
|
||||
|
||||
input_mt_create_slots(dev, 2);
|
||||
input_set_abs_params(dev, ABS_MT_TRACKING_ID,
|
||||
0, MAX_TRACKING_ID, 0, 0);
|
||||
input_set_abs_params(dev, ABS_MT_POSITION_X,
|
||||
0, touch.x, 0, 0);
|
||||
input_set_abs_params(dev, ABS_MT_POSITION_Y,
|
||||
0, touch.y, 0, 0);
|
||||
input_set_abs_params(dev, ABS_MT_TOOL_TYPE,
|
||||
0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return w8001_command(w8001, W8001_CMD_START, false);
|
||||
}
|
||||
|
||||
@@ -208,6 +372,7 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv)
|
||||
w8001->serio = serio;
|
||||
w8001->id = serio->id.id;
|
||||
w8001->dev = input_dev;
|
||||
w8001->trkid[0] = w8001->trkid[1] = -1;
|
||||
init_completion(&w8001->cmd_done);
|
||||
snprintf(w8001->phys, sizeof(w8001->phys), "%s/input0", serio->phys);
|
||||
|
||||
@@ -221,6 +386,10 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv)
|
||||
|
||||
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
|
||||
input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
|
||||
input_dev->keybit[BIT_WORD(BTN_TOOL_PEN)] |= BIT_MASK(BTN_TOOL_PEN);
|
||||
input_dev->keybit[BIT_WORD(BTN_TOOL_RUBBER)] |= BIT_MASK(BTN_TOOL_RUBBER);
|
||||
input_dev->keybit[BIT_WORD(BTN_STYLUS)] |= BIT_MASK(BTN_STYLUS);
|
||||
input_dev->keybit[BIT_WORD(BTN_STYLUS2)] |= BIT_MASK(BTN_STYLUS2);
|
||||
|
||||
serio_set_drvdata(serio, w8001);
|
||||
err = serio_open(serio, drv);
|
||||
|
||||
@@ -125,6 +125,8 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel)
|
||||
{
|
||||
int power_adc = 0, auxval;
|
||||
u16 power = 0;
|
||||
int rc = 0;
|
||||
int timeout = 0;
|
||||
|
||||
/* get codec */
|
||||
mutex_lock(&wm->codec_mutex);
|
||||
@@ -143,7 +145,9 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel)
|
||||
|
||||
/* Turn polling mode on to read AUX ADC */
|
||||
wm->pen_probably_down = 1;
|
||||
wm->codec->poll_sample(wm, adcsel, &auxval);
|
||||
|
||||
while (rc != RC_VALID && timeout++ < 5)
|
||||
rc = wm->codec->poll_sample(wm, adcsel, &auxval);
|
||||
|
||||
if (power_adc)
|
||||
wm97xx_reg_write(wm, AC97_EXTENDED_MID, power | 0x8000);
|
||||
@@ -152,8 +156,15 @@ int wm97xx_read_aux_adc(struct wm97xx *wm, u16 adcsel)
|
||||
|
||||
wm->pen_probably_down = 0;
|
||||
|
||||
if (timeout >= 5) {
|
||||
dev_err(wm->dev,
|
||||
"timeout reading auxadc %d, disabling digitiser\n",
|
||||
adcsel);
|
||||
wm->codec->dig_enable(wm, false);
|
||||
}
|
||||
|
||||
mutex_unlock(&wm->codec_mutex);
|
||||
return auxval & 0xfff;
|
||||
return (rc == RC_VALID ? auxval & 0xfff : -EBUSY);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc);
|
||||
|
||||
@@ -684,8 +695,7 @@ static int wm97xx_probe(struct device *dev)
|
||||
touch_reg_err:
|
||||
platform_device_put(wm->touch_dev);
|
||||
touch_err:
|
||||
platform_device_unregister(wm->battery_dev);
|
||||
wm->battery_dev = NULL;
|
||||
platform_device_del(wm->battery_dev);
|
||||
batt_reg_err:
|
||||
platform_device_put(wm->battery_dev);
|
||||
batt_err:
|
||||
|
||||
Reference in New Issue
Block a user