ovcamchip_priv.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. /* --------------------------------- */
  47. /* I2C I/O */
  48. /* --------------------------------- */
  49. static inline int ov_read(struct i2c_client *c, unsigned char reg,
  50. unsigned char *value)
  51. {
  52. int rc;
  53. rc = i2c_smbus_read_byte_data(c, reg);
  54. *value = (unsigned char) rc;
  55. return rc;
  56. }
  57. static inline int ov_write(struct i2c_client *c, unsigned char reg,
  58. unsigned char value )
  59. {
  60. return i2c_smbus_write_byte_data(c, reg, value);
  61. }
  62. /* --------------------------------- */
  63. /* FUNCTION PROTOTYPES */
  64. /* --------------------------------- */
  65. /* Functions in ovcamchip_core.c */
  66. extern int ov_write_regvals(struct i2c_client *c,
  67. struct ovcamchip_regvals *rvals);
  68. extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
  69. unsigned char value, unsigned char mask);
  70. #endif