]> git.pld-linux.org Git - packages/X11.git/blob - xorg-x11-6.8.1-dualhead.patch
- orphaned, outdated
[packages/X11.git] / xorg-x11-6.8.1-dualhead.patch
1
2 # Dual-head dual-user patch for xorg-x11 (or multi-head multi-user, if you
3 # prefer that). Based on the work of Miguel Freitas and others.
4 # Look at http://cambuca.ldhs.cetuc.puc-rio.br/multiuser/ for detailed
5 # information on how to use this.
6 #
7 # Modified for xorg-x11-6.8.1 by Jan "Yenya" Kasprzak <kas@fi.muni.cz>
8 #
9 # KNOWN BUGS:
10 # - Keyboard LED support is still buggy and unfinished.
11 # - on my setup it destroys font on the text console or something like that.
12 #   I have no time to investigate this and I don't use text console on this
13 #   box (except for booting).
14 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Config.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
15 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Config.c   2004-08-16 22:17:51.000000000 +0200
16 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Config.c   2004-11-19 21:49:47.000000000 +0100
17 @@ -1195,6 +1195,16 @@
18              return FALSE;
19       }
20  #endif
21 +  } else if (xf86NameCmp(s, "usbev") == 0) {
22 +     xf86Info.kbdProc    = xf86KbdProc;
23 +     xf86Info.kbdEvents  = xf86USBKbdEvents;
24 +     xf86Msg(X_CONFIG, "Keyboard: Protocol: usbev\n");
25 +     s = xf86SetStrOption(inputp->commonOptions, "Device", "/dev/input/event0");
26 +     xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL);
27 +     if (xf86Info.kbdFd == -1) {
28 +       xf86ConfigError("Keyboard device: cannot open \"%s\"", s);
29 +       return FALSE;
30 +     }
31    } else {
32      xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s);
33      xfree(s);
34 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c
35 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c  2004-07-06 16:37:47.000000000 +0200
36 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Globals.c  2004-11-19 21:49:47.000000000 +0100
37 @@ -245,3 +245,6 @@
38   * only to be used when using dlopen() modules for debugging purposes.
39   */
40  #endif
41 +
42 +Bool xf86NoVTSwitches = FALSE;
43 +Bool xf86NoPCIAccessDisable = FALSE;
44 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Init.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
45 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Init.c     2004-11-18 22:19:31.000000000 +0100
46 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Init.c     2004-11-19 21:49:47.000000000 +0100
47 @@ -1429,6 +1429,28 @@
48      xf86ProbeOnly = TRUE;
49      return 1;
50    }
51 +  if (!strcmp(argv[i],"-delay"))
52 +  {
53 +    int delay;
54 +
55 +    if (!argv[i + 1] || (delay = atoi(argv[i + 1])) <= 0) {
56 +      sleep(10);
57 +      return 1;
58 +    } else {
59 +      sleep((unsigned) delay);
60 +      return 2;
61 +    }
62 +  }
63 +  if (!strcmp(argv[i],"-novtswitches"))
64 +  {
65 +    xf86NoVTSwitches = TRUE;
66 +    return 1;
67 +  }
68 +  if (!strcmp(argv[i],"-nopciaccessdisable"))
69 +  {
70 +    xf86NoPCIAccessDisable = TRUE;
71 +    return 1;
72 +  }
73    if (!strcmp(argv[i],"-flipPixels"))
74    {
75      xf86FlipPixels = TRUE;
76 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c
77 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c   2004-11-18 22:19:29.000000000 +0100
78 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c   2004-11-19 21:49:47.000000000 +0100
79 @@ -606,6 +606,9 @@
80  static void
81  pciIoAccessDisable(void* arg)
82  {
83 +    if (xf86NoPCIAccessDisable)
84 +       return;
85 +
86  #ifdef DEBUG
87      ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
88  #endif
89 @@ -628,6 +631,9 @@
90  static void
91  pciIo_MemAccessDisable(void* arg)
92  {
93 +    if (xf86NoPCIAccessDisable)
94 +       return;
95 +
96  #ifdef DEBUG
97      ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
98  #endif
99 @@ -650,6 +656,9 @@
100  static void
101  pciMemAccessDisable(void* arg)
102  {
103 +    if (xf86NoPCIAccessDisable)
104 +       return;
105 +
106  #ifdef DEBUG
107      ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
108  #endif
109 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h
110 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h     2004-01-29 09:08:26.000000000 +0100
111 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h     2004-11-19 21:49:47.000000000 +0100
112 @@ -115,6 +115,9 @@
113  
114  extern RootWinPropPtr *xf86RegisteredPropertiesTable;
115  
116 +extern Bool xf86NoVTSwitches;
117 +extern Bool xf86NoPCIAccessDisable;
118 +
119  #ifndef DEFAULT_VERBOSE
120  #define DEFAULT_VERBOSE                0
121  #endif
122 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h
123 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h  2004-01-29 09:08:26.000000000 +0100
124 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h  2004-11-19 21:49:47.000000000 +0100
125 @@ -82,6 +82,7 @@
126      int                        bell_pitch;
127      int                        bell_duration;
128      Bool               autoRepeat;
129 +    int                        ledsave;
130      unsigned long      leds;
131      unsigned long      xleds;
132      char *             vtinit;
133 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c
134 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c   2004-04-23 21:54:08.000000000 +0200
135 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c   2004-11-19 21:49:47.000000000 +0100
136 @@ -121,22 +121,35 @@
137                 FatalError(
138                     "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
139                     strerror(errno));
140 -           if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
141 -               (xf86Info.vtno == -1)) {
142 -               FatalError("xf86OpenConsole: Cannot find a free VT\n");
143 +
144 +           if (xf86NoVTSwitches) {
145 +               if (ioctl(fd, VT_GETSTATE, &vts) == 0)
146 +               {
147 +                   xf86Info.vtno = vts.v_active;
148 +               } else {
149 +                   FatalError("xf86OpenConsole: Cannot find the current VT\n");
150 +               }
151 +           } else {
152 +               if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
153 +                   (xf86Info.vtno == -1)) {
154 +                   FatalError("xf86OpenConsole: Cannot find a free VT\n");
155 +               }
156             }
157 +
158             close(fd);
159         }
160  
161  #ifdef USE_DEV_FB
162 -       fb_dev_name=getenv("FRAMEBUFFER");
163 -       if (!fb_dev_name)
164 -           fb_dev_name="/dev/fb0current";
165 -       if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
166 -           FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
167 -       fb_dev_name, strerror(errno));
168 -       if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var))
169 -           FatalError("xf86OpenConsole: Unable to get screen info\n");
170 +       if (!xf86NoVTSwitches) {
171 +           fb_dev_name=getenv("FRAMEBUFFER");
172 +           if (!fb_dev_name)
173 +               fb_dev_name="/dev/fb0current";
174 +           if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
175 +               FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
176 +           fb_dev_name, strerror(errno));
177 +           if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var))
178 +               FatalError("xf86OpenConsole: Unable to get screen info\n");
179 +       }
180  #endif
181         xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
182  
183 @@ -167,8 +180,12 @@
184                   "xf86OpenConsole: Could not save ownership of VT\n");
185         }
186  
187 -       /* change ownership of the vt */
188 -       chown(vtname, getuid(), getgid());
189 +       /* humm, not a good idea if we don't really use this vt, chowning it would
190 +          probably mess with the first XFree instance. Right? i don't know! */
191 +       if (!xf86NoVTSwitches) {
192 +           /* change ownership of the vt */
193 +           chown(vtname, getuid(), getgid());
194 +       }
195  
196         /*
197          * the current VT device we're running on is not "console", we want
198 @@ -213,37 +230,42 @@
199         {
200             xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
201         }
202 -       SYSCALL(result = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
203 -       if (result < 0)
204 -       {
205 -           FatalError("xf86OpenConsole: VT_GETMODE failed\n");
206 -       }
207  
208 -       signal(SIGUSR1, xf86VTRequest);
209 +       if (xf86NoVTSwitches) {
210 +           close(xf86Info.consoleFd);
211 +       } else {
212 +           SYSCALL(result = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
213 +           if (result < 0)
214 +           {
215 +               FatalError("xf86OpenConsole: VT_GETMODE failed\n");
216 +           }
217  
218 -       VT.mode = VT_PROCESS;
219 -       VT.relsig = SIGUSR1;
220 -       VT.acqsig = SIGUSR1;
221 -       if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
222 -       {
223 -           FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
224 -       }
225 -       if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
226 -       {
227 -           FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
228 -       }
229 +           signal(SIGUSR1, xf86VTRequest);
230 +
231 +           VT.mode = VT_PROCESS;
232 +           VT.relsig = SIGUSR1;
233 +           VT.acqsig = SIGUSR1;
234 +           if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
235 +           {
236 +               FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
237 +           }
238 +           if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
239 +           {
240 +               FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
241 +           }
242  
243 -       /* we really should have a InitOSInputDevices() function instead
244 -        * of Init?$#*&Device(). So I just place it here */
245 -       
246 +           /* we really should have a InitOSInputDevices() function instead
247 +            * of Init?$#*&Device(). So I just place it here */
248 +           
249  #ifdef USE_DEV_FB
250 -       /* copy info to new console */
251 -       var.yoffset=0;
252 -       var.xoffset=0;
253 -       if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
254 -           FatalError("Unable to set screen info\n");
255 -       close(fbfd);
256 +           /* copy info to new console */
257 +           var.yoffset=0;
258 +           var.xoffset=0;
259 +           if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
260 +               FatalError("Unable to set screen info\n");
261 +           close(fbfd);
262  #endif
263 +       }
264      }
265      else
266      {
267 @@ -251,16 +273,18 @@
268         /*
269          * now get the VT
270          */
271 -       SYSCALL(result = ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
272 -       if (result != 0)
273 -       {
274 -           xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
275 -       }
276 -       SYSCALL(result =
277 -               ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
278 -       if (result != 0)
279 -       {
280 -           xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
281 +       if (!xf86NoVTSwitches) {
282 +           SYSCALL(result = ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
283 +           if (result != 0)
284 +           {
285 +               xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
286 +           }
287 +           SYSCALL(result =
288 +                   ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
289 +           if (result != 0)
290 +           {
291 +               xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
292 +           }
293         }
294      }
295      return;
296 @@ -275,22 +299,23 @@
297      ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
298      ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
299  #endif
300 -    ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode ... */
301 -    if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
302 -    {
303 -       VT.mode = VT_AUTO;
304 -       ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
305 -    }
306 -    /*
307 -     * Perform a switch back to the active VT when we were started
308 -     */
309 -    if (activeVT >= 0)
310 -    {
311 -       ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT);
312 -       activeVT = -1;
313 +    if (!xf86NoVTSwitches) {
314 +        ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode ... */
315 +        if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
316 +        {
317 +           VT.mode = VT_AUTO;
318 +           ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
319 +        }
320 +        /*
321 +         * Perform a switch back to the active VT when we were started
322 +         */
323 +        if (activeVT >= 0)
324 +        {
325 +           ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT);
326 +           activeVT = -1;
327 +        }
328 +        close(xf86Info.consoleFd);                /* make the vt-manager happy */
329      }
330 -    close(xf86Info.consoleFd);                /* make the vt-manager happy */
331 -
332      restoreVtPerms();          /* restore the permissions */
333  
334      return;
335 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c
336 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c     2004-04-23 21:54:08.000000000 +0200
337 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c     2004-11-19 21:49:47.000000000 +0100
338 @@ -33,12 +33,19 @@
339  #include "xf86.h"
340  #include "xf86Priv.h"
341  #include "xf86_OSlib.h"
342 +#include <linux/input.h>
343 +#include <linux/kd.h>
344  
345  #define KBC_TIMEOUT 250        /* Timeout in ms for sending to keyboard controller */
346  
347  void
348  xf86SoundKbdBell(int loudness, int pitch, int duration)
349  {
350 +       /* i guess it should be safe to beep even on a diferent keyboard (?) */
351 +       /* the beep will be on the system speaker anyway... */
352 +       if (xf86Info.kbdEvents == xf86USBKbdEvents)
353 +               return;
354 +
355         if (loudness && pitch)
356         {
357                 ioctl(xf86Info.consoleFd, KDMKTONE,
358 @@ -51,7 +58,35 @@
359  void
360  xf86SetKbdLeds(int leds)
361  {
362 -       ioctl(xf86Info.consoleFd, KDSETLED, leds);
363 +       struct s_output_event {
364 +              struct timeval time;
365 +              unsigned short type;
366 +              unsigned short code;
367 +              unsigned int value;
368 +       } output_event;
369 +
370 +       fprintf(stderr, "xf86SetKbdLeds(0x%x) called\n", leds);
371 +       if (xf86Info.kbdEvents != xf86USBKbdEvents) {
372 +               ioctl(xf86Info.consoleFd, KDSETLED, leds);
373 +               return;
374 +       }
375 +
376 +       output_event.type = EV_LED;
377 +       output_event.code = LED_NUML;
378 +       output_event.value = (leds&(LED_NUM)) ? 1 : 0;
379 +       write( xf86Info.kbdFd, (char *)&output_event, sizeof(output_event));
380 +
381 +       output_event.type = EV_LED;
382 +       output_event.code = LED_CAPSL;
383 +       output_event.value = (leds&(LED_CAP)) ? 1 : 0;
384 +       write( xf86Info.kbdFd, (char *)&output_event, sizeof(output_event));
385 +
386 +       output_event.type = EV_LED;
387 +       output_event.code = LED_SCROLLL;
388 +       output_event.value = (leds&(LED_SCR)) ? 1 : 0;
389 +       write( xf86Info.kbdFd, (char *)&output_event, sizeof(output_event));
390 +
391 +       xf86Info.ledsave = leds;
392  }
393  
394  int
395 @@ -59,7 +94,13 @@
396  {
397         int leds = 0;
398  
399 -       ioctl(xf86Info.consoleFd, KDGETLED, &leds);
400 +       if (xf86Info.kbdEvents == xf86USBKbdEvents) {
401 +               leds = xf86Info.ledsave;
402 +       } else {
403 +               ioctl(xf86Info.consoleFd, KDGETLED, &leds);
404 +       }
405 +
406 +       fprintf(stderr, "xf86GetKbdLeds called, returing 0x%x\n", leds);
407         return(leds);
408  }
409  
410 @@ -173,6 +214,10 @@
411    if (xf86Info.kbdDelay >= 0)
412      delay = xf86Info.kbdDelay;
413  
414 +  /* FIXME: just returning so we don't mess with any other keyboards... */
415 +  if (xf86Info.kbdEvents == xf86USBKbdEvents)
416 +    return;
417 +
418    if(KDKBDREP_ioctl_ok(rate, delay))   /* m68k? */
419      return;
420  
421 @@ -223,14 +268,24 @@
422  void
423  xf86KbdInit()
424  {
425 -       ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
426 -       tcgetattr (xf86Info.consoleFd, &kbdtty);
427 +       if (xf86Info.kbdEvents == xf86USBKbdEvents) {
428 +               int data;
429 +               data=1;
430 +               if (ioctl(xf86Info.kbdFd, EVIOCGRAB, &data) == 0)
431 +                       printf("exclusive access granted");
432 +       } else {
433 +               ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
434 +               tcgetattr (xf86Info.consoleFd, &kbdtty);
435 +       }
436  }
437  
438  int
439  xf86KbdOn()
440  {
441         struct termios nTty;
442
443 +       if (xf86Info.kbdEvents == xf86USBKbdEvents)
444 +               return(xf86Info.kbdFd);
445  
446  #ifdef __powerpc__
447         if (xf86Info.kbdCustomKeycodes)
448 @@ -255,6 +310,9 @@
449  int
450  xf86KbdOff()
451  {
452 +       if (xf86Info.kbdEvents == xf86USBKbdEvents)
453 +               return(xf86Info.kbdFd);
454 +
455         ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
456         tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
457         return(xf86Info.consoleFd);
458 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c
459 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c    2004-04-23 21:54:08.000000000 +0200
460 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c    2004-11-19 21:49:47.000000000 +0100
461 @@ -22,11 +22,13 @@
462  #include "xf86OSKbd.h"
463  #include "atKeynames.h"
464  #include "lnx_kbd.h"
465 +#include <linux/input.h>
466  
467  #define KBC_TIMEOUT 250        /* Timeout in ms for sending to keyboard controller */
468  
469  static KbdProtocolRec protocols[] = {
470     {"standard", PROT_STD },
471 +   {"usbev", PROT_USB },
472     { NULL, PROT_UNKNOWN_KBD }
473  };
474  
475 @@ -76,6 +78,45 @@
476      ioctl(pInfo->fd, KDSETLED, real_leds);
477  }
478  
479 +static void
480 +SetUSBKbdLeds(InputInfoPtr pInfo, int leds)
481 +{
482 +    struct s_output_event {
483 +           struct timeval time;
484 +           unsigned short type;
485 +           unsigned short code;
486 +           unsigned int value;
487 +    } output_event;
488 +    int real_leds = 0;
489 +    fprintf(stderr, "SetUSBKbdLeds called with leds=0x%x\n", leds);
490 +    fprintf(stderr, "CAP=0x%x, NUM=0x%x, SCR=0x%x\n", LED_CAP, LED_NUM, LED_SCR);
491 +#ifdef LED_CAP
492 +    if (leds & XLED1)  real_leds |= LED_CAP;
493 +    if (leds & XLED2)  real_leds |= LED_NUM;
494 +    if (leds & XLED3)  real_leds |= LED_SCR;
495 +#ifdef LED_COMP
496 +    if (leds & XLED4)  real_leds |= LED_COMP;
497 +#else
498 +    if (leds & XLED4)  real_leds |= LED_SCR;
499 +#endif
500 +#endif
501 +    output_event.type = EV_LED;
502 +    output_event.code = LED_NUML;
503 +    output_event.value = (leds&(LED_NUM)) ? 1 : 0;
504 +    write(pInfo->fd, (char *)&output_event, sizeof(output_event));
505 +
506 +    output_event.type = EV_LED;
507 +    output_event.code = LED_CAPSL;
508 +    output_event.value = (leds&(LED_CAP)) ? 1 : 0;
509 +    write(pInfo->fd, (char *)&output_event, sizeof(output_event));
510 +
511 +    output_event.type = EV_LED;
512 +    output_event.code = LED_SCROLLL;
513 +    output_event.value = (leds&(LED_SCR)) ? 1 : 0;
514 +    write(pInfo->fd, (char *)&output_event, sizeof(output_event));
515 +
516 +    xf86Info.ledsave = leds;
517 +}
518  static int
519  GetKbdLeds(InputInfoPtr pInfo)
520  {
521 @@ -87,6 +128,7 @@
522      if (real_leds & LED_NUM) leds |= XLED2;
523      if (real_leds & LED_SCR) leds |= XLED3;
524  
525 +    fprintf(stderr, "GetKbdLeds called, returing 0x%x\n", leds);
526      return(leds);
527  }
528  
529 @@ -442,6 +484,62 @@
530         }
531  }
532  
533 +static unsigned short x86_keycodes[256] =
534 +       { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
535 +        16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
536 +        32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
537 +        48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
538 +        64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
539 +        80, 81, 82, 83, 43, 85, 86, 87, 88,115,119,120,121,375,123, 90,
540 +       284,285,309,311,312, 91,327,328,329,331,333,335,336,337,338,339,
541 +       367,294,293,286,350, 92,334,512,116,377,109,111,373,347,348,349,
542 +       360, 93, 94, 95, 98,376,100,101,357,316,354,304,289,102,351,355,
543 +       103,104,105,275,281,272,306,106,274,107,288,364,358,363,362,361,
544 +       291,108,381,290,287,292,279,305,280, 99,112,257,258,113,270,114,
545 +       118,117,125,374,379,259,260,261,262,263,264,265,266,267,268,269,
546 +       271,273,276,277,278,282,283,295,296,297,299,300,301,302,303,307,
547 +       308,310,313,314,315,317,318,319,320,321,322,323,324,325,326,330,
548 +       332,340,341,342,343,344,345,346,356,359,365,368,369,370,371,372 };
549 +
550 +static void handle_scancode(InputInfoPtr pInfo, int code, int down)
551 +{
552 +    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
553 +    pKbd->PostEvent(pInfo, code & 0x7f, down);
554 +}
555 +       
556 +       
557 +static void
558 +usbReadInput(InputInfoPtr pInfo)
559 +{
560 +    struct input_event {
561 +           struct timeval time;
562 +           unsigned short type;
563 +           unsigned short code;
564 +           unsigned int value;
565 +    } ev;
566 +
567 +    int nBytes;
568 +    if ((nBytes = read( pInfo->fd, (char *)&ev, sizeof(ev))) > 0) {
569 +       if (ev.type == EV_KEY) {
570 +          unsigned int keycode = ev.code;
571 +         
572 +         if (keycode > 255 || !x86_keycodes[keycode])
573 +               return;
574 +
575 +         if (keycode == KEY_PAUSE) {
576 +               handle_scancode(pInfo, 0xe1, 1);
577 +               handle_scancode(pInfo, 0x1d, ev.value);
578 +               handle_scancode(pInfo, 0x45, ev.value);
579 +               return;
580 +         }
581 +         if (x86_keycodes[keycode] & 0x100)
582 +                 handle_scancode(pInfo, 0xe0, 1);
583 +
584 +         handle_scancode(pInfo, x86_keycodes[keycode] & 0x7f, ev.value);
585 +       }
586 +    }
587 +}
588 +
589  static Bool
590  OpenKeyboard(InputInfoPtr pInfo)
591  {
592 @@ -449,6 +547,7 @@
593      int i;
594      KbdProtocolId prot = PROT_UNKNOWN_KBD;
595      char *s;
596 +    int flag = O_RDONLY;
597  
598      s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
599      for (i = 0; protocols[i].name; i++) {
600 @@ -461,6 +560,12 @@
601      switch (prot) {
602          case PROT_STD:
603             pInfo->read_input = stdReadInput;
604 +           pKbd->SetLeds = SetKbdLeds;
605 +           break;
606 +       case PROT_USB:
607 +           pInfo->read_input = usbReadInput;
608 +           pKbd->SetLeds = SetUSBKbdLeds;
609 +          flag = O_RDWR;
610             break;
611          default:
612             xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
613 @@ -476,7 +581,7 @@
614         pInfo->fd = xf86Info.consoleFd;
615         pKbd->isConsole = TRUE;
616      } else {
617 -       pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
618 +       pInfo->fd = open(s, flag | O_NONBLOCK | O_EXCL);
619         if (pInfo->fd == -1) {
620             xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
621             xfree(s);
622 @@ -501,7 +606,6 @@
623      pKbd->KbdOn         = KbdOn;
624      pKbd->KbdOff        = KbdOff;
625      pKbd->Bell          = SoundBell;
626 -    pKbd->SetLeds       = SetKbdLeds;
627      pKbd->GetLeds       = GetKbdLeds;
628      pKbd->SetKbdRepeat  = SetKbdRepeat;
629      pKbd->KbdGetMapping = KbdGetMapping;
630 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c
631 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c 2004-04-23 21:54:12.000000000 +0200
632 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c 2004-11-19 21:49:47.000000000 +0100
633 @@ -25,10 +25,53 @@
634   */
635  /* $XConsortium: std_kbdEv.c /main/4 1996/03/11 10:47:33 kaleb $ */
636  
637 +/* 2001/01/14 Miguel Freitas <miguel@cetuc.puc-rio.br>
638 + *
639 + * USB Keyboard to PC-AT Keyboard HACK
640 + *
641 + * Included routines from Linux Kernel to handle usb keyboard events.
642 + * I don't know if there are any license issues here. Any code written
643 + * by me in this file is under the terms of the GNU General Public
644 + * License as described below.
645 + *
646 +*/
647 +
648 +/*
649 + * $Id$
650 + *
651 + *  Copyright (c) 1999-2000 Vojtech Pavlik
652 + *
653 + *  Input driver to keyboard driver binding.
654 + *
655 + *  Sponsored by SuSE
656 + */
657 +
658 +/*
659 + * This program is free software; you can redistribute it and/or modify
660 + * it under the terms of the GNU General Public License as published by
661 + * the Free Software Foundation; either version 2 of the License, or
662 + * (at your option) any later version.
663 + *
664 + * This program is distributed in the hope that it will be useful,
665 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
666 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
667 + * GNU General Public License for more details.
668 + *
669 + * You should have received a copy of the GNU General Public License
670 + * along with this program; if not, write to the Free Software
671 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
672 + *
673 + * Should you need to contact me, the author, you can do so either by
674 + * e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
675 + * Vojtech Pavlik, Ucitelska 1576, Prague 8, 182 00 Czech Republic
676 + */
677 +
678 +
679  #include "X.h"
680  #include "xf86.h"
681  #include "xf86Priv.h"
682  #include "xf86_OSlib.h"
683 +#include <linux/input.h>
684  
685  void
686  xf86KbdEvents()
687 @@ -44,3 +87,68 @@
688         }
689  }
690  
691 +static unsigned short x86_keycodes[256] =
692 +       { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
693 +        16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
694 +        32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
695 +        48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
696 +        64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
697 +        80, 81, 82, 83, 43, 85, 86, 87, 88,115,119,120,121,375,123, 90,
698 +       284,285,309,298,312, 91,327,328,329,331,333,335,336,337,338,339,
699 +       367,294,293,286,350, 92,334,512,116,377,109,111,373,347,348,349,
700 +       360, 93, 94, 95, 98,376,100,101,357,316,354,304,289,102,351,355,
701 +       103,104,105,275,281,272,306,106,274,107,288,364,358,363,362,361,
702 +       291,108,381,290,287,292,279,305,280, 99,112,257,258,113,270,114,
703 +       118,117,125,374,379,259,260,261,262,263,264,265,266,267,268,269,
704 +       271,273,276,277,278,282,283,295,296,297,299,300,301,302,303,307,
705 +       308,310,313,314,315,317,318,319,320,321,322,323,324,325,326,330,
706 +       332,340,341,342,343,344,345,346,356,359,365,368,369,370,371,372 };
707 +
708 +static void handle_scancode(unsigned char scancode, int down)
709 +{
710 +        char up_flag = down ? 0 : 0200;
711 +
712 +        xf86PostKbdEvent(scancode | up_flag);
713 +}
714 +
715 +static int emulate_raw(unsigned int keycode, int down)
716 +{
717 +       if (keycode > 255 || !x86_keycodes[keycode])
718 +               return -1; 
719 +
720 +       if (keycode == KEY_PAUSE) {
721 +               handle_scancode(0xe1, 1);
722 +               handle_scancode(0x1d, down);
723 +               handle_scancode(0x45, down);
724 +               return 0;
725 +       } 
726 +
727 +       if (x86_keycodes[keycode] & 0x100)
728 +               handle_scancode(0xe0, 1);
729 +
730 +       handle_scancode(x86_keycodes[keycode] & 0x7f, down);
731 +
732 +       if (keycode == KEY_SYSRQ) {
733 +               handle_scancode(0xe0, 1);
734 +               handle_scancode(0x37, down);
735 +       }
736 +
737 +       return 0;
738 +}
739 +
740 +void
741 +xf86USBKbdEvents()
742 +{
743 +       struct input_event {
744 +              struct timeval time;
745 +              unsigned short type;
746 +              unsigned short code;
747 +              unsigned int value;
748 +       } ev;
749 +
750 +       int nBytes;
751 +
752 +       while ((nBytes = read(xf86Info.kbdFd, (char *)&ev, sizeof(ev))) > 0)
753 +           if (ev.type == EV_KEY)
754 +               emulate_raw(ev.code, ev.value);
755 +}
756 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c
757 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c  2004-04-23 21:54:12.000000000 +0200
758 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c  2004-11-19 21:49:47.000000000 +0100
759 @@ -41,6 +41,9 @@
760  void
761  xf86VTRequest(int sig)
762  {
763 +       if (xf86NoVTSwitches)
764 +               return;
765 +
766         signal(sig, (void(*)(int))xf86VTRequest);
767         xf86Info.vtRequestsPending = TRUE;
768         return;
769 @@ -49,12 +52,15 @@
770  Bool
771  xf86VTSwitchPending()
772  {
773 -    return(xf86Info.vtRequestsPending ? TRUE : FALSE);
774 +       return(!xf86NoVTSwitches && xf86Info.vtRequestsPending ? TRUE : FALSE);
775  }
776  
777  Bool
778  xf86VTSwitchAway()
779  {
780 +       if (xf86NoVTSwitches)
781 +               return FALSE;
782 +
783         xf86Info.vtRequestsPending = FALSE;
784         if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
785         {
786 @@ -69,6 +75,9 @@
787  Bool
788  xf86VTSwitchTo()
789  {
790 +       if (xf86NoVTSwitches)
791 +               return TRUE;
792 +
793         xf86Info.vtRequestsPending = FALSE;
794         if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
795         {
796 diff -uNr xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h
797 --- xorg-x11-6.8.1-rhbuild/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h      2004-04-23 21:54:07.000000000 +0200
798 +++ xorg-x11-6.8.1/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h      2004-11-19 21:49:47.000000000 +0100
799 @@ -229,6 +229,7 @@
800  extern int xf86KbdOn(void);
801  extern int xf86KbdOff(void);
802  extern void xf86KbdEvents(void);
803 +extern void xf86USBKbdEvents(void);
804  #ifdef XQUEUE
805  extern int  xf86XqueKbdProc(DeviceIntPtr, int);
806  extern void xf86XqueEvents(void);
This page took 0.141369 seconds and 3 git commands to generate.