treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / media / i2c / smiapp / smiapp-quirk.h
blob17505be60c1d4aab9d12e7cbd52557f02fab4e19
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * drivers/media/i2c/smiapp/smiapp-quirk.h
5 * Generic driver for SMIA/SMIA++ compliant camera modules
7 * Copyright (C) 2011--2012 Nokia Corporation
8 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
9 */
11 #ifndef __SMIAPP_QUIRK__
12 #define __SMIAPP_QUIRK__
14 struct smiapp_sensor;
16 /**
17 * struct smiapp_quirk - quirks for sensors that deviate from SMIA++ standard
19 * @limits: Replace sensor->limits with values which can't be read from
20 * sensor registers. Called the first time the sensor is powered up.
21 * @post_poweron: Called always after the sensor has been fully powered on.
22 * @pre_streamon: Called just before streaming is enabled.
23 * @post_streamon: Called right after stopping streaming.
24 * @pll_flags: Return flags for the PLL calculator.
25 * @init: Quirk initialisation, called the last in probe(). This is
26 * also appropriate for adding sensor specific controls, for instance.
27 * @reg_access: Register access quirk. The quirk may divert the access
28 * to another register, or no register at all.
30 * @write: Is this read (false) or write (true) access?
31 * @reg: Pointer to the register to access
32 * @value: Register value, set by the caller on write, or
33 * 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
39 struct smiapp_quirk {
40 int (*limits)(struct smiapp_sensor *sensor);
41 int (*post_poweron)(struct smiapp_sensor *sensor);
42 int (*pre_streamon)(struct smiapp_sensor *sensor);
43 int (*post_streamoff)(struct smiapp_sensor *sensor);
44 unsigned long (*pll_flags)(struct smiapp_sensor *sensor);
45 int (*init)(struct smiapp_sensor *sensor);
46 int (*reg_access)(struct smiapp_sensor *sensor, bool write, u32 *reg,
47 u32 *val);
48 unsigned long flags;
51 #define SMIAPP_QUIRK_FLAG_8BIT_READ_ONLY (1 << 0)
53 struct smiapp_reg_8 {
54 u16 reg;
55 u8 val;
58 void smiapp_replace_limit(struct smiapp_sensor *sensor,
59 u32 limit, u32 val);
61 #define SMIAPP_MK_QUIRK_REG_8(_reg, _val) \
62 { \
63 .reg = (u16)_reg, \
64 .val = _val, \
67 #define smiapp_call_quirk(sensor, _quirk, ...) \
68 ((sensor)->minfo.quirk && \
69 (sensor)->minfo.quirk->_quirk ? \
70 (sensor)->minfo.quirk->_quirk(sensor, ##__VA_ARGS__) : 0)
72 #define smiapp_needs_quirk(sensor, _quirk) \
73 ((sensor)->minfo.quirk ? \
74 (sensor)->minfo.quirk->flags & _quirk : 0)
76 extern const struct smiapp_quirk smiapp_jt8ev1_quirk;
77 extern const struct smiapp_quirk smiapp_imx125es_quirk;
78 extern const struct smiapp_quirk smiapp_jt8ew9_quirk;
79 extern const struct smiapp_quirk smiapp_tcm8500md_quirk;
81 #endif /* __SMIAPP_QUIRK__ */