1
commit 4a0163c1e18b1c752bfaf086bf806f0fc7be5c41
2
Author: aurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
3
Date: Tue Apr 8 06:01:02 2008 +0000
10
git-svn-id: svn+ssh://svn.savannah.nongnu.org/qemu/trunk@4173 c046a42c-6fe2-441c-8c8c-71466251a162
12
Index: qemu-0.9.1/Makefile
13
===================================================================
14
--- qemu-0.9.1.orig/Makefile 2008-04-14 11:26:14.000000000 +0200
15
+++ qemu-0.9.1/Makefile 2008-04-14 11:26:14.000000000 +0200
17
OBJS+=usb.o usb-hub.o usb-linux.o usb-hid.o usb-msd.o usb-wacom.o usb-serial.o
28
Index: qemu-0.9.1/Makefile.target
29
===================================================================
30
--- qemu-0.9.1.orig/Makefile.target 2008-04-14 11:26:14.000000000 +0200
31
+++ qemu-0.9.1/Makefile.target 2008-04-14 11:26:14.000000000 +0200
35
$(QEMU_SYSTEM): $(VL_OBJS) ../libqemu_common.a libqemu.a
36
- $(CC) $(VL_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(CURSES_LIBS) $(COCOA_LIBS) $(VL_LIBS)
37
+ $(CC) $(VL_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(CURSES_LIBS) $(COCOA_LIBS) $(VL_LIBS) $(BRLAPI_LIBS)
40
$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
41
Index: qemu-0.9.1/configure
42
===================================================================
43
--- qemu-0.9.1.orig/configure 2008-04-14 11:26:14.000000000 +0200
44
+++ qemu-0.9.1/configure 2008-04-14 11:26:14.000000000 +0200
47
--disable-kqemu) kqemu="no"
49
+ --disable-brlapi) brlapi="no"
51
--enable-profiler) profiler="yes"
53
--enable-cocoa) cocoa="yes" ; coreaudio="yes" ; sdl="no"
55
echo " --enable-alsa enable ALSA audio driver"
56
echo " --enable-fmod enable FMOD audio driver"
57
echo " --enable-dsound enable DirectSound audio driver"
58
+echo " --disable-brlapi disable BrlAPI"
59
echo " --disable-vnc-tls disable TLS encryption for VNC server"
60
echo " --enable-system enable all system emulation targets"
61
echo " --disable-system disable all system emulation targets"
65
##########################################
68
+if test -z "$brlapi" ; then
72
+int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
74
+ if $cc -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi 2> /tmp/qemu-$$-brlapi.log ; then
76
+ fi # brlapi compile test
79
+##########################################
82
if test "$curses" = "yes" ; then
84
echo "Target Sparc Arch $sparc_cpu"
86
echo "kqemu support $kqemu"
87
+echo "brlapi support $brlapi"
88
echo "Documentation $build_docs"
89
[ ! -z "$uname_release" ] && \
90
echo "uname -r $uname_release"
91
@@ -1006,6 +1024,11 @@
92
echo "CONFIG_CURSES=yes" >> $config_mak
93
echo "CURSES_LIBS=-lcurses" >> $config_mak
95
+if test "$brlapi" = "yes" ; then
96
+ echo "CONFIG_BRLAPI=yes" >> $config_mak
97
+ echo "#define CONFIG_BRLAPI 1" >> $config_h
98
+ echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
102
if [ "$bsd" = "yes" ] ; then
103
Index: qemu-0.9.1/hw/baum.c
104
===================================================================
105
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
106
+++ qemu-0.9.1/hw/baum.c 2008-04-14 11:26:14.000000000 +0200
109
+ * QEMU Baum Braille Device
111
+ * Copyright (c) 2008 Samuel Thibault
113
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
114
+ * of this software and associated documentation files (the "Software"), to deal
115
+ * in the Software without restriction, including without limitation the rights
116
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
117
+ * copies of the Software, and to permit persons to whom the Software is
118
+ * furnished to do so, subject to the following conditions:
120
+ * The above copyright notice and this permission notice shall be included in
121
+ * all copies or substantial portions of the Software.
123
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
124
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
125
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
126
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
127
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
128
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
131
+#include "qemu-common.h"
132
+#include "qemu-char.h"
133
+#include "qemu-timer.h"
137
+#include <brlapi_constants.h>
138
+#include <brlapi_keycodes.h>
140
+#include <SDL/SDL_syswm.h>
144
+#define DPRINTF(fmt, ...) \
145
+ printf(fmt, ## __VA_ARGS__)
147
+#define DPRINTF(fmt, ...)
152
+#define BAUM_REQ_DisplayData 0x01
153
+#define BAUM_REQ_GetVersionNumber 0x05
154
+#define BAUM_REQ_GetKeys 0x08
155
+#define BAUM_REQ_SetMode 0x12
156
+#define BAUM_REQ_SetProtocol 0x15
157
+#define BAUM_REQ_GetDeviceIdentity 0x84
158
+#define BAUM_REQ_GetSerialNumber 0x8A
160
+#define BAUM_RSP_CellCount 0x01
161
+#define BAUM_RSP_VersionNumber 0x05
162
+#define BAUM_RSP_ModeSetting 0x11
163
+#define BAUM_RSP_CommunicationChannel 0x16
164
+#define BAUM_RSP_PowerdownSignal 0x17
165
+#define BAUM_RSP_HorizontalSensors 0x20
166
+#define BAUM_RSP_VerticalSensors 0x21
167
+#define BAUM_RSP_RoutingKeys 0x22
168
+#define BAUM_RSP_Switches 0x23
169
+#define BAUM_RSP_TopKeys 0x24
170
+#define BAUM_RSP_HorizontalSensor 0x25
171
+#define BAUM_RSP_VerticalSensor 0x26
172
+#define BAUM_RSP_RoutingKey 0x27
173
+#define BAUM_RSP_FrontKeys6 0x28
174
+#define BAUM_RSP_BackKeys6 0x29
175
+#define BAUM_RSP_CommandKeys 0x2B
176
+#define BAUM_RSP_FrontKeys10 0x2C
177
+#define BAUM_RSP_BackKeys10 0x2D
178
+#define BAUM_RSP_EntryKeys 0x33
179
+#define BAUM_RSP_JoyStick 0x34
180
+#define BAUM_RSP_ErrorCode 0x40
181
+#define BAUM_RSP_InfoBlock 0x42
182
+#define BAUM_RSP_DeviceIdentity 0x84
183
+#define BAUM_RSP_SerialNumber 0x8A
184
+#define BAUM_RSP_BluetoothName 0x8C
186
+#define BAUM_TL1 0x01
187
+#define BAUM_TL2 0x02
188
+#define BAUM_TL3 0x04
189
+#define BAUM_TR1 0x08
190
+#define BAUM_TR2 0x10
191
+#define BAUM_TR3 0x20
193
+#define BUF_SIZE 256
196
+ CharDriverState *chr;
198
+ brlapi_handle_t *brlapi;
202
+ uint8_t in_buf[BUF_SIZE];
203
+ uint8_t in_buf_used;
204
+ uint8_t out_buf[BUF_SIZE];
205
+ uint8_t out_buf_used, out_buf_ptr;
207
+ QEMUTimer *cellCount_timer;
210
+/* Let's assume NABCC by default */
211
+static const uint8_t nabcc_translation[256] = {
214
+#define BRLAPI_DOTS(d1,d2,d3,d4,d5,d6,d7,d8) \
215
+ ((d1?BRLAPI_DOT1:0)|\
216
+ (d2?BRLAPI_DOT2:0)|\
217
+ (d3?BRLAPI_DOT3:0)|\
218
+ (d4?BRLAPI_DOT4:0)|\
219
+ (d5?BRLAPI_DOT5:0)|\
220
+ (d6?BRLAPI_DOT6:0)|\
221
+ (d7?BRLAPI_DOT7:0)|\
222
+ (d8?BRLAPI_DOT8:0))
224
+ [BRLAPI_DOTS(1,0,0,0,0,0,0,0)] = 'a',
225
+ [BRLAPI_DOTS(1,1,0,0,0,0,0,0)] = 'b',
226
+ [BRLAPI_DOTS(1,0,0,1,0,0,0,0)] = 'c',
227
+ [BRLAPI_DOTS(1,0,0,1,1,0,0,0)] = 'd',
228
+ [BRLAPI_DOTS(1,0,0,0,1,0,0,0)] = 'e',
229
+ [BRLAPI_DOTS(1,1,0,1,0,0,0,0)] = 'f',
230
+ [BRLAPI_DOTS(1,1,0,1,1,0,0,0)] = 'g',
231
+ [BRLAPI_DOTS(1,1,0,0,1,0,0,0)] = 'h',
232
+ [BRLAPI_DOTS(0,1,0,1,0,0,0,0)] = 'i',
233
+ [BRLAPI_DOTS(0,1,0,1,1,0,0,0)] = 'j',
234
+ [BRLAPI_DOTS(1,0,1,0,0,0,0,0)] = 'k',
235
+ [BRLAPI_DOTS(1,1,1,0,0,0,0,0)] = 'l',
236
+ [BRLAPI_DOTS(1,0,1,1,0,0,0,0)] = 'm',
237
+ [BRLAPI_DOTS(1,0,1,1,1,0,0,0)] = 'n',
238
+ [BRLAPI_DOTS(1,0,1,0,1,0,0,0)] = 'o',
239
+ [BRLAPI_DOTS(1,1,1,1,0,0,0,0)] = 'p',
240
+ [BRLAPI_DOTS(1,1,1,1,1,0,0,0)] = 'q',
241
+ [BRLAPI_DOTS(1,1,1,0,1,0,0,0)] = 'r',
242
+ [BRLAPI_DOTS(0,1,1,1,0,0,0,0)] = 's',
243
+ [BRLAPI_DOTS(0,1,1,1,1,0,0,0)] = 't',
244
+ [BRLAPI_DOTS(1,0,1,0,0,1,0,0)] = 'u',
245
+ [BRLAPI_DOTS(1,1,1,0,0,1,0,0)] = 'v',
246
+ [BRLAPI_DOTS(0,1,0,1,1,1,0,0)] = 'w',
247
+ [BRLAPI_DOTS(1,0,1,1,0,1,0,0)] = 'x',
248
+ [BRLAPI_DOTS(1,0,1,1,1,1,0,0)] = 'y',
249
+ [BRLAPI_DOTS(1,0,1,0,1,1,0,0)] = 'z',
251
+ [BRLAPI_DOTS(1,0,0,0,0,0,1,0)] = 'A',
252
+ [BRLAPI_DOTS(1,1,0,0,0,0,1,0)] = 'B',
253
+ [BRLAPI_DOTS(1,0,0,1,0,0,1,0)] = 'C',
254
+ [BRLAPI_DOTS(1,0,0,1,1,0,1,0)] = 'D',
255
+ [BRLAPI_DOTS(1,0,0,0,1,0,1,0)] = 'E',
256
+ [BRLAPI_DOTS(1,1,0,1,0,0,1,0)] = 'F',
257
+ [BRLAPI_DOTS(1,1,0,1,1,0,1,0)] = 'G',
258
+ [BRLAPI_DOTS(1,1,0,0,1,0,1,0)] = 'H',
259
+ [BRLAPI_DOTS(0,1,0,1,0,0,1,0)] = 'I',
260
+ [BRLAPI_DOTS(0,1,0,1,1,0,1,0)] = 'J',
261
+ [BRLAPI_DOTS(1,0,1,0,0,0,1,0)] = 'K',
262
+ [BRLAPI_DOTS(1,1,1,0,0,0,1,0)] = 'L',
263
+ [BRLAPI_DOTS(1,0,1,1,0,0,1,0)] = 'M',
264
+ [BRLAPI_DOTS(1,0,1,1,1,0,1,0)] = 'N',
265
+ [BRLAPI_DOTS(1,0,1,0,1,0,1,0)] = 'O',
266
+ [BRLAPI_DOTS(1,1,1,1,0,0,1,0)] = 'P',
267
+ [BRLAPI_DOTS(1,1,1,1,1,0,1,0)] = 'Q',
268
+ [BRLAPI_DOTS(1,1,1,0,1,0,1,0)] = 'R',
269
+ [BRLAPI_DOTS(0,1,1,1,0,0,1,0)] = 'S',
270
+ [BRLAPI_DOTS(0,1,1,1,1,0,1,0)] = 'T',
271
+ [BRLAPI_DOTS(1,0,1,0,0,1,1,0)] = 'U',
272
+ [BRLAPI_DOTS(1,1,1,0,0,1,1,0)] = 'V',
273
+ [BRLAPI_DOTS(0,1,0,1,1,1,1,0)] = 'W',
274
+ [BRLAPI_DOTS(1,0,1,1,0,1,1,0)] = 'X',
275
+ [BRLAPI_DOTS(1,0,1,1,1,1,1,0)] = 'Y',
276
+ [BRLAPI_DOTS(1,0,1,0,1,1,1,0)] = 'Z',
278
+ [BRLAPI_DOTS(0,0,1,0,1,1,0,0)] = '0',
279
+ [BRLAPI_DOTS(0,1,0,0,0,0,0,0)] = '1',
280
+ [BRLAPI_DOTS(0,1,1,0,0,0,0,0)] = '2',
281
+ [BRLAPI_DOTS(0,1,0,0,1,0,0,0)] = '3',
282
+ [BRLAPI_DOTS(0,1,0,0,1,1,0,0)] = '4',
283
+ [BRLAPI_DOTS(0,1,0,0,0,1,0,0)] = '5',
284
+ [BRLAPI_DOTS(0,1,1,0,1,0,0,0)] = '6',
285
+ [BRLAPI_DOTS(0,1,1,0,1,1,0,0)] = '7',
286
+ [BRLAPI_DOTS(0,1,1,0,0,1,0,0)] = '8',
287
+ [BRLAPI_DOTS(0,0,1,0,1,0,0,0)] = '9',
289
+ [BRLAPI_DOTS(0,0,0,1,0,1,0,0)] = '.',
290
+ [BRLAPI_DOTS(0,0,1,1,0,1,0,0)] = '+',
291
+ [BRLAPI_DOTS(0,0,1,0,0,1,0,0)] = '-',
292
+ [BRLAPI_DOTS(1,0,0,0,0,1,0,0)] = '*',
293
+ [BRLAPI_DOTS(0,0,1,1,0,0,0,0)] = '/',
294
+ [BRLAPI_DOTS(1,1,1,0,1,1,0,0)] = '(',
295
+ [BRLAPI_DOTS(0,1,1,1,1,1,0,0)] = ')',
297
+ [BRLAPI_DOTS(1,1,1,1,0,1,0,0)] = '&',
298
+ [BRLAPI_DOTS(0,0,1,1,1,1,0,0)] = '#',
300
+ [BRLAPI_DOTS(0,0,0,0,0,1,0,0)] = ',',
301
+ [BRLAPI_DOTS(0,0,0,0,1,1,0,0)] = ';',
302
+ [BRLAPI_DOTS(1,0,0,0,1,1,0,0)] = ':',
303
+ [BRLAPI_DOTS(0,1,1,1,0,1,0,0)] = '!',
304
+ [BRLAPI_DOTS(1,0,0,1,1,1,0,0)] = '?',
305
+ [BRLAPI_DOTS(0,0,0,0,1,0,0,0)] = '"',
306
+ [BRLAPI_DOTS(0,0,1,0,0,0,0,0)] ='\'',
307
+ [BRLAPI_DOTS(0,0,0,1,0,0,0,0)] = '`',
308
+ [BRLAPI_DOTS(0,0,0,1,1,0,1,0)] = '^',
309
+ [BRLAPI_DOTS(0,0,0,1,1,0,0,0)] = '~',
310
+ [BRLAPI_DOTS(0,1,0,1,0,1,1,0)] = '[',
311
+ [BRLAPI_DOTS(1,1,0,1,1,1,1,0)] = ']',
312
+ [BRLAPI_DOTS(0,1,0,1,0,1,0,0)] = '{',
313
+ [BRLAPI_DOTS(1,1,0,1,1,1,0,0)] = '}',
314
+ [BRLAPI_DOTS(1,1,1,1,1,1,0,0)] = '=',
315
+ [BRLAPI_DOTS(1,1,0,0,0,1,0,0)] = '<',
316
+ [BRLAPI_DOTS(0,0,1,1,1,0,0,0)] = '>',
317
+ [BRLAPI_DOTS(1,1,0,1,0,1,0,0)] = '$',
318
+ [BRLAPI_DOTS(1,0,0,1,0,1,0,0)] = '%',
319
+ [BRLAPI_DOTS(0,0,0,1,0,0,1,0)] = '@',
320
+ [BRLAPI_DOTS(1,1,0,0,1,1,0,0)] = '|',
321
+ [BRLAPI_DOTS(1,1,0,0,1,1,1,0)] ='\\',
322
+ [BRLAPI_DOTS(0,0,0,1,1,1,0,0)] = '_',
325
+/* The serial port can receive more of our data */
326
+static void baum_accept_input(struct CharDriverState *chr)
328
+ BaumDriverState *baum = chr->opaque;
331
+ if (!baum->out_buf_used)
333
+ room = qemu_chr_can_read(chr);
336
+ if (room > baum->out_buf_used)
337
+ room = baum->out_buf_used;
339
+ first = BUF_SIZE - baum->out_buf_ptr;
340
+ if (room > first) {
341
+ qemu_chr_read(chr, baum->out_buf + baum->out_buf_ptr, first);
342
+ baum->out_buf_ptr = 0;
343
+ baum->out_buf_used -= first;
346
+ qemu_chr_read(chr, baum->out_buf + baum->out_buf_ptr, room);
347
+ baum->out_buf_ptr += room;
348
+ baum->out_buf_used -= room;
351
+/* We want to send a packet */
352
+static void baum_write_packet(BaumDriverState *baum, const uint8_t *buf, int len)
354
+ uint8_t io_buf[1 + 2 * len], *cur = io_buf;
358
+ if ((*cur++ = *buf++) == ESC)
360
+ room = qemu_chr_can_read(baum->chr);
361
+ len = cur - io_buf;
364
+ qemu_chr_read(baum->chr, io_buf, len);
368
+ /* Can't fit all, send what can be, and store the rest. */
369
+ qemu_chr_read(baum->chr, io_buf, room);
371
+ cur = io_buf + room;
372
+ if (len > BUF_SIZE - baum->out_buf_used) {
373
+ /* Can't even store it, drop the previous data... */
374
+ assert(len <= BUF_SIZE);
375
+ baum->out_buf_used = 0;
376
+ baum->out_buf_ptr = 0;
378
+ out = baum->out_buf_ptr;
379
+ baum->out_buf_used += len;
380
+ first = BUF_SIZE - baum->out_buf_ptr;
382
+ memcpy(baum->out_buf + out, cur, first);
387
+ memcpy(baum->out_buf + out, cur, len);
391
+/* Called when the other end seems to have a wrong idea of our display size */
392
+static void baum_cellCount_timer_cb(void *opaque)
394
+ BaumDriverState *baum = opaque;
395
+ uint8_t cell_count[] = { BAUM_RSP_CellCount, baum->x * baum->y };
396
+ DPRINTF("Timeout waiting for DisplayData, sending cell count\n");
397
+ baum_write_packet(baum, cell_count, sizeof(cell_count));
400
+/* Try to interpret a whole incoming packet */
401
+static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len)
403
+ const uint8_t *cur = buf;
408
+ if (*cur++ != ESC) {
409
+ while (*cur != ESC) {
414
+ DPRINTF("Dropped %d bytes!\n", cur - buf);
417
+#define EAT(c) do {\
420
+ if ((c = *cur++) == ESC) { \
423
+ if (*cur++ != ESC) { \
424
+ DPRINTF("Broken packet %#2x, tossing\n", req); \
425
+ if (qemu_timer_pending(baum->cellCount_timer)) { \
426
+ qemu_del_timer(baum->cellCount_timer); \
427
+ baum_cellCount_timer_cb(baum); \
429
+ return (cur - 2 - buf); \
436
+ case BAUM_REQ_DisplayData:
438
+ uint8_t cells[baum->x * baum->y], c;
439
+ uint8_t text[baum->x * baum->y];
440
+ uint8_t zero[baum->x * baum->y];
441
+ int cursor = BRLAPI_CURSOR_OFF;
444
+ /* Allow 100ms to complete the DisplayData packet */
445
+ qemu_mod_timer(baum->cellCount_timer, qemu_get_clock(vm_clock) + ticks_per_sec / 10);
446
+ for (i = 0; i < baum->x * baum->y ; i++) {
449
+ if ((c & (BRLAPI_DOT7|BRLAPI_DOT8))
450
+ == (BRLAPI_DOT7|BRLAPI_DOT8)) {
452
+ c &= ~(BRLAPI_DOT7|BRLAPI_DOT8);
454
+ if (!(c = nabcc_translation[c]))
458
+ qemu_del_timer(baum->cellCount_timer);
460
+ memset(zero, 0, sizeof(zero));
462
+ brlapi_writeArguments_t wa = {
463
+ .displayNumber = BRLAPI_DISPLAY_DEFAULT,
465
+ .regionSize = baum->x * baum->y,
467
+ .textSize = baum->x * baum->y,
471
+ .charset = "ISO-8859-1",
474
+ if (brlapi__write(baum->brlapi, &wa) == -1)
475
+ brlapi_perror("baum brlapi_write");
478
+ case BAUM_REQ_SetMode:
480
+ uint8_t mode, setting;
481
+ DPRINTF("SetMode\n");
487
+ case BAUM_REQ_SetProtocol:
490
+ DPRINTF("SetProtocol\n");
495
+ case BAUM_REQ_GetDeviceIdentity:
497
+ uint8_t identity[17] = { BAUM_RSP_DeviceIdentity,
498
+ 'B','a','u','m',' ','V','a','r','i','o' };
499
+ DPRINTF("GetDeviceIdentity\n");
500
+ identity[11] = '0' + baum->x / 10;
501
+ identity[12] = '0' + baum->x % 10;
502
+ baum_write_packet(baum, identity, sizeof(identity));
505
+ case BAUM_REQ_GetVersionNumber:
507
+ uint8_t version[] = { BAUM_RSP_VersionNumber, 1 }; /* ? */
508
+ DPRINTF("GetVersionNumber\n");
509
+ baum_write_packet(baum, version, sizeof(version));
512
+ case BAUM_REQ_GetSerialNumber:
514
+ uint8_t serial[] = { BAUM_RSP_SerialNumber,
515
+ '0','0','0','0','0','0','0','0' };
516
+ DPRINTF("GetSerialNumber\n");
517
+ baum_write_packet(baum, serial, sizeof(serial));
520
+ case BAUM_REQ_GetKeys:
522
+ DPRINTF("Get%0#2x\n", req);
527
+ DPRINTF("unrecognized request %0#2x\n", req);
531
+ while (*cur++ != ESC);
538
+/* The other end is writing some data. Store it and try to interpret */
539
+static int baum_write(CharDriverState *chr, const uint8_t *buf, int len)
541
+ BaumDriverState *baum = chr->opaque;
542
+ int tocopy, cur, eaten, orig_len = len;
550
+ /* Complete our buffer as much as possible */
552
+ if (tocopy > BUF_SIZE - baum->in_buf_used)
553
+ tocopy = BUF_SIZE - baum->in_buf_used;
555
+ memcpy(baum->in_buf + baum->in_buf_used, buf, tocopy);
556
+ baum->in_buf_used += tocopy;
560
+ /* Interpret it as much as possible */
562
+ while (cur < baum->in_buf_used &&
563
+ (eaten = baum_eat_packet(baum, baum->in_buf + cur, baum->in_buf_used - cur)))
566
+ /* Shift the remainder */
568
+ memmove(baum->in_buf, baum->in_buf + cur, baum->in_buf_used - cur);
569
+ baum->in_buf_used -= cur;
572
+ /* And continue if any data left */
577
+/* The other end sent us some event */
578
+static void baum_send_event(CharDriverState *chr, int event)
580
+ BaumDriverState *baum = chr->opaque;
582
+ case CHR_EVENT_BREAK:
584
+ case CHR_EVENT_RESET:
586
+ baum->in_buf_used = 0;
591
+/* Send the key code to the other end */
592
+static void baum_send_key(BaumDriverState *baum, uint8_t type, uint8_t value) {
593
+ uint8_t packet[] = { type, value };
594
+ DPRINTF("writing key %x %x\n", type, value);
595
+ baum_write_packet(baum, packet, sizeof(packet));
598
+/* We got some data on the BrlAPI socket */
599
+static void baum_chr_read(void *opaque)
601
+ BaumDriverState *baum = opaque;
602
+ brlapi_keyCode_t code;
606
+ while ((ret = brlapi__readKey(baum->brlapi, 0, &code)) == 1) {
607
+ DPRINTF("got key %"BRLAPI_PRIxKEYCODE"\n", code);
609
+ switch (code & BRLAPI_KEY_TYPE_MASK) {
610
+ case BRLAPI_KEY_TYPE_CMD:
611
+ switch (code & BRLAPI_KEY_CMD_BLK_MASK) {
612
+ case BRLAPI_KEY_CMD_ROUTE:
613
+ baum_send_key(baum, BAUM_RSP_RoutingKey, (code & BRLAPI_KEY_CMD_ARG_MASK)+1);
614
+ baum_send_key(baum, BAUM_RSP_RoutingKey, 0);
617
+ switch (code & BRLAPI_KEY_CMD_ARG_MASK) {
618
+ case BRLAPI_KEY_CMD_FWINLT:
619
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL2);
620
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
622
+ case BRLAPI_KEY_CMD_FWINRT:
623
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TR2);
624
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
626
+ case BRLAPI_KEY_CMD_LNUP:
627
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TR1);
628
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
630
+ case BRLAPI_KEY_CMD_LNDN:
631
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TR3);
632
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
634
+ case BRLAPI_KEY_CMD_TOP:
635
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL1|BAUM_TR1);
636
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
638
+ case BRLAPI_KEY_CMD_BOT:
639
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL3|BAUM_TR3);
640
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
642
+ case BRLAPI_KEY_CMD_TOP_LEFT:
643
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL2|BAUM_TR1);
644
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
646
+ case BRLAPI_KEY_CMD_BOT_LEFT:
647
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL2|BAUM_TR3);
648
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
650
+ case BRLAPI_KEY_CMD_HOME:
651
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL2|BAUM_TR1|BAUM_TR3);
652
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
654
+ case BRLAPI_KEY_CMD_PREFMENU:
655
+ baum_send_key(baum, BAUM_RSP_TopKeys, BAUM_TL1|BAUM_TL3|BAUM_TR1);
656
+ baum_send_key(baum, BAUM_RSP_TopKeys, 0);
661
+ case BRLAPI_KEY_TYPE_SYM:
665
+ if (ret == -1 && (brlapi_errno != BRLAPI_ERROR_LIBCERR || errno != EINTR)) {
666
+ brlapi_perror("baum: brlapi_readKey");
667
+ brlapi__closeConnection(baum->brlapi);
668
+ free(baum->brlapi);
669
+ baum->brlapi = NULL;
673
+CharDriverState *chr_baum_init(void)
675
+ BaumDriverState *baum;
676
+ CharDriverState *chr;
677
+ brlapi_handle_t *handle;
679
+ SDL_SysWMinfo info;
683
+ baum = qemu_mallocz(sizeof(BaumDriverState));
687
+ baum->chr = chr = qemu_mallocz(sizeof(CharDriverState));
691
+ chr->opaque = baum;
692
+ chr->chr_write = baum_write;
693
+ chr->chr_send_event = baum_send_event;
694
+ chr->chr_accept_input = baum_accept_input;
696
+ handle = qemu_mallocz(brlapi_getHandleSize());
699
+ baum->brlapi = handle;
701
+ baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL);
702
+ if (baum->brlapi_fd == -1) {
703
+ brlapi_perror("baum_init: brlapi_openConnection");
707
+ baum->cellCount_timer = qemu_new_timer(vm_clock, baum_cellCount_timer_cb, baum);
709
+ if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) {
710
+ brlapi_perror("baum_init: brlapi_getDisplaySize");
715
+ memset(&info, 0, sizeof(info));
716
+ SDL_VERSION(&info.version);
717
+ if (SDL_GetWMInfo(&info))
718
+ tty = info.info.x11.wmwindow;
721
+ tty = BRLAPI_TTY_DEFAULT;
723
+ if (brlapi__enterTtyMode(handle, tty, NULL) == -1) {
724
+ brlapi_perror("baum_init: brlapi_enterTtyMode");
728
+ qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum);
730
+ qemu_chr_reset(chr);
735
+ qemu_free_timer(baum->cellCount_timer);
736
+ brlapi__closeConnection(handle);
746
+USBDevice *usb_baum_init(void)
748
+ /* USB Product ID of Super Vario 40 */
749
+ return usb_serial_init("productid=FE72:braille");
751
Index: qemu-0.9.1/hw/baum.h
752
===================================================================
753
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
754
+++ qemu-0.9.1/hw/baum.h 2008-04-14 11:26:14.000000000 +0200
759
+ * Copyright (c) 2008 Samuel Thibault
761
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
762
+ * of this software and associated documentation files (the "Software"), to deal
763
+ * in the Software without restriction, including without limitation the rights
764
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
765
+ * copies of the Software, and to permit persons to whom the Software is
766
+ * furnished to do so, subject to the following conditions:
768
+ * The above copyright notice and this permission notice shall be included in
769
+ * all copies or substantial portions of the Software.
771
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
772
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
773
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
774
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
775
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
776
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
781
+USBDevice *usb_baum_init(void);
784
+CharDriverState *chr_baum_init(void);
785
Index: qemu-0.9.1/qemu-doc.texi
786
===================================================================
787
--- qemu-0.9.1.orig/qemu-doc.texi 2008-04-14 11:26:14.000000000 +0200
788
+++ qemu-0.9.1/qemu-doc.texi 2008-04-14 11:26:14.000000000 +0200
790
Serial converter to host character device @var{dev}, see @code{-serial} for the
794
+Braille device. This will use BrlAPI to display the braille output on a real
801
@item -serial mon:telnet::4444,server,nowait
805
+Braille device. This will use BrlAPI to display the braille output on a real
810
@item -parallel @var{dev}
811
@@ -1596,6 +1604,9 @@
813
will connect to tcp port 4444 of ip 192.168.0.2, and plug that to the virtual
814
serial converter, faking a Matrix Orbital LCD Display (USB ID 0403:FA00).
816
+Braille device. This will use BrlAPI to display the braille output on a real
820
@node host_usb_devices
821
Index: qemu-0.9.1/vl.c
822
===================================================================
823
--- qemu-0.9.1.orig/vl.c 2008-04-14 11:26:14.000000000 +0200
824
+++ qemu-0.9.1/vl.c 2008-04-14 11:27:17.000000000 +0200
827
#include "hw/audiodev.h"
829
+#include "hw/baum.h"
833
@@ -3434,7 +3435,12 @@
835
if (strstart(filename, "file:", &p)) {
836
return qemu_chr_open_win_file_out(p);
840
+#ifdef CONFIG_BRLAPI
841
+ if (!strcmp(filename, "braille")) {
842
+ return chr_baum_init();
847
@@ -5217,6 +5223,10 @@
848
dev = usb_wacom_init();
849
} else if (strstart(devname, "serial:", &p)) {
850
dev = usb_serial_init(p);
851
+#ifdef CONFIG_BRLAPI
852
+ } else if (!strcmp(devname, "braille")) {
853
+ dev = usb_baum_init();