intel_dp_mst.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /*
  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. #include <drm/drmP.h>
  26. #include "i915_drv.h"
  27. #include "intel_drv.h"
  28. #include <drm/drm_atomic_helper.h>
  29. #include <drm/drm_crtc_helper.h>
  30. #include <drm/drm_edid.h>
  31. static bool intel_dp_mst_compute_config(struct intel_encoder *encoder,
  32. struct intel_crtc_state *pipe_config)
  33. {
  34. struct drm_device *dev = encoder->base.dev;
  35. struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
  36. struct intel_digital_port *intel_dig_port = intel_mst->primary;
  37. struct intel_dp *intel_dp = &intel_dig_port->dp;
  38. struct drm_atomic_state *state;
  39. int bpp, i;
  40. int lane_count, slots;
  41. const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
  42. struct drm_connector *drm_connector;
  43. struct intel_connector *connector, *found = NULL;
  44. struct drm_connector_state *connector_state;
  45. int mst_pbn;
  46. pipe_config->dp_encoder_is_mst = true;
  47. pipe_config->has_pch_encoder = false;
  48. pipe_config->has_dp_encoder = true;
  49. bpp = 24;
  50. /*
  51. * for MST we always configure max link bw - the spec doesn't
  52. * seem to suggest we should do otherwise.
  53. */
  54. lane_count = drm_dp_max_lane_count(intel_dp->dpcd);
  55. pipe_config->lane_count = lane_count;
  56. pipe_config->pipe_bpp = 24;
  57. pipe_config->port_clock = intel_dp_max_link_rate(intel_dp);
  58. state = pipe_config->base.state;
  59. for_each_connector_in_state(state, drm_connector, connector_state, i) {
  60. connector = to_intel_connector(drm_connector);
  61. if (connector_state->best_encoder == &encoder->base) {
  62. found = connector;
  63. break;
  64. }
  65. }
  66. if (!found) {
  67. DRM_ERROR("can't find connector\n");
  68. return false;
  69. }
  70. mst_pbn = drm_dp_calc_pbn_mode(adjusted_mode->crtc_clock, bpp);
  71. pipe_config->pbn = mst_pbn;
  72. slots = drm_dp_find_vcpi_slots(&intel_dp->mst_mgr, mst_pbn);
  73. intel_link_compute_m_n(bpp, lane_count,
  74. adjusted_mode->crtc_clock,
  75. pipe_config->port_clock,
  76. &pipe_config->dp_m_n);
  77. pipe_config->dp_m_n.tu = slots;
  78. if (IS_HASWELL(dev) || IS_BROADWELL(dev))
  79. hsw_dp_set_ddi_pll_sel(pipe_config);
  80. return true;
  81. }
  82. static void intel_mst_disable_dp(struct intel_encoder *encoder)
  83. {
  84. struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
  85. struct intel_digital_port *intel_dig_port = intel_mst->primary;
  86. struct intel_dp *intel_dp = &intel_dig_port->dp;
  87. int ret;
  88. DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
  89. drm_dp_mst_reset_vcpi_slots(&intel_dp->mst_mgr, intel_mst->port);
  90. ret = drm_dp_update_payload_part1(&intel_dp->mst_mgr);
  91. if (ret) {
  92. DRM_ERROR("failed to update payload %d\n", ret);
  93. }
  94. }
  95. static void intel_mst_post_disable_dp(struct intel_encoder *encoder)
  96. {
  97. struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
  98. struct intel_digital_port *intel_dig_port = intel_mst->primary;
  99. struct intel_dp *intel_dp = &intel_dig_port->dp;
  100. DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
  101. /* this can fail */
  102. drm_dp_check_act_status(&intel_dp->mst_mgr);
  103. /* and this can also fail */
  104. drm_dp_update_payload_part2(&intel_dp->mst_mgr);
  105. drm_dp_mst_deallocate_vcpi(&intel_dp->mst_mgr, intel_mst->port);
  106. intel_dp->active_mst_links--;
  107. intel_mst->port = NULL;
  108. if (intel_dp->active_mst_links == 0) {
  109. intel_dig_port->base.post_disable(&intel_dig_port->base);
  110. intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
  111. }
  112. }
  113. static void intel_mst_pre_enable_dp(struct intel_encoder *encoder)
  114. {
  115. struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
  116. struct intel_digital_port *intel_dig_port = intel_mst->primary;
  117. struct intel_dp *intel_dp = &intel_dig_port->dp;
  118. struct drm_device *dev = encoder->base.dev;
  119. struct drm_i915_private *dev_priv = dev->dev_private;
  120. enum port port = intel_dig_port->port;
  121. int ret;
  122. uint32_t temp;
  123. struct intel_connector *found = NULL, *connector;
  124. int slots;
  125. struct drm_crtc *crtc = encoder->base.crtc;
  126. struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  127. for_each_intel_connector(dev, connector) {
  128. if (connector->base.state->best_encoder == &encoder->base) {
  129. found = connector;
  130. break;
  131. }
  132. }
  133. if (!found) {
  134. DRM_ERROR("can't find connector\n");
  135. return;
  136. }
  137. /* MST encoders are bound to a crtc, not to a connector,
  138. * force the mapping here for get_hw_state.
  139. */
  140. found->encoder = encoder;
  141. DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
  142. intel_mst->port = found->port;
  143. if (intel_dp->active_mst_links == 0) {
  144. enum port port = intel_ddi_get_encoder_port(encoder);
  145. intel_dp_set_link_params(intel_dp, intel_crtc->config);
  146. /* FIXME: add support for SKL */
  147. if (INTEL_INFO(dev)->gen < 9)
  148. I915_WRITE(PORT_CLK_SEL(port),
  149. intel_crtc->config->ddi_pll_sel);
  150. intel_ddi_init_dp_buf_reg(&intel_dig_port->base);
  151. intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
  152. intel_dp_start_link_train(intel_dp);
  153. intel_dp_stop_link_train(intel_dp);
  154. }
  155. ret = drm_dp_mst_allocate_vcpi(&intel_dp->mst_mgr,
  156. intel_mst->port,
  157. intel_crtc->config->pbn, &slots);
  158. if (ret == false) {
  159. DRM_ERROR("failed to allocate vcpi\n");
  160. return;
  161. }
  162. intel_dp->active_mst_links++;
  163. temp = I915_READ(DP_TP_STATUS(port));
  164. I915_WRITE(DP_TP_STATUS(port), temp);
  165. ret = drm_dp_update_payload_part1(&intel_dp->mst_mgr);
  166. }
  167. static void intel_mst_enable_dp(struct intel_encoder *encoder)
  168. {
  169. struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
  170. struct intel_digital_port *intel_dig_port = intel_mst->primary;
  171. struct intel_dp *intel_dp = &intel_dig_port->dp;
  172. struct drm_device *dev = intel_dig_port->base.base.dev;
  173. struct drm_i915_private *dev_priv = dev->dev_private;
  174. enum port port = intel_dig_port->port;
  175. int ret;
  176. DRM_DEBUG_KMS("%d\n", intel_dp->active_mst_links);
  177. if (wait_for((I915_READ(DP_TP_STATUS(port)) & DP_TP_STATUS_ACT_SENT),
  178. 1))
  179. DRM_ERROR("Timed out waiting for ACT sent\n");
  180. ret = drm_dp_check_act_status(&intel_dp->mst_mgr);
  181. ret = drm_dp_update_payload_part2(&intel_dp->mst_mgr);
  182. }
  183. static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder,
  184. enum pipe *pipe)
  185. {
  186. struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
  187. *pipe = intel_mst->pipe;
  188. if (intel_mst->port)
  189. return true;
  190. return false;
  191. }
  192. static void intel_dp_mst_enc_get_config(struct intel_encoder *encoder,
  193. struct intel_crtc_state *pipe_config)
  194. {
  195. struct intel_dp_mst_encoder *intel_mst = enc_to_mst(&encoder->base);
  196. struct intel_digital_port *intel_dig_port = intel_mst->primary;
  197. struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
  198. struct drm_device *dev = encoder->base.dev;
  199. struct drm_i915_private *dev_priv = dev->dev_private;
  200. enum transcoder cpu_transcoder = pipe_config->cpu_transcoder;
  201. u32 temp, flags = 0;
  202. pipe_config->has_dp_encoder = true;
  203. temp = I915_READ(TRANS_DDI_FUNC_CTL(cpu_transcoder));
  204. if (temp & TRANS_DDI_PHSYNC)
  205. flags |= DRM_MODE_FLAG_PHSYNC;
  206. else
  207. flags |= DRM_MODE_FLAG_NHSYNC;
  208. if (temp & TRANS_DDI_PVSYNC)
  209. flags |= DRM_MODE_FLAG_PVSYNC;
  210. else
  211. flags |= DRM_MODE_FLAG_NVSYNC;
  212. switch (temp & TRANS_DDI_BPC_MASK) {
  213. case TRANS_DDI_BPC_6:
  214. pipe_config->pipe_bpp = 18;
  215. break;
  216. case TRANS_DDI_BPC_8:
  217. pipe_config->pipe_bpp = 24;
  218. break;
  219. case TRANS_DDI_BPC_10:
  220. pipe_config->pipe_bpp = 30;
  221. break;
  222. case TRANS_DDI_BPC_12:
  223. pipe_config->pipe_bpp = 36;
  224. break;
  225. default:
  226. break;
  227. }
  228. pipe_config->base.adjusted_mode.flags |= flags;
  229. pipe_config->lane_count =
  230. ((temp & DDI_PORT_WIDTH_MASK) >> DDI_PORT_WIDTH_SHIFT) + 1;
  231. intel_dp_get_m_n(crtc, pipe_config);
  232. intel_ddi_clock_get(&intel_dig_port->base, pipe_config);
  233. }
  234. static int intel_dp_mst_get_ddc_modes(struct drm_connector *connector)
  235. {
  236. struct intel_connector *intel_connector = to_intel_connector(connector);
  237. struct intel_dp *intel_dp = intel_connector->mst_port;
  238. struct edid *edid;
  239. int ret;
  240. edid = drm_dp_mst_get_edid(connector, &intel_dp->mst_mgr, intel_connector->port);
  241. if (!edid)
  242. return 0;
  243. ret = intel_connector_update_modes(connector, edid);
  244. kfree(edid);
  245. return ret;
  246. }
  247. static enum drm_connector_status
  248. intel_dp_mst_detect(struct drm_connector *connector, bool force)
  249. {
  250. struct intel_connector *intel_connector = to_intel_connector(connector);
  251. struct intel_dp *intel_dp = intel_connector->mst_port;
  252. return drm_dp_mst_detect_port(connector, &intel_dp->mst_mgr, intel_connector->port);
  253. }
  254. static int
  255. intel_dp_mst_set_property(struct drm_connector *connector,
  256. struct drm_property *property,
  257. uint64_t val)
  258. {
  259. return 0;
  260. }
  261. static void
  262. intel_dp_mst_connector_destroy(struct drm_connector *connector)
  263. {
  264. struct intel_connector *intel_connector = to_intel_connector(connector);
  265. if (!IS_ERR_OR_NULL(intel_connector->edid))
  266. kfree(intel_connector->edid);
  267. drm_connector_cleanup(connector);
  268. kfree(connector);
  269. }
  270. static const struct drm_connector_funcs intel_dp_mst_connector_funcs = {
  271. .dpms = drm_atomic_helper_connector_dpms,
  272. .detect = intel_dp_mst_detect,
  273. .fill_modes = drm_helper_probe_single_connector_modes,
  274. .set_property = intel_dp_mst_set_property,
  275. .atomic_get_property = intel_connector_atomic_get_property,
  276. .destroy = intel_dp_mst_connector_destroy,
  277. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  278. .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  279. };
  280. static int intel_dp_mst_get_modes(struct drm_connector *connector)
  281. {
  282. return intel_dp_mst_get_ddc_modes(connector);
  283. }
  284. static enum drm_mode_status
  285. intel_dp_mst_mode_valid(struct drm_connector *connector,
  286. struct drm_display_mode *mode)
  287. {
  288. /* TODO - validate mode against available PBN for link */
  289. if (mode->clock < 10000)
  290. return MODE_CLOCK_LOW;
  291. if (mode->flags & DRM_MODE_FLAG_DBLCLK)
  292. return MODE_H_ILLEGAL;
  293. return MODE_OK;
  294. }
  295. static struct drm_encoder *intel_mst_atomic_best_encoder(struct drm_connector *connector,
  296. struct drm_connector_state *state)
  297. {
  298. struct intel_connector *intel_connector = to_intel_connector(connector);
  299. struct intel_dp *intel_dp = intel_connector->mst_port;
  300. struct intel_crtc *crtc = to_intel_crtc(state->crtc);
  301. return &intel_dp->mst_encoders[crtc->pipe]->base.base;
  302. }
  303. static struct drm_encoder *intel_mst_best_encoder(struct drm_connector *connector)
  304. {
  305. struct intel_connector *intel_connector = to_intel_connector(connector);
  306. struct intel_dp *intel_dp = intel_connector->mst_port;
  307. return &intel_dp->mst_encoders[0]->base.base;
  308. }
  309. static const struct drm_connector_helper_funcs intel_dp_mst_connector_helper_funcs = {
  310. .get_modes = intel_dp_mst_get_modes,
  311. .mode_valid = intel_dp_mst_mode_valid,
  312. .atomic_best_encoder = intel_mst_atomic_best_encoder,
  313. .best_encoder = intel_mst_best_encoder,
  314. };
  315. static void intel_dp_mst_encoder_destroy(struct drm_encoder *encoder)
  316. {
  317. struct intel_dp_mst_encoder *intel_mst = enc_to_mst(encoder);
  318. drm_encoder_cleanup(encoder);
  319. kfree(intel_mst);
  320. }
  321. static const struct drm_encoder_funcs intel_dp_mst_enc_funcs = {
  322. .destroy = intel_dp_mst_encoder_destroy,
  323. };
  324. static bool intel_dp_mst_get_hw_state(struct intel_connector *connector)
  325. {
  326. if (connector->encoder && connector->base.state->crtc) {
  327. enum pipe pipe;
  328. if (!connector->encoder->get_hw_state(connector->encoder, &pipe))
  329. return false;
  330. return true;
  331. }
  332. return false;
  333. }
  334. static void intel_connector_add_to_fbdev(struct intel_connector *connector)
  335. {
  336. #ifdef CONFIG_DRM_FBDEV_EMULATION
  337. struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
  338. drm_fb_helper_add_one_connector(&dev_priv->fbdev->helper, &connector->base);
  339. #endif
  340. }
  341. static void intel_connector_remove_from_fbdev(struct intel_connector *connector)
  342. {
  343. #ifdef CONFIG_DRM_FBDEV_EMULATION
  344. struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
  345. drm_fb_helper_remove_one_connector(&dev_priv->fbdev->helper, &connector->base);
  346. #endif
  347. }
  348. static struct drm_connector *intel_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, const char *pathprop)
  349. {
  350. struct intel_dp *intel_dp = container_of(mgr, struct intel_dp, mst_mgr);
  351. struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
  352. struct drm_device *dev = intel_dig_port->base.base.dev;
  353. struct intel_connector *intel_connector;
  354. struct drm_connector *connector;
  355. int i;
  356. intel_connector = intel_connector_alloc();
  357. if (!intel_connector)
  358. return NULL;
  359. connector = &intel_connector->base;
  360. drm_connector_init(dev, connector, &intel_dp_mst_connector_funcs, DRM_MODE_CONNECTOR_DisplayPort);
  361. drm_connector_helper_add(connector, &intel_dp_mst_connector_helper_funcs);
  362. intel_connector->unregister = intel_connector_unregister;
  363. intel_connector->get_hw_state = intel_dp_mst_get_hw_state;
  364. intel_connector->mst_port = intel_dp;
  365. intel_connector->port = port;
  366. for (i = PIPE_A; i <= PIPE_C; i++) {
  367. drm_mode_connector_attach_encoder(&intel_connector->base,
  368. &intel_dp->mst_encoders[i]->base.base);
  369. }
  370. intel_dp_add_properties(intel_dp, connector);
  371. drm_object_attach_property(&connector->base, dev->mode_config.path_property, 0);
  372. drm_object_attach_property(&connector->base, dev->mode_config.tile_property, 0);
  373. drm_mode_connector_set_path_property(connector, pathprop);
  374. return connector;
  375. }
  376. static void intel_dp_register_mst_connector(struct drm_connector *connector)
  377. {
  378. struct intel_connector *intel_connector = to_intel_connector(connector);
  379. struct drm_device *dev = connector->dev;
  380. drm_modeset_lock_all(dev);
  381. intel_connector_add_to_fbdev(intel_connector);
  382. drm_modeset_unlock_all(dev);
  383. drm_connector_register(&intel_connector->base);
  384. }
  385. static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
  386. struct drm_connector *connector)
  387. {
  388. struct intel_connector *intel_connector = to_intel_connector(connector);
  389. struct drm_device *dev = connector->dev;
  390. intel_connector->unregister(intel_connector);
  391. /* need to nuke the connector */
  392. drm_modeset_lock_all(dev);
  393. if (connector->state->crtc) {
  394. struct drm_mode_set set;
  395. int ret;
  396. memset(&set, 0, sizeof(set));
  397. set.crtc = connector->state->crtc,
  398. ret = drm_atomic_helper_set_config(&set);
  399. WARN(ret, "Disabling mst crtc failed with %i\n", ret);
  400. }
  401. intel_connector_remove_from_fbdev(intel_connector);
  402. drm_connector_cleanup(connector);
  403. drm_modeset_unlock_all(dev);
  404. kfree(intel_connector);
  405. DRM_DEBUG_KMS("\n");
  406. }
  407. static void intel_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr)
  408. {
  409. struct intel_dp *intel_dp = container_of(mgr, struct intel_dp, mst_mgr);
  410. struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
  411. struct drm_device *dev = intel_dig_port->base.base.dev;
  412. drm_kms_helper_hotplug_event(dev);
  413. }
  414. static struct drm_dp_mst_topology_cbs mst_cbs = {
  415. .add_connector = intel_dp_add_mst_connector,
  416. .register_connector = intel_dp_register_mst_connector,
  417. .destroy_connector = intel_dp_destroy_mst_connector,
  418. .hotplug = intel_dp_mst_hotplug,
  419. };
  420. static struct intel_dp_mst_encoder *
  421. intel_dp_create_fake_mst_encoder(struct intel_digital_port *intel_dig_port, enum pipe pipe)
  422. {
  423. struct intel_dp_mst_encoder *intel_mst;
  424. struct intel_encoder *intel_encoder;
  425. struct drm_device *dev = intel_dig_port->base.base.dev;
  426. intel_mst = kzalloc(sizeof(*intel_mst), GFP_KERNEL);
  427. if (!intel_mst)
  428. return NULL;
  429. intel_mst->pipe = pipe;
  430. intel_encoder = &intel_mst->base;
  431. intel_mst->primary = intel_dig_port;
  432. drm_encoder_init(dev, &intel_encoder->base, &intel_dp_mst_enc_funcs,
  433. DRM_MODE_ENCODER_DPMST);
  434. intel_encoder->type = INTEL_OUTPUT_DP_MST;
  435. intel_encoder->crtc_mask = 0x7;
  436. intel_encoder->cloneable = 0;
  437. intel_encoder->compute_config = intel_dp_mst_compute_config;
  438. intel_encoder->disable = intel_mst_disable_dp;
  439. intel_encoder->post_disable = intel_mst_post_disable_dp;
  440. intel_encoder->pre_enable = intel_mst_pre_enable_dp;
  441. intel_encoder->enable = intel_mst_enable_dp;
  442. intel_encoder->get_hw_state = intel_dp_mst_enc_get_hw_state;
  443. intel_encoder->get_config = intel_dp_mst_enc_get_config;
  444. return intel_mst;
  445. }
  446. static bool
  447. intel_dp_create_fake_mst_encoders(struct intel_digital_port *intel_dig_port)
  448. {
  449. int i;
  450. struct intel_dp *intel_dp = &intel_dig_port->dp;
  451. for (i = PIPE_A; i <= PIPE_C; i++)
  452. intel_dp->mst_encoders[i] = intel_dp_create_fake_mst_encoder(intel_dig_port, i);
  453. return true;
  454. }
  455. int
  456. intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_base_id)
  457. {
  458. struct intel_dp *intel_dp = &intel_dig_port->dp;
  459. struct drm_device *dev = intel_dig_port->base.base.dev;
  460. int ret;
  461. intel_dp->can_mst = true;
  462. intel_dp->mst_mgr.cbs = &mst_cbs;
  463. /* create encoders */
  464. intel_dp_create_fake_mst_encoders(intel_dig_port);
  465. ret = drm_dp_mst_topology_mgr_init(&intel_dp->mst_mgr, dev->dev, &intel_dp->aux, 16, 3, conn_base_id);
  466. if (ret) {
  467. intel_dp->can_mst = false;
  468. return ret;
  469. }
  470. return 0;
  471. }
  472. void
  473. intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port)
  474. {
  475. struct intel_dp *intel_dp = &intel_dig_port->dp;
  476. if (!intel_dp->can_mst)
  477. return;
  478. drm_dp_mst_topology_mgr_destroy(&intel_dp->mst_mgr);
  479. /* encoders will get killed by normal cleanup */
  480. }