Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * drivers/media/i2c/ccs/ccs-quirk.h
0004  *
0005  * Generic driver for MIPI CCS/SMIA/SMIA++ compliant camera sensors
0006  *
0007  * Copyright (C) 2020 Intel Corporation
0008  * Copyright (C) 2011--2012 Nokia Corporation
0009  * Contact: Sakari Ailus <sakari.ailus@linux.intel.com>
0010  */
0011 
0012 #ifndef __CCS_QUIRK__
0013 #define __CCS_QUIRK__
0014 
0015 struct ccs_sensor;
0016 
0017 /**
0018  * struct ccs_quirk - quirks for sensors that deviate from SMIA++ standard
0019  *
0020  * @limits: Replace sensor->limits with values which can't be read from
0021  *      sensor registers. Called the first time the sensor is powered up.
0022  * @post_poweron: Called always after the sensor has been fully powered on.
0023  * @pre_streamon: Called just before streaming is enabled.
0024  * @post_streamoff: Called right after stopping streaming.
0025  * @pll_flags: Return flags for the PLL calculator.
0026  * @init: Quirk initialisation, called the last in probe(). This is
0027  *    also appropriate for adding sensor specific controls, for instance.
0028  * @reg_access: Register access quirk. The quirk may divert the access
0029  *      to another register, or no register at all.
0030  *
0031  *      @write: Is this read (false) or write (true) access?
0032  *      @reg: Pointer to the register to access
0033  *      @value: Register value, set by the caller on write, or
0034  *          by the quirk on read
0035  *
0036  * @flags: Quirk flags
0037  *
0038  *      @return: 0 on success, -ENOIOCTLCMD if no register
0039  *           access may be done by the caller (default read
0040  *           value is zero), else negative error code on error
0041  */
0042 struct ccs_quirk {
0043     int (*limits)(struct ccs_sensor *sensor);
0044     int (*post_poweron)(struct ccs_sensor *sensor);
0045     int (*pre_streamon)(struct ccs_sensor *sensor);
0046     int (*post_streamoff)(struct ccs_sensor *sensor);
0047     unsigned long (*pll_flags)(struct ccs_sensor *sensor);
0048     int (*init)(struct ccs_sensor *sensor);
0049     int (*reg_access)(struct ccs_sensor *sensor, bool write, u32 *reg,
0050               u32 *val);
0051     unsigned long flags;
0052 };
0053 
0054 #define CCS_QUIRK_FLAG_8BIT_READ_ONLY           (1 << 0)
0055 
0056 struct ccs_reg_8 {
0057     u16 reg;
0058     u8 val;
0059 };
0060 
0061 #define CCS_MK_QUIRK_REG_8(_reg, _val) \
0062     {               \
0063         .reg = (u16)_reg,   \
0064         .val = _val,        \
0065     }
0066 
0067 #define ccs_call_quirk(sensor, _quirk, ...)             \
0068     ((sensor)->minfo.quirk &&                   \
0069      (sensor)->minfo.quirk->_quirk ?                \
0070      (sensor)->minfo.quirk->_quirk(sensor, ##__VA_ARGS__) : 0)
0071 
0072 #define ccs_needs_quirk(sensor, _quirk)     \
0073     ((sensor)->minfo.quirk ?            \
0074      (sensor)->minfo.quirk->flags & _quirk : 0)
0075 
0076 extern const struct ccs_quirk smiapp_jt8ev1_quirk;
0077 extern const struct ccs_quirk smiapp_imx125es_quirk;
0078 extern const struct ccs_quirk smiapp_jt8ew9_quirk;
0079 extern const struct ccs_quirk smiapp_tcm8500md_quirk;
0080 
0081 #endif /* __CCS_QUIRK__ */