All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Stezenbach <js@linuxtv.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, Vadim Catana <skystar@moldova.cc>,
	Patrick Boettcher <pb@linuxtv.org>
Subject: [DVB patch 03/11] flexcop: fix USB transfer handling
Date: Sat, 14 May 2005 00:00:22 +0200	[thread overview]
Message-ID: <20050513220225.247672000@abc> (raw)
In-Reply-To: 20050513220019.907667000@abc

[-- Attachment #1: dvb-flexcop-usb-fixes.patch --]
[-- Type: text/plain, Size: 4858 bytes --]

- driver receives many null TS packets (pid=0x1fff). They occupy the
  limited USB bandwidth and this leads to loss of video packets.
  Enabling the null packet filter fixes this.
- packets that flexcop sends to USB have a 2 byte header that has to
  be removed.
- sometimes a TS packet is split between different urbs. These parts have
  to be combined in a temporary buffer.

Signed-off-by: Vadim Catana <skystar@moldova.cc>
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Johannes Stezenbach <js@linuxtv.org>
---

 drivers/media/dvb/b2c2/flexcop-hw-filter.c |    9 +++--
 drivers/media/dvb/b2c2/flexcop-usb.c       |   47 ++++++++++++++++++++++++++++-
 drivers/media/dvb/b2c2/flexcop-usb.h       |    3 +
 3 files changed, 55 insertions(+), 4 deletions(-)

Index: linux-2.6.12-rc4/drivers/media/dvb/b2c2/flexcop-hw-filter.c
===================================================================
--- linux-2.6.12-rc4.orig/drivers/media/dvb/b2c2/flexcop-hw-filter.c	2005-05-12 01:30:04.000000000 +0200
+++ linux-2.6.12-rc4/drivers/media/dvb/b2c2/flexcop-hw-filter.c	2005-05-12 01:30:16.000000000 +0200
@@ -159,7 +159,7 @@ int flexcop_pid_feed_control(struct flex
 	} else if (fc->feedcount == onoff && !onoff) {
 		if (!fc->pid_filtering) {
 			deb_ts("disabling full TS transfer\n");
-			flexcop_pid_group_filter(fc, 0x1fe0,0);
+			flexcop_pid_group_filter(fc, 0, 0x1fe0);
 			flexcop_pid_group_filter_ctrl(fc,0);
 		}
 
@@ -175,7 +175,7 @@ int flexcop_pid_feed_control(struct flex
 		flexcop_pid_group_filter(fc, 0,0);
 		flexcop_pid_group_filter_ctrl(fc,1);
 	} else if (fc->pid_filtering && fc->feedcount <= max_pid_filter) {
-		flexcop_pid_group_filter(fc, 0x1fe0,0);
+		flexcop_pid_group_filter(fc, 0,0x1fe0);
 		flexcop_pid_group_filter_ctrl(fc,0);
 	}
 
@@ -189,10 +189,13 @@ void flexcop_hw_filter_init(struct flexc
 	for (i = 0; i < 6 + 32*fc->has_32_hw_pid_filter; i++)
 		flexcop_pid_control(fc,i,0x1fff,0);
 
-	flexcop_pid_group_filter(fc, 0x1fe0,0);
+	flexcop_pid_group_filter(fc, 0, 0x1fe0);
+	flexcop_pid_group_filter_ctrl(fc,0);
 
 	v = fc->read_ibi_reg(fc,pid_filter_308);
 	v.pid_filter_308.EMM_filter_4 = 1;
 	v.pid_filter_308.EMM_filter_6 = 0;
 	fc->write_ibi_reg(fc,pid_filter_308,v);
+
+	flexcop_null_filter_ctrl(fc, 1);
 }
Index: linux-2.6.12-rc4/drivers/media/dvb/b2c2/flexcop-usb.c
===================================================================
--- linux-2.6.12-rc4.orig/drivers/media/dvb/b2c2/flexcop-usb.c	2005-05-12 01:30:04.000000000 +0200
+++ linux-2.6.12-rc4/drivers/media/dvb/b2c2/flexcop-usb.c	2005-05-12 01:30:16.000000000 +0200
@@ -282,6 +282,51 @@ static int flexcop_usb_i2c_request(struc
 		return flexcop_usb_i2c_req(fc->bus_specific,B2C2_USB_I2C_REQUEST,USB_FUNC_I2C_WRITE,port,chipaddr,addr,buf,len);
 }
 
+static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb, u8 *buffer, int buffer_length)
+{
+	u8 *b;
+	int l;
+
+	deb_ts("tmp_buffer_length=%d, buffer_length=%d\n", fc_usb->tmp_buffer_length, buffer_length);
+
+	if (fc_usb->tmp_buffer_length > 0) {
+		memcpy(fc_usb->tmp_buffer+fc_usb->tmp_buffer_length, buffer, buffer_length);
+		fc_usb->tmp_buffer_length += buffer_length;
+		b = fc_usb->tmp_buffer;
+		l = fc_usb->tmp_buffer_length;
+	} else {
+		b=buffer;
+		l=buffer_length;
+	}
+
+	while (l >= 190) {
+		if (*b == 0xff)
+			switch (*(b+1) & 0x03) {
+				case 0x01: /* media packet */
+					if ( *(b+2) == 0x47 )
+						flexcop_pass_dmx_packets(fc_usb->fc_dev, b+2, 1);
+					else
+						deb_ts("not ts packet %02x %02x %02x %02x \n", *(b+2), *(b+3), *(b+4), *(b+5) );
+
+					b += 190;
+					l -= 190;
+				break;
+				default:
+					deb_ts("wrong packet type\n");
+					l = 0;
+				break;
+			}
+		else {
+			deb_ts("wrong header\n");
+			l = 0;
+		}
+	}
+
+	if (l>0)
+		memcpy(fc_usb->tmp_buffer, b, l);
+	fc_usb->tmp_buffer_length = l;
+}
+
 static void flexcop_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
 {
 	struct flexcop_usb *fc_usb = urb->context;
@@ -297,7 +342,7 @@ static void flexcop_usb_urb_complete(str
 			if (urb->iso_frame_desc[i].actual_length > 0) {
 				deb_ts("passed %d bytes to the demux\n",urb->iso_frame_desc[i].actual_length);
 
-				flexcop_pass_dmx_data(fc_usb->fc_dev,
+				flexcop_usb_process_frame(fc_usb,
 					urb->transfer_buffer + urb->iso_frame_desc[i].offset,
 					urb->iso_frame_desc[i].actual_length);
 		}
Index: linux-2.6.12-rc4/drivers/media/dvb/b2c2/flexcop-usb.h
===================================================================
--- linux-2.6.12-rc4.orig/drivers/media/dvb/b2c2/flexcop-usb.h	2005-05-12 01:30:04.000000000 +0200
+++ linux-2.6.12-rc4/drivers/media/dvb/b2c2/flexcop-usb.h	2005-05-12 01:30:16.000000000 +0200
@@ -21,6 +21,9 @@ struct flexcop_usb {
 	struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
 
 	struct flexcop_device *fc_dev;
+
+	u8 tmp_buffer[1023+190];
+	int tmp_buffer_length;
 };
 
 #if 0

--


  parent reply	other threads:[~2005-05-13 22:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-13 22:00 [DVB patch 00/11] B2C2 / FlexCop driver rewrite Johannes Stezenbach
2005-05-13 22:00 ` [DVB patch 01/11] b2c2/flexcop driver refactoring part 1: drop old b2c2-usb stuff Johannes Stezenbach
2005-05-13 22:00 ` Johannes Stezenbach [this message]
2005-05-13 22:00 ` [DVB patch 04/11] flexcop: add acknowledgements Johannes Stezenbach
2005-05-13 22:00 ` [DVB patch 05/11] flexcop: fix MAC address reading Johannes Stezenbach
2005-05-13 22:00 ` [DVB patch 06/11] flexcop: fixed interrupt-sharing Johannes Stezenbach
2005-05-13 22:00 ` [DVB patch 07/11] flexcop: use hw pid filter Johannes Stezenbach
2005-05-13 22:00 ` [DVB patch 08/11] flexcop: fix module refcount handling Johannes Stezenbach
2005-05-13 22:00 ` [DVB patch 09/11] flexcop: readme update Johannes Stezenbach
2005-05-13 22:00 ` [DVB patch 10/11] flexcop: i2c read fixes Johannes Stezenbach
2005-05-13 22:00 ` [DVB patch 11/11] B2C2 / FlexCop driver rewrite Johannes Stezenbach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050513220225.247672000@abc \
    --to=js@linuxtv.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pb@linuxtv.org \
    --cc=skystar@moldova.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.