Sakari Ailus | ccfc97b | 2012-03-03 17:19:52 -0300 | [diff] [blame] | 1 | /* |
Mauro Carvalho Chehab | cb7a01a | 2012-08-14 16:23:43 -0300 | [diff] [blame] | 2 | * drivers/media/i2c/smiapp/smiapp-quirk.h |
Sakari Ailus | ccfc97b | 2012-03-03 17:19:52 -0300 | [diff] [blame] | 3 | * |
| 4 | * Generic driver for SMIA/SMIA++ compliant camera modules |
| 5 | * |
| 6 | * Copyright (C) 2011--2012 Nokia Corporation |
Sakari Ailus | 8c5dff9 | 2012-10-28 06:44:17 -0300 | [diff] [blame] | 7 | * Contact: Sakari Ailus <sakari.ailus@iki.fi> |
Sakari Ailus | ccfc97b | 2012-03-03 17:19:52 -0300 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * version 2 as published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 21 | * 02110-1301 USA |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #ifndef __SMIAPP_QUIRK__ |
| 26 | #define __SMIAPP_QUIRK__ |
| 27 | |
| 28 | struct smiapp_sensor; |
| 29 | |
| 30 | /** |
| 31 | * struct smiapp_quirk - quirks for sensors that deviate from SMIA++ standard |
| 32 | * |
| 33 | * @limits: Replace sensor->limits with values which can't be read from |
| 34 | * sensor registers. Called the first time the sensor is powered up. |
| 35 | * @post_poweron: Called always after the sensor has been fully powered on. |
| 36 | * @pre_streamon: Called just before streaming is enabled. |
| 37 | * @post_streamon: Called right after stopping streaming. |
Sakari Ailus | 6f7481b | 2014-04-01 08:37:38 -0300 | [diff] [blame] | 38 | * @reg_access: Register access quirk. The quirk may divert the access |
| 39 | * to another register, or no register at all. |
| 40 | * |
| 41 | * @write: Is this read (false) or write (true) access? |
| 42 | * @reg: Pointer to the register to access |
| 43 | * @value: Register value, set by the caller on write, or |
| 44 | * by the quirk on read |
| 45 | * |
| 46 | * @return: 0 on success, -ENOIOCTLCMD if no register |
| 47 | * access may be done by the caller (default read |
| 48 | * value is zero), else negative error code on error |
Sakari Ailus | ccfc97b | 2012-03-03 17:19:52 -0300 | [diff] [blame] | 49 | */ |
| 50 | struct smiapp_quirk { |
| 51 | int (*limits)(struct smiapp_sensor *sensor); |
| 52 | int (*post_poweron)(struct smiapp_sensor *sensor); |
| 53 | int (*pre_streamon)(struct smiapp_sensor *sensor); |
| 54 | int (*post_streamoff)(struct smiapp_sensor *sensor); |
Sakari Ailus | 03efb2a | 2014-04-08 18:18:10 -0300 | [diff] [blame] | 55 | unsigned long (*pll_flags)(struct smiapp_sensor *sensor); |
Sakari Ailus | 6f7481b | 2014-04-01 08:37:38 -0300 | [diff] [blame] | 56 | int (*reg_access)(struct smiapp_sensor *sensor, bool write, u32 *reg, |
| 57 | u32 *val); |
Sakari Ailus | ccfc97b | 2012-03-03 17:19:52 -0300 | [diff] [blame] | 58 | unsigned long flags; |
| 59 | }; |
| 60 | |
Sakari Ailus | caf447b | 2014-02-12 10:33:51 -0300 | [diff] [blame] | 61 | #define SMIAPP_QUIRK_FLAG_8BIT_READ_ONLY (1 << 0) |
Sakari Ailus | ccfc97b | 2012-03-03 17:19:52 -0300 | [diff] [blame] | 62 | |
| 63 | struct smiapp_reg_8 { |
| 64 | u16 reg; |
| 65 | u8 val; |
| 66 | }; |
| 67 | |
| 68 | void smiapp_replace_limit(struct smiapp_sensor *sensor, |
| 69 | u32 limit, u32 val); |
Sakari Ailus | ccfc97b | 2012-03-03 17:19:52 -0300 | [diff] [blame] | 70 | |
Sakari Ailus | 125a1c0 | 2014-04-11 06:30:18 -0300 | [diff] [blame] | 71 | #define SMIAPP_MK_QUIRK_REG_8(_reg, _val) \ |
| 72 | { \ |
| 73 | .reg = (u16)_reg, \ |
| 74 | .val = _val, \ |
| 75 | } |
| 76 | |
Sakari Ailus | ccfc97b | 2012-03-03 17:19:52 -0300 | [diff] [blame] | 77 | #define smiapp_call_quirk(_sensor, _quirk, ...) \ |
| 78 | (_sensor->minfo.quirk && \ |
| 79 | _sensor->minfo.quirk->_quirk ? \ |
| 80 | _sensor->minfo.quirk->_quirk(_sensor, ##__VA_ARGS__) : 0) |
| 81 | |
| 82 | #define smiapp_needs_quirk(_sensor, _quirk) \ |
| 83 | (_sensor->minfo.quirk ? \ |
| 84 | _sensor->minfo.quirk->flags & _quirk : 0) |
| 85 | |
| 86 | extern const struct smiapp_quirk smiapp_jt8ev1_quirk; |
| 87 | extern const struct smiapp_quirk smiapp_imx125es_quirk; |
| 88 | extern const struct smiapp_quirk smiapp_jt8ew9_quirk; |
| 89 | extern const struct smiapp_quirk smiapp_tcm8500md_quirk; |
| 90 | |
| 91 | #endif /* __SMIAPP_QUIRK__ */ |