]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/stream.h
Use DECLARE_*CHECKER* macros
[mirror_qemu.git] / include / hw / stream.h
CommitLineData
669b4983 1#ifndef STREAM_H
175de524 2#define STREAM_H
669b4983 3
14cccb61 4#include "qom/object.h"
669b4983
PC
5
6/* stream slave. Used until qdev provides a generic way. */
7#define TYPE_STREAM_SLAVE "stream-slave"
8
db1015e9 9typedef struct StreamSlaveClass StreamSlaveClass;
8110fa1d
EH
10DECLARE_CLASS_CHECKERS(StreamSlaveClass, STREAM_SLAVE,
11 TYPE_STREAM_SLAVE)
669b4983
PC
12#define STREAM_SLAVE(obj) \
13 INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE)
14
aa1b35b9 15typedef struct StreamSlave StreamSlave;
669b4983 16
35e60bfd
PC
17typedef void (*StreamCanPushNotifyFn)(void *opaque);
18
db1015e9 19struct StreamSlaveClass {
669b4983 20 InterfaceClass parent;
35e60bfd
PC
21 /**
22 * can push - determine if a stream slave is capable of accepting at least
23 * one byte of data. Returns false if cannot accept. If not implemented, the
805a2505 24 * slave is assumed to always be capable of receiving.
35e60bfd 25 * @notify: Optional callback that the slave will call when the slave is
805a2505 26 * capable of receiving again. Only called if false is returned.
35e60bfd
PC
27 * @notify_opaque: opaque data to pass to notify call.
28 */
29 bool (*can_push)(StreamSlave *obj, StreamCanPushNotifyFn notify,
30 void *notify_opaque);
31 /**
32 * push - push data to a Stream slave. The number of bytes pushed is
33 * returned. If the slave short returns, the master must wait before trying
34 * again, the slave may continue to just return 0 waiting for the vm time to
35 * advance. The can_push() function can be used to trap the point in time
805a2505 36 * where the slave is ready to receive again, otherwise polling on a QEMU
35e60bfd
PC
37 * timer will work.
38 * @obj: Stream slave to push to
39 * @buf: Data to write
40 * @len: Maximum number of bytes to write
51b19950 41 * @eop: End of packet flag
35e60bfd 42 */
51b19950 43 size_t (*push)(StreamSlave *obj, unsigned char *buf, size_t len, bool eop);
db1015e9 44};
669b4983 45
35e60bfd 46size_t
51b19950 47stream_push(StreamSlave *sink, uint8_t *buf, size_t len, bool eop);
669b4983 48
35e60bfd
PC
49bool
50stream_can_push(StreamSlave *sink, StreamCanPushNotifyFn notify,
51 void *notify_opaque);
52
53
669b4983 54#endif /* STREAM_H */