gl860-mi2020.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. /* Subdriver for the GL860 chip with the MI2020 sensor
  2. * Author Olivier LORIN, from logs by Iceman/Soro2005 + Fret_saw/Hulkie/Tricid
  3. * with the help of Kytrix/BUGabundo/Blazercist.
  4. * Driver achieved thanks to a webcam gift by Kytrix.
  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. * 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, see <http://www.gnu.org/licenses/>.
  18. */
  19. /* Sensor : MI2020 */
  20. #include "gl860.h"
  21. static u8 dat_wbal1[] = {0x8c, 0xa2, 0x0c};
  22. static u8 dat_bright1[] = {0x8c, 0xa2, 0x06};
  23. static u8 dat_bright3[] = {0x8c, 0xa1, 0x02};
  24. static u8 dat_bright4[] = {0x90, 0x00, 0x0f};
  25. static u8 dat_bright5[] = {0x8c, 0xa1, 0x03};
  26. static u8 dat_bright6[] = {0x90, 0x00, 0x05};
  27. static u8 dat_hvflip1[] = {0x8c, 0x27, 0x19};
  28. static u8 dat_hvflip3[] = {0x8c, 0x27, 0x3b};
  29. static u8 dat_hvflip5[] = {0x8c, 0xa1, 0x03};
  30. static u8 dat_hvflip6[] = {0x90, 0x00, 0x06};
  31. static struct idxdata tbl_middle_hvflip_low[] = {
  32. {0x33, "\x90\x00\x06"},
  33. {6, "\xff\xff\xff"},
  34. {0x33, "\x90\x00\x06"},
  35. {6, "\xff\xff\xff"},
  36. {0x33, "\x90\x00\x06"},
  37. {6, "\xff\xff\xff"},
  38. {0x33, "\x90\x00\x06"},
  39. {6, "\xff\xff\xff"},
  40. };
  41. static struct idxdata tbl_middle_hvflip_big[] = {
  42. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa1\x20"},
  43. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"},
  44. {102, "\xff\xff\xff"},
  45. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa1\x20"},
  46. {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
  47. };
  48. static struct idxdata tbl_end_hvflip[] = {
  49. {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
  50. {6, "\xff\xff\xff"},
  51. {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
  52. {6, "\xff\xff\xff"},
  53. {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
  54. {6, "\xff\xff\xff"},
  55. {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
  56. };
  57. static u8 dat_freq1[] = { 0x8c, 0xa4, 0x04 };
  58. static u8 dat_multi5[] = { 0x8c, 0xa1, 0x03 };
  59. static u8 dat_multi6[] = { 0x90, 0x00, 0x05 };
  60. static struct validx tbl_init_at_startup[] = {
  61. {0x0000, 0x0000}, {0x0010, 0x0010}, {0x0008, 0x00c0}, {0x0001, 0x00c1},
  62. {0x0001, 0x00c2}, {0x0020, 0x0006}, {0x006a, 0x000d},
  63. {53, 0xffff},
  64. {0x0040, 0x0000}, {0x0063, 0x0006},
  65. };
  66. static struct validx tbl_common_0B[] = {
  67. {0x0002, 0x0004}, {0x006a, 0x0007}, {0x00ef, 0x0006}, {0x006a, 0x000d},
  68. {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2},
  69. {0x0004, 0x00d8}, {0x0000, 0x0058}, {0x0041, 0x0000},
  70. };
  71. static struct idxdata tbl_common_3B[] = {
  72. {0x33, "\x86\x25\x01"}, {0x33, "\x86\x25\x00"},
  73. {2, "\xff\xff\xff"},
  74. {0x30, "\x1a\x0a\xcc"}, {0x32, "\x02\x00\x08"}, {0x33, "\xf4\x03\x1d"},
  75. {6, "\xff\xff\xff"}, /* 12 */
  76. {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"},
  77. {2, "\xff\xff\xff"}, /* - */
  78. {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\x22\x23"},
  79. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa2\x0f"}, {0x33, "\x90\x00\x0d"},
  80. {0x33, "\x8c\xa2\x10"}, {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x11"},
  81. {0x33, "\x90\x00\x07"}, {0x33, "\xf4\x03\x1d"}, {0x35, "\xa2\x00\xe2"},
  82. {0x33, "\x8c\xab\x05"}, {0x33, "\x90\x00\x01"}, {0x32, "\x6e\x00\x86"},
  83. {0x32, "\x70\x0f\xaa"}, {0x32, "\x72\x0f\xe4"}, {0x33, "\x8c\xa3\x4a"},
  84. {0x33, "\x90\x00\x5a"}, {0x33, "\x8c\xa3\x4b"}, {0x33, "\x90\x00\xa6"},
  85. {0x33, "\x8c\xa3\x61"}, {0x33, "\x90\x00\xc8"}, {0x33, "\x8c\xa3\x62"},
  86. {0x33, "\x90\x00\xe1"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"},
  87. {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"},
  88. {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"},
  89. {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"},
  90. {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"},
  91. {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"},
  92. {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"},
  93. {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"},
  94. {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"},
  95. {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"},
  96. {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"},
  97. {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"},
  98. {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"},
  99. {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"},
  100. {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"},
  101. {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"},
  102. {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"},
  103. {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"},
  104. {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"},
  105. {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"},
  106. {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"},
  107. {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"},
  108. {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"},
  109. {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"},
  110. {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"},
  111. {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"},
  112. {0x33, "\x78\x00\x00"},
  113. {2, "\xff\xff\xff"},
  114. {0x35, "\xb8\x1f\x20"}, {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x10"},
  115. {0x33, "\x8c\xa2\x07"}, {0x33, "\x90\x00\x08"}, {0x33, "\x8c\xa2\x42"},
  116. {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x4a"}, {0x33, "\x90\x00\x8c"},
  117. {0x35, "\xba\xfa\x08"}, {0x33, "\x8c\xa2\x02"}, {0x33, "\x90\x00\x22"},
  118. {0x33, "\x8c\xa2\x03"}, {0x33, "\x90\x00\xbb"}, {0x33, "\x8c\xa4\x04"},
  119. {0x33, "\x90\x00\x80"}, {0x33, "\x8c\xa7\x9d"}, {0x33, "\x90\x00\x00"},
  120. {0x33, "\x8c\xa7\x9e"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa2\x0c"},
  121. {0x33, "\x90\x00\x17"}, {0x33, "\x8c\xa2\x15"}, {0x33, "\x90\x00\x04"},
  122. {0x33, "\x8c\xa2\x14"}, {0x33, "\x90\x00\x20"}, {0x33, "\x8c\xa1\x03"},
  123. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"}, {0x33, "\x90\x21\x11"},
  124. {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x25"},
  125. {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x39"}, {0x33, "\x90\x21\x11"},
  126. {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"}, {0x33, "\x8c\x27\x47"},
  127. {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x03"}, {0x33, "\x90\x02\x84"},
  128. {0x33, "\x8c\x27\x05"}, {0x33, "\x90\x01\xe2"}, {0x33, "\x8c\x27\x07"},
  129. {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x09"}, {0x33, "\x90\x04\xb0"},
  130. {0x33, "\x8c\x27\x0d"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x0f"},
  131. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x11"}, {0x33, "\x90\x04\xbd"},
  132. {0x33, "\x8c\x27\x13"}, {0x33, "\x90\x06\x4d"}, {0x33, "\x8c\x27\x15"},
  133. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"}, {0x33, "\x90\x21\x11"},
  134. {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"}, {0x33, "\x8c\x27\x1b"},
  135. {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x1d"}, {0x33, "\x90\x01\x02"},
  136. {0x33, "\x8c\x27\x1f"}, {0x33, "\x90\x02\x79"}, {0x33, "\x8c\x27\x21"},
  137. {0x33, "\x90\x01\x55"}, {0x33, "\x8c\x27\x23"}, {0x33, "\x90\x02\x85"},
  138. {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x27"},
  139. {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x29"}, {0x33, "\x90\x20\x20"},
  140. {0x33, "\x8c\x27\x2b"}, {0x33, "\x90\x10\x20"}, {0x33, "\x8c\x27\x2d"},
  141. {0x33, "\x90\x20\x07"}, {0x33, "\x8c\x27\x2f"}, {0x33, "\x90\x00\x04"},
  142. {0x33, "\x8c\x27\x31"}, {0x33, "\x90\x00\x04"}, {0x33, "\x8c\x27\x33"},
  143. {0x33, "\x90\x04\xbb"}, {0x33, "\x8c\x27\x35"}, {0x33, "\x90\x06\x4b"},
  144. {0x33, "\x8c\x27\x37"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x39"},
  145. {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3b"}, {0x33, "\x90\x00\x24"},
  146. {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"}, {0x33, "\x8c\x27\x41"},
  147. {0x33, "\x90\x01\x69"}, {0x33, "\x8c\x27\x45"}, {0x33, "\x90\x04\xed"},
  148. {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x51"},
  149. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x53"}, {0x33, "\x90\x03\x20"},
  150. {0x33, "\x8c\x27\x55"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x57"},
  151. {0x33, "\x90\x02\x58"}, {0x33, "\x8c\x27\x5f"}, {0x33, "\x90\x00\x00"},
  152. {0x33, "\x8c\x27\x61"}, {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x63"},
  153. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x65"}, {0x33, "\x90\x04\xb0"},
  154. {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa1"}, {0x33, "\x8c\xa4\x08"},
  155. {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x21"},
  156. {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\xa4\x0b"},
  157. {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\xa1"},
  158. {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc1"}, {0x33, "\x8c\x24\x15"},
  159. {0x33, "\x90\x00\x6a"}, {0x33, "\x8c\x24\x17"}, {0x33, "\x90\x00\x80"},
  160. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  161. {2, "\xff\xff\xff"},
  162. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  163. {3, "\xff\xff\xff"},
  164. };
  165. static struct idxdata tbl_init_post_alt_low1[] = {
  166. {0x33, "\x8c\x27\x15"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\x22\x2e"},
  167. {0x33, "\x90\x00\x81"}, {0x33, "\x8c\xa4\x08"}, {0x33, "\x90\x00\x17"},
  168. {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x1a"}, {0x33, "\x8c\xa4\x0a"},
  169. {0x33, "\x90\x00\x1d"}, {0x33, "\x8c\xa4\x0b"}, {0x33, "\x90\x00\x20"},
  170. {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\x81"}, {0x33, "\x8c\x24\x13"},
  171. {0x33, "\x90\x00\x9b"},
  172. };
  173. static struct idxdata tbl_init_post_alt_low2[] = {
  174. {0x33, "\x8c\x27\x03"}, {0x33, "\x90\x03\x24"}, {0x33, "\x8c\x27\x05"},
  175. {0x33, "\x90\x02\x58"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  176. {2, "\xff\xff\xff"},
  177. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  178. {2, "\xff\xff\xff"},
  179. };
  180. static struct idxdata tbl_init_post_alt_low3[] = {
  181. {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"},
  182. {2, "\xff\xff\xff"},
  183. {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x20"},
  184. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x01"},
  185. {0x33, "\x2e\x01\x00"}, {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"},
  186. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x95"}, {0x33, "\x90\x01\x00"},
  187. {2, "\xff\xff\xff"},
  188. {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x03"},
  189. {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
  190. {2, "\xff\xff\xff"},
  191. {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"},
  192. {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"},
  193. {2, "\xff\xff\xff"},
  194. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  195. {2, "\xff\xff\xff"},
  196. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  197. {2, "\xff\xff\xff"},
  198. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  199. {2, "\xff\xff\xff"},
  200. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  201. };
  202. static struct idxdata tbl_init_post_alt_big[] = {
  203. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  204. {2, "\xff\xff\xff"},
  205. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  206. {2, "\xff\xff\xff"},
  207. {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"},
  208. {2, "\xff\xff\xff"},
  209. {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x03"},
  210. {0x33, "\x90\x00\x05"},
  211. {2, "\xff\xff\xff"},
  212. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  213. {2, "\xff\xff\xff"},
  214. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  215. {2, "\xff\xff\xff"},
  216. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, {0x33, "\x8c\xa1\x20"},
  217. {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x30"}, {0x33, "\x90\x00\x03"},
  218. {0x33, "\x8c\xa1\x31"}, {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa1\x32"},
  219. {0x33, "\x90\x00\x03"}, {0x33, "\x8c\xa1\x34"}, {0x33, "\x90\x00\x03"},
  220. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x2e\x01\x00"},
  221. {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
  222. {0x33, "\x8c\x27\x97"}, {0x33, "\x90\x01\x00"},
  223. {51, "\xff\xff\xff"},
  224. {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"},
  225. {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"},
  226. {51, "\xff\xff\xff"},
  227. {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x03"},
  228. {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
  229. {51, "\xff\xff\xff"},
  230. };
  231. static struct idxdata tbl_init_post_alt_3B[] = {
  232. {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"},
  233. {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"},
  234. {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"},
  235. {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"},
  236. {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"},
  237. {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"},
  238. {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"},
  239. {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"},
  240. {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"},
  241. {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"},
  242. {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"},
  243. {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"},
  244. {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"},
  245. {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"},
  246. {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"},
  247. {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"},
  248. {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"},
  249. {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"},
  250. {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"},
  251. {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"},
  252. {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"},
  253. {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"},
  254. {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"},
  255. {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"},
  256. {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"},
  257. {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"},
  258. };
  259. static u8 *dat_640 = "\xd0\x02\xd1\x08\xd2\xe1\xd3\x02\xd4\x10\xd5\x81";
  260. static u8 *dat_800 = "\xd0\x02\xd1\x10\xd2\x57\xd3\x02\xd4\x18\xd5\x21";
  261. static u8 *dat_1280 = "\xd0\x02\xd1\x20\xd2\x01\xd3\x02\xd4\x28\xd5\x01";
  262. static u8 *dat_1600 = "\xd0\x02\xd1\x20\xd2\xaf\xd3\x02\xd4\x30\xd5\x41";
  263. static int mi2020_init_at_startup(struct gspca_dev *gspca_dev);
  264. static int mi2020_configure_alt(struct gspca_dev *gspca_dev);
  265. static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev);
  266. static int mi2020_init_post_alt(struct gspca_dev *gspca_dev);
  267. static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev);
  268. static int mi2020_camera_settings(struct gspca_dev *gspca_dev);
  269. /*==========================================================================*/
  270. void mi2020_init_settings(struct gspca_dev *gspca_dev)
  271. {
  272. struct sd *sd = (struct sd *) gspca_dev;
  273. sd->vcur.backlight = 0;
  274. sd->vcur.brightness = 70;
  275. sd->vcur.sharpness = 20;
  276. sd->vcur.contrast = 0;
  277. sd->vcur.gamma = 0;
  278. sd->vcur.hue = 0;
  279. sd->vcur.saturation = 60;
  280. sd->vcur.whitebal = 0; /* 50, not done by hardware */
  281. sd->vcur.mirror = 0;
  282. sd->vcur.flip = 0;
  283. sd->vcur.AC50Hz = 1;
  284. sd->vmax.backlight = 64;
  285. sd->vmax.brightness = 128;
  286. sd->vmax.sharpness = 40;
  287. sd->vmax.contrast = 3;
  288. sd->vmax.gamma = 2;
  289. sd->vmax.hue = 0 + 1; /* 200, not done by hardware */
  290. sd->vmax.saturation = 0; /* 100, not done by hardware */
  291. sd->vmax.whitebal = 2; /* 100, not done by hardware */
  292. sd->vmax.mirror = 1;
  293. sd->vmax.flip = 1;
  294. sd->vmax.AC50Hz = 1;
  295. sd->dev_camera_settings = mi2020_camera_settings;
  296. sd->dev_init_at_startup = mi2020_init_at_startup;
  297. sd->dev_configure_alt = mi2020_configure_alt;
  298. sd->dev_init_pre_alt = mi2020_init_pre_alt;
  299. sd->dev_post_unset_alt = mi2020_post_unset_alt;
  300. }
  301. /*==========================================================================*/
  302. static void common(struct gspca_dev *gspca_dev)
  303. {
  304. fetch_validx(gspca_dev, tbl_common_0B, ARRAY_SIZE(tbl_common_0B));
  305. fetch_idxdata(gspca_dev, tbl_common_3B, ARRAY_SIZE(tbl_common_3B));
  306. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL);
  307. }
  308. static int mi2020_init_at_startup(struct gspca_dev *gspca_dev)
  309. {
  310. u8 c;
  311. ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &c);
  312. ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &c);
  313. fetch_validx(gspca_dev, tbl_init_at_startup,
  314. ARRAY_SIZE(tbl_init_at_startup));
  315. ctrl_out(gspca_dev, 0x40, 1, 0x7a00, 0x8030, 0, NULL);
  316. ctrl_in(gspca_dev, 0xc0, 2, 0x7a00, 0x8030, 1, &c);
  317. common(gspca_dev);
  318. msleep(61);
  319. /* ctrl_out(gspca_dev, 0x40, 11, 0x0000, 0x0000, 0, NULL); */
  320. /* msleep(36); */
  321. ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL);
  322. return 0;
  323. }
  324. static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev)
  325. {
  326. struct sd *sd = (struct sd *) gspca_dev;
  327. sd->mirrorMask = 0;
  328. sd->vold.hue = -1;
  329. /* These controls need to be reset */
  330. sd->vold.brightness = -1;
  331. sd->vold.sharpness = -1;
  332. /* If not different from default, they do not need to be set */
  333. sd->vold.contrast = 0;
  334. sd->vold.gamma = 0;
  335. sd->vold.backlight = 0;
  336. mi2020_init_post_alt(gspca_dev);
  337. return 0;
  338. }
  339. static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
  340. {
  341. struct sd *sd = (struct sd *) gspca_dev;
  342. s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
  343. s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0);
  344. s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0);
  345. s32 freq = (sd->vcur.AC50Hz > 0);
  346. s32 wbal = sd->vcur.whitebal;
  347. u8 dat_freq2[] = {0x90, 0x00, 0x80};
  348. u8 dat_multi1[] = {0x8c, 0xa7, 0x00};
  349. u8 dat_multi2[] = {0x90, 0x00, 0x00};
  350. u8 dat_multi3[] = {0x8c, 0xa7, 0x00};
  351. u8 dat_multi4[] = {0x90, 0x00, 0x00};
  352. u8 dat_hvflip2[] = {0x90, 0x04, 0x6c};
  353. u8 dat_hvflip4[] = {0x90, 0x00, 0x24};
  354. u8 dat_wbal2[] = {0x90, 0x00, 0x00};
  355. u8 c;
  356. sd->nbIm = -1;
  357. dat_freq2[2] = freq ? 0xc0 : 0x80;
  358. dat_multi1[2] = 0x9d;
  359. dat_multi3[2] = dat_multi1[2] + 1;
  360. if (wbal == 0) {
  361. dat_multi4[2] = dat_multi2[2] = 0;
  362. dat_wbal2[2] = 0x17;
  363. } else if (wbal == 1) {
  364. dat_multi4[2] = dat_multi2[2] = 0;
  365. dat_wbal2[2] = 0x35;
  366. } else if (wbal == 2) {
  367. dat_multi4[2] = dat_multi2[2] = 0x20;
  368. dat_wbal2[2] = 0x17;
  369. }
  370. dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror);
  371. dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror);
  372. msleep(200);
  373. ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL);
  374. msleep(2);
  375. common(gspca_dev);
  376. msleep(142);
  377. ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL);
  378. ctrl_out(gspca_dev, 0x40, 1, 0x0003, 0x00c1, 0, NULL);
  379. ctrl_out(gspca_dev, 0x40, 1, 0x0042, 0x00c2, 0, NULL);
  380. ctrl_out(gspca_dev, 0x40, 1, 0x006a, 0x000d, 0, NULL);
  381. switch (reso) {
  382. case IMAGE_640:
  383. case IMAGE_800:
  384. if (reso != IMAGE_800)
  385. ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
  386. 12, dat_640);
  387. else
  388. ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
  389. 12, dat_800);
  390. fetch_idxdata(gspca_dev, tbl_init_post_alt_low1,
  391. ARRAY_SIZE(tbl_init_post_alt_low1));
  392. if (reso == IMAGE_800)
  393. fetch_idxdata(gspca_dev, tbl_init_post_alt_low2,
  394. ARRAY_SIZE(tbl_init_post_alt_low2));
  395. fetch_idxdata(gspca_dev, tbl_init_post_alt_low3,
  396. ARRAY_SIZE(tbl_init_post_alt_low3));
  397. ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL);
  398. ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
  399. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
  400. msleep(120);
  401. break;
  402. case IMAGE_1280:
  403. case IMAGE_1600:
  404. if (reso == IMAGE_1280) {
  405. ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
  406. 12, dat_1280);
  407. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  408. 3, "\x8c\x27\x07");
  409. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  410. 3, "\x90\x05\x04");
  411. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  412. 3, "\x8c\x27\x09");
  413. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  414. 3, "\x90\x04\x02");
  415. } else {
  416. ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
  417. 12, dat_1600);
  418. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  419. 3, "\x8c\x27\x07");
  420. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  421. 3, "\x90\x06\x40");
  422. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  423. 3, "\x8c\x27\x09");
  424. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  425. 3, "\x90\x04\xb0");
  426. }
  427. fetch_idxdata(gspca_dev, tbl_init_post_alt_big,
  428. ARRAY_SIZE(tbl_init_post_alt_big));
  429. ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
  430. ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
  431. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
  432. msleep(1850);
  433. }
  434. ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
  435. msleep(40);
  436. /* AC power frequency */
  437. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1);
  438. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2);
  439. msleep(33);
  440. /* light source */
  441. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  442. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  443. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  444. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  445. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal1);
  446. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal2);
  447. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  448. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  449. msleep(7);
  450. ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c);
  451. fetch_idxdata(gspca_dev, tbl_init_post_alt_3B,
  452. ARRAY_SIZE(tbl_init_post_alt_3B));
  453. /* hvflip */
  454. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1);
  455. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2);
  456. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3);
  457. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4);
  458. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5);
  459. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6);
  460. msleep(250);
  461. if (reso == IMAGE_640 || reso == IMAGE_800)
  462. fetch_idxdata(gspca_dev, tbl_middle_hvflip_low,
  463. ARRAY_SIZE(tbl_middle_hvflip_low));
  464. else
  465. fetch_idxdata(gspca_dev, tbl_middle_hvflip_big,
  466. ARRAY_SIZE(tbl_middle_hvflip_big));
  467. fetch_idxdata(gspca_dev, tbl_end_hvflip,
  468. ARRAY_SIZE(tbl_end_hvflip));
  469. sd->nbIm = 0;
  470. sd->vold.mirror = mirror;
  471. sd->vold.flip = flip;
  472. sd->vold.AC50Hz = freq;
  473. sd->vold.whitebal = wbal;
  474. mi2020_camera_settings(gspca_dev);
  475. return 0;
  476. }
  477. static int mi2020_configure_alt(struct gspca_dev *gspca_dev)
  478. {
  479. s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
  480. switch (reso) {
  481. case IMAGE_640:
  482. gspca_dev->alt = 3 + 1;
  483. break;
  484. case IMAGE_800:
  485. case IMAGE_1280:
  486. case IMAGE_1600:
  487. gspca_dev->alt = 1 + 1;
  488. break;
  489. }
  490. return 0;
  491. }
  492. static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
  493. {
  494. struct sd *sd = (struct sd *) gspca_dev;
  495. s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
  496. s32 backlight = sd->vcur.backlight;
  497. s32 bright = sd->vcur.brightness;
  498. s32 sharp = sd->vcur.sharpness;
  499. s32 cntr = sd->vcur.contrast;
  500. s32 gam = sd->vcur.gamma;
  501. s32 hue = (sd->vcur.hue > 0);
  502. s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0);
  503. s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0);
  504. s32 freq = (sd->vcur.AC50Hz > 0);
  505. s32 wbal = sd->vcur.whitebal;
  506. u8 dat_sharp[] = {0x6c, 0x00, 0x08};
  507. u8 dat_bright2[] = {0x90, 0x00, 0x00};
  508. u8 dat_freq2[] = {0x90, 0x00, 0x80};
  509. u8 dat_multi1[] = {0x8c, 0xa7, 0x00};
  510. u8 dat_multi2[] = {0x90, 0x00, 0x00};
  511. u8 dat_multi3[] = {0x8c, 0xa7, 0x00};
  512. u8 dat_multi4[] = {0x90, 0x00, 0x00};
  513. u8 dat_hvflip2[] = {0x90, 0x04, 0x6c};
  514. u8 dat_hvflip4[] = {0x90, 0x00, 0x24};
  515. u8 dat_wbal2[] = {0x90, 0x00, 0x00};
  516. /* Less than 4 images received -> too early to set the settings */
  517. if (sd->nbIm < 4) {
  518. sd->waitSet = 1;
  519. return 0;
  520. }
  521. sd->waitSet = 0;
  522. if (freq != sd->vold.AC50Hz) {
  523. sd->vold.AC50Hz = freq;
  524. dat_freq2[2] = freq ? 0xc0 : 0x80;
  525. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1);
  526. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2);
  527. msleep(20);
  528. }
  529. if (wbal != sd->vold.whitebal) {
  530. sd->vold.whitebal = wbal;
  531. if (wbal < 0 || wbal > sd->vmax.whitebal)
  532. wbal = 0;
  533. dat_multi1[2] = 0x9d;
  534. dat_multi3[2] = dat_multi1[2] + 1;
  535. if (wbal == 0) {
  536. dat_multi4[2] = dat_multi2[2] = 0;
  537. dat_wbal2[2] = 0x17;
  538. } else if (wbal == 1) {
  539. dat_multi4[2] = dat_multi2[2] = 0;
  540. dat_wbal2[2] = 0x35;
  541. } else if (wbal == 2) {
  542. dat_multi4[2] = dat_multi2[2] = 0x20;
  543. dat_wbal2[2] = 0x17;
  544. }
  545. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  546. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  547. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  548. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  549. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal1);
  550. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_wbal2);
  551. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  552. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  553. }
  554. if (mirror != sd->vold.mirror || flip != sd->vold.flip) {
  555. sd->vold.mirror = mirror;
  556. sd->vold.flip = flip;
  557. dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror);
  558. dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror);
  559. fetch_idxdata(gspca_dev, tbl_init_post_alt_3B,
  560. ARRAY_SIZE(tbl_init_post_alt_3B));
  561. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1);
  562. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2);
  563. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3);
  564. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4);
  565. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5);
  566. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6);
  567. msleep(40);
  568. if (reso == IMAGE_640 || reso == IMAGE_800)
  569. fetch_idxdata(gspca_dev, tbl_middle_hvflip_low,
  570. ARRAY_SIZE(tbl_middle_hvflip_low));
  571. else
  572. fetch_idxdata(gspca_dev, tbl_middle_hvflip_big,
  573. ARRAY_SIZE(tbl_middle_hvflip_big));
  574. fetch_idxdata(gspca_dev, tbl_end_hvflip,
  575. ARRAY_SIZE(tbl_end_hvflip));
  576. }
  577. if (bright != sd->vold.brightness) {
  578. sd->vold.brightness = bright;
  579. if (bright < 0 || bright > sd->vmax.brightness)
  580. bright = 0;
  581. dat_bright2[2] = bright;
  582. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright1);
  583. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright2);
  584. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright3);
  585. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright4);
  586. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright5);
  587. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright6);
  588. }
  589. if (cntr != sd->vold.contrast || gam != sd->vold.gamma) {
  590. sd->vold.contrast = cntr;
  591. if (cntr < 0 || cntr > sd->vmax.contrast)
  592. cntr = 0;
  593. sd->vold.gamma = gam;
  594. if (gam < 0 || gam > sd->vmax.gamma)
  595. gam = 0;
  596. dat_multi1[2] = 0x6d;
  597. dat_multi3[2] = dat_multi1[2] + 1;
  598. if (cntr == 0)
  599. cntr = 4;
  600. dat_multi4[2] = dat_multi2[2] = cntr * 0x10 + 2 - gam;
  601. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  602. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  603. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  604. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  605. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  606. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  607. }
  608. if (backlight != sd->vold.backlight) {
  609. sd->vold.backlight = backlight;
  610. if (backlight < 0 || backlight > sd->vmax.backlight)
  611. backlight = 0;
  612. dat_multi1[2] = 0x9d;
  613. dat_multi3[2] = dat_multi1[2] + 1;
  614. dat_multi4[2] = dat_multi2[2] = backlight;
  615. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  616. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  617. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  618. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  619. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  620. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  621. }
  622. if (sharp != sd->vold.sharpness) {
  623. sd->vold.sharpness = sharp;
  624. if (sharp < 0 || sharp > sd->vmax.sharpness)
  625. sharp = 0;
  626. dat_sharp[1] = sharp;
  627. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0032, 3, dat_sharp);
  628. }
  629. if (hue != sd->vold.hue) {
  630. sd->swapRB = hue;
  631. sd->vold.hue = hue;
  632. }
  633. return 0;
  634. }
  635. static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev)
  636. {
  637. ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL);
  638. msleep(40);
  639. ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL);
  640. }