14562236bSHarry Wentland /*
24562236bSHarry Wentland  * Copyright 2012-15 Advanced Micro Devices, Inc.
34562236bSHarry Wentland  *
44562236bSHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
54562236bSHarry Wentland  * copy of this software and associated documentation files (the "Software"),
64562236bSHarry Wentland  * to deal in the Software without restriction, including without limitation
74562236bSHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
84562236bSHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
94562236bSHarry Wentland  * Software is furnished to do so, subject to the following conditions:
104562236bSHarry Wentland  *
114562236bSHarry Wentland  * The above copyright notice and this permission notice shall be included in
124562236bSHarry Wentland  * all copies or substantial portions of the Software.
134562236bSHarry Wentland  *
144562236bSHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154562236bSHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
164562236bSHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
174562236bSHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
184562236bSHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
194562236bSHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
204562236bSHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
214562236bSHarry Wentland  *
224562236bSHarry Wentland  * Authors: AMD
234562236bSHarry Wentland  *
244562236bSHarry Wentland  */
254562236bSHarry Wentland 
264fc4dca8SSam Ravnborg #include <linux/slab.h>
274fc4dca8SSam Ravnborg 
284562236bSHarry Wentland #include "dm_services.h"
294562236bSHarry Wentland #include "virtual_stream_encoder.h"
304562236bSHarry Wentland 
314562236bSHarry Wentland static void virtual_stream_encoder_dp_set_stream_attribute(
324562236bSHarry Wentland 	struct stream_encoder *enc,
334562236bSHarry Wentland 	struct dc_crtc_timing *crtc_timing,
34bb1cb98eSNikola Cornij 	enum dc_color_space output_color_space,
355ed78cd6SAnthony Koo 	bool use_vsc_sdp_for_colorimetry,
36bb1cb98eSNikola Cornij 	uint32_t enable_sdp_splitting) {}
374562236bSHarry Wentland 
384562236bSHarry Wentland static void virtual_stream_encoder_hdmi_set_stream_attribute(
394562236bSHarry Wentland 	struct stream_encoder *enc,
404562236bSHarry Wentland 	struct dc_crtc_timing *crtc_timing,
414562236bSHarry Wentland 	int actual_pix_clk_khz,
424562236bSHarry Wentland 	bool enable_audio) {}
434562236bSHarry Wentland 
444562236bSHarry Wentland static void virtual_stream_encoder_dvi_set_stream_attribute(
454562236bSHarry Wentland 	struct stream_encoder *enc,
464562236bSHarry Wentland 	struct dc_crtc_timing *crtc_timing,
474562236bSHarry Wentland 	bool is_dual_link) {}
484562236bSHarry Wentland 
496c95320dSGeorge Shen static void virtual_stream_encoder_set_throttled_vcp_size(
504562236bSHarry Wentland 	struct stream_encoder *enc,
516c95320dSGeorge Shen 	struct fixed31_32 avg_time_slots_per_mtp)
526c95320dSGeorge Shen {}
534562236bSHarry Wentland 
544562236bSHarry Wentland static void virtual_stream_encoder_update_hdmi_info_packets(
554562236bSHarry Wentland 	struct stream_encoder *enc,
564562236bSHarry Wentland 	const struct encoder_info_frame *info_frame) {}
574562236bSHarry Wentland 
584562236bSHarry Wentland static void virtual_stream_encoder_stop_hdmi_info_packets(
594562236bSHarry Wentland 	struct stream_encoder *enc) {}
604562236bSHarry Wentland 
6115e17335SCharlene Liu static void virtual_stream_encoder_set_avmute(
6215e17335SCharlene Liu 	struct stream_encoder *enc,
6315e17335SCharlene Liu 	bool enable) {}
644562236bSHarry Wentland static void virtual_stream_encoder_update_dp_info_packets(
654562236bSHarry Wentland 	struct stream_encoder *enc,
664562236bSHarry Wentland 	const struct encoder_info_frame *info_frame) {}
674562236bSHarry Wentland 
684562236bSHarry Wentland static void virtual_stream_encoder_stop_dp_info_packets(
694562236bSHarry Wentland 	struct stream_encoder *enc) {}
704562236bSHarry Wentland 
714562236bSHarry Wentland static void virtual_stream_encoder_dp_blank(
724562236bSHarry Wentland 	struct stream_encoder *enc) {}
734562236bSHarry Wentland 
744562236bSHarry Wentland static void virtual_stream_encoder_dp_unblank(
754562236bSHarry Wentland 	struct stream_encoder *enc,
764562236bSHarry Wentland 	const struct encoder_unblank_param *param) {}
774562236bSHarry Wentland 
784562236bSHarry Wentland static void virtual_audio_mute_control(
794562236bSHarry Wentland 	struct stream_encoder *enc,
804562236bSHarry Wentland 	bool mute) {}
814562236bSHarry Wentland 
82ac42fd63SWenjing Liu static void virtual_stream_encoder_reset_hdmi_stream_attribute(
83ac42fd63SWenjing Liu 		struct stream_encoder *enc)
84ac42fd63SWenjing Liu {}
85ac42fd63SWenjing Liu 
8697bda032SHarry Wentland static void virtual_enc_dp_set_odm_combine(
8797bda032SHarry Wentland 	struct stream_encoder *enc,
8897bda032SHarry Wentland 	bool odm_combine)
8997bda032SHarry Wentland {}
90ca4d9b3aSHarry Wentland 
91d8a8258eSEric Bernstein static void virtual_dig_connect_to_otg(
92d8a8258eSEric Bernstein 		struct stream_encoder *enc,
93d8a8258eSEric Bernstein 		int tg_inst)
94d8a8258eSEric Bernstein {}
95d8a8258eSEric Bernstein 
96d8a8258eSEric Bernstein static void virtual_setup_stereo_sync(
97d8a8258eSEric Bernstein 			struct stream_encoder *enc,
98d8a8258eSEric Bernstein 			int tg_inst,
99d8a8258eSEric Bernstein 			bool enable)
100d8a8258eSEric Bernstein {}
101d8a8258eSEric Bernstein 
1024ab1edbcSEric Bernstein static void virtual_stream_encoder_set_dsc_pps_info_packet(
1034ab1edbcSEric Bernstein 		struct stream_encoder *enc,
1044ab1edbcSEric Bernstein 		bool enable,
1054ab1edbcSEric Bernstein 		uint8_t *dsc_packed_pps)
1064ab1edbcSEric Bernstein {}
1074ab1edbcSEric Bernstein 
1084562236bSHarry Wentland static const struct stream_encoder_funcs virtual_str_enc_funcs = {
10997bda032SHarry Wentland 	.dp_set_odm_combine =
11097bda032SHarry Wentland 		virtual_enc_dp_set_odm_combine,
1114562236bSHarry Wentland 	.dp_set_stream_attribute =
1124562236bSHarry Wentland 		virtual_stream_encoder_dp_set_stream_attribute,
1134562236bSHarry Wentland 	.hdmi_set_stream_attribute =
1144562236bSHarry Wentland 		virtual_stream_encoder_hdmi_set_stream_attribute,
1154562236bSHarry Wentland 	.dvi_set_stream_attribute =
1164562236bSHarry Wentland 		virtual_stream_encoder_dvi_set_stream_attribute,
1176c95320dSGeorge Shen 	.set_throttled_vcp_size =
1186c95320dSGeorge Shen 		virtual_stream_encoder_set_throttled_vcp_size,
1194562236bSHarry Wentland 	.update_hdmi_info_packets =
1204562236bSHarry Wentland 		virtual_stream_encoder_update_hdmi_info_packets,
1214562236bSHarry Wentland 	.stop_hdmi_info_packets =
1224562236bSHarry Wentland 		virtual_stream_encoder_stop_hdmi_info_packets,
1234562236bSHarry Wentland 	.update_dp_info_packets =
1244562236bSHarry Wentland 		virtual_stream_encoder_update_dp_info_packets,
1254562236bSHarry Wentland 	.stop_dp_info_packets =
1264562236bSHarry Wentland 		virtual_stream_encoder_stop_dp_info_packets,
1274562236bSHarry Wentland 	.dp_blank =
1284562236bSHarry Wentland 		virtual_stream_encoder_dp_blank,
1294562236bSHarry Wentland 	.dp_unblank =
1304562236bSHarry Wentland 		virtual_stream_encoder_dp_unblank,
1314562236bSHarry Wentland 
1324562236bSHarry Wentland 	.audio_mute_control = virtual_audio_mute_control,
13315e17335SCharlene Liu 	.set_avmute = virtual_stream_encoder_set_avmute,
134ac42fd63SWenjing Liu 	.hdmi_reset_stream_attribute = virtual_stream_encoder_reset_hdmi_stream_attribute,
135d8a8258eSEric Bernstein 	.dig_connect_to_otg = virtual_dig_connect_to_otg,
136d8a8258eSEric Bernstein 	.setup_stereo_sync = virtual_setup_stereo_sync,
1374ab1edbcSEric Bernstein 	.dp_set_dsc_pps_info_packet = virtual_stream_encoder_set_dsc_pps_info_packet,
1384562236bSHarry Wentland };
1394562236bSHarry Wentland 
1404562236bSHarry Wentland bool virtual_stream_encoder_construct(
1414562236bSHarry Wentland 	struct stream_encoder *enc,
1424562236bSHarry Wentland 	struct dc_context *ctx,
1434562236bSHarry Wentland 	struct dc_bios *bp)
1444562236bSHarry Wentland {
1454562236bSHarry Wentland 	if (!enc)
1464562236bSHarry Wentland 		return false;
1474562236bSHarry Wentland 	if (!bp)
1484562236bSHarry Wentland 		return false;
1494562236bSHarry Wentland 
1504562236bSHarry Wentland 	enc->funcs = &virtual_str_enc_funcs;
1514562236bSHarry Wentland 	enc->ctx = ctx;
1524562236bSHarry Wentland 	enc->id = ENGINE_ID_VIRTUAL;
1534562236bSHarry Wentland 	enc->bp = bp;
1544562236bSHarry Wentland 
1554562236bSHarry Wentland 	return true;
1564562236bSHarry Wentland }
1574562236bSHarry Wentland 
1584562236bSHarry Wentland struct stream_encoder *virtual_stream_encoder_create(
1594562236bSHarry Wentland 	struct dc_context *ctx, struct dc_bios *bp)
1604562236bSHarry Wentland {
1612004f45eSHarry Wentland 	struct stream_encoder *enc = kzalloc(sizeof(*enc), GFP_KERNEL);
1624562236bSHarry Wentland 
1634562236bSHarry Wentland 	if (!enc)
1644562236bSHarry Wentland 		return NULL;
1654562236bSHarry Wentland 
1664562236bSHarry Wentland 	if (virtual_stream_encoder_construct(enc, ctx, bp))
1674562236bSHarry Wentland 		return enc;
1684562236bSHarry Wentland 
1694562236bSHarry Wentland 	BREAK_TO_DEBUGGER();
1702004f45eSHarry Wentland 	kfree(enc);
1714562236bSHarry Wentland 	return NULL;
1724562236bSHarry Wentland }
1734562236bSHarry Wentland 
174