^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Header for M-5MOLS 8M Pixel camera sensor with ISP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2011 Samsung Electronics Co., Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Author: HeungJun Kim <riverful.kim@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (C) 2009 Samsung Electronics Co., Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifndef M5MOLS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define M5MOLS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/sizes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <media/v4l2-subdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "m5mols_reg.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* An amount of data transmitted in addition to the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * determined by CAPP_JPEG_SIZE_MAX register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define M5MOLS_JPEG_TAGS_SIZE 0x20000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define M5MOLS_MAIN_JPEG_SIZE_MAX (5 * SZ_1M)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) extern int m5mols_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) enum m5mols_restype {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) M5MOLS_RESTYPE_MONITOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) M5MOLS_RESTYPE_CAPTURE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) M5MOLS_RESTYPE_MAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * struct m5mols_resolution - structure for the resolution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * @type: resolution type according to the pixel code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * @width: width of the resolution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * @height: height of the resolution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * @reg: resolution preset register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct m5mols_resolution {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) u8 reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) enum m5mols_restype type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) u16 width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) u16 height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * struct m5mols_exif - structure for the EXIF information of M-5MOLS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * @exposure_time: exposure time register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @shutter_speed: speed of the shutter register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @aperture: aperture register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * @exposure_bias: it calls also EV bias
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * @iso_speed: ISO register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * @flash: status register value of the flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * @sdr: status register value of the Subject Distance Range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @qval: not written exact meaning in document
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct m5mols_exif {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) u32 exposure_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) u32 shutter_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) u32 aperture;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u32 brightness;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u32 exposure_bias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) u16 iso_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) u16 flash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u16 sdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u16 qval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * struct m5mols_capture - Structure for the capture capability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * @exif: EXIF information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * @buf_size: internal JPEG frame buffer size, in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @main: size in bytes of the main image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * @thumb: size in bytes of the thumb image, if it was accompanied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * @total: total size in bytes of the produced image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct m5mols_capture {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct m5mols_exif exif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) unsigned int buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u32 main;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) u32 thumb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) u32 total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * struct m5mols_scenemode - structure for the scenemode capability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * @metering: metering light register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * @ev_bias: EV bias register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * @wb_mode: mode which means the WhiteBalance is Auto or Manual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * @wb_preset: whitebalance preset register value in the Manual mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * @chroma_en: register value whether the Chroma capability is enabled or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * @chroma_lvl: chroma's level register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * @edge_en: register value Whether the Edge capability is enabled or not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * @edge_lvl: edge's level register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * @af_range: Auto Focus's range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * @fd_mode: Face Detection mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * @mcc: Multi-axis Color Conversion which means emotion color
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * @light: status of the Light
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * @flash: status of the Flash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @tone: Tone color which means Contrast
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * @iso: ISO register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * @capt_mode: Mode of the Image Stabilization while the camera capturing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * @wdr: Wide Dynamic Range register value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * The each value according to each scenemode is recommended in the documents.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct m5mols_scenemode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) u8 metering;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) u8 ev_bias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) u8 wb_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) u8 wb_preset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) u8 chroma_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) u8 chroma_lvl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) u8 edge_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) u8 edge_lvl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) u8 af_range;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) u8 fd_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) u8 mcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) u8 light;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u8 flash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) u8 tone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) u8 iso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) u8 capt_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) u8 wdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * struct m5mols_version - firmware version information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * @customer: customer information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * @project: version of project information according to customer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * @fw: firmware revision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * @hw: hardware revision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * @param: version of the parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * @awb: Auto WhiteBalance algorithm version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * @str: information about manufacturer and packaging vendor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * @af: Auto Focus version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * The register offset starts the customer version at 0x0, and it ends
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * the awb version at 0x09. The customer, project information occupies 1 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * each. And also the fw, hw, param, awb each requires 2 bytes. The str is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * unique string associated with firmware's version. It includes information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * about manufacturer and the vendor of the sensor's packaging. The least
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * significant 2 bytes of the string indicate packaging manufacturer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define VERSION_STRING_SIZE 22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct m5mols_version {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) u8 customer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) u8 project;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) u16 fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) u16 hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) u16 param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) u16 awb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) u8 str[VERSION_STRING_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) u8 af;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * struct m5mols_info - M-5MOLS driver data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * @pdata: platform data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * @sd: v4l-subdev instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * @pad: media pad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * @irq_waitq: waitqueue for the capture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * @irq_done: set to 1 in the interrupt handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * @handle: control handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * @auto_exposure: auto/manual exposure control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * @exposure_bias: exposure compensation control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * @exposure: manual exposure control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * @metering: exposure metering control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * @auto_iso: auto/manual ISO sensitivity control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * @iso: manual ISO sensitivity control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * @auto_wb: auto white balance control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * @lock_3a: 3A lock control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * @colorfx: color effect control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * @saturation: saturation control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * @zoom: zoom control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * @wdr: wide dynamic range control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * @stabilization: image stabilization control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * @jpeg_quality: JPEG compression quality control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * @set_power: optional power callback to the board code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * @lock: mutex protecting the structure fields below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * @ffmt: current fmt according to resolution type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * @res_type: current resolution type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * @ver: information of the version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * @cap: the capture mode attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * @isp_ready: 1 when the ISP controller has completed booting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * @power: current sensor's power status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * @ctrl_sync: 1 when the control handler state is restored in H/W
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * @resolution: register value for current resolution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * @mode: register value for current operation mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct m5mols_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) const struct m5mols_platform_data *pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct v4l2_subdev sd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct media_pad pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) wait_queue_head_t irq_waitq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) atomic_t irq_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) struct v4l2_ctrl_handler handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /* exposure/exposure bias/auto exposure cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) struct v4l2_ctrl *auto_exposure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct v4l2_ctrl *exposure_bias;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct v4l2_ctrl *exposure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct v4l2_ctrl *metering;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /* iso/auto iso cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct v4l2_ctrl *auto_iso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct v4l2_ctrl *iso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct v4l2_ctrl *auto_wb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct v4l2_ctrl *lock_3a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct v4l2_ctrl *colorfx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct v4l2_ctrl *saturation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) struct v4l2_ctrl *zoom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct v4l2_ctrl *wdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct v4l2_ctrl *stabilization;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct v4l2_ctrl *jpeg_quality;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) int (*set_power)(struct device *dev, int on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) int res_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct m5mols_version ver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct m5mols_capture cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) unsigned int isp_ready:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) unsigned int power:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) unsigned int ctrl_sync:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) u8 resolution;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) u8 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define is_available_af(__info) (__info->ver.af)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) #define is_manufacturer(__info, __manufacturer) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) (__info->ver.str[0] == __manufacturer[0] && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) __info->ver.str[1] == __manufacturer[1])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * I2C operation of the M-5MOLS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * The I2C read operation of the M-5MOLS requires 2 messages. The first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * message sends the information about the command, command category, and total
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * message size. The second message is used to retrieve the data specified in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * the first message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * 1st message 2nd message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * +-------+---+----------+-----+-------+ +------+------+------+------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * | size1 | R | category | cmd | size2 | | d[0] | d[1] | d[2] | d[3] |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * +-------+---+----------+-----+-------+ +------+------+------+------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * - size1: message data size(5 in this case)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * - size2: desired buffer size of the 2nd message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * - d[0..3]: according to size2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * The I2C write operation needs just one message. The message includes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * category, command, total size, and desired data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * 1st message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * +-------+---+----------+-----+------+------+------+------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * | size1 | W | category | cmd | d[0] | d[1] | d[2] | d[3] |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * +-------+---+----------+-----+------+------+------+------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * - d[0..3]: according to size1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) int m5mols_read_u8(struct v4l2_subdev *sd, u32 reg_comb, u8 *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int m5mols_read_u16(struct v4l2_subdev *sd, u32 reg_comb, u16 *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) int m5mols_read_u32(struct v4l2_subdev *sd, u32 reg_comb, u32 *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) int m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) int m5mols_busy_wait(struct v4l2_subdev *sd, u32 reg, u32 value, u32 mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) int timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /* Mask value for busy waiting until M-5MOLS I2C interface is initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) #define M5MOLS_I2C_RDY_WAIT_FL (1 << 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) /* ISP state transition timeout, in ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #define M5MOLS_MODE_CHANGE_TIMEOUT 200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) #define M5MOLS_BUSY_WAIT_DEF_TIMEOUT 250
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * Mode operation of the M-5MOLS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * Changing the mode of the M-5MOLS is needed right executing order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * There are three modes(PARAMETER, MONITOR, CAPTURE) which can be changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * by user. There are various categories associated with each mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * +============================================================+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) * | mode | category |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) * +============================================================+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * | FLASH | FLASH(only after Stand-by or Power-on) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * | SYSTEM | SYSTEM(only after sensor arm-booting) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) * | PARAMETER | PARAMETER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * | MONITOR | MONITOR(preview), Auto Focus, Face Detection |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * | CAPTURE | Single CAPTURE, Preview(recording) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * +============================================================+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * The available executing order between each modes are as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * PARAMETER <---> MONITOR <---> CAPTURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) int m5mols_set_mode(struct m5mols_info *info, u8 mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) int m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) int m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) int m5mols_restore_controls(struct m5mols_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) int m5mols_start_capture(struct m5mols_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) int m5mols_do_scenemode(struct m5mols_info *info, u8 mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) int m5mols_lock_3a(struct m5mols_info *info, bool lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) int m5mols_set_ctrl(struct v4l2_ctrl *ctrl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) int m5mols_init_controls(struct v4l2_subdev *sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) /* The firmware function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) int m5mols_update_fw(struct v4l2_subdev *sd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) int (*set_power)(struct m5mols_info *, bool));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static inline struct m5mols_info *to_m5mols(struct v4l2_subdev *subdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) return container_of(subdev, struct m5mols_info, sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct m5mols_info *info = container_of(ctrl->handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct m5mols_info, handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return &info->sd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) static inline void m5mols_set_ctrl_mode(struct v4l2_ctrl *ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) unsigned int mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) ctrl->priv = (void *)(uintptr_t)mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) static inline unsigned int m5mols_get_ctrl_mode(struct v4l2_ctrl *ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) return (unsigned int)(uintptr_t)ctrl->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) #endif /* M5MOLS_H */