ovcamchip_priv.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <media/ovcamchip.h>
  17. #ifdef DEBUG
  18. extern int ovcamchip_debug;
  19. #endif
  20. #define PDEBUG(level, fmt, args...) \
  21. if (ovcamchip_debug >= (level)) pr_debug("[%s:%d] " fmt "\n", \
  22. __FUNCTION__, __LINE__ , ## args)
  23. #define DDEBUG(level, dev, fmt, args...) \
  24. if (ovcamchip_debug >= (level)) dev_dbg(dev, "[%s:%d] " fmt "\n", \
  25. __FUNCTION__, __LINE__ , ## args)
  26. /* Number of times to retry chip detection. Increase this if you are getting
  27. * "Failed to init camera chip" */
  28. #define I2C_DETECT_RETRIES 10
  29. struct ovcamchip_regvals {
  30. unsigned char reg;
  31. unsigned char val;
  32. };
  33. struct ovcamchip_ops {
  34. int (*init)(struct i2c_client *);
  35. int (*free)(struct i2c_client *);
  36. int (*command)(struct i2c_client *, unsigned int, void *);
  37. };
  38. struct ovcamchip {
  39. struct ovcamchip_ops *sops;
  40. void *spriv; /* Private data for OV7x10.c etc... */
  41. int subtype; /* = SEN_OV7610 etc... */
  42. int mono; /* Monochrome chip? (invalid until init) */
  43. int initialized; /* OVCAMCHIP_CMD_INITIALIZE was successful */
  44. };
  45. /* --------------------------------- */
  46. /* I2C I/O */
  47. /* --------------------------------- */
  48. static inline int ov_read(struct i2c_client *c, unsigned char reg,
  49. unsigned char *value)
  50. {
  51. int rc;
  52. rc = i2c_smbus_read_byte_data(c, reg);
  53. *value = (unsigned char) rc;
  54. return rc;
  55. }
  56. static inline int ov_write(struct i2c_client *c, unsigned char reg,
  57. unsigned char value )
  58. {
  59. return i2c_smbus_write_byte_data(c, reg, value);
  60. }
  61. /* --------------------------------- */
  62. /* FUNCTION PROTOTYPES */
  63. /* --------------------------------- */
  64. /* Functions in ovcamchip_core.c */
  65. extern int ov_write_regvals(struct i2c_client *c,
  66. struct ovcamchip_regvals *rvals);
  67. extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
  68. unsigned char value, unsigned char mask);
  69. #endif