aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2006-04-02 00:08:05 -0500
committerDmitry Torokhov <dtor_core@ameritech.net>2006-04-02 00:08:05 -0500
commit95d465fd750897ab32462a6702fbfe1b122cbbc0 (patch)
tree65c38b2f11c51bb6932e44dd6c92f15b0091abfe /drivers/input/mouse
parent642fde17dceceb56c7ba2762733ac688666ae657 (diff)
parent683aa4012f53b2ada0f430487e05d37b0d94e90a (diff)
Manual merge with Linus.
Conflicts: arch/powerpc/kernel/setup-common.c drivers/input/keyboard/hil_kbd.c drivers/input/mouse/hil_ptr.c
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r--drivers/input/mouse/hil_ptr.c88
1 files changed, 47 insertions, 41 deletions
diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c
index 798f4a3ad7d2..69f02178c528 100644
--- a/drivers/input/mouse/hil_ptr.c
+++ b/drivers/input/mouse/hil_ptr.c
@@ -55,7 +55,7 @@ MODULE_LICENSE("Dual BSD/GPL");
55#define HIL_PTR_MAX_LENGTH 16 55#define HIL_PTR_MAX_LENGTH 16
56 56
57struct hil_ptr { 57struct hil_ptr {
58 struct input_dev dev; 58 struct input_dev *dev;
59 struct serio *serio; 59 struct serio *serio;
60 60
61 /* Input buffer and index for packets from HIL bus. */ 61 /* Input buffer and index for packets from HIL bus. */
@@ -79,7 +79,7 @@ struct hil_ptr {
79/* Process a complete packet after transfer from the HIL */ 79/* Process a complete packet after transfer from the HIL */
80static void hil_ptr_process_record(struct hil_ptr *ptr) 80static void hil_ptr_process_record(struct hil_ptr *ptr)
81{ 81{
82 struct input_dev *dev = &ptr->dev; 82 struct input_dev *dev = ptr->dev;
83 hil_packet *data = ptr->data; 83 hil_packet *data = ptr->data;
84 hil_packet p; 84 hil_packet p;
85 int idx, i, cnt, laxis; 85 int idx, i, cnt, laxis;
@@ -148,12 +148,12 @@ static void hil_ptr_process_record(struct hil_ptr *ptr)
148 if (absdev) { 148 if (absdev) {
149 val = lo + (hi<<8); 149 val = lo + (hi<<8);
150#ifdef TABLET_AUTOADJUST 150#ifdef TABLET_AUTOADJUST
151 if (val < ptr->dev.absmin[ABS_X + i]) 151 if (val < dev->absmin[ABS_X + i])
152 ptr->dev.absmin[ABS_X + i] = val; 152 dev->absmin[ABS_X + i] = val;
153 if (val > ptr->dev.absmax[ABS_X + i]) 153 if (val > dev->absmax[ABS_X + i])
154 ptr->dev.absmax[ABS_X + i] = val; 154 dev->absmax[ABS_X + i] = val;
155#endif 155#endif
156 if (i%3) val = ptr->dev.absmax[ABS_X + i] - val; 156 if (i%3) val = dev->absmax[ABS_X + i] - val;
157 input_report_abs(dev, ABS_X + i, val); 157 input_report_abs(dev, ABS_X + i, val);
158 } else { 158 } else {
159 val = (int) (((int8_t)lo) | ((int8_t)hi<<8)); 159 val = (int) (((int8_t)lo) | ((int8_t)hi<<8));
@@ -233,27 +233,32 @@ static void hil_ptr_disconnect(struct serio *serio)
233 return; 233 return;
234 } 234 }
235 235
236 input_unregister_device(&ptr->dev);
237 serio_close(serio); 236 serio_close(serio);
237 input_unregister_device(ptr->dev);
238 kfree(ptr); 238 kfree(ptr);
239} 239}
240 240
241static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver) 241static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
242{ 242{
243 struct hil_ptr *ptr; 243 struct hil_ptr *ptr;
244 char *txt; 244 char *txt;
245 unsigned int i, naxsets, btntype; 245 unsigned int i, naxsets, btntype;
246 uint8_t did, *idd; 246 uint8_t did, *idd;
247 247
248 if (!(ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL))) 248 if (!(ptr = kzalloc(sizeof(struct hil_ptr), GFP_KERNEL)))
249 return -ENOMEM; 249 return -ENOMEM;
250 250
251 if (serio_open(serio, driver)) 251 ptr->dev = input_allocate_device();
252 if (!ptr->dev)
252 goto bail0; 253 goto bail0;
253 254
255 ptr->dev->private = ptr;
256
257 if (serio_open(serio, driver))
258 goto bail1;
259
254 serio_set_drvdata(serio, ptr); 260 serio_set_drvdata(serio, ptr);
255 ptr->serio = serio; 261 ptr->serio = serio;
256 ptr->dev.private = ptr;
257 262
258 init_MUTEX_LOCKED(&(ptr->sem)); 263 init_MUTEX_LOCKED(&(ptr->sem));
259 264
@@ -284,25 +289,24 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
284 289
285 up(&(ptr->sem)); 290 up(&(ptr->sem));
286 291
287 init_input_dev(&ptr->dev);
288 did = ptr->idd[0]; 292 did = ptr->idd[0];
289 idd = ptr->idd + 1; 293 idd = ptr->idd + 1;
290 txt = "unknown"; 294 txt = "unknown";
291 if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { 295 if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) {
292 ptr->dev.evbit[0] = BIT(EV_REL); 296 ptr->dev->evbit[0] = BIT(EV_REL);
293 txt = "relative"; 297 txt = "relative";
294 } 298 }
295 299
296 if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_ABS) { 300 if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_ABS) {
297 ptr->dev.evbit[0] = BIT(EV_ABS); 301 ptr->dev->evbit[0] = BIT(EV_ABS);
298 txt = "absolute"; 302 txt = "absolute";
299 } 303 }
300 if (!ptr->dev.evbit[0]) { 304 if (!ptr->dev->evbit[0]) {
301 goto bail1; 305 goto bail2;
302 } 306 }
303 307
304 ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd); 308 ptr->nbtn = HIL_IDD_NUM_BUTTONS(idd);
305 if (ptr->nbtn) ptr->dev.evbit[0] |= BIT(EV_KEY); 309 if (ptr->nbtn) ptr->dev->evbit[0] |= BIT(EV_KEY);
306 310
307 naxsets = HIL_IDD_NUM_AXSETS(*idd); 311 naxsets = HIL_IDD_NUM_AXSETS(*idd);
308 ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd); 312 ptr->naxes = HIL_IDD_NUM_AXES_PER_SET(*idd);
@@ -326,7 +330,7 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
326 btntype = BTN_MOUSE; 330 btntype = BTN_MOUSE;
327 331
328 for (i = 0; i < ptr->nbtn; i++) { 332 for (i = 0; i < ptr->nbtn; i++) {
329 set_bit(btntype | i, ptr->dev.keybit); 333 set_bit(btntype | i, ptr->dev->keybit);
330 ptr->btnmap[i] = btntype | i; 334 ptr->btnmap[i] = btntype | i;
331 } 335 }
332 336
@@ -338,50 +342,52 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
338 342
339 if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) { 343 if ((did & HIL_IDD_DID_TYPE_MASK) == HIL_IDD_DID_TYPE_REL) {
340 for (i = 0; i < ptr->naxes; i++) { 344 for (i = 0; i < ptr->naxes; i++) {
341 set_bit(REL_X + i, ptr->dev.relbit); 345 set_bit(REL_X + i, ptr->dev->relbit);
342 } 346 }
343 for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) { 347 for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) {
344 set_bit(REL_X + i, ptr->dev.relbit); 348 set_bit(REL_X + i, ptr->dev->relbit);
345 } 349 }
346 } else { 350 } else {
347 for (i = 0; i < ptr->naxes; i++) { 351 for (i = 0; i < ptr->naxes; i++) {
348 set_bit(ABS_X + i, ptr->dev.absbit); 352 set_bit(ABS_X + i, ptr->dev->absbit);
349 ptr->dev.absmin[ABS_X + i] = 0; 353 ptr->dev->absmin[ABS_X + i] = 0;
350 ptr->dev.absmax[ABS_X + i] = 354 ptr->dev->absmax[ABS_X + i] =
351 HIL_IDD_AXIS_MAX((ptr->idd + 1), i); 355 HIL_IDD_AXIS_MAX((ptr->idd + 1), i);
352 } 356 }
353 for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) { 357 for (i = 3; (i < ptr->naxes + 3) && (naxsets > 1); i++) {
354 set_bit(ABS_X + i, ptr->dev.absbit); 358 set_bit(ABS_X + i, ptr->dev->absbit);
355 ptr->dev.absmin[ABS_X + i] = 0; 359 ptr->dev->absmin[ABS_X + i] = 0;
356 ptr->dev.absmax[ABS_X + i] = 360 ptr->dev->absmax[ABS_X + i] =
357 HIL_IDD_AXIS_MAX((ptr->idd + 1), (i - 3)); 361 HIL_IDD_AXIS_MAX((ptr->idd + 1), (i - 3));
358 } 362 }
359#ifdef TABLET_AUTOADJUST 363#ifdef TABLET_AUTOADJUST
360 for (i = 0; i < ABS_MAX; i++) { 364 for (i = 0; i < ABS_MAX; i++) {
361 int diff = ptr->dev.absmax[ABS_X + i] / 10; 365 int diff = ptr->dev->absmax[ABS_X + i] / 10;
362 ptr->dev.absmin[ABS_X + i] += diff; 366 ptr->dev->absmin[ABS_X + i] += diff;
363 ptr->dev.absmax[ABS_X + i] -= diff; 367 ptr->dev->absmax[ABS_X + i] -= diff;
364 } 368 }
365#endif 369#endif
366 } 370 }
367 371
368 ptr->dev.name = strlen(ptr->rnm) ? ptr->rnm : HIL_GENERIC_NAME; 372 ptr->dev->name = strlen(ptr->rnm) ? ptr->rnm : HIL_GENERIC_NAME;
369 373
370 ptr->dev.id.bustype = BUS_HIL; 374 ptr->dev->id.bustype = BUS_HIL;
371 ptr->dev.id.vendor = PCI_VENDOR_ID_HP; 375 ptr->dev->id.vendor = PCI_VENDOR_ID_HP;
372 ptr->dev.id.product = 0x0001; /* TODO: get from ptr->rsc */ 376 ptr->dev->id.product = 0x0001; /* TODO: get from ptr->rsc */
373 ptr->dev.id.version = 0x0100; /* TODO: get from ptr->rsc */ 377 ptr->dev->id.version = 0x0100; /* TODO: get from ptr->rsc */
374 ptr->dev.dev = &serio->dev; 378 ptr->dev->dev = &serio->dev;
375 379
376 input_register_device(&ptr->dev); 380 input_register_device(ptr->dev);
377 printk(KERN_INFO "input: %s (%s), ID: %d\n", 381 printk(KERN_INFO "input: %s (%s), ID: %d\n",
378 ptr->dev.name, 382 ptr->dev->name,
379 (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad", 383 (btntype == BTN_MOUSE) ? "HIL mouse":"HIL tablet or touchpad",
380 did); 384 did);
381 385
382 return 0; 386 return 0;
383 bail1: 387 bail2:
384 serio_close(serio); 388 serio_close(serio);
389 bail1:
390 input_free_device(ptr->dev);
385 bail0: 391 bail0:
386 kfree(ptr); 392 kfree(ptr);
387 serio_set_drvdata(serio, NULL); 393 serio_set_drvdata(serio, NULL);