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