rtl28xxu.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  1. /*
  2. * Realtek RTL28xxU DVB USB driver
  3. *
  4. * Copyright (C) 2009 Antti Palosaari <crope@iki.fi>
  5. * Copyright (C) 2011 Antti Palosaari <crope@iki.fi>
  6. * Copyright (C) 2012 Thomas Mair <thomas.mair86@googlemail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #include "rtl28xxu.h"
  23. #include "rtl2830.h"
  24. #include "rtl2832.h"
  25. #include "qt1010.h"
  26. #include "mt2060.h"
  27. #include "mxl5005s.h"
  28. #include "fc0012.h"
  29. #include "fc0013.h"
  30. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  31. static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req)
  32. {
  33. int ret;
  34. unsigned int pipe;
  35. u8 requesttype;
  36. u8 *buf;
  37. buf = kmalloc(req->size, GFP_KERNEL);
  38. if (!buf) {
  39. ret = -ENOMEM;
  40. goto err;
  41. }
  42. if (req->index & CMD_WR_FLAG) {
  43. /* write */
  44. memcpy(buf, req->data, req->size);
  45. requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT);
  46. pipe = usb_sndctrlpipe(d->udev, 0);
  47. } else {
  48. /* read */
  49. requesttype = (USB_TYPE_VENDOR | USB_DIR_IN);
  50. pipe = usb_rcvctrlpipe(d->udev, 0);
  51. }
  52. ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value,
  53. req->index, buf, req->size, 1000);
  54. if (ret > 0)
  55. ret = 0;
  56. deb_dump(0, requesttype, req->value, req->index, buf, req->size);
  57. /* read request, copy returned data to return buf */
  58. if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN))
  59. memcpy(req->data, buf, req->size);
  60. kfree(buf);
  61. if (ret)
  62. goto err;
  63. return ret;
  64. err:
  65. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  66. return ret;
  67. }
  68. static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len)
  69. {
  70. struct rtl28xxu_req req;
  71. if (reg < 0x3000)
  72. req.index = CMD_USB_WR;
  73. else if (reg < 0x4000)
  74. req.index = CMD_SYS_WR;
  75. else
  76. req.index = CMD_IR_WR;
  77. req.value = reg;
  78. req.size = len;
  79. req.data = val;
  80. return rtl28xxu_ctrl_msg(d, &req);
  81. }
  82. static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len)
  83. {
  84. struct rtl28xxu_req req;
  85. if (reg < 0x3000)
  86. req.index = CMD_USB_RD;
  87. else if (reg < 0x4000)
  88. req.index = CMD_SYS_RD;
  89. else
  90. req.index = CMD_IR_RD;
  91. req.value = reg;
  92. req.size = len;
  93. req.data = val;
  94. return rtl28xxu_ctrl_msg(d, &req);
  95. }
  96. static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val)
  97. {
  98. return rtl28xx_wr_regs(d, reg, &val, 1);
  99. }
  100. static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val)
  101. {
  102. return rtl2831_rd_regs(d, reg, val, 1);
  103. }
  104. /* I2C */
  105. static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  106. int num)
  107. {
  108. int ret;
  109. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  110. struct rtl28xxu_priv *priv = d->priv;
  111. struct rtl28xxu_req req;
  112. /*
  113. * It is not known which are real I2C bus xfer limits, but testing
  114. * with RTL2831U + MT2060 gives max RD 24 and max WR 22 bytes.
  115. * TODO: find out RTL2832U lens
  116. */
  117. /*
  118. * I2C adapter logic looks rather complicated due to fact it handles
  119. * three different access methods. Those methods are;
  120. * 1) integrated demod access
  121. * 2) old I2C access
  122. * 3) new I2C access
  123. *
  124. * Used method is selected in order 1, 2, 3. Method 3 can handle all
  125. * requests but there is two reasons why not use it always;
  126. * 1) It is most expensive, usually two USB messages are needed
  127. * 2) At least RTL2831U does not support it
  128. *
  129. * Method 3 is needed in case of I2C write+read (typical register read)
  130. * where write is more than one byte.
  131. */
  132. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  133. return -EAGAIN;
  134. if (num == 2 && !(msg[0].flags & I2C_M_RD) &&
  135. (msg[1].flags & I2C_M_RD)) {
  136. if (msg[0].len > 24 || msg[1].len > 24) {
  137. /* TODO: check msg[0].len max */
  138. ret = -EOPNOTSUPP;
  139. goto err_mutex_unlock;
  140. } else if (msg[0].addr == 0x10) {
  141. /* method 1 - integrated demod */
  142. req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
  143. req.index = CMD_DEMOD_RD | priv->page;
  144. req.size = msg[1].len;
  145. req.data = &msg[1].buf[0];
  146. ret = rtl28xxu_ctrl_msg(d, &req);
  147. } else if (msg[0].len < 2) {
  148. /* method 2 - old I2C */
  149. req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
  150. req.index = CMD_I2C_RD;
  151. req.size = msg[1].len;
  152. req.data = &msg[1].buf[0];
  153. ret = rtl28xxu_ctrl_msg(d, &req);
  154. } else {
  155. /* method 3 - new I2C */
  156. req.value = (msg[0].addr << 1);
  157. req.index = CMD_I2C_DA_WR;
  158. req.size = msg[0].len;
  159. req.data = msg[0].buf;
  160. ret = rtl28xxu_ctrl_msg(d, &req);
  161. if (ret)
  162. goto err_mutex_unlock;
  163. req.value = (msg[0].addr << 1);
  164. req.index = CMD_I2C_DA_RD;
  165. req.size = msg[1].len;
  166. req.data = msg[1].buf;
  167. ret = rtl28xxu_ctrl_msg(d, &req);
  168. }
  169. } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) {
  170. if (msg[0].len > 22) {
  171. /* TODO: check msg[0].len max */
  172. ret = -EOPNOTSUPP;
  173. goto err_mutex_unlock;
  174. } else if (msg[0].addr == 0x10) {
  175. /* method 1 - integrated demod */
  176. if (msg[0].buf[0] == 0x00) {
  177. /* save demod page for later demod access */
  178. priv->page = msg[0].buf[1];
  179. ret = 0;
  180. } else {
  181. req.value = (msg[0].buf[0] << 8) |
  182. (msg[0].addr << 1);
  183. req.index = CMD_DEMOD_WR | priv->page;
  184. req.size = msg[0].len-1;
  185. req.data = &msg[0].buf[1];
  186. ret = rtl28xxu_ctrl_msg(d, &req);
  187. }
  188. } else if (msg[0].len < 23) {
  189. /* method 2 - old I2C */
  190. req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
  191. req.index = CMD_I2C_WR;
  192. req.size = msg[0].len-1;
  193. req.data = &msg[0].buf[1];
  194. ret = rtl28xxu_ctrl_msg(d, &req);
  195. } else {
  196. /* method 3 - new I2C */
  197. req.value = (msg[0].addr << 1);
  198. req.index = CMD_I2C_DA_WR;
  199. req.size = msg[0].len;
  200. req.data = msg[0].buf;
  201. ret = rtl28xxu_ctrl_msg(d, &req);
  202. }
  203. } else {
  204. ret = -EINVAL;
  205. }
  206. err_mutex_unlock:
  207. mutex_unlock(&d->i2c_mutex);
  208. return ret ? ret : num;
  209. }
  210. static u32 rtl28xxu_i2c_func(struct i2c_adapter *adapter)
  211. {
  212. return I2C_FUNC_I2C;
  213. }
  214. static struct i2c_algorithm rtl28xxu_i2c_algo = {
  215. .master_xfer = rtl28xxu_i2c_xfer,
  216. .functionality = rtl28xxu_i2c_func,
  217. };
  218. static struct rtl2830_config rtl28xxu_rtl2830_mt2060_config = {
  219. .i2c_addr = 0x10, /* 0x20 */
  220. .xtal = 28800000,
  221. .ts_mode = 0,
  222. .spec_inv = 1,
  223. .if_dvbt = 36150000,
  224. .vtop = 0x20,
  225. .krf = 0x04,
  226. .agc_targ_val = 0x2d,
  227. };
  228. static struct rtl2830_config rtl28xxu_rtl2830_qt1010_config = {
  229. .i2c_addr = 0x10, /* 0x20 */
  230. .xtal = 28800000,
  231. .ts_mode = 0,
  232. .spec_inv = 1,
  233. .if_dvbt = 36125000,
  234. .vtop = 0x20,
  235. .krf = 0x04,
  236. .agc_targ_val = 0x2d,
  237. };
  238. static struct rtl2830_config rtl28xxu_rtl2830_mxl5005s_config = {
  239. .i2c_addr = 0x10, /* 0x20 */
  240. .xtal = 28800000,
  241. .ts_mode = 0,
  242. .spec_inv = 0,
  243. .if_dvbt = 4570000,
  244. .vtop = 0x3f,
  245. .krf = 0x04,
  246. .agc_targ_val = 0x3e,
  247. };
  248. static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap)
  249. {
  250. int ret;
  251. struct dvb_usb_device *d = adap_to_d(adap);
  252. struct rtl28xxu_priv *priv = d_to_priv(d);
  253. u8 buf[1];
  254. struct rtl2830_config *rtl2830_config;
  255. /* open RTL2831U/RTL2830 I2C gate */
  256. struct rtl28xxu_req req_gate = { 0x0120, 0x0011, 0x0001, "\x08" };
  257. /* for MT2060 tuner probe */
  258. struct rtl28xxu_req req_mt2060 = { 0x00c0, CMD_I2C_RD, 1, buf };
  259. /* for QT1010 tuner probe */
  260. struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf };
  261. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  262. /*
  263. * RTL2831U GPIOs
  264. * =========================================================
  265. * GPIO0 | tuner#0 | 0 off | 1 on | MXL5005S (?)
  266. * GPIO2 | LED | 0 off | 1 on |
  267. * GPIO4 | tuner#1 | 0 on | 1 off | MT2060
  268. */
  269. /* GPIO direction */
  270. ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, 0x0a);
  271. if (ret)
  272. goto err;
  273. /* enable as output GPIO0, GPIO2, GPIO4 */
  274. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, 0x15);
  275. if (ret)
  276. goto err;
  277. /*
  278. * Probe used tuner. We need to know used tuner before demod attach
  279. * since there is some demod params needed to set according to tuner.
  280. */
  281. /* demod needs some time to wake up */
  282. msleep(20);
  283. /* open demod I2C gate */
  284. ret = rtl28xxu_ctrl_msg(d, &req_gate);
  285. if (ret)
  286. goto err;
  287. /* check QT1010 ID(?) register; reg=0f val=2c */
  288. ret = rtl28xxu_ctrl_msg(d, &req_qt1010);
  289. if (ret == 0 && buf[0] == 0x2c) {
  290. priv->tuner = TUNER_RTL2830_QT1010;
  291. rtl2830_config = &rtl28xxu_rtl2830_qt1010_config;
  292. dev_dbg(&d->udev->dev, "%s: QT1010\n", __func__);
  293. goto found;
  294. } else {
  295. dev_dbg(&d->udev->dev, "%s: QT1010 probe failed=%d - %02x\n",
  296. __func__, ret, buf[0]);
  297. }
  298. /* open demod I2C gate */
  299. ret = rtl28xxu_ctrl_msg(d, &req_gate);
  300. if (ret)
  301. goto err;
  302. /* check MT2060 ID register; reg=00 val=63 */
  303. ret = rtl28xxu_ctrl_msg(d, &req_mt2060);
  304. if (ret == 0 && buf[0] == 0x63) {
  305. priv->tuner = TUNER_RTL2830_MT2060;
  306. rtl2830_config = &rtl28xxu_rtl2830_mt2060_config;
  307. dev_dbg(&d->udev->dev, "%s: MT2060\n", __func__);
  308. goto found;
  309. } else {
  310. dev_dbg(&d->udev->dev, "%s: MT2060 probe failed=%d - %02x\n",
  311. __func__, ret, buf[0]);
  312. }
  313. /* assume MXL5005S */
  314. ret = 0;
  315. priv->tuner = TUNER_RTL2830_MXL5005S;
  316. rtl2830_config = &rtl28xxu_rtl2830_mxl5005s_config;
  317. dev_dbg(&d->udev->dev, "%s: MXL5005S\n", __func__);
  318. goto found;
  319. found:
  320. /* attach demodulator */
  321. adap->fe[0] = dvb_attach(rtl2830_attach, rtl2830_config,
  322. &d->i2c_adap);
  323. if (adap->fe[0] == NULL) {
  324. ret = -ENODEV;
  325. goto err;
  326. }
  327. return ret;
  328. err:
  329. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  330. return ret;
  331. }
  332. static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = {
  333. .i2c_addr = 0x10, /* 0x20 */
  334. .xtal = 28800000,
  335. .if_dvbt = 0,
  336. .tuner = TUNER_RTL2832_FC0012
  337. };
  338. static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = {
  339. .i2c_addr = 0x10, /* 0x20 */
  340. .xtal = 28800000,
  341. .if_dvbt = 0,
  342. .tuner = TUNER_RTL2832_FC0013
  343. };
  344. static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d,
  345. int cmd, int arg)
  346. {
  347. int ret;
  348. u8 val;
  349. dev_dbg(&d->udev->dev, "%s: cmd=%d arg=%d\n", __func__, cmd, arg);
  350. switch (cmd) {
  351. case FC_FE_CALLBACK_VHF_ENABLE:
  352. /* set output values */
  353. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
  354. if (ret)
  355. goto err;
  356. if (arg)
  357. val &= 0xbf; /* set GPIO6 low */
  358. else
  359. val |= 0x40; /* set GPIO6 high */
  360. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
  361. if (ret)
  362. goto err;
  363. break;
  364. default:
  365. ret = -EINVAL;
  366. goto err;
  367. }
  368. return 0;
  369. err:
  370. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  371. return ret;
  372. }
  373. static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d,
  374. int cmd, int arg)
  375. {
  376. /* TODO implement*/
  377. return 0;
  378. }
  379. static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg)
  380. {
  381. struct rtl28xxu_priv *priv = d->priv;
  382. switch (priv->tuner) {
  383. case TUNER_RTL2832_FC0012:
  384. return rtl2832u_fc0012_tuner_callback(d, cmd, arg);
  385. case TUNER_RTL2832_FC0013:
  386. return rtl2832u_fc0013_tuner_callback(d, cmd, arg);
  387. default:
  388. break;
  389. }
  390. return -ENODEV;
  391. }
  392. static int rtl2832u_frontend_callback(void *adapter_priv, int component,
  393. int cmd, int arg)
  394. {
  395. struct i2c_adapter *adap = adapter_priv;
  396. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  397. switch (component) {
  398. case DVB_FRONTEND_COMPONENT_TUNER:
  399. return rtl2832u_tuner_callback(d, cmd, arg);
  400. default:
  401. break;
  402. }
  403. return -EINVAL;
  404. }
  405. static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
  406. {
  407. int ret;
  408. struct dvb_usb_device *d = adap_to_d(adap);
  409. struct rtl28xxu_priv *priv = d_to_priv(d);
  410. struct rtl2832_config *rtl2832_config;
  411. u8 buf[2], val;
  412. /* open RTL2832U/RTL2832 I2C gate */
  413. struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"};
  414. /* close RTL2832U/RTL2832 I2C gate */
  415. struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"};
  416. /* for FC0012 tuner probe */
  417. struct rtl28xxu_req req_fc0012 = {0x00c6, CMD_I2C_RD, 1, buf};
  418. /* for FC0013 tuner probe */
  419. struct rtl28xxu_req req_fc0013 = {0x00c6, CMD_I2C_RD, 1, buf};
  420. /* for MT2266 tuner probe */
  421. struct rtl28xxu_req req_mt2266 = {0x00c0, CMD_I2C_RD, 1, buf};
  422. /* for FC2580 tuner probe */
  423. struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf};
  424. /* for MT2063 tuner probe */
  425. struct rtl28xxu_req req_mt2063 = {0x00c0, CMD_I2C_RD, 1, buf};
  426. /* for MAX3543 tuner probe */
  427. struct rtl28xxu_req req_max3543 = {0x00c0, CMD_I2C_RD, 1, buf};
  428. /* for TUA9001 tuner probe */
  429. struct rtl28xxu_req req_tua9001 = {0x7ec0, CMD_I2C_RD, 2, buf};
  430. /* for MXL5007T tuner probe */
  431. struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf};
  432. /* for E4000 tuner probe */
  433. struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf};
  434. /* for TDA18272 tuner probe */
  435. struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf};
  436. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  437. ret = rtl28xx_rd_reg(d, SYS_GPIO_DIR, &val);
  438. if (ret)
  439. goto err;
  440. val &= 0xbf;
  441. ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, val);
  442. if (ret)
  443. goto err;
  444. /* enable as output GPIO3 and GPIO6*/
  445. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_EN, &val);
  446. if (ret)
  447. goto err;
  448. val |= 0x48;
  449. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, val);
  450. if (ret)
  451. goto err;
  452. /*
  453. * Probe used tuner. We need to know used tuner before demod attach
  454. * since there is some demod params needed to set according to tuner.
  455. */
  456. /* open demod I2C gate */
  457. ret = rtl28xxu_ctrl_msg(d, &req_gate_open);
  458. if (ret)
  459. goto err;
  460. priv->tuner = TUNER_NONE;
  461. /* check FC0012 ID register; reg=00 val=a1 */
  462. ret = rtl28xxu_ctrl_msg(d, &req_fc0012);
  463. if (ret == 0 && buf[0] == 0xa1) {
  464. priv->tuner = TUNER_RTL2832_FC0012;
  465. rtl2832_config = &rtl28xxu_rtl2832_fc0012_config;
  466. dev_info(&d->udev->dev, "%s: FC0012 tuner found",
  467. KBUILD_MODNAME);
  468. goto found;
  469. }
  470. /* check FC0013 ID register; reg=00 val=a3 */
  471. ret = rtl28xxu_ctrl_msg(d, &req_fc0013);
  472. if (ret == 0 && buf[0] == 0xa3) {
  473. priv->tuner = TUNER_RTL2832_FC0013;
  474. rtl2832_config = &rtl28xxu_rtl2832_fc0013_config;
  475. dev_info(&d->udev->dev, "%s: FC0013 tuner found",
  476. KBUILD_MODNAME);
  477. goto found;
  478. }
  479. /* check MT2266 ID register; reg=00 val=85 */
  480. ret = rtl28xxu_ctrl_msg(d, &req_mt2266);
  481. if (ret == 0 && buf[0] == 0x85) {
  482. priv->tuner = TUNER_RTL2832_MT2266;
  483. /* TODO implement tuner */
  484. dev_info(&d->udev->dev, "%s: MT2266 tuner found",
  485. KBUILD_MODNAME);
  486. goto unsupported;
  487. }
  488. /* check FC2580 ID register; reg=01 val=56 */
  489. ret = rtl28xxu_ctrl_msg(d, &req_fc2580);
  490. if (ret == 0 && buf[0] == 0x56) {
  491. priv->tuner = TUNER_RTL2832_FC2580;
  492. /* TODO implement tuner */
  493. dev_info(&d->udev->dev, "%s: FC2580 tuner found",
  494. KBUILD_MODNAME);
  495. goto unsupported;
  496. }
  497. /* check MT2063 ID register; reg=00 val=9e || 9c */
  498. ret = rtl28xxu_ctrl_msg(d, &req_mt2063);
  499. if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) {
  500. priv->tuner = TUNER_RTL2832_MT2063;
  501. /* TODO implement tuner */
  502. dev_info(&d->udev->dev, "%s: MT2063 tuner found",
  503. KBUILD_MODNAME);
  504. goto unsupported;
  505. }
  506. /* check MAX3543 ID register; reg=00 val=38 */
  507. ret = rtl28xxu_ctrl_msg(d, &req_max3543);
  508. if (ret == 0 && buf[0] == 0x38) {
  509. priv->tuner = TUNER_RTL2832_MAX3543;
  510. /* TODO implement tuner */
  511. dev_info(&d->udev->dev, "%s: MAX3534 tuner found",
  512. KBUILD_MODNAME);
  513. goto unsupported;
  514. }
  515. /* check TUA9001 ID register; reg=7e val=2328 */
  516. ret = rtl28xxu_ctrl_msg(d, &req_tua9001);
  517. if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) {
  518. priv->tuner = TUNER_RTL2832_TUA9001;
  519. /* TODO implement tuner */
  520. dev_info(&d->udev->dev, "%s: TUA9001 tuner found",
  521. KBUILD_MODNAME);
  522. goto unsupported;
  523. }
  524. /* check MXL5007R ID register; reg=d9 val=14 */
  525. ret = rtl28xxu_ctrl_msg(d, &req_mxl5007t);
  526. if (ret == 0 && buf[0] == 0x14) {
  527. priv->tuner = TUNER_RTL2832_MXL5007T;
  528. /* TODO implement tuner */
  529. dev_info(&d->udev->dev, "%s: MXL5007T tuner found",
  530. KBUILD_MODNAME);
  531. goto unsupported;
  532. }
  533. /* check E4000 ID register; reg=02 val=40 */
  534. ret = rtl28xxu_ctrl_msg(d, &req_e4000);
  535. if (ret == 0 && buf[0] == 0x40) {
  536. priv->tuner = TUNER_RTL2832_E4000;
  537. /* TODO implement tuner */
  538. dev_info(&d->udev->dev, "%s: E4000 tuner found",
  539. KBUILD_MODNAME);
  540. goto unsupported;
  541. }
  542. /* check TDA18272 ID register; reg=00 val=c760 */
  543. ret = rtl28xxu_ctrl_msg(d, &req_tda18272);
  544. if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) {
  545. priv->tuner = TUNER_RTL2832_TDA18272;
  546. /* TODO implement tuner */
  547. dev_info(&d->udev->dev, "%s: TDA18272 tuner found",
  548. KBUILD_MODNAME);
  549. goto unsupported;
  550. }
  551. unsupported:
  552. /* close demod I2C gate */
  553. ret = rtl28xxu_ctrl_msg(d, &req_gate_close);
  554. if (ret)
  555. goto err;
  556. /* tuner not found */
  557. dev_dbg(&d->udev->dev, "%s: No compatible tuner found\n", __func__);
  558. ret = -ENODEV;
  559. return ret;
  560. found:
  561. /* close demod I2C gate */
  562. ret = rtl28xxu_ctrl_msg(d, &req_gate_close);
  563. if (ret)
  564. goto err;
  565. /* attach demodulator */
  566. adap->fe[0] = dvb_attach(rtl2832_attach, rtl2832_config,
  567. &d->i2c_adap);
  568. if (adap->fe[0] == NULL) {
  569. ret = -ENODEV;
  570. goto err;
  571. }
  572. /* set fe callbacks */
  573. adap->fe[0]->callback = rtl2832u_frontend_callback;
  574. return ret;
  575. err:
  576. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  577. return ret;
  578. }
  579. static struct qt1010_config rtl28xxu_qt1010_config = {
  580. .i2c_address = 0x62, /* 0xc4 */
  581. };
  582. static struct mt2060_config rtl28xxu_mt2060_config = {
  583. .i2c_address = 0x60, /* 0xc0 */
  584. .clock_out = 0,
  585. };
  586. static struct mxl5005s_config rtl28xxu_mxl5005s_config = {
  587. .i2c_address = 0x63, /* 0xc6 */
  588. .if_freq = IF_FREQ_4570000HZ,
  589. .xtal_freq = CRYSTAL_FREQ_16000000HZ,
  590. .agc_mode = MXL_SINGLE_AGC,
  591. .tracking_filter = MXL_TF_C_H,
  592. .rssi_enable = MXL_RSSI_ENABLE,
  593. .cap_select = MXL_CAP_SEL_ENABLE,
  594. .div_out = MXL_DIV_OUT_4,
  595. .clock_out = MXL_CLOCK_OUT_DISABLE,
  596. .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
  597. .top = MXL5005S_TOP_25P2,
  598. .mod_mode = MXL_DIGITAL_MODE,
  599. .if_mode = MXL_ZERO_IF,
  600. .AgcMasterByte = 0x00,
  601. };
  602. static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap)
  603. {
  604. int ret;
  605. struct dvb_usb_device *d = adap_to_d(adap);
  606. struct rtl28xxu_priv *priv = d_to_priv(d);
  607. struct i2c_adapter *rtl2830_tuner_i2c;
  608. struct dvb_frontend *fe;
  609. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  610. /* use rtl2830 driver I2C adapter, for more info see rtl2830 driver */
  611. rtl2830_tuner_i2c = rtl2830_get_tuner_i2c_adapter(adap->fe[0]);
  612. switch (priv->tuner) {
  613. case TUNER_RTL2830_QT1010:
  614. fe = dvb_attach(qt1010_attach, adap->fe[0],
  615. rtl2830_tuner_i2c, &rtl28xxu_qt1010_config);
  616. break;
  617. case TUNER_RTL2830_MT2060:
  618. fe = dvb_attach(mt2060_attach, adap->fe[0],
  619. rtl2830_tuner_i2c, &rtl28xxu_mt2060_config,
  620. 1220);
  621. break;
  622. case TUNER_RTL2830_MXL5005S:
  623. fe = dvb_attach(mxl5005s_attach, adap->fe[0],
  624. rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config);
  625. break;
  626. default:
  627. fe = NULL;
  628. dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
  629. priv->tuner);
  630. }
  631. if (fe == NULL) {
  632. ret = -ENODEV;
  633. goto err;
  634. }
  635. return 0;
  636. err:
  637. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  638. return ret;
  639. }
  640. static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
  641. {
  642. int ret;
  643. struct dvb_usb_device *d = adap_to_d(adap);
  644. struct rtl28xxu_priv *priv = d_to_priv(d);
  645. struct dvb_frontend *fe;
  646. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  647. switch (priv->tuner) {
  648. case TUNER_RTL2832_FC0012:
  649. fe = dvb_attach(fc0012_attach, adap->fe[0],
  650. &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ);
  651. /* since fc0012 includs reading the signal strength delegate
  652. * that to the tuner driver */
  653. adap->fe[0]->ops.read_signal_strength =
  654. adap->fe[0]->ops.tuner_ops.get_rf_strength;
  655. return 0;
  656. break;
  657. case TUNER_RTL2832_FC0013:
  658. fe = dvb_attach(fc0013_attach, adap->fe[0],
  659. &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ);
  660. /* fc0013 also supports signal strength reading */
  661. adap->fe[0]->ops.read_signal_strength =
  662. adap->fe[0]->ops.tuner_ops.get_rf_strength;
  663. return 0;
  664. default:
  665. fe = NULL;
  666. dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
  667. priv->tuner);
  668. }
  669. if (fe == NULL) {
  670. ret = -ENODEV;
  671. goto err;
  672. }
  673. return 0;
  674. err:
  675. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  676. return ret;
  677. }
  678. static int rtl28xxu_init(struct dvb_usb_device *d)
  679. {
  680. int ret;
  681. u8 val;
  682. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  683. /* init USB endpoints */
  684. ret = rtl28xx_rd_reg(d, USB_SYSCTL_0, &val);
  685. if (ret)
  686. goto err;
  687. /* enable DMA and Full Packet Mode*/
  688. val |= 0x09;
  689. ret = rtl28xx_wr_reg(d, USB_SYSCTL_0, val);
  690. if (ret)
  691. goto err;
  692. /* set EPA maximum packet size to 0x0200 */
  693. ret = rtl28xx_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4);
  694. if (ret)
  695. goto err;
  696. /* change EPA FIFO length */
  697. ret = rtl28xx_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4);
  698. if (ret)
  699. goto err;
  700. return ret;
  701. err:
  702. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  703. return ret;
  704. }
  705. static int rtl28xxu_streaming_ctrl(struct dvb_frontend *fe , int onoff)
  706. {
  707. int ret;
  708. u8 buf[2];
  709. struct dvb_usb_device *d = fe_to_d(fe);
  710. dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
  711. if (onoff) {
  712. buf[0] = 0x00;
  713. buf[1] = 0x00;
  714. usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81));
  715. } else {
  716. buf[0] = 0x10; /* stall EPA */
  717. buf[1] = 0x02; /* reset EPA */
  718. }
  719. ret = rtl28xx_wr_regs(d, USB_EPA_CTL, buf, 2);
  720. if (ret)
  721. goto err;
  722. return ret;
  723. err:
  724. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  725. return ret;
  726. }
  727. static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff)
  728. {
  729. int ret;
  730. u8 gpio, sys0;
  731. dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
  732. /* demod adc */
  733. ret = rtl28xx_rd_reg(d, SYS_SYS0, &sys0);
  734. if (ret)
  735. goto err;
  736. /* tuner power, read GPIOs */
  737. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio);
  738. if (ret)
  739. goto err;
  740. dev_dbg(&d->udev->dev, "%s: RD SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__,
  741. sys0, gpio);
  742. if (onoff) {
  743. gpio |= 0x01; /* GPIO0 = 1 */
  744. gpio &= (~0x10); /* GPIO4 = 0 */
  745. gpio |= 0x04; /* GPIO2 = 1, LED on */
  746. sys0 = sys0 & 0x0f;
  747. sys0 |= 0xe0;
  748. } else {
  749. gpio &= (~0x01); /* GPIO0 = 0 */
  750. gpio |= 0x10; /* GPIO4 = 1 */
  751. gpio &= (~0x04); /* GPIO2 = 1, LED off */
  752. sys0 = sys0 & (~0xc0);
  753. }
  754. dev_dbg(&d->udev->dev, "%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__,
  755. sys0, gpio);
  756. /* demod adc */
  757. ret = rtl28xx_wr_reg(d, SYS_SYS0, sys0);
  758. if (ret)
  759. goto err;
  760. /* tuner power, write GPIOs */
  761. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, gpio);
  762. if (ret)
  763. goto err;
  764. return ret;
  765. err:
  766. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  767. return ret;
  768. }
  769. static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff)
  770. {
  771. int ret;
  772. u8 val;
  773. dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
  774. if (onoff) {
  775. /* set output values */
  776. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
  777. if (ret)
  778. goto err;
  779. val |= 0x08;
  780. val &= 0xef;
  781. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
  782. if (ret)
  783. goto err;
  784. /* demod_ctl_1 */
  785. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val);
  786. if (ret)
  787. goto err;
  788. val &= 0xef;
  789. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val);
  790. if (ret)
  791. goto err;
  792. /* demod control */
  793. /* PLL enable */
  794. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
  795. if (ret)
  796. goto err;
  797. /* bit 7 to 1 */
  798. val |= 0x80;
  799. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
  800. if (ret)
  801. goto err;
  802. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
  803. if (ret)
  804. goto err;
  805. val |= 0x20;
  806. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
  807. if (ret)
  808. goto err;
  809. mdelay(5);
  810. /*enable ADC_Q and ADC_I */
  811. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
  812. if (ret)
  813. goto err;
  814. val |= 0x48;
  815. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
  816. if (ret)
  817. goto err;
  818. } else {
  819. /* demod_ctl_1 */
  820. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val);
  821. if (ret)
  822. goto err;
  823. val |= 0x0c;
  824. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val);
  825. if (ret)
  826. goto err;
  827. /* set output values */
  828. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
  829. if (ret)
  830. goto err;
  831. val |= 0x10;
  832. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
  833. if (ret)
  834. goto err;
  835. /* demod control */
  836. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
  837. if (ret)
  838. goto err;
  839. val &= 0x37;
  840. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
  841. if (ret)
  842. goto err;
  843. }
  844. return ret;
  845. err:
  846. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  847. return ret;
  848. }
  849. static int rtl2831u_rc_query(struct dvb_usb_device *d)
  850. {
  851. int ret, i;
  852. struct rtl28xxu_priv *priv = d->priv;
  853. u8 buf[5];
  854. u32 rc_code;
  855. struct rtl28xxu_reg_val rc_nec_tab[] = {
  856. { 0x3033, 0x80 },
  857. { 0x3020, 0x43 },
  858. { 0x3021, 0x16 },
  859. { 0x3022, 0x16 },
  860. { 0x3023, 0x5a },
  861. { 0x3024, 0x2d },
  862. { 0x3025, 0x16 },
  863. { 0x3026, 0x01 },
  864. { 0x3028, 0xb0 },
  865. { 0x3029, 0x04 },
  866. { 0x302c, 0x88 },
  867. { 0x302e, 0x13 },
  868. { 0x3030, 0xdf },
  869. { 0x3031, 0x05 },
  870. };
  871. /* init remote controller */
  872. if (!priv->rc_active) {
  873. for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) {
  874. ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg,
  875. rc_nec_tab[i].val);
  876. if (ret)
  877. goto err;
  878. }
  879. priv->rc_active = true;
  880. }
  881. ret = rtl2831_rd_regs(d, SYS_IRRC_RP, buf, 5);
  882. if (ret)
  883. goto err;
  884. if (buf[4] & 0x01) {
  885. if (buf[2] == (u8) ~buf[3]) {
  886. if (buf[0] == (u8) ~buf[1]) {
  887. /* NEC standard (16 bit) */
  888. rc_code = buf[0] << 8 | buf[2];
  889. } else {
  890. /* NEC extended (24 bit) */
  891. rc_code = buf[0] << 16 |
  892. buf[1] << 8 | buf[2];
  893. }
  894. } else {
  895. /* NEC full (32 bit) */
  896. rc_code = buf[0] << 24 | buf[1] << 16 |
  897. buf[2] << 8 | buf[3];
  898. }
  899. rc_keydown(d->rc_dev, rc_code, 0);
  900. ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1);
  901. if (ret)
  902. goto err;
  903. /* repeated intentionally to avoid extra keypress */
  904. ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1);
  905. if (ret)
  906. goto err;
  907. }
  908. return ret;
  909. err:
  910. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  911. return ret;
  912. }
  913. static int rtl2831u_get_rc_config(struct dvb_usb_device *d,
  914. struct dvb_usb_rc *rc)
  915. {
  916. rc->map_name = RC_MAP_EMPTY;
  917. rc->allowed_protos = RC_TYPE_NEC;
  918. rc->query = rtl2831u_rc_query;
  919. rc->interval = 400;
  920. return 0;
  921. }
  922. static int rtl2832u_rc_query(struct dvb_usb_device *d)
  923. {
  924. int ret, i;
  925. struct rtl28xxu_priv *priv = d->priv;
  926. u8 buf[128];
  927. int len;
  928. struct rtl28xxu_reg_val rc_nec_tab[] = {
  929. { IR_RX_CTRL, 0x20 },
  930. { IR_RX_BUF_CTRL, 0x80 },
  931. { IR_RX_IF, 0xff },
  932. { IR_RX_IE, 0xff },
  933. { IR_MAX_DURATION0, 0xd0 },
  934. { IR_MAX_DURATION1, 0x07 },
  935. { IR_IDLE_LEN0, 0xc0 },
  936. { IR_IDLE_LEN1, 0x00 },
  937. { IR_GLITCH_LEN, 0x03 },
  938. { IR_RX_CLK, 0x09 },
  939. { IR_RX_CFG, 0x1c },
  940. { IR_MAX_H_TOL_LEN, 0x1e },
  941. { IR_MAX_L_TOL_LEN, 0x1e },
  942. { IR_RX_CTRL, 0x80 },
  943. };
  944. /* init remote controller */
  945. if (!priv->rc_active) {
  946. for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) {
  947. ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg,
  948. rc_nec_tab[i].val);
  949. if (ret)
  950. goto err;
  951. }
  952. priv->rc_active = true;
  953. }
  954. ret = rtl28xx_rd_reg(d, IR_RX_IF, &buf[0]);
  955. if (ret)
  956. goto err;
  957. if (buf[0] != 0x83)
  958. goto exit;
  959. ret = rtl28xx_rd_reg(d, IR_RX_BC, &buf[0]);
  960. if (ret)
  961. goto err;
  962. len = buf[0];
  963. ret = rtl2831_rd_regs(d, IR_RX_BUF, buf, len);
  964. /* TODO: pass raw IR to Kernel IR decoder */
  965. ret = rtl28xx_wr_reg(d, IR_RX_IF, 0x03);
  966. ret = rtl28xx_wr_reg(d, IR_RX_BUF_CTRL, 0x80);
  967. ret = rtl28xx_wr_reg(d, IR_RX_CTRL, 0x80);
  968. exit:
  969. return ret;
  970. err:
  971. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  972. return ret;
  973. }
  974. static int rtl2832u_get_rc_config(struct dvb_usb_device *d,
  975. struct dvb_usb_rc *rc)
  976. {
  977. rc->map_name = RC_MAP_EMPTY;
  978. rc->allowed_protos = RC_TYPE_NEC;
  979. rc->query = rtl2832u_rc_query;
  980. rc->interval = 400;
  981. return 0;
  982. }
  983. static const struct dvb_usb_device_properties rtl2831u_props = {
  984. .driver_name = KBUILD_MODNAME,
  985. .owner = THIS_MODULE,
  986. .adapter_nr = adapter_nr,
  987. .size_of_priv = sizeof(struct rtl28xxu_priv),
  988. .power_ctrl = rtl2831u_power_ctrl,
  989. .i2c_algo = &rtl28xxu_i2c_algo,
  990. .frontend_attach = rtl2831u_frontend_attach,
  991. .tuner_attach = rtl2831u_tuner_attach,
  992. .init = rtl28xxu_init,
  993. .get_rc_config = rtl2831u_get_rc_config,
  994. .streaming_ctrl = rtl28xxu_streaming_ctrl,
  995. .num_adapters = 1,
  996. .adapter = {
  997. {
  998. .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512),
  999. },
  1000. },
  1001. };
  1002. static const struct dvb_usb_device_properties rtl2832u_props = {
  1003. .driver_name = KBUILD_MODNAME,
  1004. .owner = THIS_MODULE,
  1005. .adapter_nr = adapter_nr,
  1006. .size_of_priv = sizeof(struct rtl28xxu_priv),
  1007. .power_ctrl = rtl2832u_power_ctrl,
  1008. .i2c_algo = &rtl28xxu_i2c_algo,
  1009. .frontend_attach = rtl2832u_frontend_attach,
  1010. .tuner_attach = rtl2832u_tuner_attach,
  1011. .init = rtl28xxu_init,
  1012. .get_rc_config = rtl2832u_get_rc_config,
  1013. .streaming_ctrl = rtl28xxu_streaming_ctrl,
  1014. .num_adapters = 1,
  1015. .adapter = {
  1016. {
  1017. .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512),
  1018. },
  1019. },
  1020. };
  1021. static const struct usb_device_id rtl28xxu_id_table[] = {
  1022. { DVB_USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U,
  1023. &rtl2831u_props, "Realtek RTL2831U reference design", NULL) },
  1024. { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT,
  1025. &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) },
  1026. { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2,
  1027. &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) },
  1028. { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1,
  1029. &rtl2832u_props, "Terratec Cinergy T Stick Black", NULL) },
  1030. { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT,
  1031. &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) },
  1032. { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK,
  1033. &rtl2832u_props, "NOXON DAB/DAB+ USB dongle", NULL) },
  1034. { }
  1035. };
  1036. MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
  1037. static struct usb_driver rtl28xxu_usb_driver = {
  1038. .name = KBUILD_MODNAME,
  1039. .id_table = rtl28xxu_id_table,
  1040. .probe = dvb_usbv2_probe,
  1041. .disconnect = dvb_usbv2_disconnect,
  1042. .suspend = dvb_usbv2_suspend,
  1043. .resume = dvb_usbv2_resume,
  1044. .reset_resume = dvb_usbv2_reset_resume,
  1045. .no_dynamic_id = 1,
  1046. .soft_unbind = 1,
  1047. };
  1048. module_usb_driver(rtl28xxu_usb_driver);
  1049. MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver");
  1050. MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
  1051. MODULE_AUTHOR("Thomas Mair <thomas.mair86@googlemail.com>");
  1052. MODULE_LICENSE("GPL");