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