2 * Copyright (C) 2013 Google, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #ifndef _UAPI_VIDEO_ADF_H_
16 #define _UAPI_VIDEO_ADF_H_
18 #include <linux/ioctl.h>
19 #include <linux/types.h>
21 #include <drm/drm_fourcc.h>
22 #include <drm/drm_mode.h>
24 #define ADF_NAME_LEN 32
25 #define ADF_MAX_CUSTOM_DATA_SIZE 4096
27 enum adf_interface_type {
35 ADF_INTF_TYPE_DEVICE_CUSTOM = 128,
36 ADF_INTF_TYPE_MAX = (~(__u32)0),
39 #define ADF_INTF_FLAG_PRIMARY (1 << 0)
40 #define ADF_INTF_FLAG_EXTERNAL (1 << 1)
44 ADF_EVENT_HOTPLUG = 1,
45 ADF_EVENT_DEVICE_CUSTOM = 128,
46 ADF_EVENT_TYPE_MAX = 255,
50 * struct adf_set_event - start or stop subscribing to ADF events
52 * @type: the type of event to (un)subscribe
53 * @enabled: subscribe or unsubscribe
55 * After subscribing to an event, userspace may poll() the ADF object's fd
56 * to wait for events or read() to consume the event's data.
58 * ADF reserves event types 0 to %ADF_EVENT_DEVICE_CUSTOM-1 for its own events.
59 * Devices may use event types %ADF_EVENT_DEVICE_CUSTOM to %ADF_EVENT_TYPE_MAX-1
60 * for driver-private events.
62 struct adf_set_event {
68 * struct adf_event - common header for ADF event data
71 * @length: total size of event data, header inclusive
79 * struct adf_vsync_event - ADF vsync event
81 * @base: event header (see &struct adf_event)
82 * @timestamp: time of vsync event, in nanoseconds
84 struct adf_vsync_event {
85 struct adf_event base;
86 __aligned_u64 timestamp;
90 * struct adf_vsync_event - ADF display hotplug event
92 * @base: event header (see &struct adf_event)
93 * @connected: whether a display is now connected to the interface
95 struct adf_hotplug_event {
96 struct adf_event base;
100 #define ADF_MAX_PLANES 4
102 * struct adf_buffer_config - description of buffer displayed by adf_post_config
104 * @overlay_engine: id of the target overlay engine
105 * @w: width of display region in pixels
106 * @h: height of display region in pixels
107 * @format: DRM-style fourcc, see drm_fourcc.h for standard formats
108 * @fd: dma_buf fd for each plane
109 * @offset: location of first pixel to scan out, in bytes
110 * @pitch: stride (i.e. length of a scanline including padding) in bytes
111 * @n_planes: number of planes in buffer
112 * @acquire_fence: sync_fence fd which will clear when the buffer is
113 * ready for display, or <0 if the buffer is already ready
115 struct adf_buffer_config {
116 __u32 overlay_engine;
122 __s32 fd[ADF_MAX_PLANES];
123 __u32 offset[ADF_MAX_PLANES];
124 __u32 pitch[ADF_MAX_PLANES];
129 #define ADF_MAX_BUFFERS (4096 / sizeof(struct adf_buffer_config))
132 * struct adf_post_config - request to flip to a new set of buffers
134 * @n_interfaces: number of interfaces targeted by the flip (input)
135 * @interfaces: ids of interfaces targeted by the flip (input)
136 * @n_bufs: number of buffers displayed (input)
137 * @bufs: description of buffers displayed (input)
138 * @custom_data_size: size of driver-private data (input)
139 * @custom_data: driver-private data (input)
140 * @complete_fence: sync_fence fd which will clear when this
141 * configuration has left the screen (output)
143 struct adf_post_config {
145 __u32 __user *interfaces;
148 struct adf_buffer_config __user *bufs;
150 size_t custom_data_size;
151 void __user *custom_data;
153 __s32 complete_fence;
155 #define ADF_MAX_INTERFACES (4096 / sizeof(__u32))
158 * struct adf_simple_buffer_allocate - request to allocate a "simple" buffer
160 * @w: width of buffer in pixels (input)
161 * @h: height of buffer in pixels (input)
162 * @format: DRM-style fourcc (input)
164 * @fd: dma_buf fd (output)
165 * @offset: location of first pixel, in bytes (output)
166 * @pitch: length of a scanline including padding, in bytes (output)
168 * Simple buffers are analogous to DRM's "dumb" buffers. They have a single
169 * plane of linear RGB data which can be allocated and scanned out without
170 * any driver-private ioctls or data.
172 * @format must be a standard RGB format defined in drm_fourcc.h.
174 * ADF clients must NOT assume that an interface can scan out a simple buffer
175 * allocated by a different ADF interface, even if the two interfaces belong to
176 * the same ADF device.
178 struct adf_simple_buffer_alloc {
189 * struct adf_simple_post_config - request to flip to a single buffer without
190 * driver-private data
192 * @buf: description of buffer displayed (input)
193 * @complete_fence: sync_fence fd which will clear when this buffer has left the
196 struct adf_simple_post_config {
197 struct adf_buffer_config buf;
198 __s32 complete_fence;
202 * struct adf_attachment_config - description of attachment between an overlay
203 * engine and an interface
205 * @overlay_engine: id of the overlay engine
206 * @interface: id of the interface
208 struct adf_attachment_config {
209 __u32 overlay_engine;
214 * struct adf_device_data - describes a display device
216 * @name: display device's name
217 * @n_attachments: the number of current attachments
218 * @attachments: list of current attachments
219 * @n_allowed_attachments: the number of allowed attachments
220 * @allowed_attachments: list of allowed attachments
221 * @custom_data_size: size of driver-private data
222 * @custom_data: driver-private data
224 struct adf_device_data {
225 char name[ADF_NAME_LEN];
227 size_t n_attachments;
228 struct adf_attachment_config __user *attachments;
230 size_t n_allowed_attachments;
231 struct adf_attachment_config __user *allowed_attachments;
233 size_t custom_data_size;
234 void __user *custom_data;
236 #define ADF_MAX_ATTACHMENTS (4096 / sizeof(struct adf_attachment_config))
239 * struct adf_device_data - describes a display interface
241 * @name: display interface's name
242 * @type: interface type (see enum @adf_interface_type)
243 * @id: which interface of type @type;
244 * e.g. interface DSI.1 -> @type=@ADF_INTF_TYPE_DSI, @id=1
245 * @flags: informational flags (bitmask of %ADF_INTF_FLAG_* values)
246 * @dpms_state: DPMS state (one of @DRM_MODE_DPMS_* defined in drm_mode.h)
247 * @hotplug_detect: whether a display is plugged in
248 * @width_mm: screen width in millimeters, or 0 if unknown
249 * @height_mm: screen height in millimeters, or 0 if unknown
250 * @current_mode: current display mode
251 * @n_available_modes: the number of hardware display modes
252 * @available_modes: list of hardware display modes
253 * @custom_data_size: size of driver-private data
254 * @custom_data: driver-private data
256 struct adf_interface_data {
257 char name[ADF_NAME_LEN];
261 /* e.g. type=ADF_INTF_TYPE_DSI, id=1 => DSI.1 */
269 struct drm_mode_modeinfo current_mode;
270 size_t n_available_modes;
271 struct drm_mode_modeinfo __user *available_modes;
273 size_t custom_data_size;
274 void __user *custom_data;
276 #define ADF_MAX_MODES (4096 / sizeof(struct drm_mode_modeinfo))
279 * struct adf_overlay_engine_data - describes an overlay engine
281 * @name: overlay engine's name
282 * @n_supported_formats: number of supported formats
283 * @supported_formats: list of supported formats
284 * @custom_data_size: size of driver-private data
285 * @custom_data: driver-private data
287 struct adf_overlay_engine_data {
288 char name[ADF_NAME_LEN];
290 size_t n_supported_formats;
291 __u32 __user *supported_formats;
293 size_t custom_data_size;
294 void __user *custom_data;
296 #define ADF_MAX_SUPPORTED_FORMATS (4096 / sizeof(__u32))
298 #define ADF_IOCTL_TYPE 'D'
299 #define ADF_IOCTL_NR_CUSTOM 128
301 #define ADF_SET_EVENT _IOW(ADF_IOCTL_TYPE, 0, struct adf_set_event)
302 #define ADF_BLANK _IOW(ADF_IOCTL_TYPE, 1, __u8)
303 #define ADF_POST_CONFIG _IOW(ADF_IOCTL_TYPE, 2, struct adf_post_config)
304 #define ADF_SET_MODE _IOW(ADF_IOCTL_TYPE, 3, \
305 struct drm_mode_modeinfo)
306 #define ADF_GET_DEVICE_DATA _IOR(ADF_IOCTL_TYPE, 4, struct adf_device_data)
307 #define ADF_GET_INTERFACE_DATA _IOR(ADF_IOCTL_TYPE, 5, \
308 struct adf_interface_data)
309 #define ADF_GET_OVERLAY_ENGINE_DATA \
310 _IOR(ADF_IOCTL_TYPE, 6, \
311 struct adf_overlay_engine_data)
312 #define ADF_SIMPLE_POST_CONFIG _IOW(ADF_IOCTL_TYPE, 7, \
313 struct adf_simple_post_config)
314 #define ADF_SIMPLE_BUFFER_ALLOC _IOW(ADF_IOCTL_TYPE, 8, \
315 struct adf_simple_buffer_alloc)
316 #define ADF_ATTACH _IOW(ADF_IOCTL_TYPE, 9, \
317 struct adf_attachment_config)
318 #define ADF_DETACH _IOW(ADF_IOCTL_TYPE, 10, \
319 struct adf_attachment_config)
321 #endif /* _UAPI_VIDEO_ADF_H_ */