psm.c (186218) | psm.c (189870) |
---|---|
1/*- 2 * Copyright (c) 1992, 1993 Erik Forsberg. 3 * Copyright (c) 1996, 1997 Kazutaka YOKOTA. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 45 unchanged lines hidden (view full) --- 54 * HiNote UltraII/Latitude/Armada laptops. 55 * - 30 July 1997. Added APM support. 56 * - 5 March 1997. Defined driver configuration flags (PSM_CONFIG_XXX). 57 * Improved sync check logic. 58 * Vendor specific support routines. 59 */ 60 61#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1992, 1993 Erik Forsberg. 3 * Copyright (c) 1996, 1997 Kazutaka YOKOTA. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 45 unchanged lines hidden (view full) --- 54 * HiNote UltraII/Latitude/Armada laptops. 55 * - 30 July 1997. Added APM support. 56 * - 5 March 1997. Defined driver configuration flags (PSM_CONFIG_XXX). 57 * Improved sync check logic. 58 * Vendor specific support routines. 59 */ 60 61#include <sys/cdefs.h> |
62__FBSDID("$FreeBSD: head/sys/dev/atkbdc/psm.c 186218 2008-12-17 10:42:53Z dumbbell $"); | 62__FBSDID("$FreeBSD: head/sys/dev/atkbdc/psm.c 189870 2009-03-16 08:21:51Z rnoland $"); |
63 64#include "opt_isa.h" 65#include "opt_psm.h" 66 67#include <sys/param.h> 68#include <sys/systm.h> 69#include <sys/kernel.h> 70#include <sys/module.h> 71#include <sys/bus.h> 72#include <sys/conf.h> | 63 64#include "opt_isa.h" 65#include "opt_psm.h" 66 67#include <sys/param.h> 68#include <sys/systm.h> 69#include <sys/kernel.h> 70#include <sys/module.h> 71#include <sys/bus.h> 72#include <sys/conf.h> |
73#include <sys/filio.h> |
|
73#include <sys/poll.h> | 74#include <sys/poll.h> |
75#include <sys/sigio.h> 76#include <sys/signalvar.h> |
|
74#include <sys/syslog.h> 75#include <machine/bus.h> 76#include <sys/rman.h> 77#include <sys/selinfo.h> 78#include <sys/sysctl.h> 79#include <sys/time.h> 80#include <sys/uio.h> 81 --- 212 unchanged lines hidden (view full) --- 294 struct timeval taptimeout; /* tap timeout for touchpads */ 295 int watchdog; /* watchdog timer flag */ 296 struct callout_handle callout; /* watchdog timer call out */ 297 struct callout_handle softcallout; /* buffer timer call out */ 298 struct cdev *dev; 299 struct cdev *bdev; 300 int lasterr; 301 int cmdcount; | 77#include <sys/syslog.h> 78#include <machine/bus.h> 79#include <sys/rman.h> 80#include <sys/selinfo.h> 81#include <sys/sysctl.h> 82#include <sys/time.h> 83#include <sys/uio.h> 84 --- 212 unchanged lines hidden (view full) --- 297 struct timeval taptimeout; /* tap timeout for touchpads */ 298 int watchdog; /* watchdog timer flag */ 299 struct callout_handle callout; /* watchdog timer call out */ 300 struct callout_handle softcallout; /* buffer timer call out */ 301 struct cdev *dev; 302 struct cdev *bdev; 303 int lasterr; 304 int cmdcount; |
305 struct sigio *async; /* Processes waiting for SIGIO */ |
|
302}; 303static devclass_t psm_devclass; 304#define PSM_SOFTC(unit) \ 305 ((struct psm_softc*)devclass_get_softc(psm_devclass, unit)) 306 307/* driver state flags (state) */ 308#define PSM_VALID 0x80 309#define PSM_OPEN 1 /* Device is open */ --- 1175 unchanged lines hidden (view full) --- 1485 return (EBUSY); 1486 1487 device_busy(devclass_get_device(psm_devclass, unit)); 1488 1489 /* Initialize state */ 1490 sc->mode.level = sc->dflt_mode.level; 1491 sc->mode.protocol = sc->dflt_mode.protocol; 1492 sc->watchdog = FALSE; | 306}; 307static devclass_t psm_devclass; 308#define PSM_SOFTC(unit) \ 309 ((struct psm_softc*)devclass_get_softc(psm_devclass, unit)) 310 311/* driver state flags (state) */ 312#define PSM_VALID 0x80 313#define PSM_OPEN 1 /* Device is open */ --- 1175 unchanged lines hidden (view full) --- 1489 return (EBUSY); 1490 1491 device_busy(devclass_get_device(psm_devclass, unit)); 1492 1493 /* Initialize state */ 1494 sc->mode.level = sc->dflt_mode.level; 1495 sc->mode.protocol = sc->dflt_mode.protocol; 1496 sc->watchdog = FALSE; |
1497 sc->async = NULL; |
|
1493 1494 /* flush the event queue */ 1495 sc->queue.count = 0; 1496 sc->queue.head = 0; 1497 sc->queue.tail = 0; 1498 sc->status.flags = 0; 1499 sc->status.button = 0; 1500 sc->status.obutton = 0; --- 123 unchanged lines hidden (view full) --- 1624 log(LOG_ERR, 1625 "psm%d: failed to disable the aux port (psmclose).\n", 1626 unit); 1627 } 1628 1629 /* remove anything left in the output buffer */ 1630 empty_aux_buffer(sc->kbdc, 10); 1631 | 1498 1499 /* flush the event queue */ 1500 sc->queue.count = 0; 1501 sc->queue.head = 0; 1502 sc->queue.tail = 0; 1503 sc->status.flags = 0; 1504 sc->status.button = 0; 1505 sc->status.obutton = 0; --- 123 unchanged lines hidden (view full) --- 1629 log(LOG_ERR, 1630 "psm%d: failed to disable the aux port (psmclose).\n", 1631 unit); 1632 } 1633 1634 /* remove anything left in the output buffer */ 1635 empty_aux_buffer(sc->kbdc, 10); 1636 |
1637 /* clean up and sigio requests */ 1638 if (sc->async != NULL) { 1639 funsetown(&sc->async); 1640 sc->async = NULL; 1641 } 1642 |
|
1632 /* close is almost always successful */ 1633 sc->state &= ~PSM_OPEN; 1634 kbdc_lock(sc->kbdc, FALSE); 1635 device_unbusy(devclass_get_device(psm_devclass, unit)); 1636 return (0); 1637} 1638 1639static int --- 545 unchanged lines hidden (view full) --- 2185 return (error); 2186 sc->hw.hwid &= ~0x00ff; 2187 sc->hw.hwid |= get_aux_id(sc->kbdc); 2188 *(int *)addr = sc->hw.hwid & 0x00ff; 2189 unblock_mouse_data(sc, command_byte); 2190 break; 2191#endif /* MOUSE_GETHWID */ 2192 | 1643 /* close is almost always successful */ 1644 sc->state &= ~PSM_OPEN; 1645 kbdc_lock(sc->kbdc, FALSE); 1646 device_unbusy(devclass_get_device(psm_devclass, unit)); 1647 return (0); 1648} 1649 1650static int --- 545 unchanged lines hidden (view full) --- 2196 return (error); 2197 sc->hw.hwid &= ~0x00ff; 2198 sc->hw.hwid |= get_aux_id(sc->kbdc); 2199 *(int *)addr = sc->hw.hwid & 0x00ff; 2200 unblock_mouse_data(sc, command_byte); 2201 break; 2202#endif /* MOUSE_GETHWID */ 2203 |
2204 case FIONBIO: 2205 case FIOASYNC: 2206 break; 2207 case FIOSETOWN: 2208 error = fsetown(*(int *)addr, &sc->async); 2209 break; 2210 case FIOGETOWN: 2211 *(int *) addr = fgetown(&sc->async); 2212 break; |
|
2193 default: 2194 return (ENOTTY); 2195 } 2196 2197 return (error); 2198} 2199 2200static void --- 1248 unchanged lines hidden (view full) --- 3449 sc->pqueue_start = 0; 3450 } while (sc->pqueue_start != sc->pqueue_end); 3451 3452 if (sc->state & PSM_ASLP) { 3453 sc->state &= ~PSM_ASLP; 3454 wakeup(sc); 3455 } 3456 selwakeuppri(&sc->rsel, PZERO); | 2213 default: 2214 return (ENOTTY); 2215 } 2216 2217 return (error); 2218} 2219 2220static void --- 1248 unchanged lines hidden (view full) --- 3469 sc->pqueue_start = 0; 3470 } while (sc->pqueue_start != sc->pqueue_end); 3471 3472 if (sc->state & PSM_ASLP) { 3473 sc->state &= ~PSM_ASLP; 3474 wakeup(sc); 3475 } 3476 selwakeuppri(&sc->rsel, PZERO); |
3477 if (sc->async != NULL) { 3478 pgsigio(&sc->async, SIGIO, 0); 3479 } |
|
3457 sc->state &= ~PSM_SOFTARMED; 3458 splx(s); 3459} 3460 3461static int 3462psmpoll(struct cdev *dev, int events, struct thread *td) 3463{ 3464 struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev)); --- 1185 unchanged lines hidden --- | 3480 sc->state &= ~PSM_SOFTARMED; 3481 splx(s); 3482} 3483 3484static int 3485psmpoll(struct cdev *dev, int events, struct thread *td) 3486{ 3487 struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev)); --- 1185 unchanged lines hidden --- |