Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115057
b: refs/heads/master
c: 82a196f
h: refs/heads/master
i:
  115055: f15bc9e
v: v3
  • Loading branch information
Sven Anders authored and Dmitry Torokhov committed Aug 8, 2008
1 parent 14d6984 commit 08d7f25
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d83d213d9fda671dfd84ea81182742f9e329a6b4
refs/heads/master: 82a196f481661170b4982dc7e68a12e9253309d0
53 changes: 35 additions & 18 deletions trunk/drivers/input/mouse/appletouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,28 @@ MODULE_DEVICE_TABLE(usb, atp_table);
#define ATP_GEYSER_MODE_REQUEST_INDEX 0
#define ATP_GEYSER_MODE_VENDOR_VALUE 0x04

/**
* enum atp_status_bits - status bit meanings
*
* These constants represent the meaning of the status bits.
* (only Geyser 3/4)
*
* @ATP_STATUS_BUTTON: The button was pressed
* @ATP_STATUS_BASE_UPDATE: Update of the base values (untouched pad)
* @ATP_STATUS_FROM_RESET: Reset previously performed
*/
enum atp_status_bits {
ATP_STATUS_BUTTON = BIT(0),
ATP_STATUS_BASE_UPDATE = BIT(2),
ATP_STATUS_FROM_RESET = BIT(4),
};

/* Structure to hold all of our device specific stuff */
struct atp {
char phys[64];
struct usb_device *udev; /* usb device */
struct urb *urb; /* usb request block */
signed char *data; /* transferred data */
u8 *data; /* transferred data */
struct input_dev *input; /* input dev */
enum atp_touchpad_type type; /* type of touchpad */
bool open;
Expand Down Expand Up @@ -251,8 +267,6 @@ static void atp_reinit(struct work_struct *work)
int retval;

dprintk("appletouch: putting appletouch to sleep (reinit)\n");
dev->idlecount = 0;

atp_geyser_init(udev);

retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
Expand Down Expand Up @@ -488,7 +502,7 @@ static void atp_complete_geyser_1_2(struct urb *urb)
ATP_XFACT, &x_z, &x_f);
y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS,
ATP_YFACT, &y_z, &y_f);
key = dev->data[dev->datalen - 1] & 1;
key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON;

if (x && y) {
if (dev->x_old != -1) {
Expand Down Expand Up @@ -568,34 +582,38 @@ static void atp_complete_geyser_3_4(struct urb *urb)

dbg_dump("sample", dev->xy_cur);

if (!dev->valid) {
/* first sample */
dev->valid = true;
dev->x_old = dev->y_old = -1;
memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
/* Just update the base values (i.e. touchpad in untouched state) */
if (dev->data[dev->datalen - 1] & ATP_STATUS_BASE_UPDATE) {

dprintk(KERN_DEBUG "appletouch: updated base values\n");

memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));
goto exit;
}

for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) {
/* accumulate the change */
signed char change = dev->xy_old[i] - dev->xy_cur[i];
dev->xy_acc[i] -= change;
/* calculate the change */
dev->xy_acc[i] = dev->xy_cur[i] - dev->xy_old[i];

/* this is a round-robin value, so couple with that */
if (dev->xy_acc[i] > 127)
dev->xy_acc[i] -= 256;

if (dev->xy_acc[i] < -127)
dev->xy_acc[i] += 256;

/* prevent down drifting */
if (dev->xy_acc[i] < 0)
dev->xy_acc[i] = 0;
}

memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));

dbg_dump("accumulator", dev->xy_acc);

x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS,
ATP_XFACT, &x_z, &x_f);
y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS,
ATP_YFACT, &y_z, &y_f);
key = dev->data[dev->datalen - 1] & 1;
key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON;

if (x && y) {
if (dev->x_old != -1) {
Expand Down Expand Up @@ -647,7 +665,8 @@ static void atp_complete_geyser_3_4(struct urb *urb)
if (!x && !y && !key) {
dev->idlecount++;
if (dev->idlecount == 10) {
dev->valid = false;
dev->x_old = dev->y_old = -1;
dev->idlecount = 0;
schedule_work(&dev->work);
/* Don't resubmit urb here, wait for reinit */
return;
Expand Down Expand Up @@ -879,8 +898,6 @@ static int atp_suspend(struct usb_interface *iface, pm_message_t message)
struct atp *dev = usb_get_intfdata(iface);

usb_kill_urb(dev->urb);
dev->valid = false;

return 0;
}

Expand Down

0 comments on commit 08d7f25

Please sign in to comment.