static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, int intf_type) { struct drm_device *dev = mdp4_kms->dev; struct msm_drm_private *priv = dev->dev_private; struct drm_encoder *encoder; struct drm_connector *connector; struct device_node *panel_node; int dsi_id; int ret; switch (intf_type) { case DRM_MODE_ENCODER_LVDS: /* * bail out early if there is no panel node (no need to * initialize LCDC encoder and LVDS connector) */ panel_node = of_graph_get_remote_node(dev->dev->of_node, 0, 0); if (!panel_node) return 0; encoder = mdp4_lcdc_encoder_init(dev, panel_node); if (IS_ERR(encoder)) { dev_err(dev->dev, "failed to construct LCDC encoder\n"); return PTR_ERR(encoder); } /* LCDC can be hooked to DMA_P (TODO: Add DMA_S later?) */ encoder->possible_crtcs = 1 << DMA_P; connector = mdp4_lvds_connector_init(dev, panel_node, encoder); if (IS_ERR(connector)) { dev_err(dev->dev, "failed to initialize LVDS connector\n"); return PTR_ERR(connector); } priv->encoders[priv->num_encoders++] = encoder; priv->connectors[priv->num_connectors++] = connector; break; case DRM_MODE_ENCODER_TMDS: encoder = mdp4_dtv_encoder_init(dev); if (IS_ERR(encoder)) { dev_err(dev->dev, "failed to construct DTV encoder\n"); return PTR_ERR(encoder); } /* DTV can be hooked to DMA_E: */ encoder->possible_crtcs = 1 << 1; if (priv->hdmi) { /* Construct bridge/connector for HDMI: */ ret = msm_hdmi_modeset_init(priv->hdmi, dev, encoder); if (ret) { dev_err(dev->dev, "failed to initialize HDMI: %d\n", ret); return ret; } } priv->encoders[priv->num_encoders++] = encoder; break; case DRM_MODE_ENCODER_DSI: /* only DSI1 supported for now */ dsi_id = 0; if (!priv->dsi[dsi_id]) break; encoder = mdp4_dsi_encoder_init(dev); if (IS_ERR(encoder)) { ret = PTR_ERR(encoder); dev_err(dev->dev, "failed to construct DSI encoder: %d\n", ret); return ret; } /* TODO: Add DMA_S later? */ encoder->possible_crtcs = 1 << DMA_P; priv->encoders[priv->num_encoders++] = encoder; ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, encoder); if (ret) { dev_err(dev->dev, "failed to initialize DSI: %d\n", ret); return ret; } break; default: dev_err(dev->dev, "Invalid or unsupported interface\n"); return -EINVAL; } return 0; }
static int modeset_init(struct mdp4_kms *mdp4_kms) { struct drm_device *dev = mdp4_kms->dev; struct msm_drm_private *priv = dev->dev_private; struct drm_plane *plane; struct drm_crtc *crtc; struct drm_encoder *encoder; struct hdmi *hdmi; int ret; /* * NOTE: this is a bit simplistic until we add support * for more than just RGB1->DMA_E->DTV->HDMI */ /* construct non-private planes: */ plane = mdp4_plane_init(dev, VG1, false); if (IS_ERR(plane)) { dev_err(dev->dev, "failed to construct plane for VG1\n"); ret = PTR_ERR(plane); goto fail; } priv->planes[priv->num_planes++] = plane; plane = mdp4_plane_init(dev, VG2, false); if (IS_ERR(plane)) { dev_err(dev->dev, "failed to construct plane for VG2\n"); ret = PTR_ERR(plane); goto fail; } priv->planes[priv->num_planes++] = plane; /* the CRTCs get constructed with a private plane: */ plane = mdp4_plane_init(dev, RGB1, true); if (IS_ERR(plane)) { dev_err(dev->dev, "failed to construct plane for RGB1\n"); ret = PTR_ERR(plane); goto fail; } crtc = mdp4_crtc_init(dev, plane, priv->num_crtcs, 1, DMA_E); if (IS_ERR(crtc)) { dev_err(dev->dev, "failed to construct crtc for DMA_E\n"); ret = PTR_ERR(crtc); goto fail; } priv->crtcs[priv->num_crtcs++] = crtc; encoder = mdp4_dtv_encoder_init(dev); if (IS_ERR(encoder)) { dev_err(dev->dev, "failed to construct DTV encoder\n"); ret = PTR_ERR(encoder); goto fail; } encoder->possible_crtcs = 0x1; /* DTV can be hooked to DMA_E */ priv->encoders[priv->num_encoders++] = encoder; hdmi = hdmi_init(dev, encoder); if (IS_ERR(hdmi)) { ret = PTR_ERR(hdmi); dev_err(dev->dev, "failed to initialize HDMI: %d\n", ret); goto fail; } return 0; fail: return ret; }