blob: 6e4cc5334f47d7105b60c0bec72fccfb4875ddac [file] [log] [blame]
Dave Airlie0e32b392014-05-02 14:02:48 +10001/*
2 * Copyright © 2008 Intel Corporation
3 * 2014 Red Hat Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 *
24 */
25
26#include <drm/drmP.h>
27#include "i915_drv.h"
28#include "intel_drv.h"
Matt Roperc6f95f22015-01-22 16:50:32 -080029#include <drm/drm_atomic_helper.h>
Dave Airlie0e32b392014-05-02 14:02:48 +100030#include <drm/drm_crtc_helper.h>
31#include <drm/drm_edid.h>
32
33static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,
Ander Conselvan de Oliveira5cec2582015-01-15 14:55:21 +020034 struct intel_crtc_state *pipe_config)
Dave Airlie0e32b392014-05-02 14:02:48 +100035{
36 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
37 struct intel_digital_port *intel_dig_port = intel_mst->primary;
38 struct intel_dp *intel_dp = &intel_dig_port->dp;
Ander Conselvan de Oliveirae75f4772015-03-20 16:18:13 +020039 struct drm_atomic_state *state;
40 int bpp, i;
Ville Syrjäläed4e9c12015-03-12 17:10:36 +020041 int lane_count, slots, rate;
Ander Conselvan de Oliveira2d112de2015-01-15 14:55:22 +020042 struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
Ander Conselvan de Oliveirada3ced22015-04-21 17:12:59 +030043 struct drm_connector *drm_connector;
44 struct intel_connector *connector, *found = NULL;
45 struct drm_connector_state *connector_state;
Dave Airlie0e32b392014-05-02 14:02:48 +100046 int mst_pbn;
47
48 pipe_config->dp_encoder_is_mst = true;
49 pipe_config->has_pch_encoder = false;
50 pipe_config->has_dp_encoder = true;
51 bpp = 24;
52 /*
53 * for MST we always configure max link bw - the spec doesn't
54 * seem to suggest we should do otherwise.
55 */
56 lane_count = drm_dp_max_lane_count(intel_dp->dpcd);
Ville Syrjäläed4e9c12015-03-12 17:10:36 +020057
58 rate = intel_dp_max_link_rate(intel_dp);
59
Ville Syrjälä94ca7192015-03-13 19:40:31 +020060 if (intel_dp->num_sink_rates) {
Ville Syrjäläed4e9c12015-03-12 17:10:36 +020061 intel_dp->link_bw = 0;
62 intel_dp->rate_select = intel_dp_rate_select(intel_dp, rate);
63 } else {
64 intel_dp->link_bw = drm_dp_link_rate_to_bw_code(rate);
65 intel_dp->rate_select = 0;
66 }
67
Dave Airlie0e32b392014-05-02 14:02:48 +100068 intel_dp->lane_count = lane_count;
69
70 pipe_config->pipe_bpp = 24;
Ville Syrjäläed4e9c12015-03-12 17:10:36 +020071 pipe_config->port_clock = rate;
Dave Airlie0e32b392014-05-02 14:02:48 +100072
Ander Conselvan de Oliveirae75f4772015-03-20 16:18:13 +020073 state = pipe_config->base.state;
74
Ander Conselvan de Oliveirada3ced22015-04-21 17:12:59 +030075 for_each_connector_in_state(state, drm_connector, connector_state, i) {
76 connector = to_intel_connector(drm_connector);
Ander Conselvan de Oliveirae75f4772015-03-20 16:18:13 +020077
Ander Conselvan de Oliveirada3ced22015-04-21 17:12:59 +030078 if (connector_state->best_encoder == &encoder->base) {
79 found = connector;
Dave Airlie0e32b392014-05-02 14:02:48 +100080 break;
81 }
82 }
83
84 if (!found) {
85 DRM_ERROR("can't find connector\n");
86 return false;
87 }
88
89 mst_pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp);
90
91 pipe_config->pbn = mst_pbn;
92 slots = drm_dp_find_vcpi_slots(&intel_dp->mst_mgr, mst_pbn);
93
94 intel_link_compute_m_n(bpp, lane_count,
95 adjusted_mode->crtc_clock,
96 pipe_config->port_clock,
97 &pipe_config->dp_m_n);
98
99 pipe_config->dp_m_n.tu = slots;
100 return true;
101
102}
103
104static void intel_mst_disable_dp(struct intel_encoder *encoder)
105{
106 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
107 struct intel_digital_port *intel_dig_port = intel_mst->primary;
108 struct intel_dp *intel_dp = &intel_dig_port->dp;
109 int ret;
110
111 DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
112
113 drm_dp_mst_reset_vcpi_slots(&intel_dp->mst_mgr, intel_mst->port);
114
115 ret = drm_dp_update_payload_part1(&intel_dp->mst_mgr);
116 if (ret) {
117 DRM_ERROR("failed to update payload %d\n", ret);
118 }
119}
120
121static void intel_mst_post_disable_dp(struct intel_encoder *encoder)
122{
123 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
124 struct intel_digital_port *intel_dig_port = intel_mst->primary;
125 struct intel_dp *intel_dp = &intel_dig_port->dp;
126
127 DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
128
129 /* this can fail */
130 drm_dp_check_act_status(&intel_dp->mst_mgr);
131 /* and this can also fail */
132 drm_dp_update_payload_part2(&intel_dp->mst_mgr);
133
134 drm_dp_mst_deallocate_vcpi(&intel_dp->mst_mgr, intel_mst->port);
135
136 intel_dp->active_mst_links--;
137 intel_mst->port = NULL;
138 if (intel_dp->active_mst_links == 0) {
139 intel_dig_port->base.post_disable(&intel_dig_port->base);
140 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
141 }
142}
143
144static void intel_mst_pre_enable_dp(struct intel_encoder *encoder)
145{
146 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
147 struct intel_digital_port *intel_dig_port = intel_mst->primary;
148 struct intel_dp *intel_dp = &intel_dig_port->dp;
149 struct drm_device *dev = encoder->base.dev;
150 struct drm_i915_private *dev_priv = dev->dev_private;
151 enum port port = intel_dig_port->port;
152 int ret;
153 uint32_t temp;
Ander Conselvan de Oliveira9b4fd8f2015-04-02 14:48:01 +0300154 struct intel_connector *found = NULL, *connector;
Dave Airlie0e32b392014-05-02 14:02:48 +1000155 int slots;
156 struct drm_crtc *crtc = encoder->base.crtc;
157 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
158
Ander Conselvan de Oliveira9b4fd8f2015-04-02 14:48:01 +0300159 for_each_intel_connector(dev, connector) {
160 if (connector->base.state->best_encoder == &encoder->base) {
161 found = connector;
Dave Airlie0e32b392014-05-02 14:02:48 +1000162 break;
163 }
164 }
165
166 if (!found) {
167 DRM_ERROR("can't find connector\n");
168 return;
169 }
170
171 DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
172 intel_mst->port = found->port;
173
174 if (intel_dp->active_mst_links == 0) {
175 enum port port = intel_ddi_get_encoder_port(encoder);
176
Satheeshakrishna M1ab23382014-08-22 09:49:06 +0530177 /* FIXME: add support for SKL */
178 if (INTEL_INFO(dev)->gen < 9)
179 I915_WRITE(PORT_CLK_SEL(port),
180 intel_crtc->config->ddi_pll_sel);
Dave Airlie0e32b392014-05-02 14:02:48 +1000181
182 intel_ddi_init_dp_buf_reg(&intel_dig_port->base);
183
184 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
185
186
187 intel_dp_start_link_train(intel_dp);
188 intel_dp_complete_link_train(intel_dp);
189 intel_dp_stop_link_train(intel_dp);
190 }
191
192 ret = drm_dp_mst_allocate_vcpi(&intel_dp->mst_mgr,
Ander Conselvan de Oliveira6e3c9712015-01-15 14:55:25 +0200193 intel_mst->port,
194 intel_crtc->config->pbn, &slots);
Dave Airlie0e32b392014-05-02 14:02:48 +1000195 if (ret == false) {
196 DRM_ERROR("failed to allocate vcpi\n");
197 return;
198 }
199
200
201 intel_dp->active_mst_links++;
202 temp = I915_READ(DP_TP_STATUS(port));
203 I915_WRITE(DP_TP_STATUS(port), temp);
204
205 ret = drm_dp_update_payload_part1(&intel_dp->mst_mgr);
206}
207
208static void intel_mst_enable_dp(struct intel_encoder *encoder)
209{
210 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
211 struct intel_digital_port *intel_dig_port = intel_mst->primary;
212 struct intel_dp *intel_dp = &intel_dig_port->dp;
213 struct drm_device *dev = intel_dig_port->base.base.dev;
214 struct drm_i915_private *dev_priv = dev->dev_private;
215 enum port port = intel_dig_port->port;
216 int ret;
217
218 DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
219
220 if (wait_for((I915_READ(DP_TP_STATUS(port)) & DP_TP_STATUS_ACT_SENT),
221 1))
222 DRM_ERROR("Timed out waiting for ACT sent\n");
223
224 ret = drm_dp_check_act_status(&intel_dp->mst_mgr);
225
226 ret = drm_dp_update_payload_part2(&intel_dp->mst_mgr);
227}
228
229static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder,
230 enum pipe *pipe)
231{
232 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
233 *pipe = intel_mst->pipe;
234 if (intel_mst->port)
235 return true;
236 return false;
237}
238
239static void intel_dp_mst_enc_get_config(struct intel_encoder *encoder,
Ander Conselvan de Oliveira5cec2582015-01-15 14:55:21 +0200240 struct intel_crtc_state *pipe_config)
Dave Airlie0e32b392014-05-02 14:02:48 +1000241{
242 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
243 struct intel_digital_port *intel_dig_port = intel_mst->primary;
244 struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
245 struct drm_device *dev = encoder->base.dev;
246 struct drm_i915_private *dev_priv = dev->dev_private;
Ander Conselvan de Oliveira0cb09a92015-01-30 12:17:23 +0200247 enum transcoder cpu_transcoder = pipe_config->cpu_transcoder;
Dave Airlie0e32b392014-05-02 14:02:48 +1000248 u32 temp, flags = 0;
249
250 pipe_config->has_dp_encoder = true;
251
252 temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
253 if (temp & TRANS_DDI_PHSYNC)
254 flags |= DRM_MODE_FLAG_PHSYNC;
255 else
256 flags |= DRM_MODE_FLAG_NHSYNC;
257 if (temp & TRANS_DDI_PVSYNC)
258 flags |= DRM_MODE_FLAG_PVSYNC;
259 else
260 flags |= DRM_MODE_FLAG_NVSYNC;
261
262 switch (temp & TRANS_DDI_BPC_MASK) {
263 case TRANS_DDI_BPC_6:
264 pipe_config->pipe_bpp = 18;
265 break;
266 case TRANS_DDI_BPC_8:
267 pipe_config->pipe_bpp = 24;
268 break;
269 case TRANS_DDI_BPC_10:
270 pipe_config->pipe_bpp = 30;
271 break;
272 case TRANS_DDI_BPC_12:
273 pipe_config->pipe_bpp = 36;
274 break;
275 default:
276 break;
277 }
Ander Conselvan de Oliveira2d112de2015-01-15 14:55:22 +0200278 pipe_config->base.adjusted_mode.flags |= flags;
Dave Airlie0e32b392014-05-02 14:02:48 +1000279 intel_dp_get_m_n(crtc, pipe_config);
280
281 intel_ddi_clock_get(&intel_dig_port->base, pipe_config);
282}
283
284static int intel_dp_mst_get_ddc_modes(struct drm_connector *connector)
285{
286 struct intel_connector *intel_connector = to_intel_connector(connector);
287 struct intel_dp *intel_dp = intel_connector->mst_port;
288 struct edid *edid;
289 int ret;
290
291 edid = drm_dp_mst_get_edid(connector, &intel_dp->mst_mgr, intel_connector->port);
292 if (!edid)
293 return 0;
294
295 ret = intel_connector_update_modes(connector, edid);
296 kfree(edid);
297
298 return ret;
299}
300
301static enum drm_connector_status
Daniel Vetterf7f3d482014-10-22 11:06:44 +0200302intel_dp_mst_detect(struct drm_connector *connector, bool force)
Dave Airlie0e32b392014-05-02 14:02:48 +1000303{
304 struct intel_connector *intel_connector = to_intel_connector(connector);
305 struct intel_dp *intel_dp = intel_connector->mst_port;
306
Dave Airliec6a0aed2014-10-20 16:28:02 +1000307 return drm_dp_mst_detect_port(connector, &intel_dp->mst_mgr, intel_connector->port);
Dave Airlie0e32b392014-05-02 14:02:48 +1000308}
309
Dave Airlie0e32b392014-05-02 14:02:48 +1000310static int
311intel_dp_mst_set_property(struct drm_connector *connector,
312 struct drm_property *property,
313 uint64_t val)
314{
315 return 0;
316}
317
318static void
319intel_dp_mst_connector_destroy(struct drm_connector *connector)
320{
321 struct intel_connector *intel_connector = to_intel_connector(connector);
322
323 if (!IS_ERR_OR_NULL(intel_connector->edid))
324 kfree(intel_connector->edid);
325
326 drm_connector_cleanup(connector);
327 kfree(connector);
328}
329
330static const struct drm_connector_funcs intel_dp_mst_connector_funcs = {
331 .dpms = intel_connector_dpms,
332 .detect = intel_dp_mst_detect,
333 .fill_modes = drm_helper_probe_single_connector_modes,
334 .set_property = intel_dp_mst_set_property,
Matt Roper2545e4a2015-01-22 16:51:27 -0800335 .atomic_get_property = intel_connector_atomic_get_property,
Dave Airlie0e32b392014-05-02 14:02:48 +1000336 .destroy = intel_dp_mst_connector_destroy,
Matt Roperc6f95f22015-01-22 16:50:32 -0800337 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
Ander Conselvan de Oliveira98969722015-03-20 16:18:06 +0200338 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
Dave Airlie0e32b392014-05-02 14:02:48 +1000339};
340
341static int intel_dp_mst_get_modes(struct drm_connector *connector)
342{
343 return intel_dp_mst_get_ddc_modes(connector);
344}
345
346static enum drm_mode_status
347intel_dp_mst_mode_valid(struct drm_connector *connector,
348 struct drm_display_mode *mode)
349{
350 /* TODO - validate mode against available PBN for link */
351 if (mode->clock < 10000)
352 return MODE_CLOCK_LOW;
353
354 if (mode->flags & DRM_MODE_FLAG_DBLCLK)
355 return MODE_H_ILLEGAL;
356
357 return MODE_OK;
358}
359
360static struct drm_encoder *intel_mst_best_encoder(struct drm_connector *connector)
361{
362 struct intel_connector *intel_connector = to_intel_connector(connector);
363 struct intel_dp *intel_dp = intel_connector->mst_port;
364 return &intel_dp->mst_encoders[0]->base.base;
365}
366
367static const struct drm_connector_helper_funcs intel_dp_mst_connector_helper_funcs = {
368 .get_modes = intel_dp_mst_get_modes,
369 .mode_valid = intel_dp_mst_mode_valid,
370 .best_encoder = intel_mst_best_encoder,
371};
372
373static void intel_dp_mst_encoder_destroy(struct drm_encoder *encoder)
374{
375 struct intel_dp_mst_encoder *intel_mst = enc_to_mst(encoder);
376
377 drm_encoder_cleanup(encoder);
378 kfree(intel_mst);
379}
380
381static const struct drm_encoder_funcs intel_dp_mst_enc_funcs = {
382 .destroy = intel_dp_mst_encoder_destroy,
383};
384
385static bool intel_dp_mst_get_hw_state(struct intel_connector *connector)
386{
387 if (connector->encoder) {
388 enum pipe pipe;
389 if (!connector->encoder->get_hw_state(connector->encoder, &pipe))
390 return false;
391 return true;
392 }
393 return false;
394}
395
Chris Wilson7296c842014-07-22 20:10:28 +1000396static void intel_connector_add_to_fbdev(struct intel_connector *connector)
397{
398#ifdef CONFIG_DRM_I915_FBDEV
399 struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
400 drm_fb_helper_add_one_connector(&dev_priv->fbdev->helper, &connector->base);
401#endif
402}
403
404static void intel_connector_remove_from_fbdev(struct intel_connector *connector)
405{
406#ifdef CONFIG_DRM_I915_FBDEV
407 struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
408 drm_fb_helper_remove_one_connector(&dev_priv->fbdev->helper, &connector->base);
409#endif
410}
411
Thierry Reding12e6cec2014-05-13 11:38:36 +0200412static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, const char *pathprop)
Dave Airlie0e32b392014-05-02 14:02:48 +1000413{
414 struct intel_dp *intel_dp = container_of(mgr, struct intel_dp, mst_mgr);
415 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
416 struct drm_device *dev = intel_dig_port->base.base.dev;
Dave Airlie0e32b392014-05-02 14:02:48 +1000417 struct intel_connector *intel_connector;
418 struct drm_connector *connector;
419 int i;
420
Ander Conselvan de Oliveira9bdbd0b2015-04-10 10:59:10 +0300421 intel_connector = intel_connector_alloc();
Dave Airlie0e32b392014-05-02 14:02:48 +1000422 if (!intel_connector)
423 return NULL;
424
425 connector = &intel_connector->base;
426 drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs, DRM_MODE_CONNECTOR_DisplayPort);
427 drm_connector_helper_add(connector, &intel_dp_mst_connector_helper_funcs);
428
429 intel_connector->unregister = intel_connector_unregister;
430 intel_connector->get_hw_state = intel_dp_mst_get_hw_state;
431 intel_connector->mst_port = intel_dp;
432 intel_connector->port = port;
433
434 for (i = PIPE_A; i <= PIPE_C; i++) {
435 drm_mode_connector_attach_encoder(&intel_connector->base,
436 &intel_dp->mst_encoders[i]->base.base);
437 }
438 intel_dp_add_properties(intel_dp, connector);
439
440 drm_object_attach_property(&connector->base, dev->mode_config.path_property, 0);
Dave Airlie6f134d72014-10-20 16:30:50 +1000441 drm_object_attach_property(&connector->base, dev->mode_config.tile_property, 0);
442
Dave Airlie0e32b392014-05-02 14:02:48 +1000443 drm_mode_connector_set_path_property(connector, pathprop);
444 drm_reinit_primary_mode_group(dev);
445 mutex_lock(&dev->mode_config.mutex);
Chris Wilson7296c842014-07-22 20:10:28 +1000446 intel_connector_add_to_fbdev(intel_connector);
Dave Airlie0e32b392014-05-02 14:02:48 +1000447 mutex_unlock(&dev->mode_config.mutex);
448 drm_connector_register(&intel_connector->base);
449 return connector;
450}
451
452static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
453 struct drm_connector *connector)
454{
455 struct intel_connector *intel_connector = to_intel_connector(connector);
456 struct drm_device *dev = connector->dev;
Dave Airlie0e32b392014-05-02 14:02:48 +1000457 /* need to nuke the connector */
458 mutex_lock(&dev->mode_config.mutex);
459 intel_connector_dpms(connector, DRM_MODE_DPMS_OFF);
460 mutex_unlock(&dev->mode_config.mutex);
461
462 intel_connector->unregister(intel_connector);
463
464 mutex_lock(&dev->mode_config.mutex);
Chris Wilson7296c842014-07-22 20:10:28 +1000465 intel_connector_remove_from_fbdev(intel_connector);
Dave Airlie0e32b392014-05-02 14:02:48 +1000466 drm_connector_cleanup(connector);
467 mutex_unlock(&dev->mode_config.mutex);
468
469 drm_reinit_primary_mode_group(dev);
470
471 kfree(intel_connector);
472 DRM_DEBUG_KMS("\n");
473}
474
475static void intel_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr)
476{
477 struct intel_dp *intel_dp = container_of(mgr, struct intel_dp, mst_mgr);
478 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
479 struct drm_device *dev = intel_dig_port->base.base.dev;
480
481 drm_kms_helper_hotplug_event(dev);
482}
483
484static struct drm_dp_mst_topology_cbs mst_cbs = {
485 .add_connector = intel_dp_add_mst_connector,
486 .destroy_connector = intel_dp_destroy_mst_connector,
487 .hotplug = intel_dp_mst_hotplug,
488};
489
490static struct intel_dp_mst_encoder *
491intel_dp_create_fake_mst_encoder(struct intel_digital_port *intel_dig_port, enum pipe pipe)
492{
493 struct intel_dp_mst_encoder *intel_mst;
494 struct intel_encoder *intel_encoder;
495 struct drm_device *dev = intel_dig_port->base.base.dev;
496
497 intel_mst = kzalloc(sizeof(*intel_mst), GFP_KERNEL);
498
499 if (!intel_mst)
500 return NULL;
501
502 intel_mst->pipe = pipe;
503 intel_encoder = &intel_mst->base;
504 intel_mst->primary = intel_dig_port;
505
506 drm_encoder_init(dev, &intel_encoder->base, &intel_dp_mst_enc_funcs,
507 DRM_MODE_ENCODER_DPMST);
508
509 intel_encoder->type = INTEL_OUTPUT_DP_MST;
510 intel_encoder->crtc_mask = 0x7;
511 intel_encoder->cloneable = 0;
512
513 intel_encoder->compute_config = intel_dp_mst_compute_config;
514 intel_encoder->disable = intel_mst_disable_dp;
515 intel_encoder->post_disable = intel_mst_post_disable_dp;
516 intel_encoder->pre_enable = intel_mst_pre_enable_dp;
517 intel_encoder->enable = intel_mst_enable_dp;
518 intel_encoder->get_hw_state = intel_dp_mst_enc_get_hw_state;
519 intel_encoder->get_config = intel_dp_mst_enc_get_config;
520
521 return intel_mst;
522
523}
524
525static bool
526intel_dp_create_fake_mst_encoders(struct intel_digital_port *intel_dig_port)
527{
528 int i;
529 struct intel_dp *intel_dp = &intel_dig_port->dp;
530
531 for (i = PIPE_A; i <= PIPE_C; i++)
532 intel_dp->mst_encoders[i] = intel_dp_create_fake_mst_encoder(intel_dig_port, i);
533 return true;
534}
535
536int
537intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_base_id)
538{
539 struct intel_dp *intel_dp = &intel_dig_port->dp;
540 struct drm_device *dev = intel_dig_port->base.base.dev;
541 int ret;
542
543 intel_dp->can_mst = true;
544 intel_dp->mst_mgr.cbs = &mst_cbs;
545
546 /* create encoders */
547 intel_dp_create_fake_mst_encoders(intel_dig_port);
548 ret = drm_dp_mst_topology_mgr_init(&intel_dp->mst_mgr, dev->dev, &intel_dp->aux, 16, 3, conn_base_id);
549 if (ret) {
550 intel_dp->can_mst = false;
551 return ret;
552 }
553 return 0;
554}
555
556void
557intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port)
558{
559 struct intel_dp *intel_dp = &intel_dig_port->dp;
560
561 if (!intel_dp->can_mst)
562 return;
563
564 drm_dp_mst_topology_mgr_destroy(&intel_dp->mst_mgr);
565 /* encoders will get killed by normal cleanup */
566}