aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/slp_s5k4ecgx.h
blob: 400581fe4fff6abdc30338a61cd07708f727cb55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 * Driver for S5K4ECGX 5M ISP from Samsung
 * Copyright (C) 2012 Samsung Electronics Co., Ltd.
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef __S5K4ECGX_H
#define __S5K4ECGX_H

#include <linux/types.h>

#define S5K4ECGX_DRIVER_NAME	"S5K4ECGX"
#define is_focus(__mode)		(state->focus.mode == __mode)

#define FIRST_AF_SEARCH_COUNT   80
#define SECOND_AF_SEARCH_COUNT  80

extern struct class *camera_class;

enum stream_cmd {
	STREAM_STOP,
	STREAM_START,
};

struct s5k4ecgx_framesize {
	u32 index;
	u32 width;
	u32 height;
};

struct s5k4ecgx_exif {
	u32 exptime;		/* us */
	u16 flash;
	u16 iso;
	int tv;			/* shutter speed */
	int bv;			/* brightness */
	int ebv;		/* exposure bias */
};

struct s5k4ecgx_focus {
	unsigned int mode;
	unsigned int lock;
	unsigned int status;
	unsigned int touch;
	unsigned int pos_x;
	unsigned int pos_y;
	unsigned int width;
	unsigned int height;
	unsigned int start;
	bool focusing;
	bool needed;
	bool first;
};

enum preflash_status {
	PREFLASH_NONE = 0,
	PREFLASH_OFF,
	PREFLASH_ON,
};

enum s5k4ecgx_runmode {
	RUNMODE_NOTREADY,
	RUNMODE_INIT,
	RUNMODE_RUNNING, /* previewing */
	RUNMODE_RUNNING_STOP,
	RUNMODE_CAPTURING,
	RUNMODE_CAPTURE_STOP,
};

/*
 * Driver information
 */
struct s5k4ecgx_state {
	struct v4l2_subdev sd;
	struct device *s5k4ecgx_dev;
	struct s5k4ecgx_platform_data *pdata;
	/*
	 * req_fmt is the requested format from the application.
	 * set_fmt is the output format of the camera. Finally FIMC
	 * converts the camera output(set_fmt) to the requested format
	 * with hardware scaler.
	 */
	struct v4l2_pix_format req_fmt;
	const struct s5k4ecgx_framesize *preview_frmsizes;
	const struct s5k4ecgx_framesize *capture_frmsizes;
	struct s5k4ecgx_exif exif;
	struct s5k4ecgx_focus focus;

	enum v4l2_flash_mode flash_mode;
	enum preflash_status preflash;
	enum v4l2_sensor_mode sensor_mode;
	enum v4l2_scene_mode scene_mode;
	enum v4l2_wb_mode wb_mode;
	enum s5k4ecgx_runmode runmode;

	struct mutex ctrl_lock; /* Mutex */
	struct mutex af_lock; /* Mutex */
	struct work_struct af_work; /* workque for AF */
	struct work_struct af_win_work; /* workque for AF */
	struct workqueue_struct *workqueue; /* workque for AF */

	s32 vt_mode;
	s32 check_dataline;
	u32 req_fps;
	u32 set_fps;
	u32 initialized;
	u32 zoom;
	bool lowlight;
	bool ae_lock;
	bool awb_lock;
};

enum AF_1ST_STATUS {
	AF_PROGRESS_1ST = 1,
	AF_SUCCESS_1ST	,
	AF_FAIL_1ST,
};

enum AF_2ND_STATUS {
	AF_SUCCESS_2ND = 0,
	AF_PROGRESS_2ND = 1,
};

enum s5k4ecgx_prev_frmsize {
	S5K4ECGX_PREVIEW_176, /* 176 x 144 */
	S5K4ECGX_PREVIEW_320, /* 320 x 240 */
	S5K4ECGX_PREVIEW_640, /* 640 x 480 */
	S5K4ECGX_PREVIEW_720, /* 720 x 480 */
	S5K4ECGX_PREVIEW_800, /* 800 x 480 */
	S5K4ECGX_PREVIEW_1280, /* 1280 x 720 */
};

enum s5k4ecgx_cap_frmsize {
	S5K4ECGX_CAPTURE_VGA,	/* 640 x 480 */
	S5K4ECGX_CAPTURE_XGA,	/* 1024 x 768 */
	S5K4ECGX_CAPTURE_1MP,	/* 1280 x 960 */
	S5K4ECGX_CAPTURE_2MP,	/* UXGA - 1600 x 1200 */
	S5K4ECGX_CAPTURE_3MP,	/* QXGA - 2048 x 1536 */
	S5K4ECGX_CAPTURE_5MP,	/* 2560 x 1920 */
};

static inline struct s5k4ecgx_state *to_state(struct v4l2_subdev *sd)
{
	return container_of(sd, struct s5k4ecgx_state, sd);
}

/*#define CONFIG_CAM_DEBUG */
#define cam_warn(fmt, ...)	\
	do { \
		printk(KERN_WARNING "%s: " fmt, __func__, ##__VA_ARGS__); \
	} while (0)

#define cam_err(fmt, ...)	\
	do { \
		printk(KERN_ERR "%s: " fmt, __func__, ##__VA_ARGS__); \
	} while (0)

#define cam_info(fmt, ...)	\
	do { \
		printk(KERN_INFO "%s: " fmt, __func__, ##__VA_ARGS__); \
	} while (0)

#ifdef CONFIG_CAM_DEBUG
#define cam_dbg(fmt, ...)	\
	do { \
		printk(KERN_DEBUG "%s: " fmt, __func__, ##__VA_ARGS__); \
	} while (0)
#else
#define cam_dbg(fmt, ...)
#endif /* CONFIG_CAM_DEBUG */


/************ driver feature ************/
#define S5K4ECGX_USLEEP
/* #define CONFIG_LOAD_FILE */


/*********** Sensor specific ************/
/* #define S5K4ECGX_100MS_DELAY	0xAA55AA5F */
/* #define S5K4ECGX_10MS_DELAY	0xAA55AA5E */
#define S5K4ECGX_DELAY		0xFFFF0000
#define S5K4ECGX_DEF_APEX_DEN	100

/* Register address */
#define REG_PAGE_SHUTTER    0x7000
#define REG_ADDR_SHUTTER    0x14D0
#define REG_PAGE_ISO        0x7000
#define REG_ADDR_ISO        0x14C8

#include  "slp_s5k4ecgx_setfile.h"

#endif /* __S5K4ECGX_H */