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