summaryrefslogtreecommitdiff
path: root/original-kernel-headers/media/msm_vpu.h
blob: 7bcbc4f90872037068f636f138f6c514bb0e6250 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
#ifndef _H_MSM_VPU_H_
#define _H_MSM_VPU_H_

#include <linux/videodev2.h>

/*
 * V 4 L 2   E X T E N S I O N S   B Y   V P U
 */

/*
 * v4l2_buffer:
 *
 * VPU uses standard V4L2 buffer flags, and defines some custom
 * flags (used in v4l2_buffer.flags field):
 *	V4L2_QCOM_BUF_FLAG_EOS: buffer flag indicating end of stream
 *	V4L2_BUF_FLAG_CDS_ENABLE: buffer flag to enable chroma down-sampling
 */
#define V4L2_BUF_FLAG_CDS_ENABLE	0x10000000

/*
 * VPU uses multi-plane v4l2_buffer in the following manner:
 * each plane can be a separate ION buffer, or all planes are from the
 * same ION buffer (under this case all planes have the same fd, but different
 * offset).
 *
 * For struct v4l2_plane
 *   fd: ION fd representing the ION buffer this plane is from
 *   reserved[0]: offset of this plane from the start of the ION buffer in
 *		bytes. Needed when all planes are from the same ION buffer.
 */
#define V4L2_PLANE_MEM_OFFSET		0

/*
 * struct v4l2_format:
 * always use v4l2_pix_format_mplane, even when there is only one plane
 *
 * v4l2_pix_format_mplane:
 *
 * VPU uses v4l2_pix_format_mplane for pixel format configuration
 * The following members of this structure is either extended or changed:
 *    pixelformat: extended, a few more private formats added
 *    colorspace:  possible values are enum vpu_colorspace
 *    field: when it is V4L2_FIELD_ALTERNATE, flags from vpu format extension
 *           specifies which field first.
 *    reserved[]:  VPU format extension. struct v4l2_format_vpu_extension
 */
enum vpu_colorspace {
	VPU_CS_MIN = 0,
	/* RGB with full range*/
	VPU_CS_RGB_FULL = 1,
	/* RGB with limited range*/
	VPU_CS_RGB_LIMITED = 2,
	/* REC 601 with full range */
	VPU_CS_REC601_FULL = 3,
	/* REC 601 with limited range */
	VPU_CS_REC601_LIMITED = 4,
	/* REC 709 with full range */
	VPU_CS_REC709_FULL = 5,
	/* REC 709 with limited range */
	VPU_CS_REC709_LIMITED = 6,
	/* SMPTE 240 with full range */
	VPU_CS_SMPTE240_FULL = 7,
	/* SMPTE 240 with limited range */
	VPU_CS_SMPTE240_LIMITED = 8,
	VPU_CS_MAX = 9,
};


#define VPU_FMT_EXT_FLAG_BT	1	/* bottom field first */
#define VPU_FMT_EXT_FLAG_TB	2	/* top field first */
#define VPU_FMT_EXT_FLAG_3D	4	/* 3D format */
struct v4l2_format_vpu_extension {
	__u8		flag;
	__u8		gap_in_lines;
};

/*
 * Supported pixel formats:
 *
 * VPU supported pixel format fourcc codes (use in s_fmt pixelformat field).
 *	Can be enumerated using VIDIOC_ENUM_FMT
 *
 * Standard V4L2 formats, defined in videodev2.h :
 *
 * V4L2_PIX_FMT_RGB24		24 bit RGB-8-8-8
 * V4L2_PIX_FMT_RGB32		32 bit XRGB-8-8-8-8
 * V4L2_PIX_FMT_BGR24		24 bit BGR-8-8-8
 * V4L2_PIX_FMT_BGR32		32 bit BGRX-8-8-8-8
 *
 * V4L2_PIX_FMT_NV12		12 bit YUV 4:2:0  semi-planar NV12
 * V4L2_PIX_FMT_NV21		12 bit YUV 4:2:0  semi-planar NV21
 * V4L2_PIX_FMT_YUYV		16 bit YUYV 4:2:2 interleaved
 * V4L2_PIX_FMT_YVYU		16 bit YVYU 4:2:2 interleaved
 * V4L2_PIX_FMT_UYVY		16 bit UYVY 4:2:2 interleaved
 * V4L2_PIX_FMT_VYUY		16 bit VYUY 4:2:2 interleaved
 *
 *
 * Private VPU formats, defined here :
 *
 * V4L2_PIX_FMT_XRGB2		32 bit XRGB-2-10-10-10
 * V4L2_PIX_FMT_XBGR2		32 bit XBGR-2-10-10-10
 *
 * V4L2_PIX_FMT_YUYV10		24 bit YUYV 4:2:2  10 bit per component loose
 * V4L2_PIX_FMT_YUV8		24 bit YUV 4:4:4   8 bit per component
 * V4L2_PIX_FMT_YUV10		32 bit YUV 4:4:4   10 bit per component loose
 * V4L2_PIX_FMT_YUYV10BWC	10 bit YUYV 4:2:2  compressed, for output only
 */
