V4L/DVB (5865): Remove usage of HZ on ivtv driver, replacing by msecs_to_jiffies
authorMauro Carvalho Chehab <mchehab@infradead.org>
Thu, 19 Jul 2007 14:21:04 +0000 (11:21 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Fri, 20 Jul 2007 20:35:51 +0000 (17:35 -0300)
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/ivtv/ivtv-driver.c
drivers/media/video/ivtv/ivtv-driver.h
drivers/media/video/ivtv/ivtv-fileops.c
drivers/media/video/ivtv/ivtv-firmware.c
drivers/media/video/ivtv/ivtv-irq.c
drivers/media/video/ivtv/ivtv-mailbox.c
drivers/media/video/ivtv/ivtv-streams.c

index 9e4edb8..d73d433 100644 (file)
@@ -275,9 +275,10 @@ int ivtv_waitq(wait_queue_head_t *waitq)
 }
 
 /* Generic utility functions */
-int ivtv_sleep_timeout(int timeout, int intr)
+int ivtv_msleep_timeout(unsigned int msecs, int intr)
 {
        int ret;
+       int timeout = msecs_to_jiffies(msecs);
 
        do {
                set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
index 6c1a85f..91b588d 100644 (file)
@@ -848,7 +848,7 @@ int ivtv_set_output_mode(struct ivtv *itv, int mode);
 struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv);
 
 /* Return non-zero if a signal is pending */
-int ivtv_sleep_timeout(int timeout, int intr);
+int ivtv_msleep_timeout(unsigned int msecs, int intr);
 
 /* Wait on queue, returns -EINTR if interrupted */
 int ivtv_waitq(wait_queue_head_t *waitq);
index 489fbf2..8e97a93 100644 (file)
@@ -218,7 +218,7 @@ static struct ivtv_buffer *ivtv_get_buffer(struct ivtv_stream *s, int non_block,
                        /* Process pending program info updates and pending VBI data */
                        ivtv_update_pgm_info(itv);
 
-                       if (jiffies - itv->dualwatch_jiffies > HZ) {
+                       if (jiffies - itv->dualwatch_jiffies > msecs_to_jiffies(1000)) {
                                itv->dualwatch_jiffies = jiffies;
                                ivtv_dualwatch(itv);
                        }
@@ -924,7 +924,7 @@ void ivtv_unmute(struct ivtv *itv)
        if (atomic_read(&itv->capturing) == 0)
                ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
 
-       ivtv_sleep_timeout(HZ / 10, 0);
+       ivtv_msleep_timeout(100, 0);
 
        if (atomic_read(&itv->capturing)) {
                ivtv_vapi(itv, CX2341X_ENC_MISC, 1, 12);
index 5bc45c9..d0feabf 100644 (file)
@@ -36,7 +36,7 @@
 #define IVTV_CMD_SPU_STOP              0x00000001
 #define IVTV_CMD_SDRAM_PRECHARGE_INIT  0x0000001A
 #define IVTV_CMD_SDRAM_REFRESH_INIT    0x80000640
-#define IVTV_SDRAM_SLEEPTIME           (60 * HZ / 100) /* 600 ms */
+#define IVTV_SDRAM_SLEEPTIME           600
 
 #define IVTV_DECODE_INIT_MPEG_FILENAME         "v4l-cx2341x-init.mpg"
 #define IVTV_DECODE_INIT_MPEG_SIZE     (152*1024)
@@ -89,7 +89,7 @@ void ivtv_halt_firmware(struct ivtv *itv)
        if (itv->enc_mbox.mbox)
                ivtv_vapi(itv, CX2341X_ENC_HALT_FW, 0);
 
-       ivtv_sleep_timeout(HZ / 100, 0);
+       ivtv_msleep_timeout(10, 0);
        itv->enc_mbox.mbox = itv->dec_mbox.mbox = NULL;
 
        IVTV_DEBUG_INFO("Stopping VDM\n");
@@ -113,7 +113,7 @@ void ivtv_halt_firmware(struct ivtv *itv)
        IVTV_DEBUG_INFO("Stopping SPU\n");
        write_reg(IVTV_CMD_SPU_STOP, IVTV_REG_SPU);
 
-       ivtv_sleep_timeout(HZ / 100, 0);
+       ivtv_msleep_timeout(10, 0);
 
        IVTV_DEBUG_INFO("init Encoder SDRAM pre-charge\n");
        write_reg(IVTV_CMD_SDRAM_PRECHARGE_INIT, IVTV_REG_ENC_SDRAM_PRECHARGE);
@@ -129,9 +129,8 @@ void ivtv_halt_firmware(struct ivtv *itv)
                write_reg(IVTV_CMD_SDRAM_REFRESH_INIT, IVTV_REG_DEC_SDRAM_REFRESH);
        }
 
-       IVTV_DEBUG_INFO("Sleeping for %dms (600 recommended)\n",
-                  (int)(IVTV_SDRAM_SLEEPTIME * 1000 / HZ));
-       ivtv_sleep_timeout(IVTV_SDRAM_SLEEPTIME, 0);
+       IVTV_DEBUG_INFO("Sleeping for %dms\n", IVTV_SDRAM_SLEEPTIME);
+       ivtv_msleep_timeout(IVTV_SDRAM_SLEEPTIME, 0);
 }
 
 void ivtv_firmware_versions(struct ivtv *itv)
@@ -204,12 +203,12 @@ int ivtv_firmware_init(struct ivtv *itv)
 
        /* start firmware */
        write_reg(read_reg(IVTV_REG_SPU) & IVTV_MASK_SPU_ENABLE, IVTV_REG_SPU);
-       ivtv_sleep_timeout(HZ / 10, 0);
+       ivtv_msleep_timeout(100, 0);
        if (itv->has_cx23415)
                write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE15, IVTV_REG_VPU);
        else
                write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE16, IVTV_REG_VPU);
