[linux-dvb] AirStar USB status (+patch)

samuli at tuomola.net samuli at tuomola.net
Fri Feb 25 18:56:14 CET 2005


(Was subscribed to digest at first so missing Message-id from this post
will probably make a new thread.)

On Fri, 25 Feb 2005 Patrick Boettcher wrote:
> On Fri, 25 Feb 2005 samuli at tuomola.net wrote:
> 
> > Hi, just wanted to know where the b2c2-usb driver development is going
> > nowadays? Made an impulse buy of the Technisat AirStar box (rev 2.1
> > with FlexCop III and TDTC9251DH01C (mt352)) a month ago and would now
> > like to use it in linux, so I'd be very intrested to see it supported.
> 
> Hi,
> 
> I currently rewrite the dma stuff and pci initialization of the 
> pci-bus-driver. As you can see in the README, the adapting of the
> existing 
> usb driver is the step afterwards.
> 
> I want to stick to this order, because there will some changes in the 
> flexcop-part, that will require changes in the usb-part as well.
> 
> Maybe this weekend I'll find the time to create a first working usb 
> driver.

That'd be awesome :). I would like to do something, but can't really
help with the pci driver not having the hardware and all, so getting
even a workable basis of the usb driver would be great.

> > I realize the b2c2-directory under dvb-kernel in cvs is temporary and
> 
> dvb-kernel/b2c2 is compatible with dvb-kernel/build-2.6
> 
> ie. make in build-2.6, make in b2c2, run ./in.sh in b2c2 is the way to
> go.

I see, yeah should probably use the drivers from cvs in case there's
changes versus the ones in distribution kernel.

> > So still quite useless, but at least it loads :).
> 
> Unfortunately your patch is non-unified, so hard to read for me. Can you 
> send me a 'cvs diff -u' privately. I then have a look, what I can use 
> from.
> 
> Thanks so far.

Oops didn't even notice, was running late from a lunch, new one
attached. Although I fear there's not much anything to use, actually
just wanted to see something happening here (guess it worked :).

> > Btw, would the specs referred to here
> > http://pvrguide.no-ip.com/bbs-old/viewtopic.php?t=16643 be available
> > from somewhere?
> 
> They are not public, sorry.

Oh well, the important thing is that at least someone who makes use of
them has them.

Later,
-samuli

-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/b2c2/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- Makefile	16 Feb 2005 20:40:15 -0000	1.7
+++ Makefile	25 Feb 2005 17:14:45 -0000
@@ -1,10 +1,10 @@
 b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o
-obj-$(CONFIG_B2C2_FLEXCOP) += b2c2-flexcop.o
+obj-$(CONFIG_DVB_B2C2_SKYSTAR) += b2c2-flexcop.o
 
 b2c2-flexcop-pci-objs = flexcop-pci.o
 obj-$(CONFIG_B2C2_FLEXCOP_PCI) += b2c2-flexcop-pci.o
 
-#b2c2-flexcop-usb-objs = flexcop-usb.o 
-#obj-$(CONFIG_B2C2_FLEXCOP_USB) += b2c2-flexcop-usb.o
+b2c2-flexcop-usb-objs = flexcop-usb.o 
+obj-$(CONFIG_DVB_B2C2_USB) += b2c2-flexcop-usb.o
 
 EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
Index: flexcop-common.h
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/b2c2/flexcop-common.h,v
retrieving revision 1.11
diff -u -r1.11 flexcop-common.h
--- flexcop-common.h	22 Feb 2005 22:17:52 -0000	1.11
+++ flexcop-common.h	25 Feb 2005 17:14:45 -0000
@@ -73,6 +73,7 @@
 
 int  flexcop_device_initialize(struct flexcop_device*);
 void flexcop_device_uninitialize(struct flexcop_device*);
+void flexcop_reset(struct flexcop_device *fc);
 
 /* the PCI uses this a i2c_request callback, whereas the usb part has its own
  * one. We have it in flexcop-i2c.c, because it is going via the actual
Index: flexcop-usb.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/b2c2/flexcop-usb.c,v
retrieving revision 1.4
diff -u -r1.4 flexcop-usb.c
--- flexcop-usb.c	22 Feb 2005 22:17:52 -0000	1.4
+++ flexcop-usb.c	25 Feb 2005 17:14:45 -0000
@@ -6,7 +6,7 @@
  * see flexcop.c for copyright information.
  */
 #include <linux/usb.h>
