From 6254312352dfd1c996245cb3bc74be901dc165cc Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:33 -0300 Subject: [PATCH 01/11] V4L/DVB (3568a): saa7114: Fix i2c block write Fix the i2c block write mode of the saa7114 driver. A previous code change accidentally commented out a local variable increment, which should have been kept, causing the register writes over the I2C bus to never be batched, replacing any attempted block write by slower, individual write transactions. Also drop the commented out code, as it only adds to confusion. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7114.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index fd0a4b4ef014..1c29d05307a5 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c @@ -139,9 +139,6 @@ saa7114_write (struct i2c_client *client, u8 reg, u8 value) { - /*struct saa7114 *decoder = i2c_get_clientdata(client);*/ - - /*decoder->reg[reg] = value;*/ return i2c_smbus_write_byte_data(client, reg, value); } @@ -157,7 +154,6 @@ saa7114_write_block (struct i2c_client *client, * the adapter understands raw I2C */ if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ - /*struct saa7114 *decoder = i2c_get_clientdata(client);*/ struct i2c_msg msg; u8 block_data[32]; @@ -168,8 +164,8 @@ saa7114_write_block (struct i2c_client *client, msg.len = 0; block_data[msg.len++] = reg = data[0]; do { - block_data[msg.len++] = - /*decoder->reg[reg++] =*/ data[1]; + block_data[msg.len++] = data[1]; + reg++; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && From 6eb5d9ca9f1496108cb86f2d9bfc2db5d9c796fe Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:32 -0300 Subject: [PATCH 02/11] V4L/DVB (3568b): saa7111: Prevent array overrun Explicitely state the number of registers the SAA7111 has, and use that defined value where relevant. This should prevent any future array overrun like the one I just fixed in the saa7110 driver. This patch also saves 8 bytes of memory as a side effect, as the register cache was larger than needed. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7111.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 8c06592b37ff..a2e1ccb79e49 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -70,8 +70,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); /* ----------------------------------------------------------------------- */ +#define SAA7111_NR_REG 0x18 + struct saa7111 { - unsigned char reg[32]; + unsigned char reg[SAA7111_NR_REG]; int norm; int input; @@ -227,11 +229,11 @@ saa7111_command (struct i2c_client *client, { int i; - for (i = 0; i < 32; i += 16) { + for (i = 0; i < SAA7111_NR_REG; i += 16) { int j; printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i); - for (j = 0; j < 16; ++j) { + for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { printk(" %02x", saa7111_read(client, i + j)); } From daf72f408c66aee4ac939f614293a78841aa7717 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:37 -0300 Subject: [PATCH 03/11] V4L/DVB (3568c): zoran: Init cleanups Cleanups to the zr36057 initialization: * Drop intermediate local variables. * Single error path. Also drop a needless cast on kfree. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/zoran_card.c | 38 ++++++++++++++------------------ 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index 246e67cd8b51..a2e528ccf28a 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c @@ -995,10 +995,7 @@ test_interrupts (struct zoran *zr) static int __devinit zr36057_init (struct zoran *zr) { - u32 *mem; - void *vdev; - unsigned mem_needed; - int j; + int j, err; int two = 2; int zero = 0; @@ -1049,19 +1046,16 @@ zr36057_init (struct zoran *zr) /* allocate memory *before* doing anything to the hardware * in case allocation fails */ - mem_needed = BUZ_NUM_STAT_COM * 4; - mem = kzalloc(mem_needed, GFP_KERNEL); - vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL); - if (!mem || !vdev) { + zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL); + zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL); + if (!zr->stat_com || !zr->video_dev) { dprintk(1, KERN_ERR "%s: zr36057_init() - kmalloc (STAT_COM) failed\n", ZR_DEVNAME(zr)); - kfree(vdev); - kfree(mem); - return -ENOMEM; + err = -ENOMEM; + goto exit_free; } - zr->stat_com = mem; for (j = 0; j < BUZ_NUM_STAT_COM; j++) { zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */ } @@ -1069,16 +1063,11 @@ zr36057_init (struct zoran *zr) /* * Now add the template and register the device unit. */ - zr->video_dev = vdev; memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template)); strcpy(zr->video_dev->name, ZR_DEVNAME(zr)); - if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER, - video_nr) < 0) { - zoran_unregister_i2c(zr); - kfree((void *) zr->stat_com); - kfree(vdev); - return -1; - } + err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr); + if (err < 0) + goto exit_unregister; zoran_init_hardware(zr); if (*zr_debug > 2) @@ -1092,6 +1081,13 @@ zr36057_init (struct zoran *zr) zr->zoran_proc = NULL; zr->initialized = 1; return 0; + +exit_unregister: + zoran_unregister_i2c(zr); +exit_free: + kfree(zr->stat_com); + kfree(zr->video_dev); + return err; } static void @@ -1121,7 +1117,7 @@ zoran_release (struct zoran *zr) btwrite(0, ZR36057_SPGPPCR); free_irq(zr->pci_dev->irq, zr); /* unmap and free memory */ - kfree((void *) zr->stat_com); + kfree(zr->stat_com); zoran_proc_cleanup(zr); iounmap(zr->zr36057_mem); pci_disable_device(zr->pci_dev); From 58a0b84c92e62c2cc42036259a4b51e0bcaf8fa5 Mon Sep 17 00:00:00 2001 From: Martin Samuelsson Date: Wed, 22 Mar 2006 03:48:38 -0300 Subject: [PATCH 04/11] V4L/DVB (3568d): saa7111.c fix When grabbing composite video with Iomega Buz, the stock driver will prevent grabbing from the same input twice in a row, forcing the user to switch inputs before anything useful can be grabbed again. It is caused by some optimization code in the input selection parts, and triggered by the saa7111_command() executing cmd 0. The attached patch will remedy this by disabling cmd 0 altogether; a fix that has no found negative effects on the rest of the code. In fact, saa7110.c does the exact same thing. Acked-by: Ronald S. Bultje Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7111.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index a2e1ccb79e49..6bd1789c8f78 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -212,6 +212,7 @@ saa7111_command (struct i2c_client *client, switch (cmd) { case 0: + break; case DECODER_INIT: { struct video_decoder_init *init = arg; From f49a5eaea6d7b3ed3d01ca9388eac9e7e5bf6025 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:36 -0300 Subject: [PATCH 05/11] V4L/DVB (3568e): bt856: Spare memory The bt856 driver has a register cache much larger than needed. We really only write to 3 registers, so a 32-byte cache is a bit too much. We can be just as efficient with a 6-byte cache. We could even do with a 3-byte cache, but at the cost of additional arithmetics arguably not worth the spared 3 bytes. Also, 4 of the 6 other members of the bt856 data structure were not used anywhere, so we can as well drop them for an additional 16 bytes of memory spared. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/bt856.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 909b593530ed..7c68937853b0 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c @@ -71,17 +71,14 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); /* ----------------------------------------------------------------------- */ -#define REG_OFFSET 0xCE +#define REG_OFFSET 0xDA +#define BT856_NR_REG 6 struct bt856 { - unsigned char reg[32]; + unsigned char reg[BT856_NR_REG]; int norm; int enable; - int bright; - int contrast; - int hue; - int sat; }; #define I2C_BT856 0x88 @@ -120,8 +117,8 @@ bt856_dump (struct i2c_client *client) struct bt856 *encoder = i2c_get_clientdata(client); printk(KERN_INFO "%s: register dump:", I2C_NAME(client)); - for (i = 0xd6; i <= 0xde; i += 2) - printk(" %02x", encoder->reg[i - REG_OFFSET]); + for (i = 0; i < BT856_NR_REG; i += 2) + printk(" %02x", encoder->reg[i]); printk("\n"); } From 6201573cc9bfe1e0bdec229bed8e95b0dc88a587 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:30 -0300 Subject: [PATCH 06/11] V4L/DVB (3568f): saa7110: Fix array overrun Fix a (probably harmless) array overrun in the DECODER_DUMP command of the saa7110 driver. No big deal as this command is not used anywhere anyway. Also reformat the dump so that it displays nicely. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/saa7110.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 7bb85a7b326e..20cad9fc99ef 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c @@ -432,15 +432,13 @@ saa7110_command (struct i2c_client *client, break; case DECODER_DUMP: - for (v = 0; v < 0x34; v += 16) { + for (v = 0; v < SAA7110_NR_REG; v += 16) { int j; - dprintk(1, KERN_INFO "%s: %03x\n", I2C_NAME(client), + dprintk(1, KERN_DEBUG "%s: %02x:", I2C_NAME(client), v); - for (j = 0; j < 16; j++) { - dprintk(1, KERN_INFO " %02x", - decoder->reg[v + j]); - } - dprintk(1, KERN_INFO "\n"); + for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) + dprintk(1, " %02x", decoder->reg[v + j]); + dprintk(1, "\n"); } break; From 384c36893f94e0e2145832cf2f20684ae372aee5 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 22 Mar 2006 03:54:16 -0300 Subject: [PATCH 07/11] V4L/DVB (3568g): sem2mutex: zoran Semaphore to mutexes conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/zoran.h | 2 +- drivers/media/video/zoran_card.c | 11 +- drivers/media/video/zoran_driver.c | 227 +++++++++++++++-------------- 3 files changed, 121 insertions(+), 119 deletions(-) diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h index 9fe6ad3b6352..ad04a129499d 100644 --- a/drivers/media/video/zoran.h +++ b/drivers/media/video/zoran.h @@ -395,7 +395,7 @@ struct zoran { struct videocodec *codec; /* video codec */ struct videocodec *vfe; /* video front end */ - struct semaphore resource_lock; /* prevent evil stuff */ + struct mutex resource_lock; /* prevent evil stuff */ u8 initialized; /* flag if zoran has been correctly initalized */ int user; /* number of current users */ diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index a2e528ccf28a..b22dbb6d18f6 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -673,7 +674,7 @@ zoran_i2c_client_register (struct i2c_client *client) KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n", ZR_DEVNAME(zr), client->driver->id); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (zr->user > 0) { /* we're already busy, so we keep a reference to @@ -694,7 +695,7 @@ zoran_i2c_client_register (struct i2c_client *client) } clientreg_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -707,7 +708,7 @@ zoran_i2c_client_unregister (struct i2c_client *client) dprintk(2, KERN_DEBUG "%s: i2c_client_unregister()\n", ZR_DEVNAME(zr)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (zr->user > 0) { res = -EBUSY; @@ -722,7 +723,7 @@ zoran_i2c_client_unregister (struct i2c_client *client) snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]", zr->id); } clientunreg_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -1202,7 +1203,7 @@ find_zr36057 (void) zr->id = zoran_num; snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); spin_lock_init(&zr->spinlock); - init_MUTEX(&zr->resource_lock); + mutex_init(&zr->resource_lock); if (pci_enable_device(dev)) continue; zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c index 485553be190b..b2c6e01e3923 100644 --- a/drivers/media/video/zoran_driver.c +++ b/drivers/media/video/zoran_driver.c @@ -81,6 +81,7 @@ #include #include +#include #include "zoran.h" #include "zoran_device.h" #include "zoran_card.h" @@ -1292,7 +1293,7 @@ zoran_open (struct inode *inode, /* see fs/device.c - the kernel already locks during open(), * so locking ourselves only causes deadlocks */ - /*down(&zr->resource_lock);*/ + /*mutex_lock(&zr->resource_lock);*/ if (!zr->decoder) { dprintk(1, @@ -1371,7 +1372,7 @@ zoran_open (struct inode *inode, if (zr->user++ == 0) first_open = 1; - /*up(&zr->resource_lock);*/ + /*mutex_unlock(&zr->resource_lock);*/ /* default setup - TODO: look at flags */ if (first_open) { /* First device open */ @@ -1401,7 +1402,7 @@ open_unlock_and_return: /* if there's no device found, we didn't obtain the lock either */ if (zr) { - /*up(&zr->resource_lock);*/ + /*mutex_unlock(&zr->resource_lock);*/ } return res; @@ -1419,7 +1420,7 @@ zoran_close (struct inode *inode, /* kernel locks (fs/device.c), so don't do that ourselves * (prevents deadlocks) */ - /*down(&zr->resource_lock);*/ + /*mutex_lock(&zr->resource_lock);*/ zoran_close_end_session(file); @@ -1466,7 +1467,7 @@ zoran_close (struct inode *inode, } module_put(THIS_MODULE); - /*up(&zr->resource_lock);*/ + /*mutex_unlock(&zr->resource_lock);*/ dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr)); @@ -2027,14 +2028,14 @@ zoran_do_ioctl (struct inode *inode, * but moving the free code outside the munmap() handler fixes * all this... If someone knows why, please explain me (Ronald) */ - if (!down_trylock(&zr->resource_lock)) { + if (!!mutex_trylock(&zr->resource_lock)) { /* we obtained it! Let's try to free some things */ if (fh->jpg_buffers.ready_to_be_freed) jpg_fbuffer_free(file); if (fh->v4l_buffers.ready_to_be_freed) v4l_fbuffer_free(file); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); } switch (cmd) { @@ -2051,12 +2052,12 @@ zoran_do_ioctl (struct inode *inode, vcap->channels = zr->card.inputs; vcap->audios = 0; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); vcap->maxwidth = BUZ_MAX_WIDTH; vcap->maxheight = BUZ_MAX_HEIGHT; vcap->minwidth = BUZ_MIN_WIDTH; vcap->minheight = BUZ_MIN_HEIGHT; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -2084,9 +2085,9 @@ zoran_do_ioctl (struct inode *inode, vchan->tuners = 0; vchan->flags = 0; vchan->type = VIDEO_TYPE_CAMERA; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); vchan->norm = zr->norm; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); vchan->channel = channel; return 0; @@ -2113,7 +2114,7 @@ zoran_do_ioctl (struct inode *inode, "%s: VIDIOCSCHAN - channel=%d, norm=%d\n", ZR_DEVNAME(zr), vchan->channel, vchan->norm); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if ((res = zoran_set_input(zr, vchan->channel))) goto schan_unlock_and_return; if ((res = zoran_set_norm(zr, vchan->norm))) @@ -2122,7 +2123,7 @@ zoran_do_ioctl (struct inode *inode, /* Make sure the changes come into effect */ res = wait_grab_pending(zr); schan_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } break; @@ -2134,7 +2135,7 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOCGPICT\n", ZR_DEVNAME(zr)); memset(vpict, 0, sizeof(struct video_picture)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); vpict->hue = zr->hue; vpict->brightness = zr->brightness; vpict->contrast = zr->contrast; @@ -2145,7 +2146,7 @@ zoran_do_ioctl (struct inode *inode, } else { vpict->depth = 0; } - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -2180,7 +2181,7 @@ zoran_do_ioctl (struct inode *inode, return -EINVAL; } - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); decoder_command(zr, DECODER_SET_PICTURE, vpict); @@ -2191,7 +2192,7 @@ zoran_do_ioctl (struct inode *inode, fh->overlay_settings.format = &zoran_formats[i]; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -2204,9 +2205,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOCCAPTURE - on=%d\n", ZR_DEVNAME(zr), *on); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = setup_overlay(file, *on); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2219,12 +2220,12 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr)); memset(vwin, 0, sizeof(struct video_window)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); vwin->x = fh->overlay_settings.x; vwin->y = fh->overlay_settings.y; vwin->width = fh->overlay_settings.width; vwin->height = fh->overlay_settings.height; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); vwin->clipcount = 0; return 0; } @@ -2241,12 +2242,12 @@ zoran_do_ioctl (struct inode *inode, ZR_DEVNAME(zr), vwin->x, vwin->y, vwin->width, vwin->height, vwin->clipcount); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = setup_window(file, vwin->x, vwin->y, vwin->width, vwin->height, vwin->clips, vwin->clipcount, NULL); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2258,9 +2259,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); *vbuf = zr->buffer; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } break; @@ -2287,12 +2288,12 @@ zoran_do_ioctl (struct inode *inode, return -EINVAL; } - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = setup_fbuffer(file, vbuf->base, &zoran_formats[i], vbuf->width, vbuf->height, vbuf->bytesperline); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2305,9 +2306,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n", ZR_DEVNAME(zr), *frame); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = v4l_sync(file, *frame); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); if (!res) zr->v4l_sync_tail++; return res; @@ -2325,9 +2326,9 @@ zoran_do_ioctl (struct inode *inode, ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height, vmap->format); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = v4l_grab(file, vmap); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } break; @@ -2348,7 +2349,7 @@ zoran_do_ioctl (struct inode *inode, i * fh->v4l_buffers.buffer_size; } - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { dprintk(1, @@ -2367,7 +2368,7 @@ zoran_do_ioctl (struct inode *inode, /* The next mmap will map the V4L buffers */ fh->map_mode = ZORAN_MAP_MODE_RAW; v4l1reqbuf_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2421,7 +2422,7 @@ zoran_do_ioctl (struct inode *inode, bparams->major_version = MAJOR_VERSION; bparams->minor_version = MINOR_VERSION; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); bparams->norm = zr->norm; bparams->input = zr->input; @@ -2450,7 +2451,7 @@ zoran_do_ioctl (struct inode *inode, bparams->jpeg_markers = fh->jpg_settings.jpg_comp.jpeg_markers; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); bparams->VFIFO_FB = 0; @@ -2486,7 +2487,7 @@ zoran_do_ioctl (struct inode *inode, sizeof(bparams->COM_data)); settings.jpg_comp.jpeg_markers = bparams->jpeg_markers; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (zr->codec_mode != BUZ_MODE_IDLE) { dprintk(1, @@ -2506,7 +2507,7 @@ zoran_do_ioctl (struct inode *inode, fh->jpg_settings = settings; sparams_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2538,7 +2539,7 @@ zoran_do_ioctl (struct inode *inode, breq->size > MAX_KMALLOC_MEM) breq->size = MAX_KMALLOC_MEM; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { dprintk(1, @@ -2561,7 +2562,7 @@ zoran_do_ioctl (struct inode *inode, * also be *_PLAY, but it doesn't matter here */ fh->map_mode = ZORAN_MAP_MODE_JPG_REC; jpgreqbuf_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2574,9 +2575,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_CAPT - frame=%d\n", ZR_DEVNAME(zr), *frame); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_COMPRESS); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2589,9 +2590,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_PLAY - frame=%d\n", ZR_DEVNAME(zr), *frame); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_DECOMPRESS); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2604,9 +2605,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: BUZIOC_SYNC\n", ZR_DEVNAME(zr)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = jpg_sync(file, bsync); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -2630,7 +2631,7 @@ zoran_do_ioctl (struct inode *inode, input = zr->card.input[bstat->input].muxsel; norm = VIDEO_MODE_AUTO; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (zr->codec_mode != BUZ_MODE_IDLE) { dprintk(1, @@ -2655,7 +2656,7 @@ zoran_do_ioctl (struct inode *inode, decoder_command(zr, DECODER_SET_INPUT, &input); decoder_command(zr, DECODER_SET_NORM, &zr->norm); gstat_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); if (!res) { bstat->signal = @@ -2763,7 +2764,7 @@ zoran_do_ioctl (struct inode *inode, switch (fmt->type) { case V4L2_BUF_TYPE_VIDEO_OVERLAY: - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); fmt->fmt.win.w.left = fh->overlay_settings.x; fmt->fmt.win.w.top = fh->overlay_settings.y; @@ -2776,14 +2777,14 @@ zoran_do_ioctl (struct inode *inode, else fmt->fmt.win.field = V4L2_FIELD_TOP; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); break; case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_OUTPUT: - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && fh->map_mode == ZORAN_MAP_MODE_RAW) { @@ -2837,7 +2838,7 @@ zoran_do_ioctl (struct inode *inode, V4L2_COLORSPACE_SMPTE170M; } - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); break; @@ -2870,7 +2871,7 @@ zoran_do_ioctl (struct inode *inode, fmt->fmt.win.w.height, fmt->fmt.win.clipcount, fmt->fmt.win.bitmap); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = setup_window(file, fmt->fmt.win.w.left, fmt->fmt.win.w.top, @@ -2880,7 +2881,7 @@ zoran_do_ioctl (struct inode *inode, fmt->fmt.win.clips, fmt->fmt.win.clipcount, fmt->fmt.win.bitmap); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; break; @@ -2917,7 +2918,7 @@ zoran_do_ioctl (struct inode *inode, } if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); settings = fh->jpg_settings; @@ -2995,7 +2996,7 @@ zoran_do_ioctl (struct inode *inode, ZORAN_MAP_MODE_JPG_REC : ZORAN_MAP_MODE_JPG_PLAY; sfmtjpg_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); } else { for (i = 0; i < zoran_num_formats; i++) if (fmt->fmt.pix.pixelformat == @@ -3010,7 +3011,7 @@ zoran_do_ioctl (struct inode *inode, (char *) &printformat); return -EINVAL; } - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fh->jpg_buffers.allocated || (fh->v4l_buffers.allocated && fh->v4l_buffers.active != @@ -3052,7 +3053,7 @@ zoran_do_ioctl (struct inode *inode, fh->map_mode = ZORAN_MAP_MODE_RAW; sfmtv4l_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); } break; @@ -3077,7 +3078,7 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOC_G_FBUF\n", ZR_DEVNAME(zr)); memset(fb, 0, sizeof(*fb)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); fb->base = zr->buffer.base; fb->fmt.width = zr->buffer.width; fb->fmt.height = zr->buffer.height; @@ -3086,7 +3087,7 @@ zoran_do_ioctl (struct inode *inode, fh->overlay_settings.format->fourcc; } fb->fmt.bytesperline = zr->buffer.bytesperline; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); fb->fmt.colorspace = V4L2_COLORSPACE_SRGB; fb->fmt.field = V4L2_FIELD_INTERLACED; fb->flags = V4L2_FBUF_FLAG_OVERLAY; @@ -3121,12 +3122,12 @@ zoran_do_ioctl (struct inode *inode, return -EINVAL; } - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = setup_fbuffer(file, fb->base, &zoran_formats[i], fb->fmt.width, fb->fmt.height, fb->fmt.bytesperline); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -3139,9 +3140,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOC_PREVIEW - on=%d\n", ZR_DEVNAME(zr), *on); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = setup_overlay(file, *on); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -3163,7 +3164,7 @@ zoran_do_ioctl (struct inode *inode, return -EINVAL; } - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fh->v4l_buffers.allocated || fh->jpg_buffers.allocated) { dprintk(1, @@ -3224,7 +3225,7 @@ zoran_do_ioctl (struct inode *inode, goto v4l2reqbuf_unlock_and_return; } v4l2reqbuf_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -3245,9 +3246,9 @@ zoran_do_ioctl (struct inode *inode, buf->type = type; buf->index = index; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); res = zoran_v4l2_buffer_status(file, buf, buf->index); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -3262,7 +3263,7 @@ zoran_do_ioctl (struct inode *inode, KERN_DEBUG "%s: VIDIOC_QBUF - type=%d, index=%d\n", ZR_DEVNAME(zr), buf->type, buf->index); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); switch (fh->map_mode) { case ZORAN_MAP_MODE_RAW: @@ -3322,7 +3323,7 @@ zoran_do_ioctl (struct inode *inode, goto qbuf_unlock_and_return; } qbuf_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -3336,7 +3337,7 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOC_DQBUF - type=%d\n", ZR_DEVNAME(zr), buf->type); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); switch (fh->map_mode) { case ZORAN_MAP_MODE_RAW: @@ -3410,7 +3411,7 @@ zoran_do_ioctl (struct inode *inode, goto dqbuf_unlock_and_return; } dqbuf_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -3422,7 +3423,7 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMON\n", ZR_DEVNAME(zr)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); switch (fh->map_mode) { case ZORAN_MAP_MODE_RAW: /* raw capture */ @@ -3470,7 +3471,7 @@ zoran_do_ioctl (struct inode *inode, goto strmon_unlock_and_return; } strmon_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -3482,7 +3483,7 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMOFF\n", ZR_DEVNAME(zr)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); switch (fh->map_mode) { case ZORAN_MAP_MODE_RAW: /* raw capture */ @@ -3540,7 +3541,7 @@ zoran_do_ioctl (struct inode *inode, goto strmoff_unlock_and_return; } strmoff_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -3600,7 +3601,7 @@ zoran_do_ioctl (struct inode *inode, ctrl->id > V4L2_CID_HUE) return -EINVAL; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); switch (ctrl->id) { case V4L2_CID_BRIGHTNESS: ctrl->value = zr->brightness; @@ -3615,7 +3616,7 @@ zoran_do_ioctl (struct inode *inode, ctrl->value = zr->hue; break; } - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -3642,7 +3643,7 @@ zoran_do_ioctl (struct inode *inode, return -EINVAL; } - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); switch (ctrl->id) { case V4L2_CID_BRIGHTNESS: zr->brightness = ctrl->value; @@ -3664,7 +3665,7 @@ zoran_do_ioctl (struct inode *inode, decoder_command(zr, DECODER_SET_PICTURE, &pict); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -3732,9 +3733,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); norm = zr->norm; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); switch (norm) { case VIDEO_MODE_PAL: @@ -3776,13 +3777,13 @@ zoran_do_ioctl (struct inode *inode, return -EINVAL; } - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if ((res = zoran_set_norm(zr, norm))) goto sstd_unlock_and_return; res = wait_grab_pending(zr); sstd_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } break; @@ -3809,9 +3810,9 @@ zoran_do_ioctl (struct inode *inode, inp->std = V4L2_STD_ALL; /* Get status of video decoder */ - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); decoder_command(zr, DECODER_GET_STATUS, &status); - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); if (!(status & DECODER_STATUS_GOOD)) { inp->status |= V4L2_IN_ST_NO_POWER; @@ -3830,9 +3831,9 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); *input = zr->input; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -3845,14 +3846,14 @@ zoran_do_ioctl (struct inode *inode, dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n", ZR_DEVNAME(zr), *input); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if ((res = zoran_set_input(zr, *input))) goto sinput_unlock_and_return; /* Make sure the changes come into effect */ res = wait_grab_pending(zr); sinput_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } break; @@ -3914,7 +3915,7 @@ zoran_do_ioctl (struct inode *inode, memset(cropcap, 0, sizeof(*cropcap)); cropcap->type = type; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || @@ -3934,7 +3935,7 @@ zoran_do_ioctl (struct inode *inode, cropcap->defrect.width = BUZ_MIN_WIDTH; cropcap->defrect.height = BUZ_MIN_HEIGHT; cropcap_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } break; @@ -3950,7 +3951,7 @@ zoran_do_ioctl (struct inode *inode, memset(crop, 0, sizeof(*crop)); crop->type = type; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || @@ -3969,7 +3970,7 @@ zoran_do_ioctl (struct inode *inode, crop->c.height = fh->jpg_settings.img_height; gcrop_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -3988,7 +3989,7 @@ zoran_do_ioctl (struct inode *inode, ZR_DEVNAME(zr), crop->type, crop->c.left, crop->c.top, crop->c.width, crop->c.height); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { dprintk(1, @@ -4024,7 +4025,7 @@ zoran_do_ioctl (struct inode *inode, fh->jpg_settings = settings; scrop_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } break; @@ -4038,7 +4039,7 @@ zoran_do_ioctl (struct inode *inode, memset(params, 0, sizeof(*params)); - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); params->quality = fh->jpg_settings.jpg_comp.quality; params->APPn = fh->jpg_settings.jpg_comp.APPn; @@ -4053,7 +4054,7 @@ zoran_do_ioctl (struct inode *inode, params->jpeg_markers = fh->jpg_settings.jpg_comp.jpeg_markers; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -4074,7 +4075,7 @@ zoran_do_ioctl (struct inode *inode, settings.jpg_comp = *params; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fh->v4l_buffers.active != ZORAN_FREE || fh->jpg_buffers.active != ZORAN_FREE) { @@ -4093,7 +4094,7 @@ zoran_do_ioctl (struct inode *inode, zoran_v4l2_calc_bufsize(&fh->jpg_settings); fh->jpg_settings.jpg_comp = *params = settings.jpg_comp; sjpegc_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return 0; } @@ -4127,7 +4128,7 @@ zoran_do_ioctl (struct inode *inode, switch (fmt->type) { case V4L2_BUF_TYPE_VIDEO_OVERLAY: - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH) fmt->fmt.win.w.width = BUZ_MAX_WIDTH; @@ -4138,7 +4139,7 @@ zoran_do_ioctl (struct inode *inode, if (fmt->fmt.win.w.height < BUZ_MIN_HEIGHT) fmt->fmt.win.w.height = BUZ_MIN_HEIGHT; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); break; case V4L2_BUF_TYPE_VIDEO_CAPTURE: @@ -4146,7 +4147,7 @@ zoran_do_ioctl (struct inode *inode, if (fmt->fmt.pix.bytesperline > 0) return -EINVAL; - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { settings = fh->jpg_settings; @@ -4229,7 +4230,7 @@ zoran_do_ioctl (struct inode *inode, goto tryfmt_unlock_and_return; } tryfmt_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; break; @@ -4280,7 +4281,7 @@ zoran_poll (struct file *file, * if no buffers queued or so, return POLLNVAL */ - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); switch (fh->map_mode) { case ZORAN_MAP_MODE_RAW: @@ -4329,7 +4330,7 @@ zoran_poll (struct file *file, } poll_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); return res; } @@ -4385,7 +4386,7 @@ zoran_vm_close (struct vm_area_struct *vma) if (fh->jpg_buffers.buffer[i].map) break; if (i == fh->jpg_buffers.num_buffers) { - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fh->jpg_buffers.active != ZORAN_FREE) { jpg_qbuf(file, -1, zr->codec_mode); @@ -4398,7 +4399,7 @@ zoran_vm_close (struct vm_area_struct *vma) fh->jpg_buffers.allocated = 0; fh->jpg_buffers.ready_to_be_freed = 1; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); } break; @@ -4421,7 +4422,7 @@ zoran_vm_close (struct vm_area_struct *vma) if (fh->v4l_buffers.buffer[i].map) break; if (i == fh->v4l_buffers.num_buffers) { - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); if (fh->v4l_buffers.active != ZORAN_FREE) { zr36057_set_memgrab(zr, 0); @@ -4434,7 +4435,7 @@ zoran_vm_close (struct vm_area_struct *vma) fh->v4l_buffers.allocated = 0; fh->v4l_buffers.ready_to_be_freed = 1; - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); } break; @@ -4489,7 +4490,7 @@ zoran_mmap (struct file *file, case ZORAN_MAP_MODE_JPG_PLAY: /* lock */ - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); /* Map the MJPEG buffers */ if (!fh->jpg_buffers.allocated) { @@ -4579,13 +4580,13 @@ zoran_mmap (struct file *file, } jpg_mmap_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); break; case ZORAN_MAP_MODE_RAW: - down(&zr->resource_lock); + mutex_lock(&zr->resource_lock); /* Map the V4L buffers */ if (!fh->v4l_buffers.allocated) { @@ -4657,7 +4658,7 @@ zoran_mmap (struct file *file, break; } v4l_mmap_unlock_and_return: - up(&zr->resource_lock); + mutex_unlock(&zr->resource_lock); break; From 2f8de1a10697efe7bee08e51b587208706b44e97 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 21 Mar 2006 14:53:22 -0300 Subject: [PATCH 08/11] V4L/DVB (3568h): cpia: correct email address Correct email address typo (erdfeld -> erdfelt). Signed-off-by: Randy Dunlap Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/cpia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index d93a561e6b80..3cebfa91ca14 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c @@ -58,7 +58,7 @@ static int video_nr = -1; #ifdef MODULE module_param(video_nr, int, 0); -MODULE_AUTHOR("Scott J. Bertin & Peter Pregler & Johannes Erdfelt "); +MODULE_AUTHOR("Scott J. Bertin & Peter Pregler & Johannes Erdfelt "); MODULE_DESCRIPTION("V4L-driver for Vision CPiA based cameras"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("video"); From 2467a670ee24631b05e91971286730e71f6a6af0 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:34 -0300 Subject: [PATCH 09/11] V4L/DVB (3568i): adv7175: Drop unused register cache Drop the adv7175 register cache, as it is only written to and never read back from. This saves 128 bytes of memory and slightly speeds up the register writes. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/adv7175.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 4e218f22b214..245f94265758 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -68,8 +68,6 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); /* ----------------------------------------------------------------------- */ struct adv7175 { - unsigned char reg[128]; - int norm; int input; int enable; @@ -95,9 +93,6 @@ adv7175_write (struct i2c_client *client, u8 reg, u8 value) { - struct adv7175 *encoder = i2c_get_clientdata(client); - - encoder->reg[reg] = value; return i2c_smbus_write_byte_data(client, reg, value); } @@ -120,7 +115,6 @@ adv7175_write_block (struct i2c_client *client, * the adapter understands raw I2C */ if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ - struct adv7175 *encoder = i2c_get_clientdata(client); struct i2c_msg msg; u8 block_data[32]; @@ -131,8 +125,8 @@ adv7175_write_block (struct i2c_client *client, msg.len = 0; block_data[msg.len++] = reg = data[0]; do { - block_data[msg.len++] = - encoder->reg[reg++] = data[1]; + block_data[msg.len++] = data[1]; + reg++; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && From 5a313c59bcc5062fc56088d5ff9289828c4b6626 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:34 -0300 Subject: [PATCH 10/11] V4L/DVB (3568j): adv7175: Drop unused encoder dump command Drop support for the ENCODER_DUMP command in the adv7175 driver. ENCODER_DUMP was never actually defined as far as I can see, so the code was ifdef'd out, and I suspect it was never used, not even once, as it includes an obvious array overrun. The register values of this specific chip can be dumped in a generic way using the i2c-dev driver and the "i2cdump" user-space tool if it is ever really needed. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/adv7175.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 245f94265758..ca86de0c2805 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -165,24 +165,6 @@ set_subcarrier_freq (struct i2c_client *client, adv7175_write(client, 0x05, 0x25); } -#ifdef ENCODER_DUMP -static void -dump (struct i2c_client *client) -{ - struct adv7175 *encoder = i2c_get_clientdata(client); - int i, j; - - printk(KERN_INFO "%s: registry dump\n", I2C_NAME(client)); - for (i = 0; i < 182 / 8; i++) { - printk("%s: 0x%02x -", I2C_NAME(client), i * 8); - for (j = 0; j < 8; j++) { - printk(" 0x%02x", encoder->reg[i * 8 + j]); - } - printk("\n"); - } -} -#endif - /* ----------------------------------------------------------------------- */ // Output filter: S-Video Composite @@ -401,14 +383,6 @@ adv7175_command (struct i2c_client *client, } break; -#ifdef ENCODER_DUMP - case ENCODER_DUMP: - { - dump(client); - } - break; -#endif - default: return -EINVAL; } From 9aa45e34d2948f360f8c0e63d10f49015ca51edd Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 22 Mar 2006 03:48:35 -0300 Subject: [PATCH 11/11] V4L/DVB (3568k): zoran: Use i2c_master_send when possible Change all the Zoran (ZR36050/ZR36060) drivers to use i2c_master_send instead of i2c_transfer when possible. This simplifies the code by a few lines in each driver. Signed-off-by: Jean Delvare Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/adv7170.c | 17 +++++++---------- drivers/media/video/adv7175.c | 17 +++++++---------- drivers/media/video/bt819.c | 17 +++++++---------- drivers/media/video/saa7110.c | 7 +------ drivers/media/video/saa7111.c | 17 +++++++---------- drivers/media/video/saa7114.c | 17 +++++++---------- drivers/media/video/saa7185.c | 17 +++++++---------- 7 files changed, 43 insertions(+), 66 deletions(-) diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 4ce07ae62dac..d18bf9097dc9 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c @@ -125,24 +125,21 @@ adv7170_write_block (struct i2c_client *client, if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ struct adv7170 *encoder = i2c_get_clientdata(client); - struct i2c_msg msg; u8 block_data[32]; + int block_len; - msg.addr = client->addr; - msg.flags = 0; while (len >= 2) { - msg.buf = (char *) block_data; - msg.len = 0; - block_data[msg.len++] = reg = data[0]; + block_len = 0; + block_data[block_len++] = reg = data[0]; do { - block_data[msg.len++] = + block_data[block_len++] = encoder->reg[reg++] = data[1]; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && - msg.len < 32); - if ((ret = i2c_transfer(client->adapter, - &msg, 1)) < 0) + block_len < 32); + if ((ret = i2c_master_send(client, block_data, + block_len)) < 0) break; } } else { diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index ca86de0c2805..1a2b111897d5 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -115,24 +115,21 @@ adv7175_write_block (struct i2c_client *client, * the adapter understands raw I2C */ if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ - struct i2c_msg msg; u8 block_data[32]; + int block_len; - msg.addr = client->addr; - msg.flags = 0; while (len >= 2) { - msg.buf = (char *) block_data; - msg.len = 0; - block_data[msg.len++] = reg = data[0]; + block_len = 0; + block_data[block_len++] = reg = data[0]; do { - block_data[msg.len++] = data[1]; + block_data[block_len++] = data[1]; reg++; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && - msg.len < 32); - if ((ret = i2c_transfer(client->adapter, - &msg, 1)) < 0) + block_len < 32); + if ((ret = i2c_master_send(client, block_data, + block_len)) < 0) break; } } else { diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index d6447791d0e5..c2c450fbf683 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c @@ -141,24 +141,21 @@ bt819_write_block (struct i2c_client *client, if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ struct bt819 *decoder = i2c_get_clientdata(client); - struct i2c_msg msg; u8 block_data[32]; + int block_len; - msg.addr = client->addr; - msg.flags = 0; while (len >= 2) { - msg.buf = (char *) block_data; - msg.len = 0; - block_data[msg.len++] = reg = data[0]; + block_len = 0; + block_data[block_len++] = reg = data[0]; do { - block_data[msg.len++] = + block_data[block_len++] = decoder->reg[reg++] = data[1]; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && - msg.len < 32); - if ((ret = i2c_transfer(client->adapter, - &msg, 1)) < 0) + block_len < 32); + if ((ret = i2c_master_send(client, block_data, + block_len)) < 0) break; } } else { diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 20cad9fc99ef..36123fa0b63f 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c @@ -108,13 +108,8 @@ saa7110_write_block (struct i2c_client *client, * the adapter understands raw I2C */ if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { struct saa7110 *decoder = i2c_get_clientdata(client); - struct i2c_msg msg; - msg.len = len; - msg.buf = (char *) data; - msg.addr = client->addr; - msg.flags = 0; - ret = i2c_transfer(client->adapter, &msg, 1); + ret = i2c_master_send(client, data, len); /* Cache the written data */ memcpy(decoder->reg + reg, data + 1, len - 1); diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 6bd1789c8f78..cb27917c376a 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -112,24 +112,21 @@ saa7111_write_block (struct i2c_client *client, if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ struct saa7111 *decoder = i2c_get_clientdata(client); - struct i2c_msg msg; u8 block_data[32]; + int block_len; - msg.addr = client->addr; - msg.flags = 0; while (len >= 2) { - msg.buf = (char *) block_data; - msg.len = 0; - block_data[msg.len++] = reg = data[0]; + block_len = 0; + block_data[block_len++] = reg = data[0]; do { - block_data[msg.len++] = + block_data[block_len++] = decoder->reg[reg++] = data[1]; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && - msg.len < 32); - if ((ret = i2c_transfer(client->adapter, - &msg, 1)) < 0) + block_len < 32); + if ((ret = i2c_master_send(client, block_data, + block_len)) < 0) break; } } else { diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index 1c29d05307a5..849b54cd5c24 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c @@ -154,24 +154,21 @@ saa7114_write_block (struct i2c_client *client, * the adapter understands raw I2C */ if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ - struct i2c_msg msg; u8 block_data[32]; + int block_len; - msg.addr = client->addr; - msg.flags = 0; while (len >= 2) { - msg.buf = (char *) block_data; - msg.len = 0; - block_data[msg.len++] = reg = data[0]; + block_len = 0; + block_data[block_len++] = reg = data[0]; do { - block_data[msg.len++] = data[1]; + block_data[block_len++] = data[1]; reg++; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && - msg.len < 32); - if ((ret = i2c_transfer(client->adapter, - &msg, 1)) < 0) + block_len < 32); + if ((ret = i2c_master_send(client, block_data, + block_len)) < 0) break; } } else { diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 3ed0edb870a4..67dfa7186453 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c @@ -113,24 +113,21 @@ saa7185_write_block (struct i2c_client *client, if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { /* do raw I2C, not smbus compatible */ struct saa7185 *encoder = i2c_get_clientdata(client); - struct i2c_msg msg; u8 block_data[32]; + int block_len; - msg.addr = client->addr; - msg.flags = 0; while (len >= 2) { - msg.buf = (char *) block_data; - msg.len = 0; - block_data[msg.len++] = reg = data[0]; + block_len = 0; + block_data[block_len++] = reg = data[0]; do { - block_data[msg.len++] = + block_data[block_len++] = encoder->reg[reg++] = data[1]; len -= 2; data += 2; } while (len >= 2 && data[0] == reg && - msg.len < 32); - if ((ret = i2c_transfer(client->adapter, - &msg, 1)) < 0) + block_len < 32); + if ((ret = i2c_master_send(client, block_data, + block_len)) < 0) break; } } else {