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