1 /*
2  * Copyright (C) 2016-2017 Dmitry Osipenko <digetx@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version
7  * 2 of the License, or (at your option) any later version.
8  */
9 
10 #ifndef _UAPI_TEGRA_VDE_H_
11 #define _UAPI_TEGRA_VDE_H_
12 
13 #include <linux/types.h>
14 #include <asm/ioctl.h>
15 
16 #define FLAG_B_FRAME		(1 << 0)
17 #define FLAG_REFERENCE		(1 << 1)
18 
19 struct tegra_vde_h264_frame {
20 	__s32 y_fd;
21 	__s32 cb_fd;
22 	__s32 cr_fd;
23 	__s32 aux_fd;
24 	__u32 y_offset;
25 	__u32 cb_offset;
26 	__u32 cr_offset;
27 	__u32 aux_offset;
28 	__u32 frame_num;
29 	__u32 flags;
30 
31 	__u32 reserved;
32 } __attribute__((packed));
33 
34 struct tegra_vde_h264_decoder_ctx {
35 	__s32 bitstream_data_fd;
36 	__u32 bitstream_data_offset;
37 
38 	__u64 dpb_frames_ptr;
39 	__u8  dpb_frames_nb;
40 	__u8  dpb_ref_frames_with_earlier_poc_nb;
41 
42 	// SPS
43 	__u8  baseline_profile;
44 	__u8  level_idc;
45 	__u8  log2_max_pic_order_cnt_lsb;
46 	__u8  log2_max_frame_num;
47 	__u8  pic_order_cnt_type;
48 	__u8  direct_8x8_inference_flag;
49 	__u8  pic_width_in_mbs;
50 	__u8  pic_height_in_mbs;
51 
52 	// PPS
53 	__u8  pic_init_qp;
54 	__u8  deblocking_filter_control_present_flag;
55 	__u8  constrained_intra_pred_flag;
56 	__u8  chroma_qp_index_offset;
57 	__u8  pic_order_present_flag;
58 
59 	// Slice header
60 	__u8  num_ref_idx_l0_active_minus1;
61 	__u8  num_ref_idx_l1_active_minus1;
62 
63 	__u32 reserved;
64 } __attribute__((packed));
65 
66 #define VDE_IOCTL_BASE			('v' + 0x20)
67 
68 #define VDE_IO(nr)			_IO(VDE_IOCTL_BASE, nr)
69 #define VDE_IOR(nr, type)		_IOR(VDE_IOCTL_BASE, nr, type)
70 #define VDE_IOW(nr, type)		_IOW(VDE_IOCTL_BASE, nr, type)
71 #define VDE_IOWR(nr, type)		_IOWR(VDE_IOCTL_BASE, nr, type)
72 
73 #define TEGRA_VDE_DECODE_H264		0x00
74 
75 #define TEGRA_VDE_IOCTL_DECODE_H264	\
76 	VDE_IOW(TEGRA_VDE_DECODE_H264, struct tegra_vde_h264_decoder_ctx)
77 
78 #endif // _UAPI_TEGRA_VDE_H_
79