rtl28xxu.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  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. dvb_usb_dbg_usb_control_msg(d->udev, 0, requesttype, req->value,
  55. req->index, buf, req->size);
  56. if (ret > 0)
  57. ret = 0;
  58. /* read request, copy returned data to return buf */
  59. if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN))
  60. memcpy(req->data, buf, req->size);
  61. kfree(buf);
  62. if (ret)
  63. goto err;
  64. return ret;
  65. err:
  66. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  67. return ret;
  68. }
  69. static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len)
  70. {
  71. struct rtl28xxu_req req;
  72. if (reg < 0x3000)
  73. req.index = CMD_USB_WR;
  74. else if (reg < 0x4000)
  75. req.index = CMD_SYS_WR;
  76. else
  77. req.index = CMD_IR_WR;
  78. req.value = reg;
  79. req.size = len;
  80. req.data = val;
  81. return rtl28xxu_ctrl_msg(d, &req);
  82. }
  83. static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len)
  84. {
  85. struct rtl28xxu_req req;
  86. if (reg < 0x3000)
  87. req.index = CMD_USB_RD;
  88. else if (reg < 0x4000)
  89. req.index = CMD_SYS_RD;
  90. else
  91. req.index = CMD_IR_RD;
  92. req.value = reg;
  93. req.size = len;
  94. req.data = val;
  95. return rtl28xxu_ctrl_msg(d, &req);
  96. }
  97. static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val)
  98. {
  99. return rtl28xx_wr_regs(d, reg, &val, 1);
  100. }
  101. static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val)
  102. {
  103. return rtl2831_rd_regs(d, reg, val, 1);
  104. }
  105. /* I2C */
  106. static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  107. int num)
  108. {
  109. int ret;
  110. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  111. struct rtl28xxu_priv *priv = d->priv;
  112. struct rtl28xxu_req req;
  113. /*
  114. * It is not known which are real I2C bus xfer limits, but testing
  115. * with RTL2831U + MT2060 gives max RD 24 and max WR 22 bytes.
  116. * TODO: find out RTL2832U lens
  117. */
  118. /*
  119. * I2C adapter logic looks rather complicated due to fact it handles
  120. * three different access methods. Those methods are;
  121. * 1) integrated demod access
  122. * 2) old I2C access
  123. * 3) new I2C access
  124. *
  125. * Used method is selected in order 1, 2, 3. Method 3 can handle all
  126. * requests but there is two reasons why not use it always;
  127. * 1) It is most expensive, usually two USB messages are needed
  128. * 2) At least RTL2831U does not support it
  129. *
  130. * Method 3 is needed in case of I2C write+read (typical register read)
  131. * where write is more than one byte.
  132. */
  133. if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
  134. return -EAGAIN;
  135. if (num == 2 && !(msg[0].flags & I2C_M_RD) &&
  136. (msg[1].flags & I2C_M_RD)) {
  137. if (msg[0].len > 24 || msg[1].len > 24) {
  138. /* TODO: check msg[0].len max */
  139. ret = -EOPNOTSUPP;
  140. goto err_mutex_unlock;
  141. } else if (msg[0].addr == 0x10) {
  142. /* method 1 - integrated demod */
  143. req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
  144. req.index = CMD_DEMOD_RD | priv->page;
  145. req.size = msg[1].len;
  146. req.data = &msg[1].buf[0];
  147. ret = rtl28xxu_ctrl_msg(d, &req);
  148. } else if (msg[0].len < 2) {
  149. /* method 2 - old I2C */
  150. req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
  151. req.index = CMD_I2C_RD;
  152. req.size = msg[1].len;
  153. req.data = &msg[1].buf[0];
  154. ret = rtl28xxu_ctrl_msg(d, &req);
  155. } else {
  156. /* method 3 - new I2C */
  157. req.value = (msg[0].addr << 1);
  158. req.index = CMD_I2C_DA_WR;
  159. req.size = msg[0].len;
  160. req.data = msg[0].buf;
  161. ret = rtl28xxu_ctrl_msg(d, &req);
  162. if (ret)
  163. goto err_mutex_unlock;
  164. req.value = (msg[0].addr << 1);
  165. req.index = CMD_I2C_DA_RD;
  166. req.size = msg[1].len;
  167. req.data = msg[1].buf;
  168. ret = rtl28xxu_ctrl_msg(d, &req);
  169. }
  170. } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) {
  171. if (msg[0].len > 22) {
  172. /* TODO: check msg[0].len max */
  173. ret = -EOPNOTSUPP;
  174. goto err_mutex_unlock;
  175. } else if (msg[0].addr == 0x10) {
  176. /* method 1 - integrated demod */
  177. if (msg[0].buf[0] == 0x00) {
  178. /* save demod page for later demod access */
  179. priv->page = msg[0].buf[1];
  180. ret = 0;
  181. } else {
  182. req.value = (msg[0].buf[0] << 8) |
  183. (msg[0].addr << 1);
  184. req.index = CMD_DEMOD_WR | priv->page;
  185. req.size = msg[0].len-1;
  186. req.data = &msg[0].buf[1];
  187. ret = rtl28xxu_ctrl_msg(d, &req);
  188. }
  189. } else if (msg[0].len < 23) {
  190. /* method 2 - old I2C */
  191. req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1);
  192. req.index = CMD_I2C_WR;
  193. req.size = msg[0].len-1;
  194. req.data = &msg[0].buf[1];
  195. ret = rtl28xxu_ctrl_msg(d, &req);
  196. } else {
  197. /* method 3 - new I2C */
  198. req.value = (msg[0].addr << 1);
  199. req.index = CMD_I2C_DA_WR;
  200. req.size = msg[0].len;
  201. req.data = msg[0].buf;
  202. ret = rtl28xxu_ctrl_msg(d, &req);
  203. }
  204. } else {
  205. ret = -EINVAL;
  206. }
  207. err_mutex_unlock:
  208. mutex_unlock(&d->i2c_mutex);
  209. return ret ? ret : num;
  210. }
  211. static u32 rtl28xxu_i2c_func(struct i2c_adapter *adapter)
  212. {
  213. return I2C_FUNC_I2C;
  214. }
  215. static struct i2c_algorithm rtl28xxu_i2c_algo = {
  216. .master_xfer = rtl28xxu_i2c_xfer,
  217. .functionality = rtl28xxu_i2c_func,
  218. };
  219. static struct rtl2830_config rtl28xxu_rtl2830_mt2060_config = {
  220. .i2c_addr = 0x10, /* 0x20 */
  221. .xtal = 28800000,
  222. .ts_mode = 0,
  223. .spec_inv = 1,
  224. .if_dvbt = 36150000,
  225. .vtop = 0x20,
  226. .krf = 0x04,
  227. .agc_targ_val = 0x2d,
  228. };
  229. static struct rtl2830_config rtl28xxu_rtl2830_qt1010_config = {
  230. .i2c_addr = 0x10, /* 0x20 */
  231. .xtal = 28800000,
  232. .ts_mode = 0,
  233. .spec_inv = 1,
  234. .if_dvbt = 36125000,
  235. .vtop = 0x20,
  236. .krf = 0x04,
  237. .agc_targ_val = 0x2d,
  238. };
  239. static struct rtl2830_config rtl28xxu_rtl2830_mxl5005s_config = {
  240. .i2c_addr = 0x10, /* 0x20 */
  241. .xtal = 28800000,
  242. .ts_mode = 0,
  243. .spec_inv = 0,
  244. .if_dvbt = 4570000,
  245. .vtop = 0x3f,
  246. .krf = 0x04,
  247. .agc_targ_val = 0x3e,
  248. };
  249. static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap)
  250. {
  251. int ret;
  252. struct dvb_usb_device *d = adap_to_d(adap);
  253. struct rtl28xxu_priv *priv = d_to_priv(d);
  254. u8 buf[1];
  255. struct rtl2830_config *rtl2830_config;
  256. /* open RTL2831U/RTL2830 I2C gate */
  257. struct rtl28xxu_req req_gate = { 0x0120, 0x0011, 0x0001, "\x08" };
  258. /* for MT2060 tuner probe */
  259. struct rtl28xxu_req req_mt2060 = { 0x00c0, CMD_I2C_RD, 1, buf };
  260. /* for QT1010 tuner probe */
  261. struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf };
  262. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  263. /*
  264. * RTL2831U GPIOs
  265. * =========================================================
  266. * GPIO0 | tuner#0 | 0 off | 1 on | MXL5005S (?)
  267. * GPIO2 | LED | 0 off | 1 on |
  268. * GPIO4 | tuner#1 | 0 on | 1 off | MT2060
  269. */
  270. /* GPIO direction */
  271. ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, 0x0a);
  272. if (ret)
  273. goto err;
  274. /* enable as output GPIO0, GPIO2, GPIO4 */
  275. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, 0x15);
  276. if (ret)
  277. goto err;
  278. /*
  279. * Probe used tuner. We need to know used tuner before demod attach
  280. * since there is some demod params needed to set according to tuner.
  281. */
  282. /* demod needs some time to wake up */
  283. msleep(20);
  284. /* open demod I2C gate */
  285. ret = rtl28xxu_ctrl_msg(d, &req_gate);
  286. if (ret)
  287. goto err;
  288. /* check QT1010 ID(?) register; reg=0f val=2c */
  289. ret = rtl28xxu_ctrl_msg(d, &req_qt1010);
  290. if (ret == 0 && buf[0] == 0x2c) {
  291. priv->tuner = TUNER_RTL2830_QT1010;
  292. rtl2830_config = &rtl28xxu_rtl2830_qt1010_config;
  293. dev_dbg(&d->udev->dev, "%s: QT1010\n", __func__);
  294. goto found;
  295. } else {
  296. dev_dbg(&d->udev->dev, "%s: QT1010 probe failed=%d - %02x\n",
  297. __func__, ret, buf[0]);
  298. }
  299. /* open demod I2C gate */
  300. ret = rtl28xxu_ctrl_msg(d, &req_gate);
  301. if (ret)
  302. goto err;
  303. /* check MT2060 ID register; reg=00 val=63 */
  304. ret = rtl28xxu_ctrl_msg(d, &req_mt2060);
  305. if (ret == 0 && buf[0] == 0x63) {
  306. priv->tuner = TUNER_RTL2830_MT2060;
  307. rtl2830_config = &rtl28xxu_rtl2830_mt2060_config;
  308. dev_dbg(&d->udev->dev, "%s: MT2060\n", __func__);
  309. goto found;
  310. } else {
  311. dev_dbg(&d->udev->dev, "%s: MT2060 probe failed=%d - %02x\n",
  312. __func__, ret, buf[0]);
  313. }
  314. /* assume MXL5005S */
  315. ret = 0;
  316. priv->tuner = TUNER_RTL2830_MXL5005S;
  317. rtl2830_config = &rtl28xxu_rtl2830_mxl5005s_config;
  318. dev_dbg(&d->udev->dev, "%s: MXL5005S\n", __func__);
  319. goto found;
  320. found:
  321. /* attach demodulator */
  322. adap->fe[0] = dvb_attach(rtl2830_attach, rtl2830_config,
  323. &d->i2c_adap);
  324. if (adap->fe[0] == NULL) {
  325. ret = -ENODEV;
  326. goto err;
  327. }
  328. return ret;
  329. err:
  330. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  331. return ret;
  332. }
  333. static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = {
  334. .i2c_addr = 0x10, /* 0x20 */
  335. .xtal = 28800000,
  336. .if_dvbt = 0,
  337. .tuner = TUNER_RTL2832_FC0012
  338. };
  339. static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = {
  340. .i2c_addr = 0x10, /* 0x20 */
  341. .xtal = 28800000,
  342. .if_dvbt = 0,
  343. .tuner = TUNER_RTL2832_FC0013
  344. };
  345. static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d,
  346. int cmd, int arg)
  347. {
  348. int ret;
  349. u8 val;
  350. dev_dbg(&d->udev->dev, "%s: cmd=%d arg=%d\n", __func__, cmd, arg);
  351. switch (cmd) {
  352. case FC_FE_CALLBACK_VHF_ENABLE:
  353. /* set output values */
  354. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
  355. if (ret)
  356. goto err;
  357. if (arg)
  358. val &= 0xbf; /* set GPIO6 low */
  359. else
  360. val |= 0x40; /* set GPIO6 high */
  361. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
  362. if (ret)
  363. goto err;
  364. break;
  365. default:
  366. ret = -EINVAL;
  367. goto err;
  368. }
  369. return 0;
  370. err:
  371. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  372. return ret;
  373. }
  374. static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d,
  375. int cmd, int arg)
  376. {
  377. /* TODO implement*/
  378. return 0;
  379. }
  380. static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg)
  381. {
  382. struct rtl28xxu_priv *priv = d->priv;
  383. switch (priv->tuner) {
  384. case TUNER_RTL2832_FC0012:
  385. return rtl2832u_fc0012_tuner_callback(d, cmd, arg);
  386. case TUNER_RTL2832_FC0013:
  387. return rtl2832u_fc0013_tuner_callback(d, cmd, arg);
  388. default:
  389. break;
  390. }
  391. return -ENODEV;
  392. }
  393. static int rtl2832u_frontend_callback(void *adapter_priv, int component,
  394. int cmd, int arg)
  395. {
  396. struct i2c_adapter *adap = adapter_priv;
  397. struct dvb_usb_device *d = i2c_get_adapdata(adap);
  398. switch (component) {
  399. case DVB_FRONTEND_COMPONENT_TUNER:
  400. return rtl2832u_tuner_callback(d, cmd, arg);
  401. default:
  402. break;
  403. }
  404. return -EINVAL;
  405. }
  406. static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
  407. {
  408. int ret;
  409. struct dvb_usb_device *d = adap_to_d(adap);
  410. struct rtl28xxu_priv *priv = d_to_priv(d);
  411. struct rtl2832_config *rtl2832_config;
  412. u8 buf[2], val;
  413. /* open RTL2832U/RTL2832 I2C gate */
  414. struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"};
  415. /* close RTL2832U/RTL2832 I2C gate */
  416. struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"};
  417. /* for FC0012 tuner probe */
  418. struct rtl28xxu_req req_fc0012 = {0x00c6, CMD_I2C_RD, 1, buf};
  419. /* for FC0013 tuner probe */
  420. struct rtl28xxu_req req_fc0013 = {0x00c6, CMD_I2C_RD, 1, buf};
  421. /* for MT2266 tuner probe */
  422. struct rtl28xxu_req req_mt2266 = {0x00c0, CMD_I2C_RD, 1, buf};
  423. /* for FC2580 tuner probe */
  424. struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf};
  425. /* for MT2063 tuner probe */
  426. struct rtl28xxu_req req_mt2063 = {0x00c0, CMD_I2C_RD, 1, buf};
  427. /* for MAX3543 tuner probe */
  428. struct rtl28xxu_req req_max3543 = {0x00c0, CMD_I2C_RD, 1, buf};
  429. /* for TUA9001 tuner probe */
  430. struct rtl28xxu_req req_tua9001 = {0x7ec0, CMD_I2C_RD, 2, buf};
  431. /* for MXL5007T tuner probe */
  432. struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf};
  433. /* for E4000 tuner probe */
  434. struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf};
  435. /* for TDA18272 tuner probe */
  436. struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf};
  437. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  438. ret = rtl28xx_rd_reg(d, SYS_GPIO_DIR, &val);
  439. if (ret)
  440. goto err;
  441. val &= 0xbf;
  442. ret = rtl28xx_wr_reg(d, SYS_GPIO_DIR, val);
  443. if (ret)
  444. goto err;
  445. /* enable as output GPIO3 and GPIO6*/
  446. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_EN, &val);
  447. if (ret)
  448. goto err;
  449. val |= 0x48;
  450. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_EN, val);
  451. if (ret)
  452. goto err;
  453. /*
  454. * Probe used tuner. We need to know used tuner before demod attach
  455. * since there is some demod params needed to set according to tuner.
  456. */
  457. /* open demod I2C gate */
  458. ret = rtl28xxu_ctrl_msg(d, &req_gate_open);
  459. if (ret)
  460. goto err;
  461. priv->tuner = TUNER_NONE;
  462. /* check FC0012 ID register; reg=00 val=a1 */
  463. ret = rtl28xxu_ctrl_msg(d, &req_fc0012);
  464. if (ret == 0 && buf[0] == 0xa1) {
  465. priv->tuner = TUNER_RTL2832_FC0012;
  466. rtl2832_config = &rtl28xxu_rtl2832_fc0012_config;
  467. dev_info(&d->udev->dev, "%s: FC0012 tuner found",
  468. KBUILD_MODNAME);
  469. goto found;
  470. }
  471. /* check FC0013 ID register; reg=00 val=a3 */
  472. ret = rtl28xxu_ctrl_msg(d, &req_fc0013);
  473. if (ret == 0 && buf[0] == 0xa3) {
  474. priv->tuner = TUNER_RTL2832_FC0013;
  475. rtl2832_config = &rtl28xxu_rtl2832_fc0013_config;
  476. dev_info(&d->udev->dev, "%s: FC0013 tuner found",
  477. KBUILD_MODNAME);
  478. goto found;
  479. }
  480. /* check MT2266 ID register; reg=00 val=85 */
  481. ret = rtl28xxu_ctrl_msg(d, &req_mt2266);
  482. if (ret == 0 && buf[0] == 0x85) {
  483. priv->tuner = TUNER_RTL2832_MT2266;
  484. /* TODO implement tuner */
  485. dev_info(&d->udev->dev, "%s: MT2266 tuner found",
  486. KBUILD_MODNAME);
  487. goto unsupported;
  488. }
  489. /* check FC2580 ID register; reg=01 val=56 */
  490. ret = rtl28xxu_ctrl_msg(d, &req_fc2580);
  491. if (ret == 0 && buf[0] == 0x56) {
  492. priv->tuner = TUNER_RTL2832_FC2580;
  493. /* TODO implement tuner */
  494. dev_info(&d->udev->dev, "%s: FC2580 tuner found",
  495. KBUILD_MODNAME);
  496. goto unsupported;
  497. }
  498. /* check MT2063 ID register; reg=00 val=9e || 9c */
  499. ret = rtl28xxu_ctrl_msg(d, &req_mt2063);
  500. if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) {
  501. priv->tuner = TUNER_RTL2832_MT2063;
  502. /* TODO implement tuner */
  503. dev_info(&d->udev->dev, "%s: MT2063 tuner found",
  504. KBUILD_MODNAME);
  505. goto unsupported;
  506. }
  507. /* check MAX3543 ID register; reg=00 val=38 */
  508. ret = rtl28xxu_ctrl_msg(d, &req_max3543);
  509. if (ret == 0 && buf[0] == 0x38) {
  510. priv->tuner = TUNER_RTL2832_MAX3543;
  511. /* TODO implement tuner */
  512. dev_info(&d->udev->dev, "%s: MAX3534 tuner found",
  513. KBUILD_MODNAME);
  514. goto unsupported;
  515. }
  516. /* check TUA9001 ID register; reg=7e val=2328 */
  517. ret = rtl28xxu_ctrl_msg(d, &req_tua9001);
  518. if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) {
  519. priv->tuner = TUNER_RTL2832_TUA9001;
  520. /* TODO implement tuner */
  521. dev_info(&d->udev->dev, "%s: TUA9001 tuner found",
  522. KBUILD_MODNAME);
  523. goto unsupported;
  524. }
  525. /* check MXL5007R ID register; reg=d9 val=14 */
  526. ret = rtl28xxu_ctrl_msg(d, &req_mxl5007t);
  527. if (ret == 0 && buf[0] == 0x14) {
  528. priv->tuner = TUNER_RTL2832_MXL5007T;
  529. /* TODO implement tuner */
  530. dev_info(&d->udev->dev, "%s: MXL5007T tuner found",
  531. KBUILD_MODNAME);
  532. goto unsupported;
  533. }
  534. /* check E4000 ID register; reg=02 val=40 */
  535. ret = rtl28xxu_ctrl_msg(d, &req_e4000);
  536. if (ret == 0 && buf[0] == 0x40) {
  537. priv->tuner = TUNER_RTL2832_E4000;
  538. /* TODO implement tuner */
  539. dev_info(&d->udev->dev, "%s: E4000 tuner found",
  540. KBUILD_MODNAME);
  541. goto unsupported;
  542. }
  543. /* check TDA18272 ID register; reg=00 val=c760 */
  544. ret = rtl28xxu_ctrl_msg(d, &req_tda18272);
  545. if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) {
  546. priv->tuner = TUNER_RTL2832_TDA18272;
  547. /* TODO implement tuner */
  548. dev_info(&d->udev->dev, "%s: TDA18272 tuner found",
  549. KBUILD_MODNAME);
  550. goto unsupported;
  551. }
  552. unsupported:
  553. /* close demod I2C gate */
  554. ret = rtl28xxu_ctrl_msg(d, &req_gate_close);
  555. if (ret)
  556. goto err;
  557. /* tuner not found */
  558. dev_dbg(&d->udev->dev, "%s: No compatible tuner found\n", __func__);
  559. ret = -ENODEV;
  560. return ret;
  561. found:
  562. /* close demod I2C gate */
  563. ret = rtl28xxu_ctrl_msg(d, &req_gate_close);
  564. if (ret)
  565. goto err;
  566. /* attach demodulator */
  567. adap->fe[0] = dvb_attach(rtl2832_attach, rtl2832_config,
  568. &d->i2c_adap);
  569. if (adap->fe[0] == NULL) {
  570. ret = -ENODEV;
  571. goto err;
  572. }
  573. /* set fe callbacks */
  574. adap->fe[0]->callback = rtl2832u_frontend_callback;
  575. return ret;
  576. err:
  577. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  578. return ret;
  579. }
  580. static struct qt1010_config rtl28xxu_qt1010_config = {
  581. .i2c_address = 0x62, /* 0xc4 */
  582. };
  583. static struct mt2060_config rtl28xxu_mt2060_config = {
  584. .i2c_address = 0x60, /* 0xc0 */
  585. .clock_out = 0,
  586. };
  587. static struct mxl5005s_config rtl28xxu_mxl5005s_config = {
  588. .i2c_address = 0x63, /* 0xc6 */
  589. .if_freq = IF_FREQ_4570000HZ,
  590. .xtal_freq = CRYSTAL_FREQ_16000000HZ,
  591. .agc_mode = MXL_SINGLE_AGC,
  592. .tracking_filter = MXL_TF_C_H,
  593. .rssi_enable = MXL_RSSI_ENABLE,
  594. .cap_select = MXL_CAP_SEL_ENABLE,
  595. .div_out = MXL_DIV_OUT_4,
  596. .clock_out = MXL_CLOCK_OUT_DISABLE,
  597. .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
  598. .top = MXL5005S_TOP_25P2,
  599. .mod_mode = MXL_DIGITAL_MODE,
  600. .if_mode = MXL_ZERO_IF,
  601. .AgcMasterByte = 0x00,
  602. };
  603. static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap)
  604. {
  605. int ret;
  606. struct dvb_usb_device *d = adap_to_d(adap);
  607. struct rtl28xxu_priv *priv = d_to_priv(d);
  608. struct i2c_adapter *rtl2830_tuner_i2c;
  609. struct dvb_frontend *fe;
  610. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  611. /* use rtl2830 driver I2C adapter, for more info see rtl2830 driver */
  612. rtl2830_tuner_i2c = rtl2830_get_tuner_i2c_adapter(adap->fe[0]);
  613. switch (priv->tuner) {
  614. case TUNER_RTL2830_QT1010:
  615. fe = dvb_attach(qt1010_attach, adap->fe[0],
  616. rtl2830_tuner_i2c, &rtl28xxu_qt1010_config);
  617. break;
  618. case TUNER_RTL2830_MT2060:
  619. fe = dvb_attach(mt2060_attach, adap->fe[0],
  620. rtl2830_tuner_i2c, &rtl28xxu_mt2060_config,
  621. 1220);
  622. break;
  623. case TUNER_RTL2830_MXL5005S:
  624. fe = dvb_attach(mxl5005s_attach, adap->fe[0],
  625. rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config);
  626. break;
  627. default:
  628. fe = NULL;
  629. dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
  630. priv->tuner);
  631. }
  632. if (fe == NULL) {
  633. ret = -ENODEV;
  634. goto err;
  635. }
  636. return 0;
  637. err:
  638. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  639. return ret;
  640. }
  641. static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
  642. {
  643. int ret;
  644. struct dvb_usb_device *d = adap_to_d(adap);
  645. struct rtl28xxu_priv *priv = d_to_priv(d);
  646. struct dvb_frontend *fe;
  647. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  648. switch (priv->tuner) {
  649. case TUNER_RTL2832_FC0012:
  650. fe = dvb_attach(fc0012_attach, adap->fe[0],
  651. &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ);
  652. /* since fc0012 includs reading the signal strength delegate
  653. * that to the tuner driver */
  654. adap->fe[0]->ops.read_signal_strength =
  655. adap->fe[0]->ops.tuner_ops.get_rf_strength;
  656. return 0;
  657. break;
  658. case TUNER_RTL2832_FC0013:
  659. fe = dvb_attach(fc0013_attach, adap->fe[0],
  660. &d->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ);
  661. /* fc0013 also supports signal strength reading */
  662. adap->fe[0]->ops.read_signal_strength =
  663. adap->fe[0]->ops.tuner_ops.get_rf_strength;
  664. return 0;
  665. default:
  666. fe = NULL;
  667. dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
  668. priv->tuner);
  669. }
  670. if (fe == NULL) {
  671. ret = -ENODEV;
  672. goto err;
  673. }
  674. return 0;
  675. err:
  676. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  677. return ret;
  678. }
  679. static int rtl28xxu_init(struct dvb_usb_device *d)
  680. {
  681. int ret;
  682. u8 val;
  683. dev_dbg(&d->udev->dev, "%s:\n", __func__);
  684. /* init USB endpoints */
  685. ret = rtl28xx_rd_reg(d, USB_SYSCTL_0, &val);
  686. if (ret)
  687. goto err;
  688. /* enable DMA and Full Packet Mode*/
  689. val |= 0x09;
  690. ret = rtl28xx_wr_reg(d, USB_SYSCTL_0, val);
  691. if (ret)
  692. goto err;
  693. /* set EPA maximum packet size to 0x0200 */
  694. ret = rtl28xx_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4);
  695. if (ret)
  696. goto err;
  697. /* change EPA FIFO length */
  698. ret = rtl28xx_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4);
  699. if (ret)
  700. goto err;
  701. return ret;
  702. err:
  703. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  704. return ret;
  705. }
  706. static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff)
  707. {
  708. int ret;
  709. u8 gpio, sys0, epa_ctl[2];
  710. dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
  711. /* demod adc */
  712. ret = rtl28xx_rd_reg(d, SYS_SYS0, &sys0);
  713. if (ret)
  714. goto err;
  715. /* tuner power, read GPIOs */
  716. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio);
  717. if (ret)
  718. goto err;
  719. dev_dbg(&d->udev->dev, "%s: RD SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__,
  720. sys0, gpio);
  721. if (onoff) {
  722. gpio |= 0x01; /* GPIO0 = 1 */
  723. gpio &= (~0x10); /* GPIO4 = 0 */
  724. gpio |= 0x04; /* GPIO2 = 1, LED on */
  725. sys0 = sys0 & 0x0f;
  726. sys0 |= 0xe0;
  727. epa_ctl[0] = 0x00; /* clear stall */
  728. epa_ctl[1] = 0x00; /* clear reset */
  729. } else {
  730. gpio &= (~0x01); /* GPIO0 = 0 */
  731. gpio |= 0x10; /* GPIO4 = 1 */
  732. gpio &= (~0x04); /* GPIO2 = 1, LED off */
  733. sys0 = sys0 & (~0xc0);
  734. epa_ctl[0] = 0x10; /* set stall */
  735. epa_ctl[1] = 0x02; /* set reset */
  736. }
  737. dev_dbg(&d->udev->dev, "%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__,
  738. sys0, gpio);
  739. /* demod adc */
  740. ret = rtl28xx_wr_reg(d, SYS_SYS0, sys0);
  741. if (ret)
  742. goto err;
  743. /* tuner power, write GPIOs */
  744. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, gpio);
  745. if (ret)
  746. goto err;
  747. /* streaming EP: stall & reset */
  748. ret = rtl28xx_wr_regs(d, USB_EPA_CTL, epa_ctl, 2);
  749. if (ret)
  750. goto err;
  751. if (onoff)
  752. usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81));
  753. return ret;
  754. err:
  755. dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
  756. return ret;
  757. }
  758. static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff)
  759. {
  760. int ret;
  761. u8 val;
  762. dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
  763. if (onoff) {
  764. /* set output values */
  765. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
  766. if (ret)
  767. goto err;
  768. val |= 0x08;
  769. val &= 0xef;
  770. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
  771. if (ret)
  772. goto err;
  773. /* demod_ctl_1 */
  774. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val);
  775. if (ret)
  776. goto err;
  777. val &= 0xef;
  778. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val);
  779. if (ret)
  780. goto err;
  781. /* demod control */
  782. /* PLL enable */
  783. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
  784. if (ret)
  785. goto err;
  786. /* bit 7 to 1 */
  787. val |= 0x80;
  788. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
  789. if (ret)
  790. goto err;
  791. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
  792. if (ret)
  793. goto err;
  794. val |= 0x20;
  795. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
  796. if (ret)
  797. goto err;
  798. mdelay(5);
  799. /*enable ADC_Q and ADC_I */
  800. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
  801. if (ret)
  802. goto err;
  803. val |= 0x48;
  804. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
  805. if (ret)
  806. goto err;
  807. /* streaming EP: clear stall & reset */
  808. ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x00\x00", 2);
  809. if (ret)
  810. goto err;
  811. ret = usb_clear_halt(d->udev, usb_rcvbulkpipe(d->udev, 0x81));
  812. if (ret)
  813. goto err;
  814. } else {
  815. /* demod_ctl_1 */
  816. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val);
  817. if (ret)
  818. goto err;
  819. val |= 0x0c;
  820. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val);
  821. if (ret)
  822. goto err;
  823. /* set output values */
  824. ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val);
  825. if (ret)
  826. goto err;
  827. val |= 0x10;
  828. ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
  829. if (ret)
  830. goto err;
  831. /* demod control */
  832. ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
  833. if (ret)
  834. goto err;
  835. val &= 0x37;
  836. ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
  837. if (ret)
  838. goto err;
  839. /* streaming EP: set stall & reset */
  840. ret = rtl28xx_wr_regs(d, USB_EPA_CTL, "\x10\x02", 2);
  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. .num_adapters = 1,
  995. .adapter = {
  996. {
  997. .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512),
  998. },
  999. },
  1000. };
  1001. static const struct dvb_usb_device_properties rtl2832u_props = {
  1002. .driver_name = KBUILD_MODNAME,
  1003. .owner = THIS_MODULE,
  1004. .adapter_nr = adapter_nr,
  1005. .size_of_priv = sizeof(struct rtl28xxu_priv),
  1006. .power_ctrl = rtl2832u_power_ctrl,
  1007. .i2c_algo = &rtl28xxu_i2c_algo,
  1008. .frontend_attach = rtl2832u_frontend_attach,
  1009. .tuner_attach = rtl2832u_tuner_attach,
  1010. .init = rtl28xxu_init,
  1011. .get_rc_config = rtl2832u_get_rc_config,
  1012. .num_adapters = 1,
  1013. .adapter = {
  1014. {
  1015. .stream = DVB_USB_STREAM_BULK(0x81, 6, 8 * 512),
  1016. },
  1017. },
  1018. };
  1019. static const struct usb_device_id rtl28xxu_id_table[] = {
  1020. { DVB_USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U,
  1021. &rtl2831u_props, "Realtek RTL2831U reference design", NULL) },
  1022. { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT,
  1023. &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) },
  1024. { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2,
  1025. &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) },
  1026. { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1,
  1027. &rtl2832u_props, "Terratec Cinergy T Stick Black", NULL) },
  1028. { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT,
  1029. &rtl2832u_props, "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", NULL) },
  1030. { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK,
  1031. &rtl2832u_props, "NOXON DAB/DAB+ USB dongle", NULL) },
  1032. { }
  1033. };
  1034. MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
  1035. static struct usb_driver rtl28xxu_usb_driver = {
  1036. .name = KBUILD_MODNAME,
  1037. .id_table = rtl28xxu_id_table,
  1038. .probe = dvb_usbv2_probe,
  1039. .disconnect = dvb_usbv2_disconnect,
  1040. .suspend = dvb_usbv2_suspend,
  1041. .resume = dvb_usbv2_resume,
  1042. .reset_resume = dvb_usbv2_reset_resume,
  1043. .no_dynamic_id = 1,
  1044. .soft_unbind = 1,
  1045. };
  1046. module_usb_driver(rtl28xxu_usb_driver);
  1047. MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver");
  1048. MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
  1049. MODULE_AUTHOR("Thomas Mair <thomas.mair86@googlemail.com>");
  1050. MODULE_LICENSE("GPL");