dw2102.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956
  1. /* DVB USB framework compliant Linux driver for the
  2. * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
  3. * TeVii S600, S630, S650, S660, S480,
  4. * Prof 1100, 7500,
  5. * Geniatech SU3000 Cards
  6. * Copyright (C) 2008-2011 Igor M. Liplianin (liplianin@me.by)
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, version 2.
  11. *
  12. * see Documentation/dvb/README.dvb-usb for more information
  13. */
  14. #include "dw2102.h"
  15. #include "si21xx.h"
  16. #include "stv0299.h"
  17. #include "z0194a.h"
  18. #include "stv0288.h"
  19. #include "stb6000.h"
  20. #include "eds1547.h"
  21. #include "cx24116.h"
  22. #include "tda1002x.h"
  23. #include "mt312.h"
  24. #include "zl10039.h"
  25. #include "ds3000.h"
  26. #include "stv0900.h"
  27. #include "stv6110.h"
  28. #include "stb6100.h"
  29. #include "stb6100_proc.h"
  30. #ifndef USB_PID_DW2102
  31. #define USB_PID_DW2102 0x2102
  32. #endif
  33. #ifndef USB_PID_DW2104
  34. #define USB_PID_DW2104 0x2104
  35. #endif
  36. #ifndef USB_PID_DW3101
  37. #define USB_PID_DW3101 0x3101
  38. #endif
  39. #ifndef USB_PID_CINERGY_S
  40. #define USB_PID_CINERGY_S 0x0064
  41. #endif
  42. #ifndef USB_PID_TEVII_S630
  43. #define USB_PID_TEVII_S630 0xd630
  44. #endif
  45. #ifndef USB_PID_TEVII_S650
  46. #define USB_PID_TEVII_S650 0xd650
  47. #endif
  48. #ifndef USB_PID_TEVII_S660
  49. #define USB_PID_TEVII_S660 0xd660
  50. #endif
  51. #ifndef USB_PID_TEVII_S480_1
  52. #define USB_PID_TEVII_S480_1 0xd481
  53. #endif
  54. #ifndef USB_PID_TEVII_S480_2
  55. #define USB_PID_TEVII_S480_2 0xd482
  56. #endif
  57. #ifndef USB_PID_PROF_1100
  58. #define USB_PID_PROF_1100 0xb012
  59. #endif
  60. #define DW210X_READ_MSG 0
  61. #define DW210X_WRITE_MSG 1
  62. #define REG_1F_SYMBOLRATE_BYTE0 0x1f
  63. #define REG_20_SYMBOLRATE_BYTE1 0x20
  64. #define REG_21_SYMBOLRATE_BYTE2 0x21
  65. /* on my own*/
  66. #define DW2102_VOLTAGE_CTRL (0x1800)
  67. #define SU3000_STREAM_CTRL (0x1900)
  68. #define DW2102_RC_QUERY (0x1a00)
  69. #define DW2102_LED_CTRL (0x1b00)
  70. #define err_str "did not find the firmware file. (%s) " \
  71. "Please see linux/Documentation/dvb/ for more details " \
  72. "on firmware-problems."
  73. struct rc_map_dvb_usb_table_table {
  74. struct rc_map_table *rc_keys;
  75. int rc_keys_size;
  76. };
  77. struct su3000_state {
  78. u8 initialized;
  79. };
  80. struct s6x0_state {
  81. int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
  82. };
  83. /* debug */
  84. static int dvb_usb_dw2102_debug;
  85. module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
  86. MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
  87. DVB_USB_DEBUG_STATUS);
  88. /* keymaps */
  89. static int ir_keymap;
  90. module_param_named(keymap, ir_keymap, int, 0644);
  91. MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs ..."
  92. " 256=none");
  93. /* demod probe */
  94. static int demod_probe = 1;
  95. module_param_named(demod, demod_probe, int, 0644);
  96. MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
  97. "4=stv0903+stb6100(or-able)).");
  98. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  99. static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
  100. u16 index, u8 * data, u16 len, int flags)
  101. {
  102. int ret;
  103. u8 *u8buf;
  104. unsigned int pipe = (flags == DW210X_READ_MSG) ?
  105. usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
  106. u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
  107. u8buf = kmalloc(len, GFP_KERNEL);
  108. if (!u8buf)
  109. return -ENOMEM;
  110. if (flags == DW210X_WRITE_MSG)
  111. memcpy(u8buf, data, len);
  112. ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
  113. value, index , u8buf, len, 2000);
  114. if (flags == DW210X_READ_MSG)
  115. memcpy(data, u8buf, len);
  116. kfree(u8buf);
  117. return ret;
  118. }
  119. /* I2C */
  120. static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  121. int num)
  122. {
  123. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  124. int i = 0, ret = 0;
  125. u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
  126. u16 value;
  127. if (!d)
  128. return -ENODEV;
  129. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  130. return -EAGAIN;
  131. switch (num) {
  132. case 2:
  133. /* read stv0299 register */
  134. value = msg[0].buf[0];/* register */
  135. for (i = 0; i < msg[1].len; i++) {
  136. ret = dw210x_op_rw(d->udev, 0xb5, value + i, 0,
  137. buf6, 2, DW210X_READ_MSG);
  138. msg[1].buf[i] = buf6[0];
  139. }
  140. break;
  141. case 1:
  142. switch (msg[0].addr) {
  143. case 0x68:
  144. /* write to stv0299 register */
  145. buf6[0] = 0x2a;
  146. buf6[1] = msg[0].buf[0];
  147. buf6[2] = msg[0].buf[1];
  148. ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
  149. buf6, 3, DW210X_WRITE_MSG);
  150. break;
  151. case 0x60:
  152. if (msg[0].flags == 0) {
  153. /* write to tuner pll */
  154. buf6[0] = 0x2c;
  155. buf6[1] = 5;
  156. buf6[2] = 0xc0;
  157. buf6[3] = msg[0].buf[0];
  158. buf6[4] = msg[0].buf[1];
  159. buf6[5] = msg[0].buf[2];
  160. buf6[6] = msg[0].buf[3];
  161. ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
  162. buf6, 7, DW210X_WRITE_MSG);
  163. } else {
  164. /* read from tuner */
  165. ret = dw210x_op_rw(d->udev, 0xb5, 0, 0,
  166. buf6, 1, DW210X_READ_MSG);
  167. msg[0].buf[0] = buf6[0];
  168. }
  169. break;
  170. case (DW2102_RC_QUERY):
  171. ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
  172. buf6, 2, DW210X_READ_MSG);
  173. msg[0].buf[0] = buf6[0];
  174. msg[0].buf[1] = buf6[1];
  175. break;
  176. case (DW2102_VOLTAGE_CTRL):
  177. buf6[0] = 0x30;
  178. buf6[1] = msg[0].buf[0];
  179. ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
  180. buf6, 2, DW210X_WRITE_MSG);
  181. break;
  182. }
  183. break;
  184. }
  185. mutex_unlock(&d->i2c_mutex);
  186. return num;
  187. }
  188. static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
  189. struct i2c_msg msg[], int num)
  190. {
  191. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  192. int ret = 0;
  193. u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
  194. if (!d)
  195. return -ENODEV;
  196. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  197. return -EAGAIN;
  198. switch (num) {
  199. case 2:
  200. /* read si2109 register by number */
  201. buf6[0] = msg[0].addr << 1;
  202. buf6[1] = msg[0].len;
  203. buf6[2] = msg[0].buf[0];
  204. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
  205. buf6, msg[0].len + 2, DW210X_WRITE_MSG);
  206. /* read si2109 register */
  207. ret = dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
  208. buf6, msg[1].len + 2, DW210X_READ_MSG);
  209. memcpy(msg[1].buf, buf6 + 2, msg[1].len);
  210. break;
  211. case 1:
  212. switch (msg[0].addr) {
  213. case 0x68:
  214. /* write to si2109 register */
  215. buf6[0] = msg[0].addr << 1;
  216. buf6[1] = msg[0].len;
  217. memcpy(buf6 + 2, msg[0].buf, msg[0].len);
  218. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
  219. msg[0].len + 2, DW210X_WRITE_MSG);
  220. break;
  221. case(DW2102_RC_QUERY):
  222. ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
  223. buf6, 2, DW210X_READ_MSG);
  224. msg[0].buf[0] = buf6[0];
  225. msg[0].buf[1] = buf6[1];
  226. break;
  227. case(DW2102_VOLTAGE_CTRL):
  228. buf6[0] = 0x30;
  229. buf6[1] = msg[0].buf[0];
  230. ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
  231. buf6, 2, DW210X_WRITE_MSG);
  232. break;
  233. }
  234. break;
  235. }
  236. mutex_unlock(&d->i2c_mutex);
  237. return num;
  238. }
  239. static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
  240. {
  241. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  242. int ret = 0;
  243. if (!d)
  244. return -ENODEV;
  245. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  246. return -EAGAIN;
  247. switch (num) {
  248. case 2: {
  249. /* read */
  250. /* first write first register number */
  251. u8 ibuf[msg[1].len + 2], obuf[3];
  252. obuf[0] = msg[0].addr << 1;
  253. obuf[1] = msg[0].len;
  254. obuf[2] = msg[0].buf[0];
  255. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
  256. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  257. /* second read registers */
  258. ret = dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
  259. ibuf, msg[1].len + 2, DW210X_READ_MSG);
  260. memcpy(msg[1].buf, ibuf + 2, msg[1].len);
  261. break;
  262. }
  263. case 1:
  264. switch (msg[0].addr) {
  265. case 0x68: {
  266. /* write to register */
  267. u8 obuf[msg[0].len + 2];
  268. obuf[0] = msg[0].addr << 1;
  269. obuf[1] = msg[0].len;
  270. memcpy(obuf + 2, msg[0].buf, msg[0].len);
  271. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
  272. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  273. break;
  274. }
  275. case 0x61: {
  276. /* write to tuner */
  277. u8 obuf[msg[0].len + 2];
  278. obuf[0] = msg[0].addr << 1;
  279. obuf[1] = msg[0].len;
  280. memcpy(obuf + 2, msg[0].buf, msg[0].len);
  281. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
  282. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  283. break;
  284. }
  285. case(DW2102_RC_QUERY): {
  286. u8 ibuf[2];
  287. ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
  288. ibuf, 2, DW210X_READ_MSG);
  289. memcpy(msg[0].buf, ibuf , 2);
  290. break;
  291. }
  292. case(DW2102_VOLTAGE_CTRL): {
  293. u8 obuf[2];
  294. obuf[0] = 0x30;
  295. obuf[1] = msg[0].buf[0];
  296. ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
  297. obuf, 2, DW210X_WRITE_MSG);
  298. break;
  299. }
  300. }
  301. break;
  302. }
  303. mutex_unlock(&d->i2c_mutex);
  304. return num;
  305. }
  306. static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
  307. {
  308. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  309. int ret = 0;
  310. int len, i, j;
  311. if (!d)
  312. return -ENODEV;
  313. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  314. return -EAGAIN;
  315. for (j = 0; j < num; j++) {
  316. switch (msg[j].addr) {
  317. case(DW2102_RC_QUERY): {
  318. u8 ibuf[2];
  319. ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
  320. ibuf, 2, DW210X_READ_MSG);
  321. memcpy(msg[j].buf, ibuf , 2);
  322. break;
  323. }
  324. case(DW2102_VOLTAGE_CTRL): {
  325. u8 obuf[2];
  326. obuf[0] = 0x30;
  327. obuf[1] = msg[j].buf[0];
  328. ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
  329. obuf, 2, DW210X_WRITE_MSG);
  330. break;
  331. }
  332. /*case 0x55: cx24116
  333. case 0x6a: stv0903
  334. case 0x68: ds3000, stv0903
  335. case 0x60: ts2020, stv6110, stb6100 */
  336. default: {
  337. if (msg[j].flags == I2C_M_RD) {
  338. /* read registers */
  339. u8 ibuf[msg[j].len + 2];
  340. ret = dw210x_op_rw(d->udev, 0xc3,
  341. (msg[j].addr << 1) + 1, 0,
  342. ibuf, msg[j].len + 2,
  343. DW210X_READ_MSG);
  344. memcpy(msg[j].buf, ibuf + 2, msg[j].len);
  345. mdelay(10);
  346. } else if (((msg[j].buf[0] == 0xb0) &&
  347. (msg[j].addr == 0x68)) ||
  348. ((msg[j].buf[0] == 0xf7) &&
  349. (msg[j].addr == 0x55))) {
  350. /* write firmware */
  351. u8 obuf[19];
  352. obuf[0] = msg[j].addr << 1;
  353. obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
  354. obuf[2] = msg[j].buf[0];
  355. len = msg[j].len - 1;
  356. i = 1;
  357. do {
  358. memcpy(obuf + 3, msg[j].buf + i,
  359. (len > 16 ? 16 : len));
  360. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
  361. obuf, (len > 16 ? 16 : len) + 3,
  362. DW210X_WRITE_MSG);
  363. i += 16;
  364. len -= 16;
  365. } while (len > 0);
  366. } else {
  367. /* write registers */
  368. u8 obuf[msg[j].len + 2];
  369. obuf[0] = msg[j].addr << 1;
  370. obuf[1] = msg[j].len;
  371. memcpy(obuf + 2, msg[j].buf, msg[j].len);
  372. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
  373. obuf, msg[j].len + 2,
  374. DW210X_WRITE_MSG);
  375. }
  376. break;
  377. }
  378. }
  379. }
  380. mutex_unlock(&d->i2c_mutex);
  381. return num;
  382. }
  383. static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  384. int num)
  385. {
  386. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  387. int ret = 0, i;
  388. if (!d)
  389. return -ENODEV;
  390. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  391. return -EAGAIN;
  392. switch (num) {
  393. case 2: {
  394. /* read */
  395. /* first write first register number */
  396. u8 ibuf[msg[1].len + 2], obuf[3];
  397. obuf[0] = msg[0].addr << 1;
  398. obuf[1] = msg[0].len;
  399. obuf[2] = msg[0].buf[0];
  400. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
  401. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  402. /* second read registers */
  403. ret = dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
  404. ibuf, msg[1].len + 2, DW210X_READ_MSG);
  405. memcpy(msg[1].buf, ibuf + 2, msg[1].len);
  406. break;
  407. }
  408. case 1:
  409. switch (msg[0].addr) {
  410. case 0x60:
  411. case 0x0c: {
  412. /* write to register */
  413. u8 obuf[msg[0].len + 2];
  414. obuf[0] = msg[0].addr << 1;
  415. obuf[1] = msg[0].len;
  416. memcpy(obuf + 2, msg[0].buf, msg[0].len);
  417. ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
  418. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  419. break;
  420. }
  421. case(DW2102_RC_QUERY): {
  422. u8 ibuf[2];
  423. ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
  424. ibuf, 2, DW210X_READ_MSG);
  425. memcpy(msg[0].buf, ibuf , 2);
  426. break;
  427. }
  428. }
  429. break;
  430. }
  431. for (i = 0; i < num; i++) {
  432. deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
  433. msg[i].flags == 0 ? ">>>" : "<<<");
  434. debug_dump(msg[i].buf, msg[i].len, deb_xfer);
  435. }
  436. mutex_unlock(&d->i2c_mutex);
  437. return num;
  438. }
  439. static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  440. int num)
  441. {
  442. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  443. struct usb_device *udev;
  444. int ret = 0;
  445. int len, i, j;
  446. if (!d)
  447. return -ENODEV;
  448. udev = d->udev;
  449. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  450. return -EAGAIN;
  451. for (j = 0; j < num; j++) {
  452. switch (msg[j].addr) {
  453. case (DW2102_RC_QUERY): {
  454. u8 ibuf[5];
  455. ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
  456. ibuf, 5, DW210X_READ_MSG);
  457. memcpy(msg[j].buf, ibuf + 3, 2);
  458. break;
  459. }
  460. case (DW2102_VOLTAGE_CTRL): {
  461. u8 obuf[2];
  462. obuf[0] = 1;
  463. obuf[1] = msg[j].buf[1];/* off-on */
  464. ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
  465. obuf, 2, DW210X_WRITE_MSG);
  466. obuf[0] = 3;
  467. obuf[1] = msg[j].buf[0];/* 13v-18v */
  468. ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
  469. obuf, 2, DW210X_WRITE_MSG);
  470. break;
  471. }
  472. case (DW2102_LED_CTRL): {
  473. u8 obuf[2];
  474. obuf[0] = 5;
  475. obuf[1] = msg[j].buf[0];
  476. ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
  477. obuf, 2, DW210X_WRITE_MSG);
  478. break;
  479. }
  480. /*case 0x55: cx24116
  481. case 0x6a: stv0903
  482. case 0x68: ds3000, stv0903
  483. case 0x60: ts2020, stv6110, stb6100
  484. case 0xa0: eeprom */
  485. default: {
  486. if (msg[j].flags == I2C_M_RD) {
  487. /* read registers */
  488. u8 ibuf[msg[j].len];
  489. ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
  490. ibuf, msg[j].len,
  491. DW210X_READ_MSG);
  492. memcpy(msg[j].buf, ibuf, msg[j].len);
  493. break;
  494. } else if ((msg[j].buf[0] == 0xb0) &&
  495. (msg[j].addr == 0x68)) {
  496. /* write firmware */
  497. u8 obuf[19];
  498. obuf[0] = (msg[j].len > 16 ?
  499. 18 : msg[j].len + 1);
  500. obuf[1] = msg[j].addr << 1;
  501. obuf[2] = msg[j].buf[0];
  502. len = msg[j].len - 1;
  503. i = 1;
  504. do {
  505. memcpy(obuf + 3, msg[j].buf + i,
  506. (len > 16 ? 16 : len));
  507. ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
  508. obuf, (len > 16 ? 16 : len) + 3,
  509. DW210X_WRITE_MSG);
  510. i += 16;
  511. len -= 16;
  512. } while (len > 0);
  513. } else if (j < (num - 1)) {
  514. /* write register addr before read */
  515. u8 obuf[msg[j].len + 2];
  516. obuf[0] = msg[j + 1].len;
  517. obuf[1] = (msg[j].addr << 1);
  518. memcpy(obuf + 2, msg[j].buf, msg[j].len);
  519. ret = dw210x_op_rw(d->udev,
  520. udev->descriptor.idProduct ==
  521. 0x7500 ? 0x92 : 0x90, 0, 0,
  522. obuf, msg[j].len + 2,
  523. DW210X_WRITE_MSG);
  524. break;
  525. } else {
  526. /* write registers */
  527. u8 obuf[msg[j].len + 2];
  528. obuf[0] = msg[j].len + 1;
  529. obuf[1] = (msg[j].addr << 1);
  530. memcpy(obuf + 2, msg[j].buf, msg[j].len);
  531. ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
  532. obuf, msg[j].len + 2,
  533. DW210X_WRITE_MSG);
  534. break;
  535. }
  536. break;
  537. }
  538. }
  539. }
  540. mutex_unlock(&d->i2c_mutex);
  541. return num;
  542. }
  543. static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  544. int num)
  545. {
  546. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  547. u8 obuf[0x40], ibuf[0x40];
  548. if (!d)
  549. return -ENODEV;
  550. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  551. return -EAGAIN;
  552. switch (num) {
  553. case 1:
  554. switch (msg[0].addr) {
  555. case SU3000_STREAM_CTRL:
  556. obuf[0] = msg[0].buf[0] + 0x36;
  557. obuf[1] = 3;
  558. obuf[2] = 0;
  559. if (dvb_usb_generic_rw(d, obuf, 3, ibuf, 0, 0) < 0)
  560. err("i2c transfer failed.");
  561. break;
  562. case DW2102_RC_QUERY:
  563. obuf[0] = 0x10;
  564. if (dvb_usb_generic_rw(d, obuf, 1, ibuf, 2, 0) < 0)
  565. err("i2c transfer failed.");
  566. msg[0].buf[1] = ibuf[0];
  567. msg[0].buf[0] = ibuf[1];
  568. break;
  569. default:
  570. /* always i2c write*/
  571. obuf[0] = 0x08;
  572. obuf[1] = msg[0].addr;
  573. obuf[2] = msg[0].len;
  574. memcpy(&obuf[3], msg[0].buf, msg[0].len);
  575. if (dvb_usb_generic_rw(d, obuf, msg[0].len + 3,
  576. ibuf, 1, 0) < 0)
  577. err("i2c transfer failed.");
  578. }
  579. break;
  580. case 2:
  581. /* always i2c read */
  582. obuf[0] = 0x09;
  583. obuf[1] = msg[0].len;
  584. obuf[2] = msg[1].len;
  585. obuf[3] = msg[0].addr;
  586. memcpy(&obuf[4], msg[0].buf, msg[0].len);
  587. if (dvb_usb_generic_rw(d, obuf, msg[0].len + 4,
  588. ibuf, msg[1].len + 1, 0) < 0)
  589. err("i2c transfer failed.");
  590. memcpy(msg[1].buf, &ibuf[1], msg[1].len);
  591. break;
  592. default:
  593. warn("more than 2 i2c messages at a time is not handled yet.");
  594. break;
  595. }
  596. mutex_unlock(&d->i2c_mutex);
  597. return num;
  598. }
  599. static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
  600. {
  601. return I2C_FUNC_I2C;
  602. }
  603. static struct i2c_algorithm dw2102_i2c_algo = {
  604. .master_xfer = dw2102_i2c_transfer,
  605. .functionality = dw210x_i2c_func,
  606. };
  607. static struct i2c_algorithm dw2102_serit_i2c_algo = {
  608. .master_xfer = dw2102_serit_i2c_transfer,
  609. .functionality = dw210x_i2c_func,
  610. };
  611. static struct i2c_algorithm dw2102_earda_i2c_algo = {
  612. .master_xfer = dw2102_earda_i2c_transfer,
  613. .functionality = dw210x_i2c_func,
  614. };
  615. static struct i2c_algorithm dw2104_i2c_algo = {
  616. .master_xfer = dw2104_i2c_transfer,
  617. .functionality = dw210x_i2c_func,
  618. };
  619. static struct i2c_algorithm dw3101_i2c_algo = {
  620. .master_xfer = dw3101_i2c_transfer,
  621. .functionality = dw210x_i2c_func,
  622. };
  623. static struct i2c_algorithm s6x0_i2c_algo = {
  624. .master_xfer = s6x0_i2c_transfer,
  625. .functionality = dw210x_i2c_func,
  626. };
  627. static struct i2c_algorithm su3000_i2c_algo = {
  628. .master_xfer = su3000_i2c_transfer,
  629. .functionality = dw210x_i2c_func,
  630. };
  631. static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
  632. {
  633. int i;
  634. u8 ibuf[] = {0, 0};
  635. u8 eeprom[256], eepromline[16];
  636. for (i = 0; i < 256; i++) {
  637. if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
  638. err("read eeprom failed.");
  639. return -1;
  640. } else {
  641. eepromline[i%16] = ibuf[0];
  642. eeprom[i] = ibuf[0];
  643. }
  644. if ((i % 16) == 15) {
  645. deb_xfer("%02x: ", i - 15);
  646. debug_dump(eepromline, 16, deb_xfer);
  647. }
  648. }
  649. memcpy(mac, eeprom + 8, 6);
  650. return 0;
  651. };
  652. static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
  653. {
  654. int i, ret;
  655. u8 ibuf[] = { 0 }, obuf[] = { 0 };
  656. u8 eeprom[256], eepromline[16];
  657. struct i2c_msg msg[] = {
  658. {
  659. .addr = 0xa0 >> 1,
  660. .flags = 0,
  661. .buf = obuf,
  662. .len = 1,
  663. }, {
  664. .addr = 0xa0 >> 1,
  665. .flags = I2C_M_RD,
  666. .buf = ibuf,
  667. .len = 1,
  668. }
  669. };
  670. for (i = 0; i < 256; i++) {
  671. obuf[0] = i;
  672. ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
  673. if (ret != 2) {
  674. err("read eeprom failed.");
  675. return -1;
  676. } else {
  677. eepromline[i % 16] = ibuf[0];
  678. eeprom[i] = ibuf[0];
  679. }
  680. if ((i % 16) == 15) {
  681. deb_xfer("%02x: ", i - 15);
  682. debug_dump(eepromline, 16, deb_xfer);
  683. }
  684. }
  685. memcpy(mac, eeprom + 16, 6);
  686. return 0;
  687. };
  688. static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  689. {
  690. static u8 command_start[] = {0x00};
  691. static u8 command_stop[] = {0x01};
  692. struct i2c_msg msg = {
  693. .addr = SU3000_STREAM_CTRL,
  694. .flags = 0,
  695. .buf = onoff ? command_start : command_stop,
  696. .len = 1
  697. };
  698. i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
  699. return 0;
  700. }
  701. static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
  702. {
  703. struct su3000_state *state = (struct su3000_state *)d->priv;
  704. u8 obuf[] = {0xde, 0};
  705. info("%s: %d, initialized %d\n", __func__, i, state->initialized);
  706. if (i && !state->initialized) {
  707. state->initialized = 1;
  708. /* reset board */
  709. dvb_usb_generic_rw(d, obuf, 2, NULL, 0, 0);
  710. }
  711. return 0;
  712. }
  713. static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
  714. {
  715. int i;
  716. u8 obuf[] = { 0x1f, 0xf0 };
  717. u8 ibuf[] = { 0 };
  718. struct i2c_msg msg[] = {
  719. {
  720. .addr = 0x51,
  721. .flags = 0,
  722. .buf = obuf,
  723. .len = 2,
  724. }, {
  725. .addr = 0x51,
  726. .flags = I2C_M_RD,
  727. .buf = ibuf,
  728. .len = 1,
  729. }
  730. };
  731. for (i = 0; i < 6; i++) {
  732. obuf[1] = 0xf0 + i;
  733. if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
  734. break;
  735. else
  736. mac[i] = ibuf[0];
  737. debug_dump(mac, 6, printk);
  738. }
  739. return 0;
  740. }
  741. static int su3000_identify_state(struct usb_device *udev,
  742. struct dvb_usb_device_properties *props,
  743. struct dvb_usb_device_description **desc,
  744. int *cold)
  745. {
  746. info("%s\n", __func__);
  747. *cold = 0;
  748. return 0;
  749. }
  750. static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  751. {
  752. static u8 command_13v[] = {0x00, 0x01};
  753. static u8 command_18v[] = {0x01, 0x01};
  754. static u8 command_off[] = {0x00, 0x00};
  755. struct i2c_msg msg = {
  756. .addr = DW2102_VOLTAGE_CTRL,
  757. .flags = 0,
  758. .buf = command_off,
  759. .len = 2,
  760. };
  761. struct dvb_usb_adapter *udev_adap =
  762. (struct dvb_usb_adapter *)(fe->dvb->priv);
  763. if (voltage == SEC_VOLTAGE_18)
  764. msg.buf = command_18v;
  765. else if (voltage == SEC_VOLTAGE_13)
  766. msg.buf = command_13v;
  767. i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
  768. return 0;
  769. }
  770. static int s660_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  771. {
  772. struct dvb_usb_adapter *d =
  773. (struct dvb_usb_adapter *)(fe->dvb->priv);
  774. struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
  775. dw210x_set_voltage(fe, voltage);
  776. if (st->old_set_voltage)
  777. st->old_set_voltage(fe, voltage);
  778. return 0;
  779. }
  780. static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
  781. {
  782. static u8 led_off[] = { 0 };
  783. static u8 led_on[] = { 1 };
  784. struct i2c_msg msg = {
  785. .addr = DW2102_LED_CTRL,
  786. .flags = 0,
  787. .buf = led_off,
  788. .len = 1
  789. };
  790. struct dvb_usb_adapter *udev_adap =
  791. (struct dvb_usb_adapter *)(fe->dvb->priv);
  792. if (offon)
  793. msg.buf = led_on;
  794. i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
  795. }
  796. static struct stv0299_config sharp_z0194a_config = {
  797. .demod_address = 0x68,
  798. .inittab = sharp_z0194a_inittab,
  799. .mclk = 88000000UL,
  800. .invert = 1,
  801. .skip_reinit = 0,
  802. .lock_output = STV0299_LOCKOUTPUT_1,
  803. .volt13_op0_op1 = STV0299_VOLT13_OP1,
  804. .min_delay_ms = 100,
  805. .set_symbol_rate = sharp_z0194a_set_symbol_rate,
  806. };
  807. static struct cx24116_config dw2104_config = {
  808. .demod_address = 0x55,
  809. .mpg_clk_pos_pol = 0x01,
  810. };
  811. static struct si21xx_config serit_sp1511lhb_config = {
  812. .demod_address = 0x68,
  813. .min_delay_ms = 100,
  814. };
  815. static struct tda10023_config dw3101_tda10023_config = {
  816. .demod_address = 0x0c,
  817. .invert = 1,
  818. };
  819. static struct mt312_config zl313_config = {
  820. .demod_address = 0x0e,
  821. };
  822. static struct ds3000_config dw2104_ds3000_config = {
  823. .demod_address = 0x68,
  824. };
  825. static struct stv0900_config dw2104a_stv0900_config = {
  826. .demod_address = 0x6a,
  827. .demod_mode = 0,
  828. .xtal = 27000000,
  829. .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
  830. .diseqc_mode = 2,/* 2/3 PWM */
  831. .tun1_maddress = 0,/* 0x60 */
  832. .tun1_adc = 0,/* 2 Vpp */
  833. .path1_mode = 3,
  834. };
  835. static struct stb6100_config dw2104a_stb6100_config = {
  836. .tuner_address = 0x60,
  837. .refclock = 27000000,
  838. };
  839. static struct stv0900_config dw2104_stv0900_config = {
  840. .demod_address = 0x68,
  841. .demod_mode = 0,
  842. .xtal = 8000000,
  843. .clkmode = 3,
  844. .diseqc_mode = 2,
  845. .tun1_maddress = 0,
  846. .tun1_adc = 1,/* 1 Vpp */
  847. .path1_mode = 3,
  848. };
  849. static struct stv6110_config dw2104_stv6110_config = {
  850. .i2c_address = 0x60,
  851. .mclk = 16000000,
  852. .clk_div = 1,
  853. };
  854. static struct stv0900_config prof_7500_stv0900_config = {
  855. .demod_address = 0x6a,
  856. .demod_mode = 0,
  857. .xtal = 27000000,
  858. .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
  859. .diseqc_mode = 2,/* 2/3 PWM */
  860. .tun1_maddress = 0,/* 0x60 */
  861. .tun1_adc = 0,/* 2 Vpp */
  862. .path1_mode = 3,
  863. .tun1_type = 3,
  864. .set_lock_led = dw210x_led_ctrl,
  865. };
  866. static struct ds3000_config su3000_ds3000_config = {
  867. .demod_address = 0x68,
  868. .ci_mode = 1,
  869. };
  870. static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
  871. {
  872. struct dvb_tuner_ops *tuner_ops = NULL;
  873. if (demod_probe & 4) {
  874. d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
  875. &d->dev->i2c_adap, 0);
  876. if (d->fe_adap[0].fe != NULL) {
  877. if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
  878. &dw2104a_stb6100_config,
  879. &d->dev->i2c_adap)) {
  880. tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
  881. tuner_ops->set_frequency = stb6100_set_freq;
  882. tuner_ops->get_frequency = stb6100_get_freq;
  883. tuner_ops->set_bandwidth = stb6100_set_bandw;
  884. tuner_ops->get_bandwidth = stb6100_get_bandw;
  885. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  886. info("Attached STV0900+STB6100!\n");
  887. return 0;
  888. }
  889. }
  890. }
  891. if (demod_probe & 2) {
  892. d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
  893. &d->dev->i2c_adap, 0);
  894. if (d->fe_adap[0].fe != NULL) {
  895. if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
  896. &dw2104_stv6110_config,
  897. &d->dev->i2c_adap)) {
  898. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  899. info("Attached STV0900+STV6110A!\n");
  900. return 0;
  901. }
  902. }
  903. }
  904. if (demod_probe & 1) {
  905. d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
  906. &d->dev->i2c_adap);
  907. if (d->fe_adap[0].fe != NULL) {
  908. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  909. info("Attached cx24116!\n");
  910. return 0;
  911. }
  912. }
  913. d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
  914. &d->dev->i2c_adap);
  915. if (d->fe_adap[0].fe != NULL) {
  916. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  917. info("Attached DS3000!\n");
  918. return 0;
  919. }
  920. return -EIO;
  921. }
  922. static struct dvb_usb_device_properties dw2102_properties;
  923. static struct dvb_usb_device_properties dw2104_properties;
  924. static struct dvb_usb_device_properties s6x0_properties;
  925. static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
  926. {
  927. if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
  928. /*dw2102_properties.adapter->tuner_attach = NULL;*/
  929. d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
  930. &d->dev->i2c_adap);
  931. if (d->fe_adap[0].fe != NULL) {
  932. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  933. info("Attached si21xx!\n");
  934. return 0;
  935. }
  936. }
  937. if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
  938. d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
  939. &d->dev->i2c_adap);
  940. if (d->fe_adap[0].fe != NULL) {
  941. if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
  942. &d->dev->i2c_adap)) {
  943. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  944. info("Attached stv0288!\n");
  945. return 0;
  946. }
  947. }
  948. }
  949. if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
  950. /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
  951. d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
  952. &d->dev->i2c_adap);
  953. if (d->fe_adap[0].fe != NULL) {
  954. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  955. info("Attached stv0299!\n");
  956. return 0;
  957. }
  958. }
  959. return -EIO;
  960. }
  961. static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
  962. {
  963. d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
  964. &d->dev->i2c_adap, 0x48);
  965. if (d->fe_adap[0].fe != NULL) {
  966. info("Attached tda10023!\n");
  967. return 0;
  968. }
  969. return -EIO;
  970. }
  971. static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
  972. {
  973. d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
  974. &d->dev->i2c_adap);
  975. if (d->fe_adap[0].fe != NULL) {
  976. if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
  977. &d->dev->i2c_adap)) {
  978. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  979. info("Attached zl100313+zl10039!\n");
  980. return 0;
  981. }
  982. }
  983. return -EIO;
  984. }
  985. static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
  986. {
  987. u8 obuf[] = {7, 1};
  988. d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
  989. &d->dev->i2c_adap);
  990. if (d->fe_adap[0].fe == NULL)
  991. return -EIO;
  992. if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
  993. return -EIO;
  994. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  995. dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
  996. info("Attached stv0288+stb6000!\n");
  997. return 0;
  998. }
  999. static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
  1000. {
  1001. struct s6x0_state *st = (struct s6x0_state *)d->dev->priv;
  1002. u8 obuf[] = {7, 1};
  1003. d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
  1004. &d->dev->i2c_adap);
  1005. if (d->fe_adap[0].fe == NULL)
  1006. return -EIO;
  1007. st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
  1008. d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
  1009. dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
  1010. info("Attached ds3000+ds2020!\n");
  1011. return 0;
  1012. }
  1013. static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
  1014. {
  1015. u8 obuf[] = {7, 1};
  1016. d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
  1017. &d->dev->i2c_adap, 0);
  1018. if (d->fe_adap[0].fe == NULL)
  1019. return -EIO;
  1020. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1021. dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
  1022. info("Attached STV0900+STB6100A!\n");
  1023. return 0;
  1024. }
  1025. static int su3000_frontend_attach(struct dvb_usb_adapter *d)
  1026. {
  1027. u8 obuf[3] = { 0xe, 0x80, 0 };
  1028. u8 ibuf[] = { 0 };
  1029. if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
  1030. err("command 0x0e transfer failed.");
  1031. obuf[0] = 0xe;
  1032. obuf[1] = 0x83;
  1033. obuf[2] = 0;
  1034. if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
  1035. err("command 0x0e transfer failed.");
  1036. obuf[0] = 0xe;
  1037. obuf[1] = 0x83;
  1038. obuf[2] = 1;
  1039. if (dvb_usb_generic_rw(d->dev, obuf, 3, ibuf, 1, 0) < 0)
  1040. err("command 0x0e transfer failed.");
  1041. obuf[0] = 0x51;
  1042. if (dvb_usb_generic_rw(d->dev, obuf, 1, ibuf, 1, 0) < 0)
  1043. err("command 0x51 transfer failed.");
  1044. d->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
  1045. &d->dev->i2c_adap);
  1046. if (d->fe_adap[0].fe == NULL)
  1047. return -EIO;
  1048. info("Attached DS3000!\n");
  1049. return 0;
  1050. }
  1051. static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
  1052. {
  1053. dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
  1054. &adap->dev->i2c_adap, DVB_PLL_OPERA1);
  1055. return 0;
  1056. }
  1057. static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
  1058. {
  1059. dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
  1060. &adap->dev->i2c_adap, DVB_PLL_TUA6034);
  1061. return 0;
  1062. }
  1063. static struct rc_map_table rc_map_dw210x_table[] = {
  1064. { 0xf80a, KEY_POWER2 }, /*power*/
  1065. { 0xf80c, KEY_MUTE }, /*mute*/
  1066. { 0xf811, KEY_1 },
  1067. { 0xf812, KEY_2 },
  1068. { 0xf813, KEY_3 },
  1069. { 0xf814, KEY_4 },
  1070. { 0xf815, KEY_5 },
  1071. { 0xf816, KEY_6 },
  1072. { 0xf817, KEY_7 },
  1073. { 0xf818, KEY_8 },
  1074. { 0xf819, KEY_9 },
  1075. { 0xf810, KEY_0 },
  1076. { 0xf81c, KEY_CHANNELUP }, /*ch+*/
  1077. { 0xf80f, KEY_CHANNELDOWN }, /*ch-*/
  1078. { 0xf81a, KEY_VOLUMEUP }, /*vol+*/
  1079. { 0xf80e, KEY_VOLUMEDOWN }, /*vol-*/
  1080. { 0xf804, KEY_RECORD }, /*rec*/
  1081. { 0xf809, KEY_FAVORITES }, /*fav*/
  1082. { 0xf808, KEY_REWIND }, /*rewind*/
  1083. { 0xf807, KEY_FASTFORWARD }, /*fast*/
  1084. { 0xf80b, KEY_PAUSE }, /*pause*/
  1085. { 0xf802, KEY_ESC }, /*cancel*/
  1086. { 0xf803, KEY_TAB }, /*tab*/
  1087. { 0xf800, KEY_UP }, /*up*/
  1088. { 0xf81f, KEY_OK }, /*ok*/
  1089. { 0xf801, KEY_DOWN }, /*down*/
  1090. { 0xf805, KEY_CAMERA }, /*cap*/
  1091. { 0xf806, KEY_STOP }, /*stop*/
  1092. { 0xf840, KEY_ZOOM }, /*full*/
  1093. { 0xf81e, KEY_TV }, /*tvmode*/
  1094. { 0xf81b, KEY_LAST }, /*recall*/
  1095. };
  1096. static struct rc_map_table rc_map_tevii_table[] = {
  1097. { 0xf80a, KEY_POWER },
  1098. { 0xf80c, KEY_MUTE },
  1099. { 0xf811, KEY_1 },
  1100. { 0xf812, KEY_2 },
  1101. { 0xf813, KEY_3 },
  1102. { 0xf814, KEY_4 },
  1103. { 0xf815, KEY_5 },
  1104. { 0xf816, KEY_6 },
  1105. { 0xf817, KEY_7 },
  1106. { 0xf818, KEY_8 },
  1107. { 0xf819, KEY_9 },
  1108. { 0xf810, KEY_0 },
  1109. { 0xf81c, KEY_MENU },
  1110. { 0xf80f, KEY_VOLUMEDOWN },
  1111. { 0xf81a, KEY_LAST },
  1112. { 0xf80e, KEY_OPEN },
  1113. { 0xf804, KEY_RECORD },
  1114. { 0xf809, KEY_VOLUMEUP },
  1115. { 0xf808, KEY_CHANNELUP },
  1116. { 0xf807, KEY_PVR },
  1117. { 0xf80b, KEY_TIME },
  1118. { 0xf802, KEY_RIGHT },
  1119. { 0xf803, KEY_LEFT },
  1120. { 0xf800, KEY_UP },
  1121. { 0xf81f, KEY_OK },
  1122. { 0xf801, KEY_DOWN },
  1123. { 0xf805, KEY_TUNER },
  1124. { 0xf806, KEY_CHANNELDOWN },
  1125. { 0xf840, KEY_PLAYPAUSE },
  1126. { 0xf81e, KEY_REWIND },
  1127. { 0xf81b, KEY_FAVORITES },
  1128. { 0xf81d, KEY_BACK },
  1129. { 0xf84d, KEY_FASTFORWARD },
  1130. { 0xf844, KEY_EPG },
  1131. { 0xf84c, KEY_INFO },
  1132. { 0xf841, KEY_AB },
  1133. { 0xf843, KEY_AUDIO },
  1134. { 0xf845, KEY_SUBTITLE },
  1135. { 0xf84a, KEY_LIST },
  1136. { 0xf846, KEY_F1 },
  1137. { 0xf847, KEY_F2 },
  1138. { 0xf85e, KEY_F3 },
  1139. { 0xf85c, KEY_F4 },
  1140. { 0xf852, KEY_F5 },
  1141. { 0xf85a, KEY_F6 },
  1142. { 0xf856, KEY_MODE },
  1143. { 0xf858, KEY_SWITCHVIDEOMODE },
  1144. };
  1145. static struct rc_map_table rc_map_tbs_table[] = {
  1146. { 0xf884, KEY_POWER },
  1147. { 0xf894, KEY_MUTE },
  1148. { 0xf887, KEY_1 },
  1149. { 0xf886, KEY_2 },
  1150. { 0xf885, KEY_3 },
  1151. { 0xf88b, KEY_4 },
  1152. { 0xf88a, KEY_5 },
  1153. { 0xf889, KEY_6 },
  1154. { 0xf88f, KEY_7 },
  1155. { 0xf88e, KEY_8 },
  1156. { 0xf88d, KEY_9 },
  1157. { 0xf892, KEY_0 },
  1158. { 0xf896, KEY_CHANNELUP },
  1159. { 0xf891, KEY_CHANNELDOWN },
  1160. { 0xf893, KEY_VOLUMEUP },
  1161. { 0xf88c, KEY_VOLUMEDOWN },
  1162. { 0xf883, KEY_RECORD },
  1163. { 0xf898, KEY_PAUSE },
  1164. { 0xf899, KEY_OK },
  1165. { 0xf89a, KEY_SHUFFLE },
  1166. { 0xf881, KEY_UP },
  1167. { 0xf890, KEY_LEFT },
  1168. { 0xf882, KEY_RIGHT },
  1169. { 0xf888, KEY_DOWN },
  1170. { 0xf895, KEY_FAVORITES },
  1171. { 0xf897, KEY_SUBTITLE },
  1172. { 0xf89d, KEY_ZOOM },
  1173. { 0xf89f, KEY_EXIT },
  1174. { 0xf89e, KEY_MENU },
  1175. { 0xf89c, KEY_EPG },
  1176. { 0xf880, KEY_PREVIOUS },
  1177. { 0xf89b, KEY_MODE }
  1178. };
  1179. static struct rc_map_table rc_map_su3000_table[] = {
  1180. { 0x25, KEY_POWER }, /* right-bottom Red */
  1181. { 0x0a, KEY_MUTE }, /* -/-- */
  1182. { 0x01, KEY_1 },
  1183. { 0x02, KEY_2 },
  1184. { 0x03, KEY_3 },
  1185. { 0x04, KEY_4 },
  1186. { 0x05, KEY_5 },
  1187. { 0x06, KEY_6 },
  1188. { 0x07, KEY_7 },
  1189. { 0x08, KEY_8 },
  1190. { 0x09, KEY_9 },
  1191. { 0x00, KEY_0 },
  1192. { 0x20, KEY_UP }, /* CH+ */
  1193. { 0x21, KEY_DOWN }, /* CH+ */
  1194. { 0x12, KEY_VOLUMEUP }, /* Brightness Up */
  1195. { 0x13, KEY_VOLUMEDOWN },/* Brightness Down */
  1196. { 0x1f, KEY_RECORD },
  1197. { 0x17, KEY_PLAY },
  1198. { 0x16, KEY_PAUSE },
  1199. { 0x0b, KEY_STOP },
  1200. { 0x27, KEY_FASTFORWARD },/* >> */
  1201. { 0x26, KEY_REWIND }, /* << */
  1202. { 0x0d, KEY_OK }, /* Mute */
  1203. { 0x11, KEY_LEFT }, /* VOL- */
  1204. { 0x10, KEY_RIGHT }, /* VOL+ */
  1205. { 0x29, KEY_BACK }, /* button under 9 */
  1206. { 0x2c, KEY_MENU }, /* TTX */
  1207. { 0x2b, KEY_EPG }, /* EPG */
  1208. { 0x1e, KEY_RED }, /* OSD */
  1209. { 0x0e, KEY_GREEN }, /* Window */
  1210. { 0x2d, KEY_YELLOW }, /* button under << */
  1211. { 0x0f, KEY_BLUE }, /* bottom yellow button */
  1212. { 0x14, KEY_AUDIO }, /* Snapshot */
  1213. { 0x38, KEY_TV }, /* TV/Radio */
  1214. { 0x0c, KEY_ESC } /* upper Red button */
  1215. };
  1216. static struct rc_map_dvb_usb_table_table keys_tables[] = {
  1217. { rc_map_dw210x_table, ARRAY_SIZE(rc_map_dw210x_table) },
  1218. { rc_map_tevii_table, ARRAY_SIZE(rc_map_tevii_table) },
  1219. { rc_map_tbs_table, ARRAY_SIZE(rc_map_tbs_table) },
  1220. { rc_map_su3000_table, ARRAY_SIZE(rc_map_su3000_table) },
  1221. };
  1222. static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
  1223. {
  1224. struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
  1225. int keymap_size = d->props.rc.legacy.rc_map_size;
  1226. u8 key[2];
  1227. struct i2c_msg msg = {
  1228. .addr = DW2102_RC_QUERY,
  1229. .flags = I2C_M_RD,
  1230. .buf = key,
  1231. .len = 2
  1232. };
  1233. int i;
  1234. /* override keymap */
  1235. if ((ir_keymap > 0) && (ir_keymap <= ARRAY_SIZE(keys_tables))) {
  1236. keymap = keys_tables[ir_keymap - 1].rc_keys ;
  1237. keymap_size = keys_tables[ir_keymap - 1].rc_keys_size;
  1238. } else if (ir_keymap > ARRAY_SIZE(keys_tables))
  1239. return 0; /* none */
  1240. *state = REMOTE_NO_KEY_PRESSED;
  1241. if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
  1242. for (i = 0; i < keymap_size ; i++) {
  1243. if (rc5_data(&keymap[i]) == msg.buf[0]) {
  1244. *state = REMOTE_KEY_PRESSED;
  1245. *event = keymap[i].keycode;
  1246. break;
  1247. }
  1248. }
  1249. if ((*state) == REMOTE_KEY_PRESSED)
  1250. deb_rc("%s: found rc key: %x, %x, event: %x\n",
  1251. __func__, key[0], key[1], (*event));
  1252. else if (key[0] != 0xff)
  1253. deb_rc("%s: unknown rc key: %x, %x\n",
  1254. __func__, key[0], key[1]);
  1255. }
  1256. return 0;
  1257. }
  1258. enum dw2102_table_entry {
  1259. CYPRESS_DW2102,
  1260. CYPRESS_DW2101,
  1261. CYPRESS_DW2104,
  1262. TEVII_S650,
  1263. TERRATEC_CINERGY_S,
  1264. CYPRESS_DW3101,
  1265. TEVII_S630,
  1266. PROF_1100,
  1267. TEVII_S660,
  1268. PROF_7500,
  1269. GENIATECH_SU3000,
  1270. TERRATEC_CINERGY_S2,
  1271. TEVII_S480_1,
  1272. TEVII_S480_2,
  1273. X3M_SPC1400HD,
  1274. };
  1275. static struct usb_device_id dw2102_table[] = {
  1276. [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
  1277. [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
  1278. [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
  1279. [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
  1280. [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
  1281. [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
  1282. [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
  1283. [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
  1284. [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
  1285. [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
  1286. [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
  1287. [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
  1288. [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
  1289. [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
  1290. [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
  1291. { }
  1292. };
  1293. MODULE_DEVICE_TABLE(usb, dw2102_table);
  1294. static int dw2102_load_firmware(struct usb_device *dev,
  1295. const struct firmware *frmwr)
  1296. {
  1297. u8 *b, *p;
  1298. int ret = 0, i;
  1299. u8 reset;
  1300. u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
  1301. const struct firmware *fw;
  1302. const char *fw_2101 = "dvb-usb-dw2101.fw";
  1303. switch (dev->descriptor.idProduct) {
  1304. case 0x2101:
  1305. ret = request_firmware(&fw, fw_2101, &dev->dev);
  1306. if (ret != 0) {
  1307. err(err_str, fw_2101);
  1308. return ret;
  1309. }
  1310. break;
  1311. default:
  1312. fw = frmwr;
  1313. break;
  1314. }
  1315. info("start downloading DW210X firmware");
  1316. p = kmalloc(fw->size, GFP_KERNEL);
  1317. reset = 1;
  1318. /*stop the CPU*/
  1319. dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
  1320. dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
  1321. if (p != NULL) {
  1322. memcpy(p, fw->data, fw->size);
  1323. for (i = 0; i < fw->size; i += 0x40) {
  1324. b = (u8 *) p + i;
  1325. if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
  1326. DW210X_WRITE_MSG) != 0x40) {
  1327. err("error while transferring firmware");
  1328. ret = -EINVAL;
  1329. break;
  1330. }
  1331. }
  1332. /* restart the CPU */
  1333. reset = 0;
  1334. if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
  1335. DW210X_WRITE_MSG) != 1) {
  1336. err("could not restart the USB controller CPU.");
  1337. ret = -EINVAL;
  1338. }
  1339. if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
  1340. DW210X_WRITE_MSG) != 1) {
  1341. err("could not restart the USB controller CPU.");
  1342. ret = -EINVAL;
  1343. }
  1344. /* init registers */
  1345. switch (dev->descriptor.idProduct) {
  1346. case USB_PID_TEVII_S650:
  1347. dw2104_properties.rc.legacy.rc_map_table = rc_map_tevii_table;
  1348. dw2104_properties.rc.legacy.rc_map_size =
  1349. ARRAY_SIZE(rc_map_tevii_table);
  1350. case USB_PID_DW2104:
  1351. reset = 1;
  1352. dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
  1353. DW210X_WRITE_MSG);
  1354. /* break omitted intentionally */
  1355. case USB_PID_DW3101:
  1356. reset = 0;
  1357. dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
  1358. DW210X_WRITE_MSG);
  1359. break;
  1360. case USB_PID_CINERGY_S:
  1361. case USB_PID_DW2102:
  1362. dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
  1363. DW210X_WRITE_MSG);
  1364. dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
  1365. DW210X_READ_MSG);
  1366. /* check STV0299 frontend */
  1367. dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
  1368. DW210X_READ_MSG);
  1369. if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
  1370. dw2102_properties.i2c_algo = &dw2102_i2c_algo;
  1371. dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
  1372. break;
  1373. } else {
  1374. /* check STV0288 frontend */
  1375. reset16[0] = 0xd0;
  1376. reset16[1] = 1;
  1377. reset16[2] = 0;
  1378. dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
  1379. DW210X_WRITE_MSG);
  1380. dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
  1381. DW210X_READ_MSG);
  1382. if (reset16[2] == 0x11) {
  1383. dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
  1384. break;
  1385. }
  1386. }
  1387. case 0x2101:
  1388. dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
  1389. DW210X_READ_MSG);
  1390. dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
  1391. DW210X_READ_MSG);
  1392. dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
  1393. DW210X_READ_MSG);
  1394. dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
  1395. DW210X_READ_MSG);
  1396. break;
  1397. }
  1398. msleep(100);
  1399. kfree(p);
  1400. }
  1401. return ret;
  1402. }
  1403. static struct dvb_usb_device_properties dw2102_properties = {
  1404. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1405. .usb_ctrl = DEVICE_SPECIFIC,
  1406. .firmware = "dvb-usb-dw2102.fw",
  1407. .no_reconnect = 1,
  1408. .i2c_algo = &dw2102_serit_i2c_algo,
  1409. .rc.legacy = {
  1410. .rc_map_table = rc_map_dw210x_table,
  1411. .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
  1412. .rc_interval = 150,
  1413. .rc_query = dw2102_rc_query,
  1414. },
  1415. .generic_bulk_ctrl_endpoint = 0x81,
  1416. /* parameter for the MPEG2-data transfer */
  1417. .num_adapters = 1,
  1418. .download_firmware = dw2102_load_firmware,
  1419. .read_mac_address = dw210x_read_mac_address,
  1420. .adapter = {
  1421. {
  1422. .num_frontends = 1,
  1423. .fe = {{
  1424. .frontend_attach = dw2102_frontend_attach,
  1425. .stream = {
  1426. .type = USB_BULK,
  1427. .count = 8,
  1428. .endpoint = 0x82,
  1429. .u = {
  1430. .bulk = {
  1431. .buffersize = 4096,
  1432. }
  1433. }
  1434. },
  1435. }},
  1436. }
  1437. },
  1438. .num_device_descs = 3,
  1439. .devices = {
  1440. {"DVBWorld DVB-S 2102 USB2.0",
  1441. {&dw2102_table[CYPRESS_DW2102], NULL},
  1442. {NULL},
  1443. },
  1444. {"DVBWorld DVB-S 2101 USB2.0",
  1445. {&dw2102_table[CYPRESS_DW2101], NULL},
  1446. {NULL},
  1447. },
  1448. {"TerraTec Cinergy S USB",
  1449. {&dw2102_table[TERRATEC_CINERGY_S], NULL},
  1450. {NULL},
  1451. },
  1452. }
  1453. };
  1454. static struct dvb_usb_device_properties dw2104_properties = {
  1455. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1456. .usb_ctrl = DEVICE_SPECIFIC,
  1457. .firmware = "dvb-usb-dw2104.fw",
  1458. .no_reconnect = 1,
  1459. .i2c_algo = &dw2104_i2c_algo,
  1460. .rc.legacy = {
  1461. .rc_map_table = rc_map_dw210x_table,
  1462. .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
  1463. .rc_interval = 150,
  1464. .rc_query = dw2102_rc_query,
  1465. },
  1466. .generic_bulk_ctrl_endpoint = 0x81,
  1467. /* parameter for the MPEG2-data transfer */
  1468. .num_adapters = 1,
  1469. .download_firmware = dw2102_load_firmware,
  1470. .read_mac_address = dw210x_read_mac_address,
  1471. .adapter = {
  1472. {
  1473. .num_frontends = 1,
  1474. .fe = {{
  1475. .frontend_attach = dw2104_frontend_attach,
  1476. .stream = {
  1477. .type = USB_BULK,
  1478. .count = 8,
  1479. .endpoint = 0x82,
  1480. .u = {
  1481. .bulk = {
  1482. .buffersize = 4096,
  1483. }
  1484. }
  1485. },
  1486. }},
  1487. }
  1488. },
  1489. .num_device_descs = 2,
  1490. .devices = {
  1491. { "DVBWorld DW2104 USB2.0",
  1492. {&dw2102_table[CYPRESS_DW2104], NULL},
  1493. {NULL},
  1494. },
  1495. { "TeVii S650 USB2.0",
  1496. {&dw2102_table[TEVII_S650], NULL},
  1497. {NULL},
  1498. },
  1499. }
  1500. };
  1501. static struct dvb_usb_device_properties dw3101_properties = {
  1502. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1503. .usb_ctrl = DEVICE_SPECIFIC,
  1504. .firmware = "dvb-usb-dw3101.fw",
  1505. .no_reconnect = 1,
  1506. .i2c_algo = &dw3101_i2c_algo,
  1507. .rc.legacy = {
  1508. .rc_map_table = rc_map_dw210x_table,
  1509. .rc_map_size = ARRAY_SIZE(rc_map_dw210x_table),
  1510. .rc_interval = 150,
  1511. .rc_query = dw2102_rc_query,
  1512. },
  1513. .generic_bulk_ctrl_endpoint = 0x81,
  1514. /* parameter for the MPEG2-data transfer */
  1515. .num_adapters = 1,
  1516. .download_firmware = dw2102_load_firmware,
  1517. .read_mac_address = dw210x_read_mac_address,
  1518. .adapter = {
  1519. {
  1520. .num_frontends = 1,
  1521. .fe = {{
  1522. .frontend_attach = dw3101_frontend_attach,
  1523. .tuner_attach = dw3101_tuner_attach,
  1524. .stream = {
  1525. .type = USB_BULK,
  1526. .count = 8,
  1527. .endpoint = 0x82,
  1528. .u = {
  1529. .bulk = {
  1530. .buffersize = 4096,
  1531. }
  1532. }
  1533. },
  1534. }},
  1535. }
  1536. },
  1537. .num_device_descs = 1,
  1538. .devices = {
  1539. { "DVBWorld DVB-C 3101 USB2.0",
  1540. {&dw2102_table[CYPRESS_DW3101], NULL},
  1541. {NULL},
  1542. },
  1543. }
  1544. };
  1545. static struct dvb_usb_device_properties s6x0_properties = {
  1546. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1547. .usb_ctrl = DEVICE_SPECIFIC,
  1548. .size_of_priv = sizeof(struct s6x0_state),
  1549. .firmware = "dvb-usb-s630.fw",
  1550. .no_reconnect = 1,
  1551. .i2c_algo = &s6x0_i2c_algo,
  1552. .rc.legacy = {
  1553. .rc_map_table = rc_map_tevii_table,
  1554. .rc_map_size = ARRAY_SIZE(rc_map_tevii_table),
  1555. .rc_interval = 150,
  1556. .rc_query = dw2102_rc_query,
  1557. },
  1558. .generic_bulk_ctrl_endpoint = 0x81,
  1559. .num_adapters = 1,
  1560. .download_firmware = dw2102_load_firmware,
  1561. .read_mac_address = s6x0_read_mac_address,
  1562. .adapter = {
  1563. {
  1564. .num_frontends = 1,
  1565. .fe = {{
  1566. .frontend_attach = zl100313_frontend_attach,
  1567. .stream = {
  1568. .type = USB_BULK,
  1569. .count = 8,
  1570. .endpoint = 0x82,
  1571. .u = {
  1572. .bulk = {
  1573. .buffersize = 4096,
  1574. }
  1575. }
  1576. },
  1577. }},
  1578. }
  1579. },
  1580. .num_device_descs = 1,
  1581. .devices = {
  1582. {"TeVii S630 USB",
  1583. {&dw2102_table[TEVII_S630], NULL},
  1584. {NULL},
  1585. },
  1586. }
  1587. };
  1588. struct dvb_usb_device_properties *p1100;
  1589. static struct dvb_usb_device_description d1100 = {
  1590. "Prof 1100 USB ",
  1591. {&dw2102_table[PROF_1100], NULL},
  1592. {NULL},
  1593. };
  1594. struct dvb_usb_device_properties *s660;
  1595. static struct dvb_usb_device_description d660 = {
  1596. "TeVii S660 USB",
  1597. {&dw2102_table[TEVII_S660], NULL},
  1598. {NULL},
  1599. };
  1600. static struct dvb_usb_device_description d480_1 = {
  1601. "TeVii S480.1 USB",
  1602. {&dw2102_table[TEVII_S480_1], NULL},
  1603. {NULL},
  1604. };
  1605. static struct dvb_usb_device_description d480_2 = {
  1606. "TeVii S480.2 USB",
  1607. {&dw2102_table[TEVII_S480_2], NULL},
  1608. {NULL},
  1609. };
  1610. struct dvb_usb_device_properties *p7500;
  1611. static struct dvb_usb_device_description d7500 = {
  1612. "Prof 7500 USB DVB-S2",
  1613. {&dw2102_table[PROF_7500], NULL},
  1614. {NULL},
  1615. };
  1616. static struct dvb_usb_device_properties su3000_properties = {
  1617. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1618. .usb_ctrl = DEVICE_SPECIFIC,
  1619. .size_of_priv = sizeof(struct su3000_state),
  1620. .power_ctrl = su3000_power_ctrl,
  1621. .num_adapters = 1,
  1622. .identify_state = su3000_identify_state,
  1623. .i2c_algo = &su3000_i2c_algo,
  1624. .rc.legacy = {
  1625. .rc_map_table = rc_map_su3000_table,
  1626. .rc_map_size = ARRAY_SIZE(rc_map_su3000_table),
  1627. .rc_interval = 150,
  1628. .rc_query = dw2102_rc_query,
  1629. },
  1630. .read_mac_address = su3000_read_mac_address,
  1631. .generic_bulk_ctrl_endpoint = 0x01,
  1632. .adapter = {
  1633. {
  1634. .num_frontends = 1,
  1635. .fe = {{
  1636. .streaming_ctrl = su3000_streaming_ctrl,
  1637. .frontend_attach = su3000_frontend_attach,
  1638. .stream = {
  1639. .type = USB_BULK,
  1640. .count = 8,
  1641. .endpoint = 0x82,
  1642. .u = {
  1643. .bulk = {
  1644. .buffersize = 4096,
  1645. }
  1646. }
  1647. }
  1648. }},
  1649. }
  1650. },
  1651. .num_device_descs = 3,
  1652. .devices = {
  1653. { "SU3000HD DVB-S USB2.0",
  1654. { &dw2102_table[GENIATECH_SU3000], NULL },
  1655. { NULL },
  1656. },
  1657. { "Terratec Cinergy S2 USB HD",
  1658. { &dw2102_table[TERRATEC_CINERGY_S2], NULL },
  1659. { NULL },
  1660. },
  1661. { "X3M TV SPC1400HD PCI",
  1662. { &dw2102_table[X3M_SPC1400HD], NULL },
  1663. { NULL },
  1664. },
  1665. }
  1666. };
  1667. static int dw2102_probe(struct usb_interface *intf,
  1668. const struct usb_device_id *id)
  1669. {
  1670. p1100 = kmemdup(&s6x0_properties,
  1671. sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
  1672. if (!p1100)
  1673. return -ENOMEM;
  1674. /* copy default structure */
  1675. /* fill only different fields */
  1676. p1100->firmware = "dvb-usb-p1100.fw";
  1677. p1100->devices[0] = d1100;
  1678. p1100->rc.legacy.rc_map_table = rc_map_tbs_table;
  1679. p1100->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
  1680. p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
  1681. s660 = kmemdup(&s6x0_properties,
  1682. sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
  1683. if (!s660) {
  1684. kfree(p1100);
  1685. return -ENOMEM;
  1686. }
  1687. s660->firmware = "dvb-usb-s660.fw";
  1688. s660->num_device_descs = 3;
  1689. s660->devices[0] = d660;
  1690. s660->devices[1] = d480_1;
  1691. s660->devices[2] = d480_2;
  1692. s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
  1693. p7500 = kmemdup(&s6x0_properties,
  1694. sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
  1695. if (!p7500) {
  1696. kfree(p1100);
  1697. kfree(s660);
  1698. return -ENOMEM;
  1699. }
  1700. p7500->firmware = "dvb-usb-p7500.fw";
  1701. p7500->devices[0] = d7500;
  1702. p7500->rc.legacy.rc_map_table = rc_map_tbs_table;
  1703. p7500->rc.legacy.rc_map_size = ARRAY_SIZE(rc_map_tbs_table);
  1704. p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
  1705. if (0 == dvb_usb_device_init(intf, &dw2102_properties,
  1706. THIS_MODULE, NULL, adapter_nr) ||
  1707. 0 == dvb_usb_device_init(intf, &dw2104_properties,
  1708. THIS_MODULE, NULL, adapter_nr) ||
  1709. 0 == dvb_usb_device_init(intf, &dw3101_properties,
  1710. THIS_MODULE, NULL, adapter_nr) ||
  1711. 0 == dvb_usb_device_init(intf, &s6x0_properties,
  1712. THIS_MODULE, NULL, adapter_nr) ||
  1713. 0 == dvb_usb_device_init(intf, p1100,
  1714. THIS_MODULE, NULL, adapter_nr) ||
  1715. 0 == dvb_usb_device_init(intf, s660,
  1716. THIS_MODULE, NULL, adapter_nr) ||
  1717. 0 == dvb_usb_device_init(intf, p7500,
  1718. THIS_MODULE, NULL, adapter_nr) ||
  1719. 0 == dvb_usb_device_init(intf, &su3000_properties,
  1720. THIS_MODULE, NULL, adapter_nr))
  1721. return 0;
  1722. return -ENODEV;
  1723. }
  1724. static struct usb_driver dw2102_driver = {
  1725. .name = "dw2102",
  1726. .probe = dw2102_probe,
  1727. .disconnect = dvb_usb_device_exit,
  1728. .id_table = dw2102_table,
  1729. };
  1730. module_usb_driver(dw2102_driver);
  1731. MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
  1732. MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
  1733. " DVB-C 3101 USB2.0,"
  1734. " TeVii S600, S630, S650, S660, S480,"
  1735. " Prof 1100, 7500 USB2.0,"
  1736. " Geniatech SU3000 devices");
  1737. MODULE_VERSION("0.1");
  1738. MODULE_LICENSE("GPL");