@@ -31,6 +31,36 @@ static enum drm_connector_status dp_bridge_detect(struct drm_bridge *bridge)
3131 connector_status_disconnected ;
3232}
3333
34+ static int dp_bridge_atomic_check (struct drm_bridge * bridge ,
35+ struct drm_bridge_state * bridge_state ,
36+ struct drm_crtc_state * crtc_state ,
37+ struct drm_connector_state * conn_state )
38+ {
39+ struct msm_dp * dp ;
40+
41+ dp = to_dp_bridge (bridge )-> dp_display ;
42+
43+ drm_dbg_dp (dp -> drm_dev , "is_connected = %s\n" ,
44+ (dp -> is_connected ) ? "true" : "false" );
45+
46+ /*
47+ * There is no protection in the DRM framework to check if the display
48+ * pipeline has been already disabled before trying to disable it again.
49+ * Hence if the sink is unplugged, the pipeline gets disabled, but the
50+ * crtc->active is still true. Any attempt to set the mode or manually
51+ * disable this encoder will result in the crash.
52+ *
53+ * TODO: add support for telling the DRM subsystem that the pipeline is
54+ * disabled by the hardware and thus all access to it should be forbidden.
55+ * After that this piece of code can be removed.
56+ */
57+ if (bridge -> ops & DRM_BRIDGE_OP_HPD )
58+ return (dp -> is_connected ) ? 0 : - ENOTCONN ;
59+
60+ return 0 ;
61+ }
62+
63+
3464/**
3565 * dp_bridge_get_modes - callback to add drm modes via drm_mode_probed_add()
3666 * @bridge: Poiner to drm bridge
@@ -61,13 +91,17 @@ static int dp_bridge_get_modes(struct drm_bridge *bridge, struct drm_connector *
6191}
6292
6393static const struct drm_bridge_funcs dp_bridge_ops = {
94+ .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state ,
95+ .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state ,
96+ .atomic_reset = drm_atomic_helper_bridge_reset ,
6497 .enable = dp_bridge_enable ,
6598 .disable = dp_bridge_disable ,
6699 .post_disable = dp_bridge_post_disable ,
67100 .mode_set = dp_bridge_mode_set ,
68101 .mode_valid = dp_bridge_mode_valid ,
69102 .get_modes = dp_bridge_get_modes ,
70103 .detect = dp_bridge_detect ,
104+ .atomic_check = dp_bridge_atomic_check ,
71105};
72106
73107struct drm_bridge * dp_bridge_init (struct msm_dp * dp_display , struct drm_device * dev ,
0 commit comments