From patchwork Wed Dec 20 00:24:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pieter \\\"PoroCYon\\\" Sluys" X-Patchwork-Id: 10124771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 96518603B5 for ; Wed, 20 Dec 2017 00:30:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8053B29336 for ; Wed, 20 Dec 2017 00:30:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E86E29685; Wed, 20 Dec 2017 00:30:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1657295FF for ; Wed, 20 Dec 2017 00:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753446AbdLTAaF (ORCPT ); Tue, 19 Dec 2017 19:30:05 -0500 Received: from cock.li ([185.100.85.212]:47132 "EHLO cock.li" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753439AbdLTAaE (ORCPT ); Tue, 19 Dec 2017 19:30:04 -0500 X-Greylist: delayed 358 seconds by postgrey-1.27 at vger.kernel.org; Tue, 19 Dec 2017 19:30:04 EST To: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=national.shitposting.agency; s=mail; t=1513729445; bh=qo7LOwilcedfKiwldfHYlxrnUM94HnYLlVilf8omSWI=; h=To:Cc:From:Subject:Date:From; b=d4Bvdqb+PDqtBjwEVanVAW6zSCghVMfTv3Wy6yq9zOAtBT/yOSFQg01v3QoiGAbVW Z3uh8Uk59yXfVzNHf0MFGqVvKROexT5F43zX/MF4L4UPf5OROB3ub5KWe9Jy0MQM91 a/yI8EkjeHfebRVvmvr5V2IYHxXcKEVdEw6cYhvv4el6nY1IvWbpe+0UMHmXPk8uyc yjFgcR6ewWtxy4TyffLg/sBM6J0d0s22RlByhRXjV++LYnQDRHFYiA/FfQIIRFVxIq rjjK6qq2yOmDbywBsf7a8pxPxsulrr31UHuttbs07BMnhnSyeonXt2cmIVSk0HnLXj EcTBV3VVcvAcw== Cc: Bartlomiej Zolnierkiewicz , Geert Uytterhoeven From: "Pieter \"PoroCYon\" Sluys" Subject: [PATCH] vfb: fix video mode and line_length being set when loaded Message-ID: <39a57338-18ac-c64f-1cf1-70a5f905990a@national.shitposting.agency> Date: Wed, 20 Dec 2017 00:24:00 +0000 MIME-Version: 1.0 Content-Language: en-US Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Thanks for your consideration, Pieter "PoroCYon" Sluys Reviewed-by: Geert Uytterhoeven --- drivers/video/fbdev/vfb.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.15.1 Fix vfb not setting the video mode and line_length when loaded. Copyright 2017 Pieter "PoroCYon" Sluys under the terms of the GPLv2 --- drivers/video/fbdev/vfb.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c index da653a080394..6e866fbaab8a 100644 --- a/drivers/video/fbdev/vfb.c +++ b/drivers/video/fbdev/vfb.c @@ -239,8 +239,25 @@ 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 2: + case 4: + 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 +467,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; -- 2.15.1