18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Header for M-5MOLS 8M Pixel camera sensor with ISP 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2011 Samsung Electronics Co., Ltd. 68c2ecf20Sopenharmony_ci * Author: HeungJun Kim <riverful.kim@samsung.com> 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright (C) 2009 Samsung Electronics Co., Ltd. 98c2ecf20Sopenharmony_ci * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com> 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef M5MOLS_H 138c2ecf20Sopenharmony_ci#define M5MOLS_H 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/sizes.h> 168c2ecf20Sopenharmony_ci#include <media/v4l2-subdev.h> 178c2ecf20Sopenharmony_ci#include "m5mols_reg.h" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* An amount of data transmitted in addition to the value 218c2ecf20Sopenharmony_ci * determined by CAPP_JPEG_SIZE_MAX register. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#define M5MOLS_JPEG_TAGS_SIZE 0x20000 248c2ecf20Sopenharmony_ci#define M5MOLS_MAIN_JPEG_SIZE_MAX (5 * SZ_1M) 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ciextern int m5mols_debug; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cienum m5mols_restype { 298c2ecf20Sopenharmony_ci M5MOLS_RESTYPE_MONITOR, 308c2ecf20Sopenharmony_ci M5MOLS_RESTYPE_CAPTURE, 318c2ecf20Sopenharmony_ci M5MOLS_RESTYPE_MAX, 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/** 358c2ecf20Sopenharmony_ci * struct m5mols_resolution - structure for the resolution 368c2ecf20Sopenharmony_ci * @type: resolution type according to the pixel code 378c2ecf20Sopenharmony_ci * @width: width of the resolution 388c2ecf20Sopenharmony_ci * @height: height of the resolution 398c2ecf20Sopenharmony_ci * @reg: resolution preset register value 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_cistruct m5mols_resolution { 428c2ecf20Sopenharmony_ci u8 reg; 438c2ecf20Sopenharmony_ci enum m5mols_restype type; 448c2ecf20Sopenharmony_ci u16 width; 458c2ecf20Sopenharmony_ci u16 height; 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/** 498c2ecf20Sopenharmony_ci * struct m5mols_exif - structure for the EXIF information of M-5MOLS 508c2ecf20Sopenharmony_ci * @exposure_time: exposure time register value 518c2ecf20Sopenharmony_ci * @shutter_speed: speed of the shutter register value 528c2ecf20Sopenharmony_ci * @aperture: aperture register value 538c2ecf20Sopenharmony_ci * @exposure_bias: it calls also EV bias 548c2ecf20Sopenharmony_ci * @iso_speed: ISO register value 558c2ecf20Sopenharmony_ci * @flash: status register value of the flash 568c2ecf20Sopenharmony_ci * @sdr: status register value of the Subject Distance Range 578c2ecf20Sopenharmony_ci * @qval: not written exact meaning in document 588c2ecf20Sopenharmony_ci */ 598c2ecf20Sopenharmony_cistruct m5mols_exif { 608c2ecf20Sopenharmony_ci u32 exposure_time; 618c2ecf20Sopenharmony_ci u32 shutter_speed; 628c2ecf20Sopenharmony_ci u32 aperture; 638c2ecf20Sopenharmony_ci u32 brightness; 648c2ecf20Sopenharmony_ci u32 exposure_bias; 658c2ecf20Sopenharmony_ci u16 iso_speed; 668c2ecf20Sopenharmony_ci u16 flash; 678c2ecf20Sopenharmony_ci u16 sdr; 688c2ecf20Sopenharmony_ci u16 qval; 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/** 728c2ecf20Sopenharmony_ci * struct m5mols_capture - Structure for the capture capability 738c2ecf20Sopenharmony_ci * @exif: EXIF information 748c2ecf20Sopenharmony_ci * @buf_size: internal JPEG frame buffer size, in bytes 758c2ecf20Sopenharmony_ci * @main: size in bytes of the main image 768c2ecf20Sopenharmony_ci * @thumb: size in bytes of the thumb image, if it was accompanied 778c2ecf20Sopenharmony_ci * @total: total size in bytes of the produced image 788c2ecf20Sopenharmony_ci */ 798c2ecf20Sopenharmony_cistruct m5mols_capture { 808c2ecf20Sopenharmony_ci struct m5mols_exif exif; 818c2ecf20Sopenharmony_ci unsigned int buf_size; 828c2ecf20Sopenharmony_ci u32 main; 838c2ecf20Sopenharmony_ci u32 thumb; 848c2ecf20Sopenharmony_ci u32 total; 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/** 888c2ecf20Sopenharmony_ci * struct m5mols_scenemode - structure for the scenemode capability 898c2ecf20Sopenharmony_ci * @metering: metering light register value 908c2ecf20Sopenharmony_ci * @ev_bias: EV bias register value 918c2ecf20Sopenharmony_ci * @wb_mode: mode which means the WhiteBalance is Auto or Manual 928c2ecf20Sopenharmony_ci * @wb_preset: whitebalance preset register value in the Manual mode 938c2ecf20Sopenharmony_ci * @chroma_en: register value whether the Chroma capability is enabled or not 948c2ecf20Sopenharmony_ci * @chroma_lvl: chroma's level register value 958c2ecf20Sopenharmony_ci * @edge_en: register value Whether the Edge capability is enabled or not 968c2ecf20Sopenharmony_ci * @edge_lvl: edge's level register value 978c2ecf20Sopenharmony_ci * @af_range: Auto Focus's range 988c2ecf20Sopenharmony_ci * @fd_mode: Face Detection mode 998c2ecf20Sopenharmony_ci * @mcc: Multi-axis Color Conversion which means emotion color 1008c2ecf20Sopenharmony_ci * @light: status of the Light 1018c2ecf20Sopenharmony_ci * @flash: status of the Flash 1028c2ecf20Sopenharmony_ci * @tone: Tone color which means Contrast 1038c2ecf20Sopenharmony_ci * @iso: ISO register value 1048c2ecf20Sopenharmony_ci * @capt_mode: Mode of the Image Stabilization while the camera capturing 1058c2ecf20Sopenharmony_ci * @wdr: Wide Dynamic Range register value 1068c2ecf20Sopenharmony_ci * 1078c2ecf20Sopenharmony_ci * The each value according to each scenemode is recommended in the documents. 1088c2ecf20Sopenharmony_ci */ 1098c2ecf20Sopenharmony_cistruct m5mols_scenemode { 1108c2ecf20Sopenharmony_ci u8 metering; 1118c2ecf20Sopenharmony_ci u8 ev_bias; 1128c2ecf20Sopenharmony_ci u8 wb_mode; 1138c2ecf20Sopenharmony_ci u8 wb_preset; 1148c2ecf20Sopenharmony_ci u8 chroma_en; 1158c2ecf20Sopenharmony_ci u8 chroma_lvl; 1168c2ecf20Sopenharmony_ci u8 edge_en; 1178c2ecf20Sopenharmony_ci u8 edge_lvl; 1188c2ecf20Sopenharmony_ci u8 af_range; 1198c2ecf20Sopenharmony_ci u8 fd_mode; 1208c2ecf20Sopenharmony_ci u8 mcc; 1218c2ecf20Sopenharmony_ci u8 light; 1228c2ecf20Sopenharmony_ci u8 flash; 1238c2ecf20Sopenharmony_ci u8 tone; 1248c2ecf20Sopenharmony_ci u8 iso; 1258c2ecf20Sopenharmony_ci u8 capt_mode; 1268c2ecf20Sopenharmony_ci u8 wdr; 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci/** 1308c2ecf20Sopenharmony_ci * struct m5mols_version - firmware version information 1318c2ecf20Sopenharmony_ci * @customer: customer information 1328c2ecf20Sopenharmony_ci * @project: version of project information according to customer 1338c2ecf20Sopenharmony_ci * @fw: firmware revision 1348c2ecf20Sopenharmony_ci * @hw: hardware revision 1358c2ecf20Sopenharmony_ci * @param: version of the parameter 1368c2ecf20Sopenharmony_ci * @awb: Auto WhiteBalance algorithm version 1378c2ecf20Sopenharmony_ci * @str: information about manufacturer and packaging vendor 1388c2ecf20Sopenharmony_ci * @af: Auto Focus version 1398c2ecf20Sopenharmony_ci * 1408c2ecf20Sopenharmony_ci * The register offset starts the customer version at 0x0, and it ends 1418c2ecf20Sopenharmony_ci * the awb version at 0x09. The customer, project information occupies 1 bytes 1428c2ecf20Sopenharmony_ci * each. And also the fw, hw, param, awb each requires 2 bytes. The str is 1438c2ecf20Sopenharmony_ci * unique string associated with firmware's version. It includes information 1448c2ecf20Sopenharmony_ci * about manufacturer and the vendor of the sensor's packaging. The least 1458c2ecf20Sopenharmony_ci * significant 2 bytes of the string indicate packaging manufacturer. 1468c2ecf20Sopenharmony_ci */ 1478c2ecf20Sopenharmony_ci#define VERSION_STRING_SIZE 22 1488c2ecf20Sopenharmony_cistruct m5mols_version { 1498c2ecf20Sopenharmony_ci u8 customer; 1508c2ecf20Sopenharmony_ci u8 project; 1518c2ecf20Sopenharmony_ci u16 fw; 1528c2ecf20Sopenharmony_ci u16 hw; 1538c2ecf20Sopenharmony_ci u16 param; 1548c2ecf20Sopenharmony_ci u16 awb; 1558c2ecf20Sopenharmony_ci u8 str[VERSION_STRING_SIZE]; 1568c2ecf20Sopenharmony_ci u8 af; 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci/** 1608c2ecf20Sopenharmony_ci * struct m5mols_info - M-5MOLS driver data structure 1618c2ecf20Sopenharmony_ci * @pdata: platform data 1628c2ecf20Sopenharmony_ci * @sd: v4l-subdev instance 1638c2ecf20Sopenharmony_ci * @pad: media pad 1648c2ecf20Sopenharmony_ci * @irq_waitq: waitqueue for the capture 1658c2ecf20Sopenharmony_ci * @irq_done: set to 1 in the interrupt handler 1668c2ecf20Sopenharmony_ci * @handle: control handler 1678c2ecf20Sopenharmony_ci * @auto_exposure: auto/manual exposure control 1688c2ecf20Sopenharmony_ci * @exposure_bias: exposure compensation control 1698c2ecf20Sopenharmony_ci * @exposure: manual exposure control 1708c2ecf20Sopenharmony_ci * @metering: exposure metering control 1718c2ecf20Sopenharmony_ci * @auto_iso: auto/manual ISO sensitivity control 1728c2ecf20Sopenharmony_ci * @iso: manual ISO sensitivity control 1738c2ecf20Sopenharmony_ci * @auto_wb: auto white balance control 1748c2ecf20Sopenharmony_ci * @lock_3a: 3A lock control 1758c2ecf20Sopenharmony_ci * @colorfx: color effect control 1768c2ecf20Sopenharmony_ci * @saturation: saturation control 1778c2ecf20Sopenharmony_ci * @zoom: zoom control 1788c2ecf20Sopenharmony_ci * @wdr: wide dynamic range control 1798c2ecf20Sopenharmony_ci * @stabilization: image stabilization control 1808c2ecf20Sopenharmony_ci * @jpeg_quality: JPEG compression quality control 1818c2ecf20Sopenharmony_ci * @set_power: optional power callback to the board code 1828c2ecf20Sopenharmony_ci * @lock: mutex protecting the structure fields below 1838c2ecf20Sopenharmony_ci * @ffmt: current fmt according to resolution type 1848c2ecf20Sopenharmony_ci * @res_type: current resolution type 1858c2ecf20Sopenharmony_ci * @ver: information of the version 1868c2ecf20Sopenharmony_ci * @cap: the capture mode attributes 1878c2ecf20Sopenharmony_ci * @isp_ready: 1 when the ISP controller has completed booting 1888c2ecf20Sopenharmony_ci * @power: current sensor's power status 1898c2ecf20Sopenharmony_ci * @ctrl_sync: 1 when the control handler state is restored in H/W 1908c2ecf20Sopenharmony_ci * @resolution: register value for current resolution 1918c2ecf20Sopenharmony_ci * @mode: register value for current operation mode 1928c2ecf20Sopenharmony_ci */ 1938c2ecf20Sopenharmony_cistruct m5mols_info { 1948c2ecf20Sopenharmony_ci const struct m5mols_platform_data *pdata; 1958c2ecf20Sopenharmony_ci struct v4l2_subdev sd; 1968c2ecf20Sopenharmony_ci struct media_pad pad; 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci wait_queue_head_t irq_waitq; 1998c2ecf20Sopenharmony_ci atomic_t irq_done; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci struct v4l2_ctrl_handler handle; 2028c2ecf20Sopenharmony_ci struct { 2038c2ecf20Sopenharmony_ci /* exposure/exposure bias/auto exposure cluster */ 2048c2ecf20Sopenharmony_ci struct v4l2_ctrl *auto_exposure; 2058c2ecf20Sopenharmony_ci struct v4l2_ctrl *exposure_bias; 2068c2ecf20Sopenharmony_ci struct v4l2_ctrl *exposure; 2078c2ecf20Sopenharmony_ci struct v4l2_ctrl *metering; 2088c2ecf20Sopenharmony_ci }; 2098c2ecf20Sopenharmony_ci struct { 2108c2ecf20Sopenharmony_ci /* iso/auto iso cluster */ 2118c2ecf20Sopenharmony_ci struct v4l2_ctrl *auto_iso; 2128c2ecf20Sopenharmony_ci struct v4l2_ctrl *iso; 2138c2ecf20Sopenharmony_ci }; 2148c2ecf20Sopenharmony_ci struct v4l2_ctrl *auto_wb; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci struct v4l2_ctrl *lock_3a; 2178c2ecf20Sopenharmony_ci struct v4l2_ctrl *colorfx; 2188c2ecf20Sopenharmony_ci struct v4l2_ctrl *saturation; 2198c2ecf20Sopenharmony_ci struct v4l2_ctrl *zoom; 2208c2ecf20Sopenharmony_ci struct v4l2_ctrl *wdr; 2218c2ecf20Sopenharmony_ci struct v4l2_ctrl *stabilization; 2228c2ecf20Sopenharmony_ci struct v4l2_ctrl *jpeg_quality; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci int (*set_power)(struct device *dev, int on); 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci struct mutex lock; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci struct v4l2_mbus_framefmt ffmt[M5MOLS_RESTYPE_MAX]; 2298c2ecf20Sopenharmony_ci int res_type; 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci struct m5mols_version ver; 2328c2ecf20Sopenharmony_ci struct m5mols_capture cap; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci unsigned int isp_ready:1; 2358c2ecf20Sopenharmony_ci unsigned int power:1; 2368c2ecf20Sopenharmony_ci unsigned int ctrl_sync:1; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci u8 resolution; 2398c2ecf20Sopenharmony_ci u8 mode; 2408c2ecf20Sopenharmony_ci}; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci#define is_available_af(__info) (__info->ver.af) 2438c2ecf20Sopenharmony_ci#define is_code(__code, __type) (__code == m5mols_default_ffmt[__type].code) 2448c2ecf20Sopenharmony_ci#define is_manufacturer(__info, __manufacturer) \ 2458c2ecf20Sopenharmony_ci (__info->ver.str[0] == __manufacturer[0] && \ 2468c2ecf20Sopenharmony_ci __info->ver.str[1] == __manufacturer[1]) 2478c2ecf20Sopenharmony_ci/* 2488c2ecf20Sopenharmony_ci * I2C operation of the M-5MOLS 2498c2ecf20Sopenharmony_ci * 2508c2ecf20Sopenharmony_ci * The I2C read operation of the M-5MOLS requires 2 messages. The first 2518c2ecf20Sopenharmony_ci * message sends the information about the command, command category, and total 2528c2ecf20Sopenharmony_ci * message size. The second message is used to retrieve the data specified in 2538c2ecf20Sopenharmony_ci * the first message 2548c2ecf20Sopenharmony_ci * 2558c2ecf20Sopenharmony_ci * 1st message 2nd message 2568c2ecf20Sopenharmony_ci * +-------+---+----------+-----+-------+ +------+------+------+------+ 2578c2ecf20Sopenharmony_ci * | size1 | R | category | cmd | size2 | | d[0] | d[1] | d[2] | d[3] | 2588c2ecf20Sopenharmony_ci * +-------+---+----------+-----+-------+ +------+------+------+------+ 2598c2ecf20Sopenharmony_ci * - size1: message data size(5 in this case) 2608c2ecf20Sopenharmony_ci * - size2: desired buffer size of the 2nd message 2618c2ecf20Sopenharmony_ci * - d[0..3]: according to size2 2628c2ecf20Sopenharmony_ci * 2638c2ecf20Sopenharmony_ci * The I2C write operation needs just one message. The message includes 2648c2ecf20Sopenharmony_ci * category, command, total size, and desired data. 2658c2ecf20Sopenharmony_ci * 2668c2ecf20Sopenharmony_ci * 1st message 2678c2ecf20Sopenharmony_ci * +-------+---+----------+-----+------+------+------+------+ 2688c2ecf20Sopenharmony_ci * | size1 | W | category | cmd | d[0] | d[1] | d[2] | d[3] | 2698c2ecf20Sopenharmony_ci * +-------+---+----------+-----+------+------+------+------+ 2708c2ecf20Sopenharmony_ci * - d[0..3]: according to size1 2718c2ecf20Sopenharmony_ci */ 2728c2ecf20Sopenharmony_ciint m5mols_read_u8(struct v4l2_subdev *sd, u32 reg_comb, u8 *val); 2738c2ecf20Sopenharmony_ciint m5mols_read_u16(struct v4l2_subdev *sd, u32 reg_comb, u16 *val); 2748c2ecf20Sopenharmony_ciint m5mols_read_u32(struct v4l2_subdev *sd, u32 reg_comb, u32 *val); 2758c2ecf20Sopenharmony_ciint m5mols_write(struct v4l2_subdev *sd, u32 reg_comb, u32 val); 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ciint m5mols_busy_wait(struct v4l2_subdev *sd, u32 reg, u32 value, u32 mask, 2788c2ecf20Sopenharmony_ci int timeout); 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci/* Mask value for busy waiting until M-5MOLS I2C interface is initialized */ 2818c2ecf20Sopenharmony_ci#define M5MOLS_I2C_RDY_WAIT_FL (1 << 16) 2828c2ecf20Sopenharmony_ci/* ISP state transition timeout, in ms */ 2838c2ecf20Sopenharmony_ci#define M5MOLS_MODE_CHANGE_TIMEOUT 200 2848c2ecf20Sopenharmony_ci#define M5MOLS_BUSY_WAIT_DEF_TIMEOUT 250 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci/* 2878c2ecf20Sopenharmony_ci * Mode operation of the M-5MOLS 2888c2ecf20Sopenharmony_ci * 2898c2ecf20Sopenharmony_ci * Changing the mode of the M-5MOLS is needed right executing order. 2908c2ecf20Sopenharmony_ci * There are three modes(PARAMETER, MONITOR, CAPTURE) which can be changed 2918c2ecf20Sopenharmony_ci * by user. There are various categories associated with each mode. 2928c2ecf20Sopenharmony_ci * 2938c2ecf20Sopenharmony_ci * +============================================================+ 2948c2ecf20Sopenharmony_ci * | mode | category | 2958c2ecf20Sopenharmony_ci * +============================================================+ 2968c2ecf20Sopenharmony_ci * | FLASH | FLASH(only after Stand-by or Power-on) | 2978c2ecf20Sopenharmony_ci * | SYSTEM | SYSTEM(only after sensor arm-booting) | 2988c2ecf20Sopenharmony_ci * | PARAMETER | PARAMETER | 2998c2ecf20Sopenharmony_ci * | MONITOR | MONITOR(preview), Auto Focus, Face Detection | 3008c2ecf20Sopenharmony_ci * | CAPTURE | Single CAPTURE, Preview(recording) | 3018c2ecf20Sopenharmony_ci * +============================================================+ 3028c2ecf20Sopenharmony_ci * 3038c2ecf20Sopenharmony_ci * The available executing order between each modes are as follows: 3048c2ecf20Sopenharmony_ci * PARAMETER <---> MONITOR <---> CAPTURE 3058c2ecf20Sopenharmony_ci */ 3068c2ecf20Sopenharmony_ciint m5mols_set_mode(struct m5mols_info *info, u8 mode); 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ciint m5mols_enable_interrupt(struct v4l2_subdev *sd, u8 reg); 3098c2ecf20Sopenharmony_ciint m5mols_wait_interrupt(struct v4l2_subdev *sd, u8 condition, u32 timeout); 3108c2ecf20Sopenharmony_ciint m5mols_restore_controls(struct m5mols_info *info); 3118c2ecf20Sopenharmony_ciint m5mols_start_capture(struct m5mols_info *info); 3128c2ecf20Sopenharmony_ciint m5mols_do_scenemode(struct m5mols_info *info, u8 mode); 3138c2ecf20Sopenharmony_ciint m5mols_lock_3a(struct m5mols_info *info, bool lock); 3148c2ecf20Sopenharmony_ciint m5mols_set_ctrl(struct v4l2_ctrl *ctrl); 3158c2ecf20Sopenharmony_ciint m5mols_init_controls(struct v4l2_subdev *sd); 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci/* The firmware function */ 3188c2ecf20Sopenharmony_ciint m5mols_update_fw(struct v4l2_subdev *sd, 3198c2ecf20Sopenharmony_ci int (*set_power)(struct m5mols_info *, bool)); 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_cistatic inline struct m5mols_info *to_m5mols(struct v4l2_subdev *subdev) 3228c2ecf20Sopenharmony_ci{ 3238c2ecf20Sopenharmony_ci return container_of(subdev, struct m5mols_info, sd); 3248c2ecf20Sopenharmony_ci} 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_cistatic inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) 3278c2ecf20Sopenharmony_ci{ 3288c2ecf20Sopenharmony_ci struct m5mols_info *info = container_of(ctrl->handler, 3298c2ecf20Sopenharmony_ci struct m5mols_info, handle); 3308c2ecf20Sopenharmony_ci return &info->sd; 3318c2ecf20Sopenharmony_ci} 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_cistatic inline void m5mols_set_ctrl_mode(struct v4l2_ctrl *ctrl, 3348c2ecf20Sopenharmony_ci unsigned int mode) 3358c2ecf20Sopenharmony_ci{ 3368c2ecf20Sopenharmony_ci ctrl->priv = (void *)(uintptr_t)mode; 3378c2ecf20Sopenharmony_ci} 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cistatic inline unsigned int m5mols_get_ctrl_mode(struct v4l2_ctrl *ctrl) 3408c2ecf20Sopenharmony_ci{ 3418c2ecf20Sopenharmony_ci return (unsigned int)(uintptr_t)ctrl->priv; 3428c2ecf20Sopenharmony_ci} 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci#endif /* M5MOLS_H */ 345