msmb_camera.h revision b562c238e74c679409fca91c01de03b91a104c30
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
119/* The msm_v4l2_event_data structure should match the
120 * v4l2_event.u.data field.
121 * should not exceed 16 elements */
122struct msm_v4l2_event_data {
123	/*word 0*/
124	unsigned int command;
125	/*word 1*/
126	unsigned int status;
127	/*word 2*/
128	unsigned int session_id;
129	/*word 3*/
130	unsigned int stream_id;
131	/*word 4*/
132	unsigned int map_op;
133	/*word 5*/
134	unsigned int map_buf_idx;
135	/*word 6*/
136	unsigned int notify;
137	/*word 7*/
138	unsigned int arg_value;
139	/*word 8*/
140	unsigned int ret_value;
141	/*word 9*/
142	unsigned int v4l2_event_type;
143	/*word 10*/
144	unsigned int v4l2_event_id;
145	/*word 11*/
146	unsigned int nop5;
147	/*word 12*/
148	unsigned int nop6;
149	/*word 13*/
150	unsigned int nop7;
151	/*word 14*/
152	unsigned int nop8;
153	/*word 15*/
154	unsigned int nop9;
155};
156
157/* map to v4l2_format.fmt.raw_data */
158struct msm_v4l2_format_data {
159	enum v4l2_buf_type type;
160	unsigned int width;
161	unsigned int height;
162	unsigned int pixelformat; /* FOURCC */
163	unsigned char num_planes;
164	unsigned int plane_sizes[VIDEO_MAX_PLANES];
165};
166
167/*  MSM Four-character-code (FOURCC) */
168#define msm_v4l2_fourcc(a, b, c, d)\
169	((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) |\
170	((__u32)(d) << 24))
171
172/* Composite stats */
173#define MSM_V4L2_PIX_FMT_STATS_COMB v4l2_fourcc('S', 'T', 'C', 'M')
174/* AEC stats */
175#define MSM_V4L2_PIX_FMT_STATS_AE   v4l2_fourcc('S', 'T', 'A', 'E')
176/* AF stats */
177#define MSM_V4L2_PIX_FMT_STATS_AF   v4l2_fourcc('S', 'T', 'A', 'F')
178/* AWB stats */
179#define MSM_V4L2_PIX_FMT_STATS_AWB  v4l2_fourcc('S', 'T', 'W', 'B')
180/* IHIST stats */
181#define MSM_V4L2_PIX_FMT_STATS_IHST v4l2_fourcc('I', 'H', 'S', 'T')
182/* Column count stats */
183#define MSM_V4L2_PIX_FMT_STATS_CS   v4l2_fourcc('S', 'T', 'C', 'S')
184/* Row count stats */
185#define MSM_V4L2_PIX_FMT_STATS_RS   v4l2_fourcc('S', 'T', 'R', 'S')
186/* Bayer Grid stats */
187#define MSM_V4L2_PIX_FMT_STATS_BG   v4l2_fourcc('S', 'T', 'B', 'G')
188/* Bayer focus stats */
189#define MSM_V4L2_PIX_FMT_STATS_BF   v4l2_fourcc('S', 'T', 'B', 'F')
190/* Bayer hist stats */
191#define MSM_V4L2_PIX_FMT_STATS_BHST v4l2_fourcc('B', 'H', 'S', 'T')
192
193enum smmu_attach_mode {
194	NON_SECURE_MODE,
195	SECURE_MODE,
196	MAX_PROTECTION_MODE,
197};
198
199struct msm_camera_smmu_attach_type {
200	enum smmu_attach_mode attach;
201};
202
203struct msm_camera_user_buf_cont_t {
204	unsigned int buf_cnt;
205	unsigned int buf_idx[MSM_CAMERA_MAX_USER_BUFF_CNT];
206};
207
208#endif /* __LINUX_MSMB_CAMERA_H */
209