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