From owner-freebsd-hackers@freebsd.org Fri Jun 16 16:56:48 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5CC73C78410 for ; Fri, 16 Jun 2017 16:56:48 +0000 (UTC) (envelope-from aplattner@nvidia.com) Received: from hqemgate14.nvidia.com (hqemgate14.nvidia.com [216.228.121.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hqemgate14.nvidia.com", Issuer "RapidSSL SHA256 CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 46AE22E1F for ; Fri, 16 Jun 2017 16:56:47 +0000 (UTC) (envelope-from aplattner@nvidia.com) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com id ; Fri, 16 Jun 2017 09:51:32 -0700 Received: from HQMAIL105.nvidia.com ([172.20.13.39]) by hqpgpgate102.nvidia.com (PGP Universal service); Fri, 16 Jun 2017 09:51:42 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 16 Jun 2017 09:51:42 -0700 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 16 Jun 2017 16:51:41 +0000 Received: from tenor.nvidia.com (172.20.13.39) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 16 Jun 2017 16:51:40 +0000 To: X-Nvconfidentiality: public From: Aaron Plattner Subject: efifb framebuffer info for NVIDIA driver console restore Message-ID: Date: Fri, 16 Jun 2017 09:51:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL106.nvidia.com (172.18.146.12) To HQMAIL102.nvidia.com (172.18.146.10) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jun 2017 16:56:48 -0000 Hi FreeBSD hackers, My name is Aaron Plattner. I'm a driver developer at NVIDIA working on the FreeBSD driver, among other things. I was hoping you could help me out regarding some changes I've been making to the driver. Recently, we've revamped how our driver handles switching from graphical modes to the console mode. For framebuffer consoles, the new nvidia_modeset module tries to take care of it without having to fall back to old-school VESA VBE modesets. However, in order for this to work, the driver needs to know where the framebuffer console is in physical memory, and its layout. On Linux, we get this information from the global 'screen_info' structure: void NV_API_CALL os_get_screen_info( NvU64 *pPhysicalAddress, NvU16 *pFbWidth, NvU16 *pFbHeight, NvU16 *pFbDepth, NvU16 *pFbPitch ) { // // If there is not a framebuffer console, return 0 size. // // orig_video_isVGA is set to 1 during early Linux kernel // initialization, and then will be set to a value, such as // VIDEO_TYPE_VLFB or VIDEO_TYPE_EFI if an fbdev console is used. // if (screen_info.orig_video_isVGA <= 1) { *pPhysicalAddress = 0; *pFbWidth = *pFbHeight = *pFbDepth = *pFbPitch = 0; return; } *pPhysicalAddress = screen_info.lfb_base; #if defined(VIDEO_CAPABILITY_64BIT_BASE) *pPhysicalAddress |= (NvU64)screen_info.ext_lfb_base << 32; #endif *pFbWidth = screen_info.lfb_width; *pFbHeight = screen_info.lfb_height; *pFbDepth = screen_info.lfb_depth; *pFbPitch = screen_info.lfb_linelength; } This works for both legacy boot systems with vesafb as well as UEFI systems that use Linux's efifb. On FreeBSD, I was able to find this information on my legacy system: void NV_API_CALL os_get_screen_info( NvU64 *pPhysicalAddress, NvU16 *pFbWidth, NvU16 *pFbHeight, NvU16 *pFbDepth, NvU16 *pFbPitch ) { const sc_softc_t *sc = sc_get_softc(0, SC_KERNEL_CONSOLE); if (sc) { const video_adapter_t *adp = sc->adp; if (adp) { const struct video_info *vi = &adp->va_info; if (vi && (vi->vi_flags & V_INFO_LINEAR)) { *pPhysicalAddress = vi->vi_buffer; *pFbWidth = vi->vi_width; *pFbHeight = vi->vi_height; *pFbDepth = vi->vi_depth; *pFbPitch = adp->va_line_width; return; } } } *pPhysicalAddress = 0; *pFbWidth = *pFbHeight = *pFbDepth = *pFbPitch = 0; } However, this doesn't work on UEFI systems because efifb doesn't go through the video_adapter_t stuff. Does anyone know how I can get that information from efifb, or who to talk to about adding an interface the driver can use to find it? Sincerely, Aaron