budget.c 26 KB

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