Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 http://www.linuxtv.org/dvb/ |
| 35 | */ |
| 36 | |
| 37 | #include "budget.h" |
| 38 | #include "stv0299.h" |
| 39 | #include "ves1x93.h" |
| 40 | #include "ves1820.h" |
| 41 | #include "l64781.h" |
| 42 | #include "tda8083.h" |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 43 | #include "s5h1420.h" |
Oliver Endriss | 2f27bdc | 2006-02-28 09:31:16 -0300 | [diff] [blame] | 44 | #include "lnbp21.h" |
Perceval Anichini | 265366e | 2006-03-16 11:22:47 -0300 | [diff] [blame] | 45 | #include "bsru6.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | static void Set22K (struct budget *budget, int state) |
| 48 | { |
| 49 | struct saa7146_dev *dev=budget->dev; |
| 50 | dprintk(2, "budget: %p\n", budget); |
| 51 | saa7146_setgpio(dev, 3, (state ? SAA7146_GPIO_OUTHI : SAA7146_GPIO_OUTLO)); |
| 52 | } |
| 53 | |
| 54 | /* Diseqc functions only for TT Budget card */ |
| 55 | /* taken from the Skyvision DVB driver by |
| 56 | Ralph Metzler <rjkm@metzlerbros.de> */ |
| 57 | |
| 58 | static void DiseqcSendBit (struct budget *budget, int data) |
| 59 | { |
| 60 | struct saa7146_dev *dev=budget->dev; |
| 61 | dprintk(2, "budget: %p\n", budget); |
| 62 | |
| 63 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); |
| 64 | udelay(data ? 500 : 1000); |
| 65 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); |
| 66 | udelay(data ? 1000 : 500); |
| 67 | } |
| 68 | |
| 69 | static void DiseqcSendByte (struct budget *budget, int data) |
| 70 | { |
| 71 | int i, par=1, d; |
| 72 | |
| 73 | dprintk(2, "budget: %p\n", budget); |
| 74 | |
| 75 | for (i=7; i>=0; i--) { |
| 76 | d = (data>>i)&1; |
| 77 | par ^= d; |
| 78 | DiseqcSendBit(budget, d); |
| 79 | } |
| 80 | |
| 81 | DiseqcSendBit(budget, par); |
| 82 | } |
| 83 | |
| 84 | static int SendDiSEqCMsg (struct budget *budget, int len, u8 *msg, unsigned long burst) |
| 85 | { |
| 86 | struct saa7146_dev *dev=budget->dev; |
| 87 | int i; |
| 88 | |
| 89 | dprintk(2, "budget: %p\n", budget); |
| 90 | |
| 91 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); |
| 92 | mdelay(16); |
| 93 | |
| 94 | for (i=0; i<len; i++) |
| 95 | DiseqcSendByte(budget, msg[i]); |
| 96 | |
| 97 | mdelay(16); |
| 98 | |
| 99 | if (burst!=-1) { |
| 100 | if (burst) |
| 101 | DiseqcSendByte(budget, 0xff); |
| 102 | else { |
| 103 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); |
| 104 | udelay(12500); |
| 105 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); |
| 106 | } |
| 107 | msleep(20); |
| 108 | } |
| 109 | |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | /* |
| 114 | * Routines for the Fujitsu Siemens Activy budget card |
| 115 | * 22 kHz tone and DiSEqC are handled by the frontend. |
| 116 | * Voltage must be set here. |
Oliver Endriss | f49cc15 | 2006-01-09 15:25:06 -0200 | [diff] [blame] | 117 | * GPIO 1: LNBP EN, GPIO 2: LNBP VSEL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | */ |
| 119 | static int SetVoltage_Activy (struct budget *budget, fe_sec_voltage_t voltage) |
| 120 | { |
| 121 | struct saa7146_dev *dev=budget->dev; |
| 122 | |
| 123 | dprintk(2, "budget: %p\n", budget); |
| 124 | |
| 125 | switch (voltage) { |
| 126 | case SEC_VOLTAGE_13: |
Oliver Endriss | f49cc15 | 2006-01-09 15:25:06 -0200 | [diff] [blame] | 127 | saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTLO); |
| 129 | break; |
| 130 | case SEC_VOLTAGE_18: |
Oliver Endriss | f49cc15 | 2006-01-09 15:25:06 -0200 | [diff] [blame] | 131 | saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); |
| 133 | break; |
Oliver Endriss | f49cc15 | 2006-01-09 15:25:06 -0200 | [diff] [blame] | 134 | case SEC_VOLTAGE_OFF: |
| 135 | saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTLO); |
| 136 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | default: |
| 138 | return -EINVAL; |
| 139 | } |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | static int siemens_budget_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) |
| 145 | { |
| 146 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 147 | |
| 148 | return SetVoltage_Activy (budget, voltage); |
| 149 | } |
| 150 | |
| 151 | static int budget_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) |
| 152 | { |
| 153 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 154 | |
| 155 | switch (tone) { |
| 156 | case SEC_TONE_ON: |
| 157 | Set22K (budget, 1); |
| 158 | break; |
| 159 | |
| 160 | case SEC_TONE_OFF: |
| 161 | Set22K (budget, 0); |
| 162 | break; |
| 163 | |
| 164 | default: |
| 165 | return -EINVAL; |
| 166 | } |
| 167 | |
| 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | static int budget_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) |
| 172 | { |
| 173 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 174 | |
| 175 | SendDiSEqCMsg (budget, cmd->msg_len, cmd->msg, 0); |
| 176 | |
| 177 | return 0; |
| 178 | } |
| 179 | |
| 180 | static int budget_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd) |
| 181 | { |
| 182 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 183 | |
| 184 | SendDiSEqCMsg (budget, 0, NULL, minicmd); |
| 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 189 | static int alps_bsrv2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | { |
| 191 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 192 | u8 pwr = 0; |
| 193 | u8 buf[4]; |
| 194 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; |
| 195 | u32 div = (params->frequency + 479500) / 125; |
| 196 | |
| 197 | if (params->frequency > 2000000) pwr = 3; |
| 198 | else if (params->frequency > 1800000) pwr = 2; |
| 199 | else if (params->frequency > 1600000) pwr = 1; |
| 200 | else if (params->frequency > 1200000) pwr = 0; |
| 201 | else if (params->frequency >= 1100000) pwr = 1; |
| 202 | else pwr = 2; |
| 203 | |
| 204 | buf[0] = (div >> 8) & 0x7f; |
| 205 | buf[1] = div & 0xff; |
| 206 | buf[2] = ((div & 0x18000) >> 10) | 0x95; |
| 207 | buf[3] = (pwr << 6) | 0x30; |
| 208 | |
Mauro Carvalho Chehab | 9101e62 | 2005-12-12 00:37:24 -0800 | [diff] [blame] | 209 | // NOTE: since we're using a prescaler of 2, we set the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | // divisor frequency to 62.5kHz and divide by 125 above |
| 211 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 212 | if (fe->ops.i2c_gate_ctrl) |
| 213 | fe->ops.i2c_gate_ctrl(fe, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | static struct ves1x93_config alps_bsrv2_config = |
| 219 | { |
| 220 | .demod_address = 0x08, |
| 221 | .xin = 90100000UL, |
| 222 | .invert_pwm = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | }; |
| 224 | |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 225 | static int alps_tdbe2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | { |
| 227 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 228 | u32 div; |
| 229 | u8 data[4]; |
| 230 | struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 231 | |
| 232 | div = (params->frequency + 35937500 + 31250) / 62500; |
| 233 | |
| 234 | data[0] = (div >> 8) & 0x7f; |
| 235 | data[1] = div & 0xff; |
| 236 | data[2] = 0x85 | ((div >> 10) & 0x60); |
| 237 | data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81); |
| 238 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 239 | if (fe->ops.i2c_gate_ctrl) |
| 240 | fe->ops.i2c_gate_ctrl(fe, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | static struct ves1820_config alps_tdbe2_config = { |
| 246 | .demod_address = 0x09, |
| 247 | .xin = 57840000UL, |
| 248 | .invert = 1, |
| 249 | .selagc = VES1820_SELAGC_SIGNAMPERR, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | }; |
| 251 | |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 252 | static int grundig_29504_401_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | { |
| 254 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 255 | u32 div; |
| 256 | u8 cfg, cpump, band_select; |
| 257 | u8 data[4]; |
| 258 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 259 | |
| 260 | div = (36125000 + params->frequency) / 166666; |
| 261 | |
| 262 | cfg = 0x88; |
| 263 | |
| 264 | if (params->frequency < 175000000) cpump = 2; |
| 265 | else if (params->frequency < 390000000) cpump = 1; |
| 266 | else if (params->frequency < 470000000) cpump = 2; |
| 267 | else if (params->frequency < 750000000) cpump = 1; |
| 268 | else cpump = 3; |
| 269 | |
| 270 | if (params->frequency < 175000000) band_select = 0x0e; |
| 271 | else if (params->frequency < 470000000) band_select = 0x05; |
| 272 | else band_select = 0x03; |
| 273 | |
| 274 | data[0] = (div >> 8) & 0x7f; |
| 275 | data[1] = div & 0xff; |
| 276 | data[2] = ((div >> 10) & 0x60) | cfg; |
| 277 | data[3] = (cpump << 6) | band_select; |
| 278 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 279 | if (fe->ops.i2c_gate_ctrl) |
| 280 | fe->ops.i2c_gate_ctrl(fe, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 282 | return 0; |
| 283 | } |
| 284 | |
| 285 | static struct l64781_config grundig_29504_401_config = { |
| 286 | .demod_address = 0x55, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | }; |
| 288 | |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 289 | static int grundig_29504_451_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | { |
| 291 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 292 | u32 div; |
| 293 | u8 data[4]; |
| 294 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 295 | |
| 296 | div = params->frequency / 125; |
| 297 | data[0] = (div >> 8) & 0x7f; |
| 298 | data[1] = div & 0xff; |
| 299 | data[2] = 0x8e; |
| 300 | data[3] = 0x00; |
| 301 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 302 | if (fe->ops.i2c_gate_ctrl) |
| 303 | fe->ops.i2c_gate_ctrl(fe, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | static struct tda8083_config grundig_29504_451_config = { |
| 309 | .demod_address = 0x68, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | }; |
| 311 | |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 312 | static int s5h1420_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 313 | { |
| 314 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 315 | u32 div; |
| 316 | u8 data[4]; |
| 317 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 318 | |
| 319 | div = params->frequency / 1000; |
| 320 | data[0] = (div >> 8) & 0x7f; |
| 321 | data[1] = div & 0xff; |
| 322 | data[2] = 0xc2; |
| 323 | |
| 324 | if (div < 1450) |
| 325 | data[3] = 0x00; |
| 326 | else if (div < 1850) |
| 327 | data[3] = 0x40; |
| 328 | else if (div < 2000) |
| 329 | data[3] = 0x80; |
| 330 | else |
| 331 | data[3] = 0xc0; |
| 332 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 333 | if (fe->ops.i2c_gate_ctrl) |
| 334 | fe->ops.i2c_gate_ctrl(fe, 1); |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 335 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 336 | |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | static struct s5h1420_config s5h1420_config = { |
| 341 | .demod_address = 0x53, |
Andrew de Quincey | a9d6a80 | 2005-09-09 13:02:31 -0700 | [diff] [blame] | 342 | .invert = 1, |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 343 | }; |
| 344 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | static u8 read_pwm(struct budget* budget) |
| 346 | { |
| 347 | u8 b = 0xff; |
| 348 | u8 pwm; |
| 349 | struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 }, |
| 350 | { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} }; |
| 351 | |
Mauro Carvalho Chehab | 9101e62 | 2005-12-12 00:37:24 -0800 | [diff] [blame] | 352 | if ((i2c_transfer(&budget->i2c_adap, msg, 2) != 2) || (pwm == 0xff)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | pwm = 0x48; |
| 354 | |
| 355 | return pwm; |
| 356 | } |
| 357 | |
| 358 | static void frontend_init(struct budget *budget) |
| 359 | { |
| 360 | switch(budget->dev->pci->subsystem_device) { |
| 361 | case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659)) |
| 362 | case 0x1013: |
| 363 | // try the ALPS BSRV2 first of all |
| 364 | budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); |
| 365 | if (budget->dvb_frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 366 | budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; |
| 367 | budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd; |
| 368 | budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst; |
| 369 | budget->dvb_frontend->ops.set_tone = budget_set_tone; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | break; |
| 371 | } |
| 372 | |
| 373 | // try the ALPS BSRU6 now |
| 374 | budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); |
| 375 | if (budget->dvb_frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 376 | budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 377 | budget->dvb_frontend->tuner_priv = &budget->i2c_adap; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 378 | budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd; |
| 379 | budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst; |
| 380 | budget->dvb_frontend->ops.set_tone = budget_set_tone; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | break; |
| 382 | } |
| 383 | break; |
| 384 | |
| 385 | case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) |
| 386 | |
| 387 | budget->dvb_frontend = ves1820_attach(&alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget)); |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 388 | if (budget->dvb_frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 389 | budget->dvb_frontend->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 390 | break; |
| 391 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | break; |
| 393 | |
| 394 | case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060)) |
| 395 | |
| 396 | budget->dvb_frontend = l64781_attach(&grundig_29504_401_config, &budget->i2c_adap); |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 397 | if (budget->dvb_frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 398 | budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params; |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 399 | break; |
| 400 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | break; |
| 402 | |
| 403 | case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059)) |
| 404 | budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); |
| 405 | if (budget->dvb_frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 406 | budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; |
Andrew de Quincey | 067145b | 2006-04-18 17:47:11 -0300 | [diff] [blame] | 407 | budget->dvb_frontend->tuner_priv = &budget->i2c_adap; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 408 | budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage; |
| 409 | budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | } |
| 411 | break; |
| 412 | |
| 413 | case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522)) |
| 414 | budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); |
| 415 | if (budget->dvb_frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 416 | budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; |
| 417 | budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage; |
| 418 | budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | } |
| 420 | break; |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 421 | |
| 422 | case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260)) |
| 423 | budget->dvb_frontend = s5h1420_attach(&s5h1420_config, &budget->i2c_adap); |
| 424 | if (budget->dvb_frontend) { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 425 | budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params; |
Andrew de Quincey | d020542 | 2006-04-27 21:45:01 -0300 | [diff] [blame] | 426 | if (lnbp21_attach(budget->dvb_frontend, &budget->i2c_adap, 0, 0)) { |
Martin Zwickel | 9691bb1 | 2005-11-08 21:35:10 -0800 | [diff] [blame] | 427 | printk("%s: No LNBP21 found!\n", __FUNCTION__); |
| 428 | goto error_out; |
| 429 | } |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 430 | break; |
| 431 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | if (budget->dvb_frontend == NULL) { |
| 435 | printk("budget: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", |
| 436 | budget->dev->pci->vendor, |
| 437 | budget->dev->pci->device, |
| 438 | budget->dev->pci->subsystem_vendor, |
| 439 | budget->dev->pci->subsystem_device); |
| 440 | } else { |
Martin Zwickel | 9691bb1 | 2005-11-08 21:35:10 -0800 | [diff] [blame] | 441 | if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) |
| 442 | goto error_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | } |
Martin Zwickel | 9691bb1 | 2005-11-08 21:35:10 -0800 | [diff] [blame] | 444 | return; |
| 445 | |
| 446 | error_out: |
| 447 | printk("budget: Frontend registration failed!\n"); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 448 | if (budget->dvb_frontend->ops.release) |
| 449 | budget->dvb_frontend->ops.release(budget->dvb_frontend); |
Martin Zwickel | 9691bb1 | 2005-11-08 21:35:10 -0800 | [diff] [blame] | 450 | budget->dvb_frontend = NULL; |
| 451 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info) |
| 455 | { |
| 456 | struct budget *budget = NULL; |
| 457 | int err; |
| 458 | |
| 459 | budget = kmalloc(sizeof(struct budget), GFP_KERNEL); |
| 460 | if( NULL == budget ) { |
| 461 | return -ENOMEM; |
| 462 | } |
| 463 | |
| 464 | dprintk(2, "dev:%p, info:%p, budget:%p\n", dev, info, budget); |
| 465 | |
| 466 | dev->ext_priv = budget; |
| 467 | |
| 468 | if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) { |
| 469 | printk("==> failed\n"); |
| 470 | kfree (budget); |
| 471 | return err; |
| 472 | } |
| 473 | |
Johannes Stezenbach | fdc53a6 | 2005-05-16 21:54:39 -0700 | [diff] [blame] | 474 | budget->dvb_adapter.priv = budget; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | frontend_init(budget); |
| 476 | |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | static int budget_detach (struct saa7146_dev* dev) |
| 481 | { |
| 482 | struct budget *budget = (struct budget*) dev->ext_priv; |
| 483 | int err; |
| 484 | |
| 485 | if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend); |
| 486 | |
| 487 | err = ttpci_budget_deinit (budget); |
| 488 | |
| 489 | kfree (budget); |
| 490 | dev->ext_priv = NULL; |
| 491 | |
| 492 | return err; |
| 493 | } |
| 494 | |
| 495 | static struct saa7146_extension budget_extension; |
| 496 | |
| 497 | MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT); |
| 498 | MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT); |
| 499 | MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); |
| 500 | MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC); |
| 501 | MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY); |
| 502 | MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY); |
| 503 | |
| 504 | static struct pci_device_id pci_tbl[] = { |
| 505 | MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1003), |
| 506 | MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004), |
| 507 | MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005), |
| 508 | MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013), |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 509 | MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60), |
| 511 | MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61), |
| 512 | { |
| 513 | .vendor = 0, |
| 514 | } |
| 515 | }; |
| 516 | |
| 517 | MODULE_DEVICE_TABLE(pci, pci_tbl); |
| 518 | |
| 519 | static struct saa7146_extension budget_extension = { |
| 520 | .name = "budget dvb\0", |
Oliver Endriss | 69459f3 | 2005-12-01 00:51:48 -0800 | [diff] [blame] | 521 | .flags = SAA7146_I2C_SHORT_DELAY, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | |
| 523 | .module = THIS_MODULE, |
| 524 | .pci_tbl = pci_tbl, |
| 525 | .attach = budget_attach, |
| 526 | .detach = budget_detach, |
| 527 | |
| 528 | .irq_mask = MASK_10, |
| 529 | .irq_func = ttpci_budget_irq10_handler, |
| 530 | }; |
| 531 | |
| 532 | static int __init budget_init(void) |
| 533 | { |
| 534 | return saa7146_register_extension(&budget_extension); |
| 535 | } |
| 536 | |
| 537 | static void __exit budget_exit(void) |
| 538 | { |
| 539 | saa7146_unregister_extension(&budget_extension); |
| 540 | } |
| 541 | |
| 542 | module_init(budget_init); |
| 543 | module_exit(budget_exit); |
| 544 | |
| 545 | MODULE_LICENSE("GPL"); |
| 546 | MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others"); |
| 547 | MODULE_DESCRIPTION("driver for the SAA7146 based so-called " |
| 548 | "budget PCI DVB cards by Siemens, Technotrend, Hauppauge"); |