From: Mikulas Patocka <mpatocka@redhat.com> To: Michal Januszewski <spock@gentoo.org> Cc: linux-fbdev@vger.kernel.org, Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>, Tomi Valkeinen <tomi.valkeinen@ti.com>, linux-kernel@vger.kernel.org Subject: [PATCH] uvesafb: make scaling configurable on Nvidia cards Date: Wed, 2 Sep 2015 17:23:25 -0400 (EDT) [thread overview] Message-ID: <alpine.LRH.2.02.1509021719170.12073@file01.intranet.prod.int.rdu2.redhat.com> (raw) [ I sent this some times ago, but didn't get any response ] 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. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Index: linux-4.0.9/drivers/video/fbdev/uvesafb.c =================================================================== --- linux-4.0.9.orig/drivers/video/fbdev/uvesafb.c +++ linux-4.0.9/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 <spock@gentoo.org>"); Index: linux-4.0.9/Documentation/fb/uvesafb.txt =================================================================== --- linux-4.0.9.orig/Documentation/fb/uvesafb.txt +++ linux-4.0.9/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.
WARNING: multiple messages have this Message-ID (diff)
From: Mikulas Patocka <mpatocka@redhat.com> To: Michal Januszewski <spock@gentoo.org> Cc: linux-fbdev@vger.kernel.org, Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>, Tomi Valkeinen <tomi.valkeinen@ti.com>, linux-kernel@vger.kernel.org Subject: [PATCH] uvesafb: make scaling configurable on Nvidia cards Date: Wed, 02 Sep 2015 21:23:25 +0000 [thread overview] Message-ID: <alpine.LRH.2.02.1509021719170.12073@file01.intranet.prod.int.rdu2.redhat.com> (raw) In-Reply-To: <alpine.LRH.2.02.1505161334150.19574@file01.intranet.prod.int.rdu2.redhat.com> [ I sent this some times ago, but didn't get any response ] 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. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Index: linux-4.0.9/drivers/video/fbdev/uvesafb.c =================================--- linux-4.0.9.orig/drivers/video/fbdev/uvesafb.c +++ linux-4.0.9/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 <spock@gentoo.org>"); Index: linux-4.0.9/Documentation/fb/uvesafb.txt =================================--- linux-4.0.9.orig/Documentation/fb/uvesafb.txt +++ linux-4.0.9/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.
next reply other threads:[~2015-09-02 21:23 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-09-02 21:23 Mikulas Patocka [this message] 2015-09-02 21:23 ` [PATCH] uvesafb: make scaling configurable on Nvidia cards Mikulas Patocka 2015-10-08 9:31 ` Tomi Valkeinen 2015-10-08 9:31 ` Tomi Valkeinen 2015-10-08 11:51 ` Mikulas Patocka 2015-10-08 11:51 ` Mikulas Patocka 2015-10-08 12:21 ` Tomi Valkeinen 2015-10-08 12:21 ` Tomi Valkeinen 2015-10-08 13:55 ` Mikulas Patocka 2015-10-08 13:55 ` Mikulas Patocka -- strict thread matches above, loose matches on Subject: below -- 2015-05-17 6:56 Mikulas Patocka 2015-05-17 6:56 ` Mikulas Patocka
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=alpine.LRH.2.02.1509021719170.12073@file01.intranet.prod.int.rdu2.redhat.com \ --to=mpatocka@redhat.com \ --cc=linux-fbdev@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=plagnioj@jcrosoft.com \ --cc=spock@gentoo.org \ --cc=tomi.valkeinen@ti.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.