-       ivtv_sleep_timeout(HZ / 10, 0);
+       ivtv_msleep_timeout(100, 0);
 
        /* find mailboxes and ping firmware */
        itv->enc_mbox.mbox = ivtv_search_mailbox(itv->enc_mem, IVTV_ENCODER_SIZE);
@@ -264,7 +263,7 @@ void ivtv_init_mpeg_decoder(struct ivtv *itv)
                                IVTV_DECODE_INIT_MPEG_FILENAME);
        } else {
                ivtv_vapi(itv, CX2341X_DEC_SCHED_DMA_FROM_HOST, 3, 0, readbytes, 0);
-               ivtv_sleep_timeout(HZ / 10, 0);
+               ivtv_msleep_timeout(100, 0);
        }
        ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 4, 0, 0, 0, 1);
 }
index 1a3ee46..14f35df 100644 (file)
@@ -420,7 +420,7 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
                write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER);
                set_bit(IVTV_F_I_DMA, &itv->i_flags);
                itv->cur_dma_stream = s->type;
-               itv->dma_timer.expires = jiffies + HZ / 10;
+               itv->dma_timer.expires = jiffies + msecs_to_jiffies(100);
                add_timer(&itv->dma_timer);
        }
 }
@@ -437,7 +437,7 @@ static void ivtv_dma_dec_start(struct ivtv_stream *s)
        write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x01, IVTV_REG_DMAXFER);
        set_bit(IVTV_F_I_DMA, &itv->i_flags);
        itv->cur_dma_stream = s->type;
-       itv->dma_timer.expires = jiffies + HZ / 10;
+       itv->dma_timer.expires = jiffies + msecs_to_jiffies(100);
        add_timer(&itv->dma_timer);
 }
 
