vfb: fix video mode and line_length being set when loaded

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/7b9faf5df0ac495a1a3d7cdb64921c179f9008ac
Commit:     7b9faf5df0ac495a1a3d7cdb64921c179f9008ac
Parent:     f1b95b71f19562a17bfc34c355efe3a86049f8bb
Refname:    refs/heads/master
Author:     Pieter \"PoroCYon\" Sluys <[email protected]>
AuthorDate: Thu Jan 4 16:53:50 2018 +0100
Committer:  Bartlomiej Zolnierkiewicz <[email protected]>
CommitDate: Thu Jan 4 16:53:50 2018 +0100

    vfb: fix video mode and line_length being set when loaded
    
    Currently, when loading the vfb module, the newly created fbdev
    has a line_length of 0, and its video mode would be PSEUDOCOLOR
    regardless of color depth. (The former could be worked around by
    calling the FBIOPUT_VSCREENINFO ioctl with having the FBACTIVIATE_FORCE
    flag set.) This patch automatically sets the line_length correctly,
    and the video mode is derived from the bit depth now as well.
    
    Thanks to Geert Uytterhoeven for confirming the bug and helping me with
    the patch.
    
    Output of `fbset -i' before the patch:
    mode "1366x768-60"
        # D: 72.432 MHz, H: 47.403 kHz, V: 60.004 Hz
        geometry 1366 768 1366 768 32
        timings 13806 120 10 14 3 32 5
        rgba 8/0,8/8,8/16,8/24
    endmode
    
    Frame buffer device information:
        Name        : Virtual FB
        Address     : 0xffffaa1405d85000
        Size        : 4196352
        Type        : PACKED PIXELS
        Visual      : PSEUDOCOLOR
        XPanStep    : 1
        YPanStep    : 1
        YWrapStep   : 1
        LineLength  : 0                    <-- note this
        Accelerator : No
    
    After:
    mode "1366x768-60"
        # D: 72.432 MHz, H: 47.403 kHz, V: 60.004 Hz
        geometry 1366 768 1366 768 32
        timings 13806 120 10 14 3 32 5
        rgba 8/0,8/8,8/16,8/24
    endmode
    
    Frame buffer device information:
        Name        : Virtual FB
        Address     : 0xffffaa1405d85000
        Size        : 4196352
        Type        : PACKED PIXELS
        Visual      : TRUECOLOR
        XPanStep    : 1
        YPanStep    : 1
        YWrapStep   : 1
        LineLength  : 5464
        Accelerator : No
    
    Signed-off-by: "Pieter \"PoroCYon\" Sluys" <[email protected]>
    Reviewed-by: Geert Uytterhoeven <[email protected]>
    [b.zolnierkie: minor fixups]
    Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
---
 drivers/video/fbdev/vfb.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c
index da653a080394..54127905bfe7 100644
--- a/drivers/video/fbdev/vfb.c
+++ b/drivers/video/fbdev/vfb.c
@@ -239,8 +239,23 @@ static int vfb_check_var(struct fb_var_screeninfo *var,
  */
 static int vfb_set_par(struct fb_info *info)
 {
+	switch (info->var.bits_per_pixel) {
+	case 1:
+		info->fix.visual = FB_VISUAL_MONO01;
+		break;
+	case 8:
+		info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
+		break;
+	case 16:
+	case 24:
+	case 32:
+		info->fix.visual = FB_VISUAL_TRUECOLOR;
+		break;
+	}
+
 	info->fix.line_length = get_line_length(info->var.xres_virtual,
 						info->var.bits_per_pixel);
+
 	return 0;
 }
 
@@ -450,6 +465,8 @@ static int vfb_probe(struct platform_device *dev)
 		goto err2;
 	platform_set_drvdata(dev, info);
 
+	vfb_set_par(info);
+
 	fb_info(info, "Virtual frame buffer device, using %ldK of video memory\n",
 		videomemorysize >> 10);
 	return 0;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.