Debian Codegraph @

drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Broadcom BCM2835 V4L2 driver
4 *
5 * Copyright © 2013 Raspberry Pi (Trading) Ltd.
6 *
7 * Authors: Vincent Sanders @ Collabora
8 * Dave Stevenson @ Broadcom
9 * (now [email protected])
10 * Simon Mellor @ Broadcom
11 * Luke Diamand @ Broadcom
12 *
13 * MMAL interface to VCHIQ message passing
14 */
15
16 #ifndef MMAL_VCHIQ_H
17 #define MMAL_VCHIQ_H
18
19 #include "mmal-common.h"
20 #include "mmal-msg-format.h"
21
22 #define MAX_PORT_COUNT 4
23
24 /* Maximum size of the format extradata. */
25 #define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
26
27 struct vchiq_mmal_instance;
28 struct device;
29
30 enum vchiq_mmal_es_type {
31 MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
32 MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
33 MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
34 MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
35 MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
36 };
37
38 struct vchiq_mmal_port_buffer {
39 unsigned int num; /* number of buffers */
40 u32 size; /* size of buffers */
41 u32 alignment; /* alignment of buffers */
42 };
43
44 struct vchiq_mmal_port;
45
46 typedef void (*vchiq_mmal_buffer_cb)(struct vchiq_mmal_instance *instance,
47 struct vchiq_mmal_port *port,
48 int status, struct mmal_buffer *buffer);
49
50 struct vchiq_mmal_port {
51 bool enabled;
52 u32 handle;
53 u32 type; /* port type, cached to use on port info set */
54 u32 index; /* port index, cached to use on port info set */
55
56 /* component port belongs to, allows simple deref */
57 struct vchiq_mmal_component *component;
58
59 struct vchiq_mmal_port *connected; /* port connected to */
60
61 /* buffer info */
62 struct vchiq_mmal_port_buffer minimum_buffer;
63 struct vchiq_mmal_port_buffer recommended_buffer;
64 struct vchiq_mmal_port_buffer current_buffer;
65
66 /* stream format */
67 struct mmal_es_format_local format;
68 /* elementary stream format */
69 union mmal_es_specific_format es;
70
71 /* data buffers to fill */
72 struct list_head buffers;
73 /* lock to serialise adding and removing buffers from list */
74 spinlock_t slock;
75
76 /* Count of buffers the VPU has yet to return */
77 atomic_t buffers_with_vpu;
78 /* callback on buffer completion */
79 vchiq_mmal_buffer_cb buffer_cb;
80 /* callback context */
81 void *cb_ctx;
82 };
83
84 struct vchiq_mmal_component {
85 bool in_use;
86 bool enabled;
87 u32 handle; /* VideoCore handle for component */
88 u32 inputs; /* Number of input ports */
89 u32 outputs; /* Number of output ports */
90 u32 clocks; /* Number of clock ports */
91 struct vchiq_mmal_port control; /* control port */
92 struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
93 struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
94 struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
95 u32 client_component; /* Used to ref back to client struct */
96 };
97
98 int vchiq_mmal_init(struct device *dev, struct vchiq_mmal_instance **out_instance);
99 int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
100
101 /* Initialise a mmal component and its ports
102 *
103 */
104 int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
105 const char *name, struct vchiq_mmal_component **component_out);
106
107 int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
108 struct vchiq_mmal_component *component);
109
110 int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance,
111 struct vchiq_mmal_component *component);
112
113 int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance,
114 struct vchiq_mmal_component *component);
115
116 /* enable a mmal port
117 *
118 * enables a port and, if a buffer callback provided, enqueues buffer
119 * headers as appropriate for the port.
120 */
121 int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance,
122 struct vchiq_mmal_port *port,
123 vchiq_mmal_buffer_cb buffer_cb);
124
125 /* disable a port
126 *
127 * disable a port will dequeue any pending buffers
128 */
129 int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
130 struct vchiq_mmal_port *port);
131
132 int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
133 struct vchiq_mmal_port *port,
134 u32 parameter,
135 void *value,
136 u32 value_size);
137
138 int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
139 struct vchiq_mmal_port *port,
140 u32 parameter,
141 void *value,
142 u32 *value_size);
143
144 int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
145 struct vchiq_mmal_port *port);
146
147 int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
148 struct vchiq_mmal_port *src,
149 struct vchiq_mmal_port *dst);
150
151 int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
152 u32 *major_out,
153 u32 *minor_out);
154
155 int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
156 struct vchiq_mmal_port *port,
157 struct mmal_buffer *buf);
158
159 int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
160 struct mmal_buffer *buf);
161 int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf);
162 #endif /* MMAL_VCHIQ_H */