et61x251_sensor.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /***************************************************************************
  2. * API for image sensors connected to ET61X[12]51 PC Camera Controllers *
  3. * *
  4. * Copyright (C) 2006-2007 by Luca Risolia <luca.risolia@studio.unibo.it> *
  5. * *
  6. * This program is free software; you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation; either version 2 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * You should have received a copy of the GNU General Public License *
  17. * along with this program; if not, write to the Free Software *
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
  19. ***************************************************************************/
  20. #ifndef _ET61X251_SENSOR_H_
  21. #define _ET61X251_SENSOR_H_
  22. #include <linux/usb.h>
  23. #include <linux/videodev2.h>
  24. #include <linux/device.h>
  25. #include <linux/stddef.h>
  26. #include <linux/errno.h>
  27. #include <asm/types.h>
  28. struct et61x251_device;
  29. struct et61x251_sensor;
  30. /*****************************************************************************/
  31. extern int et61x251_probe_tas5130d1b(struct et61x251_device* cam);
  32. #define ET61X251_SENSOR_TABLE \
  33. /* Weak detections must go at the end of the list */ \
  34. static int (*et61x251_sensor_table[])(struct et61x251_device*) = { \
  35. &et61x251_probe_tas5130d1b, \
  36. NULL, \
  37. };
  38. extern struct et61x251_device*
  39. et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id);
  40. extern void
  41. et61x251_attach_sensor(struct et61x251_device* cam,
  42. const struct et61x251_sensor* sensor);
  43. /*****************************************************************************/
  44. extern int et61x251_write_reg(struct et61x251_device*, u8 value, u16 index);
  45. extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1,
  46. u8 data2, u8 data3, u8 data4, u8 data5,
  47. u8 data6, u8 data7, u8 data8, u8 address);
  48. /*****************************************************************************/
  49. enum et61x251_i2c_sysfs_ops {
  50. ET61X251_I2C_READ = 0x01,
  51. ET61X251_I2C_WRITE = 0x02,
  52. };
  53. enum et61x251_i2c_interface {
  54. ET61X251_I2C_2WIRES,
  55. ET61X251_I2C_3WIRES,
  56. };
  57. /* Repeat start condition when RSTA is high */
  58. enum et61x251_i2c_rsta {
  59. ET61X251_I2C_RSTA_STOP = 0x00, /* stop then start */
  60. ET61X251_I2C_RSTA_REPEAT = 0x01, /* repeat start */
  61. };
  62. #define ET61X251_MAX_CTRLS (V4L2_CID_LASTP1-V4L2_CID_BASE+10)
  63. struct et61x251_sensor {
  64. char name[32];
  65. enum et61x251_i2c_sysfs_ops sysfs_ops;
  66. enum et61x251_i2c_interface interface;
  67. u8 i2c_slave_id;
  68. enum et61x251_i2c_rsta rsta;
  69. struct v4l2_rect active_pixel; /* left and top define FVSX and FVSY */
  70. struct v4l2_queryctrl qctrl[ET61X251_MAX_CTRLS];
  71. struct v4l2_cropcap cropcap;
  72. struct v4l2_pix_format pix_format;
  73. int (*init)(struct et61x251_device* cam);
  74. int (*get_ctrl)(struct et61x251_device* cam,
  75. struct v4l2_control* ctrl);
  76. int (*set_ctrl)(struct et61x251_device* cam,
  77. const struct v4l2_control* ctrl);
  78. int (*set_crop)(struct et61x251_device* cam,
  79. const struct v4l2_rect* rect);
  80. int (*set_pix_format)(struct et61x251_device* cam,
  81. const struct v4l2_pix_format* pix);
  82. /* Private */
  83. struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS];
  84. struct v4l2_rect _rect;
  85. };
  86. #endif /* _ET61X251_SENSOR_H_ */