ARM: pmu: add support for interrupt-affinity property
[linux/fpc-iii.git] / drivers / gpu / drm / msm / edp / edp_bridge.c
blob2bc73f82f3f50e00124cbec05908a879850ac29b
1 /*
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.
14 #include "edp.h"
16 struct edp_bridge {
17 struct drm_bridge base;
18 struct msm_edp *edp;
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;
31 DBG("");
32 msm_edp_ctrl_power(edp->ctrl, true);
35 static void edp_bridge_enable(struct drm_bridge *bridge)
37 DBG("");
40 static void edp_bridge_disable(struct drm_bridge *bridge)
42 DBG("");
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;
50 DBG("");
51 msm_edp_ctrl_power(edp->ctrl, false);
54 static void edp_bridge_mode_set(struct drm_bridge *bridge,
55 struct drm_display_mode *mode,
56 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: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
64 mode->base.id, mode->name,
65 mode->vrefresh, mode->clock,
66 mode->hdisplay, mode->hsync_start,
67 mode->hsync_end, mode->htotal,
68 mode->vdisplay, mode->vsync_start,
69 mode->vsync_end, mode->vtotal,
70 mode->type, mode->flags);
72 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
73 if ((connector->encoder != NULL) &&
74 (connector->encoder->bridge == bridge)) {
75 msm_edp_ctrl_timing_cfg(edp->ctrl,
76 adjusted_mode, &connector->display_info);
77 break;
82 static const struct drm_bridge_funcs edp_bridge_funcs = {
83 .pre_enable = edp_bridge_pre_enable,
84 .enable = edp_bridge_enable,
85 .disable = edp_bridge_disable,
86 .post_disable = edp_bridge_post_disable,
87 .mode_set = edp_bridge_mode_set,
90 /* initialize bridge */
91 struct drm_bridge *msm_edp_bridge_init(struct msm_edp *edp)
93 struct drm_bridge *bridge = NULL;
94 struct edp_bridge *edp_bridge;
95 int ret;
97 edp_bridge = devm_kzalloc(edp->dev->dev,
98 sizeof(*edp_bridge), GFP_KERNEL);
99 if (!edp_bridge) {
100 ret = -ENOMEM;
101 goto fail;
104 edp_bridge->edp = edp;
106 bridge = &edp_bridge->base;
107 bridge->funcs = &edp_bridge_funcs;
109 ret = drm_bridge_attach(edp->dev, bridge);
110 if (ret)
111 goto fail;
113 return bridge;
115 fail:
116 if (bridge)
117 edp_bridge_destroy(bridge);
119 return ERR_PTR(ret);