2 * drivers/media/platform/samsung/mfc5/s5p_mfc_intr.c
4 * C file for Samsung MFC (Multi Function Codec - FIMV) driver
5 * This file contains functions used to wait for command completion.
7 * Kamil Debski, Copyright (C) 2011 Samsung Electronics Co., Ltd.
8 * http://www.samsung.com/
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/delay.h>
16 #include <linux/errno.h>
18 #include <linux/sched.h>
19 #include <linux/wait.h>
20 #include "s5p_mfc_common.h"
21 #include "s5p_mfc_debug.h"
22 #include "s5p_mfc_intr.h"
24 int s5p_mfc_wait_for_done_dev(struct s5p_mfc_dev
*dev
, int command
)
28 ret
= wait_event_interruptible_timeout(dev
->queue
,
29 (dev
->int_cond
&& (dev
->int_type
== command
30 || dev
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)),
31 msecs_to_jiffies(MFC_INT_TIMEOUT
));
33 mfc_err("Interrupt (dev->int_type:%d, command:%d) timed out\n",
34 dev
->int_type
, command
);
36 } else if (ret
== -ERESTARTSYS
) {
37 mfc_err("Interrupted by a signal\n");
40 mfc_debug(1, "Finished waiting (dev->int_type:%d, command: %d)\n",
41 dev
->int_type
, command
);
42 if (dev
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)
47 void s5p_mfc_clean_dev_int_flags(struct s5p_mfc_dev
*dev
)
54 int s5p_mfc_wait_for_done_ctx(struct s5p_mfc_ctx
*ctx
,
55 int command
, int interrupt
)
60 ret
= wait_event_interruptible_timeout(ctx
->queue
,
61 (ctx
->int_cond
&& (ctx
->int_type
== command
62 || ctx
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)),
63 msecs_to_jiffies(MFC_INT_TIMEOUT
));
65 ret
= wait_event_timeout(ctx
->queue
,
66 (ctx
->int_cond
&& (ctx
->int_type
== command
67 || ctx
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)),
68 msecs_to_jiffies(MFC_INT_TIMEOUT
));
71 mfc_err("Interrupt (ctx->int_type:%d, command:%d) timed out\n",
72 ctx
->int_type
, command
);
74 } else if (ret
== -ERESTARTSYS
) {
75 mfc_err("Interrupted by a signal\n");
78 mfc_debug(1, "Finished waiting (ctx->int_type:%d, command: %d)\n",
79 ctx
->int_type
, command
);
80 if (ctx
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)
85 void s5p_mfc_clean_ctx_int_flags(struct s5p_mfc_ctx
*ctx
)