提交 384c3689 编写于 作者: I Ingo Molnar 提交者: Mauro Carvalho Chehab

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: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 6201573c
...@@ -395,7 +395,7 @@ struct zoran { ...@@ -395,7 +395,7 @@ struct zoran {
struct videocodec *codec; /* video codec */ struct videocodec *codec; /* video codec */
struct videocodec *vfe; /* video front end */ 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 */ u8 initialized; /* flag if zoran has been correctly initalized */
int user; /* number of current users */ int user; /* number of current users */
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/video_decoder.h> #include <linux/video_decoder.h>
#include <linux/video_encoder.h> #include <linux/video_encoder.h>
#include <linux/mutex.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -673,7 +674,7 @@ zoran_i2c_client_register (struct i2c_client *client) ...@@ -673,7 +674,7 @@ zoran_i2c_client_register (struct i2c_client *client)
KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n", KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n",
ZR_DEVNAME(zr), client->driver->id); ZR_DEVNAME(zr), client->driver->id);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (zr->user > 0) { if (zr->user > 0) {
/* we're already busy, so we keep a reference to /* we're already busy, so we keep a reference to
...@@ -694,7 +695,7 @@ zoran_i2c_client_register (struct i2c_client *client) ...@@ -694,7 +695,7 @@ zoran_i2c_client_register (struct i2c_client *client)
} }
clientreg_unlock_and_return: clientreg_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -707,7 +708,7 @@ zoran_i2c_client_unregister (struct i2c_client *client) ...@@ -707,7 +708,7 @@ zoran_i2c_client_unregister (struct i2c_client *client)
dprintk(2, KERN_DEBUG "%s: i2c_client_unregister()\n", ZR_DEVNAME(zr)); 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) { if (zr->user > 0) {
res = -EBUSY; res = -EBUSY;
...@@ -722,7 +723,7 @@ zoran_i2c_client_unregister (struct i2c_client *client) ...@@ -722,7 +723,7 @@ zoran_i2c_client_unregister (struct i2c_client *client)
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]", zr->id); snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]", zr->id);
} }
clientunreg_unlock_and_return: clientunreg_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -1202,7 +1203,7 @@ find_zr36057 (void) ...@@ -1202,7 +1203,7 @@ find_zr36057 (void)
zr->id = zoran_num; zr->id = zoran_num;
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id); snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id);
spin_lock_init(&zr->spinlock); spin_lock_init(&zr->spinlock);
init_MUTEX(&zr->resource_lock); mutex_init(&zr->resource_lock);
if (pci_enable_device(dev)) if (pci_enable_device(dev))
continue; continue;
zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0);
......
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
#include <linux/video_decoder.h> #include <linux/video_decoder.h>
#include <linux/video_encoder.h> #include <linux/video_encoder.h>
#include <linux/mutex.h>
#include "zoran.h" #include "zoran.h"
#include "zoran_device.h" #include "zoran_device.h"
#include "zoran_card.h" #include "zoran_card.h"
...@@ -1292,7 +1293,7 @@ zoran_open (struct inode *inode, ...@@ -1292,7 +1293,7 @@ zoran_open (struct inode *inode,
/* see fs/device.c - the kernel already locks during open(), /* see fs/device.c - the kernel already locks during open(),
* so locking ourselves only causes deadlocks */ * so locking ourselves only causes deadlocks */
/*down(&zr->resource_lock);*/ /*mutex_lock(&zr->resource_lock);*/
if (!zr->decoder) { if (!zr->decoder) {
dprintk(1, dprintk(1,
...@@ -1371,7 +1372,7 @@ zoran_open (struct inode *inode, ...@@ -1371,7 +1372,7 @@ zoran_open (struct inode *inode,
if (zr->user++ == 0) if (zr->user++ == 0)
first_open = 1; first_open = 1;
/*up(&zr->resource_lock);*/ /*mutex_unlock(&zr->resource_lock);*/
/* default setup - TODO: look at flags */ /* default setup - TODO: look at flags */
if (first_open) { /* First device open */ if (first_open) { /* First device open */
...@@ -1401,7 +1402,7 @@ zoran_open (struct inode *inode, ...@@ -1401,7 +1402,7 @@ zoran_open (struct inode *inode,
/* if there's no device found, we didn't obtain the lock either */ /* if there's no device found, we didn't obtain the lock either */
if (zr) { if (zr) {
/*up(&zr->resource_lock);*/ /*mutex_unlock(&zr->resource_lock);*/
} }
return res; return res;
...@@ -1419,7 +1420,7 @@ zoran_close (struct inode *inode, ...@@ -1419,7 +1420,7 @@ zoran_close (struct inode *inode,
/* kernel locks (fs/device.c), so don't do that ourselves /* kernel locks (fs/device.c), so don't do that ourselves
* (prevents deadlocks) */ * (prevents deadlocks) */
/*down(&zr->resource_lock);*/ /*mutex_lock(&zr->resource_lock);*/
zoran_close_end_session(file); zoran_close_end_session(file);
...@@ -1466,7 +1467,7 @@ zoran_close (struct inode *inode, ...@@ -1466,7 +1467,7 @@ zoran_close (struct inode *inode,
} }
module_put(THIS_MODULE); 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)); dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr));
...@@ -2027,14 +2028,14 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2027,14 +2028,14 @@ zoran_do_ioctl (struct inode *inode,
* but moving the free code outside the munmap() handler fixes * but moving the free code outside the munmap() handler fixes
* all this... If someone knows why, please explain me (Ronald) * 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 */ /* we obtained it! Let's try to free some things */
if (fh->jpg_buffers.ready_to_be_freed) if (fh->jpg_buffers.ready_to_be_freed)
jpg_fbuffer_free(file); jpg_fbuffer_free(file);
if (fh->v4l_buffers.ready_to_be_freed) if (fh->v4l_buffers.ready_to_be_freed)
v4l_fbuffer_free(file); v4l_fbuffer_free(file);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
} }
switch (cmd) { switch (cmd) {
...@@ -2051,12 +2052,12 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2051,12 +2052,12 @@ zoran_do_ioctl (struct inode *inode,
vcap->channels = zr->card.inputs; vcap->channels = zr->card.inputs;
vcap->audios = 0; vcap->audios = 0;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
vcap->maxwidth = BUZ_MAX_WIDTH; vcap->maxwidth = BUZ_MAX_WIDTH;
vcap->maxheight = BUZ_MAX_HEIGHT; vcap->maxheight = BUZ_MAX_HEIGHT;
vcap->minwidth = BUZ_MIN_WIDTH; vcap->minwidth = BUZ_MIN_WIDTH;
vcap->minheight = BUZ_MIN_HEIGHT; vcap->minheight = BUZ_MIN_HEIGHT;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -2084,9 +2085,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2084,9 +2085,9 @@ zoran_do_ioctl (struct inode *inode,
vchan->tuners = 0; vchan->tuners = 0;
vchan->flags = 0; vchan->flags = 0;
vchan->type = VIDEO_TYPE_CAMERA; vchan->type = VIDEO_TYPE_CAMERA;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
vchan->norm = zr->norm; vchan->norm = zr->norm;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
vchan->channel = channel; vchan->channel = channel;
return 0; return 0;
...@@ -2113,7 +2114,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2113,7 +2114,7 @@ zoran_do_ioctl (struct inode *inode,
"%s: VIDIOCSCHAN - channel=%d, norm=%d\n", "%s: VIDIOCSCHAN - channel=%d, norm=%d\n",
ZR_DEVNAME(zr), vchan->channel, vchan->norm); ZR_DEVNAME(zr), vchan->channel, vchan->norm);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if ((res = zoran_set_input(zr, vchan->channel))) if ((res = zoran_set_input(zr, vchan->channel)))
goto schan_unlock_and_return; goto schan_unlock_and_return;
if ((res = zoran_set_norm(zr, vchan->norm))) if ((res = zoran_set_norm(zr, vchan->norm)))
...@@ -2122,7 +2123,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2122,7 +2123,7 @@ zoran_do_ioctl (struct inode *inode,
/* Make sure the changes come into effect */ /* Make sure the changes come into effect */
res = wait_grab_pending(zr); res = wait_grab_pending(zr);
schan_unlock_and_return: schan_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
break; break;
...@@ -2134,7 +2135,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2134,7 +2135,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCGPICT\n", ZR_DEVNAME(zr)); dprintk(3, KERN_DEBUG "%s: VIDIOCGPICT\n", ZR_DEVNAME(zr));
memset(vpict, 0, sizeof(struct video_picture)); memset(vpict, 0, sizeof(struct video_picture));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
vpict->hue = zr->hue; vpict->hue = zr->hue;
vpict->brightness = zr->brightness; vpict->brightness = zr->brightness;
vpict->contrast = zr->contrast; vpict->contrast = zr->contrast;
...@@ -2145,7 +2146,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2145,7 +2146,7 @@ zoran_do_ioctl (struct inode *inode,
} else { } else {
vpict->depth = 0; vpict->depth = 0;
} }
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -2180,7 +2181,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2180,7 +2181,7 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL; return -EINVAL;
} }
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
decoder_command(zr, DECODER_SET_PICTURE, vpict); decoder_command(zr, DECODER_SET_PICTURE, vpict);
...@@ -2191,7 +2192,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2191,7 +2192,7 @@ zoran_do_ioctl (struct inode *inode,
fh->overlay_settings.format = &zoran_formats[i]; fh->overlay_settings.format = &zoran_formats[i];
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -2204,9 +2205,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2204,9 +2205,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCCAPTURE - on=%d\n", dprintk(3, KERN_DEBUG "%s: VIDIOCCAPTURE - on=%d\n",
ZR_DEVNAME(zr), *on); ZR_DEVNAME(zr), *on);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = setup_overlay(file, *on); res = setup_overlay(file, *on);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2219,12 +2220,12 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2219,12 +2220,12 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr)); dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr));
memset(vwin, 0, sizeof(struct video_window)); memset(vwin, 0, sizeof(struct video_window));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
vwin->x = fh->overlay_settings.x; vwin->x = fh->overlay_settings.x;
vwin->y = fh->overlay_settings.y; vwin->y = fh->overlay_settings.y;
vwin->width = fh->overlay_settings.width; vwin->width = fh->overlay_settings.width;
vwin->height = fh->overlay_settings.height; vwin->height = fh->overlay_settings.height;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
vwin->clipcount = 0; vwin->clipcount = 0;
return 0; return 0;
} }
...@@ -2241,12 +2242,12 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2241,12 +2242,12 @@ zoran_do_ioctl (struct inode *inode,
ZR_DEVNAME(zr), vwin->x, vwin->y, vwin->width, ZR_DEVNAME(zr), vwin->x, vwin->y, vwin->width,
vwin->height, vwin->clipcount); vwin->height, vwin->clipcount);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = res =
setup_window(file, vwin->x, vwin->y, vwin->width, setup_window(file, vwin->x, vwin->y, vwin->width,
vwin->height, vwin->clips, vwin->height, vwin->clips,
vwin->clipcount, NULL); vwin->clipcount, NULL);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2258,9 +2259,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2258,9 +2259,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr)); dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
*vbuf = zr->buffer; *vbuf = zr->buffer;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
break; break;
...@@ -2287,12 +2288,12 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2287,12 +2288,12 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL; return -EINVAL;
} }
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = res =
setup_fbuffer(file, vbuf->base, &zoran_formats[i], setup_fbuffer(file, vbuf->base, &zoran_formats[i],
vbuf->width, vbuf->height, vbuf->width, vbuf->height,
vbuf->bytesperline); vbuf->bytesperline);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2305,9 +2306,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2305,9 +2306,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n", dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n",
ZR_DEVNAME(zr), *frame); ZR_DEVNAME(zr), *frame);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = v4l_sync(file, *frame); res = v4l_sync(file, *frame);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
if (!res) if (!res)
zr->v4l_sync_tail++; zr->v4l_sync_tail++;
return res; return res;
...@@ -2325,9 +2326,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2325,9 +2326,9 @@ zoran_do_ioctl (struct inode *inode,
ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height, ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height,
vmap->format); vmap->format);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = v4l_grab(file, vmap); res = v4l_grab(file, vmap);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
break; break;
...@@ -2348,7 +2349,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2348,7 +2349,7 @@ zoran_do_ioctl (struct inode *inode,
i * fh->v4l_buffers.buffer_size; i * fh->v4l_buffers.buffer_size;
} }
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) {
dprintk(1, dprintk(1,
...@@ -2367,7 +2368,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2367,7 +2368,7 @@ zoran_do_ioctl (struct inode *inode,
/* The next mmap will map the V4L buffers */ /* The next mmap will map the V4L buffers */
fh->map_mode = ZORAN_MAP_MODE_RAW; fh->map_mode = ZORAN_MAP_MODE_RAW;
v4l1reqbuf_unlock_and_return: v4l1reqbuf_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2421,7 +2422,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2421,7 +2422,7 @@ zoran_do_ioctl (struct inode *inode,
bparams->major_version = MAJOR_VERSION; bparams->major_version = MAJOR_VERSION;
bparams->minor_version = MINOR_VERSION; bparams->minor_version = MINOR_VERSION;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
bparams->norm = zr->norm; bparams->norm = zr->norm;
bparams->input = zr->input; bparams->input = zr->input;
...@@ -2450,7 +2451,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2450,7 +2451,7 @@ zoran_do_ioctl (struct inode *inode,
bparams->jpeg_markers = bparams->jpeg_markers =
fh->jpg_settings.jpg_comp.jpeg_markers; fh->jpg_settings.jpg_comp.jpeg_markers;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
bparams->VFIFO_FB = 0; bparams->VFIFO_FB = 0;
...@@ -2486,7 +2487,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2486,7 +2487,7 @@ zoran_do_ioctl (struct inode *inode,
sizeof(bparams->COM_data)); sizeof(bparams->COM_data));
settings.jpg_comp.jpeg_markers = bparams->jpeg_markers; settings.jpg_comp.jpeg_markers = bparams->jpeg_markers;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (zr->codec_mode != BUZ_MODE_IDLE) { if (zr->codec_mode != BUZ_MODE_IDLE) {
dprintk(1, dprintk(1,
...@@ -2506,7 +2507,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2506,7 +2507,7 @@ zoran_do_ioctl (struct inode *inode,
fh->jpg_settings = settings; fh->jpg_settings = settings;
sparams_unlock_and_return: sparams_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2538,7 +2539,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2538,7 +2539,7 @@ zoran_do_ioctl (struct inode *inode,
breq->size > MAX_KMALLOC_MEM) breq->size > MAX_KMALLOC_MEM)
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) { if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) {
dprintk(1, dprintk(1,
...@@ -2561,7 +2562,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2561,7 +2562,7 @@ zoran_do_ioctl (struct inode *inode,
* also be *_PLAY, but it doesn't matter here */ * also be *_PLAY, but it doesn't matter here */
fh->map_mode = ZORAN_MAP_MODE_JPG_REC; fh->map_mode = ZORAN_MAP_MODE_JPG_REC;
jpgreqbuf_unlock_and_return: jpgreqbuf_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2574,9 +2575,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2574,9 +2575,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_CAPT - frame=%d\n", dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_CAPT - frame=%d\n",
ZR_DEVNAME(zr), *frame); ZR_DEVNAME(zr), *frame);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_COMPRESS); res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_COMPRESS);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2589,9 +2590,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2589,9 +2590,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_PLAY - frame=%d\n", dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_PLAY - frame=%d\n",
ZR_DEVNAME(zr), *frame); ZR_DEVNAME(zr), *frame);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_DECOMPRESS); res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_DECOMPRESS);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2604,9 +2605,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2604,9 +2605,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: BUZIOC_SYNC\n", ZR_DEVNAME(zr)); 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); res = jpg_sync(file, bsync);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -2630,7 +2631,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2630,7 +2631,7 @@ zoran_do_ioctl (struct inode *inode,
input = zr->card.input[bstat->input].muxsel; input = zr->card.input[bstat->input].muxsel;
norm = VIDEO_MODE_AUTO; norm = VIDEO_MODE_AUTO;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (zr->codec_mode != BUZ_MODE_IDLE) { if (zr->codec_mode != BUZ_MODE_IDLE) {
dprintk(1, dprintk(1,
...@@ -2655,7 +2656,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2655,7 +2656,7 @@ zoran_do_ioctl (struct inode *inode,
decoder_command(zr, DECODER_SET_INPUT, &input); decoder_command(zr, DECODER_SET_INPUT, &input);
decoder_command(zr, DECODER_SET_NORM, &zr->norm); decoder_command(zr, DECODER_SET_NORM, &zr->norm);
gstat_unlock_and_return: gstat_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
if (!res) { if (!res) {
bstat->signal = bstat->signal =
...@@ -2763,7 +2764,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2763,7 +2764,7 @@ zoran_do_ioctl (struct inode *inode,
switch (fmt->type) { switch (fmt->type) {
case V4L2_BUF_TYPE_VIDEO_OVERLAY: 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.left = fh->overlay_settings.x;
fmt->fmt.win.w.top = fh->overlay_settings.y; fmt->fmt.win.w.top = fh->overlay_settings.y;
...@@ -2776,14 +2777,14 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2776,14 +2777,14 @@ zoran_do_ioctl (struct inode *inode,
else else
fmt->fmt.win.field = V4L2_FIELD_TOP; fmt->fmt.win.field = V4L2_FIELD_TOP;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
break; break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
case V4L2_BUF_TYPE_VIDEO_OUTPUT: case V4L2_BUF_TYPE_VIDEO_OUTPUT:
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE &&
fh->map_mode == ZORAN_MAP_MODE_RAW) { fh->map_mode == ZORAN_MAP_MODE_RAW) {
...@@ -2837,7 +2838,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2837,7 +2838,7 @@ zoran_do_ioctl (struct inode *inode,
V4L2_COLORSPACE_SMPTE170M; V4L2_COLORSPACE_SMPTE170M;
} }
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
break; break;
...@@ -2870,7 +2871,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2870,7 +2871,7 @@ zoran_do_ioctl (struct inode *inode,
fmt->fmt.win.w.height, fmt->fmt.win.w.height,
fmt->fmt.win.clipcount, fmt->fmt.win.clipcount,
fmt->fmt.win.bitmap); fmt->fmt.win.bitmap);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = res =
setup_window(file, fmt->fmt.win.w.left, setup_window(file, fmt->fmt.win.w.left,
fmt->fmt.win.w.top, fmt->fmt.win.w.top,
...@@ -2880,7 +2881,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2880,7 +2881,7 @@ zoran_do_ioctl (struct inode *inode,
fmt->fmt.win.clips, fmt->fmt.win.clips,
fmt->fmt.win.clipcount, fmt->fmt.win.clipcount,
fmt->fmt.win.bitmap); fmt->fmt.win.bitmap);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
break; break;
...@@ -2917,7 +2918,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2917,7 +2918,7 @@ zoran_do_ioctl (struct inode *inode,
} }
if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) {
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
settings = fh->jpg_settings; settings = fh->jpg_settings;
...@@ -2995,7 +2996,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -2995,7 +2996,7 @@ zoran_do_ioctl (struct inode *inode,
ZORAN_MAP_MODE_JPG_REC : ZORAN_MAP_MODE_JPG_REC :
ZORAN_MAP_MODE_JPG_PLAY; ZORAN_MAP_MODE_JPG_PLAY;
sfmtjpg_unlock_and_return: sfmtjpg_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
} else { } else {
for (i = 0; i < zoran_num_formats; i++) for (i = 0; i < zoran_num_formats; i++)
if (fmt->fmt.pix.pixelformat == if (fmt->fmt.pix.pixelformat ==
...@@ -3010,7 +3011,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3010,7 +3011,7 @@ zoran_do_ioctl (struct inode *inode,
(char *) &printformat); (char *) &printformat);
return -EINVAL; return -EINVAL;
} }
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.allocated || if (fh->jpg_buffers.allocated ||
(fh->v4l_buffers.allocated && (fh->v4l_buffers.allocated &&
fh->v4l_buffers.active != fh->v4l_buffers.active !=
...@@ -3052,7 +3053,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3052,7 +3053,7 @@ zoran_do_ioctl (struct inode *inode,
fh->map_mode = ZORAN_MAP_MODE_RAW; fh->map_mode = ZORAN_MAP_MODE_RAW;
sfmtv4l_unlock_and_return: sfmtv4l_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
} }
break; break;
...@@ -3077,7 +3078,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3077,7 +3078,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_FBUF\n", ZR_DEVNAME(zr)); dprintk(3, KERN_DEBUG "%s: VIDIOC_G_FBUF\n", ZR_DEVNAME(zr));
memset(fb, 0, sizeof(*fb)); memset(fb, 0, sizeof(*fb));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
fb->base = zr->buffer.base; fb->base = zr->buffer.base;
fb->fmt.width = zr->buffer.width; fb->fmt.width = zr->buffer.width;
fb->fmt.height = zr->buffer.height; fb->fmt.height = zr->buffer.height;
...@@ -3086,7 +3087,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3086,7 +3087,7 @@ zoran_do_ioctl (struct inode *inode,
fh->overlay_settings.format->fourcc; fh->overlay_settings.format->fourcc;
} }
fb->fmt.bytesperline = zr->buffer.bytesperline; fb->fmt.bytesperline = zr->buffer.bytesperline;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
fb->fmt.colorspace = V4L2_COLORSPACE_SRGB; fb->fmt.colorspace = V4L2_COLORSPACE_SRGB;
fb->fmt.field = V4L2_FIELD_INTERLACED; fb->fmt.field = V4L2_FIELD_INTERLACED;
fb->flags = V4L2_FBUF_FLAG_OVERLAY; fb->flags = V4L2_FBUF_FLAG_OVERLAY;
...@@ -3121,12 +3122,12 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3121,12 +3122,12 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL; return -EINVAL;
} }
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = res =
setup_fbuffer(file, fb->base, &zoran_formats[i], setup_fbuffer(file, fb->base, &zoran_formats[i],
fb->fmt.width, fb->fmt.height, fb->fmt.width, fb->fmt.height,
fb->fmt.bytesperline); fb->fmt.bytesperline);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -3139,9 +3140,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3139,9 +3140,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_PREVIEW - on=%d\n", dprintk(3, KERN_DEBUG "%s: VIDIOC_PREVIEW - on=%d\n",
ZR_DEVNAME(zr), *on); ZR_DEVNAME(zr), *on);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = setup_overlay(file, *on); res = setup_overlay(file, *on);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -3163,7 +3164,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3163,7 +3164,7 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL; return -EINVAL;
} }
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fh->v4l_buffers.allocated || fh->jpg_buffers.allocated) { if (fh->v4l_buffers.allocated || fh->jpg_buffers.allocated) {
dprintk(1, dprintk(1,
...@@ -3224,7 +3225,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3224,7 +3225,7 @@ zoran_do_ioctl (struct inode *inode,
goto v4l2reqbuf_unlock_and_return; goto v4l2reqbuf_unlock_and_return;
} }
v4l2reqbuf_unlock_and_return: v4l2reqbuf_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -3245,9 +3246,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3245,9 +3246,9 @@ zoran_do_ioctl (struct inode *inode,
buf->type = type; buf->type = type;
buf->index = index; buf->index = index;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
res = zoran_v4l2_buffer_status(file, buf, buf->index); res = zoran_v4l2_buffer_status(file, buf, buf->index);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -3262,7 +3263,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3262,7 +3263,7 @@ zoran_do_ioctl (struct inode *inode,
KERN_DEBUG "%s: VIDIOC_QBUF - type=%d, index=%d\n", KERN_DEBUG "%s: VIDIOC_QBUF - type=%d, index=%d\n",
ZR_DEVNAME(zr), buf->type, buf->index); ZR_DEVNAME(zr), buf->type, buf->index);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
switch (fh->map_mode) { switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW: case ZORAN_MAP_MODE_RAW:
...@@ -3322,7 +3323,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3322,7 +3323,7 @@ zoran_do_ioctl (struct inode *inode,
goto qbuf_unlock_and_return; goto qbuf_unlock_and_return;
} }
qbuf_unlock_and_return: qbuf_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -3336,7 +3337,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3336,7 +3337,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_DQBUF - type=%d\n", dprintk(3, KERN_DEBUG "%s: VIDIOC_DQBUF - type=%d\n",
ZR_DEVNAME(zr), buf->type); ZR_DEVNAME(zr), buf->type);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
switch (fh->map_mode) { switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW: case ZORAN_MAP_MODE_RAW:
...@@ -3410,7 +3411,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3410,7 +3411,7 @@ zoran_do_ioctl (struct inode *inode,
goto dqbuf_unlock_and_return; goto dqbuf_unlock_and_return;
} }
dqbuf_unlock_and_return: dqbuf_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -3422,7 +3423,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3422,7 +3423,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMON\n", ZR_DEVNAME(zr)); dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMON\n", ZR_DEVNAME(zr));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
switch (fh->map_mode) { switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW: /* raw capture */ case ZORAN_MAP_MODE_RAW: /* raw capture */
...@@ -3470,7 +3471,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3470,7 +3471,7 @@ zoran_do_ioctl (struct inode *inode,
goto strmon_unlock_and_return; goto strmon_unlock_and_return;
} }
strmon_unlock_and_return: strmon_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -3482,7 +3483,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3482,7 +3483,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMOFF\n", ZR_DEVNAME(zr)); dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMOFF\n", ZR_DEVNAME(zr));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
switch (fh->map_mode) { switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW: /* raw capture */ case ZORAN_MAP_MODE_RAW: /* raw capture */
...@@ -3540,7 +3541,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3540,7 +3541,7 @@ zoran_do_ioctl (struct inode *inode,
goto strmoff_unlock_and_return; goto strmoff_unlock_and_return;
} }
strmoff_unlock_and_return: strmoff_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -3600,7 +3601,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3600,7 +3601,7 @@ zoran_do_ioctl (struct inode *inode,
ctrl->id > V4L2_CID_HUE) ctrl->id > V4L2_CID_HUE)
return -EINVAL; return -EINVAL;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS: case V4L2_CID_BRIGHTNESS:
ctrl->value = zr->brightness; ctrl->value = zr->brightness;
...@@ -3615,7 +3616,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3615,7 +3616,7 @@ zoran_do_ioctl (struct inode *inode,
ctrl->value = zr->hue; ctrl->value = zr->hue;
break; break;
} }
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -3642,7 +3643,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3642,7 +3643,7 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL; return -EINVAL;
} }
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS: case V4L2_CID_BRIGHTNESS:
zr->brightness = ctrl->value; zr->brightness = ctrl->value;
...@@ -3664,7 +3665,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3664,7 +3665,7 @@ zoran_do_ioctl (struct inode *inode,
decoder_command(zr, DECODER_SET_PICTURE, &pict); decoder_command(zr, DECODER_SET_PICTURE, &pict);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -3732,9 +3733,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3732,9 +3733,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr)); dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
norm = zr->norm; norm = zr->norm;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
switch (norm) { switch (norm) {
case VIDEO_MODE_PAL: case VIDEO_MODE_PAL:
...@@ -3776,13 +3777,13 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3776,13 +3777,13 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL; return -EINVAL;
} }
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if ((res = zoran_set_norm(zr, norm))) if ((res = zoran_set_norm(zr, norm)))
goto sstd_unlock_and_return; goto sstd_unlock_and_return;
res = wait_grab_pending(zr); res = wait_grab_pending(zr);
sstd_unlock_and_return: sstd_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
break; break;
...@@ -3809,9 +3810,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3809,9 +3810,9 @@ zoran_do_ioctl (struct inode *inode,
inp->std = V4L2_STD_ALL; inp->std = V4L2_STD_ALL;
/* Get status of video decoder */ /* Get status of video decoder */
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
decoder_command(zr, DECODER_GET_STATUS, &status); decoder_command(zr, DECODER_GET_STATUS, &status);
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
if (!(status & DECODER_STATUS_GOOD)) { if (!(status & DECODER_STATUS_GOOD)) {
inp->status |= V4L2_IN_ST_NO_POWER; inp->status |= V4L2_IN_ST_NO_POWER;
...@@ -3830,9 +3831,9 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3830,9 +3831,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr)); dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
*input = zr->input; *input = zr->input;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -3845,14 +3846,14 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3845,14 +3846,14 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n", dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n",
ZR_DEVNAME(zr), *input); ZR_DEVNAME(zr), *input);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if ((res = zoran_set_input(zr, *input))) if ((res = zoran_set_input(zr, *input)))
goto sinput_unlock_and_return; goto sinput_unlock_and_return;
/* Make sure the changes come into effect */ /* Make sure the changes come into effect */
res = wait_grab_pending(zr); res = wait_grab_pending(zr);
sinput_unlock_and_return: sinput_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
break; break;
...@@ -3914,7 +3915,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3914,7 +3915,7 @@ zoran_do_ioctl (struct inode *inode,
memset(cropcap, 0, sizeof(*cropcap)); memset(cropcap, 0, sizeof(*cropcap));
cropcap->type = type; cropcap->type = type;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
(cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
...@@ -3934,7 +3935,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3934,7 +3935,7 @@ zoran_do_ioctl (struct inode *inode,
cropcap->defrect.width = BUZ_MIN_WIDTH; cropcap->defrect.width = BUZ_MIN_WIDTH;
cropcap->defrect.height = BUZ_MIN_HEIGHT; cropcap->defrect.height = BUZ_MIN_HEIGHT;
cropcap_unlock_and_return: cropcap_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
break; break;
...@@ -3950,7 +3951,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3950,7 +3951,7 @@ zoran_do_ioctl (struct inode *inode,
memset(crop, 0, sizeof(*crop)); memset(crop, 0, sizeof(*crop));
crop->type = type; crop->type = type;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
(crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
...@@ -3969,7 +3970,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3969,7 +3970,7 @@ zoran_do_ioctl (struct inode *inode,
crop->c.height = fh->jpg_settings.img_height; crop->c.height = fh->jpg_settings.img_height;
gcrop_unlock_and_return: gcrop_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -3988,7 +3989,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -3988,7 +3989,7 @@ zoran_do_ioctl (struct inode *inode,
ZR_DEVNAME(zr), crop->type, crop->c.left, crop->c.top, ZR_DEVNAME(zr), crop->type, crop->c.left, crop->c.top,
crop->c.width, crop->c.height); crop->c.width, crop->c.height);
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) {
dprintk(1, dprintk(1,
...@@ -4024,7 +4025,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4024,7 +4025,7 @@ zoran_do_ioctl (struct inode *inode,
fh->jpg_settings = settings; fh->jpg_settings = settings;
scrop_unlock_and_return: scrop_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
break; break;
...@@ -4038,7 +4039,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4038,7 +4039,7 @@ zoran_do_ioctl (struct inode *inode,
memset(params, 0, sizeof(*params)); memset(params, 0, sizeof(*params));
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
params->quality = fh->jpg_settings.jpg_comp.quality; params->quality = fh->jpg_settings.jpg_comp.quality;
params->APPn = fh->jpg_settings.jpg_comp.APPn; params->APPn = fh->jpg_settings.jpg_comp.APPn;
...@@ -4053,7 +4054,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4053,7 +4054,7 @@ zoran_do_ioctl (struct inode *inode,
params->jpeg_markers = params->jpeg_markers =
fh->jpg_settings.jpg_comp.jpeg_markers; fh->jpg_settings.jpg_comp.jpeg_markers;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -4074,7 +4075,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4074,7 +4075,7 @@ zoran_do_ioctl (struct inode *inode,
settings.jpg_comp = *params; settings.jpg_comp = *params;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fh->v4l_buffers.active != ZORAN_FREE || if (fh->v4l_buffers.active != ZORAN_FREE ||
fh->jpg_buffers.active != ZORAN_FREE) { fh->jpg_buffers.active != ZORAN_FREE) {
...@@ -4093,7 +4094,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4093,7 +4094,7 @@ zoran_do_ioctl (struct inode *inode,
zoran_v4l2_calc_bufsize(&fh->jpg_settings); zoran_v4l2_calc_bufsize(&fh->jpg_settings);
fh->jpg_settings.jpg_comp = *params = settings.jpg_comp; fh->jpg_settings.jpg_comp = *params = settings.jpg_comp;
sjpegc_unlock_and_return: sjpegc_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return 0; return 0;
} }
...@@ -4127,7 +4128,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4127,7 +4128,7 @@ zoran_do_ioctl (struct inode *inode,
switch (fmt->type) { switch (fmt->type) {
case V4L2_BUF_TYPE_VIDEO_OVERLAY: case V4L2_BUF_TYPE_VIDEO_OVERLAY:
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH) if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH)
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, ...@@ -4138,7 +4139,7 @@ zoran_do_ioctl (struct inode *inode,
if (fmt->fmt.win.w.height < BUZ_MIN_HEIGHT) if (fmt->fmt.win.w.height < BUZ_MIN_HEIGHT)
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; break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE: case V4L2_BUF_TYPE_VIDEO_CAPTURE:
...@@ -4146,7 +4147,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4146,7 +4147,7 @@ zoran_do_ioctl (struct inode *inode,
if (fmt->fmt.pix.bytesperline > 0) if (fmt->fmt.pix.bytesperline > 0)
return -EINVAL; return -EINVAL;
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) {
settings = fh->jpg_settings; settings = fh->jpg_settings;
...@@ -4229,7 +4230,7 @@ zoran_do_ioctl (struct inode *inode, ...@@ -4229,7 +4230,7 @@ zoran_do_ioctl (struct inode *inode,
goto tryfmt_unlock_and_return; goto tryfmt_unlock_and_return;
} }
tryfmt_unlock_and_return: tryfmt_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
break; break;
...@@ -4280,7 +4281,7 @@ zoran_poll (struct file *file, ...@@ -4280,7 +4281,7 @@ zoran_poll (struct file *file,
* if no buffers queued or so, return POLLNVAL * if no buffers queued or so, return POLLNVAL
*/ */
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
switch (fh->map_mode) { switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW: case ZORAN_MAP_MODE_RAW:
...@@ -4329,7 +4330,7 @@ zoran_poll (struct file *file, ...@@ -4329,7 +4330,7 @@ zoran_poll (struct file *file,
} }
poll_unlock_and_return: poll_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
return res; return res;
} }
...@@ -4385,7 +4386,7 @@ zoran_vm_close (struct vm_area_struct *vma) ...@@ -4385,7 +4386,7 @@ zoran_vm_close (struct vm_area_struct *vma)
if (fh->jpg_buffers.buffer[i].map) if (fh->jpg_buffers.buffer[i].map)
break; break;
if (i == fh->jpg_buffers.num_buffers) { if (i == fh->jpg_buffers.num_buffers) {
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.active != ZORAN_FREE) { if (fh->jpg_buffers.active != ZORAN_FREE) {
jpg_qbuf(file, -1, zr->codec_mode); jpg_qbuf(file, -1, zr->codec_mode);
...@@ -4398,7 +4399,7 @@ zoran_vm_close (struct vm_area_struct *vma) ...@@ -4398,7 +4399,7 @@ zoran_vm_close (struct vm_area_struct *vma)
fh->jpg_buffers.allocated = 0; fh->jpg_buffers.allocated = 0;
fh->jpg_buffers.ready_to_be_freed = 1; fh->jpg_buffers.ready_to_be_freed = 1;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
} }
break; break;
...@@ -4421,7 +4422,7 @@ zoran_vm_close (struct vm_area_struct *vma) ...@@ -4421,7 +4422,7 @@ zoran_vm_close (struct vm_area_struct *vma)
if (fh->v4l_buffers.buffer[i].map) if (fh->v4l_buffers.buffer[i].map)
break; break;
if (i == fh->v4l_buffers.num_buffers) { if (i == fh->v4l_buffers.num_buffers) {
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
if (fh->v4l_buffers.active != ZORAN_FREE) { if (fh->v4l_buffers.active != ZORAN_FREE) {
zr36057_set_memgrab(zr, 0); zr36057_set_memgrab(zr, 0);
...@@ -4434,7 +4435,7 @@ zoran_vm_close (struct vm_area_struct *vma) ...@@ -4434,7 +4435,7 @@ zoran_vm_close (struct vm_area_struct *vma)
fh->v4l_buffers.allocated = 0; fh->v4l_buffers.allocated = 0;
fh->v4l_buffers.ready_to_be_freed = 1; fh->v4l_buffers.ready_to_be_freed = 1;
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
} }
break; break;
...@@ -4489,7 +4490,7 @@ zoran_mmap (struct file *file, ...@@ -4489,7 +4490,7 @@ zoran_mmap (struct file *file,
case ZORAN_MAP_MODE_JPG_PLAY: case ZORAN_MAP_MODE_JPG_PLAY:
/* lock */ /* lock */
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
/* Map the MJPEG buffers */ /* Map the MJPEG buffers */
if (!fh->jpg_buffers.allocated) { if (!fh->jpg_buffers.allocated) {
...@@ -4579,13 +4580,13 @@ zoran_mmap (struct file *file, ...@@ -4579,13 +4580,13 @@ zoran_mmap (struct file *file,
} }
jpg_mmap_unlock_and_return: jpg_mmap_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
break; break;
case ZORAN_MAP_MODE_RAW: case ZORAN_MAP_MODE_RAW:
down(&zr->resource_lock); mutex_lock(&zr->resource_lock);
/* Map the V4L buffers */ /* Map the V4L buffers */
if (!fh->v4l_buffers.allocated) { if (!fh->v4l_buffers.allocated) {
...@@ -4657,7 +4658,7 @@ zoran_mmap (struct file *file, ...@@ -4657,7 +4658,7 @@ zoran_mmap (struct file *file,
break; break;
} }
v4l_mmap_unlock_and_return: v4l_mmap_unlock_and_return:
up(&zr->resource_lock); mutex_unlock(&zr->resource_lock);
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册