| 1 | /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
| 2 | /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ |
| 3 | |
| 4 | #ifndef VCHIQ_H |
| 5 | #define VCHIQ_H |
| 6 | |
| 7 | #define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ |
| 8 | (((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3)) |
| 9 | |
| 10 | enum vchiq_reason { |
| 11 | VCHIQ_SERVICE_OPENED, /* service, -, - */ |
| 12 | VCHIQ_SERVICE_CLOSED, /* service, -, - */ |
| 13 | VCHIQ_MESSAGE_AVAILABLE, /* service, header, - */ |
| 14 | VCHIQ_BULK_TRANSMIT_DONE, /* service, -, bulk_userdata */ |
| 15 | VCHIQ_BULK_RECEIVE_DONE, /* service, -, bulk_userdata */ |
| 16 | VCHIQ_BULK_TRANSMIT_ABORTED, /* service, -, bulk_userdata */ |
| 17 | VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ |
| 18 | }; |
| 19 | |
| 20 | enum vchiq_bulk_mode { |
| 21 | VCHIQ_BULK_MODE_CALLBACK, |
| 22 | VCHIQ_BULK_MODE_BLOCKING, |
| 23 | VCHIQ_BULK_MODE_NOCALLBACK, |
| 24 | VCHIQ_BULK_MODE_WAITING /* Reserved for internal use */ |
| 25 | }; |
| 26 | |
| 27 | enum vchiq_service_option { |
| 28 | VCHIQ_SERVICE_OPTION_AUTOCLOSE, |
| 29 | VCHIQ_SERVICE_OPTION_SLOT_QUOTA, |
| 30 | VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA, |
| 31 | VCHIQ_SERVICE_OPTION_SYNCHRONOUS, |
| 32 | VCHIQ_SERVICE_OPTION_TRACE |
| 33 | }; |
| 34 | |
| 35 | struct { |
| 36 | /* The message identifier - opaque to applications. */ |
| 37 | int ; |
| 38 | |
| 39 | /* Size of message data. */ |
| 40 | unsigned int ; |
| 41 | |
| 42 | char []; /* message */ |
| 43 | }; |
| 44 | |
| 45 | struct vchiq_element { |
| 46 | const void __user *data; |
| 47 | unsigned int size; |
| 48 | }; |
| 49 | |
| 50 | struct vchiq_instance; |
| 51 | struct vchiq_state; |
| 52 | |
| 53 | struct vchiq_service_base { |
| 54 | int fourcc; |
| 55 | int (*callback)(struct vchiq_instance *instance, |
| 56 | enum vchiq_reason reason, |
| 57 | struct vchiq_header *, |
| 58 | unsigned int handle, |
| 59 | void *cb_data, void __user *cb_userdata); |
| 60 | void *userdata; |
| 61 | }; |
| 62 | |
| 63 | struct vchiq_completion_data_kernel { |
| 64 | enum vchiq_reason reason; |
| 65 | struct vchiq_header *; |
| 66 | void *service_userdata; |
| 67 | void *cb_data; |
| 68 | void __user *cb_userdata; |
| 69 | }; |
| 70 | |
| 71 | struct vchiq_service_params_kernel { |
| 72 | int fourcc; |
| 73 | int (*callback)(struct vchiq_instance *instance, |
| 74 | enum vchiq_reason reason, |
| 75 | struct vchiq_header *, |
| 76 | unsigned int handle, |
| 77 | void *cb_data, void __user *cb_userdata); |
| 78 | void *userdata; |
| 79 | short version; /* Increment for non-trivial changes */ |
| 80 | short version_min; /* Update for incompatible changes */ |
| 81 | }; |
| 82 | |
| 83 | extern int vchiq_initialise(struct vchiq_state *state, |
| 84 | struct vchiq_instance **pinstance); |
| 85 | extern int vchiq_shutdown(struct vchiq_instance *instance); |
| 86 | extern int vchiq_connect(struct vchiq_instance *instance); |
| 87 | extern int vchiq_open_service(struct vchiq_instance *instance, |
| 88 | const struct vchiq_service_params_kernel *params, |
| 89 | unsigned int *pservice); |
| 90 | extern int vchiq_close_service(struct vchiq_instance *instance, |
| 91 | unsigned int service); |
| 92 | extern int vchiq_use_service(struct vchiq_instance *instance, unsigned int service); |
| 93 | extern int vchiq_release_service(struct vchiq_instance *instance, |
| 94 | unsigned int service); |
| 95 | extern void vchiq_msg_queue_push(struct vchiq_instance *instance, unsigned int handle, |
| 96 | struct vchiq_header *); |
| 97 | extern void vchiq_release_message(struct vchiq_instance *instance, unsigned int service, |
| 98 | struct vchiq_header *); |
| 99 | extern int vchiq_queue_kernel_message(struct vchiq_instance *instance, unsigned int handle, |
| 100 | void *data, unsigned int size); |
| 101 | extern int vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int service, |
| 102 | const void *data, unsigned int size, void *userdata, |
| 103 | enum vchiq_bulk_mode mode); |
| 104 | extern int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int service, |
| 105 | void *data, unsigned int size, void *userdata, |
| 106 | enum vchiq_bulk_mode mode); |
| 107 | extern void *vchiq_get_service_userdata(struct vchiq_instance *instance, unsigned int service); |
| 108 | extern int vchiq_get_peer_version(struct vchiq_instance *instance, unsigned int handle, |
| 109 | short *peer_version); |
| 110 | extern struct vchiq_header *vchiq_msg_hold(struct vchiq_instance *instance, unsigned int handle); |
| 111 | |
| 112 | #endif /* VCHIQ_H */ |
| 113 | |