[U-Boot] [PATCH v2 2/2] video: bcm2835: respect the pitch value

Anatolij Gustschin
2013-11-07T23:04:01Z

On Thu, 24 Oct 2013 20:00:41 +0200
Andre Heider <a.heider@gmail.com> wrote:
...
> @@ -90,6 +94,7 @@ void lcd_ctrl_init(void *lcdbase)
>
> w = msg_setup->physical_w_h.body.resp.width;
> h = msg_setup->physical_w_h.body.resp.height;
> + bcm2835_pitch = msg_setup->pitch.body.resp.pitch;
>
> debug("bcm2835: Final resolution is %d x %d\n", w, h);
>
> @@ -102,4 +107,6 @@ void lcd_ctrl_init(void *lcdbase)
>
> void lcd_enable(void)
> {
> + if (bcm2835_pitch)
> + lcd_line_length = bcm2835_pitch;
> }

setting lcd_line_length in lcd_enable() is wrong, it should
happen earlier, before lcd_clear() is called in the lcd.c
driver. I suggest making the lcd_get_size() in lcd.c a weak
function and then provide bcm2835 specific lcd_get_size()
which sets the pitch as needed:

diff --git a/common/lcd.c b/common/lcd.c
index 5dd7948..60faa62 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -386,8 +386,13 @@ static void test_pattern(void)
/************************************************************************/
/* ** GENERIC Initialization Routines */
/************************************************************************/
-
-int lcd_get_size(int *line_length)
+/*
+ * Implement a weak default function for getting the length/size
+ * from panel_info parameters. With some boards/drivers the
+ * length might need adjustments, so allow defining the driver
+ * specific lcd_get_size() function.
+ */
+__weak int lcd_get_size(int *line_length)
{
*line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
return *line_length * panel_info.vl_row;

and

diff --git a/drivers/video/bcm2835.c b/drivers/video/bcm2835.c
index 58a6163..45b470a 100644
--- a/drivers/video/bcm2835.c
+++ b/drivers/video/bcm2835.c
@@ -103,3 +103,9 @@ void lcd_ctrl_init(void *lcdbase)
void lcd_enable(void)
{
}
+
+void lcd_get_size(int *line_length)
+{
+ *line_length = bcm2835_pitch;
+ return *line_length * panel_info.vl_row;
+}

Anatolij