<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Nov 3, 2016 at 8:47 AM Sean Paul <<a href="mailto:seanpaul@chromium.org">seanpaul@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Nov 1, 2016 at 3:41 PM, Kristian H. Kristensen<br class="gmail_msg">
<<a href="mailto:hoegsberg@gmail.com" class="gmail_msg" target="_blank">hoegsberg@gmail.com</a>> wrote:<br class="gmail_msg">
> We used to call drm_of_encoder_active_endpoint_id() from<br class="gmail_msg">
> rockchip_dp_drm_encoder_atomic_check() to determine the endpoint for the<br class="gmail_msg">
> active encoder. However, the encoder isn't necessarily active at this<br class="gmail_msg">
> point or it may be connected to different crtc than what we're switching<br class="gmail_msg">
> to. Instead, look at the crtc from the drm_crtc_state. This fixes wrong<br class="gmail_msg">
> colors when driving the eDP with the big VOP. Further, we can identify<br class="gmail_msg">
> the type of VOP we're dealing with by just putting a VOP id enum in the<br class="gmail_msg">
> vop_data.<br class="gmail_msg">
><br class="gmail_msg">
> On way to test this is to use the modetest tool from libdrm:<br class="gmail_msg">
><br class="gmail_msg">
> $ modetest -M rockchip -s 32@28:2400x1600<br class="gmail_msg">
><br class="gmail_msg">
> which displays dark or black colors because we fail to look up the<br class="gmail_msg">
> endpoint and use default 0 (which is ROCKCHIP_OUT_MODE_P888) for big<br class="gmail_msg">
> VOP instead of RGB10 as required.<br class="gmail_msg">
><br class="gmail_msg">
> For reference,<br class="gmail_msg">
><br class="gmail_msg">
> $ modetest -M rockchip -s 32@25:2400x1600<br class="gmail_msg">
><br class="gmail_msg">
> drives the eDP from little VOP and displays correctly.<br class="gmail_msg">
><br class="gmail_msg">
> BUG=chrome-os-partner:56407<br class="gmail_msg">
> TEST=verify 'modetest -M rockchip -s 32@28:2400x1600' looks right<br class="gmail_msg">
> Signed-off-by: Kristian H. Kristensen <<a href="mailto:hoegsberg@chromium.org" class="gmail_msg" target="_blank">hoegsberg@chromium.org</a>><br class="gmail_msg">
> Change-Id: If5c5f36bcee09113008ee5155a13337f0e69371f<br class="gmail_msg">
<br class="gmail_msg">
Thanks for the patch, Kristian. In the future, can you please strip<br class="gmail_msg">
out BUG/TEST/Change-Id when you upstream? I think checkpatch will<br class="gmail_msg">
gently remind you of this as well.<br class="gmail_msg"></blockquote><div><br></div><div>Yup, I sent a v2 with the headers stripped and fixed the compile errors in the</div><div>encoder modules I didn't initially compile.</div><div><br></div><div>Kristian</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
> ---<br class="gmail_msg">
> drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 45 ++++++++++---------------<br class="gmail_msg">
> drivers/gpu/drm/rockchip/cdn-dp-core.c | 19 +++++------<br class="gmail_msg">
<br class="gmail_msg">
cdn-dp isn't upstream yet (I need to get that posted), I'll work on<br class="gmail_msg">
this next week when I'm back from Plumbers. If that goes smoothly, I<br class="gmail_msg">
can push this patch on top.<br class="gmail_msg">
<br class="gmail_msg">
Reviewed-by: Sean Paul <<a href="mailto:seanpaul@chromium.org" class="gmail_msg" target="_blank">seanpaul@chromium.org</a>><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
> drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 9 +++--<br class="gmail_msg">
> drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 7 ++++<br class="gmail_msg">
> drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 10 ++++++<br class="gmail_msg">
> drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 4 +++<br class="gmail_msg">
> 6 files changed, 54 insertions(+), 40 deletions(-)<br class="gmail_msg">
><br class="gmail_msg">
> diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c<br class="gmail_msg">
> index 558a3bc..9ae4a9c 100644<br class="gmail_msg">
> --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c<br class="gmail_msg">
> +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c<br class="gmail_msg">
> @@ -196,14 +196,16 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder)<br class="gmail_msg">
> int ret;<br class="gmail_msg">
> u32 val;<br class="gmail_msg">
><br class="gmail_msg">
> - ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder);<br class="gmail_msg">
> - if (ret < 0)<br class="gmail_msg">
> - return;<br class="gmail_msg">
> -<br class="gmail_msg">
> - if (ret)<br class="gmail_msg">
> + switch (vop_get_crtc_vop_id(encoder->crtc)) {<br class="gmail_msg">
> + case RK3399_VOP_LIT:<br class="gmail_msg">
> val = dp->data->lcdsel_lit;<br class="gmail_msg">
> - else<br class="gmail_msg">
> + break;<br class="gmail_msg">
> + case RK3399_VOP_BIG:<br class="gmail_msg">
> val = dp->data->lcdsel_big;<br class="gmail_msg">
> + break;<br class="gmail_msg">
> + default:<br class="gmail_msg">
> + return;<br class="gmail_msg">
> + }<br class="gmail_msg">
><br class="gmail_msg">
> dev_dbg(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");<br class="gmail_msg">
><br class="gmail_msg">
> @@ -231,34 +233,23 @@ rockchip_dp_drm_encoder_atomic_check(struct drm_encoder *encoder,<br class="gmail_msg">
> struct drm_connector_state *conn_state)<br class="gmail_msg">
> {<br class="gmail_msg">
> struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state);<br class="gmail_msg">
> - struct rockchip_dp_device *dp = to_dp(encoder);<br class="gmail_msg">
> - int ret;<br class="gmail_msg">
><br class="gmail_msg">
> - /*<br class="gmail_msg">
> - * The hardware IC designed that VOP must output the RGB10 video<br class="gmail_msg">
> - * format to eDP contoller, and if eDP panel only support RGB8,<br class="gmail_msg">
> - * then eDP contoller should cut down the video data, not via VOP<br class="gmail_msg">
> - * contoller, that's why we need to hardcode the VOP output mode<br class="gmail_msg">
> - * to RGA10 here.<br class="gmail_msg">
> - */<br class="gmail_msg">
> -<br class="gmail_msg">
> - ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder);<br class="gmail_msg">
> - if (ret < 0)<br class="gmail_msg">
> - return 0;<br class="gmail_msg">
> -<br class="gmail_msg">
> - switch (dp->data->chip_type) {<br class="gmail_msg">
> - case RK3399_EDP:<br class="gmail_msg">
> + switch (vop_get_crtc_vop_id(crtc_state->crtc)) {<br class="gmail_msg">
> + case RK3399_VOP_LIT:<br class="gmail_msg">
> /*<br class="gmail_msg">
> * For RK3399, VOP Lit must code the out mode to RGB888,<br class="gmail_msg">
> * VOP Big must code the out mode to RGB10.<br class="gmail_msg">
> */<br class="gmail_msg">
> - if (ret)<br class="gmail_msg">
> - s->output_mode = ROCKCHIP_OUT_MODE_P888;<br class="gmail_msg">
> - else<br class="gmail_msg">
> - s->output_mode = ROCKCHIP_OUT_MODE_AAAA;<br class="gmail_msg">
> + s->output_mode = ROCKCHIP_OUT_MODE_P888;<br class="gmail_msg">
> break;<br class="gmail_msg">
> -<br class="gmail_msg">
> default:<br class="gmail_msg">
> + /*<br class="gmail_msg">
> + * The hardware IC designed that VOP must output the RGB10 video<br class="gmail_msg">
> + * format to eDP contoller, and if eDP panel only support RGB8,<br class="gmail_msg">
> + * then eDP contoller should cut down the video data, not via VOP<br class="gmail_msg">
> + * contoller, that's why we need to hardcode the VOP output mode<br class="gmail_msg">
> + * to RGA10 here.<br class="gmail_msg">
> + */<br class="gmail_msg">
> s->output_mode = ROCKCHIP_OUT_MODE_AAAA;<br class="gmail_msg">
> break;<br class="gmail_msg">
> }<br class="gmail_msg">
> diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c<br class="gmail_msg">
> index f020e2e..b9e6184 100644<br class="gmail_msg">
> --- a/drivers/gpu/drm/rockchip/cdn-dp-core.c<br class="gmail_msg">
> +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c<br class="gmail_msg">
> @@ -570,21 +570,20 @@ static void cdn_dp_encoder_mode_set(struct drm_encoder *encoder,<br class="gmail_msg">
> video->v_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NVSYNC);<br class="gmail_msg">
> video->h_sync_polarity = !!(mode->flags & DRM_MODE_FLAG_NHSYNC);<br class="gmail_msg">
><br class="gmail_msg">
> - ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder);<br class="gmail_msg">
> - if (ret < 0) {<br class="gmail_msg">
> - DRM_DEV_ERROR(dp->dev, "Could not get vop id, %d", ret);<br class="gmail_msg">
> - return;<br class="gmail_msg">
> - }<br class="gmail_msg">
> -<br class="gmail_msg">
> - DRM_DEV_DEBUG_KMS(dp->dev, "vop %s output to cdn-dp\n",<br class="gmail_msg">
> - (ret) ? "LIT" : "BIG");<br class="gmail_msg">
> state = to_rockchip_crtc_state(encoder->crtc->state);<br class="gmail_msg">
> - if (ret) {<br class="gmail_msg">
> + switch (vop_get_crtc_vop_id(encoder->crtc)) {<br class="gmail_msg">
> + case RK3399_VOP_LIT:<br class="gmail_msg">
> + DRM_DEV_DEBUG_KMS(dp->dev, "vop LIT output to cdn-dp\n");<br class="gmail_msg">
> val = DP_SEL_VOP_LIT | (DP_SEL_VOP_LIT << 16);<br class="gmail_msg">
> state->output_mode = ROCKCHIP_OUT_MODE_P888;<br class="gmail_msg">
> - } else {<br class="gmail_msg">
> + break;<br class="gmail_msg">
> + case RK3399_VOP_BIG:<br class="gmail_msg">
> + DRM_DEV_DEBUG_KMS(dp->dev, "vop BIG output to cdn-dp\n");<br class="gmail_msg">
> val = DP_SEL_VOP_LIT << 16;<br class="gmail_msg">
> state->output_mode = ROCKCHIP_OUT_MODE_AAAA;<br class="gmail_msg">
> + break;<br class="gmail_msg">
> + default:<br class="gmail_msg">
> + break;<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
> ret = cdn_dp_grf_write(dp, GRF_SOC_CON9, val);<br class="gmail_msg">
> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c<br class="gmail_msg">
> index dedc65b..c2b0f5d 100644<br class="gmail_msg">
> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c<br class="gmail_msg">
> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c<br class="gmail_msg">
> @@ -878,7 +878,6 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder)<br class="gmail_msg">
> static void dw_mipi_dsi_encoder_commit(struct drm_encoder *encoder)<br class="gmail_msg">
> {<br class="gmail_msg">
> struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder);<br class="gmail_msg">
> - int mux = drm_of_encoder_active_endpoint_id(dsi->dev->of_node, encoder);<br class="gmail_msg">
> u32 val;<br class="gmail_msg">
><br class="gmail_msg">
> if (clk_prepare_enable(dsi->pclk)) {<br class="gmail_msg">
> @@ -894,10 +893,14 @@ static void dw_mipi_dsi_encoder_commit(struct drm_encoder *encoder)<br class="gmail_msg">
><br class="gmail_msg">
> clk_disable_unprepare(dsi->pclk);<br class="gmail_msg">
><br class="gmail_msg">
> - if (mux)<br class="gmail_msg">
> + switch (vop_get_crtc_vop_id(crtc_state->crtc)) {<br class="gmail_msg">
> + case RK3399_VOP_LIT:<br class="gmail_msg">
> val = DSI0_SEL_VOP_LIT | (DSI0_SEL_VOP_LIT << 16);<br class="gmail_msg">
> - else<br class="gmail_msg">
> + break;<br class="gmail_msg">
> + default:<br class="gmail_msg">
> val = DSI0_SEL_VOP_LIT << 16;<br class="gmail_msg">
> + break;<br class="gmail_msg">
> + }<br class="gmail_msg">
><br class="gmail_msg">
> regmap_write(dsi->grf_regmap, GRF_SOC_CON6, val);<br class="gmail_msg">
> dev_dbg(dsi->dev, "vop %s output to dsi0\n", (mux) ? "LIT" : "BIG");<br class="gmail_msg">
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c<br class="gmail_msg">
> index d5ea4ab..e849f26 100644<br class="gmail_msg">
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c<br class="gmail_msg">
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c<br class="gmail_msg">
> @@ -141,6 +141,13 @@ struct vop {<br class="gmail_msg">
> struct vop_win win[];<br class="gmail_msg">
> };<br class="gmail_msg">
><br class="gmail_msg">
> +enum vop_id vop_get_crtc_vop_id(struct drm_crtc *crtc)<br class="gmail_msg">
> +{<br class="gmail_msg">
> + struct vop *vop = to_vop(crtc);<br class="gmail_msg">
> +<br class="gmail_msg">
> + return vop->data->id;<br class="gmail_msg">
> +}<br class="gmail_msg">
> +<br class="gmail_msg">
> static inline void vop_writel(struct vop *vop, uint32_t offset, uint32_t v)<br class="gmail_msg">
> {<br class="gmail_msg">
> writel(v, vop->regs + offset);<br class="gmail_msg">
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h<br class="gmail_msg">
> index 5a4faa85..2c54bcc 100644<br class="gmail_msg">
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h<br class="gmail_msg">
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h<br class="gmail_msg">
> @@ -135,8 +135,16 @@ struct vop_win_data {<br class="gmail_msg">
> enum drm_plane_type type;<br class="gmail_msg">
> };<br class="gmail_msg">
><br class="gmail_msg">
> +enum vop_id {<br class="gmail_msg">
> + RK3036_VOP,<br class="gmail_msg">
> + RK3288_VOP,<br class="gmail_msg">
> + RK3399_VOP_BIG,<br class="gmail_msg">
> + RK3399_VOP_LIT,<br class="gmail_msg">
> +};<br class="gmail_msg">
> +<br class="gmail_msg">
> struct vop_data {<br class="gmail_msg">
> const struct vop_reg_data *init_table;<br class="gmail_msg">
> + uint32_t id;<br class="gmail_msg">
> unsigned int table_size;<br class="gmail_msg">
> const struct vop_ctrl *ctrl;<br class="gmail_msg">
> const struct vop_intr *intr;<br class="gmail_msg">
> @@ -321,5 +329,7 @@ static inline int scl_vop_cal_lb_mode(int width, bool is_yuv)<br class="gmail_msg">
> return lb_mode;<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
> +enum vop_id vop_get_crtc_vop_id(struct drm_crtc *crtc);<br class="gmail_msg">
> +<br class="gmail_msg">
> extern const struct component_ops vop_component_ops;<br class="gmail_msg">
> #endif /* _ROCKCHIP_DRM_VOP_H */<br class="gmail_msg">
> diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c<br class="gmail_msg">
> index aaede6b..a46e2c8 100644<br class="gmail_msg">
> --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c<br class="gmail_msg">
> +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c<br class="gmail_msg">
> @@ -131,6 +131,7 @@ static const struct vop_reg_data rk3036_vop_init_reg_table[] = {<br class="gmail_msg">
> };<br class="gmail_msg">
><br class="gmail_msg">
> static const struct vop_data rk3036_vop = {<br class="gmail_msg">
> + .id = RK3036_VOP,<br class="gmail_msg">
> .init_table = rk3036_vop_init_reg_table,<br class="gmail_msg">
> .table_size = ARRAY_SIZE(rk3036_vop_init_reg_table),<br class="gmail_msg">
> .ctrl = &rk3036_ctrl_data,<br class="gmail_msg">
> @@ -272,6 +273,7 @@ static const struct vop_intr rk3288_vop_intr = {<br class="gmail_msg">
> };<br class="gmail_msg">
><br class="gmail_msg">
> static const struct vop_data rk3288_vop = {<br class="gmail_msg">
> + .id = RK3288_VOP,<br class="gmail_msg">
> .init_table = rk3288_init_reg_table,<br class="gmail_msg">
> .table_size = ARRAY_SIZE(rk3288_init_reg_table),<br class="gmail_msg">
> .intr = &rk3288_vop_intr,<br class="gmail_msg">
> @@ -340,6 +342,7 @@ static const struct vop_reg_data rk3399_init_reg_table[] = {<br class="gmail_msg">
> };<br class="gmail_msg">
><br class="gmail_msg">
> static const struct vop_data rk3399_vop_big = {<br class="gmail_msg">
> + .id = RK3399_VOP_BIG,<br class="gmail_msg">
> .init_table = rk3399_init_reg_table,<br class="gmail_msg">
> .table_size = ARRAY_SIZE(rk3399_init_reg_table),<br class="gmail_msg">
> .intr = &rk3399_vop_intr,<br class="gmail_msg">
> @@ -359,6 +362,7 @@ static const struct vop_win_data rk3399_vop_lit_win_data[] = {<br class="gmail_msg">
> };<br class="gmail_msg">
><br class="gmail_msg">
> static const struct vop_data rk3399_vop_lit = {<br class="gmail_msg">
> + .id = RK3399_VOP_LIT,<br class="gmail_msg">
> .init_table = rk3399_init_reg_table,<br class="gmail_msg">
> .table_size = ARRAY_SIZE(rk3399_init_reg_table),<br class="gmail_msg">
> .intr = &rk3399_vop_intr,<br class="gmail_msg">
> --<br class="gmail_msg">
> 2.8.0.rc3.226.g39d4020<br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> dri-devel mailing list<br class="gmail_msg">
> <a href="mailto:dri-devel@lists.freedesktop.org" class="gmail_msg" target="_blank">dri-devel@lists.freedesktop.org</a><br class="gmail_msg">
> <a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br class="gmail_msg">
</blockquote></div></div>