#define V4L2_PIX_FMT_XRGB2		v4l2_fourcc('X', 'R', 'G', '2')
#define V4L2_PIX_FMT_XBGR2		v4l2_fourcc('X', 'B', 'G', '2')
#define V4L2_PIX_FMT_YUYV10		v4l2_fourcc('Y', 'U', 'Y', 'L')
#define V4L2_PIX_FMT_YUV8		v4l2_fourcc('Y', 'U', 'V', '8')
#define V4L2_PIX_FMT_YUV10		v4l2_fourcc('Y', 'U', 'V', 'L')
#define V4L2_PIX_FMT_YUYV10BWC		v4l2_fourcc('Y', 'B', 'W', 'C')

/*
 * VIDIOC_S_INPUT/VIDIOC_S_OUTPUT
 *
 * The single integer passed by these commands specifies port type in the
 * lower 16 bits, and pipe bit mask in the higher 16 bits.
 */
/* input / output types */
#define VPU_INPUT_TYPE_HOST			0
#define VPU_INPUT_TYPE_VCAP			1
#define VPU_OUTPUT_TYPE_HOST			0
#define VPU_OUTPUT_TYPE_DISPLAY			1

/* input / output pipe bit fields */
#define VPU_PIPE_VCAP0			(1 << 16)
#define VPU_PIPE_VCAP1			(1 << 17)
#define VPU_PIPE_DISPLAY0		(1 << 18)
#define VPU_PIPE_DISPLAY1		(1 << 19)
#define VPU_PIPE_DISPLAY2		(1 << 20)
#define VPU_PIPE_DISPLAY3		(1 << 21)

/*
 * V P U   E V E N T S :   I D s   A N D   D A T A   P A Y L O A D S
 */

/*
 * Event ID: set in type field of struct v4l2_event
 * payload: returned in u.data array of struct v4l2_event
 *
 *
 * VPU_EVENT_FLUSH_DONE: Done flushing buffers after VPU_FLUSH_BUFS ioctl
 * payload data: enum v4l2_buf_type (buffer type of flushed port)
 *
 * VPU_EVENT_ACTIVE_REGION_CHANGED: New Active Region Detected
 * payload data: struct v4l2_rect (new active region rectangle)
 *
 * VPU_EVENT_SESSION_TIMESTAMP: New Session timestamp
 * payload data: vpu_frame_timestamp_info
 *
 * VPU_EVENT_SESSION_CREATED: New session has been created
 * payload data: int (number of the attached session)
 *
 * VPU_EVENT_SESSION_FREED: Session is detached and free
 * payload data: int (number of the detached session)
 *
 * VPU_EVENT_SESSION_CLIENT_EXITED: Indicates that clients of current
 *	session have exited.
 * payload data: int (number of all remaining clients for this session)
 *
 * VPU_EVENT_HW_ERROR: a hardware error occurred in VPU
 * payload data: NULL
 *
 * VPU_EVENT_INVALID_CONFIG: invalid VPU session configuration
 * payload data: NULL
 *
 * VPU_EVENT_FAILED_SESSION_STREAMING: Failed to stream session
 * payload data: NULL
 */
#define VPU_PRIVATE_EVENT_BASE (V4L2_EVENT_PRIVATE_START + 6 * 1000)
enum VPU_PRIVATE_EVENT {
	VPU_EVENT_START = VPU_PRIVATE_EVENT_BASE,

