staging: vchi: Use struct vchiq_service_params
[linux-2.6-microblaze.git] / drivers / staging / vc04_services / interface / vchi / vchi.h
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */
3
4 #ifndef VCHI_H_
5 #define VCHI_H_
6
7 /******************************************************************************
8  * Global defs
9  *****************************************************************************/
10
11 // Macros to manipulate 'FOURCC' values
12 #define MAKE_FOURCC(x) ((int32_t)((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3]))
13
14 // Opaque service information
15 struct opaque_vchi_service_t;
16
17 // Descriptor for a held message. Allocated by client, initialised by vchi_msg_hold,
18 // vchi_msg_iter_hold or vchi_msg_iter_hold_next. Fields are for internal VCHI use only.
19 struct vchi_held_msg {
20         struct opaque_vchi_service_t *service;
21         void *message;
22 };
23
24 struct vchi_service {
25         unsigned int handle;
26 };
27
28 // Opaque handle for a VCHIQ instance
29 struct vchiq_instance;
30
31 /******************************************************************************
32  * Global funcs - implementation is specific to which side you are on
33  * (local / remote)
34  *****************************************************************************/
35
36 // Routine used to initialise the vchi on both local + remote connections
37 extern int32_t vchi_initialise(struct vchiq_instance **instance);
38
39 extern int32_t vchi_connect(struct vchiq_instance *instance);
40
41 //When this is called, ensure that all services have no data pending.
42 //Bulk transfers can remain 'queued'
43 extern int32_t vchi_disconnect(struct vchiq_instance *instance);
44
45 /******************************************************************************
46  * Global service API
47  *****************************************************************************/
48 // Routine to open a named service
49 extern int32_t vchi_service_open(struct vchiq_instance *instance,
50                                  struct vchiq_service_params *setup,
51                                  struct vchi_service **service);
52
53 extern int32_t vchi_get_peer_version(struct vchi_service *service,
54                                      short *peer_version);
55
56 // Routine to close a named service
57 extern int32_t vchi_service_close(struct vchi_service *service);
58
59 // Routine to increment ref count on a named service
60 extern int32_t vchi_service_use(struct vchi_service *service);
61
62 // Routine to decrement ref count on a named service
63 extern int32_t vchi_service_release(struct vchi_service *service);
64
65 /* Routine to send a message from kernel memory across a service */
66 extern int vchi_queue_kernel_message(struct vchi_service *service, void *data,
67                                      unsigned int size);
68
69 // Routine to look at a message in place.
70 // The message is dequeued, so the caller is left holding it; the descriptor is
71 // filled in and must be released when the user has finished with the message.
72 extern int32_t vchi_msg_hold(unsigned handle,
73                              void **data,        // } may be NULL, as info can be
74                              uint32_t *msg_size, // } obtained from HELD_MSG_T
75                              struct vchi_held_msg *message_descriptor);
76
77 /*******************************************************************************
78  * Global service support API - operations on held messages
79  * and message iterators
80  ******************************************************************************/
81
82 // Routine to release a held message after it has been processed
83 extern int32_t vchi_held_msg_release(struct vchi_held_msg *message);
84
85 /******************************************************************************
86  * Global bulk API
87  *****************************************************************************/
88
89 // Routine to prepare interface for a transfer from the other side
90 extern int32_t vchi_bulk_queue_receive(struct vchi_service *service,
91                                        void *data_dst,
92                                        uint32_t data_size,
93                                        enum vchiq_bulk_mode mode,
94                                        void *transfer_handle);
95
96 // Routine to queue up data ready for transfer to the other (once they have signalled they are ready)
97 extern int32_t vchi_bulk_queue_transmit(struct vchi_service *service,
98                                         const void *data_src,
99                                         uint32_t data_size,
100                                         enum vchiq_bulk_mode mode,
101                                         void *transfer_handle);
102
103 /******************************************************************************
104  * Configuration plumbing
105  *****************************************************************************/
106
107 #endif /* VCHI_H_ */
108
109 /****************************** End of file **********************************/