OMAPDRM: fix overlay manager handling
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Tue, 14 May 2013 07:55:19 +0000 (10:55 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 17 Jun 2013 11:00:43 +0000 (14:00 +0300)
Currently omapdrm creates crtcs, which map directly to DSS overlay
managers, only on demand at init time. This would make it difficult to
manage connecting the display entities in the future, as the code cannot
just search for a suitable overlay manager.

We cannot fix this the sane way, which would be to create crtcs for each
overlay manager, because we need an overlay for each crtc. With limited
number of overlays, that's not possible.

So the solution for now is to detach the overlay manager from the crtc.
crtcs are still created on demand at init time, but all overlay managers
are always initialized by the omapdss.

This way we can create and connect whole display pipelines from the
overlay manager to the display, regardless of which crtcs omapdrm would
create.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/omap_crtc.c
drivers/gpu/drm/omapdrm/omap_drv.c
drivers/gpu/drm/omapdrm/omap_drv.h
drivers/video/omap2/dss/apply.c
drivers/video/omap2/dss/dispc.c

index 79b200aee18a50e4b82277a0e2b3e380ab8cf280..02075bfcd8fda95fb4a8f7dcdff51918ba41ce36 100644 (file)
@@ -40,7 +40,7 @@ struct omap_crtc {
         * mgr->id.)  Eventually this will be replaced w/ something
         * more common-panel-framework-y
         */
-       struct omap_overlay_manager mgr;
+       struct omap_overlay_manager *mgr;
 
        struct omap_video_timings timings;
        bool enabled;
@@ -90,6 +90,9 @@ uint32_t pipe2vbl(struct drm_crtc *crtc)
  * job of sequencing the setup of the video pipe in the proper order
  */
 
+/* ovl-mgr-id -> crtc */
+static struct omap_crtc *omap_crtcs[8];
+
 /* we can probably ignore these until we support command-mode panels: */
 static void omap_crtc_start_update(struct omap_overlay_manager *mgr)
 {
@@ -107,7 +110,7 @@ static void omap_crtc_disable(struct omap_overlay_manager *mgr)
 static void omap_crtc_set_timings(struct omap_overlay_manager *mgr,
                const struct omap_video_timings *timings)
 {
-       struct omap_crtc *omap_crtc = container_of(mgr, struct omap_crtc, mgr);
+       struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
        DBG("%s", omap_crtc->name);
        omap_crtc->timings = *timings;
        omap_crtc->full_update = true;
@@ -116,7 +119,7 @@ static void omap_crtc_set_timings(struct omap_overlay_manager *mgr,
 static void omap_crtc_set_lcd_config(struct omap_overlay_manager *mgr,
                const struct dss_lcd_mgr_config *config)
 {
-       struct omap_crtc *omap_crtc = container_of(mgr, struct omap_crtc, mgr);
+       struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
        DBG("%s", omap_crtc->name);
        dispc_mgr_set_lcd_config(omap_crtc->channel, config);
 }
@@ -569,7 +572,7 @@ static void omap_crtc_pre_apply(struct omap_drm_apply *apply)
        } else {
                if (encoder) {
                        omap_encoder_set_enabled(encoder, false);
-                       omap_encoder_update(encoder, &omap_crtc->mgr,
+                       omap_encoder_update(encoder, omap_crtc->mgr,
                                        &omap_crtc->timings);
                        omap_encoder_set_enabled(encoder, true);
                        omap_crtc->full_update = false;
@@ -595,6 +598,11 @@ static const char *channel_names[] = {
                [OMAP_DSS_CHANNEL_LCD2] = "lcd2",
 };
 
+void omap_crtc_pre_init(void)
+{
+       dss_install_mgr_ops(&mgr_ops);
+}
+
 /* initialize crtc */
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
                struct drm_plane *plane, enum omap_channel channel, int id)
@@ -635,9 +643,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
        omap_irq_register(dev, &omap_crtc->error_irq);
 
        /* temporary: */
-       omap_crtc->mgr.id = channel;
-
-       dss_install_mgr_ops(&mgr_ops);
+       omap_crtc->mgr = omap_dss_get_overlay_manager(channel);
 
        /* TODO: fix hard-coded setup.. add properties! */
        info = &omap_crtc->info;
@@ -651,6 +657,8 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 
        omap_plane_install_properties(omap_crtc->plane, &crtc->base);
 
+       omap_crtcs[channel] = omap_crtc;
+
        return crtc;
 
 fail:
index b3577cb367af82eebe4d54bf191afaec7f015a41..ff9b49276b810ecfb8633e514e3e12ec138f7eec 100644 (file)
@@ -98,6 +98,8 @@ static int omap_modeset_init(struct drm_device *dev)
        int num_crtcs;
        int i, id = 0;
 
+       omap_crtc_pre_init();
+
        drm_mode_config_init(dev);
 
        omap_drm_irq_install(dev);
index 215a20dd340cc8984ddffad32b0c7c42010d06c1..14f17da2ce25552a973c7d8d5cebe1ed1c8fa037 100644 (file)
@@ -157,6 +157,7 @@ const struct omap_video_timings *omap_crtc_timings(struct drm_crtc *crtc);
 enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
 int omap_crtc_apply(struct drm_crtc *crtc,
                struct omap_drm_apply *apply);
+void omap_crtc_pre_init(void);
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
                struct drm_plane *plane, enum omap_channel channel, int id);
 
index 74d1d000e92d742adf636c7cea18f0529e35bbd9..c844071e8e28441cb2ed68544928bfc0663fe761 100644 (file)
@@ -1577,7 +1577,6 @@ int omapdss_compat_init(void)
 
        apply_init_priv();
 
-       dss_init_overlay_managers();
        dss_init_overlay_managers_sysfs(pdev);
        dss_init_overlays(pdev);
 
@@ -1642,7 +1641,6 @@ err_disp_sysfs:
 
 err_mgr_ops:
        dss_uninit_overlay_managers_sysfs(pdev);
-       dss_uninit_overlay_managers();
        dss_uninit_overlays(pdev);
 
        compat_refcnt--;
@@ -1671,7 +1669,6 @@ void omapdss_compat_uninit(void)
        dss_uninstall_mgr_ops();
 
        dss_uninit_overlay_managers_sysfs(pdev);
-       dss_uninit_overlay_managers();
        dss_uninit_overlays(pdev);
 out:
        mutex_unlock(&compat_init_lock);
index b33b0169bb3b3f85f5722c52d8568cf0ad62ab4e..83d7bb9da609a037bef99146497ec6023223beed 100644 (file)
@@ -3710,6 +3710,8 @@ static int __init omap_dispchw_probe(struct platform_device *pdev)
 
        dispc_runtime_put();
 
+       dss_init_overlay_managers();
+
        dss_debugfs_create_file("dispc", dispc_dump_regs);
 
        return 0;
@@ -3723,6 +3725,8 @@ static int __exit omap_dispchw_remove(struct platform_device *pdev)
 {
        pm_runtime_disable(&pdev->dev);
 
+       dss_uninit_overlay_managers();
+
        return 0;
 }