smiapp-quirk.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * drivers/media/i2c/smiapp/smiapp-quirk.h
  3. *
  4. * Generic driver for SMIA/SMIA++ compliant camera modules
  5. *
  6. * Copyright (C) 2011--2012 Nokia Corporation
  7. * Contact: Sakari Ailus <sakari.ailus@iki.fi>
  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. #ifndef __SMIAPP_QUIRK__
  19. #define __SMIAPP_QUIRK__
  20. struct smiapp_sensor;
  21. /**
  22. * struct smiapp_quirk - quirks for sensors that deviate from SMIA++ standard
  23. *
  24. * @limits: Replace sensor->limits with values which can't be read from
  25. * sensor registers. Called the first time the sensor is powered up.
  26. * @post_poweron: Called always after the sensor has been fully powered on.
  27. * @pre_streamon: Called just before streaming is enabled.
  28. * @post_streamon: Called right after stopping streaming.
  29. * @pll_flags: Return flags for the PLL calculator.
  30. * @init: Quirk initialisation, called the last in probe(). This is
  31. * also appropriate for adding sensor specific controls, for instance.
  32. * @reg_access: Register access quirk. The quirk may divert the access
  33. * to another register, or no register at all.
  34. *
  35. * @write: Is this read (false) or write (true) access?
  36. * @reg: Pointer to the register to access
  37. * @value: Register value, set by the caller on write, or
  38. * by the quirk on read
  39. *
  40. * @return: 0 on success, -ENOIOCTLCMD if no register
  41. * access may be done by the caller (default read
  42. * value is zero), else negative error code on error
  43. */
  44. struct smiapp_quirk {
  45. int (*limits)(struct smiapp_sensor *sensor);
  46. int (*post_poweron)(struct smiapp_sensor *sensor);
  47. int (*pre_streamon)(struct smiapp_sensor *sensor);
  48. int (*post_streamoff)(struct smiapp_sensor *sensor);
  49. unsigned long (*pll_flags)(struct smiapp_sensor *sensor);
  50. int (*init)(struct smiapp_sensor *sensor);
  51. int (*reg_access)(struct smiapp_sensor *sensor, bool write, u32 *reg,
  52. u32 *val);
  53. unsigned long flags;
  54. };
  55. #define SMIAPP_QUIRK_FLAG_8BIT_READ_ONLY (1 << 0)
  56. struct smiapp_reg_8 {
  57. u16 reg;
  58. u8 val;
  59. };
  60. void smiapp_replace_limit(struct smiapp_sensor *sensor,
  61. u32 limit, u32 val);
  62. #define SMIAPP_MK_QUIRK_REG_8(_reg, _val) \
  63. { \
  64. .reg = (u16)_reg, \
  65. .val = _val, \
  66. }
  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)
  71. #define smiapp_needs_quirk(sensor, _quirk) \
  72. ((sensor)->minfo.quirk ? \
  73. (sensor)->minfo.quirk->flags & _quirk : 0)
  74. extern const struct smiapp_quirk smiapp_jt8ev1_quirk;
  75. extern const struct smiapp_quirk smiapp_imx125es_quirk;
  76. extern const struct smiapp_quirk smiapp_jt8ew9_quirk;
  77. extern const struct smiapp_quirk smiapp_tcm8500md_quirk;
  78. #endif /* __SMIAPP_QUIRK__ */