-#include "flexcop-common.h"
+#include "flexcop.h"
 
 static int debug;
 module_param(debug, int, 0644);
@@ -28,31 +28,6 @@
 #define B2C2_USB_CTRL_PIPE_OUT		usb_sndctrlpipe(b2c2->udev,0)
 #define B2C2_USB_DATA_PIPE			usb_rcvisocpipe(b2c2->udev,0x81)
 
-/* debug */
-#define dprintk(level,args...) \
-	    do { if ((debug & level)) { printk(args); } } while (0)
-#define debug_dump(b,l) if (debug) {\
-	int i; deb_xfer("%s: %d > ",__FUNCTION__,l); \
-	for (i = 0; i < l; i++) deb_xfer("%02x ", b[i]); \
-	deb_xfer("\n");\
-}
-
-#define deb_info(args...) dprintk(0x01,args)
-#define deb_ts(args...)   dprintk(0x02,args)
-#define deb_ctrl(args...) dprintk(0x04,args)
-#define deb_i2c(args...) dprintk(0x08,args)
-
-struct usb_b2c2_usb {
-	struct usb_device *udev;
-	struct usb_interface *uintf;
-
-	u8 *iso_buffer;
-	int buffer_size;
-	dma_addr_t iso_dma_handle;
-	struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
-};
-
-
 /*
  * USB
  * 10 90 34 12 78 56 04 00
@@ -147,6 +122,18 @@
 	UTILITY_SRAM_TESTVERIFY     = 0x16,
 } b2c2_usb_utility_function_t;
 
+struct usb_b2c2_usb {
+	struct usb_device *udev;
+	struct usb_interface *uintf;
+
+	u8 *iso_buffer;
+	int buffer_size;
+	dma_addr_t iso_dma_handle;
+	struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
+	/* just a hack to retain the flexcop_device i2c callback structure */
+	b2c2_usb_request_t i2c_req;
+};
+
 #define B2C2_WAIT_FOR_OPERATION_RW  1  /* 1 s */
 #define B2C2_WAIT_FOR_OPERATION_RDW 3  /* 3 s */
 #define B2C2_WAIT_FOR_OPERATION_WDW 1  /* 1 s */
@@ -167,6 +154,9 @@
 #define B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(usPCI) (u8) (((usPCI >> 2) & 0x07) + ((usPCI >> 4) & 0x70))
 #define B2C2_FLEX_INTERNALADDR_TO_PCIOFFSET(ucAddr) (u16) (((ucAddr & 0x07) << 2) + ((ucAddr & 0x70) << 4))
 
+/* common */
+int b2c2_flexcop_debug;
+
 /*
  * DKT 020228 
  * - forget about this VENDOR_BUFFER_SIZE, read and write register
@@ -176,7 +166,7 @@
  *   and force this to write only 4 bytes at a time.
  *   NOTE: this should work with all the firmware from 1.00 and newer
  */
-static int b2c2_usb_readwrite_dw(struct b2c2_device *card, u16 wRegOffsPCI, u32 *val, u8 read)
+static int b2c2_usb_readwrite_dw(struct flexcop_device *card, u16 wRegOffsPCI, u32 *val, u8 read)
 {
 	struct usb_b2c2_usb *b2c2 = card->bus_specific;
 	u8 request = read ? B2C2_USB_READ_REG : B2C2_USB_WRITE_REG;
@@ -194,7 +184,7 @@
 			B2C2_WAIT_FOR_OPERATION_RDW * HZ);
 
 	if (len != sizeof(u32)) {
-		b2c2_err("error while %s dword from %d (%d).",read ? "reading" : "writing",
+		deb_info("error while %s dword from %d (%d).",read ? "reading" : "writing",
 			wAddress,wRegOffsPCI);
 		return -EIO;
 	} 
@@ -277,17 +267,17 @@
 		 (dwAddress & V8_MEMORY_PAGE_MASK) )
 
 
-static int b2c2_usb_memory_raw_req(struct b2c2_device *b2c2,u8 req,u32 dwAddr,u8 *buf,u16 len)
+static int b2c2_usb_memory_raw_req(struct flexcop_device *b2c2,u8 req,u32 dwAddr,u8 *buf,u16 len)
 {
 	return b2c2_usb_v8_memory_req(b2c2->bus_specific,req,
 			(u8) (dwAddr >> 16), (u16) (dwAddr & 0xFFFF), 
 			len, buf);
 }
 
