[PATCH] zr36067 driver update

From: Ronald S. Bultje
Date: Thu Feb 26 2004 - 12:40:02 EST


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@xxxxxxxxxxxxxxxxxxx>
Linux Video/Multimedia developer
--- 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@xxxxxxxxxxx
+M: rbultje@xxxxxxxxxxxxxxxxxxx
L: mjpeg-users@xxxxxxxxxxxxxxxxxxxxx
W: http://mjpeg.sourceforge.net/driver-zoran/
S: Maintained