| .. | .. |
|---|
| 1 | | -// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | +// SPDX-License-Identifier: MIT |
|---|
| 2 | 2 | |
|---|
| 3 | | -#include <drm/drmP.h> |
|---|
| 3 | +#include <drm/drm_debugfs.h> |
|---|
| 4 | 4 | #include <drm/drm_dp_mst_helper.h> |
|---|
| 5 | 5 | #include <drm/drm_fb_helper.h> |
|---|
| 6 | +#include <drm/drm_file.h> |
|---|
| 7 | +#include <drm/drm_probe_helper.h> |
|---|
| 6 | 8 | |
|---|
| 7 | | -#include "radeon.h" |
|---|
| 8 | 9 | #include "atom.h" |
|---|
| 9 | 10 | #include "ni_reg.h" |
|---|
| 11 | +#include "radeon.h" |
|---|
| 10 | 12 | |
|---|
| 11 | 13 | static struct radeon_encoder *radeon_dp_create_fake_mst_encoder(struct radeon_connector *connector); |
|---|
| 12 | 14 | |
|---|
| .. | .. |
|---|
| 231 | 233 | return &radeon_connector->mst_encoder->base; |
|---|
| 232 | 234 | } |
|---|
| 233 | 235 | |
|---|
| 236 | +static int |
|---|
| 237 | +radeon_dp_mst_detect(struct drm_connector *connector, |
|---|
| 238 | + struct drm_modeset_acquire_ctx *ctx, |
|---|
| 239 | + bool force) |
|---|
| 240 | +{ |
|---|
| 241 | + struct radeon_connector *radeon_connector = |
|---|
| 242 | + to_radeon_connector(connector); |
|---|
| 243 | + struct radeon_connector *master = radeon_connector->mst_port; |
|---|
| 244 | + |
|---|
| 245 | + if (drm_connector_is_unregistered(connector)) |
|---|
| 246 | + return connector_status_disconnected; |
|---|
| 247 | + |
|---|
| 248 | + return drm_dp_mst_detect_port(connector, ctx, &master->mst_mgr, |
|---|
| 249 | + radeon_connector->port); |
|---|
| 250 | +} |
|---|
| 251 | + |
|---|
| 234 | 252 | static const struct drm_connector_helper_funcs radeon_dp_mst_connector_helper_funcs = { |
|---|
| 235 | 253 | .get_modes = radeon_dp_mst_get_modes, |
|---|
| 236 | 254 | .mode_valid = radeon_dp_mst_mode_valid, |
|---|
| 237 | 255 | .best_encoder = radeon_mst_best_encoder, |
|---|
| 256 | + .detect_ctx = radeon_dp_mst_detect, |
|---|
| 238 | 257 | }; |
|---|
| 239 | | - |
|---|
| 240 | | -static enum drm_connector_status |
|---|
| 241 | | -radeon_dp_mst_detect(struct drm_connector *connector, bool force) |
|---|
| 242 | | -{ |
|---|
| 243 | | - struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
|---|
| 244 | | - struct radeon_connector *master = radeon_connector->mst_port; |
|---|
| 245 | | - |
|---|
| 246 | | - return drm_dp_mst_detect_port(connector, &master->mst_mgr, radeon_connector->port); |
|---|
| 247 | | -} |
|---|
| 248 | 258 | |
|---|
| 249 | 259 | static void |
|---|
| 250 | 260 | radeon_dp_mst_connector_destroy(struct drm_connector *connector) |
|---|
| .. | .. |
|---|
| 260 | 270 | |
|---|
| 261 | 271 | static const struct drm_connector_funcs radeon_dp_mst_connector_funcs = { |
|---|
| 262 | 272 | .dpms = drm_helper_connector_dpms, |
|---|
| 263 | | - .detect = radeon_dp_mst_detect, |
|---|
| 264 | 273 | .fill_modes = drm_helper_probe_single_connector_modes, |
|---|
| 265 | 274 | .destroy = radeon_dp_mst_connector_destroy, |
|---|
| 266 | 275 | }; |
|---|
| .. | .. |
|---|
| 295 | 304 | return connector; |
|---|
| 296 | 305 | } |
|---|
| 297 | 306 | |
|---|
| 298 | | -static void radeon_dp_register_mst_connector(struct drm_connector *connector) |
|---|
| 299 | | -{ |
|---|
| 300 | | - struct drm_device *dev = connector->dev; |
|---|
| 301 | | - struct radeon_device *rdev = dev->dev_private; |
|---|
| 302 | | - |
|---|
| 303 | | - radeon_fb_add_connector(rdev, connector); |
|---|
| 304 | | - |
|---|
| 305 | | - drm_connector_register(connector); |
|---|
| 306 | | -} |
|---|
| 307 | | - |
|---|
| 308 | | -static void radeon_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, |
|---|
| 309 | | - struct drm_connector *connector) |
|---|
| 310 | | -{ |
|---|
| 311 | | - struct radeon_connector *master = container_of(mgr, struct radeon_connector, mst_mgr); |
|---|
| 312 | | - struct drm_device *dev = master->base.dev; |
|---|
| 313 | | - struct radeon_device *rdev = dev->dev_private; |
|---|
| 314 | | - |
|---|
| 315 | | - drm_connector_unregister(connector); |
|---|
| 316 | | - radeon_fb_remove_connector(rdev, connector); |
|---|
| 317 | | - drm_connector_cleanup(connector); |
|---|
| 318 | | - |
|---|
| 319 | | - kfree(connector); |
|---|
| 320 | | - DRM_DEBUG_KMS("\n"); |
|---|
| 321 | | -} |
|---|
| 322 | | - |
|---|
| 323 | | -static void radeon_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr) |
|---|
| 324 | | -{ |
|---|
| 325 | | - struct radeon_connector *master = container_of(mgr, struct radeon_connector, mst_mgr); |
|---|
| 326 | | - struct drm_device *dev = master->base.dev; |
|---|
| 327 | | - |
|---|
| 328 | | - drm_kms_helper_hotplug_event(dev); |
|---|
| 329 | | -} |
|---|
| 330 | | - |
|---|
| 331 | 307 | static const struct drm_dp_mst_topology_cbs mst_cbs = { |
|---|
| 332 | 308 | .add_connector = radeon_dp_add_mst_connector, |
|---|
| 333 | | - .register_connector = radeon_dp_register_mst_connector, |
|---|
| 334 | | - .destroy_connector = radeon_dp_destroy_mst_connector, |
|---|
| 335 | | - .hotplug = radeon_dp_mst_hotplug, |
|---|
| 336 | 309 | }; |
|---|
| 337 | 310 | |
|---|
| 338 | 311 | static struct |
|---|
| .. | .. |
|---|
| 521 | 494 | |
|---|
| 522 | 495 | mst_enc = radeon_encoder->enc_priv; |
|---|
| 523 | 496 | |
|---|
| 524 | | - mst_enc->pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp); |
|---|
| 497 | + mst_enc->pbn = drm_dp_calc_pbn_mode(adjusted_mode->clock, bpp, false); |
|---|
| 525 | 498 | |
|---|
| 526 | 499 | mst_enc->primary->active_device = mst_enc->primary->devices & mst_enc->connector->devices; |
|---|
| 527 | 500 | DRM_DEBUG_KMS("setting active device to %08x from %08x %08x for encoder %d\n", |
|---|