2019-05-27 08:55:21 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2012-03-03 17:19:52 -03:00
/*
2020-02-11 19:05:57 +01:00
* drivers / media / i2c / ccs / ccs - quirk . h
2012-03-03 17:19:52 -03:00
*
2020-02-11 19:05:57 +01:00
* Generic driver for MIPI CCS / SMIA / SMIA + + compliant camera sensors
2012-03-03 17:19:52 -03:00
*
2020-02-11 19:05:57 +01:00
* Copyright ( C ) 2020 Intel Corporation
2012-03-03 17:19:52 -03:00
* Copyright ( C ) 2011 - - 2012 Nokia Corporation
2020-06-24 23:57:46 +02:00
* Contact : Sakari Ailus < sakari . ailus @ linux . intel . com >
2012-03-03 17:19:52 -03:00
*/
2020-02-11 14:19:13 +01:00
# ifndef __CCS_QUIRK__
# define __CCS_QUIRK__
2012-03-03 17:19:52 -03:00
2020-02-11 14:19:13 +01:00
struct ccs_sensor ;
2012-03-03 17:19:52 -03:00
/**
2020-02-11 14:19:13 +01:00
* struct ccs_quirk - quirks for sensors that deviate from SMIA + + standard
2012-03-03 17:19:52 -03:00
*
* @ 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 .
2021-03-09 14:00:44 +01:00
* @ post_streamoff : Called right after stopping streaming .
2014-10-03 11:38:32 -03: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 08:37:38 -03: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
*
2021-03-09 14:00:44 +01:00
* @ flags : Quirk flags
*
2014-04-01 08:37:38 -03:00
* @ 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 17:19:52 -03:00
*/
2020-02-11 14:19:13 +01:00
struct ccs_quirk {
int ( * limits ) ( struct ccs_sensor * sensor ) ;
int ( * post_poweron ) ( struct ccs_sensor * sensor ) ;
int ( * pre_streamon ) ( struct ccs_sensor * sensor ) ;
int ( * post_streamoff ) ( struct ccs_sensor * sensor ) ;
unsigned long ( * pll_flags ) ( struct ccs_sensor * sensor ) ;
int ( * init ) ( struct ccs_sensor * sensor ) ;
int ( * reg_access ) ( struct ccs_sensor * sensor , bool write , u32 * reg ,
2014-04-01 08:37:38 -03:00
u32 * val ) ;
2012-03-03 17:19:52 -03:00
unsigned long flags ;
} ;
2020-02-11 14:19:13 +01:00
# define CCS_QUIRK_FLAG_8BIT_READ_ONLY (1 << 0)
2012-03-03 17:19:52 -03:00
2020-02-11 14:19:13 +01:00
struct ccs_reg_8 {
2012-03-03 17:19:52 -03:00
u16 reg ;
u8 val ;
} ;
2020-02-11 14:19:13 +01:00
# define CCS_MK_QUIRK_REG_8(_reg, _val) \
2014-04-11 06:30:18 -03:00
{ \
. reg = ( u16 ) _reg , \
. val = _val , \
}
2020-02-11 14:19:13 +01:00
# define ccs_call_quirk(sensor, _quirk, ...) \
2014-12-09 18:43:16 -03:00
( ( sensor ) - > minfo . quirk & & \
( sensor ) - > minfo . quirk - > _quirk ? \
( sensor ) - > minfo . quirk - > _quirk ( sensor , # # __VA_ARGS__ ) : 0 )
2012-03-03 17:19:52 -03:00
2020-02-11 14:19:13 +01:00
# define ccs_needs_quirk(sensor, _quirk) \
2014-12-09 18:43:16 -03:00
( ( sensor ) - > minfo . quirk ? \
( sensor ) - > minfo . quirk - > flags & _quirk : 0 )
2012-03-03 17:19:52 -03:00
2020-02-11 14:19:13 +01:00
extern const struct ccs_quirk smiapp_jt8ev1_quirk ;
extern const struct ccs_quirk smiapp_imx125es_quirk ;
extern const struct ccs_quirk smiapp_jt8ew9_quirk ;
extern const struct ccs_quirk smiapp_tcm8500md_quirk ;
2012-03-03 17:19:52 -03:00
2020-02-11 14:19:13 +01:00
# endif /* __CCS_QUIRK__ */