Merge to kernel-2.6.20-1.2949.fc6.vs2.2.0.1
[linux-2.6.git] / drivers / media / dvb / b2c2 / flexcop.c
index 8b5d14d..29ec418 100644 (file)
@@ -46,7 +46,7 @@
 
 int b2c2_flexcop_debug;
 module_param_named(debug, b2c2_flexcop_debug,  int, 0644);
-MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram (|-able))." DEBSTATUS);
+MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg (|-able))." DEBSTATUS);
 #undef DEBSTATUS
 
 /* global zero for ibi values */
@@ -67,7 +67,7 @@ static int flexcop_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
 static int flexcop_dvb_init(struct flexcop_device *fc)
 {
        int ret;
-       if ((ret = dvb_register_adapter(&fc->dvb_adapter,"FlexCop Digital TV device",fc->owner)) < 0) {
+       if ((ret = dvb_register_adapter(&fc->dvb_adapter,"FlexCop Digital TV device",fc->owner,fc->dev)) < 0) {
                err("error registering DVB adapter");
                return ret;
        }
@@ -116,7 +116,7 @@ static int flexcop_dvb_init(struct flexcop_device *fc)
        dvb_net_init(&fc->dvb_adapter, &fc->dvbnet, &fc->demux.dmx);
 
        fc->init_state |= FC_STATE_DVB_INIT;
-       goto success;
+       return 0;
 
 err_connect_frontend:
        fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->mem_frontend);
@@ -129,9 +129,6 @@ err_dmx_dev:
 err_dmx:
        dvb_unregister_adapter(&fc->dvb_adapter);
        return ret;
-
-success:
-       return 0;
 }
 
 static void flexcop_dvb_exit(struct flexcop_device *fc)
@@ -173,36 +170,65 @@ static void flexcop_reset(struct flexcop_device *fc)
        fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
 
        v210.raw = 0;
-       v210.sw_reset_210.reset_blocks = 0xff;
+       v210.sw_reset_210.reset_block_000 = 1;
+       v210.sw_reset_210.reset_block_100 = 1;
+       v210.sw_reset_210.reset_block_200 = 1;
+       v210.sw_reset_210.reset_block_300 = 1;
+       v210.sw_reset_210.reset_block_400 = 1;
+       v210.sw_reset_210.reset_block_500 = 1;
+       v210.sw_reset_210.reset_block_600 = 1;
+       v210.sw_reset_210.reset_block_700 = 1;
        v210.sw_reset_210.Block_reset_enable = 0xb2;
+
+       v210.sw_reset_210.Special_controls = 0xc259;
+
        fc->write_ibi_reg(fc,sw_reset_210,v210);
+       msleep(1);
 
 /* reset the periphical devices */
 
        v204 = fc->read_ibi_reg(fc,misc_204);
        v204.misc_204.Per_reset_sig = 0;
        fc->write_ibi_reg(fc,misc_204,v204);
+       msleep(1);
        v204.misc_204.Per_reset_sig = 1;
        fc->write_ibi_reg(fc,misc_204,v204);
 }
 
+void flexcop_reset_block_300(struct flexcop_device *fc)
+{
+       flexcop_ibi_value v208_save = fc->read_ibi_reg(fc,ctrl_208),
+                                         v210 = fc->read_ibi_reg(fc,sw_reset_210);
+
+       deb_rdump("208: %08x, 210: %08x\n",v208_save.raw,v210.raw);
+
+       fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
+
+       v210.sw_reset_210.reset_block_300 = 1;
+       v210.sw_reset_210.Block_reset_enable = 0xb2;
+
+       fc->write_ibi_reg(fc,sw_reset_210,v210);
+       msleep(1);
+
+       fc->write_ibi_reg(fc,ctrl_208,v208_save);
+}
+EXPORT_SYMBOL(flexcop_reset_block_300);
+
 struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
 {
        void *bus;
-       struct flexcop_device *fc = kmalloc(sizeof(struct flexcop_device), GFP_KERNEL);
+       struct flexcop_device *fc = kzalloc(sizeof(struct flexcop_device), GFP_KERNEL);
        if (!fc) {
                err("no memory");
                return NULL;
        }
-       memset(fc, 0, sizeof(struct flexcop_device));
 
-       bus = kmalloc(bus_specific_len, GFP_KERNEL);
+       bus = kzalloc(bus_specific_len, GFP_KERNEL);
        if (!bus) {
                err("no memory");
                kfree(fc);
                return NULL;
        }
-       memset(bus, 0, bus_specific_len);
 
        fc->bus_specific = bus;
 
@@ -250,11 +276,10 @@ int flexcop_device_initialize(struct flexcop_device *fc)
 
        flexcop_device_name(fc,"initialization of","complete");
 
-       ret = 0;
-       goto success;
+       return 0;
+
 error:
        flexcop_device_exit(fc);
-success:
        return ret;
 }
 EXPORT_SYMBOL(flexcop_device_initialize);