From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Sun, 24 May 2020 19:48:43 -0600 Subject: [PATCH v2 06/26] video: Adjust rotated console to start at right edge In-Reply-To: <20200525014904.115621-1-sjg@chromium.org> References: <20200525014904.115621-1-sjg@chromium.org> Message-ID: <20200524194852.v2.6.Ie8637472573bd3e94375131aa034e7498df340b1@changeid> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de At present when the console is rotated 180 degrees it starts almost a whole character to the left of the right edge (typically 7 pixels with an 8-pixel-wide font). On a display which aligns with the font width, this just wastes space. On a display that does not this can result in x_frac going negative for the final character (the one on the left side) and the overflow -EAGAIN check at the start of the function failing. Change the function to start at the rightmost pixel to fix these problems. Signed-off-by: Simon Glass Reviewed-by: Anatolij Gustschin --- Changes in v2: None drivers/video/console_rotate.c | 2 +- test/dm/video.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c index 8bb05ae02c..da0ce7b9ce 100644 --- a/drivers/video/console_rotate.c +++ b/drivers/video/console_rotate.c @@ -212,7 +212,7 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch) if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac) return -EAGAIN; linenum = vid_priv->ysize - y - 1; - x = vid_priv->xsize - VID_TO_PIXEL(x_frac) - VIDEO_FONT_WIDTH - 1; + x = vid_priv->xsize - VID_TO_PIXEL(x_frac) - 1; line = vid_priv->fb + linenum * vid_priv->line_length + x * pbytes; for (row = 0; row < VIDEO_FONT_HEIGHT; row++) { diff --git a/test/dm/video.c b/test/dm/video.c index 0664e3f22b..68f5ba44e7 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -251,7 +251,7 @@ DM_TEST(dm_test_video_rotation1, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test rotated text output through the console uclass */ static int dm_test_video_rotation2(struct unit_test_state *uts) { - ut_assertok(check_vidconsole_output(uts, 2, 785, 446)); + ut_assertok(check_vidconsole_output(uts, 2, 783, 445)); return 0; } -- 2.27.0.rc0.183.gde8f92d652-goog