adb: keep track of devices with pending data
Add a new pending variable to ADBBusState which is a bitmask indicating which ADB devices have data to send. Update the bitmask every time that an ADB request is executed. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Tested-by: Finn Thain <fthain@telegraphics.com.au> Acked-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20200623204936.24064-13-mark.cave-ayland@ilande.co.uk>
This commit is contained in:
parent
969ca2f7a1
commit
244a0ee965
|
@ -41,6 +41,7 @@ static void adb_device_reset(ADBDevice *d)
|
||||||
int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
|
int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
ADBDevice *d;
|
ADBDevice *d;
|
||||||
|
ADBDeviceClass *adc;
|
||||||
int devaddr, cmd, i;
|
int devaddr, cmd, i;
|
||||||
|
|
||||||
cmd = buf[0] & 0xf;
|
cmd = buf[0] & 0xf;
|
||||||
|
@ -51,14 +52,27 @@ int adb_request(ADBBusState *s, uint8_t *obuf, const uint8_t *buf, int len)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s->pending = 0;
|
||||||
|
for (i = 0; i < s->nb_devices; i++) {
|
||||||
|
d = s->devices[i];
|
||||||
|
adc = ADB_DEVICE_GET_CLASS(d);
|
||||||
|
|
||||||
|
if (adc->devhasdata(d)) {
|
||||||
|
s->pending |= (1 << d->devaddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
devaddr = buf[0] >> 4;
|
devaddr = buf[0] >> 4;
|
||||||
for (i = 0; i < s->nb_devices; i++) {
|
for (i = 0; i < s->nb_devices; i++) {
|
||||||
d = s->devices[i];
|
d = s->devices[i];
|
||||||
|
adc = ADB_DEVICE_GET_CLASS(d);
|
||||||
|
|
||||||
if (d->devaddr == devaddr) {
|
if (d->devaddr == devaddr) {
|
||||||
ADBDeviceClass *adc = ADB_DEVICE_GET_CLASS(d);
|
|
||||||
return adc->devreq(d, obuf, buf, len);
|
return adc->devreq(d, obuf, buf, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ADB_RET_NOTPRESENT;
|
return ADB_RET_NOTPRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct ADBBusState {
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
|
|
||||||
ADBDevice *devices[MAX_ADB_DEVICES];
|
ADBDevice *devices[MAX_ADB_DEVICES];
|
||||||
|
uint16_t pending;
|
||||||
int nb_devices;
|
int nb_devices;
|
||||||
int poll_index;
|
int poll_index;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue