blob: c5d2e62cdb9bfb2a73e361ad9db94e000f7a6986 [file] [log] [blame]
Greg Hackmannfc29df82013-05-22 14:23:10 -07001/*
2 * Copyright (C) 2013 Google, Inc.
3 *
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.
7 *
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.
12 *
13 */
14
15#ifndef _UAPI_VIDEO_ADF_H_
16#define _UAPI_VIDEO_ADF_H_
17
18#include <linux/ioctl.h>
19#include <linux/types.h>
20
21#include <drm/drm_fourcc.h>
22#include <drm/drm_mode.h>
23
24#define ADF_NAME_LEN 32
Greg Hackmanneaa9f6b2013-11-20 14:02:09 -080025#define ADF_MAX_CUSTOM_DATA_SIZE 4096
Greg Hackmannfc29df82013-05-22 14:23:10 -070026
27enum adf_interface_type {
28 ADF_INTF_DSI = 0,
29 ADF_INTF_eDP = 1,
30 ADF_INTF_DPI = 2,
31 ADF_INTF_VGA = 3,
32 ADF_INTF_DVI = 4,
33 ADF_INTF_HDMI = 5,
34 ADF_INTF_MEMORY = 6,
35 ADF_INTF_TYPE_DEVICE_CUSTOM = 128,
36 ADF_INTF_TYPE_MAX = (~(__u32)0),
37};
38
Greg Hackmannfd81dd32013-09-13 11:23:05 -070039#define ADF_INTF_FLAG_PRIMARY (1 << 0)
40#define ADF_INTF_FLAG_EXTERNAL (1 << 1)
41
Greg Hackmannfc29df82013-05-22 14:23:10 -070042enum adf_event_type {
43 ADF_EVENT_VSYNC = 0,
44 ADF_EVENT_HOTPLUG = 1,
45 ADF_EVENT_DEVICE_CUSTOM = 128,
46 ADF_EVENT_TYPE_MAX = 255,
47};
48
49/**
50 * struct adf_set_event - start or stop subscribing to ADF events
51 *
52 * @type: the type of event to (un)subscribe
53 * @enabled: subscribe or unsubscribe
54 *
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.
57 *
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.
61 */
62struct adf_set_event {
63 __u8 type;
64 __u8 enabled;
65};
66
67/**
68 * struct adf_event - common header for ADF event data
69 *
70 * @type: event type
71 * @length: total size of event data, header inclusive
72 */
73struct adf_event {
74 __u8 type;
75 __u32 length;
76};
77
78/**
79 * struct adf_vsync_event - ADF vsync event
80 *
81 * @base: event header (see &struct adf_event)
82 * @timestamp: time of vsync event, in nanoseconds
83 */
84struct adf_vsync_event {
85 struct adf_event base;
Greg Hackmann1d8124a2014-03-26 16:43:23 -070086 __aligned_u64 timestamp;
Greg Hackmannfc29df82013-05-22 14:23:10 -070087};
88
89/**
90 * struct adf_vsync_event - ADF display hotplug event
91 *
92 * @base: event header (see &struct adf_event)
93 * @connected: whether a display is now connected to the interface
94 */
95struct adf_hotplug_event {
96 struct adf_event base;
97 __u8 connected;
98};
99
100#define ADF_MAX_PLANES 4
101/**
102 * struct adf_buffer_config - description of buffer displayed by adf_post_config
103 *
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
114 */
115struct adf_buffer_config {
116 __u32 overlay_engine;
117
118 __u32 w;
119 __u32 h;
120 __u32 format;
121
Greg Hackmann1d8124a2014-03-26 16:43:23 -0700122 __s32 fd[ADF_MAX_PLANES];
Greg Hackmannfc29df82013-05-22 14:23:10 -0700123 __u32 offset[ADF_MAX_PLANES];
124 __u32 pitch[ADF_MAX_PLANES];
125 __u8 n_planes;
126
Greg Hackmann1d8124a2014-03-26 16:43:23 -0700127 __s32 acquire_fence;
Greg Hackmannfc29df82013-05-22 14:23:10 -0700128};
Greg Hackmanneaa9f6b2013-11-20 14:02:09 -0800129#define ADF_MAX_BUFFERS (4096 / sizeof(struct adf_buffer_config))
Greg Hackmannfc29df82013-05-22 14:23:10 -0700130
131/**
132 * struct adf_post_config - request to flip to a new set of buffers
133 *
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)
142 */
143struct adf_post_config {
144 size_t n_interfaces;
145 __u32 __user *interfaces;
146
147 size_t n_bufs;
148 struct adf_buffer_config __user *bufs;
149
150 size_t custom_data_size;
151 void __user *custom_data;
152
Greg Hackmann1d8124a2014-03-26 16:43:23 -0700153 __s32 complete_fence;
Greg Hackmannfc29df82013-05-22 14:23:10 -0700154};
Greg Hackmanneaa9f6b2013-11-20 14:02:09 -0800155#define ADF_MAX_INTERFACES (4096 / sizeof(__u32))
Greg Hackmannfc29df82013-05-22 14:23:10 -0700156
157/**
Greg Hackmann949005d2013-10-10 13:03:26 -0700158 * struct adf_simple_buffer_allocate - request to allocate a "simple" buffer
159 *
160 * @w: width of buffer in pixels (input)
161 * @h: height of buffer in pixels (input)
162 * @format: DRM-style fourcc (input)
163 *
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)
167 *
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.
171 *
172 * @format must be a standard RGB format defined in drm_fourcc.h.
173 *
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.
177 */
178struct adf_simple_buffer_alloc {
179 __u16 w;
180 __u16 h;
181 __u32 format;
182
Greg Hackmann1d8124a2014-03-26 16:43:23 -0700183 __s32 fd;
Greg Hackmann949005d2013-10-10 13:03:26 -0700184 __u32 offset;
185 __u32 pitch;
186};
187
188/**
189 * struct adf_simple_post_config - request to flip to a single buffer without
190 * driver-private data
191 *
192 * @buf: description of buffer displayed (input)
193 * @complete_fence: sync_fence fd which will clear when this buffer has left the
194 * screen (output)
195 */
196struct adf_simple_post_config {
197 struct adf_buffer_config buf;
Greg Hackmann1d8124a2014-03-26 16:43:23 -0700198 __s32 complete_fence;
Greg Hackmann949005d2013-10-10 13:03:26 -0700199};
200
201/**
Greg Hackmannfc29df82013-05-22 14:23:10 -0700202 * struct adf_attachment_config - description of attachment between an overlay
203 * engine and an interface
204 *
205 * @overlay_engine: id of the overlay engine
206 * @interface: id of the interface
207 */
208struct adf_attachment_config {
209 __u32 overlay_engine;
210 __u32 interface;
211};
212
213/**
214 * struct adf_device_data - describes a display device
215 *
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
223 */
224struct adf_device_data {
225 char name[ADF_NAME_LEN];
226
227 size_t n_attachments;
228 struct adf_attachment_config __user *attachments;
229
230 size_t n_allowed_attachments;
231 struct adf_attachment_config __user *allowed_attachments;
232
233 size_t custom_data_size;
234 void __user *custom_data;
235};
Greg Hackmann2e640042013-11-11 14:31:12 -0800236#define ADF_MAX_ATTACHMENTS (4096 / sizeof(struct adf_attachment_config))
Greg Hackmannfc29df82013-05-22 14:23:10 -0700237
238/**
239 * struct adf_device_data - describes a display interface
240 *
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
Greg Hackmann949005d2013-10-10 13:03:26 -0700245 * @flags: informational flags (bitmask of %ADF_INTF_FLAG_* values)
Greg Hackmannfc29df82013-05-22 14:23:10 -0700246 * @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
255 */
256struct adf_interface_data {
257 char name[ADF_NAME_LEN];
258
259 __u32 type;
260 __u32 id;
261 /* e.g. type=ADF_INTF_TYPE_DSI, id=1 => DSI.1 */
Greg Hackmannfd81dd32013-09-13 11:23:05 -0700262 __u32 flags;
Greg Hackmannfc29df82013-05-22 14:23:10 -0700263
264 __u8 dpms_state;
265 __u8 hotplug_detect;
266 __u16 width_mm;
267 __u16 height_mm;
268
269 struct drm_mode_modeinfo current_mode;
270 size_t n_available_modes;
271 struct drm_mode_modeinfo __user *available_modes;
272
273 size_t custom_data_size;
274 void __user *custom_data;
275};
Greg Hackmanneaa9f6b2013-11-20 14:02:09 -0800276#define ADF_MAX_MODES (4096 / sizeof(struct drm_mode_modeinfo))
Greg Hackmannfc29df82013-05-22 14:23:10 -0700277
278/**
279 * struct adf_overlay_engine_data - describes an overlay engine
280 *
281 * @name: overlay engine's name
Greg Hackmann47017b12013-06-11 12:59:41 -0700282 * @n_supported_formats: number of supported formats
283 * @supported_formats: list of supported formats
Greg Hackmannfc29df82013-05-22 14:23:10 -0700284 * @custom_data_size: size of driver-private data
285 * @custom_data: driver-private data
286 */
287struct adf_overlay_engine_data {
288 char name[ADF_NAME_LEN];
289
Greg Hackmann47017b12013-06-11 12:59:41 -0700290 size_t n_supported_formats;
291 __u32 __user *supported_formats;
292
Greg Hackmannfc29df82013-05-22 14:23:10 -0700293 size_t custom_data_size;
294 void __user *custom_data;
295};
Greg Hackmanneaa9f6b2013-11-20 14:02:09 -0800296#define ADF_MAX_SUPPORTED_FORMATS (4096 / sizeof(__u32))
Greg Hackmannfc29df82013-05-22 14:23:10 -0700297
Greg Hackmann637c4d82014-01-13 15:24:24 -0800298#define ADF_IOCTL_TYPE 'D'
299#define ADF_IOCTL_NR_CUSTOM 128
300
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)
Greg Hackmannfc29df82013-05-22 14:23:10 -0700309#define ADF_GET_OVERLAY_ENGINE_DATA \
Greg Hackmann637c4d82014-01-13 15:24:24 -0800310 _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)
Greg Hackmannfc29df82013-05-22 14:23:10 -0700320
321#endif /* _UAPI_VIDEO_ADF_H_ */