Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
m5mols.h
Go to the documentation of this file.
1 /*
2  * Header for M-5MOLS 8M Pixel camera sensor with ISP
3  *
4  * Copyright (C) 2011 Samsung Electronics Co., Ltd.
5  * Author: HeungJun Kim <[email protected]>
6  *
7  * Copyright (C) 2009 Samsung Electronics Co., Ltd.
8  * Author: Dongsoo Nathaniel Kim <[email protected]>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  */
15 
16 #ifndef M5MOLS_H
17 #define M5MOLS_H
18 
19 #include <linux/sizes.h>
20 #include <media/v4l2-subdev.h>
21 #include "m5mols_reg.h"
22 
23 
24 /* An amount of data transmitted in addition to the value
25  * determined by CAPP_JPEG_SIZE_MAX register.
26  */
27 #define M5MOLS_JPEG_TAGS_SIZE 0x20000
28 #define M5MOLS_MAIN_JPEG_SIZE_MAX (5 * SZ_1M)
29 
30 extern int m5mols_debug;
31 
36 };
37 
50 };
51 
63 struct m5mols_exif {
73 };
74 
84  struct m5mols_exif exif;
85  unsigned int buf_size;
89 };
90 
131 };
132 
151 #define VERSION_STRING_SIZE 22
161 };
162 
197 struct m5mols_info {
199  struct v4l2_subdev sd;
200  struct media_pad pad;
201 
204 
206  struct {
207  /* exposure/exposure bias/auto exposure cluster */
212  };
213  struct {
214  /* iso/auto iso cluster */
216  struct v4l2_ctrl *iso;
217  };
219 
223  struct v4l2_ctrl *zoom;
224  struct v4l2_ctrl *wdr;
227 
228  int (*set_power)(struct device *dev, int on);
229 
230  struct mutex lock;
231 
232  struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX];
233  int res_type;
234 
237 
238  unsigned int isp_ready:1;
239  unsigned int power:1;
240  unsigned int ctrl_sync:1;
241 
244 };
245 
246 #define is_available_af(__info) (__info->ver.af)
247 #define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code)
248 #define is_manufacturer(__info, __manufacturer) \
249  (__info->ver.str[0] == __manufacturer[0] && \
250  __info->ver.str[1] == __manufacturer[1])
251 /*
252  * I2C operation of the M-5MOLS
253  *
254  * The I2C read operation of the M-5MOLS requires 2 messages. The first
255  * message sends the information about the command, command category, and total
256  * message size. The second message is used to retrieve the data specifed in
257  * the first message
258  *
259  * 1st message 2nd message
260  * +-------+---+----------+-----+-------+ +------+------+------+------+
261  * | size1 | R | category | cmd | size2 | | d[0] | d[1] | d[2] | d[3] |
262  * +-------+---+----------+-----+-------+ +------+------+------+------+
263  * - size1: message data size(5 in this case)
264  * - size2: desired buffer size of the 2nd message
265  * - d[0..3]: according to size2
266  *
267  * The I2C write operation needs just one message. The message includes
268  * category, command, total size, and desired data.
269  *
270  * 1st message
271  * +-------+---+----------+-----+------+------+------+------+
272  * | size1 | W | category | cmd | d[0] | d[1] | d[2] | d[3] |
273  * +-------+---+----------+-----+------+------+------+------+
274  * - d[0..3]: according to size1
275  */
276 int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg_comb, u8 *val);
277 int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg_comb, u16 *val);
278 int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg_comb, u32 *val);
279 int m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val);
280 
282  int timeout);
283 
284 /* Mask value for busy waiting until M-5MOLS I2C interface is initialized */
285 #define M5MOLS_I2C_RDY_WAIT_FL (1 << 16)
286 /* ISP state transition timeout, in ms */
287 #define M5MOLS_MODE_CHANGE_TIMEOUT 200
288 #define M5MOLS_BUSY_WAIT_DEF_TIMEOUT 250
289 
290 /*
291  * Mode operation of the M-5MOLS
292  *
293  * Changing the mode of the M-5MOLS is needed right executing order.
294  * There are three modes(PARAMETER, MONITOR, CAPTURE) which can be changed
295  * by user. There are various categories associated with each mode.
296  *
297  * +============================================================+
298  * | mode | category |
299  * +============================================================+
300  * | FLASH | FLASH(only after Stand-by or Power-on) |
301  * | SYSTEM | SYSTEM(only after sensor arm-booting) |
302  * | PARAMETER | PARAMETER |
303  * | MONITOR | MONITOR(preview), Auto Focus, Face Detection |
304  * | CAPTURE | Single CAPTURE, Preview(recording) |
305  * +============================================================+
306  *
307  * The available executing order between each modes are as follows:
308  * PARAMETER <---> MONITOR <---> CAPTURE
309  */
310 int m5mols_set_mode(struct m5mols_info *info, u8 mode);
311 
313 int m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout);
317 int m5mols_lock_3a(struct m5mols_info *info, bool lock);
318 int m5mols_set_ctrl(struct v4l2_ctrl *ctrl);
319 int m5mols_init_controls(struct v4l2_subdev *sd);
320 
321 /* The firmware function */
322 int m5mols_update_fw(struct v4l2_subdev *sd,
323  int (*set_power)(struct m5mols_info *, bool));
324 
325 static inline struct m5mols_info *to_m5mols(struct v4l2_subdev *subdev)
326 {
327  return container_of(subdev, struct m5mols_info, sd);
328 }
329 
330 static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
331 {
332  struct m5mols_info *info = container_of(ctrl->handler,
333  struct m5mols_info, handle);
334  return &info->sd;
335 }
336 
337 static inline void m5mols_set_ctrl_mode(struct v4l2_ctrl *ctrl,
338  unsigned int mode)
339 {
340  ctrl->priv = (void *)(uintptr_t)mode;
341 }
342 
343 static inline unsigned int m5mols_get_ctrl_mode(struct v4l2_ctrl *ctrl)
344 {
345  return (unsigned int)(uintptr_t)ctrl->priv;
346 }
347 
348 #endif /* M5MOLS_H */