patch-2.4.9 linux/drivers/ieee1394/video1394.c

Next file: linux/drivers/ieee1394/video1394.h
Previous file: linux/drivers/ieee1394/sbp2.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.8/linux/drivers/ieee1394/video1394.c linux/drivers/ieee1394/video1394.c
@@ -103,6 +103,7 @@
 	int ctxMatch;
 	wait_queue_head_t waitq;
         spinlock_t lock;
+    unsigned int syt_offset;
 	int flags;
 };
 
@@ -140,10 +141,10 @@
 #define PRINT(level, card, fmt, args...) \
 printk(level "video1394_%d: " fmt "\n" , card , ## args)
 
-void irq_handler(int card, quadlet_t isoRecvIntEvent, 
+static void irq_handler(int card, quadlet_t isoRecvIntEvent, 
 		 quadlet_t isoXmitIntEvent);
 
-LIST_HEAD(video1394_cards);
+static LIST_HEAD(video1394_cards);
 static spinlock_t video1394_cards_lock = SPIN_LOCK_UNLOCKED;
 
 static devfs_handle_t devfs_handle;
@@ -607,7 +608,7 @@
 }
 
 static inline void put_timestamp(struct ti_ohci *ohci, struct dma_iso_ctx * d,
-				 int curr, int n)
+				 int n)
 {
 	unsigned char* buf = d->buf + n * d->buf_size;
 	u32 cycleTimer;
@@ -619,13 +620,39 @@
 
 	cycleTimer = reg_read(ohci, OHCI1394_IsochronousCycleTimer);
 
-	timeStamp = ((cycleTimer & 0x0fff) + 11059);
+	timeStamp = ((cycleTimer & 0x0fff) + d->syt_offset); /* 11059 = 450 us */
 	timeStamp = (timeStamp % 3072 + ((timeStamp / 3072) << 12)
 		+ (cycleTimer & 0xf000)) & 0xffff;
 	
 	buf[6] = timeStamp >> 8; 
 	buf[7] = timeStamp & 0xff; 
 
+    /* if first packet is empty packet, then put timestamp into the next full one too */
+    if ( (d->it_prg[n][0].data[1] >>16) == 0x008) {
+   	    buf += d->packet_size;
+    	buf[6] = timeStamp >> 8;
+	    buf[7] = timeStamp & 0xff;
+	}
+
+    /* do the next buffer frame too in case of irq latency */
+	n = d->next_buffer[n];
+	if (n == -1) {
+	  return;
+	}
+	buf = d->buf + n * d->buf_size;
+
+	timeStamp += (d->last_used_cmd[n] << 12) & 0xffff;
+
+	buf[6] = timeStamp >> 8;
+	buf[7] = timeStamp & 0xff;
+
+    /* if first packet is empty packet, then put timestamp into the next full one too */
+    if ( (d->it_prg[n][0].data[1] >>16) == 0x008) {
+   	    buf += d->packet_size;
+    	buf[6] = timeStamp >> 8;
+	    buf[7] = timeStamp & 0xff;
+	}
+
 #if 0
 	printk("curr: %d, next: %d, cycleTimer: %08x timeStamp: %08x\n",
 	       curr, n, cycleTimer, timeStamp);
@@ -646,7 +673,7 @@
 	for (i=0;i<d->num_desc;i++) {
 		if (d->it_prg[i][d->last_used_cmd[i]].end.status& 0xFFFF0000) {
 			int next = d->next_buffer[i];
-			put_timestamp(ohci, d, i, next);
+			put_timestamp(ohci, d, next);
 			d->it_prg[i][d->last_used_cmd[i]].end.status = 0;
 			d->buffer_status[i] = VIDEO1394_BUFFER_READY;
 		}
@@ -757,12 +784,13 @@
 }
 
 static void initialize_dma_it_ctx(struct dma_iso_ctx *d, int sync_tag,
-				  int flags)
+				  unsigned int syt_offset, int flags)
 {
 	struct ti_ohci *ohci = (struct ti_ohci *)d->ohci;
 	int i;
 
 	d->flags = flags;
+	d->syt_offset = (syt_offset == 0 ? 11000 : syt_offset);
 
 	ohci1394_stop_context(ohci, d->ctrlClear, NULL);
 
@@ -807,7 +835,7 @@
 			   unsigned int cmd, unsigned long arg)
 {
 	struct video_card *video = NULL;
-	struct ti_ohci *ohci;
+	struct ti_ohci *ohci = NULL;
 	unsigned long flags;
 	struct list_head *lh;
 
@@ -931,7 +959,7 @@
 				return -EFAULT;
 			}
 			initialize_dma_it_ctx(video->it_context[i], 
-					      v.sync_tag, v.flags);
+					      v.sync_tag, v.syt_offset, v.flags);
 
 			video->current_ctx = video->it_context[i];
 
