59559d4cd5f1637c22a8ce8976e6f578d3c7346b
[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 handle for a VCHIQ instance
15 struct vchiq_instance;
16
17 /******************************************************************************
18  * Global funcs - implementation is specific to which side you are on
19  * (local / remote)
20  *****************************************************************************/
21
22 // Routine used to initialise the vchi on both local + remote connections
23 extern int32_t vchi_initialise(struct vchiq_instance **instance);
24
25 extern int32_t vchi_connect(struct vchiq_instance *instance);
26
27 //When this is called, ensure that all services have no data pending.
28 //Bulk transfers can remain 'queued'
29 extern int32_t vchi_disconnect(struct vchiq_instance *instance);
30
31 /******************************************************************************
32  * Global service API
33  *****************************************************************************/
34 // Routine to open a named service
35 extern int vchi_service_open(struct vchiq_instance *instance,
36                             struct vchiq_service_params *params,
37                             unsigned *handle);
38
39 extern int32_t vchi_get_peer_version(unsigned handle, short *peer_version);
40
41 // Routine to close a named service
42 extern int32_t vchi_service_close(unsigned handle);
43
44 // Routine to increment ref count on a named service
45 extern int32_t vchi_service_use(unsigned handle);
46
47 // Routine to decrement ref count on a named service
48 extern int32_t vchi_service_release(unsigned handle);
49
50 /* Routine to send a message from kernel memory across a service */
51 extern int vchi_queue_kernel_message(unsigned handle, void *data,
52                                      unsigned int size);
53
54 // Routine to look at a message in place.
55 // The message is dequeued, so the caller is left holding it; the descriptor is
56 // filled in and must be released when the user has finished with the message.
57 struct vchiq_header *vchi_msg_hold(unsigned handle);
58
59 /*******************************************************************************
60  * Global service support API - operations on held messages
61  * and message iterators
62  ******************************************************************************/
63
64 // Routine to release a held message after it has been processed
65 extern int32_t vchi_held_msg_release(unsigned handle, struct vchiq_header *message);
66
67 /******************************************************************************
68  * Global bulk API
69  *****************************************************************************/
70
71 // Routine to prepare interface for a transfer from the other side
72 extern int32_t vchi_bulk_queue_receive(unsigned handle,
73                                        void *data_dst,
74                                        uint32_t data_size,
75                                        enum vchiq_bulk_mode mode,
76                                        void *transfer_handle);
77
78 // Routine to queue up data ready for transfer to the other (once they have signalled they are ready)
79 extern int32_t vchi_bulk_queue_transmit(unsigned handle,
80                                         const void *data_src,
81                                         uint32_t data_size,
82                                         enum vchiq_bulk_mode mode,
83                                         void *transfer_handle);
84
85 /******************************************************************************
86  * Configuration plumbing
87  *****************************************************************************/
88
89 #endif /* VCHI_H_ */
90
91 /****************************** End of file **********************************/