-static int b2c2_usb_memory_req(struct b2c2_device *b2c2,u8 req,u8 dwAddress,void *pvData, u32 len)
+static int b2c2_usb_memory_req(struct flexcop_device *b2c2,u8 req,u8 dwAddress,void *pvData, u32 len)
 {
 	int ret = 0;
-	u16 wMax;
+	u16 wMax = 0;
 	u32 dwExtEnable = dwAddress & V8_MEMORY_EXT_ENABLE;
 	u8 *data = (u8 *) pvData;
 	u32 dwFlatAddr = v8FlatAddr(dwAddress);
@@ -326,7 +316,7 @@
 #define b2c2_usb_memory_writeb(b2c2,dwAddress,bData) \
 	b2c2_usb_memory_req(b2c2,B2C2_USB_WRITE_V8_MEM,dwAddress,&bData,1)
 
-u8 b2c2_usb_memory_readb(struct b2c2_device *b2c2, u32 dwAddress)
+u8 b2c2_usb_memory_readb(struct flexcop_device *b2c2, u32 dwAddress)
 {
 	u8 b;
 	b2c2_usb_memory_req(b2c2,B2C2_USB_READ_V8_MEM,dwAddress,&b,1);
@@ -356,6 +346,10 @@
  *                                          }
  */
 
+#if 0
+/* How is this going to be done? flexcop-sram at least isn't very compatible
+ * with the current usb code.
+ */
 
 static int b2c2_usb_utility_req(struct usb_b2c2_usb *b2c2, int set,
 		b2c2_usb_utility_function_t func, u8 extra, u16 wIndex,
@@ -380,12 +374,18 @@
 			nWaitTime * HZ);
 	return len == buflen ? 0 : -EIO;
 }
+#endif
 
