From patchwork Sun May 17 06:56:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 6422541 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C2B5B9F38D for ; Sun, 17 May 2015 06:56:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C40F3204A0 for ; Sun, 17 May 2015 06:56:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 735A320499 for ; Sun, 17 May 2015 06:56:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751126AbbEQG4f (ORCPT ); Sun, 17 May 2015 02:56:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43544 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751051AbbEQG4e (ORCPT ); Sun, 17 May 2015 02:56:34 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id DA7F28EFCC; Sun, 17 May 2015 06:56:33 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4H6uWgm007098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 17 May 2015 02:56:32 -0400 Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id t4H6uW8D015756; Sun, 17 May 2015 02:56:32 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id t4H6uUee015752; Sun, 17 May 2015 02:56:31 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Sun, 17 May 2015 02:56:29 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Michal Januszewski cc: linux-fbdev@vger.kernel.org, Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-kernel@vger.kernel.org Subject: [PATCH] uvesafb: make scaling configurable on Nvidia cards Message-ID: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP uvesafb: make scaling configurable on Nvidia cards Nvidia cards have a BIOS function 0x4f14 that allows to set flat panel scaling. This patch adds a module parameter "scaling" that uses this function to set the scaling. By default, the parameter is -1, so that the driver doesn't attempt to call the scaling function. This patch is useful when using the binary Nvidia graphics driver - in that case, the console may be only in text mode or VESA mode. By default, the video card does scaling that degrades font quality and changes aspect ratio. This patch makes it possible to turn off the scaling and improve font quality on the console. The allowed values depend on VESA BIOS. On my card, the following values are allowed: -1 - do not change the scaling 0 - scale to full screen 1, 2 - don't scale 3 - scale and preserve aspect ratio 4 - scale with black border around Example use: echo 1 >/sys/module/uvesafb/parameters/scaling; fbset 1280x1024-60 -depth 32 -a - this sets unscaled 1280x1024 video mode that has much sharper font than the scaled modes. I'm suggesting to backport this to stable kernels. The patch doesn't really fix a bug, but it enhances user experience significantly - the unscaled console font looks much better than the scaled font. By default, the patch does nothing, so it can't break any existing system. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org --- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/video/fbdev/uvesafb.c =================================================================== --- linux-2.6.orig/drivers/video/fbdev/uvesafb.c +++ linux-2.6/drivers/video/fbdev/uvesafb.c @@ -52,6 +52,7 @@ static u16 maxclk; /* maximum pixel clo static u16 maxvf; /* maximum vertical frequency */ static u16 maxhf; /* maximum horizontal frequency */ static u16 vbemode; /* force use of a specific VBE mode */ +static short scaling = -1; static char *mode_option; static u8 dac_width = 6; @@ -1245,7 +1246,22 @@ static int uvesafb_set_par(struct fb_inf task = uvesafb_prep(); if (!task) return -ENOMEM; + + if (scaling > 0) { + /* + * We must first reset scaling state with 0. This is workaround + * for some supposed BIOS bug - without this, scaling mode 4 + * could not be set. + */ + uvesafb_reset(task); + task->t.regs.eax = 0x4f14; + task->t.regs.ebx = 0x0102; + task->t.regs.ecx = 0; + uvesafb_exec(task); + } + setmode: + uvesafb_reset(task); task->t.regs.eax = 0x4f02; task->t.regs.ebx = mode->mode_id | 0x4000; /* use LFB */ @@ -1296,7 +1312,6 @@ setmode: printk(KERN_WARNING "uvesafb: mode switch failed " "(eax=0x%x, err=%d). Trying again with " "default timings.\n", task->t.regs.eax, err); - uvesafb_reset(task); kfree(crtc); crtc = NULL; info->var.pixclock = 0; @@ -1330,6 +1345,14 @@ setmode: FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; info->fix.line_length = mode->bytes_per_scan_line; + if (scaling >= 0) { + uvesafb_reset(task); + task->t.regs.eax = 0x4f14; + task->t.regs.ebx = 0x0102; + task->t.regs.ecx = scaling; + uvesafb_exec(task); + } + out: kfree(crtc); uvesafb_free(task); @@ -2019,6 +2042,9 @@ MODULE_PARM_DESC(vbemode, "VBE mode number to set, overrides the 'mode' option"); module_param_string(v86d, v86d_path, PATH_MAX, 0660); MODULE_PARM_DESC(v86d, "Path to the v86d userspace helper."); +module_param(scaling, short, 0660); +MODULE_PARM_DESC(scaling, + "Scaling option for nvidia (0 - scaled, 1 - unscaled centered, 2 - unscaled in left corner"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Michal Januszewski "); Index: linux-2.6/Documentation/fb/uvesafb.txt =================================================================== --- linux-2.6.orig/Documentation/fb/uvesafb.txt +++ linux-2.6/Documentation/fb/uvesafb.txt @@ -128,6 +128,14 @@ v86d:path need to use it and have uvesafb built into the kernel, use uvesafb.v86d="path". +scaling:n + Set scaling on Nvidia cards. Possible values depend on card's BIOS. + -1 - do not change the scaling + 0 - scale to full screen + 1, 2 - don't scale + 3 - scale and preserve aspect ratio + 4 - scale with black border around + Additionally, the following parameters may be provided. They all override the EDID-provided values and BIOS defaults. Refer to your monitor's specs to get the correct values for maxhf, maxvf and maxclk for your hardware.