I've revised Jose Alberto Reguero's patch for ivtv-0.3.2b.
This is along the lines of my revision to his patch for
ivtv-0.2.0-rc3d.

I have NOT tested this.  I tried to use that ATrpms source RPM and
found that this is a very difficult poposition.  Darn.  Can anyone
else suggest an easy path to testing?

I would very much like the fixes to go in.  But without testing, there
ought to be some reluctance.  I hope my explanations for the changes
would help overcome any reluctance.

I am including two patches.  The first is just Jose's, with one
important change and updated to ivtv-0.2.0-rc3d.  I explained the
important change in previous emails:

| All of these declarations of "then" should be of type unsigned long.
| The patch changes them to u64.  So every place that the patch has
| "u64" should instead say "unsigned long".  Simple to fix!

The first patch should be correct: it is hardly different from Jose's
and Jose did testing.  Jose's patch would probably break a 32-bit
system but my version should work on both 32-bit and 64-bit systems.


The second patch has further bug fixes.

The second patch is what needs justification.  Most of the changes
were described in my previous message, but not all.

New:

- in driver.h, the ts field of the struct ivtv_dec_dma was declared to
  be u32.  As far as I can make out, it is only used to store 0 or
  values read from "jiffie".  So I think that it should be of type
  "unsigned long"

  I don't really understand how this field is used: please check my
  work.

- the formats used to format ts must be %lu, not %u.


Remember Axel's post in this thread?
http://sourceforge.net/mailarchive/message.php?msg_id=10630737
I think that he was refering the the field "jiffies" in struct
api_cmd, not the global variable with the same name.  He asked:
        The current "u32 then" only interacts with jiffies which already is
        (unconditionally) a u64. Is this a 64bits issue at all?
The field jiffies is declared u64.  I find that a bit thought
provoking.  Perhaps it too should be "unsigned long".  On the other
hand, the name "api_cmd" suggests that this representation might be
shared with code outside the driver and therefore that the layout
cannot be unilaterally changed.  Does anyone else know?


Old:

- I removed redundant assignments to "then" (i.e. when it was obvious
  that the value stored there would not be used).

- several local variables "then" were not actually used so I deleted
  them

- in one segment of code, a pair of messages printing the duration of
  a delay used an incorrect format and also calculated the value in a
  way that is inaccurate on some systems (eg. those with HZ == 1024).

How can we get this debugged and adopted?  It would be great to
support x86_64.

================ patch 1 ================
diff -Nur ivtv-0.3.2c.ORIG/driver/ivtv-dma.c 
ivtv-0.3.2c.1st-update/driver/ivtv-dma.c
--- ivtv-0.3.2c.ORIG/driver/ivtv-dma.c  2004-09-24 09:50:40.000000000 -0400
+++ ivtv-0.3.2c.1st-update/driver/ivtv-dma.c    2005-01-27 17:07:18.000000000 
-0500
@@ -101,7 +101,7 @@
 {
         DECLARE_WAITQUEUE(wait, current);
         int rc = 0;
-        u32 then;
+        unsigned long then;
 
         then = jiffies;
         add_wait_queue(&itv->streams[type].waitq, &wait);
diff -Nur ivtv-0.3.2c.ORIG/driver/ivtv-fileops.c 
ivtv-0.3.2c.1st-update/driver/ivtv-fileops.c
--- ivtv-0.3.2c.ORIG/driver/ivtv-fileops.c      2004-12-05 19:26:56.000000000 
-0500
+++ ivtv-0.3.2c.1st-update/driver/ivtv-fileops.c        2005-01-27 
17:07:18.000000000 -0500
@@ -276,7 +276,8 @@
        DECLARE_WAITQUEUE(wait, current);
        int idx = itv->vbi_inserted_frame % 20;
        int blocking = !(filp->f_flags & O_NONBLOCK);
-       u32 old_trans_id, then;
+       u32 old_trans_id;
+       unsigned long then;
         u32 bytes_received = 0;
         LIST_HEAD(full_list);
 
diff -Nur ivtv-0.3.2c.ORIG/driver/ivtv-irq.c 
ivtv-0.3.2c.1st-update/driver/ivtv-irq.c
--- ivtv-0.3.2c.ORIG/driver/ivtv-irq.c  2004-11-28 01:46:22.000000000 -0500
+++ ivtv-0.3.2c.1st-update/driver/ivtv-irq.c    2005-01-27 17:07:18.000000000 
-0500
@@ -406,7 +406,7 @@
         struct ivtv_buffer *buf;
         LIST_HEAD(free_list);
        int xfer_pad;
-       u32 then;
+       unsigned long then;
        int redo_dma = 0;
        DECLARE_WAITQUEUE(wait, current);
        int rc = 0;
diff -Nur ivtv-0.3.2c.ORIG/driver/ivtv-osd.c 
ivtv-0.3.2c.1st-update/driver/ivtv-osd.c
--- ivtv-0.3.2c.ORIG/driver/ivtv-osd.c  2005-01-24 14:26:04.000000000 -0500
+++ ivtv-0.3.2c.1st-update/driver/ivtv-osd.c    2005-01-27 17:07:18.000000000 
-0500
@@ -773,7 +773,7 @@
                &itv->streams[IVTV_DEC_STREAM_TYPE_MPG];
        u32 data[IVTV_MBOX_MAX_DATA];
        int ret = 0;
-       u32 then;
+       unsigned long then;
        int redo_dma = 0;
        unsigned long flags;
 
@@ -948,7 +948,7 @@
         int cur_buf = 0;
         int offset = 0;
         int ret = 0;
-        u32 then;
+        unsigned long then;
         int redo_dma = 0;
         unsigned long flags;
         int i;
@@ -1209,7 +1209,7 @@
         int rc = 0;
         struct ivtv_stream *stream = /* Use Decoder Stream for locking */
                 &itv->streams[IVTV_DEC_STREAM_TYPE_OSD];
-        u32 then;
+        unsigned long then;
         DECLARE_WAITQUEUE(wait, current);
 
         /* If needing to re-setup the OSD */
@@ -1272,7 +1272,7 @@
         int rc = 0;
         struct ivtv_stream *stream = /* Use Decoder Stream for locking */
                 &itv->streams[IVTV_DEC_STREAM_TYPE_YUV];
-        u32 then;
+        unsigned long then;
         DECLARE_WAITQUEUE(wait, current);
 
         then = jiffies;
@@ -1324,7 +1324,7 @@
        int rc = 0;
        struct ivtv_stream *stream = /* Use Decoder Stream for locking */
                &itv->streams[IVTV_DEC_STREAM_TYPE_MPG];
-       u32 then;
+       unsigned long then;
        DECLARE_WAITQUEUE(wait, current);
 
 
diff -Nur ivtv-0.3.2c.ORIG/driver/ivtv-streams.c 
ivtv-0.3.2c.1st-update/driver/ivtv-streams.c
--- ivtv-0.3.2c.ORIG/driver/ivtv-streams.c      2004-12-17 14:14:49.000000000 
-0500
+++ ivtv-0.3.2c.1st-update/driver/ivtv-streams.c        2005-01-27 
17:07:18.000000000 -0500
@@ -1018,7 +1018,8 @@
 int ivtv_stop_capture(struct ivtv *itv, int type)
 {
        struct ivtv_stream *st = &itv->streams[type];
-       int cap_type, then;
+       int cap_type;
+       unsigned long then;
        int x;
        int stopmode;
        u32 data[IVTV_MBOX_MAX_DATA], result;
@@ -1194,7 +1195,7 @@
 static void ivtv_stop_wait(struct ivtv *itv, int type) {
         DECLARE_WAITQUEUE(wait, current);
         int rc = 0;
-        u32 then;
+        unsigned long then;
 
         then = jiffies;
         add_wait_queue(&itv->streams[type].waitq, &wait);
================ end of patch 1 ================


================ patch 2 ================
diff -Nur ivtv-0.3.2c.1st-update/driver/ivtv-driver.h 
ivtv-0.3.2c/driver/ivtv-driver.h
--- ivtv-0.3.2c.1st-update/driver/ivtv-driver.h 2005-01-24 14:26:19.000000000 
-0500.1st
+++ ivtv-0.3.2c/driver/ivtv-driver.h    2005-01-27 17:44:05.000000000 -0500
@@ -310,7 +310,7 @@
        u32             data[IVTV_MBOX_MAX_DATA];
        u32             speed_data[IVTV_MBOX_MAX_DATA];
        atomic_t        vsync_count;
-       u32             ts;
+       unsigned long   ts;
        u32             wq_runs;
        atomic_t        intr;
 };
diff -Nur ivtv-0.3.2c.1st-update/driver/ivtv-irq.c ivtv-0.3.2c/driver/ivtv-irq.c
--- ivtv-0.3.2c.1st-update/driver/ivtv-irq.c    2005-01-27 17:07:18.000000000 
-0500
+++ ivtv-0.3.2c/driver/ivtv-irq.c       2005-01-27 17:18:01.000000000 -0500
@@ -486,7 +486,6 @@
        if (type == 1)
                bytes_needed += (UVsize%itv->dma_cfg.enc_yuv_buf_size) + 
(size%itv->dma_cfg.enc_yuv_buf_size);
 
-        then = jiffies;
         add_wait_queue(&st->waitq, &wait);
         do {
                 set_current_state(TASK_INTERRUPTIBLE);
diff -Nur ivtv-0.3.2c.1st-update/driver/ivtv-kthreads.c 
ivtv-0.3.2c/driver/ivtv-kthreads.c
--- ivtv-0.3.2c.1st-update/driver/ivtv-kthreads.c       2005-01-27 
17:07:18.000000000 -0500
+++ ivtv-0.3.2c/driver/ivtv-kthreads.c  2005-01-27 17:45:14.000000000 -0500
@@ -373,7 +373,7 @@
         int type = IVTV_DEC_STREAM_TYPE_MPG;
         struct ivtv_stream *stream= &itv->streams[type];
        int ret = -1;
-       unsigned long then = 0; 
+       unsigned long then;     
        int rc = 0;
         int x=0, bytes_written=0;
         struct ivtv_buffer *buf;
@@ -854,7 +854,7 @@
                        "total_xfer: 0x%08x\n"
                        " sg_bytes: 0x%08x\n"
                        " vsync_count: %d\n"
-                       " ts: %u\n",
+                       " ts: %lu\n",
                        atomic_read(&itv->dec_dma_stat.type),
                        itv->dec_dma_stat.last_xfer,
                        itv->dec_dma_stat.last_addr,
diff -Nur ivtv-0.3.2c.1st-update/driver/ivtv-osd.c ivtv-0.3.2c/driver/ivtv-osd.c
--- ivtv-0.3.2c.1st-update/driver/ivtv-osd.c    2005-01-27 17:07:18.000000000 
-0500
+++ ivtv-0.3.2c/driver/ivtv-osd.c       2005-01-27 17:18:01.000000000 -0500
@@ -1209,14 +1209,12 @@
         int rc = 0;
         struct ivtv_stream *stream = /* Use Decoder Stream for locking */
                 &itv->streams[IVTV_DEC_STREAM_TYPE_OSD];
-        unsigned long then;
         DECLARE_WAITQUEUE(wait, current);
 
         /* If needing to re-setup the OSD */
         if (test_and_clear_bit(OSD_RESET_NEEDED, &itv->r_flags))
                 ivtvfb_setup();
 
-        then = jiffies;
         add_wait_queue(&stream->waitq, &wait);
         do {
                 set_current_state(TASK_INTERRUPTIBLE);
@@ -1272,10 +1270,8 @@
         int rc = 0;
         struct ivtv_stream *stream = /* Use Decoder Stream for locking */
                 &itv->streams[IVTV_DEC_STREAM_TYPE_YUV];
-        unsigned long then;
         DECLARE_WAITQUEUE(wait, current);
 
-        then = jiffies;
         add_wait_queue(&stream->waitq, &wait);
         do {
                 set_current_state(TASK_INTERRUPTIBLE);
@@ -1324,7 +1320,6 @@
        int rc = 0;
        struct ivtv_stream *stream = /* Use Decoder Stream for locking */
                &itv->streams[IVTV_DEC_STREAM_TYPE_MPG];
-       unsigned long then;
        DECLARE_WAITQUEUE(wait, current);
 
 
@@ -1334,7 +1329,6 @@
                clear_bit(DMA_IN_USE, &stream->udma.u_flags);
        }
 
-       then = jiffies;
        add_wait_queue(&stream->udma.waitq, &wait);
        do {
                set_current_state(TASK_INTERRUPTIBLE);
diff -Nur ivtv-0.3.2c.1st-update/driver/ivtv-streams.c 
ivtv-0.3.2c/driver/ivtv-streams.c
--- ivtv-0.3.2c.1st-update/driver/ivtv-streams.c        2005-01-27 
17:07:18.000000000 -0500
+++ ivtv-0.3.2c/driver/ivtv-streams.c   2005-01-27 17:18:01.000000000 -0500
@@ -1105,20 +1105,20 @@
                         {
                                 schedule_timeout(HZ/100);
                         }
-                        then = jiffies - then;
+                        then = ((1000 + HZ/2) / HZ) * (jiffies - then);
 
                         if (!test_bit(IVTV_F_I_EOS, &itv->i_flags)) {
                                 IVTV_DEBUG(IVTV_DEBUG_ERR,
                                         "ENC: EOS interrupt not "
                                         "received! stopping anyway.\n");
                                 IVTV_DEBUG(IVTV_DEBUG_ERR,
-                                        "ENC: waited %d ms.\n",
-                                        (1000/HZ)*then);
+                                        "ENC: waited %lu ms.\n",
+                                        then);
                         } else {
                                 IVTV_DEBUG(IVTV_DEBUG_ERR,
-                                        "ENC: EOS took %d "
+                                        "ENC: EOS took %lu "
                                         "ms to occur.\n",
-                                        (1000/HZ)*then);
+                                        then);
                         }
                         set_current_state(TASK_RUNNING);
                         remove_wait_queue(&itv->cap_w, &wait);
================ end of patch 2 ================


-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
ivtv-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ivtv-devel

Reply via email to