dw2102.c 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403
  1. /* DVB USB framework compliant Linux driver for the
  2. * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
  3. * TeVii S421, S480, S482, S600, S630, S632, S650, S660, S662,
  4. * Prof 1100, 7500,
  5. * Geniatech SU3000, T220,
  6. * TechnoTrend S2-4600,
  7. * Terratec Cinergy S2 cards
  8. * Copyright (C) 2008-2012 Igor M. Liplianin (liplianin@me.by)
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation, version 2.
  13. *
  14. * see Documentation/dvb/README.dvb-usb for more information
  15. */
  16. #include "dvb-usb-ids.h"
  17. #include "dw2102.h"
  18. #include "si21xx.h"
  19. #include "stv0299.h"
  20. #include "z0194a.h"
  21. #include "stv0288.h"
  22. #include "stb6000.h"
  23. #include "eds1547.h"
  24. #include "cx24116.h"
  25. #include "tda1002x.h"
  26. #include "mt312.h"
  27. #include "zl10039.h"
  28. #include "ts2020.h"
  29. #include "ds3000.h"
  30. #include "stv0900.h"
  31. #include "stv6110.h"
  32. #include "stb6100.h"
  33. #include "stb6100_proc.h"
  34. #include "m88rs2000.h"
  35. #include "tda18271.h"
  36. #include "cxd2820r.h"
  37. #include "m88ds3103.h"
  38. /* Max transfer size done by I2C transfer functions */
  39. #define MAX_XFER_SIZE 64
  40. #define DW210X_READ_MSG 0
  41. #define DW210X_WRITE_MSG 1
  42. #define REG_1F_SYMBOLRATE_BYTE0 0x1f
  43. #define REG_20_SYMBOLRATE_BYTE1 0x20
  44. #define REG_21_SYMBOLRATE_BYTE2 0x21
  45. /* on my own*/
  46. #define DW2102_VOLTAGE_CTRL (0x1800)
  47. #define SU3000_STREAM_CTRL (0x1900)
  48. #define DW2102_RC_QUERY (0x1a00)
  49. #define DW2102_LED_CTRL (0x1b00)
  50. #define DW2101_FIRMWARE "dvb-usb-dw2101.fw"
  51. #define DW2102_FIRMWARE "dvb-usb-dw2102.fw"
  52. #define DW2104_FIRMWARE "dvb-usb-dw2104.fw"
  53. #define DW3101_FIRMWARE "dvb-usb-dw3101.fw"
  54. #define S630_FIRMWARE "dvb-usb-s630.fw"
  55. #define S660_FIRMWARE "dvb-usb-s660.fw"
  56. #define P1100_FIRMWARE "dvb-usb-p1100.fw"
  57. #define P7500_FIRMWARE "dvb-usb-p7500.fw"
  58. #define err_str "did not find the firmware file. (%s) " \
  59. "Please see linux/Documentation/dvb/ for more details " \
  60. "on firmware-problems."
  61. struct dw2102_state {
  62. u8 initialized;
  63. u8 last_lock;
  64. u8 data[MAX_XFER_SIZE + 4];
  65. struct i2c_client *i2c_client_demod;
  66. struct i2c_client *i2c_client_tuner;
  67. /* fe hook functions*/
  68. int (*old_set_voltage)(struct dvb_frontend *f, enum fe_sec_voltage v);
  69. int (*fe_read_status)(struct dvb_frontend *fe,
  70. enum fe_status *status);
  71. };
  72. /* debug */
  73. static int dvb_usb_dw2102_debug;
  74. module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
  75. MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
  76. DVB_USB_DEBUG_STATUS);
  77. /* demod probe */
  78. static int demod_probe = 1;
  79. module_param_named(demod, demod_probe, int, 0644);
  80. MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 4=stv0903+stb6100(or-able)).");
  81. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  82. static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
  83. u16 index, u8 * data, u16 len, int flags)
  84. {
  85. int ret;
  86. u8 *u8buf;
  87. unsigned int pipe = (flags == DW210X_READ_MSG) ?
  88. usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
  89. u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
  90. u8buf = kmalloc(len, GFP_KERNEL);
  91. if (!u8buf)
  92. return -ENOMEM;
  93. if (flags == DW210X_WRITE_MSG)
  94. memcpy(u8buf, data, len);
  95. ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
  96. value, index , u8buf, len, 2000);
  97. if (flags == DW210X_READ_MSG)
  98. memcpy(data, u8buf, len);
  99. kfree(u8buf);
  100. return ret;
  101. }
  102. /* I2C */
  103. static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  104. int num)
  105. {
  106. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  107. int i = 0;
  108. u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
  109. u16 value;
  110. if (!d)
  111. return -ENODEV;
  112. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  113. return -EAGAIN;
  114. switch (num) {
  115. case 2:
  116. /* read stv0299 register */
  117. value = msg[0].buf[0];/* register */
  118. for (i = 0; i < msg[1].len; i++) {
  119. dw210x_op_rw(d->udev, 0xb5, value + i, 0,
  120. buf6, 2, DW210X_READ_MSG);
  121. msg[1].buf[i] = buf6[0];
  122. }
  123. break;
  124. case 1:
  125. switch (msg[0].addr) {
  126. case 0x68:
  127. /* write to stv0299 register */
  128. buf6[0] = 0x2a;
  129. buf6[1] = msg[0].buf[0];
  130. buf6[2] = msg[0].buf[1];
  131. dw210x_op_rw(d->udev, 0xb2, 0, 0,
  132. buf6, 3, DW210X_WRITE_MSG);
  133. break;
  134. case 0x60:
  135. if (msg[0].flags == 0) {
  136. /* write to tuner pll */
  137. buf6[0] = 0x2c;
  138. buf6[1] = 5;
  139. buf6[2] = 0xc0;
  140. buf6[3] = msg[0].buf[0];
  141. buf6[4] = msg[0].buf[1];
  142. buf6[5] = msg[0].buf[2];
  143. buf6[6] = msg[0].buf[3];
  144. dw210x_op_rw(d->udev, 0xb2, 0, 0,
  145. buf6, 7, DW210X_WRITE_MSG);
  146. } else {
  147. /* read from tuner */
  148. dw210x_op_rw(d->udev, 0xb5, 0, 0,
  149. buf6, 1, DW210X_READ_MSG);
  150. msg[0].buf[0] = buf6[0];
  151. }
  152. break;
  153. case (DW2102_RC_QUERY):
  154. dw210x_op_rw(d->udev, 0xb8, 0, 0,
  155. buf6, 2, DW210X_READ_MSG);
  156. msg[0].buf[0] = buf6[0];
  157. msg[0].buf[1] = buf6[1];
  158. break;
  159. case (DW2102_VOLTAGE_CTRL):
  160. buf6[0] = 0x30;
  161. buf6[1] = msg[0].buf[0];
  162. dw210x_op_rw(d->udev, 0xb2, 0, 0,
  163. buf6, 2, DW210X_WRITE_MSG);
  164. break;
  165. }
  166. break;
  167. }
  168. mutex_unlock(&d->i2c_mutex);
  169. return num;
  170. }
  171. static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
  172. struct i2c_msg msg[], int num)
  173. {
  174. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  175. u8 buf6[] = {0, 0, 0, 0, 0, 0, 0};
  176. if (!d)
  177. return -ENODEV;
  178. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  179. return -EAGAIN;
  180. switch (num) {
  181. case 2:
  182. /* read si2109 register by number */
  183. buf6[0] = msg[0].addr << 1;
  184. buf6[1] = msg[0].len;
  185. buf6[2] = msg[0].buf[0];
  186. dw210x_op_rw(d->udev, 0xc2, 0, 0,
  187. buf6, msg[0].len + 2, DW210X_WRITE_MSG);
  188. /* read si2109 register */
  189. dw210x_op_rw(d->udev, 0xc3, 0xd0, 0,
  190. buf6, msg[1].len + 2, DW210X_READ_MSG);
  191. memcpy(msg[1].buf, buf6 + 2, msg[1].len);
  192. break;
  193. case 1:
  194. switch (msg[0].addr) {
  195. case 0x68:
  196. /* write to si2109 register */
  197. buf6[0] = msg[0].addr << 1;
  198. buf6[1] = msg[0].len;
  199. memcpy(buf6 + 2, msg[0].buf, msg[0].len);
  200. dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
  201. msg[0].len + 2, DW210X_WRITE_MSG);
  202. break;
  203. case(DW2102_RC_QUERY):
  204. dw210x_op_rw(d->udev, 0xb8, 0, 0,
  205. buf6, 2, DW210X_READ_MSG);
  206. msg[0].buf[0] = buf6[0];
  207. msg[0].buf[1] = buf6[1];
  208. break;
  209. case(DW2102_VOLTAGE_CTRL):
  210. buf6[0] = 0x30;
  211. buf6[1] = msg[0].buf[0];
  212. dw210x_op_rw(d->udev, 0xb2, 0, 0,
  213. buf6, 2, DW210X_WRITE_MSG);
  214. break;
  215. }
  216. break;
  217. }
  218. mutex_unlock(&d->i2c_mutex);
  219. return num;
  220. }
  221. static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
  222. {
  223. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  224. int ret;
  225. if (!d)
  226. return -ENODEV;
  227. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  228. return -EAGAIN;
  229. switch (num) {
  230. case 2: {
  231. /* read */
  232. /* first write first register number */
  233. u8 ibuf[MAX_XFER_SIZE], obuf[3];
  234. if (2 + msg[1].len > sizeof(ibuf)) {
  235. warn("i2c rd: len=%d is too big!\n",
  236. msg[1].len);
  237. ret = -EOPNOTSUPP;
  238. goto unlock;
  239. }
  240. obuf[0] = msg[0].addr << 1;
  241. obuf[1] = msg[0].len;
  242. obuf[2] = msg[0].buf[0];
  243. dw210x_op_rw(d->udev, 0xc2, 0, 0,
  244. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  245. /* second read registers */
  246. dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0,
  247. ibuf, msg[1].len + 2, DW210X_READ_MSG);
  248. memcpy(msg[1].buf, ibuf + 2, msg[1].len);
  249. break;
  250. }
  251. case 1:
  252. switch (msg[0].addr) {
  253. case 0x68: {
  254. /* write to register */
  255. u8 obuf[MAX_XFER_SIZE];
  256. if (2 + msg[0].len > sizeof(obuf)) {
  257. warn("i2c wr: len=%d is too big!\n",
  258. msg[1].len);
  259. ret = -EOPNOTSUPP;
  260. goto unlock;
  261. }
  262. obuf[0] = msg[0].addr << 1;
  263. obuf[1] = msg[0].len;
  264. memcpy(obuf + 2, msg[0].buf, msg[0].len);
  265. dw210x_op_rw(d->udev, 0xc2, 0, 0,
  266. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  267. break;
  268. }
  269. case 0x61: {
  270. /* write to tuner */
  271. u8 obuf[MAX_XFER_SIZE];
  272. if (2 + msg[0].len > sizeof(obuf)) {
  273. warn("i2c wr: len=%d is too big!\n",
  274. msg[1].len);
  275. ret = -EOPNOTSUPP;
  276. goto unlock;
  277. }
  278. obuf[0] = msg[0].addr << 1;
  279. obuf[1] = msg[0].len;
  280. memcpy(obuf + 2, msg[0].buf, msg[0].len);
  281. 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. 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. dw210x_op_rw(d->udev, 0xb2, 0, 0,
  297. obuf, 2, DW210X_WRITE_MSG);
  298. break;
  299. }
  300. }
  301. break;
  302. }
  303. ret = num;
  304. unlock:
  305. mutex_unlock(&d->i2c_mutex);
  306. return ret;
  307. }
  308. static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
  309. {
  310. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  311. int len, i, j, ret;
  312. if (!d)
  313. return -ENODEV;
  314. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  315. return -EAGAIN;
  316. for (j = 0; j < num; j++) {
  317. switch (msg[j].addr) {
  318. case(DW2102_RC_QUERY): {
  319. u8 ibuf[2];
  320. dw210x_op_rw(d->udev, 0xb8, 0, 0,
  321. ibuf, 2, DW210X_READ_MSG);
  322. memcpy(msg[j].buf, ibuf , 2);
  323. break;
  324. }
  325. case(DW2102_VOLTAGE_CTRL): {
  326. u8 obuf[2];
  327. obuf[0] = 0x30;
  328. obuf[1] = msg[j].buf[0];
  329. dw210x_op_rw(d->udev, 0xb2, 0, 0,
  330. obuf, 2, DW210X_WRITE_MSG);
  331. break;
  332. }
  333. /*case 0x55: cx24116
  334. case 0x6a: stv0903
  335. case 0x68: ds3000, stv0903
  336. case 0x60: ts2020, stv6110, stb6100 */
  337. default: {
  338. if (msg[j].flags == I2C_M_RD) {
  339. /* read registers */
  340. u8 ibuf[MAX_XFER_SIZE];
  341. if (2 + msg[j].len > sizeof(ibuf)) {
  342. warn("i2c rd: len=%d is too big!\n",
  343. msg[j].len);
  344. ret = -EOPNOTSUPP;
  345. goto unlock;
  346. }
  347. dw210x_op_rw(d->udev, 0xc3,
  348. (msg[j].addr << 1) + 1, 0,
  349. ibuf, msg[j].len + 2,
  350. DW210X_READ_MSG);
  351. memcpy(msg[j].buf, ibuf + 2, msg[j].len);
  352. mdelay(10);
  353. } else if (((msg[j].buf[0] == 0xb0) &&
  354. (msg[j].addr == 0x68)) ||
  355. ((msg[j].buf[0] == 0xf7) &&
  356. (msg[j].addr == 0x55))) {
  357. /* write firmware */
  358. u8 obuf[19];
  359. obuf[0] = msg[j].addr << 1;
  360. obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
  361. obuf[2] = msg[j].buf[0];
  362. len = msg[j].len - 1;
  363. i = 1;
  364. do {
  365. memcpy(obuf + 3, msg[j].buf + i,
  366. (len > 16 ? 16 : len));
  367. dw210x_op_rw(d->udev, 0xc2, 0, 0,
  368. obuf, (len > 16 ? 16 : len) + 3,
  369. DW210X_WRITE_MSG);
  370. i += 16;
  371. len -= 16;
  372. } while (len > 0);
  373. } else {
  374. /* write registers */
  375. u8 obuf[MAX_XFER_SIZE];
  376. if (2 + msg[j].len > sizeof(obuf)) {
  377. warn("i2c wr: len=%d is too big!\n",
  378. msg[j].len);
  379. ret = -EOPNOTSUPP;
  380. goto unlock;
  381. }
  382. obuf[0] = msg[j].addr << 1;
  383. obuf[1] = msg[j].len;
  384. memcpy(obuf + 2, msg[j].buf, msg[j].len);
  385. dw210x_op_rw(d->udev, 0xc2, 0, 0,
  386. obuf, msg[j].len + 2,
  387. DW210X_WRITE_MSG);
  388. }
  389. break;
  390. }
  391. }
  392. }
  393. ret = num;
  394. unlock:
  395. mutex_unlock(&d->i2c_mutex);
  396. return ret;
  397. }
  398. static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  399. int num)
  400. {
  401. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  402. int ret;
  403. int i;
  404. if (!d)
  405. return -ENODEV;
  406. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  407. return -EAGAIN;
  408. switch (num) {
  409. case 2: {
  410. /* read */
  411. /* first write first register number */
  412. u8 ibuf[MAX_XFER_SIZE], obuf[3];
  413. if (2 + msg[1].len > sizeof(ibuf)) {
  414. warn("i2c rd: len=%d is too big!\n",
  415. msg[1].len);
  416. ret = -EOPNOTSUPP;
  417. goto unlock;
  418. }
  419. obuf[0] = msg[0].addr << 1;
  420. obuf[1] = msg[0].len;
  421. obuf[2] = msg[0].buf[0];
  422. dw210x_op_rw(d->udev, 0xc2, 0, 0,
  423. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  424. /* second read registers */
  425. dw210x_op_rw(d->udev, 0xc3, 0x19 , 0,
  426. ibuf, msg[1].len + 2, DW210X_READ_MSG);
  427. memcpy(msg[1].buf, ibuf + 2, msg[1].len);
  428. break;
  429. }
  430. case 1:
  431. switch (msg[0].addr) {
  432. case 0x60:
  433. case 0x0c: {
  434. /* write to register */
  435. u8 obuf[MAX_XFER_SIZE];
  436. if (2 + msg[0].len > sizeof(obuf)) {
  437. warn("i2c wr: len=%d is too big!\n",
  438. msg[0].len);
  439. ret = -EOPNOTSUPP;
  440. goto unlock;
  441. }
  442. obuf[0] = msg[0].addr << 1;
  443. obuf[1] = msg[0].len;
  444. memcpy(obuf + 2, msg[0].buf, msg[0].len);
  445. dw210x_op_rw(d->udev, 0xc2, 0, 0,
  446. obuf, msg[0].len + 2, DW210X_WRITE_MSG);
  447. break;
  448. }
  449. case(DW2102_RC_QUERY): {
  450. u8 ibuf[2];
  451. dw210x_op_rw(d->udev, 0xb8, 0, 0,
  452. ibuf, 2, DW210X_READ_MSG);
  453. memcpy(msg[0].buf, ibuf , 2);
  454. break;
  455. }
  456. }
  457. break;
  458. }
  459. for (i = 0; i < num; i++) {
  460. deb_xfer("%02x:%02x: %s ", i, msg[i].addr,
  461. msg[i].flags == 0 ? ">>>" : "<<<");
  462. debug_dump(msg[i].buf, msg[i].len, deb_xfer);
  463. }
  464. ret = num;
  465. unlock:
  466. mutex_unlock(&d->i2c_mutex);
  467. return ret;
  468. }
  469. static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  470. int num)
  471. {
  472. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  473. struct usb_device *udev;
  474. int len, i, j, ret;
  475. if (!d)
  476. return -ENODEV;
  477. udev = d->udev;
  478. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  479. return -EAGAIN;
  480. for (j = 0; j < num; j++) {
  481. switch (msg[j].addr) {
  482. case (DW2102_RC_QUERY): {
  483. u8 ibuf[5];
  484. dw210x_op_rw(d->udev, 0xb8, 0, 0,
  485. ibuf, 5, DW210X_READ_MSG);
  486. memcpy(msg[j].buf, ibuf + 3, 2);
  487. break;
  488. }
  489. case (DW2102_VOLTAGE_CTRL): {
  490. u8 obuf[2];
  491. obuf[0] = 1;
  492. obuf[1] = msg[j].buf[1];/* off-on */
  493. dw210x_op_rw(d->udev, 0x8a, 0, 0,
  494. obuf, 2, DW210X_WRITE_MSG);
  495. obuf[0] = 3;
  496. obuf[1] = msg[j].buf[0];/* 13v-18v */
  497. dw210x_op_rw(d->udev, 0x8a, 0, 0,
  498. obuf, 2, DW210X_WRITE_MSG);
  499. break;
  500. }
  501. case (DW2102_LED_CTRL): {
  502. u8 obuf[2];
  503. obuf[0] = 5;
  504. obuf[1] = msg[j].buf[0];
  505. dw210x_op_rw(d->udev, 0x8a, 0, 0,
  506. obuf, 2, DW210X_WRITE_MSG);
  507. break;
  508. }
  509. /*case 0x55: cx24116
  510. case 0x6a: stv0903
  511. case 0x68: ds3000, stv0903, rs2000
  512. case 0x60: ts2020, stv6110, stb6100
  513. case 0xa0: eeprom */
  514. default: {
  515. if (msg[j].flags == I2C_M_RD) {
  516. /* read registers */
  517. u8 ibuf[MAX_XFER_SIZE];
  518. if (msg[j].len > sizeof(ibuf)) {
  519. warn("i2c rd: len=%d is too big!\n",
  520. msg[j].len);
  521. ret = -EOPNOTSUPP;
  522. goto unlock;
  523. }
  524. dw210x_op_rw(d->udev, 0x91, 0, 0,
  525. ibuf, msg[j].len,
  526. DW210X_READ_MSG);
  527. memcpy(msg[j].buf, ibuf, msg[j].len);
  528. break;
  529. } else if ((msg[j].buf[0] == 0xb0) &&
  530. (msg[j].addr == 0x68)) {
  531. /* write firmware */
  532. u8 obuf[19];
  533. obuf[0] = (msg[j].len > 16 ?
  534. 18 : msg[j].len + 1);
  535. obuf[1] = msg[j].addr << 1;
  536. obuf[2] = msg[j].buf[0];
  537. len = msg[j].len - 1;
  538. i = 1;
  539. do {
  540. memcpy(obuf + 3, msg[j].buf + i,
  541. (len > 16 ? 16 : len));
  542. dw210x_op_rw(d->udev, 0x80, 0, 0,
  543. obuf, (len > 16 ? 16 : len) + 3,
  544. DW210X_WRITE_MSG);
  545. i += 16;
  546. len -= 16;
  547. } while (len > 0);
  548. } else if (j < (num - 1)) {
  549. /* write register addr before read */
  550. u8 obuf[MAX_XFER_SIZE];
  551. if (2 + msg[j].len > sizeof(obuf)) {
  552. warn("i2c wr: len=%d is too big!\n",
  553. msg[j].len);
  554. ret = -EOPNOTSUPP;
  555. goto unlock;
  556. }
  557. obuf[0] = msg[j + 1].len;
  558. obuf[1] = (msg[j].addr << 1);
  559. memcpy(obuf + 2, msg[j].buf, msg[j].len);
  560. dw210x_op_rw(d->udev,
  561. le16_to_cpu(udev->descriptor.idProduct) ==
  562. 0x7500 ? 0x92 : 0x90, 0, 0,
  563. obuf, msg[j].len + 2,
  564. DW210X_WRITE_MSG);
  565. break;
  566. } else {
  567. /* write registers */
  568. u8 obuf[MAX_XFER_SIZE];
  569. if (2 + msg[j].len > sizeof(obuf)) {
  570. warn("i2c wr: len=%d is too big!\n",
  571. msg[j].len);
  572. ret = -EOPNOTSUPP;
  573. goto unlock;
  574. }
  575. obuf[0] = msg[j].len + 1;
  576. obuf[1] = (msg[j].addr << 1);
  577. memcpy(obuf + 2, msg[j].buf, msg[j].len);
  578. dw210x_op_rw(d->udev, 0x80, 0, 0,
  579. obuf, msg[j].len + 2,
  580. DW210X_WRITE_MSG);
  581. break;
  582. }
  583. break;
  584. }
  585. }
  586. }
  587. ret = num;
  588. unlock:
  589. mutex_unlock(&d->i2c_mutex);
  590. return ret;
  591. }
  592. static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  593. int num)
  594. {
  595. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  596. struct dw2102_state *state;
  597. if (!d)
  598. return -ENODEV;
  599. state = d->priv;
  600. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  601. return -EAGAIN;
  602. if (mutex_lock_interruptible(&d->data_mutex) < 0) {
  603. mutex_unlock(&d->i2c_mutex);
  604. return -EAGAIN;
  605. }
  606. switch (num) {
  607. case 1:
  608. switch (msg[0].addr) {
  609. case SU3000_STREAM_CTRL:
  610. state->data[0] = msg[0].buf[0] + 0x36;
  611. state->data[1] = 3;
  612. state->data[2] = 0;
  613. if (dvb_usb_generic_rw(d, state->data, 3,
  614. state->data, 0, 0) < 0)
  615. err("i2c transfer failed.");
  616. break;
  617. case DW2102_RC_QUERY:
  618. state->data[0] = 0x10;
  619. if (dvb_usb_generic_rw(d, state->data, 1,
  620. state->data, 2, 0) < 0)
  621. err("i2c transfer failed.");
  622. msg[0].buf[1] = state->data[0];
  623. msg[0].buf[0] = state->data[1];
  624. break;
  625. default:
  626. /* always i2c write*/
  627. state->data[0] = 0x08;
  628. state->data[1] = msg[0].addr;
  629. state->data[2] = msg[0].len;
  630. memcpy(&state->data[3], msg[0].buf, msg[0].len);
  631. if (dvb_usb_generic_rw(d, state->data, msg[0].len + 3,
  632. state->data, 1, 0) < 0)
  633. err("i2c transfer failed.");
  634. }
  635. break;
  636. case 2:
  637. /* always i2c read */
  638. state->data[0] = 0x09;
  639. state->data[1] = msg[0].len;
  640. state->data[2] = msg[1].len;
  641. state->data[3] = msg[0].addr;
  642. memcpy(&state->data[4], msg[0].buf, msg[0].len);
  643. if (dvb_usb_generic_rw(d, state->data, msg[0].len + 4,
  644. state->data, msg[1].len + 1, 0) < 0)
  645. err("i2c transfer failed.");
  646. memcpy(msg[1].buf, &state->data[1], msg[1].len);
  647. break;
  648. default:
  649. warn("more than 2 i2c messages at a time is not handled yet.");
  650. break;
  651. }
  652. mutex_unlock(&d->data_mutex);
  653. mutex_unlock(&d->i2c_mutex);
  654. return num;
  655. }
  656. static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
  657. {
  658. return I2C_FUNC_I2C;
  659. }
  660. static struct i2c_algorithm dw2102_i2c_algo = {
  661. .master_xfer = dw2102_i2c_transfer,
  662. .functionality = dw210x_i2c_func,
  663. };
  664. static struct i2c_algorithm dw2102_serit_i2c_algo = {
  665. .master_xfer = dw2102_serit_i2c_transfer,
  666. .functionality = dw210x_i2c_func,
  667. };
  668. static struct i2c_algorithm dw2102_earda_i2c_algo = {
  669. .master_xfer = dw2102_earda_i2c_transfer,
  670. .functionality = dw210x_i2c_func,
  671. };
  672. static struct i2c_algorithm dw2104_i2c_algo = {
  673. .master_xfer = dw2104_i2c_transfer,
  674. .functionality = dw210x_i2c_func,
  675. };
  676. static struct i2c_algorithm dw3101_i2c_algo = {
  677. .master_xfer = dw3101_i2c_transfer,
  678. .functionality = dw210x_i2c_func,
  679. };
  680. static struct i2c_algorithm s6x0_i2c_algo = {
  681. .master_xfer = s6x0_i2c_transfer,
  682. .functionality = dw210x_i2c_func,
  683. };
  684. static struct i2c_algorithm su3000_i2c_algo = {
  685. .master_xfer = su3000_i2c_transfer,
  686. .functionality = dw210x_i2c_func,
  687. };
  688. static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
  689. {
  690. int i;
  691. u8 ibuf[] = {0, 0};
  692. u8 eeprom[256], eepromline[16];
  693. for (i = 0; i < 256; i++) {
  694. if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) {
  695. err("read eeprom failed.");
  696. return -1;
  697. } else {
  698. eepromline[i%16] = ibuf[0];
  699. eeprom[i] = ibuf[0];
  700. }
  701. if ((i % 16) == 15) {
  702. deb_xfer("%02x: ", i - 15);
  703. debug_dump(eepromline, 16, deb_xfer);
  704. }
  705. }
  706. memcpy(mac, eeprom + 8, 6);
  707. return 0;
  708. };
  709. static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
  710. {
  711. int i, ret;
  712. u8 ibuf[] = { 0 }, obuf[] = { 0 };
  713. u8 eeprom[256], eepromline[16];
  714. struct i2c_msg msg[] = {
  715. {
  716. .addr = 0xa0 >> 1,
  717. .flags = 0,
  718. .buf = obuf,
  719. .len = 1,
  720. }, {
  721. .addr = 0xa0 >> 1,
  722. .flags = I2C_M_RD,
  723. .buf = ibuf,
  724. .len = 1,
  725. }
  726. };
  727. for (i = 0; i < 256; i++) {
  728. obuf[0] = i;
  729. ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
  730. if (ret != 2) {
  731. err("read eeprom failed.");
  732. return -1;
  733. } else {
  734. eepromline[i % 16] = ibuf[0];
  735. eeprom[i] = ibuf[0];
  736. }
  737. if ((i % 16) == 15) {
  738. deb_xfer("%02x: ", i - 15);
  739. debug_dump(eepromline, 16, deb_xfer);
  740. }
  741. }
  742. memcpy(mac, eeprom + 16, 6);
  743. return 0;
  744. };
  745. static int su3000_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
  746. {
  747. static u8 command_start[] = {0x00};
  748. static u8 command_stop[] = {0x01};
  749. struct i2c_msg msg = {
  750. .addr = SU3000_STREAM_CTRL,
  751. .flags = 0,
  752. .buf = onoff ? command_start : command_stop,
  753. .len = 1
  754. };
  755. i2c_transfer(&adap->dev->i2c_adap, &msg, 1);
  756. return 0;
  757. }
  758. static int su3000_power_ctrl(struct dvb_usb_device *d, int i)
  759. {
  760. struct dw2102_state *state = (struct dw2102_state *)d->priv;
  761. int ret = 0;
  762. info("%s: %d, initialized %d", __func__, i, state->initialized);
  763. if (i && !state->initialized) {
  764. mutex_lock(&d->data_mutex);
  765. state->data[0] = 0xde;
  766. state->data[1] = 0;
  767. state->initialized = 1;
  768. /* reset board */
  769. ret = dvb_usb_generic_rw(d, state->data, 2, NULL, 0, 0);
  770. mutex_unlock(&d->data_mutex);
  771. }
  772. return ret;
  773. }
  774. static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
  775. {
  776. int i;
  777. u8 obuf[] = { 0x1f, 0xf0 };
  778. u8 ibuf[] = { 0 };
  779. struct i2c_msg msg[] = {
  780. {
  781. .addr = 0x51,
  782. .flags = 0,
  783. .buf = obuf,
  784. .len = 2,
  785. }, {
  786. .addr = 0x51,
  787. .flags = I2C_M_RD,
  788. .buf = ibuf,
  789. .len = 1,
  790. }
  791. };
  792. for (i = 0; i < 6; i++) {
  793. obuf[1] = 0xf0 + i;
  794. if (i2c_transfer(&d->i2c_adap, msg, 2) != 2)
  795. break;
  796. else
  797. mac[i] = ibuf[0];
  798. }
  799. return 0;
  800. }
  801. static int su3000_identify_state(struct usb_device *udev,
  802. struct dvb_usb_device_properties *props,
  803. struct dvb_usb_device_description **desc,
  804. int *cold)
  805. {
  806. info("%s", __func__);
  807. *cold = 0;
  808. return 0;
  809. }
  810. static int dw210x_set_voltage(struct dvb_frontend *fe,
  811. enum fe_sec_voltage voltage)
  812. {
  813. static u8 command_13v[] = {0x00, 0x01};
  814. static u8 command_18v[] = {0x01, 0x01};
  815. static u8 command_off[] = {0x00, 0x00};
  816. struct i2c_msg msg = {
  817. .addr = DW2102_VOLTAGE_CTRL,
  818. .flags = 0,
  819. .buf = command_off,
  820. .len = 2,
  821. };
  822. struct dvb_usb_adapter *udev_adap =
  823. (struct dvb_usb_adapter *)(fe->dvb->priv);
  824. if (voltage == SEC_VOLTAGE_18)
  825. msg.buf = command_18v;
  826. else if (voltage == SEC_VOLTAGE_13)
  827. msg.buf = command_13v;
  828. i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
  829. return 0;
  830. }
  831. static int s660_set_voltage(struct dvb_frontend *fe,
  832. enum fe_sec_voltage voltage)
  833. {
  834. struct dvb_usb_adapter *d =
  835. (struct dvb_usb_adapter *)(fe->dvb->priv);
  836. struct dw2102_state *st = (struct dw2102_state *)d->dev->priv;
  837. dw210x_set_voltage(fe, voltage);
  838. if (st->old_set_voltage)
  839. st->old_set_voltage(fe, voltage);
  840. return 0;
  841. }
  842. static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
  843. {
  844. static u8 led_off[] = { 0 };
  845. static u8 led_on[] = { 1 };
  846. struct i2c_msg msg = {
  847. .addr = DW2102_LED_CTRL,
  848. .flags = 0,
  849. .buf = led_off,
  850. .len = 1
  851. };
  852. struct dvb_usb_adapter *udev_adap =
  853. (struct dvb_usb_adapter *)(fe->dvb->priv);
  854. if (offon)
  855. msg.buf = led_on;
  856. i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
  857. }
  858. static int tt_s2_4600_read_status(struct dvb_frontend *fe,
  859. enum fe_status *status)
  860. {
  861. struct dvb_usb_adapter *d =
  862. (struct dvb_usb_adapter *)(fe->dvb->priv);
  863. struct dw2102_state *st = (struct dw2102_state *)d->dev->priv;
  864. int ret;
  865. ret = st->fe_read_status(fe, status);
  866. /* resync slave fifo when signal change from unlock to lock */
  867. if ((*status & FE_HAS_LOCK) && (!st->last_lock))
  868. su3000_streaming_ctrl(d, 1);
  869. st->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0;
  870. return ret;
  871. }
  872. static struct stv0299_config sharp_z0194a_config = {
  873. .demod_address = 0x68,
  874. .inittab = sharp_z0194a_inittab,
  875. .mclk = 88000000UL,
  876. .invert = 1,
  877. .skip_reinit = 0,
  878. .lock_output = STV0299_LOCKOUTPUT_1,
  879. .volt13_op0_op1 = STV0299_VOLT13_OP1,
  880. .min_delay_ms = 100,
  881. .set_symbol_rate = sharp_z0194a_set_symbol_rate,
  882. };
  883. static struct cx24116_config dw2104_config = {
  884. .demod_address = 0x55,
  885. .mpg_clk_pos_pol = 0x01,
  886. };
  887. static struct si21xx_config serit_sp1511lhb_config = {
  888. .demod_address = 0x68,
  889. .min_delay_ms = 100,
  890. };
  891. static struct tda10023_config dw3101_tda10023_config = {
  892. .demod_address = 0x0c,
  893. .invert = 1,
  894. };
  895. static struct mt312_config zl313_config = {
  896. .demod_address = 0x0e,
  897. };
  898. static struct ds3000_config dw2104_ds3000_config = {
  899. .demod_address = 0x68,
  900. };
  901. static struct ts2020_config dw2104_ts2020_config = {
  902. .tuner_address = 0x60,
  903. .clk_out_div = 1,
  904. .frequency_div = 1060000,
  905. };
  906. static struct ds3000_config s660_ds3000_config = {
  907. .demod_address = 0x68,
  908. .ci_mode = 1,
  909. .set_lock_led = dw210x_led_ctrl,
  910. };
  911. static struct ts2020_config s660_ts2020_config = {
  912. .tuner_address = 0x60,
  913. .clk_out_div = 1,
  914. .frequency_div = 1146000,
  915. };
  916. static struct stv0900_config dw2104a_stv0900_config = {
  917. .demod_address = 0x6a,
  918. .demod_mode = 0,
  919. .xtal = 27000000,
  920. .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
  921. .diseqc_mode = 2,/* 2/3 PWM */
  922. .tun1_maddress = 0,/* 0x60 */
  923. .tun1_adc = 0,/* 2 Vpp */
  924. .path1_mode = 3,
  925. };
  926. static struct stb6100_config dw2104a_stb6100_config = {
  927. .tuner_address = 0x60,
  928. .refclock = 27000000,
  929. };
  930. static struct stv0900_config dw2104_stv0900_config = {
  931. .demod_address = 0x68,
  932. .demod_mode = 0,
  933. .xtal = 8000000,
  934. .clkmode = 3,
  935. .diseqc_mode = 2,
  936. .tun1_maddress = 0,
  937. .tun1_adc = 1,/* 1 Vpp */
  938. .path1_mode = 3,
  939. };
  940. static struct stv6110_config dw2104_stv6110_config = {
  941. .i2c_address = 0x60,
  942. .mclk = 16000000,
  943. .clk_div = 1,
  944. };
  945. static struct stv0900_config prof_7500_stv0900_config = {
  946. .demod_address = 0x6a,
  947. .demod_mode = 0,
  948. .xtal = 27000000,
  949. .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
  950. .diseqc_mode = 2,/* 2/3 PWM */
  951. .tun1_maddress = 0,/* 0x60 */
  952. .tun1_adc = 0,/* 2 Vpp */
  953. .path1_mode = 3,
  954. .tun1_type = 3,
  955. .set_lock_led = dw210x_led_ctrl,
  956. };
  957. static struct ds3000_config su3000_ds3000_config = {
  958. .demod_address = 0x68,
  959. .ci_mode = 1,
  960. .set_lock_led = dw210x_led_ctrl,
  961. };
  962. static struct cxd2820r_config cxd2820r_config = {
  963. .i2c_address = 0x6c, /* (0xd8 >> 1) */
  964. .ts_mode = 0x38,
  965. .ts_clock_inv = 1,
  966. };
  967. static struct tda18271_config tda18271_config = {
  968. .output_opt = TDA18271_OUTPUT_LT_OFF,
  969. .gate = TDA18271_GATE_DIGITAL,
  970. };
  971. static u8 m88rs2000_inittab[] = {
  972. DEMOD_WRITE, 0x9a, 0x30,
  973. DEMOD_WRITE, 0x00, 0x01,
  974. WRITE_DELAY, 0x19, 0x00,
  975. DEMOD_WRITE, 0x00, 0x00,
  976. DEMOD_WRITE, 0x9a, 0xb0,
  977. DEMOD_WRITE, 0x81, 0xc1,
  978. DEMOD_WRITE, 0x81, 0x81,
  979. DEMOD_WRITE, 0x86, 0xc6,
  980. DEMOD_WRITE, 0x9a, 0x30,
  981. DEMOD_WRITE, 0xf0, 0x80,
  982. DEMOD_WRITE, 0xf1, 0xbf,
  983. DEMOD_WRITE, 0xb0, 0x45,
  984. DEMOD_WRITE, 0xb2, 0x01,
  985. DEMOD_WRITE, 0x9a, 0xb0,
  986. 0xff, 0xaa, 0xff
  987. };
  988. static struct m88rs2000_config s421_m88rs2000_config = {
  989. .demod_addr = 0x68,
  990. .inittab = m88rs2000_inittab,
  991. };
  992. static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
  993. {
  994. struct dvb_tuner_ops *tuner_ops = NULL;
  995. if (demod_probe & 4) {
  996. d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
  997. &d->dev->i2c_adap, 0);
  998. if (d->fe_adap[0].fe != NULL) {
  999. if (dvb_attach(stb6100_attach, d->fe_adap[0].fe,
  1000. &dw2104a_stb6100_config,
  1001. &d->dev->i2c_adap)) {
  1002. tuner_ops = &d->fe_adap[0].fe->ops.tuner_ops;
  1003. tuner_ops->set_frequency = stb6100_set_freq;
  1004. tuner_ops->get_frequency = stb6100_get_freq;
  1005. tuner_ops->set_bandwidth = stb6100_set_bandw;
  1006. tuner_ops->get_bandwidth = stb6100_get_bandw;
  1007. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1008. info("Attached STV0900+STB6100!");
  1009. return 0;
  1010. }
  1011. }
  1012. }
  1013. if (demod_probe & 2) {
  1014. d->fe_adap[0].fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
  1015. &d->dev->i2c_adap, 0);
  1016. if (d->fe_adap[0].fe != NULL) {
  1017. if (dvb_attach(stv6110_attach, d->fe_adap[0].fe,
  1018. &dw2104_stv6110_config,
  1019. &d->dev->i2c_adap)) {
  1020. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1021. info("Attached STV0900+STV6110A!");
  1022. return 0;
  1023. }
  1024. }
  1025. }
  1026. if (demod_probe & 1) {
  1027. d->fe_adap[0].fe = dvb_attach(cx24116_attach, &dw2104_config,
  1028. &d->dev->i2c_adap);
  1029. if (d->fe_adap[0].fe != NULL) {
  1030. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1031. info("Attached cx24116!");
  1032. return 0;
  1033. }
  1034. }
  1035. d->fe_adap[0].fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
  1036. &d->dev->i2c_adap);
  1037. if (d->fe_adap[0].fe != NULL) {
  1038. dvb_attach(ts2020_attach, d->fe_adap[0].fe,
  1039. &dw2104_ts2020_config, &d->dev->i2c_adap);
  1040. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1041. info("Attached DS3000!");
  1042. return 0;
  1043. }
  1044. return -EIO;
  1045. }
  1046. static struct dvb_usb_device_properties dw2102_properties;
  1047. static struct dvb_usb_device_properties dw2104_properties;
  1048. static struct dvb_usb_device_properties s6x0_properties;
  1049. static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
  1050. {
  1051. if (dw2102_properties.i2c_algo == &dw2102_serit_i2c_algo) {
  1052. /*dw2102_properties.adapter->tuner_attach = NULL;*/
  1053. d->fe_adap[0].fe = dvb_attach(si21xx_attach, &serit_sp1511lhb_config,
  1054. &d->dev->i2c_adap);
  1055. if (d->fe_adap[0].fe != NULL) {
  1056. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1057. info("Attached si21xx!");
  1058. return 0;
  1059. }
  1060. }
  1061. if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
  1062. d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
  1063. &d->dev->i2c_adap);
  1064. if (d->fe_adap[0].fe != NULL) {
  1065. if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61,
  1066. &d->dev->i2c_adap)) {
  1067. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1068. info("Attached stv0288!");
  1069. return 0;
  1070. }
  1071. }
  1072. }
  1073. if (dw2102_properties.i2c_algo == &dw2102_i2c_algo) {
  1074. /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
  1075. d->fe_adap[0].fe = dvb_attach(stv0299_attach, &sharp_z0194a_config,
  1076. &d->dev->i2c_adap);
  1077. if (d->fe_adap[0].fe != NULL) {
  1078. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1079. info("Attached stv0299!");
  1080. return 0;
  1081. }
  1082. }
  1083. return -EIO;
  1084. }
  1085. static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
  1086. {
  1087. d->fe_adap[0].fe = dvb_attach(tda10023_attach, &dw3101_tda10023_config,
  1088. &d->dev->i2c_adap, 0x48);
  1089. if (d->fe_adap[0].fe != NULL) {
  1090. info("Attached tda10023!");
  1091. return 0;
  1092. }
  1093. return -EIO;
  1094. }
  1095. static int zl100313_frontend_attach(struct dvb_usb_adapter *d)
  1096. {
  1097. d->fe_adap[0].fe = dvb_attach(mt312_attach, &zl313_config,
  1098. &d->dev->i2c_adap);
  1099. if (d->fe_adap[0].fe != NULL) {
  1100. if (dvb_attach(zl10039_attach, d->fe_adap[0].fe, 0x60,
  1101. &d->dev->i2c_adap)) {
  1102. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1103. info("Attached zl100313+zl10039!");
  1104. return 0;
  1105. }
  1106. }
  1107. return -EIO;
  1108. }
  1109. static int stv0288_frontend_attach(struct dvb_usb_adapter *d)
  1110. {
  1111. u8 obuf[] = {7, 1};
  1112. d->fe_adap[0].fe = dvb_attach(stv0288_attach, &earda_config,
  1113. &d->dev->i2c_adap);
  1114. if (d->fe_adap[0].fe == NULL)
  1115. return -EIO;
  1116. if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap))
  1117. return -EIO;
  1118. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1119. dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
  1120. info("Attached stv0288+stb6000!");
  1121. return 0;
  1122. }
  1123. static int ds3000_frontend_attach(struct dvb_usb_adapter *d)
  1124. {
  1125. struct dw2102_state *st = d->dev->priv;
  1126. u8 obuf[] = {7, 1};
  1127. d->fe_adap[0].fe = dvb_attach(ds3000_attach, &s660_ds3000_config,
  1128. &d->dev->i2c_adap);
  1129. if (d->fe_adap[0].fe == NULL)
  1130. return -EIO;
  1131. dvb_attach(ts2020_attach, d->fe_adap[0].fe, &s660_ts2020_config,
  1132. &d->dev->i2c_adap);
  1133. st->old_set_voltage = d->fe_adap[0].fe->ops.set_voltage;
  1134. d->fe_adap[0].fe->ops.set_voltage = s660_set_voltage;
  1135. dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
  1136. info("Attached ds3000+ts2020!");
  1137. return 0;
  1138. }
  1139. static int prof_7500_frontend_attach(struct dvb_usb_adapter *d)
  1140. {
  1141. u8 obuf[] = {7, 1};
  1142. d->fe_adap[0].fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config,
  1143. &d->dev->i2c_adap, 0);
  1144. if (d->fe_adap[0].fe == NULL)
  1145. return -EIO;
  1146. d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage;
  1147. dw210x_op_rw(d->dev->udev, 0x8a, 0, 0, obuf, 2, DW210X_WRITE_MSG);
  1148. info("Attached STV0900+STB6100A!");
  1149. return 0;
  1150. }
  1151. static int su3000_frontend_attach(struct dvb_usb_adapter *adap)
  1152. {
  1153. struct dvb_usb_device *d = adap->dev;
  1154. struct dw2102_state *state = d->priv;
  1155. mutex_lock(&d->data_mutex);
  1156. state->data[0] = 0xe;
  1157. state->data[1] = 0x80;
  1158. state->data[2] = 0;
  1159. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1160. err("command 0x0e transfer failed.");
  1161. state->data[0] = 0xe;
  1162. state->data[1] = 0x02;
  1163. state->data[2] = 1;
  1164. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1165. err("command 0x0e transfer failed.");
  1166. msleep(300);
  1167. state->data[0] = 0xe;
  1168. state->data[1] = 0x83;
  1169. state->data[2] = 0;
  1170. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1171. err("command 0x0e transfer failed.");
  1172. state->data[0] = 0xe;
  1173. state->data[1] = 0x83;
  1174. state->data[2] = 1;
  1175. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1176. err("command 0x0e transfer failed.");
  1177. state->data[0] = 0x51;
  1178. if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0)
  1179. err("command 0x51 transfer failed.");
  1180. mutex_unlock(&d->data_mutex);
  1181. adap->fe_adap[0].fe = dvb_attach(ds3000_attach, &su3000_ds3000_config,
  1182. &d->i2c_adap);
  1183. if (adap->fe_adap[0].fe == NULL)
  1184. return -EIO;
  1185. if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe,
  1186. &dw2104_ts2020_config,
  1187. &d->i2c_adap)) {
  1188. info("Attached DS3000/TS2020!");
  1189. return 0;
  1190. }
  1191. info("Failed to attach DS3000/TS2020!");
  1192. return -EIO;
  1193. }
  1194. static int t220_frontend_attach(struct dvb_usb_adapter *adap)
  1195. {
  1196. struct dvb_usb_device *d = adap->dev;
  1197. struct dw2102_state *state = d->priv;
  1198. mutex_lock(&d->data_mutex);
  1199. state->data[0] = 0xe;
  1200. state->data[1] = 0x87;
  1201. state->data[2] = 0x0;
  1202. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1203. err("command 0x0e transfer failed.");
  1204. state->data[0] = 0xe;
  1205. state->data[1] = 0x86;
  1206. state->data[2] = 1;
  1207. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1208. err("command 0x0e transfer failed.");
  1209. state->data[0] = 0xe;
  1210. state->data[1] = 0x80;
  1211. state->data[2] = 0;
  1212. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1213. err("command 0x0e transfer failed.");
  1214. msleep(50);
  1215. state->data[0] = 0xe;
  1216. state->data[1] = 0x80;
  1217. state->data[2] = 1;
  1218. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1219. err("command 0x0e transfer failed.");
  1220. state->data[0] = 0x51;
  1221. if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0)
  1222. err("command 0x51 transfer failed.");
  1223. mutex_unlock(&d->data_mutex);
  1224. adap->fe_adap[0].fe = dvb_attach(cxd2820r_attach, &cxd2820r_config,
  1225. &d->i2c_adap, NULL);
  1226. if (adap->fe_adap[0].fe != NULL) {
  1227. if (dvb_attach(tda18271_attach, adap->fe_adap[0].fe, 0x60,
  1228. &d->i2c_adap, &tda18271_config)) {
  1229. info("Attached TDA18271HD/CXD2820R!");
  1230. return 0;
  1231. }
  1232. }
  1233. info("Failed to attach TDA18271HD/CXD2820R!");
  1234. return -EIO;
  1235. }
  1236. static int m88rs2000_frontend_attach(struct dvb_usb_adapter *adap)
  1237. {
  1238. struct dvb_usb_device *d = adap->dev;
  1239. struct dw2102_state *state = d->priv;
  1240. mutex_lock(&d->data_mutex);
  1241. state->data[0] = 0x51;
  1242. if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0)
  1243. err("command 0x51 transfer failed.");
  1244. mutex_unlock(&d->data_mutex);
  1245. adap->fe_adap[0].fe = dvb_attach(m88rs2000_attach,
  1246. &s421_m88rs2000_config,
  1247. &d->i2c_adap);
  1248. if (adap->fe_adap[0].fe == NULL)
  1249. return -EIO;
  1250. if (dvb_attach(ts2020_attach, adap->fe_adap[0].fe,
  1251. &dw2104_ts2020_config,
  1252. &d->i2c_adap)) {
  1253. info("Attached RS2000/TS2020!");
  1254. return 0;
  1255. }
  1256. info("Failed to attach RS2000/TS2020!");
  1257. return -EIO;
  1258. }
  1259. static int tt_s2_4600_frontend_attach(struct dvb_usb_adapter *adap)
  1260. {
  1261. struct dvb_usb_device *d = adap->dev;
  1262. struct dw2102_state *state = d->priv;
  1263. struct i2c_adapter *i2c_adapter;
  1264. struct i2c_client *client;
  1265. struct i2c_board_info board_info;
  1266. struct m88ds3103_platform_data m88ds3103_pdata = {};
  1267. struct ts2020_config ts2020_config = {};
  1268. mutex_lock(&d->data_mutex);
  1269. state->data[0] = 0xe;
  1270. state->data[1] = 0x80;
  1271. state->data[2] = 0x0;
  1272. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1273. err("command 0x0e transfer failed.");
  1274. state->data[0] = 0xe;
  1275. state->data[1] = 0x02;
  1276. state->data[2] = 1;
  1277. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1278. err("command 0x0e transfer failed.");
  1279. msleep(300);
  1280. state->data[0] = 0xe;
  1281. state->data[1] = 0x83;
  1282. state->data[2] = 0;
  1283. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1284. err("command 0x0e transfer failed.");
  1285. state->data[0] = 0xe;
  1286. state->data[1] = 0x83;
  1287. state->data[2] = 1;
  1288. if (dvb_usb_generic_rw(d, state->data, 3, state->data, 1, 0) < 0)
  1289. err("command 0x0e transfer failed.");
  1290. state->data[0] = 0x51;
  1291. if (dvb_usb_generic_rw(d, state->data, 1, state->data, 1, 0) < 0)
  1292. err("command 0x51 transfer failed.");
  1293. mutex_unlock(&d->data_mutex);
  1294. /* attach demod */
  1295. m88ds3103_pdata.clk = 27000000;
  1296. m88ds3103_pdata.i2c_wr_max = 33;
  1297. m88ds3103_pdata.ts_mode = M88DS3103_TS_CI;
  1298. m88ds3103_pdata.ts_clk = 16000;
  1299. m88ds3103_pdata.ts_clk_pol = 0;
  1300. m88ds3103_pdata.spec_inv = 0;
  1301. m88ds3103_pdata.agc = 0x99;
  1302. m88ds3103_pdata.agc_inv = 0;
  1303. m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_ENABLED;
  1304. m88ds3103_pdata.envelope_mode = 0;
  1305. m88ds3103_pdata.lnb_hv_pol = 1;
  1306. m88ds3103_pdata.lnb_en_pol = 0;
  1307. memset(&board_info, 0, sizeof(board_info));
  1308. strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE);
  1309. board_info.addr = 0x68;
  1310. board_info.platform_data = &m88ds3103_pdata;
  1311. request_module("m88ds3103");
  1312. client = i2c_new_device(&d->i2c_adap, &board_info);
  1313. if (client == NULL || client->dev.driver == NULL)
  1314. return -ENODEV;
  1315. if (!try_module_get(client->dev.driver->owner)) {
  1316. i2c_unregister_device(client);
  1317. return -ENODEV;
  1318. }
  1319. adap->fe_adap[0].fe = m88ds3103_pdata.get_dvb_frontend(client);
  1320. i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client);
  1321. state->i2c_client_demod = client;
  1322. /* attach tuner */
  1323. ts2020_config.fe = adap->fe_adap[0].fe;
  1324. memset(&board_info, 0, sizeof(board_info));
  1325. strlcpy(board_info.type, "ts2022", I2C_NAME_SIZE);
  1326. board_info.addr = 0x60;
  1327. board_info.platform_data = &ts2020_config;
  1328. request_module("ts2020");
  1329. client = i2c_new_device(i2c_adapter, &board_info);
  1330. if (client == NULL || client->dev.driver == NULL) {
  1331. dvb_frontend_detach(adap->fe_adap[0].fe);
  1332. return -ENODEV;
  1333. }
  1334. if (!try_module_get(client->dev.driver->owner)) {
  1335. i2c_unregister_device(client);
  1336. dvb_frontend_detach(adap->fe_adap[0].fe);
  1337. return -ENODEV;
  1338. }
  1339. /* delegate signal strength measurement to tuner */
  1340. adap->fe_adap[0].fe->ops.read_signal_strength =
  1341. adap->fe_adap[0].fe->ops.tuner_ops.get_rf_strength;
  1342. state->i2c_client_tuner = client;
  1343. /* hook fe: need to resync the slave fifo when signal locks */
  1344. state->fe_read_status = adap->fe_adap[0].fe->ops.read_status;
  1345. adap->fe_adap[0].fe->ops.read_status = tt_s2_4600_read_status;
  1346. state->last_lock = 0;
  1347. return 0;
  1348. }
  1349. static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
  1350. {
  1351. dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
  1352. &adap->dev->i2c_adap, DVB_PLL_OPERA1);
  1353. return 0;
  1354. }
  1355. static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
  1356. {
  1357. dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60,
  1358. &adap->dev->i2c_adap, DVB_PLL_TUA6034);
  1359. return 0;
  1360. }
  1361. static int dw2102_rc_query(struct dvb_usb_device *d)
  1362. {
  1363. u8 key[2];
  1364. struct i2c_msg msg = {
  1365. .addr = DW2102_RC_QUERY,
  1366. .flags = I2C_M_RD,
  1367. .buf = key,
  1368. .len = 2
  1369. };
  1370. if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
  1371. if (msg.buf[0] != 0xff) {
  1372. deb_rc("%s: rc code: %x, %x\n",
  1373. __func__, key[0], key[1]);
  1374. rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0], 0);
  1375. }
  1376. }
  1377. return 0;
  1378. }
  1379. static int prof_rc_query(struct dvb_usb_device *d)
  1380. {
  1381. u8 key[2];
  1382. struct i2c_msg msg = {
  1383. .addr = DW2102_RC_QUERY,
  1384. .flags = I2C_M_RD,
  1385. .buf = key,
  1386. .len = 2
  1387. };
  1388. if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
  1389. if (msg.buf[0] != 0xff) {
  1390. deb_rc("%s: rc code: %x, %x\n",
  1391. __func__, key[0], key[1]);
  1392. rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0]^0xff, 0);
  1393. }
  1394. }
  1395. return 0;
  1396. }
  1397. static int su3000_rc_query(struct dvb_usb_device *d)
  1398. {
  1399. u8 key[2];
  1400. struct i2c_msg msg = {
  1401. .addr = DW2102_RC_QUERY,
  1402. .flags = I2C_M_RD,
  1403. .buf = key,
  1404. .len = 2
  1405. };
  1406. if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
  1407. if (msg.buf[0] != 0xff) {
  1408. deb_rc("%s: rc code: %x, %x\n",
  1409. __func__, key[0], key[1]);
  1410. rc_keydown(d->rc_dev, RC_TYPE_RC5,
  1411. RC_SCANCODE_RC5(key[1], key[0]), 0);
  1412. }
  1413. }
  1414. return 0;
  1415. }
  1416. enum dw2102_table_entry {
  1417. CYPRESS_DW2102,
  1418. CYPRESS_DW2101,
  1419. CYPRESS_DW2104,
  1420. TEVII_S650,
  1421. TERRATEC_CINERGY_S,
  1422. CYPRESS_DW3101,
  1423. TEVII_S630,
  1424. PROF_1100,
  1425. TEVII_S660,
  1426. PROF_7500,
  1427. GENIATECH_SU3000,
  1428. TERRATEC_CINERGY_S2,
  1429. TEVII_S480_1,
  1430. TEVII_S480_2,
  1431. X3M_SPC1400HD,
  1432. TEVII_S421,
  1433. TEVII_S632,
  1434. TERRATEC_CINERGY_S2_R2,
  1435. TERRATEC_CINERGY_S2_R3,
  1436. TERRATEC_CINERGY_S2_R4,
  1437. GOTVIEW_SAT_HD,
  1438. GENIATECH_T220,
  1439. TECHNOTREND_S2_4600,
  1440. TEVII_S482_1,
  1441. TEVII_S482_2,
  1442. TERRATEC_CINERGY_S2_BOX,
  1443. TEVII_S662
  1444. };
  1445. static struct usb_device_id dw2102_table[] = {
  1446. [CYPRESS_DW2102] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2102)},
  1447. [CYPRESS_DW2101] = {USB_DEVICE(USB_VID_CYPRESS, 0x2101)},
  1448. [CYPRESS_DW2104] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW2104)},
  1449. [TEVII_S650] = {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
  1450. [TERRATEC_CINERGY_S] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S)},
  1451. [CYPRESS_DW3101] = {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
  1452. [TEVII_S630] = {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
  1453. [PROF_1100] = {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
  1454. [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
  1455. [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
  1456. [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
  1457. [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R1)},
  1458. [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
  1459. [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
  1460. [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
  1461. [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
  1462. [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
  1463. [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R2)},
  1464. [TERRATEC_CINERGY_S2_R3] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R3)},
  1465. [TERRATEC_CINERGY_S2_R4] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4)},
  1466. [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)},
  1467. [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)},
  1468. [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND,
  1469. USB_PID_TECHNOTREND_CONNECT_S2_4600)},
  1470. [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)},
  1471. [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)},
  1472. [TERRATEC_CINERGY_S2_BOX] = {USB_DEVICE(USB_VID_TERRATEC, 0x0105)},
  1473. [TEVII_S662] = {USB_DEVICE(0x9022, USB_PID_TEVII_S662)},
  1474. { }
  1475. };
  1476. MODULE_DEVICE_TABLE(usb, dw2102_table);
  1477. static int dw2102_load_firmware(struct usb_device *dev,
  1478. const struct firmware *frmwr)
  1479. {
  1480. u8 *b, *p;
  1481. int ret = 0, i;
  1482. u8 reset;
  1483. u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
  1484. const struct firmware *fw;
  1485. switch (le16_to_cpu(dev->descriptor.idProduct)) {
  1486. case 0x2101:
  1487. ret = request_firmware(&fw, DW2101_FIRMWARE, &dev->dev);
  1488. if (ret != 0) {
  1489. err(err_str, DW2101_FIRMWARE);
  1490. return ret;
  1491. }
  1492. break;
  1493. default:
  1494. fw = frmwr;
  1495. break;
  1496. }
  1497. info("start downloading DW210X firmware");
  1498. p = kmalloc(fw->size, GFP_KERNEL);
  1499. reset = 1;
  1500. /*stop the CPU*/
  1501. dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1, DW210X_WRITE_MSG);
  1502. dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1, DW210X_WRITE_MSG);
  1503. if (p != NULL) {
  1504. memcpy(p, fw->data, fw->size);
  1505. for (i = 0; i < fw->size; i += 0x40) {
  1506. b = (u8 *) p + i;
  1507. if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40,
  1508. DW210X_WRITE_MSG) != 0x40) {
  1509. err("error while transferring firmware");
  1510. ret = -EINVAL;
  1511. break;
  1512. }
  1513. }
  1514. /* restart the CPU */
  1515. reset = 0;
  1516. if (ret || dw210x_op_rw(dev, 0xa0, 0x7f92, 0, &reset, 1,
  1517. DW210X_WRITE_MSG) != 1) {
  1518. err("could not restart the USB controller CPU.");
  1519. ret = -EINVAL;
  1520. }
  1521. if (ret || dw210x_op_rw(dev, 0xa0, 0xe600, 0, &reset, 1,
  1522. DW210X_WRITE_MSG) != 1) {
  1523. err("could not restart the USB controller CPU.");
  1524. ret = -EINVAL;
  1525. }
  1526. /* init registers */
  1527. switch (le16_to_cpu(dev->descriptor.idProduct)) {
  1528. case USB_PID_TEVII_S650:
  1529. dw2104_properties.rc.core.rc_codes = RC_MAP_TEVII_NEC;
  1530. case USB_PID_DW2104:
  1531. reset = 1;
  1532. dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
  1533. DW210X_WRITE_MSG);
  1534. /* break omitted intentionally */
  1535. case USB_PID_DW3101:
  1536. reset = 0;
  1537. dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
  1538. DW210X_WRITE_MSG);
  1539. break;
  1540. case USB_PID_TERRATEC_CINERGY_S:
  1541. case USB_PID_DW2102:
  1542. dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
  1543. DW210X_WRITE_MSG);
  1544. dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
  1545. DW210X_READ_MSG);
  1546. /* check STV0299 frontend */
  1547. dw210x_op_rw(dev, 0xb5, 0, 0, &reset16[0], 2,
  1548. DW210X_READ_MSG);
  1549. if ((reset16[0] == 0xa1) || (reset16[0] == 0x80)) {
  1550. dw2102_properties.i2c_algo = &dw2102_i2c_algo;
  1551. dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach;
  1552. break;
  1553. } else {
  1554. /* check STV0288 frontend */
  1555. reset16[0] = 0xd0;
  1556. reset16[1] = 1;
  1557. reset16[2] = 0;
  1558. dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3,
  1559. DW210X_WRITE_MSG);
  1560. dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3,
  1561. DW210X_READ_MSG);
  1562. if (reset16[2] == 0x11) {
  1563. dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
  1564. break;
  1565. }
  1566. }
  1567. case 0x2101:
  1568. dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
  1569. DW210X_READ_MSG);
  1570. dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
  1571. DW210X_READ_MSG);
  1572. dw210x_op_rw(dev, 0xba, 0x0000, 0, &reset16[0], 7,
  1573. DW210X_READ_MSG);
  1574. dw210x_op_rw(dev, 0xb9, 0x0000, 0, &reset16[0], 2,
  1575. DW210X_READ_MSG);
  1576. break;
  1577. }
  1578. msleep(100);
  1579. kfree(p);
  1580. }
  1581. if (le16_to_cpu(dev->descriptor.idProduct) == 0x2101)
  1582. release_firmware(fw);
  1583. return ret;
  1584. }
  1585. static struct dvb_usb_device_properties dw2102_properties = {
  1586. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1587. .usb_ctrl = DEVICE_SPECIFIC,
  1588. .firmware = DW2102_FIRMWARE,
  1589. .no_reconnect = 1,
  1590. .i2c_algo = &dw2102_serit_i2c_algo,
  1591. .rc.core = {
  1592. .rc_interval = 150,
  1593. .rc_codes = RC_MAP_DM1105_NEC,
  1594. .module_name = "dw2102",
  1595. .allowed_protos = RC_BIT_NEC,
  1596. .rc_query = dw2102_rc_query,
  1597. },
  1598. .generic_bulk_ctrl_endpoint = 0x81,
  1599. /* parameter for the MPEG2-data transfer */
  1600. .num_adapters = 1,
  1601. .download_firmware = dw2102_load_firmware,
  1602. .read_mac_address = dw210x_read_mac_address,
  1603. .adapter = {
  1604. {
  1605. .num_frontends = 1,
  1606. .fe = {{
  1607. .frontend_attach = dw2102_frontend_attach,
  1608. .stream = {
  1609. .type = USB_BULK,
  1610. .count = 8,
  1611. .endpoint = 0x82,
  1612. .u = {
  1613. .bulk = {
  1614. .buffersize = 4096,
  1615. }
  1616. }
  1617. },
  1618. }},
  1619. }
  1620. },
  1621. .num_device_descs = 3,
  1622. .devices = {
  1623. {"DVBWorld DVB-S 2102 USB2.0",
  1624. {&dw2102_table[CYPRESS_DW2102], NULL},
  1625. {NULL},
  1626. },
  1627. {"DVBWorld DVB-S 2101 USB2.0",
  1628. {&dw2102_table[CYPRESS_DW2101], NULL},
  1629. {NULL},
  1630. },
  1631. {"TerraTec Cinergy S USB",
  1632. {&dw2102_table[TERRATEC_CINERGY_S], NULL},
  1633. {NULL},
  1634. },
  1635. }
  1636. };
  1637. static struct dvb_usb_device_properties dw2104_properties = {
  1638. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1639. .usb_ctrl = DEVICE_SPECIFIC,
  1640. .firmware = DW2104_FIRMWARE,
  1641. .no_reconnect = 1,
  1642. .i2c_algo = &dw2104_i2c_algo,
  1643. .rc.core = {
  1644. .rc_interval = 150,
  1645. .rc_codes = RC_MAP_DM1105_NEC,
  1646. .module_name = "dw2102",
  1647. .allowed_protos = RC_BIT_NEC,
  1648. .rc_query = dw2102_rc_query,
  1649. },
  1650. .generic_bulk_ctrl_endpoint = 0x81,
  1651. /* parameter for the MPEG2-data transfer */
  1652. .num_adapters = 1,
  1653. .download_firmware = dw2102_load_firmware,
  1654. .read_mac_address = dw210x_read_mac_address,
  1655. .adapter = {
  1656. {
  1657. .num_frontends = 1,
  1658. .fe = {{
  1659. .frontend_attach = dw2104_frontend_attach,
  1660. .stream = {
  1661. .type = USB_BULK,
  1662. .count = 8,
  1663. .endpoint = 0x82,
  1664. .u = {
  1665. .bulk = {
  1666. .buffersize = 4096,
  1667. }
  1668. }
  1669. },
  1670. }},
  1671. }
  1672. },
  1673. .num_device_descs = 2,
  1674. .devices = {
  1675. { "DVBWorld DW2104 USB2.0",
  1676. {&dw2102_table[CYPRESS_DW2104], NULL},
  1677. {NULL},
  1678. },
  1679. { "TeVii S650 USB2.0",
  1680. {&dw2102_table[TEVII_S650], NULL},
  1681. {NULL},
  1682. },
  1683. }
  1684. };
  1685. static struct dvb_usb_device_properties dw3101_properties = {
  1686. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1687. .usb_ctrl = DEVICE_SPECIFIC,
  1688. .firmware = DW3101_FIRMWARE,
  1689. .no_reconnect = 1,
  1690. .i2c_algo = &dw3101_i2c_algo,
  1691. .rc.core = {
  1692. .rc_interval = 150,
  1693. .rc_codes = RC_MAP_DM1105_NEC,
  1694. .module_name = "dw2102",
  1695. .allowed_protos = RC_BIT_NEC,
  1696. .rc_query = dw2102_rc_query,
  1697. },
  1698. .generic_bulk_ctrl_endpoint = 0x81,
  1699. /* parameter for the MPEG2-data transfer */
  1700. .num_adapters = 1,
  1701. .download_firmware = dw2102_load_firmware,
  1702. .read_mac_address = dw210x_read_mac_address,
  1703. .adapter = {
  1704. {
  1705. .num_frontends = 1,
  1706. .fe = {{
  1707. .frontend_attach = dw3101_frontend_attach,
  1708. .tuner_attach = dw3101_tuner_attach,
  1709. .stream = {
  1710. .type = USB_BULK,
  1711. .count = 8,
  1712. .endpoint = 0x82,
  1713. .u = {
  1714. .bulk = {
  1715. .buffersize = 4096,
  1716. }
  1717. }
  1718. },
  1719. }},
  1720. }
  1721. },
  1722. .num_device_descs = 1,
  1723. .devices = {
  1724. { "DVBWorld DVB-C 3101 USB2.0",
  1725. {&dw2102_table[CYPRESS_DW3101], NULL},
  1726. {NULL},
  1727. },
  1728. }
  1729. };
  1730. static struct dvb_usb_device_properties s6x0_properties = {
  1731. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1732. .usb_ctrl = DEVICE_SPECIFIC,
  1733. .size_of_priv = sizeof(struct dw2102_state),
  1734. .firmware = S630_FIRMWARE,
  1735. .no_reconnect = 1,
  1736. .i2c_algo = &s6x0_i2c_algo,
  1737. .rc.core = {
  1738. .rc_interval = 150,
  1739. .rc_codes = RC_MAP_TEVII_NEC,
  1740. .module_name = "dw2102",
  1741. .allowed_protos = RC_BIT_NEC,
  1742. .rc_query = dw2102_rc_query,
  1743. },
  1744. .generic_bulk_ctrl_endpoint = 0x81,
  1745. .num_adapters = 1,
  1746. .download_firmware = dw2102_load_firmware,
  1747. .read_mac_address = s6x0_read_mac_address,
  1748. .adapter = {
  1749. {
  1750. .num_frontends = 1,
  1751. .fe = {{
  1752. .frontend_attach = zl100313_frontend_attach,
  1753. .stream = {
  1754. .type = USB_BULK,
  1755. .count = 8,
  1756. .endpoint = 0x82,
  1757. .u = {
  1758. .bulk = {
  1759. .buffersize = 4096,
  1760. }
  1761. }
  1762. },
  1763. }},
  1764. }
  1765. },
  1766. .num_device_descs = 1,
  1767. .devices = {
  1768. {"TeVii S630 USB",
  1769. {&dw2102_table[TEVII_S630], NULL},
  1770. {NULL},
  1771. },
  1772. }
  1773. };
  1774. static struct dvb_usb_device_properties *p1100;
  1775. static struct dvb_usb_device_description d1100 = {
  1776. "Prof 1100 USB ",
  1777. {&dw2102_table[PROF_1100], NULL},
  1778. {NULL},
  1779. };
  1780. static struct dvb_usb_device_properties *s660;
  1781. static struct dvb_usb_device_description d660 = {
  1782. "TeVii S660 USB",
  1783. {&dw2102_table[TEVII_S660], NULL},
  1784. {NULL},
  1785. };
  1786. static struct dvb_usb_device_description d480_1 = {
  1787. "TeVii S480.1 USB",
  1788. {&dw2102_table[TEVII_S480_1], NULL},
  1789. {NULL},
  1790. };
  1791. static struct dvb_usb_device_description d480_2 = {
  1792. "TeVii S480.2 USB",
  1793. {&dw2102_table[TEVII_S480_2], NULL},
  1794. {NULL},
  1795. };
  1796. static struct dvb_usb_device_properties *p7500;
  1797. static struct dvb_usb_device_description d7500 = {
  1798. "Prof 7500 USB DVB-S2",
  1799. {&dw2102_table[PROF_7500], NULL},
  1800. {NULL},
  1801. };
  1802. static struct dvb_usb_device_properties *s421;
  1803. static struct dvb_usb_device_description d421 = {
  1804. "TeVii S421 PCI",
  1805. {&dw2102_table[TEVII_S421], NULL},
  1806. {NULL},
  1807. };
  1808. static struct dvb_usb_device_description d632 = {
  1809. "TeVii S632 USB",
  1810. {&dw2102_table[TEVII_S632], NULL},
  1811. {NULL},
  1812. };
  1813. static struct dvb_usb_device_properties su3000_properties = {
  1814. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1815. .usb_ctrl = DEVICE_SPECIFIC,
  1816. .size_of_priv = sizeof(struct dw2102_state),
  1817. .power_ctrl = su3000_power_ctrl,
  1818. .num_adapters = 1,
  1819. .identify_state = su3000_identify_state,
  1820. .i2c_algo = &su3000_i2c_algo,
  1821. .rc.core = {
  1822. .rc_interval = 150,
  1823. .rc_codes = RC_MAP_SU3000,
  1824. .module_name = "dw2102",
  1825. .allowed_protos = RC_BIT_RC5,
  1826. .rc_query = su3000_rc_query,
  1827. },
  1828. .read_mac_address = su3000_read_mac_address,
  1829. .generic_bulk_ctrl_endpoint = 0x01,
  1830. .adapter = {
  1831. {
  1832. .num_frontends = 1,
  1833. .fe = {{
  1834. .streaming_ctrl = su3000_streaming_ctrl,
  1835. .frontend_attach = su3000_frontend_attach,
  1836. .stream = {
  1837. .type = USB_BULK,
  1838. .count = 8,
  1839. .endpoint = 0x82,
  1840. .u = {
  1841. .bulk = {
  1842. .buffersize = 4096,
  1843. }
  1844. }
  1845. }
  1846. }},
  1847. }
  1848. },
  1849. .num_device_descs = 6,
  1850. .devices = {
  1851. { "SU3000HD DVB-S USB2.0",
  1852. { &dw2102_table[GENIATECH_SU3000], NULL },
  1853. { NULL },
  1854. },
  1855. { "Terratec Cinergy S2 USB HD",
  1856. { &dw2102_table[TERRATEC_CINERGY_S2], NULL },
  1857. { NULL },
  1858. },
  1859. { "X3M TV SPC1400HD PCI",
  1860. { &dw2102_table[X3M_SPC1400HD], NULL },
  1861. { NULL },
  1862. },
  1863. { "Terratec Cinergy S2 USB HD Rev.2",
  1864. { &dw2102_table[TERRATEC_CINERGY_S2_R2], NULL },
  1865. { NULL },
  1866. },
  1867. { "Terratec Cinergy S2 USB HD Rev.3",
  1868. { &dw2102_table[TERRATEC_CINERGY_S2_R3], NULL },
  1869. { NULL },
  1870. },
  1871. { "GOTVIEW Satellite HD",
  1872. { &dw2102_table[GOTVIEW_SAT_HD], NULL },
  1873. { NULL },
  1874. },
  1875. }
  1876. };
  1877. static struct dvb_usb_device_properties t220_properties = {
  1878. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1879. .usb_ctrl = DEVICE_SPECIFIC,
  1880. .size_of_priv = sizeof(struct dw2102_state),
  1881. .power_ctrl = su3000_power_ctrl,
  1882. .num_adapters = 1,
  1883. .identify_state = su3000_identify_state,
  1884. .i2c_algo = &su3000_i2c_algo,
  1885. .rc.core = {
  1886. .rc_interval = 150,
  1887. .rc_codes = RC_MAP_SU3000,
  1888. .module_name = "dw2102",
  1889. .allowed_protos = RC_BIT_RC5,
  1890. .rc_query = su3000_rc_query,
  1891. },
  1892. .read_mac_address = su3000_read_mac_address,
  1893. .generic_bulk_ctrl_endpoint = 0x01,
  1894. .adapter = {
  1895. {
  1896. .num_frontends = 1,
  1897. .fe = { {
  1898. .streaming_ctrl = su3000_streaming_ctrl,
  1899. .frontend_attach = t220_frontend_attach,
  1900. .stream = {
  1901. .type = USB_BULK,
  1902. .count = 8,
  1903. .endpoint = 0x82,
  1904. .u = {
  1905. .bulk = {
  1906. .buffersize = 4096,
  1907. }
  1908. }
  1909. }
  1910. } },
  1911. }
  1912. },
  1913. .num_device_descs = 1,
  1914. .devices = {
  1915. { "Geniatech T220 DVB-T/T2 USB2.0",
  1916. { &dw2102_table[GENIATECH_T220], NULL },
  1917. { NULL },
  1918. },
  1919. }
  1920. };
  1921. static struct dvb_usb_device_properties tt_s2_4600_properties = {
  1922. .caps = DVB_USB_IS_AN_I2C_ADAPTER,
  1923. .usb_ctrl = DEVICE_SPECIFIC,
  1924. .size_of_priv = sizeof(struct dw2102_state),
  1925. .power_ctrl = su3000_power_ctrl,
  1926. .num_adapters = 1,
  1927. .identify_state = su3000_identify_state,
  1928. .i2c_algo = &su3000_i2c_algo,
  1929. .rc.core = {
  1930. .rc_interval = 250,
  1931. .rc_codes = RC_MAP_TT_1500,
  1932. .module_name = "dw2102",
  1933. .allowed_protos = RC_BIT_RC5,
  1934. .rc_query = su3000_rc_query,
  1935. },
  1936. .read_mac_address = su3000_read_mac_address,
  1937. .generic_bulk_ctrl_endpoint = 0x01,
  1938. .adapter = {
  1939. {
  1940. .num_frontends = 1,
  1941. .fe = {{
  1942. .streaming_ctrl = su3000_streaming_ctrl,
  1943. .frontend_attach = tt_s2_4600_frontend_attach,
  1944. .stream = {
  1945. .type = USB_BULK,
  1946. .count = 8,
  1947. .endpoint = 0x82,
  1948. .u = {
  1949. .bulk = {
  1950. .buffersize = 4096,
  1951. }
  1952. }
  1953. }
  1954. } },
  1955. }
  1956. },
  1957. .num_device_descs = 5,
  1958. .devices = {
  1959. { "TechnoTrend TT-connect S2-4600",
  1960. { &dw2102_table[TECHNOTREND_S2_4600], NULL },
  1961. { NULL },
  1962. },
  1963. { "TeVii S482 (tuner 1)",
  1964. { &dw2102_table[TEVII_S482_1], NULL },
  1965. { NULL },
  1966. },
  1967. { "TeVii S482 (tuner 2)",
  1968. { &dw2102_table[TEVII_S482_2], NULL },
  1969. { NULL },
  1970. },
  1971. { "Terratec Cinergy S2 USB BOX",
  1972. { &dw2102_table[TERRATEC_CINERGY_S2_BOX], NULL },
  1973. { NULL },
  1974. },
  1975. { "TeVii S662",
  1976. { &dw2102_table[TEVII_S662], NULL },
  1977. { NULL },
  1978. },
  1979. }
  1980. };
  1981. static int dw2102_probe(struct usb_interface *intf,
  1982. const struct usb_device_id *id)
  1983. {
  1984. p1100 = kmemdup(&s6x0_properties,
  1985. sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
  1986. if (!p1100)
  1987. return -ENOMEM;
  1988. /* copy default structure */
  1989. /* fill only different fields */
  1990. p1100->firmware = P1100_FIRMWARE;
  1991. p1100->devices[0] = d1100;
  1992. p1100->rc.core.rc_query = prof_rc_query;
  1993. p1100->rc.core.rc_codes = RC_MAP_TBS_NEC;
  1994. p1100->adapter->fe[0].frontend_attach = stv0288_frontend_attach;
  1995. s660 = kmemdup(&s6x0_properties,
  1996. sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
  1997. if (!s660) {
  1998. kfree(p1100);
  1999. return -ENOMEM;
  2000. }
  2001. s660->firmware = S660_FIRMWARE;
  2002. s660->num_device_descs = 3;
  2003. s660->devices[0] = d660;
  2004. s660->devices[1] = d480_1;
  2005. s660->devices[2] = d480_2;
  2006. s660->adapter->fe[0].frontend_attach = ds3000_frontend_attach;
  2007. p7500 = kmemdup(&s6x0_properties,
  2008. sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
  2009. if (!p7500) {
  2010. kfree(p1100);
  2011. kfree(s660);
  2012. return -ENOMEM;
  2013. }
  2014. p7500->firmware = P7500_FIRMWARE;
  2015. p7500->devices[0] = d7500;
  2016. p7500->rc.core.rc_query = prof_rc_query;
  2017. p7500->rc.core.rc_codes = RC_MAP_TBS_NEC;
  2018. p7500->adapter->fe[0].frontend_attach = prof_7500_frontend_attach;
  2019. s421 = kmemdup(&su3000_properties,
  2020. sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
  2021. if (!s421) {
  2022. kfree(p1100);
  2023. kfree(s660);
  2024. kfree(p7500);
  2025. return -ENOMEM;
  2026. }
  2027. s421->num_device_descs = 2;
  2028. s421->devices[0] = d421;
  2029. s421->devices[1] = d632;
  2030. s421->adapter->fe[0].frontend_attach = m88rs2000_frontend_attach;
  2031. if (0 == dvb_usb_device_init(intf, &dw2102_properties,
  2032. THIS_MODULE, NULL, adapter_nr) ||
  2033. 0 == dvb_usb_device_init(intf, &dw2104_properties,
  2034. THIS_MODULE, NULL, adapter_nr) ||
  2035. 0 == dvb_usb_device_init(intf, &dw3101_properties,
  2036. THIS_MODULE, NULL, adapter_nr) ||
  2037. 0 == dvb_usb_device_init(intf, &s6x0_properties,
  2038. THIS_MODULE, NULL, adapter_nr) ||
  2039. 0 == dvb_usb_device_init(intf, p1100,
  2040. THIS_MODULE, NULL, adapter_nr) ||
  2041. 0 == dvb_usb_device_init(intf, s660,
  2042. THIS_MODULE, NULL, adapter_nr) ||
  2043. 0 == dvb_usb_device_init(intf, p7500,
  2044. THIS_MODULE, NULL, adapter_nr) ||
  2045. 0 == dvb_usb_device_init(intf, s421,
  2046. THIS_MODULE, NULL, adapter_nr) ||
  2047. 0 == dvb_usb_device_init(intf, &su3000_properties,
  2048. THIS_MODULE, NULL, adapter_nr) ||
  2049. 0 == dvb_usb_device_init(intf, &t220_properties,
  2050. THIS_MODULE, NULL, adapter_nr) ||
  2051. 0 == dvb_usb_device_init(intf, &tt_s2_4600_properties,
  2052. THIS_MODULE, NULL, adapter_nr))
  2053. return 0;
  2054. return -ENODEV;
  2055. }
  2056. static void dw2102_disconnect(struct usb_interface *intf)
  2057. {
  2058. struct dvb_usb_device *d = usb_get_intfdata(intf);
  2059. struct dw2102_state *st = (struct dw2102_state *)d->priv;
  2060. struct i2c_client *client;
  2061. /* remove I2C client for tuner */
  2062. client = st->i2c_client_tuner;
  2063. if (client) {
  2064. module_put(client->dev.driver->owner);
  2065. i2c_unregister_device(client);
  2066. }
  2067. /* remove I2C client for demodulator */
  2068. client = st->i2c_client_demod;
  2069. if (client) {
  2070. module_put(client->dev.driver->owner);
  2071. i2c_unregister_device(client);
  2072. }
  2073. dvb_usb_device_exit(intf);
  2074. }
  2075. static struct usb_driver dw2102_driver = {
  2076. .name = "dw2102",
  2077. .probe = dw2102_probe,
  2078. .disconnect = dw2102_disconnect,
  2079. .id_table = dw2102_table,
  2080. };
  2081. module_usb_driver(dw2102_driver);
  2082. MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
  2083. MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101 USB2.0, TeVii S421, S480, S482, S600, S630, S632, S650, TeVii S660, S662, Prof 1100, 7500 USB2.0, Geniatech SU3000, T220, TechnoTrend S2-4600, Terratec Cinergy S2 devices");
  2084. MODULE_VERSION("0.1");
  2085. MODULE_LICENSE("GPL");
  2086. MODULE_FIRMWARE(DW2101_FIRMWARE);
  2087. MODULE_FIRMWARE(DW2102_FIRMWARE);
  2088. MODULE_FIRMWARE(DW2104_FIRMWARE);
  2089. MODULE_FIRMWARE(DW3101_FIRMWARE);
  2090. MODULE_FIRMWARE(S630_FIRMWARE);
  2091. MODULE_FIRMWARE(S660_FIRMWARE);
  2092. MODULE_FIRMWARE(P1100_FIRMWARE);
  2093. MODULE_FIRMWARE(P7500_FIRMWARE);