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 | |
| 189 | static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 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 | |
| 212 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | static struct ves1x93_config alps_bsrv2_config = |
| 217 | { |
| 218 | .demod_address = 0x08, |
| 219 | .xin = 90100000UL, |
| 220 | .invert_pwm = 0, |
| 221 | .pll_set = alps_bsrv2_pll_set, |
| 222 | }; |
| 223 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 225 | { |
| 226 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 227 | u32 div; |
| 228 | u8 data[4]; |
| 229 | struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 230 | |
| 231 | div = (params->frequency + 35937500 + 31250) / 62500; |
| 232 | |
| 233 | data[0] = (div >> 8) & 0x7f; |
| 234 | data[1] = div & 0xff; |
| 235 | data[2] = 0x85 | ((div >> 10) & 0x60); |
| 236 | data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81); |
| 237 | |
| 238 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | static struct ves1820_config alps_tdbe2_config = { |
| 243 | .demod_address = 0x09, |
| 244 | .xin = 57840000UL, |
| 245 | .invert = 1, |
| 246 | .selagc = VES1820_SELAGC_SIGNAMPERR, |
| 247 | .pll_set = alps_tdbe2_pll_set, |
| 248 | }; |
| 249 | |
| 250 | static int grundig_29504_401_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 251 | { |
| 252 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 253 | u32 div; |
| 254 | u8 cfg, cpump, band_select; |
| 255 | u8 data[4]; |
| 256 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 257 | |
| 258 | div = (36125000 + params->frequency) / 166666; |
| 259 | |
| 260 | cfg = 0x88; |
| 261 | |
| 262 | if (params->frequency < 175000000) cpump = 2; |
| 263 | else if (params->frequency < 390000000) cpump = 1; |
| 264 | else if (params->frequency < 470000000) cpump = 2; |
| 265 | else if (params->frequency < 750000000) cpump = 1; |
| 266 | else cpump = 3; |
| 267 | |
| 268 | if (params->frequency < 175000000) band_select = 0x0e; |
| 269 | else if (params->frequency < 470000000) band_select = 0x05; |
| 270 | else band_select = 0x03; |
| 271 | |
| 272 | data[0] = (div >> 8) & 0x7f; |
| 273 | data[1] = div & 0xff; |
| 274 | data[2] = ((div >> 10) & 0x60) | cfg; |
| 275 | data[3] = (cpump << 6) | band_select; |
| 276 | |
| 277 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 278 | return 0; |
| 279 | } |
| 280 | |
| 281 | static struct l64781_config grundig_29504_401_config = { |
| 282 | .demod_address = 0x55, |
| 283 | .pll_set = grundig_29504_401_pll_set, |
| 284 | }; |
| 285 | |
| 286 | static int grundig_29504_451_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 287 | { |
| 288 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 289 | u32 div; |
| 290 | u8 data[4]; |
| 291 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 292 | |
| 293 | div = params->frequency / 125; |
| 294 | data[0] = (div >> 8) & 0x7f; |
| 295 | data[1] = div & 0xff; |
| 296 | data[2] = 0x8e; |
| 297 | data[3] = 0x00; |
| 298 | |
| 299 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | static struct tda8083_config grundig_29504_451_config = { |
| 304 | .demod_address = 0x68, |
| 305 | .pll_set = grundig_29504_451_pll_set, |
| 306 | }; |
| 307 | |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 308 | static int s5h1420_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout) |
| 309 | { |
| 310 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| 311 | u32 div; |
| 312 | u8 data[4]; |
| 313 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 314 | |
| 315 | div = params->frequency / 1000; |
| 316 | data[0] = (div >> 8) & 0x7f; |
| 317 | data[1] = div & 0xff; |
| 318 | data[2] = 0xc2; |
| 319 | |
| 320 | if (div < 1450) |
| 321 | data[3] = 0x00; |
| 322 | else if (div < 1850) |
| 323 | data[3] = 0x40; |
| 324 | else if (div < 2000) |
| 325 | data[3] = 0x80; |
| 326 | else |
| 327 | data[3] = 0xc0; |
| 328 | |
| 329 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; |
| 330 | |
| 331 | *freqout = div * 1000; |
| 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | static struct s5h1420_config s5h1420_config = { |
| 336 | .demod_address = 0x53, |
Andrew de Quincey | a9d6a80 | 2005-09-09 13:02:31 -0700 | [diff] [blame] | 337 | .invert = 1, |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 338 | .pll_set = s5h1420_pll_set, |
| 339 | }; |
| 340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | static u8 read_pwm(struct budget* budget) |
| 342 | { |
| 343 | u8 b = 0xff; |
| 344 | u8 pwm; |
| 345 | struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 }, |
| 346 | { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} }; |
| 347 | |
Mauro Carvalho Chehab | 9101e62 | 2005-12-12 00:37:24 -0800 | [diff] [blame] | 348 | if ((i2c_transfer(&budget->i2c_adap, msg, 2) != 2) || (pwm == 0xff)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | pwm = 0x48; |
| 350 | |
| 351 | return pwm; |
| 352 | } |
| 353 | |
| 354 | static void frontend_init(struct budget *budget) |
| 355 | { |
| 356 | switch(budget->dev->pci->subsystem_device) { |
| 357 | case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659)) |
| 358 | case 0x1013: |
| 359 | // try the ALPS BSRV2 first of all |
| 360 | budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); |
| 361 | if (budget->dvb_frontend) { |
| 362 | budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd; |
Mauro Carvalho Chehab | 9101e62 | 2005-12-12 00:37:24 -0800 | [diff] [blame] | 363 | budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | budget->dvb_frontend->ops->set_tone = budget_set_tone; |
| 365 | break; |
| 366 | } |
| 367 | |
| 368 | // try the ALPS BSRU6 now |
| 369 | budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); |
| 370 | if (budget->dvb_frontend) { |
| 371 | budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd; |
| 372 | budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst; |
| 373 | budget->dvb_frontend->ops->set_tone = budget_set_tone; |
| 374 | break; |
| 375 | } |
| 376 | break; |
| 377 | |
| 378 | case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) |
| 379 | |
| 380 | budget->dvb_frontend = ves1820_attach(&alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget)); |
| 381 | if (budget->dvb_frontend) break; |
| 382 | break; |
| 383 | |
| 384 | case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060)) |
| 385 | |
| 386 | budget->dvb_frontend = l64781_attach(&grundig_29504_401_config, &budget->i2c_adap); |
| 387 | if (budget->dvb_frontend) break; |
| 388 | break; |
| 389 | |
| 390 | case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059)) |
| 391 | budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); |
| 392 | if (budget->dvb_frontend) { |
| 393 | budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage; |
Oliver Endriss | f49cc15 | 2006-01-09 15:25:06 -0200 | [diff] [blame] | 394 | budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | } |
| 396 | break; |
| 397 | |
| 398 | case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522)) |
| 399 | budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); |
| 400 | if (budget->dvb_frontend) { |
| 401 | budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage; |
Oliver Endriss | f49cc15 | 2006-01-09 15:25:06 -0200 | [diff] [blame] | 402 | budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | } |
| 404 | break; |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 405 | |
| 406 | case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260)) |
| 407 | budget->dvb_frontend = s5h1420_attach(&s5h1420_config, &budget->i2c_adap); |
| 408 | if (budget->dvb_frontend) { |
Oliver Endriss | 2f27bdc | 2006-02-28 09:31:16 -0300 | [diff] [blame] | 409 | if (lnbp21_init(budget->dvb_frontend, &budget->i2c_adap, 0, 0)) { |
Martin Zwickel | 9691bb1 | 2005-11-08 21:35:10 -0800 | [diff] [blame] | 410 | printk("%s: No LNBP21 found!\n", __FUNCTION__); |
| 411 | goto error_out; |
| 412 | } |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 413 | break; |
| 414 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | if (budget->dvb_frontend == NULL) { |
| 418 | printk("budget: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", |
| 419 | budget->dev->pci->vendor, |
| 420 | budget->dev->pci->device, |
| 421 | budget->dev->pci->subsystem_vendor, |
| 422 | budget->dev->pci->subsystem_device); |
| 423 | } else { |
Martin Zwickel | 9691bb1 | 2005-11-08 21:35:10 -0800 | [diff] [blame] | 424 | if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) |
| 425 | goto error_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | } |
Martin Zwickel | 9691bb1 | 2005-11-08 21:35:10 -0800 | [diff] [blame] | 427 | return; |
| 428 | |
| 429 | error_out: |
| 430 | printk("budget: Frontend registration failed!\n"); |
| 431 | if (budget->dvb_frontend->ops->release) |
| 432 | budget->dvb_frontend->ops->release(budget->dvb_frontend); |
| 433 | budget->dvb_frontend = NULL; |
| 434 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info) |
| 438 | { |
| 439 | struct budget *budget = NULL; |
| 440 | int err; |
| 441 | |
| 442 | budget = kmalloc(sizeof(struct budget), GFP_KERNEL); |
| 443 | if( NULL == budget ) { |
| 444 | return -ENOMEM; |
| 445 | } |
| 446 | |
| 447 | dprintk(2, "dev:%p, info:%p, budget:%p\n", dev, info, budget); |
| 448 | |
| 449 | dev->ext_priv = budget; |
| 450 | |
| 451 | if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) { |
| 452 | printk("==> failed\n"); |
| 453 | kfree (budget); |
| 454 | return err; |
| 455 | } |
| 456 | |
Johannes Stezenbach | fdc53a6 | 2005-05-16 21:54:39 -0700 | [diff] [blame] | 457 | budget->dvb_adapter.priv = budget; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | frontend_init(budget); |
| 459 | |
| 460 | return 0; |
| 461 | } |
| 462 | |
| 463 | static int budget_detach (struct saa7146_dev* dev) |
| 464 | { |
| 465 | struct budget *budget = (struct budget*) dev->ext_priv; |
| 466 | int err; |
| 467 | |
| 468 | if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend); |
| 469 | |
| 470 | err = ttpci_budget_deinit (budget); |
| 471 | |
| 472 | kfree (budget); |
| 473 | dev->ext_priv = NULL; |
| 474 | |
| 475 | return err; |
| 476 | } |
| 477 | |
| 478 | static struct saa7146_extension budget_extension; |
| 479 | |
| 480 | MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT); |
| 481 | MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT); |
| 482 | MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); |
| 483 | MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC); |
| 484 | MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY); |
| 485 | MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY); |
| 486 | |
| 487 | static struct pci_device_id pci_tbl[] = { |
| 488 | MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1003), |
| 489 | MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004), |
| 490 | MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005), |
| 491 | MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013), |
Andrew de Quincey | 96bf2f2 | 2005-07-07 17:57:53 -0700 | [diff] [blame] | 492 | MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60), |
| 494 | MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61), |
| 495 | { |
| 496 | .vendor = 0, |
| 497 | } |
| 498 | }; |
| 499 | |
| 500 | MODULE_DEVICE_TABLE(pci, pci_tbl); |
| 501 | |
| 502 | static struct saa7146_extension budget_extension = { |
| 503 | .name = "budget dvb\0", |
Oliver Endriss | 69459f3d | 2005-12-01 00:51:48 -0800 | [diff] [blame] | 504 | .flags = SAA7146_I2C_SHORT_DELAY, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | .module = THIS_MODULE, |
| 507 | .pci_tbl = pci_tbl, |
| 508 | .attach = budget_attach, |
| 509 | .detach = budget_detach, |
| 510 | |
| 511 | .irq_mask = MASK_10, |
| 512 | .irq_func = ttpci_budget_irq10_handler, |
| 513 | }; |
| 514 | |
| 515 | static int __init budget_init(void) |
| 516 | { |
| 517 | return saa7146_register_extension(&budget_extension); |
| 518 | } |
| 519 | |
| 520 | static void __exit budget_exit(void) |
| 521 | { |
| 522 | saa7146_unregister_extension(&budget_extension); |
| 523 | } |
| 524 | |
| 525 | module_init(budget_init); |
| 526 | module_exit(budget_exit); |
| 527 | |
| 528 | MODULE_LICENSE("GPL"); |
| 529 | MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others"); |
| 530 | MODULE_DESCRIPTION("driver for the SAA7146 based so-called " |
| 531 | "budget PCI DVB cards by Siemens, Technotrend, Hauppauge"); |