1/*
2 * Copyright 2023 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: AMD
23 *
24 */
25
26#ifndef _DC_STATE_PRIV_H_
27#define _DC_STATE_PRIV_H_
28
29#include "dc_state.h"
30#include "dc_stream.h"
31
32/* Get the type of the provided resource (none, phantom, main) based on the provided
33 * context. If the context is unavailable, determine only if phantom or not.
34 */
35enum mall_stream_type dc_state_get_pipe_subvp_type(const struct dc_state *state,
36		const struct pipe_ctx *pipe_ctx);
37enum mall_stream_type dc_state_get_stream_subvp_type(const struct dc_state *state,
38		const struct dc_stream_state *stream);
39
40/* Gets the phantom stream if main is provided, gets the main if phantom is provided.*/
41struct dc_stream_state *dc_state_get_paired_subvp_stream(const struct dc_state *state,
42		const struct dc_stream_state *stream);
43
44/* allocate's phantom stream or plane and returns pointer to the object */
45struct dc_stream_state *dc_state_create_phantom_stream(const struct dc *dc,
46		struct dc_state *state,
47		struct dc_stream_state *main_stream);
48struct dc_plane_state *dc_state_create_phantom_plane(struct dc *dc,
49		struct dc_state *state,
50		struct dc_plane_state *main_plane);
51
52/* deallocate's phantom stream or plane */
53void dc_state_release_phantom_stream(const struct dc *dc,
54		struct dc_state *state,
55		struct dc_stream_state *phantom_stream);
56void dc_state_release_phantom_plane(const struct dc *dc,
57		struct dc_state *state,
58		struct dc_plane_state *phantom_plane);
59
60/* add/remove phantom stream to context and generate subvp meta data */
61enum dc_status dc_state_add_phantom_stream(struct dc *dc,
62		struct dc_state *state,
63		struct dc_stream_state *phantom_stream,
64		struct dc_stream_state *main_stream);
65enum dc_status dc_state_remove_phantom_stream(struct dc *dc,
66		struct dc_state *state,
67		struct dc_stream_state *phantom_stream);
68
69bool dc_state_add_phantom_plane(
70		const struct dc *dc,
71		struct dc_stream_state *phantom_stream,
72		struct dc_plane_state *phantom_plane,
73		struct dc_state *state);
74
75bool dc_state_remove_phantom_plane(
76		const struct dc *dc,
77		struct dc_stream_state *phantom_stream,
78		struct dc_plane_state *phantom_plane,
79		struct dc_state *state);
80
81bool dc_state_rem_all_phantom_planes_for_stream(
82		const struct dc *dc,
83		struct dc_stream_state *phantom_stream,
84		struct dc_state *state,
85		bool should_release_planes);
86
87bool dc_state_add_all_phantom_planes_for_stream(
88		const struct dc *dc,
89		struct dc_stream_state *phantom_stream,
90		struct dc_plane_state * const *phantom_planes,
91		int plane_count,
92		struct dc_state *state);
93
94bool dc_state_remove_phantom_streams_and_planes(
95		struct dc *dc,
96		struct dc_state *state);
97
98void dc_state_release_phantom_streams_and_planes(
99		struct dc *dc,
100		struct dc_state *state);
101
102#endif /* _DC_STATE_PRIV_H_ */
103