diff -Nrup 3-v4l-dvb_xc-bluebird_dd4.au_xc-status/linux/drivers/media/dvb/dvb-usb/cxusb.c 4-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote/linux/drivers/media/dvb/dvb-usb/cxusb.c --- 3-v4l-dvb_xc-bluebird_dd4.au_xc-status/linux/drivers/media/dvb/dvb-usb/cxusb.c 2007-11-14 11:18:32.000000000 +1000 +++ 4-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote/linux/drivers/media/dvb/dvb-usb/cxusb.c 2007-11-14 11:21:51.000000000 +1000 @@ -76,20 +76,40 @@ static void cxusb_gpio_tuner(struct dvb_ st->gpio_write_state[GPIO_TUNER] = onoff; } -static void cxusb_bluebird_gpio(struct dvb_usb_device *d, u8 pin) +static void cxusb_bluebird_nano_led(struct dvb_usb_device *d, int onoff) +{ + u8 o[2],i; + + o[0] = 0xbf; + o[1] = onoff ? 0x00 : 0x40; + + cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_WRITE, o, 2, &i, 1); +} + +static void cxusb_bluebird_gpio_pre_all(struct dvb_usb_device *d) { u8 o[2],i; - o[0] = 0xff & ~pin; + o[0] = 0xfb; o[1] = 0x00; cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_WRITE, o, 2, &i, 1); +} + +static void cxusb_bluebird_gpio(struct dvb_usb_device *d, u8 pin) +{ + u8 o[2],i; + + o[0] = 0xff & ~pin; // mask to keep + o[1] = 0x00; // new value (off) + + cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_WRITE, o, 2, &i, 1); msleep(140); if ((i & pin) != 0x00) deb_info("gpio_write failed.\n"); - o[1] = pin; + o[1] = pin; // new value (on) cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_WRITE, o, 2, &i, 1); msleep(140); @@ -123,8 +143,19 @@ static int cxusb_i2c_xfer(struct i2c_ada break; } - /* read request */ - if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { + if (msg[i].flags & I2C_M_RD) { + /* read only */ + u8 obuf[3], ibuf[1+msg[i].len]; + obuf[0] = 0; + obuf[1] = msg[i].len; + obuf[2] = msg[i].addr; + if (cxusb_ctrl_msg(d, CMD_I2C_READ, + obuf, 3, + ibuf, 1+msg[i].len) < 0) + break; + memcpy(msg[i].buf, &ibuf[1], msg[i].len); + } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) { + /* write then read */ u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len]; obuf[0] = msg[i].len; obuf[1] = msg[i+1].len; @@ -142,7 +173,8 @@ static int cxusb_i2c_xfer(struct i2c_ada memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len); i++; - } else { /* write */ + } else { + /* write only */ u8 obuf[2+msg[i].len], ibuf; obuf[0] = msg[i].addr; obuf[1] = msg[i].len; @@ -223,6 +255,33 @@ static int cxusb_rc_query(struct dvb_usb return 0; } +static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event, int *state) +{ + struct dvb_usb_rc_key *keymap = d->props.rc_key_map; + u8 ircode[4]; + int i; + + struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD, + .buf = ircode, .len = 4 }; + + cxusb_i2c_xfer(&d->i2c_adap, &msg, 1); + + *event = 0; + *state = REMOTE_NO_KEY_PRESSED; + + for (i = 0; i < d->props.rc_key_map_size; i++) { + if (keymap[i].custom == ircode[1] && + keymap[i].data == ircode[2]) { + *event = keymap[i].event; + *state = REMOTE_KEY_PRESSED; + + return 0; + } + } + + return 0; +} + static struct dvb_usb_rc_key dvico_mce_rc_keys[] = { { 0xfe, 0x02, KEY_TV }, { 0xfe, 0x0e, KEY_MP3 }, @@ -379,6 +438,7 @@ static struct mt352_config cxusb_mt352_c static struct zl10353_config cxusb_zl10353_dualdig4_config = { .demod_address = 0x0f, + .itb_override = 0x2217, /* For Australia */ .no_tuner = 1, .parallel_ts = 1, }; @@ -399,6 +459,8 @@ static int cxusb_xc3028_zl353_gpio_reset // the toggle of register 0xEA although it appears to be non-critical. // Input frequency (regs 0x6C, 0x6D) is also set incorrectly for // Australia. + // We pass the correct ITB frequency for the dd4 in Australia via the + // zl10353_config structure, above. return 0; #else struct dvb_usb_adapter *adap = fe->dvb->priv; @@ -503,14 +565,34 @@ static int cxusb_cx22702_frontend_attach static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap) { + u8 ircode[4]; + int i; + struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD, + .buf = ircode, .len = 4 }; + if (usb_set_interface(adap->dev->udev, 0, 1) < 0) err("set interface failed"); cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); - /* pulse the GPIO demod reset pin */ + /* reset the tuner and demodulator */ + cxusb_bluebird_gpio_pre_all(adap->dev); + msleep(10); + cxusb_bluebird_gpio(adap->dev,0x01); cxusb_bluebird_gpio(adap->dev,0x02); + /* try to determine if there is no IR decoder attached */ + for (i = 0; adap->dev->props.rc_key_map != NULL && i < 10; i++) { + msleep(20); + cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1); + if (ircode[0] == 0 && ircode[1] == 0) + continue; + if (ircode[2] + ircode[3] != 0xff) { + adap->dev->props.rc_key_map = NULL; + break; + } + } + if ((adap->fe = dvb_attach(zl10353_attach, &cxusb_zl10353_dualdig4_config, &adap->dev->i2c_adap)) != NULL) @@ -598,6 +680,7 @@ static struct dvb_usb_device_properties static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties; static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties; static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties; +static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties; static int cxusb_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -607,7 +690,8 @@ static int cxusb_probe(struct usb_interf dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 || dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 || dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0 || - dvb_usb_device_init(intf,&cxusb_bluebird_dualdig4_properties,THIS_MODULE,NULL) == 0) { + dvb_usb_device_init(intf,&cxusb_bluebird_dualdig4_properties,THIS_MODULE,NULL) == 0 || + dvb_usb_device_init(intf,&cxusb_bluebird_nano2_properties,THIS_MODULE,NULL) == 0) { return 0; } @@ -921,12 +1005,60 @@ static struct dvb_usb_device_properties .generic_bulk_ctrl_endpoint = 0x01, - .num_device_descs = 2, + .rc_interval = 100, + .rc_key_map = dvico_mce_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys), + .rc_query = cxusb_bluebird2_rc_query, + + .num_device_descs = 1, .devices = { { "DViCO FusionHDTV DVB-T Dual Digital 4", { NULL }, { &cxusb_table[13], NULL }, }, + } +}; + +static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = { + .caps = DVB_USB_IS_AN_I2C_ADAPTER, + + .usb_ctrl = CYPRESS_FX2, + + .size_of_priv = sizeof(struct cxusb_state), + + .num_adapters = 1, + .adapter = { + { + .streaming_ctrl = cxusb_streaming_ctrl, + .frontend_attach = cxusb_dualdig4_frontend_attach, + .tuner_attach = cxusb_xc3028_tuner_attach, + /* parameter for the MPEG2-data transfer */ + .stream = { + .type = USB_BULK, + .count = 5, + .endpoint = 0x02, + .u = { + .bulk = { + .buffersize = 8192, + } + } + }, + }, + }, + + .power_ctrl = cxusb_bluebird_power_ctrl, + + .i2c_algo = &cxusb_i2c_algo, + + .generic_bulk_ctrl_endpoint = 0x01, + + .rc_interval = 100, + .rc_key_map = dvico_portable_rc_keys, + .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys), + .rc_query = cxusb_bluebird2_rc_query, + + .num_device_descs = 1, + .devices = { { "DViCO FusionHDTV DVB-T NANO2", { NULL }, { &cxusb_table[14], NULL }, diff -Nrup 3-v4l-dvb_xc-bluebird_dd4.au_xc-status/linux/drivers/media/dvb/frontends/zl10353.c 4-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote/linux/drivers/media/dvb/frontends/zl10353.c --- 3-v4l-dvb_xc-bluebird_dd4.au_xc-status/linux/drivers/media/dvb/frontends/zl10353.c 2007-11-14 11:18:32.000000000 +1000 +++ 4-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote/linux/drivers/media/dvb/frontends/zl10353.c 2007-11-14 11:20:38.000000000 +1000 @@ -167,6 +167,7 @@ static int zl10353_set_parameters(struct struct zl10353_state *state = fe->demodulator_priv; u16 nominal_rate; u8 pllbuf[6] = { 0x67 }; + u16 itb_freq = 0xCD7E; /* These settings set "auto-everything" and start the FSM. */ zl10353_single_write(fe, 0x55, 0x80); @@ -183,14 +184,11 @@ static int zl10353_set_parameters(struct zl10353_single_write(fe, TRL_NOMINAL_RATE_1, msb(nominal_rate)); zl10353_single_write(fe, TRL_NOMINAL_RATE_0, lsb(nominal_rate)); -#if 1 - // Australia requires a different input frequency to correctly lock. - zl10353_single_write(fe, 0x6C, 0x22); - zl10353_single_write(fe, 0x6D, 0x17); -#else - zl10353_single_write(fe, 0x6C, 0xCD); - zl10353_single_write(fe, 0x6D, 0x7E); -#endif + if (state->config.itb_override) + itb_freq = state->config.itb_override; + zl10353_single_write(fe, 0x6C, msb(itb_freq)); + zl10353_single_write(fe, 0x6D, lsb(itb_freq)); + if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); diff -Nrup 3-v4l-dvb_xc-bluebird_dd4.au_xc-status/linux/drivers/media/dvb/frontends/zl10353.h 4-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote/linux/drivers/media/dvb/frontends/zl10353.h --- 3-v4l-dvb_xc-bluebird_dd4.au_xc-status/linux/drivers/media/dvb/frontends/zl10353.h 2007-11-14 01:26:23.000000000 +1000 +++ 4-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote/linux/drivers/media/dvb/frontends/zl10353.h 2007-11-14 11:20:38.000000000 +1000 @@ -37,6 +37,9 @@ struct zl10353_config /* set if parallel ts output is required */ int parallel_ts; + + /* register overrides */ + int itb_override; // default: 0xCD7E }; #if defined(CONFIG_DVB_ZL10353) || (defined(CONFIG_DVB_ZL10353_MODULE) && defined(MODULE)) diff -ru 4-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote/v4l/Makefile 5-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote-obsolete/v4l/Makefile --- 4-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote/v4l/Makefile 2007-11-14 01:26:25.000000000 +1000 +++ 5-v4l-dvb_xc-bluebird_dd4.au_xc-status_dd4.remote-obsolete/v4l/Makefile 2007-12-28 20:15:51.000000000 +1000 @@ -39,10 +39,32 @@ ################################################# # default compilation rule -default:: config-compat.h Makefile.media links oss +default:: obsolete_warning config-compat.h Makefile.media links oss @echo Kernel build directory is $(OUTDIR) $(MAKE) -C $(OUTDIR) SUBDIRS=$(PWD) $(MYCFLAGS) modules ./scripts/rmmod.pl check + +obsolete_warning:: + @echo "" + @echo "Please note that this code has been superseded and is not" + @echo "supported." + @echo "" + @echo "You should instead follow the build instructions and use the" + @echo "code from the 2007/12/15 (or later relevant) entry at:" + @echo "" + @echo " http://www.itee.uq.edu.au/~chrisp/Linux-DVB/DVICO/" + @echo "" + @echo "The code described in this entry represents what will be" + @echo "submitted upstream to the main Linux kernel via the main" + @echo "v4l-dvb development repository." + @echo "" + @echo "Thank you." + @echo "" + @echo "(If you really want to use this code, the build process will" + @echo " continue in 30 seconds.)" + @echo "" + @sleep 30 + ################################################# # Object specific rules