et61x251_tas5130d1b.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /***************************************************************************
  2. * Plug-in for TAS5130D1B image sensor connected to the ET61X[12]51 *
  3. * PC Camera Controllers *
  4. * *
  5. * Copyright (C) 2006 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. #include "et61x251_sensor.h"
  22. static int tas5130d1b_init(struct et61x251_device* cam)
  23. {
  24. int err = 0;
  25. err += et61x251_write_reg(cam, 0x14, 0x01);
  26. err += et61x251_write_reg(cam, 0x1b, 0x02);
  27. err += et61x251_write_reg(cam, 0x02, 0x12);
  28. err += et61x251_write_reg(cam, 0x0e, 0x60);
  29. err += et61x251_write_reg(cam, 0x80, 0x61);
  30. err += et61x251_write_reg(cam, 0xf0, 0x62);
  31. err += et61x251_write_reg(cam, 0x03, 0x63);
  32. err += et61x251_write_reg(cam, 0x14, 0x64);
  33. err += et61x251_write_reg(cam, 0xf4, 0x65);
  34. err += et61x251_write_reg(cam, 0x01, 0x66);
  35. err += et61x251_write_reg(cam, 0x05, 0x67);
  36. err += et61x251_write_reg(cam, 0x8f, 0x68);
  37. err += et61x251_write_reg(cam, 0x0f, 0x8d);
  38. err += et61x251_write_reg(cam, 0x08, 0x8e);
  39. return err;
  40. }
  41. static int tas5130d1b_set_ctrl(struct et61x251_device* cam,
  42. const struct v4l2_control* ctrl)
  43. {
  44. int err = 0;
  45. switch (ctrl->id) {
  46. case V4L2_CID_GAIN:
  47. err += et61x251_i2c_raw_write(cam, 2, 0x20,
  48. 0xf6-ctrl->value, 0, 0, 0,
  49. 0, 0, 0, 0);
  50. break;
  51. case V4L2_CID_EXPOSURE:
  52. err += et61x251_i2c_raw_write(cam, 2, 0x40,
  53. 0x47-ctrl->value, 0, 0, 0,
  54. 0, 0, 0, 0);
  55. break;
  56. default:
  57. return -EINVAL;
  58. }
  59. return err ? -EIO : 0;
  60. }
  61. static struct et61x251_sensor tas5130d1b = {
  62. .name = "TAS5130D1B",
  63. .interface = ET61X251_I2C_3WIRES,
  64. .rsta = ET61X251_I2C_RSTA_STOP,
  65. .active_pixel = {
  66. .left = 106,
  67. .top = 13,
  68. },
  69. .init = &tas5130d1b_init,
  70. .qctrl = {
  71. {
  72. .id = V4L2_CID_GAIN,
  73. .type = V4L2_CTRL_TYPE_INTEGER,
  74. .name = "global gain",
  75. .minimum = 0x00,
  76. .maximum = 0xf6,
  77. .step = 0x02,
  78. .default_value = 0x0d,
  79. .flags = 0,
  80. },
  81. {
  82. .id = V4L2_CID_EXPOSURE,
  83. .type = V4L2_CTRL_TYPE_INTEGER,
  84. .name = "exposure",
  85. .minimum = 0x00,
  86. .maximum = 0x47,
  87. .step = 0x01,
  88. .default_value = 0x23,
  89. .flags = 0,
  90. },
  91. },
  92. .set_ctrl = &tas5130d1b_set_ctrl,
  93. .cropcap = {
  94. .bounds = {
  95. .left = 0,
  96. .top = 0,
  97. .width = 640,
  98. .height = 480,
  99. },
  100. .defrect = {
  101. .left = 0,
  102. .top = 0,
  103. .width = 640,
  104. .height = 480,
  105. },
  106. },
  107. .pix_format = {
  108. .width = 640,
  109. .height = 480,
  110. .pixelformat = V4L2_PIX_FMT_SBGGR8,
  111. .priv = 8,
  112. },
  113. };
  114. int et61x251_probe_tas5130d1b(struct et61x251_device* cam)
  115. {
  116. /* This sensor has no identifiers, so let's attach it anyway */
  117. et61x251_attach_sensor(cam, &tas5130d1b);
  118. /* Sensor detection is based on USB pid/vid */
  119. if (le16_to_cpu(tas5130d1b.usbdev->descriptor.idProduct) != 0x6251)
  120. return -ENODEV;
  121. return 0;
  122. }