Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright 2012-14 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#ifndef DC_LINK_H_
27#define DC_LINK_H_
28
29#include "dc_types.h"
30#include "grph_object_defs.h"
31
32struct dc_link_status {
33 struct dpcd_caps *dpcd_caps;
34};
35
36/* DP MST stream allocation (payload bandwidth number) */
37struct link_mst_stream_allocation {
38 /* DIG front */
39 const struct stream_encoder *stream_enc;
40 /* associate DRM payload table with DC stream encoder */
41 uint8_t vcp_id;
42 /* number of slots required for the DP stream in transport packet */
43 uint8_t slot_count;
44};
45
46/* DP MST stream allocation table */
47struct link_mst_stream_allocation_table {
48 /* number of DP video streams */
49 int stream_count;
50 /* array of stream allocations */
51 struct link_mst_stream_allocation stream_allocations[MAX_CONTROLLER_NUM];
52};
53
54struct time_stamp {
55 uint64_t edp_poweroff;
56 uint64_t edp_poweron;
57};
58
59struct link_trace {
60 struct time_stamp time_stamp;
61};
62/*
63 * A link contains one or more sinks and their connected status.
64 * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
65 */
66struct dc_link {
67 struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
68 unsigned int sink_count;
69 struct dc_sink *local_sink;
70 unsigned int link_index;
71 enum dc_connection_type type;
72 enum signal_type connector_signal;
73 enum dc_irq_source irq_source_hpd;
74 enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */
75 bool is_hpd_filter_disabled;
76 bool dp_ss_off;
77
78 /* caps is the same as reported_link_cap. link_traing use
79 * reported_link_cap. Will clean up. TODO
80 */
81 struct dc_link_settings reported_link_cap;
82 struct dc_link_settings verified_link_cap;
83 struct dc_link_settings cur_link_settings;
84 struct dc_lane_settings cur_lane_setting;
85 struct dc_link_settings preferred_link_setting;
86
87 uint8_t ddc_hw_inst;
88
89 uint8_t hpd_src;
90
91 uint8_t link_enc_hw_inst;
92
93 bool test_pattern_enabled;
94 union compliance_test_state compliance_test_state;
95
96 void *priv;
97
98 struct ddc_service *ddc;
99
100 bool aux_mode;
101
102 /* Private to DC core */
103
104 const struct dc *dc;
105
106 struct dc_context *ctx;
107
108 struct link_encoder *link_enc;
109 struct graphics_object_id link_id;
110 union ddi_channel_mapping ddi_channel_mapping;
111 struct connector_device_tag_info device_tag;
112 struct dpcd_caps dpcd_caps;
113 unsigned short chip_caps;
114 unsigned int dpcd_sink_count;
115 enum edp_revision edp_revision;
116 bool psr_enabled;
117
118 /* MST record stream using this link */
119 struct link_flags {
120 bool dp_keep_receiver_powered;
121 } wa_flags;
122 struct link_mst_stream_allocation_table mst_stream_alloc_table;
123
124 struct dc_link_status link_status;
125
126 struct link_trace link_trace;
127};
128
129const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link);
130
131/**
132 * dc_get_link_at_index() - Return an enumerated dc_link.
133 *
134 * dc_link order is constant and determined at
135 * boot time. They cannot be created or destroyed.
136 * Use dc_get_caps() to get number of links.
137 */
138static inline struct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index)
139{
140 return dc->links[link_index];
141}
142
143/* Set backlight level of an embedded panel (eDP, LVDS).
144 * backlight_pwm_u16_16 is unsigned 32 bit with 16 bit integer
145 * and 16 bit fractional, where 1.0 is max backlight value.
146 */
147bool dc_link_set_backlight_level(const struct dc_link *dc_link,
148 uint32_t backlight_pwm_u16_16,
149 uint32_t frame_ramp);
150
151int dc_link_get_backlight_level(const struct dc_link *dc_link);
152
153bool dc_link_set_abm_disable(const struct dc_link *dc_link);
154
155bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable, bool wait);
156
157bool dc_link_get_psr_state(const struct dc_link *dc_link, uint32_t *psr_state);
158
159bool dc_link_setup_psr(struct dc_link *dc_link,
160 const struct dc_stream_state *stream, struct psr_config *psr_config,
161 struct psr_context *psr_context);
162
163/* Request DC to detect if there is a Panel connected.
164 * boot - If this call is during initial boot.
165 * Return false for any type of detection failure or MST detection
166 * true otherwise. True meaning further action is required (status update
167 * and OS notification).
168 */
169enum dc_detect_reason {
170 DETECT_REASON_BOOT,
171 DETECT_REASON_HPD,
172 DETECT_REASON_HPDRX,
173};
174
175bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason);
176bool dc_link_get_hpd_state(struct dc_link *dc_link);
177
178/* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt).
179 * Return:
180 * true - Downstream port status changed. DM should call DC to do the
181 * detection.
182 * false - no change in Downstream port status. No further action required
183 * from DM. */
184bool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link,
185 union hpd_irq_data *hpd_irq_dpcd_data, bool *out_link_loss);
186
187struct dc_sink_init_data;
188
189struct dc_sink *dc_link_add_remote_sink(
190 struct dc_link *dc_link,
191 const uint8_t *edid,
192 int len,
193 struct dc_sink_init_data *init_data);
194
195void dc_link_remove_remote_sink(
196 struct dc_link *link,
197 struct dc_sink *sink);
198
199/* Used by diagnostics for virtual link at the moment */
200
201void dc_link_dp_set_drive_settings(
202 struct dc_link *link,
203 struct link_training_settings *lt_settings);
204
205enum link_training_result dc_link_dp_perform_link_training(
206 struct dc_link *link,
207 const struct dc_link_settings *link_setting,
208 bool skip_video_pattern);
209
210void dc_link_dp_enable_hpd(const struct dc_link *link);
211
212void dc_link_dp_disable_hpd(const struct dc_link *link);
213
214bool dc_link_dp_set_test_pattern(
215 struct dc_link *link,
216 enum dp_test_pattern test_pattern,
217 const struct link_training_settings *p_link_settings,
218 const unsigned char *p_custom_pattern,
219 unsigned int cust_pattern_size);
220
221void dc_link_enable_hpd_filter(struct dc_link *link, bool enable);
222
223bool dc_link_is_dp_sink_present(struct dc_link *link);
224
225bool dc_link_detect_sink(struct dc_link *link, enum dc_connection_type *type);
226/*
227 * DPCD access interfaces
228 */
229
230void dc_link_set_drive_settings(struct dc *dc,
231 struct link_training_settings *lt_settings,
232 const struct dc_link *link);
233void dc_link_perform_link_training(struct dc *dc,
234 struct dc_link_settings *link_setting,
235 bool skip_video_pattern);
236void dc_link_set_preferred_link_settings(struct dc *dc,
237 struct dc_link_settings *link_setting,
238 struct dc_link *link);
239void dc_link_enable_hpd(const struct dc_link *link);
240void dc_link_disable_hpd(const struct dc_link *link);
241void dc_link_set_test_pattern(struct dc_link *link,
242 enum dp_test_pattern test_pattern,
243 const struct link_training_settings *p_link_settings,
244 const unsigned char *p_custom_pattern,
245 unsigned int cust_pattern_size);
246
247bool dc_submit_i2c(
248 struct dc *dc,
249 uint32_t link_index,
250 struct i2c_command *cmd);
251
252#endif /* DC_LINK_H_ */