	VPU_EVENT_FLUSH_DONE = VPU_EVENT_START + 1,
	VPU_EVENT_ACTIVE_REGION_CHANGED = VPU_EVENT_START + 2,
	VPU_EVENT_SESSION_TIMESTAMP = VPU_EVENT_START + 3,
	VPU_EVENT_SESSION_CREATED = VPU_EVENT_START + 4,
	VPU_EVENT_SESSION_FREED = VPU_EVENT_START + 5,
	VPU_EVENT_SESSION_CLIENT_EXITED = VPU_EVENT_START + 6,

	VPU_EVENT_HW_ERROR = VPU_EVENT_START + 11,
	VPU_EVENT_INVALID_CONFIG = VPU_EVENT_START + 12,
	VPU_EVENT_FAILED_SESSION_STREAMING = VPU_EVENT_START + 13,

	VPU_EVENT_END
};


/*
 * V P U   CO N T R O L S :   S T R U C T S   A N D   I D s
 *
 * Controls are video processing parameters
 */

/*
 * Standard VPU Controls
 */
struct vpu_ctrl_standard {
	__u32 enable;		/* boolean: 0=disable, else=enable */
	__s32 value;
};

struct vpu_ctrl_auto_manual {
	__u32 enable;		/* boolean: 0=disable, else=enable */
	__u32 auto_mode;	/* boolean: 0=manual, else=automatic */
	__s32 value;
};

struct vpu_ctrl_range_mapping {
	__u32 enable;		/* boolean: 0=disable, else=enable */
	__u32 y_range;		/* the range mapping set for Y [0, 7] */
	__u32 uv_range;		/* the range mapping set for UV [0, 7] */
};

#define VPU_ACTIVE_REGION_N_EXCLUSIONS 1
struct vpu_ctrl_active_region_param {
	__u32               enable; /* boolean: 0=disable, else=enable */
	/* number of exclusion regions */
	__u32               num_exclusions;
	/* roi where active region detection is applied */
	struct v4l2_rect    detection_region;
	/* roi(s) excluded from active region detection*/
	struct v4l2_rect    excluded_regions[VPU_ACTIVE_REGION_N_EXCLUSIONS];
};

struct vpu_ctrl_deinterlacing_mode {
	__u32 field_polarity;
	__u32 mvp_mode;
};

struct vpu_ctrl_hqv {
	__u32 enable;
	/* strength control of all sharpening features [0, 100] */
	__u32 sharpen_strength;
	/* strength control of Auto NR feature [0, 100] */
	__u32 auto_nr_strength;
};

struct vpu_info_frame_timestamp {
	/* presentation timestamp of the frame */
	__u32 pts_low;
	__u32 pts_high;
	/* qtimer snapshot */
	__u32 qtime_low;
	__u32 qtime_high;
};

struct vpu_control {
	__u32 control_id;
	union control_data {
		__s32 value;
		struct vpu_ctrl_standard standard;
		struct vpu_ctrl_auto_manual auto_manual;
		struct vpu_ctrl_range_mapping range_mapping;
		struct vpu_ctrl_active_region_param active_region_param;
		struct v4l2_rect active_region_result;
		struct vpu_ctrl_deinterlacing_mode deinterlacing_mode;
		struct vpu_ctrl_hqv hqv;
		struct vpu_info_frame_timestamp timestamp;
		__u8 reserved[124];
	} data;
};

