2019-05-27 06:55:21 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2012-03-03 20:19:52 +00:00
|
|
|
/*
|
2012-08-14 19:23:43 +00:00
|
|
|
* drivers/media/i2c/smiapp/smiapp-quirk.h
|
2012-03-03 20:19:52 +00:00
|
|
|
*
|
|
|
|
* Generic driver for SMIA/SMIA++ compliant camera modules
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011--2012 Nokia Corporation
|
2012-10-28 09:44:17 +00:00
|
|
|
* Contact: Sakari Ailus <sakari.ailus@iki.fi>
|
2012-03-03 20:19:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SMIAPP_QUIRK__
|
|
|
|
#define __SMIAPP_QUIRK__
|
|
|
|
|
|
|
|
struct smiapp_sensor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct smiapp_quirk - quirks for sensors that deviate from SMIA++ standard
|
|
|
|
*
|
|
|
|
* @limits: Replace sensor->limits with values which can't be read from
|
|
|
|
* sensor registers. Called the first time the sensor is powered up.
|
|
|
|
* @post_poweron: Called always after the sensor has been fully powered on.
|
|
|
|
* @pre_streamon: Called just before streaming is enabled.
|
|
|
|
* @post_streamon: Called right after stopping streaming.
|
2014-10-03 14:38:32 +00:00
|
|
|
* @pll_flags: Return flags for the PLL calculator.
|
|
|
|
* @init: Quirk initialisation, called the last in probe(). This is
|
|
|
|
* also appropriate for adding sensor specific controls, for instance.
|
2014-04-01 11:37:38 +00:00
|
|
|
* @reg_access: Register access quirk. The quirk may divert the access
|
|
|
|
* to another register, or no register at all.
|
|
|
|
*
|
|
|
|
* @write: Is this read (false) or write (true) access?
|
|
|
|
* @reg: Pointer to the register to access
|
|
|
|
* @value: Register value, set by the caller on write, or
|
|
|
|
* by the quirk on read
|
|
|
|
*
|
|
|
|
* @return: 0 on success, -ENOIOCTLCMD if no register
|
|
|
|
* access may be done by the caller (default read
|
|
|
|
* value is zero), else negative error code on error
|
2012-03-03 20:19:52 +00:00
|
|
|
*/
|
|
|
|
struct smiapp_quirk {
|
|
|
|
int (*limits)(struct smiapp_sensor *sensor);
|
|
|
|
int (*post_poweron)(struct smiapp_sensor *sensor);
|
|
|
|
int (*pre_streamon)(struct smiapp_sensor *sensor);
|
|
|
|
int (*post_streamoff)(struct smiapp_sensor *sensor);
|
2014-04-08 21:18:10 +00:00
|
|
|
unsigned long (*pll_flags)(struct smiapp_sensor *sensor);
|
2014-10-03 14:38:32 +00:00
|
|
|
int (*init)(struct smiapp_sensor *sensor);
|
2014-04-01 11:37:38 +00:00
|
|
|
int (*reg_access)(struct smiapp_sensor *sensor, bool write, u32 *reg,
|
|
|
|
u32 *val);
|
2012-03-03 20:19:52 +00:00
|
|
|
unsigned long flags;
|
|
|
|
};
|
|
|
|
|
2014-02-12 13:33:51 +00:00
|
|
|
#define SMIAPP_QUIRK_FLAG_8BIT_READ_ONLY (1 << 0)
|
2012-03-03 20:19:52 +00:00
|
|
|
|
|
|
|
struct smiapp_reg_8 {
|
|
|
|
u16 reg;
|
|
|
|
u8 val;
|
|
|
|
};
|
|
|
|
|
|
|
|
void smiapp_replace_limit(struct smiapp_sensor *sensor,
|
|
|
|
u32 limit, u32 val);
|
|
|
|
|
2014-04-11 09:30:18 +00:00
|
|
|
#define SMIAPP_MK_QUIRK_REG_8(_reg, _val) \
|
|
|
|
{ \
|
|
|
|
.reg = (u16)_reg, \
|
|
|
|
.val = _val, \
|
|
|
|
}
|
|
|
|
|
2014-12-09 21:43:16 +00:00
|
|
|
#define smiapp_call_quirk(sensor, _quirk, ...) \
|
|
|
|
((sensor)->minfo.quirk && \
|
|
|
|
(sensor)->minfo.quirk->_quirk ? \
|
|
|
|
(sensor)->minfo.quirk->_quirk(sensor, ##__VA_ARGS__) : 0)
|
2012-03-03 20:19:52 +00:00
|
|
|
|
2014-12-09 21:43:16 +00:00
|
|
|
#define smiapp_needs_quirk(sensor, _quirk) \
|
|
|
|
((sensor)->minfo.quirk ? \
|
|
|
|
(sensor)->minfo.quirk->flags & _quirk : 0)
|
2012-03-03 20:19:52 +00:00
|
|
|
|
|
|
|
extern const struct smiapp_quirk smiapp_jt8ev1_quirk;
|
|
|
|
extern const struct smiapp_quirk smiapp_imx125es_quirk;
|
|
|
|
extern const struct smiapp_quirk smiapp_jt8ew9_quirk;
|
|
|
|
extern const struct smiapp_quirk smiapp_tcm8500md_quirk;
|
|
|
|
|
|
|
|
#endif /* __SMIAPP_QUIRK__ */
|