*/
 
 /* ovl-mgr-id -> crtc */
-static struct omap_crtc *omap_crtcs[8];
 static struct omap_dss_device *omap_crtc_output[8];
 
 /* we can probably ignore these until we support command-mode panels: */
 static int omap_crtc_dss_enable(struct omap_drm_private *priv,
                                enum omap_channel channel)
 {
-       struct omap_crtc *omap_crtc = omap_crtcs[channel];
+       struct drm_crtc *crtc = priv->channels[channel]->crtc;
+       struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
        priv->dispc_ops->mgr_set_timings(priv->dispc, omap_crtc->channel,
                                         &omap_crtc->vm);
 static void omap_crtc_dss_disable(struct omap_drm_private *priv,
                                  enum omap_channel channel)
 {
-       struct omap_crtc *omap_crtc = omap_crtcs[channel];
+       struct drm_crtc *crtc = priv->channels[channel]->crtc;
+       struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
        omap_crtc_set_enabled(&omap_crtc->base, false);
 }
                enum omap_channel channel,
                const struct videomode *vm)
 {
-       struct omap_crtc *omap_crtc = omap_crtcs[channel];
+       struct drm_crtc *crtc = priv->channels[channel]->crtc;
+       struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+
        DBG("%s", omap_crtc->name);
        omap_crtc->vm = *vm;
 }
                enum omap_channel channel,
                const struct dss_lcd_mgr_config *config)
 {
-       struct omap_crtc *omap_crtc = omap_crtcs[channel];
+       struct drm_crtc *crtc = priv->channels[channel]->crtc;
+       struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
        DBG("%s", omap_crtc->name);
        priv->dispc_ops->mgr_set_lcd_config(priv->dispc, omap_crtc->channel,
 
 void omap_crtc_pre_init(struct omap_drm_private *priv)
 {
-       memset(omap_crtcs, 0, sizeof(omap_crtcs));
-
        dss_install_mgr_ops(priv->dss, &mgr_ops, priv);
 }
 
 
        DBG("%s", channel_names[channel]);
 
-       /* Multiple displays on same channel is not allowed */
-       if (WARN_ON(omap_crtcs[channel] != NULL))
-               return ERR_PTR(-EINVAL);
-
        omap_crtc = kzalloc(sizeof(*omap_crtc), GFP_KERNEL);
        if (!omap_crtc)
                return ERR_PTR(-ENOMEM);
 
        omap_plane_install_properties(crtc->primary, &crtc->base);
 
-       omap_crtcs[channel] = omap_crtc;
-
        return crtc;
 }
 
                pipe->display = NULL;
        }
 
+       memset(&priv->channels, 0, sizeof(priv->channels));
+
        priv->num_pipes = 0;
 }
 
 {
        struct omap_drm_private *priv = ddev->dev_private;
        struct omap_dss_device *output = NULL;
+       unsigned int i;
        int r;
 
        if (!omapdss_stack_is_ready())
        sort(priv->pipes, priv->num_pipes, sizeof(priv->pipes[0]),
             omap_compare_pipes, NULL);
 
+       /*
+        * Populate the pipeline lookup table by DISPC channel. Only one display
+        * is allowed per channel.
+        */
+       for (i = 0; i < priv->num_pipes; ++i) {
+               struct omap_drm_pipeline *pipe = &priv->pipes[i];
+               enum omap_channel channel = pipe->output->dispc_channel;
+
+               if (WARN_ON(priv->channels[channel] != NULL)) {
+                       r = -EINVAL;
+                       goto cleanup;
+               }
+
+               priv->channels[channel] = pipe;
+       }
+
        return 0;
 
 cleanup: