1 #ifndef __UAPI_LINUX_MSMB_CAMERA_H
2 #define __UAPI_LINUX_MSMB_CAMERA_H
3 
4 #include <linux/videodev2.h>
5 #include <linux/types.h>
6 #include <linux/ioctl.h>
7 #include <linux/media.h>
8 
9 #define MSM_CAM_LOGSYNC_FILE_NAME "logsync"
10 #define MSM_CAM_LOGSYNC_FILE_BASEDIR "camera"
11 
12 #define MSM_CAM_V4L2_IOCTL_NOTIFY \
13 	_IOW('V', BASE_VIDIOC_PRIVATE + 30, struct msm_v4l2_event_data)
14 
15 #define MSM_CAM_V4L2_IOCTL_NOTIFY_META \
16 	_IOW('V', BASE_VIDIOC_PRIVATE + 31, struct msm_v4l2_event_data)
17 
18 #define MSM_CAM_V4L2_IOCTL_CMD_ACK \
19 	_IOW('V', BASE_VIDIOC_PRIVATE + 32, struct msm_v4l2_event_data)
20 
21 #define MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR \
22 	_IOW('V', BASE_VIDIOC_PRIVATE + 33, struct msm_v4l2_event_data)
23 
24 #define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG \
25 	_IOW('V', BASE_VIDIOC_PRIVATE + 34, struct msm_v4l2_event_data)
26 
27 #define MSM_CAM_V4L2_IOCTL_DAEMON_DISABLED \
28 	_IOW('V', BASE_VIDIOC_PRIVATE + 35, struct msm_v4l2_event_data)
29 
30 #define QCAMERA_VNODE_GROUP_ID	MEDIA_ENT_F_IO_V4L
31 #define MSM_CAMERA_NAME			"msm_camera"
32 #define MSM_CONFIGURATION_NAME	"msm_config"
33 
34 //#define MSM_CAMERA_SUBDEV_BASE         (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
35 #define MSM_CAMERA_SUBDEV_BASE         (MEDIA_ENT_F_OLD_BASE + 0xF00)
36 #define MSM_CAMERA_SUBDEV_CSIPHY       (MSM_CAMERA_SUBDEV_BASE + 0)
37 //#define MSM_CAMERA_SUBDEV_CSID         (MSM_CAMERA_SUBDEV_BASE + 1)
38 #define MSM_CAMERA_SUBDEV_CSID         (MSM_CAMERA_SUBDEV_BASE + 13)
39 #define MSM_CAMERA_SUBDEV_ISPIF        (MSM_CAMERA_SUBDEV_BASE + 2)
40 #define MSM_CAMERA_SUBDEV_VFE          (MSM_CAMERA_SUBDEV_BASE + 3)
41 #define MSM_CAMERA_SUBDEV_AXI          (MSM_CAMERA_SUBDEV_BASE + 4)
42 #define MSM_CAMERA_SUBDEV_VPE          (MSM_CAMERA_SUBDEV_BASE + 5)
43 #define MSM_CAMERA_SUBDEV_SENSOR       (MSM_CAMERA_SUBDEV_BASE + 6)
44 #define MSM_CAMERA_SUBDEV_ACTUATOR     (MSM_CAMERA_SUBDEV_BASE + 7)
45 #define MSM_CAMERA_SUBDEV_EEPROM       (MSM_CAMERA_SUBDEV_BASE + 8)
46 #define MSM_CAMERA_SUBDEV_CPP          (MSM_CAMERA_SUBDEV_BASE + 9)
47 #define MSM_CAMERA_SUBDEV_CCI          (MSM_CAMERA_SUBDEV_BASE + 10)
48 #define MSM_CAMERA_SUBDEV_LED_FLASH    (MSM_CAMERA_SUBDEV_BASE + 11)
49 #define MSM_CAMERA_SUBDEV_STROBE_FLASH (MSM_CAMERA_SUBDEV_BASE + 12)
50 #define MSM_CAMERA_SUBDEV_BUF_MNGR     (MSM_CAMERA_SUBDEV_BASE + 1)
51 //#define MSM_CAMERA_SUBDEV_BUF_MNGR     (MSM_CAMERA_SUBDEV_BASE + 13)
52 #define MSM_CAMERA_SUBDEV_SENSOR_INIT  (MSM_CAMERA_SUBDEV_BASE + 14)
53 #define MSM_CAMERA_SUBDEV_OIS          (MSM_CAMERA_SUBDEV_BASE + 15)
54 #define MSM_CAMERA_SUBDEV_FLASH        (MSM_CAMERA_SUBDEV_BASE + 16)
55 #define MSM_CAMERA_SUBDEV_IR_LED       (MSM_CAMERA_SUBDEV_BASE + 17)
56 #define MSM_CAMERA_SUBDEV_IR_CUT       (MSM_CAMERA_SUBDEV_BASE + 18)
57 #define MSM_CAMERA_SUBDEV_EXT          (MSM_CAMERA_SUBDEV_BASE + 19)
58 #define MSM_CAMERA_SUBDEV_TOF          (MSM_CAMERA_SUBDEV_BASE + 20)
59 #define MSM_CAMERA_SUBDEV_LASER_LED    (MSM_CAMERA_SUBDEV_BASE + 21)
60 #define MSM_MAX_CAMERA_SENSORS  5
61 
62 /* The below macro is defined to put an upper limit on maximum
63  * number of buffer requested per stream. In case of extremely
64  * large value for number of buffer due to data structure corruption
65  * we return error to avoid integer overflow. Group processing
66  * can have max of 9 groups of 8 bufs each. This value may be
67  * configured in future
68  */
69 #define MSM_CAMERA_MAX_STREAM_BUF 72
70 
71 /* Max batch size of processing */
72 #define MSM_CAMERA_MAX_USER_BUFF_CNT 16
73 
74 /* featur base */
75 #define MSM_CAMERA_FEATURE_BASE     0x00010000
76 #define MSM_CAMERA_FEATURE_SHUTDOWN (MSM_CAMERA_FEATURE_BASE + 1)
77 
78 #define MSM_CAMERA_STATUS_BASE      0x00020000
79 #define MSM_CAMERA_STATUS_FAIL      (MSM_CAMERA_STATUS_BASE + 1)
80 #define MSM_CAMERA_STATUS_SUCCESS   (MSM_CAMERA_STATUS_BASE + 2)
81 
82 /* event type */
83 #define MSM_CAMERA_V4L2_EVENT_TYPE (V4L2_EVENT_PRIVATE_START + 0x00002000)
84 
85 /* event id */
86 #define MSM_CAMERA_EVENT_MIN    0
87 #define MSM_CAMERA_NEW_SESSION  (MSM_CAMERA_EVENT_MIN + 1)
88 #define MSM_CAMERA_DEL_SESSION  (MSM_CAMERA_EVENT_MIN + 2)
89 #define MSM_CAMERA_SET_PARM     (MSM_CAMERA_EVENT_MIN + 3)
90 #define MSM_CAMERA_GET_PARM     (MSM_CAMERA_EVENT_MIN + 4)
91 #define MSM_CAMERA_MAPPING_CFG  (MSM_CAMERA_EVENT_MIN + 5)
92 #define MSM_CAMERA_MAPPING_SES  (MSM_CAMERA_EVENT_MIN + 6)
93 #define MSM_CAMERA_MSM_NOTIFY   (MSM_CAMERA_EVENT_MIN + 7)
94 #define MSM_CAMERA_EVENT_MAX    (MSM_CAMERA_EVENT_MIN + 8)
95 
96 /* data.command */
97 #define MSM_CAMERA_PRIV_S_CROP			(V4L2_CID_PRIVATE_BASE + 1)
98 #define MSM_CAMERA_PRIV_G_CROP			(V4L2_CID_PRIVATE_BASE + 2)
99 #define MSM_CAMERA_PRIV_G_FMT			(V4L2_CID_PRIVATE_BASE + 3)
100 #define MSM_CAMERA_PRIV_S_FMT			(V4L2_CID_PRIVATE_BASE + 4)
101 #define MSM_CAMERA_PRIV_TRY_FMT			(V4L2_CID_PRIVATE_BASE + 5)
102 #define MSM_CAMERA_PRIV_METADATA		(V4L2_CID_PRIVATE_BASE + 6)
103 #define MSM_CAMERA_PRIV_QUERY_CAP		(V4L2_CID_PRIVATE_BASE + 7)
104 #define MSM_CAMERA_PRIV_STREAM_ON		(V4L2_CID_PRIVATE_BASE + 8)
105 #define MSM_CAMERA_PRIV_STREAM_OFF		(V4L2_CID_PRIVATE_BASE + 9)
106 #define MSM_CAMERA_PRIV_NEW_STREAM		(V4L2_CID_PRIVATE_BASE + 10)
107 #define MSM_CAMERA_PRIV_DEL_STREAM		(V4L2_CID_PRIVATE_BASE + 11)
108 #define MSM_CAMERA_PRIV_SHUTDOWN		(V4L2_CID_PRIVATE_BASE + 12)
109 #define MSM_CAMERA_PRIV_STREAM_INFO_SYNC \
110 	(V4L2_CID_PRIVATE_BASE + 13)
111 #define MSM_CAMERA_PRIV_G_SESSION_ID (V4L2_CID_PRIVATE_BASE + 14)
112 #define MSM_CAMERA_PRIV_CMD_MAX  20
113 
114 /* data.status - success */
115 #define MSM_CAMERA_CMD_SUCCESS      0x00000001
116 #define MSM_CAMERA_BUF_MAP_SUCCESS  0x00000002
117 
118 /* data.status - error */
119 #define MSM_CAMERA_ERR_EVT_BASE 0x00010000
120 #define MSM_CAMERA_ERR_CMD_FAIL		(MSM_CAMERA_ERR_EVT_BASE + 1)
121 #define MSM_CAMERA_ERR_MAPPING		(MSM_CAMERA_ERR_EVT_BASE + 2)
122 #define MSM_CAMERA_ERR_DEVICE_BUSY	(MSM_CAMERA_ERR_EVT_BASE + 3)
123 
124 /* The msm_v4l2_event_data structure should match the
125  * v4l2_event.u.data field.
126  * should not exceed 16 elements
127  */
128 struct msm_v4l2_event_data {
129 	/*word 0*/
130 	unsigned int command;
131 	/*word 1*/
132 	unsigned int status;
133 	/*word 2*/
134 	unsigned int session_id;
135 	/*word 3*/
136 	unsigned int stream_id;
137 	/*word 4*/
138 	unsigned int map_op;
139 	/*word 5*/
140 	unsigned int map_buf_idx;
141 	/*word 6*/
142 	unsigned int notify;
143 	/*word 7*/
144 	unsigned int arg_value;
145 	/*word 8*/
146 	unsigned int ret_value;
147 	/*word 9*/
148 	unsigned int v4l2_event_type;
149 	/*word 10*/
150 	unsigned int v4l2_event_id;
151 	/*word 11*/
152 	unsigned int handle;
153 	/*word 12*/
154 	unsigned int nop6;
155 	/*word 13*/
156 	unsigned int nop7;
157 	/*word 14*/
158 	unsigned int nop8;
159 	/*word 15*/
160 	unsigned int nop9;
161 };
162 
163 /* map to v4l2_format.fmt.raw_data */
164 struct msm_v4l2_format_data {
165 	enum v4l2_buf_type type;
166 	unsigned int width;
167 	unsigned int height;
168 	unsigned int pixelformat; /* FOURCC */
169 	unsigned char num_planes;
170 	unsigned int plane_sizes[VIDEO_MAX_PLANES];
171 };
172 
173 /*  MSM Four-character-code (FOURCC) */
174 #define msm_v4l2_fourcc(a, b, c, d)\
175 	((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) |\
176 	((__u32)(d) << 24))
177 
178 /* Composite stats */
179 #define MSM_V4L2_PIX_FMT_STATS_COMB v4l2_fourcc('S', 'T', 'C', 'M')
180 /* AEC stats */
181 #define MSM_V4L2_PIX_FMT_STATS_AE   v4l2_fourcc('S', 'T', 'A', 'E')
182 /* AF stats */
183 #define MSM_V4L2_PIX_FMT_STATS_AF   v4l2_fourcc('S', 'T', 'A', 'F')
184 /* AWB stats */
185 #define MSM_V4L2_PIX_FMT_STATS_AWB  v4l2_fourcc('S', 'T', 'W', 'B')
186 /* IHIST stats */
187 #define MSM_V4L2_PIX_FMT_STATS_IHST v4l2_fourcc('I', 'H', 'S', 'T')
188 /* Column count stats */
189 #define MSM_V4L2_PIX_FMT_STATS_CS   v4l2_fourcc('S', 'T', 'C', 'S')
190 /* Row count stats */
191 #define MSM_V4L2_PIX_FMT_STATS_RS   v4l2_fourcc('S', 'T', 'R', 'S')
192 /* Bayer Grid stats */
193 #define MSM_V4L2_PIX_FMT_STATS_BG   v4l2_fourcc('S', 'T', 'B', 'G')
194 /* Bayer focus stats */
195 #define MSM_V4L2_PIX_FMT_STATS_BF   v4l2_fourcc('S', 'T', 'B', 'F')
196 /* Bayer hist stats */
197 #define MSM_V4L2_PIX_FMT_STATS_BHST v4l2_fourcc('B', 'H', 'S', 'T')
198 
199 enum smmu_attach_mode {
200 	NON_SECURE_MODE = 0x01,
201 	SECURE_MODE = 0x02,
202 	MAX_PROTECTION_MODE = 0x03,
203 };
204 
205 struct msm_camera_smmu_attach_type {
206 	enum smmu_attach_mode attach;
207 };
208 
209 struct msm_camera_user_buf_cont_t {
210 	unsigned int buf_cnt;
211 	unsigned int buf_idx[MSM_CAMERA_MAX_USER_BUFF_CNT];
212 };
213 
214 struct msm_camera_return_buf {
215 	__u32 index;
216 	__u32 reserved;
217 };
218 
219 #define MSM_CAMERA_PRIV_IOCTL_ID_BASE 0
220 #define MSM_CAMERA_PRIV_IOCTL_ID_RETURN_BUF 1
221 
222 struct msm_camera_private_ioctl_arg {
223 	__u32 id;
224 	__u32 size;
225 	__u32 result;
226 	__u32 reserved;
227 	__u64 ioctl_ptr;
228 };
229 
230 #define VIDIOC_MSM_CAMERA_PRIVATE_IOCTL_CMD \
231 	_IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_camera_private_ioctl_arg)
232 
233 #endif
234 
235