diff options
| author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2015-01-11 09:30:44 -0500 |
|---|---|---|
| committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2015-03-20 08:30:16 -0400 |
| commit | fb9a35f89fac2ca97597ce212439d2997f2caf7e (patch) | |
| tree | e717f6973dc9f7e8769135827d6a7d71d16a05e9 /drivers | |
| parent | 222025e42d7f77133b8c3a2355d20a6004096c4b (diff) | |
drm: omapdrm: Refactor CRTC creation code
Create a omap_modeset_create_crtc() function to avoid duplicating plane
and CRTC creation code.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_drv.c | 76 | ||||
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_plane.c | 2 |
2 files changed, 45 insertions, 33 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 642748cb7a4e..021855605a1f 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c | |||
| @@ -128,6 +128,29 @@ cleanup: | |||
| 128 | return r; | 128 | return r; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | static int omap_modeset_create_crtc(struct drm_device *dev, int id, | ||
| 132 | enum omap_channel channel) | ||
| 133 | { | ||
| 134 | struct omap_drm_private *priv = dev->dev_private; | ||
| 135 | struct drm_plane *plane; | ||
| 136 | struct drm_crtc *crtc; | ||
| 137 | |||
| 138 | plane = omap_plane_init(dev, id, true); | ||
| 139 | if (IS_ERR(plane)) | ||
| 140 | return PTR_ERR(plane); | ||
| 141 | |||
| 142 | crtc = omap_crtc_init(dev, plane, channel, id); | ||
| 143 | |||
| 144 | BUG_ON(priv->num_crtcs >= ARRAY_SIZE(priv->crtcs)); | ||
| 145 | priv->crtcs[id] = crtc; | ||
| 146 | priv->num_crtcs++; | ||
| 147 | |||
| 148 | priv->planes[id] = plane; | ||
| 149 | priv->num_planes++; | ||
| 150 | |||
| 151 | return 0; | ||
| 152 | } | ||
| 153 | |||
| 131 | static int omap_modeset_init(struct drm_device *dev) | 154 | static int omap_modeset_init(struct drm_device *dev) |
| 132 | { | 155 | { |
| 133 | struct omap_drm_private *priv = dev->dev_private; | 156 | struct omap_drm_private *priv = dev->dev_private; |
| @@ -136,6 +159,7 @@ static int omap_modeset_init(struct drm_device *dev) | |||
| 136 | int num_mgrs = dss_feat_get_num_mgrs(); | 159 | int num_mgrs = dss_feat_get_num_mgrs(); |
| 137 | int num_crtcs; | 160 | int num_crtcs; |
| 138 | int i, id = 0; | 161 | int i, id = 0; |
| 162 | int ret; | ||
| 139 | 163 | ||
| 140 | drm_mode_config_init(dev); | 164 | drm_mode_config_init(dev); |
| 141 | 165 | ||
| @@ -209,18 +233,13 @@ static int omap_modeset_init(struct drm_device *dev) | |||
| 209 | * allocated crtc, we create a new crtc for it | 233 | * allocated crtc, we create a new crtc for it |
| 210 | */ | 234 | */ |
| 211 | if (!channel_used(dev, channel)) { | 235 | if (!channel_used(dev, channel)) { |
| 212 | struct drm_plane *plane; | 236 | ret = omap_modeset_create_crtc(dev, id, channel); |
| 213 | struct drm_crtc *crtc; | 237 | if (ret < 0) { |
| 214 | 238 | dev_err(dev->dev, | |
| 215 | plane = omap_plane_init(dev, id, true); | 239 | "could not create CRTC (channel %u)\n", |
| 216 | crtc = omap_crtc_init(dev, plane, channel, id); | 240 | channel); |
| 217 | 241 | return ret; | |
| 218 | BUG_ON(priv->num_crtcs >= ARRAY_SIZE(priv->crtcs)); | 242 | } |
| 219 | priv->crtcs[id] = crtc; | ||
| 220 | priv->num_crtcs++; | ||
| 221 | |||
| 222 | priv->planes[id] = plane; | ||
| 223 | priv->num_planes++; | ||
| 224 | 243 | ||
| 225 | id++; | 244 | id++; |
| 226 | } | 245 | } |
| @@ -234,26 +253,8 @@ static int omap_modeset_init(struct drm_device *dev) | |||
| 234 | 253 | ||
| 235 | /* find a free manager for this crtc */ | 254 | /* find a free manager for this crtc */ |
| 236 | for (i = 0; i < num_mgrs; i++) { | 255 | for (i = 0; i < num_mgrs; i++) { |
| 237 | if (!channel_used(dev, i)) { | 256 | if (!channel_used(dev, i)) |
| 238 | struct drm_plane *plane; | ||
| 239 | struct drm_crtc *crtc; | ||
| 240 | |||
| 241 | plane = omap_plane_init(dev, id, true); | ||
| 242 | crtc = omap_crtc_init(dev, plane, i, id); | ||
| 243 | |||
| 244 | BUG_ON(priv->num_crtcs >= | ||
| 245 | ARRAY_SIZE(priv->crtcs)); | ||
| 246 | |||
| 247 | priv->crtcs[id] = crtc; | ||
| 248 | priv->num_crtcs++; | ||
| 249 | |||
| 250 | priv->planes[id] = plane; | ||
| 251 | priv->num_planes++; | ||
| 252 | |||
| 253 | break; | 257 | break; |
| 254 | } else { | ||
| 255 | continue; | ||
| 256 | } | ||
| 257 | } | 258 | } |
| 258 | 259 | ||
| 259 | if (i == num_mgrs) { | 260 | if (i == num_mgrs) { |
| @@ -261,13 +262,24 @@ static int omap_modeset_init(struct drm_device *dev) | |||
| 261 | dev_err(dev->dev, "no managers left for crtc\n"); | 262 | dev_err(dev->dev, "no managers left for crtc\n"); |
| 262 | return -ENOMEM; | 263 | return -ENOMEM; |
| 263 | } | 264 | } |
| 265 | |||
| 266 | ret = omap_modeset_create_crtc(dev, id, i); | ||
| 267 | if (ret < 0) { | ||
| 268 | dev_err(dev->dev, | ||
| 269 | "could not create CRTC (channel %u)\n", i); | ||
| 270 | return ret; | ||
| 271 | } | ||
| 264 | } | 272 | } |
| 265 | 273 | ||
| 266 | /* | 274 | /* |
| 267 | * Create normal planes for the remaining overlays: | 275 | * Create normal planes for the remaining overlays: |
| 268 | */ | 276 | */ |
| 269 | for (; id < num_ovls; id++) { | 277 | for (; id < num_ovls; id++) { |
| 270 | struct drm_plane *plane = omap_plane_init(dev, id, false); | 278 | struct drm_plane *plane; |
| 279 | |||
| 280 | plane = omap_plane_init(dev, id, false); | ||
| 281 | if (IS_ERR(plane)) | ||
| 282 | return PTR_ERR(plane); | ||
| 271 | 283 | ||
| 272 | BUG_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)); | 284 | BUG_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)); |
| 273 | priv->planes[priv->num_planes++] = plane; | 285 | priv->planes[priv->num_planes++] = plane; |
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index a418fa7e5d0e..056ded8280f8 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c | |||
| @@ -393,7 +393,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, | |||
| 393 | 393 | ||
| 394 | omap_plane = kzalloc(sizeof(*omap_plane), GFP_KERNEL); | 394 | omap_plane = kzalloc(sizeof(*omap_plane), GFP_KERNEL); |
| 395 | if (!omap_plane) | 395 | if (!omap_plane) |
| 396 | return NULL; | 396 | return ERR_PTR(-ENOMEM); |
| 397 | 397 | ||
| 398 | drm_flip_work_init(&omap_plane->unpin_work, | 398 | drm_flip_work_init(&omap_plane->unpin_work, |
| 399 | "unpin", unpin_worker); | 399 | "unpin", unpin_worker); |
