drm/fb: width/height cleanups/fixes
Subsystems (6)
v2 cover drm/fb: width/height cleanups/fixes
In the process of fixing fb_width/fb_height problems with tiled displays (such as DP MST), I realized there were a few drivers having confusion about drm_fb_helper_surface_size.
So, document the struct, fix the drivers, simplify the logic in drm_fb_helper_single_fb_probe() that figures out the sizes, and finally fix the logic for tiled displays.
Oh and a minor completely unrelated kerneldoc fix for a typo that I noticed.
Rob Clark (7):
drm/fb: document drm_fb_helper_surface_size
drm/atomic: minor kerneldoc typo fix
drm/cma: use correct fb width/height
drm/exynos: use correct fb width/height
drm/rockchip: use correct fb width/height
drm/fb: small cleanup
drm/fb: handle tiled connectors better
drivers/gpu/drm/drm_fb_cma_helper.c | 2 +- drivers/gpu/drm/drm_fb_helper.c | 48 +++++++++++++++++++-------- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 5 +-- drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 2 +- include/drm/drm_crtc.h | 2 +- include/drm/drm_fb_helper.h | 19 +++++++++++ 6 files changed, 60 insertions(+), 18 deletions(-)
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/7 drm/fb: document drm_fb_helper_surface_size
There has been some confusion about this struct. Lack of documentation probably didn't help.
--- include/drm/drm_fb_helper.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/drm/drm_fb_helper.h +19 -0
@@ -44,6 +44,25 @@ struct drm_fb_helper_crtc {int x, y; }; +/** +* struct drm_fb_helper_surface_size - describes fbdev size and scanout surface size +* @fb_width: fbdev width +* @fb_height: fbdev height +* @surface_width: scanout buffer width +* @surface_height: scanout buffer height +* @surface_bpp: scanout buffer bpp +* @surface_depth: scanout buffer depth +* +* Note that the scanout surface width/height may be larger than the fbdev +* width/height. In case of multiple displays, the scanout surface is sized +* according to the largest width/height (so it is large enough for all CRTCs +* to scanout). But the fbdev width/height is sized to the minimum width/ +* height of all the displays. This ensures that fbcon fits on the smallest +* of the attached displays. +* +* So what is passed to drm_fb_helper_fill_var() should be fb_width/fb_height, +* rather than the surface size. +*/ struct drm_fb_helper_surface_size {u32 fb_width;u32 fb_height;
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/7 drm/atomic: minor kerneldoc typo fix
In reply to Rob Clark--- include/drm/drm_crtc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_crtc.h +1 -1
@@ -915,7 +915,7 @@ struct drm_bridge { };/** -* struct struct drm_atomic_state - the global state object for atomic updates +* struct drm_atomic_state - the global state object for atomic updates * @dev: parent DRM device * @allow_modeset: allow full modeset * @legacy_cursor_update: hint to enforce legacy cursor ioctl semantics
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 3/7 drm/cma: use correct fb width/height
In reply to Rob ClarkWhat is passed to drm_fb_helper_fill_var() should be fb_width/fb_height, rather than the surface size.
--- drivers/gpu/drm/drm_fb_cma_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_cma_helper.c +1 -1
@@ -304,7 +304,7 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper, }drm_fb_helper_fill_fix (fbi, fb->pitches[0 ], fb->depth); -drm_fb_helper_fill_var (fbi, helper, fb->width, fb->height); +drm_fb_helper_fill_var (fbi, helper, sizes->fb_width, sizes->fb_height); offset = fbi->var.xoffset * bytes_per_pixel; offset += fbi->var.yoffset * fb->pitches[0 ];
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 4/7 drm/exynos: use correct fb width/height
In reply to Rob ClarkWhat is passed to drm_fb_helper_fill_var() should be fb_width/fb_height, rather than the surface size.
--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +3 -2
@@ -76,6 +76,7 @@ static struct fb_ops exynos_drm_fb_ops = { };static int exynos_drm_fbdev_update (struct drm_fb_helper *helper, +struct drm_fb_helper_surface_size *sizes,struct drm_framebuffer *fb) {struct fb_info *fbi = helper->fbdev;
@@ -85,7 +86,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,unsigned long offset;drm_fb_helper_fill_fix (fbi, fb->pitches[0 ], fb->depth); -drm_fb_helper_fill_var (fbi, helper, fb->width, fb->height); +drm_fb_helper_fill_var (fbi, helper, sizes->fb_width, sizes->fb_height);/* RGB formats use only one buffer */ buffer =exynos_drm_fb_buffer (fb,0 );
@@ -189,7 +190,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, goto err_destroy_framebuffer; } - ret =exynos_drm_fbdev_update (helper, helper->fb); + ret =exynos_drm_fbdev_update (helper, sizes, helper->fb);if (ret <0 ) goto err_dealloc_cmap;
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 5/7 drm/rockchip: use correct fb width/height
In reply to Rob ClarkWhat is passed to drm_fb_helper_fill_var() should be fb_width/fb_height, rather than the surface size.
--- drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c +1 -1
@@ -106,7 +106,7 @@ static int rockchip_drm_fbdev_create(struct drm_fb_helper *helper, fb = helper->fb;drm_fb_helper_fill_fix (fbi, fb->pitches[0 ], fb->depth); -drm_fb_helper_fill_var (fbi, helper, fb->width, fb->height); +drm_fb_helper_fill_var (fbi, helper, sizes->fb_width, sizes->fb_height); offset = fbi->var.xoffset * bytes_per_pixel; offset += fbi->var.yoffset * fb->pitches[0 ];
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 6/7 drm/fb: small cleanup
In reply to Rob ClarkFlip conditional to reduce indentation level of rest of fxn, and use min/max to make the code clearer.
v2: surface_width -> surface_height typo
--- drivers/gpu/drm/drm_fb_helper.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +15 -13
@@ -1035,22 +1035,24 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_display_mode *desired_mode;int x, y; + desired_mode = fb_helper->crtc_info[i].desired_mode; + +if (!desired_mode) +continue ; + + crtc_count++; + x = fb_helper->crtc_info[i].x; y = fb_helper->crtc_info[i].y; -if (desired_mode) { -if (gamma_size ==0 ) - gamma_size = fb_helper->crtc_info[i].mode_set.crtc->gamma_size; -if (desired_mode->hdisplay + x < sizes.fb_width) - sizes.fb_width = desired_mode->hdisplay + x; -if (desired_mode->vdisplay + y < sizes.fb_height) - sizes.fb_height = desired_mode->vdisplay + y; -if (desired_mode->hdisplay + x > sizes.surface_width) - sizes.surface_width = desired_mode->hdisplay + x; -if (desired_mode->vdisplay + y > sizes.surface_height) - sizes.surface_height = desired_mode->vdisplay + y; - crtc_count++; - } + +if (gamma_size ==0 ) + gamma_size = fb_helper->crtc_info[i].mode_set.crtc->gamma_size; + + sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); + sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height); + sizes.fb_width =min_t (u32, desired_mode->hdisplay + x, sizes.fb_width); + sizes.fb_height =min_t (u32, desired_mode->vdisplay + y, sizes.fb_height); }if (crtc_count ==0 || sizes.fb_width ==-1 || sizes.fb_height ==-1 ) {
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 6/7] drm/fb: small cleanup
Hi Rob,
Thank you for the patch.
Quoted 54 lines · On Wednesday 11 March 2015 10:23:13 Rob Clark wrote:
Flip conditional to reduce indentation level of rest of fxn, and use min/max to make the code clearer.
v2:
surface_width->surface_heighttypoSigned-off-by Rob Clark <[email protected]>Reviewed-by Daniel Kurtz <[email protected]>--- drivers/gpu/drm/drm_fb_helper.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/drm_fb_helper.cindex 1e6a0c7..dca98a4 100644drivers/gpu/drm/drm_fb_helper.c +14
-13@@ -1035,22 +1035,24 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, for (i = 0; i < fb_helper->crtc_count; i++) {struct drm_display_mode *desired_mode;int x, y; + desired_mode = fb_helper->crtc_info[i].desired_mode; + +if (!desired_mode) +continue ; + + crtc_count++; + x = fb_helper->crtc_info[i].x; y = fb_helper->crtc_info[i].y; -if (desired_mode) { -if (gamma_size ==0 ) - gamma_size = fb_helper->crtc_info[i].mode_set.crtc- gamma_size; -if (desired_mode->hdisplay + x < sizes.fb_width) - sizes.fb_width = desired_mode->hdisplay + x; -if (desired_mode->vdisplay + y < sizes.fb_height) - sizes.fb_height = desired_mode->vdisplay + y; -if (desired_mode->hdisplay + x > sizes.surface_width) - sizes.surface_width = desired_mode->hdisplay + x; -if (desired_mode->vdisplay + y > sizes.surface_height) - sizes.surface_height = desired_mode->vdisplay + y; - crtc_count++; - } + +if (gamma_size ==0 ) + gamma_size = fb_helper->crtc_info[i].mode_set.crtc->gamma_size; + + sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); + sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height); + sizes.fb_width = min_t(u32, desired_mode->hdisplay + x,sizes.fb_width);
drivers/gpu/drm/drm_fb_helper.c +1
-0+ sizes.fb_height = min_t(u32, desired_mode->vdisplay + y,
Quoted 1 line
sizes.fb_height); }
Nitpicking, reducing the indentation level is nice, but you're making lines longer. I would add line breaks here.
Quoted 1 line
if (
crtc_count== 0 || sizes.fb_width == -1 || sizes.fb_height == -1) {
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 7/7 drm/fb: handle tiled connectors better
In reply to Rob ClarkWe don't want tile 0,0 to artificially constrain the size of the legacy fbdev device. Instead when reducing fb_size to be the minimum of all displays, only consider the rightmost and bottommost tiles.
--- drivers/gpu/drm/drm_fb_helper.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +23 -3
@@ -1034,9 +1034,16 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, crtc_count =0 ;for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_display_mode *desired_mode; -int x, y; +struct drm_mode_set *mode_set; +int x, y, j; +/* in case of tile group, are we the last tile vert or horiz? +* If no tile group you are always the last one both vertically +* and horizontally +*/ +bool lastv = true, lasth = true; desired_mode = fb_helper->crtc_info[i].desired_mode; + mode_set = &fb_helper->crtc_info[i].mode_set;if (!desired_mode)continue ;
@@ -1051,8 +1058,21 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height); - sizes.fb_width =min_t (u32, desired_mode->hdisplay + x, sizes.fb_width); - sizes.fb_height =min_t (u32, desired_mode->vdisplay + y, sizes.fb_height); + +for (j =0 ; j < mode_set->num_connectors; j++) { +struct drm_connector *connector = mode_set->connectors[j]; +if (connector->has_tile) { + lasth = (connector->tile_h_loc == (connector->num_h_tile -1 )); + lastv = (connector->tile_v_loc == (connector->num_v_tile -1 )); +/* cloning to multiple tiles is just crazy-talk, so: */ +break ; + } + } + +if (lasth) + sizes.fb_width =min_t (u32, desired_mode->hdisplay + x, sizes.fb_width); +if (lastv) + sizes.fb_height =min_t (u32, desired_mode->vdisplay + y, sizes.fb_height); }if (crtc_count ==0 || sizes.fb_width ==-1 || sizes.fb_height ==-1 ) {
Signature · 6 lines
2.1.0 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 7/7] drm/fb: handle tiled connectors better
Quoted 6 lines · Rob Clark
We don't want tile 0,0 to artificially constrain the size of the legacy fbdev device. Instead when reducing
fb_sizeto be the minimum of all displays, only consider the rightmost and bottommost tiles.Signed-off-by Rob Clark <[email protected]>Tested-by Hai Li <[email protected]>
Yeah checkpatch isn't really happy about this and the previous one now, but I didn't really see a easy way to fix it and it's late ;-) So pulled them all into drm-misc.
Thanks, Daniel
Quoted 53 lines
--- drivers/gpu/drm/drm_fb_helper.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_fb_helper.c +23
-3@@ -1034,9 +1034,16 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, crtc_count =0 ;for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_display_mode *desired_mode; -int x, y; +struct drm_mode_set *mode_set; +int x, y, j; +/* in case of tile group, are we the last tile vert or horiz? +* If no tile group you are always the last one both vertically +* and horizontally +*/ +bool lastv = true, lasth = true; desired_mode = fb_helper->crtc_info[i].desired_mode; + mode_set = &fb_helper->crtc_info[i].mode_set;if (!desired_mode)continue ;@@ -1051,8 +1058,21 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height); - sizes.fb_width =min_t (u32, desired_mode->hdisplay + x, sizes.fb_width); - sizes.fb_height =min_t (u32, desired_mode->vdisplay + y, sizes.fb_height); + +for (j =0 ; j < mode_set->num_connectors; j++) { +struct drm_connector *connector = mode_set->connectors[j]; +if (connector->has_tile) { + lasth = (connector->tile_h_loc == (connector->num_h_tile -1 )); + lastv = (connector->tile_v_loc == (connector->num_v_tile -1 )); +/* cloning to multiple tiles is just crazy-talk, so: */ +break ; + } + } + +if (lasth) + sizes.fb_width =min_t (u32, desired_mode->hdisplay + x, sizes.fb_width); +if (lastv) + sizes.fb_height =min_t (u32, desired_mode->vdisplay + y, sizes.fb_height); }if (crtc_count ==0 || sizes.fb_width ==-1 || sizes.fb_height ==-1 ) {Signature · 1 line
2.1.0
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 7/7] drm/fb: handle tiled connectors better
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Rob Clark
We don't want tile 0,0 to artificially constrain the size of the legacy fbdev device. Instead when reducing
fb_sizeto be the minimum of all displays, only consider the rightmost and bottommost tiles.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Rob Clark <[email protected]>Tested-by Hai Li <[email protected]>Yeah checkpatch isn't really happy about this and the previous one now, but I didn't really see a easy way to fix it and it's late ;-) So pulled them all into drm-misc.
yeah, I was going with the "lines were already too long to begin with, and adding some line breaks made it more ugly" exception ;-)
BR,
-R
Quoted 51 lines
Thanks, Daniel
Quoted 49 lines
--- drivers/gpu/drm/drm_fb_helper.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_fb_helper.c +23
-3@@ -1034,9 +1034,16 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, crtc_count =0 ;for (i =0 ; i < fb_helper->crtc_count; i++) {struct drm_display_mode *desired_mode; -int x, y; +struct drm_mode_set *mode_set; +int x, y, j; +/* in case of tile group, are we the last tile vert or horiz? +* If no tile group you are always the last one both vertically +* and horizontally +*/ +bool lastv = true, lasth = true; desired_mode = fb_helper->crtc_info[i].desired_mode; + mode_set = &fb_helper->crtc_info[i].mode_set;if (!desired_mode)continue ;@@ -1051,8 +1058,21 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper, sizes.surface_width =max_t (u32, desired_mode->hdisplay + x, sizes.surface_width); sizes.surface_height =max_t (u32, desired_mode->vdisplay + y, sizes.surface_height); - sizes.fb_width =min_t (u32, desired_mode->hdisplay + x, sizes.fb_width); - sizes.fb_height =min_t (u32, desired_mode->vdisplay + y, sizes.fb_height); + +for (j =0 ; j < mode_set->num_connectors; j++) { +struct drm_connector *connector = mode_set->connectors[j]; +if (connector->has_tile) { + lasth = (connector->tile_h_loc == (connector->num_h_tile -1 )); + lastv = (connector->tile_v_loc == (connector->num_v_tile -1 )); +/* cloning to multiple tiles is just crazy-talk, so: */ +break ; + } + } + +if (lasth) + sizes.fb_width =min_t (u32, desired_mode->hdisplay + x, sizes.fb_width); +if (lastv) + sizes.fb_height =min_t (u32, desired_mode->vdisplay + y, sizes.fb_height); }
Quoted 9 lines
Quoted 4 lines
drivers/gpu/drm/drm_fb_helper.c +0
-1if (crtc_count ==0 || sizes.fb_width ==-1 || sizes.fb_height ==-1 ) { --2.1.0
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Rob Clark
In the process of fixing fb_width/fb_height problems with tiled displays (such as DP MST), I realized there were a few drivers having confusion about
drm_fb_helper_surface_size.So, document the struct, fix the drivers, simplify the logic in
drm_fb_helper_single_fb_probe()that figures out the sizes, and finally fix the logic for tiled displays.Oh and a minor completely unrelated kerneldoc fix for a typo that I noticed.
Series is:
Quoted 18 lines
Rob Clark (7):
drm/fb: documentdrm_fb_helper_surface_size
drm/atomic: minor kerneldoc typo fix
drm/cma: use correct fb width/height
drm/exynos: use correct fb width/height
drm/rockchip: use correct fb width/height
drm/fb: small cleanup
drm/fb: handle tiled connectors betterdrivers/gpu/drm/drm_fb_cma_helper.c | 2 +- drivers/gpu/drm/drm_fb_helper.c | 48 +++++++++++++++++++-------- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 5 +-- drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 2 +- include/drm/drm_crtc.h | 2 +- include/drm/drm_fb_helper.h | 19 +++++++++++ 6 files changed, 60 insertions(+), 18 deletions(-)
Quoted 7 lines
--
2.1.0_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Rob,
Thank you for the patches.
Quoted 11 lines · On Wednesday 11 March 2015 10:23:07 Rob Clark wrote:
In the process of fixing fb_width/fb_height problems with tiled displays (such as DP MST), I realized there were a few drivers having confusion about
drm_fb_helper_surface_size.So, document the struct, fix the drivers, simplify the logic in
drm_fb_helper_single_fb_probe()that figures out the sizes, and finally fix the logic for tiled displays.Oh and a minor completely unrelated kerneldoc fix for a typo that I noticed.
Quoted 8 lines
Rob Clark (7):
drm/fb: documentdrm_fb_helper_surface_size
drm/atomic: minor kerneldoc typo fix
drm/cma: use correct fb width/height
drm/exynos: use correct fb width/height
drm/rockchip: use correct fb width/height
drm/fb: small cleanup
drm/fb: handle tiled connectors better
For patches 1 to 5,
Quoted 7 lines
drivers/gpu/drm/drm_fb_cma_helper.c | 2 +- drivers/gpu/drm/drm_fb_helper.c | 48 ++++++++++++++++-------- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 5 +-- drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 2 +- include/drm/drm_crtc.h | 2 +- include/drm/drm_fb_helper.h | 19 +++++++++++ 6 files changed, 60 insertions(+), 18 deletions(-)
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel