Index: driver/ivtv-streams.c
===================================================================
--- driver/ivtv-streams.c	(revision 3703)
+++ driver/ivtv-streams.c	(working copy)
@@ -122,8 +122,17 @@
 	/* Step 2: initialize ivtv_stream fields */
 	init_waitqueue_head(&s->waitq);
 	init_waitqueue_head(&s->udma.waitq);
+#if defined(CONFIG_RT_MUTEXES) && defined(__COMPAT_DECLARE_SEMAPHORE_GENERIC)
+	compat_init_MUTEX(&s->mlock);
+#else
 	init_MUTEX(&s->mlock);
+#endif
+	
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+	spin_lock_init(&s->slock);
+#else
 	s->slock = SPIN_LOCK_UNLOCKED;
+#endif
 	s->ubytes = 0;
 	s->dma = dma;
 	s->id = -1;
Index: driver/ivtv-driver.c
===================================================================
--- driver/ivtv-driver.c	(revision 3703)
+++ driver/ivtv-driver.c	(working copy)
@@ -682,6 +682,15 @@
 	/* Set FrameBuffer-ID to invalid */
 	itv->fb_id = -1;
 
+#if defined(CONFIG_RT_MUTEXES) && defined(__COMPAT_DECLARE_SEMAPHORE_GENERIC)
+	compat_init_MUTEX(&itv->enc_msem);
+	compat_init_MUTEX(&itv->dec_msem);
+	compat_init_MUTEX(&itv->streams_lock);
+	compat_init_MUTEX(&itv->i2c_lock);
+	compat_init_MUTEX(&itv->DMA_lock);
+	compat_init_MUTEX(&itv->vbi_dec_lock);
+	compat_init_MUTEX(&itv->i2c_bus_lock);
+#else
 	init_MUTEX(&itv->enc_msem);
 	init_MUTEX(&itv->dec_msem);
 	init_MUTEX(&itv->streams_lock);
@@ -689,8 +698,13 @@
 	init_MUTEX(&itv->DMA_lock);
 	init_MUTEX(&itv->vbi_dec_lock);
 	init_MUTEX(&itv->i2c_bus_lock);
+#endif
 
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+	spin_lock_init(&itv->DMA_slock);
+#else
 	itv->DMA_slock = SPIN_LOCK_UNLOCKED;
+#endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 	itv->vbi_work_queues = create_workqueue("ivtv_vbi");
Index: driver/ivtv-driver.h
===================================================================
--- driver/ivtv-driver.h	(revision 3703)
+++ driver/ivtv-driver.h	(working copy)
@@ -721,8 +721,11 @@
 
 	/* Locking */
 	spinlock_t slock;
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+	struct compat_semaphore mlock;
+#else
 	struct semaphore mlock;
-
+#endif
 	/* Redo DMA? */
 	atomic_t redo_dma;
 
@@ -752,7 +755,11 @@
 
 	/* control thread */
 	struct task_struct *thread;
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+	struct compat_semaphore startstop_sem;
+#else
 	struct semaphore startstop_sem;
+#endif
 	wait_queue_head_t queue;
 	int terminate;
 };
@@ -881,9 +888,15 @@
 	   precise: while this lock is held, no other process can start/stop,
 	   pause/resume or change codecs/formats for any stream.
 	 */
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+	struct compat_semaphore streams_lock;
+	struct compat_semaphore i2c_lock;
+	struct compat_semaphore DMA_lock;
+#else
 	struct semaphore streams_lock;
 	struct semaphore i2c_lock;
 	struct semaphore DMA_lock;
+#endif
 	spinlock_t DMA_slock;
 
 	int open_id;		/* incremented each time an open occurs, used as unique ID.
@@ -951,8 +964,13 @@
 	struct timer_list vbi_passthrough_timer;
 
 	struct ivtv_mailbox *enc_mbox, *dec_mbox;
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+	struct compat_semaphore enc_msem;
+	struct compat_semaphore dec_msem;
+#else
 	struct semaphore enc_msem;
 	struct semaphore dec_msem;
+#endif
 
 	u8 card_rev, *enc_mem, *dec_mem, *reg_mem;
 
@@ -976,7 +994,11 @@
 	struct i2c_adapter i2c_adap;
 	struct i2c_algo_bit_data i2c_algo;
 	struct i2c_client i2c_client;
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+	struct compat_semaphore i2c_bus_lock;
+#else
 	struct semaphore i2c_bus_lock;
+#endif
 	int i2c_state;
 	struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
 
@@ -1052,8 +1074,12 @@
 
 	u32 vbi_raw_size;
 	u32 vbi_sliced_size;
-
+	
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+	struct compat_semaphore vbi_dec_lock;
+#else
 	struct semaphore vbi_dec_lock;
+#endif
 	atomic_t vbi_vsync;
 	atomic_t yuv_vsync;
 	atomic_t fs_vsync;
@@ -1117,10 +1143,16 @@
 	writel(val, reg);
 	readl(reg);
 }
-
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+static inline int ivtv_sem_count(struct compat_semaphore *sem)
+{
+	return atomic_read(&sem->count);
+}
+#else
 static inline int ivtv_sem_count(struct semaphore *sem)
 {
 	return atomic_read(&sem->count);
 }
+#endif
 
 #endif /* IVTV_DRIVER_H */
Index: driver/ivtv-kthreads.c
===================================================================
--- driver/ivtv-kthreads.c	(revision 3703)
+++ driver/ivtv-kthreads.c	(working copy)
@@ -179,7 +179,11 @@
 	struct ivtv_dualwatch *kthread = &ivtv->dualwatch;
 
 	if (!kthread->thread) {
+#if defined(CONFIG_RT_MUTEXES) && defined(__COMPAT_DECLARE_SEMAPHORE_GENERIC)
+		compat_init_MUTEX_LOCKED(&kthread->startstop_sem);
+#else
 		init_MUTEX_LOCKED(&kthread->startstop_sem);
+#endif
 		kernel_thread(ivtv_dualwatch_kthread, ivtv, 0);
 		down(&kthread->startstop_sem);
 	}
@@ -197,7 +201,11 @@
 	   flag and released after the down() call. */
 	lock_kernel();
 	if (kthread->thread) {	/* paranoid mode */
+#if defined(CONFIG_RT_MUTEXES) && defined(__COMPAT_DECLARE_SEMAPHORE_GENERIC)
+		compat_init_MUTEX_LOCKED(&kthread->startstop_sem);
+#else
 		init_MUTEX_LOCKED(&kthread->startstop_sem);
+#endif
 		/* We need to do a memory barrier here to be sure that
 		   the flags are visible on all CPUs. 
 		 */
Index: driver/ivtv-mailbox.c
===================================================================
--- driver/ivtv-mailbox.c	(revision 3703)
+++ driver/ivtv-mailbox.c	(working copy)
@@ -254,10 +254,15 @@
         }
         return "Unknown";
 }
-
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+int ivtv_api(struct ivtv *itv, struct ivtv_mailbox *mbox, struct compat_semaphore *sem,
+	     int cmd, u32 * result, int args, u32 data[])
+{
+#else
 int ivtv_api(struct ivtv *itv, struct ivtv_mailbox *mbox, struct semaphore *sem,
 	     int cmd, u32 * result, int args, u32 data[])
-{
+{	
+#endif
 	int x = 0, gotsem = 0, needsresult = 1;
 	int api_timeout = 1000;
 	struct ivtv_mailbox *local_box;
Index: driver/ivtv-mailbox.h
===================================================================
--- driver/ivtv-mailbox.h	(revision 3703)
+++ driver/ivtv-mailbox.h	(working copy)
@@ -17,8 +17,13 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#ifdef __COMPAT_DECLARE_SEMAPHORE_GENERIC
+int ivtv_api(struct ivtv *itv, struct ivtv_mailbox *mbox, struct compat_semaphore *sem,
+	     int cmd, u32 * result, int args, u32 data[]);
+#else
 int ivtv_api(struct ivtv *itv, struct ivtv_mailbox *mbox, struct semaphore *sem,
 	     int cmd, u32 * result, int args, u32 data[]);
+#endif
 int ivtv_api_getresult_nosleep(struct ivtv *itv, struct ivtv_mailbox *mbox, u32 *result,
 			       u32 data[]);
 int ivtv_vapi(struct ivtv *itv, int cmd, int args, ...);