index eaa43e9..814a673 100644 (file)
@@ -176,9 +176,9 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f
 
                /* Sleep before a retry, if not atomic */
                if (!(flags & API_NO_WAIT_MB)) {
-                       if (jiffies - then > retries * HZ / 100)
+                       if (jiffies - then > msecs_to_jiffies(10*retries))
                               break;
-                       ivtv_sleep_timeout(HZ / 100, 0);
+                       ivtv_msleep_timeout(10, 0);
                }
        }
        return -ENODEV;
@@ -213,7 +213,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
 {
        struct ivtv_mailbox_data *mbdata = (cmd >= 128) ? &itv->enc_mbox : &itv->dec_mbox;
        volatile struct ivtv_mailbox __iomem *mbox;
-       int api_timeout = HZ;
+       int api_timeout = msecs_to_jiffies(1000);
        int flags, mb, i;
        unsigned long then;
 
@@ -243,7 +243,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
           data, then just return 0 as there is no need to issue this command again.
           Just an optimization to prevent unnecessary use of mailboxes. */
        if (itv->api_cache[cmd].last_jiffies &&
-           jiffies - itv->api_cache[cmd].last_jiffies < HZ * 1800 &&
+           jiffies - itv->api_cache[cmd].last_jiffies < msecs_to_jiffies(1800000) &&
            !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) {
                itv->api_cache[cmd].last_jiffies = jiffies;
                return 0;
@@ -268,7 +268,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
        }
 
        if ((flags & API_FAST_RESULT) == API_FAST_RESULT)
-               api_timeout = HZ / 10;
+               api_timeout = msecs_to_jiffies(100);
 
        mb = get_mailbox(itv, mbdata, flags);
        if (mb < 0) {
@@ -301,11 +301,12 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
                if (flags & API_NO_WAIT_RES)
                        mdelay(1);
                else
-                       ivtv_sleep_timeout(HZ / 100, 0);
+                       ivtv_msleep_timeout(10, 0);
        }
-       if (jiffies - then > HZ / 10)
-               IVTV_DEBUG_WARN("%s took %lu jiffies (%d per HZ)\n",
-                               api_info[cmd].name, jiffies - then, HZ);
+       if (jiffies - then > msecs_to_jiffies(100))
+               IVTV_DEBUG_WARN("%s took %u jiffies\n",
+                               api_info[cmd].name,
+                               jiffies_to_msecs(jiffies - then));
 
        for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++)
                data[i] = readl(&mbox->data[i]);
index 2871171..322b347 100644 (file)
@@ -565,7 +565,7 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s)
                /* Initialize Digitizer for Capture */
                ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0);
 
-               ivtv_sleep_timeout(HZ / 10, 0);
+               ivtv_msleep_timeout(100, 0);
        }
 
        /* begin_capture */
@@ -781,8 +781,9 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
                        set_current_state(TASK_INTERRUPTIBLE);
 
                        /* wait 2s for EOS interrupt */
-                       while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && jiffies < then + 2 * HZ) {
-                               schedule_timeout(HZ / 100);
+                       while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) &&
+                               jiffies < then + msecs_to_jiffies (2000)) {
+                               schedule_timeout(msecs_to_jiffies(10));
                        }
 
                        /* To convert jiffies to ms, we must multiply by 1000
@@ -821,7 +822,8 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
                        } else if (read_reg(IVTV_REG_DMASTATUS) & 0x02) {
                                break;
                        }
-               } while (!ivtv_sleep_timeout(HZ / 100, 1) && then + HZ * 2 > jiffies);
+               } while (!ivtv_msleep_timeout(10, 1) &&
+                        then + msecs_to_jiffies(2000) > jiffies);
 
                set_current_state(TASK_RUNNING);
                remove_wait_queue(&s->waitq, &wait);
@@ -892,7 +894,7 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts)
                                        break;
                                tmp = data[3];
                        }
-                       if (ivtv_sleep_timeout(HZ/10, 1))
+                       if (ivtv_msleep_timeout(100, 1))
                                break;
                }
        }