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