Skip to content

Commit 10f7ffa

Browse files
committed
Merge remote-tracking branch 'remotes/mcayland/tags/qemu-macppc-20200626' into staging
qemu-macppc patches # gpg: Signature made Fri 26 Jun 2020 10:15:36 BST # gpg: using RSA key CC621AB98E82200D915CC9C45BC2C56FAE0F321F # gpg: issuer "[email protected]" # gpg: Good signature from "Mark Cave-Ayland <[email protected]>" [full] # Primary key fingerprint: CC62 1AB9 8E82 200D 915C C9C4 5BC2 C56F AE0F 321F * remotes/mcayland/tags/qemu-macppc-20200626: (22 commits) adb: add ADB bus trace events adb: use adb_device prefix for ADB device trace events adb: only call autopoll callbacks when autopoll is not blocked mac_via: rework ADB state machine to be compatible with both MacOS and Linux mac_via: move VIA1 portB write logic into mos6522_q800_via1_write() pmu: add adb_autopoll_block() and adb_autopoll_unblock() functions cuda: add adb_autopoll_block() and adb_autopoll_unblock() functions adb: add autopoll_blocked variable to block autopoll adb: use adb_request() only for explicit requests adb: add status field for holding information about the last ADB request adb: keep track of devices with pending data adb: introduce new ADBDeviceHasData method to ADBDeviceClass mac_via: convert to use ADBBusState internal autopoll variables pmu: convert to use ADBBusState internal autopoll variables cuda: convert to use ADBBusState internal autopoll variables adb: create autopoll variables directly within ADBBusState adb: introduce realize/unrealize and VMStateDescription for ADB bus pmu: honour autopoll_rate_ms when rearming the ADB autopoll timer pmu: fix duplicate autopoll mask variable cuda: convert ADB autopoll timer from ns to ms ... Signed-off-by: Peter Maydell <[email protected]>
2 parents 611ac63 + e590e7f commit 10f7ffa

File tree

13 files changed

+620
-283
lines changed

13 files changed

+620
-283
lines changed

hw/input/adb-kbd.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,
243243
olen = 0;
244244
switch (cmd) {
245245
case ADB_WRITEREG:
246-
trace_adb_kbd_writereg(reg, buf[1]);
246+
trace_adb_device_kbd_writereg(reg, buf[1]);
247247
switch (reg) {
248248
case 2:
249249
/* LED status */
@@ -256,24 +256,22 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,
256256
case ADB_CMD_CHANGE_ID_AND_ACT:
257257
case ADB_CMD_CHANGE_ID_AND_ENABLE:
258258
d->devaddr = buf[1] & 0xf;
259-
trace_adb_kbd_request_change_addr(d->devaddr);
259+
trace_adb_device_kbd_request_change_addr(d->devaddr);
260260
break;
261261
default:
262-
if (!d->disable_direct_reg3_writes) {
263-
d->devaddr = buf[1] & 0xf;
264-
265-
/* we support handlers:
266-
* 1: Apple Standard Keyboard
267-
* 2: Apple Extended Keyboard (LShift = RShift)
268-
* 3: Apple Extended Keyboard (LShift != RShift)
269-
*/
270-
if (buf[2] == 1 || buf[2] == 2 || buf[2] == 3) {
271-
d->handler = buf[2];
272-
}
273-
274-
trace_adb_kbd_request_change_addr_and_handler(d->devaddr,
275-
d->handler);
262+
d->devaddr = buf[1] & 0xf;
263+
/*
264+
* we support handlers:
265+
* 1: Apple Standard Keyboard
266+
* 2: Apple Extended Keyboard (LShift = RShift)
267+
* 3: Apple Extended Keyboard (LShift != RShift)
268+
*/
269+
if (buf[2] == 1 || buf[2] == 2 || buf[2] == 3) {
270+
d->handler = buf[2];
276271
}
272+
273+
trace_adb_device_kbd_request_change_addr_and_handler(
274+
d->devaddr, d->handler);
277275
break;
278276
}
279277
}
@@ -296,12 +294,19 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,
296294
olen = 2;
297295
break;
298296
}
299-
trace_adb_kbd_readreg(reg, obuf[0], obuf[1]);
297+
trace_adb_device_kbd_readreg(reg, obuf[0], obuf[1]);
300298
break;
301299
}
302300
return olen;
303301
}
304302

303+
static bool adb_kbd_has_data(ADBDevice *d)
304+
{
305+
KBDState *s = ADB_KEYBOARD(d);
306+
307+
return s->count > 0;
308+
}
309+
305310
/* This is where keyboard events enter this file */
306311
static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,
307312
InputEvent *evt)
@@ -316,7 +321,7 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,
316321
/* FIXME: take handler into account when translating qcode */
317322
keycode = qcode_to_adb_keycode[qcode];
318323
if (keycode == NO_KEY) { /* We don't want to send this to the guest */
319-
trace_adb_kbd_no_key();
324+
trace_adb_device_kbd_no_key();
320325
return;
321326
}
322327
if (evt->u.key.data->down == false) { /* if key release event */
@@ -384,6 +389,7 @@ static void adb_kbd_class_init(ObjectClass *oc, void *data)
384389
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
385390

386391
adc->devreq = adb_kbd_request;
392+
adc->devhasdata = adb_kbd_has_data;
387393
dc->reset = adb_kbd_reset;
388394
dc->vmsd = &vmstate_adb_kbd;
389395
}