@@ -1200,6 +1228,7 @@
 		{
 			DBGMSG(ohci->id, "Starting iso transmit DMA ctx=%d",
 			       d->ctx);
+			put_timestamp(ohci, d, d->last_buffer);
 
 			/* Tell the controller where the first program is */
 			reg_write(ohci, d->cmdPtr, 
@@ -1214,6 +1243,7 @@
 				PRINT(KERN_INFO, ohci->id, 
 				      "Waking up iso transmit dma ctx=%d", 
 				      d->ctx);
+				put_timestamp(ohci, d, d->last_buffer);
 				reg_write(ohci, d->ctrlSet, 0x1000);
 			}
 		}
@@ -1283,7 +1313,8 @@
 {
 	struct video_card *video = NULL;
 	struct ti_ohci *ohci;
-	int res = -EINVAL, flags;
+	int res = -EINVAL;
+	unsigned long flags;
 	struct list_head *lh;
 
         spin_lock_irqsave(&video1394_cards_lock, flags);
@@ -1320,7 +1351,8 @@
 
 static int video1394_open(struct inode *inode, struct file *file)
 {
-	int i = MINOR(inode->i_rdev), flags;
+	int i = MINOR(inode->i_rdev);
+	unsigned long flags;
 	struct video_card *video = NULL;
 	struct list_head *lh;
 
@@ -1340,7 +1372,7 @@
         if (video == NULL)
                 return -EIO;
 
-	MOD_INC_USE_COUNT;
+	V22_COMPAT_MOD_INC_USE_COUNT;
 
 	return 0;
 }
@@ -1350,7 +1382,8 @@
 	struct video_card *video = NULL;
 	struct ti_ohci *ohci;
 	u64 mask;
-	int i, flags;
+	int i;
+	unsigned long flags;
 	struct list_head *lh;
 
         spin_lock_irqsave(&video1394_cards_lock, flags);
@@ -1407,16 +1440,17 @@
 			free_dma_iso_ctx(&video->it_context[i]);
 		}
 
-	MOD_DEC_USE_COUNT;
+	V22_COMPAT_MOD_DEC_USE_COUNT;
 
 	unlock_kernel();
 	return 0;
 }
 
-void irq_handler(int card, quadlet_t isoRecvIntEvent, 
+static void irq_handler(int card, quadlet_t isoRecvIntEvent, 
 		 quadlet_t isoXmitIntEvent)
 {
-	int i, flags;
+	int i;
+	unsigned long flags;
 	struct video_card *video = NULL;
 	struct list_head *lh;
 
@@ -1455,7 +1489,7 @@
 
 static struct file_operations video1394_fops=
 {
-	owner:		THIS_MODULE,
+        OWNER_THIS_MODULE
 	ioctl:		video1394_ioctl,
 	mmap:		video1394_mmap,
 	open:		video1394_open,
@@ -1465,7 +1499,7 @@
 static int video1394_init(struct ti_ohci *ohci)
 {
 	struct video_card *video = kmalloc(sizeof(struct video_card), GFP_KERNEL);
-	int flags;
+	unsigned long flags;
 	char name[16];
 
 	if (video == NULL) {
@@ -1525,7 +1559,8 @@
 /* Must be called under spinlock */
 static void remove_card(struct video_card *video)
 {
-	int i, flags;
+	int i;
+	unsigned long flags;
 
 	ohci1394_unregister_video(video->ohci, &video_tmpl);
 
@@ -1556,7 +1591,7 @@
 static void video1394_remove_host (struct hpsb_host *host)
 {
 	struct ti_ohci *ohci;
-	int flags;
+	unsigned long flags;
 	struct list_head *lh;
 
 	/* We only work with the OHCI-1394 driver */
@@ -1623,7 +1658,12 @@
 				VIDEO1394_MAJOR);
 		return -EIO;
 	}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
+	devfs_handle = devfs_mk_dir(NULL, VIDEO1394_DRIVER_NAME,
+			strlen(VIDEO1394_DRIVER_NAME), NULL);
+#else
 	devfs_handle = devfs_mk_dir(NULL, VIDEO1394_DRIVER_NAME, NULL);
+#endif
 
 	hl_handle = hpsb_register_highlevel (VIDEO1394_DRIVER_NAME, &hl_ops);
 	if (hl_handle == NULL) {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)