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 "dm_services_types.h"
30 
31 #include "virtual_link_encoder.h"
32 
33 static bool virtual_link_encoder_validate_output_with_stream(
34 	struct link_encoder *enc,
35 	const struct dc_stream_state *stream) { return true; }
36 
37 static void virtual_link_encoder_hw_init(struct link_encoder *enc) {}
38 
39 static void virtual_link_encoder_setup(
40 	struct link_encoder *enc,
41 	enum signal_type signal) {}
42 
43 static void virtual_link_encoder_enable_tmds_output(
44 	struct link_encoder *enc,
45 	enum clock_source_id clock_source,
46 	enum dc_color_depth color_depth,
47 	enum signal_type signal,
48 	uint32_t pixel_clock) {}
49 
50 static void virtual_link_encoder_enable_dp_output(
51 	struct link_encoder *enc,
52 	const struct dc_link_settings *link_settings,
53 	enum clock_source_id clock_source) {}
54 
55 static void virtual_link_encoder_enable_dp_mst_output(
56 	struct link_encoder *enc,
57 	const struct dc_link_settings *link_settings,
58 	enum clock_source_id clock_source) {}
59 
60 static void virtual_link_encoder_disable_output(
61 	struct link_encoder *link_enc,
62 	enum signal_type signal) {}
63 
64 static void virtual_link_encoder_dp_set_lane_settings(
65 	struct link_encoder *enc,
66 	const struct dc_link_settings *link_settings,
67 	const struct dc_lane_settings lane_settings[LANE_COUNT_DP_MAX]) {}
68 
69 static void virtual_link_encoder_dp_set_phy_pattern(
70 	struct link_encoder *enc,
71 	const struct encoder_set_dp_phy_pattern_param *param) {}
72 
73 static void virtual_link_encoder_update_mst_stream_allocation_table(
74 	struct link_encoder *enc,
75 	const struct link_mst_stream_allocation_table *table) {}
76 
77 static void virtual_link_encoder_connect_dig_be_to_fe(
78 	struct link_encoder *enc,
79 	enum engine_id engine,
80 	bool connect) {}
81 
82 static void virtual_link_encoder_destroy(struct link_encoder **enc)
83 {
84 	kfree(*enc);
85 	*enc = NULL;
86 }
87 
88 static void virtual_link_encoder_get_max_link_cap(struct link_encoder *enc,
89 		struct dc_link_settings *link_settings)
90 {
91 	/* Set Default link settings */
92 	struct dc_link_settings max_link_cap = {LANE_COUNT_FOUR, LINK_RATE_HIGH,
93 				LINK_SPREAD_05_DOWNSPREAD_30KHZ, false, 0};
94 	*link_settings = max_link_cap;
95 }
96 
97 static const struct link_encoder_funcs virtual_lnk_enc_funcs = {
98 	.validate_output_with_stream =
99 		virtual_link_encoder_validate_output_with_stream,
100 	.hw_init = virtual_link_encoder_hw_init,
101 	.setup = virtual_link_encoder_setup,
102 	.enable_tmds_output = virtual_link_encoder_enable_tmds_output,
103 	.enable_dp_output = virtual_link_encoder_enable_dp_output,
104 	.enable_dp_mst_output = virtual_link_encoder_enable_dp_mst_output,
105 	.disable_output = virtual_link_encoder_disable_output,
106 	.get_max_link_cap = virtual_link_encoder_get_max_link_cap,
107 	.dp_set_lane_settings = virtual_link_encoder_dp_set_lane_settings,
108 	.dp_set_phy_pattern = virtual_link_encoder_dp_set_phy_pattern,
109 	.update_mst_stream_allocation_table =
110 		virtual_link_encoder_update_mst_stream_allocation_table,
111 	.connect_dig_be_to_fe = virtual_link_encoder_connect_dig_be_to_fe,
112 	.destroy = virtual_link_encoder_destroy
113 };
114 
115 bool virtual_link_encoder_construct(
116 	struct link_encoder *enc, const struct encoder_init_data *init_data)
117 {
118 	enc->funcs = &virtual_lnk_enc_funcs;
119 	enc->ctx = init_data->ctx;
120 	enc->id = init_data->encoder;
121 
122 	enc->hpd_source = init_data->hpd_source;
123 	enc->connector = init_data->connector;
124 
125 	enc->transmitter = init_data->transmitter;
126 
127 	enc->output_signals = SIGNAL_TYPE_VIRTUAL;
128 
129 	enc->preferred_engine = ENGINE_ID_VIRTUAL;
130 
131 	return true;
132 }
133 
134 
135