Linux Audio

Check our new training course

Loading...
v5.14.15
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * drivers/media/platform/samsung/mfc5/s5p_mfc_intr.c
 4 *
 5 * C file for Samsung MFC (Multi Function Codec - FIMV) driver
 6 * This file contains functions used to wait for command completion.
 7 *
 8 * Kamil Debski, Copyright (C) 2011 Samsung Electronics Co., Ltd.
 9 * http://www.samsung.com/
 
 
 
 
10 */
11
12#include <linux/delay.h>
13#include <linux/errno.h>
14#include <linux/io.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"
20
21int s5p_mfc_wait_for_done_dev(struct s5p_mfc_dev *dev, int command)
22{
23	int ret;
24
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));
29	if (ret == 0) {
30		mfc_err("Interrupt (dev->int_type:%d, command:%d) timed out\n",
31							dev->int_type, command);
32		return 1;
33	} else if (ret == -ERESTARTSYS) {
34		mfc_err("Interrupted by a signal\n");
35		return 1;
36	}
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)
40		return 1;
41	return 0;
42}
43
44void s5p_mfc_clean_dev_int_flags(struct s5p_mfc_dev *dev)
45{
46	dev->int_cond = 0;
47	dev->int_type = 0;
48	dev->int_err = 0;
49}
50
51int s5p_mfc_wait_for_done_ctx(struct s5p_mfc_ctx *ctx,
52				    int command, int interrupt)
53{
54	int ret;
55
56	if (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));
61	} else {
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));
66	}
67	if (ret == 0) {
68		mfc_err("Interrupt (ctx->int_type:%d, command:%d) timed out\n",
69							ctx->int_type, command);
70		return 1;
71	} else if (ret == -ERESTARTSYS) {
72		mfc_err("Interrupted by a signal\n");
73		return 1;
74	}
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)
78		return 1;
79	return 0;
80}
81
82void s5p_mfc_clean_ctx_int_flags(struct s5p_mfc_ctx *ctx)
83{
84	ctx->int_cond = 0;
85	ctx->int_type = 0;
86	ctx->int_err = 0;
87}
88
v4.10.11
 
 1/*
 2 * drivers/media/platform/samsung/mfc5/s5p_mfc_intr.c
 3 *
 4 * C file for Samsung MFC (Multi Function Codec - FIMV) driver
 5 * This file contains functions used to wait for command completion.
 6 *
 7 * Kamil Debski, Copyright (C) 2011 Samsung Electronics Co., Ltd.
 8 * http://www.samsung.com/
 9 *
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.
13 */
14
15#include <linux/delay.h>
16#include <linux/errno.h>
17#include <linux/io.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"
23
24int s5p_mfc_wait_for_done_dev(struct s5p_mfc_dev *dev, int command)
25{
26	int ret;
27
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));
32	if (ret == 0) {
33		mfc_err("Interrupt (dev->int_type:%d, command:%d) timed out\n",
34							dev->int_type, command);
35		return 1;
36	} else if (ret == -ERESTARTSYS) {
37		mfc_err("Interrupted by a signal\n");
38		return 1;
39	}
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)
43		return 1;
44	return 0;
45}
46
47void s5p_mfc_clean_dev_int_flags(struct s5p_mfc_dev *dev)
48{
49	dev->int_cond = 0;
50	dev->int_type = 0;
51	dev->int_err = 0;
52}
53
54int s5p_mfc_wait_for_done_ctx(struct s5p_mfc_ctx *ctx,
55				    int command, int interrupt)
56{
57	int ret;
58
59	if (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));
64	} else {
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));
69	}
70	if (ret == 0) {
71		mfc_err("Interrupt (ctx->int_type:%d, command:%d) timed out\n",
72							ctx->int_type, command);
73		return 1;
74	} else if (ret == -ERESTARTSYS) {
75		mfc_err("Interrupted by a signal\n");
76		return 1;
77	}
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)
81		return 1;
82	return 0;
83}
84
85void s5p_mfc_clean_ctx_int_flags(struct s5p_mfc_ctx *ctx)
86{
87	ctx->int_cond = 0;
88	ctx->int_type = 0;
89	ctx->int_err = 0;
90}
91