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