From b9ede79ada766eec535e1230970bd885489d5990 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 27 Sep 2010 20:52:43 -0300 Subject: [media] add a driver for mb86a20s This adds the trivial bits to mb86a20s. As the driver won't touch at the channel/layer parameters, this may not be enough for receiving all channels, especially ISDB-Tsb, but the driver worked properly for receiving video channels on my tests. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/mb86a20s.c | 584 +++++++++++++++++++++++++++++++++ 1 file changed, 584 insertions(+) create mode 100644 drivers/media/dvb/frontends/mb86a20s.c (limited to 'drivers/media/dvb/frontends/mb86a20s.c') diff --git a/drivers/media/dvb/frontends/mb86a20s.c b/drivers/media/dvb/frontends/mb86a20s.c new file mode 100644 index 00000000000..1e6bec6aa0f --- /dev/null +++ b/drivers/media/dvb/frontends/mb86a20s.c @@ -0,0 +1,584 @@ +/* + * Fujitu mb86a20s ISDB-T/ISDB-Tsb Module driver + * + * Copyright (C) 2010 Mauro Carvalho Chehab + * Copyright (C) 2009-2010 Douglas Landgraf + * + * FIXME: Need to port to DVB v5.2 API + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#include +#include + +#include "dvb_frontend.h" +#include "mb86a20s.h" + +static int debug = 1; +module_param(debug, int, 0644); +MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); + +#define rc(args...) do { \ + printk(KERN_ERR "mb86a20s: " args); \ +} while (0) + +#define dprintk(args...) \ + do { \ + if (debug) { \ + printk(KERN_DEBUG "mb86a20s: %s: ", __func__); \ + printk(args); \ + } \ + } while (0) + +struct mb86a20s_state { + struct i2c_adapter *i2c; + const struct mb86a20s_config *config; + + struct dvb_frontend frontend; + + + + +}; + +struct regdata { + u8 reg; + u8 data; +}; + +/* + * Initialization sequence: Use whatevere default values that PV SBTVD + * does on its initialisation, obtained via USB snoop + */ +static struct regdata mb86a20s_init[] = { + { 0x70, 0x0f }, + { 0x70, 0xff }, + { 0x08, 0x01 }, + { 0x09, 0x3e }, + { 0x50, 0xd1 }, + { 0x51, 0x22 }, + { 0x39, 0x01 }, + { 0x71, 0x00 }, + { 0x28, 0x2a }, + { 0x29, 0x00 }, + { 0x2a, 0xff }, + { 0x2b, 0x80 }, + { 0x28, 0x20 }, + { 0x29, 0x33 }, + { 0x2a, 0xdf }, + { 0x2b, 0xa9 }, + { 0x3b, 0x21 }, + { 0x3c, 0x3a }, + { 0x01, 0x0d }, + { 0x04, 0x08 }, + { 0x05, 0x05 }, + { 0x04, 0x0e }, + { 0x05, 0x00 }, + { 0x04, 0x0f }, + { 0x05, 0x14 }, + { 0x04, 0x0b }, + { 0x05, 0x8c }, + { 0x04, 0x00 }, + { 0x05, 0x00 }, + { 0x04, 0x01 }, + { 0x05, 0x07 }, + { 0x04, 0x02 }, + { 0x05, 0x0f }, + { 0x04, 0x03 }, + { 0x05, 0xa0 }, + { 0x04, 0x09 }, + { 0x05, 0x00 }, + { 0x04, 0x0a }, + { 0x05, 0xff }, + { 0x04, 0x27 }, + { 0x05, 0x64 }, + { 0x04, 0x28 }, + { 0x05, 0x00 }, + { 0x04, 0x1e }, + { 0x05, 0xff }, + { 0x04, 0x29 }, + { 0x05, 0x0a }, + { 0x04, 0x32 }, + { 0x05, 0x0a }, + { 0x04, 0x14 }, + { 0x05, 0x02 }, + { 0x04, 0x04 }, + { 0x05, 0x00 }, + { 0x04, 0x05 }, + { 0x05, 0x22 }, + { 0x04, 0x06 }, + { 0x05, 0x0e }, + { 0x04, 0x07 }, + { 0x05, 0xd8 }, + { 0x04, 0x12 }, + { 0x05, 0x00 }, + { 0x04, 0x13 }, + { 0x05, 0xff }, + { 0x52, 0x01 }, + { 0x50, 0xa7 }, + { 0x51, 0x00 }, + { 0x50, 0xa8 }, + { 0x51, 0xff }, + { 0x50, 0xa9 }, + { 0x51, 0xff }, + { 0x50, 0xaa }, + { 0x51, 0x00 }, + { 0x50, 0xab }, + { 0x51, 0xff }, + { 0x50, 0xac }, + { 0x51, 0xff }, + { 0x50, 0xad }, + { 0x51, 0x00 }, + { 0x50, 0xae }, + { 0x51, 0xff }, + { 0x50, 0xaf }, + { 0x51, 0xff }, + { 0x5e, 0x07 }, + { 0x50, 0xdc }, + { 0x51, 0x01 }, + { 0x50, 0xdd }, + { 0x51, 0xf4 }, + { 0x50, 0xde }, + { 0x51, 0x01 }, + { 0x50, 0xdf }, + { 0x51, 0xf4 }, + { 0x50, 0xe0 }, + { 0x51, 0x01 }, + { 0x50, 0xe1 }, + { 0x51, 0xf4 }, + { 0x50, 0xb0 }, + { 0x51, 0x07 }, + { 0x50, 0xb2 }, + { 0x51, 0xff }, + { 0x50, 0xb3 }, + { 0x51, 0xff }, + { 0x50, 0xb4 }, + { 0x51, 0xff }, + { 0x50, 0xb5 }, + { 0x51, 0xff }, + { 0x50, 0xb6 }, + { 0x51, 0xff }, + { 0x50, 0xb7 }, + { 0x51, 0xff }, + { 0x50, 0x50 }, + { 0x51, 0x02 }, + { 0x50, 0x51 }, + { 0x51, 0x04 }, + { 0x45, 0x04 }, + { 0x48, 0x04 }, + { 0x50, 0xd5 }, + { 0x51, 0x01 }, + { 0x50, 0xd6 }, + { 0x51, 0x1f }, + { 0x50, 0xd2 }, + { 0x51, 0x03 }, + { 0x50, 0xd7 }, + { 0x51, 0x3f }, + { 0x1c, 0x01 }, + { 0x28, 0x06 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x03 }, + { 0x28, 0x07 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x0d }, + { 0x28, 0x08 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x02 }, + { 0x28, 0x09 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x01 }, + { 0x28, 0x0a }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x21 }, + { 0x28, 0x0b }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x29 }, + { 0x28, 0x0c }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x16 }, + { 0x28, 0x0d }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x31 }, + { 0x28, 0x0e }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x0e }, + { 0x28, 0x0f }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x4e }, + { 0x28, 0x10 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x46 }, + { 0x28, 0x11 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x0f }, + { 0x28, 0x12 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x56 }, + { 0x28, 0x13 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x35 }, + { 0x28, 0x14 }, + { 0x29, 0x00 }, + { 0x2a, 0x01 }, + { 0x2b, 0xbe }, + { 0x28, 0x15 }, + { 0x29, 0x00 }, + { 0x2a, 0x01 }, + { 0x2b, 0x84 }, + { 0x28, 0x16 }, + { 0x29, 0x00 }, + { 0x2a, 0x03 }, + { 0x2b, 0xee }, + { 0x28, 0x17 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x98 }, + { 0x28, 0x18 }, + { 0x29, 0x00 }, + { 0x2a, 0x00 }, + { 0x2b, 0x9f }, + { 0x28, 0x19 }, + { 0x29, 0x00 }, + { 0x2a, 0x07 }, + { 0x2b, 0xb2 }, + { 0x28, 0x1a }, + { 0x29, 0x00 }, + { 0x2a, 0x06 }, + { 0x2b, 0xc2 }, + { 0x28, 0x1b }, + { 0x29, 0x00 }, + { 0x2a, 0x07 }, + { 0x2b, 0x4a }, + { 0x28, 0x1c }, + { 0x29, 0x00 }, + { 0x2a, 0x01 }, + { 0x2b, 0xbc }, + { 0x28, 0x1d }, + { 0x29, 0x00 }, + { 0x2a, 0x04 }, + { 0x2b, 0xba }, + { 0x28, 0x1e }, + { 0x29, 0x00 }, + { 0x2a, 0x06 }, + { 0x2b, 0x14 }, + { 0x50, 0x1e }, + { 0x51, 0x5d }, + { 0x50, 0x22 }, + { 0x51, 0x00 }, + { 0x50, 0x23 }, + { 0x51, 0xc8 }, + { 0x50, 0x24 }, + { 0x51, 0x00 }, + { 0x50, 0x25 }, + { 0x51, 0xf0 }, + { 0x50, 0x26 }, + { 0x51, 0x00 }, + { 0x50, 0x27 }, + { 0x51, 0xc3 }, + { 0x50, 0x39 }, + { 0x51, 0x02 }, + { 0x50, 0xd5 }, + { 0x51, 0x01 }, + { 0xd0, 0x00 }, +}; + +static struct regdata mb86a20s_reset_reception[] = { + { 0x70, 0xf0 }, + { 0x70, 0xff }, + { 0x08, 0x01 }, + { 0x08, 0x00 }, +}; + +static int mb86a20s_i2c_writereg(struct mb86a20s_state *state, + u8 i2c_addr, int reg, int data) +{ + u8 buf[] = { reg, data }; + struct i2c_msg msg = { + .addr = i2c_addr, .flags = 0, .buf = buf, .len = 2 + }; + int rc; + + rc = i2c_transfer(state->i2c, &msg, 1); + if (rc != 1) { + printk("%s: writereg rcor(rc == %i, reg == 0x%02x," + " data == 0x%02x)\n", __func__, rc, reg, data); + return rc; + } + + return 0; +} + +static int mb86a20s_i2c_writeregdata(struct mb86a20s_state *state, + u8 i2c_addr, struct regdata *rd, int size) +{ + int i, rc; + + for (i = 0; i < size; i++) { + rc = mb86a20s_i2c_writereg(state, i2c_addr, rd[i].reg, + rd[i].data); + if (rc < 0) + return rc; + } + return 0; +} + +static int mb86a20s_i2c_readreg(struct mb86a20s_state *state, + u8 i2c_addr, u8 reg) +{ + u8 val; + int rc; + struct i2c_msg msg[] = { + { .addr = i2c_addr, .flags = 0, .buf = ®, .len = 1 }, + { .addr = i2c_addr, .flags = I2C_M_RD, .buf = &val, .len = 1 } + }; + + rc = i2c_transfer(state->i2c, msg, 2); + + if (rc != 2) { + rc("%s: reg=0x%x (rcor=%d)\n", __func__, reg, rc); + return rc; + } + + return val; +} + +#define mb86a20s_readreg(state, reg) \ + mb86a20s_i2c_readreg(state, state->config->demod_address, reg) +#define mb86a20s_writereg(state, reg, val) \ + mb86a20s_i2c_writereg(state, state->config->demod_address, reg, val) +#define mb86a20s_writeregdata(state, regdata) \ + mb86a20s_i2c_writeregdata(state, state->config->demod_address, \ + regdata, ARRAY_SIZE(regdata)) + +static int mb86a20s_initfe(struct dvb_frontend *fe) +{ + struct mb86a20s_state *state = fe->demodulator_priv; + int rc; + + dprintk("\n"); + + /* Initialize the frontend */ + rc = mb86a20s_writeregdata(state, mb86a20s_init); + if (rc < 0) + return rc; + + return 0; +} + +static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength) +{ + struct mb86a20s_state *state = fe->demodulator_priv; + unsigned rf_max, rf_min, rf; + u8 val; + + dprintk("\n"); + + /* Does a binary search to get RF strength */ + rf_max = 0xfff; + rf_min = 0; + do { + rf = (rf_max + rf_min) / 2; + mb86a20s_writereg(state, 0x04, 0x1f); + mb86a20s_writereg(state, 0x05, rf >> 8); + mb86a20s_writereg(state, 0x04, 0x20); + mb86a20s_writereg(state, 0x04, rf); + + val = mb86a20s_readreg(state, 0x02); + if (val & 0x08) + rf_min = (rf_max + rf_min) / 2; + else + rf_max = (rf_max + rf_min) / 2; + if (rf_max - rf_min < 4) { + *strength = (((rf_max + rf_min) / 2) * 65535) / 4095; + break; + } + } while (1); + + dprintk("signal strength = %d\n", *strength); + + return 0; +} + +static int mb86a20s_read_status(struct dvb_frontend *fe, fe_status_t *status) +{ + struct mb86a20s_state *state = fe->demodulator_priv; + u8 val; + + dprintk("\n"); + *status = 0; + + val = mb86a20s_readreg(state, 0x0a) & 0xf; + + if (val >= 2) + *status |= FE_HAS_SIGNAL; + + if (val >= 4) + *status |= FE_HAS_CARRIER; + + if (val >= 5) + *status |= FE_HAS_VITERBI; + + if (val >= 7) + *status |= FE_HAS_SYNC; + + if (val >= 8) /* Maybe 9? */ + *status |= FE_HAS_LOCK; + + dprintk("val = %d, status = 0x%02x\n", val, *status); + + return 0; +} + +static int mb86a20s_set_frontend(struct dvb_frontend *fe, + struct dvb_frontend_parameters *p) +{ + struct mb86a20s_state *state = fe->demodulator_priv; + int rc; + + dprintk("\n"); + + fe->ops.tuner_ops.set_params(fe, p); + rc = mb86a20s_writeregdata(state, mb86a20s_reset_reception); + + return rc; +} + +static int mb86a20s_get_frontend(struct dvb_frontend *fe, + struct dvb_frontend_parameters *p) +{ + + /* FIXME: For now, it does nothing */ + + fe->dtv_property_cache.bandwidth_hz = 6000000; + fe->dtv_property_cache.transmission_mode = TRANSMISSION_MODE_AUTO; + fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_AUTO; + fe->dtv_property_cache.isdbt_partial_reception = 0; + + return 0; +} + +static int mb86a20s_tune(struct dvb_frontend *fe, + struct dvb_frontend_parameters *params, + unsigned int mode_flags, + unsigned int *delay, + fe_status_t *status) +{ + int rc = 0; + + dprintk("\n"); + + if (params != NULL) + rc = mb86a20s_set_frontend(fe, params); + + if (!(mode_flags & FE_TUNE_MODE_ONESHOT)) + mb86a20s_read_status(fe, status); + + return rc; +} + +static void mb86a20s_release(struct dvb_frontend *fe) +{ + struct mb86a20s_state *state = fe->demodulator_priv; + + dprintk("\n"); + + kfree(state); +} + +static struct dvb_frontend_ops mb86a20s_ops; + +struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, + struct i2c_adapter *i2c) +{ + u8 rev; + + /* allocate memory for the internal state */ + struct mb86a20s_state *state = + kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL); + + dprintk("\n"); + if (state == NULL) { + rc("Unable to kzalloc\n"); + goto error; + } + + /* setup the state */ + state->config = config; + state->i2c = i2c; + + /* create dvb_frontend */ + memcpy(&state->frontend.ops, &mb86a20s_ops, + sizeof(struct dvb_frontend_ops)); + state->frontend.demodulator_priv = state; + + /* Check if it is a mb86a20s frontend */ + rev = mb86a20s_readreg(state, 0); + + if (rev == 0x13) { + printk(KERN_INFO "Detected a Fujitsu mb86a20s frontend\n"); + } else { + printk(KERN_ERR "Frontend revision %d is unknown - aborting.\n", + rev); + goto error; + } + + return &state->frontend; + +error: + kfree(state); + return NULL; +} +EXPORT_SYMBOL(mb86a20s_attach); + +static struct dvb_frontend_ops mb86a20s_ops = { + /* Use dib8000 values per default */ + .info = { + .name = "Fujitsu mb86A20s", + .type = FE_OFDM, + .caps = FE_CAN_INVERSION_AUTO | FE_CAN_RECOVER | + FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | + FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | + FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | + FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_QAM_AUTO | + FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_HIERARCHY_AUTO, + /* Actually, those values depend on the used tuner */ + .frequency_min = 45000000, + .frequency_max = 864000000, + .frequency_stepsize = 62500, + }, + + .release = mb86a20s_release, + + .init = mb86a20s_initfe, + .set_frontend = mb86a20s_set_frontend, + .get_frontend = mb86a20s_get_frontend, + .read_status = mb86a20s_read_status, + .read_signal_strength = mb86a20s_read_signal_strength, + .tune = mb86a20s_tune, +}; + +MODULE_DESCRIPTION("DVB Frontend module for Fujitsu mb86A20s hardware"); +MODULE_AUTHOR("Mauro Carvalho Chehab "); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-70-g09d2 From 7572f9c5575c721f43b575a71fda1ecd896e0327 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 3 Oct 2010 16:48:49 -0300 Subject: [media] mb86a20s: add support for serial streams By comparing the traffic between Pixelview (cx23102-based and Kworld (saa7134-based), the only difference is at register 0xd5. After some tests, It seems that it is used to change mode between serial and parallel. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/mb86a20s.c | 18 +++++++++++++----- drivers/media/dvb/frontends/mb86a20s.h | 1 + drivers/media/video/cx231xx/cx231xx-dvb.c | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'drivers/media/dvb/frontends/mb86a20s.c') diff --git a/drivers/media/dvb/frontends/mb86a20s.c b/drivers/media/dvb/frontends/mb86a20s.c index 1e6bec6aa0f..b4de8f12df2 100644 --- a/drivers/media/dvb/frontends/mb86a20s.c +++ b/drivers/media/dvb/frontends/mb86a20s.c @@ -43,10 +43,6 @@ struct mb86a20s_state { const struct mb86a20s_config *config; struct dvb_frontend frontend; - - - - }; struct regdata { @@ -175,7 +171,7 @@ static struct regdata mb86a20s_init[] = { { 0x45, 0x04 }, { 0x48, 0x04 }, { 0x50, 0xd5 }, - { 0x51, 0x01 }, + { 0x51, 0x01 }, /* Serial */ { 0x50, 0xd6 }, { 0x51, 0x1f }, { 0x50, 0xd2 }, @@ -376,6 +372,7 @@ static int mb86a20s_initfe(struct dvb_frontend *fe) { struct mb86a20s_state *state = fe->demodulator_priv; int rc; + u8 regD5 = 1; dprintk("\n"); @@ -384,6 +381,17 @@ static int mb86a20s_initfe(struct dvb_frontend *fe) if (rc < 0) return rc; + if (!state->config->is_serial) { + regD5 &= ~1; + + rc = mb86a20s_writereg(state, 0x50, 0xd5); + if (rc < 0) + return rc; + rc = mb86a20s_writereg(state, 0x51, regD5); + if (rc < 0) + return rc; + } + return 0; } diff --git a/drivers/media/dvb/frontends/mb86a20s.h b/drivers/media/dvb/frontends/mb86a20s.h index e3461983a83..bf22e77888b 100644 --- a/drivers/media/dvb/frontends/mb86a20s.h +++ b/drivers/media/dvb/frontends/mb86a20s.h @@ -26,6 +26,7 @@ struct mb86a20s_config { u8 demod_address; + bool is_serial; }; #if defined(CONFIG_DVB_MB86A20S) || (defined(CONFIG_DVB_MB86A20S_MODULE) \ diff --git a/drivers/media/video/cx231xx/cx231xx-dvb.c b/drivers/media/video/cx231xx/cx231xx-dvb.c index b55e7e0bc24..fe59a1c3f06 100644 --- a/drivers/media/video/cx231xx/cx231xx-dvb.c +++ b/drivers/media/video/cx231xx/cx231xx-dvb.c @@ -143,6 +143,7 @@ static struct tda18271_config hcw_tda18271_config = { static const struct mb86a20s_config pv_mb86a20s_config = { .demod_address = 0x10, + .is_serial = true, }; static struct tda18271_config pv_tda18271_config = { -- cgit v1.2.3-70-g09d2 From 68541cdaadecbc280cd50122f11fdbb249a2ae29 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 3 Oct 2010 05:27:59 -0300 Subject: [media] Add support for Kworld SBTVD board Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/mb86a20s.c | 23 ++++++ drivers/media/video/saa7134/saa7134-cards.c | 109 ++++++++++++++++++++++++++++ drivers/media/video/saa7134/saa7134.h | 1 + 3 files changed, 133 insertions(+) (limited to 'drivers/media/dvb/frontends/mb86a20s.c') diff --git a/drivers/media/dvb/frontends/mb86a20s.c b/drivers/media/dvb/frontends/mb86a20s.c index b4de8f12df2..d3ad3e75a35 100644 --- a/drivers/media/dvb/frontends/mb86a20s.c +++ b/drivers/media/dvb/frontends/mb86a20s.c @@ -376,6 +376,9 @@ static int mb86a20s_initfe(struct dvb_frontend *fe) dprintk("\n"); + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 0); + /* Initialize the frontend */ rc = mb86a20s_writeregdata(state, mb86a20s_init); if (rc < 0) @@ -392,6 +395,9 @@ static int mb86a20s_initfe(struct dvb_frontend *fe) return rc; } + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); + return 0; } @@ -403,6 +409,9 @@ static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength) dprintk("\n"); + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 0); + /* Does a binary search to get RF strength */ rf_max = 0xfff; rf_min = 0; @@ -426,6 +435,9 @@ static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength) dprintk("signal strength = %d\n", *strength); + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); + return 0; } @@ -437,7 +449,11 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, fe_status_t *status) dprintk("\n"); *status = 0; + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 0); val = mb86a20s_readreg(state, 0x0a) & 0xf; + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); if (val >= 2) *status |= FE_HAS_SIGNAL; @@ -467,8 +483,15 @@ static int mb86a20s_set_frontend(struct dvb_frontend *fe, dprintk("\n"); + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); fe->ops.tuner_ops.set_params(fe, p); + + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 0); rc = mb86a20s_writeregdata(state, mb86a20s_reset_reception); + if (fe->ops.i2c_gate_ctrl) + fe->ops.i2c_gate_ctrl(fe, 1); return rc; } diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 1d4d0a49ea5..58c8c03fd8f 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c @@ -5176,6 +5176,47 @@ struct saa7134_board saa7134_boards[] = { .amux = 2, }, }, + [SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG] = { + .name = "Kworld PCI SBTVD/ISDB-T Full-Seg Hybrid", + .audio_clock = 0x00187de7, + .tuner_type = TUNER_NXP_TDA18271, /* TUNER_PHILIPS_TDA8290 */ + .radio_type = UNSET, + .tuner_addr = 0x60, + .radio_addr = ADDR_UNSET, + .gpiomask = 0x8e054000, + .mpeg = SAA7134_MPEG_DVB, + .inputs = { { + .name = name_tv, + .vmux = 1, + .amux = TV, + .tv = 1, +#if 0 /* FIXME */ + }, { + .name = name_comp1, + .vmux = 3, + .amux = LINE1, + .gpio = 0x200, + }, { + .name = name_svideo, + .vmux = 8, + .amux = LINE1, + .gpio = 0x200, +#endif + } }, +#if 0 + .radio = { + .name = name_radio, + .vmux = 1, + .amux = LINE1, + .gpio = 0x100, + }, +#endif + .mute = { + .name = name_mute, + .vmux = 0, + .amux = TV, + }, + }, [SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS] = { .name = "Avermedia AVerTV GO 007 FM Plus", .audio_clock = 0x00187de7, @@ -6612,6 +6653,12 @@ struct pci_device_id saa7134_pci_tbl[] = { .subvendor = 0x17de, .subdevice = 0x7128, .driver_data = SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG, + }, { + .vendor = PCI_VENDOR_ID_PHILIPS, + .device = PCI_DEVICE_ID_PHILIPS_SAA7133, + .subvendor = 0x17de, + .subdevice = 0xb136, + .driver_data = SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG, }, { .vendor = PCI_VENDOR_ID_PHILIPS, .device = PCI_DEVICE_ID_PHILIPS_SAA7133, @@ -6831,6 +6878,23 @@ static inline int saa7134_tda18271_hvr11x0_toggle_agc(struct saa7134_dev *dev, return 0; } +static inline int saa7134_kworld_sbtvd_toggle_agc(struct saa7134_dev *dev, + enum tda18271_mode mode) +{ + /* toggle AGC switch through GPIO 27 */ + switch (mode) { + case TDA18271_ANALOG: + saa7134_set_gpio(dev, 27, 0); + break; + case TDA18271_DIGITAL: + saa7134_set_gpio(dev, 27, 1); + break; + default: + return -EINVAL; + } + return 0; +} + static int saa7134_tda8290_18271_callback(struct saa7134_dev *dev, int command, int arg) { @@ -6843,6 +6907,9 @@ static int saa7134_tda8290_18271_callback(struct saa7134_dev *dev, case SAA7134_BOARD_HAUPPAUGE_HVR1120: ret = saa7134_tda18271_hvr11x0_toggle_agc(dev, arg); break; + case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG: + ret = saa7134_kworld_sbtvd_toggle_agc(dev, arg); + break; default: break; } @@ -6863,6 +6930,7 @@ static int saa7134_tda8290_callback(struct saa7134_dev *dev, case SAA7134_BOARD_HAUPPAUGE_HVR1150: case SAA7134_BOARD_HAUPPAUGE_HVR1120: case SAA7134_BOARD_AVERMEDIA_M733A: + case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG: /* tda8290 + tda18271 */ ret = saa7134_tda8290_18271_callback(dev, command, arg); break; @@ -7541,6 +7609,47 @@ int saa7134_board_init2(struct saa7134_dev *dev) dev->name); break; } + case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG: + { + struct i2c_msg msg = { .addr = 0x4b, .flags = 0 }; + int i; + static u8 buffer[][2] = { + {0x30, 0x31}, + {0xff, 0x00}, + {0x41, 0x03}, + {0x41, 0x1a}, + {0xff, 0x02}, + {0x34, 0x00}, + {0x45, 0x97}, + {0x45, 0xc1}, + }; + + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x0000); + saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0000); + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x0000); + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000); + saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0000); + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000); + saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x4000); + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000); + saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0000); + saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000); + saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x4000); + + /* + * FIXME: identify what device is at addr 0x4b and what means + * this initialization + */ + for (i = 0; i < ARRAY_SIZE(buffer); i++) { + msg.buf = &buffer[i][0]; + msg.len = ARRAY_SIZE(buffer[0]); + if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) + printk(KERN_WARNING + "%s: Unable to enable tuner(%i).\n", + dev->name, i); + } + break; + } } /* switch() */ /* initialize tuner */ diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index d3b6a196e5d..4e37b8bfb6f 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -305,6 +305,7 @@ struct saa7134_format { #define SAA7134_BOARD_BEHOLD_A7 179 #define SAA7134_BOARD_AVERMEDIA_M733A 180 #define SAA7134_BOARD_TECHNOTREND_BUDGET_T3000 181 +#define SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG 182 #define SAA7134_MAXBOARDS 32 #define SAA7134_INPUT_MAX 8 -- cgit v1.2.3-70-g09d2