video: bcm2835: fix various output modes
Subsystems (3)
PATCH 2/2 video: bcm2835: fix various output modes
Depending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
To always archive the required contiguousness for the used 16bpp, round the framebuffer width down so its aligned to a width of 16.
[1] http://elinux.org/RPiconfig#Video_mode_options
--- drivers/video/bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/bcm2835.c +1 -1
@@ -52,7 +52,7 @@ void lcd_ctrl_init(void *lcdbase)return ; } - w = msg_query->physical_w_h.body.resp.width; + w =ROUND (msg_query->physical_w_h.body.resp.width,16 ); h = msg_query->physical_w_h.body.resp.height;debug ("bcm2835: Setting up display for %d x %d\n" , w, h);
Signature · 1 line
1.8.3.2
PATCH 2/2 video: bcm2835: fix various output modes
Quoted 6 lines · Andre Heider
Depending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
To always archive the required contiguousness for the used 16bpp, round the framebuffer width down so its aligned to a width of 16.
This doesn't sound like the correct approach. By doing this, either the SET_PHYSICAL_W_H request will fail since the requested mode doesn't match the connected display device, or perhaps it'll work, but end up with a frame-buffer that's a different resolution than the video signal, so the HW will scale the image slightly, which will reduce quality.
Instead, can't you obtain the buffer width and stride separately, and then configure the LCD core based on both those values, rather than assuming they're the same?
PATCH 2/2 video: bcm2835: fix various output modes
Quoted 5 lines · Stephen Warren
Quoted 4 lines · Andre Heider
Depending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
Quoted 8 lines
Quoted 2 lines
To always archive the required contiguousness for the used 16bpp, round the framebuffer width down so its aligned to a width of 16.
This doesn't sound like the correct approach. By doing this, either the
SET_PHYSICAL_W_Hrequest will fail since the requested mode doesn't match the connected display device, or perhaps it'll work, but end up with a frame-buffer that's a different resolution than the video signal, so the HW will scale the image slightly, which will reduce quality.
SET_PHYSICAL_W_H works in any case, but yeah, it does get "funky" resolutions in some cases.
The thing is, the firmware is stupid to begin with (duh). In my case, I do have both outputs connected. For the analog one, I have to set sdtv_* and overscan_* config settings.
When the HDMI connection is active, the analog output is inactive, but yet the firmware applies the sdtv_* and overscan_* settings to the HDMI output too, so the clean 1:1 resolution is already gone...
Quoted 3 lines
Instead, can't you obtain the buffer width and stride separately, and then configure the LCD core based on both those values, rather than assuming they're the same?
What I did try is to get the overscan values and add those to the requested resolution (that's where patch 1 comes from). That gives saner resolutions, but some are still broken for me.
I agree that getting the pitch value would be the right thing to do, I do some digging to find a spot where to shove that into.
Thanks,
Andre
PATCH 2/2 video: bcm2835: fix various output modes
In reply to Stephen WarrenHi Stephen,
Quoted 3 lines · Stephen Warren
Instead, can't you obtain the buffer width and stride separately, and then configure the LCD core based on both those values, rather than assuming they're the same?
I just sent a v2 patch to do exactly that.
Regarding overscan, I wonder why you zero out the initial overscan settings.
If it was just to gain a contiguous frame buffer, can we keep the overscan settings now (assuming my v2 patch is accepted)? That way the framebuffer doesn't get cut off on the sides for old analog SDTV display devices.
For HDTV, that means there's a border - but only if the user set the overscan_* values.
Thanks,
Andre
PATCH 2/2 video: bcm2835: fix various output modes
Quoted 11 lines · Andre Heider
Hi Stephen,
Quoted 3 lines · Stephen Warren
Instead, can't you obtain the buffer width and stride separately, and then configure the LCD core based on both those values, rather than assuming they're the same?
I just sent a v2 patch to do exactly that.
Regarding overscan, I wonder why you zero out the initial overscan settings.
I think it was because the firmware incorrectly decided by default that my HDMI device needed overscan, when in fact it can display the entire signal it's sent. If there's a way to control that in the config file, then perhaps that might be possible instead, or perhaps I should file a bug against the firmware, assuming I'm remembering correctly...
PATCH v2 2/2 video: bcm2835: respect the pitch value
In reply to Andre HeiderDepending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
Fix this by setting lcd_line_length to the pitch value of the configured framebuffer.
[1] http://elinux.org/RPiconfig#Video_mode_options
--- drivers/video/bcm2835.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/video/bcm2835.c +7 -0
@@ -14,6 +14,8 @@ DECLARE_GLOBAL_DATA_PTR;/* Global variables that lcd.c expects to exist */ vidinfo_t panel_info; +static u32 bcm2835_pitch; +struct msg_query {struct bcm2835_mbox_hdr hdr;struct bcm2835_mbox_tag_physical_w_h physical_w_h;
@@ -30,6 +32,7 @@ struct msg_setup {struct bcm2835_mbox_tag_virtual_offset virtual_offset;struct bcm2835_mbox_tag_overscan overscan;struct bcm2835_mbox_tag_allocate_buffer allocate_buffer; +struct bcm2835_mbox_tag_pitch pitch;u32 end_tag; };
@@ -80,6 +83,7 @@ void lcd_ctrl_init(void *lcdbase) msg_setup->overscan.body.req.right =0 ;BCM2835_MBOX_INIT_TAG (&msg_setup->allocate_buffer,ALLOCATE_BUFFER ); msg_setup->allocate_buffer.body.req.alignment =0x100 ; +BCM2835_MBOX_INIT_TAG_NO_REQ (&msg_setup->pitch,GET_PITCH ); ret =bcm2835_mbox_call_prop (BCM2835_MBOX_PROP_CHAN , &msg_setup->hdr);if (ret) {
@@ -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; }
Signature · 1 line
1.8.3.2
PATCH v2 2/2 video: bcm2835: respect the pitch value
Quoted 6 lines · Andre Heider
Depending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
Fix this by setting
lcd_line_lengthto the pitch value of the configured framebuffer.
This sounds like the right concept.
drivers/video/bcm2835.c void lcd_ctrl_init(void *lcdbase) · line 110
Quoted 5 lines
drivers/video/bcm2835.c +1
-0void lcd_enable (void ) { +if (bcm2835_pitch)
Why make this conditional? Does the firmware sometimes not return the correct pitch and/or does lcd_enable() get called before lcd_ctrl_init() so the global hasn't been set up? Either of those seem like nasty bugs that should be fixed...
drivers/video/bcm2835.c void lcd_ctrl_init(void *lcdbase) · line 111
Quoted 1 line
drivers/video/bcm2835.c +1
-0+ lcd_line_length = bcm2835_pitch;
Why set lcd_line_length at a different time than the mailbox message is executed? Can't lcd_line_length be set at the end of lcd_ctrl_init(), thus avoiding the global variable bcm2835_pitch?
Quoted 1 line
}
PATCH v2 2/2 video: bcm2835: respect the pitch value
In reply to Andre HeiderOn Thu, 24 Oct 2013 20:00:41 +0200
Andre Heider <[email protected]> wrote:
...
Quoted 9 lines
(quoted diff) +1
-0@@ -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);
Review void lcd_ctrl_init(void *lcdbase) · line 112
Quoted 6 lines
(quoted diff) +2
-0@@ -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:
common/lcd.c +7 -2
@@ -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
drivers/video/bcm2835.c +6 -0
@@ -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
PATCH 1/1 lcd: allow overriding lcd_get_size()
In reply to Andre HeiderRemove the redundant lcd_line_length initialisation which sneaked in when an earlier version of the patch of commit 6d330719 has been rebased.
Some lcd drivers need to setup lcd_line_length not from the panel_info parameters but by different means. Make the lcd_get_size() weak to allow setting lcd_line_length in a driver specific way.
--- common/lcd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
common/lcd.c +7 -3
@@ -386,8 +386,13 @@ static void test_pattern(void)/************************************************************************/ /* ** GENERIC Initialization Routines */ /************************************************************************/ - -int lcd_get_size (int *line_length) +/* +* With most lcd drivers the line length is set up +* by calculating it from panel_info parameters. Some +* drivers need to calculate the line length differently, +* so make the function weak to allow overriding it. +*/ +__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;
@@ -495,7 +500,6 @@ static int lcd_init(void *lcdbase)debug ("[LCD] Using LCD frambuffer at %p\n" , lcd_base);lcd_get_size (&lcd_line_length); - lcd_line_length = (panel_info.vl_col *NBITS (panel_info.vl_bpix)) /8 ; lcd_is_enabled =1 ;lcd_clear ();lcd_enable ();
Signature · 1 line
1.7.9.5
PATCH 1/1 lcd: allow overriding lcd_get_size()
Quoted 9 lines · On Sat, 9 Nov 2013 11:00:09 +0100 Anatolij Gustschin <[email protected]> wrote:
Remove the redundant
lcd_line_lengthinitialisation which sneaked in when an earlier version of the patch of commit6d330719has been rebased.Some lcd drivers need to setup
lcd_line_lengthnot from thepanel_infoparameters but by different means. Make thelcd_get_size()weak to allow settinglcd_line_lengthin a driver specific way.
Quoted 5 lines
Signed-off-by Anatolij Gustschin <[email protected]>Cc Stephen Warren <[email protected]>--- common/lcd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
applied to u-boot-video/master, thanks!
Anatolij
PATCH v3 2/2 video: bcm2835: respect the pitch value
In reply to Andre HeiderFrom: Andre Heider <[email protected]>
Depending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
Fix this by setting lcd_line_length to the pitch value of the configured framebuffer.
[1] http://elinux.org/RPiconfig#Video_mode_options
---
Changes in v3:
- set lcd_line_length by driver specific lcd_get_size() since setting it in lcd_enable() is not correct. This patch version depends on patch http://patchwork.ozlabs.org/patch/289957
Please test these both patches on rpi_b, thanks!
drivers/video/bcm2835.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/video/bcm2835.c +11 -0
@@ -14,6 +14,8 @@ DECLARE_GLOBAL_DATA_PTR;/* Global variables that lcd.c expects to exist */ vidinfo_t panel_info; +static u32 bcm2835_pitch; +struct msg_query {struct bcm2835_mbox_hdr hdr;struct bcm2835_mbox_tag_physical_w_h physical_w_h;
@@ -30,6 +32,7 @@ struct msg_setup {struct bcm2835_mbox_tag_virtual_offset virtual_offset;struct bcm2835_mbox_tag_overscan overscan;struct bcm2835_mbox_tag_allocate_buffer allocate_buffer; +struct bcm2835_mbox_tag_pitch pitch;u32 end_tag; };
@@ -80,6 +83,7 @@ void lcd_ctrl_init(void *lcdbase) msg_setup->overscan.body.req.right =0 ;BCM2835_MBOX_INIT_TAG (&msg_setup->allocate_buffer,ALLOCATE_BUFFER ); msg_setup->allocate_buffer.body.req.alignment =0x100 ; +BCM2835_MBOX_INIT_TAG_NO_REQ (&msg_setup->pitch,GET_PITCH ); ret =bcm2835_mbox_call_prop (BCM2835_MBOX_PROP_CHAN , &msg_setup->hdr);if (ret) {
@@ -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);
@@ -103,3 +108,9 @@ void lcd_ctrl_init(void *lcdbase)void lcd_enable (void ) { } + +int lcd_get_size (int *line_length) +{ + *line_length = bcm2835_pitch; +return *line_length * panel_info.vl_row; +}
Signature · 1 line
1.7.9.5
PATCH v3 2/2 video: bcm2835: respect the pitch value
Hi Anatolij,
Quoted 14 lines · Anatolij Gustschin
From: Andre Heider <[email protected]>
Depending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
Fix this by setting
lcd_line_lengthto the pitch value of the configured framebuffer.[1] http://elinux.org/RPiconfig#Video_mode_options
Signed-off-by Andre Heider <[email protected]>Cc Stephen Warren <[email protected]>Signed-off-by Anatolij Gustschin <[email protected]>
Quoted 6 lines
---
Changes in v3:
- setlcd_line_lengthby driver specificlcd_get_size()since setting it inlcd_enable()is not correct. This patch version depends on patch http://patchwork.ozlabs.org/patch/289957
Please test these both patches onrpi_b, thanks!
I just tested these on my rpi, and confirm that it still works.
Thanks,
Andre
PATCH v3 2/2 video: bcm2835: respect the pitch value
Hi Andre,
On Sat, 9 Nov 2013 13:25:58 +0100
Andre Heider <[email protected]> wrote:
...
Quoted 1 line
I just tested these on my rpi, and confirm that it still works.
Thanks for testing!
Anatolij
PATCH v3 2/2 video: bcm2835: respect the pitch value
In reply to Anatolij GustschinQuoted 10 lines · Anatolij Gustschin
From: Andre Heider <[email protected]>
Depending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
Fix this by setting
lcd_line_lengthto the pitch value of the configured framebuffer.
PATCH v3 2/2 video: bcm2835: respect the pitch value
In reply to Anatolij GustschinQuoted 21 lines · On Sat, 9 Nov 2013 11:07:53 +0100 Anatolij Gustschin <[email protected]> wrote:
From: Andre Heider <[email protected]>
Depending on the firmware's video options [1] the active SDTV or HDTV mode can yield a framebuffer with noncontiguous horizontal lines, giving a messed up display, for both, u-boot and the loaded kernel.
Fix this by setting
lcd_line_lengthto the pitch value of the configured framebuffer.[1] http://elinux.org/RPiconfig#Video_mode_options
Signed-off-by Andre Heider <[email protected]>Cc Stephen Warren <[email protected]>Signed-off-by Anatolij Gustschin <[email protected]>---
Changes in v3:
- setlcd_line_lengthby driver specificlcd_get_size()since setting it inlcd_enable()is not correct. This patch version depends on patch http://patchwork.ozlabs.org/patch/289957
Please test these both patches onrpi_b, thanks!
Quoted 2 lines
drivers/video/bcm2835.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
applied to u-boot-video/master, thanks!
Anatolij