From owner-svn-src-all@freebsd.org Tue Sep 3 14:08:07 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 491A6DD6FD; Tue, 3 Sep 2019 14:07:14 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N80K40j8z4QNY; Tue, 3 Sep 2019 14:07:13 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id B48E91B2C8; Tue, 3 Sep 2019 14:06:32 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id E5BD510E2C; Sat, 20 Apr 2019 20:29:07 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 520447091D; Sat, 20 Apr 2019 20:29:07 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 1A5F210DF2; Sat, 20 Apr 2019 20:29:07 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 543AF10DF0 for ; Sat, 20 Apr 2019 20:29:04 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 22E5C70917; Sat, 20 Apr 2019 20:29:04 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EABB81B24F; Sat, 20 Apr 2019 20:29:03 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3KKT3bA086903; Sat, 20 Apr 2019 20:29:03 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3KKT3pB086901; Sat, 20 Apr 2019 20:29:03 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201904202029.x3KKT3pB086901@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346454 - head/lib/libvgl X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/lib/libvgl X-SVN-Commit-Revision: 346454 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 520447091D X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Status: O X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Tue, 03 Sep 2019 14:08:07 -0000 X-Original-Date: Sat, 20 Apr 2019 20:29:03 +0000 (UTC) X-List-Received-Date: Tue, 03 Sep 2019 14:08:07 -0000 Author: bde Date: Sat Apr 20 20:29:03 2019 New Revision: 346454 URL: https://svnweb.freebsd.org/changeset/base/346454 Log: Make libvgl mostly work without superuser privilege in direct modes by not doing any unnecessary PIO instructions or refusing to start when the i/o privilege needed for these instructions cannot be acquired. This turns off useless palette management in direct modes. Palette management had no useful effect since the hardware palette is not used in these modes. This transiently acquires i/o privilege if possible as needed to give VGLSetBorder() and VGLBlankDisplay() a chance of working. Neither has much chance of working. I was going to drop support for them in direct modes, but found that VGLBlankDisplay() still works with an old graphics card on a not so old LCD monitor. This has some good side effects: reduce glitches for managing the palette for screen switches, and speed up and reduce async-signal-unsafeness in mouse cursor drawing. Modified: head/lib/libvgl/main.c head/lib/libvgl/mouse.c head/lib/libvgl/simple.c Modified: head/lib/libvgl/main.c ============================================================================== --- head/lib/libvgl/main.c Sat Apr 20 17:16:36 2019 (r346453) +++ head/lib/libvgl/main.c Sat Apr 20 20:29:03 2019 (r346454) @@ -93,7 +93,8 @@ struct vt_mode smode; size[2] = VGLOldVInfo.font_size;; ioctl(0, KDRASTER, size); } - ioctl(0, KDDISABIO, 0); + if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) + ioctl(0, KDDISABIO, 0); ioctl(0, KDSETMODE, KD_TEXT); smode.mode = VT_AUTO; ioctl(0, VT_SETMODE, &smode); @@ -176,7 +177,7 @@ VGLInit(int mode) if (VGLDisplay == NULL) return -2; - if (ioctl(0, KDENABIO, 0)) { + if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT && ioctl(0, KDENABIO, 0)) { free(VGLDisplay); return -3; } @@ -370,7 +371,8 @@ VGLCheckSwitch() VGLSwitchPending = 0; if (VGLOnDisplay) { - ioctl(0, KDENABIO, 0); + if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) + ioctl(0, KDENABIO, 0); ioctl(0, KDSETMODE, KD_GRAPHICS); ioctl(0, VGLMode, 0); VGLCurWindow = 0; @@ -531,7 +533,8 @@ VGLCheckSwitch() munmap(VGLDisplay->Bitmap, VGLAdpInfo.va_window_size); ioctl(0, VGLOldMode, 0); ioctl(0, KDSETMODE, KD_TEXT); - ioctl(0, KDDISABIO, 0); + if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) + ioctl(0, KDDISABIO, 0); ioctl(0, VT_RELDISP, VT_TRUE); VGLDisplay->Bitmap = VGLBuf; VGLDisplay->Type = MEMBUF; Modified: head/lib/libvgl/mouse.c ============================================================================== --- head/lib/libvgl/mouse.c Sat Apr 20 17:16:36 2019 (r346453) +++ head/lib/libvgl/mouse.c Sat Apr 20 20:29:03 2019 (r346454) @@ -111,10 +111,12 @@ VGLMousePointerShow() if (!VGLMouseVisible) { INTOFF(); VGLMouseVisible = 1; - crtcidx = inb(0x3c4); - crtcval = inb(0x3c5); - gdcidx = inb(0x3ce); - gdcval = inb(0x3cf); + if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) { + crtcidx = inb(0x3c4); + crtcval = inb(0x3c5); + gdcidx = inb(0x3ce); + gdcval = inb(0x3cf); + } __VGLBitmapCopy(VGLDisplay, VGLMouseXpos, VGLMouseYpos, &VGLMouseSave, 0, 0, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); bcopy(VGLMouseSave.Bitmap, buffer.Bitmap, @@ -128,10 +130,12 @@ VGLMousePointerShow() } __VGLBitmapCopy(&buffer, 0, 0, VGLDisplay, VGLMouseXpos, VGLMouseYpos, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); - outb(0x3c4, crtcidx); - outb(0x3c5, crtcval); - outb(0x3ce, gdcidx); - outb(0x3cf, gdcval); + if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) { + outb(0x3c4, crtcidx); + outb(0x3c5, crtcval); + outb(0x3ce, gdcidx); + outb(0x3cf, gdcval); + } INTON(); } } @@ -144,16 +148,20 @@ VGLMousePointerHide() if (VGLMouseVisible) { INTOFF(); VGLMouseVisible = 0; - crtcidx = inb(0x3c4); - crtcval = inb(0x3c5); - gdcidx = inb(0x3ce); - gdcval = inb(0x3cf); + if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) { + crtcidx = inb(0x3c4); + crtcval = inb(0x3c5); + gdcidx = inb(0x3ce); + gdcval = inb(0x3cf); + } __VGLBitmapCopy(&VGLMouseSave, 0, 0, VGLDisplay, VGLMouseXpos, VGLMouseYpos, MOUSE_IMG_SIZE, MOUSE_IMG_SIZE); - outb(0x3c4, crtcidx); - outb(0x3c5, crtcval); - outb(0x3ce, gdcidx); - outb(0x3cf, gdcval); + if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT) { + outb(0x3c4, crtcidx); + outb(0x3c5, crtcval); + outb(0x3ce, gdcidx); + outb(0x3cf, gdcval); + } INTON(); } } Modified: head/lib/libvgl/simple.c ============================================================================== --- head/lib/libvgl/simple.c Sat Apr 20 17:16:36 2019 (r346453) +++ head/lib/libvgl/simple.c Sat Apr 20 20:29:03 2019 (r346454) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include "vgl.h" @@ -551,6 +552,8 @@ VGLRestorePalette() { int i; + if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) + return; outb(0x3C6, 0xFF); inb(0x3DA); outb(0x3C8, 0x00); @@ -571,6 +574,8 @@ VGLSavePalette() { int i; + if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) + return; outb(0x3C6, 0xFF); inb(0x3DA); outb(0x3C7, 0x00); @@ -591,6 +596,8 @@ VGLSetPalette(byte *red, byte *green, byte *blue) { int i; + if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) + return; for (i=0; i<256; i++) { VGLSavePaletteRed[i] = red[i]; VGLSavePaletteGreen[i] = green[i]; @@ -615,6 +622,8 @@ VGLSetPalette(byte *red, byte *green, byte *blue) void VGLSetPaletteIndex(byte color, byte red, byte green, byte blue) { + if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) + return; VGLSavePaletteRed[color] = red; VGLSavePaletteGreen[color] = green; VGLSavePaletteBlue[color] = blue; @@ -630,11 +639,15 @@ VGLSetPaletteIndex(byte color, byte red, byte green, b void VGLSetBorder(byte color) { + if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT && ioctl(0, KDENABIO, 0)) + return; VGLCheckSwitch(); inb(0x3DA); outb(0x3C0,0x11); outb(0x3C0, color); inb(0x3DA); outb(0x3C0, 0x20); + if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) + ioctl(0, KDDISABIO, 0); } void @@ -642,7 +655,11 @@ VGLBlankDisplay(int blank) { byte val; + if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT && ioctl(0, KDENABIO, 0)) + return; VGLCheckSwitch(); outb(0x3C4, 0x01); val = inb(0x3C5); outb(0x3C4, 0x01); outb(0x3C5, ((blank) ? (val |= 0x20) : (val &= 0xDF))); + if (VGLModeInfo.vi_mem_model == V_INFO_MM_DIRECT) + ioctl(0, KDDISABIO, 0); }