1/*	$NetBSD: amdgpu_virtual_stream_encoder.c,v 1.2 2021/12/18 23:45:06 riastradh Exp $	*/
2
3/*
4 * Copyright 2012-15 Advanced Micro Devices, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors: AMD
25 *
26 */
27
28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: amdgpu_virtual_stream_encoder.c,v 1.2 2021/12/18 23:45:06 riastradh Exp $");
30
31#include <linux/slab.h>
32
33#include "dm_services.h"
34#include "virtual_stream_encoder.h"
35
36static void virtual_stream_encoder_dp_set_stream_attribute(
37	struct stream_encoder *enc,
38	struct dc_crtc_timing *crtc_timing,
39	enum dc_color_space output_color_space,
40	bool use_vsc_sdp_for_colorimetry,
41	uint32_t enable_sdp_splitting) {}
42
43static void virtual_stream_encoder_hdmi_set_stream_attribute(
44	struct stream_encoder *enc,
45	struct dc_crtc_timing *crtc_timing,
46	int actual_pix_clk_khz,
47	bool enable_audio) {}
48
49static void virtual_stream_encoder_dvi_set_stream_attribute(
50	struct stream_encoder *enc,
51	struct dc_crtc_timing *crtc_timing,
52	bool is_dual_link) {}
53
54static void virtual_stream_encoder_set_mst_bandwidth(
55	struct stream_encoder *enc,
56	struct fixed31_32 avg_time_slots_per_mtp) {}
57
58static void virtual_stream_encoder_update_hdmi_info_packets(
59	struct stream_encoder *enc,
60	const struct encoder_info_frame *info_frame) {}
61
62static void virtual_stream_encoder_stop_hdmi_info_packets(
63	struct stream_encoder *enc) {}
64
65static void virtual_stream_encoder_set_avmute(
66	struct stream_encoder *enc,
67	bool enable) {}
68static void virtual_stream_encoder_update_dp_info_packets(
69	struct stream_encoder *enc,
70	const struct encoder_info_frame *info_frame) {}
71
72static void virtual_stream_encoder_stop_dp_info_packets(
73	struct stream_encoder *enc) {}
74
75static void virtual_stream_encoder_dp_blank(
76	struct stream_encoder *enc) {}
77
78static void virtual_stream_encoder_dp_unblank(
79	struct stream_encoder *enc,
80	const struct encoder_unblank_param *param) {}
81
82static void virtual_audio_mute_control(
83	struct stream_encoder *enc,
84	bool mute) {}
85
86static void virtual_stream_encoder_reset_hdmi_stream_attribute(
87		struct stream_encoder *enc)
88{}
89
90static void virtual_enc_dp_set_odm_combine(
91	struct stream_encoder *enc,
92	bool odm_combine)
93{}
94
95static const struct stream_encoder_funcs virtual_str_enc_funcs = {
96	.dp_set_odm_combine =
97		virtual_enc_dp_set_odm_combine,
98	.dp_set_stream_attribute =
99		virtual_stream_encoder_dp_set_stream_attribute,
100	.hdmi_set_stream_attribute =
101		virtual_stream_encoder_hdmi_set_stream_attribute,
102	.dvi_set_stream_attribute =
103		virtual_stream_encoder_dvi_set_stream_attribute,
104	.set_mst_bandwidth =
105		virtual_stream_encoder_set_mst_bandwidth,
106	.update_hdmi_info_packets =
107		virtual_stream_encoder_update_hdmi_info_packets,
108	.stop_hdmi_info_packets =
109		virtual_stream_encoder_stop_hdmi_info_packets,
110	.update_dp_info_packets =
111		virtual_stream_encoder_update_dp_info_packets,
112	.stop_dp_info_packets =
113		virtual_stream_encoder_stop_dp_info_packets,
114	.dp_blank =
115		virtual_stream_encoder_dp_blank,
116	.dp_unblank =
117		virtual_stream_encoder_dp_unblank,
118
119	.audio_mute_control = virtual_audio_mute_control,
120	.set_avmute = virtual_stream_encoder_set_avmute,
121	.hdmi_reset_stream_attribute = virtual_stream_encoder_reset_hdmi_stream_attribute,
122};
123
124bool virtual_stream_encoder_construct(
125	struct stream_encoder *enc,
126	struct dc_context *ctx,
127	struct dc_bios *bp)
128{
129	if (!enc)
130		return false;
131	if (!bp)
132		return false;
133
134	enc->funcs = &virtual_str_enc_funcs;
135	enc->ctx = ctx;
136	enc->id = ENGINE_ID_VIRTUAL;
137	enc->bp = bp;
138
139	return true;
140}
141
142struct stream_encoder *virtual_stream_encoder_create(
143	struct dc_context *ctx, struct dc_bios *bp)
144{
145	struct stream_encoder *enc = kzalloc(sizeof(*enc), GFP_KERNEL);
146
147	if (!enc)
148		return NULL;
149
150	if (virtual_stream_encoder_construct(enc, ctx, bp))
151		return enc;
152
153	BREAK_TO_DEBUGGER();
154	kfree(enc);
155	return NULL;
156}
157
158