diff options
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-mailbox.c')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-mailbox.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/drivers/media/video/ivtv/ivtv-mailbox.c b/drivers/media/video/ivtv/ivtv-mailbox.c index 6ae42a3b03cc..814a673712b3 100644 --- a/drivers/media/video/ivtv/ivtv-mailbox.c +++ b/drivers/media/video/ivtv/ivtv-mailbox.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #define API_RESULT (1 << 1) /* Allow 1 second for this cmd to end */ | 37 | #define API_RESULT (1 << 1) /* Allow 1 second for this cmd to end */ |
38 | #define API_FAST_RESULT (3 << 1) /* Allow 0.1 second for this cmd to end */ | 38 | #define API_FAST_RESULT (3 << 1) /* Allow 0.1 second for this cmd to end */ |
39 | #define API_DMA (1 << 3) /* DMA mailbox, has special handling */ | 39 | #define API_DMA (1 << 3) /* DMA mailbox, has special handling */ |
40 | #define API_HIGH_VOL (1 << 5) /* High volume command (i.e. called during encoding or decoding) */ | ||
40 | #define API_NO_WAIT_MB (1 << 4) /* Command may not wait for a free mailbox */ | 41 | #define API_NO_WAIT_MB (1 << 4) /* Command may not wait for a free mailbox */ |
41 | #define API_NO_WAIT_RES (1 << 5) /* Command may not wait for the result */ | 42 | #define API_NO_WAIT_RES (1 << 5) /* Command may not wait for the result */ |
42 | 43 | ||
@@ -77,11 +78,11 @@ static const struct ivtv_api_info api_info[256] = { | |||
77 | API_ENTRY(CX2341X_ENC_SET_DMA_BLOCK_SIZE, API_CACHE), | 78 | API_ENTRY(CX2341X_ENC_SET_DMA_BLOCK_SIZE, API_CACHE), |
78 | API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_10, API_FAST_RESULT), | 79 | API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_10, API_FAST_RESULT), |
79 | API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_9, API_FAST_RESULT), | 80 | API_ENTRY(CX2341X_ENC_GET_PREV_DMA_INFO_MB_9, API_FAST_RESULT), |
80 | API_ENTRY(CX2341X_ENC_SCHED_DMA_TO_HOST, API_DMA), | 81 | API_ENTRY(CX2341X_ENC_SCHED_DMA_TO_HOST, API_DMA | API_HIGH_VOL), |
81 | API_ENTRY(CX2341X_ENC_INITIALIZE_INPUT, API_RESULT), | 82 | API_ENTRY(CX2341X_ENC_INITIALIZE_INPUT, API_RESULT), |
82 | API_ENTRY(CX2341X_ENC_SET_FRAME_DROP_RATE, API_CACHE), | 83 | API_ENTRY(CX2341X_ENC_SET_FRAME_DROP_RATE, API_CACHE), |
83 | API_ENTRY(CX2341X_ENC_PAUSE_ENCODER, API_RESULT), | 84 | API_ENTRY(CX2341X_ENC_PAUSE_ENCODER, API_RESULT), |
84 | API_ENTRY(CX2341X_ENC_REFRESH_INPUT, API_NO_WAIT_MB), | 85 | API_ENTRY(CX2341X_ENC_REFRESH_INPUT, API_NO_WAIT_MB | API_HIGH_VOL), |
85 | API_ENTRY(CX2341X_ENC_SET_COPYRIGHT, API_CACHE), | 86 | API_ENTRY(CX2341X_ENC_SET_COPYRIGHT, API_CACHE), |
86 | API_ENTRY(CX2341X_ENC_SET_EVENT_NOTIFICATION, API_RESULT), | 87 | API_ENTRY(CX2341X_ENC_SET_EVENT_NOTIFICATION, API_RESULT), |
87 | API_ENTRY(CX2341X_ENC_SET_NUM_VSYNC_LINES, API_CACHE), | 88 | API_ENTRY(CX2341X_ENC_SET_NUM_VSYNC_LINES, API_CACHE), |
@@ -102,7 +103,7 @@ static const struct ivtv_api_info api_info[256] = { | |||
102 | API_ENTRY(CX2341X_DEC_SET_DMA_BLOCK_SIZE, API_CACHE), | 103 | API_ENTRY(CX2341X_DEC_SET_DMA_BLOCK_SIZE, API_CACHE), |
103 | API_ENTRY(CX2341X_DEC_GET_XFER_INFO, API_FAST_RESULT), | 104 | API_ENTRY(CX2341X_DEC_GET_XFER_INFO, API_FAST_RESULT), |
104 | API_ENTRY(CX2341X_DEC_GET_DMA_STATUS, API_FAST_RESULT), | 105 | API_ENTRY(CX2341X_DEC_GET_DMA_STATUS, API_FAST_RESULT), |
105 | API_ENTRY(CX2341X_DEC_SCHED_DMA_FROM_HOST, API_DMA), | 106 | API_ENTRY(CX2341X_DEC_SCHED_DMA_FROM_HOST, API_DMA | API_HIGH_VOL), |
106 | API_ENTRY(CX2341X_DEC_PAUSE_PLAYBACK, API_RESULT), | 107 | API_ENTRY(CX2341X_DEC_PAUSE_PLAYBACK, API_RESULT), |
107 | API_ENTRY(CX2341X_DEC_HALT_FW, API_FAST_RESULT), | 108 | API_ENTRY(CX2341X_DEC_HALT_FW, API_FAST_RESULT), |
108 | API_ENTRY(CX2341X_DEC_SET_STANDARD, API_CACHE), | 109 | API_ENTRY(CX2341X_DEC_SET_STANDARD, API_CACHE), |
@@ -175,9 +176,9 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f | |||
175 | 176 | ||
176 | /* Sleep before a retry, if not atomic */ | 177 | /* Sleep before a retry, if not atomic */ |
177 | if (!(flags & API_NO_WAIT_MB)) { | 178 | if (!(flags & API_NO_WAIT_MB)) { |
178 | if (jiffies - then > retries * HZ / 100) | 179 | if (jiffies - then > msecs_to_jiffies(10*retries)) |
179 | break; | 180 | break; |
180 | ivtv_sleep_timeout(HZ / 100, 0); | 181 | ivtv_msleep_timeout(10, 0); |
181 | } | 182 | } |
182 | } | 183 | } |
183 | return -ENODEV; | 184 | return -ENODEV; |
@@ -212,7 +213,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
212 | { | 213 | { |
213 | 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; |
214 | volatile struct ivtv_mailbox __iomem *mbox; | 215 | volatile struct ivtv_mailbox __iomem *mbox; |
215 | int api_timeout = HZ; | 216 | int api_timeout = msecs_to_jiffies(1000); |
216 | int flags, mb, i; | 217 | int flags, mb, i; |
217 | unsigned long then; | 218 | unsigned long then; |
218 | 219 | ||
@@ -227,7 +228,12 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
227 | return -EINVAL; | 228 | return -EINVAL; |
228 | } | 229 | } |
229 | 230 | ||
230 | IVTV_DEBUG_API("API Call: %s\n", api_info[cmd].name); | 231 | if (api_info[cmd].flags & API_HIGH_VOL) { |
232 | IVTV_DEBUG_HI_API("API Call: %s\n", api_info[cmd].name); | ||
233 | } | ||
234 | else { | ||
235 | IVTV_DEBUG_API("API Call: %s\n", api_info[cmd].name); | ||
236 | } | ||
231 | 237 | ||
232 | /* clear possibly uninitialized part of data array */ | 238 | /* clear possibly uninitialized part of data array */ |
233 | for (i = args; i < CX2341X_MBOX_MAX_DATA; i++) | 239 | for (i = args; i < CX2341X_MBOX_MAX_DATA; i++) |
@@ -237,7 +243,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
237 | 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. |
238 | Just an optimization to prevent unnecessary use of mailboxes. */ | 244 | Just an optimization to prevent unnecessary use of mailboxes. */ |
239 | if (itv->api_cache[cmd].last_jiffies && | 245 | if (itv->api_cache[cmd].last_jiffies && |
240 | jiffies - itv->api_cache[cmd].last_jiffies < HZ * 1800 && | 246 | jiffies - itv->api_cache[cmd].last_jiffies < msecs_to_jiffies(1800000) && |
241 | !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))) { |
242 | itv->api_cache[cmd].last_jiffies = jiffies; | 248 | itv->api_cache[cmd].last_jiffies = jiffies; |
243 | return 0; | 249 | return 0; |
@@ -262,7 +268,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
262 | } | 268 | } |
263 | 269 | ||
264 | if ((flags & API_FAST_RESULT) == API_FAST_RESULT) | 270 | if ((flags & API_FAST_RESULT) == API_FAST_RESULT) |
265 | api_timeout = HZ / 10; | 271 | api_timeout = msecs_to_jiffies(100); |
266 | 272 | ||
267 | mb = get_mailbox(itv, mbdata, flags); | 273 | mb = get_mailbox(itv, mbdata, flags); |
268 | if (mb < 0) { | 274 | if (mb < 0) { |
@@ -295,11 +301,12 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
295 | if (flags & API_NO_WAIT_RES) | 301 | if (flags & API_NO_WAIT_RES) |
296 | mdelay(1); | 302 | mdelay(1); |
297 | else | 303 | else |
298 | ivtv_sleep_timeout(HZ / 100, 0); | 304 | ivtv_msleep_timeout(10, 0); |
299 | } | 305 | } |
300 | if (jiffies - then > HZ / 10) | 306 | if (jiffies - then > msecs_to_jiffies(100)) |
301 | IVTV_DEBUG_WARN("%s took %lu jiffies (%d per HZ)\n", | 307 | IVTV_DEBUG_WARN("%s took %u jiffies\n", |
302 | api_info[cmd].name, jiffies - then, HZ); | 308 | api_info[cmd].name, |
309 | jiffies_to_msecs(jiffies - then)); | ||
303 | 310 | ||
304 | for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++) | 311 | for (i = 0; i < CX2341X_MBOX_MAX_DATA; i++) |
305 | data[i] = readl(&mbox->data[i]); | 312 | data[i] = readl(&mbox->data[i]); |