diff --git a/hw/kdrive/i810/i810_cursor.c b/hw/kdrive/i810/i810_cursor.c index 9136ce748..48f1addbb 100644 --- a/hw/kdrive/i810/i810_cursor.c +++ b/hw/kdrive/i810/i810_cursor.c @@ -60,7 +60,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -/* $XFree86$ */ +/* $XFree86: xc/programs/Xserver/hw/kdrive/i810/i810_cursor.c,v 1.1 2001/03/30 02:18:41 keithp Exp $ */ /* i810_cursor.c: KDrive hardware cursor routines for the i810 chipset */ @@ -167,13 +167,19 @@ _i810SetCursorColors(ScreenPtr pScreen) { /* int bg, int fg */ OUTREG8( PIXPIPE_CONFIG_0, tmp ); } +#define InvertBits32(v) { \ + v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \ + v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \ + v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \ +} + static void i810LoadCursor(ScreenPtr pScreen, int x, int y) { SetupCursor(pScreen); int w, h; unsigned short r; - unsigned char *msk, *mskLine, *src, *srcLine; + unsigned int *msk, *mskLine, *src, *srcLine; int i, j; int src_stride, src_width; @@ -181,35 +187,36 @@ static void i810LoadCursor(ScreenPtr pScreen, int x, int y) { CursorPtr pCursor = pCurPriv->pCursor; CursorBitsPtr bits = pCursor->bits; CARD8 tmp; - unsigned char *ram, *ramLine; + unsigned int *ram, *ramLine; pCurPriv->pCursor = pCursor; pCurPriv->xhot = pCursor->bits->xhot; pCurPriv->yhot = pCursor->bits->yhot; - ramLine = (unsigned char *)(i810c->FbBase + i810c->CursorStart); - mskLine = (unsigned char *) bits->mask; - srcLine = (unsigned char *) bits->source; + ramLine = (unsigned int *) (i810c->FbBase + i810c->CursorStart); + mskLine = (unsigned int *) (bits->mask); + srcLine = (unsigned int *) (bits->source); h = bits->height; if (h > I810_CURSOR_HEIGHT) h = I810_CURSOR_HEIGHT; - src_stride = BitmapBytePad(bits->width); /* bytes per line */ - src_width = (bits->width + 7) >> 3; + src_stride = (src_stride +3) >> 2; + src_width = (bits->width + 31) >> 5; for (i = 0; i < I810_CURSOR_HEIGHT; i++) { + msk = mskLine; src = srcLine; ram = ramLine; mskLine += src_stride; srcLine += src_stride; - ramLine += I810_CURSOR_WIDTH / 4; + ramLine += I810_CURSOR_WIDTH / 16; - for (j = 0; j < I810_CURSOR_WIDTH / 8; j++) { + for (j = 0; j < I810_CURSOR_WIDTH / 32; j++) { - unsigned short m, s, b1, b2; + unsigned long m, s, b1, b2; if (i < h && j < src_width) { @@ -217,23 +224,22 @@ static void i810LoadCursor(ScreenPtr pScreen, int x, int y) { s = *src++ & m; m = ~m; /* mask off right side */ - if (j == src_width - 1 && (bits->width & 7)) + if (j == src_width - 1 && (bits->width & 31)) { - m |= 0xff << (bits->width & 7); + m |= 0xffffffff << (bits->width & 31); } } else { - m = 0xff; - s = 0x00; + m = 0xffffffff; + s = 0x00000000; } - /* The i810 stores the cursor in an interleaved bitmap format, - in reverse byte order */ - /* Not tested with cursors bigger than 16x16 !!! */ + InvertBits32(s); + InvertBits32(m); - ram[8+(j ^ 1)] = s; /* b2 */ - ram[0+(j ^ 1)] = m; /* b1 */ + ram[2+j]=s; + ram[0+j]=m; } } /* Set new color */ diff --git a/hw/kdrive/linux/mouse.c b/hw/kdrive/linux/mouse.c index 2e46d3db1..986500594 100644 --- a/hw/kdrive/linux/mouse.c +++ b/hw/kdrive/linux/mouse.c @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/hw/kdrive/linux/mouse.c,v 1.2 2001/11/08 09:35:08 keithp Exp $ + * $XFree86: xc/programs/Xserver/hw/kdrive/linux/mouse.c,v 1.3 2001/11/22 23:38:21 keithp Exp $ * * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. * @@ -905,6 +905,9 @@ MouseInit (void) int n = 0; char *prot; + if (!MouseInputType) + MouseInputType = KdAllocInputType (); + for (mi = kdMouseInfo; mi; mi = next) { next = mi->next; diff --git a/hw/kdrive/linux/ts.c b/hw/kdrive/linux/ts.c index 92766ac67..581ec7243 100644 --- a/hw/kdrive/linux/ts.c +++ b/hw/kdrive/linux/ts.c @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/hw/kdrive/linux/ts.c,v 1.4 2001/06/29 14:00:41 keithp Exp $ + * $XFree86: xc/programs/Xserver/hw/kdrive/linux/ts.c,v 1.5 2001/07/11 02:58:19 keithp Exp $ * * Derived from ps2.c by Jim Gettys * @@ -33,15 +33,57 @@ #include "kdrive.h" #include "Xpoll.h" #include +#if 1 #include /* touch screen events */ +#else +/* inline for non-arm debug builds */ +typedef struct { + unsigned short pressure; + unsigned short x; + unsigned short y; + unsigned short pad; /* TODO TODO word boundary pad */ +} TS_EVENT; +#endif static long lastx = 0, lasty = 0; int TsScreen; extern int TsFbdev; +int +TsReadBytes (int fd, char *buf, int len, int min) +{ + int n, tot; + fd_set set; + struct timeval tv; + + tot = 0; + while (len) + { + n = read (fd, buf, len); + if (n > 0) + { + tot += n; + buf += n; + len -= n; + } + if (tot % min == 0) + break; + FD_ZERO (&set); + FD_SET (fd, &set); + tv.tv_sec = 0; + tv.tv_usec = 100 * 1000; + n = select (fd + 1, &set, 0, 0, &tv); + if (n <= 0) + break; + } + return tot; +} + void TsRead (int tsPort, void *closure) { + KdMouseInfo *mi = closure; + int fd = (int) mi->driver; TS_EVENT event; long buf[3]; int n; @@ -50,8 +92,7 @@ TsRead (int tsPort, void *closure) unsigned long flags; unsigned long buttons; - n = Ps2ReadBytes (tsPort, (char *) &event, - sizeof (event), sizeof (event)); + n = TsReadBytes (tsPort, (char *) &event, sizeof (event), sizeof (event)); if (n == sizeof (event)) { if (event.pressure) @@ -85,7 +126,7 @@ TsRead (int tsPort, void *closure) lastx = 0; lasty = 0; } - KdEnqueueMouseEvent (flags, x, y); + KdEnqueueMouseEvent (mi, flags, x, y); } } @@ -102,22 +143,40 @@ int TsInputType; int TsInit (void) { - int i; - int TsPort; + int i; + int fd; + KdMouseInfo *mi, *next; + int n = 0; if (!TsInputType) TsInputType = KdAllocInputType (); - for (i = 0; i < NUM_TS_NAMES; i++) + + for (mi = kdMouseInfo; mi; mi = next) { - TsPort = open (TsNames[i], 0); - if (TsPort >= 0) + next = mi->next; + if (!mi->name) { - if (KdRegisterFd (TsInputType, TsPort, TsRead, 0)) - return 1; + for (i = 0; i < NUM_TS_NAMES; i++) + { + fd = open (TsNames[i], 0); + if (fd >= 0) + { + mi->name = KdSaveString (TsNames[i]); + break; + } + } } + else + fd = open (mi->name, 0); + if (fd >= 0) + { + mi->driver = (void *) fd; + if (KdRegisterFd (TsInputType, fd, TsRead, (void *) mi)) + n++; + } + else + KdMouseInfoDispose (mi); } - perror("Touch screen not found.\n"); - exit (1); } void