diff options
-rw-r--r-- | v4l/ChangeLog | 25 | ||||
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-context.c | 8 | ||||
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-context.h | 14 | ||||
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h | 27 | ||||
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-hdw.c | 7 | ||||
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-i2c-core.c | 40 | ||||
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-io.c | 52 | ||||
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-ioread.c | 28 | ||||
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-v4l2.c | 4 |
9 files changed, 137 insertions, 68 deletions
diff --git a/v4l/ChangeLog b/v4l/ChangeLog index a2bd4c985..54b0d4d58 100644 --- a/v4l/ChangeLog +++ b/v4l/ChangeLog @@ -1,3 +1,28 @@ +2006-01-23 06:54 mcisely + + * v4l_experimental/pvrusb2/pvrusb2-context.c: + (pvr2_context_create), (pvr2_context_enter), (pvr2_context_exit): + * v4l_experimental/pvrusb2/pvrusb2-context.h: + * v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h: + * v4l_experimental/pvrusb2/pvrusb2-hdw.c: (pvr2_hdw_create): + * v4l_experimental/pvrusb2/pvrusb2-i2c-core.c: (pvr2_i2c_core_cmd), + (pvr2_i2c_core_sync), (pvr2_i2c_core_check_stale), + (pvr2_i2c_report), (pvr2_i2c_attach_inform), + (pvr2_i2c_detach_inform), (pvr2_i2c_core_init): + * v4l_experimental/pvrusb2/pvrusb2-io.c: (pvr2_stream_init), + (pvr2_stream_done), (pvr2_stream_setup), + (pvr2_stream_set_callback), (pvr2_stream_set_buffer_count), + (pvr2_stream_flush), (pvr2_stream_kill), (pvr2_buffer_queue), + (pvr2_buffer_idle), (pvr2_buffer_set_buffer): + * v4l_experimental/pvrusb2/pvrusb2-ioread.c: (pvr2_ioread_init), + (pvr2_ioread_setup), (pvr2_ioread_set_enabled), (pvr2_ioread_read): + * v4l_experimental/pvrusb2/pvrusb2-v4l2.c: (pvr2_v4l2_open): + + - Switch to using mutexes in pvrusb2 when compiling for 2.6.16 or + later. + + Signed-off-by: Mike Isely <isely@pobox.com> + 2006-01-23 05:37 mkrufky * linux/drivers/media/video/tuner-types.c: diff --git a/v4l_experimental/pvrusb2/pvrusb2-context.c b/v4l_experimental/pvrusb2/pvrusb2-context.c index 483aba179..1f8b400a0 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-context.c +++ b/v4l_experimental/pvrusb2/pvrusb2-context.c @@ -1,5 +1,5 @@ /* - * $Id: pvrusb2-context.c,v 1.2 2006/01/01 08:26:03 mcisely Exp $ + * $Id: pvrusb2-context.c,v 1.3 2006/01/23 06:58:06 mcisely Exp $ * * Copyright (C) 2005 Mike Isely <isely@pobox.com> * @@ -82,7 +82,7 @@ struct pvr2_context *pvr2_context_create( memset(mp,0,sizeof(*mp)); pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_main id=%p",mp); mp->setup_func = setup_func; - init_MUTEX(&mp->sem); + mutex_init(&mp->mutex); mp->hdw = pvr2_hdw_create(intf); if (!mp->hdw) { pvr2_context_destroy(mp); @@ -101,7 +101,7 @@ struct pvr2_context *pvr2_context_create( void pvr2_context_enter(struct pvr2_context *mp) { - down(&mp->sem); + mutex_lock(&mp->mutex); pvr2_trace(PVR2_TRACE_CREG,"pvr2_context_enter(id=%p)",mp); } @@ -113,7 +113,7 @@ void pvr2_context_exit(struct pvr2_context *mp) destroy_flag = !0; } pvr2_trace(PVR2_TRACE_CREG,"pvr2_context_exit(id=%p) outside",mp); - up(&mp->sem); + mutex_unlock(&mp->mutex); if (destroy_flag) pvr2_context_destroy(mp); } diff --git a/v4l_experimental/pvrusb2/pvrusb2-context.h b/v4l_experimental/pvrusb2/pvrusb2-context.h index 2f453c908..229a8ef0e 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-context.h +++ b/v4l_experimental/pvrusb2/pvrusb2-context.h @@ -1,5 +1,5 @@ /* - * $Id: pvrusb2-context.h,v 1.2 2006/01/01 08:26:03 mcisely Exp $ + * $Id: pvrusb2-context.h,v 1.3 2006/01/23 06:58:06 mcisely Exp $ * * Copyright (C) 2005 Mike Isely <isely@pobox.com> * @@ -20,7 +20,13 @@ #ifndef __PVRUSB2_BASE_H #define __PVRUSB2_BASE_H +#include "compat.h" +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include <asm/atomic.h> +#include <asm/mutex.h> +#else #include <asm/semaphore.h> +#endif #include <linux/usb.h> #include <linux/workqueue.h> @@ -42,7 +48,11 @@ struct pvr2_context { struct pvr2_channel *mc_last; struct pvr2_hdw *hdw; struct pvr2_context_stream video_stream; - struct semaphore sem; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex mutex; +#else + struct semaphore mutex; +#endif int disconnect_flag; /* Called after pvr2_context initialization is complete */ diff --git a/v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h b/v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h index 4f2bb58ac..c4b1cbdcd 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h +++ b/v4l_experimental/pvrusb2/pvrusb2-hdw-internal.h @@ -1,6 +1,6 @@ /* * - * $Id: pvrusb2-hdw-internal.h,v 1.5 2006/01/09 06:37:48 mcisely Exp $ + * $Id: pvrusb2-hdw-internal.h,v 1.6 2006/01/23 06:58:06 mcisely Exp $ * * Copyright (C) 2005 Mike Isely <isely@pobox.com> * @@ -36,7 +36,12 @@ #include "compat.h" #include <linux/videodev2.h> #include <linux/i2c.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include <asm/atomic.h> +#include <asm/mutex.h> +#else #include <asm/semaphore.h> +#endif #include "pvrusb2-hdw.h" #include "pvrusb2-io.h" @@ -48,8 +53,8 @@ #define FREQTABLE_SIZE 500 -#define LOCK_TAKE(x) do { down(&x##_sem); x##_held = !0; } while (0) -#define LOCK_GIVE(x) do { x##_held = 0; up(&x##_sem); } while (0) +#define LOCK_TAKE(x) do { mutex_lock(&x##_mutex); x##_held = !0; } while (0) +#define LOCK_GIVE(x) do { x##_held = 0; mutex_unlock(&x##_mutex); } while (0) struct pvr2_decoder; @@ -100,7 +105,11 @@ struct pvr2_hdw { struct pvr2_stream *vid_stream; /* Mutex for all hardware state control */ - struct semaphore big_lock_sem; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex big_lock_mutex; +#else + struct semaphore big_lock_mutex; +#endif int big_lock_held; /* For debugging */ void (*poll_trigger_func)(void *); @@ -117,13 +126,21 @@ struct pvr2_hdw { unsigned long i2c_stale_mask; /* Pending broadcast change bits */ unsigned long i2c_active_mask; /* All change bits currently in use */ struct list_head i2c_clients; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex i2c_list_lock; +#else struct semaphore i2c_list_lock; +#endif /* Frequency table */ unsigned int freqTable[FREQTABLE_SIZE]; /* Stuff for handling low level control interaction with device */ - struct semaphore ctl_lock_sem; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex ctl_lock_mutex; +#else + struct semaphore ctl_lock_mutex; +#endif int ctl_lock_held; /* For debugging */ struct urb *ctl_write_urb; struct urb *ctl_read_urb; diff --git a/v4l_experimental/pvrusb2/pvrusb2-hdw.c b/v4l_experimental/pvrusb2/pvrusb2-hdw.c index c7b169d0f..20206cff9 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-hdw.c +++ b/v4l_experimental/pvrusb2/pvrusb2-hdw.c @@ -1,6 +1,6 @@ /* * - * $Id: pvrusb2-hdw.c,v 1.12 2006/01/14 21:11:17 mcisely Exp $ + * $Id: pvrusb2-hdw.c,v 1.13 2006/01/23 06:58:06 mcisely Exp $ * * Copyright (C) 2005 Mike Isely <isely@pobox.com> * @@ -1165,9 +1165,8 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf) ifnum = hdw->usb_intf->cur_altsetting->desc.bInterfaceNumber; usb_set_interface(hdw->usb_dev,ifnum,0); - init_MUTEX(&hdw->ctl_lock_sem); - init_MUTEX(&hdw->big_lock_sem); - + mutex_init(&hdw->ctl_lock_mutex); + mutex_init(&hdw->big_lock_mutex); return hdw; fail: diff --git a/v4l_experimental/pvrusb2/pvrusb2-i2c-core.c b/v4l_experimental/pvrusb2/pvrusb2-i2c-core.c index d7e9ffabb..b45463a2d 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-i2c-core.c +++ b/v4l_experimental/pvrusb2/pvrusb2-i2c-core.c @@ -1,6 +1,6 @@ /* * - * $Id: pvrusb2-i2c-core.c,v 1.4 2006/01/22 03:51:19 mcisely Exp $ + * $Id: pvrusb2-i2c-core.c,v 1.5 2006/01/23 06:58:06 mcisely Exp $ * * Copyright (C) 2005 Mike Isely <isely@pobox.com> * @@ -334,15 +334,15 @@ int pvr2_i2c_core_cmd(struct pvr2_hdw *hdw,unsigned int cmd,void *arg) if (!hdw) return stat; - down(&hdw->i2c_list_lock); + mutex_lock(&hdw->i2c_list_lock); list_for_each_safe(item,nc,&hdw->i2c_clients) { cp = list_entry(item,struct pvr2_i2c_client,list); if (!cp->recv_enable) continue; - up(&hdw->i2c_list_lock); + mutex_unlock(&hdw->i2c_list_lock); stat = pvr2_i2c_client_cmd(cp,cmd,arg); - down(&hdw->i2c_list_lock); + mutex_lock(&hdw->i2c_list_lock); } - up(&hdw->i2c_list_lock); + mutex_unlock(&hdw->i2c_list_lock); return stat; } @@ -368,7 +368,7 @@ void pvr2_i2c_core_sync(struct pvr2_hdw *hdw) if (!(hdw->i2c_pend_types & PVR2_I2C_PEND_ALL)) { return; } - down(&hdw->i2c_list_lock); do { + mutex_lock(&hdw->i2c_list_lock); do { pvr2_trace(PVR2_TRACE_I2C_CORE,"i2c: core_sync BEGIN"); if (hdw->i2c_pend_types & PVR2_I2C_PEND_DETECT) { /* One or more I2C clients have attached since we @@ -448,10 +448,10 @@ void pvr2_i2c_core_sync(struct pvr2_hdw *hdw) if (!cp->handler->func_table->update) continue; pvr2_trace(PVR2_TRACE_I2C_CORE, "i2c: cp=%p update",cp); - up(&hdw->i2c_list_lock); + mutex_unlock(&hdw->i2c_list_lock); cp->handler->func_table->update( cp->handler->func_data); - down(&hdw->i2c_list_lock); + mutex_lock(&hdw->i2c_list_lock); /* If client's update function set some additional pending bits, account for that here. */ @@ -488,13 +488,13 @@ void pvr2_i2c_core_sync(struct pvr2_hdw *hdw) } opf = pvr2_i2c_get_op(idx); if (!opf) continue; - up(&hdw->i2c_list_lock); + mutex_unlock(&hdw->i2c_list_lock); opf->update(hdw); - down(&hdw->i2c_list_lock); + mutex_lock(&hdw->i2c_list_lock); } } pvr2_trace(PVR2_TRACE_I2C_CORE,"i2c: core_sync END"); - } while (0); up(&hdw->i2c_list_lock); + } while (0); mutex_unlock(&hdw->i2c_list_lock); } int pvr2_i2c_core_check_stale(struct pvr2_hdw *hdw) @@ -528,11 +528,11 @@ int pvr2_i2c_core_check_stale(struct pvr2_hdw *hdw) } if (pt) { - down(&hdw->i2c_list_lock); do { + mutex_lock(&hdw->i2c_list_lock); do { hdw->i2c_pend_types |= pt; hdw->i2c_stale_mask |= sm; hdw->i2c_pend_mask |= hdw->i2c_stale_mask; - } while (0); up(&hdw->i2c_list_lock); + } while (0); mutex_unlock(&hdw->i2c_list_lock); } pvr2_trace(PVR2_TRACE_I2C_CORE, @@ -616,7 +616,7 @@ unsigned int pvr2_i2c_report(struct pvr2_hdw *hdw, struct list_head *item; struct pvr2_i2c_client *cp; ccnt = 0; - down(&hdw->i2c_list_lock); do { + mutex_lock(&hdw->i2c_list_lock); do { list_for_each(item,&hdw->i2c_clients) { cp = list_entry(item,struct pvr2_i2c_client,list); bcnt = pvr2_i2c_client_describe( @@ -628,7 +628,7 @@ unsigned int pvr2_i2c_report(struct pvr2_hdw *hdw, bcnt = scnprintf(buf,maxlen,"\n"); ccnt += bcnt; buf += bcnt; maxlen -= bcnt; } - } while (0); up(&hdw->i2c_list_lock); + } while (0); mutex_unlock(&hdw->i2c_list_lock); return ccnt; } @@ -645,10 +645,10 @@ static int pvr2_i2c_attach_inform(struct i2c_client *client) memset(cp,0,sizeof(*cp)); INIT_LIST_HEAD(&cp->list); cp->client = client; - down(&hdw->i2c_list_lock); do { + mutex_lock(&hdw->i2c_list_lock); do { list_add_tail(&cp->list,&hdw->i2c_clients); hdw->i2c_pend_types |= PVR2_I2C_PEND_DETECT; - } while (0); up(&hdw->i2c_list_lock); + } while (0); mutex_unlock(&hdw->i2c_list_lock); if (fl) pvr2_hdw_poll_trigger_unlocked(hdw); return 0; } @@ -660,7 +660,7 @@ static int pvr2_i2c_detach_inform(struct i2c_client *client) struct list_head *item,*nc; unsigned long amask = 0; int foundfl = 0; - down(&hdw->i2c_list_lock); do { + mutex_lock(&hdw->i2c_list_lock); do { list_for_each_safe(item,nc,&hdw->i2c_clients) { cp = list_entry(item,struct pvr2_i2c_client,list); if (cp->client == client) { @@ -681,7 +681,7 @@ static int pvr2_i2c_detach_inform(struct i2c_client *client) amask |= cp->ctl_mask; } hdw->i2c_active_mask = amask; - } while (0); up(&hdw->i2c_list_lock); + } while (0); mutex_unlock(&hdw->i2c_list_lock); if (!foundfl) { trace_i2c("pvr2_i2c_detach [client=%s @ 0x%x ctxt=<unknown>]", client->name, @@ -744,7 +744,7 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw) hdw->i2c_stale_mask = 0; hdw->i2c_active_mask = 0; INIT_LIST_HEAD(&hdw->i2c_clients); - init_MUTEX(&hdw->i2c_list_lock); + mutex_init(&hdw->i2c_list_lock); hdw->i2c_linked = !0; i2c_add_adapter(&hdw->i2c_adap); if (i2c_scan) do_i2c_scan(hdw); diff --git a/v4l_experimental/pvrusb2/pvrusb2-io.c b/v4l_experimental/pvrusb2/pvrusb2-io.c index c170bede0..d53c63785 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-io.c +++ b/v4l_experimental/pvrusb2/pvrusb2-io.c @@ -1,6 +1,6 @@ /* * - * $Id: pvrusb2-io.c,v 1.2 2006/01/09 06:54:46 mcisely Exp $ + * $Id: pvrusb2-io.c,v 1.3 2006/01/23 06:58:06 mcisely Exp $ * * Copyright (C) 2005 Mike Isely <isely@pobox.com> * @@ -19,12 +19,18 @@ * */ +#include "compat.h" #include "pvrusb2-io.h" #include "pvrusb2-debug.h" #include <linux/errno.h> #include <linux/string.h> #include <linux/slab.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include <asm/atomic.h> +#include <asm/mutex.h> +#else #include <asm/semaphore.h> +#endif #define BUFFER_SIG 0x47653271 @@ -85,7 +91,11 @@ struct pvr2_stream { int endpoint; /* Overhead for mutex enforcement */ spinlock_t list_lock; - struct semaphore sem; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex mutex; +#else + struct semaphore mutex; +#endif /* Tracking state for tolerating errors */ unsigned int fail_count; unsigned int fail_tolerance; @@ -422,7 +432,7 @@ static void pvr2_stream_internal_flush(struct pvr2_stream *sp) static void pvr2_stream_init(struct pvr2_stream *sp) { spin_lock_init(&sp->list_lock); - init_MUTEX(&sp->sem); + mutex_init(&sp->mutex); INIT_LIST_HEAD(&sp->queued_list); INIT_LIST_HEAD(&sp->ready_list); INIT_LIST_HEAD(&sp->idle_list); @@ -430,10 +440,10 @@ static void pvr2_stream_init(struct pvr2_stream *sp) static void pvr2_stream_done(struct pvr2_stream *sp) { - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { pvr2_stream_internal_flush(sp); pvr2_stream_buffer_count(sp,0); - } while (0); up(&sp->sem); + } while (0); mutex_unlock(&sp->mutex); } static void buffer_complete(struct urb *urb, struct pt_regs *regs) @@ -502,12 +512,12 @@ void pvr2_stream_setup(struct pvr2_stream *sp, int endpoint, unsigned int tolerance) { - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { pvr2_stream_internal_flush(sp); sp->dev = dev; sp->endpoint = endpoint; sp->fail_tolerance = tolerance; - } while(0); up(&sp->sem); + } while(0); mutex_unlock(&sp->mutex); } void pvr2_stream_set_callback(struct pvr2_stream *sp, @@ -515,12 +525,12 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp, void *data) { unsigned long irq_flags; - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { spin_lock_irqsave(&sp->list_lock,irq_flags); sp->callback_data = data; sp->callback_func = func; spin_unlock_irqrestore(&sp->list_lock,irq_flags); - } while(0); up(&sp->sem); + } while(0); mutex_unlock(&sp->mutex); } /* Query / set the nominal buffer count */ @@ -533,10 +543,10 @@ int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt) { int ret; if (sp->buffer_target_count == cnt) return 0; - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { sp->buffer_target_count = cnt; ret = pvr2_stream_achieve_buffer_count(sp); - } while(0); up(&sp->sem); + } while(0); mutex_unlock(&sp->mutex); return ret; } @@ -573,15 +583,15 @@ int pvr2_stream_get_idle_count(struct pvr2_stream *sp) void pvr2_stream_flush(struct pvr2_stream *sp) { - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { pvr2_stream_internal_flush(sp); - } while(0); up(&sp->sem); + } while(0); mutex_unlock(&sp->mutex); } void pvr2_stream_kill(struct pvr2_stream *sp) { struct pvr2_buffer *bp; - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { pvr2_stream_internal_flush(sp); while ((bp = pvr2_stream_get_ready_buffer(sp)) != 0) { pvr2_buffer_set_idle(bp); @@ -589,7 +599,7 @@ void pvr2_stream_kill(struct pvr2_stream *sp) if (sp->buffer_total_count != sp->buffer_target_count) { pvr2_stream_achieve_buffer_count(sp); } - } while(0); up(&sp->sem); + } while(0); mutex_unlock(&sp->mutex); } int pvr2_buffer_queue(struct pvr2_buffer *bp) @@ -603,7 +613,7 @@ int pvr2_buffer_queue(struct pvr2_buffer *bp) struct pvr2_stream *sp; if (!bp) return -EINVAL; sp = bp->stream; - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { pvr2_buffer_wipe(bp); if (!sp->dev) { ret = -EIO; @@ -627,7 +637,7 @@ int pvr2_buffer_queue(struct pvr2_buffer *bp) buffer_complete, bp); usb_submit_urb(bp->purb,GFP_KERNEL); - } while(0); up(&sp->sem); + } while(0); mutex_unlock(&sp->mutex); return ret; } @@ -636,13 +646,13 @@ int pvr2_buffer_idle(struct pvr2_buffer *bp) struct pvr2_stream *sp; if (!bp) return -EINVAL; sp = bp->stream; - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { pvr2_buffer_wipe(bp); pvr2_buffer_set_idle(bp); if (sp->buffer_total_count != sp->buffer_target_count) { pvr2_stream_achieve_buffer_count(sp); } - } while(0); up(&sp->sem); + } while(0); mutex_unlock(&sp->mutex); return 0; } @@ -653,7 +663,7 @@ int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt) struct pvr2_stream *sp; if (!bp) return -EINVAL; sp = bp->stream; - down(&sp->sem); do { + mutex_lock(&sp->mutex); do { spin_lock_irqsave(&sp->list_lock,irq_flags); if (bp->state != pvr2_buffer_state_idle) { ret = -EPERM; @@ -670,7 +680,7 @@ int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt) bp->stream->i_bcount,bp->stream->i_count); } spin_unlock_irqrestore(&sp->list_lock,irq_flags); - } while(0); up(&sp->sem); + } while(0); mutex_unlock(&sp->mutex); return ret; } diff --git a/v4l_experimental/pvrusb2/pvrusb2-ioread.c b/v4l_experimental/pvrusb2/pvrusb2-ioread.c index 5517e545c..375dd8acb 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-ioread.c +++ b/v4l_experimental/pvrusb2/pvrusb2-ioread.c @@ -1,6 +1,6 @@ /* * - * $Id: pvrusb2-ioread.c,v 1.1 2005/11/14 13:31:24 mchehab Exp $ + * $Id: pvrusb2-ioread.c,v 1.2 2006/01/23 06:58:06 mcisely Exp $ * * Copyright (C) 2005 Mike Isely <isely@pobox.com> * @@ -19,12 +19,18 @@ * */ +#include "compat.h" #include "pvrusb2-ioread.h" #include "pvrusb2-debug.h" #include <linux/errno.h> #include <linux/string.h> #include <linux/slab.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#include <asm/atomic.h> +#include <asm/mutex.h> +#else #include <asm/semaphore.h> +#endif #include <asm/uaccess.h> #define BUFFER_COUNT 32 @@ -37,7 +43,11 @@ struct pvr2_ioread { int enabled; int stream_running; int spigot_open; - struct semaphore sem; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) + struct mutex mutex; +#else + struct semaphore mutex; +#endif }; static int pvr2_ioread_init(struct pvr2_ioread *cp) @@ -45,7 +55,7 @@ static int pvr2_ioread_init(struct pvr2_ioread *cp) unsigned int idx; cp->stream = 0; - init_MUTEX(&cp->sem); + mutex_init(&cp->mutex); for (idx = 0; idx < BUFFER_COUNT; idx++) { cp->buffer_storage[idx] = kmalloc(BUFFER_SIZE,GFP_KERNEL); @@ -146,7 +156,7 @@ int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp) unsigned int idx; struct pvr2_buffer *bp; - down(&cp->sem); do { + mutex_lock(&cp->mutex); do { if (cp->stream) { pvr2_trace(PVR2_TRACE_START_STOP, "/*---TRACE_READ---*/" @@ -171,7 +181,7 @@ int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp) } cp->stream = sp; } - } while (0); up(&cp->sem); + } while (0); mutex_unlock(&cp->mutex); return 0; } @@ -181,13 +191,13 @@ int pvr2_ioread_set_enabled(struct pvr2_ioread *cp,int fl) int ret = 0; if ((!fl) == (!(cp->enabled))) return ret; - down(&cp->sem); do { + mutex_lock(&cp->mutex); do { if (fl) { ret = pvr2_ioread_start(cp); } else { pvr2_ioread_stop(cp); } - } while (0); up(&cp->sem); + } while (0); mutex_unlock(&cp->mutex); return ret; } @@ -249,7 +259,7 @@ int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt) cp->stream_running = !0; - down(&cp->sem); do { + mutex_lock(&cp->mutex); do { // Suck data out of the buffers and copy to the user copied_cnt = 0; @@ -325,7 +335,7 @@ int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt) } } - } while (0); up(&cp->sem); + } while (0); mutex_unlock(&cp->mutex); if (!ret) { if (copied_cnt) { diff --git a/v4l_experimental/pvrusb2/pvrusb2-v4l2.c b/v4l_experimental/pvrusb2/pvrusb2-v4l2.c index 9449f775f..0a78a6646 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-v4l2.c +++ b/v4l_experimental/pvrusb2/pvrusb2-v4l2.c @@ -1,6 +1,6 @@ /* * - * $Id: pvrusb2-v4l2.c,v 1.8 2006/01/21 04:44:52 mcisely Exp $ + * $Id: pvrusb2-v4l2.c,v 1.9 2006/01/23 06:58:06 mcisely Exp $ * * Copyright (C) 2005 Mike Isely <isely@pobox.com> * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr> @@ -63,7 +63,6 @@ struct pvr2_v4l2_fh { struct pvr2_v4l2_fh *vprev; wait_queue_head_t wait_data; int fw_mode_flag; - struct semaphore sem; }; struct pvr2_v4l2 { @@ -981,7 +980,6 @@ int pvr2_v4l2_open(struct inode *inode, struct file *file) } memset(fhp,0,sizeof(*fhp)); - init_MUTEX(&fhp->sem); init_waitqueue_head(&fhp->wait_data); fhp->dev_info = dip; |