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,
89 enum s5c73m3_cap_frmsize {
90 S5C73M3_CAPTURE_VGA, /* 640 x 480 */
91 S5C73M3_CAPTURE_WVGA, /* 800 x 480 */
92 S5C73M3_CAPTURE_960x540, /* 960 x 540 */
93 S5C73M3_CAPTURE_960x720, /* 960 x 720 */
94 S5C73M3_CAPTURE_1024X768, /* 1024 x 768 */
95 S5C73M3_CAPTURE_HD, /* 1280 x 720 */
96 S5C73M3_CAPTURE_W1MP, /* 1600 x 960 */
97 S5C73M3_CAPTURE_2MP, /* UXGA - 1600 x 1200 */
98 S5C73M3_CAPTURE_W2MP, /* 2048 x 1232 */
99 S5C73M3_CAPTURE_3MP, /* QXGA - 2048 x 1536 */
100 S5C73M3_CAPTURE_W4MP, /* WQXGA - 2560 x 1440 */
101 S5C73M3_CAPTURE_5MP, /* 2560 x 1920 */
102 S5C73M3_CAPTURE_W6MP, /* 3072 x 1856 */
103 S5C73M3_CAPTURE_7MP, /* 3072 x 2304 */
104 S5C73M3_CAPTURE_W7MP, /* WQXGA - 2560 x 1536 */
105 S5C73M3_CAPTURE_3264X2176, /* 3264 x 2176 */
106 S5C73M3_CAPTURE_8MP, /* 3264 x 2448 */
109 enum s5c73m3_isneed_flash_tristate {
110 S5C73M3_ISNEED_FLASH_OFF = 0x00,
111 S5C73M3_ISNEED_FLASH_ON = 0x01,
112 S5C73M3_ISNEED_FLASH_UNDEFINED = 0x02,
115 struct s5c73m3_control {
118 s32 minimum; /* Note signedness */
124 struct s5c73m3_frmsizeenum {
128 u8 reg_val; /* a value for category parameter */
131 struct s5c73m3_effectenum {
133 unsigned int reg_val;
137 wait_queue_head_t wait;
138 unsigned int irq; /* irq issued by ISP */
140 unsigned int int_factor;
141 unsigned int bad_fw:1;
144 struct s5c73m3_jpeg {
146 unsigned int main_size; /* Main JPEG file size */
147 unsigned int thumb_size; /* Thumbnail file size */
148 unsigned int main_offset;
149 unsigned int thumb_offset;
150 unsigned int postview_offset;
152 struct s5c73m3_fw_version {
159 struct s5c73m3_focus {
167 /* rectangle type values */
174 struct s5c73m3_exif {
176 u32 exptime; /* us */
179 int tv; /* shutter speed */
180 int bv; /* brightness */
181 int ebv; /* exposure bias */
182 int effect; /* effect(colorfx) */
189 struct s5c73m3_state {
190 struct s5c73m3_platform_data *pdata;
191 struct v4l2_subdev sd;
193 struct s5c73m3_isp isp;
195 const struct s5c73m3_frmsizeenum *preview;
196 const struct s5c73m3_frmsizeenum *capture;
198 enum v4l2_pix_format_mode format_mode;
199 enum v4l2_sensor_mode sensor_mode;
200 enum v4l2_flash_mode flash_mode;
201 enum v4l2_wb_mode wb_mode;
202 enum v4l2_scene_mode scene_mode;
216 struct s5c73m3_focus focus;
220 struct s5c73m3_jpeg jpeg;
221 struct s5c73m3_exif exif;
235 #ifdef CONFIG_CAM_DEBUG
240 #define S5C73M3_IMG_OUTPUT 0x0902
241 #define S5C73M3_HDR_OUTPUT 0x0008
242 #define S5C73M3_YUV_OUTPUT 0x0009
243 #define S5C73M3_INTERLEAVED_OUTPUT 0x000D
244 #define S5C73M3_HYBRID_OUTPUT 0x0016
246 #define S5C73M3_STILL_PRE_FLASH 0x0A00
247 #define S5C73M3_STILL_PRE_FLASH_FIRE 0x0000
248 #define S5C73M3_STILL_PRE_FLASH_NON_FIRED 0x0000
249 #define S5C73M3_STILL_PRE_FLASH_FIRED 0x0001
251 #define S5C73M3_STILL_MAIN_FLASH 0x0A02
252 #define S5C73M3_STILL_MAIN_FLASH_CANCEL 0x0001
253 #define S5C73M3_STILL_MAIN_FLASH_FIRE 0x0002
256 #define S5C73M3_ZOOM_STEP 0x0B00
259 #define S5C73M3_IMAGE_EFFECT 0x0B0A
260 #define S5C73M3_IMAGE_EFFECT_NONE 0x0001
261 #define S5C73M3_IMAGE_EFFECT_NEGATIVE 0x0002
262 #define S5C73M3_IMAGE_EFFECT_AQUA 0x0003
263 #define S5C73M3_IMAGE_EFFECT_SEPIA 0x0004
264 #define S5C73M3_IMAGE_EFFECT_MONO 0x0005
265 #define S5C73M3_IMAGE_EFFECT_SKETCH 0x0006
266 #define S5C73M3_IMAGE_EFFECT_WASHED 0x0007
267 #define S5C73M3_IMAGE_EFFECT_VINTAGE_WARM 0x0008
268 #define S5C73M3_IMAGE_EFFECT_VINTAGE_COLD 0x0009
269 #define S5C73M3_IMAGE_EFFECT_SOLARIZE 0x000A
270 #define S5C73M3_IMAGE_EFFECT_POSTERIZE 0x000B
271 #define S5C73M3_IMAGE_EFFECT_POINT_BLUE 0x000C
272 #define S5C73M3_IMAGE_EFFECT_POINT_RED_YELLOW 0x000D
273 #define S5C73M3_IMAGE_EFFECT_POINT_COLOR_3 0x000E
274 #define S5C73M3_IMAGE_EFFECT_POINT_GREEN 0x000F
275 #define S5C73M3_IMAGE_EFFECT_CARTOONIZE 0x001A
277 #define S5C73M3_IMAGE_QUALITY 0x0B0C
278 #define S5C73M3_IMAGE_QUALITY_SUPERFINE 0x0000
279 #define S5C73M3_IMAGE_QUALITY_FINE 0x0001
280 #define S5C73M3_IMAGE_QUALITY_NORMAL 0x0002
283 #define S5C73M3_FLASH_MODE 0x0B0E
284 #define S5C73M3_FLASH_MODE_OFF 0x0000
285 #define S5C73M3_FLASH_MODE_ON 0x0001
286 #define S5C73M3_FLASH_MODE_AUTO 0x0002
288 #define S5C73M3_FLASH_TORCH 0x0B12
289 #define S5C73M3_FLASH_TORCH_OFF 0x0000
290 #define S5C73M3_FLASH_TORCH_ON 0x0001
292 #define S5C73M3_AE_ISNEEDFLASH 0x0CBA
293 #define S5C73M3_AE_ISNEEDFLASH_OFF 0x0000
294 #define S5C73M3_AE_ISNEEDFLASH_ON 0x0001
297 #define S5C73M3_CHG_MODE 0x0B10
298 #define S5C73M3_DEFAULT_MODE 0x8000
300 #define S5C73M3_CHG_MODE_YUV_320_240 0x8001
301 #define S5C73M3_CHG_MODE_YUV_400_300 0x8002
302 #define S5C73M3_CHG_MODE_YUV_640_480 0x8003
303 #define S5C73M3_CHG_MODE_YUV_800_600 0x8004
304 #define S5C73M3_CHG_MODE_YUV_960_720 0x8005
305 #define S5C73M3_CHG_MODE_YUV_1280_720 0x8006
306 #define S5C73M3_CHG_MODE_YUV_1280_960 0x8007
307 #define S5C73M3_CHG_MODE_YUV_1600_1200 0x8008
308 #define S5C73M3_CHG_MODE_YUV_1632_1224 0x8009
309 #define S5C73M3_CHG_MODE_YUV_1920_1080 0x800A
310 #define S5C73M3_CHG_MODE_YUV_1920_1440 0x800B
311 #define S5C73M3_CHG_MODE_YUV_2304_1296 0x800C
312 #define S5C73M3_CHG_MODE_YUV_2304_1728 0x800D
313 #define S5C73M3_CHG_MODE_JPEG_640_480 0x0010
314 #define S5C73M3_CHG_MODE_JPEG_800_450 0x0020
315 #define S5C73M3_CHG_MODE_JPEG_800_600 0x0030
316 #define S5C73M3_CHG_MODE_JPEG_1600_960 0x0040
317 #define S5C73M3_CHG_MODE_JPEG_1600_1200 0x0050
318 #define S5C73M3_CHG_MODE_JPEG_2048_1152 0x0060
319 #define S5C73M3_CHG_MODE_JPEG_2048_1536 0x0070
320 #define S5C73M3_CHG_MODE_JPEG_2560_1440 0x0080
321 #define S5C73M3_CHG_MODE_JPEG_2560_1920 0x0090
322 #define S5C73M3_CHG_MODE_JPEG_3072_1728 0x00A0
323 #define S5C73M3_CHG_MODE_JPEG_3264_2304 0x00B0
324 #define S5C73M3_CHG_MODE_JPEG_3264_1836 0x00C0
325 #define S5C73M3_CHG_MODE_JPEG_3264_2448 0x00D0
328 #define S5C73M3_AF_CON 0x0E00
329 #define S5C73M3_AF_CON_STOP 0x0000
330 #define S5C73M3_AF_CON_SCAN 0x0001/*AF_SCAN:Full Search*/
331 #define S5C73M3_AF_CON_START 0x0002/*AF_START:Fast Search*/
333 #define S5C73M3_AF_STATUS 0x5E80
335 #define S5C73M3_AF_TOUCH_AF 0x0E0A
337 #define S5C73M3_AF_CAL 0x0E06
339 #define S5C73M3_CAF_STATUS_FIND_SEARCHING_DIR 0x0001
340 #define S5C73M3_CAF_STATUS_FOCUSING 0x0002
341 #define S5C73M3_CAF_STATUS_FOCUSED 0x0003
342 #define S5C73M3_CAF_STATUS_UNFOCUSED 0x0004
344 #define S5C73M3_AF_STATUS_INVALID 0x0010
345 #define S5C73M3_AF_STATUS_FOCUSING 0x0020
346 #define S5C73M3_AF_STATUS_FOCUSED 0x0030/*SUCCESS*/
347 #define S5C73M3_AF_STATUS_UNFOCUSED 0x0040/*FAIL*/
349 #define S5C73M3_AF_TOUCH_POSITION 0x5E8E
351 #define S5C73M3_AF_FACE_ZOOM 0x0E10
353 #define S5C73M3_AF_MODE 0x0E02
354 #define S5C73M3_AF_MODE_NORMAL 0x0000
355 #define S5C73M3_AF_MODE_MACRO 0x0001
356 #define S5C73M3_AF_MODE_MOVIE_CAF_START 0x0002
357 #define S5C73M3_AF_MODE_MOVIE_CAF_STOP 0x0003
358 #define S5C73M3_AF_MODE_PREVIEW_CAF_START 0x0004
359 #define S5C73M3_AF_MODE_PREVIEW_CAF_STOP 0x0005
361 #define S5C73M3_AF_SOFTLANDING 0x0E16
362 #define S5C73M3_AF_SOFTLANDING_ON 0x0000
364 #define S5C73M3_FACE_DET 0x0E0C
365 #define S5C73M3_FACE_DET_OFF 0x0000
366 #define S5C73M3_FACE_DET_ON 0x0001
368 #define S5C73M3_FACE_DET_OSD 0x0E0E
369 #define S5C73M3_FACE_DET_OSD_OFF 0x0000
370 #define S5C73M3_FACE_DET_OSD_ON 0x0001
372 #define S5C73M3_AE_CON 0x0C00
373 #define S5C73M3_AE_STOP 0x0000/*LOCK*/
374 #define S5C73M3_AE_START 0x0001/*UNLOCK*/
376 #define S5C73M3_ISO 0x0C02
377 #define S5C73M3_ISO_AUTO 0x0000
378 #define S5C73M3_ISO_100 0x0001
379 #define S5C73M3_ISO_200 0x0002
380 #define S5C73M3_ISO_400 0x0003
381 #define S5C73M3_ISO_800 0x0004
382 #define S5C73M3_ISO_SPORTS 0x0005
383 #define S5C73M3_ISO_NIGHT 0x0006
384 #define S5C73M3_ISO_INDOOR 0x0007
386 #define S5C73M3_EV 0x0C04
387 #define S5C73M3_EV_M20 0x0000
388 #define S5C73M3_EV_M15 0x0001
389 #define S5C73M3_EV_M10 0x0002
390 #define S5C73M3_EV_M05 0x0003
391 #define S5C73M3_EV_ZERO 0x0004
392 #define S5C73M3_EV_P05 0x0005
393 #define S5C73M3_EV_P10 0x0006
394 #define S5C73M3_EV_P15 0x0007
395 #define S5C73M3_EV_P20 0x0008
397 #define S5C73M3_METER 0x0C06
398 #define S5C73M3_METER_CENTER 0x0000
399 #define S5C73M3_METER_SPOT 0x0001
400 #define S5C73M3_METER_AVERAGE 0x0002
401 #define S5C73M3_METER_SMART 0x0003
403 #define S5C73M3_WDR 0x0C08
404 #define S5C73M3_WDR_OFF 0x0000
405 #define S5C73M3_WDR_ON 0x0001
407 #define S5C73M3_FLICKER_MODE 0x0C12
408 #define S5C73M3_FLICKER_NONE 0x0000
409 #define S5C73M3_FLICKER_MANUAL_50HZ 0x0001
410 #define S5C73M3_FLICKER_MANUAL_60HZ 0x0002
411 #define S5C73M3_FLICKER_AUTO 0x0003
412 #define S5C73M3_FLICKER_AUTO_50HZ 0x0004
413 #define S5C73M3_FLICKER_AUTO_60HZ 0x0005
415 #define S5C73M3_AE_MODE 0x0C1E
416 #define S5C73M3_AUTO_MODE_AE_SET 0x0000
417 #define S5C73M3_FIXED_30FPS 0x0002
418 #define S5C73M3_FIXED_20FPS 0x0003
419 #define S5C73M3_FIXED_15FPS 0x0004
420 #define S5C73M3_FIXED_60FPS 0x0007
421 #define S5C73M3_FIXED_120FPS 0x0008
422 #define S5C73M3_FIXED_7FPS 0x0009
423 #define S5C73M3_FIXED_10FPS 0x000A
424 #define S5C73M3_FIXED_90FPS 0x000B
425 #define S5C73M3_ANTI_SHAKE 0x0013
427 #define S5C73M3_SHARPNESS 0x0C14
428 #define S5C73M3_SHARPNESS_0 0x0000
429 #define S5C73M3_SHARPNESS_1 0x0001
430 #define S5C73M3_SHARPNESS_2 0x0002
431 #define S5C73M3_SHARPNESS_M1 0x0003
432 #define S5C73M3_SHARPNESS_M2 0x0004
434 #define S5C73M3_SATURATION 0x0C16
435 #define S5C73M3_SATURATION_0 0x0000
436 #define S5C73M3_SATURATION_1 0x0001
437 #define S5C73M3_SATURATION_2 0x0002
438 #define S5C73M3_SATURATION_M1 0x0003
439 #define S5C73M3_SATURATION_M2 0x0004
441 #define S5C73M3_CONTRAST 0x0C18
442 #define S5C73M3_CONTRAST_0 0x0000
443 #define S5C73M3_CONTRAST_1 0x0001
444 #define S5C73M3_CONTRAST_2 0x0002
445 #define S5C73M3_CONTRAST_M1 0x0003
446 #define S5C73M3_CONTRAST_M2 0x0004
448 #define S5C73M3_SCENE_MODE 0x0C1A
449 #define S5C73M3_SCENE_MODE_NONE 0x0000
450 #define S5C73M3_SCENE_MODE_PORTRAIT 0x0001
451 #define S5C73M3_SCENE_MODE_LANDSCAPE 0x0002
452 #define S5C73M3_SCENE_MODE_SPORTS 0x0003
453 #define S5C73M3_SCENE_MODE_INDOOR 0x0004
454 #define S5C73M3_SCENE_MODE_BEACH 0x0005
455 #define S5C73M3_SCENE_MODE_SUNSET 0x0006
456 #define S5C73M3_SCENE_MODE_DAWN 0x0007
457 #define S5C73M3_SCENE_MODE_FALL 0x0008
458 #define S5C73M3_SCENE_MODE_NIGHT 0x0009
459 #define S5C73M3_SCENE_MODE_AGAINSTLIGHT 0x000A
460 #define S5C73M3_SCENE_MODE_FIRE 0x000B
461 #define S5C73M3_SCENE_MODE_TEXT 0x000C
462 #define S5C73M3_SCENE_MODE_CANDLE 0x000D
464 #define S5C73M3_FIREWORK_CAPTURE 0x0C20
466 #define S5C73M3_AE_AUTO_BRAKET 0x0B14
467 #define S5C73M3_AE_AUTO_BRAKET_EV05 0x0080
468 #define S5C73M3_AE_AUTO_BRAKET_EV10 0x0100
469 #define S5C73M3_AE_AUTO_BRAKET_EV15 0x0180
470 #define S5C73M3_AE_AUTO_BRAKET_EV20 0x0200
472 #define S5C73M3_SENSOR_STREAMING 0x090A
473 #define S5C73M3_SENSOR_STREAMING_OFF 0x0000
474 #define S5C73M3_SENSOR_STREAMING_ON 0x0001
476 #define S5C73M3_AWB_MODE 0x0D02
477 #define S5C73M3_AWB_MODE_INCANDESCENT 0x0000
478 #define S5C73M3_AWB_MODE_FLUORESCENT1 0x0001
479 #define S5C73M3_AWB_MODE_FLUORESCENT2 0x0002
480 #define S5C73M3_AWB_MODE_DAYLIGHT 0x0003
481 #define S5C73M3_AWB_MODE_CLOUDY 0x0004
482 #define S5C73M3_AWB_MODE_AUTO 0x0005
484 #define S5C73M3_AWB_CON 0x0D00
485 #define S5C73M3_AWB_STOP 0x0000/*LOCK*/
486 #define S5C73M3_AWB_START 0x0001/*UNLOCK*/
488 #define S5C73M3_HYBRID_CAPTURE 0x0996
490 #define S5C73M3_STATUS 0x5080
492 #define S5C73M3_I2C_SEQ_STATUS 0x59A6
493 #define SEQ_END_PLL (1<<0x0)
494 #define SEQ_END_SENSOR (1<<0x1)
495 #define SEQ_END_GPIO (1<<0x2)
496 #define SEQ_END_FROM (1<<0x3)
497 #define SEQ_END_STABLE_AE_AWB (1<<0x4)
498 #define SEQ_END_READY_I2C_CMD (1<<0x5)
500 #define S5C73M3_I2C_ERR_STATUS 0x599E
501 #define ERR_STATUS_CIS_I2C (1<<0x0)
502 #define ERR_STATUS_AF_INIT (1<<0x1)
503 #define ERR_STATUS_CAL_DATA (1<<0x2)
504 #define ERR_STATUS_FRAME_COUNT (1<<0x3)
505 #define ERR_STATUS_FROM_INIT (1<<0x4)
506 #define ERR_STATUS_I2C_CIS_STREAM_OFF (1<<0x5)
507 #define ERR_STATUS_I2C_N_CMD_OVER (1<<0x6)
508 #define ERROR_STATUS_I2C_N_CMD_MISMATCH (1<<0x7)
509 #define ERROR_STATUS_CHECK_BIN_CRC (1<<0x8)
510 #define ERROR_STATUS_EXCEPTION (1<<0x9)
511 #define ERROR_STATUS_INIF_INIT_STATE (0x8)
513 /* S5C73M3 Sensor Mode */
514 #define S5C73M3_SYSINIT_MODE 0x0
515 #define S5C73M3_PARMSET_MODE 0x1
516 #define S5C73M3_MONITOR_MODE 0x2
517 #define S5C73M3_STILLCAP_MODE 0x3
519 /* Interrupt Factor */
520 #define S5C73M3_INT_SOUND (1 << 7)
521 #define S5C73M3_INT_LENS_INIT (1 << 6)
522 #define S5C73M3_INT_FD (1 << 5)
523 #define S5C73M3_INT_FRAME_SYNC (1 << 4)
524 #define S5C73M3_INT_CAPTURE (1 << 3)
525 #define S5C73M3_INT_ZOOM (1 << 2)
526 #define S5C73M3_INT_AF (1 << 1)
527 #define S5C73M3_INT_MODE (1 << 0)
530 #define S5C73M3_INT_ESD (1 << 0)
532 static const u32 S5C73M3_INIT[] = {
538 0x0F140403, /*640MHz*/
543 #ifdef CONFIG_VIDEO_S5C73M3_SPI
544 extern int s5c73m3_spi_write(const u8 *addr, const int len, const int txSize);
545 extern int s5c73m3_spi_read(u8 *buf, size_t len, const int rxSize);
548 #endif /* __SLP_S5C73M3_H */