summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/qcom/iris/iris_state.h
blob: 78c61aac5e7e0e1c7ee6d3fb6f9b121b61481a2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
 */

#ifndef __IRIS_STATE_H__
#define __IRIS_STATE_H__

struct iris_inst;

/**
 * enum iris_core_state
 *
 * @IRIS_CORE_DEINIT: default state.
 * @IRIS_CORE_INIT:   core state with core initialized. FW loaded and
 *                   HW brought out of reset, shared queues established
 *                   between host driver and firmware.
 * @IRIS_CORE_ERROR:  error state.
 *
 *        -----------
 *             |
 *             V
 *        -----------
 *   +--->| DEINIT  |<---+
 *   |   -----------    |
 *   |         |        |
 *   |         v        |
 *   |   -----------    |
 *   |     /     \      |
 *   |    /       \     |
 *   |   /         \    |
 *   |  v           v   v
 * -----------    -----------
 * |  INIT  |--->|  ERROR  |
 * -----------    -----------
 */
enum iris_core_state {
	IRIS_CORE_DEINIT,
	IRIS_CORE_INIT,
	IRIS_CORE_ERROR,
};

/**
 * enum iris_inst_state
 *
 * @IRIS_INST_INIT: video instance is opened.
 * @IRIS_INST_INPUT_STREAMING: stream on is completed on output plane.
 * @IRIS_INST_OUTPUT_STREAMING: stream on is completed on capture plane.
 * @IRIS_INST_STREAMING: stream on is completed on both output and capture planes.
 * @IRIS_INST_DEINIT: video instance is closed.
 * @IRIS_INST_ERROR: error state.
 *                    |
 *                    V
 *             -------------
 *   +--------|     INIT    |----------+
 *   |         -------------           |
 *   |            ^   ^                |
 *   |           /      \              |
 *   |          /        \             |
 *   |         v          v            |
 *   |   -----------    -----------    |
 *   |   |   INPUT         OUTPUT  |   |
 *   |---| STREAMING     STREAMING |---|
 *   |   -----------    -----------    |
 *   |       ^            ^            |
 *   |         \          /            |
 *   |          \        /             |
 *   |           v      v              |
 *   |         -------------           |
 *   |--------|  STREAMING |-----------|
 *   |        -------------            |
 *   |               |                 |
 *   |               |                 |
 *   |               v                 |
 *   |          -----------            |
 *   +-------->|  DEINIT   |<----------+
 *   |          -----------            |
 *   |               |                 |
 *   |               |                 |
 *   |               v                 |
 *   |          ----------             |
 *   +-------->|   ERROR |<------------+
 *              ----------
 */
enum iris_inst_state {
	IRIS_INST_DEINIT,
	IRIS_INST_INIT,
	IRIS_INST_INPUT_STREAMING,
	IRIS_INST_OUTPUT_STREAMING,
	IRIS_INST_STREAMING,
	IRIS_INST_ERROR,
};

#define IRIS_INST_SUB_STATES		8
#define IRIS_INST_MAX_SUB_STATE_VALUE	((1 << IRIS_INST_SUB_STATES) - 1)

/**
 * enum iris_inst_sub_state
 *
 * @IRIS_INST_SUB_FIRST_IPSC: indicates source change is received from firmware
 *			     when output port is not yet streaming.
 * @IRIS_INST_SUB_DRC: indicates source change is received from firmware
 *		      when output port is streaming and source change event is
 *		      sent to client.
 * @IRIS_INST_SUB_DRC_LAST: indicates last buffer is received from firmware
 *                         as part of source change.
 * @IRIS_INST_SUB_DRAIN: indicates drain is in progress.
 * @IRIS_INST_SUB_DRAIN_LAST: indicates last buffer is received from firmware
 *                           as part of drain sequence.
 * @IRIS_INST_SUB_INPUT_PAUSE: source change is received form firmware. This
 *                            indicates that firmware is paused to process
 *                            any further input frames.
 * @IRIS_INST_SUB_OUTPUT_PAUSE: last buffer is received form firmware as part
 *                             of drc sequence. This indicates that
 *                             firmware is paused to process any further output frames.
 * @IRIS_INST_SUB_LOAD_RESOURCES: indicates all the resources have been loaded by the
 *                               firmware and it is ready for processing.
 */
enum iris_inst_sub_state {
	IRIS_INST_SUB_FIRST_IPSC	= BIT(0),
	IRIS_INST_SUB_DRC		= BIT(1),
	IRIS_INST_SUB_DRC_LAST		= BIT(2),
	IRIS_INST_SUB_DRAIN		= BIT(3),
	IRIS_INST_SUB_DRAIN_LAST	= BIT(4),
	IRIS_INST_SUB_INPUT_PAUSE	= BIT(5),
	IRIS_INST_SUB_OUTPUT_PAUSE	= BIT(6),
	IRIS_INST_SUB_LOAD_RESOURCES	= BIT(7),
};

int iris_inst_change_state(struct iris_inst *inst,
			   enum iris_inst_state request_state);
int iris_inst_change_sub_state(struct iris_inst *inst,
			       enum iris_inst_sub_state clear_sub_state,
			       enum iris_inst_sub_state set_sub_state);

int iris_inst_state_change_streamon(struct iris_inst *inst, u32 plane);
int iris_inst_state_change_streamoff(struct iris_inst *inst, u32 plane);
int iris_inst_sub_state_change_drc(struct iris_inst *inst);
int iris_inst_sub_state_change_drain_last(struct iris_inst *inst);
int iris_inst_sub_state_change_drc_last(struct iris_inst *inst);
int iris_inst_sub_state_change_pause(struct iris_inst *inst, u32 plane);
bool iris_allow_cmd(struct iris_inst *inst, u32 cmd);

#endif