dw2102.c 58 KB

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