dw2102.c 58 KB

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