hw/input/adb-mouse.c

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,
121121
s->dx = 0;
122122
s->dy = 0;
123123
s->dz = 0;
124-
trace_adb_mouse_flush();
124+
trace_adb_device_mouse_flush();
125125
return 0;
126126
}
127127

@@ -130,42 +130,50 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,
130130
olen = 0;
131131
switch (cmd) {
132132
case ADB_WRITEREG:
133-
trace_adb_mouse_writereg(reg, buf[1]);
133+
trace_adb_device_mouse_writereg(reg, buf[1]);
134134
switch (reg) {
135135
case 2:
136136
break;
137137
case 3:
138+
/*
139+
* MacOS 9 has a bug in its ADB driver whereby after configuring
140+
* the ADB bus devices it sends another write of invalid length
141+
* to reg 3. Make sure we ignore it to prevent an address clash
142+
* with the previous device.
143+
*/
144+
if (len != 3) {
145+
return 0;
146+
}
147+
138148
switch (buf[2]) {
139149
case ADB_CMD_SELF_TEST:
140150
break;
141151
case ADB_CMD_CHANGE_ID:
142152
case ADB_CMD_CHANGE_ID_AND_ACT:
143153
case ADB_CMD_CHANGE_ID_AND_ENABLE:
144154
d->devaddr = buf[1] & 0xf;
145-
trace_adb_mouse_request_change_addr(d->devaddr);
155+
trace_adb_device_mouse_request_change_addr(d->devaddr);
146156
break;
147157
default:
148-
if (!d->disable_direct_reg3_writes) {
149-
d->devaddr = buf[1] & 0xf;
150-
151-
/* we support handlers:
152-
* 0x01: Classic Apple Mouse Protocol / 100 cpi operations
153-
* 0x02: Classic Apple Mouse Protocol / 200 cpi operations
154-
* we don't support handlers (at least):
155-
* 0x03: Mouse systems A3 trackball
156-
* 0x04: Extended Apple Mouse Protocol
157-
* 0x2f: Microspeed mouse
158-
* 0x42: Macally
159-
* 0x5f: Microspeed mouse
160-
* 0x66: Microspeed mouse
161-
*/
162-
if (buf[2] == 1 || buf[2] == 2) {
163-
d->handler = buf[2];
164-
}
165-
166-
trace_adb_mouse_request_change_addr_and_handler(
167-
d->devaddr, d->handler);
158+
d->devaddr = buf[1] & 0xf;
159+
/*
160+
* we support handlers:
161+
* 0x01: Classic Apple Mouse Protocol / 100 cpi operations
162+
* 0x02: Classic Apple Mouse Protocol / 200 cpi operations
163+
* we don't support handlers (at least):
164+
* 0x03: Mouse systems A3 trackball
165+
* 0x04: Extended Apple Mouse Protocol
166+
* 0x2f: Microspeed mouse
167+
* 0x42: Macally
168+
* 0x5f: Microspeed mouse
169+
* 0x66: Microspeed mouse
170+
*/
171+
if (buf[2] == 1 || buf[2] == 2) {
172+
d->handler = buf[2];
168173
}
174+
175+
trace_adb_device_mouse_request_change_addr_and_handler(
176+
d->devaddr, d->handler);
169177
break;
170178
}
171179
}
@@ -183,12 +191,20 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,
183191
olen = 2;
184192
break;
185193
}
186-
trace_adb_mouse_readreg(reg, obuf[0], obuf[1]);
194+
trace_adb_device_mouse_readreg(reg, obuf[0], obuf[1]);
187195
break;
188196
}
189197
return olen;
190198
}
191199

200+
static bool adb_mouse_has_data(ADBDevice *d)
201+
{
202+
MouseState *s = ADB_MOUSE(d);
203+
204+
return !(s->last_buttons_state == s->buttons_state &&
205+
s->dx == 0 && s->dy == 0);
206+
}
207+
192208
static void adb_mouse_reset(DeviceState *dev)
193209
{
194210
ADBDevice *d = ADB_DEVICE(dev);
@@ -244,6 +260,7 @@ static void adb_mouse_class_init(ObjectClass *oc, void *data)
244260
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
245261

246262
adc->devreq = adb_mouse_request;
263+
adc->devhasdata = adb_mouse_has_data;
247264
dc->reset = adb_mouse_reset;
248265
dc->vmsd = &vmstate_adb_mouse;
249266
}

0 commit comments

Comments
 (0)