m5602_s5k83a.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Driver for the s5k83a sensor
  3. *
  4. * Copyright (C) 2008 Erik Andrén
  5. * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
  6. * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
  7. *
  8. * Portions of code to USB interface and ALi driver software,
  9. * Copyright (c) 2006 Willem Duinker
  10. * v4l2 interface modeled after the V4L2 driver
  11. * for SN9C10x PC Camera Controllers
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation, version 2.
  16. *
  17. */
  18. #ifndef M5602_S5K83A_H_
  19. #define M5602_S5K83A_H_
  20. #include "m5602_sensor.h"
  21. #define S5K83A_FLIP 0x01
  22. #define S5K83A_HFLIP_TUNE 0x03
  23. #define S5K83A_VFLIP_TUNE 0x05
  24. #define S5K83A_BRIGHTNESS 0x0a
  25. #define S5K83A_EXPOSURE 0x18
  26. #define S5K83A_GAIN 0x1b
  27. #define S5K83A_PAGE_MAP 0xec
  28. #define S5K83A_DEFAULT_GAIN 0x71
  29. #define S5K83A_DEFAULT_BRIGHTNESS 0x7e
  30. #define S5K83A_DEFAULT_EXPOSURE 0x00
  31. #define S5K83A_MAXIMUM_EXPOSURE 0x3c
  32. #define S5K83A_FLIP_MASK 0x10
  33. #define S5K83A_GPIO_LED_MASK 0x10
  34. #define S5K83A_GPIO_ROTATION_MASK 0x40
  35. /*****************************************************************************/
  36. /* Kernel module parameters */
  37. extern int force_sensor;
  38. extern bool dump_sensor;
  39. int s5k83a_probe(struct sd *sd);
  40. int s5k83a_init(struct sd *sd);
  41. int s5k83a_init_controls(struct sd *sd);
  42. int s5k83a_start(struct sd *sd);
  43. int s5k83a_stop(struct sd *sd);
  44. void s5k83a_disconnect(struct sd *sd);
  45. static const struct m5602_sensor s5k83a = {
  46. .name = "S5K83A",
  47. .probe = s5k83a_probe,
  48. .init = s5k83a_init,
  49. .init_controls = s5k83a_init_controls,
  50. .start = s5k83a_start,
  51. .stop = s5k83a_stop,
  52. .disconnect = s5k83a_disconnect,
  53. .i2c_slave_id = 0x5a,
  54. .i2c_regW = 2,
  55. };
  56. static const unsigned char preinit_s5k83a[][4] = {
  57. {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
  58. {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
  59. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
  60. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
  61. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
  62. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x0d, 0x00},
  63. {BRIDGE, M5602_XB_SENSOR_CTRL, 0x00, 0x00},
  64. {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
  65. {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
  66. {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
  67. {BRIDGE, M5602_XB_GPIO_EN_H, 0x3f, 0x00},
  68. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3f, 0x00},
  69. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
  70. {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
  71. {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
  72. {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
  73. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0xb0, 0x00},
  74. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0x80, 0x00},
  75. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
  76. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
  77. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
  78. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
  79. {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
  80. {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
  81. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
  82. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},
  83. {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
  84. {BRIDGE, M5602_XB_GPIO_DAT, 0x1c, 0x00},
  85. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
  86. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},
  87. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
  88. {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
  89. {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x20, 0x00},
  90. };
  91. /* This could probably be considerably shortened.
  92. I don't have the hardware to experiment with it, patches welcome
  93. */
  94. static const unsigned char init_s5k83a[][4] = {
  95. /* The following sequence is useless after a clean boot
  96. but is necessary after resume from suspend */
  97. {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
  98. {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
  99. {BRIDGE, M5602_XB_GPIO_EN_H, 0x3f, 0x00},
  100. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x3f, 0x00},
  101. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
  102. {BRIDGE, M5602_XB_GPIO_EN_L, 0xff, 0x00},
  103. {BRIDGE, M5602_XB_GPIO_DIR_L, 0xff, 0x00},
  104. {BRIDGE, M5602_XB_GPIO_DAT_L, 0x00, 0x00},
  105. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0xb0, 0x00},
  106. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0x80, 0x00},
  107. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
  108. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
  109. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
  110. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
  111. {BRIDGE, M5602_XB_MCU_CLK_DIV, 0x02, 0x00},
  112. {BRIDGE, M5602_XB_MCU_CLK_CTRL, 0xb0, 0x00},
  113. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
  114. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xf0, 0x00},
  115. {BRIDGE, M5602_XB_GPIO_DIR, 0x1d, 0x00},
  116. {BRIDGE, M5602_XB_GPIO_DAT, 0x08, 0x00},
  117. {BRIDGE, M5602_XB_GPIO_EN_H, 0x06, 0x00},
  118. {BRIDGE, M5602_XB_GPIO_DIR_H, 0x06, 0x00},
  119. {BRIDGE, M5602_XB_GPIO_DAT_H, 0x00, 0x00},
  120. {BRIDGE, M5602_XB_GPIO_EN_L, 0x00, 0x00},
  121. {BRIDGE, M5602_XB_I2C_CLK_DIV, 0x20, 0x00},
  122. {SENSOR, S5K83A_PAGE_MAP, 0x04, 0x00},
  123. {SENSOR, 0xaf, 0x01, 0x00},
  124. {SENSOR, S5K83A_PAGE_MAP, 0x00, 0x00},
  125. {SENSOR, 0x7b, 0xff, 0x00},
  126. {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00},
  127. {SENSOR, 0x01, 0x50, 0x00},
  128. {SENSOR, 0x12, 0x20, 0x00},
  129. {SENSOR, 0x17, 0x40, 0x00},
  130. {SENSOR, 0x1c, 0x00, 0x00},
  131. {SENSOR, 0x02, 0x70, 0x00},
  132. {SENSOR, 0x03, 0x0b, 0x00},
  133. {SENSOR, 0x04, 0xf0, 0x00},
  134. {SENSOR, 0x05, 0x0b, 0x00},
  135. {SENSOR, 0x06, 0x71, 0x00},
  136. {SENSOR, 0x07, 0xe8, 0x00}, /* 488 */
  137. {SENSOR, 0x08, 0x02, 0x00},
  138. {SENSOR, 0x09, 0x88, 0x00}, /* 648 */
  139. {SENSOR, 0x14, 0x00, 0x00},
  140. {SENSOR, 0x15, 0x20, 0x00}, /* 32 */
  141. {SENSOR, 0x19, 0x00, 0x00},
  142. {SENSOR, 0x1a, 0x98, 0x00}, /* 152 */
  143. {SENSOR, 0x0f, 0x02, 0x00},
  144. {SENSOR, 0x10, 0xe5, 0x00}, /* 741 */
  145. /* normal colors
  146. (this is value after boot, but after tries can be different) */
  147. {SENSOR, 0x00, 0x06, 0x00},
  148. };
  149. static const unsigned char start_s5k83a[][4] = {
  150. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x06, 0x00},
  151. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
  152. {BRIDGE, M5602_XB_ADC_CTRL, 0xc0, 0x00},
  153. {BRIDGE, M5602_XB_SENSOR_TYPE, 0x09, 0x00},
  154. {BRIDGE, M5602_XB_LINE_OF_FRAME_H, 0x81, 0x00},
  155. {BRIDGE, M5602_XB_PIX_OF_LINE_H, 0x82, 0x00},
  156. {BRIDGE, M5602_XB_SIG_INI, 0x01, 0x00},
  157. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
  158. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
  159. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
  160. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
  161. {BRIDGE, M5602_XB_VSYNC_PARA, 0x01, 0x00},
  162. {BRIDGE, M5602_XB_VSYNC_PARA, 0xe4, 0x00}, /* 484 */
  163. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
  164. {BRIDGE, M5602_XB_VSYNC_PARA, 0x00, 0x00},
  165. {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
  166. {BRIDGE, M5602_XB_SIG_INI, 0x02, 0x00},
  167. {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
  168. {BRIDGE, M5602_XB_HSYNC_PARA, 0x00, 0x00},
  169. {BRIDGE, M5602_XB_HSYNC_PARA, 0x02, 0x00},
  170. {BRIDGE, M5602_XB_HSYNC_PARA, 0x7f, 0x00}, /* 639 */
  171. {BRIDGE, M5602_XB_SIG_INI, 0x00, 0x00},
  172. {BRIDGE, M5602_XB_SEN_CLK_DIV, 0x00, 0x00},
  173. {BRIDGE, M5602_XB_SEN_CLK_CTRL, 0xb0, 0x00},
  174. };
  175. #endif