/*
 * IDs for standard controls (use in control_id field of struct vpu_control)
 *
 * VPU_CTRL_NOISE_REDUCTION: noise reduction level, data: auto_manual,
 * value: [0, 100] (step in increments of 25).
 *
 * VPU_CTRL_IMAGE_ENHANCEMENT: image enhancement level, data: auto_manual,
 * value: [-100, 100] (step in increments of 1).
 *
 * VPU_CTRL_ANAMORPHIC_SCALING: anamorphic scaling config, data: standard,
 * value: [0, 100] (step in increments of 1).
 *
 * VPU_CTRL_DIRECTIONAL_INTERPOLATION: directional interpolation config
 * data: standard, value: [0, 100] (step in increments of 1).
 *
 * VPU_CTRL_BACKGROUND_COLOR: , data: value,
 * value: red[0:7] green[8:15] blue[16:23] alpha[24:31]
 *
 * VPU_CTRL_RANGE_MAPPING: Y/UV range mapping, data: range_mapping,
 * y_range: [0, 7], uv_range: [0, 7] (step in increments of 1).
 *
 * VPU_CTRL_DEINTERLACING_MODE: deinterlacing mode, data: deinterlacing_mode,
 * field_polarity: [0, 2], mvp_mode: [0, 2] (step in increments of 1).
 *
 * VPU_CTRL_ACTIVE_REGION_PARAM: active region detection parameters (set only)
 * data: active_region_param,
 *
 * VPU_CTRL_ACTIVE_REGION_RESULT: detected active region roi (get only)
 * data: active_region_result
 *
 * VPU_CTRL_PRIORITY: Session priority, data: value,
 * value: high 100, normal 50
 *
 * VPU_CTRL_CONTENT_PROTECTION: input content protection status, data: value,
 * value: secure 1, non-secure 0
 *
 * VPU_CTRL_DISPLAY_REFRESH_RATE: display refresh rate (set only)
 * data: value (set to __u32 16.16 format)
 *
 * VPU_CTRL_HQV: hqv block config, data: hqv,
 * sharpen_strength: [0, 100] (step in increments of 25),
 * auto_nr_strength: [0, 100] (step in increments of 1).
 *
 * VPU_CTRL_HQV_SHARPEN: , data: value,
 * sharpen_strength: [0, 100] (step in increments of 1).
 *
 * VPU_CTRL_HQV_AUTONR: , data: value,
 * auto_nr_strength: [0, 100] (step in increments of 1).
 *
 * VPU_CTRL_ACE: , data: value
 *
 * VPU_CTRL_ACE_BRIGHTNESS: , data: value,
 * value: [-100, 100] (step in increments of 1).
 *
 * VPU_CTRL_ACE_CONTRAST: , data: value,
 * value: [-100, 100] (step in increments of 1).
 *
 * VPU_CTRL_2D3D: , data: value,
 * value: 1 enabled, 0 disabled
 *
 * VPU_CTRL_2D3D_DEPTH: , data: value,
 * value: [0, 100] (step in increments of 1).
 *
 * VPU_CTRL_TIMESTAMP_INFO_MODE: timestamp reporting mode,
 *  data: value specifying how frequent a timestamp reporting info, value
 *  is in frames
 *
 * VPU_INFO_TIMESTAMP: timestamp information (get only)
 *  data: struct vpu_frame_timestamp_info
 *
 * VPU_CTRL_FRC: enable/disable FRC, data: value,
 * value: 1 enable, 0 disable
 *
 * VPU_CTRL_FRC_MOTION_SMOOTHNESS: , data: value,
 * value: [0, 100] (step in increments of 1).
 *
 * VPU_CTRL_FRC_MOTION_CLEAR: , data: value,
 * value: [0, 100] (step in increments of 1).
 *
 * VPU_CTRL_LATENCY: session latency, data: value in us
 *
 * VPU_CTRL_LATENCY_MODE: data: value (ultra low, low, etc.)
 *
 * VPU_INFO_STATISTICS: frames dropped, etc (get only),
 *  data: reserved
 */
#define VPU_CTRL_ID_MIN						0

#define VPU_CTRL_NOISE_REDUCTION				1
#define VPU_CTRL_IMAGE_ENHANCEMENT				2
#define VPU_CTRL_ANAMORPHIC_SCALING				3
#define VPU_CTRL_DIRECTIONAL_INTERPOLATION			4
#define VPU_CTRL_BACKGROUND_COLOR				5
#define VPU_CTRL_RANGE_MAPPING					6
#define VPU_CTRL_DEINTERLACING_MODE				7
#define VPU_CTRL_ACTIVE_REGION_PARAM				8
#define VPU_CTRL_ACTIVE_REGION_RESULT				9
#define VPU_CTRL_PRIORITY					10
#define VPU_CTRL_CONTENT_PROTECTION				11
#define VPU_CTRL_DISPLAY_REFRESH_RATE				12

