Commit 97e00119 authored by Archit Taneja's avatar Archit Taneja Committed by Rob Clark

drm/msm: Construct only one encoder for DSI

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: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent 0bb70b82
...@@ -18,9 +18,7 @@ struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi) ...@@ -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)) if (!msm_dsi || !msm_dsi_device_connected(msm_dsi))
return NULL; return NULL;
return (msm_dsi->device_flags & MIPI_DSI_MODE_VIDEO) ? return msm_dsi->encoder;
msm_dsi->encoders[MSM_DSI_VIDEO_ENCODER_ID] :
msm_dsi->encoders[MSM_DSI_CMD_ENCODER_ID];
} }
static int dsi_get_phy(struct msm_dsi *msm_dsi) static int dsi_get_phy(struct msm_dsi *msm_dsi)
...@@ -187,14 +185,13 @@ void __exit msm_dsi_unregister(void) ...@@ -187,14 +185,13 @@ void __exit msm_dsi_unregister(void)
} }
int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev, 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 msm_drm_private *priv = dev->dev_private;
struct drm_bridge *ext_bridge; struct drm_bridge *ext_bridge;
int ret, i; int ret;
if (WARN_ON(!encoders[MSM_DSI_VIDEO_ENCODER_ID] || if (WARN_ON(!encoder))
!encoders[MSM_DSI_CMD_ENCODER_ID]))
return -EINVAL; return -EINVAL;
msm_dsi->dev = dev; msm_dsi->dev = dev;
...@@ -205,8 +202,7 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev, ...@@ -205,8 +202,7 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
goto fail; goto fail;
} }
for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) msm_dsi->encoder = encoder;
msm_dsi->encoders[i] = encoders[i];
msm_dsi->bridge = msm_dsi_manager_bridge_init(msm_dsi->id); msm_dsi->bridge = msm_dsi_manager_bridge_init(msm_dsi->id);
if (IS_ERR(msm_dsi->bridge)) { if (IS_ERR(msm_dsi->bridge)) {
......
...@@ -73,8 +73,8 @@ struct msm_dsi { ...@@ -73,8 +73,8 @@ struct msm_dsi {
struct device *phy_dev; struct device *phy_dev;
bool phy_enabled; bool phy_enabled;
/* the encoders we are hooked to (outside of dsi block) */ /* the encoder we are hooked to (outside of dsi block) */
struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM]; struct drm_encoder *encoder;
int id; int id;
}; };
......
...@@ -540,7 +540,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id) ...@@ -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 msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
struct drm_connector *connector = NULL; struct drm_connector *connector = NULL;
struct dsi_connector *dsi_connector; struct dsi_connector *dsi_connector;
int ret, i; int ret;
dsi_connector = kzalloc(sizeof(*dsi_connector), GFP_KERNEL); dsi_connector = kzalloc(sizeof(*dsi_connector), GFP_KERNEL);
if (!dsi_connector) if (!dsi_connector)
...@@ -566,9 +566,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id) ...@@ -566,9 +566,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id)
connector->interlace_allowed = 0; connector->interlace_allowed = 0;
connector->doublescan_allowed = 0; connector->doublescan_allowed = 0;
for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) drm_mode_connector_attach_encoder(connector, msm_dsi->encoder);
drm_mode_connector_attach_encoder(connector,
msm_dsi->encoders[i]);
return connector; return connector;
} }
...@@ -591,13 +589,7 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id) ...@@ -591,13 +589,7 @@ struct drm_bridge *msm_dsi_manager_bridge_init(u8 id)
dsi_bridge->id = id; dsi_bridge->id = id;
/* encoder = msm_dsi->encoder;
* 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];
bridge = &dsi_bridge->base; bridge = &dsi_bridge->base;
bridge->funcs = &dsi_mgr_bridge_funcs; bridge->funcs = &dsi_mgr_bridge_funcs;
...@@ -628,13 +620,7 @@ struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id) ...@@ -628,13 +620,7 @@ struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id)
ext_bridge = msm_dsi->external_bridge = ext_bridge = msm_dsi->external_bridge =
msm_dsi_host_get_bridge(msm_dsi->host); msm_dsi_host_get_bridge(msm_dsi->host);
/* encoder = msm_dsi->encoder;
* 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];
/* link the internal dsi bridge to the external bridge */ /* link the internal dsi bridge to the external bridge */
drm_bridge_attach(encoder, ext_bridge, int_bridge); drm_bridge_attach(encoder, ext_bridge, int_bridge);
......
...@@ -260,8 +260,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, ...@@ -260,8 +260,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_connector *connector; struct drm_connector *connector;
struct device_node *panel_node; struct device_node *panel_node;
struct drm_encoder *dsi_encs[MSM_DSI_ENCODER_NUM]; int dsi_id;
int i, dsi_id;
int ret; int ret;
switch (intf_type) { switch (intf_type) {
...@@ -322,22 +321,19 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms, ...@@ -322,22 +321,19 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
if (!priv->dsi[dsi_id]) if (!priv->dsi[dsi_id])
break; break;
for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) { encoder = mdp4_dsi_encoder_init(dev);
dsi_encs[i] = mdp4_dsi_encoder_init(dev); if (IS_ERR(encoder)) {
if (IS_ERR(dsi_encs[i])) { ret = PTR_ERR(encoder);
ret = PTR_ERR(dsi_encs[i]);
dev_err(dev->dev, dev_err(dev->dev,
"failed to construct DSI encoder: %d\n", "failed to construct DSI encoder: %d\n", ret);
ret);
return ret; return ret;
} }
/* TODO: Add DMA_S later? */ /* TODO: Add DMA_S later? */
dsi_encs[i]->possible_crtcs = 1 << DMA_P; encoder->possible_crtcs = 1 << DMA_P;
priv->encoders[priv->num_encoders++] = dsi_encs[i]; priv->encoders[priv->num_encoders++] = encoder;
}
ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, dsi_encs); ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, encoder);
if (ret) { if (ret) {
dev_err(dev->dev, "failed to initialize DSI: %d\n", dev_err(dev->dev, "failed to initialize DSI: %d\n",
ret); ret);
......
...@@ -369,9 +369,6 @@ static int modeset_init_intf(struct mdp5_kms *mdp5_kms, int intf_num) ...@@ -369,9 +369,6 @@ static int modeset_init_intf(struct mdp5_kms *mdp5_kms, int intf_num)
case INTF_DSI: case INTF_DSI:
{ {
int dsi_id = get_dsi_id_from_intf(hw_cfg, intf_num); 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)) { if ((dsi_id >= ARRAY_SIZE(priv->dsi)) || (dsi_id < 0)) {
dev_err(dev->dev, "failed to find dsi from intf %d\n", 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) ...@@ -389,19 +386,14 @@ static int modeset_init_intf(struct mdp5_kms *mdp5_kms, int intf_num)
break; break;
} }
for (i = 0; i < MSM_DSI_ENCODER_NUM; i++) { encoder = construct_encoder(mdp5_kms, INTF_DSI, intf_num,
mode = (i == MSM_DSI_CMD_ENCODER_ID) ? MDP5_INTF_DSI_MODE_VIDEO, ctl);
MDP5_INTF_DSI_MODE_COMMAND : if (IS_ERR(encoder)) {
MDP5_INTF_DSI_MODE_VIDEO; ret = PTR_ERR(encoder);
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; 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; break;
} }
default: default:
......
...@@ -275,16 +275,11 @@ int msm_edp_modeset_init(struct msm_edp *edp, struct drm_device *dev, ...@@ -275,16 +275,11 @@ int msm_edp_modeset_init(struct msm_edp *edp, struct drm_device *dev,
struct drm_encoder *encoder); struct drm_encoder *encoder);
struct msm_dsi; 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 #ifdef CONFIG_DRM_MSM_DSI
void __init msm_dsi_register(void); void __init msm_dsi_register(void);
void __exit msm_dsi_unregister(void); void __exit msm_dsi_unregister(void);
int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev, 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 #else
static inline void __init msm_dsi_register(void) static inline void __init msm_dsi_register(void)
{ {
...@@ -294,7 +289,7 @@ static inline void __exit msm_dsi_unregister(void) ...@@ -294,7 +289,7 @@ static inline void __exit msm_dsi_unregister(void)
} }
static inline int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, static inline int msm_dsi_modeset_init(struct msm_dsi *msm_dsi,
struct drm_device *dev, struct drm_device *dev,
struct drm_encoder *encoders[MSM_DSI_ENCODER_NUM]) struct drm_encoder *encoder)
{ {
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment