1 // SPDX-License-Identifier: GPL-2.0-only
3 * drivers/media/platform/samsung/mfc5/s5p_mfc_intr.c
5 * C file for Samsung MFC (Multi Function Codec - FIMV) driver
6 * This file contains functions used to wait for command completion.
8 * Kamil Debski, Copyright (C) 2011 Samsung Electronics Co., Ltd.
9 * http://www.samsung.com/
12 #include <linux/delay.h>
13 #include <linux/errno.h>
15 #include <linux/sched.h>
16 #include <linux/wait.h>
17 #include "s5p_mfc_common.h"
18 #include "s5p_mfc_debug.h"
19 #include "s5p_mfc_intr.h"
21 int s5p_mfc_wait_for_done_dev(struct s5p_mfc_dev
*dev
, int command
)
25 ret
= wait_event_interruptible_timeout(dev
->queue
,
26 (dev
->int_cond
&& (dev
->int_type
== command
27 || dev
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)),
28 msecs_to_jiffies(MFC_INT_TIMEOUT
));
30 mfc_err("Interrupt (dev->int_type:%d, command:%d) timed out\n",
31 dev
->int_type
, command
);
33 } else if (ret
== -ERESTARTSYS
) {
34 mfc_err("Interrupted by a signal\n");
37 mfc_debug(1, "Finished waiting (dev->int_type:%d, command: %d)\n",
38 dev
->int_type
, command
);
39 if (dev
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)
44 void s5p_mfc_clean_dev_int_flags(struct s5p_mfc_dev
*dev
)
51 int s5p_mfc_wait_for_done_ctx(struct s5p_mfc_ctx
*ctx
,
52 int command
, int interrupt
)
57 ret
= wait_event_interruptible_timeout(ctx
->queue
,
58 (ctx
->int_cond
&& (ctx
->int_type
== command
59 || ctx
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)),
60 msecs_to_jiffies(MFC_INT_TIMEOUT
));
62 ret
= wait_event_timeout(ctx
->queue
,
63 (ctx
->int_cond
&& (ctx
->int_type
== command
64 || ctx
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)),
65 msecs_to_jiffies(MFC_INT_TIMEOUT
));
68 mfc_err("Interrupt (ctx->int_type:%d, command:%d) timed out\n",
69 ctx
->int_type
, command
);
71 } else if (ret
== -ERESTARTSYS
) {
72 mfc_err("Interrupted by a signal\n");
75 mfc_debug(1, "Finished waiting (ctx->int_type:%d, command: %d)\n",
76 ctx
->int_type
, command
);
77 if (ctx
->int_type
== S5P_MFC_R2H_CMD_ERR_RET
)
82 void s5p_mfc_clean_ctx_int_flags(struct s5p_mfc_ctx
*ctx
)