![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /* 0003 * Header for M-5MOLS 8M Pixel camera sensor with ISP 0004 * 0005 * Copyright (C) 2011 Samsung Electronics Co., Ltd. 0006 * Author: HeungJun Kim <riverful.kim@samsung.com> 0007 * 0008 * Copyright (C) 2009 Samsung Electronics Co., Ltd. 0009 * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com> 0010 */ 0011 0012 #ifndef M5MOLS_H 0013 #define M5MOLS_H 0014 0015 #include <linux/sizes.h> 0016 #include <linux/gpio/consumer.h> 0017 #include <media/v4l2-subdev.h> 0018 #include "m5mols_reg.h" 0019 0020 0021 /* An amount of data transmitted in addition to the value 0022 * determined by CAPP_JPEG_SIZE_MAX register. 0023 */ 0024 #define M5MOLS_JPEG_TAGS_SIZE 0x20000 0025 #define M5MOLS_MAIN_JPEG_SIZE_MAX (5 * SZ_1M) 0026 0027 extern int m5mols_debug; 0028 0029 enum m5mols_restype { 0030 M5MOLS_RESTYPE_MONITOR, 0031 M5MOLS_RESTYPE_CAPTURE, 0032 M5MOLS_RESTYPE_MAX, 0033 }; 0034 0035 /** 0036 * struct m5mols_resolution - structure for the resolution 0037 * @type: resolution type according to the pixel code 0038 * @width: width of the resolution 0039 * @height: height of the resolution 0040 * @reg: resolution preset register value 0041 */ 0042 struct m5mols_resolution { 0043 u8 reg; 0044 enum m5mols_restype type; 0045 u16 width; 0046 u16 height; 0047 }; 0048 0049 /** 0050 * struct m5mols_exif - structure for the EXIF information of M-5MOLS 0051 * @exposure_time: exposure time register value 0052 * @shutter_speed: speed of the shutter register value 0053 * @aperture: aperture register value 0054 * @brightness: brightness register value 0055 * @exposure_bias: it calls also EV bias 0056 * @iso_speed: ISO register value 0057 * @flash: status register value of the flash 0058 * @sdr: status register value of the Subject Distance Range 0059 * @qval: not written exact meaning in document 0060 */ 0061 struct m5mols_exif { 0062 u32 exposure_time; 0063 u32 shutter_speed; 0064 u32 aperture; 0065 u32 brightness; 0066 u32 exposure_bias; 0067 u16 iso_speed; 0068 u16 flash; 0069 u16 sdr; 0070 u16 qval; 0071 }; 0072 0073 /** 0074 * struct m5mols_capture - Structure for the capture capability 0075 * @exif: EXIF information 0076 * @buf_size: internal JPEG frame buffer size, in bytes 0077 * @main: size in bytes of the main image 0078 * @thumb: size in bytes of the thumb image, if it was accompanied 0079 * @total: total size in bytes of the produced image 0080 */ 0081 struct m5mols_capture { 0082 struct m5mols_exif exif; 0083 unsigned int buf_size; 0084 u32 main; 0085 u32 thumb; 0086 u32 total; 0087 }; 0088 0089 /** 0090 * struct m5mols_scenemode - structure for the scenemode capability 0091 * @metering: metering light register value 0092 * @ev_bias: EV bias register value 0093 * @wb_mode: mode which means the WhiteBalance is Auto or Manual 0094 * @wb_preset: whitebalance preset register value in the Manual mode 0095 * @chroma_en: register value whether the Chroma capability is enabled or not 0096 * @chroma_lvl: chroma's level register value 0097 * @edge_en: register value Whether the Edge capability is enabled or not 0098 * @edge_lvl: edge's level register value 0099 * @af_range: Auto Focus's range 0100 * @fd_mode: Face Detection mode 0101 * @mcc: Multi-axis Color Conversion which means emotion color 0102 * @light: status of the Light 0103 * @flash: status of the Flash 0104 * @tone: Tone color which means Contrast 0105 * @iso: ISO register value 0106 * @capt_mode: Mode of the Image Stabilization while the camera capturing 0107 * @wdr: Wide Dynamic Range register value 0108 * 0109 * The each value according to each scenemode is recommended in the documents. 0110 */ 0111 struct m5mols_scenemode { 0112 u8 metering; 0113 u8 ev_bias; 0114 u8 wb_mode; 0115 u8 wb_preset; 0116 u8 chroma_en; 0117 u8 chroma_lvl; 0118 u8 edge_en; 0119 u8 edge_lvl; 0120 u8 af_range; 0121 u8 fd_mode; 0122 u8 mcc; 0123 u8 light; 0124 u8 flash; 0125 u8 tone; 0126 u8 iso; 0127 u8 capt_mode; 0128 u8 wdr; 0129 }; 0130 0131 #define VERSION_STRING_SIZE 22 0132 0133 /** 0134 * struct m5mols_version - firmware version information 0135 * @customer: customer information 0136 * @project: version of project information according to customer 0137 * @fw: firmware revision 0138 * @hw: hardware revision 0139 * @param: version of the parameter 0140 * @awb: Auto WhiteBalance algorithm version 0141 * @str: information about manufacturer and packaging vendor 0142 * @af: Auto Focus version 0143 * 0144 * The register offset starts the customer version at 0x0, and it ends 0145 * the awb version at 0x09. The customer, project information occupies 1 bytes 0146 * each. And also the fw, hw, param, awb each requires 2 bytes. The str is 0147 * unique string associated with firmware's version. It includes information 0148 * about manufacturer and the vendor of the sensor's packaging. The least 0149 * significant 2 bytes of the string indicate packaging manufacturer. 0150 */ 0151 struct m5mols_version { 0152 u8 customer; 0153 u8 project; 0154 u16 fw; 0155 u16 hw; 0156 u16 param; 0157 u16 awb; 0158 u8 str[VERSION_STRING_SIZE]; 0159 u8 af; 0160 }; 0161 0162 /** 0163 * struct m5mols_info - M-5MOLS driver data structure 0164 * @pdata: platform data 0165 * @sd: v4l-subdev instance 0166 * @pad: media pad 0167 * @irq_waitq: waitqueue for the capture 0168 * @irq_done: set to 1 in the interrupt handler 0169 * @handle: control handler 0170 * @auto_exposure: auto/manual exposure control 0171 * @exposure_bias: exposure compensation control 0172 * @exposure: manual exposure control 0173 * @metering: exposure metering control 0174 * @auto_iso: auto/manual ISO sensitivity control 0175 * @iso: manual ISO sensitivity control 0176 * @auto_wb: auto white balance control 0177 * @lock_3a: 3A lock control 0178 * @colorfx: color effect control 0179 * @saturation: saturation control 0180 * @zoom: zoom control 0181 * @wdr: wide dynamic range control 0182 * @stabilization: image stabilization control 0183 * @jpeg_quality: JPEG compression quality control 0184 * @set_power: optional power callback to the board code 0185 * @reset: GPIO driving the reset pin of M-5MOLS 0186 * @lock: mutex protecting the structure fields below 0187 * @ffmt: current fmt according to resolution type 0188 * @res_type: current resolution type 0189 * @ver: information of the version 0190 * @cap: the capture mode attributes 0191 * @isp_ready: 1 when the ISP controller has completed booting 0192 * @power: current sensor's power status 0193 * @ctrl_sync: 1 when the control handler state is restored in H/W 0194 * @resolution: register value for current resolution 0195 * @mode: register value for current operation mode 0196 */ 0197 struct m5mols_info { 0198 const struct m5mols_platform_data *pdata; 0199 struct v4l2_subdev sd; 0200 struct media_pad pad; 0201 0202 wait_queue_head_t irq_waitq; 0203 atomic_t irq_done; 0204 0205 struct v4l2_ctrl_handler handle; 0206 struct { 0207 /* exposure/exposure bias/auto exposure cluster */ 0208 struct v4l2_ctrl *auto_exposure; 0209 struct v4l2_ctrl *exposure_bias; 0210 struct v4l2_ctrl *exposure; 0211 struct v4l2_ctrl *metering; 0212 }; 0213 struct { 0214 /* iso/auto iso cluster */ 0215 struct v4l2_ctrl *auto_iso; 0216 struct v4l2_ctrl *iso; 0217 }; 0218 struct v4l2_ctrl *auto_wb; 0219 0220 struct v4l2_ctrl *lock_3a; 0221 struct v4l2_ctrl *colorfx; 0222 struct v4l2_ctrl *saturation; 0223 struct v4l2_ctrl *zoom; 0224 struct v4l2_ctrl *wdr; 0225 struct v4l2_ctrl *stabilization; 0226 struct v4l2_ctrl *jpeg_quality; 0227 0228 int (*set_power)(struct device *dev, int on); 0229 struct gpio_desc *reset; 0230 0231 struct mutex lock; 0232 0233 struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX]; 0234 int res_type; 0235 0236 struct m5mols_version ver; 0237 struct m5mols_capture cap; 0238 0239 unsigned int isp_ready:1; 0240 unsigned int power:1; 0241 unsigned int ctrl_sync:1; 0242 0243 u8 resolution; 0244 u8 mode; 0245 }; 0246 0247 #define is_available_af(__info) (__info->ver.af) 0248 #define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code) 0249 #define is_manufacturer(__info, __manufacturer) \ 0250 (__info->ver.str[0] == __manufacturer[0] && \ 0251 __info->ver.str[1] == __manufacturer[1]) 0252 /* 0253 * I2C operation of the M-5MOLS 0254 * 0255 * The I2C read operation of the M-5MOLS requires 2 messages. The first 0256 * message sends the information about the command, command category, and total 0257 * message size. The second message is used to retrieve the data specified in 0258 * the first message 0259 * 0260 * 1st message 2nd message 0261 * +-------+---+----------+-----+-------+ +------+------+------+------+ 0262 * | size1 | R | category | cmd | size2 | | d[0] | d[1] | d[2] | d[3] | 0263 * +-------+---+----------+-----+-------+ +------+------+------+------+ 0264 * - size1: message data size(5 in this case) 0265 * - size2: desired buffer size of the 2nd message 0266 * - d[0..3]: according to size2 0267 * 0268 * The I2C write operation needs just one message. The message includes 0269 * category, command, total size, and desired data. 0270 * 0271 * 1st message 0272 * +-------+---+----------+-----+------+------+------+------+ 0273 * | size1 | W | category | cmd | d[0] | d[1] | d[2] | d[3] | 0274 * +-------+---+----------+-----+------+------+------+------+ 0275 * - d[0..3]: according to size1 0276 */ 0277 int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg_comb, u8 *val); 0278 int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg_comb, u16 *val); 0279 int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg_comb, u32 *val); 0280 int m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val); 0281 0282 int m5mols_busy_wait(struct v4l2_subdev *sd, u32 reg, u32 value, u32 mask, 0283 int timeout); 0284 0285 /* Mask value for busy waiting until M-5MOLS I2C interface is initialized */ 0286 #define M5MOLS_I2C_RDY_WAIT_FL (1 << 16) 0287 /* ISP state transition timeout, in ms */ 0288 #define M5MOLS_MODE_CHANGE_TIMEOUT 200 0289 #define M5MOLS_BUSY_WAIT_DEF_TIMEOUT 250 0290 0291 /* 0292 * Mode operation of the M-5MOLS 0293 * 0294 * Changing the mode of the M-5MOLS is needed right executing order. 0295 * There are three modes(PARAMETER, MONITOR, CAPTURE) which can be changed 0296 * by user. There are various categories associated with each mode. 0297 * 0298 * +============================================================+ 0299 * | mode | category | 0300 * +============================================================+ 0301 * | FLASH | FLASH(only after Stand-by or Power-on) | 0302 * | SYSTEM | SYSTEM(only after sensor arm-booting) | 0303 * | PARAMETER | PARAMETER | 0304 * | MONITOR | MONITOR(preview), Auto Focus, Face Detection | 0305 * | CAPTURE | Single CAPTURE, Preview(recording) | 0306 * +============================================================+ 0307 * 0308 * The available executing order between each modes are as follows: 0309 * PARAMETER <---> MONITOR <---> CAPTURE 0310 */ 0311 int m5mols_set_mode(struct m5mols_info *info, u8 mode); 0312 0313 int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg); 0314 int m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout); 0315 int m5mols_restore_controls(struct m5mols_info *info); 0316 int m5mols_start_capture(struct m5mols_info *info); 0317 int m5mols_do_scenemode(struct m5mols_info *info, u8 mode); 0318 int m5mols_lock_3a(struct m5mols_info *info, bool lock); 0319 int m5mols_set_ctrl(struct v4l2_ctrl *ctrl); 0320 int m5mols_init_controls(struct v4l2_subdev *sd); 0321 0322 /* The firmware function */ 0323 int m5mols_update_fw(struct v4l2_subdev *sd, 0324 int (*set_power)(struct m5mols_info *, bool)); 0325 0326 static inline struct m5mols_info *to_m5mols(struct v4l2_subdev *subdev) 0327 { 0328 return container_of(subdev, struct m5mols_info, sd); 0329 } 0330 0331 static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) 0332 { 0333 struct m5mols_info *info = container_of(ctrl->handler, 0334 struct m5mols_info, handle); 0335 return &info->sd; 0336 } 0337 0338 static inline void m5mols_set_ctrl_mode(struct v4l2_ctrl *ctrl, 0339 unsigned int mode) 0340 { 0341 ctrl->priv = (void *)(uintptr_t)mode; 0342 } 0343 0344 static inline unsigned int m5mols_get_ctrl_mode(struct v4l2_ctrl *ctrl) 0345 { 0346 return (unsigned int)(uintptr_t)ctrl->priv; 0347 } 0348 0349 #endif /* M5MOLS_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |