Input: xpad - add support for Xbox1 PDP Camo series gamepad
[linux/fpc-iii.git] / drivers / media / platform / mtk-vcodec / mtk_vcodec_intr.c
blob52e7e5c9afa088b944d42a42b25cf09fb6d0ed19
1 /*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Tiffany Lin <tiffany.lin@mediatek.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <linux/errno.h>
16 #include <linux/wait.h>
18 #include "mtk_vcodec_drv.h"
19 #include "mtk_vcodec_intr.h"
20 #include "mtk_vcodec_util.h"
22 int mtk_vcodec_wait_for_done_ctx(struct mtk_vcodec_ctx *ctx, int command,
23 unsigned int timeout_ms)
25 wait_queue_head_t *waitqueue;
26 long timeout_jiff, ret;
27 int status = 0;
29 waitqueue = (wait_queue_head_t *)&ctx->queue;
30 timeout_jiff = msecs_to_jiffies(timeout_ms);
32 ret = wait_event_interruptible_timeout(*waitqueue,
33 (ctx->int_cond &&
34 (ctx->int_type == command)),
35 timeout_jiff);
37 if (!ret) {
38 status = -1; /* timeout */
39 mtk_v4l2_err("[%d] cmd=%d, ctx->type=%d, wait_event_interruptible_timeout time=%ums out %d %d!",
40 ctx->id, ctx->type, command, timeout_ms,
41 ctx->int_cond, ctx->int_type);
42 } else if (-ERESTARTSYS == ret) {
43 mtk_v4l2_err("[%d] cmd=%d, ctx->type=%d, wait_event_interruptible_timeout interrupted by a signal %d %d",
44 ctx->id, ctx->type, command, ctx->int_cond,
45 ctx->int_type);
46 status = -1;
49 ctx->int_cond = 0;
50 ctx->int_type = 0;
52 return status;
54 EXPORT_SYMBOL(mtk_vcodec_wait_for_done_ctx);