zc0301_sensor.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /***************************************************************************
  2. * API for image sensors connected to the ZC0301[P] Image Processor and *
  3. * Control Chip *
  4. * *
  5. * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> *
  6. * *
  7. * This program is free software; you can redistribute it and/or modify *
  8. * it under the terms of the GNU General Public License as published by *
  9. * the Free Software Foundation; either version 2 of the License, or *
  10. * (at your option) any later version. *
  11. * *
  12. * This program is distributed in the hope that it will be useful, *
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  15. * GNU General Public License for more details. *
  16. * *
  17. * You should have received a copy of the GNU General Public License *
  18. * along with this program; if not, write to the Free Software *
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
  20. ***************************************************************************/
  21. #ifndef _ZC0301_SENSOR_H_
  22. #define _ZC0301_SENSOR_H_
  23. #include <linux/usb.h>
  24. #include <linux/videodev2.h>
  25. #include <linux/device.h>
  26. #include <linux/stddef.h>
  27. #include <linux/errno.h>
  28. #include <asm/types.h>
  29. struct zc0301_device;
  30. struct zc0301_sensor;
  31. /*****************************************************************************/
  32. extern int zc0301_probe_pas202bcb(struct zc0301_device* cam);
  33. extern int zc0301_probe_pb0330(struct zc0301_device* cam);
  34. #define ZC0301_SENSOR_TABLE \
  35. /* Weak detections must go at the end of the list */ \
  36. static int (*zc0301_sensor_table[])(struct zc0301_device*) = { \
  37. &zc0301_probe_pas202bcb, \
  38. &zc0301_probe_pb0330, \
  39. NULL, \
  40. };
  41. extern struct zc0301_device*
  42. zc0301_match_id(struct zc0301_device* cam, const struct usb_device_id *id);
  43. extern void
  44. zc0301_attach_sensor(struct zc0301_device* cam, struct zc0301_sensor* sensor);
  45. #define ZC0301_USB_DEVICE(vend, prod, intclass) \
  46. .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
  47. USB_DEVICE_ID_MATCH_INT_CLASS, \
  48. .idVendor = (vend), \
  49. .idProduct = (prod), \
  50. .bInterfaceClass = (intclass)
  51. #if !defined CONFIG_USB_GSPCA && !defined CONFIG_USB_GSPCA_MODULE
  52. #define ZC0301_ID_TABLE \
  53. static const struct usb_device_id zc0301_id_table[] = { \
  54. { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \
  55. { ZC0301_USB_DEVICE(0x0ac8, 0x303b, 0xff), }, /* PB-0330 */ \
  56. { } \
  57. };
  58. #else
  59. #define ZC0301_ID_TABLE \
  60. static const struct usb_device_id zc0301_id_table[] = { \
  61. { ZC0301_USB_DEVICE(0x046d, 0x08ae, 0xff), }, /* PAS202 */ \
  62. { } \
  63. };
  64. #endif
  65. /*****************************************************************************/
  66. extern int zc0301_write_reg(struct zc0301_device*, u16 index, u16 value);
  67. extern int zc0301_read_reg(struct zc0301_device*, u16 index);
  68. extern int zc0301_i2c_write(struct zc0301_device*, u16 address, u16 value);
  69. extern int zc0301_i2c_read(struct zc0301_device*, u16 address, u8 length);
  70. /*****************************************************************************/
  71. #define ZC0301_MAX_CTRLS (V4L2_CID_LASTP1 - V4L2_CID_BASE + 10)
  72. #define ZC0301_V4L2_CID_DAC_MAGNITUDE (V4L2_CID_PRIVATE_BASE + 0)
  73. #define ZC0301_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE + 1)
  74. struct zc0301_sensor {
  75. char name[32];
  76. struct v4l2_queryctrl qctrl[ZC0301_MAX_CTRLS];
  77. struct v4l2_cropcap cropcap;
  78. struct v4l2_pix_format pix_format;
  79. int (*init)(struct zc0301_device*);
  80. int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl);
  81. int (*set_ctrl)(struct zc0301_device*,
  82. const struct v4l2_control* ctrl);
  83. int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect);
  84. /* Private */
  85. struct v4l2_queryctrl _qctrl[ZC0301_MAX_CTRLS];
  86. struct v4l2_rect _rect;
  87. };
  88. #endif /* _ZC0301_SENSOR_H_ */