ovcamchip_priv.h 2.9 KB

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