1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * drivers/media/i2c/ccs/ccs-quirk.h
5 * Generic driver for MIPI CCS/SMIA/SMIA++ compliant camera sensors
7 * Copyright (C) 2020 Intel Corporation
8 * Copyright (C) 2011--2012 Nokia Corporation
9 * Contact: Sakari Ailus <sakari.ailus@linux.intel.com>
18 * struct ccs_quirk - quirks for sensors that deviate from SMIA++ standard
20 * @limits: Replace sensor->limits with values which can't be read from
21 * sensor registers. Called the first time the sensor is powered up.
22 * @post_poweron: Called always after the sensor has been fully powered on.
23 * @pre_streamon: Called just before streaming is enabled.
24 * @post_streamoff: Called right after stopping streaming.
25 * @pll_flags: Return flags for the PLL calculator.
26 * @init: Quirk initialisation, called the last in probe(). This is
27 * also appropriate for adding sensor specific controls, for instance.
28 * @reg_access: Register access quirk. The quirk may divert the access
29 * to another register, or no register at all.
31 * -write: Is this read (false) or write (true) access?
32 * -reg: Pointer to the register to access
33 * -val: Register value, set by the caller on write, or
34 * by the quirk on read
35 * -return: 0 on success, -ENOIOCTLCMD if no register
36 * access may be done by the caller (default read
37 * value is zero), else negative error code on error
41 int (*limits
)(struct ccs_sensor
*sensor
);
42 int (*post_poweron
)(struct ccs_sensor
*sensor
);
43 int (*pre_streamon
)(struct ccs_sensor
*sensor
);
44 int (*post_streamoff
)(struct ccs_sensor
*sensor
);
45 unsigned long (*pll_flags
)(struct ccs_sensor
*sensor
);
46 int (*init
)(struct ccs_sensor
*sensor
);
47 int (*reg_access
)(struct ccs_sensor
*sensor
, bool write
, u32
*reg
,
52 #define CCS_QUIRK_FLAG_8BIT_READ_ONLY (1 << 0)
59 #define CCS_MK_QUIRK_REG_8(_reg, _val) \
65 #define ccs_call_quirk(sensor, _quirk, ...) \
66 ((sensor)->minfo.quirk && \
67 (sensor)->minfo.quirk->_quirk ? \
68 (sensor)->minfo.quirk->_quirk(sensor, ##__VA_ARGS__) : 0)
70 #define ccs_needs_quirk(sensor, _quirk) \
71 ((sensor)->minfo.quirk ? \
72 (sensor)->minfo.quirk->flags & _quirk : 0)
74 extern const struct ccs_quirk smiapp_jt8ev1_quirk
;
75 extern const struct ccs_quirk smiapp_imx125es_quirk
;
76 extern const struct ccs_quirk smiapp_jt8ew9_quirk
;
77 extern const struct ccs_quirk smiapp_tcm8500md_quirk
;
79 #endif /* __CCS_QUIRK__ */