-/* usb i2c stuff */
+/* usb i2c stuff
 static int b2c2_usb_i2c_req(struct usb_b2c2_usb *b2c2,
 		b2c2_usb_request_t req, b2c2_usb_i2c_function_t func,
 		u8 port, u8 chipaddr, u8 addr, u8 buflen, u8 *buf)
+ */
+static int b2c2_usb_i2c_req(struct flexcop_device *fc,
+		flexcop_access_op_t func, flexcop_i2c_port_t port,
+		u8 chipaddr, u8 addr, u8 *buf, u16 buflen)
 {
+	struct usb_b2c2_usb *b2c2 = fc->bus_specific;
 	u16 wValue, wIndex;
 	int nWaitTime,pipe,len;
 //	u8 dwRequestType;
@@ -416,8 +416,9 @@
 	wValue = (func << 8 ) | port;
 	wIndex = (chipaddr << 8 ) | addr;
 
-	len = usb_control_msg(b2c2->udev,pipe,
-			req,
+	len = usb_control_msg(b2c2->udev,
+			pipe,
+			b2c2->i2c_req,
 			request_type,
 			wValue,
 			wIndex,
@@ -428,20 +429,8 @@
 	return len == buflen ? 0 : -EREMOTEIO;
 }
 
-static u32 b2c2_usb_read_dw_old(struct b2c2_device *card, u16 wRegOffsPCI)
-{
-	err("do not use this functions. ");
-	return -EINVAL;
-}
-
-static int b2c2_usb_write_dw_old(struct b2c2_device *card, u16 wRegOffsPCI, u32 val)
-{
-	err("do not use this functions. ");
-	return -EINVAL;
-}
-
 /* actual bus specific access functions, make sure prototype are/will be equal to pci */
-static flexcop_ibi_value b2c2_usb_read_ibi_reg(struct b2c2_device *card, flexcop_ibi_register reg)
+static flexcop_ibi_value b2c2_usb_read_ibi_reg(struct flexcop_device *card, flexcop_ibi_register reg)
 {
 	flexcop_ibi_value val;
 	val.raw = 0;
@@ -449,51 +438,62 @@
 	return val;
 }
 
-static int b2c2_usb_write_ibi_reg(struct b2c2_device *card, flexcop_ibi_register reg, flexcop_ibi_value val)
+static int b2c2_usb_write_ibi_reg(struct flexcop_device *card, flexcop_ibi_register reg, flexcop_ibi_value val)
 {
 	return b2c2_usb_readwrite_dw(card,reg, &val.raw, 0);
 }
 
-static int b2c2_usb_i2c_read(struct b2c2_device *card, u8 port, u8 chipaddr, u8 addr, u8 *buf, u16 len)
+/* I guess these are no longer used?	 
+static int b2c2_usb_i2c_read(struct flexcop_device *card, u8 port, u8 chipaddr, u8 addr, u8 *buf, u16 len)
 {
 	return b2c2_usb_i2c_req(card->bus_specific,B2C2_USB_I2C_REQUEST,
 			USB_FUNC_I2C_READ, port, chipaddr, addr, len, buf) == 0 ? len : 0;
 }
 
-static int b2c2_usb_i2c_write(struct b2c2_device *card, u8 port, u8 chipaddr, u8 addr, u8 *buf, u16 len)
+static int b2c2_usb_i2c_write(struct flexcop_device *card, u8 port, u8 chipaddr, u8 addr, u8 *buf, u16 len)
 {
 	return b2c2_usb_i2c_req(card->bus_specific,B2C2_USB_I2C_REQUEST, 
 			USB_FUNC_I2C_WRITE, port, chipaddr, addr, len, buf) == 0 ? len : 0;
 }
-		
-static void b2c2_dumpfourreg(struct b2c2_device *card, u16 offs)
+*/
+
+static void b2c2_dumpfourreg(struct flexcop_device *card, u16 offs)
 {
 	flexcop_ibi_value r0,r1,r2,r3;
 	r0 = b2c2_usb_read_ibi_reg(card, offs);
 	r1 = b2c2_usb_read_ibi_reg(card, offs + 0x04);
 	r2 = b2c2_usb_read_ibi_reg(card, offs + 0x08);
 	r3 = b2c2_usb_read_ibi_reg(card, offs + 0x0c);
-	deb_ctrl("dump: offset: %03x, %08x, %08x, %08x, %08x\n",offs,r0.raw,r1.raw,r2.raw,r3.raw);
+	deb_info("dump: offset: %03x, %08x, %08x, %08x, %08x\n",offs,r0.raw,r1.raw,r2.raw,r3.raw);
 }
 
 static void b2c2_urb_complete(struct urb *urb, struct pt_regs *ptregs)
 {
-	struct usb_b2c2_usb *b2c2 = urb->context;
+//	struct usb_b2c2_usb *b2c2 = urb->context;
 	deb_ts("urb completed, bufsize: %d actlen; %d\n",urb->transfer_buffer_length, urb->actual_length);
 
 //	usb_submit_urb(urb,GFP_ATOMIC); // enable for real action
 }
 
-static void open_stream_usb(struct b2c2_device *card, u16 pid)
+static void open_stream_usb(struct flexcop_device *card)
 {
 	/* TODO */
 }
 
-static void close_stream_usb(struct b2c2_device *card, u16 pid)
+static void close_stream_usb(struct flexcop_device *card)
 {
 	/* TODO */
 }
 
+static int stream_control(struct flexcop_device *fc, int onoff)
+{
+	if (onoff)
+		open_stream_usb(fc);
+	else
+		close_stream_usb(fc);
+	return 0;
+}
+
 static void b2c2_exit_usb(struct usb_b2c2_usb *b2c2)
 {
 	int i;
@@ -555,7 +555,7 @@
 		}
 
 		if ((ret = usb_submit_urb(b2c2->iso_urb[i],GFP_ATOMIC))) {
-			b2c2_err("submitting urb %d failed with %d.",i,ret);
+			deb_info("submitting urb %d failed with %d.",i,ret);
 			goto urb_error;
 		}
 		deb_info("submitted urb no. %d.\n",i);
@@ -574,27 +574,27 @@
 {
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_b2c2_usb *b2c2 = NULL;
-	struct b2c2_device *card = NULL;
+	struct flexcop_device *card = NULL;
 	int ret;
 
 	switch (udev->speed) {
 		case USB_SPEED_LOW:
-			b2c2_err("cannot handle USB speed because it is to sLOW.");
+			deb_info("cannot handle USB speed because it is to sLOW.");
 			break;
 		case USB_SPEED_FULL:
-			b2c2_info("running at FULL speed.");
+			deb_info("running at FULL speed.");
 			break;
 		case USB_SPEED_HIGH:
-			b2c2_info("running at HIGH speed.");
+			deb_info("running at HIGH speed.");
 			break;
 		case USB_SPEED_UNKNOWN: /* fall through */
 		default:
-			b2c2_err("cannot handle USB speed because it is unkown.");
+			deb_info("cannot handle USB speed because it is unkown.");
 			ret = -EPROTO;
 			goto usb_init_error;
 	}
 
-	card = b2c2_device_kmalloc(sizeof(struct usb_b2c2_usb));
+	card = flexcop_device_kmalloc(sizeof(struct usb_b2c2_usb));
 	if (card == NULL) {
 		return -ENOMEM;
 	}
@@ -603,26 +603,27 @@
 
 	b2c2->udev = udev;
 	b2c2->uintf = intf;
-
+/*
 	card->read_dw_old   = b2c2_usb_read_dw_old;
 	card->write_dw_old  = b2c2_usb_write_dw_old;
-	
+*/
 	card->read_ibi_reg  = b2c2_usb_read_ibi_reg;
 	card->write_ibi_reg = b2c2_usb_write_ibi_reg;
 	
-	card->i2c_read  = b2c2_usb_i2c_read;
-	card->i2c_write = b2c2_usb_i2c_write;
-	card->open_stream = open_stream_usb;
-	card->close_stream = close_stream_usb;
+	card->i2c_request = b2c2_usb_i2c_req;
+	
+	card->stream_control = stream_control;
 
 	/* Copy some info data from device specific to device independant */
+	card->pid_filtering = enable_hw_filters;
+	/*
 	card->debug = debug;
-	card->enable_hw_filters = enable_hw_filters;
 	card->dev_vendor = udev->descriptor.idVendor;
 	card->dev_device = udev->descriptor.idProduct;
 	card->dev_subsystem_vendor = 0;
 	card->dev_subsystem_device = 0;
-
+	*/
+	
 	/* use the alternate setting with the larges buffer */
 	usb_set_interface(udev,0,1);
 
@@ -636,15 +637,15 @@
 	b2c2_dumpfourreg(card, 0x400);
 	b2c2_dumpfourreg(card, 0x700);
 
-	b2c2_flexcop_reset(card);
-	ret = b2c2_initialize(card);
+	flexcop_reset(card);
+	ret = flexcop_device_initialize(card);
 
 	if (ret != 0) {
-		b2c2_info("%s error while loading driver (%d)",DRIVER_DESC,ret);
+		deb_info("%s error while loading driver (%d)",DRIVER_DESC,ret);
 		goto usb_init_error;
 	}
 
-	b2c2_info("%s successfully initialized and connected.",DRIVER_DESC);
+	deb_info("%s successfully initialized and connected.",DRIVER_DESC);
 	ret = 0;
 	goto success;
 
@@ -657,15 +658,18 @@
 
 static void b2c2_usb_disconnect(struct usb_interface *intf)
 {
-	struct b2c2_device *card = usb_get_intfdata(intf);
+	struct flexcop_device *card = usb_get_intfdata(intf);
 	usb_set_intfdata(intf,NULL);
 	if (card != NULL) {
+		close_stream_usb(card);
+		/*
 		b2c2_uninitialize(card);
 		b2c2_exit_usb(card->bus_specific);
+		*/
 		kfree(card->bus_specific);
 		kfree(card);
 	}
-	b2c2_info("%s successfully deinitialized and disconnected.",DRIVER_DESC);
+	deb_info("%s successfully deinitialized and disconnected.",DRIVER_DESC);
 }
 
 static struct usb_device_id b2c2_usb_table [] = {
@@ -686,7 +690,7 @@
 {
 	int result;
 	if ((result = usb_register(&b2c2_usb_driver))) {
-		b2c2_err("usb_register failed. Error number %d",result);
+		deb_info("usb_register failed. Error number %d",result);
 		return result;
 	}
 
Index: flexcop.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/b2c2/flexcop.c,v
retrieving revision 1.8
diff -u -r1.8 flexcop.c
--- flexcop.c	22 Feb 2005 22:17:52 -0000	1.8
+++ flexcop.c	25 Feb 2005 17:14:45 -0000
@@ -155,7 +155,7 @@
 }
 EXPORT_SYMBOL(flexcop_pass_dmx_data);
 
-static void flexcop_reset(struct flexcop_device *fc)
+void flexcop_reset(struct flexcop_device *fc)
 {
 	flexcop_ibi_value v210,v208;
 	fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
@@ -169,6 +169,7 @@
 	v208.ctrl_208.Null_filter_sig = 1;
 	fc->write_ibi_reg(fc,ctrl_208,v208);
 }
+EXPORT_SYMBOL(flexcop_reset);
 
 struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
 {


More information about the linux-dvb mailing list