1 /*
2  * Copyright 2012-15 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 #include "dm_services.h"
27 #include "virtual_stream_encoder.h"
28 
29 static void virtual_stream_encoder_dp_set_stream_attribute(
30 	struct stream_encoder *enc,
31 	struct dc_crtc_timing *crtc_timing,
32 	enum dc_color_space output_color_space,
33 	uint32_t enable_sdp_splitting) {}
34 
35 static void virtual_stream_encoder_hdmi_set_stream_attribute(
36 	struct stream_encoder *enc,
37 	struct dc_crtc_timing *crtc_timing,
38 	int actual_pix_clk_khz,
39 	bool enable_audio) {}
40 
41 static void virtual_stream_encoder_dvi_set_stream_attribute(
42 	struct stream_encoder *enc,
43 	struct dc_crtc_timing *crtc_timing,
44 	bool is_dual_link) {}
45 
46 static void virtual_stream_encoder_set_mst_bandwidth(
47 	struct stream_encoder *enc,
48 	struct fixed31_32 avg_time_slots_per_mtp) {}
49 
50 static void virtual_stream_encoder_update_hdmi_info_packets(
51 	struct stream_encoder *enc,
52 	const struct encoder_info_frame *info_frame) {}
53 
54 static void virtual_stream_encoder_stop_hdmi_info_packets(
55 	struct stream_encoder *enc) {}
56 
57 static void virtual_stream_encoder_set_avmute(
58 	struct stream_encoder *enc,
59 	bool enable) {}
60 static void virtual_stream_encoder_update_dp_info_packets(
61 	struct stream_encoder *enc,
62 	const struct encoder_info_frame *info_frame) {}
63 
64 static void virtual_stream_encoder_stop_dp_info_packets(
65 	struct stream_encoder *enc) {}
66 
67 static void virtual_stream_encoder_dp_blank(
68 	struct stream_encoder *enc) {}
69 
70 static void virtual_stream_encoder_dp_unblank(
71 	struct stream_encoder *enc,
72 	const struct encoder_unblank_param *param) {}
73 
74 static void virtual_audio_mute_control(
75 	struct stream_encoder *enc,
76 	bool mute) {}
77 
78 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
79 #endif
80 
81 static const struct stream_encoder_funcs virtual_str_enc_funcs = {
82 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
83 #endif
84 	.dp_set_stream_attribute =
85 		virtual_stream_encoder_dp_set_stream_attribute,
86 	.hdmi_set_stream_attribute =
87 		virtual_stream_encoder_hdmi_set_stream_attribute,
88 	.dvi_set_stream_attribute =
89 		virtual_stream_encoder_dvi_set_stream_attribute,
90 	.set_mst_bandwidth =
91 		virtual_stream_encoder_set_mst_bandwidth,
92 	.update_hdmi_info_packets =
93 		virtual_stream_encoder_update_hdmi_info_packets,
94 	.stop_hdmi_info_packets =
95 		virtual_stream_encoder_stop_hdmi_info_packets,
96 	.update_dp_info_packets =
97 		virtual_stream_encoder_update_dp_info_packets,
98 	.stop_dp_info_packets =
99 		virtual_stream_encoder_stop_dp_info_packets,
100 	.dp_blank =
101 		virtual_stream_encoder_dp_blank,
102 	.dp_unblank =
103 		virtual_stream_encoder_dp_unblank,
104 
105 	.audio_mute_control = virtual_audio_mute_control,
106 	.set_avmute = virtual_stream_encoder_set_avmute,
107 };
108 
109 bool virtual_stream_encoder_construct(
110 	struct stream_encoder *enc,
111 	struct dc_context *ctx,
112 	struct dc_bios *bp)
113 {
114 	if (!enc)
115 		return false;
116 	if (!bp)
117 		return false;
118 
119 	enc->funcs = &virtual_str_enc_funcs;
120 	enc->ctx = ctx;
121 	enc->id = ENGINE_ID_VIRTUAL;
122 	enc->bp = bp;
123 
124 	return true;
125 }
126 
127 struct stream_encoder *virtual_stream_encoder_create(
128 	struct dc_context *ctx, struct dc_bios *bp)
129 {
130 	struct stream_encoder *enc = kzalloc(sizeof(*enc), GFP_KERNEL);
131 
132 	if (!enc)
133 		return NULL;
134 
135 	if (virtual_stream_encoder_construct(enc, ctx, bp))
136 		return enc;
137 
138 	BREAK_TO_DEBUGGER();
139 	kfree(enc);
140 	return NULL;
141 }
142 
143