aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Bugla <uwe.bugla@gmx.de>2009-03-29 06:46:58 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:47 -0400
commit1589a993f074124c3edfff03656e910bb472eeaa (patch)
treea4be3dc715f569de56014a3b23b6171e09ae3639
parent7def728f558c99489cc89f4c5d62dd64dc0289b4 (diff)
V4L/DVB (11287): Code cleanup (passes checkpatch now) of the b2c2-flexcop-drivers 1/2
This patch cleans up the source code of the b2c2 flexcop-driver. It is the first of a total of two. The code is now passing the checkpatch-script. Signed-off-by: Uwe Bugla <uwe.bugla@gmx.de> Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/b2c2/Makefile1
-rw-r--r--drivers/media/dvb/b2c2/flexcop-common.h64
-rw-r--r--drivers/media/dvb/b2c2/flexcop-dma.c27
-rw-r--r--drivers/media/dvb/b2c2/flexcop-eeprom.c47
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c6
-rw-r--r--drivers/media/dvb/b2c2/flexcop-hw-filter.c171
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c49
-rw-r--r--drivers/media/dvb/b2c2/flexcop-misc.c68
-rw-r--r--drivers/media/dvb/b2c2/flexcop-reg.h21
-rw-r--r--drivers/media/dvb/b2c2/flexcop-sram.c112
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.h62
-rw-r--r--drivers/media/dvb/b2c2/flexcop.c85
-rw-r--r--drivers/media/dvb/b2c2/flexcop.h20
-rw-r--r--drivers/media/dvb/b2c2/flexcop_ibi_value_be.h7
-rw-r--r--drivers/media/dvb/b2c2/flexcop_ibi_value_le.h7
15 files changed, 353 insertions, 394 deletions
diff --git a/drivers/media/dvb/b2c2/Makefile b/drivers/media/dvb/b2c2/Makefile
index d9db066f985..b97cf7208a1 100644
--- a/drivers/media/dvb/b2c2/Makefile
+++ b/drivers/media/dvb/b2c2/Makefile
@@ -2,7 +2,6 @@ b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o \
2 flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o 2 flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o
3obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o 3obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o
4 4
5
6ifneq ($(CONFIG_DVB_B2C2_FLEXCOP_PCI),) 5ifneq ($(CONFIG_DVB_B2C2_FLEXCOP_PCI),)
7b2c2-flexcop-objs += flexcop-dma.o 6b2c2-flexcop-objs += flexcop-dma.o
8endif 7endif
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
index 8ce06336e76..3e1c472092a 100644
--- a/drivers/media/dvb/b2c2/flexcop-common.h
+++ b/drivers/media/dvb/b2c2/flexcop-common.h
@@ -28,11 +28,14 @@
28 28
29/* Steal from usb.h */ 29/* Steal from usb.h */
30#undef err 30#undef err
31#define err(format, arg...) printk(KERN_ERR FC_LOG_PREFIX ": " format "\n" , ## arg) 31#define err(format, arg...) \
32 printk(KERN_ERR FC_LOG_PREFIX ": " format "\n" , ## arg)
32#undef info 33#undef info
33#define info(format, arg...) printk(KERN_INFO FC_LOG_PREFIX ": " format "\n" , ## arg) 34#define info(format, arg...) \
35 printk(KERN_INFO FC_LOG_PREFIX ": " format "\n" , ## arg)
34#undef warn 36#undef warn
35#define warn(format, arg...) printk(KERN_WARNING FC_LOG_PREFIX ": " format "\n" , ## arg) 37#define warn(format, arg...) \
38 printk(KERN_WARNING FC_LOG_PREFIX ": " format "\n" , ## arg)
36 39
37struct flexcop_dma { 40struct flexcop_dma {
38 struct pci_dev *pdev; 41 struct pci_dev *pdev;
@@ -91,16 +94,14 @@ struct flexcop_device {
91 int fullts_streaming_state; 94 int fullts_streaming_state;
92 95
93 /* bus specific callbacks */ 96 /* bus specific callbacks */
94 flexcop_ibi_value (*read_ibi_reg) (struct flexcop_device *, flexcop_ibi_register); 97 flexcop_ibi_value(*read_ibi_reg) (struct flexcop_device *,
95 int (*write_ibi_reg) (struct flexcop_device *, flexcop_ibi_register, flexcop_ibi_value); 98 flexcop_ibi_register);
96 99 int (*write_ibi_reg) (struct flexcop_device *,
97 100 flexcop_ibi_register, flexcop_ibi_value);
98 int (*i2c_request) (struct flexcop_i2c_adapter*, 101 int (*i2c_request) (struct flexcop_i2c_adapter *,
99 flexcop_access_op_t, u8 chipaddr, u8 addr, u8 *buf, u16 len); 102 flexcop_access_op_t, u8 chipaddr, u8 addr, u8 *buf, u16 len);
100 int (*stream_control) (struct flexcop_device*, int); 103 int (*stream_control) (struct flexcop_device *, int);
101
102 int (*get_mac_addr) (struct flexcop_device *fc, int extended); 104 int (*get_mac_addr) (struct flexcop_device *fc, int extended);
103
104 void *bus_specific; 105 void *bus_specific;
105}; 106};
106 107
@@ -111,22 +112,28 @@ void flexcop_pass_dmx_data(struct flexcop_device *fc, u8 *buf, u32 len);
111void flexcop_pass_dmx_packets(struct flexcop_device *fc, u8 *buf, u32 no); 112void flexcop_pass_dmx_packets(struct flexcop_device *fc, u8 *buf, u32 no);
112 113
113struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len); 114struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len);
114void flexcop_device_kfree(struct flexcop_device*); 115void flexcop_device_kfree(struct flexcop_device *);
115 116
116int flexcop_device_initialize(struct flexcop_device*); 117int flexcop_device_initialize(struct flexcop_device *);
117void flexcop_device_exit(struct flexcop_device *fc); 118void flexcop_device_exit(struct flexcop_device *fc);
118
119void flexcop_reset_block_300(struct flexcop_device *fc); 119void flexcop_reset_block_300(struct flexcop_device *fc);
120 120
121/* from flexcop-dma.c */ 121/* from flexcop-dma.c */
122int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size); 122int flexcop_dma_allocate(struct pci_dev *pdev,
123 struct flexcop_dma *dma, u32 size);
123void flexcop_dma_free(struct flexcop_dma *dma); 124void flexcop_dma_free(struct flexcop_dma *dma);
124 125
125int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 126int flexcop_dma_control_timer_irq(struct flexcop_device *fc,
126int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 127 flexcop_dma_index_t no, int onoff);
127int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx); 128int flexcop_dma_control_size_irq(struct flexcop_device *fc,
128int flexcop_dma_xfer_control(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, flexcop_dma_addr_index_t index, int onoff); 129 flexcop_dma_index_t no, int onoff);
129int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles); 130int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma,
131 flexcop_dma_index_t dma_idx);
132int flexcop_dma_xfer_control(struct flexcop_device *fc,
133 flexcop_dma_index_t dma_idx, flexcop_dma_addr_index_t index,
134 int onoff);
135int flexcop_dma_config_timer(struct flexcop_device *fc,
136 flexcop_dma_index_t dma_idx, u8 cycles);
130 137
131/* from flexcop-eeprom.c */ 138/* from flexcop-eeprom.c */
132/* the PCI part uses this call to get the MAC address, the USB part has its own */ 139/* the PCI part uses this call to get the MAC address, the USB part has its own */
@@ -141,13 +148,15 @@ int flexcop_i2c_request(struct flexcop_i2c_adapter*, flexcop_access_op_t,
141 u8 chipaddr, u8 addr, u8 *buf, u16 len); 148 u8 chipaddr, u8 addr, u8 *buf, u16 len);
142 149
143/* from flexcop-sram.c */ 150/* from flexcop-sram.c */
144int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target); 151int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest,
152 flexcop_sram_dest_target_t target);
145void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s); 153void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s);
146void flexcop_sram_ctrl(struct flexcop_device *fc, int usb_wan, int sramdma, int maximumfill); 154void flexcop_sram_ctrl(struct flexcop_device *fc,
155 int usb_wan, int sramdma, int maximumfill);
147 156
148/* global prototypes for the flexcop-chip */ 157/* global prototypes for the flexcop-chip */
149/* from flexcop-fe-tuner.c */ 158/* from flexcop-fe-tuner.c */
150int flexcop_frontend_init(struct flexcop_device *card); 159int flexcop_frontend_init(struct flexcop_device *fc);
151void flexcop_frontend_exit(struct flexcop_device *fc); 160void flexcop_frontend_exit(struct flexcop_device *fc);
152 161
153/* from flexcop-i2c.c */ 162/* from flexcop-i2c.c */
@@ -159,11 +168,14 @@ int flexcop_sram_init(struct flexcop_device *fc);
159 168
160/* from flexcop-misc.c */ 169/* from flexcop-misc.c */
161void flexcop_determine_revision(struct flexcop_device *fc); 170void flexcop_determine_revision(struct flexcop_device *fc);
162void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const char *suffix); 171void flexcop_device_name(struct flexcop_device *fc,
163void flexcop_dump_reg(struct flexcop_device *fc, flexcop_ibi_register reg, int num); 172 const char *prefix, const char *suffix);
173void flexcop_dump_reg(struct flexcop_device *fc,
174 flexcop_ibi_register reg, int num);
164 175
165/* from flexcop-hw-filter.c */ 176/* from flexcop-hw-filter.c */
166int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff); 177int flexcop_pid_feed_control(struct flexcop_device *fc,
178 struct dvb_demux_feed *dvbdmxfeed, int onoff);
167void flexcop_hw_filter_init(struct flexcop_device *fc); 179void flexcop_hw_filter_init(struct flexcop_device *fc);
168 180
169void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff); 181void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff);
diff --git a/drivers/media/dvb/b2c2/flexcop-dma.c b/drivers/media/dvb/b2c2/flexcop-dma.c
index 26f0011a507..2881e0d956a 100644
--- a/drivers/media/dvb/b2c2/flexcop-dma.c
+++ b/drivers/media/dvb/b2c2/flexcop-dma.c
@@ -1,13 +1,12 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * 3 * flexcop-dma.c - configuring and controlling the DMA of the FlexCop
4 * flexcop-dma.c - methods for configuring and controlling the DMA of the FlexCop. 4 * see flexcop.c for copyright information
5 *
6 * see flexcop.c for copyright information.
7 */ 5 */
8#include "flexcop.h" 6#include "flexcop.h"
9 7
10int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size) 8int flexcop_dma_allocate(struct pci_dev *pdev,
9 struct flexcop_dma *dma, u32 size)
11{ 10{
12 u8 *tcpu; 11 u8 *tcpu;
13 dma_addr_t tdma = 0; 12 dma_addr_t tdma = 0;
@@ -32,7 +31,8 @@ EXPORT_SYMBOL(flexcop_dma_allocate);
32 31
33void flexcop_dma_free(struct flexcop_dma *dma) 32void flexcop_dma_free(struct flexcop_dma *dma)
34{ 33{
35 pci_free_consistent(dma->pdev, dma->size*2,dma->cpu_addr0, dma->dma_addr0); 34 pci_free_consistent(dma->pdev, dma->size*2,
35 dma->cpu_addr0, dma->dma_addr0);
36 memset(dma,0,sizeof(struct flexcop_dma)); 36 memset(dma,0,sizeof(struct flexcop_dma));
37} 37}
38EXPORT_SYMBOL(flexcop_dma_free); 38EXPORT_SYMBOL(flexcop_dma_free);
@@ -44,8 +44,8 @@ int flexcop_dma_config(struct flexcop_device *fc,
44 flexcop_ibi_value v0x0,v0x4,v0xc; 44 flexcop_ibi_value v0x0,v0x4,v0xc;
45 v0x0.raw = v0x4.raw = v0xc.raw = 0; 45 v0x0.raw = v0x4.raw = v0xc.raw = 0;
46 46
47 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2; 47 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2;
48 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2; 48 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2;
49 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4; 49 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4;
50 50
51 if ((dma_idx & FC_DMA_1) == dma_idx) { 51 if ((dma_idx & FC_DMA_1) == dma_idx) {
@@ -57,7 +57,8 @@ int flexcop_dma_config(struct flexcop_device *fc,
57 fc->write_ibi_reg(fc,dma2_014,v0x4); 57 fc->write_ibi_reg(fc,dma2_014,v0x4);
58 fc->write_ibi_reg(fc,dma2_01c,v0xc); 58 fc->write_ibi_reg(fc,dma2_01c,v0xc);
59 } else { 59 } else {
60 err("either DMA1 or DMA2 can be configured at the within one flexcop_dma_config call."); 60 err("either DMA1 or DMA2 can be configured within one "
61 "flexcop_dma_config call.");
61 return -EINVAL; 62 return -EINVAL;
62 } 63 }
63 64
@@ -81,7 +82,8 @@ int flexcop_dma_xfer_control(struct flexcop_device *fc,
81 r0x0 = dma2_010; 82 r0x0 = dma2_010;
82 r0xc = dma2_01c; 83 r0xc = dma2_01c;
83 } else { 84 } else {
84 err("either transfer DMA1 or DMA2 can be started within one flexcop_dma_xfer_control call."); 85 err("either transfer DMA1 or DMA2 can be started within one "
86 "flexcop_dma_xfer_control call.");
85 return -EINVAL; 87 return -EINVAL;
86 } 88 }
87 89
@@ -154,8 +156,7 @@ EXPORT_SYMBOL(flexcop_dma_control_timer_irq);
154 156
155/* 1 cycles = 1.97 msec */ 157/* 1 cycles = 1.97 msec */
156int flexcop_dma_config_timer(struct flexcop_device *fc, 158int flexcop_dma_config_timer(struct flexcop_device *fc,
157 flexcop_dma_index_t dma_idx, 159 flexcop_dma_index_t dma_idx, u8 cycles)
158 u8 cycles)
159{ 160{
160 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014; 161 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
161 flexcop_ibi_value v = fc->read_ibi_reg(fc,r); 162 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
diff --git a/drivers/media/dvb/b2c2/flexcop-eeprom.c b/drivers/media/dvb/b2c2/flexcop-eeprom.c
index 8a8ae8a3e6b..a25373a9bd8 100644
--- a/drivers/media/dvb/b2c2/flexcop-eeprom.c
+++ b/drivers/media/dvb/b2c2/flexcop-eeprom.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * 3 * flexcop-eeprom.c - eeprom access methods (currently only MAC address reading)
4 * flexcop-eeprom.c - eeprom access methods (currently only MAC address reading is used) 4 * see flexcop.c for copyright information
5 *
6 * see flexcop.c for copyright information.
7 */ 5 */
8#include "flexcop.h" 6#include "flexcop.h"
9 7
@@ -14,17 +12,17 @@ static int eeprom_write(struct adapter *adapter, u16 addr, u8 *buf, u16 len)
14 return flex_i2c_write(adapter, 0x20000000, 0x50, addr, buf, len); 12 return flex_i2c_write(adapter, 0x20000000, 0x50, addr, buf, len);
15} 13}
16 14
17static int eeprom_lrc_write(struct adapter *adapter, u32 addr, u32 len, u8 *wbuf, u8 *rbuf, int retries) 15static int eeprom_lrc_write(struct adapter *adapter, u32 addr,
16 u32 len, u8 *wbuf, u8 *rbuf, int retries)
18{ 17{
19 int i; 18int i;
20 19
21 for (i = 0; i < retries; i++) { 20for (i = 0; i < retries; i++) {
22 if (eeprom_write(adapter, addr, wbuf, len) == len) { 21 if (eeprom_write(adapter, addr, wbuf, len) == len) {
23 if (eeprom_lrc_read(adapter, addr, len, rbuf, retries) == 1) 22 if (eeprom_lrc_read(adapter, addr, len, rbuf, retries) == 1)
24 return 1; 23 return 1;
25 } 24 }
26 } 25 }
27
28 return 0; 26 return 0;
29} 27}
30 28
@@ -39,12 +37,10 @@ static int eeprom_writeKey(struct adapter *adapter, u8 *key, u32 len)
39 return 0; 37 return 0;
40 38
41 memcpy(wbuf, key, len); 39 memcpy(wbuf, key, len);
42
43 wbuf[16] = 0; 40 wbuf[16] = 0;
44 wbuf[17] = 0; 41 wbuf[17] = 0;
45 wbuf[18] = 0; 42 wbuf[18] = 0;
46 wbuf[19] = calc_lrc(wbuf, 19); 43 wbuf[19] = calc_lrc(wbuf, 19);
47
48 return eeprom_lrc_write(adapter, 0x3e4, 20, wbuf, rbuf, 4); 44 return eeprom_lrc_write(adapter, 0x3e4, 20, wbuf, rbuf, 4);
49} 45}
50 46
@@ -59,7 +55,6 @@ static int eeprom_readKey(struct adapter *adapter, u8 *key, u32 len)
59 return 0; 55 return 0;
60 56
61 memcpy(key, buf, len); 57 memcpy(key, buf, len);
62
63 return 1; 58 return 1;
64} 59}
65 60
@@ -74,9 +69,7 @@ static char eeprom_set_mac_addr(struct adapter *adapter, char type, u8 *mac)
74 tmp[3] = mac[5]; 69 tmp[3] = mac[5];
75 tmp[4] = mac[6]; 70 tmp[4] = mac[6];
76 tmp[5] = mac[7]; 71 tmp[5] = mac[7];
77
78 } else { 72 } else {
79
80 tmp[0] = mac[0]; 73 tmp[0] = mac[0];
81 tmp[1] = mac[1]; 74 tmp[1] = mac[1];
82 tmp[2] = mac[2]; 75 tmp[2] = mac[2];
@@ -90,11 +83,11 @@ static char eeprom_set_mac_addr(struct adapter *adapter, char type, u8 *mac)
90 83
91 if (eeprom_write(adapter, 0x3f8, tmp, 8) == 8) 84 if (eeprom_write(adapter, 0x3f8, tmp, 8) == 8)
92 return 1; 85 return 1;
93
94 return 0; 86 return 0;
95} 87}
96 88
97static int flexcop_eeprom_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len) 89static int flexcop_eeprom_read(struct flexcop_device *fc,
90 u16 addr, u8 *buf, u16 len)
98{ 91{
99 return fc->i2c_request(fc,FC_READ,FC_I2C_PORT_EEPROM,0x50,addr,buf,len); 92 return fc->i2c_request(fc,FC_READ,FC_I2C_PORT_EEPROM,0x50,addr,buf,len);
100} 93}
@@ -110,7 +103,8 @@ static u8 calc_lrc(u8 *buf, int len)
110 return sum; 103 return sum;
111} 104}
112 105
113static int flexcop_eeprom_request(struct flexcop_device *fc, flexcop_access_op_t op, u16 addr, u8 *buf, u16 len, int retries) 106static int flexcop_eeprom_request(struct flexcop_device *fc,
107 flexcop_access_op_t op, u16 addr, u8 *buf, u16 len, int retries)
114{ 108{
115 int i,ret = 0; 109 int i,ret = 0;
116 u8 chipaddr = 0x50 | ((addr >> 8) & 3); 110 u8 chipaddr = 0x50 | ((addr >> 8) & 3);
@@ -123,7 +117,8 @@ static int flexcop_eeprom_request(struct flexcop_device *fc, flexcop_access_op_t
123 return ret; 117 return ret;
124} 118}
125 119
126static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len, int retries) 120static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr,
121 u8 *buf, u16 len, int retries)
127{ 122{
128 int ret = flexcop_eeprom_request(fc, FC_READ, addr, buf, len, retries); 123 int ret = flexcop_eeprom_request(fc, FC_READ, addr, buf, len, retries);
129 if (ret == 0) 124 if (ret == 0)
@@ -133,8 +128,7 @@ static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr, u8 *buf,
133} 128}
134 129
135/* JJ's comment about extended == 1: it is not presently used anywhere but was 130/* JJ's comment about extended == 1: it is not presently used anywhere but was
136 * added to the low-level functions for possible support of EUI64 131 * added to the low-level functions for possible support of EUI64 */
137 */
138int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended) 132int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
139{ 133{
140 u8 buf[8]; 134 u8 buf[8];
@@ -142,12 +136,9 @@ int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
142 136
143 if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) { 137 if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) {
144 if (extended != 0) { 138 if (extended != 0) {
145 err("TODO: extended (EUI64) MAC addresses aren't completely supported yet"); 139 err("TODO: extended (EUI64) MAC addresses aren't "
140 "completely supported yet");
146 ret = -EINVAL; 141 ret = -EINVAL;
147/* memcpy(fc->dvb_adapter.proposed_mac,buf,3);
148 mac[3] = 0xfe;
149 mac[4] = 0xff;
150 memcpy(&fc->dvb_adapter.proposed_mac[3],&buf[5],3); */
151 } else 142 } else
152 memcpy(fc->dvb_adapter.proposed_mac,buf,6); 143 memcpy(fc->dvb_adapter.proposed_mac,buf,6);
153 } 144 }
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 5cded370854..f7afab5944c 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -592,14 +592,14 @@ int flexcop_frontend_init(struct flexcop_device *fc)
592 fc->fe_sleep = ops->sleep; 592 fc->fe_sleep = ops->sleep;
593 ops->sleep = flexcop_sleep; 593 ops->sleep = flexcop_sleep;
594 594
595 fc->dev_type = FC_SKY; 595 fc->dev_type = FC_SKY_REV26;
596 goto fe_found; 596 goto fe_found;
597 } 597 }
598 598
599 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ 599 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
600 fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c); 600 fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c);
601 if (fc->fe != NULL) { 601 if (fc->fe != NULL) {
602 fc->dev_type = FC_AIR_DVB; 602 fc->dev_type = FC_AIR_DVBT;
603 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; 603 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
604 goto fe_found; 604 goto fe_found;
605 } 605 }
@@ -653,7 +653,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
653 fc->fe_sleep = ops->sleep; 653 fc->fe_sleep = ops->sleep;
654 ops->sleep = flexcop_sleep; 654 ops->sleep = flexcop_sleep;
655 655
656 fc->dev_type = FC_SKY_OLD; 656 fc->dev_type = FC_SKY_REV23;
657 goto fe_found; 657 goto fe_found;
658 } 658 }
659 659
diff --git a/drivers/media/dvb/b2c2/flexcop-hw-filter.c b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
index 451974ba32f..77e45475f4c 100644
--- a/drivers/media/dvb/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
@@ -1,33 +1,30 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * 3 * flexcop-hw-filter.c - pid and mac address filtering and control functions
4 * flexcop-hw-filter.c - pid and mac address filtering and corresponding control functions. 4 * see flexcop.c for copyright information
5 *
6 * see flexcop.c for copyright information.
7 */ 5 */
8#include "flexcop.h" 6#include "flexcop.h"
9 7
10static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff) 8static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff)
11{ 9{
12 flexcop_set_ibi_value(ctrl_208,Rcv_Data_sig,onoff); 10 flexcop_set_ibi_value(ctrl_208, Rcv_Data_sig, onoff);
13 11 deb_ts("rcv_data is now: '%s'\n", onoff ? "on" : "off");
14 deb_ts("rcv_data is now: '%s'\n",onoff ? "on" : "off");
15} 12}
16 13
17void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff) 14void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
18{ 15{
19 flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff); 16 flexcop_set_ibi_value(ctrl_208, SMC_Enable_sig, onoff);
20} 17}
21 18
22static void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff) 19static void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff)
23{ 20{
24 flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff); 21 flexcop_set_ibi_value(ctrl_208, Null_filter_sig, onoff);
25} 22}
26 23
27void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6]) 24void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6])
28{ 25{
29 flexcop_ibi_value v418,v41c; 26 flexcop_ibi_value v418, v41c;
30 v41c = fc->read_ibi_reg(fc,mac_address_41c); 27 v41c = fc->read_ibi_reg(fc, mac_address_41c);
31 28
32 v418.mac_address_418.MAC1 = mac[0]; 29 v418.mac_address_418.MAC1 = mac[0];
33 v418.mac_address_418.MAC2 = mac[1]; 30 v418.mac_address_418.MAC2 = mac[1];
@@ -36,27 +33,28 @@ void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6])
36 v41c.mac_address_41c.MAC7 = mac[4]; 33 v41c.mac_address_41c.MAC7 = mac[4];
37 v41c.mac_address_41c.MAC8 = mac[5]; 34 v41c.mac_address_41c.MAC8 = mac[5];
38 35
39 fc->write_ibi_reg(fc,mac_address_418,v418); 36 fc->write_ibi_reg(fc, mac_address_418, v418);
40 fc->write_ibi_reg(fc,mac_address_41c,v41c); 37 fc->write_ibi_reg(fc, mac_address_41c, v41c);
41} 38}
42 39
43void flexcop_mac_filter_ctrl(struct flexcop_device *fc, int onoff) 40void flexcop_mac_filter_ctrl(struct flexcop_device *fc, int onoff)
44{ 41{
45 flexcop_set_ibi_value(ctrl_208,MAC_filter_Mode_sig,onoff); 42 flexcop_set_ibi_value(ctrl_208, MAC_filter_Mode_sig, onoff);
46} 43}
47 44
48static void flexcop_pid_group_filter(struct flexcop_device *fc, u16 pid, u16 mask) 45static void flexcop_pid_group_filter(struct flexcop_device *fc,
46 u16 pid, u16 mask)
49{ 47{
50 /* index_reg_310.extra_index_reg need to 0 or 7 to work */ 48 /* index_reg_310.extra_index_reg need to 0 or 7 to work */
51 flexcop_ibi_value v30c; 49 flexcop_ibi_value v30c;
52 v30c.pid_filter_30c_ext_ind_0_7.Group_PID = pid; 50 v30c.pid_filter_30c_ext_ind_0_7.Group_PID = pid;
53 v30c.pid_filter_30c_ext_ind_0_7.Group_mask = mask; 51 v30c.pid_filter_30c_ext_ind_0_7.Group_mask = mask;
54 fc->write_ibi_reg(fc,pid_filter_30c,v30c); 52 fc->write_ibi_reg(fc, pid_filter_30c, v30c);
55} 53}
56 54
57static void flexcop_pid_group_filter_ctrl(struct flexcop_device *fc, int onoff) 55static void flexcop_pid_group_filter_ctrl(struct flexcop_device *fc, int onoff)
58{ 56{
59 flexcop_set_ibi_value(ctrl_208,Mask_filter_sig,onoff); 57 flexcop_set_ibi_value(ctrl_208, Mask_filter_sig, onoff);
60} 58}
61 59
62/* this fancy define reduces the code size of the quite similar PID controlling of 60/* this fancy define reduces the code size of the quite similar PID controlling of
@@ -65,91 +63,112 @@ static void flexcop_pid_group_filter_ctrl(struct flexcop_device *fc, int onoff)
65 63
66#define pid_ctrl(vregname,field,enablefield,trans_field,transval) \ 64#define pid_ctrl(vregname,field,enablefield,trans_field,transval) \
67 flexcop_ibi_value vpid = fc->read_ibi_reg(fc, vregname), \ 65 flexcop_ibi_value vpid = fc->read_ibi_reg(fc, vregname), \
68 v208 = fc->read_ibi_reg(fc, ctrl_208); \ 66v208 = fc->read_ibi_reg(fc, ctrl_208); \
69\ 67vpid.vregname.field = onoff ? pid : 0x1fff; \
70 vpid.vregname.field = onoff ? pid : 0x1fff; \ 68vpid.vregname.trans_field = transval; \
71 vpid.vregname.trans_field = transval; \ 69v208.ctrl_208.enablefield = onoff; \
72 v208.ctrl_208.enablefield = onoff; \ 70fc->write_ibi_reg(fc, vregname, vpid); \
73\ 71fc->write_ibi_reg(fc, ctrl_208, v208);
74 fc->write_ibi_reg(fc,vregname,vpid); \
75 fc->write_ibi_reg(fc,ctrl_208,v208);
76 72
77static void flexcop_pid_Stream1_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff) 73static void flexcop_pid_Stream1_PID_ctrl(struct flexcop_device *fc,
74 u16 pid, int onoff)
78{ 75{
79 pid_ctrl(pid_filter_300,Stream1_PID,Stream1_filter_sig,Stream1_trans,0); 76 pid_ctrl(pid_filter_300, Stream1_PID, Stream1_filter_sig,
77 Stream1_trans, 0);
80} 78}
81 79
82static void flexcop_pid_Stream2_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff) 80static void flexcop_pid_Stream2_PID_ctrl(struct flexcop_device *fc,
81 u16 pid, int onoff)
83{ 82{
84 pid_ctrl(pid_filter_300,Stream2_PID,Stream2_filter_sig,Stream2_trans,0); 83 pid_ctrl(pid_filter_300, Stream2_PID, Stream2_filter_sig,
84 Stream2_trans, 0);
85} 85}
86 86
87static void flexcop_pid_PCR_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff) 87static void flexcop_pid_PCR_PID_ctrl(struct flexcop_device *fc,
88 u16 pid, int onoff)
88{ 89{
89 pid_ctrl(pid_filter_304,PCR_PID,PCR_filter_sig,PCR_trans,0); 90 pid_ctrl(pid_filter_304, PCR_PID, PCR_filter_sig, PCR_trans, 0);
90} 91}
91 92
92static void flexcop_pid_PMT_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff) 93static void flexcop_pid_PMT_PID_ctrl(struct flexcop_device *fc,
94 u16 pid, int onoff)
93{ 95{
94 pid_ctrl(pid_filter_304,PMT_PID,PMT_filter_sig,PMT_trans,0); 96 pid_ctrl(pid_filter_304, PMT_PID, PMT_filter_sig, PMT_trans, 0);
95} 97}
96 98
97static void flexcop_pid_EMM_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff) 99static void flexcop_pid_EMM_PID_ctrl(struct flexcop_device *fc,
100 u16 pid, int onoff)
98{ 101{
99 pid_ctrl(pid_filter_308,EMM_PID,EMM_filter_sig,EMM_trans,0); 102 pid_ctrl(pid_filter_308, EMM_PID, EMM_filter_sig, EMM_trans, 0);
100} 103}
101 104
102static void flexcop_pid_ECM_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff) 105static void flexcop_pid_ECM_PID_ctrl(struct flexcop_device *fc,
106 u16 pid, int onoff)
103{ 107{
104 pid_ctrl(pid_filter_308,ECM_PID,ECM_filter_sig,ECM_trans,0); 108 pid_ctrl(pid_filter_308, ECM_PID, ECM_filter_sig, ECM_trans, 0);
105} 109}
106 110
107static void flexcop_pid_control(struct flexcop_device *fc, int index, u16 pid,int onoff) 111static void flexcop_pid_control(struct flexcop_device *fc,
112 int index, u16 pid, int onoff)
108{ 113{
109 if (pid == 0x2000) 114 if (pid == 0x2000)
110 return; 115 return;
111 116
112 deb_ts("setting pid: %5d %04x at index %d '%s'\n",pid,pid,index,onoff ? "on" : "off"); 117 deb_ts("setting pid: %5d %04x at index %d '%s'\n",
118 pid, pid, index, onoff ? "on" : "off");
113 119
114 /* We could use bit magic here to reduce source code size. 120 /* We could use bit magic here to reduce source code size.
115 * I decided against it, but to use the real register names */ 121 * I decided against it, but to use the real register names */
116 switch (index) { 122 switch (index) {
117 case 0: flexcop_pid_Stream1_PID_ctrl(fc,pid,onoff); break; 123 case 0:
118 case 1: flexcop_pid_Stream2_PID_ctrl(fc,pid,onoff); break; 124 flexcop_pid_Stream1_PID_ctrl(fc, pid, onoff);
119 case 2: flexcop_pid_PCR_PID_ctrl(fc,pid,onoff); break; 125 break;
120 case 3: flexcop_pid_PMT_PID_ctrl(fc,pid,onoff); break; 126 case 1:
121 case 4: flexcop_pid_EMM_PID_ctrl(fc,pid,onoff); break; 127 flexcop_pid_Stream2_PID_ctrl(fc, pid, onoff);
122 case 5: flexcop_pid_ECM_PID_ctrl(fc,pid,onoff); break; 128 break;
123 default: 129 case 2:
124 if (fc->has_32_hw_pid_filter && index < 38) { 130 flexcop_pid_PCR_PID_ctrl(fc, pid, onoff);
125 flexcop_ibi_value vpid,vid; 131 break;
126 132 case 3:
127 /* set the index */ 133 flexcop_pid_PMT_PID_ctrl(fc, pid, onoff);
128 vid = fc->read_ibi_reg(fc,index_reg_310); 134 break;
129 vid.index_reg_310.index_reg = index - 6; 135 case 4:
130 fc->write_ibi_reg(fc,index_reg_310, vid); 136 flexcop_pid_EMM_PID_ctrl(fc, pid, onoff);
131 137 break;
132 vpid = fc->read_ibi_reg(fc,pid_n_reg_314); 138 case 5:
133 vpid.pid_n_reg_314.PID = onoff ? pid : 0x1fff; 139 flexcop_pid_ECM_PID_ctrl(fc, pid, onoff);
134 vpid.pid_n_reg_314.PID_enable_bit = onoff; 140 break;
135 fc->write_ibi_reg(fc,pid_n_reg_314, vpid); 141 default:
136 } 142 if (fc->has_32_hw_pid_filter && index < 38) {
137 break; 143 flexcop_ibi_value vpid, vid;
144
145 /* set the index */
146 vid = fc->read_ibi_reg(fc, index_reg_310);
147 vid.index_reg_310.index_reg = index - 6;
148 fc->write_ibi_reg(fc, index_reg_310, vid);
149
150 vpid = fc->read_ibi_reg(fc, pid_n_reg_314);
151 vpid.pid_n_reg_314.PID = onoff ? pid : 0x1fff;
152 vpid.pid_n_reg_314.PID_enable_bit = onoff;
153 fc->write_ibi_reg(fc, pid_n_reg_314, vpid);
154 }
155 break;
138 } 156 }
139} 157}
140 158
141static int flexcop_toggle_fullts_streaming(struct flexcop_device *fc,int onoff) 159static int flexcop_toggle_fullts_streaming(struct flexcop_device *fc, int onoff)
142{ 160{
143 if (fc->fullts_streaming_state != onoff) { 161 if (fc->fullts_streaming_state != onoff) {
144 deb_ts("%s full TS transfer\n",onoff ? "enabling" : "disabling"); 162 deb_ts("%s full TS transfer\n",onoff ? "enabling" : "disabling");
145 flexcop_pid_group_filter(fc, 0, 0x1fe0 * (!onoff)); 163 flexcop_pid_group_filter(fc, 0, 0x1fe0 * (!onoff));
146 flexcop_pid_group_filter_ctrl(fc,onoff); 164 flexcop_pid_group_filter_ctrl(fc, onoff);
147 fc->fullts_streaming_state = onoff; 165 fc->fullts_streaming_state = onoff;
148 } 166 }
149 return 0; 167 return 0;
150} 168}
151 169
152int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff) 170int flexcop_pid_feed_control(struct flexcop_device *fc,
171 struct dvb_demux_feed *dvbdmxfeed, int onoff)
153{ 172{
154 int max_pid_filter = 6 + fc->has_32_hw_pid_filter*32; 173 int max_pid_filter = 6 + fc->has_32_hw_pid_filter*32;
155 174
@@ -164,24 +183,25 @@ int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *d
164 * - or the requested pid is 0x2000 */ 183 * - or the requested pid is 0x2000 */
165 184
166 if (!fc->pid_filtering && fc->feedcount == onoff) 185 if (!fc->pid_filtering && fc->feedcount == onoff)
167 flexcop_toggle_fullts_streaming(fc,onoff); 186 flexcop_toggle_fullts_streaming(fc, onoff);
168 187
169 if (fc->pid_filtering) { 188 if (fc->pid_filtering) {
170 flexcop_pid_control(fc,dvbdmxfeed->index,dvbdmxfeed->pid,onoff); 189 flexcop_pid_control \
190 (fc, dvbdmxfeed->index, dvbdmxfeed->pid, onoff);
171 191
172 if (fc->extra_feedcount > 0) 192 if (fc->extra_feedcount > 0)
173 flexcop_toggle_fullts_streaming(fc,1); 193 flexcop_toggle_fullts_streaming(fc, 1);
174 else if (dvbdmxfeed->pid == 0x2000) 194 else if (dvbdmxfeed->pid == 0x2000)
175 flexcop_toggle_fullts_streaming(fc,onoff); 195 flexcop_toggle_fullts_streaming(fc, onoff);
176 else 196 else
177 flexcop_toggle_fullts_streaming(fc,0); 197 flexcop_toggle_fullts_streaming(fc, 0);
178 } 198 }
179 199
180 /* if it was the first or last feed request change the stream-status */ 200 /* if it was the first or last feed request change the stream-status */
181 if (fc->feedcount == onoff) { 201 if (fc->feedcount == onoff) {
182 flexcop_rcv_data_ctrl(fc,onoff); 202 flexcop_rcv_data_ctrl(fc, onoff);
183 if (fc->stream_control) /* device specific stream control */ 203 if (fc->stream_control) /* device specific stream control */
184 fc->stream_control(fc,onoff); 204 fc->stream_control(fc, onoff);
185 205
186 /* feeding stopped -> reset the flexcop filter*/ 206 /* feeding stopped -> reset the flexcop filter*/
187 if (onoff == 0) { 207 if (onoff == 0) {
@@ -189,7 +209,6 @@ int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *d
189 flexcop_hw_filter_init(fc); 209 flexcop_hw_filter_init(fc);
190 } 210 }
191 } 211 }
192
193 return 0; 212 return 0;
194} 213}
195EXPORT_SYMBOL(flexcop_pid_feed_control); 214EXPORT_SYMBOL(flexcop_pid_feed_control);
@@ -199,15 +218,15 @@ void flexcop_hw_filter_init(struct flexcop_device *fc)
199 int i; 218 int i;
200 flexcop_ibi_value v; 219 flexcop_ibi_value v;
201 for (i = 0; i < 6 + 32*fc->has_32_hw_pid_filter; i++) 220 for (i = 0; i < 6 + 32*fc->has_32_hw_pid_filter; i++)
202 flexcop_pid_control(fc,i,0x1fff,0); 221 flexcop_pid_control(fc, i, 0x1fff, 0);
203 222
204 flexcop_pid_group_filter(fc, 0, 0x1fe0); 223 flexcop_pid_group_filter(fc, 0, 0x1fe0);
205 flexcop_pid_group_filter_ctrl(fc,0); 224 flexcop_pid_group_filter_ctrl(fc, 0);
206 225
207 v = fc->read_ibi_reg(fc,pid_filter_308); 226 v = fc->read_ibi_reg(fc, pid_filter_308);
208 v.pid_filter_308.EMM_filter_4 = 1; 227 v.pid_filter_308.EMM_filter_4 = 1;
209 v.pid_filter_308.EMM_filter_6 = 0; 228 v.pid_filter_308.EMM_filter_6 = 0;
210 fc->write_ibi_reg(fc,pid_filter_308,v); 229 fc->write_ibi_reg(fc, pid_filter_308, v);
211 230
212 flexcop_null_filter_ctrl(fc, 1); 231 flexcop_null_filter_ctrl(fc, 1);
213} 232}
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
index a0cfde18e64..e2bed507648 100644
--- a/drivers/media/dvb/b2c2/flexcop-i2c.c
+++ b/drivers/media/dvb/b2c2/flexcop-i2c.c
@@ -1,17 +1,14 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-i2c.c - flexcop internal 2Wire bus (I2C) and dvb i2c initialization 3 * flexcop-i2c.c - flexcop internal 2Wire bus (I2C) and dvb i2c initialization
5 * 4 * see flexcop.c for copyright information
6 * see flexcop.c for copyright information.
7 */ 5 */
8#include "flexcop.h" 6#include "flexcop.h"
9 7
10#define FC_MAX_I2C_RETRIES 100000 8#define FC_MAX_I2C_RETRIES 100000
11 9
12/* #define DUMP_I2C_MESSAGES */ 10static int flexcop_i2c_operation(struct flexcop_device *fc,
13 11 flexcop_ibi_value *r100)
14static int flexcop_i2c_operation(struct flexcop_device *fc, flexcop_ibi_value *r100)
15{ 12{
16 int i; 13 int i;
17 flexcop_ibi_value r; 14 flexcop_ibi_value r;
@@ -26,7 +23,7 @@ static int flexcop_i2c_operation(struct flexcop_device *fc, flexcop_ibi_value *r
26 r = fc->read_ibi_reg(fc, tw_sm_c_100); 23 r = fc->read_ibi_reg(fc, tw_sm_c_100);
27 24
28 if (!r.tw_sm_c_100.no_base_addr_ack_error) { 25 if (!r.tw_sm_c_100.no_base_addr_ack_error) {
29 if (r.tw_sm_c_100.st_done) { /* && !r.tw_sm_c_100.working_start */ 26 if (r.tw_sm_c_100.st_done) {
30 *r100 = r; 27 *r100 = r;
31 deb_i2c("i2c success\n"); 28 deb_i2c("i2c success\n");
32 return 0; 29 return 0;
@@ -36,15 +33,17 @@ static int flexcop_i2c_operation(struct flexcop_device *fc, flexcop_ibi_value *r
36 return -EREMOTEIO; 33 return -EREMOTEIO;
37 } 34 }
38 } 35 }
39 deb_i2c("tried %d times i2c operation, never finished or too many ack errors.\n",i); 36 deb_i2c("tried %d times i2c operation, "
37 "never finished or too many ack errors.\n", i);
40 return -EREMOTEIO; 38 return -EREMOTEIO;
41} 39}
42 40
43static int flexcop_i2c_read4(struct flexcop_i2c_adapter *i2c, 41static int flexcop_i2c_read4(struct flexcop_i2c_adapter *i2c,
44 flexcop_ibi_value r100, u8 *buf) 42 flexcop_ibi_value r100, u8 *buf)
45{ 43{
46 flexcop_ibi_value r104; 44 flexcop_ibi_value r104;
47 int len = r100.tw_sm_c_100.total_bytes, /* remember total_bytes is buflen-1 */ 45 int len = r100.tw_sm_c_100.total_bytes,
46 /* remember total_bytes is buflen-1 */
48 ret; 47 ret;
49 48
50 /* work-around to have CableStar2 and SkyStar2 rev 2.7 work 49 /* work-around to have CableStar2 and SkyStar2 rev 2.7 work
@@ -81,11 +80,11 @@ static int flexcop_i2c_read4(struct flexcop_i2c_adapter *i2c,
81 if (len > 1) buf[2] = r104.tw_sm_c_104.data3_reg; 80 if (len > 1) buf[2] = r104.tw_sm_c_104.data3_reg;
82 if (len > 2) buf[3] = r104.tw_sm_c_104.data4_reg; 81 if (len > 2) buf[3] = r104.tw_sm_c_104.data4_reg;
83 } 82 }
84
85 return 0; 83 return 0;
86} 84}
87 85
88static int flexcop_i2c_write4(struct flexcop_device *fc, flexcop_ibi_value r100, u8 *buf) 86static int flexcop_i2c_write4(struct flexcop_device *fc,
87 flexcop_ibi_value r100, u8 *buf)
89{ 88{
90 flexcop_ibi_value r104; 89 flexcop_ibi_value r104;
91 int len = r100.tw_sm_c_100.total_bytes; /* remember total_bytes is buflen-1 */ 90 int len = r100.tw_sm_c_100.total_bytes; /* remember total_bytes is buflen-1 */
@@ -93,7 +92,6 @@ static int flexcop_i2c_write4(struct flexcop_device *fc, flexcop_ibi_value r100,
93 92
94 /* there is at least one byte, otherwise we wouldn't be here */ 93 /* there is at least one byte, otherwise we wouldn't be here */
95 r100.tw_sm_c_100.data1_reg = buf[0]; 94 r100.tw_sm_c_100.data1_reg = buf[0];
96
97 r104.tw_sm_c_104.data2_reg = len > 0 ? buf[1] : 0; 95 r104.tw_sm_c_104.data2_reg = len > 0 ? buf[1] : 0;
98 r104.tw_sm_c_104.data3_reg = len > 1 ? buf[2] : 0; 96 r104.tw_sm_c_104.data3_reg = len > 1 ? buf[2] : 0;
99 r104.tw_sm_c_104.data4_reg = len > 2 ? buf[3] : 0; 97 r104.tw_sm_c_104.data4_reg = len > 2 ? buf[3] : 0;
@@ -106,7 +104,7 @@ static int flexcop_i2c_write4(struct flexcop_device *fc, flexcop_ibi_value r100,
106} 104}
107 105
108int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c, 106int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c,
109 flexcop_access_op_t op, u8 chipaddr, u8 addr, u8 *buf, u16 len) 107 flexcop_access_op_t op, u8 chipaddr, u8 addr, u8 *buf, u16 len)
110{ 108{
111 int ret; 109 int ret;
112 110
@@ -129,7 +127,6 @@ int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c,
129 printk("rd("); 127 printk("rd(");
130 else 128 else
131 printk("wr("); 129 printk("wr(");
132
133 printk("%02x): %02x ", chipaddr, addr); 130 printk("%02x): %02x ", chipaddr, addr);
134#endif 131#endif
135 132
@@ -175,7 +172,8 @@ int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c,
175EXPORT_SYMBOL(flexcop_i2c_request); 172EXPORT_SYMBOL(flexcop_i2c_request);
176 173
177/* master xfer callback for demodulator */ 174/* master xfer callback for demodulator */
178static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) 175static int flexcop_master_xfer(struct i2c_adapter *i2c_adap,
176 struct i2c_msg msgs[], int num)
179{ 177{
180 struct flexcop_i2c_adapter *i2c = i2c_get_adapdata(i2c_adap); 178 struct flexcop_i2c_adapter *i2c = i2c_get_adapdata(i2c_adap);
181 int i, ret = 0; 179 int i, ret = 0;
@@ -194,12 +192,13 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs
194 /* reading */ 192 /* reading */
195 if (i+1 < num && (msgs[i+1].flags == I2C_M_RD)) { 193 if (i+1 < num && (msgs[i+1].flags == I2C_M_RD)) {
196 ret = i2c->fc->i2c_request(i2c, FC_READ, msgs[i].addr, 194 ret = i2c->fc->i2c_request(i2c, FC_READ, msgs[i].addr,
197 msgs[i].buf[0], msgs[i+1].buf, msgs[i+1].len); 195 msgs[i].buf[0], msgs[i+1].buf,
196 msgs[i+1].len);
198 i++; /* skip the following message */ 197 i++; /* skip the following message */
199 } else /* writing */ 198 } else /* writing */
200 ret = i2c->fc->i2c_request(i2c, FC_WRITE, msgs[i].addr, 199 ret = i2c->fc->i2c_request(i2c, FC_WRITE, msgs[i].addr,
201 msgs[i].buf[0], &msgs[i].buf[1], 200 msgs[i].buf[0], &msgs[i].buf[1],
202 msgs[i].len - 1); 201 msgs[i].len - 1);
203 if (ret < 0) { 202 if (ret < 0) {
204 err("i2c master_xfer failed"); 203 err("i2c master_xfer failed");
205 break; 204 break;
@@ -226,23 +225,21 @@ static struct i2c_algorithm flexcop_algo = {
226int flexcop_i2c_init(struct flexcop_device *fc) 225int flexcop_i2c_init(struct flexcop_device *fc)
227{ 226{
228 int ret; 227 int ret;
229
230 mutex_init(&fc->i2c_mutex); 228 mutex_init(&fc->i2c_mutex);
231 229
232 fc->fc_i2c_adap[0].fc = fc; 230 fc->fc_i2c_adap[0].fc = fc;
233 fc->fc_i2c_adap[1].fc = fc; 231 fc->fc_i2c_adap[1].fc = fc;
234 fc->fc_i2c_adap[2].fc = fc; 232 fc->fc_i2c_adap[2].fc = fc;
235
236 fc->fc_i2c_adap[0].port = FC_I2C_PORT_DEMOD; 233 fc->fc_i2c_adap[0].port = FC_I2C_PORT_DEMOD;
237 fc->fc_i2c_adap[1].port = FC_I2C_PORT_EEPROM; 234 fc->fc_i2c_adap[1].port = FC_I2C_PORT_EEPROM;
238 fc->fc_i2c_adap[2].port = FC_I2C_PORT_TUNER; 235 fc->fc_i2c_adap[2].port = FC_I2C_PORT_TUNER;
239 236
240 strlcpy(fc->fc_i2c_adap[0].i2c_adap.name, "B2C2 FlexCop I2C to demod", 237 strlcpy(fc->fc_i2c_adap[0].i2c_adap.name, "B2C2 FlexCop I2C to demod",
241 sizeof(fc->fc_i2c_adap[0].i2c_adap.name)); 238 sizeof(fc->fc_i2c_adap[0].i2c_adap.name));
242 strlcpy(fc->fc_i2c_adap[1].i2c_adap.name, "B2C2 FlexCop I2C to eeprom", 239 strlcpy(fc->fc_i2c_adap[1].i2c_adap.name, "B2C2 FlexCop I2C to eeprom",
243 sizeof(fc->fc_i2c_adap[1].i2c_adap.name)); 240 sizeof(fc->fc_i2c_adap[1].i2c_adap.name));
244 strlcpy(fc->fc_i2c_adap[2].i2c_adap.name, "B2C2 FlexCop I2C to tuner", 241 strlcpy(fc->fc_i2c_adap[2].i2c_adap.name, "B2C2 FlexCop I2C to tuner",
245 sizeof(fc->fc_i2c_adap[2].i2c_adap.name)); 242 sizeof(fc->fc_i2c_adap[2].i2c_adap.name));
246 243
247 i2c_set_adapdata(&fc->fc_i2c_adap[0].i2c_adap, &fc->fc_i2c_adap[0]); 244 i2c_set_adapdata(&fc->fc_i2c_adap[0].i2c_adap, &fc->fc_i2c_adap[0]);
248 i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]); 245 i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]);
@@ -280,7 +277,6 @@ adap_2_failed:
280 i2c_del_adapter(&fc->fc_i2c_adap[1].i2c_adap); 277 i2c_del_adapter(&fc->fc_i2c_adap[1].i2c_adap);
281adap_1_failed: 278adap_1_failed:
282 i2c_del_adapter(&fc->fc_i2c_adap[0].i2c_adap); 279 i2c_del_adapter(&fc->fc_i2c_adap[0].i2c_adap);
283
284 return ret; 280 return ret;
285} 281}
286 282
@@ -291,6 +287,5 @@ void flexcop_i2c_exit(struct flexcop_device *fc)
291 i2c_del_adapter(&fc->fc_i2c_adap[1].i2c_adap); 287 i2c_del_adapter(&fc->fc_i2c_adap[1].i2c_adap);
292 i2c_del_adapter(&fc->fc_i2c_adap[0].i2c_adap); 288 i2c_del_adapter(&fc->fc_i2c_adap[0].i2c_adap);
293 } 289 }
294
295 fc->init_state &= ~FC_STATE_I2C_INIT; 290 fc->init_state &= ~FC_STATE_I2C_INIT;
296} 291}
diff --git a/drivers/media/dvb/b2c2/flexcop-misc.c b/drivers/media/dvb/b2c2/flexcop-misc.c
index 93d20e56f90..e56627d2f0f 100644
--- a/drivers/media/dvb/b2c2/flexcop-misc.c
+++ b/drivers/media/dvb/b2c2/flexcop-misc.c
@@ -1,9 +1,7 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * 3 * flexcop-misc.c - miscellaneous functions
4 * flexcop-misc.c - miscellaneous functions. 4 * see flexcop.c for copyright information
5 *
6 * see flexcop.c for copyright information.
7 */ 5 */
8#include "flexcop.h" 6#include "flexcop.h"
9 7
@@ -12,39 +10,43 @@ void flexcop_determine_revision(struct flexcop_device *fc)
12 flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204); 10 flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204);
13 11
14 switch (v.misc_204.Rev_N_sig_revision_hi) { 12 switch (v.misc_204.Rev_N_sig_revision_hi) {
15 case 0x2: 13 case 0x2:
16 deb_info("found a FlexCopII.\n"); 14 deb_info("found a FlexCopII.\n");
17 fc->rev = FLEXCOP_II; 15 fc->rev = FLEXCOP_II;
18 break; 16 break;
19 case 0x3: 17 case 0x3:
20 deb_info("found a FlexCopIIb.\n"); 18 deb_info("found a FlexCopIIb.\n");
21 fc->rev = FLEXCOP_IIB; 19 fc->rev = FLEXCOP_IIB;
22 break; 20 break;
23 case 0x0: 21 case 0x0:
24 deb_info("found a FlexCopIII.\n"); 22 deb_info("found a FlexCopIII.\n");
25 fc->rev = FLEXCOP_III; 23 fc->rev = FLEXCOP_III;
26 break; 24 break;
27 default: 25 default:
28 err("unkown FlexCop Revision: %x. Please report the linux-dvb@linuxtv.org.",v.misc_204.Rev_N_sig_revision_hi); 26 err("unknown FlexCop Revision: %x. Please report this to "
29 break; 27 "linux-dvb@linuxtv.org.",
28 v.misc_204.Rev_N_sig_revision_hi);
29 break;
30 } 30 }
31 31
32 if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps)) 32 if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps))
33 deb_info("this FlexCop has the additional 32 hardware pid filter.\n"); 33 deb_info("this FlexCop has "
34 "the additional 32 hardware pid filter.\n");
34 else 35 else
35 deb_info("this FlexCop has only the 6 basic main hardware pid filter.\n"); 36 deb_info("this FlexCop has "
37 "the 6 basic main hardware pid filter.\n");
36 /* bus parts have to decide if hw pid filtering is used or not. */ 38 /* bus parts have to decide if hw pid filtering is used or not. */
37} 39}
38 40
39static const char *flexcop_revision_names[] = { 41static const char *flexcop_revision_names[] = {
40 "Unkown chip", 42 "Unknown chip",
41 "FlexCopII", 43 "FlexCopII",
42 "FlexCopIIb", 44 "FlexCopIIb",
43 "FlexCopIII", 45 "FlexCopIII",
44}; 46};
45 47
46static const char *flexcop_device_names[] = { 48static const char *flexcop_device_names[] = {
47 "Unkown device", 49 "Unknown device",
48 "Air2PC/AirStar 2 DVB-T", 50 "Air2PC/AirStar 2 DVB-T",
49 "Air2PC/AirStar 2 ATSC 1st generation", 51 "Air2PC/AirStar 2 ATSC 1st generation",
50 "Air2PC/AirStar 2 ATSC 2nd generation", 52 "Air2PC/AirStar 2 ATSC 2nd generation",
@@ -61,21 +63,23 @@ static const char *flexcop_bus_names[] = {
61 "PCI", 63 "PCI",
62}; 64};
63 65
64void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const 66void flexcop_device_name(struct flexcop_device *fc,
65 char *suffix) 67 const char *prefix, const char *suffix)
66{ 68{
67 info("%s '%s' at the '%s' bus controlled by a '%s' %s",prefix, 69 info("%s '%s' at the '%s' bus controlled by a '%s' %s",
68 flexcop_device_names[fc->dev_type],flexcop_bus_names[fc->bus_type], 70 prefix, flexcop_device_names[fc->dev_type],
69 flexcop_revision_names[fc->rev],suffix); 71 flexcop_bus_names[fc->bus_type],
72 flexcop_revision_names[fc->rev], suffix);
70} 73}
71 74
72void flexcop_dump_reg(struct flexcop_device *fc, flexcop_ibi_register reg, int num) 75void flexcop_dump_reg(struct flexcop_device *fc,
76 flexcop_ibi_register reg, int num)
73{ 77{
74 flexcop_ibi_value v; 78 flexcop_ibi_value v;
75 int i; 79 int i;
76 for (i = 0; i < num; i++) { 80 for (i = 0; i < num; i++) {
77 v = fc->read_ibi_reg(fc,reg+4*i); 81 v = fc->read_ibi_reg(fc, reg+4*i);
78 deb_rdump("0x%03x: %08x, ",reg+4*i, v.raw); 82 deb_rdump("0x%03x: %08x, ", reg+4*i, v.raw);
79 } 83 }
80 deb_rdump("\n"); 84 deb_rdump("\n");
81} 85}
diff --git a/drivers/media/dvb/b2c2/flexcop-reg.h b/drivers/media/dvb/b2c2/flexcop-reg.h
index 7599fccc1a5..dc4528dcbb9 100644
--- a/drivers/media/dvb/b2c2/flexcop-reg.h
+++ b/drivers/media/dvb/b2c2/flexcop-reg.h
@@ -1,14 +1,11 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 *
4 * flexcop-reg.h - register abstraction for FlexCopII, FlexCopIIb and FlexCopIII 3 * flexcop-reg.h - register abstraction for FlexCopII, FlexCopIIb and FlexCopIII
5 * 4 * see flexcop.c for copyright information
6 * see flexcop.c for copyright information.
7 */ 5 */
8#ifndef __FLEXCOP_REG_H__ 6#ifndef __FLEXCOP_REG_H__
9#define __FLEXCOP_REG_H__ 7#define __FLEXCOP_REG_H__
10 8
11
12typedef enum { 9typedef enum {
13 FLEXCOP_UNK = 0, 10 FLEXCOP_UNK = 0,
14 FLEXCOP_II, 11 FLEXCOP_II,
@@ -18,13 +15,13 @@ typedef enum {
18 15
19typedef enum { 16typedef enum {
20 FC_UNK = 0, 17 FC_UNK = 0,
21 FC_AIR_DVB, 18 FC_CABLE,
19 FC_AIR_DVBT,
22 FC_AIR_ATSC1, 20 FC_AIR_ATSC1,
23 FC_AIR_ATSC2, 21 FC_AIR_ATSC2,
24 FC_SKY,
25 FC_SKY_OLD,
26 FC_CABLE,
27 FC_AIR_ATSC3, 22 FC_AIR_ATSC3,
23 FC_SKY_REV23,
24 FC_SKY_REV26,
28 FC_SKY_REV27, 25 FC_SKY_REV27,
29 FC_SKY_REV28, 26 FC_SKY_REV28,
30} flexcop_device_type_t; 27} flexcop_device_type_t;
@@ -36,12 +33,12 @@ typedef enum {
36 33
37/* FlexCop IBI Registers */ 34/* FlexCop IBI Registers */
38#if defined(__LITTLE_ENDIAN) 35#if defined(__LITTLE_ENDIAN)
39 #include "flexcop_ibi_value_le.h" 36#include "flexcop_ibi_value_le.h"
40#else 37#else
41#if defined(__BIG_ENDIAN) 38#if defined(__BIG_ENDIAN)
42 #include "flexcop_ibi_value_be.h" 39#include "flexcop_ibi_value_be.h"
43#else 40#else
44 #error no endian defined 41#error no endian defined
45#endif 42#endif
46#endif 43#endif
47 44
diff --git a/drivers/media/dvb/b2c2/flexcop-sram.c b/drivers/media/dvb/b2c2/flexcop-sram.c
index cda69528548..f2199e43e80 100644
--- a/drivers/media/dvb/b2c2/flexcop-sram.c
+++ b/drivers/media/dvb/b2c2/flexcop-sram.c
@@ -1,45 +1,43 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * 3 * flexcop-sram.c - functions for controlling the SRAM
4 * flexcop-sram.c - functions for controlling the SRAM. 4 * see flexcop.c for copyright information
5 *
6 * see flexcop.c for copyright information.
7 */ 5 */
8#include "flexcop.h" 6#include "flexcop.h"
9 7
10static void flexcop_sram_set_chip (struct flexcop_device *fc, flexcop_sram_type_t type) 8static void flexcop_sram_set_chip(struct flexcop_device *fc,
9 flexcop_sram_type_t type)
11{ 10{
12 flexcop_set_ibi_value(wan_ctrl_reg_71c,sram_chip,type); 11 flexcop_set_ibi_value(wan_ctrl_reg_71c, sram_chip, type);
13} 12}
14 13
15int flexcop_sram_init(struct flexcop_device *fc) 14int flexcop_sram_init(struct flexcop_device *fc)
16{ 15{
17 switch (fc->rev) { 16 switch (fc->rev) {
18 case FLEXCOP_II: 17 case FLEXCOP_II:
19 case FLEXCOP_IIB: 18 case FLEXCOP_IIB:
20 flexcop_sram_set_chip(fc,FC_SRAM_1_32KB); 19 flexcop_sram_set_chip(fc, FC_SRAM_1_32KB);
21 break; 20 break;
22 case FLEXCOP_III: 21 case FLEXCOP_III:
23 flexcop_sram_set_chip(fc,FC_SRAM_1_48KB); 22 flexcop_sram_set_chip(fc, FC_SRAM_1_48KB);
24 break; 23 break;
25 default: 24 default:
26 return -EINVAL; 25 return -EINVAL;
27 } 26 }
28 return 0; 27 return 0;
29} 28}
30 29
31int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target) 30int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest,
31 flexcop_sram_dest_target_t target)
32{ 32{
33 flexcop_ibi_value v; 33 flexcop_ibi_value v;
34 34 v = fc->read_ibi_reg(fc, sram_dest_reg_714);
35 v = fc->read_ibi_reg(fc,sram_dest_reg_714);
36 35
37 if (fc->rev != FLEXCOP_III && target == FC_SRAM_DEST_TARGET_FC3_CA) { 36 if (fc->rev != FLEXCOP_III && target == FC_SRAM_DEST_TARGET_FC3_CA) {
38 err("SRAM destination target to available on FlexCopII(b)\n"); 37 err("SRAM destination target to available on FlexCopII(b)\n");
39 return -EINVAL; 38 return -EINVAL;
40 } 39 }
41 40 deb_sram("sram dest: %x target: %x\n", dest, target);
42 deb_sram("sram dest: %x target: %x\n",dest, target);
43 41
44 if (dest & FC_SRAM_DEST_NET) 42 if (dest & FC_SRAM_DEST_NET)
45 v.sram_dest_reg_714.NET_Dest = target; 43 v.sram_dest_reg_714.NET_Dest = target;
@@ -154,14 +152,12 @@ static void sram_write_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len
154 else 152 else
155 bank = 0x10000000; 153 bank = 0x10000000;
156 } 154 }
157
158 flex_sram_write(adapter, bank, addr & 0x7fff, buf, len); 155 flex_sram_write(adapter, bank, addr & 0x7fff, buf, len);
159} 156}
160 157
161static void sram_read_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len) 158static void sram_read_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
162{ 159{
163 u32 bank; 160 u32 bank;
164
165 bank = 0; 161 bank = 0;
166 162
167 if (adapter->dw_sram_type == 0x20000) { 163 if (adapter->dw_sram_type == 0x20000) {
@@ -174,26 +170,22 @@ static void sram_read_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
174 else 170 else
175 bank = 0x10000000; 171 bank = 0x10000000;
176 } 172 }
177
178 flex_sram_read(adapter, bank, addr & 0x7fff, buf, len); 173 flex_sram_read(adapter, bank, addr & 0x7fff, buf, len);
179} 174}
180 175
181static void sram_read(struct adapter *adapter, u32 addr, u8 *buf, u32 len) 176static void sram_read(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
182{ 177{
183 u32 length; 178 u32 length;
184
185 while (len != 0) { 179 while (len != 0) {
186 length = len; 180 length = len;
187 181 /* check if the address range belongs to the same
188 // check if the address range belongs to the same 182 * 32K memory chip. If not, the data is read
189 // 32K memory chip. If not, the data is read from 183 * from one chip at a time */
190 // one chip at a time.
191 if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) { 184 if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
192 length = (((addr >> 0x0f) + 1) << 0x0f) - addr; 185 length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
193 } 186 }
194 187
195 sram_read_chunk(adapter, addr, buf, length); 188 sram_read_chunk(adapter, addr, buf, length);
196
197 addr = addr + length; 189 addr = addr + length;
198 buf = buf + length; 190 buf = buf + length;
199 len = len - length; 191 len = len - length;
@@ -203,19 +195,17 @@ static void sram_read(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
203static void sram_write(struct adapter *adapter, u32 addr, u8 *buf, u32 len) 195static void sram_write(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
204{ 196{
205 u32 length; 197 u32 length;
206
207 while (len != 0) { 198 while (len != 0) {
208 length = len; 199 length = len;
209 200
210 // check if the address range belongs to the same 201 /* check if the address range belongs to the same
211 // 32K memory chip. If not, the data is written to 202 * 32K memory chip. If not, the data is
212 // one chip at a time. 203 * written to one chip at a time */
213 if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) { 204 if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
214 length = (((addr >> 0x0f) + 1) << 0x0f) - addr; 205 length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
215 } 206 }
216 207
217 sram_write_chunk(adapter, addr, buf, length); 208 sram_write_chunk(adapter, addr, buf, length);
218
219 addr = addr + length; 209 addr = addr + length;
220 buf = buf + length; 210 buf = buf + length;
221 len = len - length; 211 len = len - length;
@@ -224,39 +214,29 @@ static void sram_write(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
224 214
225static void sram_set_size(struct adapter *adapter, u32 mask) 215static void sram_set_size(struct adapter *adapter, u32 mask)
226{ 216{
227 write_reg_dw(adapter, 0x71c, (mask | (~0x30000 & read_reg_dw(adapter, 0x71c)))); 217 write_reg_dw(adapter, 0x71c,
218 (mask | (~0x30000 & read_reg_dw(adapter, 0x71c))));
228} 219}
229 220
230static void sram_init(struct adapter *adapter) 221static void sram_init(struct adapter *adapter)
231{ 222{
232 u32 tmp; 223 u32 tmp;
233
234 tmp = read_reg_dw(adapter, 0x71c); 224 tmp = read_reg_dw(adapter, 0x71c);
235
236 write_reg_dw(adapter, 0x71c, 1); 225 write_reg_dw(adapter, 0x71c, 1);
237 226
238 if (read_reg_dw(adapter, 0x71c) != 0) { 227 if (read_reg_dw(adapter, 0x71c) != 0) {
239 write_reg_dw(adapter, 0x71c, tmp); 228 write_reg_dw(adapter, 0x71c, tmp);
240
241 adapter->dw_sram_type = tmp & 0x30000; 229 adapter->dw_sram_type = tmp & 0x30000;
242
243 ddprintk("%s: dw_sram_type = %x\n", __func__, adapter->dw_sram_type); 230 ddprintk("%s: dw_sram_type = %x\n", __func__, adapter->dw_sram_type);
244
245 } else { 231 } else {
246
247 adapter->dw_sram_type = 0x10000; 232 adapter->dw_sram_type = 0x10000;
248
249 ddprintk("%s: dw_sram_type = %x\n", __func__, adapter->dw_sram_type); 233 ddprintk("%s: dw_sram_type = %x\n", __func__, adapter->dw_sram_type);
250 } 234 }
251
252 /* return value is never used? */
253/* return adapter->dw_sram_type; */
254} 235}
255 236
256static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr) 237static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr)
257{ 238{
258 u8 tmp1, tmp2; 239 u8 tmp1, tmp2;
259
260 dprintk("%s: mask = %x, addr = %x\n", __func__, mask, addr); 240 dprintk("%s: mask = %x, addr = %x\n", __func__, mask, addr);
261 241
262 sram_set_size(adapter, mask); 242 sram_set_size(adapter, mask);
@@ -269,7 +249,6 @@ static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr)
269 sram_write(adapter, addr + 4, &tmp1, 1); 249 sram_write(adapter, addr + 4, &tmp1, 1);
270 250
271 tmp2 = 0; 251 tmp2 = 0;
272
273 mdelay(20); 252 mdelay(20);
274 253
275 sram_read(adapter, addr, &tmp2, 1); 254 sram_read(adapter, addr, &tmp2, 1);
@@ -287,7 +266,6 @@ static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr)
287 sram_write(adapter, addr + 4, &tmp1, 1); 266 sram_write(adapter, addr + 4, &tmp1, 1);
288 267
289 tmp2 = 0; 268 tmp2 = 0;
290
291 mdelay(20); 269 mdelay(20);
292 270
293 sram_read(adapter, addr, &tmp2, 1); 271 sram_read(adapter, addr, &tmp2, 1);
@@ -297,26 +275,24 @@ static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr)
297 275
298 if (tmp2 != 0x5a) 276 if (tmp2 != 0x5a)
299 return 0; 277 return 0;
300
301 return 1; 278 return 1;
302} 279}
303 280
304static u32 sram_length(struct adapter *adapter) 281static u32 sram_length(struct adapter *adapter)
305{ 282{
306 if (adapter->dw_sram_type == 0x10000) 283 if (adapter->dw_sram_type == 0x10000)
307 return 32768; // 32K 284 return 32768; /* 32K */
308 if (adapter->dw_sram_type == 0x00000) 285 if (adapter->dw_sram_type == 0x00000)
309 return 65536; // 64K 286 return 65536; /* 64K */
310 if (adapter->dw_sram_type == 0x20000) 287 if (adapter->dw_sram_type == 0x20000)
311 return 131072; // 128K 288 return 131072; /* 128K */
312 289 return 32768; /* 32K */
313 return 32768; // 32K
314} 290}
315 291
316/* FlexcopII can work with 32K, 64K or 128K of external SRAM memory. 292/* FlexcopII can work with 32K, 64K or 128K of external SRAM memory.
317 - for 128K there are 4x32K chips at bank 0,1,2,3. 293 - for 128K there are 4x32K chips at bank 0,1,2,3.
318 - for 64K there are 2x32K chips at bank 1,2. 294 - for 64K there are 2x32K chips at bank 1,2.
319 - for 32K there is one 32K chip at bank 0. 295 - for 32K there is one 32K chip at bank 0.
320 296
321 FlexCop works only with one bank at a time. The bank is selected 297 FlexCop works only with one bank at a time. The bank is selected
322 by bits 28-29 of the 0x700 register. 298 by bits 28-29 of the 0x700 register.
@@ -324,24 +300,18 @@ static u32 sram_length(struct adapter *adapter)
324 bank 0 covers addresses 0x00000-0x07fff 300 bank 0 covers addresses 0x00000-0x07fff
325 bank 1 covers addresses 0x08000-0x0ffff 301 bank 1 covers addresses 0x08000-0x0ffff
326 bank 2 covers addresses 0x10000-0x17fff 302 bank 2 covers addresses 0x10000-0x17fff
327 bank 3 covers addresses 0x18000-0x1ffff 303 bank 3 covers addresses 0x18000-0x1ffff */
328*/
329 304
330static int flexcop_sram_detect(struct flexcop_device *fc) 305static int flexcop_sram_detect(struct flexcop_device *fc)
331{ 306{
332 flexcop_ibi_value r208,r71c_0,vr71c_1; 307 flexcop_ibi_value r208, r71c_0, vr71c_1;
333
334 r208 = fc->read_ibi_reg(fc, ctrl_208); 308 r208 = fc->read_ibi_reg(fc, ctrl_208);
335 fc->write_ibi_reg(fc, ctrl_208, ibi_zero); 309 fc->write_ibi_reg(fc, ctrl_208, ibi_zero);
336 310
337 r71c_0 = fc->read_ibi_reg(fc, wan_ctrl_reg_71c); 311 r71c_0 = fc->read_ibi_reg(fc, wan_ctrl_reg_71c);
338
339 write_reg_dw(adapter, 0x71c, 1); 312 write_reg_dw(adapter, 0x71c, 1);
340
341 tmp3 = read_reg_dw(adapter, 0x71c); 313 tmp3 = read_reg_dw(adapter, 0x71c);
342
343 dprintk("%s: tmp3 = %x\n", __func__, tmp3); 314 dprintk("%s: tmp3 = %x\n", __func__, tmp3);
344
345 write_reg_dw(adapter, 0x71c, tmp2); 315 write_reg_dw(adapter, 0x71c, tmp2);
346 316
347 // check for internal SRAM ??? 317 // check for internal SRAM ???
@@ -350,9 +320,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc)
350 sram_set_size(adapter, 0x10000); 320 sram_set_size(adapter, 0x10000);
351 sram_init(adapter); 321 sram_init(adapter);
352 write_reg_dw(adapter, 0x208, tmp); 322 write_reg_dw(adapter, 0x208, tmp);
353
354 dprintk("%s: sram size = 32K\n", __func__); 323 dprintk("%s: sram size = 32K\n", __func__);
355
356 return 32; 324 return 32;
357 } 325 }
358 326
@@ -360,9 +328,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc)
360 sram_set_size(adapter, 0x20000); 328 sram_set_size(adapter, 0x20000);
361 sram_init(adapter); 329 sram_init(adapter);
362 write_reg_dw(adapter, 0x208, tmp); 330 write_reg_dw(adapter, 0x208, tmp);
363
364 dprintk("%s: sram size = 128K\n", __func__); 331 dprintk("%s: sram size = 128K\n", __func__);
365
366 return 128; 332 return 128;
367 } 333 }
368 334
@@ -370,9 +336,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc)
370 sram_set_size(adapter, 0x00000); 336 sram_set_size(adapter, 0x00000);
371 sram_init(adapter); 337 sram_init(adapter);
372 write_reg_dw(adapter, 0x208, tmp); 338 write_reg_dw(adapter, 0x208, tmp);
373
374 dprintk("%s: sram size = 64K\n", __func__); 339 dprintk("%s: sram size = 64K\n", __func__);
375
376 return 64; 340 return 64;
377 } 341 }
378 342
@@ -380,18 +344,14 @@ static int flexcop_sram_detect(struct flexcop_device *fc)
380 sram_set_size(adapter, 0x10000); 344 sram_set_size(adapter, 0x10000);
381 sram_init(adapter); 345 sram_init(adapter);
382 write_reg_dw(adapter, 0x208, tmp); 346 write_reg_dw(adapter, 0x208, tmp);
383
384 dprintk("%s: sram size = 32K\n", __func__); 347 dprintk("%s: sram size = 32K\n", __func__);
385
386 return 32; 348 return 32;
387 } 349 }
388 350
389 sram_set_size(adapter, 0x10000); 351 sram_set_size(adapter, 0x10000);
390 sram_init(adapter); 352 sram_init(adapter);
391 write_reg_dw(adapter, 0x208, tmp); 353 write_reg_dw(adapter, 0x208, tmp);
392
393 dprintk("%s: SRAM detection failed. Set to 32K \n", __func__); 354 dprintk("%s: SRAM detection failed. Set to 32K \n", __func__);
394
395 return 0; 355 return 0;
396} 356}
397 357
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.h b/drivers/media/dvb/b2c2/flexcop-usb.h
index 630e647a2ca..92529a9c447 100644
--- a/drivers/media/dvb/b2c2/flexcop-usb.h
+++ b/drivers/media/dvb/b2c2/flexcop-usb.h
@@ -1,15 +1,20 @@
1/*
2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * flexcop-usb.h - header file for the USB part
4 * see flexcop.c for copyright information
5 */
1#ifndef __FLEXCOP_USB_H_INCLUDED__ 6#ifndef __FLEXCOP_USB_H_INCLUDED__
2#define __FLEXCOP_USB_H_INCLUDED__ 7#define __FLEXCOP_USB_H_INCLUDED__
3 8
4#include <linux/usb.h> 9#include <linux/usb.h>
5 10
6/* transfer parameters */ 11/* transfer parameters */
7#define B2C2_USB_FRAMES_PER_ISO 4 12#define B2C2_USB_FRAMES_PER_ISO 4
8#define B2C2_USB_NUM_ISO_URB 4 13#define B2C2_USB_NUM_ISO_URB 4
9 14
10#define B2C2_USB_CTRL_PIPE_IN usb_rcvctrlpipe(fc_usb->udev,0) 15#define B2C2_USB_CTRL_PIPE_IN usb_rcvctrlpipe(fc_usb->udev, 0)
11#define B2C2_USB_CTRL_PIPE_OUT usb_sndctrlpipe(fc_usb->udev,0) 16#define B2C2_USB_CTRL_PIPE_OUT usb_sndctrlpipe(fc_usb->udev, 0)
12#define B2C2_USB_DATA_PIPE usb_rcvisocpipe(fc_usb->udev,0x81) 17#define B2C2_USB_DATA_PIPE usb_rcvisocpipe(fc_usb->udev, 0x81)
13 18
14struct flexcop_usb { 19struct flexcop_usb {
15 struct usb_device *udev; 20 struct usb_device *udev;
@@ -18,8 +23,8 @@ struct flexcop_usb {
18 u8 *iso_buffer; 23 u8 *iso_buffer;
19 int buffer_size; 24 int buffer_size;
20 dma_addr_t dma_addr; 25 dma_addr_t dma_addr;
21 struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
22 26
27 struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
23 struct flexcop_device *fc_dev; 28 struct flexcop_device *fc_dev;
24 29
25 u8 tmp_buffer[1023+190]; 30 u8 tmp_buffer[1023+190];
@@ -30,14 +35,6 @@ struct flexcop_usb {
30/* request types TODO What is its use?*/ 35/* request types TODO What is its use?*/
31typedef enum { 36typedef enum {
32 37
33/* something is wrong with this part
34 RTYPE_READ_DW = (1 << 6),
35 RTYPE_WRITE_DW_1 = (3 << 6),
36 RTYPE_READ_V8_MEMORY = (6 << 6),
37 RTYPE_WRITE_V8_MEMORY = (7 << 6),
38 RTYPE_WRITE_V8_FLASH = (8 << 6),
39 RTYPE_GENERIC = (9 << 6),
40*/
41} flexcop_usb_request_type_t; 38} flexcop_usb_request_type_t;
42#endif 39#endif
43 40
@@ -47,7 +44,6 @@ typedef enum {
47 B2C2_USB_READ_V8_MEM = 0x05, 44 B2C2_USB_READ_V8_MEM = 0x05,
48 B2C2_USB_READ_REG = 0x08, 45 B2C2_USB_READ_REG = 0x08,
49 B2C2_USB_WRITE_REG = 0x0A, 46 B2C2_USB_WRITE_REG = 0x0A,
50/* B2C2_USB_WRITEREGLO = 0x0A, */
51 B2C2_USB_WRITEREGHI = 0x0B, 47 B2C2_USB_WRITEREGHI = 0x0B,
52 B2C2_USB_FLASH_BLOCK = 0x10, 48 B2C2_USB_FLASH_BLOCK = 0x10,
53 B2C2_USB_I2C_REQUEST = 0x11, 49 B2C2_USB_I2C_REQUEST = 0x11,
@@ -62,15 +58,13 @@ typedef enum {
62 USB_FUNC_I2C_REPEATWRITE = 0x04, 58 USB_FUNC_I2C_REPEATWRITE = 0x04,
63 USB_FUNC_GET_DESCRIPTOR = 0x05, 59 USB_FUNC_GET_DESCRIPTOR = 0x05,
64 USB_FUNC_I2C_REPEATREAD = 0x06, 60 USB_FUNC_I2C_REPEATREAD = 0x06,
65/* DKT 020208 - add this to support special case of DiSEqC */ 61 /* DKT 020208 - add this to support special case of DiSEqC */
66 USB_FUNC_I2C_CHECKWRITE = 0x07, 62 USB_FUNC_I2C_CHECKWRITE = 0x07,
67 USB_FUNC_I2C_CHECKRESULT = 0x08, 63 USB_FUNC_I2C_CHECKRESULT = 0x08,
68} flexcop_usb_i2c_function_t; 64} flexcop_usb_i2c_function_t;
69 65
70/* 66/* function definition for UTILITY request 0x12
71 * function definition for UTILITY request 0x12 67 * DKT 020304 - new utility function */
72 * DKT 020304 - new utility function
73 */
74typedef enum { 68typedef enum {
75 UTILITY_SET_FILTER = 0x01, 69 UTILITY_SET_FILTER = 0x01,
76 UTILITY_DATA_ENABLE = 0x02, 70 UTILITY_DATA_ENABLE = 0x02,
@@ -84,7 +78,7 @@ typedef enum {
84 UTILITY_DATA_RESET = 0x0A, 78 UTILITY_DATA_RESET = 0x0A,
85 UTILITY_GET_DATA_STATUS = 0x10, 79 UTILITY_GET_DATA_STATUS = 0x10,
86 UTILITY_GET_V8_REG = 0x11, 80 UTILITY_GET_V8_REG = 0x11,
87/* DKT 020326 - add function for v1.14 */ 81 /* DKT 020326 - add function for v1.14 */
88 UTILITY_SRAM_WRITE = 0x12, 82 UTILITY_SRAM_WRITE = 0x12,
89 UTILITY_SRAM_READ = 0x13, 83 UTILITY_SRAM_READ = 0x13,
90 UTILITY_SRAM_TESTFILL = 0x14, 84 UTILITY_SRAM_TESTFILL = 0x14,
@@ -92,13 +86,13 @@ typedef enum {
92 UTILITY_SRAM_TESTVERIFY = 0x16, 86 UTILITY_SRAM_TESTVERIFY = 0x16,
93} flexcop_usb_utility_function_t; 87} flexcop_usb_utility_function_t;
94 88
95#define B2C2_WAIT_FOR_OPERATION_RW 1*HZ /* 1 s */ 89#define B2C2_WAIT_FOR_OPERATION_RW (1*HZ)
96#define B2C2_WAIT_FOR_OPERATION_RDW 3*HZ /* 3 s */ 90#define B2C2_WAIT_FOR_OPERATION_RDW (3*HZ)
97#define B2C2_WAIT_FOR_OPERATION_WDW 1*HZ /* 1 s */ 91#define B2C2_WAIT_FOR_OPERATION_WDW (1*HZ)
98 92
99#define B2C2_WAIT_FOR_OPERATION_V8READ 3*HZ /* 3 s */ 93#define B2C2_WAIT_FOR_OPERATION_V8READ (3*HZ)
100#define B2C2_WAIT_FOR_OPERATION_V8WRITE 3*HZ /* 3 s */ 94#define B2C2_WAIT_FOR_OPERATION_V8WRITE (3*HZ)
101#define B2C2_WAIT_FOR_OPERATION_V8FLASH 3*HZ /* 3 s */ 95#define B2C2_WAIT_FOR_OPERATION_V8FLASH (3*HZ)
102 96
103typedef enum { 97typedef enum {
104 V8_MEMORY_PAGE_DVB_CI = 0x20, 98 V8_MEMORY_PAGE_DVB_CI = 0x20,
@@ -107,13 +101,11 @@ typedef enum {
107 V8_MEMORY_PAGE_FLASH = 0x80 101 V8_MEMORY_PAGE_FLASH = 0x80
108} flexcop_usb_mem_page_t; 102} flexcop_usb_mem_page_t;
109 103
110#define V8_MEMORY_EXTENDED (1 << 15) 104#define V8_MEMORY_EXTENDED (1 << 15)
111 105#define USB_MEM_READ_MAX 32
112#define USB_MEM_READ_MAX 32 106#define USB_MEM_WRITE_MAX 1
113#define USB_MEM_WRITE_MAX 1 107#define USB_FLASH_MAX 8
114#define USB_FLASH_MAX 8 108#define V8_MEMORY_PAGE_SIZE 0x8000 /* 32K */
115 109#define V8_MEMORY_PAGE_MASK 0x7FFF
116#define V8_MEMORY_PAGE_SIZE 0x8000 // 32K
117#define V8_MEMORY_PAGE_MASK 0x7FFF
118 110
119#endif 111#endif
diff --git a/drivers/media/dvb/b2c2/flexcop.c b/drivers/media/dvb/b2c2/flexcop.c
index e836caecebb..2df1b0214dc 100644
--- a/drivers/media/dvb/b2c2/flexcop.c
+++ b/drivers/media/dvb/b2c2/flexcop.c
@@ -1,22 +1,20 @@
1/* 1/*
2 * flexcop.c - driver for digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * 3 * flexcop.c - main module part
4 * Copyright (C) 2004-5 Patrick Boettcher <patrick.boettcher@desy.de> 4 * Copyright (C) 2004-9 Patrick Boettcher <patrick.boettcher@desy.de>
5 * 5 * based on skystar2-driver Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
6 * based on the skystar2-driver
7 * Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
8 * 6 *
9 * Acknowledgements: 7 * Acknowledgements:
10 * John Jurrius from BBTI, Inc. for extensive support with 8 * John Jurrius from BBTI, Inc. for extensive support
11 * code examples and data books 9 * with code examples and data books
12 * 10 * Bjarne Steinsbo, bjarne at steinsbo.com (some ideas for rewriting)
13 * Bjarne Steinsbo, bjarne at steinsbo.com (some ideas for rewriting)
14 * 11 *
15 * Contributions to the skystar2-driver have been done by 12 * Contributions to the skystar2-driver have been done by
16 * Vincenzo Di Massa, hawk.it at tiscalinet.it (several DiSEqC fixes) 13 * Vincenzo Di Massa, hawk.it at tiscalinet.it (several DiSEqC fixes)
17 * Roberto Ragusa, r.ragusa at libero.it (polishing, restyling the code) 14 * Roberto Ragusa, r.ragusa at libero.it (polishing, restyling the code)
18 * Niklas Peinecke, peinecke at gdv.uni-hannover.de (hardware pid/mac filtering) 15 * Uwe Bugla, uwe.bugla at gmx.de (doing tests, restyling code, writing docu)
19 * 16 * Niklas Peinecke, peinecke at gdv.uni-hannover.de (hardware pid/mac
17 * filtering)
20 * 18 *
21 * This program is free software; you can redistribute it and/or 19 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU Lesser General Public License 20 * modify it under the terms of the GNU Lesser General Public License
@@ -46,7 +44,10 @@
46 44
47int b2c2_flexcop_debug; 45int b2c2_flexcop_debug;
48module_param_named(debug, b2c2_flexcop_debug, int, 0644); 46module_param_named(debug, b2c2_flexcop_debug, int, 0644);
49MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg (|-able))." DEBSTATUS); 47MODULE_PARM_DESC(debug,
48 "set debug level (1=info,2=tuner,4=i2c,8=ts,"
49 "16=sram,32=reg (|-able))."
50 DEBSTATUS);
50#undef DEBSTATUS 51#undef DEBSTATUS
51 52
52DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 53DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
@@ -57,37 +58,36 @@ flexcop_ibi_value ibi_zero;
57static int flexcop_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed) 58static int flexcop_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
58{ 59{
59 struct flexcop_device *fc = dvbdmxfeed->demux->priv; 60 struct flexcop_device *fc = dvbdmxfeed->demux->priv;
60 return flexcop_pid_feed_control(fc,dvbdmxfeed,1); 61 return flexcop_pid_feed_control(fc, dvbdmxfeed, 1);
61} 62}
62 63
63static int flexcop_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) 64static int flexcop_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
64{ 65{
65 struct flexcop_device *fc = dvbdmxfeed->demux->priv; 66 struct flexcop_device *fc = dvbdmxfeed->demux->priv;
66 return flexcop_pid_feed_control(fc,dvbdmxfeed,0); 67 return flexcop_pid_feed_control(fc, dvbdmxfeed, 0);
67} 68}
68 69
69static int flexcop_dvb_init(struct flexcop_device *fc) 70static int flexcop_dvb_init(struct flexcop_device *fc)
70{ 71{
71 int ret = dvb_register_adapter(&fc->dvb_adapter, 72 int ret = dvb_register_adapter(&fc->dvb_adapter,
72 "FlexCop Digital TV device", fc->owner, 73 "FlexCop Digital TV device", fc->owner,
73 fc->dev, adapter_nr); 74 fc->dev, adapter_nr);
74 if (ret < 0) { 75 if (ret < 0) {
75 err("error registering DVB adapter"); 76 err("error registering DVB adapter");
76 return ret; 77 return ret;
77 } 78 }
78 fc->dvb_adapter.priv = fc; 79 fc->dvb_adapter.priv = fc;
79 80
80 fc->demux.dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING); 81 fc->demux.dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING
82 | DMX_MEMORY_BASED_FILTERING);
81 fc->demux.priv = fc; 83 fc->demux.priv = fc;
82
83 fc->demux.filternum = fc->demux.feednum = FC_MAX_FEED; 84 fc->demux.filternum = fc->demux.feednum = FC_MAX_FEED;
84
85 fc->demux.start_feed = flexcop_dvb_start_feed; 85 fc->demux.start_feed = flexcop_dvb_start_feed;
86 fc->demux.stop_feed = flexcop_dvb_stop_feed; 86 fc->demux.stop_feed = flexcop_dvb_stop_feed;
87 fc->demux.write_to_decoder = NULL; 87 fc->demux.write_to_decoder = NULL;
88 88
89 if ((ret = dvb_dmx_init(&fc->demux)) < 0) { 89 if ((ret = dvb_dmx_init(&fc->demux)) < 0) {
90 err("dvb_dmx failed: error %d",ret); 90 err("dvb_dmx failed: error %d", ret);
91 goto err_dmx; 91 goto err_dmx;
92 } 92 }
93 93
@@ -97,23 +97,23 @@ static int flexcop_dvb_init(struct flexcop_device *fc)
97 fc->dmxdev.demux = &fc->demux.dmx; 97 fc->dmxdev.demux = &fc->demux.dmx;
98 fc->dmxdev.capabilities = 0; 98 fc->dmxdev.capabilities = 0;
99 if ((ret = dvb_dmxdev_init(&fc->dmxdev, &fc->dvb_adapter)) < 0) { 99 if ((ret = dvb_dmxdev_init(&fc->dmxdev, &fc->dvb_adapter)) < 0) {
100 err("dvb_dmxdev_init failed: error %d",ret); 100 err("dvb_dmxdev_init failed: error %d", ret);
101 goto err_dmx_dev; 101 goto err_dmx_dev;
102 } 102 }
103 103
104 if ((ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->hw_frontend)) < 0) { 104 if ((ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->hw_frontend)) < 0) {
105 err("adding hw_frontend to dmx failed: error %d",ret); 105 err("adding hw_frontend to dmx failed: error %d", ret);
106 goto err_dmx_add_hw_frontend; 106 goto err_dmx_add_hw_frontend;
107 } 107 }
108 108
109 fc->mem_frontend.source = DMX_MEMORY_FE; 109 fc->mem_frontend.source = DMX_MEMORY_FE;
110 if ((ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->mem_frontend)) < 0) { 110 if ((ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->mem_frontend)) < 0) {
111 err("adding mem_frontend to dmx failed: error %d",ret); 111 err("adding mem_frontend to dmx failed: error %d", ret);
112 goto err_dmx_add_mem_frontend; 112 goto err_dmx_add_mem_frontend;
113 } 113 }
114 114
115 if ((ret = fc->demux.dmx.connect_frontend(&fc->demux.dmx, &fc->hw_frontend)) < 0) { 115 if ((ret = fc->demux.dmx.connect_frontend(&fc->demux.dmx, &fc->hw_frontend)) < 0) {
116 err("connect frontend failed: error %d",ret); 116 err("connect frontend failed: error %d", ret);
117 goto err_connect_frontend; 117 goto err_connect_frontend;
118 } 118 }
119 119
@@ -123,9 +123,9 @@ static int flexcop_dvb_init(struct flexcop_device *fc)
123 return 0; 123 return 0;
124 124
125err_connect_frontend: 125err_connect_frontend:
126 fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->mem_frontend); 126 fc->demux.dmx.remove_frontend(&fc->demux.dmx, &fc->mem_frontend);
127err_dmx_add_mem_frontend: 127err_dmx_add_mem_frontend:
128 fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->hw_frontend); 128 fc->demux.dmx.remove_frontend(&fc->demux.dmx, &fc->hw_frontend);
129err_dmx_add_hw_frontend: 129err_dmx_add_hw_frontend:
130 dvb_dmxdev_release(&fc->dmxdev); 130 dvb_dmxdev_release(&fc->dmxdev);
131err_dmx_dev: 131err_dmx_dev:
@@ -141,12 +141,13 @@ static void flexcop_dvb_exit(struct flexcop_device *fc)
141 dvb_net_release(&fc->dvbnet); 141 dvb_net_release(&fc->dvbnet);
142 142
143 fc->demux.dmx.close(&fc->demux.dmx); 143 fc->demux.dmx.close(&fc->demux.dmx);
144 fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->mem_frontend); 144 fc->demux.dmx.remove_frontend(&fc->demux.dmx,
145 fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->hw_frontend); 145 &fc->mem_frontend);
146 fc->demux.dmx.remove_frontend(&fc->demux.dmx,
147 &fc->hw_frontend);
146 dvb_dmxdev_release(&fc->dmxdev); 148 dvb_dmxdev_release(&fc->dmxdev);
147 dvb_dmx_release(&fc->demux); 149 dvb_dmx_release(&fc->demux);
148 dvb_unregister_adapter(&fc->dvb_adapter); 150 dvb_unregister_adapter(&fc->dvb_adapter);
149
150 deb_info("deinitialized dvb stuff\n"); 151 deb_info("deinitialized dvb stuff\n");
151 } 152 }
152 fc->init_state &= ~FC_STATE_DVB_INIT; 153 fc->init_state &= ~FC_STATE_DVB_INIT;
@@ -168,9 +169,9 @@ EXPORT_SYMBOL(flexcop_pass_dmx_packets);
168 169
169static void flexcop_reset(struct flexcop_device *fc) 170static void flexcop_reset(struct flexcop_device *fc)
170{ 171{
171 flexcop_ibi_value v210,v204; 172 flexcop_ibi_value v210, v204;
172 173
173/* reset the flexcop itself */ 174 /* reset the flexcop itself */
174 fc->write_ibi_reg(fc,ctrl_208,ibi_zero); 175 fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
175 176
176 v210.raw = 0; 177 v210.raw = 0;
@@ -183,13 +184,11 @@ static void flexcop_reset(struct flexcop_device *fc)
183 v210.sw_reset_210.reset_block_600 = 1; 184 v210.sw_reset_210.reset_block_600 = 1;
184 v210.sw_reset_210.reset_block_700 = 1; 185 v210.sw_reset_210.reset_block_700 = 1;
185 v210.sw_reset_210.Block_reset_enable = 0xb2; 186 v210.sw_reset_210.Block_reset_enable = 0xb2;
186
187 v210.sw_reset_210.Special_controls = 0xc259; 187 v210.sw_reset_210.Special_controls = 0xc259;
188
189 fc->write_ibi_reg(fc,sw_reset_210,v210); 188 fc->write_ibi_reg(fc,sw_reset_210,v210);
190 msleep(1); 189 msleep(1);
191 190
192/* reset the periphical devices */ 191 /* reset the periphical devices */
193 192
194 v204 = fc->read_ibi_reg(fc,misc_204); 193 v204 = fc->read_ibi_reg(fc,misc_204);
195 v204.misc_204.Per_reset_sig = 0; 194 v204.misc_204.Per_reset_sig = 0;
@@ -201,11 +200,10 @@ static void flexcop_reset(struct flexcop_device *fc)
201 200
202void flexcop_reset_block_300(struct flexcop_device *fc) 201void flexcop_reset_block_300(struct flexcop_device *fc)
203{ 202{
204 flexcop_ibi_value v208_save = fc->read_ibi_reg(fc,ctrl_208), 203 flexcop_ibi_value v208_save = fc->read_ibi_reg(fc, ctrl_208),
205 v210 = fc->read_ibi_reg(fc,sw_reset_210); 204 v210 = fc->read_ibi_reg(fc, sw_reset_210);
206
207 deb_rdump("208: %08x, 210: %08x\n",v208_save.raw,v210.raw);
208 205
206 deb_rdump("208: %08x, 210: %08x\n", v208_save.raw, v210.raw);
209 fc->write_ibi_reg(fc,ctrl_208,ibi_zero); 207 fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
210 208
211 v210.sw_reset_210.reset_block_300 = 1; 209 v210.sw_reset_210.reset_block_300 = 1;
@@ -218,7 +216,8 @@ void flexcop_reset_block_300(struct flexcop_device *fc)
218struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len) 216struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
219{ 217{
220 void *bus; 218 void *bus;
221 struct flexcop_device *fc = kzalloc(sizeof(struct flexcop_device), GFP_KERNEL); 219 struct flexcop_device *fc = kzalloc(sizeof(struct flexcop_device),
220 GFP_KERNEL);
222 if (!fc) { 221 if (!fc) {
223 err("no memory"); 222 err("no memory");
224 return NULL; 223 return NULL;
@@ -253,7 +252,6 @@ int flexcop_device_initialize(struct flexcop_device *fc)
253 flexcop_determine_revision(fc); 252 flexcop_determine_revision(fc);
254 flexcop_sram_init(fc); 253 flexcop_sram_init(fc);
255 flexcop_hw_filter_init(fc); 254 flexcop_hw_filter_init(fc);
256
257 flexcop_smc_ctrl(fc, 0); 255 flexcop_smc_ctrl(fc, 0);
258 256
259 if ((ret = flexcop_dvb_init(fc))) 257 if ((ret = flexcop_dvb_init(fc)))
@@ -278,7 +276,6 @@ int flexcop_device_initialize(struct flexcop_device *fc)
278 goto error; 276 goto error;
279 277
280 flexcop_device_name(fc,"initialization of","complete"); 278 flexcop_device_name(fc,"initialization of","complete");
281
282 return 0; 279 return 0;
283 280
284error: 281error:
diff --git a/drivers/media/dvb/b2c2/flexcop.h b/drivers/media/dvb/b2c2/flexcop.h
index 0cebe1d92e0..897b10c85ad 100644
--- a/drivers/media/dvb/b2c2/flexcop.h
+++ b/drivers/media/dvb/b2c2/flexcop.h
@@ -1,9 +1,7 @@
1/* 1/*
2 * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
3 * 3 * flexcop.h - private header file for all flexcop-chip-source files
4 * flexcop.h - private header file for all flexcop-chip-source files. 4 * see flexcop.c for copyright information
5 *
6 * see flexcop.c for copyright information.
7 */ 5 */
8#ifndef __FLEXCOP_H__ 6#ifndef __FLEXCOP_H__
9#define __FLEXCOP_H___ 7#define __FLEXCOP_H___
@@ -21,11 +19,11 @@ extern int b2c2_flexcop_debug;
21#define dprintk(level,args...) 19#define dprintk(level,args...)
22#endif 20#endif
23 21
24#define deb_info(args...) dprintk(0x01,args) 22#define deb_info(args...) dprintk(0x01, args)
25#define deb_tuner(args...) dprintk(0x02,args) 23#define deb_tuner(args...) dprintk(0x02, args)
26#define deb_i2c(args...) dprintk(0x04,args) 24#define deb_i2c(args...) dprintk(0x04, args)
27#define deb_ts(args...) dprintk(0x08,args) 25#define deb_ts(args...) dprintk(0x08, args)
28#define deb_sram(args...) dprintk(0x10,args) 26#define deb_sram(args...) dprintk(0x10, args)
29#define deb_rdump(args...) dprintk(0x20,args) 27#define deb_rdump(args...) dprintk(0x20, args)
30 28
31#endif 29#endif
diff --git a/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h b/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
index ed9a6756b19..8f64bdbd72b 100644
--- a/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
+++ b/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
@@ -1,10 +1,7 @@
1/* This file is part of linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III 1/* Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
2 *
3 * register descriptions 2 * register descriptions
4 * 3 * see flexcop.c for copyright information
5 * see flexcop.c for copyright information.
6 */ 4 */
7
8/* This file is automatically generated, do not edit things here. */ 5/* This file is automatically generated, do not edit things here. */
9#ifndef __FLEXCOP_IBI_VALUE_INCLUDED__ 6#ifndef __FLEXCOP_IBI_VALUE_INCLUDED__
10#define __FLEXCOP_IBI_VALUE_INCLUDED__ 7#define __FLEXCOP_IBI_VALUE_INCLUDED__
diff --git a/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h b/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
index 49f2315b6e5..c75830d7d94 100644
--- a/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
+++ b/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
@@ -1,10 +1,7 @@
1/* This file is part of linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III 1/* Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
2 *
3 * register descriptions 2 * register descriptions
4 * 3 * see flexcop.c for copyright information
5 * see flexcop.c for copyright information.
6 */ 4 */
7
8/* This file is automatically generated, do not edit things here. */ 5/* This file is automatically generated, do not edit things here. */
9#ifndef __FLEXCOP_IBI_VALUE_INCLUDED__ 6#ifndef __FLEXCOP_IBI_VALUE_INCLUDED__
10#define __FLEXCOP_IBI_VALUE_INCLUDED__ 7#define __FLEXCOP_IBI_VALUE_INCLUDED__