Path: blob/master/drivers/media/video/m5mols/m5mols.h
17780 views
/*1* Header for M-5MOLS 8M Pixel camera sensor with ISP2*3* Copyright (C) 2011 Samsung Electronics Co., Ltd.4* Author: HeungJun Kim <[email protected]>5*6* Copyright (C) 2009 Samsung Electronics Co., Ltd.7* Author: Dongsoo Nathaniel Kim <[email protected]>8*9* This program is free software; you can redistribute it and/or modify10* it under the terms of the GNU General Public License as published by11* the Free Software Foundation; either version 2 of the License, or12* (at your option) any later version.13*/1415#ifndef M5MOLS_H16#define M5MOLS_H1718#include <media/v4l2-subdev.h>19#include "m5mols_reg.h"2021extern int m5mols_debug;2223#define to_m5mols(__sd) container_of(__sd, struct m5mols_info, sd)2425#define to_sd(__ctrl) \26(&container_of(__ctrl->handler, struct m5mols_info, handle)->sd)2728enum m5mols_restype {29M5MOLS_RESTYPE_MONITOR,30M5MOLS_RESTYPE_CAPTURE,31M5MOLS_RESTYPE_MAX,32};3334/**35* struct m5mols_resolution - structure for the resolution36* @type: resolution type according to the pixel code37* @width: width of the resolution38* @height: height of the resolution39* @reg: resolution preset register value40*/41struct m5mols_resolution {42u8 reg;43enum m5mols_restype type;44u16 width;45u16 height;46};4748/**49* struct m5mols_exif - structure for the EXIF information of M-5MOLS50* @exposure_time: exposure time register value51* @shutter_speed: speed of the shutter register value52* @aperture: aperture register value53* @exposure_bias: it calls also EV bias54* @iso_speed: ISO register value55* @flash: status register value of the flash56* @sdr: status register value of the Subject Distance Range57* @qval: not written exact meaning in document58*/59struct m5mols_exif {60u32 exposure_time;61u32 shutter_speed;62u32 aperture;63u32 brightness;64u32 exposure_bias;65u16 iso_speed;66u16 flash;67u16 sdr;68u16 qval;69};7071/**72* struct m5mols_capture - Structure for the capture capability73* @exif: EXIF information74* @main: size in bytes of the main image75* @thumb: size in bytes of the thumb image, if it was accompanied76* @total: total size in bytes of the produced image77*/78struct m5mols_capture {79struct m5mols_exif exif;80u32 main;81u32 thumb;82u32 total;83};8485/**86* struct m5mols_scenemode - structure for the scenemode capability87* @metering: metering light register value88* @ev_bias: EV bias register value89* @wb_mode: mode which means the WhiteBalance is Auto or Manual90* @wb_preset: whitebalance preset register value in the Manual mode91* @chroma_en: register value whether the Chroma capability is enabled or not92* @chroma_lvl: chroma's level register value93* @edge_en: register value Whether the Edge capability is enabled or not94* @edge_lvl: edge's level register value95* @af_range: Auto Focus's range96* @fd_mode: Face Detection mode97* @mcc: Multi-axis Color Conversion which means emotion color98* @light: status of the Light99* @flash: status of the Flash100* @tone: Tone color which means Contrast101* @iso: ISO register value102* @capt_mode: Mode of the Image Stabilization while the camera capturing103* @wdr: Wide Dynamic Range register value104*105* The each value according to each scenemode is recommended in the documents.106*/107struct m5mols_scenemode {108u8 metering;109u8 ev_bias;110u8 wb_mode;111u8 wb_preset;112u8 chroma_en;113u8 chroma_lvl;114u8 edge_en;115u8 edge_lvl;116u8 af_range;117u8 fd_mode;118u8 mcc;119u8 light;120u8 flash;121u8 tone;122u8 iso;123u8 capt_mode;124u8 wdr;125};126127/**128* struct m5mols_version - firmware version information129* @customer: customer information130* @project: version of project information according to customer131* @fw: firmware revision132* @hw: hardware revision133* @param: version of the parameter134* @awb: Auto WhiteBalance algorithm version135* @str: information about manufacturer and packaging vendor136* @af: Auto Focus version137*138* The register offset starts the customer version at 0x0, and it ends139* the awb version at 0x09. The customer, project information occupies 1 bytes140* each. And also the fw, hw, param, awb each requires 2 bytes. The str is141* unique string associated with firmware's version. It includes information142* about manufacturer and the vendor of the sensor's packaging. The least143* significant 2 bytes of the string indicate packaging manufacturer.144*/145#define VERSION_STRING_SIZE 22146struct m5mols_version {147u8 customer;148u8 project;149u16 fw;150u16 hw;151u16 param;152u16 awb;153u8 str[VERSION_STRING_SIZE];154u8 af;155};156157/**158* struct m5mols_info - M-5MOLS driver data structure159* @pdata: platform data160* @sd: v4l-subdev instance161* @pad: media pad162* @ffmt: current fmt according to resolution type163* @res_type: current resolution type164* @code: current code165* @irq_waitq: waitqueue for the capture166* @work_irq: workqueue for the IRQ167* @flags: state variable for the interrupt handler168* @handle: control handler169* @autoexposure: Auto Exposure control170* @exposure: Exposure control171* @autowb: Auto White Balance control172* @colorfx: Color effect control173* @saturation: Saturation control174* @zoom: Zoom control175* @ver: information of the version176* @cap: the capture mode attributes177* @power: current sensor's power status178* @ctrl_sync: true means all controls of the sensor are initialized179* @int_capture: true means the capture interrupt is issued once180* @lock_ae: true means the Auto Exposure is locked181* @lock_awb: true means the Aut WhiteBalance is locked182* @resolution: register value for current resolution183* @interrupt: register value for current interrupt status184* @mode: register value for current operation mode185* @mode_save: register value for current operation mode for saving186* @set_power: optional power callback to the board code187*/188struct m5mols_info {189const struct m5mols_platform_data *pdata;190struct v4l2_subdev sd;191struct media_pad pad;192struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX];193int res_type;194enum v4l2_mbus_pixelcode code;195wait_queue_head_t irq_waitq;196struct work_struct work_irq;197unsigned long flags;198199struct v4l2_ctrl_handler handle;200/* Autoexposure/exposure control cluster */201struct {202struct v4l2_ctrl *autoexposure;203struct v4l2_ctrl *exposure;204};205struct v4l2_ctrl *autowb;206struct v4l2_ctrl *colorfx;207struct v4l2_ctrl *saturation;208struct v4l2_ctrl *zoom;209210struct m5mols_version ver;211struct m5mols_capture cap;212bool power;213bool ctrl_sync;214bool lock_ae;215bool lock_awb;216u8 resolution;217u8 interrupt;218u8 mode;219u8 mode_save;220int (*set_power)(struct device *dev, int on);221};222223#define ST_CAPT_IRQ 0224225#define is_powered(__info) (__info->power)226#define is_ctrl_synced(__info) (__info->ctrl_sync)227#define is_available_af(__info) (__info->ver.af)228#define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code)229#define is_manufacturer(__info, __manufacturer) \230(__info->ver.str[0] == __manufacturer[0] && \231__info->ver.str[1] == __manufacturer[1])232/*233* I2C operation of the M-5MOLS234*235* The I2C read operation of the M-5MOLS requires 2 messages. The first236* message sends the information about the command, command category, and total237* message size. The second message is used to retrieve the data specifed in238* the first message239*240* 1st message 2nd message241* +-------+---+----------+-----+-------+ +------+------+------+------+242* | size1 | R | category | cmd | size2 | | d[0] | d[1] | d[2] | d[3] |243* +-------+---+----------+-----+-------+ +------+------+------+------+244* - size1: message data size(5 in this case)245* - size2: desired buffer size of the 2nd message246* - d[0..3]: according to size2247*248* The I2C write operation needs just one message. The message includes249* category, command, total size, and desired data.250*251* 1st message252* +-------+---+----------+-----+------+------+------+------+253* | size1 | W | category | cmd | d[0] | d[1] | d[2] | d[3] |254* +-------+---+----------+-----+------+------+------+------+255* - d[0..3]: according to size1256*/257int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg_comb, u8 *val);258int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg_comb, u16 *val);259int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg_comb, u32 *val);260int m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val);261int m5mols_busy(struct v4l2_subdev *sd, u8 category, u8 cmd, u8 value);262263/*264* Mode operation of the M-5MOLS265*266* Changing the mode of the M-5MOLS is needed right executing order.267* There are three modes(PARAMETER, MONITOR, CAPTURE) which can be changed268* by user. There are various categories associated with each mode.269*270* +============================================================+271* | mode | category |272* +============================================================+273* | FLASH | FLASH(only after Stand-by or Power-on) |274* | SYSTEM | SYSTEM(only after sensor arm-booting) |275* | PARAMETER | PARAMETER |276* | MONITOR | MONITOR(preview), Auto Focus, Face Detection |277* | CAPTURE | Single CAPTURE, Preview(recording) |278* +============================================================+279*280* The available executing order between each modes are as follows:281* PARAMETER <---> MONITOR <---> CAPTURE282*/283int m5mols_mode(struct m5mols_info *info, u8 mode);284285int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg);286int m5mols_sync_controls(struct m5mols_info *info);287int m5mols_start_capture(struct m5mols_info *info);288int m5mols_do_scenemode(struct m5mols_info *info, u8 mode);289int m5mols_lock_3a(struct m5mols_info *info, bool lock);290int m5mols_set_ctrl(struct v4l2_ctrl *ctrl);291292/* The firmware function */293int m5mols_update_fw(struct v4l2_subdev *sd,294int (*set_power)(struct m5mols_info *, bool));295296#endif /* M5MOLS_H */297298299