diff options
author | Rob Clark <robdclark@gmail.com> | 2013-08-30 13:02:15 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-09-01 20:23:35 -0400 |
commit | a3376e3ec81c5dd0622cbc187db76d2824d31c1c (patch) | |
tree | 22e4e13c73905a624692cbfd7c7a560d79597b67 /drivers/gpu/drm/msm/hdmi/hdmi.c | |
parent | 3b336ec4c5460833ad7573d0b6e22793f6a389ab (diff) |
drm/msm: convert to drm_bridge
Drop the msm_connector base class, and special calls to base class
methods from the encoder, and use instead drm_bridge. This allows for a
cleaner division between the hdmi (and in future dsi) blocks, from the
mdp block.
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/msm/hdmi/hdmi.c')
-rw-r--r-- | drivers/gpu/drm/msm/hdmi/hdmi.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 12ecfb928f75..50d11df35b21 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c | |||
@@ -56,8 +56,9 @@ static irqreturn_t hdmi_irq(int irq, void *dev_id) | |||
56 | return IRQ_HANDLED; | 56 | return IRQ_HANDLED; |
57 | } | 57 | } |
58 | 58 | ||
59 | void hdmi_destroy(struct hdmi *hdmi) | 59 | void hdmi_destroy(struct kref *kref) |
60 | { | 60 | { |
61 | struct hdmi *hdmi = container_of(kref, struct hdmi, refcount); | ||
61 | struct hdmi_phy *phy = hdmi->phy; | 62 | struct hdmi_phy *phy = hdmi->phy; |
62 | 63 | ||
63 | if (phy) | 64 | if (phy) |
@@ -70,9 +71,10 @@ void hdmi_destroy(struct hdmi *hdmi) | |||
70 | } | 71 | } |
71 | 72 | ||
72 | /* initialize connector */ | 73 | /* initialize connector */ |
73 | int hdmi_init(struct hdmi *hdmi, struct drm_device *dev, | 74 | int hdmi_init(struct drm_device *dev, struct drm_encoder *encoder) |
74 | struct drm_connector *connector) | ||
75 | { | 75 | { |
76 | struct hdmi *hdmi = NULL; | ||
77 | struct msm_drm_private *priv = dev->dev_private; | ||
76 | struct platform_device *pdev = hdmi_pdev; | 78 | struct platform_device *pdev = hdmi_pdev; |
77 | struct hdmi_platform_config *config; | 79 | struct hdmi_platform_config *config; |
78 | int ret; | 80 | int ret; |
@@ -85,11 +87,19 @@ int hdmi_init(struct hdmi *hdmi, struct drm_device *dev, | |||
85 | 87 | ||
86 | config = pdev->dev.platform_data; | 88 | config = pdev->dev.platform_data; |
87 | 89 | ||
90 | hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL); | ||
91 | if (!hdmi) { | ||
92 | ret = -ENOMEM; | ||
93 | goto fail; | ||
94 | } | ||
95 | |||
96 | kref_init(&hdmi->refcount); | ||
97 | |||
88 | get_device(&pdev->dev); | 98 | get_device(&pdev->dev); |
89 | 99 | ||
90 | hdmi->dev = dev; | 100 | hdmi->dev = dev; |
91 | hdmi->pdev = pdev; | 101 | hdmi->pdev = pdev; |
92 | hdmi->connector = connector; | 102 | hdmi->encoder = encoder; |
93 | 103 | ||
94 | /* not sure about which phy maps to which msm.. probably I miss some */ | 104 | /* not sure about which phy maps to which msm.. probably I miss some */ |
95 | if (config->phy_init) | 105 | if (config->phy_init) |
@@ -152,6 +162,22 @@ int hdmi_init(struct hdmi *hdmi, struct drm_device *dev, | |||
152 | goto fail; | 162 | goto fail; |
153 | } | 163 | } |
154 | 164 | ||
165 | hdmi->bridge = hdmi_bridge_init(hdmi); | ||
166 | if (IS_ERR(hdmi->bridge)) { | ||
167 | ret = PTR_ERR(hdmi->bridge); | ||
168 | dev_err(dev->dev, "failed to create HDMI bridge: %d\n", ret); | ||
169 | hdmi->bridge = NULL; | ||
170 | goto fail; | ||
171 | } | ||
172 | |||
173 | hdmi->connector = hdmi_connector_init(hdmi); | ||
174 | if (IS_ERR(hdmi->connector)) { | ||
175 | ret = PTR_ERR(hdmi->connector); | ||
176 | dev_err(dev->dev, "failed to create HDMI connector: %d\n", ret); | ||
177 | hdmi->connector = NULL; | ||
178 | goto fail; | ||
179 | } | ||
180 | |||
155 | hdmi->irq = platform_get_irq(pdev, 0); | 181 | hdmi->irq = platform_get_irq(pdev, 0); |
156 | if (hdmi->irq < 0) { | 182 | if (hdmi->irq < 0) { |
157 | ret = hdmi->irq; | 183 | ret = hdmi->irq; |
@@ -168,11 +194,22 @@ int hdmi_init(struct hdmi *hdmi, struct drm_device *dev, | |||
168 | goto fail; | 194 | goto fail; |
169 | } | 195 | } |
170 | 196 | ||
197 | encoder->bridge = hdmi->bridge; | ||
198 | |||
199 | priv->bridges[priv->num_bridges++] = hdmi->bridge; | ||
200 | priv->connectors[priv->num_connectors++] = hdmi->connector; | ||
201 | |||
171 | return 0; | 202 | return 0; |
172 | 203 | ||
173 | fail: | 204 | fail: |
174 | if (hdmi) | 205 | if (hdmi) { |
175 | hdmi_destroy(hdmi); | 206 | /* bridge/connector are normally destroyed by drm: */ |
207 | if (hdmi->bridge) | ||
208 | hdmi->bridge->funcs->destroy(hdmi->bridge); | ||
209 | if (hdmi->connector) | ||
210 | hdmi->connector->funcs->destroy(hdmi->connector); | ||
211 | hdmi_destroy(&hdmi->refcount); | ||
212 | } | ||
176 | 213 | ||
177 | return ret; | 214 | return ret; |
178 | } | 215 | } |