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