Home | History | Annotate | Download | only in media
      1 /* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
      2  *
      3  * This program is free software; you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License version 2 and
      5  * only version 2 as published by the Free Software Foundation.
      6  *
      7  * This program is distributed in the hope that it will be useful,
      8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10  * GNU General Public License for more details.
     11  *
     12  * You should have received a copy of the GNU General Public License
     13  * along with this program; if not, write to the Free Software
     14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
     15  * 02110-1301, USA.
     16  *
     17  */
     18 
     19 #ifndef __LINUX_MSM_CAMERA_H
     20 #define __LINUX_MSM_CAMERA_H
     21 
     22 #include <linux/types.h>
     23 #include <asm/sizes.h>
     24 #include <linux/ioctl.h>
     25 
     26 #define MSM_CAM_IOCTL_MAGIC 'm'
     27 
     28 #define MSM_CAM_IOCTL_GET_SENSOR_INFO \
     29 	_IOR(MSM_CAM_IOCTL_MAGIC, 1, struct msm_camsensor_info *)
     30 
     31 #define MSM_CAM_IOCTL_REGISTER_PMEM \
     32 	_IOW(MSM_CAM_IOCTL_MAGIC, 2, struct msm_pmem_info *)
     33 
     34 #define MSM_CAM_IOCTL_UNREGISTER_PMEM \
     35 	_IOW(MSM_CAM_IOCTL_MAGIC, 3, unsigned)
     36 
     37 #define MSM_CAM_IOCTL_CTRL_COMMAND \
     38 	_IOW(MSM_CAM_IOCTL_MAGIC, 4, struct msm_ctrl_cmd *)
     39 
     40 #define MSM_CAM_IOCTL_CONFIG_VFE  \
     41 	_IOW(MSM_CAM_IOCTL_MAGIC, 5, struct msm_camera_vfe_cfg_cmd *)
     42 
     43 #define MSM_CAM_IOCTL_GET_STATS \
     44 	_IOR(MSM_CAM_IOCTL_MAGIC, 6, struct msm_camera_stats_event_ctrl *)
     45 
     46 #define MSM_CAM_IOCTL_GETFRAME \
     47 	_IOR(MSM_CAM_IOCTL_MAGIC, 7, struct msm_camera_get_frame *)
     48 
     49 #define MSM_CAM_IOCTL_ENABLE_VFE \
     50 	_IOW(MSM_CAM_IOCTL_MAGIC, 8, struct camera_enable_cmd *)
     51 
     52 #define MSM_CAM_IOCTL_CTRL_CMD_DONE \
     53 	_IOW(MSM_CAM_IOCTL_MAGIC, 9, struct camera_cmd *)
     54 
     55 #define MSM_CAM_IOCTL_CONFIG_CMD \
     56 	_IOW(MSM_CAM_IOCTL_MAGIC, 10, struct camera_cmd *)
     57 
     58 #define MSM_CAM_IOCTL_DISABLE_VFE \
     59 	_IOW(MSM_CAM_IOCTL_MAGIC, 11, struct camera_enable_cmd *)
     60 
     61 #define MSM_CAM_IOCTL_PAD_REG_RESET2 \
     62 	_IOW(MSM_CAM_IOCTL_MAGIC, 12, struct camera_enable_cmd *)
     63 
     64 #define MSM_CAM_IOCTL_VFE_APPS_RESET \
     65 	_IOW(MSM_CAM_IOCTL_MAGIC, 13, struct camera_enable_cmd *)
     66 
     67 #define MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER \
     68 	_IOW(MSM_CAM_IOCTL_MAGIC, 14, struct camera_enable_cmd *)
     69 
     70 #define MSM_CAM_IOCTL_RELEASE_STATS_BUFFER \
     71 	_IOW(MSM_CAM_IOCTL_MAGIC, 15, struct msm_stats_buf *)
     72 
     73 #define MSM_CAM_IOCTL_AXI_CONFIG \
     74 	_IOW(MSM_CAM_IOCTL_MAGIC, 16, struct msm_camera_vfe_cfg_cmd *)
     75 
     76 #define MSM_CAM_IOCTL_GET_PICTURE \
     77 	_IOW(MSM_CAM_IOCTL_MAGIC, 17, struct msm_camera_ctrl_cmd *)
     78 
     79 #define MSM_CAM_IOCTL_SET_CROP \
     80 	_IOW(MSM_CAM_IOCTL_MAGIC, 18, struct crop_info *)
     81 
     82 #define MSM_CAM_IOCTL_PP \
     83 	_IOW(MSM_CAM_IOCTL_MAGIC, 19, uint8_t *)
     84 
     85 #define MSM_CAM_IOCTL_PP_DONE \
     86 	_IOW(MSM_CAM_IOCTL_MAGIC, 20, struct msm_snapshot_pp_status *)
     87 
     88 #define MSM_CAM_IOCTL_SENSOR_IO_CFG \
     89 	_IOW(MSM_CAM_IOCTL_MAGIC, 21, struct sensor_cfg_data *)
     90 
     91 #define MSM_CAMERA_LED_OFF  0
     92 #define MSM_CAMERA_LED_LOW  1
     93 #define MSM_CAMERA_LED_HIGH 2
     94 
     95 #define MSM_CAM_IOCTL_FLASH_LED_CFG \
     96 	_IOW(MSM_CAM_IOCTL_MAGIC, 22, unsigned *)
     97 
     98 #define MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME \
     99 	_IO(MSM_CAM_IOCTL_MAGIC, 23)
    100 
    101 #define MSM_CAM_IOCTL_CTRL_COMMAND_2 \
    102 	_IOW(MSM_CAM_IOCTL_MAGIC, 24, struct msm_ctrl_cmd *)
    103 
    104 #define MSM_CAM_IOCTL_ENABLE_OUTPUT_IND \
    105 	_IOW(MSM_CAM_IOCTL_MAGIC, 25, uint32_t *)
    106 
    107 #define MSM_CAM_IOCTL_AF_CTRL \
    108 	_IOR(MSM_CAM_IOCTL_MAGIC, 26, struct msm_ctrl_cmt_t *)
    109 #define MSM_CAM_IOCTL_AF_CTRL_DONE \
    110 	_IOW(MSM_CAM_IOCTL_MAGIC, 27, struct msm_ctrl_cmt_t *)
    111 
    112 #define MAX_SENSOR_NUM  3
    113 #define MAX_SENSOR_NAME 32
    114 
    115 #define PP_SNAP		1
    116 #define PP_RAW_SNAP	(1<<1)
    117 #define PP_PREV		(1<<2)
    118 #define PP_MASK		(PP_SNAP|PP_RAW_SNAP|PP_PREV)
    119 
    120 #define MSM_CAM_CTRL_CMD_DONE  0
    121 #define MSM_CAM_SENSOR_VFE_CMD 1
    122 
    123 /*****************************************************
    124  *  structure
    125  *****************************************************/
    126 
    127 /* define five type of structures for userspace <==> kernel
    128  * space communication:
    129  * command 1 - 2 are from userspace ==> kernel
    130  * command 3 - 4 are from kernel ==> userspace
    131  *
    132  * 1. control command: control command(from control thread),
    133  *                     control status (from config thread);
    134  */
    135 struct msm_ctrl_cmd {
    136 	uint16_t type;
    137 	uint16_t length;
    138 	void *value;
    139 	uint16_t status;
    140 	uint32_t timeout_ms;
    141 	int resp_fd; /* FIXME: to be used by the kernel, pass-through for now */
    142 };
    143 
    144 struct msm_vfe_evt_msg {
    145 	unsigned short type; /* 1 == event (RPC), 0 == message (adsp) */
    146 	unsigned short msg_id;
    147 	unsigned int len; /* size in, number of bytes out */
    148 	void *data;
    149 };
    150 
    151 #define MSM_CAM_RESP_CTRL         0
    152 #define MSM_CAM_RESP_STAT_EVT_MSG 1
    153 #define MSM_CAM_RESP_V4L2         2
    154 #define MSM_CAM_RESP_MAX          3
    155 
    156 /* this one is used to send ctrl/status up to config thread */
    157 struct msm_stats_event_ctrl {
    158 	/* 0 - ctrl_cmd from control thread,
    159 	 * 1 - stats/event kernel,
    160 	 * 2 - V4L control or read request */
    161 	int resptype;
    162 	int timeout_ms;
    163 	struct msm_ctrl_cmd ctrl_cmd;
    164 	/* struct  vfe_event_t  stats_event; */
    165 	struct msm_vfe_evt_msg stats_event;
    166 };
    167 
    168 /* 2. config command: config command(from config thread); */
    169 struct msm_camera_cfg_cmd {
    170 	/* what to config:
    171 	 * 1 - sensor config, 2 - vfe config */
    172 	uint16_t cfg_type;
    173 
    174 	/* sensor config type */
    175 	uint16_t cmd_type;
    176 	uint16_t queue;
    177 	uint16_t length;
    178 	void *value;
    179 };
    180 
    181 #define CMD_GENERAL			0
    182 #define CMD_AXI_CFG_OUT1		1
    183 #define CMD_AXI_CFG_SNAP_O1_AND_O2	2
    184 #define CMD_AXI_CFG_OUT2		3
    185 #define CMD_PICT_T_AXI_CFG		4
    186 #define CMD_PICT_M_AXI_CFG		5
    187 #define CMD_RAW_PICT_AXI_CFG		6
    188 #define CMD_STATS_AXI_CFG		7
    189 #define CMD_STATS_AF_AXI_CFG		8
    190 #define CMD_FRAME_BUF_RELEASE		9
    191 #define CMD_PREV_BUF_CFG		10
    192 #define CMD_SNAP_BUF_RELEASE		11
    193 #define CMD_SNAP_BUF_CFG		12
    194 #define CMD_STATS_DISABLE		13
    195 #define CMD_STATS_AEC_AWB_ENABLE	14
    196 #define CMD_STATS_AF_ENABLE		15
    197 #define CMD_STATS_BUF_RELEASE		16
    198 #define CMD_STATS_AF_BUF_RELEASE	17
    199 #define CMD_STATS_ENABLE        18
    200 #define UPDATE_STATS_INVALID		19
    201 
    202 #define CMD_STATS_AEC_ENABLE		20
    203 #define CMD_STATS_AWB_ENABLE		21
    204 #define CMD_STATS_AEC_AXI_CFG		22
    205 #define CMD_STATS_AWB_AXI_CFG		23
    206 #define CMD_STATS_RS_AXI_CFG		24
    207 #define CMD_STATS_CS_AXI_CFG		25
    208 #define CMD_STATS_IHIST_AXI_CFG		26
    209 #define CMD_STATS_SKIN_AXI_CFG		27
    210 #define CMD_STATS_AEC_BUF_RELEASE	28
    211 #define CMD_STATS_AWB_BUF_RELEASE	29
    212 #define CMD_STATS_RS_BUF_RELEASE	30
    213 #define CMD_STATS_CS_BUF_RELEASE	31
    214 #define CMD_STATS_IHIST_BUF_RELEASE	32
    215 #define CMD_STATS_SKIN_BUF_RELEASE	33
    216 
    217 #define CMD_AXI_CFG_SNAP_GEMINI		34
    218 #define CMD_AXI_CFG_SNAP		35
    219 #define CMD_AXI_CFG_PREVIEW		36
    220 #define CMD_AXI_CFG_VIDEO		37
    221 
    222 #define CMD_STATS_IHIST_ENABLE 38
    223 #define CMD_STATS_RS_ENABLE 39
    224 #define CMD_STATS_CS_ENABLE 40
    225 #define CMD_AXI_CFG_O1_AND_O2	41 /* output1 and output2 */
    226 
    227 /* vfe config command: config command(from config thread)*/
    228 struct msm_vfe_cfg_cmd {
    229 	int cmd_type;
    230 	uint16_t length;
    231 	void *value;
    232 };
    233 
    234 #define MAX_CAMERA_ENABLE_NAME_LEN 32
    235 struct camera_enable_cmd {
    236 	char name[MAX_CAMERA_ENABLE_NAME_LEN];
    237 };
    238 
    239 #define MSM_PMEM_OUTPUT1		0
    240 #define MSM_PMEM_OUTPUT2		1
    241 #define MSM_PMEM_OUTPUT1_OUTPUT2	2
    242 #define MSM_PMEM_THUMBNAIL		3
    243 #define MSM_PMEM_MAINIMG		4
    244 #define MSM_PMEM_RAW_MAINIMG		5
    245 #define MSM_PMEM_AEC_AWB		6
    246 #define MSM_PMEM_AF			7
    247 #define MSM_PMEM_AEC			8
    248 #define MSM_PMEM_AWB			9
    249 #define MSM_PMEM_RS		    	10
    250 #define MSM_PMEM_CS	    		11
    251 #define MSM_PMEM_IHIST			12
    252 #define MSM_PMEM_SKIN			13
    253 #define MSM_PMEM_VIDEO			14
    254 #define MSM_PMEM_PREVIEW		15
    255 #define MSM_PMEM_MAX			16
    256 
    257 #define FRAME_PREVIEW_OUTPUT1		0
    258 #define FRAME_PREVIEW_OUTPUT2		1
    259 #define FRAME_SNAPSHOT			2
    260 #define FRAME_THUMBNAIL		3
    261 #define FRAME_RAW_SNAPSHOT		4
    262 #define FRAME_MAX			5
    263 
    264 struct msm_pmem_info {
    265 	int type;
    266 	int fd;
    267 	void *vaddr;
    268 	uint32_t offset;
    269 	uint32_t len;
    270 	uint32_t y_off; /* relative to offset */
    271 	uint32_t cbcr_off; /* relative to offset */
    272 	uint8_t vfe_can_write;
    273 };
    274 
    275 struct outputCfg {
    276 	uint32_t height;
    277 	uint32_t width;
    278 
    279 	uint32_t window_height_firstline;
    280 	uint32_t window_height_lastline;
    281 };
    282 
    283 #define OUTPUT_1	0
    284 #define OUTPUT_2	1
    285 #define OUTPUT_1_AND_2	2
    286 #define CAMIF_TO_AXI_VIA_OUTPUT_2		3
    287 #define OUTPUT_1_AND_CAMIF_TO_AXI_VIA_OUTPUT_2	4
    288 #define OUTPUT_2_AND_CAMIF_TO_AXI_VIA_OUTPUT_1	5
    289 #define OUTPUT_1_AND_3 6
    290 #define LAST_AXI_OUTPUT_MODE_ENUM = OUTPUT_1_AND_3            7   /* video */
    291 
    292 
    293 #define MSM_FRAME_PREV_1	0
    294 #define MSM_FRAME_PREV_2	1
    295 #define MSM_FRAME_ENC		2
    296 
    297 #define OUTPUT_TYPE_P		1
    298 #define OUTPUT_TYPE_T		2
    299 #define OUTPUT_TYPE_S		3
    300 #define OUTPUT_TYPE_V		4
    301 
    302 struct msm_frame {
    303 	int path;
    304 	unsigned long buffer;
    305 	uint32_t y_off;
    306 	uint32_t cbcr_off;
    307 	int fd;
    308 
    309 	void *cropinfo;
    310 	int croplen;
    311 };
    312 
    313 #define STAT_AEAW	0
    314 #define STAT_AF		1
    315 #define STAT_AEC	2
    316 #define STAT_AWB	3
    317 #define STAT_RS		4
    318 #define STAT_CS		5
    319 #define STAT_IHIST	6
    320 #define STAT_SKIN	7
    321 #define STAT_MAX	8
    322 
    323 struct msm_stats_buf {
    324 	int type;
    325 	unsigned long buffer;
    326 	int fd;
    327 };
    328 
    329 #define MSM_V4L2_VID_CAP_TYPE	0
    330 #define MSM_V4L2_STREAM_ON	1
    331 #define MSM_V4L2_STREAM_OFF	2
    332 #define MSM_V4L2_SNAPSHOT	3
    333 #define MSM_V4L2_QUERY_CTRL	4
    334 #define MSM_V4L2_GET_CTRL	5
    335 #define MSM_V4L2_SET_CTRL	6
    336 #define MSM_V4L2_QUERY		7
    337 #define MSM_V4L2_MAX		8
    338 
    339 struct crop_info {
    340 	void *info;
    341 	int len;
    342 };
    343 
    344 struct msm_postproc {
    345 	int ftnum;
    346 	struct msm_frame fthumnail;
    347 	int fmnum;
    348 	struct msm_frame fmain;
    349 };
    350 
    351 struct msm_snapshot_pp_status {
    352 	void *status;
    353 };
    354 
    355 #define CFG_SET_MODE			0
    356 #define CFG_SET_EFFECT			1
    357 #define CFG_START			2
    358 #define CFG_PWR_UP			3
    359 #define CFG_PWR_DOWN			4
    360 #define CFG_WRITE_EXPOSURE_GAIN		5
    361 #define CFG_SET_DEFAULT_FOCUS		6
    362 #define CFG_MOVE_FOCUS			7
    363 #define CFG_REGISTER_TO_REAL_GAIN	8
    364 #define CFG_REAL_TO_REGISTER_GAIN	9
    365 #define CFG_SET_FPS			10
    366 #define CFG_SET_PICT_FPS		11
    367 #define CFG_SET_BRIGHTNESS		12
    368 #define CFG_SET_CONTRAST		13
    369 #define CFG_SET_ZOOM			14
    370 #define CFG_SET_EXPOSURE_MODE		15
    371 #define CFG_SET_WB			16
    372 #define CFG_SET_ANTIBANDING		17
    373 #define CFG_SET_EXP_GAIN		18
    374 #define CFG_SET_PICT_EXP_GAIN		19
    375 #define CFG_SET_LENS_SHADING		20
    376 #define CFG_GET_PICT_FPS		21
    377 #define CFG_GET_PREV_L_PF		22
    378 #define CFG_GET_PREV_P_PL		23
    379 #define CFG_GET_PICT_L_PF		24
    380 #define CFG_GET_PICT_P_PL		25
    381 #define CFG_GET_AF_MAX_STEPS		26
    382 #define CFG_GET_PICT_MAX_EXP_LC		27
    383 #define CFG_MAX				28
    384 
    385 #define MOVE_NEAR	0
    386 #define MOVE_FAR	1
    387 
    388 #define SENSOR_PREVIEW_MODE		0
    389 #define SENSOR_SNAPSHOT_MODE		1
    390 #define SENSOR_RAW_SNAPSHOT_MODE	2
    391 
    392 #define SENSOR_QTR_SIZE			0
    393 #define SENSOR_FULL_SIZE		1
    394 #define SENSOR_INVALID_SIZE		2
    395 
    396 #define CAMERA_EFFECT_OFF		0
    397 #define CAMERA_EFFECT_MONO		1
    398 #define CAMERA_EFFECT_NEGATIVE		2
    399 #define CAMERA_EFFECT_SOLARIZE		3
    400 #define CAMERA_EFFECT_PASTEL		4
    401 #define CAMERA_EFFECT_MOSAIC		5
    402 #define CAMERA_EFFECT_RESIZE		6
    403 #define CAMERA_EFFECT_SEPIA		7
    404 #define CAMERA_EFFECT_POSTERIZE		8
    405 #define CAMERA_EFFECT_WHITEBOARD	9
    406 #define CAMERA_EFFECT_BLACKBOARD	10
    407 #define CAMERA_EFFECT_AQUA		11
    408 #define CAMERA_EFFECT_MAX		12
    409 
    410 struct sensor_pict_fps {
    411 	uint16_t prevfps;
    412 	uint16_t pictfps;
    413 };
    414 
    415 struct exp_gain_cfg {
    416 	uint16_t gain;
    417 	uint32_t line;
    418 };
    419 
    420 struct focus_cfg {
    421 	int32_t steps;
    422 	int dir;
    423 };
    424 
    425 struct fps_cfg {
    426 	uint16_t f_mult;
    427 	uint16_t fps_div;
    428 	uint32_t pict_fps_div;
    429 };
    430 
    431 struct sensor_cfg_data {
    432 	int cfgtype;
    433 	int mode;
    434 	int rs;
    435 	uint8_t max_steps;
    436 
    437 	union {
    438 		int8_t effect;
    439 		uint8_t lens_shading;
    440 		uint16_t prevl_pf;
    441 		uint16_t prevp_pl;
    442 		uint16_t pictl_pf;
    443 		uint16_t pictp_pl;
    444 		uint32_t pict_max_exp_lc;
    445 		uint16_t p_fps;
    446 		struct sensor_pict_fps gfps;
    447 		struct exp_gain_cfg exp_gain;
    448 		struct focus_cfg focus;
    449 		struct fps_cfg fps;
    450 	} cfg;
    451 };
    452 
    453 #define GET_NAME			0
    454 #define GET_PREVIEW_LINE_PER_FRAME	1
    455 #define GET_PREVIEW_PIXELS_PER_LINE	2
    456 #define GET_SNAPSHOT_LINE_PER_FRAME	3
    457 #define GET_SNAPSHOT_PIXELS_PER_LINE	4
    458 #define GET_SNAPSHOT_FPS		5
    459 #define GET_SNAPSHOT_MAX_EP_LINE_CNT	6
    460 
    461 struct msm_camsensor_info {
    462 	char name[MAX_SENSOR_NAME];
    463 	uint8_t flash_enabled;
    464 };
    465 #endif /* __LINUX_MSM_CAMERA_H */
    466