2 * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
17 struct drm_bridge base
;
20 #define to_edp_bridge(x) container_of(x, struct edp_bridge, base)
22 void edp_bridge_destroy(struct drm_bridge
*bridge
)
26 static void edp_bridge_pre_enable(struct drm_bridge
*bridge
)
28 struct edp_bridge
*edp_bridge
= to_edp_bridge(bridge
);
29 struct msm_edp
*edp
= edp_bridge
->edp
;
32 msm_edp_ctrl_power(edp
->ctrl
, true);
35 static void edp_bridge_enable(struct drm_bridge
*bridge
)
40 static void edp_bridge_disable(struct drm_bridge
*bridge
)
45 static void edp_bridge_post_disable(struct drm_bridge
*bridge
)
47 struct edp_bridge
*edp_bridge
= to_edp_bridge(bridge
);
48 struct msm_edp
*edp
= edp_bridge
->edp
;
51 msm_edp_ctrl_power(edp
->ctrl
, false);
54 static void edp_bridge_mode_set(struct drm_bridge
*bridge
,
55 const struct drm_display_mode
*mode
,
56 const struct drm_display_mode
*adjusted_mode
)
58 struct drm_device
*dev
= bridge
->dev
;
59 struct drm_connector
*connector
;
60 struct edp_bridge
*edp_bridge
= to_edp_bridge(bridge
);
61 struct msm_edp
*edp
= edp_bridge
->edp
;
63 DBG("set mode: " DRM_MODE_FMT
, DRM_MODE_ARG(mode
));
65 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
, head
) {
66 if ((connector
->encoder
!= NULL
) &&
67 (connector
->encoder
->bridge
== bridge
)) {
68 msm_edp_ctrl_timing_cfg(edp
->ctrl
,
69 adjusted_mode
, &connector
->display_info
);
75 static const struct drm_bridge_funcs edp_bridge_funcs
= {
76 .pre_enable
= edp_bridge_pre_enable
,
77 .enable
= edp_bridge_enable
,
78 .disable
= edp_bridge_disable
,
79 .post_disable
= edp_bridge_post_disable
,
80 .mode_set
= edp_bridge_mode_set
,
83 /* initialize bridge */
84 struct drm_bridge
*msm_edp_bridge_init(struct msm_edp
*edp
)
86 struct drm_bridge
*bridge
= NULL
;
87 struct edp_bridge
*edp_bridge
;
90 edp_bridge
= devm_kzalloc(edp
->dev
->dev
,
91 sizeof(*edp_bridge
), GFP_KERNEL
);
97 edp_bridge
->edp
= edp
;
99 bridge
= &edp_bridge
->base
;
100 bridge
->funcs
= &edp_bridge_funcs
;
102 ret
= drm_bridge_attach(edp
->encoder
, bridge
, NULL
);
110 edp_bridge_destroy(bridge
);