budget.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. /*
  2. * budget.c: driver for the SAA7146 based Budget DVB cards
  3. *
  4. * Compiled from various sources by Michael Hunold <michael@mihu.de>
  5. *
  6. * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
  7. *
  8. * Copyright (C) 1999-2002 Ralph Metzler
  9. * & Marcus Metzler for convergence integrated media GmbH
  10. *
  11. * 26feb2004 Support for FS Activy Card (Grundig tuner) by
  12. * Michael Dreher <michael@5dot1.de>,
  13. * Oliver Endriss <o.endriss@gmx.de> and
  14. * Andreas 'randy' Weinberger
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License
  18. * as published by the Free Software Foundation; either version 2
  19. * of the License, or (at your option) any later version.
  20. *
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * To obtain the license, point your browser to
  28. * http://www.gnu.org/copyleft/gpl.html
  29. *
  30. *
  31. * the project's page is at https://linuxtv.org
  32. */
  33. #include "budget.h"
  34. #include "stv0299.h"
  35. #include "ves1x93.h"
  36. #include "ves1820.h"
  37. #include "l64781.h"
  38. #include "tda8083.h"
  39. #include "s5h1420.h"
  40. #include "tda10086.h"
  41. #include "tda826x.h"
  42. #include "lnbp21.h"
  43. #include "bsru6.h"
  44. #include "bsbe1.h"
  45. #include "tdhd1.h"
  46. #include "stv6110x.h"
  47. #include "stv090x.h"
  48. #include "isl6423.h"
  49. #include "lnbh24.h"
  50. static int diseqc_method;
  51. module_param(diseqc_method, int, 0444);
  52. MODULE_PARM_DESC(diseqc_method, "Select DiSEqC method for subsystem id 13c2:1003, 0: default, 1: more reliable (for newer revisions only)");
  53. DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
  54. static void Set22K (struct budget *budget, int state)
  55. {
  56. struct saa7146_dev *dev=budget->dev;
  57. dprintk(2, "budget: %p\n", budget);
  58. saa7146_setgpio(dev, 3, (state ? SAA7146_GPIO_OUTHI : SAA7146_GPIO_OUTLO));
  59. }
  60. /* Diseqc functions only for TT Budget card */
  61. /* taken from the Skyvision DVB driver by
  62. Ralph Metzler <rjkm@metzlerbros.de> */
  63. static void DiseqcSendBit (struct budget *budget, int data)
  64. {
  65. struct saa7146_dev *dev=budget->dev;
  66. dprintk(2, "budget: %p\n", budget);
  67. saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
  68. udelay(data ? 500 : 1000);
  69. saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
  70. udelay(data ? 1000 : 500);
  71. }
  72. static void DiseqcSendByte (struct budget *budget, int data)
  73. {
  74. int i, par=1, d;
  75. dprintk(2, "budget: %p\n", budget);
  76. for (i=7; i>=0; i--) {
  77. d = (data>>i)&1;
  78. par ^= d;
  79. DiseqcSendBit(budget, d);
  80. }
  81. DiseqcSendBit(budget, par);
  82. }
  83. static int SendDiSEqCMsg (struct budget *budget, int len, u8 *msg, unsigned long burst)
  84. {
  85. struct saa7146_dev *dev=budget->dev;
  86. int i;
  87. dprintk(2, "budget: %p\n", budget);
  88. saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
  89. mdelay(16);
  90. for (i=0; i<len; i++)
  91. DiseqcSendByte(budget, msg[i]);
  92. mdelay(16);
  93. if (burst!=-1) {
  94. if (burst)
  95. DiseqcSendByte(budget, 0xff);
  96. else {
  97. saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
  98. mdelay(12);
  99. udelay(500);
  100. saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
  101. }
  102. msleep(20);
  103. }
  104. return 0;
  105. }
  106. /*
  107. * Routines for the Fujitsu Siemens Activy budget card
  108. * 22 kHz tone and DiSEqC are handled by the frontend.
  109. * Voltage must be set here.
  110. * GPIO 1: LNBP EN, GPIO 2: LNBP VSEL
  111. */
  112. static int SetVoltage_Activy(struct budget *budget,
  113. enum fe_sec_voltage voltage)
  114. {
  115. struct saa7146_dev *dev=budget->dev;
  116. dprintk(2, "budget: %p\n", budget);
  117. switch (voltage) {
  118. case SEC_VOLTAGE_13:
  119. saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI);
  120. saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTLO);
  121. break;
  122. case SEC_VOLTAGE_18:
  123. saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI);
  124. saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
  125. break;
  126. case SEC_VOLTAGE_OFF:
  127. saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTLO);
  128. break;
  129. default:
  130. return -EINVAL;
  131. }
  132. return 0;
  133. }
  134. static int siemens_budget_set_voltage(struct dvb_frontend *fe,
  135. enum fe_sec_voltage voltage)
  136. {
  137. struct budget* budget = (struct budget*) fe->dvb->priv;
  138. return SetVoltage_Activy (budget, voltage);
  139. }
  140. static int budget_set_tone(struct dvb_frontend *fe,
  141. enum fe_sec_tone_mode tone)
  142. {
  143. struct budget* budget = (struct budget*) fe->dvb->priv;
  144. switch (tone) {
  145. case SEC_TONE_ON:
  146. Set22K (budget, 1);
  147. break;
  148. case SEC_TONE_OFF:
  149. Set22K (budget, 0);
  150. break;
  151. default:
  152. return -EINVAL;
  153. }
  154. return 0;
  155. }
  156. static int budget_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
  157. {
  158. struct budget* budget = (struct budget*) fe->dvb->priv;
  159. SendDiSEqCMsg (budget, cmd->msg_len, cmd->msg, 0);
  160. return 0;
  161. }
  162. static int budget_diseqc_send_burst(struct dvb_frontend *fe,
  163. enum fe_sec_mini_cmd minicmd)
  164. {
  165. struct budget* budget = (struct budget*) fe->dvb->priv;
  166. SendDiSEqCMsg (budget, 0, NULL, minicmd);
  167. return 0;
  168. }
  169. static int alps_bsrv2_tuner_set_params(struct dvb_frontend *fe)
  170. {
  171. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  172. struct budget* budget = (struct budget*) fe->dvb->priv;
  173. u8 pwr = 0;
  174. u8 buf[4];
  175. struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
  176. u32 div = (c->frequency + 479500) / 125;
  177. if (c->frequency > 2000000)
  178. pwr = 3;
  179. else if (c->frequency > 1800000)
  180. pwr = 2;
  181. else if (c->frequency > 1600000)
  182. pwr = 1;
  183. else if (c->frequency > 1200000)
  184. pwr = 0;
  185. else if (c->frequency >= 1100000)
  186. pwr = 1;
  187. else pwr = 2;
  188. buf[0] = (div >> 8) & 0x7f;
  189. buf[1] = div & 0xff;
  190. buf[2] = ((div & 0x18000) >> 10) | 0x95;
  191. buf[3] = (pwr << 6) | 0x30;
  192. // NOTE: since we're using a prescaler of 2, we set the
  193. // divisor frequency to 62.5kHz and divide by 125 above
  194. if (fe->ops.i2c_gate_ctrl)
  195. fe->ops.i2c_gate_ctrl(fe, 1);
  196. if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
  197. return 0;
  198. }
  199. static struct ves1x93_config alps_bsrv2_config =
  200. {
  201. .demod_address = 0x08,
  202. .xin = 90100000UL,
  203. .invert_pwm = 0,
  204. };
  205. static int alps_tdbe2_tuner_set_params(struct dvb_frontend *fe)
  206. {
  207. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  208. struct budget* budget = (struct budget*) fe->dvb->priv;
  209. u32 div;
  210. u8 data[4];
  211. struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
  212. div = (c->frequency + 35937500 + 31250) / 62500;
  213. data[0] = (div >> 8) & 0x7f;
  214. data[1] = div & 0xff;
  215. data[2] = 0x85 | ((div >> 10) & 0x60);
  216. data[3] = (c->frequency < 174000000 ? 0x88 : c->frequency < 470000000 ? 0x84 : 0x81);
  217. if (fe->ops.i2c_gate_ctrl)
  218. fe->ops.i2c_gate_ctrl(fe, 1);
  219. if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
  220. return 0;
  221. }
  222. static struct ves1820_config alps_tdbe2_config = {
  223. .demod_address = 0x09,
  224. .xin = 57840000UL,
  225. .invert = 1,
  226. .selagc = VES1820_SELAGC_SIGNAMPERR,
  227. };
  228. static int grundig_29504_401_tuner_set_params(struct dvb_frontend *fe)
  229. {
  230. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  231. struct budget *budget = fe->dvb->priv;
  232. u8 *tuner_addr = fe->tuner_priv;
  233. u32 div;
  234. u8 cfg, cpump, band_select;
  235. u8 data[4];
  236. struct i2c_msg msg = { .flags = 0, .buf = data, .len = sizeof(data) };
  237. if (tuner_addr)
  238. msg.addr = *tuner_addr;
  239. else
  240. msg.addr = 0x61;
  241. div = (36125000 + c->frequency) / 166666;
  242. cfg = 0x88;
  243. if (c->frequency < 175000000)
  244. cpump = 2;
  245. else if (c->frequency < 390000000)
  246. cpump = 1;
  247. else if (c->frequency < 470000000)
  248. cpump = 2;
  249. else if (c->frequency < 750000000)
  250. cpump = 1;
  251. else
  252. cpump = 3;
  253. if (c->frequency < 175000000)
  254. band_select = 0x0e;
  255. else if (c->frequency < 470000000)
  256. band_select = 0x05;
  257. else
  258. band_select = 0x03;
  259. data[0] = (div >> 8) & 0x7f;
  260. data[1] = div & 0xff;
  261. data[2] = ((div >> 10) & 0x60) | cfg;
  262. data[3] = (cpump << 6) | band_select;
  263. if (fe->ops.i2c_gate_ctrl)
  264. fe->ops.i2c_gate_ctrl(fe, 1);
  265. if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
  266. return 0;
  267. }
  268. static struct l64781_config grundig_29504_401_config = {
  269. .demod_address = 0x55,
  270. };
  271. static struct l64781_config grundig_29504_401_config_activy = {
  272. .demod_address = 0x54,
  273. };
  274. static u8 tuner_address_grundig_29504_401_activy = 0x60;
  275. static int grundig_29504_451_tuner_set_params(struct dvb_frontend *fe)
  276. {
  277. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  278. struct budget* budget = (struct budget*) fe->dvb->priv;
  279. u32 div;
  280. u8 data[4];
  281. struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
  282. div = c->frequency / 125;
  283. data[0] = (div >> 8) & 0x7f;
  284. data[1] = div & 0xff;
  285. data[2] = 0x8e;
  286. data[3] = 0x00;
  287. if (fe->ops.i2c_gate_ctrl)
  288. fe->ops.i2c_gate_ctrl(fe, 1);
  289. if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
  290. return 0;
  291. }
  292. static struct tda8083_config grundig_29504_451_config = {
  293. .demod_address = 0x68,
  294. };
  295. static int s5h1420_tuner_set_params(struct dvb_frontend *fe)
  296. {
  297. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  298. struct budget* budget = (struct budget*) fe->dvb->priv;
  299. u32 div;
  300. u8 data[4];
  301. struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
  302. div = c->frequency / 1000;
  303. data[0] = (div >> 8) & 0x7f;
  304. data[1] = div & 0xff;
  305. data[2] = 0xc2;
  306. if (div < 1450)
  307. data[3] = 0x00;
  308. else if (div < 1850)
  309. data[3] = 0x40;
  310. else if (div < 2000)
  311. data[3] = 0x80;
  312. else
  313. data[3] = 0xc0;
  314. if (fe->ops.i2c_gate_ctrl)
  315. fe->ops.i2c_gate_ctrl(fe, 1);
  316. if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
  317. return 0;
  318. }
  319. static struct s5h1420_config s5h1420_config = {
  320. .demod_address = 0x53,
  321. .invert = 1,
  322. .cdclk_polarity = 1,
  323. };
  324. static struct tda10086_config tda10086_config = {
  325. .demod_address = 0x0e,
  326. .invert = 0,
  327. .diseqc_tone = 1,
  328. .xtal_freq = TDA10086_XTAL_16M,
  329. };
  330. static const struct stv0299_config alps_bsru6_config_activy = {
  331. .demod_address = 0x68,
  332. .inittab = alps_bsru6_inittab,
  333. .mclk = 88000000UL,
  334. .invert = 1,
  335. .op0_off = 1,
  336. .min_delay_ms = 100,
  337. .set_symbol_rate = alps_bsru6_set_symbol_rate,
  338. };
  339. static const struct stv0299_config alps_bsbe1_config_activy = {
  340. .demod_address = 0x68,
  341. .inittab = alps_bsbe1_inittab,
  342. .mclk = 88000000UL,
  343. .invert = 1,
  344. .op0_off = 1,
  345. .min_delay_ms = 100,
  346. .set_symbol_rate = alps_bsbe1_set_symbol_rate,
  347. };
  348. static int alps_tdhd1_204_request_firmware(struct dvb_frontend *fe, const struct firmware **fw, char *name)
  349. {
  350. struct budget *budget = (struct budget *)fe->dvb->priv;
  351. return request_firmware(fw, name, &budget->dev->pci->dev);
  352. }
  353. static int i2c_readreg(struct i2c_adapter *i2c, u8 adr, u8 reg)
  354. {
  355. u8 val;
  356. struct i2c_msg msg[] = {
  357. { .addr = adr, .flags = 0, .buf = &reg, .len = 1 },
  358. { .addr = adr, .flags = I2C_M_RD, .buf = &val, .len = 1 }
  359. };
  360. return (i2c_transfer(i2c, msg, 2) != 2) ? -EIO : val;
  361. }
  362. static u8 read_pwm(struct budget* budget)
  363. {
  364. u8 b = 0xff;
  365. u8 pwm;
  366. struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
  367. { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
  368. if ((i2c_transfer(&budget->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
  369. pwm = 0x48;
  370. return pwm;
  371. }
  372. static struct stv090x_config tt1600_stv090x_config = {
  373. .device = STV0903,
  374. .demod_mode = STV090x_SINGLE,
  375. .clk_mode = STV090x_CLK_EXT,
  376. .xtal = 13500000,
  377. .address = 0x68,
  378. .ts1_mode = STV090x_TSMODE_DVBCI,
  379. .ts2_mode = STV090x_TSMODE_SERIAL_CONTINUOUS,
  380. .repeater_level = STV090x_RPTLEVEL_16,
  381. .tuner_init = NULL,
  382. .tuner_sleep = NULL,
  383. .tuner_set_mode = NULL,
  384. .tuner_set_frequency = NULL,
  385. .tuner_get_frequency = NULL,
  386. .tuner_set_bandwidth = NULL,
  387. .tuner_get_bandwidth = NULL,
  388. .tuner_set_bbgain = NULL,
  389. .tuner_get_bbgain = NULL,
  390. .tuner_set_refclk = NULL,
  391. .tuner_get_status = NULL,
  392. };
  393. static struct stv6110x_config tt1600_stv6110x_config = {
  394. .addr = 0x60,
  395. .refclk = 27000000,
  396. .clk_div = 2,
  397. };
  398. static struct isl6423_config tt1600_isl6423_config = {
  399. .current_max = SEC_CURRENT_515m,
  400. .curlim = SEC_CURRENT_LIM_ON,
  401. .mod_extern = 1,
  402. .addr = 0x08,
  403. };
  404. static void frontend_init(struct budget *budget)
  405. {
  406. (void)alps_bsbe1_config; /* avoid warning */
  407. switch(budget->dev->pci->subsystem_device) {
  408. case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659))
  409. case 0x1013:
  410. // try the ALPS BSRV2 first of all
  411. budget->dvb_frontend = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &budget->i2c_adap);
  412. if (budget->dvb_frontend) {
  413. budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
  414. budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
  415. budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
  416. budget->dvb_frontend->ops.set_tone = budget_set_tone;
  417. break;
  418. }
  419. // try the ALPS BSRU6 now
  420. budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
  421. if (budget->dvb_frontend) {
  422. budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
  423. budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
  424. if (budget->dev->pci->subsystem_device == 0x1003 && diseqc_method == 0) {
  425. budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
  426. budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
  427. budget->dvb_frontend->ops.set_tone = budget_set_tone;
  428. }
  429. break;
  430. }
  431. break;
  432. case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
  433. budget->dvb_frontend = dvb_attach(ves1820_attach, &alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget));
  434. if (budget->dvb_frontend) {
  435. budget->dvb_frontend->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
  436. break;
  437. }
  438. break;
  439. case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060))
  440. budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config, &budget->i2c_adap);
  441. if (budget->dvb_frontend) {
  442. budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
  443. budget->dvb_frontend->tuner_priv = NULL;
  444. break;
  445. }
  446. break;
  447. case 0x4f52: /* Cards based on Philips Semi Sylt PCI ref. design */
  448. budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
  449. if (budget->dvb_frontend) {
  450. printk(KERN_INFO "budget: tuner ALPS BSRU6 in Philips Semi. Sylt detected\n");
  451. budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
  452. budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
  453. break;
  454. }
  455. break;
  456. case 0x4f60: /* Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/tsa5059) */
  457. {
  458. int subtype = i2c_readreg(&budget->i2c_adap, 0x50, 0x67);
  459. if (subtype < 0)
  460. break;
  461. /* fixme: find a better way to identify the card */
  462. if (subtype < 0x36) {
  463. /* assume ALPS BSRU6 */
  464. budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config_activy, &budget->i2c_adap);
  465. if (budget->dvb_frontend) {
  466. printk(KERN_INFO "budget: tuner ALPS BSRU6 detected\n");
  467. budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
  468. budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
  469. budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage;
  470. budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
  471. break;
  472. }
  473. } else {
  474. /* assume ALPS BSBE1 */
  475. /* reset tuner */
  476. saa7146_setgpio(budget->dev, 3, SAA7146_GPIO_OUTLO);
  477. msleep(50);
  478. saa7146_setgpio(budget->dev, 3, SAA7146_GPIO_OUTHI);
  479. msleep(250);
  480. budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsbe1_config_activy, &budget->i2c_adap);
  481. if (budget->dvb_frontend) {
  482. printk(KERN_INFO "budget: tuner ALPS BSBE1 detected\n");
  483. budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
  484. budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
  485. budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage;
  486. budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
  487. break;
  488. }
  489. }
  490. break;
  491. }
  492. case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522))
  493. budget->dvb_frontend = dvb_attach(tda8083_attach, &grundig_29504_451_config, &budget->i2c_adap);
  494. if (budget->dvb_frontend) {
  495. budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
  496. budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage;
  497. budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
  498. }
  499. break;
  500. case 0x5f60: /* Fujitsu Siemens Activy Budget-T PCI rev AL (tda10046/ALPS TDHD1-204A) */
  501. budget->dvb_frontend = dvb_attach(tda10046_attach, &alps_tdhd1_204a_config, &budget->i2c_adap);
  502. if (budget->dvb_frontend) {
  503. budget->dvb_frontend->ops.tuner_ops.set_params = alps_tdhd1_204a_tuner_set_params;
  504. budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
  505. }
  506. break;
  507. case 0x5f61: /* Fujitsu Siemens Activy Budget-T PCI rev GR (L64781/Grundig 29504-401(tsa5060)) */
  508. budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config_activy, &budget->i2c_adap);
  509. if (budget->dvb_frontend) {
  510. budget->dvb_frontend->tuner_priv = &tuner_address_grundig_29504_401_activy;
  511. budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
  512. }
  513. break;
  514. case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260))
  515. {
  516. struct dvb_frontend *fe;
  517. fe = dvb_attach(s5h1420_attach, &s5h1420_config, &budget->i2c_adap);
  518. if (fe) {
  519. fe->ops.tuner_ops.set_params = s5h1420_tuner_set_params;
  520. budget->dvb_frontend = fe;
  521. if (dvb_attach(lnbp21_attach, fe, &budget->i2c_adap,
  522. 0, 0) == NULL) {
  523. printk("%s: No LNBP21 found!\n", __func__);
  524. goto error_out;
  525. }
  526. break;
  527. }
  528. }
  529. /* fall through */
  530. case 0x1018: // TT Budget-S-1401 (philips tda10086/philips tda8262)
  531. {
  532. struct dvb_frontend *fe;
  533. // gpio2 is connected to CLB - reset it + leave it high
  534. saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
  535. msleep(1);
  536. saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
  537. msleep(1);
  538. fe = dvb_attach(tda10086_attach, &tda10086_config, &budget->i2c_adap);
  539. if (fe) {
  540. budget->dvb_frontend = fe;
  541. if (dvb_attach(tda826x_attach, fe, 0x60,
  542. &budget->i2c_adap, 0) == NULL)
  543. printk("%s: No tda826x found!\n", __func__);
  544. if (dvb_attach(lnbp21_attach, fe,
  545. &budget->i2c_adap, 0, 0) == NULL) {
  546. printk("%s: No LNBP21 found!\n", __func__);
  547. goto error_out;
  548. }
  549. break;
  550. }
  551. }
  552. /* fall through */
  553. case 0x101c: { /* TT S2-1600 */
  554. const struct stv6110x_devctl *ctl;
  555. saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
  556. msleep(50);
  557. saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
  558. msleep(250);
  559. budget->dvb_frontend = dvb_attach(stv090x_attach,
  560. &tt1600_stv090x_config,
  561. &budget->i2c_adap,
  562. STV090x_DEMODULATOR_0);
  563. if (budget->dvb_frontend) {
  564. ctl = dvb_attach(stv6110x_attach,
  565. budget->dvb_frontend,
  566. &tt1600_stv6110x_config,
  567. &budget->i2c_adap);
  568. if (ctl) {
  569. tt1600_stv090x_config.tuner_init = ctl->tuner_init;
  570. tt1600_stv090x_config.tuner_sleep = ctl->tuner_sleep;
  571. tt1600_stv090x_config.tuner_set_mode = ctl->tuner_set_mode;
  572. tt1600_stv090x_config.tuner_set_frequency = ctl->tuner_set_frequency;
  573. tt1600_stv090x_config.tuner_get_frequency = ctl->tuner_get_frequency;
  574. tt1600_stv090x_config.tuner_set_bandwidth = ctl->tuner_set_bandwidth;
  575. tt1600_stv090x_config.tuner_get_bandwidth = ctl->tuner_get_bandwidth;
  576. tt1600_stv090x_config.tuner_set_bbgain = ctl->tuner_set_bbgain;
  577. tt1600_stv090x_config.tuner_get_bbgain = ctl->tuner_get_bbgain;
  578. tt1600_stv090x_config.tuner_set_refclk = ctl->tuner_set_refclk;
  579. tt1600_stv090x_config.tuner_get_status = ctl->tuner_get_status;
  580. /* call the init function once to initialize
  581. tuner's clock output divider and demod's
  582. master clock */
  583. if (budget->dvb_frontend->ops.init)
  584. budget->dvb_frontend->ops.init(budget->dvb_frontend);
  585. if (dvb_attach(isl6423_attach,
  586. budget->dvb_frontend,
  587. &budget->i2c_adap,
  588. &tt1600_isl6423_config) == NULL) {
  589. printk(KERN_ERR "%s: No Intersil ISL6423 found!\n", __func__);
  590. goto error_out;
  591. }
  592. } else {
  593. printk(KERN_ERR "%s: No STV6110(A) Silicon Tuner found!\n", __func__);
  594. goto error_out;
  595. }
  596. }
  597. }
  598. break;
  599. case 0x1020: { /* Omicom S2 */
  600. const struct stv6110x_devctl *ctl;
  601. saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
  602. msleep(50);
  603. saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
  604. msleep(250);
  605. budget->dvb_frontend = dvb_attach(stv090x_attach,
  606. &tt1600_stv090x_config,
  607. &budget->i2c_adap,
  608. STV090x_DEMODULATOR_0);
  609. if (budget->dvb_frontend) {
  610. printk(KERN_INFO "budget: Omicom S2 detected\n");
  611. ctl = dvb_attach(stv6110x_attach,
  612. budget->dvb_frontend,
  613. &tt1600_stv6110x_config,
  614. &budget->i2c_adap);
  615. if (ctl) {
  616. tt1600_stv090x_config.tuner_init = ctl->tuner_init;
  617. tt1600_stv090x_config.tuner_sleep = ctl->tuner_sleep;
  618. tt1600_stv090x_config.tuner_set_mode = ctl->tuner_set_mode;
  619. tt1600_stv090x_config.tuner_set_frequency = ctl->tuner_set_frequency;
  620. tt1600_stv090x_config.tuner_get_frequency = ctl->tuner_get_frequency;
  621. tt1600_stv090x_config.tuner_set_bandwidth = ctl->tuner_set_bandwidth;
  622. tt1600_stv090x_config.tuner_get_bandwidth = ctl->tuner_get_bandwidth;
  623. tt1600_stv090x_config.tuner_set_bbgain = ctl->tuner_set_bbgain;
  624. tt1600_stv090x_config.tuner_get_bbgain = ctl->tuner_get_bbgain;
  625. tt1600_stv090x_config.tuner_set_refclk = ctl->tuner_set_refclk;
  626. tt1600_stv090x_config.tuner_get_status = ctl->tuner_get_status;
  627. /* call the init function once to initialize
  628. tuner's clock output divider and demod's
  629. master clock */
  630. if (budget->dvb_frontend->ops.init)
  631. budget->dvb_frontend->ops.init(budget->dvb_frontend);
  632. if (dvb_attach(lnbh24_attach,
  633. budget->dvb_frontend,
  634. &budget->i2c_adap,
  635. LNBH24_PCL | LNBH24_TTX,
  636. LNBH24_TEN, 0x14>>1) == NULL) {
  637. printk(KERN_ERR
  638. "No LNBH24 found!\n");
  639. goto error_out;
  640. }
  641. } else {
  642. printk(KERN_ERR "%s: No STV6110(A) Silicon Tuner found!\n", __func__);
  643. goto error_out;
  644. }
  645. }
  646. }
  647. break;
  648. }
  649. if (budget->dvb_frontend == NULL) {
  650. printk("budget: A frontend driver was not found for device [%04x:%04x] subsystem [%04x:%04x]\n",
  651. budget->dev->pci->vendor,
  652. budget->dev->pci->device,
  653. budget->dev->pci->subsystem_vendor,
  654. budget->dev->pci->subsystem_device);
  655. } else {
  656. if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend))
  657. goto error_out;
  658. }
  659. return;
  660. error_out:
  661. printk("budget: Frontend registration failed!\n");
  662. dvb_frontend_detach(budget->dvb_frontend);
  663. budget->dvb_frontend = NULL;
  664. return;
  665. }
  666. static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
  667. {
  668. struct budget *budget = NULL;
  669. int err;
  670. budget = kmalloc(sizeof(struct budget), GFP_KERNEL);
  671. if( NULL == budget ) {
  672. return -ENOMEM;
  673. }
  674. dprintk(2, "dev:%p, info:%p, budget:%p\n", dev, info, budget);
  675. dev->ext_priv = budget;
  676. err = ttpci_budget_init(budget, dev, info, THIS_MODULE, adapter_nr);
  677. if (err) {
  678. printk("==> failed\n");
  679. kfree (budget);
  680. return err;
  681. }
  682. budget->dvb_adapter.priv = budget;
  683. frontend_init(budget);
  684. ttpci_budget_init_hooks(budget);
  685. return 0;
  686. }
  687. static int budget_detach (struct saa7146_dev* dev)
  688. {
  689. struct budget *budget = (struct budget*) dev->ext_priv;
  690. int err;
  691. if (budget->dvb_frontend) {
  692. dvb_unregister_frontend(budget->dvb_frontend);
  693. dvb_frontend_detach(budget->dvb_frontend);
  694. }
  695. err = ttpci_budget_deinit (budget);
  696. kfree (budget);
  697. dev->ext_priv = NULL;
  698. return err;
  699. }
  700. static struct saa7146_extension budget_extension;
  701. MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT);
  702. MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT);
  703. MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
  704. MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC);
  705. MAKE_BUDGET_INFO(ttbs1401, "TT-Budget-S-1401 PCI", BUDGET_TT);
  706. MAKE_BUDGET_INFO(tt1600, "TT-Budget S2-1600 PCI", BUDGET_TT);
  707. MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY);
  708. MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY);
  709. MAKE_BUDGET_INFO(fsact, "Fujitsu Siemens Activy Budget-T PCI (rev GR/Grundig frontend)", BUDGET_FS_ACTIVY);
  710. MAKE_BUDGET_INFO(fsact1, "Fujitsu Siemens Activy Budget-T PCI (rev AL/ALPS TDHD1-204A)", BUDGET_FS_ACTIVY);
  711. MAKE_BUDGET_INFO(omicom, "Omicom S2 PCI", BUDGET_TT);
  712. MAKE_BUDGET_INFO(sylt, "Philips Semi Sylt PCI", BUDGET_TT_HW_DISEQC);
  713. static const struct pci_device_id pci_tbl[] = {
  714. MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1003),
  715. MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004),
  716. MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005),
  717. MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
  718. MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016),
  719. MAKE_EXTENSION_PCI(ttbs1401, 0x13c2, 0x1018),
  720. MAKE_EXTENSION_PCI(tt1600, 0x13c2, 0x101c),
  721. MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60),
  722. MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61),
  723. MAKE_EXTENSION_PCI(fsact1, 0x1131, 0x5f60),
  724. MAKE_EXTENSION_PCI(fsact, 0x1131, 0x5f61),
  725. MAKE_EXTENSION_PCI(omicom, 0x14c4, 0x1020),
  726. MAKE_EXTENSION_PCI(sylt, 0x1131, 0x4f52),
  727. {
  728. .vendor = 0,
  729. }
  730. };
  731. MODULE_DEVICE_TABLE(pci, pci_tbl);
  732. static struct saa7146_extension budget_extension = {
  733. .name = "budget dvb",
  734. .flags = SAA7146_USE_I2C_IRQ,
  735. .module = THIS_MODULE,
  736. .pci_tbl = pci_tbl,
  737. .attach = budget_attach,
  738. .detach = budget_detach,
  739. .irq_mask = MASK_10,
  740. .irq_func = ttpci_budget_irq10_handler,
  741. };
  742. static int __init budget_init(void)
  743. {
  744. return saa7146_register_extension(&budget_extension);
  745. }
  746. static void __exit budget_exit(void)
  747. {
  748. saa7146_unregister_extension(&budget_extension);
  749. }
  750. module_init(budget_init);
  751. module_exit(budget_exit);
  752. MODULE_LICENSE("GPL");
  753. MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
  754. MODULE_DESCRIPTION("driver for the SAA7146 based so-called budget PCI DVB cards by Siemens, Technotrend, Hauppauge");