#define VPU_CTRL_HQV						20
#define VPU_CTRL_HQV_SHARPEN					21
#define VPU_CTRL_HQV_AUTONR					22
#define VPU_CTRL_ACE						23
#define VPU_CTRL_ACE_BRIGHTNESS					24
#define VPU_CTRL_ACE_CONTRAST					25
#define VPU_CTRL_2D3D						26
#define VPU_CTRL_2D3D_DEPTH					27
#define VPU_CTRL_FRC						28
#define VPU_CTRL_FRC_MOTION_SMOOTHNESS				29
#define VPU_CTRL_FRC_MOTION_CLEAR				30

#define VPU_INFO_TIMESTAMP					35
#define VPU_CTRL_TIMESTAMP_INFO_MODE				36
#define VPU_INFO_STATISTICS					37
#define VPU_CTRL_LATENCY					38
#define VPU_CTRL_LATENCY_MODE					39

#define VPU_CTRL_ID_MAX						40


/*
 * Extended VPU Controls (large data payloads)
 */
#define VPU_MAX_EXT_DATA_SIZE	720
struct vpu_control_extended {
	/*
	 * extended control type
	 * 0: system
	 * 1: session
	 */
	__u32 type;

	/*
	 * size and ptr of the data to send
	 * maximum VPU_MAX_EXT_DATA_SIZE bytes
	 */
	__u32 data_len;
	void __user *data_ptr;

	/*
	 * size and ptr of the buffer to recv data
	 * maximum VPU_MAX_EXT_DATA_SIZE bytes
	 */
	__u32 buf_size;
	void __user *buf_ptr;
};

/*
 * Port specific controls
 */
struct vpu_control_port {
	__u32 control_id;
	__u32 port;	/* 0: INPUT, 1: OUTPUT */
	union control_port_data {
		__u32 framerate;
	} data;
};

/*
 * IDs for port controls (use in control_id field of struct vpu_control_port)
 *
 * VPU_CTRL_FPS: set frame rate, data: __u32, 16.16 format
 */
#define	VPU_CTRL_FPS				1000


/*
 * V P U   D E V I C E   P R I V A T E   I O C T L   C O D E S
 */

/* VPU Session ioctls (deprecated) */
#define VPU_ATTACH_TO_SESSION	_IOW('V', (BASE_VIDIOC_PRIVATE + 1), int)

/* VPU Session ioctls */
#define VPU_QUERY_SESSIONS	_IOR('V', (BASE_VIDIOC_PRIVATE + 0), int)
#define VPU_CREATE_SESSION	_IOR('V', (BASE_VIDIOC_PRIVATE + 2), int)
#define VPU_JOIN_SESSION	_IOW('V', (BASE_VIDIOC_PRIVATE + 3), int)

/* Enable second VPU output port and use with current client */
#define VPU_CREATE_OUTPUT2	_IO('V', (BASE_VIDIOC_PRIVATE + 5))

/* Explicit commit of session configuration */
#define VPU_COMMIT_CONFIGURATION    _IO('V', (BASE_VIDIOC_PRIVATE + 10))

/* Flush all buffers of given type (port) */
#define VPU_FLUSH_BUFS		_IOW('V', (BASE_VIDIOC_PRIVATE + 15), \
		enum v4l2_buf_type)

/* VPU controls get/set ioctls (for most controls with small data) */
#define VPU_G_CONTROL		_IOWR('V', (BASE_VIDIOC_PRIVATE + 20), \
						struct vpu_control)
#define VPU_S_CONTROL		_IOW('V', (BASE_VIDIOC_PRIVATE + 21), \
						struct vpu_control)

/* extended control set/get ioctls (large data payloads) */
#define VPU_G_CONTROL_EXTENDED	_IOWR('V', (BASE_VIDIOC_PRIVATE + 22), \
		struct vpu_control_extended)
#define VPU_S_CONTROL_EXTENDED	_IOW('V', (BASE_VIDIOC_PRIVATE + 23), \
		struct vpu_control_extended)

/* VPU port (input/output) specific controls get/set ioctls */
#define VPU_G_CONTROL_PORT	_IOWR('V', (BASE_VIDIOC_PRIVATE + 24), \
						struct vpu_control_port)
#define VPU_S_CONTROL_PORT	_IOW('V', (BASE_VIDIOC_PRIVATE + 25), \
						struct vpu_control_port)

#endif /* _H_MSM_VPU_H_ */