From 11f7b4afa5d8ede8bbf762dc5c7dfb221e42aa1f Mon Sep 17 00:00:00 2001 From: Marcus Lorentzon Date: Tue, 15 Nov 2011 18:17:08 +0100 Subject: video: mcde: Hide display physical orientation User space should not have to compensate fbdev rotation for different physical mounting orientations of panels. This patch hide the mounting orientation from user space. ST-Ericsson ID: 368097 ST-Ericsson FOSS-OUT ID: Trivial ST-Ericsson Linux next: NA Change-Id: Ia6088066af04477cf9643e3151f72e4350531ccc Signed-off-by: Marcus Lorentzon Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/34137 Reviewed-by: QATOOLS Reviewed-by: QABUILD Reviewed-by: QATEST Reviewed-by: Jimmy RUBIN Reviewed-by: Srinidhi KASAGAR --- drivers/video/mcde/mcde_display.c | 26 ++++++++++---------------- drivers/video/mcde/mcde_dss.c | 15 ++++++++++++++- drivers/video/mcde/mcde_hw.c | 4 +++- include/video/mcde_display.h | 1 + 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/video/mcde/mcde_display.c b/drivers/video/mcde/mcde_display.c index a461b36c9b6..1e71514ab34 100644 --- a/drivers/video/mcde/mcde_display.c +++ b/drivers/video/mcde/mcde_display.c @@ -210,25 +210,19 @@ static int mcde_display_set_rotation_default(struct mcde_display_device *ddev, enum mcde_display_rotation rotation) { int ret; + u8 param = 0; + enum mcde_display_rotation final; - ret = mcde_chnl_set_rotation(ddev->chnl_state, rotation, - ddev->rotbuf1, ddev->rotbuf2); - if (ret < 0) { - dev_warn(&ddev->dev, "%s:Failed to set rotation = %d\n", - __func__, rotation); + final = (360 + rotation - ddev->orientation) % 360; + ret = mcde_chnl_set_rotation(ddev->chnl_state, final, + ddev->rotbuf1, ddev->rotbuf2); + if (WARN_ON(ret)) return ret; - } - if (rotation == MCDE_DISPLAY_ROT_180_CCW) { - u8 param = 0x40; - (void) mcde_dsi_dcs_write(ddev->chnl_state, - DCS_CMD_SET_ADDRESS_MODE, ¶m, 1); - } else if (ddev->rotation == MCDE_DISPLAY_ROT_180_CCW && - rotation != MCDE_DISPLAY_ROT_180_CCW) { - u8 param = 0; - (void) mcde_dsi_dcs_write(ddev->chnl_state, - DCS_CMD_SET_ADDRESS_MODE, ¶m, 1); - } + if (final == MCDE_DISPLAY_ROT_180_CW) + param = 0x40; /* Horizontal flip */ + (void)mcde_dsi_dcs_write(ddev->chnl_state, DCS_CMD_SET_ADDRESS_MODE, + ¶m, 1); ddev->rotation = rotation; ddev->update_flags |= UPDATE_FLAG_ROTATION; diff --git a/drivers/video/mcde/mcde_dss.c b/drivers/video/mcde/mcde_dss.c index 044e39ad285..a2ef0b652d7 100644 --- a/drivers/video/mcde/mcde_dss.c +++ b/drivers/video/mcde/mcde_dss.c @@ -121,6 +121,10 @@ int mcde_dss_enable_display(struct mcde_display_device *ddev) if (ret < 0) dev_warn(&ddev->dev, "Failed to set sync\n"); + ret = ddev->set_rotation(ddev, ddev->get_rotation(ddev)); + if (ret < 0) + dev_warn(&ddev->dev, "Failed to set rotation\n"); + ret = mcde_chnl_enable_synchronized_update(ddev->chnl_state, ddev->synchronized_update); if (ret < 0) { @@ -301,8 +305,17 @@ EXPORT_SYMBOL(mcde_dss_get_overlay_info); void mcde_dss_get_native_resolution(struct mcde_display_device *ddev, u16 *x_res, u16 *y_res) { + u16 x_tmp, y_tmp; mutex_lock(&ddev->display_lock); - ddev->get_native_resolution(ddev, x_res, y_res); + ddev->get_native_resolution(ddev, &x_tmp, &y_tmp); + if (ddev->orientation == MCDE_DISPLAY_ROT_90_CW || + ddev->orientation == MCDE_DISPLAY_ROT_90_CCW) { + *x_res = y_tmp; + *y_res = x_tmp; + } else { + *x_res = x_tmp; + *y_res = y_tmp; + } mutex_unlock(&ddev->display_lock); } EXPORT_SYMBOL(mcde_dss_get_native_resolution); diff --git a/drivers/video/mcde/mcde_hw.c b/drivers/video/mcde/mcde_hw.c index 6e846e60f47..dfda6490ae2 100644 --- a/drivers/video/mcde/mcde_hw.c +++ b/drivers/video/mcde/mcde_hw.c @@ -2944,7 +2944,9 @@ int mcde_chnl_set_rotation(struct mcde_chnl_state *chnl, if (!chnl->reserved) return -EINVAL; - if (chnl->id != MCDE_CHNL_A && chnl->id != MCDE_CHNL_B) + if ((rotation == MCDE_DISPLAY_ROT_90_CW || + rotation == MCDE_DISPLAY_ROT_90_CCW) && + (chnl->id != MCDE_CHNL_A && chnl->id != MCDE_CHNL_B)) return -EINVAL; chnl->rotation = rotation; diff --git a/include/video/mcde_display.h b/include/video/mcde_display.h index 97326cbc28c..b94e7befa8b 100644 --- a/include/video/mcde_display.h +++ b/include/video/mcde_display.h @@ -61,6 +61,7 @@ struct mcde_display_device { enum mcde_ovly_pix_fmt default_pixel_format; enum mcde_ovly_pix_fmt pixel_format; enum mcde_display_rotation rotation; + enum mcde_display_rotation orientation; bool synchronized_update; struct mcde_video_mode video_mode; int update_flags; -- cgit v1.2.3