diff options
Diffstat (limited to 'drivers/media/video/zoran_driver.c')
-rw-r--r-- | drivers/media/video/zoran_driver.c | 227 |
1 files changed, 114 insertions, 113 deletions
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 @@ | |||
81 | 81 | ||
82 | #include <linux/video_decoder.h> | 82 | #include <linux/video_decoder.h> |
83 | #include <linux/video_encoder.h> | 83 | #include <linux/video_encoder.h> |
84 | #include <linux/mutex.h> | ||
84 | #include "zoran.h" | 85 | #include "zoran.h" |
85 | #include "zoran_device.h" | 86 | #include "zoran_device.h" |
86 | #include "zoran_card.h" | 87 | #include "zoran_card.h" |
@@ -1292,7 +1293,7 @@ zoran_open (struct inode *inode, | |||
1292 | 1293 | ||
1293 | /* see fs/device.c - the kernel already locks during open(), | 1294 | /* see fs/device.c - the kernel already locks during open(), |
1294 | * so locking ourselves only causes deadlocks */ | 1295 | * so locking ourselves only causes deadlocks */ |
1295 | /*down(&zr->resource_lock);*/ | 1296 | /*mutex_lock(&zr->resource_lock);*/ |
1296 | 1297 | ||
1297 | if (!zr->decoder) { | 1298 | if (!zr->decoder) { |
1298 | dprintk(1, | 1299 | dprintk(1, |
@@ -1371,7 +1372,7 @@ zoran_open (struct inode *inode, | |||
1371 | if (zr->user++ == 0) | 1372 | if (zr->user++ == 0) |
1372 | first_open = 1; | 1373 | first_open = 1; |
1373 | 1374 | ||
1374 | /*up(&zr->resource_lock);*/ | 1375 | /*mutex_unlock(&zr->resource_lock);*/ |
1375 | 1376 | ||
1376 | /* default setup - TODO: look at flags */ | 1377 | /* default setup - TODO: look at flags */ |
1377 | if (first_open) { /* First device open */ | 1378 | if (first_open) { /* First device open */ |
@@ -1401,7 +1402,7 @@ open_unlock_and_return: | |||
1401 | 1402 | ||
1402 | /* if there's no device found, we didn't obtain the lock either */ | 1403 | /* if there's no device found, we didn't obtain the lock either */ |
1403 | if (zr) { | 1404 | if (zr) { |
1404 | /*up(&zr->resource_lock);*/ | 1405 | /*mutex_unlock(&zr->resource_lock);*/ |
1405 | } | 1406 | } |
1406 | 1407 | ||
1407 | return res; | 1408 | return res; |
@@ -1419,7 +1420,7 @@ zoran_close (struct inode *inode, | |||
1419 | 1420 | ||
1420 | /* kernel locks (fs/device.c), so don't do that ourselves | 1421 | /* kernel locks (fs/device.c), so don't do that ourselves |
1421 | * (prevents deadlocks) */ | 1422 | * (prevents deadlocks) */ |
1422 | /*down(&zr->resource_lock);*/ | 1423 | /*mutex_lock(&zr->resource_lock);*/ |
1423 | 1424 | ||
1424 | zoran_close_end_session(file); | 1425 | zoran_close_end_session(file); |
1425 | 1426 | ||
@@ -1466,7 +1467,7 @@ zoran_close (struct inode *inode, | |||
1466 | } | 1467 | } |
1467 | module_put(THIS_MODULE); | 1468 | module_put(THIS_MODULE); |
1468 | 1469 | ||
1469 | /*up(&zr->resource_lock);*/ | 1470 | /*mutex_unlock(&zr->resource_lock);*/ |
1470 | 1471 | ||
1471 | dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr)); | 1472 | dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr)); |
1472 | 1473 | ||
@@ -2027,14 +2028,14 @@ zoran_do_ioctl (struct inode *inode, | |||
2027 | * but moving the free code outside the munmap() handler fixes | 2028 | * but moving the free code outside the munmap() handler fixes |
2028 | * all this... If someone knows why, please explain me (Ronald) | 2029 | * all this... If someone knows why, please explain me (Ronald) |
2029 | */ | 2030 | */ |
2030 | if (!down_trylock(&zr->resource_lock)) { | 2031 | if (!!mutex_trylock(&zr->resource_lock)) { |
2031 | /* we obtained it! Let's try to free some things */ | 2032 | /* we obtained it! Let's try to free some things */ |
2032 | if (fh->jpg_buffers.ready_to_be_freed) | 2033 | if (fh->jpg_buffers.ready_to_be_freed) |
2033 | jpg_fbuffer_free(file); | 2034 | jpg_fbuffer_free(file); |
2034 | if (fh->v4l_buffers.ready_to_be_freed) | 2035 | if (fh->v4l_buffers.ready_to_be_freed) |
2035 | v4l_fbuffer_free(file); | 2036 | v4l_fbuffer_free(file); |
2036 | 2037 | ||
2037 | up(&zr->resource_lock); | 2038 | mutex_unlock(&zr->resource_lock); |
2038 | } | 2039 | } |
2039 | 2040 | ||
2040 | switch (cmd) { | 2041 | switch (cmd) { |
@@ -2051,12 +2052,12 @@ zoran_do_ioctl (struct inode *inode, | |||
2051 | 2052 | ||
2052 | vcap->channels = zr->card.inputs; | 2053 | vcap->channels = zr->card.inputs; |
2053 | vcap->audios = 0; | 2054 | vcap->audios = 0; |
2054 | down(&zr->resource_lock); | 2055 | mutex_lock(&zr->resource_lock); |
2055 | vcap->maxwidth = BUZ_MAX_WIDTH; | 2056 | vcap->maxwidth = BUZ_MAX_WIDTH; |
2056 | vcap->maxheight = BUZ_MAX_HEIGHT; | 2057 | vcap->maxheight = BUZ_MAX_HEIGHT; |
2057 | vcap->minwidth = BUZ_MIN_WIDTH; | 2058 | vcap->minwidth = BUZ_MIN_WIDTH; |
2058 | vcap->minheight = BUZ_MIN_HEIGHT; | 2059 | vcap->minheight = BUZ_MIN_HEIGHT; |
2059 | up(&zr->resource_lock); | 2060 | mutex_unlock(&zr->resource_lock); |
2060 | 2061 | ||
2061 | return 0; | 2062 | return 0; |
2062 | } | 2063 | } |
@@ -2084,9 +2085,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2084 | vchan->tuners = 0; | 2085 | vchan->tuners = 0; |
2085 | vchan->flags = 0; | 2086 | vchan->flags = 0; |
2086 | vchan->type = VIDEO_TYPE_CAMERA; | 2087 | vchan->type = VIDEO_TYPE_CAMERA; |
2087 | down(&zr->resource_lock); | 2088 | mutex_lock(&zr->resource_lock); |
2088 | vchan->norm = zr->norm; | 2089 | vchan->norm = zr->norm; |
2089 | up(&zr->resource_lock); | 2090 | mutex_unlock(&zr->resource_lock); |
2090 | vchan->channel = channel; | 2091 | vchan->channel = channel; |
2091 | 2092 | ||
2092 | return 0; | 2093 | return 0; |
@@ -2113,7 +2114,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2113 | "%s: VIDIOCSCHAN - channel=%d, norm=%d\n", | 2114 | "%s: VIDIOCSCHAN - channel=%d, norm=%d\n", |
2114 | ZR_DEVNAME(zr), vchan->channel, vchan->norm); | 2115 | ZR_DEVNAME(zr), vchan->channel, vchan->norm); |
2115 | 2116 | ||
2116 | down(&zr->resource_lock); | 2117 | mutex_lock(&zr->resource_lock); |
2117 | if ((res = zoran_set_input(zr, vchan->channel))) | 2118 | if ((res = zoran_set_input(zr, vchan->channel))) |
2118 | goto schan_unlock_and_return; | 2119 | goto schan_unlock_and_return; |
2119 | if ((res = zoran_set_norm(zr, vchan->norm))) | 2120 | if ((res = zoran_set_norm(zr, vchan->norm))) |
@@ -2122,7 +2123,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2122 | /* Make sure the changes come into effect */ | 2123 | /* Make sure the changes come into effect */ |
2123 | res = wait_grab_pending(zr); | 2124 | res = wait_grab_pending(zr); |
2124 | schan_unlock_and_return: | 2125 | schan_unlock_and_return: |
2125 | up(&zr->resource_lock); | 2126 | mutex_unlock(&zr->resource_lock); |
2126 | return res; | 2127 | return res; |
2127 | } | 2128 | } |
2128 | break; | 2129 | break; |
@@ -2134,7 +2135,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2134 | dprintk(3, KERN_DEBUG "%s: VIDIOCGPICT\n", ZR_DEVNAME(zr)); | 2135 | dprintk(3, KERN_DEBUG "%s: VIDIOCGPICT\n", ZR_DEVNAME(zr)); |
2135 | 2136 | ||
2136 | memset(vpict, 0, sizeof(struct video_picture)); | 2137 | memset(vpict, 0, sizeof(struct video_picture)); |
2137 | down(&zr->resource_lock); | 2138 | mutex_lock(&zr->resource_lock); |
2138 | vpict->hue = zr->hue; | 2139 | vpict->hue = zr->hue; |
2139 | vpict->brightness = zr->brightness; | 2140 | vpict->brightness = zr->brightness; |
2140 | vpict->contrast = zr->contrast; | 2141 | vpict->contrast = zr->contrast; |
@@ -2145,7 +2146,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2145 | } else { | 2146 | } else { |
2146 | vpict->depth = 0; | 2147 | vpict->depth = 0; |
2147 | } | 2148 | } |
2148 | up(&zr->resource_lock); | 2149 | mutex_unlock(&zr->resource_lock); |
2149 | 2150 | ||
2150 | return 0; | 2151 | return 0; |
2151 | } | 2152 | } |
@@ -2180,7 +2181,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2180 | return -EINVAL; | 2181 | return -EINVAL; |
2181 | } | 2182 | } |
2182 | 2183 | ||
2183 | down(&zr->resource_lock); | 2184 | mutex_lock(&zr->resource_lock); |
2184 | 2185 | ||
2185 | decoder_command(zr, DECODER_SET_PICTURE, vpict); | 2186 | decoder_command(zr, DECODER_SET_PICTURE, vpict); |
2186 | 2187 | ||
@@ -2191,7 +2192,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2191 | 2192 | ||
2192 | fh->overlay_settings.format = &zoran_formats[i]; | 2193 | fh->overlay_settings.format = &zoran_formats[i]; |
2193 | 2194 | ||
2194 | up(&zr->resource_lock); | 2195 | mutex_unlock(&zr->resource_lock); |
2195 | 2196 | ||
2196 | return 0; | 2197 | return 0; |
2197 | } | 2198 | } |
@@ -2204,9 +2205,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2204 | dprintk(3, KERN_DEBUG "%s: VIDIOCCAPTURE - on=%d\n", | 2205 | dprintk(3, KERN_DEBUG "%s: VIDIOCCAPTURE - on=%d\n", |
2205 | ZR_DEVNAME(zr), *on); | 2206 | ZR_DEVNAME(zr), *on); |
2206 | 2207 | ||
2207 | down(&zr->resource_lock); | 2208 | mutex_lock(&zr->resource_lock); |
2208 | res = setup_overlay(file, *on); | 2209 | res = setup_overlay(file, *on); |
2209 | up(&zr->resource_lock); | 2210 | mutex_unlock(&zr->resource_lock); |
2210 | 2211 | ||
2211 | return res; | 2212 | return res; |
2212 | } | 2213 | } |
@@ -2219,12 +2220,12 @@ zoran_do_ioctl (struct inode *inode, | |||
2219 | dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr)); | 2220 | dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr)); |
2220 | 2221 | ||
2221 | memset(vwin, 0, sizeof(struct video_window)); | 2222 | memset(vwin, 0, sizeof(struct video_window)); |
2222 | down(&zr->resource_lock); | 2223 | mutex_lock(&zr->resource_lock); |
2223 | vwin->x = fh->overlay_settings.x; | 2224 | vwin->x = fh->overlay_settings.x; |
2224 | vwin->y = fh->overlay_settings.y; | 2225 | vwin->y = fh->overlay_settings.y; |
2225 | vwin->width = fh->overlay_settings.width; | 2226 | vwin->width = fh->overlay_settings.width; |
2226 | vwin->height = fh->overlay_settings.height; | 2227 | vwin->height = fh->overlay_settings.height; |
2227 | up(&zr->resource_lock); | 2228 | mutex_unlock(&zr->resource_lock); |
2228 | vwin->clipcount = 0; | 2229 | vwin->clipcount = 0; |
2229 | return 0; | 2230 | return 0; |
2230 | } | 2231 | } |
@@ -2241,12 +2242,12 @@ zoran_do_ioctl (struct inode *inode, | |||
2241 | ZR_DEVNAME(zr), vwin->x, vwin->y, vwin->width, | 2242 | ZR_DEVNAME(zr), vwin->x, vwin->y, vwin->width, |
2242 | vwin->height, vwin->clipcount); | 2243 | vwin->height, vwin->clipcount); |
2243 | 2244 | ||
2244 | down(&zr->resource_lock); | 2245 | mutex_lock(&zr->resource_lock); |
2245 | res = | 2246 | res = |
2246 | setup_window(file, vwin->x, vwin->y, vwin->width, | 2247 | setup_window(file, vwin->x, vwin->y, vwin->width, |
2247 | vwin->height, vwin->clips, | 2248 | vwin->height, vwin->clips, |
2248 | vwin->clipcount, NULL); | 2249 | vwin->clipcount, NULL); |
2249 | up(&zr->resource_lock); | 2250 | mutex_unlock(&zr->resource_lock); |
2250 | 2251 | ||
2251 | return res; | 2252 | return res; |
2252 | } | 2253 | } |
@@ -2258,9 +2259,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2258 | 2259 | ||
2259 | dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr)); | 2260 | dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr)); |
2260 | 2261 | ||
2261 | down(&zr->resource_lock); | 2262 | mutex_lock(&zr->resource_lock); |
2262 | *vbuf = zr->buffer; | 2263 | *vbuf = zr->buffer; |
2263 | up(&zr->resource_lock); | 2264 | mutex_unlock(&zr->resource_lock); |
2264 | return 0; | 2265 | return 0; |
2265 | } | 2266 | } |
2266 | break; | 2267 | break; |
@@ -2287,12 +2288,12 @@ zoran_do_ioctl (struct inode *inode, | |||
2287 | return -EINVAL; | 2288 | return -EINVAL; |
2288 | } | 2289 | } |
2289 | 2290 | ||
2290 | down(&zr->resource_lock); | 2291 | mutex_lock(&zr->resource_lock); |
2291 | res = | 2292 | res = |
2292 | setup_fbuffer(file, vbuf->base, &zoran_formats[i], | 2293 | setup_fbuffer(file, vbuf->base, &zoran_formats[i], |
2293 | vbuf->width, vbuf->height, | 2294 | vbuf->width, vbuf->height, |
2294 | vbuf->bytesperline); | 2295 | vbuf->bytesperline); |
2295 | up(&zr->resource_lock); | 2296 | mutex_unlock(&zr->resource_lock); |
2296 | 2297 | ||
2297 | return res; | 2298 | return res; |
2298 | } | 2299 | } |
@@ -2305,9 +2306,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2305 | dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n", | 2306 | dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n", |
2306 | ZR_DEVNAME(zr), *frame); | 2307 | ZR_DEVNAME(zr), *frame); |
2307 | 2308 | ||
2308 | down(&zr->resource_lock); | 2309 | mutex_lock(&zr->resource_lock); |
2309 | res = v4l_sync(file, *frame); | 2310 | res = v4l_sync(file, *frame); |
2310 | up(&zr->resource_lock); | 2311 | mutex_unlock(&zr->resource_lock); |
2311 | if (!res) | 2312 | if (!res) |
2312 | zr->v4l_sync_tail++; | 2313 | zr->v4l_sync_tail++; |
2313 | return res; | 2314 | return res; |
@@ -2325,9 +2326,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2325 | ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height, | 2326 | ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height, |
2326 | vmap->format); | 2327 | vmap->format); |
2327 | 2328 | ||
2328 | down(&zr->resource_lock); | 2329 | mutex_lock(&zr->resource_lock); |
2329 | res = v4l_grab(file, vmap); | 2330 | res = v4l_grab(file, vmap); |
2330 | up(&zr->resource_lock); | 2331 | mutex_unlock(&zr->resource_lock); |
2331 | return res; | 2332 | return res; |
2332 | } | 2333 | } |
2333 | break; | 2334 | break; |
@@ -2348,7 +2349,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2348 | i * fh->v4l_buffers.buffer_size; | 2349 | i * fh->v4l_buffers.buffer_size; |
2349 | } | 2350 | } |
2350 | 2351 | ||
2351 | down(&zr->resource_lock); | 2352 | mutex_lock(&zr->resource_lock); |
2352 | 2353 | ||
2353 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { | 2354 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { |
2354 | dprintk(1, | 2355 | dprintk(1, |
@@ -2367,7 +2368,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2367 | /* The next mmap will map the V4L buffers */ | 2368 | /* The next mmap will map the V4L buffers */ |
2368 | fh->map_mode = ZORAN_MAP_MODE_RAW; | 2369 | fh->map_mode = ZORAN_MAP_MODE_RAW; |
2369 | v4l1reqbuf_unlock_and_return: | 2370 | v4l1reqbuf_unlock_and_return: |
2370 | up(&zr->resource_lock); | 2371 | mutex_unlock(&zr->resource_lock); |
2371 | 2372 | ||
2372 | return res; | 2373 | return res; |
2373 | } | 2374 | } |
@@ -2421,7 +2422,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2421 | bparams->major_version = MAJOR_VERSION; | 2422 | bparams->major_version = MAJOR_VERSION; |
2422 | bparams->minor_version = MINOR_VERSION; | 2423 | bparams->minor_version = MINOR_VERSION; |
2423 | 2424 | ||
2424 | down(&zr->resource_lock); | 2425 | mutex_lock(&zr->resource_lock); |
2425 | 2426 | ||
2426 | bparams->norm = zr->norm; | 2427 | bparams->norm = zr->norm; |
2427 | bparams->input = zr->input; | 2428 | bparams->input = zr->input; |
@@ -2450,7 +2451,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2450 | bparams->jpeg_markers = | 2451 | bparams->jpeg_markers = |
2451 | fh->jpg_settings.jpg_comp.jpeg_markers; | 2452 | fh->jpg_settings.jpg_comp.jpeg_markers; |
2452 | 2453 | ||
2453 | up(&zr->resource_lock); | 2454 | mutex_unlock(&zr->resource_lock); |
2454 | 2455 | ||
2455 | bparams->VFIFO_FB = 0; | 2456 | bparams->VFIFO_FB = 0; |
2456 | 2457 | ||
@@ -2486,7 +2487,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2486 | sizeof(bparams->COM_data)); | 2487 | sizeof(bparams->COM_data)); |
2487 | settings.jpg_comp.jpeg_markers = bparams->jpeg_markers; | 2488 | settings.jpg_comp.jpeg_markers = bparams->jpeg_markers; |
2488 | 2489 | ||
2489 | down(&zr->resource_lock); | 2490 | mutex_lock(&zr->resource_lock); |
2490 | 2491 | ||
2491 | if (zr->codec_mode != BUZ_MODE_IDLE) { | 2492 | if (zr->codec_mode != BUZ_MODE_IDLE) { |
2492 | dprintk(1, | 2493 | dprintk(1, |
@@ -2506,7 +2507,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2506 | 2507 | ||
2507 | fh->jpg_settings = settings; | 2508 | fh->jpg_settings = settings; |
2508 | sparams_unlock_and_return: | 2509 | sparams_unlock_and_return: |
2509 | up(&zr->resource_lock); | 2510 | mutex_unlock(&zr->resource_lock); |
2510 | 2511 | ||
2511 | return res; | 2512 | return res; |
2512 | } | 2513 | } |
@@ -2538,7 +2539,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2538 | breq->size > MAX_KMALLOC_MEM) | 2539 | breq->size > MAX_KMALLOC_MEM) |
2539 | breq->size = MAX_KMALLOC_MEM; | 2540 | breq->size = MAX_KMALLOC_MEM; |
2540 | 2541 | ||
2541 | down(&zr->resource_lock); | 2542 | mutex_lock(&zr->resource_lock); |
2542 | 2543 | ||
2543 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { | 2544 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { |
2544 | dprintk(1, | 2545 | dprintk(1, |
@@ -2561,7 +2562,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2561 | * also be *_PLAY, but it doesn't matter here */ | 2562 | * also be *_PLAY, but it doesn't matter here */ |
2562 | fh->map_mode = ZORAN_MAP_MODE_JPG_REC; | 2563 | fh->map_mode = ZORAN_MAP_MODE_JPG_REC; |
2563 | jpgreqbuf_unlock_and_return: | 2564 | jpgreqbuf_unlock_and_return: |
2564 | up(&zr->resource_lock); | 2565 | mutex_unlock(&zr->resource_lock); |
2565 | 2566 | ||
2566 | return res; | 2567 | return res; |
2567 | } | 2568 | } |
@@ -2574,9 +2575,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2574 | dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_CAPT - frame=%d\n", | 2575 | dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_CAPT - frame=%d\n", |
2575 | ZR_DEVNAME(zr), *frame); | 2576 | ZR_DEVNAME(zr), *frame); |
2576 | 2577 | ||
2577 | down(&zr->resource_lock); | 2578 | mutex_lock(&zr->resource_lock); |
2578 | res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_COMPRESS); | 2579 | res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_COMPRESS); |
2579 | up(&zr->resource_lock); | 2580 | mutex_unlock(&zr->resource_lock); |
2580 | 2581 | ||
2581 | return res; | 2582 | return res; |
2582 | } | 2583 | } |
@@ -2589,9 +2590,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2589 | dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_PLAY - frame=%d\n", | 2590 | dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_PLAY - frame=%d\n", |
2590 | ZR_DEVNAME(zr), *frame); | 2591 | ZR_DEVNAME(zr), *frame); |
2591 | 2592 | ||
2592 | down(&zr->resource_lock); | 2593 | mutex_lock(&zr->resource_lock); |
2593 | res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_DECOMPRESS); | 2594 | res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_DECOMPRESS); |
2594 | up(&zr->resource_lock); | 2595 | mutex_unlock(&zr->resource_lock); |
2595 | 2596 | ||
2596 | return res; | 2597 | return res; |
2597 | } | 2598 | } |
@@ -2604,9 +2605,9 @@ zoran_do_ioctl (struct inode *inode, | |||
2604 | 2605 | ||
2605 | dprintk(3, KERN_DEBUG "%s: BUZIOC_SYNC\n", ZR_DEVNAME(zr)); | 2606 | dprintk(3, KERN_DEBUG "%s: BUZIOC_SYNC\n", ZR_DEVNAME(zr)); |
2606 | 2607 | ||
2607 | down(&zr->resource_lock); | 2608 | mutex_lock(&zr->resource_lock); |
2608 | res = jpg_sync(file, bsync); | 2609 | res = jpg_sync(file, bsync); |
2609 | up(&zr->resource_lock); | 2610 | mutex_unlock(&zr->resource_lock); |
2610 | 2611 | ||
2611 | return res; | 2612 | return res; |
2612 | } | 2613 | } |
@@ -2630,7 +2631,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2630 | input = zr->card.input[bstat->input].muxsel; | 2631 | input = zr->card.input[bstat->input].muxsel; |
2631 | norm = VIDEO_MODE_AUTO; | 2632 | norm = VIDEO_MODE_AUTO; |
2632 | 2633 | ||
2633 | down(&zr->resource_lock); | 2634 | mutex_lock(&zr->resource_lock); |
2634 | 2635 | ||
2635 | if (zr->codec_mode != BUZ_MODE_IDLE) { | 2636 | if (zr->codec_mode != BUZ_MODE_IDLE) { |
2636 | dprintk(1, | 2637 | dprintk(1, |
@@ -2655,7 +2656,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2655 | decoder_command(zr, DECODER_SET_INPUT, &input); | 2656 | decoder_command(zr, DECODER_SET_INPUT, &input); |
2656 | decoder_command(zr, DECODER_SET_NORM, &zr->norm); | 2657 | decoder_command(zr, DECODER_SET_NORM, &zr->norm); |
2657 | gstat_unlock_and_return: | 2658 | gstat_unlock_and_return: |
2658 | up(&zr->resource_lock); | 2659 | mutex_unlock(&zr->resource_lock); |
2659 | 2660 | ||
2660 | if (!res) { | 2661 | if (!res) { |
2661 | bstat->signal = | 2662 | bstat->signal = |
@@ -2763,7 +2764,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2763 | switch (fmt->type) { | 2764 | switch (fmt->type) { |
2764 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 2765 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
2765 | 2766 | ||
2766 | down(&zr->resource_lock); | 2767 | mutex_lock(&zr->resource_lock); |
2767 | 2768 | ||
2768 | fmt->fmt.win.w.left = fh->overlay_settings.x; | 2769 | fmt->fmt.win.w.left = fh->overlay_settings.x; |
2769 | fmt->fmt.win.w.top = fh->overlay_settings.y; | 2770 | fmt->fmt.win.w.top = fh->overlay_settings.y; |
@@ -2776,14 +2777,14 @@ zoran_do_ioctl (struct inode *inode, | |||
2776 | else | 2777 | else |
2777 | fmt->fmt.win.field = V4L2_FIELD_TOP; | 2778 | fmt->fmt.win.field = V4L2_FIELD_TOP; |
2778 | 2779 | ||
2779 | up(&zr->resource_lock); | 2780 | mutex_unlock(&zr->resource_lock); |
2780 | 2781 | ||
2781 | break; | 2782 | break; |
2782 | 2783 | ||
2783 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 2784 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
2784 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 2785 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
2785 | 2786 | ||
2786 | down(&zr->resource_lock); | 2787 | mutex_lock(&zr->resource_lock); |
2787 | 2788 | ||
2788 | if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && | 2789 | if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && |
2789 | fh->map_mode == ZORAN_MAP_MODE_RAW) { | 2790 | fh->map_mode == ZORAN_MAP_MODE_RAW) { |
@@ -2837,7 +2838,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2837 | V4L2_COLORSPACE_SMPTE170M; | 2838 | V4L2_COLORSPACE_SMPTE170M; |
2838 | } | 2839 | } |
2839 | 2840 | ||
2840 | up(&zr->resource_lock); | 2841 | mutex_unlock(&zr->resource_lock); |
2841 | 2842 | ||
2842 | break; | 2843 | break; |
2843 | 2844 | ||
@@ -2870,7 +2871,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2870 | fmt->fmt.win.w.height, | 2871 | fmt->fmt.win.w.height, |
2871 | fmt->fmt.win.clipcount, | 2872 | fmt->fmt.win.clipcount, |
2872 | fmt->fmt.win.bitmap); | 2873 | fmt->fmt.win.bitmap); |
2873 | down(&zr->resource_lock); | 2874 | mutex_lock(&zr->resource_lock); |
2874 | res = | 2875 | res = |
2875 | setup_window(file, fmt->fmt.win.w.left, | 2876 | setup_window(file, fmt->fmt.win.w.left, |
2876 | fmt->fmt.win.w.top, | 2877 | fmt->fmt.win.w.top, |
@@ -2880,7 +2881,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2880 | fmt->fmt.win.clips, | 2881 | fmt->fmt.win.clips, |
2881 | fmt->fmt.win.clipcount, | 2882 | fmt->fmt.win.clipcount, |
2882 | fmt->fmt.win.bitmap); | 2883 | fmt->fmt.win.bitmap); |
2883 | up(&zr->resource_lock); | 2884 | mutex_unlock(&zr->resource_lock); |
2884 | return res; | 2885 | return res; |
2885 | break; | 2886 | break; |
2886 | 2887 | ||
@@ -2917,7 +2918,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2917 | } | 2918 | } |
2918 | 2919 | ||
2919 | if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { | 2920 | if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { |
2920 | down(&zr->resource_lock); | 2921 | mutex_lock(&zr->resource_lock); |
2921 | 2922 | ||
2922 | settings = fh->jpg_settings; | 2923 | settings = fh->jpg_settings; |
2923 | 2924 | ||
@@ -2995,7 +2996,7 @@ zoran_do_ioctl (struct inode *inode, | |||
2995 | ZORAN_MAP_MODE_JPG_REC : | 2996 | ZORAN_MAP_MODE_JPG_REC : |
2996 | ZORAN_MAP_MODE_JPG_PLAY; | 2997 | ZORAN_MAP_MODE_JPG_PLAY; |
2997 | sfmtjpg_unlock_and_return: | 2998 | sfmtjpg_unlock_and_return: |
2998 | up(&zr->resource_lock); | 2999 | mutex_unlock(&zr->resource_lock); |
2999 | } else { | 3000 | } else { |
3000 | for (i = 0; i < zoran_num_formats; i++) | 3001 | for (i = 0; i < zoran_num_formats; i++) |
3001 | if (fmt->fmt.pix.pixelformat == | 3002 | if (fmt->fmt.pix.pixelformat == |
@@ -3010,7 +3011,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3010 | (char *) &printformat); | 3011 | (char *) &printformat); |
3011 | return -EINVAL; | 3012 | return -EINVAL; |
3012 | } | 3013 | } |
3013 | down(&zr->resource_lock); | 3014 | mutex_lock(&zr->resource_lock); |
3014 | if (fh->jpg_buffers.allocated || | 3015 | if (fh->jpg_buffers.allocated || |
3015 | (fh->v4l_buffers.allocated && | 3016 | (fh->v4l_buffers.allocated && |
3016 | fh->v4l_buffers.active != | 3017 | fh->v4l_buffers.active != |
@@ -3052,7 +3053,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3052 | 3053 | ||
3053 | fh->map_mode = ZORAN_MAP_MODE_RAW; | 3054 | fh->map_mode = ZORAN_MAP_MODE_RAW; |
3054 | sfmtv4l_unlock_and_return: | 3055 | sfmtv4l_unlock_and_return: |
3055 | up(&zr->resource_lock); | 3056 | mutex_unlock(&zr->resource_lock); |
3056 | } | 3057 | } |
3057 | 3058 | ||
3058 | break; | 3059 | break; |
@@ -3077,7 +3078,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3077 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_FBUF\n", ZR_DEVNAME(zr)); | 3078 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_FBUF\n", ZR_DEVNAME(zr)); |
3078 | 3079 | ||
3079 | memset(fb, 0, sizeof(*fb)); | 3080 | memset(fb, 0, sizeof(*fb)); |
3080 | down(&zr->resource_lock); | 3081 | mutex_lock(&zr->resource_lock); |
3081 | fb->base = zr->buffer.base; | 3082 | fb->base = zr->buffer.base; |
3082 | fb->fmt.width = zr->buffer.width; | 3083 | fb->fmt.width = zr->buffer.width; |
3083 | fb->fmt.height = zr->buffer.height; | 3084 | fb->fmt.height = zr->buffer.height; |
@@ -3086,7 +3087,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3086 | fh->overlay_settings.format->fourcc; | 3087 | fh->overlay_settings.format->fourcc; |
3087 | } | 3088 | } |
3088 | fb->fmt.bytesperline = zr->buffer.bytesperline; | 3089 | fb->fmt.bytesperline = zr->buffer.bytesperline; |
3089 | up(&zr->resource_lock); | 3090 | mutex_unlock(&zr->resource_lock); |
3090 | fb->fmt.colorspace = V4L2_COLORSPACE_SRGB; | 3091 | fb->fmt.colorspace = V4L2_COLORSPACE_SRGB; |
3091 | fb->fmt.field = V4L2_FIELD_INTERLACED; | 3092 | fb->fmt.field = V4L2_FIELD_INTERLACED; |
3092 | fb->flags = V4L2_FBUF_FLAG_OVERLAY; | 3093 | fb->flags = V4L2_FBUF_FLAG_OVERLAY; |
@@ -3121,12 +3122,12 @@ zoran_do_ioctl (struct inode *inode, | |||
3121 | return -EINVAL; | 3122 | return -EINVAL; |
3122 | } | 3123 | } |
3123 | 3124 | ||
3124 | down(&zr->resource_lock); | 3125 | mutex_lock(&zr->resource_lock); |
3125 | res = | 3126 | res = |
3126 | setup_fbuffer(file, fb->base, &zoran_formats[i], | 3127 | setup_fbuffer(file, fb->base, &zoran_formats[i], |
3127 | fb->fmt.width, fb->fmt.height, | 3128 | fb->fmt.width, fb->fmt.height, |
3128 | fb->fmt.bytesperline); | 3129 | fb->fmt.bytesperline); |
3129 | up(&zr->resource_lock); | 3130 | mutex_unlock(&zr->resource_lock); |
3130 | 3131 | ||
3131 | return res; | 3132 | return res; |
3132 | } | 3133 | } |
@@ -3139,9 +3140,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3139 | dprintk(3, KERN_DEBUG "%s: VIDIOC_PREVIEW - on=%d\n", | 3140 | dprintk(3, KERN_DEBUG "%s: VIDIOC_PREVIEW - on=%d\n", |
3140 | ZR_DEVNAME(zr), *on); | 3141 | ZR_DEVNAME(zr), *on); |
3141 | 3142 | ||
3142 | down(&zr->resource_lock); | 3143 | mutex_lock(&zr->resource_lock); |
3143 | res = setup_overlay(file, *on); | 3144 | res = setup_overlay(file, *on); |
3144 | up(&zr->resource_lock); | 3145 | mutex_unlock(&zr->resource_lock); |
3145 | 3146 | ||
3146 | return res; | 3147 | return res; |
3147 | } | 3148 | } |
@@ -3163,7 +3164,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3163 | return -EINVAL; | 3164 | return -EINVAL; |
3164 | } | 3165 | } |
3165 | 3166 | ||
3166 | down(&zr->resource_lock); | 3167 | mutex_lock(&zr->resource_lock); |
3167 | 3168 | ||
3168 | if (fh->v4l_buffers.allocated || fh->jpg_buffers.allocated) { | 3169 | if (fh->v4l_buffers.allocated || fh->jpg_buffers.allocated) { |
3169 | dprintk(1, | 3170 | dprintk(1, |
@@ -3224,7 +3225,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3224 | goto v4l2reqbuf_unlock_and_return; | 3225 | goto v4l2reqbuf_unlock_and_return; |
3225 | } | 3226 | } |
3226 | v4l2reqbuf_unlock_and_return: | 3227 | v4l2reqbuf_unlock_and_return: |
3227 | up(&zr->resource_lock); | 3228 | mutex_unlock(&zr->resource_lock); |
3228 | 3229 | ||
3229 | return 0; | 3230 | return 0; |
3230 | } | 3231 | } |
@@ -3245,9 +3246,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3245 | buf->type = type; | 3246 | buf->type = type; |
3246 | buf->index = index; | 3247 | buf->index = index; |
3247 | 3248 | ||
3248 | down(&zr->resource_lock); | 3249 | mutex_lock(&zr->resource_lock); |
3249 | res = zoran_v4l2_buffer_status(file, buf, buf->index); | 3250 | res = zoran_v4l2_buffer_status(file, buf, buf->index); |
3250 | up(&zr->resource_lock); | 3251 | mutex_unlock(&zr->resource_lock); |
3251 | 3252 | ||
3252 | return res; | 3253 | return res; |
3253 | } | 3254 | } |
@@ -3262,7 +3263,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3262 | KERN_DEBUG "%s: VIDIOC_QBUF - type=%d, index=%d\n", | 3263 | KERN_DEBUG "%s: VIDIOC_QBUF - type=%d, index=%d\n", |
3263 | ZR_DEVNAME(zr), buf->type, buf->index); | 3264 | ZR_DEVNAME(zr), buf->type, buf->index); |
3264 | 3265 | ||
3265 | down(&zr->resource_lock); | 3266 | mutex_lock(&zr->resource_lock); |
3266 | 3267 | ||
3267 | switch (fh->map_mode) { | 3268 | switch (fh->map_mode) { |
3268 | case ZORAN_MAP_MODE_RAW: | 3269 | case ZORAN_MAP_MODE_RAW: |
@@ -3322,7 +3323,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3322 | goto qbuf_unlock_and_return; | 3323 | goto qbuf_unlock_and_return; |
3323 | } | 3324 | } |
3324 | qbuf_unlock_and_return: | 3325 | qbuf_unlock_and_return: |
3325 | up(&zr->resource_lock); | 3326 | mutex_unlock(&zr->resource_lock); |
3326 | 3327 | ||
3327 | return res; | 3328 | return res; |
3328 | } | 3329 | } |
@@ -3336,7 +3337,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3336 | dprintk(3, KERN_DEBUG "%s: VIDIOC_DQBUF - type=%d\n", | 3337 | dprintk(3, KERN_DEBUG "%s: VIDIOC_DQBUF - type=%d\n", |
3337 | ZR_DEVNAME(zr), buf->type); | 3338 | ZR_DEVNAME(zr), buf->type); |
3338 | 3339 | ||
3339 | down(&zr->resource_lock); | 3340 | mutex_lock(&zr->resource_lock); |
3340 | 3341 | ||
3341 | switch (fh->map_mode) { | 3342 | switch (fh->map_mode) { |
3342 | case ZORAN_MAP_MODE_RAW: | 3343 | case ZORAN_MAP_MODE_RAW: |
@@ -3410,7 +3411,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3410 | goto dqbuf_unlock_and_return; | 3411 | goto dqbuf_unlock_and_return; |
3411 | } | 3412 | } |
3412 | dqbuf_unlock_and_return: | 3413 | dqbuf_unlock_and_return: |
3413 | up(&zr->resource_lock); | 3414 | mutex_unlock(&zr->resource_lock); |
3414 | 3415 | ||
3415 | return res; | 3416 | return res; |
3416 | } | 3417 | } |
@@ -3422,7 +3423,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3422 | 3423 | ||
3423 | dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMON\n", ZR_DEVNAME(zr)); | 3424 | dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMON\n", ZR_DEVNAME(zr)); |
3424 | 3425 | ||
3425 | down(&zr->resource_lock); | 3426 | mutex_lock(&zr->resource_lock); |
3426 | 3427 | ||
3427 | switch (fh->map_mode) { | 3428 | switch (fh->map_mode) { |
3428 | case ZORAN_MAP_MODE_RAW: /* raw capture */ | 3429 | case ZORAN_MAP_MODE_RAW: /* raw capture */ |
@@ -3470,7 +3471,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3470 | goto strmon_unlock_and_return; | 3471 | goto strmon_unlock_and_return; |
3471 | } | 3472 | } |
3472 | strmon_unlock_and_return: | 3473 | strmon_unlock_and_return: |
3473 | up(&zr->resource_lock); | 3474 | mutex_unlock(&zr->resource_lock); |
3474 | 3475 | ||
3475 | return res; | 3476 | return res; |
3476 | } | 3477 | } |
@@ -3482,7 +3483,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3482 | 3483 | ||
3483 | dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMOFF\n", ZR_DEVNAME(zr)); | 3484 | dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMOFF\n", ZR_DEVNAME(zr)); |
3484 | 3485 | ||
3485 | down(&zr->resource_lock); | 3486 | mutex_lock(&zr->resource_lock); |
3486 | 3487 | ||
3487 | switch (fh->map_mode) { | 3488 | switch (fh->map_mode) { |
3488 | case ZORAN_MAP_MODE_RAW: /* raw capture */ | 3489 | case ZORAN_MAP_MODE_RAW: /* raw capture */ |
@@ -3540,7 +3541,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3540 | goto strmoff_unlock_and_return; | 3541 | goto strmoff_unlock_and_return; |
3541 | } | 3542 | } |
3542 | strmoff_unlock_and_return: | 3543 | strmoff_unlock_and_return: |
3543 | up(&zr->resource_lock); | 3544 | mutex_unlock(&zr->resource_lock); |
3544 | 3545 | ||
3545 | return res; | 3546 | return res; |
3546 | } | 3547 | } |
@@ -3600,7 +3601,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3600 | ctrl->id > V4L2_CID_HUE) | 3601 | ctrl->id > V4L2_CID_HUE) |
3601 | return -EINVAL; | 3602 | return -EINVAL; |
3602 | 3603 | ||
3603 | down(&zr->resource_lock); | 3604 | mutex_lock(&zr->resource_lock); |
3604 | switch (ctrl->id) { | 3605 | switch (ctrl->id) { |
3605 | case V4L2_CID_BRIGHTNESS: | 3606 | case V4L2_CID_BRIGHTNESS: |
3606 | ctrl->value = zr->brightness; | 3607 | ctrl->value = zr->brightness; |
@@ -3615,7 +3616,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3615 | ctrl->value = zr->hue; | 3616 | ctrl->value = zr->hue; |
3616 | break; | 3617 | break; |
3617 | } | 3618 | } |
3618 | up(&zr->resource_lock); | 3619 | mutex_unlock(&zr->resource_lock); |
3619 | 3620 | ||
3620 | return 0; | 3621 | return 0; |
3621 | } | 3622 | } |
@@ -3642,7 +3643,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3642 | return -EINVAL; | 3643 | return -EINVAL; |
3643 | } | 3644 | } |
3644 | 3645 | ||
3645 | down(&zr->resource_lock); | 3646 | mutex_lock(&zr->resource_lock); |
3646 | switch (ctrl->id) { | 3647 | switch (ctrl->id) { |
3647 | case V4L2_CID_BRIGHTNESS: | 3648 | case V4L2_CID_BRIGHTNESS: |
3648 | zr->brightness = ctrl->value; | 3649 | zr->brightness = ctrl->value; |
@@ -3664,7 +3665,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3664 | 3665 | ||
3665 | decoder_command(zr, DECODER_SET_PICTURE, &pict); | 3666 | decoder_command(zr, DECODER_SET_PICTURE, &pict); |
3666 | 3667 | ||
3667 | up(&zr->resource_lock); | 3668 | mutex_unlock(&zr->resource_lock); |
3668 | 3669 | ||
3669 | return 0; | 3670 | return 0; |
3670 | } | 3671 | } |
@@ -3732,9 +3733,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3732 | 3733 | ||
3733 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr)); | 3734 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr)); |
3734 | 3735 | ||
3735 | down(&zr->resource_lock); | 3736 | mutex_lock(&zr->resource_lock); |
3736 | norm = zr->norm; | 3737 | norm = zr->norm; |
3737 | up(&zr->resource_lock); | 3738 | mutex_unlock(&zr->resource_lock); |
3738 | 3739 | ||
3739 | switch (norm) { | 3740 | switch (norm) { |
3740 | case VIDEO_MODE_PAL: | 3741 | case VIDEO_MODE_PAL: |
@@ -3776,13 +3777,13 @@ zoran_do_ioctl (struct inode *inode, | |||
3776 | return -EINVAL; | 3777 | return -EINVAL; |
3777 | } | 3778 | } |
3778 | 3779 | ||
3779 | down(&zr->resource_lock); | 3780 | mutex_lock(&zr->resource_lock); |
3780 | if ((res = zoran_set_norm(zr, norm))) | 3781 | if ((res = zoran_set_norm(zr, norm))) |
3781 | goto sstd_unlock_and_return; | 3782 | goto sstd_unlock_and_return; |
3782 | 3783 | ||
3783 | res = wait_grab_pending(zr); | 3784 | res = wait_grab_pending(zr); |
3784 | sstd_unlock_and_return: | 3785 | sstd_unlock_and_return: |
3785 | up(&zr->resource_lock); | 3786 | mutex_unlock(&zr->resource_lock); |
3786 | return res; | 3787 | return res; |
3787 | } | 3788 | } |
3788 | break; | 3789 | break; |
@@ -3809,9 +3810,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3809 | inp->std = V4L2_STD_ALL; | 3810 | inp->std = V4L2_STD_ALL; |
3810 | 3811 | ||
3811 | /* Get status of video decoder */ | 3812 | /* Get status of video decoder */ |
3812 | down(&zr->resource_lock); | 3813 | mutex_lock(&zr->resource_lock); |
3813 | decoder_command(zr, DECODER_GET_STATUS, &status); | 3814 | decoder_command(zr, DECODER_GET_STATUS, &status); |
3814 | up(&zr->resource_lock); | 3815 | mutex_unlock(&zr->resource_lock); |
3815 | 3816 | ||
3816 | if (!(status & DECODER_STATUS_GOOD)) { | 3817 | if (!(status & DECODER_STATUS_GOOD)) { |
3817 | inp->status |= V4L2_IN_ST_NO_POWER; | 3818 | inp->status |= V4L2_IN_ST_NO_POWER; |
@@ -3830,9 +3831,9 @@ zoran_do_ioctl (struct inode *inode, | |||
3830 | 3831 | ||
3831 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr)); | 3832 | dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr)); |
3832 | 3833 | ||
3833 | down(&zr->resource_lock); | 3834 | mutex_lock(&zr->resource_lock); |
3834 | *input = zr->input; | 3835 | *input = zr->input; |
3835 | up(&zr->resource_lock); | 3836 | mutex_unlock(&zr->resource_lock); |
3836 | 3837 | ||
3837 | return 0; | 3838 | return 0; |
3838 | } | 3839 | } |
@@ -3845,14 +3846,14 @@ zoran_do_ioctl (struct inode *inode, | |||
3845 | dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n", | 3846 | dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n", |
3846 | ZR_DEVNAME(zr), *input); | 3847 | ZR_DEVNAME(zr), *input); |
3847 | 3848 | ||
3848 | down(&zr->resource_lock); | 3849 | mutex_lock(&zr->resource_lock); |
3849 | if ((res = zoran_set_input(zr, *input))) | 3850 | if ((res = zoran_set_input(zr, *input))) |
3850 | goto sinput_unlock_and_return; | 3851 | goto sinput_unlock_and_return; |
3851 | 3852 | ||
3852 | /* Make sure the changes come into effect */ | 3853 | /* Make sure the changes come into effect */ |
3853 | res = wait_grab_pending(zr); | 3854 | res = wait_grab_pending(zr); |
3854 | sinput_unlock_and_return: | 3855 | sinput_unlock_and_return: |
3855 | up(&zr->resource_lock); | 3856 | mutex_unlock(&zr->resource_lock); |
3856 | return res; | 3857 | return res; |
3857 | } | 3858 | } |
3858 | break; | 3859 | break; |
@@ -3914,7 +3915,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3914 | memset(cropcap, 0, sizeof(*cropcap)); | 3915 | memset(cropcap, 0, sizeof(*cropcap)); |
3915 | cropcap->type = type; | 3916 | cropcap->type = type; |
3916 | 3917 | ||
3917 | down(&zr->resource_lock); | 3918 | mutex_lock(&zr->resource_lock); |
3918 | 3919 | ||
3919 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && | 3920 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && |
3920 | (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 3921 | (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
@@ -3934,7 +3935,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3934 | cropcap->defrect.width = BUZ_MIN_WIDTH; | 3935 | cropcap->defrect.width = BUZ_MIN_WIDTH; |
3935 | cropcap->defrect.height = BUZ_MIN_HEIGHT; | 3936 | cropcap->defrect.height = BUZ_MIN_HEIGHT; |
3936 | cropcap_unlock_and_return: | 3937 | cropcap_unlock_and_return: |
3937 | up(&zr->resource_lock); | 3938 | mutex_unlock(&zr->resource_lock); |
3938 | return res; | 3939 | return res; |
3939 | } | 3940 | } |
3940 | break; | 3941 | break; |
@@ -3950,7 +3951,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3950 | memset(crop, 0, sizeof(*crop)); | 3951 | memset(crop, 0, sizeof(*crop)); |
3951 | crop->type = type; | 3952 | crop->type = type; |
3952 | 3953 | ||
3953 | down(&zr->resource_lock); | 3954 | mutex_lock(&zr->resource_lock); |
3954 | 3955 | ||
3955 | if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && | 3956 | if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT && |
3956 | (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 3957 | (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
@@ -3969,7 +3970,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3969 | crop->c.height = fh->jpg_settings.img_height; | 3970 | crop->c.height = fh->jpg_settings.img_height; |
3970 | 3971 | ||
3971 | gcrop_unlock_and_return: | 3972 | gcrop_unlock_and_return: |
3972 | up(&zr->resource_lock); | 3973 | mutex_unlock(&zr->resource_lock); |
3973 | 3974 | ||
3974 | return res; | 3975 | return res; |
3975 | } | 3976 | } |
@@ -3988,7 +3989,7 @@ zoran_do_ioctl (struct inode *inode, | |||
3988 | ZR_DEVNAME(zr), crop->type, crop->c.left, crop->c.top, | 3989 | ZR_DEVNAME(zr), crop->type, crop->c.left, crop->c.top, |
3989 | crop->c.width, crop->c.height); | 3990 | crop->c.width, crop->c.height); |
3990 | 3991 | ||
3991 | down(&zr->resource_lock); | 3992 | mutex_lock(&zr->resource_lock); |
3992 | 3993 | ||
3993 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { | 3994 | if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) { |
3994 | dprintk(1, | 3995 | dprintk(1, |
@@ -4024,7 +4025,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4024 | fh->jpg_settings = settings; | 4025 | fh->jpg_settings = settings; |
4025 | 4026 | ||
4026 | scrop_unlock_and_return: | 4027 | scrop_unlock_and_return: |
4027 | up(&zr->resource_lock); | 4028 | mutex_unlock(&zr->resource_lock); |
4028 | return res; | 4029 | return res; |
4029 | } | 4030 | } |
4030 | break; | 4031 | break; |
@@ -4038,7 +4039,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4038 | 4039 | ||
4039 | memset(params, 0, sizeof(*params)); | 4040 | memset(params, 0, sizeof(*params)); |
4040 | 4041 | ||
4041 | down(&zr->resource_lock); | 4042 | mutex_lock(&zr->resource_lock); |
4042 | 4043 | ||
4043 | params->quality = fh->jpg_settings.jpg_comp.quality; | 4044 | params->quality = fh->jpg_settings.jpg_comp.quality; |
4044 | params->APPn = fh->jpg_settings.jpg_comp.APPn; | 4045 | params->APPn = fh->jpg_settings.jpg_comp.APPn; |
@@ -4053,7 +4054,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4053 | params->jpeg_markers = | 4054 | params->jpeg_markers = |
4054 | fh->jpg_settings.jpg_comp.jpeg_markers; | 4055 | fh->jpg_settings.jpg_comp.jpeg_markers; |
4055 | 4056 | ||
4056 | up(&zr->resource_lock); | 4057 | mutex_unlock(&zr->resource_lock); |
4057 | 4058 | ||
4058 | return 0; | 4059 | return 0; |
4059 | } | 4060 | } |
@@ -4074,7 +4075,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4074 | 4075 | ||
4075 | settings.jpg_comp = *params; | 4076 | settings.jpg_comp = *params; |
4076 | 4077 | ||
4077 | down(&zr->resource_lock); | 4078 | mutex_lock(&zr->resource_lock); |
4078 | 4079 | ||
4079 | if (fh->v4l_buffers.active != ZORAN_FREE || | 4080 | if (fh->v4l_buffers.active != ZORAN_FREE || |
4080 | fh->jpg_buffers.active != ZORAN_FREE) { | 4081 | fh->jpg_buffers.active != ZORAN_FREE) { |
@@ -4093,7 +4094,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4093 | zoran_v4l2_calc_bufsize(&fh->jpg_settings); | 4094 | zoran_v4l2_calc_bufsize(&fh->jpg_settings); |
4094 | fh->jpg_settings.jpg_comp = *params = settings.jpg_comp; | 4095 | fh->jpg_settings.jpg_comp = *params = settings.jpg_comp; |
4095 | sjpegc_unlock_and_return: | 4096 | sjpegc_unlock_and_return: |
4096 | up(&zr->resource_lock); | 4097 | mutex_unlock(&zr->resource_lock); |
4097 | 4098 | ||
4098 | return 0; | 4099 | return 0; |
4099 | } | 4100 | } |
@@ -4127,7 +4128,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4127 | 4128 | ||
4128 | switch (fmt->type) { | 4129 | switch (fmt->type) { |
4129 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 4130 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
4130 | down(&zr->resource_lock); | 4131 | mutex_lock(&zr->resource_lock); |
4131 | 4132 | ||
4132 | if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH) | 4133 | if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH) |
4133 | fmt->fmt.win.w.width = BUZ_MAX_WIDTH; | 4134 | fmt->fmt.win.w.width = BUZ_MAX_WIDTH; |
@@ -4138,7 +4139,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4138 | if (fmt->fmt.win.w.height < BUZ_MIN_HEIGHT) | 4139 | if (fmt->fmt.win.w.height < BUZ_MIN_HEIGHT) |
4139 | fmt->fmt.win.w.height = BUZ_MIN_HEIGHT; | 4140 | fmt->fmt.win.w.height = BUZ_MIN_HEIGHT; |
4140 | 4141 | ||
4141 | up(&zr->resource_lock); | 4142 | mutex_unlock(&zr->resource_lock); |
4142 | break; | 4143 | break; |
4143 | 4144 | ||
4144 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 4145 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
@@ -4146,7 +4147,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4146 | if (fmt->fmt.pix.bytesperline > 0) | 4147 | if (fmt->fmt.pix.bytesperline > 0) |
4147 | return -EINVAL; | 4148 | return -EINVAL; |
4148 | 4149 | ||
4149 | down(&zr->resource_lock); | 4150 | mutex_lock(&zr->resource_lock); |
4150 | 4151 | ||
4151 | if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { | 4152 | if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) { |
4152 | settings = fh->jpg_settings; | 4153 | settings = fh->jpg_settings; |
@@ -4229,7 +4230,7 @@ zoran_do_ioctl (struct inode *inode, | |||
4229 | goto tryfmt_unlock_and_return; | 4230 | goto tryfmt_unlock_and_return; |
4230 | } | 4231 | } |
4231 | tryfmt_unlock_and_return: | 4232 | tryfmt_unlock_and_return: |
4232 | up(&zr->resource_lock); | 4233 | mutex_unlock(&zr->resource_lock); |
4233 | 4234 | ||
4234 | return res; | 4235 | return res; |
4235 | break; | 4236 | break; |
@@ -4280,7 +4281,7 @@ zoran_poll (struct file *file, | |||
4280 | * if no buffers queued or so, return POLLNVAL | 4281 | * if no buffers queued or so, return POLLNVAL |
4281 | */ | 4282 | */ |
4282 | 4283 | ||
4283 | down(&zr->resource_lock); | 4284 | mutex_lock(&zr->resource_lock); |
4284 | 4285 | ||
4285 | switch (fh->map_mode) { | 4286 | switch (fh->map_mode) { |
4286 | case ZORAN_MAP_MODE_RAW: | 4287 | case ZORAN_MAP_MODE_RAW: |
@@ -4329,7 +4330,7 @@ zoran_poll (struct file *file, | |||
4329 | } | 4330 | } |
4330 | 4331 | ||
4331 | poll_unlock_and_return: | 4332 | poll_unlock_and_return: |
4332 | up(&zr->resource_lock); | 4333 | mutex_unlock(&zr->resource_lock); |
4333 | 4334 | ||
4334 | return res; | 4335 | return res; |
4335 | } | 4336 | } |
@@ -4385,7 +4386,7 @@ zoran_vm_close (struct vm_area_struct *vma) | |||
4385 | if (fh->jpg_buffers.buffer[i].map) | 4386 | if (fh->jpg_buffers.buffer[i].map) |
4386 | break; | 4387 | break; |
4387 | if (i == fh->jpg_buffers.num_buffers) { | 4388 | if (i == fh->jpg_buffers.num_buffers) { |
4388 | down(&zr->resource_lock); | 4389 | mutex_lock(&zr->resource_lock); |
4389 | 4390 | ||
4390 | if (fh->jpg_buffers.active != ZORAN_FREE) { | 4391 | if (fh->jpg_buffers.active != ZORAN_FREE) { |
4391 | jpg_qbuf(file, -1, zr->codec_mode); | 4392 | jpg_qbuf(file, -1, zr->codec_mode); |
@@ -4398,7 +4399,7 @@ zoran_vm_close (struct vm_area_struct *vma) | |||
4398 | fh->jpg_buffers.allocated = 0; | 4399 | fh->jpg_buffers.allocated = 0; |
4399 | fh->jpg_buffers.ready_to_be_freed = 1; | 4400 | fh->jpg_buffers.ready_to_be_freed = 1; |
4400 | 4401 | ||
4401 | up(&zr->resource_lock); | 4402 | mutex_unlock(&zr->resource_lock); |
4402 | } | 4403 | } |
4403 | 4404 | ||
4404 | break; | 4405 | break; |
@@ -4421,7 +4422,7 @@ zoran_vm_close (struct vm_area_struct *vma) | |||
4421 | if (fh->v4l_buffers.buffer[i].map) | 4422 | if (fh->v4l_buffers.buffer[i].map) |
4422 | break; | 4423 | break; |
4423 | if (i == fh->v4l_buffers.num_buffers) { | 4424 | if (i == fh->v4l_buffers.num_buffers) { |
4424 | down(&zr->resource_lock); | 4425 | mutex_lock(&zr->resource_lock); |
4425 | 4426 | ||
4426 | if (fh->v4l_buffers.active != ZORAN_FREE) { | 4427 | if (fh->v4l_buffers.active != ZORAN_FREE) { |
4427 | zr36057_set_memgrab(zr, 0); | 4428 | zr36057_set_memgrab(zr, 0); |
@@ -4434,7 +4435,7 @@ zoran_vm_close (struct vm_area_struct *vma) | |||
4434 | fh->v4l_buffers.allocated = 0; | 4435 | fh->v4l_buffers.allocated = 0; |
4435 | fh->v4l_buffers.ready_to_be_freed = 1; | 4436 | fh->v4l_buffers.ready_to_be_freed = 1; |
4436 | 4437 | ||
4437 | up(&zr->resource_lock); | 4438 | mutex_unlock(&zr->resource_lock); |
4438 | } | 4439 | } |
4439 | 4440 | ||
4440 | break; | 4441 | break; |
@@ -4489,7 +4490,7 @@ zoran_mmap (struct file *file, | |||
4489 | case ZORAN_MAP_MODE_JPG_PLAY: | 4490 | case ZORAN_MAP_MODE_JPG_PLAY: |
4490 | 4491 | ||
4491 | /* lock */ | 4492 | /* lock */ |
4492 | down(&zr->resource_lock); | 4493 | mutex_lock(&zr->resource_lock); |
4493 | 4494 | ||
4494 | /* Map the MJPEG buffers */ | 4495 | /* Map the MJPEG buffers */ |
4495 | if (!fh->jpg_buffers.allocated) { | 4496 | if (!fh->jpg_buffers.allocated) { |
@@ -4579,13 +4580,13 @@ zoran_mmap (struct file *file, | |||
4579 | 4580 | ||
4580 | } | 4581 | } |
4581 | jpg_mmap_unlock_and_return: | 4582 | jpg_mmap_unlock_and_return: |
4582 | up(&zr->resource_lock); | 4583 | mutex_unlock(&zr->resource_lock); |
4583 | 4584 | ||
4584 | break; | 4585 | break; |
4585 | 4586 | ||
4586 | case ZORAN_MAP_MODE_RAW: | 4587 | case ZORAN_MAP_MODE_RAW: |
4587 | 4588 | ||
4588 | down(&zr->resource_lock); | 4589 | mutex_lock(&zr->resource_lock); |
4589 | 4590 | ||
4590 | /* Map the V4L buffers */ | 4591 | /* Map the V4L buffers */ |
4591 | if (!fh->v4l_buffers.allocated) { | 4592 | if (!fh->v4l_buffers.allocated) { |
@@ -4657,7 +4658,7 @@ zoran_mmap (struct file *file, | |||
4657 | break; | 4658 | break; |
4658 | } | 4659 | } |
4659 | v4l_mmap_unlock_and_return: | 4660 | v4l_mmap_unlock_and_return: |
4660 | up(&zr->resource_lock); | 4661 | mutex_unlock(&zr->resource_lock); |
4661 | 4662 | ||
4662 | break; | 4663 | break; |
4663 | 4664 | ||