diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-07-19 10:21:04 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-07-20 16:35:51 -0400 |
commit | 201700d3544c653d453716a60976efe1987110af (patch) | |
tree | 8052fb09ac170b6de4b28737f89cb2621fac4fe7 /drivers/media | |
parent | fe06fe0a4d0f781f8ae0570e4d7e517a81878c1d (diff) |
V4L/DVB (5865): Remove usage of HZ on ivtv driver, replacing by msecs_to_jiffies
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-driver.c | 3 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-driver.h | 2 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-fileops.c | 4 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-firmware.c | 17 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-irq.c | 4 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-mailbox.c | 19 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-streams.c | 12 |
7 files changed, 32 insertions, 29 deletions
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index 9e4edb8b7d82..d73d433a4ff6 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -275,9 +275,10 @@ int ivtv_waitq(wait_queue_head_t *waitq) | |||
275 | } | 275 | } |
276 | 276 | ||
277 | /* Generic utility functions */ | 277 | /* Generic utility functions */ |
278 | int ivtv_sleep_timeout(int timeout, int intr) | 278 | int ivtv_msleep_timeout(unsigned int msecs, int intr) |
279 | { | 279 | { |
280 | int ret; | 280 | int ret; |
281 | int timeout = msecs_to_jiffies(msecs); | ||
281 | 282 | ||
282 | do { | 283 | do { |
283 | set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); | 284 | set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); |
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h index 6c1a85f1ee1b..91b588d261ae 100644 --- a/drivers/media/video/ivtv/ivtv-driver.h +++ b/drivers/media/video/ivtv/ivtv-driver.h | |||
@@ -848,7 +848,7 @@ int ivtv_set_output_mode(struct ivtv *itv, int mode); | |||
848 | struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv); | 848 | struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv); |
849 | 849 | ||
850 | /* Return non-zero if a signal is pending */ | 850 | /* Return non-zero if a signal is pending */ |
851 | int ivtv_sleep_timeout(int timeout, int intr); | 851 | int ivtv_msleep_timeout(unsigned int msecs, int intr); |
852 | 852 | ||
853 | /* Wait on queue, returns -EINTR if interrupted */ | 853 | /* Wait on queue, returns -EINTR if interrupted */ |
854 | int ivtv_waitq(wait_queue_head_t *waitq); | 854 | int ivtv_waitq(wait_queue_head_t *waitq); |
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index 489fbf25e723..8e97a938398f 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
@@ -218,7 +218,7 @@ static struct ivtv_buffer *ivtv_get_buffer(struct ivtv_stream *s, int non_block, | |||
218 | /* Process pending program info updates and pending VBI data */ | 218 | /* Process pending program info updates and pending VBI data */ |
219 | ivtv_update_pgm_info(itv); | 219 | ivtv_update_pgm_info(itv); |
220 | 220 | ||
221 | if (jiffies - itv->dualwatch_jiffies > HZ) { | 221 | if (jiffies - itv->dualwatch_jiffies > msecs_to_jiffies(1000)) { |
222 | itv->dualwatch_jiffies = jiffies; | 222 | itv->dualwatch_jiffies = jiffies; |
223 | ivtv_dualwatch(itv); | 223 | ivtv_dualwatch(itv); |
224 | } | 224 | } |
@@ -924,7 +924,7 @@ void ivtv_unmute(struct ivtv *itv) | |||
924 | if (atomic_read(&itv->capturing) == 0) | 924 | if (atomic_read(&itv->capturing) == 0) |
925 | ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0); | 925 | ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0); |
926 | 926 | ||
927 | ivtv_sleep_timeout(HZ / 10, 0); | 927 | ivtv_msleep_timeout(100, 0); |
928 | 928 | ||
929 | if (atomic_read(&itv->capturing)) { | 929 | if (atomic_read(&itv->capturing)) { |
930 | ivtv_vapi(itv, CX2341X_ENC_MISC, 1, 12); | 930 | ivtv_vapi(itv, CX2341X_ENC_MISC, 1, 12); |
diff --git a/drivers/media/video/ivtv/ivtv-firmware.c b/drivers/media/video/ivtv/ivtv-firmware.c index 5bc45c9f0df2..d0feabf93080 100644 --- a/drivers/media/video/ivtv/ivtv-firmware.c +++ b/drivers/media/video/ivtv/ivtv-firmware.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #define IVTV_CMD_SPU_STOP 0x00000001 | 36 | #define IVTV_CMD_SPU_STOP 0x00000001 |
37 | #define IVTV_CMD_SDRAM_PRECHARGE_INIT 0x0000001A | 37 | #define IVTV_CMD_SDRAM_PRECHARGE_INIT 0x0000001A |
38 | #define IVTV_CMD_SDRAM_REFRESH_INIT 0x80000640 | 38 | #define IVTV_CMD_SDRAM_REFRESH_INIT 0x80000640 |
39 | #define IVTV_SDRAM_SLEEPTIME (60 * HZ / 100) /* 600 ms */ | 39 | #define IVTV_SDRAM_SLEEPTIME 600 |
40 | 40 | ||
41 | #define IVTV_DECODE_INIT_MPEG_FILENAME "v4l-cx2341x-init.mpg" | 41 | #define IVTV_DECODE_INIT_MPEG_FILENAME "v4l-cx2341x-init.mpg" |
42 | #define IVTV_DECODE_INIT_MPEG_SIZE (152*1024) | 42 | #define IVTV_DECODE_INIT_MPEG_SIZE (152*1024) |
@@ -89,7 +89,7 @@ void ivtv_halt_firmware(struct ivtv *itv) | |||
89 | if (itv->enc_mbox.mbox) | 89 | if (itv->enc_mbox.mbox) |
90 | ivtv_vapi(itv, CX2341X_ENC_HALT_FW, 0); | 90 | ivtv_vapi(itv, CX2341X_ENC_HALT_FW, 0); |
91 | 91 | ||
92 | ivtv_sleep_timeout(HZ / 100, 0); | 92 | ivtv_msleep_timeout(10, 0); |
93 | itv->enc_mbox.mbox = itv->dec_mbox.mbox = NULL; | 93 | itv->enc_mbox.mbox = itv->dec_mbox.mbox = NULL; |
94 | 94 | ||
95 | IVTV_DEBUG_INFO("Stopping VDM\n"); | 95 | IVTV_DEBUG_INFO("Stopping VDM\n"); |
@@ -113,7 +113,7 @@ void ivtv_halt_firmware(struct ivtv *itv) | |||
113 | IVTV_DEBUG_INFO("Stopping SPU\n"); | 113 | IVTV_DEBUG_INFO("Stopping SPU\n"); |
114 | write_reg(IVTV_CMD_SPU_STOP, IVTV_REG_SPU); | 114 | write_reg(IVTV_CMD_SPU_STOP, IVTV_REG_SPU); |
115 | 115 | ||
116 | ivtv_sleep_timeout(HZ / 100, 0); | 116 | ivtv_msleep_timeout(10, 0); |
117 | 117 | ||
118 | IVTV_DEBUG_INFO("init Encoder SDRAM pre-charge\n"); | 118 | IVTV_DEBUG_INFO("init Encoder SDRAM pre-charge\n"); |
119 | write_reg(IVTV_CMD_SDRAM_PRECHARGE_INIT, IVTV_REG_ENC_SDRAM_PRECHARGE); | 119 | write_reg(IVTV_CMD_SDRAM_PRECHARGE_INIT, IVTV_REG_ENC_SDRAM_PRECHARGE); |
@@ -129,9 +129,8 @@ void ivtv_halt_firmware(struct ivtv *itv) | |||
129 | write_reg(IVTV_CMD_SDRAM_REFRESH_INIT, IVTV_REG_DEC_SDRAM_REFRESH); | 129 | write_reg(IVTV_CMD_SDRAM_REFRESH_INIT, IVTV_REG_DEC_SDRAM_REFRESH); |
130 | } | 130 | } |
131 | 131 | ||
132 | IVTV_DEBUG_INFO("Sleeping for %dms (600 recommended)\n", | 132 | IVTV_DEBUG_INFO("Sleeping for %dms\n", IVTV_SDRAM_SLEEPTIME); |
133 | (int)(IVTV_SDRAM_SLEEPTIME * 1000 / HZ)); | 133 | ivtv_msleep_timeout(IVTV_SDRAM_SLEEPTIME, 0); |
134 | ivtv_sleep_timeout(IVTV_SDRAM_SLEEPTIME, 0); | ||
135 | } | 134 | } |
136 | 135 | ||
137 | void ivtv_firmware_versions(struct ivtv *itv) | 136 | void ivtv_firmware_versions(struct ivtv *itv) |
@@ -204,12 +203,12 @@ int ivtv_firmware_init(struct ivtv *itv) | |||
204 | 203 | ||
205 | /* start firmware */ | 204 | /* start firmware */ |
206 | write_reg(read_reg(IVTV_REG_SPU) & IVTV_MASK_SPU_ENABLE, IVTV_REG_SPU); | 205 | write_reg(read_reg(IVTV_REG_SPU) & IVTV_MASK_SPU_ENABLE, IVTV_REG_SPU); |
207 | ivtv_sleep_timeout(HZ / 10, 0); | 206 | ivtv_msleep_timeout(100, 0); |
208 | if (itv->has_cx23415) | 207 | if (itv->has_cx23415) |
209 | write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE15, IVTV_REG_VPU); | 208 | write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE15, IVTV_REG_VPU); |
210 | else | 209 | else |
211 | write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE16, IVTV_REG_VPU); | 210 | write_reg(read_reg(IVTV_REG_VPU) & IVTV_MASK_VPU_ENABLE16, IVTV_REG_VPU); |
212 | ivtv_sleep_timeout(HZ / 10, 0); | 211 | ivtv_msleep_timeout(100, 0); |
213 | 212 | ||
214 | /* find mailboxes and ping firmware */ | 213 | /* find mailboxes and ping firmware */ |
215 | itv->enc_mbox.mbox = ivtv_search_mailbox(itv->enc_mem, IVTV_ENCODER_SIZE); | 214 | 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) | |||
264 | IVTV_DECODE_INIT_MPEG_FILENAME); | 263 | IVTV_DECODE_INIT_MPEG_FILENAME); |
265 | } else { | 264 | } else { |
266 | ivtv_vapi(itv, CX2341X_DEC_SCHED_DMA_FROM_HOST, 3, 0, readbytes, 0); | 265 | ivtv_vapi(itv, CX2341X_DEC_SCHED_DMA_FROM_HOST, 3, 0, readbytes, 0); |
267 | ivtv_sleep_timeout(HZ / 10, 0); | 266 | ivtv_msleep_timeout(100, 0); |
268 | } | 267 | } |
269 | ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 4, 0, 0, 0, 1); | 268 | ivtv_vapi(itv, CX2341X_DEC_STOP_PLAYBACK, 4, 0, 0, 0, 1); |
270 | } | 269 | } |
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c index 1a3ee464a826..14f35df05fa2 100644 --- a/drivers/media/video/ivtv/ivtv-irq.c +++ b/drivers/media/video/ivtv/ivtv-irq.c | |||
@@ -420,7 +420,7 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s) | |||
420 | write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER); | 420 | write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER); |
421 | set_bit(IVTV_F_I_DMA, &itv->i_flags); | 421 | set_bit(IVTV_F_I_DMA, &itv->i_flags); |
422 | itv->cur_dma_stream = s->type; | 422 | itv->cur_dma_stream = s->type; |
423 | itv->dma_timer.expires = jiffies + HZ / 10; | 423 | itv->dma_timer.expires = jiffies + msecs_to_jiffies(100); |
424 | add_timer(&itv->dma_timer); | 424 | add_timer(&itv->dma_timer); |
425 | } | 425 | } |
426 | } | 426 | } |
@@ -437,7 +437,7 @@ static void ivtv_dma_dec_start(struct ivtv_stream *s) | |||
437 | write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x01, IVTV_REG_DMAXFER); | 437 | write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x01, IVTV_REG_DMAXFER); |
438 | set_bit(IVTV_F_I_DMA, &itv->i_flags); | 438 | set_bit(IVTV_F_I_DMA, &itv->i_flags); |
439 | itv->cur_dma_stream = s->type; | 439 | itv->cur_dma_stream = s->type; |
440 | itv->dma_timer.expires = jiffies + HZ / 10; | 440 | itv->dma_timer.expires = jiffies + msecs_to_jiffies(100); |
441 | add_timer(&itv->dma_timer); | 441 | add_timer(&itv->dma_timer); |
442 | } | 442 | } |
443 | 443 | ||
diff --git a/drivers/media/video/ivtv/ivtv-mailbox.c b/drivers/media/video/ivtv/ivtv-mailbox.c index eaa43e9e9185..814a673712b3 100644 --- a/drivers/media/video/ivtv/ivtv-mailbox.c +++ b/drivers/media/video/ivtv/ivtv-mailbox.c | |||
@@ -176,9 +176,9 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f | |||
176 | 176 | ||
177 | /* Sleep before a retry, if not atomic */ | 177 | /* Sleep before a retry, if not atomic */ |
178 | if (!(flags & API_NO_WAIT_MB)) { | 178 | if (!(flags & API_NO_WAIT_MB)) { |
179 | if (jiffies - then > retries * HZ / 100) | 179 | if (jiffies - then > msecs_to_jiffies(10*retries)) |
180 | break; | 180 | break; |
181 | ivtv_sleep_timeout(HZ / 100, 0); | 181 | ivtv_msleep_timeout(10, 0); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | return -ENODEV; | 184 | return -ENODEV; |
@@ -213,7 +213,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
213 | { | 213 | { |
214 | struct ivtv_mailbox_data *mbdata = (cmd >= 128) ? &itv->enc_mbox : &itv->dec_mbox; | 214 | struct ivtv_mailbox_data *mbdata = (cmd >= 128) ? &itv->enc_mbox : &itv->dec_mbox; |
215 | volatile struct ivtv_mailbox __iomem *mbox; | 215 | volatile struct ivtv_mailbox __iomem *mbox; |
216 | int api_timeout = HZ; | 216 | int api_timeout = msecs_to_jiffies(1000); |
217 | int flags, mb, i; | 217 | int flags, mb, i; |
218 | unsigned long then; | 218 | unsigned long then; |
219 | 219 | ||
@@ -243,7 +243,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
243 | data, then just return 0 as there is no need to issue this command again. | 243 | data, then just return 0 as there is no need to issue this command again. |
244 | Just an optimization to prevent unnecessary use of mailboxes. */ | 244 | Just an optimization to prevent unnecessary use of mailboxes. */ |
245 | if (itv->api_cache[cmd].last_jiffies && | 245 | if (itv->api_cache[cmd].last_jiffies && |
246 | jiffies - itv->api_cache[cmd].last_jiffies < HZ * 1800 && | 246 | jiffies - itv->api_cache[cmd].last_jiffies < msecs_to_jiffies(1800000) && |
247 | !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) { | 247 | !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) { |
248 | itv->api_cache[cmd].last_jiffies = jiffies; | 248 | itv->api_cache[cmd].last_jiffies = jiffies; |
249 | return 0; | 249 | return 0; |
@@ -268,7 +268,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
268 | } | 268 | } |
269 | 269 | ||
270 | if ((flags & API_FAST_RESULT) == API_FAST_RESULT) | 270 | if ((flags & API_FAST_RESULT) == API_FAST_RESULT) |
271 | api_timeout = HZ / 10; | 271 | api_timeout = msecs_to_jiffies(100); |
272 | 272 | ||
273 | mb = get_mailbox(itv, mbdata, flags); | 273 | mb = get_mailbox(itv, mbdata, flags); |
274 | if (mb < 0) { | 274 | if (mb < 0) { |
@@ -301,11 +301,12 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
301 | if (flags & API_NO_WAIT_RES) | 301 | if (flags & API_NO_WAIT_RES) |
302 | mdelay(1); | 302 | mdelay(1); |
303 | else | 303 | else |
304 | ivtv_sleep_timeout(HZ / 100, 0); | 304 | ivtv_msleep_timeout(10, 0); |
305 | } | 305 | } |
306 | if (jiffies - then > HZ / 10) | 306 | if (jiffies - then > msecs_to_jiffies(100)) |
307 | IVTV_DEBUG_WARN("%s took %lu jiffies (%d per HZ)\n", | 307 | IVTV_DEBUG_WARN("%s took %u jiffies\n", |
308 | api_info[cmd].name, jiffies - then, HZ); | 308 | api_info[cmd].name, |
309 | jiffies_to_msecs(jiffies - then)); | ||
309 | 310 | ||
310 | for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++) | 311 | for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++) |
311 | data[i] = readl(&mbox->data[i]); | 312 | data[i] = readl(&mbox->data[i]); |
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index 287117187499..322b347b67c2 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
@@ -565,7 +565,7 @@ int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s) | |||
565 | /* Initialize Digitizer for Capture */ | 565 | /* Initialize Digitizer for Capture */ |
566 | ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0); | 566 | ivtv_vapi(itv, CX2341X_ENC_INITIALIZE_INPUT, 0); |
567 | 567 | ||
568 | ivtv_sleep_timeout(HZ / 10, 0); | 568 | ivtv_msleep_timeout(100, 0); |
569 | } | 569 | } |
570 | 570 | ||
571 | /* begin_capture */ | 571 | /* begin_capture */ |
@@ -781,8 +781,9 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end) | |||
781 | set_current_state(TASK_INTERRUPTIBLE); | 781 | set_current_state(TASK_INTERRUPTIBLE); |
782 | 782 | ||
783 | /* wait 2s for EOS interrupt */ | 783 | /* wait 2s for EOS interrupt */ |
784 | while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && jiffies < then + 2 * HZ) { | 784 | while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && |
785 | schedule_timeout(HZ / 100); | 785 | jiffies < then + msecs_to_jiffies (2000)) { |
786 | schedule_timeout(msecs_to_jiffies(10)); | ||
786 | } | 787 | } |
787 | 788 | ||
788 | /* To convert jiffies to ms, we must multiply by 1000 | 789 | /* 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) | |||
821 | } else if (read_reg(IVTV_REG_DMASTATUS) & 0x02) { | 822 | } else if (read_reg(IVTV_REG_DMASTATUS) & 0x02) { |
822 | break; | 823 | break; |
823 | } | 824 | } |
824 | } while (!ivtv_sleep_timeout(HZ / 100, 1) && then + HZ * 2 > jiffies); | 825 | } while (!ivtv_msleep_timeout(10, 1) && |
826 | then + msecs_to_jiffies(2000) > jiffies); | ||
825 | 827 | ||
826 | set_current_state(TASK_RUNNING); | 828 | set_current_state(TASK_RUNNING); |
827 | remove_wait_queue(&s->waitq, &wait); | 829 | remove_wait_queue(&s->waitq, &wait); |
@@ -892,7 +894,7 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts) | |||
892 | break; | 894 | break; |
893 | tmp = data[3]; | 895 | tmp = data[3]; |
894 | } | 896 | } |
895 | if (ivtv_sleep_timeout(HZ/10, 1)) | 897 | if (ivtv_msleep_timeout(100, 1)) |
896 | break; | 898 | break; |
897 | } | 899 | } |
898 | } | 900 | } |