1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016 MediaTek Inc.
4 * Author: Tiffany Lin <tiffany.lin@mediatek.com>
7 #include <linux/errno.h>
8 #include <linux/wait.h>
10 #include "mtk_vcodec_drv.h"
11 #include "mtk_vcodec_intr.h"
12 #include "mtk_vcodec_util.h"
14 int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx
*ctx
, int command
,
15 unsigned int timeout_ms
)
17 wait_queue_head_t
*waitqueue
;
18 long timeout_jiff
, ret
;
21 waitqueue
= (wait_queue_head_t
*)&ctx
->queue
;
22 timeout_jiff
= msecs_to_jiffies(timeout_ms
);
24 ret
= wait_event_interruptible_timeout(*waitqueue
,
29 status
= -1; /* timeout */
30 mtk_v4l2_err("[%d] cmd=%d, ctx->type=%d, wait_event_interruptible_timeout time=%ums out %d %d!",
31 ctx
->id
, ctx
->type
, command
, timeout_ms
,
32 ctx
->int_cond
, ctx
->int_type
);
33 } else if (-ERESTARTSYS
== ret
) {
34 mtk_v4l2_err("[%d] cmd=%d, ctx->type=%d, wait_event_interruptible_timeout interrupted by a signal %d %d",
35 ctx
->id
, ctx
->type
, command
, ctx
->int_cond
,
45 EXPORT_SYMBOL(mtk_vcodec_wait_for_done_ctx
);