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,bool use_vsc_sdp_for_colorimetry,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 bool use_vsc_sdp_for_colorimetry,
36 uint32_t enable_sdp_splitting) {}
37
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)38 static void virtual_stream_encoder_hdmi_set_stream_attribute(
39 struct stream_encoder *enc,
40 struct dc_crtc_timing *crtc_timing,
41 int actual_pix_clk_khz,
42 bool enable_audio) {}
43
virtual_stream_encoder_dvi_set_stream_attribute(struct stream_encoder * enc,struct dc_crtc_timing * crtc_timing,bool is_dual_link)44 static void virtual_stream_encoder_dvi_set_stream_attribute(
45 struct stream_encoder *enc,
46 struct dc_crtc_timing *crtc_timing,
47 bool is_dual_link) {}
48
virtual_stream_encoder_set_throttled_vcp_size(struct stream_encoder * enc,struct fixed31_32 avg_time_slots_per_mtp)49 static void virtual_stream_encoder_set_throttled_vcp_size(
50 struct stream_encoder *enc,
51 struct fixed31_32 avg_time_slots_per_mtp)
52 {}
53
virtual_stream_encoder_update_hdmi_info_packets(struct stream_encoder * enc,const struct encoder_info_frame * info_frame)54 static void virtual_stream_encoder_update_hdmi_info_packets(
55 struct stream_encoder *enc,
56 const struct encoder_info_frame *info_frame) {}
57
virtual_stream_encoder_stop_hdmi_info_packets(struct stream_encoder * enc)58 static void virtual_stream_encoder_stop_hdmi_info_packets(
59 struct stream_encoder *enc) {}
60
virtual_stream_encoder_set_avmute(struct stream_encoder * enc,bool enable)61 static void virtual_stream_encoder_set_avmute(
62 struct stream_encoder *enc,
63 bool enable) {}
virtual_stream_encoder_update_dp_info_packets(struct stream_encoder * enc,const struct encoder_info_frame * info_frame)64 static void virtual_stream_encoder_update_dp_info_packets(
65 struct stream_encoder *enc,
66 const struct encoder_info_frame *info_frame) {}
67
virtual_stream_encoder_stop_dp_info_packets(struct stream_encoder * enc)68 static void virtual_stream_encoder_stop_dp_info_packets(
69 struct stream_encoder *enc) {}
70
virtual_stream_encoder_dp_blank(struct dc_link * link,struct stream_encoder * enc)71 static void virtual_stream_encoder_dp_blank(
72 struct dc_link *link,
73 struct stream_encoder *enc) {}
74
virtual_stream_encoder_dp_unblank(struct dc_link * link,struct stream_encoder * enc,const struct encoder_unblank_param * param)75 static void virtual_stream_encoder_dp_unblank(
76 struct dc_link *link,
77 struct stream_encoder *enc,
78 const struct encoder_unblank_param *param) {}
79
virtual_audio_mute_control(struct stream_encoder * enc,bool mute)80 static void virtual_audio_mute_control(
81 struct stream_encoder *enc,
82 bool mute) {}
83
virtual_stream_encoder_reset_hdmi_stream_attribute(struct stream_encoder * enc)84 static void virtual_stream_encoder_reset_hdmi_stream_attribute(
85 struct stream_encoder *enc)
86 {}
87
virtual_enc_dp_set_odm_combine(struct stream_encoder * enc,bool odm_combine)88 static void virtual_enc_dp_set_odm_combine(
89 struct stream_encoder *enc,
90 bool odm_combine)
91 {}
92
virtual_dig_connect_to_otg(struct stream_encoder * enc,int tg_inst)93 static void virtual_dig_connect_to_otg(
94 struct stream_encoder *enc,
95 int tg_inst)
96 {}
97
virtual_setup_stereo_sync(struct stream_encoder * enc,int tg_inst,bool enable)98 static void virtual_setup_stereo_sync(
99 struct stream_encoder *enc,
100 int tg_inst,
101 bool enable)
102 {}
103
virtual_stream_encoder_set_dsc_pps_info_packet(struct stream_encoder * enc,bool enable,uint8_t * dsc_packed_pps,bool immediate_update)104 static void virtual_stream_encoder_set_dsc_pps_info_packet(
105 struct stream_encoder *enc,
106 bool enable,
107 uint8_t *dsc_packed_pps,
108 bool immediate_update)
109 {}
110
111 static const struct stream_encoder_funcs virtual_str_enc_funcs = {
112 .dp_set_odm_combine =
113 virtual_enc_dp_set_odm_combine,
114 .dp_set_stream_attribute =
115 virtual_stream_encoder_dp_set_stream_attribute,
116 .hdmi_set_stream_attribute =
117 virtual_stream_encoder_hdmi_set_stream_attribute,
118 .dvi_set_stream_attribute =
119 virtual_stream_encoder_dvi_set_stream_attribute,
120 .set_throttled_vcp_size =
121 virtual_stream_encoder_set_throttled_vcp_size,
122 .update_hdmi_info_packets =
123 virtual_stream_encoder_update_hdmi_info_packets,
124 .stop_hdmi_info_packets =
125 virtual_stream_encoder_stop_hdmi_info_packets,
126 .update_dp_info_packets =
127 virtual_stream_encoder_update_dp_info_packets,
128 .stop_dp_info_packets =
129 virtual_stream_encoder_stop_dp_info_packets,
130 .dp_blank =
131 virtual_stream_encoder_dp_blank,
132 .dp_unblank =
133 virtual_stream_encoder_dp_unblank,
134
135 .audio_mute_control = virtual_audio_mute_control,
136 .set_avmute = virtual_stream_encoder_set_avmute,
137 .hdmi_reset_stream_attribute = virtual_stream_encoder_reset_hdmi_stream_attribute,
138 .dig_connect_to_otg = virtual_dig_connect_to_otg,
139 .setup_stereo_sync = virtual_setup_stereo_sync,
140 .dp_set_dsc_pps_info_packet = virtual_stream_encoder_set_dsc_pps_info_packet,
141 };
142
virtual_stream_encoder_construct(struct stream_encoder * enc,struct dc_context * ctx,struct dc_bios * bp)143 bool virtual_stream_encoder_construct(
144 struct stream_encoder *enc,
145 struct dc_context *ctx,
146 struct dc_bios *bp)
147 {
148 if (!enc)
149 return false;
150 if (!bp)
151 return false;
152
153 enc->funcs = &virtual_str_enc_funcs;
154 enc->ctx = ctx;
155 enc->id = ENGINE_ID_VIRTUAL;
156 enc->bp = bp;
157
158 return true;
159 }
160
virtual_stream_encoder_create(struct dc_context * ctx,struct dc_bios * bp)161 struct stream_encoder *virtual_stream_encoder_create(
162 struct dc_context *ctx, struct dc_bios *bp)
163 {
164 struct stream_encoder *enc = kzalloc(sizeof(*enc), GFP_KERNEL);
165
166 if (!enc)
167 return NULL;
168
169 if (virtual_stream_encoder_construct(enc, ctx, bp))
170 return enc;
171
172 BREAK_TO_DEBUGGER();
173 kfree(enc);
174 return NULL;
175 }
176
177