[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 13/22] adb: add status field for holding information about the
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v2 13/22] adb: add status field for holding information about the last ADB request |
Date: |
Tue, 23 Jun 2020 21:49:27 +0100 |
Currently only 2 bits are defined: one to indicate if the request timed out (no
reply) and another to indicate whether the request was the result of an autopoll
operation.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: Finn Thain <fthain@telegraphics.com.au>
---
hw/input/adb.c | 14 +++++++++++---
include/hw/input/adb.h | 4 ++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/hw/input/adb.c b/hw/input/adb.c
index c1adb21e6b..a7a482fdfa 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -42,7 +42,7 @@ int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t
*buf, int len)
{
ADBDevice *d;
ADBDeviceClass *adc;
- int devaddr, cmd, i;
+ int devaddr, cmd, olen, i;
cmd = buf[0] & 0xf;
if (cmd == ADB_BUSRESET) {
@@ -50,6 +50,7 @@ int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t
*buf, int len)
d = s->devices[i];
adb_device_reset(d);
}
+ s->status = 0;
return 0;
}
@@ -63,16 +64,22 @@ int adb_request(ADBBusState *s, uint8_t *obuf, const
uint8_t *buf, int len)
}
}
+ s->status = 0;
devaddr = buf[0] >> 4;
for (i = 0; i < s->nb_devices; i++) {
d = s->devices[i];
adc = ADB_DEVICE_GET_CLASS(d);
if (d->devaddr == devaddr) {
- return adc->devreq(d, obuf, buf, len);
+ olen = adc->devreq(d, obuf, buf, len);
+ if (!olen) {
+ s->status |= ADB_STATUS_BUSTIMEOUT;
+ }
+ return olen;
}
}
+ s->status |= ADB_STATUS_BUSTIMEOUT;
return ADB_RET_NOTPRESENT;
}
@@ -94,9 +101,10 @@ int adb_poll(ADBBusState *s, uint8_t *obuf, uint16_t
poll_mask)
olen = adb_request(s, obuf + 1, buf, 1);
/* if there is data, we poll again the same device */
if (olen > 0) {
+ s->status |= ADB_STATUS_POLLREPLY;
obuf[0] = buf[0];
olen++;
- break;
+ return olen;
}
}
s->poll_index++;
diff --git a/include/hw/input/adb.h b/include/hw/input/adb.h
index f1bc358d8e..cff264739c 100644
--- a/include/hw/input/adb.h
+++ b/include/hw/input/adb.h
@@ -70,6 +70,9 @@ typedef struct ADBDeviceClass {
#define TYPE_ADB_BUS "apple-desktop-bus"
#define ADB_BUS(obj) OBJECT_CHECK(ADBBusState, (obj), TYPE_ADB_BUS)
+#define ADB_STATUS_BUSTIMEOUT 0x1
+#define ADB_STATUS_POLLREPLY 0x2
+
struct ADBBusState {
/*< private >*/
BusState parent_obj;
@@ -79,6 +82,7 @@ struct ADBBusState {
uint16_t pending;
int nb_devices;
int poll_index;
+ uint8_t status;
QEMUTimer *autopoll_timer;
bool autopoll_enabled;
--
2.20.1
- [PATCH v2 03/22] cuda: convert ADB autopoll timer from ns to ms, (continued)
- [PATCH v2 03/22] cuda: convert ADB autopoll timer from ns to ms, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 04/22] pmu: fix duplicate autopoll mask variable, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 05/22] pmu: honour autopoll_rate_ms when rearming the ADB autopoll timer, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 06/22] adb: introduce realize/unrealize and VMStateDescription for ADB bus, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 07/22] adb: create autopoll variables directly within ADBBusState, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 08/22] cuda: convert to use ADBBusState internal autopoll variables, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 09/22] pmu: convert to use ADBBusState internal autopoll variables, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 10/22] mac_via: convert to use ADBBusState internal autopoll variables, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 11/22] adb: introduce new ADBDeviceHasData method to ADBDeviceClass, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 12/22] adb: keep track of devices with pending data, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 13/22] adb: add status field for holding information about the last ADB request,
Mark Cave-Ayland <=
- [PATCH v2 14/22] adb: use adb_request() only for explicit requests, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 15/22] adb: add autopoll_blocked variable to block autopoll, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 16/22] cuda: add adb_autopoll_block() and adb_autopoll_unblock() functions, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 17/22] pmu: add adb_autopoll_block() and adb_autopoll_unblock() functions, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 18/22] mac_via: move VIA1 portB write logic into mos6522_q800_via1_write(), Mark Cave-Ayland, 2020/06/23
- [PATCH v2 19/22] mac_via: rework ADB state machine to be compatible with both MacOS and Linux, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 20/22] adb: only call autopoll callbacks when autopoll is not blocked, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 21/22] adb: use adb_device prefix for ADB device trace events, Mark Cave-Ayland, 2020/06/23
- [PATCH v2 22/22] adb: add ADB bus trace events, Mark Cave-Ayland, 2020/06/23
- Re: [PATCH v2 00/22] ADB: fix autopoll issues and rework mac_via state machine, Laurent Vivier, 2020/06/26