1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef __MSM_VIDC_PRIVATE_H__
3 #define __MSM_VIDC_PRIVATE_H__
4 
5 #include <linux/videodev2.h>
6 
7 /* VIDIOC private video command */
8 #define VIDIOC_VIDEO_CMD \
9 		_IOWR('V', BASE_VIDIOC_PRIVATE_VIDEO, struct msm_vidc_arg)
10 
11 /* Commands type */
12 #define MSM_VIDC_CMD_START			0x10000000
13 #define MSM_CVP_START				(MSM_VIDC_CMD_START + 0x1000)
14 
15 /*
16  * userspace clients pass one of the below arguments type
17  * in struct msm_vidc_arg (@type field).
18  */
19 
20 /*
21  * MSM_CVP_GET_SESSION_INFO - this argument type is used to
22  *          get the session information from driver. it passes
23  *          struct msm_cvp_session_info {}
24  */
25 #define MSM_CVP_GET_SESSION_INFO	(MSM_CVP_START + 1)
26 
27 /*
28  * MSM_CVP_REQUEST_POWER - this argument type is used to
29  *          set the power required to driver. it passes
30  *          struct msm_cvp_request_power {}
31  */
32 #define MSM_CVP_REQUEST_POWER		(MSM_CVP_START + 2)
33 
34 /*
35  * MSM_CVP_REGISTER_BUFFER - this argument type is used to
36  *          register the buffer to driver. it passes
37  *          struct msm_cvp_buffer {}
38  */
39 #define MSM_CVP_REGISTER_BUFFER		(MSM_CVP_START + 3)
40 
41 /*
42  * MSM_CVP_REGISTER_BUFFER - this argument type is used to
43  *          unregister the buffer to driver. it passes
44  *          struct msm_cvp_buffer {}
45  */
46 #define MSM_CVP_UNREGISTER_BUFFER	(MSM_CVP_START + 4)
47 
48 /* flags */
49 #define MSM_CVP_FLAG_UNSECURE			0x00000000
50 #define MSM_CVP_FLAG_SECURE			0x00000001
51 
52 /* buffer type */
53 #define MSM_CVP_BUFTYPE_INPUT			0x00000001
54 #define MSM_CVP_BUFTYPE_OUTPUT			0x00000002
55 #define MSM_CVP_BUFTYPE_INTERNAL_1		0x00000003
56 #define MSM_CVP_BUFTYPE_INTERNAL_2		0x00000004
57 
58 
59 /**
60  * struct msm_cvp_session_info - session information
61  * @session_id:    current session id
62  */
63 struct msm_cvp_session_info {
64 	unsigned int session_id;
65 	unsigned int reserved[10];
66 };
67 
68 /**
69  * struct msm_cvp_request_power - power / clock data information
70  * @clock_cycles_a:  clock cycles per second required for hardware_a
71  * @clock_cycles_b:  clock cycles per second required for hardware_b
72  * @ddr_bw:        bandwidth required for ddr in bps
73  * @sys_cache_bw:  bandwidth required for system cache in bps
74  */
75 struct msm_cvp_request_power {
76 	unsigned int clock_cycles_a;
77 	unsigned int clock_cycles_b;
78 	unsigned int ddr_bw;
79 	unsigned int sys_cache_bw;
80 	unsigned int reserved[8];
81 };
82 
83 /**
84  * struct msm_cvp_buffer - buffer information to be registered
85  * @index:         index of buffer
86  * @type:          buffer type
87  * @fd:            file descriptor of buffer
88  * @size:          allocated size of buffer
89  * @offset:        offset in fd from where usable data starts
90  * @pixelformat:   fourcc format
91  * @flags:         buffer flags
92  */
93 struct msm_cvp_buffer {
94 	unsigned int index;
95 	unsigned int type;
96 	unsigned int fd;
97 	unsigned int size;
98 	unsigned int offset;
99 	unsigned int pixelformat;
100 	unsigned int flags;
101 	unsigned int reserved[5];
102 };
103 
104 /**
105  * struct msm_vidc_arg - argument passed with VIDIOC_VIDEO_CMD
106  * @type:          command type
107  * @session:       session information
108  * @req_power:     power information
109  * @regbuf:        buffer to be registered
110  * @unregbuf:      buffer to be unregistered
111  */
112 struct msm_vidc_arg {
113 	unsigned int type;
114 	union data_t {
115 		struct msm_cvp_session_info session;
116 		struct msm_cvp_request_power req_power;
117 		struct msm_cvp_buffer regbuf;
118 		struct msm_cvp_buffer unregbuf;
119 	} data;
120 	unsigned int reserved[12];
121 };
122 
123 #endif
124