diff options
Diffstat (limited to 'drivers/media/dvb')
61 files changed, 2770 insertions, 1824 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index 0410cc96a48e..47e28b0ee951 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c | |||
| @@ -164,12 +164,11 @@ static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, | |||
| 164 | return 0; | 164 | return 0; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 167 | static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) |
| 168 | { | 168 | { |
| 169 | u8 buf[4]; | 169 | u8 buf[4]; |
| 170 | u32 div; | 170 | u32 div; |
| 171 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; | 171 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) }; |
| 172 | struct flexcop_device *fc = fe->dvb->priv; | ||
| 173 | 172 | ||
| 174 | div = params->frequency / 125; | 173 | div = params->frequency / 125; |
| 175 | 174 | ||
| @@ -180,7 +179,7 @@ static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_fronten | |||
| 180 | 179 | ||
| 181 | if (params->frequency < 1500000) buf[3] |= 0x10; | 180 | if (params->frequency < 1500000) buf[3] |= 0x10; |
| 182 | 181 | ||
| 183 | if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) | 182 | if (i2c_transfer(i2c, &msg, 1) != 1) |
| 184 | return -EIO; | 183 | return -EIO; |
| 185 | return 0; | 184 | return 0; |
| 186 | } | 185 | } |
| @@ -335,8 +334,103 @@ static struct mt312_config skystar23_samsung_tbdu18132_config = { | |||
| 335 | .pll_set = skystar23_samsung_tbdu18132_pll_set, | 334 | .pll_set = skystar23_samsung_tbdu18132_pll_set, |
| 336 | }; | 335 | }; |
| 337 | 336 | ||
| 337 | |||
| 338 | static u8 alps_tdee4_stv0297_inittab[] = { | ||
| 339 | 0x80, 0x01, | ||
| 340 | 0x80, 0x00, | ||
| 341 | 0x81, 0x01, | ||
| 342 | 0x81, 0x00, | ||
| 343 | 0x00, 0x09, | ||
| 344 | 0x01, 0x69, | ||
| 345 | 0x03, 0x00, | ||
| 346 | 0x04, 0x00, | ||
| 347 | 0x07, 0x00, | ||
| 348 | 0x08, 0x00, | ||
| 349 | 0x20, 0x00, | ||
| 350 | 0x21, 0x40, | ||
| 351 | 0x22, 0x00, | ||
| 352 | 0x23, 0x00, | ||
| 353 | 0x24, 0x40, | ||
| 354 | 0x25, 0x88, | ||
| 355 | 0x30, 0xff, | ||
| 356 | 0x31, 0x00, | ||
| 357 | 0x32, 0xff, | ||
| 358 | 0x33, 0x00, | ||
| 359 | 0x34, 0x50, | ||
| 360 | 0x35, 0x7f, | ||
| 361 | 0x36, 0x00, | ||
| 362 | 0x37, 0x20, | ||
| 363 | 0x38, 0x00, | ||
| 364 | 0x40, 0x1c, | ||
| 365 | 0x41, 0xff, | ||
| 366 | 0x42, 0x29, | ||
| 367 | 0x43, 0x00, | ||
| 368 | 0x44, 0xff, | ||
| 369 | 0x45, 0x00, | ||
| 370 | 0x46, 0x00, | ||
| 371 | 0x49, 0x04, | ||
| 372 | 0x4a, 0x00, | ||
| 373 | 0x4b, 0xf8, | ||
| 374 | 0x52, 0x30, | ||
| 375 | 0x55, 0xae, | ||
| 376 | 0x56, 0x47, | ||
| 377 | 0x57, 0xe1, | ||
| 378 | 0x58, 0x3a, | ||
| 379 | 0x5a, 0x1e, | ||
| 380 | 0x5b, 0x34, | ||
| 381 | 0x60, 0x00, | ||
| 382 | 0x63, 0x00, | ||
| 383 | 0x64, 0x00, | ||
| 384 | 0x65, 0x00, | ||
| 385 | 0x66, 0x00, | ||
| 386 | 0x67, 0x00, | ||
| 387 | 0x68, 0x00, | ||
| 388 | 0x69, 0x00, | ||
| 389 | 0x6a, 0x02, | ||
| 390 | 0x6b, 0x00, | ||
| 391 | 0x70, 0xff, | ||
| 392 | 0x71, 0x00, | ||
| 393 | 0x72, 0x00, | ||
| 394 | 0x73, 0x00, | ||
| 395 | 0x74, 0x0c, | ||
| 396 | 0x80, 0x00, | ||
| 397 | 0x81, 0x00, | ||
| 398 | 0x82, 0x00, | ||
| 399 | 0x83, 0x00, | ||
| 400 | 0x84, 0x04, | ||
| 401 | 0x85, 0x80, | ||
| 402 | 0x86, 0x24, | ||
| 403 | 0x87, 0x78, | ||
| 404 | 0x88, 0x10, | ||
| 405 | 0x89, 0x00, | ||
| 406 | 0x90, 0x01, | ||
| 407 | 0x91, 0x01, | ||
| 408 | 0xa0, 0x04, | ||
| 409 | 0xa1, 0x00, | ||
| 410 | 0xa2, 0x00, | ||
| 411 | 0xb0, 0x91, | ||
| 412 | 0xb1, 0x0b, | ||
| 413 | 0xc0, 0x53, | ||
| 414 | 0xc1, 0x70, | ||
| 415 | 0xc2, 0x12, | ||
| 416 | 0xd0, 0x00, | ||
| 417 | 0xd1, 0x00, | ||
| 418 | 0xd2, 0x00, | ||
| 419 | 0xd3, 0x00, | ||
| 420 | 0xd4, 0x00, | ||
| 421 | 0xd5, 0x00, | ||
| 422 | 0xde, 0x00, | ||
| 423 | 0xdf, 0x00, | ||
| 424 | 0x61, 0x49, | ||
| 425 | 0x62, 0x0b, | ||
| 426 | 0x53, 0x08, | ||
| 427 | 0x59, 0x08, | ||
| 428 | 0xff, 0xff, | ||
| 429 | }; | ||
| 430 | |||
| 338 | static struct stv0297_config alps_tdee4_stv0297_config = { | 431 | static struct stv0297_config alps_tdee4_stv0297_config = { |
| 339 | .demod_address = 0x1c, | 432 | .demod_address = 0x1c, |
| 433 | .inittab = alps_tdee4_stv0297_inittab, | ||
| 340 | // .invert = 1, | 434 | // .invert = 1, |
| 341 | // .pll_set = alps_tdee4_stv0297_pll_set, | 435 | // .pll_set = alps_tdee4_stv0297_pll_set, |
| 342 | }; | 436 | }; |
| @@ -370,7 +464,7 @@ int flexcop_frontend_init(struct flexcop_device *fc) | |||
| 370 | info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); | 464 | info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); |
| 371 | } else | 465 | } else |
| 372 | /* try the cable dvb (stv0297) */ | 466 | /* try the cable dvb (stv0297) */ |
| 373 | if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap, 0xf8)) != NULL) { | 467 | if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { |
| 374 | fc->dev_type = FC_CABLE; | 468 | fc->dev_type = FC_CABLE; |
| 375 | info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); | 469 | info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); |
| 376 | } else | 470 | } else |
diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c index 3c5a8e273c4a..f29571450038 100644 --- a/drivers/media/dvb/bt8xx/bt878.c +++ b/drivers/media/dvb/bt8xx/bt878.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card | 2 | * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> | 4 | * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> |
| 5 | * | 5 | * |
| 6 | * large parts based on the bttv driver | 6 | * large parts based on the bttv driver |
| 7 | * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de) | 7 | * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de) |
| @@ -219,7 +219,7 @@ void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin, | |||
| 219 | controlreg &= ~0x1f; | 219 | controlreg &= ~0x1f; |
| 220 | controlreg |= 0x1b; | 220 | controlreg |= 0x1b; |
| 221 | 221 | ||
| 222 | btwrite(cpu_to_le32(bt->risc_dma), BT878_ARISC_START); | 222 | btwrite(bt->risc_dma, BT878_ARISC_START); |
| 223 | 223 | ||
| 224 | /* original int mask had : | 224 | /* original int mask had : |
| 225 | * 6 2 8 4 0 | 225 | * 6 2 8 4 0 |
diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h index 837623f7fcdf..a73baf00ca39 100644 --- a/drivers/media/dvb/bt8xx/bt878.h +++ b/drivers/media/dvb/bt8xx/bt878.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | bt878.h - Bt878 audio module (register offsets) | 2 | bt878.h - Bt878 audio module (register offsets) |
| 3 | 3 | ||
| 4 | Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> | 4 | Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> |
| 5 | 5 | ||
| 6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 07a0b0a968a6..34a837a1abf4 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | |||
| 3 | Frontend/Card driver for TwinHan DST Frontend | 2 | Frontend/Card driver for TwinHan DST Frontend |
| 4 | Copyright (C) 2003 Jamie Honan | 3 | Copyright (C) 2003 Jamie Honan |
| 5 | Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) | 4 | Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com) |
| @@ -19,7 +18,6 @@ | |||
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ | 19 | */ |
| 21 | 20 | ||
| 22 | |||
| 23 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
| 24 | #include <linux/module.h> | 22 | #include <linux/module.h> |
| 25 | #include <linux/init.h> | 23 | #include <linux/init.h> |
| @@ -28,31 +26,45 @@ | |||
| 28 | #include <linux/vmalloc.h> | 26 | #include <linux/vmalloc.h> |
| 29 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
| 30 | #include <asm/div64.h> | 28 | #include <asm/div64.h> |
| 31 | |||
| 32 | #include "dvb_frontend.h" | 29 | #include "dvb_frontend.h" |
| 33 | #include "dst_priv.h" | 30 | #include "dst_priv.h" |
| 34 | #include "dst_common.h" | 31 | #include "dst_common.h" |
| 35 | 32 | ||
| 36 | |||
| 37 | static unsigned int verbose = 1; | 33 | static unsigned int verbose = 1; |
| 38 | module_param(verbose, int, 0644); | 34 | module_param(verbose, int, 0644); |
| 39 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); | 35 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); |
| 40 | 36 | ||
| 41 | static unsigned int debug = 1; | ||
| 42 | module_param(debug, int, 0644); | ||
| 43 | MODULE_PARM_DESC(debug, "debug messages, default is 0 (yes)"); | ||
| 44 | |||
| 45 | static unsigned int dst_addons; | 37 | static unsigned int dst_addons; |
| 46 | module_param(dst_addons, int, 0644); | 38 | module_param(dst_addons, int, 0644); |
| 47 | MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)"); | 39 | MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)"); |
| 48 | 40 | ||
| 49 | #define dprintk if (debug) printk | 41 | #define HAS_LOCK 1 |
| 50 | 42 | #define ATTEMPT_TUNE 2 | |
| 51 | #define HAS_LOCK 1 | 43 | #define HAS_POWER 4 |
| 52 | #define ATTEMPT_TUNE 2 | 44 | |
| 53 | #define HAS_POWER 4 | 45 | #define DST_ERROR 0 |
| 54 | 46 | #define DST_NOTICE 1 | |
| 55 | static void dst_packsize(struct dst_state* state, int psize) | 47 | #define DST_INFO 2 |
| 48 | #define DST_DEBUG 3 | ||
| 49 | |||
| 50 | #define dprintk(x, y, z, format, arg...) do { \ | ||
| 51 | if (z) { \ | ||
| 52 | if ((x > DST_ERROR) && (x > y)) \ | ||
| 53 | printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ | ||
| 54 | else if ((x > DST_NOTICE) && (x > y)) \ | ||
| 55 | printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ | ||
| 56 | else if ((x > DST_INFO) && (x > y)) \ | ||
| 57 | printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ | ||
| 58 | else if ((x > DST_DEBUG) && (x > y)) \ | ||
| 59 | printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ | ||
| 60 | } else { \ | ||
| 61 | if (x > y) \ | ||
| 62 | printk(format, ##arg); \ | ||
| 63 | } \ | ||
| 64 | } while(0) | ||
| 65 | |||
| 66 | |||
| 67 | static void dst_packsize(struct dst_state *state, int psize) | ||
| 56 | { | 68 | { |
| 57 | union dst_gpio_packet bits; | 69 | union dst_gpio_packet bits; |
| 58 | 70 | ||
| @@ -60,7 +72,7 @@ static void dst_packsize(struct dst_state* state, int psize) | |||
| 60 | bt878_device_control(state->bt, DST_IG_TS, &bits); | 72 | bt878_device_control(state->bt, DST_IG_TS, &bits); |
| 61 | } | 73 | } |
| 62 | 74 | ||
| 63 | int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay) | 75 | int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb, u32 outhigh, int delay) |
| 64 | { | 76 | { |
| 65 | union dst_gpio_packet enb; | 77 | union dst_gpio_packet enb; |
| 66 | union dst_gpio_packet bits; | 78 | union dst_gpio_packet bits; |
| @@ -68,63 +80,55 @@ int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int | |||
| 68 | 80 | ||
| 69 | enb.enb.mask = mask; | 81 | enb.enb.mask = mask; |
| 70 | enb.enb.enable = enbb; | 82 | enb.enb.enable = enbb; |
| 71 | if (verbose > 4) | ||
| 72 | dprintk("%s: mask=[%04x], enbb=[%04x], outhigh=[%04x]\n", __FUNCTION__, mask, enbb, outhigh); | ||
| 73 | 83 | ||
| 84 | dprintk(verbose, DST_INFO, 1, "mask=[%04x], enbb=[%04x], outhigh=[%04x]", mask, enbb, outhigh); | ||
| 74 | if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { | 85 | if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { |
| 75 | dprintk("%s: dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)\n", __FUNCTION__, err, mask, enbb); | 86 | dprintk(verbose, DST_INFO, 1, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)", err, mask, enbb); |
| 76 | return -EREMOTEIO; | 87 | return -EREMOTEIO; |
| 77 | } | 88 | } |
| 78 | udelay(1000); | 89 | udelay(1000); |
| 79 | /* because complete disabling means no output, no need to do output packet */ | 90 | /* because complete disabling means no output, no need to do output packet */ |
| 80 | if (enbb == 0) | 91 | if (enbb == 0) |
| 81 | return 0; | 92 | return 0; |
| 82 | |||
| 83 | if (delay) | 93 | if (delay) |
| 84 | msleep(10); | 94 | msleep(10); |
| 85 | |||
| 86 | bits.outp.mask = enbb; | 95 | bits.outp.mask = enbb; |
| 87 | bits.outp.highvals = outhigh; | 96 | bits.outp.highvals = outhigh; |
| 88 | |||
| 89 | if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { | 97 | if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { |
| 90 | dprintk("%s: dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)\n", __FUNCTION__, err, enbb, outhigh); | 98 | dprintk(verbose, DST_INFO, 1, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)", err, enbb, outhigh); |
| 91 | return -EREMOTEIO; | 99 | return -EREMOTEIO; |
| 92 | } | 100 | } |
| 101 | |||
| 93 | return 0; | 102 | return 0; |
| 94 | } | 103 | } |
| 95 | EXPORT_SYMBOL(dst_gpio_outb); | 104 | EXPORT_SYMBOL(dst_gpio_outb); |
| 96 | 105 | ||
| 97 | int dst_gpio_inb(struct dst_state *state, u8 * result) | 106 | int dst_gpio_inb(struct dst_state *state, u8 *result) |
| 98 | { | 107 | { |
| 99 | union dst_gpio_packet rd_packet; | 108 | union dst_gpio_packet rd_packet; |
| 100 | int err; | 109 | int err; |
| 101 | 110 | ||
| 102 | *result = 0; | 111 | *result = 0; |
| 103 | |||
| 104 | if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) { | 112 | if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) { |
| 105 | dprintk("%s: dst_gpio_inb error (err == %i)\n", __FUNCTION__, err); | 113 | dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)\n", err); |
| 106 | return -EREMOTEIO; | 114 | return -EREMOTEIO; |
| 107 | } | 115 | } |
| 108 | |||
| 109 | *result = (u8) rd_packet.rd.value; | 116 | *result = (u8) rd_packet.rd.value; |
| 117 | |||
| 110 | return 0; | 118 | return 0; |
| 111 | } | 119 | } |
| 112 | EXPORT_SYMBOL(dst_gpio_inb); | 120 | EXPORT_SYMBOL(dst_gpio_inb); |
| 113 | 121 | ||
| 114 | int rdc_reset_state(struct dst_state *state) | 122 | int rdc_reset_state(struct dst_state *state) |
| 115 | { | 123 | { |
| 116 | if (verbose > 1) | 124 | dprintk(verbose, DST_INFO, 1, "Resetting state machine"); |
| 117 | dprintk("%s: Resetting state machine\n", __FUNCTION__); | ||
| 118 | |||
| 119 | if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) { | 125 | if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) { |
| 120 | dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); | 126 | dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); |
| 121 | return -1; | 127 | return -1; |
| 122 | } | 128 | } |
| 123 | |||
| 124 | msleep(10); | 129 | msleep(10); |
| 125 | |||
| 126 | if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) { | 130 | if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) { |
| 127 | dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); | 131 | dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); |
| 128 | msleep(10); | 132 | msleep(10); |
| 129 | return -1; | 133 | return -1; |
| 130 | } | 134 | } |
| @@ -135,16 +139,14 @@ EXPORT_SYMBOL(rdc_reset_state); | |||
| 135 | 139 | ||
| 136 | int rdc_8820_reset(struct dst_state *state) | 140 | int rdc_8820_reset(struct dst_state *state) |
| 137 | { | 141 | { |
| 138 | if (verbose > 1) | 142 | dprintk(verbose, DST_DEBUG, 1, "Resetting DST"); |
| 139 | dprintk("%s: Resetting DST\n", __FUNCTION__); | ||
| 140 | |||
| 141 | if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { | 143 | if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { |
| 142 | dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); | 144 | dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); |
| 143 | return -1; | 145 | return -1; |
| 144 | } | 146 | } |
| 145 | udelay(1000); | 147 | udelay(1000); |
| 146 | if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { | 148 | if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { |
| 147 | dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); | 149 | dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); |
| 148 | return -1; | 150 | return -1; |
| 149 | } | 151 | } |
| 150 | 152 | ||
| @@ -155,10 +157,11 @@ EXPORT_SYMBOL(rdc_8820_reset); | |||
| 155 | int dst_pio_enable(struct dst_state *state) | 157 | int dst_pio_enable(struct dst_state *state) |
| 156 | { | 158 | { |
| 157 | if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) { | 159 | if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) { |
| 158 | dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); | 160 | dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); |
| 159 | return -1; | 161 | return -1; |
| 160 | } | 162 | } |
| 161 | udelay(1000); | 163 | udelay(1000); |
| 164 | |||
| 162 | return 0; | 165 | return 0; |
| 163 | } | 166 | } |
| 164 | EXPORT_SYMBOL(dst_pio_enable); | 167 | EXPORT_SYMBOL(dst_pio_enable); |
| @@ -166,7 +169,7 @@ EXPORT_SYMBOL(dst_pio_enable); | |||
| 166 | int dst_pio_disable(struct dst_state *state) | 169 | int dst_pio_disable(struct dst_state *state) |
| 167 | { | 170 | { |
| 168 | if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) { | 171 | if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) { |
| 169 | dprintk("%s: dst_gpio_outb ERROR !\n", __FUNCTION__); | 172 | dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !"); |
| 170 | return -1; | 173 | return -1; |
| 171 | } | 174 | } |
| 172 | if (state->type_flags & DST_TYPE_HAS_FW_1) | 175 | if (state->type_flags & DST_TYPE_HAS_FW_1) |
| @@ -183,19 +186,16 @@ int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode) | |||
| 183 | 186 | ||
| 184 | for (i = 0; i < 200; i++) { | 187 | for (i = 0; i < 200; i++) { |
| 185 | if (dst_gpio_inb(state, &reply) < 0) { | 188 | if (dst_gpio_inb(state, &reply) < 0) { |
| 186 | dprintk("%s: dst_gpio_inb ERROR !\n", __FUNCTION__); | 189 | dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !"); |
| 187 | return -1; | 190 | return -1; |
| 188 | } | 191 | } |
| 189 | |||
| 190 | if ((reply & RDC_8820_PIO_0_ENABLE) == 0) { | 192 | if ((reply & RDC_8820_PIO_0_ENABLE) == 0) { |
| 191 | if (verbose > 4) | 193 | dprintk(verbose, DST_INFO, 1, "dst wait ready after %d", i); |
| 192 | dprintk("%s: dst wait ready after %d\n", __FUNCTION__, i); | ||
| 193 | return 1; | 194 | return 1; |
| 194 | } | 195 | } |
| 195 | msleep(10); | 196 | msleep(10); |
| 196 | } | 197 | } |
| 197 | if (verbose > 1) | 198 | dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i); |
| 198 | dprintk("%s: dst wait NOT ready after %d\n", __FUNCTION__, i); | ||
| 199 | 199 | ||
| 200 | return 0; | 200 | return 0; |
| 201 | } | 201 | } |
| @@ -203,7 +203,7 @@ EXPORT_SYMBOL(dst_wait_dst_ready); | |||
| 203 | 203 | ||
| 204 | int dst_error_recovery(struct dst_state *state) | 204 | int dst_error_recovery(struct dst_state *state) |
| 205 | { | 205 | { |
| 206 | dprintk("%s: Trying to return from previous errors...\n", __FUNCTION__); | 206 | dprintk(verbose, DST_NOTICE, 1, "Trying to return from previous errors."); |
| 207 | dst_pio_disable(state); | 207 | dst_pio_disable(state); |
| 208 | msleep(10); | 208 | msleep(10); |
| 209 | dst_pio_enable(state); | 209 | dst_pio_enable(state); |
| @@ -215,7 +215,7 @@ EXPORT_SYMBOL(dst_error_recovery); | |||
| 215 | 215 | ||
| 216 | int dst_error_bailout(struct dst_state *state) | 216 | int dst_error_bailout(struct dst_state *state) |
| 217 | { | 217 | { |
| 218 | dprintk("%s: Trying to bailout from previous error...\n", __FUNCTION__); | 218 | dprintk(verbose, DST_INFO, 1, "Trying to bailout from previous error."); |
| 219 | rdc_8820_reset(state); | 219 | rdc_8820_reset(state); |
| 220 | dst_pio_disable(state); | 220 | dst_pio_disable(state); |
| 221 | msleep(10); | 221 | msleep(10); |
| @@ -224,17 +224,15 @@ int dst_error_bailout(struct dst_state *state) | |||
| 224 | } | 224 | } |
| 225 | EXPORT_SYMBOL(dst_error_bailout); | 225 | EXPORT_SYMBOL(dst_error_bailout); |
| 226 | 226 | ||
| 227 | 227 | int dst_comm_init(struct dst_state *state) | |
| 228 | int dst_comm_init(struct dst_state* state) | ||
| 229 | { | 228 | { |
| 230 | if (verbose > 1) | 229 | dprintk(verbose, DST_INFO, 1, "Initializing DST."); |
| 231 | dprintk ("%s: Initializing DST..\n", __FUNCTION__); | ||
| 232 | if ((dst_pio_enable(state)) < 0) { | 230 | if ((dst_pio_enable(state)) < 0) { |
| 233 | dprintk("%s: PIO Enable Failed.\n", __FUNCTION__); | 231 | dprintk(verbose, DST_ERROR, 1, "PIO Enable Failed"); |
| 234 | return -1; | 232 | return -1; |
| 235 | } | 233 | } |
| 236 | if ((rdc_reset_state(state)) < 0) { | 234 | if ((rdc_reset_state(state)) < 0) { |
| 237 | dprintk("%s: RDC 8820 State RESET Failed.\n", __FUNCTION__); | 235 | dprintk(verbose, DST_ERROR, 1, "RDC 8820 State RESET Failed."); |
| 238 | return -1; | 236 | return -1; |
| 239 | } | 237 | } |
| 240 | if (state->type_flags & DST_TYPE_HAS_FW_1) | 238 | if (state->type_flags & DST_TYPE_HAS_FW_1) |
| @@ -246,36 +244,33 @@ int dst_comm_init(struct dst_state* state) | |||
| 246 | } | 244 | } |
| 247 | EXPORT_SYMBOL(dst_comm_init); | 245 | EXPORT_SYMBOL(dst_comm_init); |
| 248 | 246 | ||
| 249 | |||
| 250 | int write_dst(struct dst_state *state, u8 *data, u8 len) | 247 | int write_dst(struct dst_state *state, u8 *data, u8 len) |
| 251 | { | 248 | { |
| 252 | struct i2c_msg msg = { | 249 | struct i2c_msg msg = { |
| 253 | .addr = state->config->demod_address,.flags = 0,.buf = data,.len = len | 250 | .addr = state->config->demod_address, |
| 251 | .flags = 0, | ||
| 252 | .buf = data, | ||
| 253 | .len = len | ||
| 254 | }; | 254 | }; |
| 255 | 255 | ||
| 256 | int err; | 256 | int err; |
| 257 | int cnt; | 257 | u8 cnt, i; |
| 258 | if (debug && (verbose > 4)) { | 258 | |
| 259 | u8 i; | 259 | dprintk(verbose, DST_NOTICE, 0, "writing [ "); |
| 260 | if (verbose > 4) { | 260 | for (i = 0; i < len; i++) |
| 261 | dprintk("%s writing [ ", __FUNCTION__); | 261 | dprintk(verbose, DST_NOTICE, 0, "%02x ", data[i]); |
| 262 | for (i = 0; i < len; i++) | 262 | dprintk(verbose, DST_NOTICE, 0, "]\n"); |
| 263 | dprintk("%02x ", data[i]); | 263 | |
| 264 | dprintk("]\n"); | ||
| 265 | } | ||
| 266 | } | ||
| 267 | for (cnt = 0; cnt < 2; cnt++) { | 264 | for (cnt = 0; cnt < 2; cnt++) { |
| 268 | if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { | 265 | if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { |
| 269 | dprintk("%s: _write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, data[0]); | 266 | dprintk(verbose, DST_INFO, 1, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, data[0]); |
| 270 | dst_error_recovery(state); | 267 | dst_error_recovery(state); |
| 271 | continue; | 268 | continue; |
| 272 | } else | 269 | } else |
| 273 | break; | 270 | break; |
| 274 | } | 271 | } |
| 275 | |||
| 276 | if (cnt >= 2) { | 272 | if (cnt >= 2) { |
| 277 | if (verbose > 1) | 273 | dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); |
| 278 | printk("%s: RDC 8820 RESET...\n", __FUNCTION__); | ||
| 279 | dst_error_bailout(state); | 274 | dst_error_bailout(state); |
| 280 | 275 | ||
| 281 | return -1; | 276 | return -1; |
| @@ -285,36 +280,37 @@ int write_dst(struct dst_state *state, u8 *data, u8 len) | |||
| 285 | } | 280 | } |
| 286 | EXPORT_SYMBOL(write_dst); | 281 | EXPORT_SYMBOL(write_dst); |
| 287 | 282 | ||
| 288 | int read_dst(struct dst_state *state, u8 * ret, u8 len) | 283 | int read_dst(struct dst_state *state, u8 *ret, u8 len) |
| 289 | { | 284 | { |
| 290 | struct i2c_msg msg = {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = ret,.len = len }; | 285 | struct i2c_msg msg = { |
| 286 | .addr = state->config->demod_address, | ||
| 287 | .flags = I2C_M_RD, | ||
| 288 | .buf = ret, | ||
| 289 | .len = len | ||
| 290 | }; | ||
| 291 | |||
| 291 | int err; | 292 | int err; |
| 292 | int cnt; | 293 | int cnt; |
| 293 | 294 | ||
| 294 | for (cnt = 0; cnt < 2; cnt++) { | 295 | for (cnt = 0; cnt < 2; cnt++) { |
| 295 | if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { | 296 | if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { |
| 296 | 297 | dprintk(verbose, DST_INFO, 1, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, ret[0]); | |
| 297 | dprintk("%s: read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)\n", __FUNCTION__, err, len, ret[0]); | ||
| 298 | dst_error_recovery(state); | 298 | dst_error_recovery(state); |
| 299 | |||
| 300 | continue; | 299 | continue; |
| 301 | } else | 300 | } else |
| 302 | break; | 301 | break; |
| 303 | } | 302 | } |
| 304 | if (cnt >= 2) { | 303 | if (cnt >= 2) { |
| 305 | if (verbose > 1) | 304 | dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET"); |
| 306 | printk("%s: RDC 8820 RESET...\n", __FUNCTION__); | ||
| 307 | dst_error_bailout(state); | 305 | dst_error_bailout(state); |
| 308 | 306 | ||
| 309 | return -1; | 307 | return -1; |
| 310 | } | 308 | } |
| 311 | if (debug && (verbose > 4)) { | 309 | dprintk(verbose, DST_DEBUG, 1, "reply is 0x%x", ret[0]); |
| 312 | dprintk("%s reply is 0x%x\n", __FUNCTION__, ret[0]); | 310 | for (err = 1; err < len; err++) |
| 313 | for (err = 1; err < len; err++) | 311 | dprintk(verbose, DST_DEBUG, 0, " 0x%x", ret[err]); |
| 314 | dprintk(" 0x%x", ret[err]); | 312 | if (err > 1) |
| 315 | if (err > 1) | 313 | dprintk(verbose, DST_DEBUG, 0, "\n"); |
| 316 | dprintk("\n"); | ||
| 317 | } | ||
| 318 | 314 | ||
| 319 | return 0; | 315 | return 0; |
| 320 | } | 316 | } |
| @@ -323,19 +319,16 @@ EXPORT_SYMBOL(read_dst); | |||
| 323 | static int dst_set_polarization(struct dst_state *state) | 319 | static int dst_set_polarization(struct dst_state *state) |
| 324 | { | 320 | { |
| 325 | switch (state->voltage) { | 321 | switch (state->voltage) { |
| 326 | case SEC_VOLTAGE_13: // vertical | 322 | case SEC_VOLTAGE_13: /* Vertical */ |
| 327 | printk("%s: Polarization=[Vertical]\n", __FUNCTION__); | 323 | dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]"); |
| 328 | state->tx_tuna[8] &= ~0x40; //1 | 324 | state->tx_tuna[8] &= ~0x40; |
| 329 | break; | 325 | break; |
| 330 | 326 | case SEC_VOLTAGE_18: /* Horizontal */ | |
| 331 | case SEC_VOLTAGE_18: // horizontal | 327 | dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]"); |
| 332 | printk("%s: Polarization=[Horizontal]\n", __FUNCTION__); | 328 | state->tx_tuna[8] |= 0x40; |
| 333 | state->tx_tuna[8] |= 0x40; // 0 | 329 | break; |
| 334 | break; | 330 | case SEC_VOLTAGE_OFF: |
| 335 | 331 | break; | |
| 336 | case SEC_VOLTAGE_OFF: | ||
| 337 | |||
| 338 | break; | ||
| 339 | } | 332 | } |
| 340 | 333 | ||
| 341 | return 0; | 334 | return 0; |
| @@ -344,14 +337,12 @@ static int dst_set_polarization(struct dst_state *state) | |||
| 344 | static int dst_set_freq(struct dst_state *state, u32 freq) | 337 | static int dst_set_freq(struct dst_state *state, u32 freq) |
| 345 | { | 338 | { |
| 346 | state->frequency = freq; | 339 | state->frequency = freq; |
| 347 | if (debug > 4) | 340 | dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq); |
| 348 | dprintk("%s: set Frequency %u\n", __FUNCTION__, freq); | ||
| 349 | 341 | ||
| 350 | if (state->dst_type == DST_TYPE_IS_SAT) { | 342 | if (state->dst_type == DST_TYPE_IS_SAT) { |
| 351 | freq = freq / 1000; | 343 | freq = freq / 1000; |
| 352 | if (freq < 950 || freq > 2150) | 344 | if (freq < 950 || freq > 2150) |
| 353 | return -EINVAL; | 345 | return -EINVAL; |
| 354 | |||
| 355 | state->tx_tuna[2] = (freq >> 8); | 346 | state->tx_tuna[2] = (freq >> 8); |
| 356 | state->tx_tuna[3] = (u8) freq; | 347 | state->tx_tuna[3] = (u8) freq; |
| 357 | state->tx_tuna[4] = 0x01; | 348 | state->tx_tuna[4] = 0x01; |
| @@ -360,27 +351,25 @@ static int dst_set_freq(struct dst_state *state, u32 freq) | |||
| 360 | if (freq < 1531) | 351 | if (freq < 1531) |
| 361 | state->tx_tuna[8] |= 0x04; | 352 | state->tx_tuna[8] |= 0x04; |
| 362 | } | 353 | } |
| 363 | |||
| 364 | } else if (state->dst_type == DST_TYPE_IS_TERR) { | 354 | } else if (state->dst_type == DST_TYPE_IS_TERR) { |
| 365 | freq = freq / 1000; | 355 | freq = freq / 1000; |
| 366 | if (freq < 137000 || freq > 858000) | 356 | if (freq < 137000 || freq > 858000) |
| 367 | return -EINVAL; | 357 | return -EINVAL; |
| 368 | |||
| 369 | state->tx_tuna[2] = (freq >> 16) & 0xff; | 358 | state->tx_tuna[2] = (freq >> 16) & 0xff; |
| 370 | state->tx_tuna[3] = (freq >> 8) & 0xff; | 359 | state->tx_tuna[3] = (freq >> 8) & 0xff; |
| 371 | state->tx_tuna[4] = (u8) freq; | 360 | state->tx_tuna[4] = (u8) freq; |
| 372 | |||
| 373 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { | 361 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { |
| 362 | freq = freq / 1000; | ||
| 374 | state->tx_tuna[2] = (freq >> 16) & 0xff; | 363 | state->tx_tuna[2] = (freq >> 16) & 0xff; |
| 375 | state->tx_tuna[3] = (freq >> 8) & 0xff; | 364 | state->tx_tuna[3] = (freq >> 8) & 0xff; |
| 376 | state->tx_tuna[4] = (u8) freq; | 365 | state->tx_tuna[4] = (u8) freq; |
| 377 | |||
| 378 | } else | 366 | } else |
| 379 | return -EINVAL; | 367 | return -EINVAL; |
| 368 | |||
| 380 | return 0; | 369 | return 0; |
| 381 | } | 370 | } |
| 382 | 371 | ||
| 383 | static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) | 372 | static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth) |
| 384 | { | 373 | { |
| 385 | state->bandwidth = bandwidth; | 374 | state->bandwidth = bandwidth; |
| 386 | 375 | ||
| @@ -388,103 +377,95 @@ static int dst_set_bandwidth(struct dst_state* state, fe_bandwidth_t bandwidth) | |||
| 388 | return 0; | 377 | return 0; |
| 389 | 378 | ||
| 390 | switch (bandwidth) { | 379 | switch (bandwidth) { |
| 391 | case BANDWIDTH_6_MHZ: | 380 | case BANDWIDTH_6_MHZ: |
| 392 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) | 381 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) |
| 393 | state->tx_tuna[7] = 0x06; | 382 | state->tx_tuna[7] = 0x06; |
| 394 | else { | 383 | else { |
| 395 | state->tx_tuna[6] = 0x06; | 384 | state->tx_tuna[6] = 0x06; |
| 396 | state->tx_tuna[7] = 0x00; | 385 | state->tx_tuna[7] = 0x00; |
| 397 | } | 386 | } |
| 398 | break; | 387 | break; |
| 399 | 388 | case BANDWIDTH_7_MHZ: | |
| 400 | case BANDWIDTH_7_MHZ: | 389 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) |
| 401 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) | 390 | state->tx_tuna[7] = 0x07; |
| 402 | state->tx_tuna[7] = 0x07; | 391 | else { |
| 403 | else { | 392 | state->tx_tuna[6] = 0x07; |
| 404 | state->tx_tuna[6] = 0x07; | 393 | state->tx_tuna[7] = 0x00; |
| 405 | state->tx_tuna[7] = 0x00; | 394 | } |
| 406 | } | 395 | break; |
| 407 | break; | 396 | case BANDWIDTH_8_MHZ: |
| 408 | 397 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) | |
| 409 | case BANDWIDTH_8_MHZ: | 398 | state->tx_tuna[7] = 0x08; |
| 410 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) | 399 | else { |
| 411 | state->tx_tuna[7] = 0x08; | 400 | state->tx_tuna[6] = 0x08; |
| 412 | else { | 401 | state->tx_tuna[7] = 0x00; |
| 413 | state->tx_tuna[6] = 0x08; | 402 | } |
| 414 | state->tx_tuna[7] = 0x00; | 403 | break; |
| 415 | } | 404 | default: |
| 416 | break; | 405 | return -EINVAL; |
| 417 | |||
| 418 | default: | ||
| 419 | return -EINVAL; | ||
| 420 | } | 406 | } |
| 407 | |||
| 421 | return 0; | 408 | return 0; |
| 422 | } | 409 | } |
| 423 | 410 | ||
| 424 | static int dst_set_inversion(struct dst_state* state, fe_spectral_inversion_t inversion) | 411 | static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion) |
| 425 | { | 412 | { |
| 426 | state->inversion = inversion; | 413 | state->inversion = inversion; |
| 427 | switch (inversion) { | 414 | switch (inversion) { |
| 428 | case INVERSION_OFF: // Inversion = Normal | 415 | case INVERSION_OFF: /* Inversion = Normal */ |
| 429 | state->tx_tuna[8] &= ~0x80; | 416 | state->tx_tuna[8] &= ~0x80; |
| 430 | break; | 417 | break; |
| 431 | 418 | case INVERSION_ON: | |
| 432 | case INVERSION_ON: | 419 | state->tx_tuna[8] |= 0x80; |
| 433 | state->tx_tuna[8] |= 0x80; | 420 | break; |
| 434 | break; | 421 | default: |
| 435 | default: | 422 | return -EINVAL; |
| 436 | return -EINVAL; | ||
| 437 | } | 423 | } |
| 424 | |||
| 438 | return 0; | 425 | return 0; |
| 439 | } | 426 | } |
| 440 | 427 | ||
| 441 | static int dst_set_fec(struct dst_state* state, fe_code_rate_t fec) | 428 | static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec) |
| 442 | { | 429 | { |
| 443 | state->fec = fec; | 430 | state->fec = fec; |
| 444 | return 0; | 431 | return 0; |
| 445 | } | 432 | } |
| 446 | 433 | ||
| 447 | static fe_code_rate_t dst_get_fec(struct dst_state* state) | 434 | static fe_code_rate_t dst_get_fec(struct dst_state *state) |
| 448 | { | 435 | { |
| 449 | return state->fec; | 436 | return state->fec; |
| 450 | } | 437 | } |
| 451 | 438 | ||
| 452 | static int dst_set_symbolrate(struct dst_state* state, u32 srate) | 439 | static int dst_set_symbolrate(struct dst_state *state, u32 srate) |
| 453 | { | 440 | { |
| 454 | u8 *val; | ||
| 455 | u32 symcalc; | 441 | u32 symcalc; |
| 456 | u64 sval; | 442 | u64 sval; |
| 457 | 443 | ||
| 458 | state->symbol_rate = srate; | 444 | state->symbol_rate = srate; |
| 459 | |||
| 460 | if (state->dst_type == DST_TYPE_IS_TERR) { | 445 | if (state->dst_type == DST_TYPE_IS_TERR) { |
| 461 | return 0; | 446 | return 0; |
| 462 | } | 447 | } |
| 463 | if (debug > 4) | 448 | dprintk(verbose, DST_INFO, 1, "set symrate %u", srate); |
| 464 | dprintk("%s: set symrate %u\n", __FUNCTION__, srate); | ||
| 465 | srate /= 1000; | 449 | srate /= 1000; |
| 466 | val = &state->tx_tuna[0]; | ||
| 467 | |||
| 468 | if (state->type_flags & DST_TYPE_HAS_SYMDIV) { | 450 | if (state->type_flags & DST_TYPE_HAS_SYMDIV) { |
| 469 | sval = srate; | 451 | sval = srate; |
| 470 | sval <<= 20; | 452 | sval <<= 20; |
| 471 | do_div(sval, 88000); | 453 | do_div(sval, 88000); |
| 472 | symcalc = (u32) sval; | 454 | symcalc = (u32) sval; |
| 473 | 455 | dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc); | |
| 474 | if (debug > 4) | 456 | state->tx_tuna[5] = (u8) (symcalc >> 12); |
| 475 | dprintk("%s: set symcalc %u\n", __FUNCTION__, symcalc); | 457 | state->tx_tuna[6] = (u8) (symcalc >> 4); |
| 476 | 458 | state->tx_tuna[7] = (u8) (symcalc << 4); | |
| 477 | val[5] = (u8) (symcalc >> 12); | ||
| 478 | val[6] = (u8) (symcalc >> 4); | ||
| 479 | val[7] = (u8) (symcalc << 4); | ||
| 480 | } else { | 459 | } else { |
| 481 | val[5] = (u8) (srate >> 16) & 0x7f; | 460 | state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f; |
| 482 | val[6] = (u8) (srate >> 8); | 461 | state->tx_tuna[6] = (u8) (srate >> 8); |
| 483 | val[7] = (u8) srate; | 462 | state->tx_tuna[7] = (u8) srate; |
| 463 | } | ||
| 464 | state->tx_tuna[8] &= ~0x20; | ||
| 465 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) { | ||
| 466 | if (srate > 8000) | ||
| 467 | state->tx_tuna[8] |= 0x20; | ||
| 484 | } | 468 | } |
| 485 | val[8] &= ~0x20; | ||
| 486 | if (srate > 8000) | ||
| 487 | val[8] |= 0x20; | ||
| 488 | return 0; | 469 | return 0; |
| 489 | } | 470 | } |
| 490 | 471 | ||
| @@ -496,32 +477,27 @@ static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulatio | |||
| 496 | 477 | ||
| 497 | state->modulation = modulation; | 478 | state->modulation = modulation; |
| 498 | switch (modulation) { | 479 | switch (modulation) { |
| 499 | case QAM_16: | 480 | case QAM_16: |
| 500 | state->tx_tuna[8] = 0x10; | 481 | state->tx_tuna[8] = 0x10; |
| 501 | break; | 482 | break; |
| 502 | 483 | case QAM_32: | |
| 503 | case QAM_32: | 484 | state->tx_tuna[8] = 0x20; |
| 504 | state->tx_tuna[8] = 0x20; | 485 | break; |
| 505 | break; | 486 | case QAM_64: |
| 506 | 487 | state->tx_tuna[8] = 0x40; | |
| 507 | case QAM_64: | 488 | break; |
| 508 | state->tx_tuna[8] = 0x40; | 489 | case QAM_128: |
| 509 | break; | 490 | state->tx_tuna[8] = 0x80; |
| 510 | 491 | break; | |
| 511 | case QAM_128: | 492 | case QAM_256: |
| 512 | state->tx_tuna[8] = 0x80; | 493 | state->tx_tuna[8] = 0x00; |
| 513 | break; | 494 | break; |
| 514 | 495 | case QPSK: | |
| 515 | case QAM_256: | 496 | case QAM_AUTO: |
| 516 | state->tx_tuna[8] = 0x00; | 497 | case VSB_8: |
| 517 | break; | 498 | case VSB_16: |
| 518 | 499 | default: | |
| 519 | case QPSK: | 500 | return -EINVAL; |
| 520 | case QAM_AUTO: | ||
| 521 | case VSB_8: | ||
| 522 | case VSB_16: | ||
| 523 | default: | ||
| 524 | return -EINVAL; | ||
| 525 | 501 | ||
| 526 | } | 502 | } |
| 527 | 503 | ||
| @@ -534,7 +510,7 @@ static fe_modulation_t dst_get_modulation(struct dst_state *state) | |||
| 534 | } | 510 | } |
| 535 | 511 | ||
| 536 | 512 | ||
| 537 | u8 dst_check_sum(u8 * buf, u32 len) | 513 | u8 dst_check_sum(u8 *buf, u32 len) |
| 538 | { | 514 | { |
| 539 | u32 i; | 515 | u32 i; |
| 540 | u8 val = 0; | 516 | u8 val = 0; |
| @@ -549,26 +525,24 @@ EXPORT_SYMBOL(dst_check_sum); | |||
| 549 | 525 | ||
| 550 | static void dst_type_flags_print(u32 type_flags) | 526 | static void dst_type_flags_print(u32 type_flags) |
| 551 | { | 527 | { |
| 552 | printk("DST type flags :"); | 528 | dprintk(verbose, DST_ERROR, 0, "DST type flags :"); |
| 553 | if (type_flags & DST_TYPE_HAS_NEWTUNE) | 529 | if (type_flags & DST_TYPE_HAS_NEWTUNE) |
| 554 | printk(" 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); | 530 | dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_NEWTUNE); |
| 555 | if (type_flags & DST_TYPE_HAS_TS204) | 531 | if (type_flags & DST_TYPE_HAS_TS204) |
| 556 | printk(" 0x%x ts204", DST_TYPE_HAS_TS204); | 532 | dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204); |
| 557 | if (type_flags & DST_TYPE_HAS_SYMDIV) | 533 | if (type_flags & DST_TYPE_HAS_SYMDIV) |
| 558 | printk(" 0x%x symdiv", DST_TYPE_HAS_SYMDIV); | 534 | dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV); |
| 559 | if (type_flags & DST_TYPE_HAS_FW_1) | 535 | if (type_flags & DST_TYPE_HAS_FW_1) |
| 560 | printk(" 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); | 536 | dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1); |
| 561 | if (type_flags & DST_TYPE_HAS_FW_2) | 537 | if (type_flags & DST_TYPE_HAS_FW_2) |
| 562 | printk(" 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); | 538 | dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2); |
| 563 | if (type_flags & DST_TYPE_HAS_FW_3) | 539 | if (type_flags & DST_TYPE_HAS_FW_3) |
| 564 | printk(" 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); | 540 | dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3); |
| 565 | // if ((type_flags & DST_TYPE_HAS_FW_BUILD) && new_fw) | 541 | dprintk(verbose, DST_ERROR, 0, "\n"); |
| 566 | |||
| 567 | printk("\n"); | ||
| 568 | } | 542 | } |
| 569 | 543 | ||
| 570 | 544 | ||
| 571 | static int dst_type_print (u8 type) | 545 | static int dst_type_print(u8 type) |
| 572 | { | 546 | { |
| 573 | char *otype; | 547 | char *otype; |
| 574 | switch (type) { | 548 | switch (type) { |
| @@ -585,10 +559,10 @@ static int dst_type_print (u8 type) | |||
| 585 | break; | 559 | break; |
| 586 | 560 | ||
| 587 | default: | 561 | default: |
| 588 | printk("%s: invalid dst type %d\n", __FUNCTION__, type); | 562 | dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type); |
| 589 | return -EINVAL; | 563 | return -EINVAL; |
| 590 | } | 564 | } |
| 591 | printk("DST type : %s\n", otype); | 565 | dprintk(verbose, DST_INFO, 1, "DST type: %s", otype); |
| 592 | 566 | ||
| 593 | return 0; | 567 | return 0; |
| 594 | } | 568 | } |
| @@ -700,7 +674,7 @@ struct dst_types dst_tlist[] = { | |||
| 700 | .offset = 1, | 674 | .offset = 1, |
| 701 | .dst_type = DST_TYPE_IS_CABLE, | 675 | .dst_type = DST_TYPE_IS_CABLE, |
| 702 | .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1 | 676 | .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_1 |
| 703 | | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, | 677 | | DST_TYPE_HAS_FW_2, |
| 704 | .dst_feature = DST_TYPE_HAS_CA | 678 | .dst_feature = DST_TYPE_HAS_CA |
| 705 | }, | 679 | }, |
| 706 | 680 | ||
| @@ -708,7 +682,7 @@ struct dst_types dst_tlist[] = { | |||
| 708 | .device_id = "DCTNEW", | 682 | .device_id = "DCTNEW", |
| 709 | .offset = 1, | 683 | .offset = 1, |
| 710 | .dst_type = DST_TYPE_IS_CABLE, | 684 | .dst_type = DST_TYPE_IS_CABLE, |
| 711 | .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3, | 685 | .type_flags = DST_TYPE_HAS_NEWTUNE | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD, |
| 712 | .dst_feature = 0 | 686 | .dst_feature = 0 |
| 713 | }, | 687 | }, |
| 714 | 688 | ||
| @@ -716,7 +690,7 @@ struct dst_types dst_tlist[] = { | |||
| 716 | .device_id = "DTT-CI", | 690 | .device_id = "DTT-CI", |
| 717 | .offset = 1, | 691 | .offset = 1, |
| 718 | .dst_type = DST_TYPE_IS_TERR, | 692 | .dst_type = DST_TYPE_IS_TERR, |
| 719 | .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD, | 693 | .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2, |
| 720 | .dst_feature = 0 | 694 | .dst_feature = 0 |
| 721 | }, | 695 | }, |
| 722 | 696 | ||
| @@ -756,6 +730,71 @@ struct dst_types dst_tlist[] = { | |||
| 756 | 730 | ||
| 757 | }; | 731 | }; |
| 758 | 732 | ||
| 733 | static int dst_get_mac(struct dst_state *state) | ||
| 734 | { | ||
| 735 | u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
| 736 | get_mac[7] = dst_check_sum(get_mac, 7); | ||
| 737 | if (dst_command(state, get_mac, 8) < 0) { | ||
| 738 | dprintk(verbose, DST_INFO, 1, "Unsupported Command"); | ||
| 739 | return -1; | ||
| 740 | } | ||
| 741 | memset(&state->mac_address, '\0', 8); | ||
| 742 | memcpy(&state->mac_address, &state->rxbuffer, 6); | ||
| 743 | dprintk(verbose, DST_ERROR, 1, "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]", | ||
| 744 | state->mac_address[0], state->mac_address[1], state->mac_address[2], | ||
| 745 | state->mac_address[4], state->mac_address[5], state->mac_address[6]); | ||
| 746 | |||
| 747 | return 0; | ||
| 748 | } | ||
| 749 | |||
| 750 | static int dst_fw_ver(struct dst_state *state) | ||
| 751 | { | ||
| 752 | u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
| 753 | get_ver[7] = dst_check_sum(get_ver, 7); | ||
| 754 | if (dst_command(state, get_ver, 8) < 0) { | ||
| 755 | dprintk(verbose, DST_INFO, 1, "Unsupported Command"); | ||
| 756 | return -1; | ||
| 757 | } | ||
| 758 | memset(&state->fw_version, '\0', 8); | ||
| 759 | memcpy(&state->fw_version, &state->rxbuffer, 8); | ||
| 760 | dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x", | ||
| 761 | state->fw_version[0] >> 4, state->fw_version[0] & 0x0f, | ||
| 762 | state->fw_version[1], | ||
| 763 | state->fw_version[5], state->fw_version[6], | ||
| 764 | state->fw_version[4], state->fw_version[3], state->fw_version[2]); | ||
| 765 | |||
| 766 | return 0; | ||
| 767 | } | ||
| 768 | |||
| 769 | static int dst_card_type(struct dst_state *state) | ||
| 770 | { | ||
| 771 | u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
| 772 | get_type[7] = dst_check_sum(get_type, 7); | ||
| 773 | if (dst_command(state, get_type, 8) < 0) { | ||
| 774 | dprintk(verbose, DST_INFO, 1, "Unsupported Command"); | ||
| 775 | return -1; | ||
| 776 | } | ||
| 777 | memset(&state->card_info, '\0', 8); | ||
| 778 | memcpy(&state->card_info, &state->rxbuffer, 8); | ||
| 779 | dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]); | ||
| 780 | |||
| 781 | return 0; | ||
| 782 | } | ||
| 783 | |||
| 784 | static int dst_get_vendor(struct dst_state *state) | ||
| 785 | { | ||
| 786 | u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
| 787 | get_vendor[7] = dst_check_sum(get_vendor, 7); | ||
| 788 | if (dst_command(state, get_vendor, 8) < 0) { | ||
| 789 | dprintk(verbose, DST_INFO, 1, "Unsupported Command"); | ||
| 790 | return -1; | ||
| 791 | } | ||
| 792 | memset(&state->vendor, '\0', 8); | ||
| 793 | memcpy(&state->vendor, &state->rxbuffer, 8); | ||
| 794 | dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]); | ||
| 795 | |||
| 796 | return 0; | ||
| 797 | } | ||
| 759 | 798 | ||
| 760 | static int dst_get_device_id(struct dst_state *state) | 799 | static int dst_get_device_id(struct dst_state *state) |
| 761 | { | 800 | { |
| @@ -772,53 +811,45 @@ static int dst_get_device_id(struct dst_state *state) | |||
| 772 | 811 | ||
| 773 | if (write_dst(state, device_type, FIXED_COMM)) | 812 | if (write_dst(state, device_type, FIXED_COMM)) |
| 774 | return -1; /* Write failed */ | 813 | return -1; /* Write failed */ |
| 775 | |||
| 776 | if ((dst_pio_disable(state)) < 0) | 814 | if ((dst_pio_disable(state)) < 0) |
| 777 | return -1; | 815 | return -1; |
| 778 | |||
| 779 | if (read_dst(state, &reply, GET_ACK)) | 816 | if (read_dst(state, &reply, GET_ACK)) |
| 780 | return -1; /* Read failure */ | 817 | return -1; /* Read failure */ |
| 781 | |||
| 782 | if (reply != ACK) { | 818 | if (reply != ACK) { |
| 783 | dprintk("%s: Write not Acknowledged! [Reply=0x%02x]\n", __FUNCTION__, reply); | 819 | dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply); |
| 784 | return -1; /* Unack'd write */ | 820 | return -1; /* Unack'd write */ |
| 785 | } | 821 | } |
| 786 | |||
| 787 | if (!dst_wait_dst_ready(state, DEVICE_INIT)) | 822 | if (!dst_wait_dst_ready(state, DEVICE_INIT)) |
| 788 | return -1; /* DST not ready yet */ | 823 | return -1; /* DST not ready yet */ |
| 789 | |||
| 790 | if (read_dst(state, state->rxbuffer, FIXED_COMM)) | 824 | if (read_dst(state, state->rxbuffer, FIXED_COMM)) |
| 791 | return -1; | 825 | return -1; |
| 792 | 826 | ||
| 793 | dst_pio_disable(state); | 827 | dst_pio_disable(state); |
| 794 | |||
| 795 | if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { | 828 | if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { |
| 796 | dprintk("%s: Checksum failure! \n", __FUNCTION__); | 829 | dprintk(verbose, DST_INFO, 1, "Checksum failure!"); |
| 797 | return -1; /* Checksum failure */ | 830 | return -1; /* Checksum failure */ |
| 798 | } | 831 | } |
| 799 | |||
| 800 | state->rxbuffer[7] = '\0'; | 832 | state->rxbuffer[7] = '\0'; |
| 801 | 833 | ||
| 802 | for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE (dst_tlist); i++, p_dst_type++) { | 834 | for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE(dst_tlist); i++, p_dst_type++) { |
| 803 | if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) { | 835 | if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) { |
| 804 | use_type_flags = p_dst_type->type_flags; | 836 | use_type_flags = p_dst_type->type_flags; |
| 805 | use_dst_type = p_dst_type->dst_type; | 837 | use_dst_type = p_dst_type->dst_type; |
| 806 | 838 | ||
| 807 | /* Card capabilities */ | 839 | /* Card capabilities */ |
| 808 | state->dst_hw_cap = p_dst_type->dst_feature; | 840 | state->dst_hw_cap = p_dst_type->dst_feature; |
| 809 | printk ("%s: Recognise [%s]\n", __FUNCTION__, p_dst_type->device_id); | 841 | dprintk(verbose, DST_ERROR, 1, "Recognise [%s]\n", p_dst_type->device_id); |
| 810 | 842 | ||
| 811 | break; | 843 | break; |
| 812 | } | 844 | } |
| 813 | } | 845 | } |
| 814 | 846 | ||
| 815 | if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { | 847 | if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) { |
| 816 | printk("%s: Unable to recognize %s or %s\n", __FUNCTION__, &state->rxbuffer[0], &state->rxbuffer[1]); | 848 | dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]); |
| 817 | printk("%s: please email linux-dvb@linuxtv.org with this type in\n", __FUNCTION__); | 849 | dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in"); |
| 818 | use_dst_type = DST_TYPE_IS_SAT; | 850 | use_dst_type = DST_TYPE_IS_SAT; |
| 819 | use_type_flags = DST_TYPE_HAS_SYMDIV; | 851 | use_type_flags = DST_TYPE_HAS_SYMDIV; |
| 820 | } | 852 | } |
| 821 | |||
| 822 | dst_type_print(use_dst_type); | 853 | dst_type_print(use_dst_type); |
| 823 | state->type_flags = use_type_flags; | 854 | state->type_flags = use_type_flags; |
| 824 | state->dst_type = use_dst_type; | 855 | state->dst_type = use_dst_type; |
| @@ -834,7 +865,7 @@ static int dst_get_device_id(struct dst_state *state) | |||
| 834 | static int dst_probe(struct dst_state *state) | 865 | static int dst_probe(struct dst_state *state) |
| 835 | { | 866 | { |
| 836 | if ((rdc_8820_reset(state)) < 0) { | 867 | if ((rdc_8820_reset(state)) < 0) { |
| 837 | dprintk("%s: RDC 8820 RESET Failed.\n", __FUNCTION__); | 868 | dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed."); |
| 838 | return -1; | 869 | return -1; |
| 839 | } | 870 | } |
| 840 | if (dst_addons & DST_TYPE_HAS_CA) | 871 | if (dst_addons & DST_TYPE_HAS_CA) |
| @@ -843,80 +874,87 @@ static int dst_probe(struct dst_state *state) | |||
| 843 | msleep(100); | 874 | msleep(100); |
| 844 | 875 | ||
| 845 | if ((dst_comm_init(state)) < 0) { | 876 | if ((dst_comm_init(state)) < 0) { |
| 846 | dprintk("%s: DST Initialization Failed.\n", __FUNCTION__); | 877 | dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed."); |
| 847 | return -1; | 878 | return -1; |
| 848 | } | 879 | } |
| 849 | msleep(100); | 880 | msleep(100); |
| 850 | if (dst_get_device_id(state) < 0) { | 881 | if (dst_get_device_id(state) < 0) { |
| 851 | dprintk("%s: unknown device.\n", __FUNCTION__); | 882 | dprintk(verbose, DST_ERROR, 1, "unknown device."); |
| 852 | return -1; | 883 | return -1; |
| 853 | } | 884 | } |
| 885 | if (dst_get_mac(state) < 0) { | ||
| 886 | dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command"); | ||
| 887 | return 0; | ||
| 888 | } | ||
| 889 | if (state->type_flags & DST_TYPE_HAS_FW_BUILD) { | ||
| 890 | if (dst_fw_ver(state) < 0) { | ||
| 891 | dprintk(verbose, DST_INFO, 1, "FW: Unsupported command"); | ||
| 892 | return 0; | ||
| 893 | } | ||
| 894 | if (dst_card_type(state) < 0) { | ||
| 895 | dprintk(verbose, DST_INFO, 1, "Card: Unsupported command"); | ||
| 896 | return 0; | ||
| 897 | } | ||
| 898 | if (dst_get_vendor(state) < 0) { | ||
| 899 | dprintk(verbose, DST_INFO, 1, "Vendor: Unsupported command"); | ||
| 900 | return 0; | ||
| 901 | } | ||
| 902 | } | ||
| 854 | 903 | ||
| 855 | return 0; | 904 | return 0; |
| 856 | } | 905 | } |
| 857 | 906 | ||
| 858 | int dst_command(struct dst_state* state, u8 * data, u8 len) | 907 | int dst_command(struct dst_state *state, u8 *data, u8 len) |
| 859 | { | 908 | { |
| 860 | u8 reply; | 909 | u8 reply; |
| 861 | if ((dst_comm_init(state)) < 0) { | 910 | if ((dst_comm_init(state)) < 0) { |
| 862 | dprintk("%s: DST Communication Initialization Failed.\n", __FUNCTION__); | 911 | dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed."); |
| 863 | return -1; | 912 | return -1; |
| 864 | } | 913 | } |
| 865 | |||
| 866 | if (write_dst(state, data, len)) { | 914 | if (write_dst(state, data, len)) { |
| 867 | if (verbose > 1) | 915 | dprintk(verbose, DST_INFO, 1, "Tring to recover.. "); |
| 868 | dprintk("%s: Tring to recover.. \n", __FUNCTION__); | ||
| 869 | if ((dst_error_recovery(state)) < 0) { | 916 | if ((dst_error_recovery(state)) < 0) { |
| 870 | dprintk("%s: Recovery Failed.\n", __FUNCTION__); | 917 | dprintk(verbose, DST_ERROR, 1, "Recovery Failed."); |
| 871 | return -1; | 918 | return -1; |
| 872 | } | 919 | } |
| 873 | return -1; | 920 | return -1; |
| 874 | } | 921 | } |
| 875 | if ((dst_pio_disable(state)) < 0) { | 922 | if ((dst_pio_disable(state)) < 0) { |
| 876 | dprintk("%s: PIO Disable Failed.\n", __FUNCTION__); | 923 | dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed."); |
| 877 | return -1; | 924 | return -1; |
| 878 | } | 925 | } |
| 879 | if (state->type_flags & DST_TYPE_HAS_FW_1) | 926 | if (state->type_flags & DST_TYPE_HAS_FW_1) |
| 880 | udelay(3000); | 927 | udelay(3000); |
| 881 | |||
| 882 | if (read_dst(state, &reply, GET_ACK)) { | 928 | if (read_dst(state, &reply, GET_ACK)) { |
| 883 | if (verbose > 1) | 929 | dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); |
| 884 | dprintk("%s: Trying to recover.. \n", __FUNCTION__); | ||
| 885 | if ((dst_error_recovery(state)) < 0) { | 930 | if ((dst_error_recovery(state)) < 0) { |
| 886 | dprintk("%s: Recovery Failed.\n", __FUNCTION__); | 931 | dprintk(verbose, DST_INFO, 1, "Recovery Failed."); |
| 887 | return -1; | 932 | return -1; |
| 888 | } | 933 | } |
| 889 | return -1; | 934 | return -1; |
| 890 | } | 935 | } |
| 891 | |||
| 892 | if (reply != ACK) { | 936 | if (reply != ACK) { |
| 893 | dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); | 937 | dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply); |
| 894 | return -1; | 938 | return -1; |
| 895 | } | 939 | } |
| 896 | if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) | 940 | if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3)) |
| 897 | return 0; | 941 | return 0; |
| 898 | |||
| 899 | // udelay(3000); | ||
| 900 | if (state->type_flags & DST_TYPE_HAS_FW_1) | 942 | if (state->type_flags & DST_TYPE_HAS_FW_1) |
| 901 | udelay(3000); | 943 | udelay(3000); |
| 902 | else | 944 | else |
| 903 | udelay(2000); | 945 | udelay(2000); |
| 904 | |||
| 905 | if (!dst_wait_dst_ready(state, NO_DELAY)) | 946 | if (!dst_wait_dst_ready(state, NO_DELAY)) |
| 906 | return -1; | 947 | return -1; |
| 907 | |||
| 908 | if (read_dst(state, state->rxbuffer, FIXED_COMM)) { | 948 | if (read_dst(state, state->rxbuffer, FIXED_COMM)) { |
| 909 | if (verbose > 1) | 949 | dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. "); |
| 910 | dprintk("%s: Trying to recover.. \n", __FUNCTION__); | ||
| 911 | if ((dst_error_recovery(state)) < 0) { | 950 | if ((dst_error_recovery(state)) < 0) { |
| 912 | dprintk("%s: Recovery failed.\n", __FUNCTION__); | 951 | dprintk(verbose, DST_INFO, 1, "Recovery failed."); |
| 913 | return -1; | 952 | return -1; |
| 914 | } | 953 | } |
| 915 | return -1; | 954 | return -1; |
| 916 | } | 955 | } |
| 917 | |||
| 918 | if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { | 956 | if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { |
| 919 | dprintk("%s: checksum failure\n", __FUNCTION__); | 957 | dprintk(verbose, DST_INFO, 1, "checksum failure"); |
| 920 | return -1; | 958 | return -1; |
| 921 | } | 959 | } |
| 922 | 960 | ||
| @@ -924,11 +962,11 @@ int dst_command(struct dst_state* state, u8 * data, u8 len) | |||
| 924 | } | 962 | } |
| 925 | EXPORT_SYMBOL(dst_command); | 963 | EXPORT_SYMBOL(dst_command); |
| 926 | 964 | ||
| 927 | static int dst_get_signal(struct dst_state* state) | 965 | static int dst_get_signal(struct dst_state *state) |
| 928 | { | 966 | { |
| 929 | int retval; | 967 | int retval; |
| 930 | u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; | 968 | u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; |
| 931 | dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); | 969 | //dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); |
| 932 | if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { | 970 | if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { |
| 933 | state->decode_lock = state->decode_strength = state->decode_snr = 0; | 971 | state->decode_lock = state->decode_strength = state->decode_snr = 0; |
| 934 | return 0; | 972 | return 0; |
| @@ -955,13 +993,12 @@ static int dst_get_signal(struct dst_state* state) | |||
| 955 | return 0; | 993 | return 0; |
| 956 | } | 994 | } |
| 957 | 995 | ||
| 958 | static int dst_tone_power_cmd(struct dst_state* state) | 996 | static int dst_tone_power_cmd(struct dst_state *state) |
| 959 | { | 997 | { |
| 960 | u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; | 998 | u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 }; |
| 961 | 999 | ||
| 962 | if (state->dst_type == DST_TYPE_IS_TERR) | 1000 | if (state->dst_type == DST_TYPE_IS_TERR) |
| 963 | return 0; | 1001 | return 0; |
| 964 | |||
| 965 | paket[4] = state->tx_tuna[4]; | 1002 | paket[4] = state->tx_tuna[4]; |
| 966 | paket[2] = state->tx_tuna[2]; | 1003 | paket[2] = state->tx_tuna[2]; |
| 967 | paket[3] = state->tx_tuna[3]; | 1004 | paket[3] = state->tx_tuna[3]; |
| @@ -971,61 +1008,53 @@ static int dst_tone_power_cmd(struct dst_state* state) | |||
| 971 | return 0; | 1008 | return 0; |
| 972 | } | 1009 | } |
| 973 | 1010 | ||
| 974 | static int dst_get_tuna(struct dst_state* state) | 1011 | static int dst_get_tuna(struct dst_state *state) |
| 975 | { | 1012 | { |
| 976 | int retval; | 1013 | int retval; |
| 977 | 1014 | ||
| 978 | if ((state->diseq_flags & ATTEMPT_TUNE) == 0) | 1015 | if ((state->diseq_flags & ATTEMPT_TUNE) == 0) |
| 979 | return 0; | 1016 | return 0; |
| 980 | |||
| 981 | state->diseq_flags &= ~(HAS_LOCK); | 1017 | state->diseq_flags &= ~(HAS_LOCK); |
| 982 | if (!dst_wait_dst_ready(state, NO_DELAY)) | 1018 | if (!dst_wait_dst_ready(state, NO_DELAY)) |
| 983 | return 0; | 1019 | return 0; |
| 984 | 1020 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) | |
| 985 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { | ||
| 986 | /* how to get variable length reply ???? */ | 1021 | /* how to get variable length reply ???? */ |
| 987 | retval = read_dst(state, state->rx_tuna, 10); | 1022 | retval = read_dst(state, state->rx_tuna, 10); |
| 988 | } else { | 1023 | else |
| 989 | retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); | 1024 | retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); |
| 990 | } | ||
| 991 | |||
| 992 | if (retval < 0) { | 1025 | if (retval < 0) { |
| 993 | dprintk("%s: read not successful\n", __FUNCTION__); | 1026 | dprintk(verbose, DST_DEBUG, 1, "read not successful"); |
| 994 | return 0; | 1027 | return 0; |
| 995 | } | 1028 | } |
| 996 | |||
| 997 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { | 1029 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { |
| 998 | if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { | 1030 | if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { |
| 999 | dprintk("%s: checksum failure?\n", __FUNCTION__); | 1031 | dprintk(verbose, DST_INFO, 1, "checksum failure ? "); |
| 1000 | return 0; | 1032 | return 0; |
| 1001 | } | 1033 | } |
| 1002 | } else { | 1034 | } else { |
| 1003 | if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { | 1035 | if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { |
| 1004 | dprintk("%s: checksum failure?\n", __FUNCTION__); | 1036 | dprintk(verbose, DST_INFO, 1, "checksum failure? "); |
| 1005 | return 0; | 1037 | return 0; |
| 1006 | } | 1038 | } |
| 1007 | } | 1039 | } |
| 1008 | if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) | 1040 | if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) |
| 1009 | return 0; | 1041 | return 0; |
| 1010 | state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; | 1042 | state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; |
| 1011 | |||
| 1012 | state->decode_lock = 1; | 1043 | state->decode_lock = 1; |
| 1013 | state->diseq_flags |= HAS_LOCK; | 1044 | state->diseq_flags |= HAS_LOCK; |
| 1014 | 1045 | ||
| 1015 | return 1; | 1046 | return 1; |
| 1016 | } | 1047 | } |
| 1017 | 1048 | ||
| 1018 | static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage); | 1049 | static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage); |
| 1019 | 1050 | ||
| 1020 | static int dst_write_tuna(struct dvb_frontend* fe) | 1051 | static int dst_write_tuna(struct dvb_frontend *fe) |
| 1021 | { | 1052 | { |
| 1022 | struct dst_state* state = fe->demodulator_priv; | 1053 | struct dst_state *state = fe->demodulator_priv; |
| 1023 | int retval; | 1054 | int retval; |
| 1024 | u8 reply; | 1055 | u8 reply; |
| 1025 | 1056 | ||
| 1026 | if (debug > 4) | 1057 | dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags); |
| 1027 | dprintk("%s: type_flags 0x%x \n", __FUNCTION__, state->type_flags); | ||
| 1028 | |||
| 1029 | state->decode_freq = 0; | 1058 | state->decode_freq = 0; |
| 1030 | state->decode_lock = state->decode_strength = state->decode_snr = 0; | 1059 | state->decode_lock = state->decode_strength = state->decode_snr = 0; |
| 1031 | if (state->dst_type == DST_TYPE_IS_SAT) { | 1060 | if (state->dst_type == DST_TYPE_IS_SAT) { |
| @@ -1035,35 +1064,31 @@ static int dst_write_tuna(struct dvb_frontend* fe) | |||
| 1035 | state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); | 1064 | state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); |
| 1036 | 1065 | ||
| 1037 | if ((dst_comm_init(state)) < 0) { | 1066 | if ((dst_comm_init(state)) < 0) { |
| 1038 | dprintk("%s: DST Communication initialization failed.\n", __FUNCTION__); | 1067 | dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); |
| 1039 | return -1; | 1068 | return -1; |
| 1040 | } | 1069 | } |
| 1041 | |||
| 1042 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { | 1070 | if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { |
| 1043 | state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); | 1071 | state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); |
| 1044 | retval = write_dst(state, &state->tx_tuna[0], 10); | 1072 | retval = write_dst(state, &state->tx_tuna[0], 10); |
| 1045 | |||
| 1046 | } else { | 1073 | } else { |
| 1047 | state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); | 1074 | state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); |
| 1048 | retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); | 1075 | retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); |
| 1049 | } | 1076 | } |
| 1050 | if (retval < 0) { | 1077 | if (retval < 0) { |
| 1051 | dst_pio_disable(state); | 1078 | dst_pio_disable(state); |
| 1052 | dprintk("%s: write not successful\n", __FUNCTION__); | 1079 | dprintk(verbose, DST_DEBUG, 1, "write not successful"); |
| 1053 | return retval; | 1080 | return retval; |
| 1054 | } | 1081 | } |
| 1055 | |||
| 1056 | if ((dst_pio_disable(state)) < 0) { | 1082 | if ((dst_pio_disable(state)) < 0) { |
| 1057 | dprintk("%s: DST PIO disable failed !\n", __FUNCTION__); | 1083 | dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !"); |
| 1058 | return -1; | 1084 | return -1; |
| 1059 | } | 1085 | } |
| 1060 | |||
| 1061 | if ((read_dst(state, &reply, GET_ACK) < 0)) { | 1086 | if ((read_dst(state, &reply, GET_ACK) < 0)) { |
| 1062 | dprintk("%s: read verify not successful.\n", __FUNCTION__); | 1087 | dprintk(verbose, DST_DEBUG, 1, "read verify not successful."); |
| 1063 | return -1; | 1088 | return -1; |
| 1064 | } | 1089 | } |
| 1065 | if (reply != ACK) { | 1090 | if (reply != ACK) { |
| 1066 | dprintk("%s: write not acknowledged 0x%02x \n", __FUNCTION__, reply); | 1091 | dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply); |
| 1067 | return 0; | 1092 | return 0; |
| 1068 | } | 1093 | } |
| 1069 | state->diseq_flags |= ATTEMPT_TUNE; | 1094 | state->diseq_flags |= ATTEMPT_TUNE; |
| @@ -1085,14 +1110,13 @@ static int dst_write_tuna(struct dvb_frontend* fe) | |||
| 1085 | * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 | 1110 | * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0 |
| 1086 | */ | 1111 | */ |
| 1087 | 1112 | ||
| 1088 | static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) | 1113 | static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd) |
| 1089 | { | 1114 | { |
| 1090 | struct dst_state* state = fe->demodulator_priv; | 1115 | struct dst_state *state = fe->demodulator_priv; |
| 1091 | u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; | 1116 | u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec }; |
| 1092 | 1117 | ||
| 1093 | if (state->dst_type != DST_TYPE_IS_SAT) | 1118 | if (state->dst_type != DST_TYPE_IS_SAT) |
| 1094 | return 0; | 1119 | return 0; |
| 1095 | |||
| 1096 | if (cmd->msg_len == 0 || cmd->msg_len > 4) | 1120 | if (cmd->msg_len == 0 || cmd->msg_len > 4) |
| 1097 | return -EINVAL; | 1121 | return -EINVAL; |
| 1098 | memcpy(&paket[3], cmd->msg, cmd->msg_len); | 1122 | memcpy(&paket[3], cmd->msg, cmd->msg_len); |
| @@ -1101,65 +1125,61 @@ static int dst_set_diseqc(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* | |||
| 1101 | return 0; | 1125 | return 0; |
| 1102 | } | 1126 | } |
| 1103 | 1127 | ||
| 1104 | static int dst_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) | 1128 | static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) |
| 1105 | { | 1129 | { |
| 1106 | int need_cmd; | 1130 | int need_cmd; |
| 1107 | struct dst_state* state = fe->demodulator_priv; | 1131 | struct dst_state *state = fe->demodulator_priv; |
| 1108 | 1132 | ||
| 1109 | state->voltage = voltage; | 1133 | state->voltage = voltage; |
| 1110 | |||
| 1111 | if (state->dst_type != DST_TYPE_IS_SAT) | 1134 | if (state->dst_type != DST_TYPE_IS_SAT) |
| 1112 | return 0; | 1135 | return 0; |
| 1113 | 1136 | ||
| 1114 | need_cmd = 0; | 1137 | need_cmd = 0; |
| 1115 | switch (voltage) { | ||
| 1116 | case SEC_VOLTAGE_13: | ||
| 1117 | case SEC_VOLTAGE_18: | ||
| 1118 | if ((state->diseq_flags & HAS_POWER) == 0) | ||
| 1119 | need_cmd = 1; | ||
| 1120 | state->diseq_flags |= HAS_POWER; | ||
| 1121 | state->tx_tuna[4] = 0x01; | ||
| 1122 | break; | ||
| 1123 | 1138 | ||
| 1124 | case SEC_VOLTAGE_OFF: | 1139 | switch (voltage) { |
| 1140 | case SEC_VOLTAGE_13: | ||
| 1141 | case SEC_VOLTAGE_18: | ||
| 1142 | if ((state->diseq_flags & HAS_POWER) == 0) | ||
| 1125 | need_cmd = 1; | 1143 | need_cmd = 1; |
| 1126 | state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); | 1144 | state->diseq_flags |= HAS_POWER; |
| 1127 | state->tx_tuna[4] = 0x00; | 1145 | state->tx_tuna[4] = 0x01; |
| 1128 | break; | 1146 | break; |
| 1129 | 1147 | case SEC_VOLTAGE_OFF: | |
| 1130 | default: | 1148 | need_cmd = 1; |
| 1131 | return -EINVAL; | 1149 | state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); |
| 1150 | state->tx_tuna[4] = 0x00; | ||
| 1151 | break; | ||
| 1152 | default: | ||
| 1153 | return -EINVAL; | ||
| 1132 | } | 1154 | } |
| 1155 | |||
| 1133 | if (need_cmd) | 1156 | if (need_cmd) |
| 1134 | dst_tone_power_cmd(state); | 1157 | dst_tone_power_cmd(state); |
| 1135 | 1158 | ||
| 1136 | return 0; | 1159 | return 0; |
| 1137 | } | 1160 | } |
| 1138 | 1161 | ||
| 1139 | static int dst_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | 1162 | static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) |
| 1140 | { | 1163 | { |
| 1141 | struct dst_state* state = fe->demodulator_priv; | 1164 | struct dst_state *state = fe->demodulator_priv; |
| 1142 | 1165 | ||
| 1143 | state->tone = tone; | 1166 | state->tone = tone; |
| 1144 | |||
| 1145 | if (state->dst_type != DST_TYPE_IS_SAT) | 1167 | if (state->dst_type != DST_TYPE_IS_SAT) |
| 1146 | return 0; | 1168 | return 0; |
| 1147 | 1169 | ||
| 1148 | switch (tone) { | 1170 | switch (tone) { |
| 1149 | case SEC_TONE_OFF: | 1171 | case SEC_TONE_OFF: |
| 1150 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) | 1172 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) |
| 1151 | state->tx_tuna[2] = 0x00; | 1173 | state->tx_tuna[2] = 0x00; |
| 1152 | else | 1174 | else |
| 1153 | state->tx_tuna[2] = 0xff; | 1175 | state->tx_tuna[2] = 0xff; |
| 1154 | 1176 | break; | |
| 1155 | break; | ||
| 1156 | |||
| 1157 | case SEC_TONE_ON: | ||
| 1158 | state->tx_tuna[2] = 0x02; | ||
| 1159 | break; | ||
| 1160 | 1177 | ||
| 1161 | default: | 1178 | case SEC_TONE_ON: |
| 1162 | return -EINVAL; | 1179 | state->tx_tuna[2] = 0x02; |
| 1180 | break; | ||
| 1181 | default: | ||
| 1182 | return -EINVAL; | ||
| 1163 | } | 1183 | } |
| 1164 | dst_tone_power_cmd(state); | 1184 | dst_tone_power_cmd(state); |
| 1165 | 1185 | ||
| @@ -1172,16 +1192,14 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) | |||
| 1172 | 1192 | ||
| 1173 | if (state->dst_type != DST_TYPE_IS_SAT) | 1193 | if (state->dst_type != DST_TYPE_IS_SAT) |
| 1174 | return 0; | 1194 | return 0; |
| 1175 | |||
| 1176 | state->minicmd = minicmd; | 1195 | state->minicmd = minicmd; |
| 1177 | |||
| 1178 | switch (minicmd) { | 1196 | switch (minicmd) { |
| 1179 | case SEC_MINI_A: | 1197 | case SEC_MINI_A: |
| 1180 | state->tx_tuna[3] = 0x02; | 1198 | state->tx_tuna[3] = 0x02; |
| 1181 | break; | 1199 | break; |
| 1182 | case SEC_MINI_B: | 1200 | case SEC_MINI_B: |
| 1183 | state->tx_tuna[3] = 0xff; | 1201 | state->tx_tuna[3] = 0xff; |
| 1184 | break; | 1202 | break; |
| 1185 | } | 1203 | } |
| 1186 | dst_tone_power_cmd(state); | 1204 | dst_tone_power_cmd(state); |
| 1187 | 1205 | ||
| @@ -1189,42 +1207,37 @@ static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd) | |||
| 1189 | } | 1207 | } |
| 1190 | 1208 | ||
| 1191 | 1209 | ||
| 1192 | static int dst_init(struct dvb_frontend* fe) | 1210 | static int dst_init(struct dvb_frontend *fe) |
| 1193 | { | 1211 | { |
| 1194 | struct dst_state* state = fe->demodulator_priv; | 1212 | struct dst_state *state = fe->demodulator_priv; |
| 1195 | static u8 ini_satci_tuna[] = { 9, 0, 3, 0xb6, 1, 0, 0x73, 0x21, 0, 0 }; | 1213 | |
| 1196 | static u8 ini_satfta_tuna[] = { 0, 0, 3, 0xb6, 1, 0x55, 0xbd, 0x50, 0, 0 }; | 1214 | static u8 sat_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x00, 0x73, 0x21, 0x00, 0x00 }; |
| 1197 | static u8 ini_tvfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; | 1215 | static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 }; |
| 1198 | static u8 ini_tvci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; | 1216 | static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
| 1199 | static u8 ini_cabfta_tuna[] = { 0, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; | 1217 | static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
| 1200 | static u8 ini_cabci_tuna[] = { 9, 0, 3, 0xb6, 1, 7, 0x0, 0x0, 0, 0 }; | 1218 | static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
| 1201 | // state->inversion = INVERSION_ON; | 1219 | static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 }; |
| 1220 | |||
| 1202 | state->inversion = INVERSION_OFF; | 1221 | state->inversion = INVERSION_OFF; |
| 1203 | state->voltage = SEC_VOLTAGE_13; | 1222 | state->voltage = SEC_VOLTAGE_13; |
| 1204 | state->tone = SEC_TONE_OFF; | 1223 | state->tone = SEC_TONE_OFF; |
| 1205 | state->symbol_rate = 29473000; | ||
| 1206 | state->fec = FEC_AUTO; | ||
| 1207 | state->diseq_flags = 0; | 1224 | state->diseq_flags = 0; |
| 1208 | state->k22 = 0x02; | 1225 | state->k22 = 0x02; |
| 1209 | state->bandwidth = BANDWIDTH_7_MHZ; | 1226 | state->bandwidth = BANDWIDTH_7_MHZ; |
| 1210 | state->cur_jiff = jiffies; | 1227 | state->cur_jiff = jiffies; |
| 1211 | if (state->dst_type == DST_TYPE_IS_SAT) { | 1228 | if (state->dst_type == DST_TYPE_IS_SAT) |
| 1212 | state->frequency = 950000; | 1229 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204)); |
| 1213 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_satci_tuna : ini_satfta_tuna), sizeof(ini_satfta_tuna)); | 1230 | else if (state->dst_type == DST_TYPE_IS_TERR) |
| 1214 | } else if (state->dst_type == DST_TYPE_IS_TERR) { | 1231 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204)); |
| 1215 | state->frequency = 137000000; | 1232 | else if (state->dst_type == DST_TYPE_IS_CABLE) |
| 1216 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_tvci_tuna : ini_tvfta_tuna), sizeof(ini_tvfta_tuna)); | 1233 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204)); |
| 1217 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { | ||
| 1218 | state->frequency = 51000000; | ||
| 1219 | memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_NEWTUNE) ? ini_cabci_tuna : ini_cabfta_tuna), sizeof(ini_cabfta_tuna)); | ||
| 1220 | } | ||
| 1221 | 1234 | ||
| 1222 | return 0; | 1235 | return 0; |
| 1223 | } | 1236 | } |
| 1224 | 1237 | ||
| 1225 | static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) | 1238 | static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status) |
| 1226 | { | 1239 | { |
| 1227 | struct dst_state* state = fe->demodulator_priv; | 1240 | struct dst_state *state = fe->demodulator_priv; |
| 1228 | 1241 | ||
| 1229 | *status = 0; | 1242 | *status = 0; |
| 1230 | if (state->diseq_flags & HAS_LOCK) { | 1243 | if (state->diseq_flags & HAS_LOCK) { |
| @@ -1236,9 +1249,9 @@ static int dst_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 1236 | return 0; | 1249 | return 0; |
| 1237 | } | 1250 | } |
| 1238 | 1251 | ||
| 1239 | static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) | 1252 | static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |
| 1240 | { | 1253 | { |
| 1241 | struct dst_state* state = fe->demodulator_priv; | 1254 | struct dst_state *state = fe->demodulator_priv; |
| 1242 | 1255 | ||
| 1243 | dst_get_signal(state); | 1256 | dst_get_signal(state); |
| 1244 | *strength = state->decode_strength; | 1257 | *strength = state->decode_strength; |
| @@ -1246,9 +1259,9 @@ static int dst_read_signal_strength(struct dvb_frontend* fe, u16* strength) | |||
| 1246 | return 0; | 1259 | return 0; |
| 1247 | } | 1260 | } |
| 1248 | 1261 | ||
| 1249 | static int dst_read_snr(struct dvb_frontend* fe, u16* snr) | 1262 | static int dst_read_snr(struct dvb_frontend *fe, u16 *snr) |
| 1250 | { | 1263 | { |
| 1251 | struct dst_state* state = fe->demodulator_priv; | 1264 | struct dst_state *state = fe->demodulator_priv; |
| 1252 | 1265 | ||
| 1253 | dst_get_signal(state); | 1266 | dst_get_signal(state); |
| 1254 | *snr = state->decode_snr; | 1267 | *snr = state->decode_snr; |
| @@ -1256,28 +1269,24 @@ static int dst_read_snr(struct dvb_frontend* fe, u16* snr) | |||
| 1256 | return 0; | 1269 | return 0; |
| 1257 | } | 1270 | } |
| 1258 | 1271 | ||
| 1259 | static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 1272 | static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) |
| 1260 | { | 1273 | { |
| 1261 | struct dst_state* state = fe->demodulator_priv; | 1274 | struct dst_state *state = fe->demodulator_priv; |
| 1262 | 1275 | ||
| 1263 | dst_set_freq(state, p->frequency); | 1276 | dst_set_freq(state, p->frequency); |
| 1264 | if (verbose > 4) | 1277 | dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency); |
| 1265 | dprintk("Set Frequency=[%d]\n", p->frequency); | ||
| 1266 | 1278 | ||
| 1267 | // dst_set_inversion(state, p->inversion); | ||
| 1268 | if (state->dst_type == DST_TYPE_IS_SAT) { | 1279 | if (state->dst_type == DST_TYPE_IS_SAT) { |
| 1269 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) | 1280 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) |
| 1270 | dst_set_inversion(state, p->inversion); | 1281 | dst_set_inversion(state, p->inversion); |
| 1271 | |||
| 1272 | dst_set_fec(state, p->u.qpsk.fec_inner); | 1282 | dst_set_fec(state, p->u.qpsk.fec_inner); |
| 1273 | dst_set_symbolrate(state, p->u.qpsk.symbol_rate); | 1283 | dst_set_symbolrate(state, p->u.qpsk.symbol_rate); |
| 1274 | dst_set_polarization(state); | 1284 | dst_set_polarization(state); |
| 1275 | if (verbose > 4) | 1285 | dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate); |
| 1276 | dprintk("Set Symbolrate=[%d]\n", p->u.qpsk.symbol_rate); | ||
| 1277 | 1286 | ||
| 1278 | } else if (state->dst_type == DST_TYPE_IS_TERR) { | 1287 | } else if (state->dst_type == DST_TYPE_IS_TERR) |
| 1279 | dst_set_bandwidth(state, p->u.ofdm.bandwidth); | 1288 | dst_set_bandwidth(state, p->u.ofdm.bandwidth); |
| 1280 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { | 1289 | else if (state->dst_type == DST_TYPE_IS_CABLE) { |
| 1281 | dst_set_fec(state, p->u.qam.fec_inner); | 1290 | dst_set_fec(state, p->u.qam.fec_inner); |
| 1282 | dst_set_symbolrate(state, p->u.qam.symbol_rate); | 1291 | dst_set_symbolrate(state, p->u.qam.symbol_rate); |
| 1283 | dst_set_modulation(state, p->u.qam.modulation); | 1292 | dst_set_modulation(state, p->u.qam.modulation); |
| @@ -1287,16 +1296,14 @@ static int dst_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 1287 | return 0; | 1296 | return 0; |
| 1288 | } | 1297 | } |
| 1289 | 1298 | ||
| 1290 | static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 1299 | static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) |
| 1291 | { | 1300 | { |
| 1292 | struct dst_state* state = fe->demodulator_priv; | 1301 | struct dst_state *state = fe->demodulator_priv; |
| 1293 | 1302 | ||
| 1294 | p->frequency = state->decode_freq; | 1303 | p->frequency = state->decode_freq; |
| 1295 | // p->inversion = state->inversion; | ||
| 1296 | if (state->dst_type == DST_TYPE_IS_SAT) { | 1304 | if (state->dst_type == DST_TYPE_IS_SAT) { |
| 1297 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) | 1305 | if (state->type_flags & DST_TYPE_HAS_OBS_REGS) |
| 1298 | p->inversion = state->inversion; | 1306 | p->inversion = state->inversion; |
| 1299 | |||
| 1300 | p->u.qpsk.symbol_rate = state->symbol_rate; | 1307 | p->u.qpsk.symbol_rate = state->symbol_rate; |
| 1301 | p->u.qpsk.fec_inner = dst_get_fec(state); | 1308 | p->u.qpsk.fec_inner = dst_get_fec(state); |
| 1302 | } else if (state->dst_type == DST_TYPE_IS_TERR) { | 1309 | } else if (state->dst_type == DST_TYPE_IS_TERR) { |
| @@ -1304,16 +1311,15 @@ static int dst_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 1304 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { | 1311 | } else if (state->dst_type == DST_TYPE_IS_CABLE) { |
| 1305 | p->u.qam.symbol_rate = state->symbol_rate; | 1312 | p->u.qam.symbol_rate = state->symbol_rate; |
| 1306 | p->u.qam.fec_inner = dst_get_fec(state); | 1313 | p->u.qam.fec_inner = dst_get_fec(state); |
| 1307 | // p->u.qam.modulation = QAM_AUTO; | ||
| 1308 | p->u.qam.modulation = dst_get_modulation(state); | 1314 | p->u.qam.modulation = dst_get_modulation(state); |
| 1309 | } | 1315 | } |
| 1310 | 1316 | ||
| 1311 | return 0; | 1317 | return 0; |
| 1312 | } | 1318 | } |
| 1313 | 1319 | ||
| 1314 | static void dst_release(struct dvb_frontend* fe) | 1320 | static void dst_release(struct dvb_frontend *fe) |
| 1315 | { | 1321 | { |
| 1316 | struct dst_state* state = fe->demodulator_priv; | 1322 | struct dst_state *state = fe->demodulator_priv; |
| 1317 | kfree(state); | 1323 | kfree(state); |
| 1318 | } | 1324 | } |
| 1319 | 1325 | ||
| @@ -1321,9 +1327,8 @@ static struct dvb_frontend_ops dst_dvbt_ops; | |||
| 1321 | static struct dvb_frontend_ops dst_dvbs_ops; | 1327 | static struct dvb_frontend_ops dst_dvbs_ops; |
| 1322 | static struct dvb_frontend_ops dst_dvbc_ops; | 1328 | static struct dvb_frontend_ops dst_dvbc_ops; |
| 1323 | 1329 | ||
| 1324 | struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) | 1330 | struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) |
| 1325 | { | 1331 | { |
| 1326 | |||
| 1327 | /* check if the ASIC is there */ | 1332 | /* check if the ASIC is there */ |
| 1328 | if (dst_probe(state) < 0) { | 1333 | if (dst_probe(state) < 0) { |
| 1329 | if (state) | 1334 | if (state) |
| @@ -1336,17 +1341,14 @@ struct dst_state* dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad | |||
| 1336 | case DST_TYPE_IS_TERR: | 1341 | case DST_TYPE_IS_TERR: |
| 1337 | memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); | 1342 | memcpy(&state->ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); |
| 1338 | break; | 1343 | break; |
| 1339 | |||
| 1340 | case DST_TYPE_IS_CABLE: | 1344 | case DST_TYPE_IS_CABLE: |
| 1341 | memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); | 1345 | memcpy(&state->ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); |
| 1342 | break; | 1346 | break; |
| 1343 | |||
| 1344 | case DST_TYPE_IS_SAT: | 1347 | case DST_TYPE_IS_SAT: |
| 1345 | memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); | 1348 | memcpy(&state->ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); |
| 1346 | break; | 1349 | break; |
| 1347 | |||
| 1348 | default: | 1350 | default: |
| 1349 | printk("%s: unknown DST type. please report to the LinuxTV.org DVB mailinglist.\n", __FUNCTION__); | 1351 | dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist."); |
| 1350 | if (state) | 1352 | if (state) |
| 1351 | kfree(state); | 1353 | kfree(state); |
| 1352 | 1354 | ||
| @@ -1374,12 +1376,9 @@ static struct dvb_frontend_ops dst_dvbt_ops = { | |||
| 1374 | }, | 1376 | }, |
| 1375 | 1377 | ||
| 1376 | .release = dst_release, | 1378 | .release = dst_release, |
| 1377 | |||
| 1378 | .init = dst_init, | 1379 | .init = dst_init, |
| 1379 | |||
| 1380 | .set_frontend = dst_set_frontend, | 1380 | .set_frontend = dst_set_frontend, |
| 1381 | .get_frontend = dst_get_frontend, | 1381 | .get_frontend = dst_get_frontend, |
| 1382 | |||
| 1383 | .read_status = dst_read_status, | 1382 | .read_status = dst_read_status, |
| 1384 | .read_signal_strength = dst_read_signal_strength, | 1383 | .read_signal_strength = dst_read_signal_strength, |
| 1385 | .read_snr = dst_read_snr, | 1384 | .read_snr = dst_read_snr, |
| @@ -1401,16 +1400,12 @@ static struct dvb_frontend_ops dst_dvbs_ops = { | |||
| 1401 | }, | 1400 | }, |
| 1402 | 1401 | ||
| 1403 | .release = dst_release, | 1402 | .release = dst_release, |
| 1404 | |||
| 1405 | .init = dst_init, | 1403 | .init = dst_init, |
| 1406 | |||
| 1407 | .set_frontend = dst_set_frontend, | 1404 | .set_frontend = dst_set_frontend, |
| 1408 | .get_frontend = dst_get_frontend, | 1405 | .get_frontend = dst_get_frontend, |
| 1409 | |||
| 1410 | .read_status = dst_read_status, | 1406 | .read_status = dst_read_status, |
| 1411 | .read_signal_strength = dst_read_signal_strength, | 1407 | .read_signal_strength = dst_read_signal_strength, |
| 1412 | .read_snr = dst_read_snr, | 1408 | .read_snr = dst_read_snr, |
| 1413 | |||
| 1414 | .diseqc_send_burst = dst_send_burst, | 1409 | .diseqc_send_burst = dst_send_burst, |
| 1415 | .diseqc_send_master_cmd = dst_set_diseqc, | 1410 | .diseqc_send_master_cmd = dst_set_diseqc, |
| 1416 | .set_voltage = dst_set_voltage, | 1411 | .set_voltage = dst_set_voltage, |
| @@ -1432,18 +1427,14 @@ static struct dvb_frontend_ops dst_dvbc_ops = { | |||
| 1432 | }, | 1427 | }, |
| 1433 | 1428 | ||
| 1434 | .release = dst_release, | 1429 | .release = dst_release, |
| 1435 | |||
| 1436 | .init = dst_init, | 1430 | .init = dst_init, |
| 1437 | |||
| 1438 | .set_frontend = dst_set_frontend, | 1431 | .set_frontend = dst_set_frontend, |
| 1439 | .get_frontend = dst_get_frontend, | 1432 | .get_frontend = dst_get_frontend, |
| 1440 | |||
| 1441 | .read_status = dst_read_status, | 1433 | .read_status = dst_read_status, |
| 1442 | .read_signal_strength = dst_read_signal_strength, | 1434 | .read_signal_strength = dst_read_signal_strength, |
| 1443 | .read_snr = dst_read_snr, | 1435 | .read_snr = dst_read_snr, |
| 1444 | }; | 1436 | }; |
| 1445 | 1437 | ||
| 1446 | |||
| 1447 | MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); | 1438 | MODULE_DESCRIPTION("DST DVB-S/T/C Combo Frontend driver"); |
| 1448 | MODULE_AUTHOR("Jamie Honan, Manu Abraham"); | 1439 | MODULE_AUTHOR("Jamie Honan, Manu Abraham"); |
| 1449 | MODULE_LICENSE("GPL"); | 1440 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index bfaacd5fc20f..6776a592045f 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c | |||
| @@ -18,30 +18,42 @@ | |||
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | |||
| 22 | |||
| 23 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
| 24 | #include <linux/module.h> | 22 | #include <linux/module.h> |
| 25 | #include <linux/init.h> | 23 | #include <linux/init.h> |
| 26 | #include <linux/string.h> | 24 | #include <linux/string.h> |
| 27 | |||
| 28 | #include <linux/dvb/ca.h> | 25 | #include <linux/dvb/ca.h> |
| 29 | #include "dvbdev.h" | 26 | #include "dvbdev.h" |
| 30 | #include "dvb_frontend.h" | 27 | #include "dvb_frontend.h" |
| 31 | |||
| 32 | #include "dst_ca.h" | 28 | #include "dst_ca.h" |
| 33 | #include "dst_common.h" | 29 | #include "dst_common.h" |
| 34 | 30 | ||
| 31 | #define DST_CA_ERROR 0 | ||
| 32 | #define DST_CA_NOTICE 1 | ||
| 33 | #define DST_CA_INFO 2 | ||
| 34 | #define DST_CA_DEBUG 3 | ||
| 35 | |||
| 36 | #define dprintk(x, y, z, format, arg...) do { \ | ||
| 37 | if (z) { \ | ||
| 38 | if ((x > DST_CA_ERROR) && (x > y)) \ | ||
| 39 | printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ | ||
| 40 | else if ((x > DST_CA_NOTICE) && (x > y)) \ | ||
| 41 | printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ | ||
| 42 | else if ((x > DST_CA_INFO) && (x > y)) \ | ||
| 43 | printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ | ||
| 44 | else if ((x > DST_CA_DEBUG) && (x > y)) \ | ||
| 45 | printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ | ||
| 46 | } else { \ | ||
| 47 | if (x > y) \ | ||
| 48 | printk(format, ## arg); \ | ||
| 49 | } \ | ||
| 50 | } while(0) | ||
| 51 | |||
| 52 | |||
| 35 | static unsigned int verbose = 5; | 53 | static unsigned int verbose = 5; |
| 36 | module_param(verbose, int, 0644); | 54 | module_param(verbose, int, 0644); |
| 37 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); | 55 | MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); |
| 38 | 56 | ||
| 39 | static unsigned int debug = 1; | ||
| 40 | module_param(debug, int, 0644); | ||
| 41 | MODULE_PARM_DESC(debug, "debug messages, default is 1 (yes)"); | ||
| 42 | |||
| 43 | #define dprintk if (debug) printk | ||
| 44 | |||
| 45 | /* Need some more work */ | 57 | /* Need some more work */ |
| 46 | static int ca_set_slot_descr(void) | 58 | static int ca_set_slot_descr(void) |
| 47 | { | 59 | { |
| @@ -61,27 +73,20 @@ static int put_checksum(u8 *check_string, int length) | |||
| 61 | { | 73 | { |
| 62 | u8 i = 0, checksum = 0; | 74 | u8 i = 0, checksum = 0; |
| 63 | 75 | ||
| 64 | if (verbose > 3) { | 76 | dprintk(verbose, DST_CA_DEBUG, 1, " ========================= Checksum calculation ==========================="); |
| 65 | dprintk("%s: ========================= Checksum calculation ===========================\n", __FUNCTION__); | 77 | dprintk(verbose, DST_CA_DEBUG, 1, " String Length=[0x%02x]", length); |
| 66 | dprintk("%s: String Length=[0x%02x]\n", __FUNCTION__, length); | 78 | dprintk(verbose, DST_CA_DEBUG, 1, " String=["); |
| 67 | 79 | ||
| 68 | dprintk("%s: String=[", __FUNCTION__); | ||
| 69 | } | ||
| 70 | while (i < length) { | 80 | while (i < length) { |
| 71 | if (verbose > 3) | 81 | dprintk(verbose, DST_CA_DEBUG, 0, " %02x", check_string[i]); |
| 72 | dprintk(" %02x", check_string[i]); | ||
| 73 | checksum += check_string[i]; | 82 | checksum += check_string[i]; |
| 74 | i++; | 83 | i++; |
| 75 | } | 84 | } |
| 76 | if (verbose > 3) { | 85 | dprintk(verbose, DST_CA_DEBUG, 0, " ]\n"); |
| 77 | dprintk(" ]\n"); | 86 | dprintk(verbose, DST_CA_DEBUG, 1, "Sum=[%02x]\n", checksum); |
| 78 | dprintk("%s: Sum=[%02x]\n", __FUNCTION__, checksum); | ||
| 79 | } | ||
| 80 | check_string[length] = ~checksum + 1; | 87 | check_string[length] = ~checksum + 1; |
| 81 | if (verbose > 3) { | 88 | dprintk(verbose, DST_CA_DEBUG, 1, " Checksum=[%02x]", check_string[length]); |
| 82 | dprintk("%s: Checksum=[%02x]\n", __FUNCTION__, check_string[length]); | 89 | dprintk(verbose, DST_CA_DEBUG, 1, " =========================================================================="); |
| 83 | dprintk("%s: ==========================================================================\n", __FUNCTION__); | ||
| 84 | } | ||
| 85 | 90 | ||
| 86 | return 0; | 91 | return 0; |
| 87 | } | 92 | } |
| @@ -94,30 +99,26 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 | |||
| 94 | msleep(65); | 99 | msleep(65); |
| 95 | 100 | ||
| 96 | if (write_dst(state, data, len)) { | 101 | if (write_dst(state, data, len)) { |
| 97 | dprintk("%s: Write not successful, trying to recover\n", __FUNCTION__); | 102 | dprintk(verbose, DST_CA_INFO, 1, " Write not successful, trying to recover"); |
| 98 | dst_error_recovery(state); | 103 | dst_error_recovery(state); |
| 99 | return -1; | 104 | return -1; |
| 100 | } | 105 | } |
| 101 | |||
| 102 | if ((dst_pio_disable(state)) < 0) { | 106 | if ((dst_pio_disable(state)) < 0) { |
| 103 | dprintk("%s: DST PIO disable failed.\n", __FUNCTION__); | 107 | dprintk(verbose, DST_CA_ERROR, 1, " DST PIO disable failed."); |
| 104 | return -1; | 108 | return -1; |
| 105 | } | 109 | } |
| 106 | |||
| 107 | if (read_dst(state, &reply, GET_ACK) < 0) { | 110 | if (read_dst(state, &reply, GET_ACK) < 0) { |
| 108 | dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); | 111 | dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); |
| 109 | dst_error_recovery(state); | 112 | dst_error_recovery(state); |
| 110 | return -1; | 113 | return -1; |
| 111 | } | 114 | } |
| 112 | |||
| 113 | if (read) { | 115 | if (read) { |
| 114 | if (! dst_wait_dst_ready(state, LONG_DELAY)) { | 116 | if (! dst_wait_dst_ready(state, LONG_DELAY)) { |
| 115 | dprintk("%s: 8820 not ready\n", __FUNCTION__); | 117 | dprintk(verbose, DST_CA_NOTICE, 1, " 8820 not ready"); |
| 116 | return -1; | 118 | return -1; |
| 117 | } | 119 | } |
| 118 | |||
| 119 | if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */ | 120 | if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */ |
| 120 | dprintk("%s: Read not successful, trying to recover\n", __FUNCTION__); | 121 | dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover"); |
| 121 | dst_error_recovery(state); | 122 | dst_error_recovery(state); |
| 122 | return -1; | 123 | return -1; |
| 123 | } | 124 | } |
| @@ -133,8 +134,7 @@ static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string, | |||
| 133 | 134 | ||
| 134 | while (dst_ca_comm_err < RETRIES) { | 135 | while (dst_ca_comm_err < RETRIES) { |
| 135 | dst_comm_init(state); | 136 | dst_comm_init(state); |
| 136 | if (verbose > 2) | 137 | dprintk(verbose, DST_CA_NOTICE, 1, " Put Command"); |
| 137 | dprintk("%s: Put Command\n", __FUNCTION__); | ||
| 138 | if (dst_ci_command(state, data, ca_string, len, read)) { // If error | 138 | if (dst_ci_command(state, data, ca_string, len, read)) { // If error |
| 139 | dst_error_recovery(state); | 139 | dst_error_recovery(state); |
| 140 | dst_ca_comm_err++; // work required here. | 140 | dst_ca_comm_err++; // work required here. |
| @@ -153,18 +153,15 @@ static int ca_get_app_info(struct dst_state *state) | |||
| 153 | 153 | ||
| 154 | put_checksum(&command[0], command[0]); | 154 | put_checksum(&command[0], command[0]); |
| 155 | if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) { | 155 | if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) { |
| 156 | dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); | 156 | dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); |
| 157 | return -1; | 157 | return -1; |
| 158 | } | 158 | } |
| 159 | if (verbose > 1) { | 159 | dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); |
| 160 | dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); | 160 | dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================"); |
| 161 | 161 | dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]", | |
| 162 | dprintk("%s: ================================ CI Module Application Info ======================================\n", __FUNCTION__); | 162 | state->messages[7], (state->messages[8] << 8) | state->messages[9], |
| 163 | dprintk("%s: Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]\n", | 163 | (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); |
| 164 | __FUNCTION__, state->messages[7], (state->messages[8] << 8) | state->messages[9], | 164 | dprintk(verbose, DST_CA_INFO, 1, " =================================================================================================="); |
| 165 | (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); | ||
| 166 | dprintk("%s: ==================================================================================================\n", __FUNCTION__); | ||
| 167 | } | ||
| 168 | 165 | ||
| 169 | return 0; | 166 | return 0; |
| 170 | } | 167 | } |
| @@ -177,31 +174,26 @@ static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps, | |||
| 177 | 174 | ||
| 178 | put_checksum(&slot_command[0], slot_command[0]); | 175 | put_checksum(&slot_command[0], slot_command[0]); |
| 179 | if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) { | 176 | if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) { |
| 180 | dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); | 177 | dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); |
| 181 | return -1; | 178 | return -1; |
| 182 | } | 179 | } |
| 183 | if (verbose > 1) | 180 | dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !"); |
| 184 | dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); | ||
| 185 | 181 | ||
| 186 | /* Will implement the rest soon */ | 182 | /* Will implement the rest soon */ |
| 187 | 183 | ||
| 188 | if (verbose > 1) { | 184 | dprintk(verbose, DST_CA_INFO, 1, " Slot cap = [%d]", slot_cap[7]); |
| 189 | dprintk("%s: Slot cap = [%d]\n", __FUNCTION__, slot_cap[7]); | 185 | dprintk(verbose, DST_CA_INFO, 0, "===================================\n"); |
| 190 | dprintk("===================================\n"); | 186 | for (i = 0; i < 8; i++) |
| 191 | for (i = 0; i < 8; i++) | 187 | dprintk(verbose, DST_CA_INFO, 0, " %d", slot_cap[i]); |
| 192 | dprintk(" %d", slot_cap[i]); | 188 | dprintk(verbose, DST_CA_INFO, 0, "\n"); |
| 193 | dprintk("\n"); | ||
| 194 | } | ||
| 195 | 189 | ||
| 196 | p_ca_caps->slot_num = 1; | 190 | p_ca_caps->slot_num = 1; |
| 197 | p_ca_caps->slot_type = 1; | 191 | p_ca_caps->slot_type = 1; |
| 198 | p_ca_caps->descr_num = slot_cap[7]; | 192 | p_ca_caps->descr_num = slot_cap[7]; |
| 199 | p_ca_caps->descr_type = 1; | 193 | p_ca_caps->descr_type = 1; |
| 200 | 194 | ||
| 201 | 195 | if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) | |
| 202 | if (copy_to_user((struct ca_caps *)arg, p_ca_caps, sizeof (struct ca_caps))) { | ||
| 203 | return -EFAULT; | 196 | return -EFAULT; |
| 204 | } | ||
| 205 | 197 | ||
| 206 | return 0; | 198 | return 0; |
| 207 | } | 199 | } |
| @@ -222,46 +214,37 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s | |||
| 222 | 214 | ||
| 223 | put_checksum(&slot_command[0], 7); | 215 | put_checksum(&slot_command[0], 7); |
| 224 | if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) { | 216 | if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) { |
| 225 | dprintk("%s: -->dst_put_ci FAILED !\n", __FUNCTION__); | 217 | dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); |
| 226 | return -1; | 218 | return -1; |
| 227 | } | 219 | } |
| 228 | if (verbose > 1) | 220 | dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); |
| 229 | dprintk("%s: -->dst_put_ci SUCCESS !\n", __FUNCTION__); | ||
| 230 | 221 | ||
| 231 | /* Will implement the rest soon */ | 222 | /* Will implement the rest soon */ |
| 232 | 223 | ||
| 233 | if (verbose > 1) { | 224 | dprintk(verbose, DST_CA_INFO, 1, " Slot info = [%d]", slot_info[3]); |
| 234 | dprintk("%s: Slot info = [%d]\n", __FUNCTION__, slot_info[3]); | 225 | dprintk(verbose, DST_CA_INFO, 0, "===================================\n"); |
| 235 | dprintk("===================================\n"); | 226 | for (i = 0; i < 8; i++) |
| 236 | for (i = 0; i < 8; i++) | 227 | dprintk(verbose, DST_CA_INFO, 0, " %d", slot_info[i]); |
| 237 | dprintk(" %d", slot_info[i]); | 228 | dprintk(verbose, DST_CA_INFO, 0, "\n"); |
| 238 | dprintk("\n"); | ||
| 239 | } | ||
| 240 | 229 | ||
| 241 | if (slot_info[4] & 0x80) { | 230 | if (slot_info[4] & 0x80) { |
| 242 | p_ca_slot_info->flags = CA_CI_MODULE_PRESENT; | 231 | p_ca_slot_info->flags = CA_CI_MODULE_PRESENT; |
| 243 | p_ca_slot_info->num = 1; | 232 | p_ca_slot_info->num = 1; |
| 244 | p_ca_slot_info->type = CA_CI; | 233 | p_ca_slot_info->type = CA_CI; |
| 245 | } | 234 | } else if (slot_info[4] & 0x40) { |
| 246 | else if (slot_info[4] & 0x40) { | ||
| 247 | p_ca_slot_info->flags = CA_CI_MODULE_READY; | 235 | p_ca_slot_info->flags = CA_CI_MODULE_READY; |
| 248 | p_ca_slot_info->num = 1; | 236 | p_ca_slot_info->num = 1; |
| 249 | p_ca_slot_info->type = CA_CI; | 237 | p_ca_slot_info->type = CA_CI; |
| 250 | } | 238 | } else |
| 251 | else { | ||
| 252 | p_ca_slot_info->flags = 0; | 239 | p_ca_slot_info->flags = 0; |
| 253 | } | ||
| 254 | 240 | ||
| 255 | if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) { | 241 | if (copy_to_user((struct ca_slot_info *)arg, p_ca_slot_info, sizeof (struct ca_slot_info))) |
| 256 | return -EFAULT; | 242 | return -EFAULT; |
| 257 | } | ||
| 258 | 243 | ||
| 259 | return 0; | 244 | return 0; |
| 260 | } | 245 | } |
| 261 | 246 | ||
| 262 | 247 | ||
| 263 | |||
| 264 | |||
| 265 | static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg) | 248 | static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void *arg) |
| 266 | { | 249 | { |
| 267 | u8 i = 0; | 250 | u8 i = 0; |
| @@ -270,24 +253,21 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, | |||
| 270 | if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) | 253 | if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) |
| 271 | return -EFAULT; | 254 | return -EFAULT; |
| 272 | 255 | ||
| 273 | |||
| 274 | if (p_ca_message->msg) { | 256 | if (p_ca_message->msg) { |
| 275 | if (verbose > 3) | 257 | dprintk(verbose, DST_CA_NOTICE, 1, " Message = [%02x %02x %02x]", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); |
| 276 | dprintk("Message = [%02x %02x %02x]\n", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]); | ||
| 277 | 258 | ||
| 278 | for (i = 0; i < 3; i++) { | 259 | for (i = 0; i < 3; i++) { |
| 279 | command = command | p_ca_message->msg[i]; | 260 | command = command | p_ca_message->msg[i]; |
| 280 | if (i < 2) | 261 | if (i < 2) |
| 281 | command = command << 8; | 262 | command = command << 8; |
| 282 | } | 263 | } |
| 283 | if (verbose > 3) | 264 | dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command); |
| 284 | dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); | ||
| 285 | 265 | ||
| 286 | switch (command) { | 266 | switch (command) { |
| 287 | case CA_APP_INFO: | 267 | case CA_APP_INFO: |
| 288 | memcpy(p_ca_message->msg, state->messages, 128); | 268 | memcpy(p_ca_message->msg, state->messages, 128); |
| 289 | if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) | 269 | if (copy_to_user((void *)arg, p_ca_message, sizeof (struct ca_msg)) ) |
| 290 | return -EFAULT; | 270 | return -EFAULT; |
| 291 | break; | 271 | break; |
| 292 | } | 272 | } |
| 293 | } | 273 | } |
| @@ -298,10 +278,13 @@ static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, | |||
| 298 | static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length) | 278 | static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length) |
| 299 | { | 279 | { |
| 300 | if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) { | 280 | if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) { |
| 301 | hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ | 281 | hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */ |
| 302 | hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ | 282 | hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */ |
| 303 | } | 283 | } else { |
| 304 | else { | 284 | if (length > 247) { |
| 285 | dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !"); | ||
| 286 | return -1; | ||
| 287 | } | ||
| 305 | hw_buffer->msg[0] = (length & 0xff) + 7; | 288 | hw_buffer->msg[0] = (length & 0xff) + 7; |
| 306 | hw_buffer->msg[1] = 0x40; | 289 | hw_buffer->msg[1] = 0x40; |
| 307 | hw_buffer->msg[2] = 0x03; | 290 | hw_buffer->msg[2] = 0x03; |
| @@ -309,6 +292,11 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, | |||
| 309 | hw_buffer->msg[4] = 0x03; | 292 | hw_buffer->msg[4] = 0x03; |
| 310 | hw_buffer->msg[5] = length & 0xff; | 293 | hw_buffer->msg[5] = length & 0xff; |
| 311 | hw_buffer->msg[6] = 0x00; | 294 | hw_buffer->msg[6] = 0x00; |
| 295 | /* | ||
| 296 | * Need to compute length for EN50221 section 8.3.2, for the time being | ||
| 297 | * assuming 8.3.2 is not applicable | ||
| 298 | */ | ||
| 299 | memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length); | ||
| 312 | } | 300 | } |
| 313 | return 0; | 301 | return 0; |
| 314 | } | 302 | } |
| @@ -317,13 +305,12 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, | |||
| 317 | static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) | 305 | static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply) |
| 318 | { | 306 | { |
| 319 | if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) { | 307 | if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) { |
| 320 | dprintk("%s: DST-CI Command failed.\n", __FUNCTION__); | 308 | dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed."); |
| 321 | dprintk("%s: Resetting DST.\n", __FUNCTION__); | 309 | dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST."); |
| 322 | rdc_reset_state(state); | 310 | rdc_reset_state(state); |
| 323 | return -1; | 311 | return -1; |
| 324 | } | 312 | } |
| 325 | if (verbose > 2) | 313 | dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command succes."); |
| 326 | dprintk("%s: DST-CI Command succes.\n", __FUNCTION__); | ||
| 327 | 314 | ||
| 328 | return 0; | 315 | return 0; |
| 329 | } | 316 | } |
| @@ -334,130 +321,47 @@ u32 asn_1_decode(u8 *asn_1_array) | |||
| 334 | u32 length = 0; | 321 | u32 length = 0; |
| 335 | 322 | ||
| 336 | length_field = asn_1_array[0]; | 323 | length_field = asn_1_array[0]; |
| 337 | dprintk("%s: Length field=[%02x]\n", __FUNCTION__, length_field); | 324 | dprintk(verbose, DST_CA_DEBUG, 1, " Length field=[%02x]", length_field); |
| 338 | if (length_field < 0x80) { | 325 | if (length_field < 0x80) { |
| 339 | length = length_field & 0x7f; | 326 | length = length_field & 0x7f; |
| 340 | dprintk("%s: Length=[%02x]\n", __FUNCTION__, length); | 327 | dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%02x]\n", length); |
| 341 | } else { | 328 | } else { |
| 342 | word_count = length_field & 0x7f; | 329 | word_count = length_field & 0x7f; |
| 343 | for (count = 0; count < word_count; count++) { | 330 | for (count = 0; count < word_count; count++) { |
| 344 | length = (length | asn_1_array[count + 1]) << 8; | 331 | length = (length | asn_1_array[count + 1]) << 8; |
| 345 | dprintk("%s: Length=[%04x]\n", __FUNCTION__, length); | 332 | dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%04x]", length); |
| 346 | } | 333 | } |
| 347 | } | 334 | } |
| 348 | return length; | 335 | return length; |
| 349 | } | 336 | } |
| 350 | 337 | ||
| 351 | static int init_buffer(u8 *buffer, u32 length) | ||
| 352 | { | ||
| 353 | u32 i; | ||
| 354 | for (i = 0; i < length; i++) | ||
| 355 | buffer[i] = 0; | ||
| 356 | |||
| 357 | return 0; | ||
| 358 | } | ||
| 359 | |||
| 360 | static int debug_string(u8 *msg, u32 length, u32 offset) | 338 | static int debug_string(u8 *msg, u32 length, u32 offset) |
| 361 | { | 339 | { |
| 362 | u32 i; | 340 | u32 i; |
| 363 | 341 | ||
| 364 | dprintk(" String=[ "); | 342 | dprintk(verbose, DST_CA_DEBUG, 0, " String=[ "); |
| 365 | for (i = offset; i < length; i++) | 343 | for (i = offset; i < length; i++) |
| 366 | dprintk("%02x ", msg[i]); | 344 | dprintk(verbose, DST_CA_DEBUG, 0, "%02x ", msg[i]); |
| 367 | dprintk("]\n"); | 345 | dprintk(verbose, DST_CA_DEBUG, 0, "]\n"); |
| 368 | |||
| 369 | return 0; | ||
| 370 | } | ||
| 371 | |||
| 372 | static int copy_string(u8 *destination, u8 *source, u32 dest_offset, u32 source_offset, u32 length) | ||
| 373 | { | ||
| 374 | u32 i; | ||
| 375 | dprintk("%s: Copying [", __FUNCTION__); | ||
| 376 | for (i = 0; i < length; i++) { | ||
| 377 | destination[i + dest_offset] = source[i + source_offset]; | ||
| 378 | dprintk(" %02x", source[i + source_offset]); | ||
| 379 | } | ||
| 380 | dprintk("]\n"); | ||
| 381 | |||
| 382 | return i; | ||
| 383 | } | ||
| 384 | |||
| 385 | static int modify_4_bits(u8 *message, u32 pos) | ||
| 386 | { | ||
| 387 | message[pos] &= 0x0f; | ||
| 388 | 346 | ||
| 389 | return 0; | 347 | return 0; |
| 390 | } | 348 | } |
| 391 | 349 | ||
| 392 | |||
| 393 | |||
| 394 | static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query) | 350 | static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query) |
| 395 | { | 351 | { |
| 396 | u32 length = 0, count = 0; | 352 | u32 length = 0; |
| 397 | u8 asn_1_words, program_header_length; | 353 | u8 tag_length = 8; |
| 398 | u16 program_info_length = 0, es_info_length = 0; | ||
| 399 | u32 hw_offset = 0, buf_offset = 0, i; | ||
| 400 | u8 dst_tag_length; | ||
| 401 | 354 | ||
| 402 | length = asn_1_decode(&p_ca_message->msg[3]); | 355 | length = asn_1_decode(&p_ca_message->msg[3]); |
| 403 | dprintk("%s: CA Message length=[%d]\n", __FUNCTION__, length); | 356 | dprintk(verbose, DST_CA_DEBUG, 1, " CA Message length=[%d]", length); |
| 404 | dprintk("%s: ASN.1 ", __FUNCTION__); | 357 | debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */ |
| 405 | debug_string(&p_ca_message->msg[4], length, 0); // length does not include tag and length | ||
| 406 | 358 | ||
| 407 | init_buffer(hw_buffer->msg, length); | 359 | memset(hw_buffer->msg, '\0', length); |
| 408 | handle_dst_tag(state, p_ca_message, hw_buffer, length); | 360 | handle_dst_tag(state, p_ca_message, hw_buffer, length); |
| 361 | put_checksum(hw_buffer->msg, hw_buffer->msg[0]); | ||
| 409 | 362 | ||
| 410 | hw_offset = 7; | 363 | debug_string(hw_buffer->msg, (length + tag_length), 0); /* tags too */ |
| 411 | asn_1_words = 1; // just a hack to test, should compute this one | 364 | write_to_8820(state, hw_buffer, (length + tag_length), reply); |
| 412 | buf_offset = 3; | ||
| 413 | program_header_length = 6; | ||
| 414 | dst_tag_length = 7; | ||
| 415 | |||
| 416 | // debug_twinhan_ca_params(state, p_ca_message, hw_buffer, reply, query, length, hw_offset, buf_offset); | ||
| 417 | // dprintk("%s: Program Header(BUF)", __FUNCTION__); | ||
| 418 | // debug_string(&p_ca_message->msg[4], program_header_length, 0); | ||
| 419 | // dprintk("%s: Copying Program header\n", __FUNCTION__); | ||
| 420 | copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + asn_1_words), program_header_length); | ||
| 421 | buf_offset += program_header_length, hw_offset += program_header_length; | ||
| 422 | modify_4_bits(hw_buffer->msg, (hw_offset - 2)); | ||
| 423 | if (state->type_flags & DST_TYPE_HAS_INC_COUNT) { // workaround | ||
| 424 | dprintk("%s: Probably an ASIC bug !!!\n", __FUNCTION__); | ||
| 425 | debug_string(hw_buffer->msg, (hw_offset + program_header_length), 0); | ||
| 426 | hw_buffer->msg[hw_offset - 1] += 1; | ||
| 427 | } | ||
| 428 | |||
| 429 | // dprintk("%s: Program Header(HW), Count=[%d]", __FUNCTION__, count); | ||
| 430 | // debug_string(hw_buffer->msg, hw_offset, 0); | ||
| 431 | |||
| 432 | program_info_length = ((program_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset]; | ||
| 433 | dprintk("%s: Program info length=[%02x]\n", __FUNCTION__, program_info_length); | ||
| 434 | if (program_info_length) { | ||
| 435 | count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, (buf_offset + 1), (program_info_length + 1) ); // copy next elem, not current | ||
| 436 | buf_offset += count, hw_offset += count; | ||
| 437 | // dprintk("%s: Program level ", __FUNCTION__); | ||
| 438 | // debug_string(hw_buffer->msg, hw_offset, 0); | ||
| 439 | } | ||
| 440 | |||
| 441 | buf_offset += 1;// hw_offset += 1; | ||
| 442 | for (i = buf_offset; i < length; i++) { | ||
| 443 | // dprintk("%s: Stream Header ", __FUNCTION__); | ||
| 444 | count = copy_string(hw_buffer->msg, p_ca_message->msg, hw_offset, buf_offset, 5); | ||
| 445 | modify_4_bits(hw_buffer->msg, (hw_offset + 3)); | ||
| 446 | |||
| 447 | hw_offset += 5, buf_offset += 5, i += 4; | ||
| 448 | // debug_string(hw_buffer->msg, hw_offset, (hw_offset - 5)); | ||
| 449 | es_info_length = ((es_info_length | (p_ca_message->msg[buf_offset - 1] & 0x0f)) << 8) | p_ca_message->msg[buf_offset]; | ||
| 450 | dprintk("%s: ES info length=[%02x]\n", __FUNCTION__, es_info_length); | ||
| 451 | if (es_info_length) { | ||
| 452 | // copy descriptors @ STREAM level | ||
| 453 | dprintk("%s: Descriptors @ STREAM level...!!! \n", __FUNCTION__); | ||
| 454 | } | ||
| 455 | |||
| 456 | } | ||
| 457 | hw_buffer->msg[length + dst_tag_length] = dst_check_sum(hw_buffer->msg, (length + dst_tag_length)); | ||
| 458 | // dprintk("%s: Total length=[%d], Checksum=[%02x]\n", __FUNCTION__, (length + dst_tag_length), hw_buffer->msg[length + dst_tag_length]); | ||
| 459 | debug_string(hw_buffer->msg, (length + dst_tag_length + 1), 0); // dst tags also | ||
| 460 | write_to_8820(state, hw_buffer, (length + dst_tag_length + 1), reply); // checksum | ||
| 461 | 365 | ||
| 462 | return 0; | 366 | return 0; |
| 463 | } | 367 | } |
| @@ -471,26 +375,24 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message | |||
| 471 | /* Do test board */ | 375 | /* Do test board */ |
| 472 | /* Not there yet but soon */ | 376 | /* Not there yet but soon */ |
| 473 | 377 | ||
| 474 | |||
| 475 | /* CA PMT Reply capable */ | 378 | /* CA PMT Reply capable */ |
| 476 | if (ca_pmt_reply_test) { | 379 | if (ca_pmt_reply_test) { |
| 477 | if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) { | 380 | if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) { |
| 478 | dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); | 381 | dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); |
| 479 | return -1; | 382 | return -1; |
| 480 | } | 383 | } |
| 481 | 384 | ||
| 482 | /* Process CA PMT Reply */ | 385 | /* Process CA PMT Reply */ |
| 483 | /* will implement soon */ | 386 | /* will implement soon */ |
| 484 | dprintk("%s: Not there yet\n", __FUNCTION__); | 387 | dprintk(verbose, DST_CA_ERROR, 1, " Not there yet"); |
| 485 | } | 388 | } |
| 486 | /* CA PMT Reply not capable */ | 389 | /* CA PMT Reply not capable */ |
| 487 | if (!ca_pmt_reply_test) { | 390 | if (!ca_pmt_reply_test) { |
| 488 | if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) { | 391 | if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) { |
| 489 | dprintk("%s: ca_set_pmt.. failed !\n", __FUNCTION__); | 392 | dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); |
| 490 | return -1; | 393 | return -1; |
| 491 | } | 394 | } |
| 492 | if (verbose > 3) | 395 | dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !"); |
| 493 | dprintk("%s: ca_set_pmt.. success !\n", __FUNCTION__); | ||
| 494 | /* put a dummy message */ | 396 | /* put a dummy message */ |
| 495 | 397 | ||
| 496 | } | 398 | } |
| @@ -506,11 +408,10 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, | |||
| 506 | struct ca_msg *hw_buffer; | 408 | struct ca_msg *hw_buffer; |
| 507 | 409 | ||
| 508 | if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { | 410 | if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { |
| 509 | dprintk("%s: Memory allocation failure\n", __FUNCTION__); | 411 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
| 510 | return -ENOMEM; | 412 | return -ENOMEM; |
| 511 | } | 413 | } |
| 512 | if (verbose > 3) | 414 | dprintk(verbose, DST_CA_DEBUG, 1, " "); |
| 513 | dprintk("%s\n", __FUNCTION__); | ||
| 514 | 415 | ||
| 515 | if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) | 416 | if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) |
| 516 | return -EFAULT; | 417 | return -EFAULT; |
| @@ -525,51 +426,35 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, | |||
| 525 | if (i < 2) | 426 | if (i < 2) |
| 526 | command = command << 8; | 427 | command = command << 8; |
| 527 | } | 428 | } |
| 528 | if (verbose > 3) | 429 | dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command); |
| 529 | dprintk("%s:Command=[0x%x]\n", __FUNCTION__, command); | ||
| 530 | 430 | ||
| 531 | switch (command) { | 431 | switch (command) { |
| 532 | case CA_PMT: | 432 | case CA_PMT: |
| 533 | if (verbose > 3) | 433 | dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT"); |
| 534 | // dprintk("Command = SEND_CA_PMT\n"); | 434 | if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started |
| 535 | dprintk("Command = SEND_CA_PMT\n"); | 435 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !"); |
| 536 | // if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { | 436 | return -1; |
| 537 | if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started | 437 | } |
| 538 | dprintk("%s: -->CA_PMT Failed !\n", __FUNCTION__); | 438 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !"); |
| 539 | return -1; | 439 | break; |
| 540 | } | 440 | case CA_PMT_REPLY: |
| 541 | if (verbose > 3) | 441 | dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY"); |
| 542 | dprintk("%s: -->CA_PMT Success !\n", __FUNCTION__); | 442 | /* Have to handle the 2 basic types of cards here */ |
| 543 | // retval = dummy_set_pmt(state, p_ca_message, hw_buffer, 0, 0); | 443 | if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { |
| 544 | 444 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !"); | |
| 545 | break; | 445 | return -1; |
| 546 | 446 | } | |
| 547 | case CA_PMT_REPLY: | 447 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !"); |
| 548 | if (verbose > 3) | 448 | break; |
| 549 | dprintk("Command = CA_PMT_REPLY\n"); | 449 | case CA_APP_INFO_ENQUIRY: // only for debugging |
| 550 | /* Have to handle the 2 basic types of cards here */ | 450 | dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information"); |
| 551 | if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) { | 451 | |
| 552 | dprintk("%s: -->CA_PMT_REPLY Failed !\n", __FUNCTION__); | 452 | if ((ca_get_app_info(state)) < 0) { |
| 553 | return -1; | 453 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !"); |
| 554 | } | 454 | return -1; |
| 555 | if (verbose > 3) | 455 | } |
| 556 | dprintk("%s: -->CA_PMT_REPLY Success !\n", __FUNCTION__); | 456 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !"); |
| 557 | 457 | break; | |
| 558 | /* Certain boards do behave different ? */ | ||
| 559 | // retval = ca_set_pmt(state, p_ca_message, hw_buffer, 1, 1); | ||
| 560 | |||
| 561 | case CA_APP_INFO_ENQUIRY: // only for debugging | ||
| 562 | if (verbose > 3) | ||
| 563 | dprintk("%s: Getting Cam Application information\n", __FUNCTION__); | ||
| 564 | |||
| 565 | if ((ca_get_app_info(state)) < 0) { | ||
| 566 | dprintk("%s: -->CA_APP_INFO_ENQUIRY Failed !\n", __FUNCTION__); | ||
| 567 | return -1; | ||
| 568 | } | ||
| 569 | if (verbose > 3) | ||
| 570 | dprintk("%s: -->CA_APP_INFO_ENQUIRY Success !\n", __FUNCTION__); | ||
| 571 | |||
| 572 | break; | ||
| 573 | } | 458 | } |
| 574 | } | 459 | } |
| 575 | return 0; | 460 | return 0; |
| @@ -584,121 +469,88 @@ static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd | |||
| 584 | struct ca_msg *p_ca_message; | 469 | struct ca_msg *p_ca_message; |
| 585 | 470 | ||
| 586 | if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { | 471 | if ((p_ca_message = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) { |
| 587 | dprintk("%s: Memory allocation failure\n", __FUNCTION__); | 472 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
| 588 | return -ENOMEM; | 473 | return -ENOMEM; |
| 589 | } | 474 | } |
| 590 | |||
| 591 | if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) { | 475 | if ((p_ca_slot_info = (struct ca_slot_info *) kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL)) == NULL) { |
| 592 | dprintk("%s: Memory allocation failure\n", __FUNCTION__); | 476 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
| 593 | return -ENOMEM; | 477 | return -ENOMEM; |
| 594 | } | 478 | } |
| 595 | |||
| 596 | if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) { | 479 | if ((p_ca_caps = (struct ca_caps *) kmalloc(sizeof (struct ca_caps), GFP_KERNEL)) == NULL) { |
| 597 | dprintk("%s: Memory allocation failure\n", __FUNCTION__); | 480 | dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure"); |
| 598 | return -ENOMEM; | 481 | return -ENOMEM; |
| 599 | } | 482 | } |
| 600 | |||
| 601 | /* We have now only the standard ioctl's, the driver is upposed to handle internals. */ | 483 | /* We have now only the standard ioctl's, the driver is upposed to handle internals. */ |
| 602 | switch (cmd) { | 484 | switch (cmd) { |
| 603 | case CA_SEND_MSG: | 485 | case CA_SEND_MSG: |
| 604 | if (verbose > 1) | 486 | dprintk(verbose, DST_CA_INFO, 1, " Sending message"); |
| 605 | dprintk("%s: Sending message\n", __FUNCTION__); | 487 | if ((ca_send_message(state, p_ca_message, arg)) < 0) { |
| 606 | if ((ca_send_message(state, p_ca_message, arg)) < 0) { | 488 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !"); |
| 607 | dprintk("%s: -->CA_SEND_MSG Failed !\n", __FUNCTION__); | 489 | return -1; |
| 608 | return -1; | 490 | } |
| 609 | } | 491 | break; |
| 610 | 492 | case CA_GET_MSG: | |
| 611 | break; | 493 | dprintk(verbose, DST_CA_INFO, 1, " Getting message"); |
| 612 | 494 | if ((ca_get_message(state, p_ca_message, arg)) < 0) { | |
| 613 | case CA_GET_MSG: | 495 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !"); |
| 614 | if (verbose > 1) | 496 | return -1; |
| 615 | dprintk("%s: Getting message\n", __FUNCTION__); | 497 | } |
| 616 | if ((ca_get_message(state, p_ca_message, arg)) < 0) { | 498 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !"); |
| 617 | dprintk("%s: -->CA_GET_MSG Failed !\n", __FUNCTION__); | 499 | break; |
| 618 | return -1; | 500 | case CA_RESET: |
| 619 | } | 501 | dprintk(verbose, DST_CA_ERROR, 1, " Resetting DST"); |
| 620 | if (verbose > 1) | 502 | dst_error_bailout(state); |
| 621 | dprintk("%s: -->CA_GET_MSG Success !\n", __FUNCTION__); | 503 | msleep(4000); |
| 622 | 504 | break; | |
| 623 | break; | 505 | case CA_GET_SLOT_INFO: |
| 624 | 506 | dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info"); | |
| 625 | case CA_RESET: | 507 | if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { |
| 626 | if (verbose > 1) | 508 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !"); |
| 627 | dprintk("%s: Resetting DST\n", __FUNCTION__); | 509 | return -1; |
| 628 | dst_error_bailout(state); | 510 | } |
| 629 | msleep(4000); | 511 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_SLOT_INFO Success !"); |
| 630 | 512 | break; | |
| 631 | break; | 513 | case CA_GET_CAP: |
| 632 | 514 | dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities"); | |
| 633 | case CA_GET_SLOT_INFO: | 515 | if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { |
| 634 | if (verbose > 1) | 516 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !"); |
| 635 | dprintk("%s: Getting Slot info\n", __FUNCTION__); | 517 | return -1; |
| 636 | if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { | 518 | } |
| 637 | dprintk("%s: -->CA_GET_SLOT_INFO Failed !\n", __FUNCTION__); | 519 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !"); |
| 638 | return -1; | 520 | break; |
| 639 | } | 521 | case CA_GET_DESCR_INFO: |
| 640 | if (verbose > 1) | 522 | dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description"); |
| 641 | dprintk("%s: -->CA_GET_SLOT_INFO Success !\n", __FUNCTION__); | 523 | if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { |
| 642 | 524 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !"); | |
| 643 | break; | 525 | return -1; |
| 644 | 526 | } | |
| 645 | case CA_GET_CAP: | 527 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !"); |
| 646 | if (verbose > 1) | 528 | break; |
| 647 | dprintk("%s: Getting Slot capabilities\n", __FUNCTION__); | 529 | case CA_SET_DESCR: |
| 648 | if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { | 530 | dprintk(verbose, DST_CA_INFO, 1, " Setting descrambler"); |
| 649 | dprintk("%s: -->CA_GET_CAP Failed !\n", __FUNCTION__); | 531 | if ((ca_set_slot_descr()) < 0) { |
| 650 | return -1; | 532 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_DESCR Failed !"); |
| 651 | } | 533 | return -1; |
| 652 | if (verbose > 1) | 534 | } |
| 653 | dprintk("%s: -->CA_GET_CAP Success !\n", __FUNCTION__); | 535 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_DESCR Success !"); |
| 654 | 536 | break; | |
| 655 | break; | 537 | case CA_SET_PID: |
| 656 | 538 | dprintk(verbose, DST_CA_INFO, 1, " Setting PID"); | |
| 657 | case CA_GET_DESCR_INFO: | 539 | if ((ca_set_pid()) < 0) { |
| 658 | if (verbose > 1) | 540 | dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_PID Failed !"); |
| 659 | dprintk("%s: Getting descrambler description\n", __FUNCTION__); | 541 | return -1; |
| 660 | if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { | 542 | } |
| 661 | dprintk("%s: -->CA_GET_DESCR_INFO Failed !\n", __FUNCTION__); | 543 | dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_PID Success !"); |
| 662 | return -1; | 544 | default: |
| 663 | } | 545 | return -EOPNOTSUPP; |
| 664 | if (verbose > 1) | 546 | }; |
| 665 | dprintk("%s: -->CA_GET_DESCR_INFO Success !\n", __FUNCTION__); | ||
| 666 | |||
| 667 | break; | ||
| 668 | |||
| 669 | case CA_SET_DESCR: | ||
| 670 | if (verbose > 1) | ||
| 671 | dprintk("%s: Setting descrambler\n", __FUNCTION__); | ||
| 672 | if ((ca_set_slot_descr()) < 0) { | ||
| 673 | dprintk("%s: -->CA_SET_DESCR Failed !\n", __FUNCTION__); | ||
| 674 | return -1; | ||
| 675 | } | ||
| 676 | if (verbose > 1) | ||
| 677 | dprintk("%s: -->CA_SET_DESCR Success !\n", __FUNCTION__); | ||
| 678 | |||
| 679 | break; | ||
| 680 | |||
| 681 | case CA_SET_PID: | ||
| 682 | if (verbose > 1) | ||
| 683 | dprintk("%s: Setting PID\n", __FUNCTION__); | ||
| 684 | if ((ca_set_pid()) < 0) { | ||
| 685 | dprintk("%s: -->CA_SET_PID Failed !\n", __FUNCTION__); | ||
| 686 | return -1; | ||
| 687 | } | ||
| 688 | if (verbose > 1) | ||
| 689 | dprintk("%s: -->CA_SET_PID Success !\n", __FUNCTION__); | ||
| 690 | |||
| 691 | default: | ||
| 692 | return -EOPNOTSUPP; | ||
| 693 | }; | ||
| 694 | 547 | ||
| 695 | return 0; | 548 | return 0; |
| 696 | } | 549 | } |
| 697 | 550 | ||
| 698 | static int dst_ca_open(struct inode *inode, struct file *file) | 551 | static int dst_ca_open(struct inode *inode, struct file *file) |
| 699 | { | 552 | { |
| 700 | if (verbose > 4) | 553 | dprintk(verbose, DST_CA_DEBUG, 1, " Device opened [%p] ", file); |
| 701 | dprintk("%s:Device opened [%p]\n", __FUNCTION__, file); | ||
| 702 | try_module_get(THIS_MODULE); | 554 | try_module_get(THIS_MODULE); |
| 703 | 555 | ||
| 704 | return 0; | 556 | return 0; |
| @@ -706,27 +558,24 @@ static int dst_ca_open(struct inode *inode, struct file *file) | |||
| 706 | 558 | ||
| 707 | static int dst_ca_release(struct inode *inode, struct file *file) | 559 | static int dst_ca_release(struct inode *inode, struct file *file) |
| 708 | { | 560 | { |
| 709 | if (verbose > 4) | 561 | dprintk(verbose, DST_CA_DEBUG, 1, " Device closed."); |
| 710 | dprintk("%s:Device closed.\n", __FUNCTION__); | ||
| 711 | module_put(THIS_MODULE); | 562 | module_put(THIS_MODULE); |
| 712 | 563 | ||
| 713 | return 0; | 564 | return 0; |
| 714 | } | 565 | } |
| 715 | 566 | ||
| 716 | static int dst_ca_read(struct file *file, char __user * buffer, size_t length, loff_t * offset) | 567 | static int dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset) |
| 717 | { | 568 | { |
| 718 | int bytes_read = 0; | 569 | int bytes_read = 0; |
| 719 | 570 | ||
| 720 | if (verbose > 4) | 571 | dprintk(verbose, DST_CA_DEBUG, 1, " Device read."); |
| 721 | dprintk("%s:Device read.\n", __FUNCTION__); | ||
| 722 | 572 | ||
| 723 | return bytes_read; | 573 | return bytes_read; |
| 724 | } | 574 | } |
| 725 | 575 | ||
| 726 | static int dst_ca_write(struct file *file, const char __user * buffer, size_t length, loff_t * offset) | 576 | static int dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset) |
| 727 | { | 577 | { |
| 728 | if (verbose > 4) | 578 | dprintk(verbose, DST_CA_DEBUG, 1, " Device write."); |
| 729 | dprintk("%s:Device write.\n", __FUNCTION__); | ||
| 730 | 579 | ||
| 731 | return 0; | 580 | return 0; |
| 732 | } | 581 | } |
| @@ -751,8 +600,7 @@ static struct dvb_device dvbdev_ca = { | |||
| 751 | int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) | 600 | int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) |
| 752 | { | 601 | { |
| 753 | struct dvb_device *dvbdev; | 602 | struct dvb_device *dvbdev; |
| 754 | if (verbose > 4) | 603 | dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device"); |
| 755 | dprintk("%s:registering DST-CA device\n", __FUNCTION__); | ||
| 756 | dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA); | 604 | dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA); |
| 757 | return 0; | 605 | return 0; |
| 758 | } | 606 | } |
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h index ef532a6aceaa..3281a6ca3685 100644 --- a/drivers/media/dvb/bt8xx/dst_common.h +++ b/drivers/media/dvb/bt8xx/dst_common.h | |||
| @@ -61,7 +61,6 @@ | |||
| 61 | #define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */ | 61 | #define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */ |
| 62 | #define DST_TYPE_HAS_SESSION 128 | 62 | #define DST_TYPE_HAS_SESSION 128 |
| 63 | 63 | ||
| 64 | |||
| 65 | #define RDC_8820_PIO_0_DISABLE 0 | 64 | #define RDC_8820_PIO_0_DISABLE 0 |
| 66 | #define RDC_8820_PIO_0_ENABLE 1 | 65 | #define RDC_8820_PIO_0_ENABLE 1 |
| 67 | #define RDC_8820_INT 2 | 66 | #define RDC_8820_INT 2 |
| @@ -114,6 +113,10 @@ struct dst_state { | |||
| 114 | fe_sec_mini_cmd_t minicmd; | 113 | fe_sec_mini_cmd_t minicmd; |
| 115 | fe_modulation_t modulation; | 114 | fe_modulation_t modulation; |
| 116 | u8 messages[256]; | 115 | u8 messages[256]; |
| 116 | u8 mac_address[8]; | ||
| 117 | u8 fw_version[8]; | ||
| 118 | u8 card_info[8]; | ||
| 119 | u8 vendor[8]; | ||
| 117 | }; | 120 | }; |
| 118 | 121 | ||
| 119 | struct dst_types { | 122 | struct dst_types { |
| @@ -124,15 +127,12 @@ struct dst_types { | |||
| 124 | u32 dst_feature; | 127 | u32 dst_feature; |
| 125 | }; | 128 | }; |
| 126 | 129 | ||
| 127 | |||
| 128 | |||
| 129 | struct dst_config | 130 | struct dst_config |
| 130 | { | 131 | { |
| 131 | /* the ASIC i2c address */ | 132 | /* the ASIC i2c address */ |
| 132 | u8 demod_address; | 133 | u8 demod_address; |
| 133 | }; | 134 | }; |
| 134 | 135 | ||
| 135 | |||
| 136 | int rdc_reset_state(struct dst_state *state); | 136 | int rdc_reset_state(struct dst_state *state); |
| 137 | int rdc_8820_reset(struct dst_state *state); | 137 | int rdc_8820_reset(struct dst_state *state); |
| 138 | 138 | ||
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index 6f857c6091f3..c5c7672cd538 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c | |||
| @@ -32,9 +32,7 @@ | |||
| 32 | #include "dvbdev.h" | 32 | #include "dvbdev.h" |
| 33 | #include "dvb_demux.h" | 33 | #include "dvb_demux.h" |
| 34 | #include "dvb_frontend.h" | 34 | #include "dvb_frontend.h" |
| 35 | |||
| 36 | #include "dvb-bt8xx.h" | 35 | #include "dvb-bt8xx.h" |
| 37 | |||
| 38 | #include "bt878.h" | 36 | #include "bt878.h" |
| 39 | 37 | ||
| 40 | static int debug; | 38 | static int debug; |
| @@ -43,9 +41,11 @@ module_param(debug, int, 0644); | |||
| 43 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | 41 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); |
| 44 | 42 | ||
| 45 | #define dprintk( args... ) \ | 43 | #define dprintk( args... ) \ |
| 46 | do { \ | 44 | do \ |
| 47 | if (debug) printk(KERN_DEBUG args); \ | 45 | if (debug) printk(KERN_DEBUG args); \ |
| 48 | } while (0) | 46 | while (0) |
| 47 | |||
| 48 | #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ | ||
| 49 | 49 | ||
| 50 | static void dvb_bt8xx_task(unsigned long data) | 50 | static void dvb_bt8xx_task(unsigned long data) |
| 51 | { | 51 | { |
| @@ -119,14 +119,12 @@ static struct bt878 __init *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci | |||
| 119 | unsigned int card_nr; | 119 | unsigned int card_nr; |
| 120 | 120 | ||
| 121 | /* Hmm, n squared. Hope n is small */ | 121 | /* Hmm, n squared. Hope n is small */ |
| 122 | for (card_nr = 0; card_nr < bt878_num; card_nr++) { | 122 | for (card_nr = 0; card_nr < bt878_num; card_nr++) |
| 123 | if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev)) | 123 | if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev)) |
| 124 | return &bt878[card_nr]; | 124 | return &bt878[card_nr]; |
| 125 | } | ||
| 126 | return NULL; | 125 | return NULL; |
| 127 | } | 126 | } |
| 128 | 127 | ||
| 129 | |||
| 130 | static int thomson_dtt7579_demod_init(struct dvb_frontend* fe) | 128 | static int thomson_dtt7579_demod_init(struct dvb_frontend* fe) |
| 131 | { | 129 | { |
| 132 | static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 }; | 130 | static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 }; |
| @@ -154,16 +152,21 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ | |||
| 154 | unsigned char bs = 0; | 152 | unsigned char bs = 0; |
| 155 | unsigned char cp = 0; | 153 | unsigned char cp = 0; |
| 156 | 154 | ||
| 157 | #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ | ||
| 158 | div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; | 155 | div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; |
| 159 | 156 | ||
| 160 | if (params->frequency < 542000000) cp = 0xb4; | 157 | if (params->frequency < 542000000) |
| 161 | else if (params->frequency < 771000000) cp = 0xbc; | 158 | cp = 0xb4; |
| 162 | else cp = 0xf4; | 159 | else if (params->frequency < 771000000) |
| 160 | cp = 0xbc; | ||
| 161 | else | ||
| 162 | cp = 0xf4; | ||
| 163 | 163 | ||
| 164 | if (params->frequency == 0) bs = 0x03; | 164 | if (params->frequency == 0) |
| 165 | else if (params->frequency < 443250000) bs = 0x02; | 165 | bs = 0x03; |
| 166 | else bs = 0x08; | 166 | else if (params->frequency < 443250000) |
| 167 | bs = 0x02; | ||
| 168 | else | ||
| 169 | bs = 0x08; | ||
| 167 | 170 | ||
| 168 | pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address | 171 | pllbuf[0] = 0xc0; // Note: non-linux standard PLL i2c address |
| 169 | pllbuf[1] = div >> 8; | 172 | pllbuf[1] = div >> 8; |
| @@ -175,7 +178,6 @@ static int thomson_dtt7579_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ | |||
| 175 | } | 178 | } |
| 176 | 179 | ||
| 177 | static struct mt352_config thomson_dtt7579_config = { | 180 | static struct mt352_config thomson_dtt7579_config = { |
| 178 | |||
| 179 | .demod_address = 0x0f, | 181 | .demod_address = 0x0f, |
| 180 | .demod_init = thomson_dtt7579_demod_init, | 182 | .demod_init = thomson_dtt7579_demod_init, |
| 181 | .pll_set = thomson_dtt7579_pll_set, | 183 | .pll_set = thomson_dtt7579_pll_set, |
| @@ -183,25 +185,26 @@ static struct mt352_config thomson_dtt7579_config = { | |||
| 183 | 185 | ||
| 184 | static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 186 | static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 185 | { | 187 | { |
| 186 | u32 freq = params->frequency; | 188 | u32 freq = params->frequency; |
| 187 | |||
| 188 | int i, a, n, pump; | ||
| 189 | u32 band, pll; | ||
| 190 | 189 | ||
| 190 | int i, a, n, pump; | ||
| 191 | u32 band, pll; | ||
| 191 | 192 | ||
| 192 | u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, | 193 | u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000, |
| 193 | 1576000,1718000,1856000,2036000,2150000}; | 194 | 1576000,1718000,1856000,2036000,2150000}; |
| 194 | u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, | 195 | u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000, |
| 195 | 0x00102000,0x00104000,0x00108000,0x00110000, | 196 | 0x00102000,0x00104000,0x00108000,0x00110000, |
| 196 | 0x00120000,0x00140000}; | 197 | 0x00120000,0x00140000}; |
| 197 | 198 | ||
| 198 | #define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ | 199 | #define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */ |
| 199 | printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq); | 200 | printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq); |
| 200 | 201 | ||
| 201 | /* This is really the bit driving the tuner chip cx24108 */ | 202 | /* This is really the bit driving the tuner chip cx24108 */ |
| 202 | 203 | ||
| 203 | if(freq<950000) freq=950000; /* kHz */ | 204 | if (freq<950000) |
| 204 | if(freq>2150000) freq=2150000; /* satellite IF is 950..2150MHz */ | 205 | freq = 950000; /* kHz */ |
| 206 | else if (freq>2150000) | ||
| 207 | freq = 2150000; /* satellite IF is 950..2150MHz */ | ||
| 205 | 208 | ||
| 206 | /* decide which VCO to use for the input frequency */ | 209 | /* decide which VCO to use for the input frequency */ |
| 207 | for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++); | 210 | for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++); |
| @@ -228,25 +231,22 @@ static int cx24108_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete | |||
| 228 | cx24110_pll_write(fe,0x500c0000); | 231 | cx24110_pll_write(fe,0x500c0000); |
| 229 | cx24110_pll_write(fe,0x83f1f800); | 232 | cx24110_pll_write(fe,0x83f1f800); |
| 230 | cx24110_pll_write(fe,pll); | 233 | cx24110_pll_write(fe,pll); |
| 231 | /* writereg(client,0x56,0x7f);*/ | 234 | //writereg(client,0x56,0x7f); |
| 232 | 235 | ||
| 233 | return 0; | 236 | return 0; |
| 234 | } | 237 | } |
| 235 | 238 | ||
| 236 | static int pinnsat_pll_init(struct dvb_frontend* fe) | 239 | static int pinnsat_pll_init(struct dvb_frontend* fe) |
| 237 | { | 240 | { |
| 238 | return 0; | 241 | return 0; |
| 239 | } | 242 | } |
| 240 | 243 | ||
| 241 | |||
| 242 | static struct cx24110_config pctvsat_config = { | 244 | static struct cx24110_config pctvsat_config = { |
| 243 | |||
| 244 | .demod_address = 0x55, | 245 | .demod_address = 0x55, |
| 245 | .pll_init = pinnsat_pll_init, | 246 | .pll_init = pinnsat_pll_init, |
| 246 | .pll_set = cx24108_pll_set, | 247 | .pll_set = cx24108_pll_set, |
| 247 | }; | 248 | }; |
| 248 | 249 | ||
| 249 | |||
| 250 | static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 250 | static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 251 | { | 251 | { |
| 252 | struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; | 252 | struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; |
| @@ -258,15 +258,23 @@ static int microtune_mt7202dtf_pll_set(struct dvb_frontend* fe, struct dvb_front | |||
| 258 | div = (36000000 + params->frequency + 83333) / 166666; | 258 | div = (36000000 + params->frequency + 83333) / 166666; |
| 259 | cfg = 0x88; | 259 | cfg = 0x88; |
| 260 | 260 | ||
| 261 | if (params->frequency < 175000000) cpump = 2; | 261 | if (params->frequency < 175000000) |
| 262 | else if (params->frequency < 390000000) cpump = 1; | 262 | cpump = 2; |
| 263 | else if (params->frequency < 470000000) cpump = 2; | 263 | else if (params->frequency < 390000000) |
| 264 | else if (params->frequency < 750000000) cpump = 2; | 264 | cpump = 1; |
| 265 | else cpump = 3; | 265 | else if (params->frequency < 470000000) |
| 266 | cpump = 2; | ||
| 267 | else if (params->frequency < 750000000) | ||
| 268 | cpump = 2; | ||
| 269 | else | ||
| 270 | cpump = 3; | ||
| 266 | 271 | ||
| 267 | if (params->frequency < 175000000) band_select = 0x0e; | 272 | if (params->frequency < 175000000) |
| 268 | else if (params->frequency < 470000000) band_select = 0x05; | 273 | band_select = 0x0e; |
| 269 | else band_select = 0x03; | 274 | else if (params->frequency < 470000000) |
| 275 | band_select = 0x05; | ||
| 276 | else | ||
| 277 | band_select = 0x03; | ||
| 270 | 278 | ||
| 271 | data[0] = (div >> 8) & 0x7f; | 279 | data[0] = (div >> 8) & 0x7f; |
| 272 | data[1] = div & 0xff; | 280 | data[1] = div & 0xff; |
| @@ -285,14 +293,11 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s | |||
| 285 | } | 293 | } |
| 286 | 294 | ||
| 287 | static struct sp887x_config microtune_mt7202dtf_config = { | 295 | static struct sp887x_config microtune_mt7202dtf_config = { |
| 288 | |||
| 289 | .demod_address = 0x70, | 296 | .demod_address = 0x70, |
| 290 | .pll_set = microtune_mt7202dtf_pll_set, | 297 | .pll_set = microtune_mt7202dtf_pll_set, |
| 291 | .request_firmware = microtune_mt7202dtf_request_firmware, | 298 | .request_firmware = microtune_mt7202dtf_request_firmware, |
| 292 | }; | 299 | }; |
| 293 | 300 | ||
| 294 | |||
| 295 | |||
| 296 | static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) | 301 | static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) |
| 297 | { | 302 | { |
| 298 | static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; | 303 | static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; |
| @@ -303,7 +308,6 @@ static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe) | |||
| 303 | static u8 mt352_av771_extra[] = { 0xB5, 0x7A }; | 308 | static u8 mt352_av771_extra[] = { 0xB5, 0x7A }; |
| 304 | static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; | 309 | static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; |
| 305 | 310 | ||
| 306 | |||
| 307 | mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); | 311 | mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); |
| 308 | udelay(2000); | 312 | udelay(2000); |
| 309 | mt352_write(fe, mt352_reset, sizeof(mt352_reset)); | 313 | mt352_write(fe, mt352_reset, sizeof(mt352_reset)); |
| @@ -323,28 +327,45 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct | |||
| 323 | unsigned char bs = 0; | 327 | unsigned char bs = 0; |
| 324 | unsigned char cp = 0; | 328 | unsigned char cp = 0; |
| 325 | 329 | ||
| 326 | #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ | ||
| 327 | div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; | 330 | div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; |
| 328 | 331 | ||
| 329 | if (params->frequency < 150000000) cp = 0xB4; | 332 | if (params->frequency < 150000000) |
| 330 | else if (params->frequency < 173000000) cp = 0xBC; | 333 | cp = 0xB4; |
| 331 | else if (params->frequency < 250000000) cp = 0xB4; | 334 | else if (params->frequency < 173000000) |
| 332 | else if (params->frequency < 400000000) cp = 0xBC; | 335 | cp = 0xBC; |
| 333 | else if (params->frequency < 420000000) cp = 0xF4; | 336 | else if (params->frequency < 250000000) |
| 334 | else if (params->frequency < 470000000) cp = 0xFC; | 337 | cp = 0xB4; |
| 335 | else if (params->frequency < 600000000) cp = 0xBC; | 338 | else if (params->frequency < 400000000) |
| 336 | else if (params->frequency < 730000000) cp = 0xF4; | 339 | cp = 0xBC; |
| 337 | else cp = 0xFC; | 340 | else if (params->frequency < 420000000) |
| 338 | 341 | cp = 0xF4; | |
| 339 | if (params->frequency < 150000000) bs = 0x01; | 342 | else if (params->frequency < 470000000) |
| 340 | else if (params->frequency < 173000000) bs = 0x01; | 343 | cp = 0xFC; |
| 341 | else if (params->frequency < 250000000) bs = 0x02; | 344 | else if (params->frequency < 600000000) |
| 342 | else if (params->frequency < 400000000) bs = 0x02; | 345 | cp = 0xBC; |
| 343 | else if (params->frequency < 420000000) bs = 0x02; | 346 | else if (params->frequency < 730000000) |
| 344 | else if (params->frequency < 470000000) bs = 0x02; | 347 | cp = 0xF4; |
| 345 | else if (params->frequency < 600000000) bs = 0x08; | 348 | else |
| 346 | else if (params->frequency < 730000000) bs = 0x08; | 349 | cp = 0xFC; |
| 347 | else bs = 0x08; | 350 | |
| 351 | if (params->frequency < 150000000) | ||
| 352 | bs = 0x01; | ||
| 353 | else if (params->frequency < 173000000) | ||
| 354 | bs = 0x01; | ||
| 355 | else if (params->frequency < 250000000) | ||
| 356 | bs = 0x02; | ||
| 357 | else if (params->frequency < 400000000) | ||
| 358 | bs = 0x02; | ||
| 359 | else if (params->frequency < 420000000) | ||
| 360 | bs = 0x02; | ||
| 361 | else if (params->frequency < 470000000) | ||
| 362 | bs = 0x02; | ||
| 363 | else if (params->frequency < 600000000) | ||
| 364 | bs = 0x08; | ||
| 365 | else if (params->frequency < 730000000) | ||
| 366 | bs = 0x08; | ||
| 367 | else | ||
| 368 | bs = 0x08; | ||
| 348 | 369 | ||
| 349 | pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address | 370 | pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address |
| 350 | pllbuf[1] = div >> 8; | 371 | pllbuf[1] = div >> 8; |
| @@ -356,19 +377,15 @@ static int advbt771_samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct | |||
| 356 | } | 377 | } |
| 357 | 378 | ||
| 358 | static struct mt352_config advbt771_samsung_tdtc9251dh0_config = { | 379 | static struct mt352_config advbt771_samsung_tdtc9251dh0_config = { |
| 359 | |||
| 360 | .demod_address = 0x0f, | 380 | .demod_address = 0x0f, |
| 361 | .demod_init = advbt771_samsung_tdtc9251dh0_demod_init, | 381 | .demod_init = advbt771_samsung_tdtc9251dh0_demod_init, |
| 362 | .pll_set = advbt771_samsung_tdtc9251dh0_pll_set, | 382 | .pll_set = advbt771_samsung_tdtc9251dh0_pll_set, |
| 363 | }; | 383 | }; |
| 364 | 384 | ||
| 365 | |||
| 366 | static struct dst_config dst_config = { | 385 | static struct dst_config dst_config = { |
| 367 | |||
| 368 | .demod_address = 0x55, | 386 | .demod_address = 0x55, |
| 369 | }; | 387 | }; |
| 370 | 388 | ||
| 371 | |||
| 372 | static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) | 389 | static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name) |
| 373 | { | 390 | { |
| 374 | struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv; | 391 | struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv; |
| @@ -398,10 +415,8 @@ static void or51211_reset(struct dvb_frontend * fe) | |||
| 398 | */ | 415 | */ |
| 399 | /* reset & PRM1,2&4 are outputs */ | 416 | /* reset & PRM1,2&4 are outputs */ |
| 400 | int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); | 417 | int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F); |
| 401 | if (ret != 0) { | 418 | if (ret != 0) |
| 402 | printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR " | 419 | printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret); |
| 403 | "(%i)\n", ret); | ||
| 404 | } | ||
| 405 | bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ | 420 | bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */ |
| 406 | msleep(20); | 421 | msleep(20); |
| 407 | /* Now set for normal operation */ | 422 | /* Now set for normal operation */ |
| @@ -417,7 +432,6 @@ static void or51211_sleep(struct dvb_frontend * fe) | |||
| 417 | } | 432 | } |
| 418 | 433 | ||
| 419 | static struct or51211_config or51211_config = { | 434 | static struct or51211_config or51211_config = { |
| 420 | |||
| 421 | .demod_address = 0x15, | 435 | .demod_address = 0x15, |
| 422 | .request_firmware = or51211_request_firmware, | 436 | .request_firmware = or51211_request_firmware, |
| 423 | .setmode = or51211_setmode, | 437 | .setmode = or51211_setmode, |
| @@ -425,7 +439,6 @@ static struct or51211_config or51211_config = { | |||
| 425 | .sleep = or51211_sleep, | 439 | .sleep = or51211_sleep, |
| 426 | }; | 440 | }; |
| 427 | 441 | ||
| 428 | |||
| 429 | static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 442 | static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 430 | { | 443 | { |
| 431 | struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; | 444 | struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; |
| @@ -454,12 +467,84 @@ static int vp3021_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_fronten | |||
| 454 | } | 467 | } |
| 455 | 468 | ||
| 456 | static struct nxt6000_config vp3021_alps_tded4_config = { | 469 | static struct nxt6000_config vp3021_alps_tded4_config = { |
| 457 | |||
| 458 | .demod_address = 0x0a, | 470 | .demod_address = 0x0a, |
| 459 | .clock_inversion = 1, | 471 | .clock_inversion = 1, |
| 460 | .pll_set = vp3021_alps_tded4_pll_set, | 472 | .pll_set = vp3021_alps_tded4_pll_set, |
| 461 | }; | 473 | }; |
| 462 | 474 | ||
| 475 | static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe) | ||
| 476 | { | ||
| 477 | static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d }; | ||
| 478 | static u8 mt352_reset [] = { 0x50, 0x80 }; | ||
| 479 | static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 }; | ||
| 480 | static u8 mt352_agc_cfg [] = { 0x67, 0x20, 0xa0 }; | ||
| 481 | static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 }; | ||
| 482 | |||
| 483 | mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config)); | ||
| 484 | udelay(2000); | ||
| 485 | mt352_write(fe, mt352_reset, sizeof(mt352_reset)); | ||
| 486 | mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg)); | ||
| 487 | mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg)); | ||
| 488 | mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg)); | ||
| 489 | |||
| 490 | return 0; | ||
| 491 | } | ||
| 492 | |||
| 493 | static int digitv_alps_tded4_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) | ||
| 494 | { | ||
| 495 | u32 div; | ||
| 496 | struct dvb_ofdm_parameters *op = ¶ms->u.ofdm; | ||
| 497 | |||
| 498 | div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6; | ||
| 499 | |||
| 500 | pllbuf[0] = 0xc2; | ||
| 501 | pllbuf[1] = (div >> 8) & 0x7F; | ||
| 502 | pllbuf[2] = div & 0xFF; | ||
| 503 | pllbuf[3] = 0x85; | ||
| 504 | |||
| 505 | dprintk("frequency %u, div %u\n", params->frequency, div); | ||
| 506 | |||
| 507 | if (params->frequency < 470000000) | ||
| 508 | pllbuf[4] = 0x02; | ||
| 509 | else if (params->frequency > 823000000) | ||
| 510 | pllbuf[4] = 0x88; | ||
| 511 | else | ||
| 512 | pllbuf[4] = 0x08; | ||
| 513 | |||
| 514 | if (op->bandwidth == 8) | ||
| 515 | pllbuf[4] |= 0x04; | ||
| 516 | |||
| 517 | return 0; | ||
| 518 | } | ||
| 519 | |||
| 520 | static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt) | ||
| 521 | { | ||
| 522 | /* | ||
| 523 | * Reset the frontend, must be called before trying | ||
| 524 | * to initialise the MT352 or mt352_attach | ||
| 525 | * will fail. | ||
| 526 | * | ||
| 527 | * Presumably not required for the NXT6000 frontend. | ||
| 528 | * | ||
| 529 | */ | ||
| 530 | |||
| 531 | int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08); | ||
| 532 | if (ret != 0) | ||
| 533 | printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret); | ||
| 534 | |||
| 535 | /* Pulse the reset line */ | ||
| 536 | bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ | ||
| 537 | bttv_write_gpio(bt->bttv_nr, 0x08, 0x00); /* Low */ | ||
| 538 | msleep(100); | ||
| 539 | |||
| 540 | bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */ | ||
| 541 | } | ||
| 542 | |||
| 543 | static struct mt352_config digitv_alps_tded4_config = { | ||
| 544 | .demod_address = 0x0a, | ||
| 545 | .demod_init = digitv_alps_tded4_demod_init, | ||
| 546 | .pll_set = digitv_alps_tded4_pll_set, | ||
| 547 | }; | ||
| 463 | 548 | ||
| 464 | static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | 549 | static void frontend_init(struct dvb_bt8xx_card *card, u32 type) |
| 465 | { | 550 | { |
| @@ -473,7 +558,6 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
| 473 | if (card->fe != NULL) { | 558 | if (card->fe != NULL) { |
| 474 | card->fe->ops->info.frequency_min = 174000000; | 559 | card->fe->ops->info.frequency_min = 174000000; |
| 475 | card->fe->ops->info.frequency_max = 862000000; | 560 | card->fe->ops->info.frequency_max = 862000000; |
| 476 | break; | ||
| 477 | } | 561 | } |
| 478 | break; | 562 | break; |
| 479 | #endif | 563 | #endif |
| @@ -483,17 +567,28 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
| 483 | #else | 567 | #else |
| 484 | case BTTV_NEBULA_DIGITV: | 568 | case BTTV_NEBULA_DIGITV: |
| 485 | #endif | 569 | #endif |
| 570 | /* | ||
| 571 | * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK); | ||
| 572 | * this would be a cleaner solution than trying each frontend in turn. | ||
| 573 | */ | ||
| 574 | |||
| 575 | /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ | ||
| 486 | card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); | 576 | card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); |
| 487 | if (card->fe != NULL) { | 577 | if (card->fe != NULL) { |
| 578 | dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); | ||
| 488 | break; | 579 | break; |
| 489 | } | 580 | } |
| 581 | |||
| 582 | /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ | ||
| 583 | digitv_alps_tded4_reset(card); | ||
| 584 | card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter); | ||
| 585 | |||
| 586 | if (card->fe != NULL) | ||
| 587 | dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n"); | ||
| 490 | break; | 588 | break; |
| 491 | 589 | ||
| 492 | case BTTV_AVDVBT_761: | 590 | case BTTV_AVDVBT_761: |
| 493 | card->fe = sp887x_attach(µtune_mt7202dtf_config, card->i2c_adapter); | 591 | card->fe = sp887x_attach(µtune_mt7202dtf_config, card->i2c_adapter); |
| 494 | if (card->fe != NULL) { | ||
| 495 | break; | ||
| 496 | } | ||
| 497 | break; | 592 | break; |
| 498 | 593 | ||
| 499 | case BTTV_AVDVBT_771: | 594 | case BTTV_AVDVBT_771: |
| @@ -501,7 +596,6 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
| 501 | if (card->fe != NULL) { | 596 | if (card->fe != NULL) { |
| 502 | card->fe->ops->info.frequency_min = 174000000; | 597 | card->fe->ops->info.frequency_min = 174000000; |
| 503 | card->fe->ops->info.frequency_max = 862000000; | 598 | card->fe->ops->info.frequency_max = 862000000; |
| 504 | break; | ||
| 505 | } | 599 | } |
| 506 | break; | 600 | break; |
| 507 | 601 | ||
| @@ -522,54 +616,41 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
| 522 | 616 | ||
| 523 | /* Attach other DST peripherals if any */ | 617 | /* Attach other DST peripherals if any */ |
| 524 | /* Conditional Access device */ | 618 | /* Conditional Access device */ |
| 525 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) { | 619 | if (state->dst_hw_cap & DST_TYPE_HAS_CA) |
| 526 | ret = dst_ca_attach(state, &card->dvb_adapter); | 620 | ret = dst_ca_attach(state, &card->dvb_adapter); |
| 527 | } | ||
| 528 | if (card->fe != NULL) { | ||
| 529 | break; | ||
| 530 | } | ||
| 531 | break; | 621 | break; |
| 532 | 622 | ||
| 533 | case BTTV_PINNACLESAT: | 623 | case BTTV_PINNACLESAT: |
| 534 | card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); | 624 | card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); |
| 535 | if (card->fe != NULL) { | ||
| 536 | break; | ||
| 537 | } | ||
| 538 | break; | 625 | break; |
| 539 | 626 | ||
| 540 | case BTTV_PC_HDTV: | 627 | case BTTV_PC_HDTV: |
| 541 | card->fe = or51211_attach(&or51211_config, card->i2c_adapter); | 628 | card->fe = or51211_attach(&or51211_config, card->i2c_adapter); |
| 542 | if (card->fe != NULL) { | ||
| 543 | break; | ||
| 544 | } | ||
| 545 | break; | 629 | break; |
| 546 | } | 630 | } |
| 547 | 631 | ||
| 548 | if (card->fe == NULL) { | 632 | if (card->fe == NULL) |
| 549 | printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", | 633 | printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n", |
| 550 | card->bt->dev->vendor, | 634 | card->bt->dev->vendor, |
| 551 | card->bt->dev->device, | 635 | card->bt->dev->device, |
| 552 | card->bt->dev->subsystem_vendor, | 636 | card->bt->dev->subsystem_vendor, |
| 553 | card->bt->dev->subsystem_device); | 637 | card->bt->dev->subsystem_device); |
| 554 | } else { | 638 | else |
| 555 | if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { | 639 | if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { |
| 556 | printk("dvb-bt8xx: Frontend registration failed!\n"); | 640 | printk("dvb-bt8xx: Frontend registration failed!\n"); |
| 557 | if (card->fe->ops->release) | 641 | if (card->fe->ops->release) |
| 558 | card->fe->ops->release(card->fe); | 642 | card->fe->ops->release(card->fe); |
| 559 | card->fe = NULL; | 643 | card->fe = NULL; |
| 560 | } | 644 | } |
| 561 | } | ||
| 562 | } | 645 | } |
| 563 | 646 | ||
| 564 | static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) | 647 | static int __init dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) |
| 565 | { | 648 | { |
| 566 | int result; | 649 | int result; |
| 567 | 650 | ||
| 568 | if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, | 651 | if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE)) < 0) { |
| 569 | THIS_MODULE)) < 0) { | ||
| 570 | printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result); | 652 | printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result); |
| 571 | return result; | 653 | return result; |
| 572 | |||
| 573 | } | 654 | } |
| 574 | card->dvb_adapter.priv = card; | 655 | card->dvb_adapter.priv = card; |
| 575 | 656 | ||
| @@ -664,8 +745,7 @@ static int dvb_bt8xx_probe(struct device *dev) | |||
| 664 | strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); | 745 | strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); |
| 665 | card->i2c_adapter = &sub->core->i2c_adap; | 746 | card->i2c_adapter = &sub->core->i2c_adap; |
| 666 | 747 | ||
| 667 | switch(sub->core->type) | 748 | switch(sub->core->type) { |
| 668 | { | ||
| 669 | case BTTV_PINNACLESAT: | 749 | case BTTV_PINNACLESAT: |
| 670 | card->gpio_mode = 0x0400c060; | 750 | card->gpio_mode = 0x0400c060; |
| 671 | /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR, | 751 | /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR, |
| @@ -751,7 +831,6 @@ static int dvb_bt8xx_probe(struct device *dev) | |||
| 751 | 831 | ||
| 752 | kfree(card); | 832 | kfree(card); |
| 753 | return -EFAULT; | 833 | return -EFAULT; |
| 754 | |||
| 755 | } | 834 | } |
| 756 | 835 | ||
| 757 | init_MUTEX(&card->bt->gpio_lock); | 836 | init_MUTEX(&card->bt->gpio_lock); |
| @@ -779,7 +858,8 @@ static int dvb_bt8xx_remove(struct device *dev) | |||
| 779 | card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); | 858 | card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); |
| 780 | dvb_dmxdev_release(&card->dmxdev); | 859 | dvb_dmxdev_release(&card->dmxdev); |
| 781 | dvb_dmx_release(&card->demux); | 860 | dvb_dmx_release(&card->demux); |
| 782 | if (card->fe) dvb_unregister_frontend(card->fe); | 861 | if (card->fe) |
| 862 | dvb_unregister_frontend(card->fe); | ||
| 783 | dvb_unregister_adapter(&card->dvb_adapter); | 863 | dvb_unregister_adapter(&card->dvb_adapter); |
| 784 | 864 | ||
| 785 | kfree(card); | 865 | kfree(card); |
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h index 2923b3b0dd3c..9ec8e5bd6c1f 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Bt8xx based DVB adapter driver | 2 | * Bt8xx based DVB adapter driver |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2002,2003 Florian Schirmer <jolt@tuxbox.org> | 4 | * Copyright (C) 2002,2003 Florian Schirmer <jolt@tuxbox.org> |
| 5 | * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> | 5 | * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> |
| 6 | * Copyright (C) 1999-2001 Ralph Metzler & Marcus Metzler for convergence integrated media GmbH | 6 | * Copyright (C) 1999-2001 Ralph Metzler & Marcus Metzler for convergence integrated media GmbH |
| 7 | * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de> | 7 | * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de> |
| 8 | * | 8 | * |
diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig index 226714085f58..7cf4c4a888ec 100644 --- a/drivers/media/dvb/cinergyT2/Kconfig +++ b/drivers/media/dvb/cinergyT2/Kconfig | |||
| @@ -77,7 +77,7 @@ config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE | |||
| 77 | config DVB_CINERGYT2_RC_QUERY_INTERVAL | 77 | config DVB_CINERGYT2_RC_QUERY_INTERVAL |
| 78 | int "Infrared Remote Controller update interval [milliseconds]" | 78 | int "Infrared Remote Controller update interval [milliseconds]" |
| 79 | depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE | 79 | depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE |
| 80 | default "100" | 80 | default "50" |
| 81 | help | 81 | help |
| 82 | If you have a very fast-repeating remote control you can try lower | 82 | If you have a very fast-repeating remote control you can try lower |
| 83 | values, for normal consumer receivers the default value should be | 83 | values, for normal consumer receivers the default value should be |
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 9ea5747b1211..6db0929ef53d 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c | |||
| @@ -25,7 +25,6 @@ | |||
| 25 | #include <linux/config.h> | 25 | #include <linux/config.h> |
| 26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
| 27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 28 | #include <linux/version.h> | ||
| 29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 30 | #include <linux/usb.h> | 29 | #include <linux/usb.h> |
| 31 | #include <linux/pci.h> | 30 | #include <linux/pci.h> |
| @@ -36,7 +35,6 @@ | |||
| 36 | #include "dvb_demux.h" | 35 | #include "dvb_demux.h" |
| 37 | #include "dvb_net.h" | 36 | #include "dvb_net.h" |
| 38 | 37 | ||
| 39 | |||
| 40 | #ifdef CONFIG_DVB_CINERGYT2_TUNING | 38 | #ifdef CONFIG_DVB_CINERGYT2_TUNING |
| 41 | #define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT) | 39 | #define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT) |
| 42 | #define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE) | 40 | #define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE) |
| @@ -49,7 +47,7 @@ | |||
| 49 | #define STREAM_URB_COUNT (32) | 47 | #define STREAM_URB_COUNT (32) |
| 50 | #define STREAM_BUF_SIZE (512) /* bytes */ | 48 | #define STREAM_BUF_SIZE (512) /* bytes */ |
| 51 | #define ENABLE_RC (1) | 49 | #define ENABLE_RC (1) |
| 52 | #define RC_QUERY_INTERVAL (100) /* milliseconds */ | 50 | #define RC_QUERY_INTERVAL (50) /* milliseconds */ |
| 53 | #define QUERY_INTERVAL (333) /* milliseconds */ | 51 | #define QUERY_INTERVAL (333) /* milliseconds */ |
| 54 | #endif | 52 | #endif |
| 55 | 53 | ||
| @@ -142,6 +140,8 @@ struct cinergyt2 { | |||
| 142 | struct input_dev rc_input_dev; | 140 | struct input_dev rc_input_dev; |
| 143 | struct work_struct rc_query_work; | 141 | struct work_struct rc_query_work; |
| 144 | int rc_input_event; | 142 | int rc_input_event; |
| 143 | u32 rc_last_code; | ||
| 144 | unsigned long last_event_jiffies; | ||
| 145 | #endif | 145 | #endif |
| 146 | }; | 146 | }; |
| 147 | 147 | ||
| @@ -156,7 +156,7 @@ struct cinergyt2_rc_event { | |||
| 156 | uint32_t value; | 156 | uint32_t value; |
| 157 | } __attribute__((packed)); | 157 | } __attribute__((packed)); |
| 158 | 158 | ||
| 159 | static const uint32_t rc_keys [] = { | 159 | static const uint32_t rc_keys[] = { |
| 160 | CINERGYT2_RC_EVENT_TYPE_NEC, 0xfe01eb04, KEY_POWER, | 160 | CINERGYT2_RC_EVENT_TYPE_NEC, 0xfe01eb04, KEY_POWER, |
| 161 | CINERGYT2_RC_EVENT_TYPE_NEC, 0xfd02eb04, KEY_1, | 161 | CINERGYT2_RC_EVENT_TYPE_NEC, 0xfd02eb04, KEY_1, |
| 162 | CINERGYT2_RC_EVENT_TYPE_NEC, 0xfc03eb04, KEY_2, | 162 | CINERGYT2_RC_EVENT_TYPE_NEC, 0xfc03eb04, KEY_2, |
| @@ -685,52 +685,68 @@ static struct dvb_device cinergyt2_fe_template = { | |||
| 685 | #ifdef ENABLE_RC | 685 | #ifdef ENABLE_RC |
| 686 | static void cinergyt2_query_rc (void *data) | 686 | static void cinergyt2_query_rc (void *data) |
| 687 | { | 687 | { |
| 688 | struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data; | 688 | struct cinergyt2 *cinergyt2 = data; |
| 689 | char buf [1] = { CINERGYT2_EP1_GET_RC_EVENTS }; | 689 | char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS }; |
| 690 | struct cinergyt2_rc_event rc_events[12]; | 690 | struct cinergyt2_rc_event rc_events[12]; |
| 691 | int n, len; | 691 | int n, len, i; |
| 692 | 692 | ||
| 693 | if (down_interruptible(&cinergyt2->sem)) | 693 | if (down_interruptible(&cinergyt2->sem)) |
| 694 | return; | 694 | return; |
| 695 | 695 | ||
| 696 | len = cinergyt2_command(cinergyt2, buf, sizeof(buf), | 696 | len = cinergyt2_command(cinergyt2, buf, sizeof(buf), |
| 697 | (char *) rc_events, sizeof(rc_events)); | 697 | (char *) rc_events, sizeof(rc_events)); |
| 698 | 698 | if (len < 0) | |
| 699 | for (n=0; len>0 && n<(len/sizeof(rc_events[0])); n++) { | 699 | goto out; |
| 700 | int i; | 700 | if (len == 0) { |
| 701 | if (time_after(jiffies, cinergyt2->last_event_jiffies + | ||
| 702 | msecs_to_jiffies(150))) { | ||
| 703 | /* stop key repeat */ | ||
| 704 | if (cinergyt2->rc_input_event != KEY_MAX) { | ||
| 705 | dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event); | ||
| 706 | input_report_key(&cinergyt2->rc_input_dev, | ||
| 707 | cinergyt2->rc_input_event, 0); | ||
| 708 | cinergyt2->rc_input_event = KEY_MAX; | ||
| 709 | } | ||
| 710 | cinergyt2->rc_last_code = ~0; | ||
| 711 | } | ||
| 712 | goto out; | ||
| 713 | } | ||
| 714 | cinergyt2->last_event_jiffies = jiffies; | ||
| 701 | 715 | ||
| 702 | /* dprintk(1,"rc_events[%d].value = %x, type=%x\n",n,le32_to_cpu(rc_events[n].value),rc_events[n].type);*/ | 716 | for (n = 0; n < (len / sizeof(rc_events[0])); n++) { |
| 717 | dprintk(1, "rc_events[%d].value = %x, type=%x\n", | ||
| 718 | n, le32_to_cpu(rc_events[n].value), rc_events[n].type); | ||
| 703 | 719 | ||
| 704 | if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC && | 720 | if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC && |
| 705 | rc_events[n].value == ~0) | 721 | rc_events[n].value == ~0) { |
| 706 | { | 722 | /* keyrepeat bit -> just repeat last rc_input_event */ |
| 707 | /** | ||
| 708 | * keyrepeat bit. If we would handle this properly | ||
| 709 | * we would need to emit down events as long the | ||
| 710 | * keyrepeat goes, a up event if no further | ||
| 711 | * repeat bits occur. Would need a timer to implement | ||
| 712 | * and no other driver does this, so we simply | ||
| 713 | * emit the last key up/down sequence again. | ||
| 714 | */ | ||
| 715 | } else { | 723 | } else { |
| 716 | cinergyt2->rc_input_event = KEY_MAX; | 724 | cinergyt2->rc_input_event = KEY_MAX; |
| 717 | for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i+=3) { | 725 | for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) { |
| 718 | if (rc_keys[i+0] == rc_events[n].type && | 726 | if (rc_keys[i + 0] == rc_events[n].type && |
| 719 | rc_keys[i+1] == le32_to_cpu(rc_events[n].value)) | 727 | rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) { |
| 720 | { | 728 | cinergyt2->rc_input_event = rc_keys[i + 2]; |
| 721 | cinergyt2->rc_input_event = rc_keys[i+2]; | ||
| 722 | break; | 729 | break; |
| 723 | } | 730 | } |
| 724 | } | 731 | } |
| 725 | } | 732 | } |
| 726 | 733 | ||
| 727 | if (cinergyt2->rc_input_event != KEY_MAX) { | 734 | if (cinergyt2->rc_input_event != KEY_MAX) { |
| 728 | input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 1); | 735 | if (rc_events[n].value == cinergyt2->rc_last_code && |
| 729 | input_report_key(&cinergyt2->rc_input_dev, cinergyt2->rc_input_event, 0); | 736 | cinergyt2->rc_last_code != ~0) { |
| 730 | input_sync(&cinergyt2->rc_input_dev); | 737 | /* emit a key-up so the double event is recognized */ |
| 738 | dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event); | ||
| 739 | input_report_key(&cinergyt2->rc_input_dev, | ||
| 740 | cinergyt2->rc_input_event, 0); | ||
| 741 | } | ||
| 742 | dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event); | ||
| 743 | input_report_key(&cinergyt2->rc_input_dev, | ||
| 744 | cinergyt2->rc_input_event, 1); | ||
| 745 | cinergyt2->rc_last_code = rc_events[n].value; | ||
| 731 | } | 746 | } |
| 732 | } | 747 | } |
| 733 | 748 | ||
| 749 | out: | ||
| 734 | schedule_delayed_work(&cinergyt2->rc_query_work, | 750 | schedule_delayed_work(&cinergyt2->rc_query_work, |
| 735 | msecs_to_jiffies(RC_QUERY_INTERVAL)); | 751 | msecs_to_jiffies(RC_QUERY_INTERVAL)); |
| 736 | 752 | ||
| @@ -772,7 +788,10 @@ static int cinergyt2_probe (struct usb_interface *intf, | |||
| 772 | const struct usb_device_id *id) | 788 | const struct usb_device_id *id) |
| 773 | { | 789 | { |
| 774 | struct cinergyt2 *cinergyt2; | 790 | struct cinergyt2 *cinergyt2; |
| 775 | int i, err; | 791 | int err; |
| 792 | #ifdef ENABLE_RC | ||
| 793 | int i; | ||
| 794 | #endif | ||
| 776 | 795 | ||
| 777 | if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { | 796 | if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { |
| 778 | dprintk(1, "out of memory?!?\n"); | 797 | dprintk(1, "out of memory?!?\n"); |
| @@ -828,19 +847,18 @@ static int cinergyt2_probe (struct usb_interface *intf, | |||
| 828 | DVB_DEVICE_FRONTEND); | 847 | DVB_DEVICE_FRONTEND); |
| 829 | 848 | ||
| 830 | #ifdef ENABLE_RC | 849 | #ifdef ENABLE_RC |
| 831 | init_input_dev(&cinergyt2->rc_input_dev); | 850 | cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
| 832 | 851 | cinergyt2->rc_input_dev.keycodesize = 0; | |
| 833 | cinergyt2->rc_input_dev.evbit[0] = BIT(EV_KEY); | 852 | cinergyt2->rc_input_dev.keycodemax = 0; |
| 834 | cinergyt2->rc_input_dev.keycodesize = sizeof(unsigned char); | ||
| 835 | cinergyt2->rc_input_dev.keycodemax = KEY_MAX; | ||
| 836 | cinergyt2->rc_input_dev.name = DRIVER_NAME " remote control"; | 853 | cinergyt2->rc_input_dev.name = DRIVER_NAME " remote control"; |
| 837 | 854 | ||
| 838 | for (i=0; i<sizeof(rc_keys)/sizeof(rc_keys[0]); i+=3) | 855 | for (i = 0; i < sizeof(rc_keys) / sizeof(rc_keys[0]); i += 3) |
| 839 | set_bit(rc_keys[i+2], cinergyt2->rc_input_dev.keybit); | 856 | set_bit(rc_keys[i + 2], cinergyt2->rc_input_dev.keybit); |
| 840 | 857 | ||
| 841 | input_register_device(&cinergyt2->rc_input_dev); | 858 | input_register_device(&cinergyt2->rc_input_dev); |
| 842 | 859 | ||
| 843 | cinergyt2->rc_input_event = KEY_MAX; | 860 | cinergyt2->rc_input_event = KEY_MAX; |
| 861 | cinergyt2->rc_last_code = ~0; | ||
| 844 | 862 | ||
| 845 | INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); | 863 | INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); |
| 846 | schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); | 864 | schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); |
diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index fb55eaa5c8e7..9719a3b30f78 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
| 31 | #include <linux/list.h> | 31 | #include <linux/list.h> |
| 32 | #include <linux/time.h> | 32 | #include <linux/time.h> |
| 33 | #include <linux/dvb/dmx.h> | ||
| 33 | 34 | ||
| 34 | /*--------------------------------------------------------------------------*/ | 35 | /*--------------------------------------------------------------------------*/ |
| 35 | /* Common definitions */ | 36 | /* Common definitions */ |
| @@ -124,9 +125,7 @@ struct dmx_ts_feed { | |||
| 124 | u16 pid, | 125 | u16 pid, |
| 125 | int type, | 126 | int type, |
| 126 | enum dmx_ts_pes pes_type, | 127 | enum dmx_ts_pes pes_type, |
| 127 | size_t callback_length, | ||
| 128 | size_t circular_buffer_size, | 128 | size_t circular_buffer_size, |
| 129 | int descramble, | ||
| 130 | struct timespec timeout); | 129 | struct timespec timeout); |
| 131 | int (*start_filtering) (struct dmx_ts_feed* feed); | 130 | int (*start_filtering) (struct dmx_ts_feed* feed); |
| 132 | int (*stop_filtering) (struct dmx_ts_feed* feed); | 131 | int (*stop_filtering) (struct dmx_ts_feed* feed); |
| @@ -159,7 +158,6 @@ struct dmx_section_feed { | |||
| 159 | int (*set) (struct dmx_section_feed* feed, | 158 | int (*set) (struct dmx_section_feed* feed, |
| 160 | u16 pid, | 159 | u16 pid, |
| 161 | size_t circular_buffer_size, | 160 | size_t circular_buffer_size, |
| 162 | int descramble, | ||
| 163 | int check_crc); | 161 | int check_crc); |
| 164 | int (*allocate_filter) (struct dmx_section_feed* feed, | 162 | int (*allocate_filter) (struct dmx_section_feed* feed, |
| 165 | struct dmx_section_filter** filter); | 163 | struct dmx_section_filter** filter); |
| @@ -207,7 +205,6 @@ struct dmx_frontend { | |||
| 207 | struct list_head connectivity_list; /* List of front-ends that can | 205 | struct list_head connectivity_list; /* List of front-ends that can |
| 208 | be connected to a particular | 206 | be connected to a particular |
| 209 | demux */ | 207 | demux */ |
| 210 | void* priv; /* Pointer to private data of the API client */ | ||
| 211 | enum dmx_frontend_source source; | 208 | enum dmx_frontend_source source; |
| 212 | }; | 209 | }; |
| 213 | 210 | ||
| @@ -225,8 +222,6 @@ struct dmx_frontend { | |||
| 225 | #define DMX_MEMORY_BASED_FILTERING 8 /* write() available */ | 222 | #define DMX_MEMORY_BASED_FILTERING 8 /* write() available */ |
| 226 | #define DMX_CRC_CHECKING 16 | 223 | #define DMX_CRC_CHECKING 16 |
| 227 | #define DMX_TS_DESCRAMBLING 32 | 224 | #define DMX_TS_DESCRAMBLING 32 |
| 228 | #define DMX_SECTION_PAYLOAD_DESCRAMBLING 64 | ||
| 229 | #define DMX_MAC_ADDRESS_DESCRAMBLING 128 | ||
| 230 | 225 | ||
| 231 | /* | 226 | /* |
| 232 | * Demux resource type identifier. | 227 | * Demux resource type identifier. |
| @@ -244,9 +239,7 @@ struct dmx_frontend { | |||
| 244 | struct dmx_demux { | 239 | struct dmx_demux { |
| 245 | u32 capabilities; /* Bitfield of capability flags */ | 240 | u32 capabilities; /* Bitfield of capability flags */ |
| 246 | struct dmx_frontend* frontend; /* Front-end connected to the demux */ | 241 | struct dmx_frontend* frontend; /* Front-end connected to the demux */ |
| 247 | struct list_head reg_list; /* List of registered demuxes */ | ||
| 248 | void* priv; /* Pointer to private data of the API client */ | 242 | void* priv; /* Pointer to private data of the API client */ |
| 249 | int users; /* Number of users */ | ||
| 250 | int (*open) (struct dmx_demux* demux); | 243 | int (*open) (struct dmx_demux* demux); |
| 251 | int (*close) (struct dmx_demux* demux); | 244 | int (*close) (struct dmx_demux* demux); |
| 252 | int (*write) (struct dmx_demux* demux, const char* buf, size_t count); | 245 | int (*write) (struct dmx_demux* demux, const char* buf, size_t count); |
| @@ -260,17 +253,6 @@ struct dmx_demux { | |||
| 260 | dmx_section_cb callback); | 253 | dmx_section_cb callback); |
| 261 | int (*release_section_feed) (struct dmx_demux* demux, | 254 | int (*release_section_feed) (struct dmx_demux* demux, |
| 262 | struct dmx_section_feed* feed); | 255 | struct dmx_section_feed* feed); |
| 263 | int (*descramble_mac_address) (struct dmx_demux* demux, | ||
| 264 | u8* buffer1, | ||
| 265 | size_t buffer1_length, | ||
| 266 | u8* buffer2, | ||
| 267 | size_t buffer2_length, | ||
| 268 | u16 pid); | ||
| 269 | int (*descramble_section_payload) (struct dmx_demux* demux, | ||
| 270 | u8* buffer1, | ||
| 271 | size_t buffer1_length, | ||
| 272 | u8* buffer2, size_t buffer2_length, | ||
| 273 | u16 pid); | ||
| 274 | int (*add_frontend) (struct dmx_demux* demux, | 256 | int (*add_frontend) (struct dmx_demux* demux, |
| 275 | struct dmx_frontend* frontend); | 257 | struct dmx_frontend* frontend); |
| 276 | int (*remove_frontend) (struct dmx_demux* demux, | 258 | int (*remove_frontend) (struct dmx_demux* demux, |
| @@ -282,20 +264,12 @@ struct dmx_demux { | |||
| 282 | 264 | ||
| 283 | int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); | 265 | int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); |
| 284 | 266 | ||
| 267 | int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps); | ||
| 268 | |||
| 269 | int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src); | ||
| 270 | |||
| 285 | int (*get_stc) (struct dmx_demux* demux, unsigned int num, | 271 | int (*get_stc) (struct dmx_demux* demux, unsigned int num, |
| 286 | u64 *stc, unsigned int *base); | 272 | u64 *stc, unsigned int *base); |
| 287 | }; | 273 | }; |
| 288 | 274 | ||
| 289 | /*--------------------------------------------------------------------------*/ | ||
| 290 | /* Demux directory */ | ||
| 291 | /*--------------------------------------------------------------------------*/ | ||
| 292 | |||
| 293 | /* | ||
| 294 | * DMX_DIR_ENTRY(): Casts elements in the list of registered | ||
| 295 | * demuxes from the generic type struct list_head* to the type struct dmx_demux | ||
| 296 | *. | ||
| 297 | */ | ||
| 298 | |||
| 299 | #define DMX_DIR_ENTRY(list) list_entry(list, struct dmx_demux, reg_list) | ||
| 300 | |||
| 301 | #endif /* #ifndef __DEMUX_H */ | 275 | #endif /* #ifndef __DEMUX_H */ |
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 68050cd527cb..8028c3a5e287 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c | |||
| @@ -571,7 +571,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) | |||
| 571 | return ret; | 571 | return ret; |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | ret=(*secfeed)->set(*secfeed, para->pid, 32768, 0, | 574 | ret=(*secfeed)->set(*secfeed, para->pid, 32768, |
| 575 | (para->flags & DMX_CHECK_CRC) ? 1 : 0); | 575 | (para->flags & DMX_CHECK_CRC) ? 1 : 0); |
| 576 | 576 | ||
| 577 | if (ret<0) { | 577 | if (ret<0) { |
| @@ -654,7 +654,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) | |||
| 654 | (*tsfeed)->priv = (void *) filter; | 654 | (*tsfeed)->priv = (void *) filter; |
| 655 | 655 | ||
| 656 | ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes, | 656 | ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes, |
| 657 | 188, 32768, 0, timeout); | 657 | 32768, timeout); |
| 658 | 658 | ||
| 659 | if (ret < 0) { | 659 | if (ret < 0) { |
| 660 | dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed); | 660 | dmxdev->demux->release_ts_feed(dmxdev->demux, *tsfeed); |
| @@ -929,6 +929,22 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, | |||
| 929 | dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg); | 929 | dmxdev->demux->get_pes_pids(dmxdev->demux, (u16 *)parg); |
| 930 | break; | 930 | break; |
| 931 | 931 | ||
| 932 | case DMX_GET_CAPS: | ||
| 933 | if (!dmxdev->demux->get_caps) { | ||
| 934 | ret = -EINVAL; | ||
| 935 | break; | ||
| 936 | } | ||
| 937 | ret = dmxdev->demux->get_caps(dmxdev->demux, parg); | ||
| 938 | break; | ||
| 939 | |||
| 940 | case DMX_SET_SOURCE: | ||
| 941 | if (!dmxdev->demux->set_source) { | ||
| 942 | ret = -EINVAL; | ||
| 943 | break; | ||
| 944 | } | ||
| 945 | ret = dmxdev->demux->set_source(dmxdev->demux, parg); | ||
| 946 | break; | ||
| 947 | |||
| 932 | case DMX_GET_STC: | 948 | case DMX_GET_STC: |
| 933 | if (!dmxdev->demux->get_stc) { | 949 | if (!dmxdev->demux->get_stc) { |
| 934 | ret=-EINVAL; | 950 | ret=-EINVAL; |
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 0eb9aa711fb0..88757e2634e5 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c | |||
| @@ -47,7 +47,7 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages"); | |||
| 47 | 47 | ||
| 48 | #define dprintk if (dvb_ca_en50221_debug) printk | 48 | #define dprintk if (dvb_ca_en50221_debug) printk |
| 49 | 49 | ||
| 50 | #define INIT_TIMEOUT_SECS 5 | 50 | #define INIT_TIMEOUT_SECS 10 |
| 51 | 51 | ||
| 52 | #define HOST_LINK_BUF_SIZE 0x200 | 52 | #define HOST_LINK_BUF_SIZE 0x200 |
| 53 | 53 | ||
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index ac9889d22288..dc476dda2b71 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c | |||
| @@ -38,82 +38,52 @@ | |||
| 38 | */ | 38 | */ |
| 39 | // #define DVB_DEMUX_SECTION_LOSS_LOG | 39 | // #define DVB_DEMUX_SECTION_LOSS_LOG |
| 40 | 40 | ||
| 41 | |||
| 42 | static LIST_HEAD(dmx_muxs); | ||
| 43 | |||
| 44 | |||
| 45 | static int dmx_register_demux(struct dmx_demux *demux) | ||
| 46 | { | ||
| 47 | demux->users = 0; | ||
| 48 | list_add(&demux->reg_list, &dmx_muxs); | ||
| 49 | return 0; | ||
| 50 | } | ||
| 51 | |||
| 52 | static int dmx_unregister_demux(struct dmx_demux* demux) | ||
| 53 | { | ||
| 54 | struct list_head *pos, *n, *head=&dmx_muxs; | ||
| 55 | |||
| 56 | list_for_each_safe (pos, n, head) { | ||
| 57 | if (DMX_DIR_ENTRY(pos) == demux) { | ||
| 58 | if (demux->users>0) | ||
| 59 | return -EINVAL; | ||
| 60 | list_del(pos); | ||
| 61 | return 0; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | return -ENODEV; | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | /****************************************************************************** | 41 | /****************************************************************************** |
| 70 | * static inlined helper functions | 42 | * static inlined helper functions |
| 71 | ******************************************************************************/ | 43 | ******************************************************************************/ |
| 72 | 44 | ||
| 73 | |||
| 74 | static inline u16 section_length(const u8 *buf) | 45 | static inline u16 section_length(const u8 *buf) |
| 75 | { | 46 | { |
| 76 | return 3+((buf[1]&0x0f)<<8)+buf[2]; | 47 | return 3 + ((buf[1] & 0x0f) << 8) + buf[2]; |
| 77 | } | 48 | } |
| 78 | 49 | ||
| 79 | |||
| 80 | static inline u16 ts_pid(const u8 *buf) | 50 | static inline u16 ts_pid(const u8 *buf) |
| 81 | { | 51 | { |
| 82 | return ((buf[1]&0x1f)<<8)+buf[2]; | 52 | return ((buf[1] & 0x1f) << 8) + buf[2]; |
| 83 | } | 53 | } |
| 84 | 54 | ||
| 85 | |||
| 86 | static inline u8 payload(const u8 *tsp) | 55 | static inline u8 payload(const u8 *tsp) |
| 87 | { | 56 | { |
| 88 | if (!(tsp[3] & 0x10)) // no payload? | 57 | if (!(tsp[3] & 0x10)) // no payload? |
| 89 | return 0; | 58 | return 0; |
| 90 | if (tsp[3] & 0x20) { // adaptation field? | 59 | |
| 91 | if (tsp[4] > 183) // corrupted data? | 60 | if (tsp[3] & 0x20) { // adaptation field? |
| 61 | if (tsp[4] > 183) // corrupted data? | ||
| 92 | return 0; | 62 | return 0; |
| 93 | else | 63 | else |
| 94 | return 184-1-tsp[4]; | 64 | return 184 - 1 - tsp[4]; |
| 95 | } | 65 | } |
| 66 | |||
| 96 | return 184; | 67 | return 184; |
| 97 | } | 68 | } |
| 98 | 69 | ||
| 99 | 70 | static u32 dvb_dmx_crc32(struct dvb_demux_feed *f, const u8 *src, size_t len) | |
| 100 | static u32 dvb_dmx_crc32 (struct dvb_demux_feed *f, const u8 *src, size_t len) | ||
| 101 | { | 71 | { |
| 102 | return (f->feed.sec.crc_val = crc32_be (f->feed.sec.crc_val, src, len)); | 72 | return (f->feed.sec.crc_val = crc32_be(f->feed.sec.crc_val, src, len)); |
| 103 | } | 73 | } |
| 104 | 74 | ||
| 105 | 75 | static void dvb_dmx_memcopy(struct dvb_demux_feed *f, u8 *d, const u8 *s, | |
| 106 | static void dvb_dmx_memcopy (struct dvb_demux_feed *f, u8 *d, const u8 *s, size_t len) | 76 | size_t len) |
| 107 | { | 77 | { |
| 108 | memcpy (d, s, len); | 78 | memcpy(d, s, len); |
| 109 | } | 79 | } |
| 110 | 80 | ||
| 111 | |||
| 112 | /****************************************************************************** | 81 | /****************************************************************************** |
| 113 | * Software filter functions | 82 | * Software filter functions |
| 114 | ******************************************************************************/ | 83 | ******************************************************************************/ |
| 115 | 84 | ||
| 116 | static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u8 *buf) | 85 | static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed, |
| 86 | const u8 *buf) | ||
| 117 | { | 87 | { |
| 118 | int count = payload(buf); | 88 | int count = payload(buf); |
| 119 | int p; | 89 | int p; |
| @@ -123,32 +93,31 @@ static inline int dvb_dmx_swfilter_payload (struct dvb_demux_feed *feed, const u | |||
| 123 | if (count == 0) | 93 | if (count == 0) |
| 124 | return -1; | 94 | return -1; |
| 125 | 95 | ||
| 126 | p = 188-count; | 96 | p = 188 - count; |
| 127 | 97 | ||
| 128 | /* | 98 | /* |
| 129 | cc=buf[3]&0x0f; | 99 | cc = buf[3] & 0x0f; |
| 130 | ccok=((dvbdmxfeed->cc+1)&0x0f)==cc ? 1 : 0; | 100 | ccok = ((feed->cc + 1) & 0x0f) == cc; |
| 131 | dvbdmxfeed->cc=cc; | 101 | feed->cc = cc; |
| 132 | if (!ccok) | 102 | if (!ccok) |
| 133 | printk("missed packet!\n"); | 103 | printk("missed packet!\n"); |
| 134 | */ | 104 | */ |
| 135 | 105 | ||
| 136 | if (buf[1] & 0x40) // PUSI ? | 106 | if (buf[1] & 0x40) // PUSI ? |
| 137 | feed->peslen = 0xfffa; | 107 | feed->peslen = 0xfffa; |
| 138 | 108 | ||
| 139 | feed->peslen += count; | 109 | feed->peslen += count; |
| 140 | 110 | ||
| 141 | return feed->cb.ts (&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); | 111 | return feed->cb.ts(&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK); |
| 142 | } | 112 | } |
| 143 | 113 | ||
| 144 | 114 | static int dvb_dmx_swfilter_sectionfilter(struct dvb_demux_feed *feed, | |
| 145 | static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, | 115 | struct dvb_demux_filter *f) |
| 146 | struct dvb_demux_filter *f) | ||
| 147 | { | 116 | { |
| 148 | u8 neq = 0; | 117 | u8 neq = 0; |
| 149 | int i; | 118 | int i; |
| 150 | 119 | ||
| 151 | for (i=0; i<DVB_DEMUX_MASK_MAX; i++) { | 120 | for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) { |
| 152 | u8 xor = f->filter.filter_value[i] ^ feed->feed.sec.secbuf[i]; | 121 | u8 xor = f->filter.filter_value[i] ^ feed->feed.sec.secbuf[i]; |
| 153 | 122 | ||
| 154 | if (f->maskandmode[i] & xor) | 123 | if (f->maskandmode[i] & xor) |
| @@ -160,12 +129,11 @@ static int dvb_dmx_swfilter_sectionfilter (struct dvb_demux_feed *feed, | |||
| 160 | if (f->doneq && !neq) | 129 | if (f->doneq && !neq) |
| 161 | return 0; | 130 | return 0; |
| 162 | 131 | ||
| 163 | return feed->cb.sec (feed->feed.sec.secbuf, feed->feed.sec.seclen, | 132 | return feed->cb.sec(feed->feed.sec.secbuf, feed->feed.sec.seclen, |
| 164 | NULL, 0, &f->filter, DMX_OK); | 133 | NULL, 0, &f->filter, DMX_OK); |
| 165 | } | 134 | } |
| 166 | 135 | ||
| 167 | 136 | static inline int dvb_dmx_swfilter_section_feed(struct dvb_demux_feed *feed) | |
| 168 | static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) | ||
| 169 | { | 137 | { |
| 170 | struct dvb_demux *demux = feed->demux; | 138 | struct dvb_demux *demux = feed->demux; |
| 171 | struct dvb_demux_filter *f = feed->filter; | 139 | struct dvb_demux_filter *f = feed->filter; |
| @@ -195,26 +163,24 @@ static inline int dvb_dmx_swfilter_section_feed (struct dvb_demux_feed *feed) | |||
| 195 | return 0; | 163 | return 0; |
| 196 | } | 164 | } |
| 197 | 165 | ||
| 198 | |||
| 199 | static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) | 166 | static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) |
| 200 | { | 167 | { |
| 201 | struct dmx_section_feed *sec = &feed->feed.sec; | 168 | struct dmx_section_feed *sec = &feed->feed.sec; |
| 202 | 169 | ||
| 203 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG | 170 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG |
| 204 | if(sec->secbufp < sec->tsfeedp) | 171 | if (sec->secbufp < sec->tsfeedp) { |
| 205 | { | ||
| 206 | int i, n = sec->tsfeedp - sec->secbufp; | 172 | int i, n = sec->tsfeedp - sec->secbufp; |
| 207 | 173 | ||
| 208 | /* section padding is done with 0xff bytes entirely. | 174 | /* |
| 209 | ** due to speed reasons, we won't check all of them | 175 | * Section padding is done with 0xff bytes entirely. |
| 210 | ** but just first and last | 176 | * Due to speed reasons, we won't check all of them |
| 211 | */ | 177 | * but just first and last. |
| 212 | if(sec->secbuf[0] != 0xff || sec->secbuf[n-1] != 0xff) | 178 | */ |
| 213 | { | 179 | if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) { |
| 214 | printk("dvb_demux.c section ts padding loss: %d/%d\n", | 180 | printk("dvb_demux.c section ts padding loss: %d/%d\n", |
| 215 | n, sec->tsfeedp); | 181 | n, sec->tsfeedp); |
| 216 | printk("dvb_demux.c pad data:"); | 182 | printk("dvb_demux.c pad data:"); |
| 217 | for(i = 0; i < n; i++) | 183 | for (i = 0; i < n; i++) |
| 218 | printk(" %02x", sec->secbuf[i]); | 184 | printk(" %02x", sec->secbuf[i]); |
| 219 | printk("\n"); | 185 | printk("\n"); |
| 220 | } | 186 | } |
| @@ -226,82 +192,81 @@ static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed) | |||
| 226 | } | 192 | } |
| 227 | 193 | ||
| 228 | /* | 194 | /* |
| 229 | ** Losless Section Demux 1.4.1 by Emard | 195 | * Losless Section Demux 1.4.1 by Emard |
| 230 | ** Valsecchi Patrick: | 196 | * Valsecchi Patrick: |
| 231 | ** - middle of section A (no PUSI) | 197 | * - middle of section A (no PUSI) |
| 232 | ** - end of section A and start of section B | 198 | * - end of section A and start of section B |
| 233 | ** (with PUSI pointing to the start of the second section) | 199 | * (with PUSI pointing to the start of the second section) |
| 234 | ** | 200 | * |
| 235 | ** In this case, without feed->pusi_seen you'll receive a garbage section | 201 | * In this case, without feed->pusi_seen you'll receive a garbage section |
| 236 | ** consisting of the end of section A. Basically because tsfeedp | 202 | * consisting of the end of section A. Basically because tsfeedp |
| 237 | ** is incemented and the use=0 condition is not raised | 203 | * is incemented and the use=0 condition is not raised |
| 238 | ** when the second packet arrives. | 204 | * when the second packet arrives. |
| 239 | ** | 205 | * |
| 240 | ** Fix: | 206 | * Fix: |
| 241 | ** when demux is started, let feed->pusi_seen = 0 to | 207 | * when demux is started, let feed->pusi_seen = 0 to |
| 242 | ** prevent initial feeding of garbage from the end of | 208 | * prevent initial feeding of garbage from the end of |
| 243 | ** previous section. When you for the first time see PUSI=1 | 209 | * previous section. When you for the first time see PUSI=1 |
| 244 | ** then set feed->pusi_seen = 1 | 210 | * then set feed->pusi_seen = 1 |
| 245 | */ | 211 | */ |
| 246 | static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len) | 212 | static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, |
| 213 | const u8 *buf, u8 len) | ||
| 247 | { | 214 | { |
| 248 | struct dvb_demux *demux = feed->demux; | 215 | struct dvb_demux *demux = feed->demux; |
| 249 | struct dmx_section_feed *sec = &feed->feed.sec; | 216 | struct dmx_section_feed *sec = &feed->feed.sec; |
| 250 | u16 limit, seclen, n; | 217 | u16 limit, seclen, n; |
| 251 | 218 | ||
| 252 | if(sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) | 219 | if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE) |
| 253 | return 0; | 220 | return 0; |
| 254 | 221 | ||
| 255 | if(sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) | 222 | if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) { |
| 256 | { | ||
| 257 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG | 223 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG |
| 258 | printk("dvb_demux.c section buffer full loss: %d/%d\n", | 224 | printk("dvb_demux.c section buffer full loss: %d/%d\n", |
| 259 | sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, DMX_MAX_SECFEED_SIZE); | 225 | sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE, |
| 226 | DMX_MAX_SECFEED_SIZE); | ||
| 260 | #endif | 227 | #endif |
| 261 | len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp; | 228 | len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp; |
| 262 | } | 229 | } |
| 263 | 230 | ||
| 264 | if(len <= 0) | 231 | if (len <= 0) |
| 265 | return 0; | 232 | return 0; |
| 266 | 233 | ||
| 267 | demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len); | 234 | demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len); |
| 268 | sec->tsfeedp += len; | 235 | sec->tsfeedp += len; |
| 269 | 236 | ||
| 270 | /* ----------------------------------------------------- | 237 | /* |
| 271 | ** Dump all the sections we can find in the data (Emard) | 238 | * Dump all the sections we can find in the data (Emard) |
| 272 | */ | 239 | */ |
| 273 | |||
| 274 | limit = sec->tsfeedp; | 240 | limit = sec->tsfeedp; |
| 275 | if(limit > DMX_MAX_SECFEED_SIZE) | 241 | if (limit > DMX_MAX_SECFEED_SIZE) |
| 276 | return -1; /* internal error should never happen */ | 242 | return -1; /* internal error should never happen */ |
| 277 | 243 | ||
| 278 | /* to be sure always set secbuf */ | 244 | /* to be sure always set secbuf */ |
| 279 | sec->secbuf = sec->secbuf_base + sec->secbufp; | 245 | sec->secbuf = sec->secbuf_base + sec->secbufp; |
| 280 | 246 | ||
| 281 | for(n = 0; sec->secbufp + 2 < limit; n++) | 247 | for (n = 0; sec->secbufp + 2 < limit; n++) { |
| 282 | { | ||
| 283 | seclen = section_length(sec->secbuf); | 248 | seclen = section_length(sec->secbuf); |
| 284 | if(seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE | 249 | if (seclen <= 0 || seclen > DMX_MAX_SECFEED_SIZE |
| 285 | || seclen + sec->secbufp > limit) | 250 | || seclen + sec->secbufp > limit) |
| 286 | return 0; | 251 | return 0; |
| 287 | sec->seclen = seclen; | 252 | sec->seclen = seclen; |
| 288 | sec->crc_val = ~0; | 253 | sec->crc_val = ~0; |
| 289 | /* dump [secbuf .. secbuf+seclen) */ | 254 | /* dump [secbuf .. secbuf+seclen) */ |
| 290 | if(feed->pusi_seen) | 255 | if (feed->pusi_seen) |
| 291 | dvb_dmx_swfilter_section_feed(feed); | 256 | dvb_dmx_swfilter_section_feed(feed); |
| 292 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG | 257 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG |
| 293 | else | 258 | else |
| 294 | printk("dvb_demux.c pusi not seen, discarding section data\n"); | 259 | printk("dvb_demux.c pusi not seen, discarding section data\n"); |
| 295 | #endif | 260 | #endif |
| 296 | sec->secbufp += seclen; /* secbufp and secbuf moving together is */ | 261 | sec->secbufp += seclen; /* secbufp and secbuf moving together is */ |
| 297 | sec->secbuf += seclen; /* redundand but saves pointer arithmetic */ | 262 | sec->secbuf += seclen; /* redundant but saves pointer arithmetic */ |
| 298 | } | 263 | } |
| 299 | 264 | ||
| 300 | return 0; | 265 | return 0; |
| 301 | } | 266 | } |
| 302 | 267 | ||
| 303 | 268 | static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, | |
| 304 | static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 *buf) | 269 | const u8 *buf) |
| 305 | { | 270 | { |
| 306 | u8 p, count; | 271 | u8 p, count; |
| 307 | int ccok, dc_i = 0; | 272 | int ccok, dc_i = 0; |
| @@ -309,10 +274,10 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 | |||
| 309 | 274 | ||
| 310 | count = payload(buf); | 275 | count = payload(buf); |
| 311 | 276 | ||
| 312 | if (count == 0) /* count == 0 if no payload or out of range */ | 277 | if (count == 0) /* count == 0 if no payload or out of range */ |
| 313 | return -1; | 278 | return -1; |
| 314 | 279 | ||
| 315 | p = 188 - count; /* payload start */ | 280 | p = 188 - count; /* payload start */ |
| 316 | 281 | ||
| 317 | cc = buf[3] & 0x0f; | 282 | cc = buf[3] & 0x0f; |
| 318 | ccok = ((feed->cc + 1) & 0x0f) == cc; | 283 | ccok = ((feed->cc + 1) & 0x0f) == cc; |
| @@ -326,52 +291,53 @@ static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed, const u8 | |||
| 326 | 291 | ||
| 327 | if (!ccok || dc_i) { | 292 | if (!ccok || dc_i) { |
| 328 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG | 293 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG |
| 329 | printk("dvb_demux.c discontinuity detected %d bytes lost\n", count); | 294 | printk("dvb_demux.c discontinuity detected %d bytes lost\n", |
| 330 | /* those bytes under sume circumstances will again be reported | 295 | count); |
| 331 | ** in the following dvb_dmx_swfilter_section_new | 296 | /* |
| 332 | */ | 297 | * those bytes under sume circumstances will again be reported |
| 298 | * in the following dvb_dmx_swfilter_section_new | ||
| 299 | */ | ||
| 333 | #endif | 300 | #endif |
| 334 | /* Discontinuity detected. Reset pusi_seen = 0 to | 301 | /* |
| 335 | ** stop feeding of suspicious data until next PUSI=1 arrives | 302 | * Discontinuity detected. Reset pusi_seen = 0 to |
| 336 | */ | 303 | * stop feeding of suspicious data until next PUSI=1 arrives |
| 304 | */ | ||
| 337 | feed->pusi_seen = 0; | 305 | feed->pusi_seen = 0; |
| 338 | dvb_dmx_swfilter_section_new(feed); | 306 | dvb_dmx_swfilter_section_new(feed); |
| 339 | return 0; | ||
| 340 | } | 307 | } |
| 341 | 308 | ||
| 342 | if (buf[1] & 0x40) { | 309 | if (buf[1] & 0x40) { |
| 343 | // PUSI=1 (is set), section boundary is here | 310 | /* PUSI=1 (is set), section boundary is here */ |
| 344 | if (count > 1 && buf[p] < count) { | 311 | if (count > 1 && buf[p] < count) { |
| 345 | const u8 *before = buf+p+1; | 312 | const u8 *before = &buf[p + 1]; |
| 346 | u8 before_len = buf[p]; | 313 | u8 before_len = buf[p]; |
| 347 | const u8 *after = before+before_len; | 314 | const u8 *after = &before[before_len]; |
| 348 | u8 after_len = count-1-before_len; | 315 | u8 after_len = count - 1 - before_len; |
| 349 | 316 | ||
| 350 | dvb_dmx_swfilter_section_copy_dump(feed, before, before_len); | 317 | dvb_dmx_swfilter_section_copy_dump(feed, before, |
| 318 | before_len); | ||
| 351 | /* before start of new section, set pusi_seen = 1 */ | 319 | /* before start of new section, set pusi_seen = 1 */ |
| 352 | feed->pusi_seen = 1; | 320 | feed->pusi_seen = 1; |
| 353 | dvb_dmx_swfilter_section_new(feed); | 321 | dvb_dmx_swfilter_section_new(feed); |
| 354 | dvb_dmx_swfilter_section_copy_dump(feed, after, after_len); | 322 | dvb_dmx_swfilter_section_copy_dump(feed, after, |
| 323 | after_len); | ||
| 355 | } | 324 | } |
| 356 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG | 325 | #ifdef DVB_DEMUX_SECTION_LOSS_LOG |
| 357 | else | 326 | else if (count > 0) |
| 358 | if (count > 0) | 327 | printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); |
| 359 | printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count); | ||
| 360 | #endif | 328 | #endif |
| 361 | } else { | 329 | } else { |
| 362 | // PUSI=0 (is not set), no section boundary | 330 | /* PUSI=0 (is not set), no section boundary */ |
| 363 | const u8 *entire = buf+p; | 331 | dvb_dmx_swfilter_section_copy_dump(feed, &buf[p], count); |
| 364 | u8 entire_len = count; | ||
| 365 | |||
| 366 | dvb_dmx_swfilter_section_copy_dump(feed, entire, entire_len); | ||
| 367 | } | 332 | } |
| 333 | |||
| 368 | return 0; | 334 | return 0; |
| 369 | } | 335 | } |
| 370 | 336 | ||
| 371 | 337 | static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, | |
| 372 | static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, const u8 *buf) | 338 | const u8 *buf) |
| 373 | { | 339 | { |
| 374 | switch(feed->type) { | 340 | switch (feed->type) { |
| 375 | case DMX_TYPE_TS: | 341 | case DMX_TYPE_TS: |
| 376 | if (!feed->feed.ts.is_filtering) | 342 | if (!feed->feed.ts.is_filtering) |
| 377 | break; | 343 | break; |
| @@ -379,7 +345,8 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con | |||
| 379 | if (feed->ts_type & TS_PAYLOAD_ONLY) | 345 | if (feed->ts_type & TS_PAYLOAD_ONLY) |
| 380 | dvb_dmx_swfilter_payload(feed, buf); | 346 | dvb_dmx_swfilter_payload(feed, buf); |
| 381 | else | 347 | else |
| 382 | feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK); | 348 | feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, |
| 349 | DMX_OK); | ||
| 383 | } | 350 | } |
| 384 | if (feed->ts_type & TS_DECODER) | 351 | if (feed->ts_type & TS_DECODER) |
| 385 | if (feed->demux->write_to_decoder) | 352 | if (feed->demux->write_to_decoder) |
| @@ -390,7 +357,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con | |||
| 390 | if (!feed->feed.sec.is_filtering) | 357 | if (!feed->feed.sec.is_filtering) |
| 391 | break; | 358 | break; |
| 392 | if (dvb_dmx_swfilter_section_packet(feed, buf) < 0) | 359 | if (dvb_dmx_swfilter_section_packet(feed, buf) < 0) |
| 393 | feed->feed.sec.seclen = feed->feed.sec.secbufp=0; | 360 | feed->feed.sec.seclen = feed->feed.sec.secbufp = 0; |
| 394 | break; | 361 | break; |
| 395 | 362 | ||
| 396 | default: | 363 | default: |
| @@ -406,7 +373,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, con | |||
| 406 | static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) | 373 | static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) |
| 407 | { | 374 | { |
| 408 | struct dvb_demux_feed *feed; | 375 | struct dvb_demux_feed *feed; |
| 409 | struct list_head *pos, *head=&demux->feed_list; | 376 | struct list_head *pos, *head = &demux->feed_list; |
| 410 | u16 pid = ts_pid(buf); | 377 | u16 pid = ts_pid(buf); |
| 411 | int dvr_done = 0; | 378 | int dvr_done = 0; |
| 412 | 379 | ||
| @@ -432,21 +399,21 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) | |||
| 432 | } | 399 | } |
| 433 | } | 400 | } |
| 434 | 401 | ||
| 435 | void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, size_t count) | 402 | void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, |
| 403 | size_t count) | ||
| 436 | { | 404 | { |
| 437 | spin_lock(&demux->lock); | 405 | spin_lock(&demux->lock); |
| 438 | 406 | ||
| 439 | while (count--) { | 407 | while (count--) { |
| 440 | if(buf[0] == 0x47) { | 408 | if (buf[0] == 0x47) |
| 441 | dvb_dmx_swfilter_packet(demux, buf); | 409 | dvb_dmx_swfilter_packet(demux, buf); |
| 442 | } | ||
| 443 | buf += 188; | 410 | buf += 188; |
| 444 | } | 411 | } |
| 445 | 412 | ||
| 446 | spin_unlock(&demux->lock); | 413 | spin_unlock(&demux->lock); |
| 447 | } | 414 | } |
| 448 | EXPORT_SYMBOL(dvb_dmx_swfilter_packets); | ||
| 449 | 415 | ||
| 416 | EXPORT_SYMBOL(dvb_dmx_swfilter_packets); | ||
| 450 | 417 | ||
| 451 | void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) | 418 | void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) |
| 452 | { | 419 | { |
| @@ -454,8 +421,10 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) | |||
| 454 | 421 | ||
| 455 | spin_lock(&demux->lock); | 422 | spin_lock(&demux->lock); |
| 456 | 423 | ||
| 457 | if ((i = demux->tsbufp)) { | 424 | if (demux->tsbufp) { |
| 458 | if (count < (j=188-i)) { | 425 | i = demux->tsbufp; |
| 426 | j = 188 - i; | ||
| 427 | if (count < j) { | ||
| 459 | memcpy(&demux->tsbuf[i], buf, count); | 428 | memcpy(&demux->tsbuf[i], buf, count); |
| 460 | demux->tsbufp += count; | 429 | demux->tsbufp += count; |
| 461 | goto bailout; | 430 | goto bailout; |
| @@ -469,13 +438,13 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) | |||
| 469 | 438 | ||
| 470 | while (p < count) { | 439 | while (p < count) { |
| 471 | if (buf[p] == 0x47) { | 440 | if (buf[p] == 0x47) { |
| 472 | if (count-p >= 188) { | 441 | if (count - p >= 188) { |
| 473 | dvb_dmx_swfilter_packet(demux, buf+p); | 442 | dvb_dmx_swfilter_packet(demux, &buf[p]); |
| 474 | p += 188; | 443 | p += 188; |
| 475 | } else { | 444 | } else { |
| 476 | i = count-p; | 445 | i = count - p; |
| 477 | memcpy(demux->tsbuf, buf+p, i); | 446 | memcpy(demux->tsbuf, &buf[p], i); |
| 478 | demux->tsbufp=i; | 447 | demux->tsbufp = i; |
| 479 | goto bailout; | 448 | goto bailout; |
| 480 | } | 449 | } |
| 481 | } else | 450 | } else |
| @@ -485,24 +454,29 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) | |||
| 485 | bailout: | 454 | bailout: |
| 486 | spin_unlock(&demux->lock); | 455 | spin_unlock(&demux->lock); |
| 487 | } | 456 | } |
| 457 | |||
| 488 | EXPORT_SYMBOL(dvb_dmx_swfilter); | 458 | EXPORT_SYMBOL(dvb_dmx_swfilter); |
| 489 | 459 | ||
| 490 | void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) | 460 | void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) |
| 491 | { | 461 | { |
| 492 | int p = 0,i, j; | 462 | int p = 0, i, j; |
| 493 | u8 tmppack[188]; | 463 | u8 tmppack[188]; |
| 464 | |||
| 494 | spin_lock(&demux->lock); | 465 | spin_lock(&demux->lock); |
| 495 | 466 | ||
| 496 | if ((i = demux->tsbufp)) { | 467 | if (demux->tsbufp) { |
| 497 | if (count < (j=204-i)) { | 468 | i = demux->tsbufp; |
| 469 | j = 204 - i; | ||
| 470 | if (count < j) { | ||
| 498 | memcpy(&demux->tsbuf[i], buf, count); | 471 | memcpy(&demux->tsbuf[i], buf, count); |
| 499 | demux->tsbufp += count; | 472 | demux->tsbufp += count; |
| 500 | goto bailout; | 473 | goto bailout; |
| 501 | } | 474 | } |
| 502 | memcpy(&demux->tsbuf[i], buf, j); | 475 | memcpy(&demux->tsbuf[i], buf, j); |
| 503 | if ((demux->tsbuf[0] == 0x47)|(demux->tsbuf[0]==0xB8)) { | 476 | if ((demux->tsbuf[0] == 0x47) | (demux->tsbuf[0] == 0xB8)) { |
| 504 | memcpy(tmppack, demux->tsbuf, 188); | 477 | memcpy(tmppack, demux->tsbuf, 188); |
| 505 | if (tmppack[0] == 0xB8) tmppack[0] = 0x47; | 478 | if (tmppack[0] == 0xB8) |
| 479 | tmppack[0] = 0x47; | ||
| 506 | dvb_dmx_swfilter_packet(demux, tmppack); | 480 | dvb_dmx_swfilter_packet(demux, tmppack); |
| 507 | } | 481 | } |
| 508 | demux->tsbufp = 0; | 482 | demux->tsbufp = 0; |
| @@ -510,16 +484,17 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) | |||
| 510 | } | 484 | } |
| 511 | 485 | ||
| 512 | while (p < count) { | 486 | while (p < count) { |
| 513 | if ((buf[p] == 0x47)|(buf[p] == 0xB8)) { | 487 | if ((buf[p] == 0x47) | (buf[p] == 0xB8)) { |
| 514 | if (count-p >= 204) { | 488 | if (count - p >= 204) { |
| 515 | memcpy(tmppack, buf+p, 188); | 489 | memcpy(tmppack, &buf[p], 188); |
| 516 | if (tmppack[0] == 0xB8) tmppack[0] = 0x47; | 490 | if (tmppack[0] == 0xB8) |
| 491 | tmppack[0] = 0x47; | ||
| 517 | dvb_dmx_swfilter_packet(demux, tmppack); | 492 | dvb_dmx_swfilter_packet(demux, tmppack); |
| 518 | p += 204; | 493 | p += 204; |
| 519 | } else { | 494 | } else { |
| 520 | i = count-p; | 495 | i = count - p; |
| 521 | memcpy(demux->tsbuf, buf+p, i); | 496 | memcpy(demux->tsbuf, &buf[p], i); |
| 522 | demux->tsbufp=i; | 497 | demux->tsbufp = i; |
| 523 | goto bailout; | 498 | goto bailout; |
| 524 | } | 499 | } |
| 525 | } else { | 500 | } else { |
| @@ -530,14 +505,14 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) | |||
| 530 | bailout: | 505 | bailout: |
| 531 | spin_unlock(&demux->lock); | 506 | spin_unlock(&demux->lock); |
| 532 | } | 507 | } |
| 533 | EXPORT_SYMBOL(dvb_dmx_swfilter_204); | ||
| 534 | 508 | ||
| 509 | EXPORT_SYMBOL(dvb_dmx_swfilter_204); | ||
| 535 | 510 | ||
| 536 | static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) | 511 | static struct dvb_demux_filter *dvb_dmx_filter_alloc(struct dvb_demux *demux) |
| 537 | { | 512 | { |
| 538 | int i; | 513 | int i; |
| 539 | 514 | ||
| 540 | for (i=0; i<demux->filternum; i++) | 515 | for (i = 0; i < demux->filternum; i++) |
| 541 | if (demux->filter[i].state == DMX_STATE_FREE) | 516 | if (demux->filter[i].state == DMX_STATE_FREE) |
| 542 | break; | 517 | break; |
| 543 | 518 | ||
| @@ -549,11 +524,11 @@ static struct dvb_demux_filter * dvb_dmx_filter_alloc(struct dvb_demux *demux) | |||
| 549 | return &demux->filter[i]; | 524 | return &demux->filter[i]; |
| 550 | } | 525 | } |
| 551 | 526 | ||
| 552 | static struct dvb_demux_feed * dvb_dmx_feed_alloc(struct dvb_demux *demux) | 527 | static struct dvb_demux_feed *dvb_dmx_feed_alloc(struct dvb_demux *demux) |
| 553 | { | 528 | { |
| 554 | int i; | 529 | int i; |
| 555 | 530 | ||
| 556 | for (i=0; i<demux->feednum; i++) | 531 | for (i = 0; i < demux->feednum; i++) |
| 557 | if (demux->feed[i].state == DMX_STATE_FREE) | 532 | if (demux->feed[i].state == DMX_STATE_FREE) |
| 558 | break; | 533 | break; |
| 559 | 534 | ||
| @@ -581,7 +556,7 @@ static void dvb_demux_feed_add(struct dvb_demux_feed *feed) | |||
| 581 | spin_lock_irq(&feed->demux->lock); | 556 | spin_lock_irq(&feed->demux->lock); |
| 582 | if (dvb_demux_feed_find(feed)) { | 557 | if (dvb_demux_feed_find(feed)) { |
| 583 | printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n", | 558 | printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n", |
| 584 | __FUNCTION__, feed->type, feed->state, feed->pid); | 559 | __FUNCTION__, feed->type, feed->state, feed->pid); |
| 585 | goto out; | 560 | goto out; |
| 586 | } | 561 | } |
| 587 | 562 | ||
| @@ -595,7 +570,7 @@ static void dvb_demux_feed_del(struct dvb_demux_feed *feed) | |||
| 595 | spin_lock_irq(&feed->demux->lock); | 570 | spin_lock_irq(&feed->demux->lock); |
| 596 | if (!(dvb_demux_feed_find(feed))) { | 571 | if (!(dvb_demux_feed_find(feed))) { |
| 597 | printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n", | 572 | printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n", |
| 598 | __FUNCTION__, feed->type, feed->state, feed->pid); | 573 | __FUNCTION__, feed->type, feed->state, feed->pid); |
| 599 | goto out; | 574 | goto out; |
| 600 | } | 575 | } |
| 601 | 576 | ||
| @@ -604,18 +579,17 @@ out: | |||
| 604 | spin_unlock_irq(&feed->demux->lock); | 579 | spin_unlock_irq(&feed->demux->lock); |
| 605 | } | 580 | } |
| 606 | 581 | ||
| 607 | static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, | 582 | static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type, |
| 608 | enum dmx_ts_pes pes_type, size_t callback_length, | 583 | enum dmx_ts_pes pes_type, |
| 609 | size_t circular_buffer_size, int descramble, | 584 | size_t circular_buffer_size, struct timespec timeout) |
| 610 | struct timespec timeout) | ||
| 611 | { | 585 | { |
| 612 | struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; | 586 | struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; |
| 613 | struct dvb_demux *demux = feed->demux; | 587 | struct dvb_demux *demux = feed->demux; |
| 614 | 588 | ||
| 615 | if (pid > DMX_MAX_PID) | 589 | if (pid > DMX_MAX_PID) |
| 616 | return -EINVAL; | 590 | return -EINVAL; |
| 617 | 591 | ||
| 618 | if (down_interruptible (&demux->mutex)) | 592 | if (down_interruptible(&demux->mutex)) |
| 619 | return -ERESTARTSYS; | 593 | return -ERESTARTSYS; |
| 620 | 594 | ||
| 621 | if (ts_type & TS_DECODER) { | 595 | if (ts_type & TS_DECODER) { |
| @@ -638,20 +612,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, | |||
| 638 | 612 | ||
| 639 | feed->pid = pid; | 613 | feed->pid = pid; |
| 640 | feed->buffer_size = circular_buffer_size; | 614 | feed->buffer_size = circular_buffer_size; |
| 641 | feed->descramble = descramble; | ||
| 642 | feed->timeout = timeout; | 615 | feed->timeout = timeout; |
| 643 | feed->cb_length = callback_length; | ||
| 644 | feed->ts_type = ts_type; | 616 | feed->ts_type = ts_type; |
| 645 | feed->pes_type = pes_type; | 617 | feed->pes_type = pes_type; |
| 646 | 618 | ||
| 647 | if (feed->descramble) { | ||
| 648 | up(&demux->mutex); | ||
| 649 | return -ENOSYS; | ||
| 650 | } | ||
| 651 | |||
| 652 | if (feed->buffer_size) { | 619 | if (feed->buffer_size) { |
| 653 | #ifdef NOBUFS | 620 | #ifdef NOBUFS |
| 654 | feed->buffer=NULL; | 621 | feed->buffer = NULL; |
| 655 | #else | 622 | #else |
| 656 | feed->buffer = vmalloc(feed->buffer_size); | 623 | feed->buffer = vmalloc(feed->buffer_size); |
| 657 | if (!feed->buffer) { | 624 | if (!feed->buffer) { |
| @@ -667,14 +634,13 @@ static int dmx_ts_feed_set (struct dmx_ts_feed* ts_feed, u16 pid, int ts_type, | |||
| 667 | return 0; | 634 | return 0; |
| 668 | } | 635 | } |
| 669 | 636 | ||
| 670 | 637 | static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed) | |
| 671 | static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) | ||
| 672 | { | 638 | { |
| 673 | struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; | 639 | struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; |
| 674 | struct dvb_demux *demux = feed->demux; | 640 | struct dvb_demux *demux = feed->demux; |
| 675 | int ret; | 641 | int ret; |
| 676 | 642 | ||
| 677 | if (down_interruptible (&demux->mutex)) | 643 | if (down_interruptible(&demux->mutex)) |
| 678 | return -ERESTARTSYS; | 644 | return -ERESTARTSYS; |
| 679 | 645 | ||
| 680 | if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) { | 646 | if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) { |
| @@ -701,13 +667,13 @@ static int dmx_ts_feed_start_filtering(struct dmx_ts_feed* ts_feed) | |||
| 701 | return 0; | 667 | return 0; |
| 702 | } | 668 | } |
| 703 | 669 | ||
| 704 | static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) | 670 | static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed) |
| 705 | { | 671 | { |
| 706 | struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; | 672 | struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; |
| 707 | struct dvb_demux *demux = feed->demux; | 673 | struct dvb_demux *demux = feed->demux; |
| 708 | int ret; | 674 | int ret; |
| 709 | 675 | ||
| 710 | if (down_interruptible (&demux->mutex)) | 676 | if (down_interruptible(&demux->mutex)) |
| 711 | return -ERESTARTSYS; | 677 | return -ERESTARTSYS; |
| 712 | 678 | ||
| 713 | if (feed->state < DMX_STATE_GO) { | 679 | if (feed->state < DMX_STATE_GO) { |
| @@ -731,13 +697,14 @@ static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed* ts_feed) | |||
| 731 | return ret; | 697 | return ret; |
| 732 | } | 698 | } |
| 733 | 699 | ||
| 734 | static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed **ts_feed, | 700 | static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx, |
| 735 | dmx_ts_cb callback) | 701 | struct dmx_ts_feed **ts_feed, |
| 702 | dmx_ts_cb callback) | ||
| 736 | { | 703 | { |
| 737 | struct dvb_demux *demux = (struct dvb_demux *) dmx; | 704 | struct dvb_demux *demux = (struct dvb_demux *)dmx; |
| 738 | struct dvb_demux_feed *feed; | 705 | struct dvb_demux_feed *feed; |
| 739 | 706 | ||
| 740 | if (down_interruptible (&demux->mutex)) | 707 | if (down_interruptible(&demux->mutex)) |
| 741 | return -ERESTARTSYS; | 708 | return -ERESTARTSYS; |
| 742 | 709 | ||
| 743 | if (!(feed = dvb_dmx_feed_alloc(demux))) { | 710 | if (!(feed = dvb_dmx_feed_alloc(demux))) { |
| @@ -760,7 +727,6 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** | |||
| 760 | (*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering; | 727 | (*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering; |
| 761 | (*ts_feed)->set = dmx_ts_feed_set; | 728 | (*ts_feed)->set = dmx_ts_feed_set; |
| 762 | 729 | ||
| 763 | |||
| 764 | if (!(feed->filter = dvb_dmx_filter_alloc(demux))) { | 730 | if (!(feed->filter = dvb_dmx_filter_alloc(demux))) { |
| 765 | feed->state = DMX_STATE_FREE; | 731 | feed->state = DMX_STATE_FREE; |
| 766 | up(&demux->mutex); | 732 | up(&demux->mutex); |
| @@ -776,22 +742,22 @@ static int dvbdmx_allocate_ts_feed (struct dmx_demux *dmx, struct dmx_ts_feed ** | |||
| 776 | return 0; | 742 | return 0; |
| 777 | } | 743 | } |
| 778 | 744 | ||
| 779 | static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_feed) | 745 | static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, |
| 746 | struct dmx_ts_feed *ts_feed) | ||
| 780 | { | 747 | { |
| 781 | struct dvb_demux *demux = (struct dvb_demux *) dmx; | 748 | struct dvb_demux *demux = (struct dvb_demux *)dmx; |
| 782 | struct dvb_demux_feed *feed = (struct dvb_demux_feed *) ts_feed; | 749 | struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed; |
| 783 | 750 | ||
| 784 | if (down_interruptible (&demux->mutex)) | 751 | if (down_interruptible(&demux->mutex)) |
| 785 | return -ERESTARTSYS; | 752 | return -ERESTARTSYS; |
| 786 | 753 | ||
| 787 | if (feed->state == DMX_STATE_FREE) { | 754 | if (feed->state == DMX_STATE_FREE) { |
| 788 | up(&demux->mutex); | 755 | up(&demux->mutex); |
| 789 | return -EINVAL; | 756 | return -EINVAL; |
| 790 | } | 757 | } |
| 791 | |||
| 792 | #ifndef NOBUFS | 758 | #ifndef NOBUFS |
| 793 | vfree(feed->buffer); | 759 | vfree(feed->buffer); |
| 794 | feed->buffer=0; | 760 | feed->buffer = NULL; |
| 795 | #endif | 761 | #endif |
| 796 | 762 | ||
| 797 | feed->state = DMX_STATE_FREE; | 763 | feed->state = DMX_STATE_FREE; |
| @@ -808,19 +774,18 @@ static int dvbdmx_release_ts_feed(struct dmx_demux *dmx, struct dmx_ts_feed *ts_ | |||
| 808 | return 0; | 774 | return 0; |
| 809 | } | 775 | } |
| 810 | 776 | ||
| 811 | |||
| 812 | /****************************************************************************** | 777 | /****************************************************************************** |
| 813 | * dmx_section_feed API calls | 778 | * dmx_section_feed API calls |
| 814 | ******************************************************************************/ | 779 | ******************************************************************************/ |
| 815 | 780 | ||
| 816 | static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, | 781 | static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed, |
| 817 | struct dmx_section_filter** filter) | 782 | struct dmx_section_filter **filter) |
| 818 | { | 783 | { |
| 819 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; | 784 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; |
| 820 | struct dvb_demux *dvbdemux = dvbdmxfeed->demux; | 785 | struct dvb_demux *dvbdemux = dvbdmxfeed->demux; |
| 821 | struct dvb_demux_filter *dvbdmxfilter; | 786 | struct dvb_demux_filter *dvbdmxfilter; |
| 822 | 787 | ||
| 823 | if (down_interruptible (&dvbdemux->mutex)) | 788 | if (down_interruptible(&dvbdemux->mutex)) |
| 824 | return -ERESTARTSYS; | 789 | return -ERESTARTSYS; |
| 825 | 790 | ||
| 826 | dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux); | 791 | dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux); |
| @@ -844,36 +809,29 @@ static int dmx_section_feed_allocate_filter(struct dmx_section_feed* feed, | |||
| 844 | return 0; | 809 | return 0; |
| 845 | } | 810 | } |
| 846 | 811 | ||
| 847 | 812 | static int dmx_section_feed_set(struct dmx_section_feed *feed, | |
| 848 | static int dmx_section_feed_set(struct dmx_section_feed* feed, | 813 | u16 pid, size_t circular_buffer_size, |
| 849 | u16 pid, size_t circular_buffer_size, | 814 | int check_crc) |
| 850 | int descramble, int check_crc) | ||
| 851 | { | 815 | { |
| 852 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; | 816 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; |
| 853 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | 817 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; |
| 854 | 818 | ||
| 855 | if (pid > 0x1fff) | 819 | if (pid > 0x1fff) |
| 856 | return -EINVAL; | 820 | return -EINVAL; |
| 857 | 821 | ||
| 858 | if (down_interruptible (&dvbdmx->mutex)) | 822 | if (down_interruptible(&dvbdmx->mutex)) |
| 859 | return -ERESTARTSYS; | 823 | return -ERESTARTSYS; |
| 860 | 824 | ||
| 861 | dvb_demux_feed_add(dvbdmxfeed); | 825 | dvb_demux_feed_add(dvbdmxfeed); |
| 862 | 826 | ||
| 863 | dvbdmxfeed->pid = pid; | 827 | dvbdmxfeed->pid = pid; |
| 864 | dvbdmxfeed->buffer_size = circular_buffer_size; | 828 | dvbdmxfeed->buffer_size = circular_buffer_size; |
| 865 | dvbdmxfeed->descramble = descramble; | ||
| 866 | if (dvbdmxfeed->descramble) { | ||
| 867 | up(&dvbdmx->mutex); | ||
| 868 | return -ENOSYS; | ||
| 869 | } | ||
| 870 | |||
| 871 | dvbdmxfeed->feed.sec.check_crc = check_crc; | 829 | dvbdmxfeed->feed.sec.check_crc = check_crc; |
| 872 | 830 | ||
| 873 | #ifdef NOBUFS | 831 | #ifdef NOBUFS |
| 874 | dvbdmxfeed->buffer = NULL; | 832 | dvbdmxfeed->buffer = NULL; |
| 875 | #else | 833 | #else |
| 876 | dvbdmxfeed->buffer=vmalloc(dvbdmxfeed->buffer_size); | 834 | dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size); |
| 877 | if (!dvbdmxfeed->buffer) { | 835 | if (!dvbdmxfeed->buffer) { |
| 878 | up(&dvbdmx->mutex); | 836 | up(&dvbdmx->mutex); |
| 879 | return -ENOMEM; | 837 | return -ENOMEM; |
| @@ -885,7 +843,6 @@ static int dmx_section_feed_set(struct dmx_section_feed* feed, | |||
| 885 | return 0; | 843 | return 0; |
| 886 | } | 844 | } |
| 887 | 845 | ||
| 888 | |||
| 889 | static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) | 846 | static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) |
| 890 | { | 847 | { |
| 891 | int i; | 848 | int i; |
| @@ -893,12 +850,12 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) | |||
| 893 | struct dmx_section_filter *sf; | 850 | struct dmx_section_filter *sf; |
| 894 | u8 mask, mode, doneq; | 851 | u8 mask, mode, doneq; |
| 895 | 852 | ||
| 896 | if (!(f=dvbdmxfeed->filter)) | 853 | if (!(f = dvbdmxfeed->filter)) |
| 897 | return; | 854 | return; |
| 898 | do { | 855 | do { |
| 899 | sf = &f->filter; | 856 | sf = &f->filter; |
| 900 | doneq = 0; | 857 | doneq = 0; |
| 901 | for (i=0; i<DVB_DEMUX_MASK_MAX; i++) { | 858 | for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) { |
| 902 | mode = sf->filter_mode[i]; | 859 | mode = sf->filter_mode[i]; |
| 903 | mask = sf->filter_mask[i]; | 860 | mask = sf->filter_mask[i]; |
| 904 | f->maskandmode[i] = mask & mode; | 861 | f->maskandmode[i] = mask & mode; |
| @@ -908,14 +865,13 @@ static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed) | |||
| 908 | } while ((f = f->next)); | 865 | } while ((f = f->next)); |
| 909 | } | 866 | } |
| 910 | 867 | ||
| 911 | |||
| 912 | static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) | 868 | static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) |
| 913 | { | 869 | { |
| 914 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; | 870 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; |
| 915 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | 871 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; |
| 916 | int ret; | 872 | int ret; |
| 917 | 873 | ||
| 918 | if (down_interruptible (&dvbdmx->mutex)) | 874 | if (down_interruptible(&dvbdmx->mutex)) |
| 919 | return -ERESTARTSYS; | 875 | return -ERESTARTSYS; |
| 920 | 876 | ||
| 921 | if (feed->is_filtering) { | 877 | if (feed->is_filtering) { |
| @@ -954,14 +910,13 @@ static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed) | |||
| 954 | return 0; | 910 | return 0; |
| 955 | } | 911 | } |
| 956 | 912 | ||
| 957 | 913 | static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed) | |
| 958 | static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) | ||
| 959 | { | 914 | { |
| 960 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; | 915 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; |
| 961 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | 916 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; |
| 962 | int ret; | 917 | int ret; |
| 963 | 918 | ||
| 964 | if (down_interruptible (&dvbdmx->mutex)) | 919 | if (down_interruptible(&dvbdmx->mutex)) |
| 965 | return -ERESTARTSYS; | 920 | return -ERESTARTSYS; |
| 966 | 921 | ||
| 967 | if (!dvbdmx->stop_feed) { | 922 | if (!dvbdmx->stop_feed) { |
| @@ -980,15 +935,14 @@ static int dmx_section_feed_stop_filtering(struct dmx_section_feed* feed) | |||
| 980 | return ret; | 935 | return ret; |
| 981 | } | 936 | } |
| 982 | 937 | ||
| 983 | |||
| 984 | static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, | 938 | static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, |
| 985 | struct dmx_section_filter* filter) | 939 | struct dmx_section_filter *filter) |
| 986 | { | 940 | { |
| 987 | struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *) filter, *f; | 941 | struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *)filter, *f; |
| 988 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; | 942 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; |
| 989 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | 943 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; |
| 990 | 944 | ||
| 991 | if (down_interruptible (&dvbdmx->mutex)) | 945 | if (down_interruptible(&dvbdmx->mutex)) |
| 992 | return -ERESTARTSYS; | 946 | return -ERESTARTSYS; |
| 993 | 947 | ||
| 994 | if (dvbdmxfilter->feed != dvbdmxfeed) { | 948 | if (dvbdmxfilter->feed != dvbdmxfeed) { |
| @@ -1005,7 +959,7 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed, | |||
| 1005 | if (f == dvbdmxfilter) { | 959 | if (f == dvbdmxfilter) { |
| 1006 | dvbdmxfeed->filter = dvbdmxfilter->next; | 960 | dvbdmxfeed->filter = dvbdmxfilter->next; |
| 1007 | } else { | 961 | } else { |
| 1008 | while(f->next != dvbdmxfilter) | 962 | while (f->next != dvbdmxfilter) |
| 1009 | f = f->next; | 963 | f = f->next; |
| 1010 | f->next = f->next->next; | 964 | f->next = f->next->next; |
| 1011 | } | 965 | } |
| @@ -1020,10 +974,10 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, | |||
| 1020 | struct dmx_section_feed **feed, | 974 | struct dmx_section_feed **feed, |
| 1021 | dmx_section_cb callback) | 975 | dmx_section_cb callback) |
| 1022 | { | 976 | { |
| 1023 | struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; | 977 | struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; |
| 1024 | struct dvb_demux_feed *dvbdmxfeed; | 978 | struct dvb_demux_feed *dvbdmxfeed; |
| 1025 | 979 | ||
| 1026 | if (down_interruptible (&dvbdmx->mutex)) | 980 | if (down_interruptible(&dvbdmx->mutex)) |
| 1027 | return -ERESTARTSYS; | 981 | return -ERESTARTSYS; |
| 1028 | 982 | ||
| 1029 | if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) { | 983 | if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) { |
| @@ -1041,7 +995,7 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, | |||
| 1041 | dvbdmxfeed->filter = NULL; | 995 | dvbdmxfeed->filter = NULL; |
| 1042 | dvbdmxfeed->buffer = NULL; | 996 | dvbdmxfeed->buffer = NULL; |
| 1043 | 997 | ||
| 1044 | (*feed)=&dvbdmxfeed->feed.sec; | 998 | (*feed) = &dvbdmxfeed->feed.sec; |
| 1045 | (*feed)->is_filtering = 0; | 999 | (*feed)->is_filtering = 0; |
| 1046 | (*feed)->parent = demux; | 1000 | (*feed)->parent = demux; |
| 1047 | (*feed)->priv = NULL; | 1001 | (*feed)->priv = NULL; |
| @@ -1059,21 +1013,21 @@ static int dvbdmx_allocate_section_feed(struct dmx_demux *demux, | |||
| 1059 | static int dvbdmx_release_section_feed(struct dmx_demux *demux, | 1013 | static int dvbdmx_release_section_feed(struct dmx_demux *demux, |
| 1060 | struct dmx_section_feed *feed) | 1014 | struct dmx_section_feed *feed) |
| 1061 | { | 1015 | { |
| 1062 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) feed; | 1016 | struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed; |
| 1063 | struct dvb_demux *dvbdmx = (struct dvb_demux *) demux; | 1017 | struct dvb_demux *dvbdmx = (struct dvb_demux *)demux; |
| 1064 | 1018 | ||
| 1065 | if (down_interruptible (&dvbdmx->mutex)) | 1019 | if (down_interruptible(&dvbdmx->mutex)) |
| 1066 | return -ERESTARTSYS; | 1020 | return -ERESTARTSYS; |
| 1067 | 1021 | ||
| 1068 | if (dvbdmxfeed->state==DMX_STATE_FREE) { | 1022 | if (dvbdmxfeed->state == DMX_STATE_FREE) { |
| 1069 | up(&dvbdmx->mutex); | 1023 | up(&dvbdmx->mutex); |
| 1070 | return -EINVAL; | 1024 | return -EINVAL; |
| 1071 | } | 1025 | } |
| 1072 | #ifndef NOBUFS | 1026 | #ifndef NOBUFS |
| 1073 | vfree(dvbdmxfeed->buffer); | 1027 | vfree(dvbdmxfeed->buffer); |
| 1074 | dvbdmxfeed->buffer=0; | 1028 | dvbdmxfeed->buffer = NULL; |
| 1075 | #endif | 1029 | #endif |
| 1076 | dvbdmxfeed->state=DMX_STATE_FREE; | 1030 | dvbdmxfeed->state = DMX_STATE_FREE; |
| 1077 | 1031 | ||
| 1078 | dvb_demux_feed_del(dvbdmxfeed); | 1032 | dvb_demux_feed_del(dvbdmxfeed); |
| 1079 | 1033 | ||
| @@ -1083,14 +1037,13 @@ static int dvbdmx_release_section_feed(struct dmx_demux *demux, | |||
| 1083 | return 0; | 1037 | return 0; |
| 1084 | } | 1038 | } |
| 1085 | 1039 | ||
| 1086 | |||
| 1087 | /****************************************************************************** | 1040 | /****************************************************************************** |
| 1088 | * dvb_demux kernel data API calls | 1041 | * dvb_demux kernel data API calls |
| 1089 | ******************************************************************************/ | 1042 | ******************************************************************************/ |
| 1090 | 1043 | ||
| 1091 | static int dvbdmx_open(struct dmx_demux *demux) | 1044 | static int dvbdmx_open(struct dmx_demux *demux) |
| 1092 | { | 1045 | { |
| 1093 | struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; | 1046 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1094 | 1047 | ||
| 1095 | if (dvbdemux->users >= MAX_DVB_DEMUX_USERS) | 1048 | if (dvbdemux->users >= MAX_DVB_DEMUX_USERS) |
| 1096 | return -EUSERS; | 1049 | return -EUSERS; |
| @@ -1099,10 +1052,9 @@ static int dvbdmx_open(struct dmx_demux *demux) | |||
| 1099 | return 0; | 1052 | return 0; |
| 1100 | } | 1053 | } |
| 1101 | 1054 | ||
| 1102 | |||
| 1103 | static int dvbdmx_close(struct dmx_demux *demux) | 1055 | static int dvbdmx_close(struct dmx_demux *demux) |
| 1104 | { | 1056 | { |
| 1105 | struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; | 1057 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1106 | 1058 | ||
| 1107 | if (dvbdemux->users == 0) | 1059 | if (dvbdemux->users == 0) |
| 1108 | return -ENODEV; | 1060 | return -ENODEV; |
| @@ -1112,15 +1064,14 @@ static int dvbdmx_close(struct dmx_demux *demux) | |||
| 1112 | return 0; | 1064 | return 0; |
| 1113 | } | 1065 | } |
| 1114 | 1066 | ||
| 1115 | |||
| 1116 | static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) | 1067 | static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) |
| 1117 | { | 1068 | { |
| 1118 | struct dvb_demux *dvbdemux=(struct dvb_demux *) demux; | 1069 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1119 | 1070 | ||
| 1120 | if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) | 1071 | if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE)) |
| 1121 | return -EINVAL; | 1072 | return -EINVAL; |
| 1122 | 1073 | ||
| 1123 | if (down_interruptible (&dvbdemux->mutex)) | 1074 | if (down_interruptible(&dvbdemux->mutex)) |
| 1124 | return -ERESTARTSYS; | 1075 | return -ERESTARTSYS; |
| 1125 | dvb_dmx_swfilter(dvbdemux, buf, count); | 1076 | dvb_dmx_swfilter(dvbdemux, buf, count); |
| 1126 | up(&dvbdemux->mutex); | 1077 | up(&dvbdemux->mutex); |
| @@ -1130,10 +1081,10 @@ static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count) | |||
| 1130 | return count; | 1081 | return count; |
| 1131 | } | 1082 | } |
| 1132 | 1083 | ||
| 1133 | 1084 | static int dvbdmx_add_frontend(struct dmx_demux *demux, | |
| 1134 | static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) | 1085 | struct dmx_frontend *frontend) |
| 1135 | { | 1086 | { |
| 1136 | struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; | 1087 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1137 | struct list_head *head = &dvbdemux->frontend_list; | 1088 | struct list_head *head = &dvbdemux->frontend_list; |
| 1138 | 1089 | ||
| 1139 | list_add(&(frontend->connectivity_list), head); | 1090 | list_add(&(frontend->connectivity_list), head); |
| @@ -1141,13 +1092,13 @@ static int dvbdmx_add_frontend(struct dmx_demux *demux, struct dmx_frontend *fro | |||
| 1141 | return 0; | 1092 | return 0; |
| 1142 | } | 1093 | } |
| 1143 | 1094 | ||
| 1144 | 1095 | static int dvbdmx_remove_frontend(struct dmx_demux *demux, | |
| 1145 | static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) | 1096 | struct dmx_frontend *frontend) |
| 1146 | { | 1097 | { |
| 1147 | struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; | 1098 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1148 | struct list_head *pos, *n, *head = &dvbdemux->frontend_list; | 1099 | struct list_head *pos, *n, *head = &dvbdemux->frontend_list; |
| 1149 | 1100 | ||
| 1150 | list_for_each_safe (pos, n, head) { | 1101 | list_for_each_safe(pos, n, head) { |
| 1151 | if (DMX_FE_ENTRY(pos) == frontend) { | 1102 | if (DMX_FE_ENTRY(pos) == frontend) { |
| 1152 | list_del(pos); | 1103 | list_del(pos); |
| 1153 | return 0; | 1104 | return 0; |
| @@ -1157,25 +1108,25 @@ static int dvbdmx_remove_frontend(struct dmx_demux *demux, struct dmx_frontend * | |||
| 1157 | return -ENODEV; | 1108 | return -ENODEV; |
| 1158 | } | 1109 | } |
| 1159 | 1110 | ||
| 1160 | 1111 | static struct list_head *dvbdmx_get_frontends(struct dmx_demux *demux) | |
| 1161 | static struct list_head * dvbdmx_get_frontends(struct dmx_demux *demux) | ||
| 1162 | { | 1112 | { |
| 1163 | struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; | 1113 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1164 | 1114 | ||
| 1165 | if (list_empty(&dvbdemux->frontend_list)) | 1115 | if (list_empty(&dvbdemux->frontend_list)) |
| 1166 | return NULL; | 1116 | return NULL; |
| 1117 | |||
| 1167 | return &dvbdemux->frontend_list; | 1118 | return &dvbdemux->frontend_list; |
| 1168 | } | 1119 | } |
| 1169 | 1120 | ||
| 1170 | 1121 | static int dvbdmx_connect_frontend(struct dmx_demux *demux, | |
| 1171 | static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend *frontend) | 1122 | struct dmx_frontend *frontend) |
| 1172 | { | 1123 | { |
| 1173 | struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; | 1124 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1174 | 1125 | ||
| 1175 | if (demux->frontend) | 1126 | if (demux->frontend) |
| 1176 | return -EINVAL; | 1127 | return -EINVAL; |
| 1177 | 1128 | ||
| 1178 | if (down_interruptible (&dvbdemux->mutex)) | 1129 | if (down_interruptible(&dvbdemux->mutex)) |
| 1179 | return -ERESTARTSYS; | 1130 | return -ERESTARTSYS; |
| 1180 | 1131 | ||
| 1181 | demux->frontend = frontend; | 1132 | demux->frontend = frontend; |
| @@ -1183,12 +1134,11 @@ static int dvbdmx_connect_frontend(struct dmx_demux *demux, struct dmx_frontend | |||
| 1183 | return 0; | 1134 | return 0; |
| 1184 | } | 1135 | } |
| 1185 | 1136 | ||
| 1186 | |||
| 1187 | static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) | 1137 | static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) |
| 1188 | { | 1138 | { |
| 1189 | struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; | 1139 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1190 | 1140 | ||
| 1191 | if (down_interruptible (&dvbdemux->mutex)) | 1141 | if (down_interruptible(&dvbdemux->mutex)) |
| 1192 | return -ERESTARTSYS; | 1142 | return -ERESTARTSYS; |
| 1193 | 1143 | ||
| 1194 | demux->frontend = NULL; | 1144 | demux->frontend = NULL; |
| @@ -1196,44 +1146,42 @@ static int dvbdmx_disconnect_frontend(struct dmx_demux *demux) | |||
| 1196 | return 0; | 1146 | return 0; |
| 1197 | } | 1147 | } |
| 1198 | 1148 | ||
| 1199 | 1149 | static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 * pids) | |
| 1200 | static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 *pids) | ||
| 1201 | { | 1150 | { |
| 1202 | struct dvb_demux *dvbdemux = (struct dvb_demux *) demux; | 1151 | struct dvb_demux *dvbdemux = (struct dvb_demux *)demux; |
| 1203 | 1152 | ||
| 1204 | memcpy(pids, dvbdemux->pids, 5*sizeof(u16)); | 1153 | memcpy(pids, dvbdemux->pids, 5 * sizeof(u16)); |
| 1205 | return 0; | 1154 | return 0; |
| 1206 | } | 1155 | } |
| 1207 | 1156 | ||
| 1208 | |||
| 1209 | int dvb_dmx_init(struct dvb_demux *dvbdemux) | 1157 | int dvb_dmx_init(struct dvb_demux *dvbdemux) |
| 1210 | { | 1158 | { |
| 1211 | int i, err; | 1159 | int i; |
| 1212 | struct dmx_demux *dmx = &dvbdemux->dmx; | 1160 | struct dmx_demux *dmx = &dvbdemux->dmx; |
| 1213 | 1161 | ||
| 1214 | dvbdemux->users = 0; | 1162 | dvbdemux->users = 0; |
| 1215 | dvbdemux->filter = vmalloc(dvbdemux->filternum*sizeof(struct dvb_demux_filter)); | 1163 | dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter)); |
| 1216 | 1164 | ||
| 1217 | if (!dvbdemux->filter) | 1165 | if (!dvbdemux->filter) |
| 1218 | return -ENOMEM; | 1166 | return -ENOMEM; |
| 1219 | 1167 | ||
| 1220 | dvbdemux->feed = vmalloc(dvbdemux->feednum*sizeof(struct dvb_demux_feed)); | 1168 | dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed)); |
| 1221 | if (!dvbdemux->feed) { | 1169 | if (!dvbdemux->feed) { |
| 1222 | vfree(dvbdemux->filter); | 1170 | vfree(dvbdemux->filter); |
| 1223 | return -ENOMEM; | 1171 | return -ENOMEM; |
| 1224 | } | 1172 | } |
| 1225 | for (i=0; i<dvbdemux->filternum; i++) { | 1173 | for (i = 0; i < dvbdemux->filternum; i++) { |
| 1226 | dvbdemux->filter[i].state = DMX_STATE_FREE; | 1174 | dvbdemux->filter[i].state = DMX_STATE_FREE; |
| 1227 | dvbdemux->filter[i].index = i; | 1175 | dvbdemux->filter[i].index = i; |
| 1228 | } | 1176 | } |
| 1229 | for (i=0; i<dvbdemux->feednum; i++) { | 1177 | for (i = 0; i < dvbdemux->feednum; i++) { |
| 1230 | dvbdemux->feed[i].state = DMX_STATE_FREE; | 1178 | dvbdemux->feed[i].state = DMX_STATE_FREE; |
| 1231 | dvbdemux->feed[i].index = i; | 1179 | dvbdemux->feed[i].index = i; |
| 1232 | } | 1180 | } |
| 1233 | dvbdemux->frontend_list.next= | 1181 | |
| 1234 | dvbdemux->frontend_list.prev= | 1182 | INIT_LIST_HEAD(&dvbdemux->frontend_list); |
| 1235 | &dvbdemux->frontend_list; | 1183 | |
| 1236 | for (i=0; i<DMX_TS_PES_OTHER; i++) { | 1184 | for (i = 0; i < DMX_TS_PES_OTHER; i++) { |
| 1237 | dvbdemux->pesfilter[i] = NULL; | 1185 | dvbdemux->pesfilter[i] = NULL; |
| 1238 | dvbdemux->pids[i] = 0xffff; | 1186 | dvbdemux->pids[i] = 0xffff; |
| 1239 | } | 1187 | } |
| @@ -1247,12 +1195,11 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) | |||
| 1247 | if (!dvbdemux->check_crc32) | 1195 | if (!dvbdemux->check_crc32) |
| 1248 | dvbdemux->check_crc32 = dvb_dmx_crc32; | 1196 | dvbdemux->check_crc32 = dvb_dmx_crc32; |
| 1249 | 1197 | ||
| 1250 | if (!dvbdemux->memcopy) | 1198 | if (!dvbdemux->memcopy) |
| 1251 | dvbdemux->memcopy = dvb_dmx_memcopy; | 1199 | dvbdemux->memcopy = dvb_dmx_memcopy; |
| 1252 | 1200 | ||
| 1253 | dmx->frontend = NULL; | 1201 | dmx->frontend = NULL; |
| 1254 | dmx->reg_list.prev = dmx->reg_list.next = &dmx->reg_list; | 1202 | dmx->priv = dvbdemux; |
| 1255 | dmx->priv = (void *) dvbdemux; | ||
| 1256 | dmx->open = dvbdmx_open; | 1203 | dmx->open = dvbdmx_open; |
| 1257 | dmx->close = dvbdmx_close; | 1204 | dmx->close = dvbdmx_close; |
| 1258 | dmx->write = dvbdmx_write; | 1205 | dmx->write = dvbdmx_write; |
| @@ -1261,9 +1208,6 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) | |||
| 1261 | dmx->allocate_section_feed = dvbdmx_allocate_section_feed; | 1208 | dmx->allocate_section_feed = dvbdmx_allocate_section_feed; |
| 1262 | dmx->release_section_feed = dvbdmx_release_section_feed; | 1209 | dmx->release_section_feed = dvbdmx_release_section_feed; |
| 1263 | 1210 | ||
| 1264 | dmx->descramble_mac_address = NULL; | ||
| 1265 | dmx->descramble_section_payload = NULL; | ||
| 1266 | |||
| 1267 | dmx->add_frontend = dvbdmx_add_frontend; | 1211 | dmx->add_frontend = dvbdmx_add_frontend; |
| 1268 | dmx->remove_frontend = dvbdmx_remove_frontend; | 1212 | dmx->remove_frontend = dvbdmx_remove_frontend; |
| 1269 | dmx->get_frontends = dvbdmx_get_frontends; | 1213 | dmx->get_frontends = dvbdmx_get_frontends; |
| @@ -1274,21 +1218,15 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) | |||
| 1274 | sema_init(&dvbdemux->mutex, 1); | 1218 | sema_init(&dvbdemux->mutex, 1); |
| 1275 | spin_lock_init(&dvbdemux->lock); | 1219 | spin_lock_init(&dvbdemux->lock); |
| 1276 | 1220 | ||
| 1277 | if ((err = dmx_register_demux(dmx)) < 0) | ||
| 1278 | return err; | ||
| 1279 | |||
| 1280 | return 0; | 1221 | return 0; |
| 1281 | } | 1222 | } |
| 1282 | EXPORT_SYMBOL(dvb_dmx_init); | ||
| 1283 | 1223 | ||
| 1224 | EXPORT_SYMBOL(dvb_dmx_init); | ||
| 1284 | 1225 | ||
| 1285 | int dvb_dmx_release(struct dvb_demux *dvbdemux) | 1226 | void dvb_dmx_release(struct dvb_demux *dvbdemux) |
| 1286 | { | 1227 | { |
| 1287 | struct dmx_demux *dmx = &dvbdemux->dmx; | ||
| 1288 | |||
| 1289 | dmx_unregister_demux(dmx); | ||
| 1290 | vfree(dvbdemux->filter); | 1228 | vfree(dvbdemux->filter); |
| 1291 | vfree(dvbdemux->feed); | 1229 | vfree(dvbdemux->feed); |
| 1292 | return 0; | ||
| 1293 | } | 1230 | } |
| 1231 | |||
| 1294 | EXPORT_SYMBOL(dvb_dmx_release); | 1232 | EXPORT_SYMBOL(dvb_dmx_release); |
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h index c09beb391622..0cc888339d52 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.h +++ b/drivers/media/dvb/dvb-core/dvb_demux.h | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | * | 20 | * |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | |||
| 24 | #ifndef _DVB_DEMUX_H_ | 23 | #ifndef _DVB_DEMUX_H_ |
| 25 | #define _DVB_DEMUX_H_ | 24 | #define _DVB_DEMUX_H_ |
| 26 | 25 | ||
| @@ -44,103 +43,98 @@ | |||
| 44 | #define DVB_DEMUX_MASK_MAX 18 | 43 | #define DVB_DEMUX_MASK_MAX 18 |
| 45 | 44 | ||
| 46 | struct dvb_demux_filter { | 45 | struct dvb_demux_filter { |
| 47 | struct dmx_section_filter filter; | 46 | struct dmx_section_filter filter; |
| 48 | u8 maskandmode [DMX_MAX_FILTER_SIZE]; | 47 | u8 maskandmode[DMX_MAX_FILTER_SIZE]; |
| 49 | u8 maskandnotmode [DMX_MAX_FILTER_SIZE]; | 48 | u8 maskandnotmode[DMX_MAX_FILTER_SIZE]; |
| 50 | int doneq; | 49 | int doneq; |
| 51 | 50 | ||
| 52 | struct dvb_demux_filter *next; | 51 | struct dvb_demux_filter *next; |
| 53 | struct dvb_demux_feed *feed; | 52 | struct dvb_demux_feed *feed; |
| 54 | int index; | 53 | int index; |
| 55 | int state; | 54 | int state; |
| 56 | int type; | 55 | int type; |
| 57 | int pesto; | ||
| 58 | |||
| 59 | u16 handle; | ||
| 60 | u16 hw_handle; | ||
| 61 | struct timer_list timer; | ||
| 62 | int ts_state; | ||
| 63 | }; | ||
| 64 | 56 | ||
| 57 | u16 hw_handle; | ||
| 58 | struct timer_list timer; | ||
| 59 | }; | ||
| 65 | 60 | ||
| 66 | #define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head) | 61 | #define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head) |
| 67 | 62 | ||
| 68 | struct dvb_demux_feed { | 63 | struct dvb_demux_feed { |
| 69 | union { | 64 | union { |
| 70 | struct dmx_ts_feed ts; | 65 | struct dmx_ts_feed ts; |
| 71 | struct dmx_section_feed sec; | 66 | struct dmx_section_feed sec; |
| 72 | } feed; | 67 | } feed; |
| 73 | 68 | ||
| 74 | union { | 69 | union { |
| 75 | dmx_ts_cb ts; | 70 | dmx_ts_cb ts; |
| 76 | dmx_section_cb sec; | 71 | dmx_section_cb sec; |
| 77 | } cb; | 72 | } cb; |
| 78 | 73 | ||
| 79 | struct dvb_demux *demux; | 74 | struct dvb_demux *demux; |
| 80 | void *priv; | 75 | void *priv; |
| 81 | int type; | 76 | int type; |
| 82 | int state; | 77 | int state; |
| 83 | u16 pid; | 78 | u16 pid; |
| 84 | u8 *buffer; | 79 | u8 *buffer; |
| 85 | int buffer_size; | 80 | int buffer_size; |
| 86 | int descramble; | ||
| 87 | 81 | ||
| 88 | struct timespec timeout; | 82 | struct timespec timeout; |
| 89 | struct dvb_demux_filter *filter; | 83 | struct dvb_demux_filter *filter; |
| 90 | int cb_length; | ||
| 91 | 84 | ||
| 92 | int ts_type; | 85 | int ts_type; |
| 93 | enum dmx_ts_pes pes_type; | 86 | enum dmx_ts_pes pes_type; |
| 94 | 87 | ||
| 95 | int cc; | 88 | int cc; |
| 96 | int pusi_seen; /* prevents feeding of garbage from previous section */ | 89 | int pusi_seen; /* prevents feeding of garbage from previous section */ |
| 97 | 90 | ||
| 98 | u16 peslen; | 91 | u16 peslen; |
| 99 | 92 | ||
| 100 | struct list_head list_head; | 93 | struct list_head list_head; |
| 101 | int index; /* a unique index for each feed (can be used as hardware pid filter index) */ | 94 | unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */ |
| 102 | }; | 95 | }; |
| 103 | 96 | ||
| 104 | struct dvb_demux { | 97 | struct dvb_demux { |
| 105 | struct dmx_demux dmx; | 98 | struct dmx_demux dmx; |
| 106 | void *priv; | 99 | void *priv; |
| 107 | int filternum; | 100 | int filternum; |
| 108 | int feednum; | 101 | int feednum; |
| 109 | int (*start_feed) (struct dvb_demux_feed *feed); | 102 | int (*start_feed)(struct dvb_demux_feed *feed); |
| 110 | int (*stop_feed) (struct dvb_demux_feed *feed); | 103 | int (*stop_feed)(struct dvb_demux_feed *feed); |
| 111 | int (*write_to_decoder) (struct dvb_demux_feed *feed, | 104 | int (*write_to_decoder)(struct dvb_demux_feed *feed, |
| 112 | const u8 *buf, size_t len); | 105 | const u8 *buf, size_t len); |
| 113 | u32 (*check_crc32) (struct dvb_demux_feed *feed, | 106 | u32 (*check_crc32)(struct dvb_demux_feed *feed, |
| 114 | const u8 *buf, size_t len); | 107 | const u8 *buf, size_t len); |
| 115 | void (*memcopy) (struct dvb_demux_feed *feed, u8 *dst, | 108 | void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst, |
| 116 | const u8 *src, size_t len); | 109 | const u8 *src, size_t len); |
| 117 | 110 | ||
| 118 | int users; | 111 | int users; |
| 119 | #define MAX_DVB_DEMUX_USERS 10 | 112 | #define MAX_DVB_DEMUX_USERS 10 |
| 120 | struct dvb_demux_filter *filter; | 113 | struct dvb_demux_filter *filter; |
| 121 | struct dvb_demux_feed *feed; | 114 | struct dvb_demux_feed *feed; |
| 122 | 115 | ||
| 123 | struct list_head frontend_list; | 116 | struct list_head frontend_list; |
| 124 | 117 | ||
| 125 | struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER]; | 118 | struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER]; |
| 126 | u16 pids[DMX_TS_PES_OTHER]; | 119 | u16 pids[DMX_TS_PES_OTHER]; |
| 127 | int playing; | 120 | int playing; |
| 128 | int recording; | 121 | int recording; |
| 129 | 122 | ||
| 130 | #define DMX_MAX_PID 0x2000 | 123 | #define DMX_MAX_PID 0x2000 |
| 131 | struct list_head feed_list; | 124 | struct list_head feed_list; |
| 132 | u8 tsbuf[204]; | 125 | u8 tsbuf[204]; |
| 133 | int tsbufp; | 126 | int tsbufp; |
| 134 | 127 | ||
| 135 | struct semaphore mutex; | 128 | struct semaphore mutex; |
| 136 | spinlock_t lock; | 129 | spinlock_t lock; |
| 137 | }; | 130 | }; |
| 138 | 131 | ||
| 139 | |||
| 140 | int dvb_dmx_init(struct dvb_demux *dvbdemux); | 132 | int dvb_dmx_init(struct dvb_demux *dvbdemux); |
| 141 | int dvb_dmx_release(struct dvb_demux *dvbdemux); | 133 | void dvb_dmx_release(struct dvb_demux *dvbdemux); |
| 142 | void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, size_t count); | 134 | void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf, |
| 135 | size_t count); | ||
| 143 | void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); | 136 | void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count); |
| 144 | void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count); | 137 | void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, |
| 138 | size_t count); | ||
| 145 | 139 | ||
| 146 | #endif /* _DVB_DEMUX_H_ */ | 140 | #endif /* _DVB_DEMUX_H_ */ |
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 6a968c346a36..87935490bfb2 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c | |||
| @@ -62,7 +62,6 @@ | |||
| 62 | #include <linux/uio.h> | 62 | #include <linux/uio.h> |
| 63 | #include <asm/uaccess.h> | 63 | #include <asm/uaccess.h> |
| 64 | #include <linux/crc32.h> | 64 | #include <linux/crc32.h> |
| 65 | #include <linux/version.h> | ||
| 66 | 65 | ||
| 67 | #include "dvb_demux.h" | 66 | #include "dvb_demux.h" |
| 68 | #include "dvb_net.h" | 67 | #include "dvb_net.h" |
| @@ -171,11 +170,7 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, | |||
| 171 | 170 | ||
| 172 | skb->mac.raw=skb->data; | 171 | skb->mac.raw=skb->data; |
| 173 | skb_pull(skb,dev->hard_header_len); | 172 | skb_pull(skb,dev->hard_header_len); |
| 174 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,8) | ||
| 175 | eth = skb->mac.ethernet; | ||
| 176 | #else | ||
| 177 | eth = eth_hdr(skb); | 173 | eth = eth_hdr(skb); |
| 178 | #endif | ||
| 179 | 174 | ||
| 180 | if (*eth->h_dest & 1) { | 175 | if (*eth->h_dest & 1) { |
| 181 | if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) | 176 | if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) |
| @@ -908,7 +903,7 @@ static int dvb_net_feed_start(struct net_device *dev) | |||
| 908 | return ret; | 903 | return ret; |
| 909 | } | 904 | } |
| 910 | 905 | ||
| 911 | ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 0, 1); | 906 | ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1); |
| 912 | 907 | ||
| 913 | if (ret<0) { | 908 | if (ret<0) { |
| 914 | printk("%s: could not set section feed\n", dev->name); | 909 | printk("%s: could not set section feed\n", dev->name); |
| @@ -960,9 +955,7 @@ static int dvb_net_feed_start(struct net_device *dev) | |||
| 960 | priv->tsfeed->priv = (void *)dev; | 955 | priv->tsfeed->priv = (void *)dev; |
| 961 | ret = priv->tsfeed->set(priv->tsfeed, priv->pid, | 956 | ret = priv->tsfeed->set(priv->tsfeed, priv->pid, |
| 962 | TS_PACKET, DMX_TS_PES_OTHER, | 957 | TS_PACKET, DMX_TS_PES_OTHER, |
| 963 | 188 * 100, /* nr. of bytes delivered per callback */ | ||
| 964 | 32768, /* circular buffer size */ | 958 | 32768, /* circular buffer size */ |
| 965 | 0, /* descramble */ | ||
| 966 | timeout); | 959 | timeout); |
| 967 | 960 | ||
| 968 | if (ret < 0) { | 961 | if (ret < 0) { |
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index 612e5b087b1c..54e2b29076b1 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
| @@ -93,13 +93,30 @@ config DVB_USB_DIGITV | |||
| 93 | Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver. | 93 | Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver. |
| 94 | 94 | ||
| 95 | config DVB_USB_VP7045 | 95 | config DVB_USB_VP7045 |
| 96 | tristate "TwinhanDTV Alpha/MagicBoxII and DNTV tinyUSB2 DVB-T USB2.0 support" | 96 | tristate "TwinhanDTV Alpha/MagicBoxII, DNTV tinyUSB2, Beetle USB2.0 support" |
| 97 | depends on DVB_USB | 97 | depends on DVB_USB |
| 98 | help | 98 | help |
| 99 | Say Y here to support the | 99 | Say Y here to support the |
| 100 | |||
| 100 | TwinhanDTV Alpha (stick) (VP-7045), | 101 | TwinhanDTV Alpha (stick) (VP-7045), |
| 101 | TwinhanDTV MagicBox II (VP-7046) and | 102 | TwinhanDTV MagicBox II (VP-7046), |
| 102 | DigitalNow TinyUSB 2 DVB-t DVB-T USB2.0 receivers. | 103 | DigitalNow TinyUSB 2 DVB-t, |
| 104 | DigitalRise USB 2.0 Ter (Beetle) and | ||
| 105 | TYPHOON DVB-T USB DRIVE | ||
| 106 | |||
| 107 | DVB-T USB2.0 receivers. | ||
| 108 | |||
| 109 | config DVB_USB_VP702X | ||
| 110 | tristate "TwinhanDTV StarBox and clones DVB-S USB2.0 support" | ||
| 111 | depends on DVB_USB | ||
| 112 | help | ||
| 113 | Say Y here to support the | ||
| 114 | |||
| 115 | TwinhanDTV StarBox, | ||
| 116 | DigitalRise USB Starbox and | ||
| 117 | TYPHOON DVB-S USB 2.0 BOX | ||
| 118 | |||
| 119 | DVB-S USB2.0 receivers. | ||
| 103 | 120 | ||
| 104 | config DVB_USB_NOVA_T_USB2 | 121 | config DVB_USB_NOVA_T_USB2 |
| 105 | tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" | 122 | tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" |
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index 746d87ed6f32..2dc9aad9681e 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile | |||
| @@ -4,6 +4,9 @@ obj-$(CONFIG_DVB_USB) += dvb-usb.o | |||
| 4 | dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o | 4 | dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o |
| 5 | obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o | 5 | obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o |
| 6 | 6 | ||
| 7 | dvb-usb-vp702x-objs = vp702x.o vp702x-fe.o | ||
| 8 | obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o | ||
| 9 | |||
| 7 | dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o | 10 | dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o |
| 8 | obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o | 11 | obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o |
| 9 | 12 | ||
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index f2fcc2f1f846..e55322ef76b3 100644 --- a/drivers/media/dvb/dvb-usb/a800.c +++ b/drivers/media/dvb/dvb-usb/a800.c | |||
| @@ -90,7 +90,7 @@ static struct dvb_usb_properties a800_properties; | |||
| 90 | static int a800_probe(struct usb_interface *intf, | 90 | static int a800_probe(struct usb_interface *intf, |
| 91 | const struct usb_device_id *id) | 91 | const struct usb_device_id *id) |
| 92 | { | 92 | { |
| 93 | return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE); | 93 | return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE,NULL); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /* do not change the order of the ID table */ | 96 | /* do not change the order of the ID table */ |
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 9e96a188f1e9..3fe383f4bb4c 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c | |||
| @@ -48,35 +48,26 @@ static int cxusb_ctrl_msg(struct dvb_usb_device *d, | |||
| 48 | return 0; | 48 | return 0; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | /* I2C */ | 51 | /* GPIO */ |
| 52 | static void cxusb_set_i2c_path(struct dvb_usb_device *d, enum cxusb_i2c_pathes path) | 52 | static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff) |
| 53 | { | 53 | { |
| 54 | struct cxusb_state *st = d->priv; | 54 | struct cxusb_state *st = d->priv; |
| 55 | u8 o[2],i; | 55 | u8 o[2],i; |
| 56 | 56 | ||
| 57 | if (path == st->cur_i2c_path) | 57 | if (st->gpio_write_state[GPIO_TUNER] == onoff) |
| 58 | return; | 58 | return; |
| 59 | 59 | ||
| 60 | o[0] = IOCTL_SET_I2C_PATH; | 60 | o[0] = GPIO_TUNER; |
| 61 | switch (path) { | 61 | o[1] = onoff; |
| 62 | case PATH_CX22702: | 62 | cxusb_ctrl_msg(d,CMD_GPIO_WRITE,o,2,&i,1); |
| 63 | o[1] = 0; | ||
| 64 | break; | ||
| 65 | case PATH_TUNER_OTHER: | ||
| 66 | o[1] = 1; | ||
| 67 | break; | ||
| 68 | default: | ||
| 69 | err("unkown i2c path"); | ||
| 70 | return; | ||
| 71 | } | ||
| 72 | cxusb_ctrl_msg(d,CMD_IOCTL,o,2,&i,1); | ||
| 73 | 63 | ||
| 74 | if (i != 0x01) | 64 | if (i != 0x01) |
| 75 | deb_info("i2c_path setting failed.\n"); | 65 | deb_info("gpio_write failed.\n"); |
| 76 | 66 | ||
| 77 | st->cur_i2c_path = path; | 67 | st->gpio_write_state[GPIO_TUNER] = onoff; |
| 78 | } | 68 | } |
| 79 | 69 | ||
| 70 | /* I2C */ | ||
| 80 | static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) | 71 | static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) |
| 81 | { | 72 | { |
| 82 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | 73 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
| @@ -92,10 +83,10 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num) | |||
| 92 | 83 | ||
| 93 | switch (msg[i].addr) { | 84 | switch (msg[i].addr) { |
| 94 | case 0x63: | 85 | case 0x63: |
| 95 | cxusb_set_i2c_path(d,PATH_CX22702); | 86 | cxusb_gpio_tuner(d,0); |
| 96 | break; | 87 | break; |
| 97 | default: | 88 | default: |
| 98 | cxusb_set_i2c_path(d,PATH_TUNER_OTHER); | 89 | cxusb_gpio_tuner(d,1); |
| 99 | break; | 90 | break; |
| 100 | } | 91 | } |
| 101 | 92 | ||
| @@ -147,16 +138,20 @@ static struct i2c_algorithm cxusb_i2c_algo = { | |||
| 147 | 138 | ||
| 148 | static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff) | 139 | static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff) |
| 149 | { | 140 | { |
| 150 | return 0; | 141 | u8 b = 0; |
| 142 | if (onoff) | ||
| 143 | return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0); | ||
| 144 | else | ||
| 145 | return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0); | ||
| 151 | } | 146 | } |
| 152 | 147 | ||
| 153 | static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) | 148 | static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) |
| 154 | { | 149 | { |
| 155 | u8 buf[2] = { 0x03, 0x00 }; | 150 | u8 buf[2] = { 0x03, 0x00 }; |
| 156 | if (onoff) | 151 | if (onoff) |
| 157 | cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0); | 152 | cxusb_ctrl_msg(d,CMD_STREAMING_ON, buf, 2, NULL, 0); |
| 158 | else | 153 | else |
| 159 | cxusb_ctrl_msg(d,0x37, NULL, 0, NULL, 0); | 154 | cxusb_ctrl_msg(d,CMD_STREAMING_OFF, NULL, 0, NULL, 0); |
| 160 | 155 | ||
| 161 | return 0; | 156 | return 0; |
| 162 | } | 157 | } |
| @@ -182,22 +177,11 @@ static int cxusb_tuner_attach(struct dvb_usb_device *d) | |||
| 182 | 177 | ||
| 183 | static int cxusb_frontend_attach(struct dvb_usb_device *d) | 178 | static int cxusb_frontend_attach(struct dvb_usb_device *d) |
| 184 | { | 179 | { |
| 185 | u8 buf[2] = { 0x03, 0x00 }; | 180 | u8 b; |
| 186 | u8 b = 0; | ||
| 187 | |||
| 188 | if (usb_set_interface(d->udev,0,0) < 0) | ||
| 189 | err("set interface to alts=0 failed"); | ||
| 190 | |||
| 191 | cxusb_ctrl_msg(d,0xde,&b,0,NULL,0); | ||
| 192 | cxusb_set_i2c_path(d,PATH_TUNER_OTHER); | ||
| 193 | cxusb_ctrl_msg(d,CMD_POWER_OFF, NULL, 0, &b, 1); | ||
| 194 | |||
| 195 | if (usb_set_interface(d->udev,0,6) < 0) | 181 | if (usb_set_interface(d->udev,0,6) < 0) |
| 196 | err("set interface failed"); | 182 | err("set interface failed"); |
| 197 | 183 | ||
| 198 | cxusb_ctrl_msg(d,0x36, buf, 2, NULL, 0); | 184 | cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1); |
| 199 | cxusb_set_i2c_path(d,PATH_CX22702); | ||
| 200 | cxusb_ctrl_msg(d,CMD_POWER_ON, NULL, 0, &b, 1); | ||
| 201 | 185 | ||
| 202 | if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL) | 186 | if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL) |
| 203 | return 0; | 187 | return 0; |
| @@ -211,7 +195,7 @@ static struct dvb_usb_properties cxusb_properties; | |||
| 211 | static int cxusb_probe(struct usb_interface *intf, | 195 | static int cxusb_probe(struct usb_interface *intf, |
| 212 | const struct usb_device_id *id) | 196 | const struct usb_device_id *id) |
| 213 | { | 197 | { |
| 214 | return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE); | 198 | return dvb_usb_device_init(intf,&cxusb_properties,THIS_MODULE,NULL); |
| 215 | } | 199 | } |
| 216 | 200 | ||
| 217 | static struct usb_device_id cxusb_table [] = { | 201 | static struct usb_device_id cxusb_table [] = { |
| @@ -237,14 +221,12 @@ static struct dvb_usb_properties cxusb_properties = { | |||
| 237 | .generic_bulk_ctrl_endpoint = 0x01, | 221 | .generic_bulk_ctrl_endpoint = 0x01, |
| 238 | /* parameter for the MPEG2-data transfer */ | 222 | /* parameter for the MPEG2-data transfer */ |
| 239 | .urb = { | 223 | .urb = { |
| 240 | .type = DVB_USB_ISOC, | 224 | .type = DVB_USB_BULK, |
| 241 | .count = 5, | 225 | .count = 5, |
| 242 | .endpoint = 0x02, | 226 | .endpoint = 0x02, |
| 243 | .u = { | 227 | .u = { |
| 244 | .isoc = { | 228 | .bulk = { |
| 245 | .framesperurb = 32, | 229 | .buffersize = 8192, |
| 246 | .framesize = 940, | ||
| 247 | .interval = 5, | ||
| 248 | } | 230 | } |
| 249 | } | 231 | } |
| 250 | }, | 232 | }, |
diff --git a/drivers/media/dvb/dvb-usb/cxusb.h b/drivers/media/dvb/dvb-usb/cxusb.h index 1d79016e3195..135c2a81f581 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.h +++ b/drivers/media/dvb/dvb-usb/cxusb.h | |||
| @@ -1,30 +1,31 @@ | |||
| 1 | #ifndef _DVB_USB_CXUSB_H_ | 1 | #ifndef _DVB_USB_CXUSB_H_ |
| 2 | #define _DVB_USB_CXUSB_H_ | 2 | #define _DVB_USB_CXUSB_H_ |
| 3 | 3 | ||
| 4 | #define DVB_USB_LOG_PREFIX "digitv" | 4 | #define DVB_USB_LOG_PREFIX "cxusb" |
| 5 | #include "dvb-usb.h" | 5 | #include "dvb-usb.h" |
| 6 | 6 | ||
| 7 | extern int dvb_usb_cxusb_debug; | 7 | extern int dvb_usb_cxusb_debug; |
| 8 | #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args) | 8 | #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args) |
| 9 | 9 | ||
| 10 | /* usb commands - some of it are guesses, don't have a reference yet */ | 10 | /* usb commands - some of it are guesses, don't have a reference yet */ |
| 11 | #define CMD_I2C_WRITE 0x08 | 11 | #define CMD_I2C_WRITE 0x08 |
| 12 | #define CMD_I2C_READ 0x09 | 12 | #define CMD_I2C_READ 0x09 |
| 13 | 13 | ||
| 14 | #define CMD_IOCTL 0x0e | 14 | #define CMD_GPIO_READ 0x0d |
| 15 | #define IOCTL_SET_I2C_PATH 0x02 | 15 | #define CMD_GPIO_WRITE 0x0e |
| 16 | #define GPIO_TUNER 0x02 | ||
| 16 | 17 | ||
| 17 | #define CMD_POWER_OFF 0x50 | 18 | #define CMD_POWER_OFF 0xdc |
| 18 | #define CMD_POWER_ON 0x51 | 19 | #define CMD_POWER_ON 0xde |
| 19 | 20 | ||
| 20 | enum cxusb_i2c_pathes { | 21 | #define CMD_STREAMING_ON 0x36 |
| 21 | PATH_UNDEF = 0x00, | 22 | #define CMD_STREAMING_OFF 0x37 |
| 22 | PATH_CX22702 = 0x01, | 23 | |
| 23 | PATH_TUNER_OTHER = 0x02, | 24 | #define CMD_ANALOG 0x50 |
| 24 | }; | 25 | #define CMD_DIGITAL 0x51 |
| 25 | 26 | ||
| 26 | struct cxusb_state { | 27 | struct cxusb_state { |
| 27 | enum cxusb_i2c_pathes cur_i2c_path; | 28 | u8 gpio_write_state[3]; |
| 28 | }; | 29 | }; |
| 29 | 30 | ||
| 30 | #endif | 31 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index 828b5182e16c..0058505634a0 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c | |||
| @@ -86,9 +86,9 @@ static struct dvb_usb_properties dibusb2_0b_properties; | |||
| 86 | static int dibusb_probe(struct usb_interface *intf, | 86 | static int dibusb_probe(struct usb_interface *intf, |
| 87 | const struct usb_device_id *id) | 87 | const struct usb_device_id *id) |
| 88 | { | 88 | { |
| 89 | if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE) == 0 || | 89 | if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE,NULL) == 0 || |
| 90 | dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE) == 0 || | 90 | dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE,NULL) == 0 || |
| 91 | dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE) == 0) | 91 | dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE,NULL) == 0) |
| 92 | return 0; | 92 | return 0; |
| 93 | 93 | ||
| 94 | return -EINVAL; | 94 | return -EINVAL; |
| @@ -126,10 +126,12 @@ static struct usb_device_id dibusb_dib3000mb_table [] = { | |||
| 126 | /* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) }, | 126 | /* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) }, |
| 127 | /* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) }, | 127 | /* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) }, |
| 128 | 128 | ||
| 129 | /* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) }, | ||
| 130 | |||
| 129 | // #define DVB_USB_DIBUSB_MB_FAULTY_USB_IDs | 131 | // #define DVB_USB_DIBUSB_MB_FAULTY_USB_IDs |
| 130 | 132 | ||
| 131 | #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs | 133 | #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs |
| 132 | /* 27 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, | 134 | /* 28 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) }, |
| 133 | #endif | 135 | #endif |
| 134 | { } /* Terminating entry */ | 136 | { } /* Terminating entry */ |
| 135 | }; | 137 | }; |
| @@ -262,7 +264,7 @@ static struct dvb_usb_properties dibusb1_1_an2235_properties = { | |||
| 262 | }, | 264 | }, |
| 263 | #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs | 265 | #ifdef DVB_USB_DIBUSB_MB_FAULTY_USB_IDs |
| 264 | { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)", | 266 | { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)", |
| 265 | { &dibusb_dib3000mb_table[27], NULL }, | 267 | { &dibusb_dib3000mb_table[28], NULL }, |
| 266 | { NULL }, | 268 | { NULL }, |
| 267 | }, | 269 | }, |
| 268 | #endif | 270 | #endif |
| @@ -306,12 +308,16 @@ static struct dvb_usb_properties dibusb2_0b_properties = { | |||
| 306 | } | 308 | } |
| 307 | }, | 309 | }, |
| 308 | 310 | ||
| 309 | .num_device_descs = 1, | 311 | .num_device_descs = 2, |
| 310 | .devices = { | 312 | .devices = { |
| 311 | { "KWorld/ADSTech Instant DVB-T USB 2.0", | 313 | { "KWorld/ADSTech Instant DVB-T USB2.0", |
| 312 | { &dibusb_dib3000mb_table[23], NULL }, | 314 | { &dibusb_dib3000mb_table[23], NULL }, |
| 313 | { &dibusb_dib3000mb_table[24], NULL }, | 315 | { &dibusb_dib3000mb_table[24], NULL }, |
| 314 | }, | 316 | }, |
| 317 | { "KWorld Xpert DVB-T USB2.0", | ||
| 318 | { &dibusb_dib3000mb_table[27], NULL }, | ||
| 319 | { NULL } | ||
| 320 | }, | ||
| 315 | } | 321 | } |
| 316 | }; | 322 | }; |
| 317 | 323 | ||
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c index e9dac430f37d..6a0912eab396 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c | |||
| @@ -20,7 +20,7 @@ static struct dvb_usb_properties dibusb_mc_properties; | |||
| 20 | static int dibusb_mc_probe(struct usb_interface *intf, | 20 | static int dibusb_mc_probe(struct usb_interface *intf, |
| 21 | const struct usb_device_id *id) | 21 | const struct usb_device_id *id) |
| 22 | { | 22 | { |
| 23 | return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE); | 23 | return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE,NULL); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | /* do not change the order of the ID table */ | 26 | /* do not change the order of the ID table */ |
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index f70e0be0920a..74545f82eff1 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c | |||
| @@ -111,31 +111,28 @@ static int digitv_mt352_demod_init(struct dvb_frontend *fe) | |||
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | static struct mt352_config digitv_mt352_config = { | 113 | static struct mt352_config digitv_mt352_config = { |
| 114 | .demod_address = 0x0, /* ignored by the digitv anyway */ | ||
| 115 | .demod_init = digitv_mt352_demod_init, | 114 | .demod_init = digitv_mt352_demod_init, |
| 116 | .pll_set = dvb_usb_pll_set, | 115 | .pll_set = dvb_usb_pll_set, |
| 117 | }; | 116 | }; |
| 118 | 117 | ||
| 119 | static struct nxt6000_config digitv_nxt6000_config = { | 118 | static int digitv_nxt6000_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) |
| 120 | .demod_address = 0x0, /* ignored by the digitv anyway */ | 119 | { |
| 121 | .clock_inversion = 0x0, | 120 | struct dvb_usb_device *d = fe->dvb->priv; |
| 121 | u8 b[5]; | ||
| 122 | dvb_usb_pll_set(fe,fep,b); | ||
| 123 | return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0); | ||
| 124 | } | ||
| 122 | 125 | ||
| 123 | .pll_init = NULL, | 126 | static struct nxt6000_config digitv_nxt6000_config = { |
| 124 | .pll_set = NULL, | 127 | .clock_inversion = 1, |
| 128 | .pll_set = digitv_nxt6000_pll_set, | ||
| 125 | }; | 129 | }; |
| 126 | 130 | ||
| 127 | static int digitv_frontend_attach(struct dvb_usb_device *d) | 131 | static int digitv_frontend_attach(struct dvb_usb_device *d) |
| 128 | { | 132 | { |
| 129 | if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) | 133 | if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL || |
| 134 | (d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) | ||
| 130 | return 0; | 135 | return 0; |
| 131 | if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) { | ||
| 132 | |||
| 133 | warn("nxt6000 support is not done yet, in fact you are one of the first " | ||
| 134 | "person who wants to use this device in Linux. Please report to " | ||
| 135 | "linux-dvb@linuxtv.org"); | ||
| 136 | |||
| 137 | return 0; | ||
| 138 | } | ||
| 139 | return -EIO; | 136 | return -EIO; |
| 140 | } | 137 | } |
| 141 | 138 | ||
| @@ -173,7 +170,18 @@ static struct dvb_usb_properties digitv_properties; | |||
| 173 | static int digitv_probe(struct usb_interface *intf, | 170 | static int digitv_probe(struct usb_interface *intf, |
| 174 | const struct usb_device_id *id) | 171 | const struct usb_device_id *id) |
| 175 | { | 172 | { |
| 176 | return dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE); | 173 | struct dvb_usb_device *d; |
| 174 | int ret; | ||
| 175 | if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) { | ||
| 176 | u8 b[4] = { 0 }; | ||
| 177 | |||
| 178 | b[0] = 1; | ||
| 179 | digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0); | ||
| 180 | |||
| 181 | b[0] = 0; | ||
| 182 | digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); | ||
| 183 | } | ||
| 184 | return ret; | ||
| 177 | } | 185 | } |
| 178 | 186 | ||
| 179 | static struct usb_device_id digitv_table [] = { | 187 | static struct usb_device_id digitv_table [] = { |
diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c index b032523b07bc..0a94ec22aeb8 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u-fe.c +++ b/drivers/media/dvb/dvb-usb/dtt200u-fe.c | |||
| @@ -18,6 +18,7 @@ struct dtt200u_fe_state { | |||
| 18 | 18 | ||
| 19 | struct dvb_frontend_parameters fep; | 19 | struct dvb_frontend_parameters fep; |
| 20 | struct dvb_frontend frontend; | 20 | struct dvb_frontend frontend; |
| 21 | struct dvb_frontend_ops ops; | ||
| 21 | }; | 22 | }; |
| 22 | 23 | ||
| 23 | static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat) | 24 | static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat) |
| @@ -163,8 +164,9 @@ struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d) | |||
| 163 | deb_info("attaching frontend dtt200u\n"); | 164 | deb_info("attaching frontend dtt200u\n"); |
| 164 | 165 | ||
| 165 | state->d = d; | 166 | state->d = d; |
| 167 | memcpy(&state->ops,&dtt200u_fe_ops,sizeof(struct dvb_frontend_ops)); | ||
| 166 | 168 | ||
| 167 | state->frontend.ops = &dtt200u_fe_ops; | 169 | state->frontend.ops = &state->ops; |
| 168 | state->frontend.demodulator_priv = state; | 170 | state->frontend.demodulator_priv = state; |
| 169 | 171 | ||
| 170 | goto success; | 172 | goto success; |
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 47dba6e45968..5aa12ebab34f 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c | |||
| @@ -98,20 +98,19 @@ static struct dvb_usb_properties wt220u_properties; | |||
| 98 | static int dtt200u_usb_probe(struct usb_interface *intf, | 98 | static int dtt200u_usb_probe(struct usb_interface *intf, |
| 99 | const struct usb_device_id *id) | 99 | const struct usb_device_id *id) |
| 100 | { | 100 | { |
| 101 | if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE) == 0 || | 101 | if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 || |
| 102 | dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE) == 0) | 102 | dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0) |
| 103 | return 0; | 103 | return 0; |
| 104 | 104 | ||
| 105 | return -ENODEV; | 105 | return -ENODEV; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | static struct usb_device_id dtt200u_usb_table [] = { | 108 | static struct usb_device_id dtt200u_usb_table [] = { |
| 109 | // { USB_DEVICE(0x04b4,0x8613) }, | 109 | { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) }, |
| 110 | { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) }, | 110 | { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, |
| 111 | { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) }, | 111 | { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, |
| 112 | { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) }, | 112 | { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, |
| 113 | { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) }, | 113 | { 0 }, |
| 114 | { 0 }, | ||
| 115 | }; | 114 | }; |
| 116 | MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); | 115 | MODULE_DEVICE_TABLE(usb, dtt200u_usb_table); |
| 117 | 116 | ||
| @@ -189,7 +188,7 @@ static struct dvb_usb_properties wt220u_properties = { | |||
| 189 | 188 | ||
| 190 | .num_device_descs = 1, | 189 | .num_device_descs = 1, |
| 191 | .devices = { | 190 | .devices = { |
| 192 | { .name = "WideView WT-220U PenType Receiver (and clones)", | 191 | { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)", |
| 193 | .cold_ids = { &dtt200u_usb_table[2], NULL }, | 192 | .cold_ids = { &dtt200u_usb_table[2], NULL }, |
| 194 | .warm_ids = { &dtt200u_usb_table[3], NULL }, | 193 | .warm_ids = { &dtt200u_usb_table[3], NULL }, |
| 195 | }, | 194 | }, |
| @@ -201,9 +200,9 @@ static struct dvb_usb_properties wt220u_properties = { | |||
| 201 | static struct usb_driver dtt200u_usb_driver = { | 200 | static struct usb_driver dtt200u_usb_driver = { |
| 202 | .owner = THIS_MODULE, | 201 | .owner = THIS_MODULE, |
| 203 | .name = "dvb_usb_dtt200u", | 202 | .name = "dvb_usb_dtt200u", |
| 204 | .probe = dtt200u_usb_probe, | 203 | .probe = dtt200u_usb_probe, |
| 205 | .disconnect = dvb_usb_device_exit, | 204 | .disconnect = dvb_usb_device_exit, |
| 206 | .id_table = dtt200u_usb_table, | 205 | .id_table = dtt200u_usb_table, |
| 207 | }; | 206 | }; |
| 208 | 207 | ||
| 209 | /* module stuff */ | 208 | /* module stuff */ |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 794d513a8480..0818996bf150 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
| @@ -24,8 +24,10 @@ | |||
| 24 | #define USB_VID_HANFTEK 0x15f4 | 24 | #define USB_VID_HANFTEK 0x15f4 |
| 25 | #define USB_VID_HAUPPAUGE 0x2040 | 25 | #define USB_VID_HAUPPAUGE 0x2040 |
| 26 | #define USB_VID_HYPER_PALTEK 0x1025 | 26 | #define USB_VID_HYPER_PALTEK 0x1025 |
| 27 | #define USB_VID_KWORLD 0xeb2a | ||
| 27 | #define USB_VID_KYE 0x0458 | 28 | #define USB_VID_KYE 0x0458 |
| 28 | #define USB_VID_MEDION 0x1660 | 29 | #define USB_VID_MEDION 0x1660 |
| 30 | #define USB_VID_PINNACLE 0x2304 | ||
| 29 | #define USB_VID_VISIONPLUS 0x13d3 | 31 | #define USB_VID_VISIONPLUS 0x13d3 |
| 30 | #define USB_VID_TWINHAN 0x1822 | 32 | #define USB_VID_TWINHAN 0x1822 |
| 31 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 | 33 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 |
| @@ -52,12 +54,14 @@ | |||
| 52 | #define USB_PID_KWORLD_VSTREAM_WARM 0x17df | 54 | #define USB_PID_KWORLD_VSTREAM_WARM 0x17df |
| 53 | #define USB_PID_TWINHAN_VP7041_COLD 0x3201 | 55 | #define USB_PID_TWINHAN_VP7041_COLD 0x3201 |
| 54 | #define USB_PID_TWINHAN_VP7041_WARM 0x3202 | 56 | #define USB_PID_TWINHAN_VP7041_WARM 0x3202 |
| 57 | #define USB_PID_TWINHAN_VP7020_COLD 0x3203 | ||
| 58 | #define USB_PID_TWINHAN_VP7020_WARM 0x3204 | ||
| 55 | #define USB_PID_TWINHAN_VP7045_COLD 0x3205 | 59 | #define USB_PID_TWINHAN_VP7045_COLD 0x3205 |
| 56 | #define USB_PID_TWINHAN_VP7045_WARM 0x3206 | 60 | #define USB_PID_TWINHAN_VP7045_WARM 0x3206 |
| 57 | #define USB_PID_DNTV_TINYUSB2_COLD 0x3223 | ||
| 58 | #define USB_PID_DNTV_TINYUSB2_WARM 0x3224 | ||
| 59 | #define USB_PID_TWINHAN_VP7021_COLD 0x3207 | 61 | #define USB_PID_TWINHAN_VP7021_COLD 0x3207 |
| 60 | #define USB_PID_TWINHAN_VP7021_WARM 0x3208 | 62 | #define USB_PID_TWINHAN_VP7021_WARM 0x3208 |
| 63 | #define USB_PID_DNTV_TINYUSB2_COLD 0x3223 | ||
| 64 | #define USB_PID_DNTV_TINYUSB2_WARM 0x3224 | ||
| 61 | #define USB_PID_ULTIMA_TVBOX_COLD 0x8105 | 65 | #define USB_PID_ULTIMA_TVBOX_COLD 0x8105 |
| 62 | #define USB_PID_ULTIMA_TVBOX_WARM 0x8106 | 66 | #define USB_PID_ULTIMA_TVBOX_WARM 0x8106 |
| 63 | #define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107 | 67 | #define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107 |
| @@ -85,5 +89,7 @@ | |||
| 85 | #define USB_PID_MEDION_MD95700 0x0932 | 89 | #define USB_PID_MEDION_MD95700 0x0932 |
| 86 | #define USB_PID_KYE_DVB_T_COLD 0x701e | 90 | #define USB_PID_KYE_DVB_T_COLD 0x701e |
| 87 | #define USB_PID_KYE_DVB_T_WARM 0x701f | 91 | #define USB_PID_KYE_DVB_T_WARM 0x701f |
| 92 | #define USB_PID_PCTV_200E 0x020e | ||
| 93 | #define USB_PID_PCTV_400E 0x020f | ||
| 88 | 94 | ||
| 89 | #endif | 95 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index 65f0c095abc9..a902059812a2 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c | |||
| @@ -128,7 +128,9 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device | |||
| 128 | /* | 128 | /* |
| 129 | * USB | 129 | * USB |
| 130 | */ | 130 | */ |
| 131 | int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *props, struct module *owner) | 131 | |
| 132 | int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties | ||
| 133 | *props, struct module *owner,struct dvb_usb_device **du) | ||
| 132 | { | 134 | { |
| 133 | struct usb_device *udev = interface_to_usbdev(intf); | 135 | struct usb_device *udev = interface_to_usbdev(intf); |
| 134 | struct dvb_usb_device *d = NULL; | 136 | struct dvb_usb_device *d = NULL; |
| @@ -170,6 +172,9 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties *p | |||
| 170 | 172 | ||
| 171 | usb_set_intfdata(intf, d); | 173 | usb_set_intfdata(intf, d); |
| 172 | 174 | ||
| 175 | if (du != NULL) | ||
| 176 | *du = d; | ||
| 177 | |||
| 173 | ret = dvb_usb_init(d); | 178 | ret = dvb_usb_init(d); |
| 174 | } | 179 | } |
| 175 | 180 | ||
| @@ -196,19 +201,6 @@ void dvb_usb_device_exit(struct usb_interface *intf) | |||
| 196 | } | 201 | } |
| 197 | EXPORT_SYMBOL(dvb_usb_device_exit); | 202 | EXPORT_SYMBOL(dvb_usb_device_exit); |
| 198 | 203 | ||
| 199 | /* module stuff */ | ||
| 200 | static int __init dvb_usb_module_init(void) | ||
| 201 | { | ||
| 202 | return 0; | ||
| 203 | } | ||
| 204 | |||
| 205 | static void __exit dvb_usb_module_exit(void) | ||
| 206 | { | ||
| 207 | } | ||
| 208 | |||
| 209 | module_init (dvb_usb_module_init); | ||
| 210 | module_exit (dvb_usb_module_exit); | ||
| 211 | |||
| 212 | MODULE_VERSION("0.3"); | 204 | MODULE_VERSION("0.3"); |
| 213 | MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); | 205 | MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); |
| 214 | MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); | 206 | MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index a80567caf508..0e4f1035b0dd 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h | |||
| @@ -127,7 +127,7 @@ struct dvb_usb_device; | |||
| 127 | * helper functions. | 127 | * helper functions. |
| 128 | * | 128 | * |
| 129 | * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming. | 129 | * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming. |
| 130 | * Currently only BULK is implemented | 130 | * (BULK or ISOC) |
| 131 | * | 131 | * |
| 132 | * @num_device_descs: number of struct dvb_usb_device_description in @devices | 132 | * @num_device_descs: number of struct dvb_usb_device_description in @devices |
| 133 | * @devices: array of struct dvb_usb_device_description compatibles with these | 133 | * @devices: array of struct dvb_usb_device_description compatibles with these |
| @@ -310,7 +310,7 @@ struct dvb_usb_device { | |||
| 310 | void *priv; | 310 | void *priv; |
| 311 | }; | 311 | }; |
| 312 | 312 | ||
| 313 | extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *); | 313 | extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **); |
| 314 | extern void dvb_usb_device_exit(struct usb_interface *); | 314 | extern void dvb_usb_device_exit(struct usb_interface *); |
| 315 | 315 | ||
| 316 | /* the generic read/write method for device control */ | 316 | /* the generic read/write method for device control */ |
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c index 258a92bfbcc7..1841a66427bf 100644 --- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c +++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c | |||
| @@ -144,7 +144,7 @@ static struct dvb_usb_properties nova_t_properties; | |||
| 144 | static int nova_t_probe(struct usb_interface *intf, | 144 | static int nova_t_probe(struct usb_interface *intf, |
| 145 | const struct usb_device_id *id) | 145 | const struct usb_device_id *id) |
| 146 | { | 146 | { |
| 147 | return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE); | 147 | return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE,NULL); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | /* do not change the order of the ID table */ | 150 | /* do not change the order of the ID table */ |
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 2112ac3cf5e2..6fd67657c269 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c | |||
| @@ -77,7 +77,7 @@ static struct dvb_usb_properties umt_properties; | |||
| 77 | static int umt_probe(struct usb_interface *intf, | 77 | static int umt_probe(struct usb_interface *intf, |
| 78 | const struct usb_device_id *id) | 78 | const struct usb_device_id *id) |
| 79 | { | 79 | { |
| 80 | if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE) == 0) | 80 | if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE,NULL) == 0) |
| 81 | return 0; | 81 | return 0; |
| 82 | return -EINVAL; | 82 | return -EINVAL; |
| 83 | } | 83 | } |
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c new file mode 100644 index 000000000000..f20d8dbd0be8 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c | |||
| @@ -0,0 +1,339 @@ | |||
| 1 | /* DVB frontend part of the Linux driver for the TwinhanDTV StarBox USB2.0 | ||
| 2 | * DVB-S receiver. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de> | ||
| 5 | * Metzler Brothers Systementwicklung GbR | ||
| 6 | * | ||
| 7 | * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de> | ||
| 8 | * | ||
| 9 | * Thanks to Twinhan who kindly provided hardware and information. | ||
| 10 | * | ||
| 11 | * This file can be removed soon, after the DST-driver is rewritten to provice | ||
| 12 | * the frontend-controlling separately. | ||
| 13 | * | ||
| 14 | * This program is free software; you can redistribute it and/or modify it | ||
| 15 | * under the terms of the GNU General Public License as published by the Free | ||
| 16 | * Software Foundation, version 2. | ||
| 17 | * | ||
| 18 | * see Documentation/dvb/README.dvb-usb for more information | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | #include "vp702x.h" | ||
| 22 | |||
| 23 | struct vp702x_fe_state { | ||
| 24 | struct dvb_frontend fe; | ||
| 25 | struct dvb_usb_device *d; | ||
| 26 | |||
| 27 | fe_sec_voltage_t voltage; | ||
| 28 | fe_sec_tone_mode_t tone_mode; | ||
| 29 | |||
| 30 | u8 lnb_buf[8]; | ||
| 31 | |||
| 32 | u8 lock; | ||
| 33 | u8 sig; | ||
| 34 | u8 snr; | ||
| 35 | |||
| 36 | unsigned long next_status_check; | ||
| 37 | unsigned long status_check_interval; | ||
| 38 | }; | ||
| 39 | |||
| 40 | static int vp702x_fe_refresh_state(struct vp702x_fe_state *st) | ||
| 41 | { | ||
| 42 | u8 buf[10]; | ||
| 43 | if (time_after(jiffies,st->next_status_check)) { | ||
| 44 | vp702x_usb_in_op(st->d,READ_STATUS,0,0,buf,10); | ||
| 45 | |||
| 46 | st->lock = buf[4]; | ||
| 47 | vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x11,0,&st->snr,1); | ||
| 48 | vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x15,0,&st->sig,1); | ||
| 49 | |||
| 50 | st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; | ||
| 51 | } | ||
| 52 | return 0; | ||
| 53 | } | ||
| 54 | |||
| 55 | static u8 vp702x_chksum(u8 *buf,int f, int count) | ||
| 56 | { | ||
| 57 | u8 s = 0; | ||
| 58 | int i; | ||
| 59 | for (i = f; i < f+count; i++) | ||
| 60 | s += buf[i]; | ||
| 61 | return ~s+1; | ||
| 62 | } | ||
| 63 | |||
| 64 | static int vp702x_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) | ||
| 65 | { | ||
| 66 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 67 | vp702x_fe_refresh_state(st); | ||
| 68 | deb_fe("%s\n",__FUNCTION__); | ||
| 69 | |||
| 70 | if (st->lock == 0) | ||
| 71 | *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; | ||
| 72 | else | ||
| 73 | *status = 0; | ||
| 74 | |||
| 75 | deb_fe("real state: %x\n",*status); | ||
| 76 | *status = 0x1f; | ||
| 77 | |||
| 78 | if (*status & FE_HAS_LOCK) | ||
| 79 | st->status_check_interval = 1000; | ||
| 80 | else | ||
| 81 | st->status_check_interval = 250; | ||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | /* not supported by this Frontend */ | ||
| 86 | static int vp702x_fe_read_ber(struct dvb_frontend* fe, u32 *ber) | ||
| 87 | { | ||
| 88 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 89 | vp702x_fe_refresh_state(st); | ||
| 90 | *ber = 0; | ||
| 91 | return 0; | ||
| 92 | } | ||
| 93 | |||
| 94 | /* not supported by this Frontend */ | ||
| 95 | static int vp702x_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) | ||
| 96 | { | ||
| 97 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 98 | vp702x_fe_refresh_state(st); | ||
| 99 | *unc = 0; | ||
| 100 | return 0; | ||
| 101 | } | ||
| 102 | |||
| 103 | static int vp702x_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength) | ||
| 104 | { | ||
| 105 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 106 | vp702x_fe_refresh_state(st); | ||
| 107 | |||
| 108 | *strength = (st->sig << 8) | st->sig; | ||
| 109 | return 0; | ||
| 110 | } | ||
| 111 | |||
| 112 | static int vp702x_fe_read_snr(struct dvb_frontend* fe, u16 *snr) | ||
| 113 | { | ||
| 114 | u8 _snr; | ||
| 115 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 116 | vp702x_fe_refresh_state(st); | ||
| 117 | |||
| 118 | _snr = (st->snr & 0x1f) * 0xff / 0x1f; | ||
| 119 | *snr = (_snr << 8) | _snr; | ||
| 120 | return 0; | ||
| 121 | } | ||
| 122 | |||
| 123 | static int vp702x_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) | ||
| 124 | { | ||
| 125 | deb_fe("%s\n",__FUNCTION__); | ||
| 126 | tune->min_delay_ms = 2000; | ||
| 127 | return 0; | ||
| 128 | } | ||
| 129 | |||
| 130 | static int vp702x_fe_set_frontend(struct dvb_frontend* fe, | ||
| 131 | struct dvb_frontend_parameters *fep) | ||
| 132 | { | ||
| 133 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 134 | u32 freq = fep->frequency/1000; | ||
| 135 | /*CalFrequency*/ | ||
| 136 | /* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */ | ||
| 137 | u64 sr; | ||
| 138 | u8 cmd[8] = { 0 },ibuf[10]; | ||
| 139 | |||
| 140 | cmd[0] = (freq >> 8) & 0x7f; | ||
| 141 | cmd[1] = freq & 0xff; | ||
| 142 | cmd[2] = 1; /* divrate == 4 -> frequencyRef[1] -> 1 here */ | ||
| 143 | |||
| 144 | sr = (u64) (fep->u.qpsk.symbol_rate/1000) << 20; | ||
| 145 | do_div(sr,88000); | ||
| 146 | cmd[3] = (sr >> 12) & 0xff; | ||
| 147 | cmd[4] = (sr >> 4) & 0xff; | ||
| 148 | cmd[5] = (sr << 4) & 0xf0; | ||
| 149 | |||
| 150 | deb_fe("setting frontend to: %u -> %u (%x) LNB-based GHz, symbolrate: %d -> %Lu (%Lx)\n", | ||
| 151 | fep->frequency,freq,freq, fep->u.qpsk.symbol_rate, sr, sr); | ||
| 152 | |||
| 153 | /* if (fep->inversion == INVERSION_ON) | ||
| 154 | cmd[6] |= 0x80; */ | ||
| 155 | |||
| 156 | if (st->voltage == SEC_VOLTAGE_18) | ||
| 157 | cmd[6] |= 0x40; | ||
| 158 | |||
| 159 | /* if (fep->u.qpsk.symbol_rate > 8000000) | ||
| 160 | cmd[6] |= 0x20; | ||
| 161 | |||
| 162 | if (fep->frequency < 1531000) | ||
| 163 | cmd[6] |= 0x04; | ||
| 164 | |||
| 165 | if (st->tone_mode == SEC_TONE_ON) | ||
| 166 | cmd[6] |= 0x01;*/ | ||
| 167 | |||
| 168 | cmd[7] = vp702x_chksum(cmd,0,7); | ||
| 169 | |||
| 170 | st->status_check_interval = 250; | ||
| 171 | st->next_status_check = jiffies; | ||
| 172 | |||
| 173 | vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0); | ||
| 174 | msleep(30); | ||
| 175 | vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); | ||
| 176 | |||
| 177 | if (ibuf[2] == 0 && ibuf[3] == 0) | ||
| 178 | deb_fe("tuning failed.\n"); | ||
| 179 | else | ||
| 180 | deb_fe("tuning succeeded.\n"); | ||
| 181 | |||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | static int vp702x_fe_get_frontend(struct dvb_frontend* fe, | ||
| 186 | struct dvb_frontend_parameters *fep) | ||
| 187 | { | ||
| 188 | deb_fe("%s\n",__FUNCTION__); | ||
| 189 | return 0; | ||
| 190 | } | ||
| 191 | |||
| 192 | static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, | ||
| 193 | struct dvb_diseqc_master_cmd *m) | ||
| 194 | { | ||
| 195 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 196 | u8 cmd[8],ibuf[10]; | ||
| 197 | memset(cmd,0,8); | ||
| 198 | |||
| 199 | deb_fe("%s\n",__FUNCTION__); | ||
| 200 | |||
| 201 | if (m->msg_len > 4) | ||
| 202 | return -EINVAL; | ||
| 203 | |||
| 204 | cmd[1] = SET_DISEQC_CMD; | ||
| 205 | cmd[2] = m->msg_len; | ||
| 206 | memcpy(&cmd[3], m->msg, m->msg_len); | ||
| 207 | cmd[7] = vp702x_chksum(cmd,0,7); | ||
| 208 | |||
| 209 | vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); | ||
| 210 | |||
| 211 | if (ibuf[2] == 0 && ibuf[3] == 0) | ||
| 212 | deb_fe("diseqc cmd failed.\n"); | ||
| 213 | else | ||
| 214 | deb_fe("diseqc cmd succeeded.\n"); | ||
| 215 | |||
| 216 | return 0; | ||
| 217 | } | ||
| 218 | |||
| 219 | static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) | ||
| 220 | { | ||
| 221 | deb_fe("%s\n",__FUNCTION__); | ||
| 222 | return 0; | ||
| 223 | } | ||
| 224 | |||
| 225 | static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | ||
| 226 | { | ||
| 227 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 228 | u8 ibuf[10]; | ||
| 229 | deb_fe("%s\n",__FUNCTION__); | ||
| 230 | |||
| 231 | st->tone_mode = tone; | ||
| 232 | |||
| 233 | if (tone == SEC_TONE_ON) | ||
| 234 | st->lnb_buf[2] = 0x02; | ||
| 235 | else | ||
| 236 | st->lnb_buf[2] = 0x00; | ||
| 237 | |||
| 238 | st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); | ||
| 239 | |||
| 240 | vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); | ||
| 241 | if (ibuf[2] == 0 && ibuf[3] == 0) | ||
| 242 | deb_fe("set_tone cmd failed.\n"); | ||
| 243 | else | ||
| 244 | deb_fe("set_tone cmd succeeded.\n"); | ||
| 245 | |||
| 246 | return 0; | ||
| 247 | } | ||
| 248 | |||
| 249 | static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t | ||
| 250 | voltage) | ||
| 251 | { | ||
| 252 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 253 | u8 ibuf[10]; | ||
| 254 | deb_fe("%s\n",__FUNCTION__); | ||
| 255 | |||
| 256 | st->voltage = voltage; | ||
| 257 | |||
| 258 | if (voltage != SEC_VOLTAGE_OFF) | ||
| 259 | st->lnb_buf[4] = 0x01; | ||
| 260 | else | ||
| 261 | st->lnb_buf[4] = 0x00; | ||
| 262 | |||
| 263 | st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); | ||
| 264 | |||
| 265 | vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); | ||
| 266 | if (ibuf[2] == 0 && ibuf[3] == 0) | ||
| 267 | deb_fe("set_voltage cmd failed.\n"); | ||
| 268 | else | ||
| 269 | deb_fe("set_voltage cmd succeeded.\n"); | ||
| 270 | |||
| 271 | return 0; | ||
| 272 | } | ||
| 273 | |||
| 274 | static void vp702x_fe_release(struct dvb_frontend* fe) | ||
| 275 | { | ||
| 276 | struct vp702x_fe_state *st = fe->demodulator_priv; | ||
| 277 | kfree(st); | ||
| 278 | } | ||
| 279 | |||
| 280 | static struct dvb_frontend_ops vp702x_fe_ops; | ||
| 281 | |||
| 282 | struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d) | ||
| 283 | { | ||
| 284 | struct vp702x_fe_state *s = kmalloc(sizeof(struct vp702x_fe_state), GFP_KERNEL); | ||
| 285 | if (s == NULL) | ||
| 286 | goto error; | ||
| 287 | memset(s,0,sizeof(struct vp702x_fe_state)); | ||
| 288 | |||
| 289 | s->d = d; | ||
| 290 | s->fe.ops = &vp702x_fe_ops; | ||
| 291 | s->fe.demodulator_priv = s; | ||
| 292 | |||
| 293 | s->lnb_buf[1] = SET_LNB_POWER; | ||
| 294 | s->lnb_buf[3] = 0xff; /* 0=tone burst, 2=data burst, ff=off */ | ||
| 295 | |||
| 296 | goto success; | ||
| 297 | error: | ||
| 298 | return NULL; | ||
| 299 | success: | ||
| 300 | return &s->fe; | ||
| 301 | } | ||
| 302 | |||
| 303 | |||
| 304 | static struct dvb_frontend_ops vp702x_fe_ops = { | ||
| 305 | .info = { | ||
| 306 | .name = "Twinhan DST-like frontend (VP7021/VP7020) DVB-S", | ||
| 307 | .type = FE_QPSK, | ||
| 308 | .frequency_min = 950000, | ||
| 309 | .frequency_max = 2150000, | ||
| 310 | .frequency_stepsize = 1000, /* kHz for QPSK frontends */ | ||
| 311 | .frequency_tolerance = 0, | ||
| 312 | .symbol_rate_min = 1000000, | ||
| 313 | .symbol_rate_max = 45000000, | ||
| 314 | .symbol_rate_tolerance = 500, /* ppm */ | ||
| 315 | .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | | ||
| 316 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | | ||
| 317 | FE_CAN_QPSK | | ||
| 318 | FE_CAN_FEC_AUTO | ||
| 319 | }, | ||
| 320 | .release = vp702x_fe_release, | ||
| 321 | |||
| 322 | .init = NULL, | ||
| 323 | .sleep = NULL, | ||
| 324 | |||
| 325 | .set_frontend = vp702x_fe_set_frontend, | ||
| 326 | .get_frontend = vp702x_fe_get_frontend, | ||
| 327 | .get_tune_settings = vp702x_fe_get_tune_settings, | ||
| 328 | |||
| 329 | .read_status = vp702x_fe_read_status, | ||
| 330 | .read_ber = vp702x_fe_read_ber, | ||
| 331 | .read_signal_strength = vp702x_fe_read_signal_strength, | ||
| 332 | .read_snr = vp702x_fe_read_snr, | ||
| 333 | .read_ucblocks = vp702x_fe_read_unc_blocks, | ||
| 334 | |||
| 335 | .diseqc_send_master_cmd = vp702x_fe_send_diseqc_msg, | ||
| 336 | .diseqc_send_burst = vp702x_fe_send_diseqc_burst, | ||
| 337 | .set_tone = vp702x_fe_set_tone, | ||
| 338 | .set_voltage = vp702x_fe_set_voltage, | ||
| 339 | }; | ||
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c new file mode 100644 index 000000000000..de13c04e8e64 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x.c | |||
| @@ -0,0 +1,290 @@ | |||
| 1 | /* DVB USB compliant Linux driver for the TwinhanDTV StarBox USB2.0 DVB-S | ||
| 2 | * receiver. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de> | ||
| 5 | * Metzler Brothers Systementwicklung GbR | ||
| 6 | * | ||
| 7 | * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de> | ||
| 8 | * | ||
| 9 | * Thanks to Twinhan who kindly provided hardware and information. | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or modify it | ||
| 12 | * under the terms of the GNU General Public License as published by the Free | ||
| 13 | * Software Foundation, version 2. | ||
| 14 | * | ||
| 15 | * see Documentation/dvb/README.dvb-usb for more information | ||
| 16 | */ | ||
| 17 | #include "vp702x.h" | ||
| 18 | |||
| 19 | /* debug */ | ||
| 20 | int dvb_usb_vp702x_debug; | ||
| 21 | module_param_named(debug,dvb_usb_vp702x_debug, int, 0644); | ||
| 22 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); | ||
| 23 | |||
| 24 | struct vp702x_state { | ||
| 25 | u8 pid_table[17]; /* [16] controls the pid_table state */ | ||
| 26 | }; | ||
| 27 | |||
| 28 | /* check for mutex FIXME */ | ||
| 29 | int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) | ||
| 30 | { | ||
| 31 | int ret = 0,try = 0; | ||
| 32 | |||
| 33 | while (ret >= 0 && ret != blen && try < 3) { | ||
| 34 | ret = usb_control_msg(d->udev, | ||
| 35 | usb_rcvctrlpipe(d->udev,0), | ||
| 36 | req, | ||
| 37 | USB_TYPE_VENDOR | USB_DIR_IN, | ||
| 38 | value,index,b,blen, | ||
| 39 | 2000); | ||
| 40 | deb_info("reading number %d (ret: %d)\n",try,ret); | ||
| 41 | try++; | ||
| 42 | } | ||
| 43 | |||
| 44 | if (ret < 0 || ret != blen) { | ||
| 45 | warn("usb in operation failed."); | ||
| 46 | ret = -EIO; | ||
| 47 | } else | ||
| 48 | ret = 0; | ||
| 49 | |||
| 50 | deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index); | ||
| 51 | debug_dump(b,blen,deb_xfer); | ||
| 52 | |||
| 53 | return ret; | ||
| 54 | } | ||
| 55 | |||
| 56 | int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) | ||
| 57 | { | ||
| 58 | deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index); | ||
| 59 | debug_dump(b,blen,deb_xfer); | ||
| 60 | |||
| 61 | if (usb_control_msg(d->udev, | ||
| 62 | usb_sndctrlpipe(d->udev,0), | ||
| 63 | req, | ||
| 64 | USB_TYPE_VENDOR | USB_DIR_OUT, | ||
| 65 | value,index,b,blen, | ||
| 66 | 2000) != blen) { | ||
| 67 | warn("usb out operation failed."); | ||
| 68 | return -EIO; | ||
| 69 | } else | ||
| 70 | return 0; | ||
| 71 | } | ||
| 72 | |||
| 73 | int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec) | ||
| 74 | { | ||
| 75 | int ret; | ||
| 76 | |||
| 77 | if ((ret = down_interruptible(&d->usb_sem))) | ||
| 78 | return ret; | ||
| 79 | |||
| 80 | if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0) | ||
| 81 | goto unlock; | ||
| 82 | msleep(msec); | ||
| 83 | ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen); | ||
| 84 | |||
| 85 | unlock: | ||
| 86 | up(&d->usb_sem); | ||
| 87 | |||
| 88 | return ret; | ||
| 89 | } | ||
| 90 | |||
| 91 | int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec) | ||
| 92 | { | ||
| 93 | u8 bout[olen+2]; | ||
| 94 | u8 bin[ilen+1]; | ||
| 95 | int ret = 0; | ||
| 96 | |||
| 97 | bout[0] = 0x00; | ||
| 98 | bout[1] = cmd; | ||
| 99 | memcpy(&bout[2],o,olen); | ||
| 100 | |||
| 101 | ret = vp702x_usb_inout_op(d, bout, olen+2, bin, ilen+1,msec); | ||
| 102 | |||
| 103 | if (ret == 0) | ||
| 104 | memcpy(i,&bin[1],ilen); | ||
| 105 | |||
| 106 | return ret; | ||
| 107 | } | ||
| 108 | |||
| 109 | static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) | ||
| 110 | { | ||
| 111 | struct vp702x_state *st = d->priv; | ||
| 112 | u8 buf[9]; | ||
| 113 | |||
| 114 | if (onoff) { | ||
| 115 | st->pid_table[16] |= 1 << index; | ||
| 116 | st->pid_table[index*2] = (pid >> 8) & 0xff; | ||
| 117 | st->pid_table[index*2+1] = pid & 0xff; | ||
| 118 | } else { | ||
| 119 | st->pid_table[16] &= ~(1 << index); | ||
| 120 | st->pid_table[index*2] = st->pid_table[index*2+1] = 0; | ||
| 121 | } | ||
| 122 | |||
| 123 | return vp702x_usb_inout_cmd(d,SET_PID_FILTER,st->pid_table,17,buf,9,10); | ||
| 124 | } | ||
| 125 | |||
| 126 | static int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff) | ||
| 127 | { | ||
| 128 | vp702x_usb_in_op(d,RESET_TUNER,0,0,NULL,0); | ||
| 129 | |||
| 130 | vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); | ||
| 131 | return vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0); | ||
| 132 | } | ||
| 133 | |||
| 134 | /* keys for the enclosed remote control */ | ||
| 135 | static struct dvb_usb_rc_key vp702x_rc_keys[] = { | ||
| 136 | { 0x00, 0x01, KEY_1 }, | ||
| 137 | { 0x00, 0x02, KEY_2 }, | ||
| 138 | }; | ||
| 139 | |||
| 140 | /* remote control stuff (does not work with my box) */ | ||
| 141 | static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | ||
| 142 | { | ||
| 143 | u8 key[10]; | ||
| 144 | int i; | ||
| 145 | |||
| 146 | /* remove the following return to enabled remote querying */ | ||
| 147 | return 0; | ||
| 148 | |||
| 149 | vp702x_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10); | ||
| 150 | |||
| 151 | deb_rc("remote query key: %x %d\n",key[1],key[1]); | ||
| 152 | |||
| 153 | if (key[1] == 0x44) { | ||
| 154 | *state = REMOTE_NO_KEY_PRESSED; | ||
| 155 | return 0; | ||
| 156 | } | ||
| 157 | |||
| 158 | for (i = 0; i < ARRAY_SIZE(vp702x_rc_keys); i++) | ||
| 159 | if (vp702x_rc_keys[i].custom == key[1]) { | ||
| 160 | *state = REMOTE_KEY_PRESSED; | ||
| 161 | *event = vp702x_rc_keys[i].event; | ||
| 162 | break; | ||
| 163 | } | ||
| 164 | return 0; | ||
| 165 | } | ||
| 166 | |||
| 167 | static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) | ||
| 168 | { | ||
| 169 | u8 macb[9]; | ||
| 170 | if (vp702x_usb_inout_cmd(d, GET_MAC_ADDRESS, NULL, 0, macb, 9, 10)) | ||
| 171 | return -EIO; | ||
| 172 | memcpy(mac,&macb[3],6); | ||
| 173 | return 0; | ||
| 174 | } | ||
| 175 | |||
| 176 | static int vp702x_frontend_attach(struct dvb_usb_device *d) | ||
| 177 | { | ||
| 178 | u8 buf[9] = { 0 }; | ||
| 179 | |||
| 180 | if (vp702x_usb_inout_cmd(d, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10)) | ||
| 181 | return -EIO; | ||
| 182 | |||
| 183 | buf[8] = '\0'; | ||
| 184 | info("system string: %s",&buf[1]); | ||
| 185 | |||
| 186 | d->fe = vp702x_fe_attach(d); | ||
| 187 | return 0; | ||
| 188 | } | ||
| 189 | |||
| 190 | static struct dvb_usb_properties vp702x_properties; | ||
| 191 | |||
| 192 | static int vp702x_usb_probe(struct usb_interface *intf, | ||
| 193 | const struct usb_device_id *id) | ||
| 194 | { | ||
| 195 | struct usb_device *udev = interface_to_usbdev(intf); | ||
| 196 | |||
| 197 | usb_clear_halt(udev,usb_sndctrlpipe(udev,0)); | ||
| 198 | usb_clear_halt(udev,usb_rcvctrlpipe(udev,0)); | ||
| 199 | |||
| 200 | return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL); | ||
| 201 | } | ||
| 202 | |||
| 203 | static struct usb_device_id vp702x_usb_table [] = { | ||
| 204 | { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_COLD) }, | ||
| 205 | { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_WARM) }, | ||
| 206 | { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_COLD) }, | ||
| 207 | { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_WARM) }, | ||
| 208 | { 0 }, | ||
| 209 | }; | ||
| 210 | MODULE_DEVICE_TABLE(usb, vp702x_usb_table); | ||
| 211 | |||
| 212 | static struct dvb_usb_properties vp702x_properties = { | ||
| 213 | .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING, | ||
| 214 | .pid_filter_count = 8, /* !!! */ | ||
| 215 | |||
| 216 | .usb_ctrl = CYPRESS_FX2, | ||
| 217 | .firmware = "dvb-usb-vp702x-01.fw", | ||
| 218 | |||
| 219 | .pid_filter = vp702x_pid_filter, | ||
| 220 | .power_ctrl = vp702x_power_ctrl, | ||
| 221 | .frontend_attach = vp702x_frontend_attach, | ||
| 222 | .read_mac_address = vp702x_read_mac_addr, | ||
| 223 | |||
| 224 | .rc_key_map = vp702x_rc_keys, | ||
| 225 | .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys), | ||
| 226 | .rc_interval = 400, | ||
| 227 | .rc_query = vp702x_rc_query, | ||
| 228 | |||
| 229 | .size_of_priv = sizeof(struct vp702x_state), | ||
| 230 | |||
| 231 | /* parameter for the MPEG2-data transfer */ | ||
| 232 | .urb = { | ||
| 233 | .type = DVB_USB_BULK, | ||
| 234 | .count = 7, | ||
| 235 | .endpoint = 0x02, | ||
| 236 | .u = { | ||
| 237 | .bulk = { | ||
| 238 | .buffersize = 4096, | ||
| 239 | } | ||
| 240 | } | ||
| 241 | }, | ||
| 242 | |||
| 243 | .num_device_descs = 2, | ||
| 244 | .devices = { | ||
| 245 | { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7021)", | ||
| 246 | .cold_ids = { &vp702x_usb_table[0], NULL }, | ||
| 247 | .warm_ids = { &vp702x_usb_table[1], NULL }, | ||
| 248 | }, | ||
| 249 | { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7020)", | ||
| 250 | .cold_ids = { &vp702x_usb_table[2], NULL }, | ||
| 251 | .warm_ids = { &vp702x_usb_table[3], NULL }, | ||
| 252 | }, | ||
| 253 | { 0 }, | ||
| 254 | } | ||
| 255 | }; | ||
| 256 | |||
| 257 | /* usb specific object needed to register this driver with the usb subsystem */ | ||
| 258 | static struct usb_driver vp702x_usb_driver = { | ||
| 259 | .owner = THIS_MODULE, | ||
| 260 | .name = "dvb-usb-vp702x", | ||
| 261 | .probe = vp702x_usb_probe, | ||
| 262 | .disconnect = dvb_usb_device_exit, | ||
| 263 | .id_table = vp702x_usb_table, | ||
| 264 | }; | ||
| 265 | |||
| 266 | /* module stuff */ | ||
| 267 | static int __init vp702x_usb_module_init(void) | ||
| 268 | { | ||
| 269 | int result; | ||
| 270 | if ((result = usb_register(&vp702x_usb_driver))) { | ||
| 271 | err("usb_register failed. (%d)",result); | ||
| 272 | return result; | ||
| 273 | } | ||
| 274 | |||
| 275 | return 0; | ||
| 276 | } | ||
| 277 | |||
| 278 | static void __exit vp702x_usb_module_exit(void) | ||
| 279 | { | ||
| 280 | /* deregister this driver from the USB subsystem */ | ||
| 281 | usb_deregister(&vp702x_usb_driver); | ||
| 282 | } | ||
| 283 | |||
| 284 | module_init(vp702x_usb_module_init); | ||
| 285 | module_exit(vp702x_usb_module_exit); | ||
| 286 | |||
| 287 | MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); | ||
| 288 | MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones"); | ||
| 289 | MODULE_VERSION("1.0-alpha"); | ||
| 290 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h new file mode 100644 index 000000000000..4a3e8c7eca2b --- /dev/null +++ b/drivers/media/dvb/dvb-usb/vp702x.h | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | #ifndef _DVB_USB_VP7021_H_ | ||
| 2 | #define _DVB_USB_VP7021_H_ | ||
| 3 | |||
| 4 | #define DVB_USB_LOG_PREFIX "vp702x" | ||
| 5 | #include "dvb-usb.h" | ||
| 6 | |||
| 7 | extern int dvb_usb_vp702x_debug; | ||
| 8 | #define deb_info(args...) dprintk(dvb_usb_vp702x_debug,0x01,args) | ||
| 9 | #define deb_xfer(args...) dprintk(dvb_usb_vp702x_debug,0x02,args) | ||
| 10 | #define deb_rc(args...) dprintk(dvb_usb_vp702x_debug,0x04,args) | ||
| 11 | #define deb_fe(args...) dprintk(dvb_usb_vp702x_debug,0x08,args) | ||
| 12 | |||
| 13 | /* commands are read and written with USB control messages */ | ||
| 14 | |||
| 15 | /* consecutive read/write operation */ | ||
| 16 | #define REQUEST_OUT 0xB2 | ||
| 17 | #define REQUEST_IN 0xB3 | ||
| 18 | |||
| 19 | /* the out-buffer of these consecutive operations contain sub-commands when b[0] = 0 | ||
| 20 | * request: 0xB2; i: 0; v: 0; b[0] = 0, b[1] = subcmd, additional buffer | ||
| 21 | * the returning buffer looks as follows | ||
| 22 | * request: 0xB3; i: 0; v: 0; b[0] = 0xB3, additional buffer */ | ||
| 23 | |||
| 24 | #define GET_TUNER_STATUS 0x05 | ||
| 25 | /* additional in buffer: | ||
| 26 | * 0 1 2 3 4 5 6 7 8 | ||
| 27 | * N/A N/A 0x05 signal-quality N/A N/A signal-strength lock==0 N/A */ | ||
| 28 | |||
| 29 | #define GET_SYSTEM_STRING 0x06 | ||
| 30 | /* additional in buffer: | ||
| 31 | * 0 1 2 3 4 5 6 7 8 | ||
| 32 | * N/A 'U' 'S' 'B' '7' '0' '2' 'X' N/A */ | ||
| 33 | |||
| 34 | #define SET_DISEQC_CMD 0x08 | ||
| 35 | /* additional out buffer: | ||
| 36 | * 0 1 2 3 4 | ||
| 37 | * len X1 X2 X3 X4 | ||
| 38 | * additional in buffer: | ||
| 39 | * 0 1 2 | ||
| 40 | * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ | ||
| 41 | |||
| 42 | #define SET_LNB_POWER 0x09 | ||
| 43 | /* additional out buffer: | ||
| 44 | * 0 1 2 | ||
| 45 | * 0x00 0xff 1 = on, 0 = off | ||
| 46 | * additional in buffer: | ||
| 47 | * 0 1 2 | ||
| 48 | * N/A 0 0 b[1] == b[2] == 0 -> success otherwise not */ | ||
| 49 | |||
| 50 | #define GET_MAC_ADDRESS 0x0A | ||
| 51 | /* #define GET_MAC_ADDRESS 0x0B */ | ||
| 52 | /* additional in buffer: | ||
| 53 | * 0 1 2 3 4 5 6 7 8 | ||
| 54 | * N/A N/A 0x0A or 0x0B MAC0 MAC1 MAC2 MAC3 MAC4 MAC5 */ | ||
| 55 | |||
| 56 | #define SET_PID_FILTER 0x11 | ||
| 57 | /* additional in buffer: | ||
| 58 | * 0 1 ... 14 15 16 | ||
| 59 | * PID0_MSB PID0_LSB ... PID7_MSB PID7_LSB PID_active (bits) */ | ||
| 60 | |||
| 61 | /* request: 0xB2; i: 0; v: 0; | ||
| 62 | * b[0] != 0 -> tune and lock a channel | ||
| 63 | * 0 1 2 3 4 5 6 7 | ||
| 64 | * freq0 freq1 divstep srate0 srate1 srate2 flag chksum | ||
| 65 | */ | ||
| 66 | |||
| 67 | |||
| 68 | /* one direction requests */ | ||
| 69 | #define READ_REMOTE_REQ 0xB4 | ||
| 70 | /* IN i: 0; v: 0; b[0] == request, b[1] == key */ | ||
| 71 | |||
| 72 | #define READ_PID_NUMBER_REQ 0xB5 | ||
| 73 | /* IN i: 0; v: 0; b[0] == request, b[1] == 0, b[2] = pid number */ | ||
| 74 | |||
| 75 | #define WRITE_EEPROM_REQ 0xB6 | ||
| 76 | /* OUT i: offset; v: value to write; no extra buffer */ | ||
| 77 | |||
| 78 | #define READ_EEPROM_REQ 0xB7 | ||
| 79 | /* IN i: bufferlen; v: offset; buffer with bufferlen bytes */ | ||
| 80 | |||
| 81 | #define READ_STATUS 0xB8 | ||
| 82 | /* IN i: 0; v: 0; bufferlen 10 */ | ||
| 83 | |||
| 84 | #define READ_TUNER_REG_REQ 0xB9 | ||
| 85 | /* IN i: 0; v: register; b[0] = value */ | ||
| 86 | |||
| 87 | #define READ_FX2_REG_REQ 0xBA | ||
| 88 | /* IN i: offset; v: 0; b[0] = value */ | ||
| 89 | |||
| 90 | #define WRITE_FX2_REG_REQ 0xBB | ||
| 91 | /* OUT i: offset; v: value to write; 1 byte extra buffer */ | ||
| 92 | |||
| 93 | #define SET_TUNER_POWER_REQ 0xBC | ||
| 94 | /* IN i: 0 = power off, 1 = power on */ | ||
| 95 | |||
| 96 | #define WRITE_TUNER_REG_REQ 0xBD | ||
| 97 | /* IN i: register, v: value to write, no extra buffer */ | ||
| 98 | |||
| 99 | #define RESET_TUNER 0xBE | ||
| 100 | /* IN i: 0, v: 0, no extra buffer */ | ||
| 101 | |||
| 102 | extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d); | ||
| 103 | |||
| 104 | extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec); | ||
| 105 | extern int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, int olen, u8 *i, int ilen, int msec); | ||
| 106 | extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); | ||
| 107 | extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen); | ||
| 108 | |||
| 109 | #endif | ||
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 9ac95f54f9fc..0f57abeb6d6b 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c | |||
| @@ -164,7 +164,6 @@ static int vp7045_read_eeprom(struct dvb_usb_device *d,u8 *buf, int len, int off | |||
| 164 | return 0; | 164 | return 0; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | |||
| 168 | static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) | 167 | static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) |
| 169 | { | 168 | { |
| 170 | return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR); | 169 | return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR); |
| @@ -199,7 +198,7 @@ static struct dvb_usb_properties vp7045_properties; | |||
| 199 | static int vp7045_usb_probe(struct usb_interface *intf, | 198 | static int vp7045_usb_probe(struct usb_interface *intf, |
| 200 | const struct usb_device_id *id) | 199 | const struct usb_device_id *id) |
| 201 | { | 200 | { |
| 202 | return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE); | 201 | return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE,NULL); |
| 203 | } | 202 | } |
| 204 | 203 | ||
| 205 | static struct usb_device_id vp7045_usb_table [] = { | 204 | static struct usb_device_id vp7045_usb_table [] = { |
| @@ -256,9 +255,9 @@ static struct dvb_usb_properties vp7045_properties = { | |||
| 256 | static struct usb_driver vp7045_usb_driver = { | 255 | static struct usb_driver vp7045_usb_driver = { |
| 257 | .owner = THIS_MODULE, | 256 | .owner = THIS_MODULE, |
| 258 | .name = "dvb_usb_vp7045", | 257 | .name = "dvb_usb_vp7045", |
| 259 | .probe = vp7045_usb_probe, | 258 | .probe = vp7045_usb_probe, |
| 260 | .disconnect = dvb_usb_device_exit, | 259 | .disconnect = dvb_usb_device_exit, |
| 261 | .id_table = vp7045_usb_table, | 260 | .id_table = vp7045_usb_table, |
| 262 | }; | 261 | }; |
| 263 | 262 | ||
| 264 | /* module stuff */ | 263 | /* module stuff */ |
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index 8222b88cb486..d4b97989e3ed 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | cx24110 - Single Chip Satellite Channel Receiver driver module | 2 | cx24110 - Single Chip Satellite Channel Receiver driver module |
| 3 | 3 | ||
| 4 | Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> based on | 4 | Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> based on |
| 5 | work | 5 | work |
| 6 | Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> | 6 | Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> |
| 7 | 7 | ||
| @@ -387,8 +387,9 @@ static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag | |||
| 387 | 387 | ||
| 388 | static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) | 388 | static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) |
| 389 | { | 389 | { |
| 390 | int rv, bit, i; | 390 | int rv, bit; |
| 391 | struct cx24110_state *state = fe->demodulator_priv; | 391 | struct cx24110_state *state = fe->demodulator_priv; |
| 392 | unsigned long timeout; | ||
| 392 | 393 | ||
| 393 | if (burst == SEC_MINI_A) | 394 | if (burst == SEC_MINI_A) |
| 394 | bit = 0x00; | 395 | bit = 0x00; |
| @@ -398,12 +399,14 @@ static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t | |||
| 398 | return -EINVAL; | 399 | return -EINVAL; |
| 399 | 400 | ||
| 400 | rv = cx24110_readreg(state, 0x77); | 401 | rv = cx24110_readreg(state, 0x77); |
| 401 | cx24110_writereg(state, 0x77, rv|0x04); | 402 | if (!(rv & 0x04)) |
| 403 | cx24110_writereg(state, 0x77, rv | 0x04); | ||
| 402 | 404 | ||
| 403 | rv = cx24110_readreg(state, 0x76); | 405 | rv = cx24110_readreg(state, 0x76); |
| 404 | cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); | 406 | cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit)); |
| 405 | for (i = 500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40) ; ) | 407 | timeout = jiffies + msecs_to_jiffies(100); |
| 406 | ; /* wait for LNB ready */ | 408 | while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) |
| 409 | ; /* wait for LNB ready */ | ||
| 407 | 410 | ||
| 408 | return 0; | 411 | return 0; |
| 409 | } | 412 | } |
| @@ -413,17 +416,22 @@ static int cx24110_send_diseqc_msg(struct dvb_frontend* fe, | |||
| 413 | { | 416 | { |
| 414 | int i, rv; | 417 | int i, rv; |
| 415 | struct cx24110_state *state = fe->demodulator_priv; | 418 | struct cx24110_state *state = fe->demodulator_priv; |
| 419 | unsigned long timeout; | ||
| 416 | 420 | ||
| 417 | for (i = 0; i < cmd->msg_len; i++) | 421 | for (i = 0; i < cmd->msg_len; i++) |
| 418 | cx24110_writereg(state, 0x79 + i, cmd->msg[i]); | 422 | cx24110_writereg(state, 0x79 + i, cmd->msg[i]); |
| 419 | 423 | ||
| 420 | rv = cx24110_readreg(state, 0x77); | 424 | rv = cx24110_readreg(state, 0x77); |
| 421 | cx24110_writereg(state, 0x77, rv|0x04); | 425 | if (rv & 0x04) { |
| 426 | cx24110_writereg(state, 0x77, rv & ~0x04); | ||
| 427 | msleep(30); /* reportedly fixes switching problems */ | ||
| 428 | } | ||
| 422 | 429 | ||
| 423 | rv = cx24110_readreg(state, 0x76); | 430 | rv = cx24110_readreg(state, 0x76); |
| 424 | 431 | ||
| 425 | cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); | 432 | cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); |
| 426 | for (i=500; i-- > 0 && !(cx24110_readreg(state,0x76)&0x40);) | 433 | timeout = jiffies + msecs_to_jiffies(100); |
| 434 | while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40)) | ||
| 427 | ; /* wait for LNB ready */ | 435 | ; /* wait for LNB ready */ |
| 428 | 436 | ||
| 429 | return 0; | 437 | return 0; |
diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h index 6b663f4744e0..b63ecf26421a 100644 --- a/drivers/media/dvb/frontends/cx24110.h +++ b/drivers/media/dvb/frontends/cx24110.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | cx24110 - Single Chip Satellite Channel Receiver driver module | 2 | cx24110 - Single Chip Satellite Channel Receiver driver module |
| 3 | 3 | ||
| 4 | Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@t-online.de> based on | 4 | Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> based on |
| 5 | work | 5 | work |
| 6 | Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> | 6 | Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> |
| 7 | 7 | ||
diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c index cd434b7cf9db..21433e1831e7 100644 --- a/drivers/media/dvb/frontends/dib3000mb.c +++ b/drivers/media/dvb/frontends/dib3000mb.c | |||
| @@ -23,7 +23,6 @@ | |||
| 23 | 23 | ||
| 24 | #include <linux/config.h> | 24 | #include <linux/config.h> |
| 25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
| 26 | #include <linux/version.h> | ||
| 27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| 28 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
| 29 | #include <linux/init.h> | 28 | #include <linux/init.h> |
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c index cd33705a4320..441de665fec3 100644 --- a/drivers/media/dvb/frontends/dib3000mc.c +++ b/drivers/media/dvb/frontends/dib3000mc.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | */ | 22 | */ |
| 23 | #include <linux/config.h> | 23 | #include <linux/config.h> |
| 24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
| 25 | #include <linux/version.h> | ||
| 26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
| 27 | #include <linux/moduleparam.h> | 26 | #include <linux/moduleparam.h> |
| 28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c index d32dc4de9e7f..cc1bc0edd65e 100644 --- a/drivers/media/dvb/frontends/mt352.c +++ b/drivers/media/dvb/frontends/mt352.c | |||
| @@ -462,9 +462,11 @@ static int mt352_read_signal_strength(struct dvb_frontend* fe, u16* strength) | |||
| 462 | { | 462 | { |
| 463 | struct mt352_state* state = fe->demodulator_priv; | 463 | struct mt352_state* state = fe->demodulator_priv; |
| 464 | 464 | ||
| 465 | u16 signal = ((mt352_read_register(state, AGC_GAIN_1) << 8) & 0x0f) | | 465 | /* align the 12 bit AGC gain with the most significant bits */ |
| 466 | (mt352_read_register(state, AGC_GAIN_0)); | 466 | u16 signal = ((mt352_read_register(state, AGC_GAIN_1) & 0x0f) << 12) | |
| 467 | (mt352_read_register(state, AGC_GAIN_0) << 4); | ||
| 467 | 468 | ||
| 469 | /* inverse of gain is signal strength */ | ||
| 468 | *strength = ~signal; | 470 | *strength = ~signal; |
| 469 | return 0; | 471 | return 0; |
| 470 | } | 472 | } |
diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c index 966de9853d18..88a57b791112 100644 --- a/drivers/media/dvb/frontends/nxt6000.c +++ b/drivers/media/dvb/frontends/nxt6000.c | |||
| @@ -482,6 +482,7 @@ static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 482 | if ((result = nxt6000_set_inversion(state, param->inversion)) < 0) | 482 | if ((result = nxt6000_set_inversion(state, param->inversion)) < 0) |
| 483 | return result; | 483 | return result; |
| 484 | 484 | ||
| 485 | msleep(500); | ||
| 485 | return 0; | 486 | return 0; |
| 486 | } | 487 | } |
| 487 | 488 | ||
| @@ -525,6 +526,12 @@ static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_str | |||
| 525 | return 0; | 526 | return 0; |
| 526 | } | 527 | } |
| 527 | 528 | ||
| 529 | static int nxt6000_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) | ||
| 530 | { | ||
| 531 | tune->min_delay_ms = 500; | ||
| 532 | return 0; | ||
| 533 | } | ||
| 534 | |||
| 528 | static struct dvb_frontend_ops nxt6000_ops; | 535 | static struct dvb_frontend_ops nxt6000_ops; |
| 529 | 536 | ||
| 530 | struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, | 537 | struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, |
| @@ -578,6 +585,8 @@ static struct dvb_frontend_ops nxt6000_ops = { | |||
| 578 | 585 | ||
| 579 | .init = nxt6000_init, | 586 | .init = nxt6000_init, |
| 580 | 587 | ||
| 588 | .get_tune_settings = nxt6000_fe_get_tune_settings, | ||
| 589 | |||
| 581 | .set_frontend = nxt6000_set_frontend, | 590 | .set_frontend = nxt6000_set_frontend, |
| 582 | 591 | ||
| 583 | .read_status = nxt6000_read_status, | 592 | .read_status = nxt6000_read_status, |
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c index cc0a77c790f1..b6d0eecc59eb 100644 --- a/drivers/media/dvb/frontends/or51132.c +++ b/drivers/media/dvb/frontends/or51132.c | |||
| @@ -370,22 +370,19 @@ static int or51132_set_parameters(struct dvb_frontend* fe, | |||
| 370 | or51132_setmode(fe); | 370 | or51132_setmode(fe); |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | /* Change only if we are actually changing the channel */ | 373 | dvb_pll_configure(state->config->pll_desc, buf, |
| 374 | if (state->current_frequency != param->frequency) { | 374 | param->frequency, 0); |
| 375 | dvb_pll_configure(state->config->pll_desc, buf, | 375 | dprintk("set_parameters tuner bytes: 0x%02x 0x%02x " |
| 376 | param->frequency, 0); | 376 | "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]); |
| 377 | dprintk("set_parameters tuner bytes: 0x%02x 0x%02x " | 377 | if (i2c_writebytes(state, state->config->pll_address ,buf, 4)) |
| 378 | "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]); | 378 | printk(KERN_WARNING "or51132: set_parameters error " |
| 379 | if (i2c_writebytes(state, state->config->pll_address ,buf, 4)) | 379 | "writing to tuner\n"); |
| 380 | printk(KERN_WARNING "or51132: set_parameters error " | 380 | |
| 381 | "writing to tuner\n"); | 381 | /* Set to current mode */ |
| 382 | 382 | or51132_setmode(fe); | |
| 383 | /* Set to current mode */ | 383 | |
| 384 | or51132_setmode(fe); | 384 | /* Update current frequency */ |
| 385 | 385 | state->current_frequency = param->frequency; | |
| 386 | /* Update current frequency */ | ||
| 387 | state->current_frequency = param->frequency; | ||
| 388 | } | ||
| 389 | return 0; | 386 | return 0; |
| 390 | } | 387 | } |
| 391 | 388 | ||
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 4f396ac8de77..c7fe27fd530c 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c | |||
| @@ -48,7 +48,8 @@ struct s5h1420_state { | |||
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); | 50 | static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); |
| 51 | static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings); | 51 | static int s5h1420_get_tune_settings(struct dvb_frontend* fe, |
| 52 | struct dvb_frontend_tune_settings* fesettings); | ||
| 52 | 53 | ||
| 53 | 54 | ||
| 54 | static int debug = 0; | 55 | static int debug = 0; |
| @@ -91,7 +92,8 @@ static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag | |||
| 91 | 92 | ||
| 92 | switch(voltage) { | 93 | switch(voltage) { |
| 93 | case SEC_VOLTAGE_13: | 94 | case SEC_VOLTAGE_13: |
| 94 | s5h1420_writereg(state, 0x3c, (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02); | 95 | s5h1420_writereg(state, 0x3c, |
| 96 | (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02); | ||
| 95 | break; | 97 | break; |
| 96 | 98 | ||
| 97 | case SEC_VOLTAGE_18: | 99 | case SEC_VOLTAGE_18: |
| @@ -112,18 +114,21 @@ static int s5h1420_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
| 112 | 114 | ||
| 113 | switch(tone) { | 115 | switch(tone) { |
| 114 | case SEC_TONE_ON: | 116 | case SEC_TONE_ON: |
| 115 | s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08); | 117 | s5h1420_writereg(state, 0x3b, |
| 118 | (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08); | ||
| 116 | break; | 119 | break; |
| 117 | 120 | ||
| 118 | case SEC_TONE_OFF: | 121 | case SEC_TONE_OFF: |
| 119 | s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); | 122 | s5h1420_writereg(state, 0x3b, |
| 123 | (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); | ||
| 120 | break; | 124 | break; |
| 121 | } | 125 | } |
| 122 | 126 | ||
| 123 | return 0; | 127 | return 0; |
| 124 | } | 128 | } |
| 125 | 129 | ||
| 126 | static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd) | 130 | static int s5h1420_send_master_cmd (struct dvb_frontend* fe, |
| 131 | struct dvb_diseqc_master_cmd* cmd) | ||
| 127 | { | 132 | { |
| 128 | struct s5h1420_state* state = fe->demodulator_priv; | 133 | struct s5h1420_state* state = fe->demodulator_priv; |
| 129 | u8 val; | 134 | u8 val; |
| @@ -131,6 +136,9 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m | |||
| 131 | unsigned long timeout; | 136 | unsigned long timeout; |
| 132 | int result = 0; | 137 | int result = 0; |
| 133 | 138 | ||
| 139 | if (cmd->msg_len > 8) | ||
| 140 | return -EINVAL; | ||
| 141 | |||
| 134 | /* setup for DISEQC */ | 142 | /* setup for DISEQC */ |
| 135 | val = s5h1420_readreg(state, 0x3b); | 143 | val = s5h1420_readreg(state, 0x3b); |
| 136 | s5h1420_writereg(state, 0x3b, 0x02); | 144 | s5h1420_writereg(state, 0x3b, 0x02); |
| @@ -138,16 +146,17 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m | |||
| 138 | 146 | ||
| 139 | /* write the DISEQC command bytes */ | 147 | /* write the DISEQC command bytes */ |
| 140 | for(i=0; i< cmd->msg_len; i++) { | 148 | for(i=0; i< cmd->msg_len; i++) { |
| 141 | s5h1420_writereg(state, 0x3c + i, cmd->msg[i]); | 149 | s5h1420_writereg(state, 0x3d + i, cmd->msg[i]); |
| 142 | } | 150 | } |
| 143 | 151 | ||
| 144 | /* kick off transmission */ | 152 | /* kick off transmission */ |
| 145 | s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | ((cmd->msg_len-1) << 4) | 0x08); | 153 | s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | |
| 154 | ((cmd->msg_len-1) << 4) | 0x08); | ||
| 146 | 155 | ||
| 147 | /* wait for transmission to complete */ | 156 | /* wait for transmission to complete */ |
| 148 | timeout = jiffies + ((100*HZ) / 1000); | 157 | timeout = jiffies + ((100*HZ) / 1000); |
| 149 | while(time_before(jiffies, timeout)) { | 158 | while(time_before(jiffies, timeout)) { |
| 150 | if (s5h1420_readreg(state, 0x3b) & 0x08) | 159 | if (!(s5h1420_readreg(state, 0x3b) & 0x08)) |
| 151 | break; | 160 | break; |
| 152 | 161 | ||
| 153 | msleep(5); | 162 | msleep(5); |
| @@ -161,7 +170,8 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, struct dvb_diseqc_m | |||
| 161 | return result; | 170 | return result; |
| 162 | } | 171 | } |
| 163 | 172 | ||
| 164 | static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply) | 173 | static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, |
| 174 | struct dvb_diseqc_slave_reply* reply) | ||
| 165 | { | 175 | { |
| 166 | struct s5h1420_state* state = fe->demodulator_priv; | 176 | struct s5h1420_state* state = fe->demodulator_priv; |
| 167 | u8 val; | 177 | u8 val; |
| @@ -205,7 +215,7 @@ static int s5h1420_recv_slave_reply (struct dvb_frontend* fe, struct dvb_diseqc_ | |||
| 205 | 215 | ||
| 206 | /* extract data */ | 216 | /* extract data */ |
| 207 | for(i=0; i< length; i++) { | 217 | for(i=0; i< length; i++) { |
| 208 | reply->msg[i] = s5h1420_readreg(state, 0x3c + i); | 218 | reply->msg[i] = s5h1420_readreg(state, 0x3d + i); |
| 209 | } | 219 | } |
| 210 | 220 | ||
| 211 | exit: | 221 | exit: |
| @@ -236,7 +246,7 @@ static int s5h1420_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minicm | |||
| 236 | s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08); | 246 | s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08); |
| 237 | 247 | ||
| 238 | /* wait for transmission to complete */ | 248 | /* wait for transmission to complete */ |
| 239 | timeout = jiffies + ((20*HZ) / 1000); | 249 | timeout = jiffies + ((100*HZ) / 1000); |
| 240 | while(time_before(jiffies, timeout)) { | 250 | while(time_before(jiffies, timeout)) { |
| 241 | if (!(s5h1420_readreg(state, 0x3b) & 0x08)) | 251 | if (!(s5h1420_readreg(state, 0x3b) & 0x08)) |
| 242 | break; | 252 | break; |
| @@ -259,9 +269,9 @@ static fe_status_t s5h1420_get_status_bits(struct s5h1420_state* state) | |||
| 259 | 269 | ||
| 260 | val = s5h1420_readreg(state, 0x14); | 270 | val = s5h1420_readreg(state, 0x14); |
| 261 | if (val & 0x02) | 271 | if (val & 0x02) |
| 262 | status |= FE_HAS_SIGNAL; // FIXME: not sure if this is right | 272 | status |= FE_HAS_SIGNAL; |
| 263 | if (val & 0x01) | 273 | if (val & 0x01) |
| 264 | status |= FE_HAS_CARRIER; // FIXME: not sure if this is right | 274 | status |= FE_HAS_CARRIER; |
| 265 | val = s5h1420_readreg(state, 0x36); | 275 | val = s5h1420_readreg(state, 0x36); |
| 266 | if (val & 0x01) | 276 | if (val & 0x01) |
| 267 | status |= FE_HAS_VITERBI; | 277 | status |= FE_HAS_VITERBI; |
| @@ -284,8 +294,8 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 284 | /* determine lock state */ | 294 | /* determine lock state */ |
| 285 | *status = s5h1420_get_status_bits(state); | 295 | *status = s5h1420_get_status_bits(state); |
| 286 | 296 | ||
| 287 | /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert the inversion, | 297 | /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert |
| 288 | wait a bit and check again */ | 298 | the inversion, wait a bit and check again */ |
| 289 | if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) { | 299 | if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) { |
| 290 | val = s5h1420_readreg(state, 0x32); | 300 | val = s5h1420_readreg(state, 0x32); |
| 291 | if ((val & 0x07) == 0x03) { | 301 | if ((val & 0x07) == 0x03) { |
| @@ -330,6 +340,10 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 330 | tmp = (tmp * 2 * 7) / 8; | 340 | tmp = (tmp * 2 * 7) / 8; |
| 331 | break; | 341 | break; |
| 332 | } | 342 | } |
| 343 | if (tmp == 0) { | ||
| 344 | printk("s5h1420: avoided division by 0\n"); | ||
| 345 | tmp = 1; | ||
| 346 | } | ||
| 333 | tmp = state->fclk / tmp; | 347 | tmp = state->fclk / tmp; |
| 334 | 348 | ||
| 335 | /* set the MPEG_CLK_INTL for the calculated data rate */ | 349 | /* set the MPEG_CLK_INTL for the calculated data rate */ |
| @@ -368,16 +382,21 @@ static int s5h1420_read_ber(struct dvb_frontend* fe, u32* ber) | |||
| 368 | 382 | ||
| 369 | s5h1420_writereg(state, 0x46, 0x1d); | 383 | s5h1420_writereg(state, 0x46, 0x1d); |
| 370 | mdelay(25); | 384 | mdelay(25); |
| 371 | return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); | 385 | |
| 386 | *ber = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); | ||
| 387 | |||
| 388 | return 0; | ||
| 372 | } | 389 | } |
| 373 | 390 | ||
| 374 | static int s5h1420_read_signal_strength(struct dvb_frontend* fe, u16* strength) | 391 | static int s5h1420_read_signal_strength(struct dvb_frontend* fe, u16* strength) |
| 375 | { | 392 | { |
| 376 | struct s5h1420_state* state = fe->demodulator_priv; | 393 | struct s5h1420_state* state = fe->demodulator_priv; |
| 377 | 394 | ||
| 378 | u8 val = 0xff - s5h1420_readreg(state, 0x15); | 395 | u8 val = s5h1420_readreg(state, 0x15); |
| 379 | 396 | ||
| 380 | return (int) ((val << 8) | val); | 397 | *strength = (u16) ((val << 8) | val); |
| 398 | |||
| 399 | return 0; | ||
| 381 | } | 400 | } |
| 382 | 401 | ||
| 383 | static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | 402 | static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) |
| @@ -386,7 +405,10 @@ static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
| 386 | 405 | ||
| 387 | s5h1420_writereg(state, 0x46, 0x1f); | 406 | s5h1420_writereg(state, 0x46, 0x1f); |
| 388 | mdelay(25); | 407 | mdelay(25); |
| 389 | return (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); | 408 | |
| 409 | *ucblocks = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47); | ||
| 410 | |||
| 411 | return 0; | ||
| 390 | } | 412 | } |
| 391 | 413 | ||
| 392 | static void s5h1420_reset(struct s5h1420_state* state) | 414 | static void s5h1420_reset(struct s5h1420_state* state) |
| @@ -396,11 +418,12 @@ static void s5h1420_reset(struct s5h1420_state* state) | |||
| 396 | udelay(10); | 418 | udelay(10); |
| 397 | } | 419 | } |
| 398 | 420 | ||
| 399 | static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_frontend_parameters *p) | 421 | static void s5h1420_setsymbolrate(struct s5h1420_state* state, |
| 422 | struct dvb_frontend_parameters *p) | ||
| 400 | { | 423 | { |
| 401 | u64 val; | 424 | u64 val; |
| 402 | 425 | ||
| 403 | val = (p->u.qpsk.symbol_rate / 1000) * (1<<24); | 426 | val = ((u64) p->u.qpsk.symbol_rate / 1000ULL) * (1ULL<<24); |
| 404 | if (p->u.qpsk.symbol_rate <= 21000000) { | 427 | if (p->u.qpsk.symbol_rate <= 21000000) { |
| 405 | val *= 2; | 428 | val *= 2; |
| 406 | } | 429 | } |
| @@ -415,7 +438,7 @@ static void s5h1420_setsymbolrate(struct s5h1420_state* state, struct dvb_fronte | |||
| 415 | 438 | ||
| 416 | static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) | 439 | static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) |
| 417 | { | 440 | { |
| 418 | u64 val; | 441 | u64 val = 0; |
| 419 | int sampling = 2; | 442 | int sampling = 2; |
| 420 | 443 | ||
| 421 | if (s5h1420_readreg(state, 0x05) & 0x2) | 444 | if (s5h1420_readreg(state, 0x05) & 0x2) |
| @@ -427,10 +450,10 @@ static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) | |||
| 427 | val |= s5h1420_readreg(state, 0x13); | 450 | val |= s5h1420_readreg(state, 0x13); |
| 428 | s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7); | 451 | s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7); |
| 429 | 452 | ||
| 430 | val *= (state->fclk / 1000); | 453 | val *= (state->fclk / 1000ULL); |
| 431 | do_div(val, ((1<<24) * sampling)); | 454 | do_div(val, ((1<<24) * sampling)); |
| 432 | 455 | ||
| 433 | return (u32) (val * 1000); | 456 | return (u32) (val * 1000ULL); |
| 434 | } | 457 | } |
| 435 | 458 | ||
| 436 | static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset) | 459 | static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset) |
| @@ -463,46 +486,55 @@ static int s5h1420_getfreqoffset(struct s5h1420_state* state) | |||
| 463 | 486 | ||
| 464 | /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so | 487 | /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so |
| 465 | * divide fclk by 1000000 to get the correct value. */ | 488 | * divide fclk by 1000000 to get the correct value. */ |
| 466 | val = - ((val * (state->fclk/1000000)) / (1<<24)); | 489 | val = (((-val) * (state->fclk/1000000)) / (1<<24)); |
| 467 | 490 | ||
| 468 | return val; | 491 | return val; |
| 469 | } | 492 | } |
| 470 | 493 | ||
| 471 | static void s5h1420_setfec(struct s5h1420_state* state, struct dvb_frontend_parameters *p) | 494 | static void s5h1420_setfec_inversion(struct s5h1420_state* state, |
| 495 | struct dvb_frontend_parameters *p) | ||
| 472 | { | 496 | { |
| 497 | u8 inversion = 0; | ||
| 498 | |||
| 499 | if (p->inversion == INVERSION_OFF) { | ||
| 500 | inversion = state->config->invert ? 0x08 : 0; | ||
| 501 | } else if (p->inversion == INVERSION_ON) { | ||
| 502 | inversion = state->config->invert ? 0 : 0x08; | ||
| 503 | } | ||
| 504 | |||
| 473 | if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { | 505 | if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { |
| 474 | s5h1420_writereg(state, 0x31, 0x00); | ||
| 475 | s5h1420_writereg(state, 0x30, 0x3f); | 506 | s5h1420_writereg(state, 0x30, 0x3f); |
| 507 | s5h1420_writereg(state, 0x31, 0x00 | inversion); | ||
| 476 | } else { | 508 | } else { |
| 477 | switch(p->u.qpsk.fec_inner) { | 509 | switch(p->u.qpsk.fec_inner) { |
| 478 | case FEC_1_2: | 510 | case FEC_1_2: |
| 479 | s5h1420_writereg(state, 0x31, 0x10); | ||
| 480 | s5h1420_writereg(state, 0x30, 0x01); | 511 | s5h1420_writereg(state, 0x30, 0x01); |
| 512 | s5h1420_writereg(state, 0x31, 0x10 | inversion); | ||
| 481 | break; | 513 | break; |
| 482 | 514 | ||
| 483 | case FEC_2_3: | 515 | case FEC_2_3: |
| 484 | s5h1420_writereg(state, 0x31, 0x11); | ||
| 485 | s5h1420_writereg(state, 0x30, 0x02); | 516 | s5h1420_writereg(state, 0x30, 0x02); |
| 517 | s5h1420_writereg(state, 0x31, 0x11 | inversion); | ||
| 486 | break; | 518 | break; |
| 487 | 519 | ||
| 488 | case FEC_3_4: | 520 | case FEC_3_4: |
| 489 | s5h1420_writereg(state, 0x31, 0x12); | ||
| 490 | s5h1420_writereg(state, 0x30, 0x04); | 521 | s5h1420_writereg(state, 0x30, 0x04); |
| 491 | break; | 522 | s5h1420_writereg(state, 0x31, 0x12 | inversion); |
| 523 | break; | ||
| 492 | 524 | ||
| 493 | case FEC_5_6: | 525 | case FEC_5_6: |
| 494 | s5h1420_writereg(state, 0x31, 0x13); | ||
| 495 | s5h1420_writereg(state, 0x30, 0x08); | 526 | s5h1420_writereg(state, 0x30, 0x08); |
| 527 | s5h1420_writereg(state, 0x31, 0x13 | inversion); | ||
| 496 | break; | 528 | break; |
| 497 | 529 | ||
| 498 | case FEC_6_7: | 530 | case FEC_6_7: |
| 499 | s5h1420_writereg(state, 0x31, 0x14); | ||
| 500 | s5h1420_writereg(state, 0x30, 0x10); | 531 | s5h1420_writereg(state, 0x30, 0x10); |
| 532 | s5h1420_writereg(state, 0x31, 0x14 | inversion); | ||
| 501 | break; | 533 | break; |
| 502 | 534 | ||
| 503 | case FEC_7_8: | 535 | case FEC_7_8: |
| 504 | s5h1420_writereg(state, 0x31, 0x15); | ||
| 505 | s5h1420_writereg(state, 0x30, 0x20); | 536 | s5h1420_writereg(state, 0x30, 0x20); |
| 537 | s5h1420_writereg(state, 0x31, 0x15 | inversion); | ||
| 506 | break; | 538 | break; |
| 507 | 539 | ||
| 508 | default: | 540 | default: |
| @@ -536,22 +568,6 @@ static fe_code_rate_t s5h1420_getfec(struct s5h1420_state* state) | |||
| 536 | return FEC_NONE; | 568 | return FEC_NONE; |
| 537 | } | 569 | } |
| 538 | 570 | ||
| 539 | static void s5h1420_setinversion(struct s5h1420_state* state, struct dvb_frontend_parameters *p) | ||
| 540 | { | ||
| 541 | if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { | ||
| 542 | s5h1420_writereg(state, 0x31, 0x00); | ||
| 543 | s5h1420_writereg(state, 0x30, 0x3f); | ||
| 544 | } else { | ||
| 545 | u8 tmp = s5h1420_readreg(state, 0x31) & 0xf7; | ||
| 546 | tmp |= 0x10; | ||
| 547 | |||
| 548 | if (p->inversion == INVERSION_ON) | ||
| 549 | tmp |= 0x80; | ||
| 550 | |||
| 551 | s5h1420_writereg(state, 0x31, tmp); | ||
| 552 | } | ||
| 553 | } | ||
| 554 | |||
| 555 | static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) | 571 | static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) |
| 556 | { | 572 | { |
| 557 | if (s5h1420_readreg(state, 0x32) & 0x08) | 573 | if (s5h1420_readreg(state, 0x32) & 0x08) |
| @@ -560,35 +576,35 @@ static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state) | |||
| 560 | return INVERSION_OFF; | 576 | return INVERSION_OFF; |
| 561 | } | 577 | } |
| 562 | 578 | ||
| 563 | static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 579 | static int s5h1420_set_frontend(struct dvb_frontend* fe, |
| 580 | struct dvb_frontend_parameters *p) | ||
| 564 | { | 581 | { |
| 565 | struct s5h1420_state* state = fe->demodulator_priv; | 582 | struct s5h1420_state* state = fe->demodulator_priv; |
| 566 | u32 frequency_delta; | 583 | int frequency_delta; |
| 567 | struct dvb_frontend_tune_settings fesettings; | 584 | struct dvb_frontend_tune_settings fesettings; |
| 585 | u32 tmp; | ||
| 568 | 586 | ||
| 569 | /* check if we should do a fast-tune */ | 587 | /* check if we should do a fast-tune */ |
| 570 | memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters)); | 588 | memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters)); |
| 571 | s5h1420_get_tune_settings(fe, &fesettings); | 589 | s5h1420_get_tune_settings(fe, &fesettings); |
| 572 | frequency_delta = p->frequency - state->tunedfreq; | 590 | frequency_delta = p->frequency - state->tunedfreq; |
| 573 | if ((frequency_delta > -fesettings.max_drift) && (frequency_delta < fesettings.max_drift) && | 591 | if ((frequency_delta > -fesettings.max_drift) && |
| 592 | (frequency_delta < fesettings.max_drift) && | ||
| 574 | (frequency_delta != 0) && | 593 | (frequency_delta != 0) && |
| 575 | (state->fec_inner == p->u.qpsk.fec_inner) && | 594 | (state->fec_inner == p->u.qpsk.fec_inner) && |
| 576 | (state->symbol_rate == p->u.qpsk.symbol_rate)) { | 595 | (state->symbol_rate == p->u.qpsk.symbol_rate)) { |
| 577 | 596 | ||
| 578 | s5h1420_setfreqoffset(state, frequency_delta); | 597 | if (state->config->pll_set) { |
| 598 | s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); | ||
| 599 | state->config->pll_set(fe, p, &tmp); | ||
| 600 | s5h1420_setfreqoffset(state, p->frequency - tmp); | ||
| 601 | } | ||
| 579 | return 0; | 602 | return 0; |
| 580 | } | 603 | } |
| 581 | 604 | ||
| 582 | /* first of all, software reset */ | 605 | /* first of all, software reset */ |
| 583 | s5h1420_reset(state); | 606 | s5h1420_reset(state); |
| 584 | 607 | ||
| 585 | /* set tuner PLL */ | ||
| 586 | if (state->config->pll_set) { | ||
| 587 | s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); | ||
| 588 | state->config->pll_set(fe, p, &state->tunedfreq); | ||
| 589 | s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe); | ||
| 590 | } | ||
| 591 | |||
| 592 | /* set s5h1420 fclk PLL according to desired symbol rate */ | 608 | /* set s5h1420 fclk PLL according to desired symbol rate */ |
| 593 | if (p->u.qpsk.symbol_rate > 28000000) { | 609 | if (p->u.qpsk.symbol_rate > 28000000) { |
| 594 | state->fclk = 88000000; | 610 | state->fclk = 88000000; |
| @@ -609,8 +625,9 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 609 | 625 | ||
| 610 | /* set misc registers */ | 626 | /* set misc registers */ |
| 611 | s5h1420_writereg(state, 0x02, 0x00); | 627 | s5h1420_writereg(state, 0x02, 0x00); |
| 628 | s5h1420_writereg(state, 0x06, 0x00); | ||
| 612 | s5h1420_writereg(state, 0x07, 0xb0); | 629 | s5h1420_writereg(state, 0x07, 0xb0); |
| 613 | s5h1420_writereg(state, 0x0a, 0x67); | 630 | s5h1420_writereg(state, 0x0a, 0xe7); |
| 614 | s5h1420_writereg(state, 0x0b, 0x78); | 631 | s5h1420_writereg(state, 0x0b, 0x78); |
| 615 | s5h1420_writereg(state, 0x0c, 0x48); | 632 | s5h1420_writereg(state, 0x0c, 0x48); |
| 616 | s5h1420_writereg(state, 0x0d, 0x6b); | 633 | s5h1420_writereg(state, 0x0d, 0x6b); |
| @@ -626,21 +643,26 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 626 | /* start QPSK */ | 643 | /* start QPSK */ |
| 627 | s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); | 644 | s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); |
| 628 | 645 | ||
| 629 | /* set the frequency offset to adjust for PLL inaccuracy */ | 646 | /* set tuner PLL */ |
| 630 | s5h1420_setfreqoffset(state, p->frequency - state->tunedfreq); | 647 | if (state->config->pll_set) { |
| 648 | s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); | ||
| 649 | state->config->pll_set(fe, p, &tmp); | ||
| 650 | s5h1420_setfreqoffset(state, 0); | ||
| 651 | } | ||
| 631 | 652 | ||
| 632 | /* set the reset of the parameters */ | 653 | /* set the reset of the parameters */ |
| 633 | s5h1420_setsymbolrate(state, p); | 654 | s5h1420_setsymbolrate(state, p); |
| 634 | s5h1420_setinversion(state, p); | 655 | s5h1420_setfec_inversion(state, p); |
| 635 | s5h1420_setfec(state, p); | ||
| 636 | 656 | ||
| 637 | state->fec_inner = p->u.qpsk.fec_inner; | 657 | state->fec_inner = p->u.qpsk.fec_inner; |
| 638 | state->symbol_rate = p->u.qpsk.symbol_rate; | 658 | state->symbol_rate = p->u.qpsk.symbol_rate; |
| 639 | state->postlocked = 0; | 659 | state->postlocked = 0; |
| 660 | state->tunedfreq = p->frequency; | ||
| 640 | return 0; | 661 | return 0; |
| 641 | } | 662 | } |
| 642 | 663 | ||
| 643 | static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 664 | static int s5h1420_get_frontend(struct dvb_frontend* fe, |
| 665 | struct dvb_frontend_parameters *p) | ||
| 644 | { | 666 | { |
| 645 | struct s5h1420_state* state = fe->demodulator_priv; | 667 | struct s5h1420_state* state = fe->demodulator_priv; |
| 646 | 668 | ||
| @@ -652,7 +674,8 @@ static int s5h1420_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 652 | return 0; | 674 | return 0; |
| 653 | } | 675 | } |
| 654 | 676 | ||
| 655 | static int s5h1420_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) | 677 | static int s5h1420_get_tune_settings(struct dvb_frontend* fe, |
| 678 | struct dvb_frontend_tune_settings* fesettings) | ||
| 656 | { | 679 | { |
| 657 | if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) { | 680 | if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) { |
| 658 | fesettings->min_delay_ms = 50; | 681 | fesettings->min_delay_ms = 50; |
| @@ -717,7 +740,8 @@ static void s5h1420_release(struct dvb_frontend* fe) | |||
| 717 | 740 | ||
| 718 | static struct dvb_frontend_ops s5h1420_ops; | 741 | static struct dvb_frontend_ops s5h1420_ops; |
| 719 | 742 | ||
| 720 | struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, struct i2c_adapter* i2c) | 743 | struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, |
| 744 | struct i2c_adapter* i2c) | ||
| 721 | { | 745 | { |
| 722 | struct s5h1420_state* state = NULL; | 746 | struct s5h1420_state* state = NULL; |
| 723 | u8 identity; | 747 | u8 identity; |
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h index b687fc77ceb3..872028ddf2a2 100644 --- a/drivers/media/dvb/frontends/s5h1420.h +++ b/drivers/media/dvb/frontends/s5h1420.h | |||
| @@ -30,6 +30,9 @@ struct s5h1420_config | |||
| 30 | /* the demodulator's i2c address */ | 30 | /* the demodulator's i2c address */ |
| 31 | u8 demod_address; | 31 | u8 demod_address; |
| 32 | 32 | ||
| 33 | /* does the inversion require inversion? */ | ||
| 34 | u8 invert:1; | ||
| 35 | |||
| 33 | /* PLL maintenance */ | 36 | /* PLL maintenance */ |
| 34 | int (*pll_init)(struct dvb_frontend* fe); | 37 | int (*pll_init)(struct dvb_frontend* fe); |
| 35 | int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout); | 38 | int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u32* freqout); |
diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 928aca052afe..8d09afd7545d 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c | |||
| @@ -35,7 +35,6 @@ struct stv0297_state { | |||
| 35 | struct dvb_frontend frontend; | 35 | struct dvb_frontend frontend; |
| 36 | 36 | ||
| 37 | unsigned long base_freq; | 37 | unsigned long base_freq; |
| 38 | u8 pwm; | ||
| 39 | }; | 38 | }; |
| 40 | 39 | ||
| 41 | #if 1 | 40 | #if 1 |
| @@ -46,94 +45,6 @@ struct stv0297_state { | |||
| 46 | 45 | ||
| 47 | #define STV0297_CLOCK_KHZ 28900 | 46 | #define STV0297_CLOCK_KHZ 28900 |
| 48 | 47 | ||
| 49 | static u8 init_tab[] = { | ||
| 50 | 0x00, 0x09, | ||
| 51 | 0x01, 0x69, | ||
| 52 | 0x03, 0x00, | ||
| 53 | 0x04, 0x00, | ||
| 54 | 0x07, 0x00, | ||
| 55 | 0x08, 0x00, | ||
| 56 | 0x20, 0x00, | ||
| 57 | 0x21, 0x40, | ||
| 58 | 0x22, 0x00, | ||
| 59 | 0x23, 0x00, | ||
| 60 | 0x24, 0x40, | ||
| 61 | 0x25, 0x88, | ||
| 62 | 0x30, 0xff, | ||
| 63 | 0x31, 0x00, | ||
| 64 | 0x32, 0xff, | ||
| 65 | 0x33, 0x00, | ||
| 66 | 0x34, 0x50, | ||
| 67 | 0x35, 0x7f, | ||
| 68 | 0x36, 0x00, | ||
| 69 | 0x37, 0x20, | ||
| 70 | 0x38, 0x00, | ||
| 71 | 0x40, 0x1c, | ||
| 72 | 0x41, 0xff, | ||
| 73 | 0x42, 0x29, | ||
| 74 | 0x43, 0x00, | ||
| 75 | 0x44, 0xff, | ||
| 76 | 0x45, 0x00, | ||
| 77 | 0x46, 0x00, | ||
| 78 | 0x49, 0x04, | ||
| 79 | 0x4a, 0xff, | ||
| 80 | 0x4b, 0x7f, | ||
| 81 | 0x52, 0x30, | ||
| 82 | 0x55, 0xae, | ||
| 83 | 0x56, 0x47, | ||
| 84 | 0x57, 0xe1, | ||
| 85 | 0x58, 0x3a, | ||
| 86 | 0x5a, 0x1e, | ||
| 87 | 0x5b, 0x34, | ||
| 88 | 0x60, 0x00, | ||
| 89 | 0x63, 0x00, | ||
| 90 | 0x64, 0x00, | ||
| 91 | 0x65, 0x00, | ||
| 92 | 0x66, 0x00, | ||
| 93 | 0x67, 0x00, | ||
| 94 | 0x68, 0x00, | ||
| 95 | 0x69, 0x00, | ||
| 96 | 0x6a, 0x02, | ||
| 97 | 0x6b, 0x00, | ||
| 98 | 0x70, 0xff, | ||
| 99 | 0x71, 0x00, | ||
| 100 | 0x72, 0x00, | ||
| 101 | 0x73, 0x00, | ||
| 102 | 0x74, 0x0c, | ||
| 103 | 0x80, 0x00, | ||
| 104 | 0x81, 0x00, | ||
| 105 | 0x82, 0x00, | ||
| 106 | 0x83, 0x00, | ||
| 107 | 0x84, 0x04, | ||
| 108 | 0x85, 0x80, | ||
| 109 | 0x86, 0x24, | ||
| 110 | 0x87, 0x78, | ||
| 111 | 0x88, 0x00, | ||
| 112 | 0x89, 0x00, | ||
| 113 | 0x90, 0x01, | ||
| 114 | 0x91, 0x01, | ||
| 115 | 0xa0, 0x00, | ||
| 116 | 0xa1, 0x00, | ||
| 117 | 0xa2, 0x00, | ||
| 118 | 0xb0, 0x91, | ||
| 119 | 0xb1, 0x0b, | ||
| 120 | 0xc0, 0x53, | ||
| 121 | 0xc1, 0x70, | ||
| 122 | 0xc2, 0x12, | ||
| 123 | 0xd0, 0x00, | ||
| 124 | 0xd1, 0x00, | ||
| 125 | 0xd2, 0x00, | ||
| 126 | 0xd3, 0x00, | ||
| 127 | 0xd4, 0x00, | ||
| 128 | 0xd5, 0x00, | ||
| 129 | 0xde, 0x00, | ||
| 130 | 0xdf, 0x00, | ||
| 131 | 0x61, 0x49, | ||
| 132 | 0x62, 0x0b, | ||
| 133 | 0x53, 0x08, | ||
| 134 | 0x59, 0x08, | ||
| 135 | }; | ||
| 136 | |||
| 137 | 48 | ||
| 138 | static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data) | 49 | static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data) |
| 139 | { | 50 | { |
| @@ -378,34 +289,9 @@ static int stv0297_init(struct dvb_frontend *fe) | |||
| 378 | struct stv0297_state *state = fe->demodulator_priv; | 289 | struct stv0297_state *state = fe->demodulator_priv; |
| 379 | int i; | 290 | int i; |
| 380 | 291 | ||
| 381 | /* soft reset */ | ||
| 382 | stv0297_writereg_mask(state, 0x80, 1, 1); | ||
| 383 | stv0297_writereg_mask(state, 0x80, 1, 0); | ||
| 384 | |||
| 385 | /* reset deinterleaver */ | ||
| 386 | stv0297_writereg_mask(state, 0x81, 1, 1); | ||
| 387 | stv0297_writereg_mask(state, 0x81, 1, 0); | ||
| 388 | |||
| 389 | /* load init table */ | 292 | /* load init table */ |
| 390 | for (i = 0; i < sizeof(init_tab); i += 2) { | 293 | for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2) |
| 391 | stv0297_writereg(state, init_tab[i], init_tab[i + 1]); | 294 | stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]); |
| 392 | } | ||
| 393 | |||
| 394 | /* set a dummy symbol rate */ | ||
| 395 | stv0297_set_symbolrate(state, 6900); | ||
| 396 | |||
| 397 | /* invert AGC1 polarity */ | ||
| 398 | stv0297_writereg_mask(state, 0x88, 0x10, 0x10); | ||
| 399 | |||
| 400 | /* setup bit error counting */ | ||
| 401 | stv0297_writereg_mask(state, 0xA0, 0x80, 0x00); | ||
| 402 | stv0297_writereg_mask(state, 0xA0, 0x10, 0x00); | ||
| 403 | stv0297_writereg_mask(state, 0xA0, 0x08, 0x00); | ||
| 404 | stv0297_writereg_mask(state, 0xA0, 0x07, 0x04); | ||
| 405 | |||
| 406 | /* min + max PWM */ | ||
| 407 | stv0297_writereg(state, 0x4a, 0x00); | ||
| 408 | stv0297_writereg(state, 0x4b, state->pwm); | ||
| 409 | msleep(200); | 295 | msleep(200); |
| 410 | 296 | ||
| 411 | if (state->config->pll_init) | 297 | if (state->config->pll_init) |
| @@ -606,7 +492,13 @@ static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_par | |||
| 606 | stv0297_set_inversion(state, inversion); | 492 | stv0297_set_inversion(state, inversion); |
| 607 | 493 | ||
| 608 | /* kick off lock */ | 494 | /* kick off lock */ |
| 609 | stv0297_writereg_mask(state, 0x88, 0x08, 0x08); | 495 | /* Disable corner detection for higher QAMs */ |
| 496 | if (p->u.qam.modulation == QAM_128 || | ||
| 497 | p->u.qam.modulation == QAM_256) | ||
| 498 | stv0297_writereg_mask(state, 0x88, 0x08, 0x00); | ||
| 499 | else | ||
| 500 | stv0297_writereg_mask(state, 0x88, 0x08, 0x08); | ||
| 501 | |||
| 610 | stv0297_writereg_mask(state, 0x5a, 0x20, 0x00); | 502 | stv0297_writereg_mask(state, 0x5a, 0x20, 0x00); |
| 611 | stv0297_writereg_mask(state, 0x6a, 0x01, 0x01); | 503 | stv0297_writereg_mask(state, 0x6a, 0x01, 0x01); |
| 612 | stv0297_writereg_mask(state, 0x43, 0x40, 0x40); | 504 | stv0297_writereg_mask(state, 0x43, 0x40, 0x40); |
| @@ -732,7 +624,7 @@ static void stv0297_release(struct dvb_frontend *fe) | |||
| 732 | static struct dvb_frontend_ops stv0297_ops; | 624 | static struct dvb_frontend_ops stv0297_ops; |
| 733 | 625 | ||
| 734 | struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, | 626 | struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, |
| 735 | struct i2c_adapter *i2c, int pwm) | 627 | struct i2c_adapter *i2c) |
| 736 | { | 628 | { |
| 737 | struct stv0297_state *state = NULL; | 629 | struct stv0297_state *state = NULL; |
| 738 | 630 | ||
| @@ -746,7 +638,6 @@ struct dvb_frontend *stv0297_attach(const struct stv0297_config *config, | |||
| 746 | state->i2c = i2c; | 638 | state->i2c = i2c; |
| 747 | memcpy(&state->ops, &stv0297_ops, sizeof(struct dvb_frontend_ops)); | 639 | memcpy(&state->ops, &stv0297_ops, sizeof(struct dvb_frontend_ops)); |
| 748 | state->base_freq = 0; | 640 | state->base_freq = 0; |
| 749 | state->pwm = pwm; | ||
| 750 | 641 | ||
| 751 | /* check if the demod is there */ | 642 | /* check if the demod is there */ |
| 752 | if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20) | 643 | if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20) |
diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h index 3be535989302..9e53f019db71 100644 --- a/drivers/media/dvb/frontends/stv0297.h +++ b/drivers/media/dvb/frontends/stv0297.h | |||
| @@ -29,6 +29,12 @@ struct stv0297_config | |||
| 29 | /* the demodulator's i2c address */ | 29 | /* the demodulator's i2c address */ |
| 30 | u8 demod_address; | 30 | u8 demod_address; |
| 31 | 31 | ||
| 32 | /* inittab - array of pairs of values. | ||
| 33 | * First of each pair is the register, second is the value. | ||
| 34 | * List should be terminated with an 0xff, 0xff pair. | ||
| 35 | */ | ||
| 36 | u8* inittab; | ||
| 37 | |||
| 32 | /* does the "inversion" need inverted? */ | 38 | /* does the "inversion" need inverted? */ |
| 33 | u8 invert:1; | 39 | u8 invert:1; |
| 34 | 40 | ||
| @@ -38,7 +44,7 @@ struct stv0297_config | |||
| 38 | }; | 44 | }; |
| 39 | 45 | ||
| 40 | extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, | 46 | extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, |
| 41 | struct i2c_adapter* i2c, int pwm); | 47 | struct i2c_adapter* i2c); |
| 42 | extern int stv0297_enable_plli2c(struct dvb_frontend* fe); | 48 | extern int stv0297_enable_plli2c(struct dvb_frontend* fe); |
| 43 | 49 | ||
| 44 | #endif // STV0297_H | 50 | #endif // STV0297_H |
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index cfa3928bb487..2d62931f20b5 100644 --- a/drivers/media/dvb/frontends/stv0299.c +++ b/drivers/media/dvb/frontends/stv0299.c | |||
| @@ -63,12 +63,8 @@ struct stv0299_state { | |||
| 63 | u32 tuner_frequency; | 63 | u32 tuner_frequency; |
| 64 | u32 symbol_rate; | 64 | u32 symbol_rate; |
| 65 | fe_code_rate_t fec_inner; | 65 | fe_code_rate_t fec_inner; |
| 66 | int errmode; | ||
| 67 | }; | 66 | }; |
| 68 | 67 | ||
| 69 | #define STATUS_BER 0 | ||
| 70 | #define STATUS_UCBLOCKS 1 | ||
| 71 | |||
| 72 | static int debug; | 68 | static int debug; |
| 73 | static int debug_legacy_dish_switch; | 69 | static int debug_legacy_dish_switch; |
| 74 | #define dprintk(args...) \ | 70 | #define dprintk(args...) \ |
| @@ -481,7 +477,7 @@ static int stv0299_init (struct dvb_frontend* fe) | |||
| 481 | 477 | ||
| 482 | if (state->config->pll_init) { | 478 | if (state->config->pll_init) { |
| 483 | stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ | 479 | stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ |
| 484 | state->config->pll_init(fe); | 480 | state->config->pll_init(fe, state->i2c); |
| 485 | stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ | 481 | stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ |
| 486 | } | 482 | } |
| 487 | 483 | ||
| @@ -520,7 +516,8 @@ static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber) | |||
| 520 | { | 516 | { |
| 521 | struct stv0299_state* state = fe->demodulator_priv; | 517 | struct stv0299_state* state = fe->demodulator_priv; |
| 522 | 518 | ||
| 523 | if (state->errmode != STATUS_BER) return 0; | 519 | stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x10); |
| 520 | msleep(100); | ||
| 524 | *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); | 521 | *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); |
| 525 | 522 | ||
| 526 | return 0; | 523 | return 0; |
| @@ -559,8 +556,9 @@ static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
| 559 | { | 556 | { |
| 560 | struct stv0299_state* state = fe->demodulator_priv; | 557 | struct stv0299_state* state = fe->demodulator_priv; |
| 561 | 558 | ||
| 562 | if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0; | 559 | stv0299_writeregI(state, 0x34, (stv0299_readreg(state, 0x34) & 0xcf) | 0x30); |
| 563 | else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); | 560 | msleep(100); |
| 561 | *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); | ||
| 564 | 562 | ||
| 565 | return 0; | 563 | return 0; |
| 566 | } | 564 | } |
| @@ -603,7 +601,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 603 | } else { | 601 | } else { |
| 604 | /* A "normal" tune is requested */ | 602 | /* A "normal" tune is requested */ |
| 605 | stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ | 603 | stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ |
| 606 | state->config->pll_set(fe, p); | 604 | state->config->pll_set(fe, state->i2c, p); |
| 607 | stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ | 605 | stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ |
| 608 | 606 | ||
| 609 | stv0299_writeregI(state, 0x32, 0x80); | 607 | stv0299_writeregI(state, 0x32, 0x80); |
| @@ -615,7 +613,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 615 | } | 613 | } |
| 616 | } else { | 614 | } else { |
| 617 | stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ | 615 | stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */ |
| 618 | state->config->pll_set(fe, p); | 616 | state->config->pll_set(fe, state->i2c, p); |
| 619 | stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ | 617 | stv0299_writeregI(state, 0x05, 0x35); /* disable i2c repeater on stv0299 */ |
| 620 | 618 | ||
| 621 | stv0299_set_FEC (state, p->u.qpsk.fec_inner); | 619 | stv0299_set_FEC (state, p->u.qpsk.fec_inner); |
| @@ -709,7 +707,6 @@ struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, | |||
| 709 | state->tuner_frequency = 0; | 707 | state->tuner_frequency = 0; |
| 710 | state->symbol_rate = 0; | 708 | state->symbol_rate = 0; |
| 711 | state->fec_inner = 0; | 709 | state->fec_inner = 0; |
| 712 | state->errmode = STATUS_BER; | ||
| 713 | 710 | ||
| 714 | /* check if the demod is there */ | 711 | /* check if the demod is there */ |
| 715 | stv0299_writeregI(state, 0x02, 0x34); /* standby off */ | 712 | stv0299_writeregI(state, 0x02, 0x34); /* standby off */ |
diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h index 79457a80a11f..d0c4484861e1 100644 --- a/drivers/media/dvb/frontends/stv0299.h +++ b/drivers/media/dvb/frontends/stv0299.h | |||
| @@ -92,8 +92,8 @@ struct stv0299_config | |||
| 92 | int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); | 92 | int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio); |
| 93 | 93 | ||
| 94 | /* PLL maintenance */ | 94 | /* PLL maintenance */ |
| 95 | int (*pll_init)(struct dvb_frontend* fe); | 95 | int (*pll_init)(struct dvb_frontend *fe, struct i2c_adapter *i2c); |
| 96 | int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); | 96 | int (*pll_set)(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params); |
| 97 | }; | 97 | }; |
| 98 | 98 | ||
| 99 | extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data); | 99 | extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data); |
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index ab0c032472cc..74cea9f8d721 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c | |||
| @@ -1046,8 +1046,7 @@ static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr) | |||
| 1046 | tmp = tda1004x_read_byte(state, TDA1004X_SNR); | 1046 | tmp = tda1004x_read_byte(state, TDA1004X_SNR); |
| 1047 | if (tmp < 0) | 1047 | if (tmp < 0) |
| 1048 | return -EIO; | 1048 | return -EIO; |
| 1049 | if (tmp) | 1049 | tmp = 255 - tmp; |
| 1050 | tmp = 255 - tmp; | ||
| 1051 | 1050 | ||
| 1052 | *snr = ((tmp << 8) | tmp); | 1051 | *snr = ((tmp << 8) | tmp); |
| 1053 | dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr); | 1052 | dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr); |
diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c index 70fb44b391a7..c6d276618e86 100644 --- a/drivers/media/dvb/frontends/ves1820.c +++ b/drivers/media/dvb/frontends/ves1820.c | |||
| @@ -194,19 +194,18 @@ static int ves1820_init(struct dvb_frontend* fe) | |||
| 194 | { | 194 | { |
| 195 | struct ves1820_state* state = fe->demodulator_priv; | 195 | struct ves1820_state* state = fe->demodulator_priv; |
| 196 | int i; | 196 | int i; |
| 197 | int val; | ||
| 198 | 197 | ||
| 199 | ves1820_writereg(state, 0, 0); | 198 | ves1820_writereg(state, 0, 0); |
| 200 | 199 | ||
| 201 | for (i = 0; i < 53; i++) { | 200 | for (i = 0; i < sizeof(ves1820_inittab); i++) |
| 202 | val = ves1820_inittab[i]; | 201 | ves1820_writereg(state, i, ves1820_inittab[i]); |
| 203 | if ((i == 2) && (state->config->selagc)) val |= 0x08; | 202 | if (state->config->selagc) |
| 204 | ves1820_writereg(state, i, val); | 203 | ves1820_writereg(state, 2, ves1820_inittab[2] | 0x08); |
| 205 | } | ||
| 206 | 204 | ||
| 207 | ves1820_writereg(state, 0x34, state->pwm); | 205 | ves1820_writereg(state, 0x34, state->pwm); |
| 208 | 206 | ||
| 209 | if (state->config->pll_init) state->config->pll_init(fe); | 207 | if (state->config->pll_init) |
| 208 | state->config->pll_init(fe); | ||
| 210 | 209 | ||
| 211 | return 0; | 210 | return 0; |
| 212 | } | 211 | } |
| @@ -234,7 +233,7 @@ static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_p | |||
| 234 | ves1820_writereg(state, 0x09, reg0x09[real_qam]); | 233 | ves1820_writereg(state, 0x09, reg0x09[real_qam]); |
| 235 | 234 | ||
| 236 | ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion); | 235 | ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion); |
| 237 | 236 | ves1820_writereg(state, 2, ves1820_inittab[2] | (state->config->selagc ? 0x08 : 0)); | |
| 238 | return 0; | 237 | return 0; |
| 239 | } | 238 | } |
| 240 | 239 | ||
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index e4c6e87f6c5d..22b203f8ff27 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c | |||
| @@ -168,7 +168,9 @@ static void init_av7110_av(struct av7110 *av7110) | |||
| 168 | if (ret < 0) | 168 | if (ret < 0) |
| 169 | printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret); | 169 | printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret); |
| 170 | if (rgb_on && | 170 | if (rgb_on && |
| 171 | (av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) { | 171 | ((av7110->dev->pci->subsystem_vendor == 0x110a) || |
| 172 | (av7110->dev->pci->subsystem_vendor == 0x13c2)) && | ||
| 173 | (av7110->dev->pci->subsystem_device == 0x0000)) { | ||
| 172 | saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16 | 174 | saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16 |
| 173 | //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8 | 175 | //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8 |
| 174 | } | 176 | } |
| @@ -177,9 +179,6 @@ static void init_av7110_av(struct av7110 *av7110) | |||
| 177 | ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); | 179 | ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); |
| 178 | if (ret < 0) | 180 | if (ret < 0) |
| 179 | printk("dvb-ttpci:cannot set volume :%d\n",ret); | 181 | printk("dvb-ttpci:cannot set volume :%d\n",ret); |
| 180 | ret = av7110_setup_irc_config(av7110, 0); | ||
| 181 | if (ret < 0) | ||
| 182 | printk("dvb-ttpci:cannot setup irc config :%d\n",ret); | ||
| 183 | } | 182 | } |
| 184 | 183 | ||
| 185 | static void recover_arm(struct av7110 *av7110) | 184 | static void recover_arm(struct av7110 *av7110) |
| @@ -265,60 +264,6 @@ static int arm_thread(void *data) | |||
| 265 | } | 264 | } |
| 266 | 265 | ||
| 267 | 266 | ||
| 268 | /** | ||
| 269 | * Hack! we save the last av7110 ptr. This should be ok, since | ||
| 270 | * you rarely will use more then one IR control. | ||
| 271 | * | ||
| 272 | * If we want to support multiple controls we would have to do much more... | ||
| 273 | */ | ||
| 274 | int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) | ||
| 275 | { | ||
| 276 | int ret = 0; | ||
| 277 | static struct av7110 *last; | ||
| 278 | |||
| 279 | dprintk(4, "%p\n", av7110); | ||
| 280 | |||
| 281 | if (!av7110) | ||
| 282 | av7110 = last; | ||
| 283 | else | ||
| 284 | last = av7110; | ||
| 285 | |||
| 286 | if (av7110) { | ||
| 287 | ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); | ||
| 288 | av7110->ir_config = ir_config; | ||
| 289 | } | ||
| 290 | return ret; | ||
| 291 | } | ||
| 292 | |||
| 293 | static void (*irc_handler)(u32); | ||
| 294 | |||
| 295 | void av7110_register_irc_handler(void (*func)(u32)) | ||
| 296 | { | ||
| 297 | dprintk(4, "registering %p\n", func); | ||
| 298 | irc_handler = func; | ||
| 299 | } | ||
| 300 | |||
| 301 | void av7110_unregister_irc_handler(void (*func)(u32)) | ||
| 302 | { | ||
| 303 | dprintk(4, "unregistering %p\n", func); | ||
| 304 | irc_handler = NULL; | ||
| 305 | } | ||
| 306 | |||
| 307 | static void run_handlers(unsigned long ircom) | ||
| 308 | { | ||
| 309 | if (irc_handler != NULL) | ||
| 310 | (*irc_handler)((u32) ircom); | ||
| 311 | } | ||
| 312 | |||
| 313 | static DECLARE_TASKLET(irtask, run_handlers, 0); | ||
| 314 | |||
| 315 | static void IR_handle(struct av7110 *av7110, u32 ircom) | ||
| 316 | { | ||
| 317 | dprintk(4, "ircommand = %08x\n", ircom); | ||
| 318 | irtask.data = (unsigned long) ircom; | ||
| 319 | tasklet_schedule(&irtask); | ||
| 320 | } | ||
| 321 | |||
| 322 | /**************************************************************************** | 267 | /**************************************************************************** |
| 323 | * IRQ handling | 268 | * IRQ handling |
| 324 | ****************************************************************************/ | 269 | ****************************************************************************/ |
| @@ -711,8 +656,9 @@ static void gpioirq(unsigned long data) | |||
| 711 | return; | 656 | return; |
| 712 | 657 | ||
| 713 | case DATA_IRCOMMAND: | 658 | case DATA_IRCOMMAND: |
| 714 | IR_handle(av7110, | 659 | if (av7110->ir_handler) |
| 715 | swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); | 660 | av7110->ir_handler(av7110, |
| 661 | swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4))); | ||
| 716 | iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); | 662 | iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); |
| 717 | break; | 663 | break; |
| 718 | 664 | ||
| @@ -1668,9 +1614,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra | |||
| 1668 | return 0; | 1614 | return 0; |
| 1669 | } | 1615 | } |
| 1670 | 1616 | ||
| 1671 | static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 1617 | static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) |
| 1672 | { | 1618 | { |
| 1673 | struct av7110* av7110 = (struct av7110*) fe->dvb->priv; | ||
| 1674 | int ret; | 1619 | int ret; |
| 1675 | u8 data[4]; | 1620 | u8 data[4]; |
| 1676 | u32 div; | 1621 | u32 div; |
| @@ -1687,7 +1632,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param | |||
| 1687 | 1632 | ||
| 1688 | if (params->frequency > 1530000) data[3] = 0xc0; | 1633 | if (params->frequency > 1530000) data[3] = 0xc0; |
| 1689 | 1634 | ||
| 1690 | ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); | 1635 | ret = i2c_transfer(i2c, &msg, 1); |
| 1691 | if (ret != 1) | 1636 | if (ret != 1) |
| 1692 | return -EIO; | 1637 | return -EIO; |
| 1693 | return 0; | 1638 | return 0; |
| @@ -1751,9 +1696,8 @@ static u8 alps_bsbe1_inittab[] = { | |||
| 1751 | 0xff, 0xff | 1696 | 0xff, 0xff |
| 1752 | }; | 1697 | }; |
| 1753 | 1698 | ||
| 1754 | static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 1699 | static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) |
| 1755 | { | 1700 | { |
| 1756 | struct av7110* av7110 = (struct av7110*) fe->dvb->priv; | ||
| 1757 | int ret; | 1701 | int ret; |
| 1758 | u8 data[4]; | 1702 | u8 data[4]; |
| 1759 | u32 div; | 1703 | u32 div; |
| @@ -1768,7 +1712,7 @@ static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param | |||
| 1768 | data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; | 1712 | data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; |
| 1769 | data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4; | 1713 | data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4; |
| 1770 | 1714 | ||
| 1771 | ret = i2c_transfer(&av7110->i2c_adap, &msg, 1); | 1715 | ret = i2c_transfer(i2c, &msg, 1); |
| 1772 | return (ret != 1) ? -EIO : 0; | 1716 | return (ret != 1) ? -EIO : 0; |
| 1773 | } | 1717 | } |
| 1774 | 1718 | ||
| @@ -1936,6 +1880,98 @@ static struct sp8870_config alps_tdlb7_config = { | |||
| 1936 | }; | 1880 | }; |
| 1937 | 1881 | ||
| 1938 | 1882 | ||
| 1883 | static u8 nexusca_stv0297_inittab[] = { | ||
| 1884 | 0x80, 0x01, | ||
| 1885 | 0x80, 0x00, | ||
| 1886 | 0x81, 0x01, | ||
| 1887 | 0x81, 0x00, | ||
| 1888 | 0x00, 0x09, | ||
| 1889 | 0x01, 0x69, | ||
| 1890 | 0x03, 0x00, | ||
| 1891 | 0x04, 0x00, | ||
| 1892 | 0x07, 0x00, | ||
| 1893 | 0x08, 0x00, | ||
| 1894 | 0x20, 0x00, | ||
| 1895 | 0x21, 0x40, | ||
| 1896 | 0x22, 0x00, | ||
| 1897 | 0x23, 0x00, | ||
| 1898 | 0x24, 0x40, | ||
| 1899 | 0x25, 0x88, | ||
| 1900 | 0x30, 0xff, | ||
| 1901 | 0x31, 0x00, | ||
| 1902 | 0x32, 0xff, | ||
| 1903 | 0x33, 0x00, | ||
| 1904 | 0x34, 0x50, | ||
| 1905 | 0x35, 0x7f, | ||
| 1906 | 0x36, 0x00, | ||
| 1907 | 0x37, 0x20, | ||
| 1908 | 0x38, 0x00, | ||
| 1909 | 0x40, 0x1c, | ||
| 1910 | 0x41, 0xff, | ||
| 1911 | 0x42, 0x29, | ||
| 1912 | 0x43, 0x00, | ||
| 1913 | 0x44, 0xff, | ||
| 1914 | 0x45, 0x00, | ||
| 1915 | 0x46, 0x00, | ||
| 1916 | 0x49, 0x04, | ||
| 1917 | 0x4a, 0x00, | ||
| 1918 | 0x4b, 0x7b, | ||
| 1919 | 0x52, 0x30, | ||
| 1920 | 0x55, 0xae, | ||
| 1921 | 0x56, 0x47, | ||
| 1922 | 0x57, 0xe1, | ||
| 1923 | 0x58, 0x3a, | ||
| 1924 | 0x5a, 0x1e, | ||
| 1925 | 0x5b, 0x34, | ||
| 1926 | 0x60, 0x00, | ||
| 1927 | 0x63, 0x00, | ||
| 1928 | 0x64, 0x00, | ||
| 1929 | 0x65, 0x00, | ||
| 1930 | 0x66, 0x00, | ||
| 1931 | 0x67, 0x00, | ||
| 1932 | 0x68, 0x00, | ||
| 1933 | 0x69, 0x00, | ||
| 1934 | 0x6a, 0x02, | ||
| 1935 | 0x6b, 0x00, | ||
| 1936 | 0x70, 0xff, | ||
| 1937 | 0x71, 0x00, | ||
| 1938 | 0x72, 0x00, | ||
| 1939 | 0x73, 0x00, | ||
| 1940 | 0x74, 0x0c, | ||
| 1941 | 0x80, 0x00, | ||
| 1942 | 0x81, 0x00, | ||
| 1943 | 0x82, 0x00, | ||
| 1944 | 0x83, 0x00, | ||
| 1945 | 0x84, 0x04, | ||
| 1946 | 0x85, 0x80, | ||
| 1947 | 0x86, 0x24, | ||
| 1948 | 0x87, 0x78, | ||
| 1949 | 0x88, 0x10, | ||
| 1950 | 0x89, 0x00, | ||
| 1951 | 0x90, 0x01, | ||
| 1952 | 0x91, 0x01, | ||
| 1953 | 0xa0, 0x04, | ||
| 1954 | 0xa1, 0x00, | ||
| 1955 | 0xa2, 0x00, | ||
| 1956 | 0xb0, 0x91, | ||
| 1957 | 0xb1, 0x0b, | ||
| 1958 | 0xc0, 0x53, | ||
| 1959 | 0xc1, 0x70, | ||
| 1960 | 0xc2, 0x12, | ||
| 1961 | 0xd0, 0x00, | ||
| 1962 | 0xd1, 0x00, | ||
| 1963 | 0xd2, 0x00, | ||
| 1964 | 0xd3, 0x00, | ||
| 1965 | 0xd4, 0x00, | ||
| 1966 | 0xd5, 0x00, | ||
| 1967 | 0xde, 0x00, | ||
| 1968 | 0xdf, 0x00, | ||
| 1969 | 0x61, 0x49, | ||
| 1970 | 0x62, 0x0b, | ||
| 1971 | 0x53, 0x08, | ||
| 1972 | 0x59, 0x08, | ||
| 1973 | 0xff, 0xff, | ||
| 1974 | }; | ||
| 1939 | 1975 | ||
| 1940 | static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 1976 | static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 1941 | { | 1977 | { |
| @@ -1984,6 +2020,7 @@ static int nexusca_stv0297_pll_set(struct dvb_frontend* fe, struct dvb_frontend_ | |||
| 1984 | static struct stv0297_config nexusca_stv0297_config = { | 2020 | static struct stv0297_config nexusca_stv0297_config = { |
| 1985 | 2021 | ||
| 1986 | .demod_address = 0x1C, | 2022 | .demod_address = 0x1C, |
| 2023 | .inittab = nexusca_stv0297_inittab, | ||
| 1987 | .invert = 1, | 2024 | .invert = 1, |
| 1988 | .pll_set = nexusca_stv0297_pll_set, | 2025 | .pll_set = nexusca_stv0297_pll_set, |
| 1989 | }; | 2026 | }; |
| @@ -2261,7 +2298,7 @@ static int frontend_init(struct av7110 *av7110) | |||
| 2261 | 2298 | ||
| 2262 | case 0x000A: // Hauppauge/TT Nexus-CA rev1.X | 2299 | case 0x000A: // Hauppauge/TT Nexus-CA rev1.X |
| 2263 | 2300 | ||
| 2264 | av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap, 0x7b); | 2301 | av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap); |
| 2265 | if (av7110->fe) { | 2302 | if (av7110->fe) { |
| 2266 | /* set TDA9819 into DVB mode */ | 2303 | /* set TDA9819 into DVB mode */ |
| 2267 | saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9198 pin9(STD) | 2304 | saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9198 pin9(STD) |
| @@ -2692,7 +2729,7 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d | |||
| 2692 | goto err_av7110_exit_v4l_12; | 2729 | goto err_av7110_exit_v4l_12; |
| 2693 | 2730 | ||
| 2694 | #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) | 2731 | #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) |
| 2695 | av7110_ir_init(); | 2732 | av7110_ir_init(av7110); |
| 2696 | #endif | 2733 | #endif |
| 2697 | printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num); | 2734 | printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num); |
| 2698 | av7110_num++; | 2735 | av7110_num++; |
| @@ -2734,6 +2771,9 @@ static int av7110_detach(struct saa7146_dev* saa) | |||
| 2734 | struct av7110 *av7110 = saa->ext_priv; | 2771 | struct av7110 *av7110 = saa->ext_priv; |
| 2735 | dprintk(4, "%p\n", av7110); | 2772 | dprintk(4, "%p\n", av7110); |
| 2736 | 2773 | ||
| 2774 | #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) | ||
| 2775 | av7110_ir_exit(av7110); | ||
| 2776 | #endif | ||
| 2737 | if (budgetpatch) { | 2777 | if (budgetpatch) { |
| 2738 | /* Disable RPS1 */ | 2778 | /* Disable RPS1 */ |
| 2739 | saa7146_write(saa, MC1, MASK_29); | 2779 | saa7146_write(saa, MC1, MASK_29); |
| @@ -2830,7 +2870,7 @@ static struct saa7146_pci_extension_data x_var = { \ | |||
| 2830 | .ext_priv = x_name, \ | 2870 | .ext_priv = x_name, \ |
| 2831 | .ext = &av7110_extension } | 2871 | .ext = &av7110_extension } |
| 2832 | 2872 | ||
| 2833 | MAKE_AV7110_INFO(tts_1_X, "Technotrend/Hauppauge WinTV DVB-S rev1.X"); | 2873 | MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C"); |
| 2834 | MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X"); | 2874 | MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X"); |
| 2835 | MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X"); | 2875 | MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X"); |
| 2836 | MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X"); | 2876 | MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X"); |
| @@ -2842,16 +2882,16 @@ MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C"); | |||
| 2842 | MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); | 2882 | MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); |
| 2843 | 2883 | ||
| 2844 | static struct pci_device_id pci_tbl[] = { | 2884 | static struct pci_device_id pci_tbl[] = { |
| 2845 | MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), | 2885 | MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), |
| 2846 | MAKE_EXTENSION_PCI(tts_1_X, 0x13c2, 0x0000), | 2886 | MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000), |
| 2847 | MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), | 2887 | MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), |
| 2848 | MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), | 2888 | MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002), |
| 2849 | MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), | 2889 | MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003), |
| 2850 | MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), | 2890 | MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006), |
| 2851 | MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), | 2891 | MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008), |
| 2852 | MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), | 2892 | MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a), |
| 2853 | MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), | 2893 | MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e), |
| 2854 | MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), | 2894 | MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002), |
| 2855 | 2895 | ||
| 2856 | /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte | 2896 | /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0004), UNDEFINED CARD */ // Galaxis DVB PC-Sat-Carte |
| 2857 | /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 | 2897 | /* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1 |
| @@ -2889,9 +2929,6 @@ static int __init av7110_init(void) | |||
| 2889 | 2929 | ||
| 2890 | static void __exit av7110_exit(void) | 2930 | static void __exit av7110_exit(void) |
| 2891 | { | 2931 | { |
| 2892 | #if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE) | ||
| 2893 | av7110_ir_exit(); | ||
| 2894 | #endif | ||
| 2895 | saa7146_unregister_extension(&av7110_extension); | 2932 | saa7146_unregister_extension(&av7110_extension); |
| 2896 | } | 2933 | } |
| 2897 | 2934 | ||
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h index 508b7739c609..cce00ef293e9 100644 --- a/drivers/media/dvb/ttpci/av7110.h +++ b/drivers/media/dvb/ttpci/av7110.h | |||
| @@ -228,7 +228,10 @@ struct av7110 { | |||
| 228 | struct dvb_video_events video_events; | 228 | struct dvb_video_events video_events; |
| 229 | video_size_t video_size; | 229 | video_size_t video_size; |
| 230 | 230 | ||
| 231 | u32 ir_config; | 231 | u32 ir_config; |
| 232 | u32 ir_command; | ||
| 233 | void (*ir_handler)(struct av7110 *av7110, u32 ircom); | ||
| 234 | struct tasklet_struct ir_tasklet; | ||
| 232 | 235 | ||
| 233 | /* firmware stuff */ | 236 | /* firmware stuff */ |
| 234 | unsigned char *bin_fw; | 237 | unsigned char *bin_fw; |
| @@ -257,12 +260,10 @@ struct av7110 { | |||
| 257 | extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, | 260 | extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, |
| 258 | u16 subpid, u16 pcrpid); | 261 | u16 subpid, u16 pcrpid); |
| 259 | 262 | ||
| 260 | extern void av7110_register_irc_handler(void (*func)(u32)); | ||
| 261 | extern void av7110_unregister_irc_handler(void (*func)(u32)); | ||
| 262 | extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config); | 263 | extern int av7110_setup_irc_config (struct av7110 *av7110, u32 ir_config); |
| 263 | 264 | ||
| 264 | extern int av7110_ir_init (void); | 265 | extern int av7110_ir_init(struct av7110 *av7110); |
| 265 | extern void av7110_ir_exit (void); | 266 | extern void av7110_ir_exit(struct av7110 *av7110); |
| 266 | 267 | ||
| 267 | /* msp3400 i2c subaddresses */ | 268 | /* msp3400 i2c subaddresses */ |
| 268 | #define MSP_WR_DEM 0x10 | 269 | #define MSP_WR_DEM 0x10 |
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index 1220826696c5..7442f56a72ec 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c | |||
| @@ -41,6 +41,8 @@ | |||
| 41 | #include "av7110.h" | 41 | #include "av7110.h" |
| 42 | #include "av7110_hw.h" | 42 | #include "av7110_hw.h" |
| 43 | 43 | ||
| 44 | #define _NOHANDSHAKE | ||
| 45 | |||
| 44 | /**************************************************************************** | 46 | /**************************************************************************** |
| 45 | * DEBI functions | 47 | * DEBI functions |
| 46 | ****************************************************************************/ | 48 | ****************************************************************************/ |
| @@ -364,7 +366,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
| 364 | msleep(1); | 366 | msleep(1); |
| 365 | } | 367 | } |
| 366 | 368 | ||
| 367 | wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); | 369 | if (FW_VERSION(av7110->arm_app) <= 0x261f) |
| 370 | wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2); | ||
| 368 | 371 | ||
| 369 | #ifndef _NOHANDSHAKE | 372 | #ifndef _NOHANDSHAKE |
| 370 | start = jiffies; | 373 | start = jiffies; |
| @@ -437,7 +440,8 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
| 437 | 440 | ||
| 438 | wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); | 441 | wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2); |
| 439 | 442 | ||
| 440 | wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); | 443 | if (FW_VERSION(av7110->arm_app) <= 0x261f) |
| 444 | wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2); | ||
| 441 | 445 | ||
| 442 | #ifdef COM_DEBUG | 446 | #ifdef COM_DEBUG |
| 443 | start = jiffies; | 447 | start = jiffies; |
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c index 665cdb8a3f71..357a3728ec68 100644 --- a/drivers/media/dvb/ttpci/av7110_ir.c +++ b/drivers/media/dvb/ttpci/av7110_ir.c | |||
| @@ -7,16 +7,16 @@ | |||
| 7 | #include <asm/bitops.h> | 7 | #include <asm/bitops.h> |
| 8 | 8 | ||
| 9 | #include "av7110.h" | 9 | #include "av7110.h" |
| 10 | #include "av7110_hw.h" | ||
| 10 | 11 | ||
| 11 | #define UP_TIMEOUT (HZ/4) | 12 | #define UP_TIMEOUT (HZ*7/25) |
| 12 | 13 | ||
| 13 | /* enable ir debugging by or'ing debug with 16 */ | 14 | /* enable ir debugging by or'ing debug with 16 */ |
| 14 | 15 | ||
| 15 | static int ir_initialized; | 16 | static int av_cnt; |
| 17 | static struct av7110 *av_list[4]; | ||
| 16 | static struct input_dev input_dev; | 18 | static struct input_dev input_dev; |
| 17 | 19 | ||
| 18 | static u32 ir_config; | ||
| 19 | |||
| 20 | static u16 key_map [256] = { | 20 | static u16 key_map [256] = { |
| 21 | KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, | 21 | KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, |
| 22 | KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO, | 22 | KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO, |
| @@ -53,8 +53,11 @@ static void av7110_emit_keyup(unsigned long data) | |||
| 53 | static struct timer_list keyup_timer = { .function = av7110_emit_keyup }; | 53 | static struct timer_list keyup_timer = { .function = av7110_emit_keyup }; |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | static void av7110_emit_key(u32 ircom) | 56 | static void av7110_emit_key(unsigned long parm) |
| 57 | { | 57 | { |
| 58 | struct av7110 *av7110 = (struct av7110 *) parm; | ||
| 59 | u32 ir_config = av7110->ir_config; | ||
| 60 | u32 ircom = av7110->ir_command; | ||
| 58 | u8 data; | 61 | u8 data; |
| 59 | u8 addr; | 62 | u8 addr; |
| 60 | static u16 old_toggle = 0; | 63 | static u16 old_toggle = 0; |
| @@ -62,19 +65,33 @@ static void av7110_emit_key(u32 ircom) | |||
| 62 | u16 keycode; | 65 | u16 keycode; |
| 63 | 66 | ||
| 64 | /* extract device address and data */ | 67 | /* extract device address and data */ |
| 65 | if (ir_config & 0x0001) { | 68 | switch (ir_config & 0x0003) { |
| 66 | /* TODO RCMM: ? bits device address, 8 bits data */ | 69 | case 0: /* RC5: 5 bits device address, 6 bits data */ |
| 70 | data = ircom & 0x3f; | ||
| 71 | addr = (ircom >> 6) & 0x1f; | ||
| 72 | break; | ||
| 73 | |||
| 74 | case 1: /* RCMM: 8(?) bits device address, 8(?) bits data */ | ||
| 67 | data = ircom & 0xff; | 75 | data = ircom & 0xff; |
| 68 | addr = (ircom >> 8) & 0xff; | 76 | addr = (ircom >> 8) & 0xff; |
| 69 | } else { | 77 | break; |
| 70 | /* RC5: 5 bits device address, 6 bits data */ | 78 | |
| 79 | case 2: /* extended RC5: 5 bits device address, 7 bits data */ | ||
| 71 | data = ircom & 0x3f; | 80 | data = ircom & 0x3f; |
| 72 | addr = (ircom >> 6) & 0x1f; | 81 | addr = (ircom >> 6) & 0x1f; |
| 82 | /* invert 7th data bit for backward compatibility with RC5 keymaps */ | ||
| 83 | if (!(ircom & 0x1000)) | ||
| 84 | data |= 0x40; | ||
| 85 | break; | ||
| 86 | |||
| 87 | default: | ||
| 88 | printk("invalid ir_config %x\n", ir_config); | ||
| 89 | return; | ||
| 73 | } | 90 | } |
| 74 | 91 | ||
| 75 | keycode = key_map[data]; | 92 | keycode = key_map[data]; |
| 76 | 93 | ||
| 77 | dprintk(16, "#########%08x######### addr %i data 0x%02x (keycode %i)\n", | 94 | dprintk(16, "code %08x -> addr %i data 0x%02x -> keycode %i\n", |
| 78 | ircom, addr, data, keycode); | 95 | ircom, addr, data, keycode); |
| 79 | 96 | ||
| 80 | /* check device address (if selected) */ | 97 | /* check device address (if selected) */ |
| @@ -87,10 +104,10 @@ static void av7110_emit_key(u32 ircom) | |||
| 87 | return; | 104 | return; |
| 88 | } | 105 | } |
| 89 | 106 | ||
| 90 | if (ir_config & 0x0001) | 107 | if ((ir_config & 0x0003) == 1) |
| 91 | new_toggle = 0; /* RCMM */ | 108 | new_toggle = 0; /* RCMM */ |
| 92 | else | 109 | else |
| 93 | new_toggle = (ircom & 0x800); /* RC5 */ | 110 | new_toggle = (ircom & 0x800); /* RC5, extended RC5 */ |
| 94 | 111 | ||
| 95 | if (timer_pending(&keyup_timer)) { | 112 | if (timer_pending(&keyup_timer)) { |
| 96 | del_timer(&keyup_timer); | 113 | del_timer(&keyup_timer); |
| @@ -137,6 +154,8 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer, | |||
| 137 | { | 154 | { |
| 138 | char *page; | 155 | char *page; |
| 139 | int size = 4 + 256 * sizeof(u16); | 156 | int size = 4 + 256 * sizeof(u16); |
| 157 | u32 ir_config; | ||
| 158 | int i; | ||
| 140 | 159 | ||
| 141 | if (count < size) | 160 | if (count < size) |
| 142 | return -EINVAL; | 161 | return -EINVAL; |
| @@ -153,60 +172,95 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer, | |||
| 153 | memcpy(&ir_config, page, 4); | 172 | memcpy(&ir_config, page, 4); |
| 154 | memcpy(&key_map, page + 4, 256 * sizeof(u16)); | 173 | memcpy(&key_map, page + 4, 256 * sizeof(u16)); |
| 155 | vfree(page); | 174 | vfree(page); |
| 156 | av7110_setup_irc_config(NULL, ir_config); | 175 | if (FW_VERSION(av_list[0]->arm_app) >= 0x2620 && !(ir_config & 0x0001)) |
| 176 | ir_config |= 0x0002; /* enable extended RC5 */ | ||
| 177 | for (i = 0; i < av_cnt; i++) | ||
| 178 | av7110_setup_irc_config(av_list[i], ir_config); | ||
| 157 | input_register_keys(); | 179 | input_register_keys(); |
| 158 | return count; | 180 | return count; |
| 159 | } | 181 | } |
| 160 | 182 | ||
| 161 | 183 | ||
| 162 | int __init av7110_ir_init(void) | 184 | int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config) |
| 163 | { | 185 | { |
| 164 | static struct proc_dir_entry *e; | 186 | int ret = 0; |
| 165 | 187 | ||
| 166 | if (ir_initialized) | 188 | dprintk(4, "%p\n", av7110); |
| 167 | return 0; | 189 | if (av7110) { |
| 190 | ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config); | ||
| 191 | av7110->ir_config = ir_config; | ||
| 192 | } | ||
| 193 | return ret; | ||
| 194 | } | ||
| 168 | 195 | ||
| 169 | init_timer(&keyup_timer); | ||
| 170 | keyup_timer.data = 0; | ||
| 171 | 196 | ||
| 172 | input_dev.name = "DVB on-card IR receiver"; | 197 | static void ir_handler(struct av7110 *av7110, u32 ircom) |
| 198 | { | ||
| 199 | dprintk(4, "ircommand = %08x\n", ircom); | ||
| 200 | av7110->ir_command = ircom; | ||
| 201 | tasklet_schedule(&av7110->ir_tasklet); | ||
| 202 | } | ||
| 173 | 203 | ||
| 174 | /** | ||
| 175 | * enable keys | ||
| 176 | */ | ||
| 177 | set_bit(EV_KEY, input_dev.evbit); | ||
| 178 | set_bit(EV_REP, input_dev.evbit); | ||
| 179 | 204 | ||
| 180 | input_register_keys(); | 205 | int __init av7110_ir_init(struct av7110 *av7110) |
| 206 | { | ||
| 207 | static struct proc_dir_entry *e; | ||
| 181 | 208 | ||
| 182 | input_register_device(&input_dev); | 209 | if (av_cnt >= sizeof av_list/sizeof av_list[0]) |
| 183 | input_dev.timer.function = input_repeat_key; | 210 | return -ENOSPC; |
| 184 | 211 | ||
| 185 | av7110_setup_irc_config(NULL, 0x0001); | 212 | av7110_setup_irc_config(av7110, 0x0001); |
| 186 | av7110_register_irc_handler(av7110_emit_key); | 213 | av_list[av_cnt++] = av7110; |
| 187 | 214 | ||
| 188 | e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); | 215 | if (av_cnt == 1) { |
| 189 | if (e) { | 216 | init_timer(&keyup_timer); |
| 190 | e->write_proc = av7110_ir_write_proc; | 217 | keyup_timer.data = 0; |
| 191 | e->size = 4 + 256 * sizeof(u16); | 218 | |
| 219 | input_dev.name = "DVB on-card IR receiver"; | ||
| 220 | set_bit(EV_KEY, input_dev.evbit); | ||
| 221 | set_bit(EV_REP, input_dev.evbit); | ||
| 222 | input_register_keys(); | ||
| 223 | input_register_device(&input_dev); | ||
| 224 | input_dev.timer.function = input_repeat_key; | ||
| 225 | |||
| 226 | e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL); | ||
| 227 | if (e) { | ||
| 228 | e->write_proc = av7110_ir_write_proc; | ||
| 229 | e->size = 4 + 256 * sizeof(u16); | ||
| 230 | } | ||
| 192 | } | 231 | } |
| 193 | 232 | ||
| 194 | ir_initialized = 1; | 233 | tasklet_init(&av7110->ir_tasklet, av7110_emit_key, (unsigned long) av7110); |
| 234 | av7110->ir_handler = ir_handler; | ||
| 235 | |||
| 195 | return 0; | 236 | return 0; |
| 196 | } | 237 | } |
| 197 | 238 | ||
| 198 | 239 | ||
| 199 | void __exit av7110_ir_exit(void) | 240 | void __exit av7110_ir_exit(struct av7110 *av7110) |
| 200 | { | 241 | { |
| 201 | if (ir_initialized == 0) | 242 | int i; |
| 243 | |||
| 244 | if (av_cnt == 0) | ||
| 202 | return; | 245 | return; |
| 203 | del_timer_sync(&keyup_timer); | 246 | |
| 204 | remove_proc_entry("av7110_ir", NULL); | 247 | av7110->ir_handler = NULL; |
| 205 | av7110_unregister_irc_handler(av7110_emit_key); | 248 | tasklet_kill(&av7110->ir_tasklet); |
| 206 | input_unregister_device(&input_dev); | 249 | for (i = 0; i < av_cnt; i++) |
| 207 | ir_initialized = 0; | 250 | if (av_list[i] == av7110) { |
| 251 | av_list[i] = av_list[av_cnt-1]; | ||
| 252 | av_list[av_cnt-1] = NULL; | ||
| 253 | break; | ||
| 254 | } | ||
| 255 | |||
| 256 | if (av_cnt == 1) { | ||
| 257 | del_timer_sync(&keyup_timer); | ||
| 258 | remove_proc_entry("av7110_ir", NULL); | ||
| 259 | input_unregister_device(&input_dev); | ||
| 260 | } | ||
| 261 | |||
| 262 | av_cnt--; | ||
| 208 | } | 263 | } |
| 209 | 264 | ||
| 210 | //MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>"); | 265 | //MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>"); |
| 211 | //MODULE_LICENSE("GPL"); | 266 | //MODULE_LICENSE("GPL"); |
| 212 | |||
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c index e65fc36e2ce8..6af74f78b3e5 100644 --- a/drivers/media/dvb/ttpci/av7110_v4l.c +++ b/drivers/media/dvb/ttpci/av7110_v4l.c | |||
| @@ -70,7 +70,7 @@ static int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val) | |||
| 70 | return 0; | 70 | return 0; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | static struct v4l2_input inputs[2] = { | 73 | static struct v4l2_input inputs[4] = { |
| 74 | { | 74 | { |
| 75 | .index = 0, | 75 | .index = 0, |
| 76 | .name = "DVB", | 76 | .name = "DVB", |
| @@ -87,6 +87,22 @@ static struct v4l2_input inputs[2] = { | |||
| 87 | .tuner = 0, | 87 | .tuner = 0, |
| 88 | .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, | 88 | .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, |
| 89 | .status = 0, | 89 | .status = 0, |
| 90 | }, { | ||
| 91 | .index = 2, | ||
| 92 | .name = "Video", | ||
| 93 | .type = V4L2_INPUT_TYPE_CAMERA, | ||
| 94 | .audioset = 0, | ||
| 95 | .tuner = 0, | ||
| 96 | .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, | ||
| 97 | .status = 0, | ||
| 98 | }, { | ||
| 99 | .index = 3, | ||
| 100 | .name = "Y/C", | ||
| 101 | .type = V4L2_INPUT_TYPE_CAMERA, | ||
| 102 | .audioset = 0, | ||
| 103 | .tuner = 0, | ||
| 104 | .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, | ||
| 105 | .status = 0, | ||
| 90 | } | 106 | } |
| 91 | }; | 107 | }; |
| 92 | 108 | ||
| @@ -212,24 +228,44 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) | |||
| 212 | } | 228 | } |
| 213 | 229 | ||
| 214 | if (0 != av7110->current_input) { | 230 | if (0 != av7110->current_input) { |
| 231 | dprintk(1, "switching to analog TV:\n"); | ||
| 215 | adswitch = 1; | 232 | adswitch = 1; |
| 216 | source = SAA7146_HPS_SOURCE_PORT_B; | 233 | source = SAA7146_HPS_SOURCE_PORT_B; |
| 217 | sync = SAA7146_HPS_SYNC_PORT_B; | 234 | sync = SAA7146_HPS_SYNC_PORT_B; |
| 218 | memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2); | 235 | memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2); |
| 219 | dprintk(1, "switching to analog TV\n"); | ||
| 220 | msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source | ||
| 221 | msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source | ||
| 222 | msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source | ||
| 223 | msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono | ||
| 224 | msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone | ||
| 225 | msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume | ||
| 226 | 236 | ||
| 227 | if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { | 237 | switch (av7110->current_input) { |
| 228 | if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) | 238 | case 1: |
| 229 | dprintk(1, "setting band in demodulator failed.\n"); | 239 | dprintk(1, "switching SAA7113 to Analog Tuner Input.\n"); |
| 230 | } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { | 240 | msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source |
| 231 | saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) | 241 | msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source |
| 232 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) | 242 | msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source |
| 243 | msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono | ||
| 244 | msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone | ||
| 245 | msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume | ||
| 246 | |||
| 247 | if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { | ||
| 248 | if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) | ||
| 249 | dprintk(1, "setting band in demodulator failed.\n"); | ||
| 250 | } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { | ||
| 251 | saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9198 pin9(STD) | ||
| 252 | saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9198 pin30(VIF) | ||
| 253 | } | ||
| 254 | if (i2c_writereg(av7110, 0x48, 0x02, 0xd0) != 1) | ||
| 255 | dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); | ||
| 256 | break; | ||
| 257 | case 2: | ||
| 258 | dprintk(1, "switching SAA7113 to Video AV CVBS Input.\n"); | ||
| 259 | if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1) | ||
| 260 | dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); | ||
| 261 | break; | ||
| 262 | case 3: | ||
| 263 | dprintk(1, "switching SAA7113 to Video AV Y/C Input.\n"); | ||
| 264 | if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1) | ||
| 265 | dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); | ||
| 266 | break; | ||
| 267 | default: | ||
| 268 | dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input.\n"); | ||
| 233 | } | 269 | } |
| 234 | } else { | 270 | } else { |
| 235 | adswitch = 0; | 271 | adswitch = 0; |
| @@ -300,7 +336,6 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | |||
| 300 | // FIXME: standard / stereo detection is still broken | 336 | // FIXME: standard / stereo detection is still broken |
| 301 | msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det); | 337 | msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det); |
| 302 | dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det); | 338 | dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det); |
| 303 | |||
| 304 | msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det); | 339 | msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det); |
| 305 | dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det); | 340 | dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det); |
| 306 | stereo = (s8)(stereo_det >> 8); | 341 | stereo = (s8)(stereo_det >> 8); |
| @@ -310,7 +345,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | |||
| 310 | t->audmode = V4L2_TUNER_MODE_STEREO; | 345 | t->audmode = V4L2_TUNER_MODE_STEREO; |
| 311 | } | 346 | } |
| 312 | else if (stereo < -0x10) { | 347 | else if (stereo < -0x10) { |
| 313 | /* bilingual*/ | 348 | /* bilingual */ |
| 314 | t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; | 349 | t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; |
| 315 | t->audmode = V4L2_TUNER_MODE_LANG1; | 350 | t->audmode = V4L2_TUNER_MODE_LANG1; |
| 316 | } | 351 | } |
| @@ -344,7 +379,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | |||
| 344 | fm_matrix = 0x3000; // mono | 379 | fm_matrix = 0x3000; // mono |
| 345 | src = 0x0010; | 380 | src = 0x0010; |
| 346 | break; | 381 | break; |
| 347 | default: /* case V4L2_TUNER_MODE_MONO: {*/ | 382 | default: /* case V4L2_TUNER_MODE_MONO: */ |
| 348 | dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n"); | 383 | dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n"); |
| 349 | fm_matrix = 0x3000; // mono | 384 | fm_matrix = 0x3000; // mono |
| 350 | src = 0x0030; | 385 | src = 0x0030; |
| @@ -406,7 +441,7 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | |||
| 406 | dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index); | 441 | dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index); |
| 407 | 442 | ||
| 408 | if (av7110->analog_tuner_flags) { | 443 | if (av7110->analog_tuner_flags) { |
| 409 | if (i->index < 0 || i->index >= 2) | 444 | if (i->index < 0 || i->index >= 4) |
| 410 | return -EINVAL; | 445 | return -EINVAL; |
| 411 | } else { | 446 | } else { |
| 412 | if (i->index != 0) | 447 | if (i->index != 0) |
| @@ -433,10 +468,9 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) | |||
| 433 | if (!av7110->analog_tuner_flags) | 468 | if (!av7110->analog_tuner_flags) |
| 434 | return 0; | 469 | return 0; |
| 435 | 470 | ||
| 436 | if (input < 0 || input >= 2) | 471 | if (input < 0 || input >= 4) |
| 437 | return -EINVAL; | 472 | return -EINVAL; |
| 438 | 473 | ||
| 439 | /* FIXME: switch inputs here */ | ||
| 440 | av7110->current_input = input; | 474 | av7110->current_input = input; |
| 441 | return av7110_dvb_c_switch(fh); | 475 | return av7110_dvb_c_switch(fh); |
| 442 | } | 476 | } |
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 9746d2bb916f..7692cd23f839 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c | |||
| @@ -192,7 +192,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) | |||
| 192 | { | 192 | { |
| 193 | struct budget_av *budget_av = (struct budget_av *) ca->data; | 193 | struct budget_av *budget_av = (struct budget_av *) ca->data; |
| 194 | struct saa7146_dev *saa = budget_av->budget.dev; | 194 | struct saa7146_dev *saa = budget_av->budget.dev; |
| 195 | int timeout = 50; // 5 seconds (4.4.6 Ready) | 195 | int timeout = 500; // 5 seconds (4.4.6 Ready) |
| 196 | 196 | ||
| 197 | if (slot != 0) | 197 | if (slot != 0) |
| 198 | return -EINVAL; | 198 | return -EINVAL; |
| @@ -217,7 +217,6 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot) | |||
| 217 | { | 217 | { |
| 218 | printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); | 218 | printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); |
| 219 | saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ | 219 | saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ |
| 220 | saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */ | ||
| 221 | return -ETIMEDOUT; | 220 | return -ETIMEDOUT; |
| 222 | } | 221 | } |
| 223 | 222 | ||
| @@ -276,7 +275,6 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open | |||
| 276 | { | 275 | { |
| 277 | printk(KERN_INFO "budget-av: cam ejected\n"); | 276 | printk(KERN_INFO "budget-av: cam ejected\n"); |
| 278 | saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ | 277 | saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ |
| 279 | saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */ | ||
| 280 | budget_av->slot_status = 0; | 278 | budget_av->slot_status = 0; |
| 281 | } | 279 | } |
| 282 | } | 280 | } |
| @@ -453,9 +451,9 @@ static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 sra | |||
| 453 | } | 451 | } |
| 454 | 452 | ||
| 455 | static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, | 453 | static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, |
| 454 | struct i2c_adapter *i2c, | ||
| 456 | struct dvb_frontend_parameters *params) | 455 | struct dvb_frontend_parameters *params) |
| 457 | { | 456 | { |
| 458 | struct budget_av *budget_av = (struct budget_av *) fe->dvb->priv; | ||
| 459 | u32 div; | 457 | u32 div; |
| 460 | u8 buf[4]; | 458 | u8 buf[4]; |
| 461 | struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; | 459 | struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; |
| @@ -481,7 +479,7 @@ static int philips_su1278_ty_ci_pll_set(struct dvb_frontend *fe, | |||
| 481 | else if (params->frequency < 2150000) | 479 | else if (params->frequency < 2150000) |
| 482 | buf[3] |= 0xC0; | 480 | buf[3] |= 0xC0; |
| 483 | 481 | ||
| 484 | if (i2c_transfer(&budget_av->budget.i2c_adap, &msg, 1) != 1) | 482 | if (i2c_transfer(i2c, &msg, 1) != 1) |
| 485 | return -EIO; | 483 | return -EIO; |
| 486 | return 0; | 484 | return 0; |
| 487 | } | 485 | } |
| @@ -745,6 +743,7 @@ static void frontend_init(struct budget_av *budget_av) | |||
| 745 | case SUBID_DVBC_KNC1_PLUS: | 743 | case SUBID_DVBC_KNC1_PLUS: |
| 746 | case SUBID_DVBT_KNC1_PLUS: | 744 | case SUBID_DVBT_KNC1_PLUS: |
| 747 | // Enable / PowerON Frontend | 745 | // Enable / PowerON Frontend |
| 746 | saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); | ||
| 748 | saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI); | 747 | saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI); |
| 749 | break; | 748 | break; |
| 750 | } | 749 | } |
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index a1267054bc01..2980db3ef22f 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | 40 | ||
| 41 | #include "dvb_ca_en50221.h" | 41 | #include "dvb_ca_en50221.h" |
| 42 | #include "stv0299.h" | 42 | #include "stv0299.h" |
| 43 | #include "stv0297.h" | ||
| 43 | #include "tda1004x.h" | 44 | #include "tda1004x.h" |
| 44 | 45 | ||
| 45 | #define DEBIADDR_IR 0x1234 | 46 | #define DEBIADDR_IR 0x1234 |
| @@ -548,9 +549,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ra | |||
| 548 | return 0; | 549 | return 0; |
| 549 | } | 550 | } |
| 550 | 551 | ||
| 551 | static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) | 552 | static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) |
| 552 | { | 553 | { |
| 553 | struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; | ||
| 554 | u8 buf[4]; | 554 | u8 buf[4]; |
| 555 | u32 div; | 555 | u32 div; |
| 556 | struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; | 556 | struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; |
| @@ -567,7 +567,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend *fe, struct dvb_frontend_param | |||
| 567 | if (params->frequency > 1530000) | 567 | if (params->frequency > 1530000) |
| 568 | buf[3] = 0xc0; | 568 | buf[3] = 0xc0; |
| 569 | 569 | ||
| 570 | if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) | 570 | if (i2c_transfer(i2c, &msg, 1) != 1) |
| 571 | return -EIO; | 571 | return -EIO; |
| 572 | return 0; | 572 | return 0; |
| 573 | } | 573 | } |
| @@ -669,9 +669,9 @@ static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, | |||
| 669 | } | 669 | } |
| 670 | 670 | ||
| 671 | static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, | 671 | static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, |
| 672 | struct i2c_adapter *i2c, | ||
| 672 | struct dvb_frontend_parameters *params) | 673 | struct dvb_frontend_parameters *params) |
| 673 | { | 674 | { |
| 674 | struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; | ||
| 675 | u32 div; | 675 | u32 div; |
| 676 | u8 buf[4]; | 676 | u8 buf[4]; |
| 677 | struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; | 677 | struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) }; |
| @@ -697,7 +697,7 @@ static int philips_su1278_tt_pll_set(struct dvb_frontend *fe, | |||
| 697 | else if (params->frequency < 2150000) | 697 | else if (params->frequency < 2150000) |
| 698 | buf[3] |= 0xC0; | 698 | buf[3] |= 0xC0; |
| 699 | 699 | ||
| 700 | if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1) | 700 | if (i2c_transfer(i2c, &msg, 1) != 1) |
| 701 | return -EIO; | 701 | return -EIO; |
| 702 | return 0; | 702 | return 0; |
| 703 | } | 703 | } |
| @@ -848,6 +848,180 @@ static struct tda1004x_config philips_tdm1316l_config = { | |||
| 848 | .request_firmware = philips_tdm1316l_request_firmware, | 848 | .request_firmware = philips_tdm1316l_request_firmware, |
| 849 | }; | 849 | }; |
| 850 | 850 | ||
| 851 | static int dvbc_philips_tdm1316l_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) | ||
| 852 | { | ||
| 853 | struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv; | ||
| 854 | u8 tuner_buf[5]; | ||
| 855 | struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address, | ||
| 856 | .flags = 0, | ||
| 857 | .buf = tuner_buf, | ||
| 858 | .len = sizeof(tuner_buf) }; | ||
| 859 | int tuner_frequency = 0; | ||
| 860 | u8 band, cp, filter; | ||
| 861 | |||
| 862 | // determine charge pump | ||
| 863 | tuner_frequency = params->frequency + 36125000; | ||
| 864 | if (tuner_frequency < 87000000) | ||
| 865 | return -EINVAL; | ||
| 866 | else if (tuner_frequency < 130000000) { | ||
| 867 | cp = 3; | ||
| 868 | band = 1; | ||
| 869 | } else if (tuner_frequency < 160000000) { | ||
| 870 | cp = 5; | ||
| 871 | band = 1; | ||
| 872 | } else if (tuner_frequency < 200000000) { | ||
| 873 | cp = 6; | ||
| 874 | band = 1; | ||
| 875 | } else if (tuner_frequency < 290000000) { | ||
| 876 | cp = 3; | ||
| 877 | band = 2; | ||
| 878 | } else if (tuner_frequency < 420000000) { | ||
| 879 | cp = 5; | ||
| 880 | band = 2; | ||
| 881 | } else if (tuner_frequency < 480000000) { | ||
| 882 | cp = 6; | ||
| 883 | band = 2; | ||
| 884 | } else if (tuner_frequency < 620000000) { | ||
| 885 | cp = 3; | ||
| 886 | band = 4; | ||
| 887 | } else if (tuner_frequency < 830000000) { | ||
| 888 | cp = 5; | ||
| 889 | band = 4; | ||
| 890 | } else if (tuner_frequency < 895000000) { | ||
| 891 | cp = 7; | ||
| 892 | band = 4; | ||
| 893 | } else | ||
| 894 | return -EINVAL; | ||
| 895 | |||
| 896 | // assume PLL filter should always be 8MHz for the moment. | ||
| 897 | filter = 1; | ||
| 898 | |||
| 899 | // calculate divisor | ||
| 900 | tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500; | ||
| 901 | |||
| 902 | // setup tuner buffer | ||
| 903 | tuner_buf[0] = tuner_frequency >> 8; | ||
| 904 | tuner_buf[1] = tuner_frequency & 0xff; | ||
| 905 | tuner_buf[2] = 0xc8; | ||
| 906 | tuner_buf[3] = (cp << 5) | (filter << 3) | band; | ||
| 907 | tuner_buf[4] = 0x80; | ||
| 908 | |||
| 909 | stv0297_enable_plli2c(fe); | ||
| 910 | if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) | ||
| 911 | return -EIO; | ||
| 912 | |||
| 913 | msleep(50); | ||
| 914 | |||
| 915 | stv0297_enable_plli2c(fe); | ||
| 916 | if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) | ||
| 917 | return -EIO; | ||
| 918 | |||
| 919 | msleep(1); | ||
| 920 | |||
| 921 | return 0; | ||
| 922 | } | ||
| 923 | |||
| 924 | static u8 dvbc_philips_tdm1316l_inittab[] = { | ||
| 925 | 0x80, 0x01, | ||
| 926 | 0x80, 0x00, | ||
| 927 | 0x81, 0x01, | ||
| 928 | 0x81, 0x00, | ||
| 929 | 0x00, 0x09, | ||
| 930 | 0x01, 0x69, | ||
| 931 | 0x03, 0x00, | ||
| 932 | 0x04, 0x00, | ||
| 933 | 0x07, 0x00, | ||
| 934 | 0x08, 0x00, | ||
| 935 | 0x20, 0x00, | ||
| 936 | 0x21, 0x40, | ||
| 937 | 0x22, 0x00, | ||
| 938 | 0x23, 0x00, | ||
| 939 | 0x24, 0x40, | ||
| 940 | 0x25, 0x88, | ||
| 941 | 0x30, 0xff, | ||
| 942 | 0x31, 0x00, | ||
| 943 | 0x32, 0xff, | ||
| 944 | 0x33, 0x00, | ||
| 945 | 0x34, 0x50, | ||
| 946 | 0x35, 0x7f, | ||
| 947 | 0x36, 0x00, | ||
| 948 | 0x37, 0x20, | ||
| 949 | 0x38, 0x00, | ||
| 950 | 0x40, 0x1c, | ||
| 951 | 0x41, 0xff, | ||
| 952 | 0x42, 0x29, | ||
| 953 | 0x43, 0x20, | ||
| 954 | 0x44, 0xff, | ||
| 955 | 0x45, 0x00, | ||
| 956 | 0x46, 0x00, | ||
| 957 | 0x49, 0x04, | ||
| 958 | 0x4a, 0x00, | ||
| 959 | 0x4b, 0x7b, | ||
| 960 | 0x52, 0x30, | ||
| 961 | 0x55, 0xae, | ||
| 962 | 0x56, 0x47, | ||
| 963 | 0x57, 0xe1, | ||
| 964 | 0x58, 0x3a, | ||
| 965 | 0x5a, 0x1e, | ||
| 966 | 0x5b, 0x34, | ||
| 967 | 0x60, 0x00, | ||
| 968 | 0x63, 0x00, | ||
| 969 | 0x64, 0x00, | ||
| 970 | 0x65, 0x00, | ||
| 971 | 0x66, 0x00, | ||
| 972 | 0x67, 0x00, | ||
| 973 | 0x68, 0x00, | ||
| 974 | 0x69, 0x00, | ||
| 975 | 0x6a, 0x02, | ||
| 976 | 0x6b, 0x00, | ||
| 977 | 0x70, 0xff, | ||
| 978 | 0x71, 0x00, | ||
| 979 | 0x72, 0x00, | ||
| 980 | 0x73, 0x00, | ||
| 981 | 0x74, 0x0c, | ||
| 982 | 0x80, 0x00, | ||
| 983 | 0x81, 0x00, | ||
| 984 | 0x82, 0x00, | ||
| 985 | 0x83, 0x00, | ||
| 986 | 0x84, 0x04, | ||
| 987 | 0x85, 0x80, | ||
| 988 | 0x86, 0x24, | ||
| 989 | 0x87, 0x78, | ||
| 990 | 0x88, 0x10, | ||
| 991 | 0x89, 0x00, | ||
| 992 | 0x90, 0x01, | ||
| 993 | 0x91, 0x01, | ||
| 994 | 0xa0, 0x04, | ||
| 995 | 0xa1, 0x00, | ||
| 996 | 0xa2, 0x00, | ||
| 997 | 0xb0, 0x91, | ||
| 998 | 0xb1, 0x0b, | ||
| 999 | 0xc0, 0x53, | ||
| 1000 | 0xc1, 0x70, | ||
| 1001 | 0xc2, 0x12, | ||
| 1002 | 0xd0, 0x00, | ||
| 1003 | 0xd1, 0x00, | ||
| 1004 | 0xd2, 0x00, | ||
| 1005 | 0xd3, 0x00, | ||
| 1006 | 0xd4, 0x00, | ||
| 1007 | 0xd5, 0x00, | ||
| 1008 | 0xde, 0x00, | ||
| 1009 | 0xdf, 0x00, | ||
| 1010 | 0x61, 0x38, | ||
| 1011 | 0x62, 0x0a, | ||
| 1012 | 0x53, 0x13, | ||
| 1013 | 0x59, 0x08, | ||
| 1014 | 0xff, 0xff, | ||
| 1015 | }; | ||
| 1016 | |||
| 1017 | static struct stv0297_config dvbc_philips_tdm1316l_config = { | ||
| 1018 | .demod_address = 0x1c, | ||
| 1019 | .inittab = dvbc_philips_tdm1316l_inittab, | ||
| 1020 | .invert = 0, | ||
| 1021 | .pll_set = dvbc_philips_tdm1316l_pll_set, | ||
| 1022 | }; | ||
| 1023 | |||
| 1024 | |||
| 851 | 1025 | ||
| 852 | 1026 | ||
| 853 | static void frontend_init(struct budget_ci *budget_ci) | 1027 | static void frontend_init(struct budget_ci *budget_ci) |
| @@ -869,6 +1043,15 @@ static void frontend_init(struct budget_ci *budget_ci) | |||
| 869 | } | 1043 | } |
| 870 | break; | 1044 | break; |
| 871 | 1045 | ||
| 1046 | case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt)) | ||
| 1047 | budget_ci->tuner_pll_address = 0x61; | ||
| 1048 | budget_ci->budget.dvb_frontend = | ||
| 1049 | stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap); | ||
| 1050 | if (budget_ci->budget.dvb_frontend) { | ||
| 1051 | break; | ||
| 1052 | } | ||
| 1053 | break; | ||
| 1054 | |||
| 872 | case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) | 1055 | case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) |
| 873 | budget_ci->tuner_pll_address = 0x63; | 1056 | budget_ci->tuner_pll_address = 0x63; |
| 874 | budget_ci->budget.dvb_frontend = | 1057 | budget_ci->budget.dvb_frontend = |
| @@ -878,7 +1061,7 @@ static void frontend_init(struct budget_ci *budget_ci) | |||
| 878 | } | 1061 | } |
| 879 | break; | 1062 | break; |
| 880 | 1063 | ||
| 881 | case 0x1012: // Hauppauge/TT Nova-T CI budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) | 1064 | case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) |
| 882 | budget_ci->tuner_pll_address = 0x60; | 1065 | budget_ci->tuner_pll_address = 0x60; |
| 883 | budget_ci->budget.dvb_frontend = | 1066 | budget_ci->budget.dvb_frontend = |
| 884 | tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); | 1067 | tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); |
| @@ -966,10 +1149,12 @@ static struct saa7146_extension budget_extension; | |||
| 966 | MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC); | 1149 | MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC); |
| 967 | MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); | 1150 | MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); |
| 968 | MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT); | 1151 | MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT); |
| 1152 | MAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT); | ||
| 969 | 1153 | ||
| 970 | static struct pci_device_id pci_tbl[] = { | 1154 | static struct pci_device_id pci_tbl[] = { |
| 971 | MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), | 1155 | MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), |
| 972 | MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), | 1156 | MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), |
| 1157 | MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010), | ||
| 973 | MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011), | 1158 | MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011), |
| 974 | MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012), | 1159 | MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012), |
| 975 | { | 1160 | { |
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c index 8142e26b47f5..b1f21ef0e3b3 100644 --- a/drivers/media/dvb/ttpci/budget-patch.c +++ b/drivers/media/dvb/ttpci/budget-patch.c | |||
| @@ -353,9 +353,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra | |||
| 353 | return 0; | 353 | return 0; |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 356 | static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) |
| 357 | { | 357 | { |
| 358 | struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv; | ||
| 359 | u8 data[4]; | 358 | u8 data[4]; |
| 360 | u32 div; | 359 | u32 div; |
| 361 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; | 360 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| @@ -370,7 +369,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param | |||
| 370 | 369 | ||
| 371 | if (params->frequency > 1530000) data[3] = 0xc0; | 370 | if (params->frequency > 1530000) data[3] = 0xc0; |
| 372 | 371 | ||
| 373 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; | 372 | if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; |
| 374 | return 0; | 373 | return 0; |
| 375 | } | 374 | } |
| 376 | 375 | ||
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 9961917e8a7f..43d6c8268642 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c | |||
| @@ -332,9 +332,8 @@ static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ra | |||
| 332 | return 0; | 332 | return 0; |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 335 | static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params) |
| 336 | { | 336 | { |
| 337 | struct budget* budget = (struct budget*) fe->dvb->priv; | ||
| 338 | u8 data[4]; | 337 | u8 data[4]; |
| 339 | u32 div; | 338 | u32 div; |
| 340 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; | 339 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| @@ -349,7 +348,7 @@ static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param | |||
| 349 | 348 | ||
| 350 | if (params->frequency > 1530000) data[3] = 0xc0; | 349 | if (params->frequency > 1530000) data[3] = 0xc0; |
| 351 | 350 | ||
| 352 | if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; | 351 | if (i2c_transfer(i2c, &msg, 1) != 1) return -EIO; |
| 353 | return 0; | 352 | return 0; |
| 354 | } | 353 | } |
| 355 | 354 | ||
| @@ -481,6 +480,7 @@ static int s5h1420_pll_set(struct dvb_frontend* fe, struct dvb_frontend_paramete | |||
| 481 | 480 | ||
| 482 | static struct s5h1420_config s5h1420_config = { | 481 | static struct s5h1420_config s5h1420_config = { |
| 483 | .demod_address = 0x53, | 482 | .demod_address = 0x53, |
| 483 | .invert = 1, | ||
| 484 | .pll_set = s5h1420_pll_set, | 484 | .pll_set = s5h1420_pll_set, |
| 485 | }; | 485 | }; |
| 486 | 486 | ||
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 7daf7b1598a0..d200ab0ad9e7 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
| 19 | #include <linux/time.h> | 19 | #include <linux/time.h> |
| 20 | #include <linux/errno.h> | 20 | #include <linux/errno.h> |
| 21 | #include <linux/jiffies.h> | ||
| 21 | #include <asm/semaphore.h> | 22 | #include <asm/semaphore.h> |
| 22 | 23 | ||
| 23 | #include "dvb_frontend.h" | 24 | #include "dvb_frontend.h" |
| @@ -570,7 +571,8 @@ static void ttusb_handle_sec_data(struct ttusb_channel *channel, | |||
| 570 | const u8 * data, int len); | 571 | const u8 * data, int len); |
| 571 | #endif | 572 | #endif |
| 572 | 573 | ||
| 573 | static int numpkt = 0, lastj, numts, numstuff, numsec, numinvalid; | 574 | static int numpkt = 0, numts, numstuff, numsec, numinvalid; |
| 575 | static unsigned long lastj; | ||
| 574 | 576 | ||
| 575 | static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, | 577 | static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, |
| 576 | int len) | 578 | int len) |
| @@ -779,7 +781,7 @@ static void ttusb_iso_irq(struct urb *urb, struct pt_regs *ptregs) | |||
| 779 | u8 *data; | 781 | u8 *data; |
| 780 | int len; | 782 | int len; |
| 781 | numpkt++; | 783 | numpkt++; |
| 782 | if ((jiffies - lastj) >= HZ) { | 784 | if (time_after_eq(jiffies, lastj + HZ)) { |
| 783 | #if DEBUG > 2 | 785 | #if DEBUG > 2 |
| 784 | printk | 786 | printk |
| 785 | ("frames/s: %d (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n", | 787 | ("frames/s: %d (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n", |
| @@ -1299,7 +1301,7 @@ static int alps_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 | |||
| 1299 | return 0; | 1301 | return 0; |
| 1300 | } | 1302 | } |
| 1301 | 1303 | ||
| 1302 | static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params) | 1304 | static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters *params) |
| 1303 | { | 1305 | { |
| 1304 | struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; | 1306 | struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; |
| 1305 | u8 buf[4]; | 1307 | u8 buf[4]; |
| @@ -1322,7 +1324,7 @@ static int philips_tsa5059_pll_set(struct dvb_frontend *fe, struct dvb_frontend_ | |||
| 1322 | if (ttusb->revision == TTUSB_REV_2_2) | 1324 | if (ttusb->revision == TTUSB_REV_2_2) |
| 1323 | buf[3] |= 0x20; | 1325 | buf[3] |= 0x20; |
| 1324 | 1326 | ||
| 1325 | if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) | 1327 | if (i2c_transfer(i2c, &msg, 1) != 1) |
| 1326 | return -EIO; | 1328 | return -EIO; |
| 1327 | 1329 | ||
| 1328 | return 0; | 1330 | return 0; |
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 45c9a9a08e4d..3d08fc83a754 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 29 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
| 30 | #include <linux/usb.h> | 30 | #include <linux/usb.h> |
| 31 | #include <linux/version.h> | ||
| 32 | #include <linux/interrupt.h> | 31 | #include <linux/interrupt.h> |
| 33 | #include <linux/firmware.h> | 32 | #include <linux/firmware.h> |
| 34 | #include <linux/crc32.h> | 33 | #include <linux/crc32.h> |
