ovcamchip_priv.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* OmniVision* camera chip driver private definitions for core code and
  2. * chip-specific code
  3. *
  4. * Copyright (c) 1999-2004 Mark McClelland
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version. NO WARRANTY OF ANY KIND is expressed or implied.
  10. *
  11. * * OmniVision is a trademark of OmniVision Technologies, Inc. This driver
  12. * is not sponsored or developed by them.
  13. */
  14. #ifndef __LINUX_OVCAMCHIP_PRIV_H
  15. #define __LINUX_OVCAMCHIP_PRIV_H
  16. #include <linux/i2c.h>
  17. #include <media/ovcamchip.h>
  18. #ifdef DEBUG
  19. extern int ovcamchip_debug;
  20. #endif
  21. #define PDEBUG(level, fmt, args...) \
  22. if (ovcamchip_debug >= (level)) pr_debug("[%s:%d] " fmt "\n", \
  23. __func__, __LINE__ , ## args)
  24. #define DDEBUG(level, dev, fmt, args...) \
  25. if (ovcamchip_debug >= (level)) dev_dbg(dev, "[%s:%d] " fmt "\n", \
  26. __func__, __LINE__ , ## args)
  27. /* Number of times to retry chip detection. Increase this if you are getting
  28. * "Failed to init camera chip" */
  29. #define I2C_DETECT_RETRIES 10
  30. struct ovcamchip_regvals {
  31. unsigned char reg;
  32. unsigned char val;
  33. };
  34. struct ovcamchip_ops {
  35. int (*init)(struct i2c_client *);
  36. int (*free)(struct i2c_client *);
  37. int (*command)(struct i2c_client *, unsigned int, void *);
  38. };
  39. struct ovcamchip {
  40. struct ovcamchip_ops *sops;
  41. void *spriv; /* Private data for OV7x10.c etc... */
  42. int subtype; /* = SEN_OV7610 etc... */
  43. int mono; /* Monochrome chip? (invalid until init) */
  44. int initialized; /* OVCAMCHIP_CMD_INITIALIZE was successful */
  45. };
  46. extern struct ovcamchip_ops ov6x20_ops;
  47. extern struct ovcamchip_ops ov6x30_ops;
  48. extern struct ovcamchip_ops ov7x10_ops;
  49. extern struct ovcamchip_ops ov7x20_ops;
  50. extern struct ovcamchip_ops ov76be_ops;
  51. /* --------------------------------- */
  52. /* I2C I/O */
  53. /* --------------------------------- */
  54. static inline int ov_read(struct i2c_client *c, unsigned char reg,
  55. unsigned char *value)
  56. {
  57. int rc;
  58. rc = i2c_smbus_read_byte_data(c, reg);
  59. *value = (unsigned char) rc;
  60. return rc;
  61. }
  62. static inline int ov_write(struct i2c_client *c, unsigned char reg,
  63. unsigned char value )
  64. {
  65. return i2c_smbus_write_byte_data(c, reg, value);
  66. }
  67. /* --------------------------------- */
  68. /* FUNCTION PROTOTYPES */
  69. /* --------------------------------- */
  70. /* Functions in ovcamchip_core.c */
  71. extern int ov_write_regvals(struct i2c_client *c,
  72. struct ovcamchip_regvals *rvals);
  73. extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
  74. unsigned char value, unsigned char mask);
  75. #endif