gl860-mi2020.c 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  1. /* @file gl860-mi2020.c
  2. * @author Olivier LORIN, from Ice/Soro2005's logs(A), Fret_saw/Hulkie's
  3. * logs(B) and Tricid"s logs(C). With the help of Kytrix/BUGabundo/Blazercist.
  4. * @date 2009-08-27
  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_bright1[] = {0x8c, 0xa2, 0x06};
  22. static u8 dat_bright3[] = {0x8c, 0xa1, 0x02};
  23. static u8 dat_bright4[] = {0x90, 0x00, 0x0f};
  24. static u8 dat_bright5[] = {0x8c, 0xa1, 0x03};
  25. static u8 dat_bright6[] = {0x90, 0x00, 0x05};
  26. static u8 dat_dummy1[] = {0x90, 0x00, 0x06};
  27. /*static u8 dummy2[] = {0x8c, 0xa1, 0x02};*/
  28. /*static u8 dummy3[] = {0x90, 0x00, 0x1f};*/
  29. static u8 dat_hvflip1[] = {0x8c, 0x27, 0x19};
  30. static u8 dat_hvflip3[] = {0x8c, 0x27, 0x3b};
  31. static u8 dat_hvflip5[] = {0x8c, 0xa1, 0x03};
  32. static u8 dat_hvflip6[] = {0x90, 0x00, 0x06};
  33. static u8 dat_freq1[] = { 0x8c, 0xa4, 0x04 };
  34. static u8 dat_multi5[] = { 0x8c, 0xa1, 0x03 };
  35. static u8 dat_multi6[] = { 0x90, 0x00, 0x05 };
  36. static struct validx tbl_common_a[] = {
  37. {0x0000, 0x0000},
  38. {1, 0xffff}, /* msleep(35); */
  39. {0x006a, 0x0007}, {0x0063, 0x0006}, {0x006a, 0x000d}, {0x0000, 0x00c0},
  40. {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2}, {0x0004, 0x00d8},
  41. {0x0000, 0x0058}, {0x0002, 0x0004}, {0x0041, 0x0000},
  42. };
  43. static struct validx tbl_common_b[] = {
  44. {0x006a, 0x0007},
  45. {35, 0xffff},
  46. {0x00ef, 0x0006},
  47. {35, 0xffff},
  48. {0x006a, 0x000d},
  49. {35, 0xffff},
  50. {0x0000, 0x00c0}, {0x0010, 0x0010}, {0x0003, 0x00c1}, {0x0042, 0x00c2},
  51. {0x0004, 0x00d8}, {0x0000, 0x0058}, {0x0041, 0x0000},
  52. };
  53. static struct idxdata tbl_common_c[] = {
  54. {0x32, "\x02\x00\x08"}, {0x33, "\xf4\x03\x1d"},
  55. {6, "\xff\xff\xff"}, /* 12 */
  56. {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"},
  57. {2, "\xff\xff\xff"}, /* - */
  58. {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\x22\x23"},
  59. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa2\x0f"}, {0x33, "\x90\x00\x0d"},
  60. {0x33, "\x8c\xa2\x10"}, {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x11"},
  61. {0x33, "\x90\x00\x07"}, {0x33, "\xf4\x03\x1d"}, {0x35, "\xa2\x00\xe2"},
  62. {0x33, "\x8c\xab\x05"}, {0x33, "\x90\x00\x01"}, {0x32, "\x6e\x00\x86"},
  63. {0x32, "\x70\x0f\xaa"}, {0x32, "\x72\x0f\xe4"}, {0x33, "\x8c\xa3\x4a"},
  64. {0x33, "\x90\x00\x5a"}, {0x33, "\x8c\xa3\x4b"}, {0x33, "\x90\x00\xa6"},
  65. {0x33, "\x8c\xa3\x61"}, {0x33, "\x90\x00\xc8"}, {0x33, "\x8c\xa3\x62"},
  66. {0x33, "\x90\x00\xe1"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"},
  67. {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"},
  68. {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"},
  69. {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"},
  70. {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"},
  71. {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"},
  72. {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"},
  73. {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"},
  74. {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"},
  75. {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"},
  76. {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"},
  77. {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"},
  78. {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"},
  79. {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"},
  80. {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"},
  81. {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"},
  82. {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"},
  83. {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"},
  84. {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"},
  85. {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"},
  86. {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"},
  87. {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"},
  88. {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"},
  89. {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"},
  90. {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"},
  91. {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"},
  92. {1, "\xff\xff\xff"},
  93. {0x33, "\x78\x00\x00"},
  94. {1, "\xff\xff\xff"},
  95. {0x35, "\xb8\x1f\x20"}, {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x10"},
  96. {0x33, "\x8c\xa2\x07"}, {0x33, "\x90\x00\x08"}, {0x33, "\x8c\xa2\x42"},
  97. {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x4a"}, {0x33, "\x90\x00\x8c"},
  98. {0x35, "\xba\xfa\x08"}, {0x33, "\x8c\xa2\x02"}, {0x33, "\x90\x00\x22"},
  99. {0x33, "\x8c\xa2\x03"}, {0x33, "\x90\x00\xbb"},
  100. };
  101. static struct idxdata tbl_common_d[] = {
  102. {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa0"}, {0x33, "\x8c\xa4\x08"},
  103. {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x21"},
  104. {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\xa4\x0b"},
  105. {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\xa0"},
  106. {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc0"}, {0x33, "\x8c\x24\x15"},
  107. {0x33, "\x90\x00\xa0"}, {0x33, "\x8c\x24\x17"}, {0x33, "\x90\x00\xc0"},
  108. };
  109. static struct idxdata tbl_common_e[] = {
  110. {0x33, "\x8c\xa4\x04"}, {0x33, "\x90\x00\x80"}, {0x33, "\x8c\xa7\x9d"},
  111. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa7\x9e"}, {0x33, "\x90\x00\x00"},
  112. {0x33, "\x8c\xa2\x0c"}, {0x33, "\x90\x00\x17"}, {0x33, "\x8c\xa2\x15"},
  113. {0x33, "\x90\x00\x04"}, {0x33, "\x8c\xa2\x14"}, {0x33, "\x90\x00\x20"},
  114. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"},
  115. /* msleep(53); */
  116. {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"},
  117. {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x39"},
  118. {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"},
  119. {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x03"},
  120. {0x33, "\x90\x02\x84"}, {0x33, "\x8c\x27\x05"}, {0x33, "\x90\x01\xe2"},
  121. {0x33, "\x8c\x27\x07"}, {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x09"},
  122. {0x33, "\x90\x04\xb0"}, {0x33, "\x8c\x27\x0d"}, {0x33, "\x90\x00\x00"},
  123. {0x33, "\x8c\x27\x0f"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x11"},
  124. {0x33, "\x90\x04\xbd"}, {0x33, "\x8c\x27\x13"}, {0x33, "\x90\x06\x4d"},
  125. {0x33, "\x8c\x27\x15"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"},
  126. {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"},
  127. {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x1d"},
  128. {0x33, "\x90\x01\x02"}, {0x33, "\x8c\x27\x1f"}, {0x33, "\x90\x02\x79"},
  129. {0x33, "\x8c\x27\x21"}, {0x33, "\x90\x01\x55"}, {0x33, "\x8c\x27\x23"},
  130. {0x33, "\x90\x02\x85"}, {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"},
  131. {0x33, "\x8c\x27\x27"}, {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x29"},
  132. {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x2b"}, {0x33, "\x90\x10\x20"},
  133. {0x33, "\x8c\x27\x2d"}, {0x33, "\x90\x20\x07"}, {0x33, "\x8c\x27\x2f"},
  134. {0x33, "\x90\x00\x04"}, {0x33, "\x8c\x27\x31"}, {0x33, "\x90\x00\x04"},
  135. {0x33, "\x8c\x27\x33"}, {0x33, "\x90\x04\xbb"}, {0x33, "\x8c\x27\x35"},
  136. {0x33, "\x90\x06\x4b"}, {0x33, "\x8c\x27\x37"}, {0x33, "\x90\x00\x00"},
  137. {0x33, "\x8c\x27\x39"}, {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3b"},
  138. {0x33, "\x90\x00\x24"}, {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"},
  139. {0x33, "\x8c\x27\x41"}, {0x33, "\x90\x01\x69"}, {0x33, "\x8c\x27\x45"},
  140. {0x33, "\x90\x04\xed"}, {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"},
  141. {0x33, "\x8c\x27\x51"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x53"},
  142. {0x33, "\x90\x03\x20"}, {0x33, "\x8c\x27\x55"}, {0x33, "\x90\x00\x00"},
  143. {0x33, "\x8c\x27\x57"}, {0x33, "\x90\x02\x58"}, {0x33, "\x8c\x27\x5f"},
  144. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x61"}, {0x33, "\x90\x06\x40"},
  145. {0x33, "\x8c\x27\x63"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x65"},
  146. {0x33, "\x90\x04\xb0"}, {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa1"},
  147. {0x33, "\x8c\xa4\x08"}, {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"},
  148. {0x33, "\x90\x00\x21"}, {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"},
  149. {0x33, "\x8c\xa4\x0b"}, {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"},
  150. {0x33, "\x90\x00\xa1"}, {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc1"},
  151. {0x33, "\x8c\x24\x15"},
  152. };
  153. static struct validx tbl_init_at_startup[] = {
  154. {0x0000, 0x0000},
  155. {53, 0xffff},
  156. {0x0010, 0x0010},
  157. {53, 0xffff},
  158. {0x0008, 0x00c0},
  159. {53, 0xffff},
  160. {0x0001, 0x00c1},
  161. {53, 0xffff},
  162. {0x0001, 0x00c2},
  163. {53, 0xffff},
  164. {0x0020, 0x0006},
  165. {53, 0xffff},
  166. {0x006a, 0x000d},
  167. {53, 0xffff},
  168. };
  169. static struct idxdata tbl_init_post_alt_low_a[] = {
  170. {0x33, "\x8c\x27\x15"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\x22\x2e"},
  171. {0x33, "\x90\x00\x81"}, {0x33, "\x8c\xa4\x08"}, {0x33, "\x90\x00\x17"},
  172. {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x1a"}, {0x33, "\x8c\xa4\x0a"},
  173. {0x33, "\x90\x00\x1d"}, {0x33, "\x8c\xa4\x0b"}, {0x33, "\x90\x00\x20"},
  174. {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\x81"}, {0x33, "\x8c\x24\x13"},
  175. {0x33, "\x90\x00\x9b"},
  176. };
  177. static struct idxdata tbl_init_post_alt_low_b[] = {
  178. {0x33, "\x8c\x27\x03"}, {0x33, "\x90\x03\x24"}, {0x33, "\x8c\x27\x05"},
  179. {0x33, "\x90\x02\x58"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  180. {2, "\xff\xff\xff"},
  181. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  182. {2, "\xff\xff\xff"},
  183. };
  184. static struct idxdata tbl_init_post_alt_low_c[] = {
  185. {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"},
  186. {2, "\xff\xff\xff"},
  187. {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x20"},
  188. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x01"},
  189. {0x33, "\x2e\x01\x00"}, {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"},
  190. {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x95"}, {0x33, "\x90\x01\x00"},
  191. {2, "\xff\xff\xff"},
  192. {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x03"},
  193. {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
  194. {2, "\xff\xff\xff"},
  195. {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"},
  196. {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"},
  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. {2, "\xff\xff\xff"},
  202. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  203. {2, "\xff\xff\xff"},
  204. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  205. {1, "\xff\xff\xff"},
  206. };
  207. static struct idxdata tbl_init_post_alt_low_d[] = {
  208. {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"},
  209. {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"},
  210. {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"},
  211. {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"},
  212. {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"},
  213. {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"},
  214. {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"},
  215. {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"},
  216. {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"},
  217. {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"},
  218. {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"},
  219. {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"},
  220. {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"},
  221. {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"},
  222. {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"},
  223. {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"},
  224. {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"},
  225. {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"},
  226. {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"},
  227. {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"},
  228. {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"},
  229. {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"},
  230. {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"},
  231. {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"},
  232. {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"},
  233. {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"},
  234. /* Flip/Mirror h/v=1 */
  235. {0x33, "\x90\x00\x3c"}, {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"},
  236. {0x33, "\x8c\x27\x3b"}, {0x33, "\x90\x00\x24"}, {0x33, "\x8c\xa1\x03"},
  237. {0x33, "\x90\x00\x06"},
  238. {130, "\xff\xff\xff"},
  239. {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"},
  240. {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"}, {0x33, "\x90\x00\x06"},
  241. {100, "\xff\xff\xff"},
  242. /* ?? */
  243. {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa1\x02"},
  244. {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
  245. {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"},
  246. /* Brigthness=70 */
  247. {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x46"}, {0x33, "\x8c\xa1\x02"},
  248. {0x33, "\x90\x00\x0f"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  249. /* Sharpness=20 */
  250. {0x32, "\x6c\x14\x08"},
  251. };
  252. static struct idxdata tbl_init_post_alt_big_a[] = {
  253. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  254. {2, "\xff\xff\xff"},
  255. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  256. {2, "\xff\xff\xff"},
  257. {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"},
  258. {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x03"},
  259. {0x33, "\x90\x00\x05"},
  260. {2, "\xff\xff\xff"},
  261. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"},
  262. {2, "\xff\xff\xff"},
  263. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"},
  264. {2, "\xff\xff\xff"},
  265. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, {0x33, "\x8c\xa1\x20"},
  266. {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x30"}, {0x33, "\x90\x00\x03"},
  267. {0x33, "\x8c\xa1\x31"}, {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa1\x32"},
  268. {0x33, "\x90\x00\x03"}, {0x33, "\x8c\xa1\x34"}, {0x33, "\x90\x00\x03"},
  269. {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x2e\x01\x00"},
  270. {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"},
  271. };
  272. static struct idxdata tbl_init_post_alt_big_b[] = {
  273. {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"},
  274. {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"},
  275. {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"},
  276. {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"},
  277. {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"},
  278. {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"},
  279. {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"},
  280. {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"},
  281. {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"},
  282. {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"},
  283. {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"},
  284. {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"},
  285. {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"},
  286. {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"},
  287. {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"},
  288. {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"},
  289. {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"},
  290. {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"},
  291. {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"},
  292. {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"},
  293. {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"},
  294. {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"},
  295. {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"},
  296. {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"},
  297. {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"},
  298. {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"},
  299. };
  300. static struct idxdata tbl_init_post_alt_big_c[] = {
  301. {0x33, "\x8c\xa1\x02"},
  302. {0x33, "\x90\x00\x1f"},
  303. {0x33, "\x8c\xa1\x02"},
  304. {0x33, "\x90\x00\x1f"},
  305. {0x33, "\x8c\xa1\x02"},
  306. {0x33, "\x90\x00\x1f"},
  307. {0x33, "\x8c\xa1\x02"},
  308. {0x33, "\x90\x00\x1f"},
  309. };
  310. static u8 *dat_640 = "\xd0\x02\xd1\x08\xd2\xe1\xd3\x02\xd4\x10\xd5\x81";
  311. static u8 *dat_800 = "\xd0\x02\xd1\x10\xd2\x57\xd3\x02\xd4\x18\xd5\x21";
  312. static u8 *dat_1280 = "\xd0\x02\xd1\x20\xd2\x01\xd3\x02\xd4\x28\xd5\x01";
  313. static u8 *dat_1600 = "\xd0\x02\xd1\x20\xd2\xaf\xd3\x02\xd4\x30\xd5\x41";
  314. static int mi2020_init_at_startup(struct gspca_dev *gspca_dev);
  315. static int mi2020_configure_alt(struct gspca_dev *gspca_dev);
  316. static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev);
  317. static int mi2020_init_post_alt(struct gspca_dev *gspca_dev);
  318. static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev);
  319. static int mi2020_camera_settings(struct gspca_dev *gspca_dev);
  320. /*==========================================================================*/
  321. void mi2020_init_settings(struct gspca_dev *gspca_dev)
  322. {
  323. struct sd *sd = (struct sd *) gspca_dev;
  324. sd->vcur.backlight = 0;
  325. sd->vcur.brightness = 70;
  326. sd->vcur.sharpness = 20;
  327. sd->vcur.contrast = 0;
  328. sd->vcur.gamma = 0;
  329. sd->vcur.hue = 0;
  330. sd->vcur.saturation = 60;
  331. sd->vcur.whitebal = 50;
  332. sd->vcur.mirror = 0;
  333. sd->vcur.flip = 0;
  334. sd->vcur.AC50Hz = 1;
  335. sd->vmax.backlight = 64;
  336. sd->vmax.brightness = 128;
  337. sd->vmax.sharpness = 40;
  338. sd->vmax.contrast = 3;
  339. sd->vmax.gamma = 2;
  340. sd->vmax.hue = 0 + 1; /* 200 */
  341. sd->vmax.saturation = 0; /* 100 */
  342. sd->vmax.whitebal = 0; /* 100 */
  343. sd->vmax.mirror = 1;
  344. sd->vmax.flip = 1;
  345. sd->vmax.AC50Hz = 1;
  346. if (_MI2020b_) {
  347. sd->vmax.contrast = 0;
  348. sd->vmax.gamma = 0;
  349. sd->vmax.backlight = 0;
  350. }
  351. sd->dev_camera_settings = mi2020_camera_settings;
  352. sd->dev_init_at_startup = mi2020_init_at_startup;
  353. sd->dev_configure_alt = mi2020_configure_alt;
  354. sd->dev_init_pre_alt = mi2020_init_pre_alt;
  355. sd->dev_post_unset_alt = mi2020_post_unset_alt;
  356. }
  357. /*==========================================================================*/
  358. static void common(struct gspca_dev *gspca_dev)
  359. {
  360. s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
  361. if (_MI2020b_) {
  362. fetch_validx(gspca_dev, tbl_common_a, ARRAY_SIZE(tbl_common_a));
  363. } else {
  364. if (_MI2020_)
  365. ctrl_out(gspca_dev, 0x40, 1, 0x0008, 0x0004, 0, NULL);
  366. else
  367. ctrl_out(gspca_dev, 0x40, 1, 0x0002, 0x0004, 0, NULL);
  368. msleep(35);
  369. fetch_validx(gspca_dev, tbl_common_b, ARRAY_SIZE(tbl_common_b));
  370. }
  371. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x86\x25\x01");
  372. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x86\x25\x00");
  373. msleep(2); /* - * */
  374. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0030, 3, "\x1a\x0a\xcc");
  375. if (reso == IMAGE_1600)
  376. msleep(2); /* 1600 */
  377. fetch_idxdata(gspca_dev, tbl_common_c, ARRAY_SIZE(tbl_common_c));
  378. if (_MI2020b_ || _MI2020_)
  379. fetch_idxdata(gspca_dev, tbl_common_d,
  380. ARRAY_SIZE(tbl_common_d));
  381. fetch_idxdata(gspca_dev, tbl_common_e, ARRAY_SIZE(tbl_common_e));
  382. if (_MI2020b_ || _MI2020_) {
  383. /* Different from fret */
  384. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x78");
  385. /* Same as fret */
  386. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x24\x17");
  387. /* Different from fret */
  388. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x90");
  389. } else {
  390. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x6a");
  391. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x24\x17");
  392. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x80");
  393. }
  394. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
  395. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x05");
  396. msleep(2);
  397. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
  398. if (reso == IMAGE_1600)
  399. msleep(14); /* 1600 */
  400. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x06");
  401. msleep(2);
  402. }
  403. static int mi2020_init_at_startup(struct gspca_dev *gspca_dev)
  404. {
  405. u8 c;
  406. ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &c);
  407. ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0004, 1, &c);
  408. fetch_validx(gspca_dev, tbl_init_at_startup,
  409. ARRAY_SIZE(tbl_init_at_startup));
  410. common(gspca_dev);
  411. return 0;
  412. }
  413. static int mi2020_init_pre_alt(struct gspca_dev *gspca_dev)
  414. {
  415. struct sd *sd = (struct sd *) gspca_dev;
  416. sd->mirrorMask = 0;
  417. sd->vold.backlight = -1;
  418. sd->vold.brightness = -1;
  419. sd->vold.sharpness = -1;
  420. sd->vold.contrast = -1;
  421. sd->vold.gamma = -1;
  422. sd->vold.hue = -1;
  423. sd->vold.mirror = -1;
  424. sd->vold.flip = -1;
  425. sd->vold.AC50Hz = -1;
  426. mi2020_init_post_alt(gspca_dev);
  427. return 0;
  428. }
  429. static int mi2020_init_post_alt(struct gspca_dev *gspca_dev)
  430. {
  431. struct sd *sd = (struct sd *) gspca_dev;
  432. s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
  433. s32 backlight = sd->vcur.backlight;
  434. s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0);
  435. s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0);
  436. s32 freq = (sd->vcur.AC50Hz > 0);
  437. u8 dat_freq2[] = {0x90, 0x00, 0x80};
  438. u8 dat_multi1[] = {0x8c, 0xa7, 0x00};
  439. u8 dat_multi2[] = {0x90, 0x00, 0x00};
  440. u8 dat_multi3[] = {0x8c, 0xa7, 0x00};
  441. u8 dat_multi4[] = {0x90, 0x00, 0x00};
  442. u8 dat_hvflip2[] = {0x90, 0x04, 0x6c};
  443. u8 dat_hvflip4[] = {0x90, 0x00, 0x24};
  444. u8 c;
  445. sd->nbIm = -1;
  446. dat_freq2[2] = freq ? 0xc0 : 0x80;
  447. dat_multi1[2] = 0x9d;
  448. dat_multi3[2] = dat_multi1[2] + 1;
  449. dat_multi4[2] = dat_multi2[2] = backlight;
  450. dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror);
  451. dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror);
  452. msleep(200);
  453. ctrl_out(gspca_dev, 0x40, 5, 0x0001, 0x0000, 0, NULL);
  454. msleep(3); /* 35 * */
  455. common(gspca_dev);
  456. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL);
  457. msleep(70);
  458. if (_MI2020b_)
  459. ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
  460. ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL);
  461. ctrl_out(gspca_dev, 0x40, 1, 0x0003, 0x00c1, 0, NULL);
  462. ctrl_out(gspca_dev, 0x40, 1, 0x0042, 0x00c2, 0, NULL);
  463. ctrl_out(gspca_dev, 0x40, 1, 0x006a, 0x000d, 0, NULL);
  464. switch (reso) {
  465. case IMAGE_640:
  466. case IMAGE_800:
  467. if (reso != IMAGE_800)
  468. ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
  469. 12, dat_640);
  470. else
  471. ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
  472. 12, dat_800);
  473. if (_MI2020c_)
  474. fetch_idxdata(gspca_dev, tbl_init_post_alt_low_a,
  475. ARRAY_SIZE(tbl_init_post_alt_low_a));
  476. if (reso == IMAGE_800)
  477. fetch_idxdata(gspca_dev, tbl_init_post_alt_low_b,
  478. ARRAY_SIZE(tbl_init_post_alt_low_b));
  479. fetch_idxdata(gspca_dev, tbl_init_post_alt_low_c,
  480. ARRAY_SIZE(tbl_init_post_alt_low_c));
  481. if (_MI2020b_) {
  482. ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
  483. ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
  484. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
  485. msleep(150);
  486. } else if (_MI2020c_) {
  487. ctrl_out(gspca_dev, 0x40, 1, 0x0010, 0x0010, 0, NULL);
  488. ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
  489. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
  490. msleep(120);
  491. ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
  492. msleep(30);
  493. } else if (_MI2020_) {
  494. ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
  495. ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
  496. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
  497. msleep(120);
  498. ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
  499. msleep(30);
  500. }
  501. /* AC power frequency */
  502. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1);
  503. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2);
  504. msleep(20);
  505. /* backlight */
  506. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  507. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  508. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  509. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  510. /* at init time but not after */
  511. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa2\x0c");
  512. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x17");
  513. /* finish the backlight */
  514. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  515. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  516. msleep(5);/* " */
  517. if (_MI2020c_) {
  518. fetch_idxdata(gspca_dev, tbl_init_post_alt_low_d,
  519. ARRAY_SIZE(tbl_init_post_alt_low_d));
  520. } else {
  521. ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c);
  522. msleep(14); /* 0xd8 */
  523. /* flip/mirror */
  524. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  525. 3, dat_hvflip1);
  526. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  527. 3, dat_hvflip2);
  528. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  529. 3, dat_hvflip3);
  530. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  531. 3, dat_hvflip4);
  532. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  533. 3, dat_hvflip5);
  534. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  535. 3, dat_hvflip6);
  536. msleep(21);
  537. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  538. 3, dat_dummy1);
  539. msleep(5);
  540. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  541. 3, dat_dummy1);
  542. msleep(5);
  543. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  544. 3, dat_dummy1);
  545. msleep(5);
  546. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  547. 3, dat_dummy1);
  548. msleep(5);
  549. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  550. 3, dat_dummy1);
  551. msleep(5);
  552. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  553. 3, dat_dummy1);
  554. /* end of flip/mirror main part */
  555. msleep(246); /* 146 */
  556. sd->nbIm = 0;
  557. }
  558. break;
  559. case IMAGE_1280:
  560. case IMAGE_1600:
  561. if (reso == IMAGE_1280) {
  562. ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
  563. 12, dat_1280);
  564. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  565. 3, "\x8c\x27\x07");
  566. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  567. 3, "\x90\x05\x04");
  568. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  569. 3, "\x8c\x27\x09");
  570. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  571. 3, "\x90\x04\x02");
  572. } else {
  573. ctrl_out(gspca_dev, 0x40, 3, 0x0000, 0x0200,
  574. 12, dat_1600);
  575. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  576. 3, "\x8c\x27\x07");
  577. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  578. 3, "\x90\x06\x40");
  579. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  580. 3, "\x8c\x27\x09");
  581. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033,
  582. 3, "\x90\x04\xb0");
  583. }
  584. fetch_idxdata(gspca_dev, tbl_init_post_alt_big_a,
  585. ARRAY_SIZE(tbl_init_post_alt_big_a));
  586. if (reso == IMAGE_1600)
  587. msleep(13); /* 1600 */
  588. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\x27\x97");
  589. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x01\x00");
  590. msleep(53);
  591. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20");
  592. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00");
  593. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
  594. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01");
  595. if (reso == IMAGE_1600)
  596. msleep(13); /* 1600 */
  597. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02");
  598. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00");
  599. msleep(53);
  600. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20");
  601. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x72");
  602. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
  603. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x02");
  604. if (reso == IMAGE_1600)
  605. msleep(13); /* 1600 */
  606. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02");
  607. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01");
  608. msleep(53);
  609. if (_MI2020b_) {
  610. ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
  611. if (reso == IMAGE_1600)
  612. msleep(500); /* 1600 */
  613. ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
  614. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
  615. msleep(1850);
  616. } else if (_MI2020c_ || _MI2020_) {
  617. ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0010, 0, NULL);
  618. ctrl_out(gspca_dev, 0x40, 1, 0x0000, 0x00c1, 0, NULL);
  619. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x00c2, 0, NULL);
  620. msleep(1850);
  621. ctrl_out(gspca_dev, 0x40, 1, 0x0040, 0x0000, 0, NULL);
  622. msleep(30);
  623. }
  624. /* AC power frequency */
  625. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1);
  626. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2);
  627. msleep(20);
  628. /* backlight */
  629. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  630. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  631. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  632. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  633. /* at init time but not after */
  634. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa2\x0c");
  635. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x17");
  636. /* finish the backlight */
  637. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  638. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  639. msleep(6); /* " */
  640. ctrl_in(gspca_dev, 0xc0, 2, 0x0000, 0x0000, 1, &c);
  641. msleep(14);
  642. if (_MI2020c_)
  643. fetch_idxdata(gspca_dev, tbl_init_post_alt_big_b,
  644. ARRAY_SIZE(tbl_init_post_alt_big_b));
  645. /* flip/mirror */
  646. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1);
  647. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2);
  648. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3);
  649. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4);
  650. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5);
  651. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6);
  652. /* end of flip/mirror main part */
  653. msleep(16);
  654. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
  655. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01");
  656. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20");
  657. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00");
  658. if (reso == IMAGE_1600)
  659. msleep(25); /* 1600 */
  660. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02");
  661. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x00");
  662. msleep(103);
  663. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x03");
  664. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x02");
  665. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa1\x20");
  666. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x72");
  667. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x8c\xa7\x02");
  668. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, "\x90\x00\x01");
  669. sd->nbIm = 0;
  670. if (_MI2020c_)
  671. fetch_idxdata(gspca_dev, tbl_init_post_alt_big_c,
  672. ARRAY_SIZE(tbl_init_post_alt_big_c));
  673. }
  674. sd->vold.mirror = mirror;
  675. sd->vold.flip = flip;
  676. sd->vold.AC50Hz = freq;
  677. sd->vold.backlight = backlight;
  678. mi2020_camera_settings(gspca_dev);
  679. return 0;
  680. }
  681. static int mi2020_configure_alt(struct gspca_dev *gspca_dev)
  682. {
  683. s32 reso = gspca_dev->cam.cam_mode[(s32) gspca_dev->curr_mode].priv;
  684. switch (reso) {
  685. case IMAGE_640:
  686. gspca_dev->alt = 3 + 1;
  687. break;
  688. case IMAGE_800:
  689. case IMAGE_1280:
  690. case IMAGE_1600:
  691. gspca_dev->alt = 1 + 1;
  692. break;
  693. }
  694. return 0;
  695. }
  696. int mi2020_camera_settings(struct gspca_dev *gspca_dev)
  697. {
  698. struct sd *sd = (struct sd *) gspca_dev;
  699. s32 backlight = sd->vcur.backlight;
  700. s32 bright = sd->vcur.brightness;
  701. s32 sharp = sd->vcur.sharpness;
  702. s32 cntr = sd->vcur.contrast;
  703. s32 gam = sd->vcur.gamma;
  704. s32 hue = (sd->vcur.hue > 0);
  705. s32 mirror = (((sd->vcur.mirror > 0) ^ sd->mirrorMask) > 0);
  706. s32 flip = (((sd->vcur.flip > 0) ^ sd->mirrorMask) > 0);
  707. s32 freq = (sd->vcur.AC50Hz > 0);
  708. u8 dat_sharp[] = {0x6c, 0x00, 0x08};
  709. u8 dat_bright2[] = {0x90, 0x00, 0x00};
  710. u8 dat_freq2[] = {0x90, 0x00, 0x80};
  711. u8 dat_multi1[] = {0x8c, 0xa7, 0x00};
  712. u8 dat_multi2[] = {0x90, 0x00, 0x00};
  713. u8 dat_multi3[] = {0x8c, 0xa7, 0x00};
  714. u8 dat_multi4[] = {0x90, 0x00, 0x00};
  715. u8 dat_hvflip2[] = {0x90, 0x04, 0x6c};
  716. u8 dat_hvflip4[] = {0x90, 0x00, 0x24};
  717. /* Less than 4 images received -> too early to set the settings */
  718. if (sd->nbIm < 4) {
  719. sd->waitSet = 1;
  720. return 0;
  721. }
  722. sd->waitSet = 0;
  723. if (freq != sd->vold.AC50Hz) {
  724. sd->vold.AC50Hz = freq;
  725. dat_freq2[2] = freq ? 0xc0 : 0x80;
  726. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq1);
  727. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_freq2);
  728. msleep(20);
  729. }
  730. if (mirror != sd->vold.mirror || flip != sd->vold.flip) {
  731. sd->vold.mirror = mirror;
  732. sd->vold.flip = flip;
  733. dat_hvflip2[2] = 0x6c + 2 * (1 - flip) + (1 - mirror);
  734. dat_hvflip4[2] = 0x24 + 2 * (1 - flip) + (1 - mirror);
  735. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip1);
  736. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip2);
  737. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip3);
  738. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip4);
  739. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip5);
  740. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_hvflip6);
  741. msleep(130);
  742. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1);
  743. msleep(6);
  744. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1);
  745. msleep(6);
  746. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1);
  747. msleep(6);
  748. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1);
  749. msleep(6);
  750. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1);
  751. msleep(6);
  752. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_dummy1);
  753. msleep(6);
  754. /* Sometimes present, sometimes not, useful? */
  755. /* ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2);
  756. * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);
  757. * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2);
  758. * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);
  759. * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2);
  760. * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);
  761. * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy2);
  762. * ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dummy3);*/
  763. }
  764. if (backlight != sd->vold.backlight) {
  765. sd->vold.backlight = backlight;
  766. if (backlight < 0 || backlight > sd->vmax.backlight)
  767. backlight = 0;
  768. dat_multi1[2] = 0x9d;
  769. dat_multi3[2] = dat_multi1[2] + 1;
  770. dat_multi4[2] = dat_multi2[2] = backlight;
  771. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  772. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  773. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  774. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  775. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  776. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  777. }
  778. if (gam != sd->vold.gamma) {
  779. sd->vold.gamma = gam;
  780. if (gam < 0 || gam > sd->vmax.gamma)
  781. gam = 0;
  782. dat_multi1[2] = 0x6d;
  783. dat_multi3[2] = dat_multi1[2] + 1;
  784. dat_multi4[2] = dat_multi2[2] = 0x40 + gam;
  785. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  786. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  787. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  788. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  789. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  790. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  791. }
  792. if (cntr != sd->vold.contrast) {
  793. sd->vold.contrast = cntr;
  794. if (cntr < 0 || cntr > sd->vmax.contrast)
  795. cntr = 0;
  796. dat_multi1[2] = 0x6d;
  797. dat_multi3[2] = dat_multi1[2] + 1;
  798. dat_multi4[2] = dat_multi2[2] = 0x12 + 16 * cntr;
  799. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi1);
  800. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi2);
  801. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi3);
  802. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi4);
  803. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi5);
  804. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_multi6);
  805. }
  806. if (bright != sd->vold.brightness) {
  807. sd->vold.brightness = bright;
  808. if (bright < 0 || bright > sd->vmax.brightness)
  809. bright = 0;
  810. dat_bright2[2] = bright;
  811. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright1);
  812. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright2);
  813. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright3);
  814. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright4);
  815. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright5);
  816. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0033, 3, dat_bright6);
  817. }
  818. if (sharp != sd->vold.sharpness) {
  819. sd->vold.sharpness = sharp;
  820. if (sharp < 0 || sharp > sd->vmax.sharpness)
  821. sharp = 0;
  822. dat_sharp[1] = sharp;
  823. ctrl_out(gspca_dev, 0x40, 3, 0x7a00, 0x0032, 3, dat_sharp);
  824. }
  825. if (hue != sd->vold.hue) {
  826. sd->swapRB = hue;
  827. sd->vold.hue = hue;
  828. }
  829. return 0;
  830. }
  831. static void mi2020_post_unset_alt(struct gspca_dev *gspca_dev)
  832. {
  833. ctrl_out(gspca_dev, 0x40, 5, 0x0000, 0x0000, 0, NULL);
  834. msleep(20);
  835. if (_MI2020c_ || _MI2020_)
  836. ctrl_out(gspca_dev, 0x40, 1, 0x0001, 0x0000, 0, NULL);
  837. else
  838. ctrl_out(gspca_dev, 0x40, 1, 0x0041, 0x0000, 0, NULL);
  839. }