2 * Driver for LSI S5C73M3 (ISP for 8MP Camera)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
10 #ifndef __SLP_S5C73M3_H
11 #define __SLP_S5C73M3_H
13 #define CONFIG_CAM_DEBUG 1
15 #define cam_warn(fmt, ...) \
17 printk(KERN_WARNING "%s: " fmt, __func__, ##__VA_ARGS__); \
20 #define cam_err(fmt, ...) \
22 printk(KERN_ERR "%s: " fmt, __func__, ##__VA_ARGS__); \
25 #define cam_info(fmt, ...) \
27 printk(KERN_INFO "%s: " fmt, __func__, ##__VA_ARGS__); \
30 #ifdef CONFIG_CAM_DEBUG
31 #define CAM_DEBUG (1 << 0)
32 #define CAM_TRACE (1 << 1)
33 #define CAM_I2C (1 << 2)
35 #define cam_dbg(fmt, ...) \
37 if (to_state(sd)->dbg_level & CAM_DEBUG) \
38 printk(KERN_DEBUG "%s: " fmt, \
39 __func__, ##__VA_ARGS__); \
42 #define cam_trace(fmt, ...) \
44 if (to_state(sd)->dbg_level & CAM_TRACE) \
45 printk(KERN_DEBUG "%s: " fmt, \
46 __func__, ##__VA_ARGS__); \
49 #define cam_i2c_dbg(fmt, ...) \
51 if (to_state(sd)->dbg_level & CAM_I2C) \
52 printk(KERN_DEBUG "%s: " fmt, \
53 __func__, ##__VA_ARGS__); \
56 #define cam_dbg(fmt, ...)
57 #define cam_trace(fmt, ...)
58 #define cam_i2c_dbg(fmt, ...)
61 enum s5c73m3_fw_path {
68 enum s5c73m3_prev_frmsize {
70 S5C73M3_PREVIEW_QCIF2,
76 S5C73M3_PREVIEW_800X600,
77 S5C73M3_PREVIEW_880X720,
78 S5C73M3_PREVIEW_960X720,
79 S5C73M3_PREVIEW_1008X672,
80 S5C73M3_PREVIEW_1056X704,
81 S5C73M3_PREVIEW_1184X666,
84 S5C73M3_PREVIEW_1080P,
87 S5C73M3_PREVIEW_3264X1836,
90 enum s5c73m3_cap_frmsize {
91 S5C73M3_CAPTURE_VGA, /* 640 x 480 */
92 S5C73M3_CAPTURE_WVGA, /* 800 x 480 */
93 S5C73M3_CAPTURE_960x540, /* 960 x 540 */
94 S5C73M3_CAPTURE_960x720, /* 960 x 720 */
95 S5C73M3_CAPTURE_1024X768, /* 1024 x 768 */
96 S5C73M3_CAPTURE_HD, /* 1280 x 720 */
97 S5C73M3_CAPTURE_W1MP, /* 1600 x 960 */
98 S5C73M3_CAPTURE_2MP, /* UXGA - 1600 x 1200 */
99 S5C73M3_CAPTURE_W2MP, /* 2048 x 1232 */
100 S5C73M3_CAPTURE_3MP, /* QXGA - 2048 x 1536 */
101 S5C73M3_CAPTURE_W4MP, /* WQXGA - 2560 x 1440 */
102 S5C73M3_CAPTURE_5MP, /* 2560 x 1920 */
103 S5C73M3_CAPTURE_W6MP, /* 3072 x 1856 */
104 S5C73M3_CAPTURE_7MP, /* 3072 x 2304 */
105 S5C73M3_CAPTURE_W7MP, /* WQXGA - 2560 x 1536 */
106 S5C73M3_CAPTURE_3264X2176, /* 3264 x 2176 */
107 S5C73M3_CAPTURE_8MP, /* 3264 x 2448 */
110 enum s5c73m3_isneed_flash_tristate {
111 S5C73M3_ISNEED_FLASH_OFF = 0x00,
112 S5C73M3_ISNEED_FLASH_ON = 0x01,
113 S5C73M3_ISNEED_FLASH_UNDEFINED = 0x02,
116 struct s5c73m3_control {
119 s32 minimum; /* Note signedness */
125 struct s5c73m3_frmsizeenum {
129 u8 reg_val; /* a value for category parameter */
132 struct s5c73m3_effectenum {
134 unsigned int reg_val;
138 wait_queue_head_t wait;
139 unsigned int irq; /* irq issued by ISP */
141 unsigned int int_factor;
142 unsigned int bad_fw:1;
145 struct s5c73m3_jpeg {
147 unsigned int main_size; /* Main JPEG file size */
148 unsigned int thumb_size; /* Thumbnail file size */
149 unsigned int main_offset;
150 unsigned int thumb_offset;
151 unsigned int postview_offset;
153 struct s5c73m3_fw_version {
160 struct s5c73m3_focus {
168 /* rectangle type values */
175 struct s5c73m3_exif {
177 u32 exptime; /* us */
180 int tv; /* shutter speed */
181 int bv; /* brightness */
182 int ebv; /* exposure bias */
183 int effect; /* effect(colorfx) */
190 struct s5c73m3_state {
191 struct s5c73m3_platform_data *pdata;
192 struct v4l2_subdev sd;
194 struct s5c73m3_isp isp;
196 const struct s5c73m3_frmsizeenum *preview;
197 const struct s5c73m3_frmsizeenum *capture;
199 enum v4l2_pix_format_mode format_mode;
200 enum v4l2_sensor_mode sensor_mode;
201 enum v4l2_flash_mode flash_mode;
202 enum v4l2_wb_mode wb_mode;
203 enum v4l2_scene_mode scene_mode;
217 struct s5c73m3_focus focus;
221 struct s5c73m3_jpeg jpeg;
222 struct s5c73m3_exif exif;
236 #ifdef CONFIG_CAM_DEBUG
241 #define S5C73M3_IMG_OUTPUT 0x0902
242 #define S5C73M3_HDR_OUTPUT 0x0008
243 #define S5C73M3_YUV_OUTPUT 0x0009
244 #define S5C73M3_INTERLEAVED_OUTPUT 0x000D
245 #define S5C73M3_HYBRID_OUTPUT 0x0016
247 #define S5C73M3_STILL_PRE_FLASH 0x0A00
248 #define S5C73M3_STILL_PRE_FLASH_FIRE 0x0000
249 #define S5C73M3_STILL_PRE_FLASH_NON_FIRED 0x0000
250 #define S5C73M3_STILL_PRE_FLASH_FIRED 0x0001
252 #define S5C73M3_STILL_MAIN_FLASH 0x0A02
253 #define S5C73M3_STILL_MAIN_FLASH_CANCEL 0x0001
254 #define S5C73M3_STILL_MAIN_FLASH_FIRE 0x0002
257 #define S5C73M3_ZOOM_STEP 0x0B00
260 #define S5C73M3_IMAGE_EFFECT 0x0B0A
261 #define S5C73M3_IMAGE_EFFECT_NONE 0x0001
262 #define S5C73M3_IMAGE_EFFECT_NEGATIVE 0x0002
263 #define S5C73M3_IMAGE_EFFECT_AQUA 0x0003
264 #define S5C73M3_IMAGE_EFFECT_SEPIA 0x0004
265 #define S5C73M3_IMAGE_EFFECT_MONO 0x0005
266 #define S5C73M3_IMAGE_EFFECT_SKETCH 0x0006
267 #define S5C73M3_IMAGE_EFFECT_WASHED 0x0007
268 #define S5C73M3_IMAGE_EFFECT_VINTAGE_WARM 0x0008
269 #define S5C73M3_IMAGE_EFFECT_VINTAGE_COLD 0x0009
270 #define S5C73M3_IMAGE_EFFECT_SOLARIZE 0x000A
271 #define S5C73M3_IMAGE_EFFECT_POSTERIZE 0x000B
272 #define S5C73M3_IMAGE_EFFECT_POINT_BLUE 0x000C
273 #define S5C73M3_IMAGE_EFFECT_POINT_RED_YELLOW 0x000D
274 #define S5C73M3_IMAGE_EFFECT_POINT_COLOR_3 0x000E
275 #define S5C73M3_IMAGE_EFFECT_POINT_GREEN 0x000F
276 #define S5C73M3_IMAGE_EFFECT_CARTOONIZE 0x001A
278 #define S5C73M3_IMAGE_QUALITY 0x0B0C
279 #define S5C73M3_IMAGE_QUALITY_SUPERFINE 0x0000
280 #define S5C73M3_IMAGE_QUALITY_FINE 0x0001
281 #define S5C73M3_IMAGE_QUALITY_NORMAL 0x0002
284 #define S5C73M3_FLASH_MODE 0x0B0E
285 #define S5C73M3_FLASH_MODE_OFF 0x0000
286 #define S5C73M3_FLASH_MODE_ON 0x0001
287 #define S5C73M3_FLASH_MODE_AUTO 0x0002
289 #define S5C73M3_FLASH_TORCH 0x0B12
290 #define S5C73M3_FLASH_TORCH_OFF 0x0000
291 #define S5C73M3_FLASH_TORCH_ON 0x0001
293 #define S5C73M3_AE_ISNEEDFLASH 0x0CBA
294 #define S5C73M3_AE_ISNEEDFLASH_OFF 0x0000
295 #define S5C73M3_AE_ISNEEDFLASH_ON 0x0001
298 #define S5C73M3_CHG_MODE 0x0B10
299 #define S5C73M3_DEFAULT_MODE 0x8000
301 #define S5C73M3_CHG_MODE_YUV_320_240 0x8001
302 #define S5C73M3_CHG_MODE_YUV_400_300 0x8002
303 #define S5C73M3_CHG_MODE_YUV_640_480 0x8003
304 #define S5C73M3_CHG_MODE_YUV_800_600 0x8004
305 #define S5C73M3_CHG_MODE_YUV_960_720 0x8005
306 #define S5C73M3_CHG_MODE_YUV_1280_720 0x8006
307 #define S5C73M3_CHG_MODE_YUV_1280_960 0x8007
308 #define S5C73M3_CHG_MODE_YUV_1600_1200 0x8008
309 #define S5C73M3_CHG_MODE_YUV_1632_1224 0x8009
310 #define S5C73M3_CHG_MODE_YUV_1920_1080 0x800A
311 #define S5C73M3_CHG_MODE_YUV_1920_1440 0x800B
312 #define S5C73M3_CHG_MODE_YUV_2304_1296 0x800C
313 #define S5C73M3_CHG_MODE_YUV_2304_1728 0x800D
314 #define S5C73M3_CHG_MODE_JPEG_640_480 0x0010
315 #define S5C73M3_CHG_MODE_JPEG_800_450 0x0020
316 #define S5C73M3_CHG_MODE_JPEG_800_600 0x0030
317 #define S5C73M3_CHG_MODE_JPEG_1600_960 0x0040
318 #define S5C73M3_CHG_MODE_JPEG_1600_1200 0x0050
319 #define S5C73M3_CHG_MODE_JPEG_2048_1152 0x0060
320 #define S5C73M3_CHG_MODE_JPEG_2048_1536 0x0070
321 #define S5C73M3_CHG_MODE_JPEG_2560_1440 0x0080
322 #define S5C73M3_CHG_MODE_JPEG_2560_1920 0x0090
323 #define S5C73M3_CHG_MODE_JPEG_3072_1728 0x00A0
324 #define S5C73M3_CHG_MODE_JPEG_3264_2304 0x00B0
325 #define S5C73M3_CHG_MODE_JPEG_3264_1836 0x00C0
326 #define S5C73M3_CHG_MODE_JPEG_3264_2448 0x00D0
329 #define S5C73M3_AF_CON 0x0E00
330 #define S5C73M3_AF_CON_STOP 0x0000
331 #define S5C73M3_AF_CON_SCAN 0x0001/*AF_SCAN:Full Search*/
332 #define S5C73M3_AF_CON_START 0x0002/*AF_START:Fast Search*/
334 #define S5C73M3_AF_STATUS 0x5E80
336 #define S5C73M3_AF_TOUCH_AF 0x0E0A
338 #define S5C73M3_AF_CAL 0x0E06
340 #define S5C73M3_CAF_STATUS_FIND_SEARCHING_DIR 0x0001
341 #define S5C73M3_CAF_STATUS_FOCUSING 0x0002
342 #define S5C73M3_CAF_STATUS_FOCUSED 0x0003
343 #define S5C73M3_CAF_STATUS_UNFOCUSED 0x0004
345 #define S5C73M3_AF_STATUS_INVALID 0x0010
346 #define S5C73M3_AF_STATUS_FOCUSING 0x0020
347 #define S5C73M3_AF_STATUS_FOCUSED 0x0030/*SUCCESS*/
348 #define S5C73M3_AF_STATUS_UNFOCUSED 0x0040/*FAIL*/
350 #define S5C73M3_AF_TOUCH_POSITION 0x5E8E
352 #define S5C73M3_AF_FACE_ZOOM 0x0E10
354 #define S5C73M3_AF_MODE 0x0E02
355 #define S5C73M3_AF_MODE_NORMAL 0x0000
356 #define S5C73M3_AF_MODE_MACRO 0x0001
357 #define S5C73M3_AF_MODE_MOVIE_CAF_START 0x0002
358 #define S5C73M3_AF_MODE_MOVIE_CAF_STOP 0x0003
359 #define S5C73M3_AF_MODE_PREVIEW_CAF_START 0x0004
360 #define S5C73M3_AF_MODE_PREVIEW_CAF_STOP 0x0005
362 #define S5C73M3_AF_SOFTLANDING 0x0E16
363 #define S5C73M3_AF_SOFTLANDING_ON 0x0000
365 #define S5C73M3_FACE_DET 0x0E0C
366 #define S5C73M3_FACE_DET_OFF 0x0000
367 #define S5C73M3_FACE_DET_ON 0x0001
369 #define S5C73M3_FACE_DET_OSD 0x0E0E
370 #define S5C73M3_FACE_DET_OSD_OFF 0x0000
371 #define S5C73M3_FACE_DET_OSD_ON 0x0001
373 #define S5C73M3_AE_CON 0x0C00
374 #define S5C73M3_AE_STOP 0x0000/*LOCK*/
375 #define S5C73M3_AE_START 0x0001/*UNLOCK*/
377 #define S5C73M3_ISO 0x0C02
378 #define S5C73M3_ISO_AUTO 0x0000
379 #define S5C73M3_ISO_100 0x0001
380 #define S5C73M3_ISO_200 0x0002
381 #define S5C73M3_ISO_400 0x0003
382 #define S5C73M3_ISO_800 0x0004
383 #define S5C73M3_ISO_SPORTS 0x0005
384 #define S5C73M3_ISO_NIGHT 0x0006
385 #define S5C73M3_ISO_INDOOR 0x0007
387 #define S5C73M3_EV 0x0C04
388 #define S5C73M3_EV_M20 0x0000
389 #define S5C73M3_EV_M15 0x0001
390 #define S5C73M3_EV_M10 0x0002
391 #define S5C73M3_EV_M05 0x0003
392 #define S5C73M3_EV_ZERO 0x0004
393 #define S5C73M3_EV_P05 0x0005
394 #define S5C73M3_EV_P10 0x0006
395 #define S5C73M3_EV_P15 0x0007
396 #define S5C73M3_EV_P20 0x0008
398 #define S5C73M3_METER 0x0C06
399 #define S5C73M3_METER_CENTER 0x0000
400 #define S5C73M3_METER_SPOT 0x0001
401 #define S5C73M3_METER_AVERAGE 0x0002
402 #define S5C73M3_METER_SMART 0x0003
404 #define S5C73M3_WDR 0x0C08
405 #define S5C73M3_WDR_OFF 0x0000
406 #define S5C73M3_WDR_ON 0x0001
408 #define S5C73M3_FLICKER_MODE 0x0C12
409 #define S5C73M3_FLICKER_NONE 0x0000
410 #define S5C73M3_FLICKER_MANUAL_50HZ 0x0001
411 #define S5C73M3_FLICKER_MANUAL_60HZ 0x0002
412 #define S5C73M3_FLICKER_AUTO 0x0003
413 #define S5C73M3_FLICKER_AUTO_50HZ 0x0004
414 #define S5C73M3_FLICKER_AUTO_60HZ 0x0005
416 #define S5C73M3_AE_MODE 0x0C1E
417 #define S5C73M3_AUTO_MODE_AE_SET 0x0000
418 #define S5C73M3_FIXED_30FPS 0x0002
419 #define S5C73M3_FIXED_20FPS 0x0003
420 #define S5C73M3_FIXED_15FPS 0x0004
421 #define S5C73M3_FIXED_60FPS 0x0007
422 #define S5C73M3_FIXED_120FPS 0x0008
423 #define S5C73M3_FIXED_7FPS 0x0009
424 #define S5C73M3_FIXED_10FPS 0x000A
425 #define S5C73M3_FIXED_90FPS 0x000B
426 #define S5C73M3_ANTI_SHAKE 0x0013
428 #define S5C73M3_SHARPNESS 0x0C14
429 #define S5C73M3_SHARPNESS_0 0x0000
430 #define S5C73M3_SHARPNESS_1 0x0001
431 #define S5C73M3_SHARPNESS_2 0x0002
432 #define S5C73M3_SHARPNESS_M1 0x0003
433 #define S5C73M3_SHARPNESS_M2 0x0004
435 #define S5C73M3_SATURATION 0x0C16
436 #define S5C73M3_SATURATION_0 0x0000
437 #define S5C73M3_SATURATION_1 0x0001
438 #define S5C73M3_SATURATION_2 0x0002
439 #define S5C73M3_SATURATION_M1 0x0003
440 #define S5C73M3_SATURATION_M2 0x0004
442 #define S5C73M3_CONTRAST 0x0C18
443 #define S5C73M3_CONTRAST_0 0x0000
444 #define S5C73M3_CONTRAST_1 0x0001
445 #define S5C73M3_CONTRAST_2 0x0002
446 #define S5C73M3_CONTRAST_M1 0x0003
447 #define S5C73M3_CONTRAST_M2 0x0004
449 #define S5C73M3_SCENE_MODE 0x0C1A
450 #define S5C73M3_SCENE_MODE_NONE 0x0000
451 #define S5C73M3_SCENE_MODE_PORTRAIT 0x0001
452 #define S5C73M3_SCENE_MODE_LANDSCAPE 0x0002
453 #define S5C73M3_SCENE_MODE_SPORTS 0x0003
454 #define S5C73M3_SCENE_MODE_INDOOR 0x0004
455 #define S5C73M3_SCENE_MODE_BEACH 0x0005
456 #define S5C73M3_SCENE_MODE_SUNSET 0x0006
457 #define S5C73M3_SCENE_MODE_DAWN 0x0007
458 #define S5C73M3_SCENE_MODE_FALL 0x0008
459 #define S5C73M3_SCENE_MODE_NIGHT 0x0009
460 #define S5C73M3_SCENE_MODE_AGAINSTLIGHT 0x000A
461 #define S5C73M3_SCENE_MODE_FIRE 0x000B
462 #define S5C73M3_SCENE_MODE_TEXT 0x000C
463 #define S5C73M3_SCENE_MODE_CANDLE 0x000D
465 #define S5C73M3_FIREWORK_CAPTURE 0x0C20
467 #define S5C73M3_AE_AUTO_BRAKET 0x0B14
468 #define S5C73M3_AE_AUTO_BRAKET_EV05 0x0080
469 #define S5C73M3_AE_AUTO_BRAKET_EV10 0x0100
470 #define S5C73M3_AE_AUTO_BRAKET_EV15 0x0180
471 #define S5C73M3_AE_AUTO_BRAKET_EV20 0x0200
473 #define S5C73M3_SENSOR_STREAMING 0x090A
474 #define S5C73M3_SENSOR_STREAMING_OFF 0x0000
475 #define S5C73M3_SENSOR_STREAMING_ON 0x0001
477 #define S5C73M3_AWB_MODE 0x0D02
478 #define S5C73M3_AWB_MODE_INCANDESCENT 0x0000
479 #define S5C73M3_AWB_MODE_FLUORESCENT1 0x0001
480 #define S5C73M3_AWB_MODE_FLUORESCENT2 0x0002
481 #define S5C73M3_AWB_MODE_DAYLIGHT 0x0003
482 #define S5C73M3_AWB_MODE_CLOUDY 0x0004
483 #define S5C73M3_AWB_MODE_AUTO 0x0005
485 #define S5C73M3_AWB_CON 0x0D00
486 #define S5C73M3_AWB_STOP 0x0000/*LOCK*/
487 #define S5C73M3_AWB_START 0x0001/*UNLOCK*/
489 #define S5C73M3_HYBRID_CAPTURE 0x0996
491 #define S5C73M3_STATUS 0x5080
493 #define S5C73M3_I2C_SEQ_STATUS 0x59A6
494 #define SEQ_END_PLL (1<<0x0)
495 #define SEQ_END_SENSOR (1<<0x1)
496 #define SEQ_END_GPIO (1<<0x2)
497 #define SEQ_END_FROM (1<<0x3)
498 #define SEQ_END_STABLE_AE_AWB (1<<0x4)
499 #define SEQ_END_READY_I2C_CMD (1<<0x5)
501 #define S5C73M3_I2C_ERR_STATUS 0x599E
502 #define ERR_STATUS_CIS_I2C (1<<0x0)
503 #define ERR_STATUS_AF_INIT (1<<0x1)
504 #define ERR_STATUS_CAL_DATA (1<<0x2)
505 #define ERR_STATUS_FRAME_COUNT (1<<0x3)
506 #define ERR_STATUS_FROM_INIT (1<<0x4)
507 #define ERR_STATUS_I2C_CIS_STREAM_OFF (1<<0x5)
508 #define ERR_STATUS_I2C_N_CMD_OVER (1<<0x6)
509 #define ERROR_STATUS_I2C_N_CMD_MISMATCH (1<<0x7)
510 #define ERROR_STATUS_CHECK_BIN_CRC (1<<0x8)
511 #define ERROR_STATUS_EXCEPTION (1<<0x9)
512 #define ERROR_STATUS_INIF_INIT_STATE (0x8)
514 /* S5C73M3 Sensor Mode */
515 #define S5C73M3_SYSINIT_MODE 0x0
516 #define S5C73M3_PARMSET_MODE 0x1
517 #define S5C73M3_MONITOR_MODE 0x2
518 #define S5C73M3_STILLCAP_MODE 0x3
520 /* Interrupt Factor */
521 #define S5C73M3_INT_SOUND (1 << 7)
522 #define S5C73M3_INT_LENS_INIT (1 << 6)
523 #define S5C73M3_INT_FD (1 << 5)
524 #define S5C73M3_INT_FRAME_SYNC (1 << 4)
525 #define S5C73M3_INT_CAPTURE (1 << 3)
526 #define S5C73M3_INT_ZOOM (1 << 2)
527 #define S5C73M3_INT_AF (1 << 1)
528 #define S5C73M3_INT_MODE (1 << 0)
531 #define S5C73M3_INT_ESD (1 << 0)
533 static const u32 S5C73M3_INIT[] = {
539 0x0F140403, /*640MHz*/
544 #ifdef CONFIG_VIDEO_S5C73M3_SPI
545 extern int s5c73m3_spi_write(const u8 *addr, const int len, const int txSize);
546 extern int s5c73m3_spi_read(u8 *buf, size_t len, const int rxSize);
549 #endif /* __SLP_S5C73M3_H */