mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] zr36067 driver update
@ 2004-02-26 11:37 Ronald S. Bultje
  0 siblings, 0 replies; only message in thread
From: Ronald S. Bultje @ 2004-02-26 11:37 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

Hi Andrew,

Attached patch fixes the zoran driver (zr36067) for the fact that we did
not handle bitrate-conversion at all in the zr36050 MJPEG codec (on DC30
cards), with the result being that at high-resolution, we'd overload the
PCI bus and drop half of our video capture data into /dev/null'ishness.

Also, could you please change my email address in MAINTAINERS? The old
one is no longer valid (it bounces).

Patch (both together) attached.

Thanks,
Ronald

-- 
Ronald Bultje <rbultje@ronald.bitfreak.net>
Linux Video/Multimedia developer

[-- Attachment #2: zr36067-36050bitrate.diff --]
[-- Type: text/plain, Size: 3570 bytes --]

--- linux-2.6.3/drivers/media/video/zr36050-old.c	2004-02-24 02:57:26.000000000 -0500
+++ linux-2.6.3/drivers/media/video/zr36050.c	2004-02-24 03:12:37.000000000 -0500
@@ -24,7 +24,7 @@
  * ------------------------------------------------------------------------
  */
 
-#define ZR050_VERSION "v0.7"
+#define ZR050_VERSION "v0.7.1"
 
 #include <linux/version.h>
 #include <linux/module.h>
@@ -479,7 +479,7 @@
 		zr36050_write(ptr, ZR050_INT_REQ_1, 3);	// low 2 bits always 1
 
 		/* volume control settings */
-		zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol >> 1);
+		/*zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol);*/
 		zr36050_write(ptr, ZR050_SF_HI, ptr->scalefact >> 8);
 		zr36050_write(ptr, ZR050_SF_LO, ptr->scalefact & 0xff);
 
@@ -521,13 +521,13 @@
 		/* setup misc. data for compression (target code sizes) */
 
 		/* size of compressed code to reach without header data */
-		sum = ptr->total_code_vol - sum;
+		sum = ptr->real_code_vol - sum;
 		bitcnt = sum << 3;	/* need the size in bits */
 
 		tmp = bitcnt >> 16;
 		dprintk(3,
 			"%s: code: csize=%d, tot=%d, bit=%ld, highbits=%ld\n",
-			ptr->name, sum, ptr->total_code_vol, bitcnt, tmp);
+			ptr->name, sum, ptr->real_code_vol, bitcnt, tmp);
 		zr36050_write(ptr, ZR050_TCV_NET_HI, tmp >> 8);
 		zr36050_write(ptr, ZR050_TCV_NET_MH, tmp & 0xff);
 		tmp = bitcnt & 0xffff;
@@ -629,17 +629,37 @@
 		   struct vfe_polarity *pol)
 {
 	struct zr36050 *ptr = (struct zr36050 *) codec->data;
+	int size;
 
-	dprintk(2, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) call\n",
+	dprintk(2, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) q%d call\n",
 		ptr->name, norm->HStart, norm->VStart,
 		cap->x, cap->y, cap->width, cap->height,
-		cap->decimation);
+		cap->decimation, cap->quality);
 	/* if () return -EINVAL;
 	 * trust the master driver that it knows what it does - so
 	 * we allow invalid startx/y and norm for now ... */
 	ptr->width = cap->width / (cap->decimation & 0xff);
 	ptr->height = cap->height / ((cap->decimation >> 8) & 0xff);
 
+	/* (KM) JPEG quality */
+	size = ptr->width * ptr->height;
+	size *= 16; /* size in bits */
+	/* apply quality setting */
+	size = size * cap->quality / 200;
+
+	/* Minimum: 1kb */
+	if (size < 8192)
+		size = 8192;
+	/* Maximum: 7/8 of code buffer */
+	if (size > ptr->total_code_vol * 7)
+		size = ptr->total_code_vol * 7;
+
+	ptr->real_code_vol = size >> 3; /* in bytes */        
+        
+	/* Set max_block_vol here (previously in zr36050_init, moved
+	 * here for consistency with zr36060 code */
+	zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol);
+
 	return 0;
 }
 
@@ -697,6 +717,9 @@
 		if (size != sizeof(int))
 			return -EFAULT;
 		ptr->total_code_vol = *ival;
+		/* (Kieran Morrissey)
+		 * code copied from zr36060.c to ensure proper bitrate */
+		ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3;
 		break;
 
 	case CODEC_G_JPEG_SCALE:	/* get scaling factor */
--- linux-2.6.3/drivers/media/video/zr36050-old.h	2004-02-24 02:57:30.000000000 -0500
+++ linux-2.6.3/drivers/media/video/zr36050.h	2004-02-24 03:09:21.000000000 -0500
@@ -44,6 +44,7 @@
 	__u16 bitrate_ctrl;
 
 	__u32 total_code_vol;
+	__u32 real_code_vol;
 	__u16 max_block_vol;
 
 	__u8 h_samp_ratio[8];
--- linux-2.6.3/MAINTAINERS-old	2004-02-24 02:56:49.000000000 -0500
+++ linux-2.6.3/MAINTAINERS	2004-02-24 02:57:02.000000000 -0500
@@ -2395,7 +2395,7 @@
 
 ZR36067 VIDEO FOR LINUX DRIVER
 P:	Ronald Bultje
-M:	R.S.Bultje@pharm.uu.nl
+M:	rbultje@ronald.bitfreak.net
 L:	mjpeg-users@lists.sourceforge.net
 W:	http://mjpeg.sourceforge.net/driver-zoran/
 S:	Maintained

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-02-26 17:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-26 11:37 [PATCH] zr36067 driver update Ronald S. Bultje

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®