dw2102.c 55 KB

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