drm/msm: Construct only one encoder for DSI
authorArchit Taneja <architt@codeaurora.org>
Mon, 16 Jan 2017 04:12:03 +0000 (09:42 +0530)
committerRob Clark <robdclark@gmail.com>
Mon, 6 Feb 2017 16:28:43 +0000 (11:28 -0500)
We currently create 2 encoders for DSI interfaces, one for command
mode and other for video mode operation. This isn't needed as we
can't really use both the encoders at the same time. It also makes
connecting bridges harder.

Switch to creating a single encoder. For now, we assume that the
encoder is configured only in video mode. Later, the same encoder
would be usable in both modes.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/dsi/dsi.c
drivers/gpu/drm/msm/dsi/dsi.h
drivers/gpu/drm/msm/dsi/dsi_manager.c
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
drivers/gpu/drm/msm/msm_drv.h

index 9593238ccc1b52917aee7c97d0784362a81941ff..311c1c1e7d6c05e735a78c86cdae376db73ff267 100644 (file)
@@ -18,9 +18,7 @@ struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi)
        if (!msm_dsi || !msm_dsi_device_connected(msm_dsi))
                return NULL;
 
-       return (msm_dsi->device_flags & MIPI_DSI_MODE_VIDEO) ?
-               msm_dsi->encoders[MSM_DSI_VIDEO_ENCODER_ID] :
-               msm_dsi->encoders[MSM_DSI_CMD_ENCODER_ID];
+       return msm_dsi->encoder;
 }
 
 static int dsi_get_phy(struct msm_dsi *msm_dsi)
@@ -187,14 +185,13 @@ void __exit msm_dsi_unregister(void)
 }
 
 int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
-               struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM])
+                        struct drm_encoder *encoder)
 {
        struct msm_drm_private *priv = dev->dev_private;
        struct drm_bridge *ext_bridge;
-       int ret, i;
+       int ret;
 
-       if (WARN_ON(!encoders[MSM_DSI_VIDEO_ENCODER_ID] ||
-               !encoders[MSM_DSI_CMD_ENCODER_ID]))
+       if (WARN_ON(!encoder))
                return -EINVAL;
 
        msm_dsi->dev = dev;
@@ -205,8 +202,7 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
                goto fail;
        }
 
-       for (i = 0; i < MSM_DSI_ENCODER_NUM; i++)
-               msm_dsi->encoders[i] = encoders[i];
+       msm_dsi->encoder = encoder;
 
        msm_dsi->bridge = msm_dsi_manager_bridge_init(msm_dsi->id);
        if (IS_ERR(msm_dsi->bridge)) {
index 03f115f532c240a82f199efefdb0af6996ded09c..ddcda8cec9a7e98011d1a7fb52b2c9373bebac3f 100644 (file)
@@ -73,8 +73,8 @@ struct msm_dsi {
        struct device *phy_dev;
        bool phy_enabled;
 
-       /* the encoders we are hooked to (outside of dsi block) */
-       struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM];
+       /* the encoder we are hooked to (outside of dsi block) */
+       struct drm_encoder *encoder;
 
        int id;
 };
index 2bd8dad761056ccec772883a0089fb4ef081c0a8..19da23d8a0b117068e4b0c57ad820d6fb18bb427 100644 (file)
@@ -540,7 +540,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id)
        struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
        struct drm_connector *connector = NULL;
        struct dsi_connector *dsi_connector;
-       int ret, i;
+       int ret;
 
        dsi_connector = kzalloc(sizeof(*dsi_connector), GFP_KERNEL);
        if (!dsi_connector)
@@ -566,9 +566,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id)
        connector->interlace_allowed = 0;
        connector->doublescan_allowed = 0;
 
-       for (i = 0; i < MSM_DSI_ENCODER_NUM; i++)
-               drm_mode_connector_attach_encoder(connector,
-                                               msm_dsi->encoders[i]);
+       drm_mode_connector_attach_encoder(connector, msm_dsi->encoder);
 
        return connector;
 }
@@ -591,13 +589,7 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id)
 
        dsi_bridge->id = id;
 
-       /*
-        * HACK: we may not know the external DSI bridge device's mode
-        * flags here. We'll get to know them only when the device
-        * attaches to the dsi host. For now, assume the bridge supports
-        * DSI video mode
-        */
-       encoder = msm_dsi->encoders[MSM_DSI_VIDEO_ENCODER_ID];
+       encoder = msm_dsi->encoder;
 
        bridge = &dsi_bridge->base;
        bridge->funcs = &dsi_mgr_bridge_funcs;
@@ -628,13 +620,7 @@ struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id)
        ext_bridge = msm_dsi->external_bridge =
                        msm_dsi_host_get_bridge(msm_dsi->host);
 
-       /*
-        * HACK: we may not know the external DSI bridge device's mode
-        * flags here. We'll get to know them only when the device
-        * attaches to the dsi host. For now, assume the bridge supports
-        * DSI video mode
-        */
-       encoder = msm_dsi->encoders[MSM_DSI_VIDEO_ENCODER_ID];
+       encoder = msm_dsi->encoder;
 
        /* link the internal dsi bridge to the external bridge */
        drm_bridge_attach(encoder, ext_bridge, int_bridge);
index b782efd4b95f6dfc911ffd4939a326914d63e5be..94ea963519b28206ff2cc47c231ed45c752df9cf 100644 (file)
@@ -260,8 +260,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
        struct drm_encoder *encoder;
        struct drm_connector *connector;
        struct device_node *panel_node;
-       struct drm_encoder *dsi_encs[MSM_DSI_ENCODER_NUM];
-       int i, dsi_id;
+       int dsi_id;
        int ret;
 
        switch (intf_type) {
@@ -322,22 +321,19 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
                if (!priv->dsi[dsi_id])
                        break;
 
-               for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) {
-                       dsi_encs[i] = mdp4_dsi_encoder_init(dev);
-                       if (IS_ERR(dsi_encs[i])) {
-                               ret = PTR_ERR(dsi_encs[i]);
-                               dev_err(dev->dev,
-                                       "failed to construct DSI encoder: %d\n",
-                                       ret);
-                               return ret;
-                       }
-
-                       /* TODO: Add DMA_S later? */
-                       dsi_encs[i]->possible_crtcs = 1 << DMA_P;
-                       priv->encoders[priv->num_encoders++] = dsi_encs[i];
+               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;
                }
 
-               ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, dsi_encs);
+               /* 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);
index c396d459a9d062769471fdc84d01120c8d1e8525..5bad72c9e253e7c4710e273bdf466c81b9bbf1fa 100644 (file)
@@ -369,9 +369,6 @@ static int modeset_init_intf(struct mdp5_kms *mdp5_kms, int intf_num)
        case INTF_DSI:
        {
                int dsi_id = get_dsi_id_from_intf(hw_cfg, intf_num);
-               struct drm_encoder *dsi_encs[MSM_DSI_ENCODER_NUM];
-               enum mdp5_intf_mode mode;
-               int i;
 
                if ((dsi_id >= ARRAY_SIZE(priv->dsi)) || (dsi_id < 0)) {
                        dev_err(dev->dev, "failed to find dsi from intf %d\n",
@@ -389,19 +386,14 @@ static int modeset_init_intf(struct mdp5_kms *mdp5_kms, int intf_num)
                        break;
                }
 
-               for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) {
-                       mode = (i == MSM_DSI_CMD_ENCODER_ID) ?
-                               MDP5_INTF_DSI_MODE_COMMAND :
-                               MDP5_INTF_DSI_MODE_VIDEO;
-                       dsi_encs[i] = construct_encoder(mdp5_kms, INTF_DSI,
-                                                       intf_num, mode, ctl);
-                       if (IS_ERR(dsi_encs[i])) {
-                               ret = PTR_ERR(dsi_encs[i]);
-                               break;
-                       }
+               encoder = construct_encoder(mdp5_kms, INTF_DSI, intf_num,
+                                           MDP5_INTF_DSI_MODE_VIDEO, ctl);
+               if (IS_ERR(encoder)) {
+                       ret = PTR_ERR(encoder);
+                       break;
                }
 
-               ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, dsi_encs);
+               ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, encoder);
                break;
        }
        default:
index 5f6f48f4fbd933bfc7a021bb930bc37bd89ae161..cdd7b2f8e977644114db727a3309496ef3ecada1 100644 (file)
@@ -275,16 +275,11 @@ int msm_edp_modeset_init(struct msm_edp *edp, struct drm_device *dev,
                struct drm_encoder *encoder);
 
 struct msm_dsi;
-enum msm_dsi_encoder_id {
-       MSM_DSI_VIDEO_ENCODER_ID = 0,
-       MSM_DSI_CMD_ENCODER_ID = 1,
-       MSM_DSI_ENCODER_NUM = 2
-};
 #ifdef CONFIG_DRM_MSM_DSI
 void __init msm_dsi_register(void);
 void __exit msm_dsi_unregister(void);
 int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
-               struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM]);
+                        struct drm_encoder *encoder);
 #else
 static inline void __init msm_dsi_register(void)
 {
@@ -293,8 +288,8 @@ static inline void __exit msm_dsi_unregister(void)
 {
 }
 static inline int msm_dsi_modeset_init(struct msm_dsi *msm_dsi,
-               struct drm_device *dev,
-               struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM])
+                                      struct drm_device *dev,
+                                      struct drm_encoder *encoder)
 {
        return -EINVAL;
 }