1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
9 struct drm_bridge base
;
12 #define to_edp_bridge(x) container_of(x, struct edp_bridge, base)
14 void edp_bridge_destroy(struct drm_bridge
*bridge
)
18 static void edp_bridge_pre_enable(struct drm_bridge
*bridge
)
20 struct edp_bridge
*edp_bridge
= to_edp_bridge(bridge
);
21 struct msm_edp
*edp
= edp_bridge
->edp
;
24 msm_edp_ctrl_power(edp
->ctrl
, true);
27 static void edp_bridge_enable(struct drm_bridge
*bridge
)
32 static void edp_bridge_disable(struct drm_bridge
*bridge
)
37 static void edp_bridge_post_disable(struct drm_bridge
*bridge
)
39 struct edp_bridge
*edp_bridge
= to_edp_bridge(bridge
);
40 struct msm_edp
*edp
= edp_bridge
->edp
;
43 msm_edp_ctrl_power(edp
->ctrl
, false);
46 static void edp_bridge_mode_set(struct drm_bridge
*bridge
,
47 const struct drm_display_mode
*mode
,
48 const struct drm_display_mode
*adjusted_mode
)
50 struct drm_device
*dev
= bridge
->dev
;
51 struct drm_connector
*connector
;
52 struct edp_bridge
*edp_bridge
= to_edp_bridge(bridge
);
53 struct msm_edp
*edp
= edp_bridge
->edp
;
55 DBG("set mode: " DRM_MODE_FMT
, DRM_MODE_ARG(mode
));
57 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
58 struct drm_encoder
*encoder
= connector
->encoder
;
59 struct drm_bridge
*first_bridge
;
61 if (!connector
->encoder
)
64 first_bridge
= drm_bridge_chain_get_first_bridge(encoder
);
65 if (bridge
== first_bridge
) {
66 msm_edp_ctrl_timing_cfg(edp
->ctrl
,
67 adjusted_mode
, &connector
->display_info
);
73 static const struct drm_bridge_funcs edp_bridge_funcs
= {
74 .pre_enable
= edp_bridge_pre_enable
,
75 .enable
= edp_bridge_enable
,
76 .disable
= edp_bridge_disable
,
77 .post_disable
= edp_bridge_post_disable
,
78 .mode_set
= edp_bridge_mode_set
,
81 /* initialize bridge */
82 struct drm_bridge
*msm_edp_bridge_init(struct msm_edp
*edp
)
84 struct drm_bridge
*bridge
= NULL
;
85 struct edp_bridge
*edp_bridge
;
88 edp_bridge
= devm_kzalloc(edp
->dev
->dev
,
89 sizeof(*edp_bridge
), GFP_KERNEL
);
95 edp_bridge
->edp
= edp
;
97 bridge
= &edp_bridge
->base
;
98 bridge
->funcs
= &edp_bridge_funcs
;
100 ret
= drm_bridge_attach(edp
->encoder
, bridge
, NULL
, 0);
108 edp_bridge_destroy(bridge
);