[openchrome-devel] xf86-video-openchrome: Branch 'main' - 3 commits - configure.ac src/openchrome_drm.h src/via_driver.c src/via_driver.h src/via_drm.h src/via_memmgr.c tools/registers.c

Kevin Brace kevinbrace at kemper.freedesktop.org
Wed Jun 8 18:43:45 UTC 2022


 configure.ac         |    2 
 src/openchrome_drm.h |   75 ---------------------------------
 src/via_driver.c     |  113 +++++++++++++--------------------------------------
 src/via_driver.h     |    3 -
 src/via_drm.h        |   35 +++++++++++++--
 src/via_memmgr.c     |   21 ++++-----
 tools/registers.c    |    3 -
 7 files changed, 76 insertions(+), 176 deletions(-)

New commits:
commit 422d028257c27952460fa9a35a7291212db43982
Author: Kevin Brace <kevinbrace at bracecomputerlab.com>
Date:   Wed Jun 8 13:42:37 2022 -0500

    Version bumped to 0.6.500
    
    Discontinue the use of 'openchrome' based OpenChrome DRM.  'via' based
    OpenChrome DRM Version 3.5.0 will replace it.  Its uAPI will also change
    as a result.
    
    Signed-off-by: Kevin Brace <kevinbrace at bracecomputerlab.com>

diff --git a/configure.ac b/configure.ac
index 0d01bd3..5309970 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-openchrome],
-        [0.6.411],
+        [0.6.500],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
         [xf86-video-openchrome])
 
commit 04c73010c6ea30a27dda3cd01cfd68e864206df4
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Jun 8 13:42:37 2022 -0500

    Use 'via' based OpenChrome DRM only from now on
    
    Discontinue the use of 'openchrome' based OpenChrome DRM.
    Its uAPI will also change as a result.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/openchrome_drm.h b/src/openchrome_drm.h
deleted file mode 100644
index bfa296e..0000000
--- a/src/openchrome_drm.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright © 2020 Kevin Brace
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including
- * the next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-/*
- * Author(s):
- *
- * Kevin Brace <kevinbrace at gmx.com>
- */
-
-#ifndef __OPENCHROME_DRM_H__
-#define __OPENCHROME_DRM_H__
-
-
-#include "drm.h"
-
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-
-#define DRM_OPENCHROME_GEM_CREATE	0x00
-#define DRM_OPENCHROME_GEM_MAP		0x01
-#define DRM_OPENCHROME_GEM_UNMAP	0x02
-
-
-#define DRM_IOCTL_OPENCHROME_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_OPENCHROME_GEM_CREATE, struct drm_openchrome_gem_create)
-#define DRM_IOCTL_OPENCHROME_GEM_MAP    DRM_IOWR(DRM_COMMAND_BASE + DRM_OPENCHROME_GEM_MAP, struct drm_openchrome_gem_map)
-#define DRM_IOCTL_OPENCHROME_GEM_UNMAP  DRM_IOR(DRM_COMMAND_BASE + DRM_OPENCHROME_GEM_UNMAP, struct drm_openchrome_gem_unmap)
-
-
-struct drm_openchrome_gem_create {
-	uint64_t size;
-	uint32_t alignment;
-	uint32_t domain;
-	uint32_t handle;
-	uint64_t offset;
-};
-
-struct drm_openchrome_gem_map {
-	uint32_t handle;
-	uint64_t map_offset;
-};
-
-struct drm_openchrome_gem_unmap {
-	uint32_t handle;
-};
-
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* __OPENCHROME_DRM_H__ */
diff --git a/src/via_driver.c b/src/via_driver.c
index e50cbfd..a24e2cf 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -65,7 +65,7 @@
 #ifdef OPENCHROMEDRI
 static const ViaDRMVersion drmVIADRMExpected = { 1, 3, 0 };
 static const ViaDRMVersion drmVIADRMCompat = { 3, 0, 0 };
-static const ViaDRMVersion drmOpenChromeDRMVersion = { 3, 4, 0 };
+static const ViaDRMVersion drmVIADRMKMSSupport = { 3, 5, 0 };
 #endif /* OPENCHROMEDRI */
 
 /* Prototypes. */
@@ -870,120 +870,69 @@ viaDrmOpen(ScrnInfoPtr pScrn)
                 pVia->PciInfo->func);
     }
 
-    /*
-     * Look for OpenChrome DRM first.
-     * KMS supports needs to be present for OpenChrome DRM to
-     * function properly.
-     */
-    pVia->drmmode.fd = drmOpen(OPENCHROME_DRM_DRIVER_NAME, busId);
+    busId = DRICreatePCIBusID(pVia->PciInfo);
+    pVia->drmmode.fd = drmOpen(VIA_DRM_DRIVER_NAME, busId);
     if (pVia->drmmode.fd != -1) {
         xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                    "OpenChrome DRM detected.\n");
+                    "Compatible DRM detected.\n");
         drmVer = drmGetVersion(pVia->drmmode.fd);
         if (drmVer) {
             pVia->drmVerMajor = drmVer->version_major;
             pVia->drmVerMinor = drmVer->version_minor;
             pVia->drmVerPatchLevel = drmVer->version_patchlevel;
             drmFreeVersion(drmVer);
+
             xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "OpenChrome DRM Version: %d.%d.%d\n",
+                        "DRM Version: %d.%d.%d\n",
                         pVia->drmVerMajor, pVia->drmVerMinor,
                         pVia->drmVerPatchLevel);
 
-            if ((pVia->drmVerMajor > drmOpenChromeDRMVersion.major) ||
-                ((pVia->drmVerMajor == drmOpenChromeDRMVersion.major) &&
-                (pVia->drmVerMinor >= drmOpenChromeDRMVersion.minor))) {
+            if ((pVia->drmVerMajor > drmVIADRMKMSSupport.major) ||
+                ((pVia->drmVerMajor == drmVIADRMKMSSupport.major) &&
+                (pVia->drmVerMinor >= drmVIADRMKMSSupport.minor))) {
                 if (!drmCheckModesettingSupported(busId)) {
                     pVia->KMS = TRUE;
                     pVia->directRenderingType = DRI_2;
                     pVia->NoAccel = TRUE;
                     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                                "KMS is supported by "
-                                "OpenChrome DRM.\n");
+                                "KMS is supported by DRM.\n");
                 } else {
                     xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                                 "KMS is not available.\n");
                     xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                                "Disabling OpenChrome DRM support.\n");
+                                "Disabling DRM support.\n");
                 }
+            } else if (((pVia->drmVerMajor > drmVIADRMExpected.major) &&
+                (pVia->drmVerMajor < drmVIADRMCompat.major)) ||
+                ((pVia->drmVerMajor == drmVIADRMExpected.major) &&
+                (pVia->drmVerMinor >= drmVIADRMExpected.minor) &&
+                (pVia->drmVerMajor < drmVIADRMCompat.major))) {
+                pVia->directRenderingType = DRI_1;
+                xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                            "DRI1 DRM is found.\n");
             } else {
                 xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                            "Unsupported version of OpenChrome DRM "
-                            "detected.\n");
+                            "DRM is not compatible with DDX.\n"
+                            "DDX can work with "
+                            "DRM version from %d.%d to less than %d.%d.\n",
+                            drmVIADRMExpected.major,
+                            drmVIADRMExpected.minor,
+                            drmVIADRMCompat.major,
+                            drmVIADRMCompat.minor);
                 xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                            "Only OpenChrome DRM Version %d.%d or "
-                            "later is supported.\n",
-                            drmOpenChromeDRMVersion.major,
-                            drmOpenChromeDRMVersion.minor);
-                xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                            "Disabling OpenChrome DRM support.\n");
+                            "Disabling DRM support.\n");
             }
         } else {
             xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                        "Not able to obtain OpenChrome DRM version.\n");
-            xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                        "Disabling OpenChrome DRM support.\n");
+                        "Not able to obtain DRM version.\n");
         }
+    } else {
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                    "DDX will now operate without DRM.\n");
     }
 
     free(busId);
 
-    /*
-     * Now, check for "legacy" DRI1 VIA DRM.
-     */
-    if (!pVia->KMS) {
-        busId = DRICreatePCIBusID(pVia->PciInfo);
-        pVia->drmmode.fd = drmOpen(VIA_DRM_DRIVER_NAME, busId);
-        if (pVia->drmmode.fd != -1) {
-            xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "VIA DRM detected.\n");
-            drmVer = drmGetVersion(pVia->drmmode.fd);
-            if (drmVer) {
-                pVia->drmVerMajor = drmVer->version_major;
-                pVia->drmVerMinor = drmVer->version_minor;
-                pVia->drmVerPatchLevel = drmVer->version_patchlevel;
-                drmFreeVersion(drmVer);
-
-                xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                            "VIA DRM Version: %d.%d.%d\n",
-                            pVia->drmVerMajor, pVia->drmVerMinor,
-                            pVia->drmVerPatchLevel);
-
-                if (((pVia->drmVerMajor > drmVIADRMExpected.major) &&
-                    (pVia->drmVerMajor < drmVIADRMCompat.major)) ||
-                    ((pVia->drmVerMajor == drmVIADRMExpected.major) &&
-                    (pVia->drmVerMinor >= drmVIADRMExpected.minor) &&
-                    (pVia->drmVerMajor < drmVIADRMCompat.major))) {
-                    pVia->directRenderingType = DRI_1;
-                    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                                "This version of VIA DRM is "
-                                "compatible with OpenChrome DDX.\n");
-                } else {
-                    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                                "This version of VIA DRM is not "
-                                "compatible with OpenChrome DDX.\n"
-                                "OpenChrome DDX can work with "
-                                "VIA DRM Version %d.%d to %d.%d.\n",
-                                drmVIADRMExpected.major,
-                                drmVIADRMExpected.minor,
-                                drmVIADRMCompat.major,
-                                drmVIADRMCompat.minor);
-                    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                                "Disabling VIA DRM support.\n");
-                }
-            } else {
-                xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                            "Not able to obtain VIA DRM version.\n");
-            }
-        } else {
-            xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                        "OpenChrome DDX will now operate "
-                        "without DRM.\n");
-        }
-
-        free(busId);
-    }
-
     status = TRUE;
 exit:
     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
diff --git a/src/via_driver.h b/src/via_driver.h
index d175069..08969a6 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -95,8 +95,7 @@
                             (PACKAGE_VERSION_MINOR << 16) | \
                             PACKAGE_VERSION_PATCHLEVEL
 
-#define OPENCHROME_DRM_DRIVER_NAME  "openchrome"
-#define VIA_DRM_DRIVER_NAME         "via"
+#define VIA_DRM_DRIVER_NAME     "via"
 
 #define VIA_AGP_UPL_SIZE    (1024*128)
 #define VIA_DMA_DL_SIZE     (1024*128)
diff --git a/src/via_drm.h b/src/via_drm.h
index a1e125d..e9da45c 100644
--- a/src/via_drm.h
+++ b/src/via_drm.h
@@ -1,4 +1,5 @@
 /*
+ * Copyright © 2020 Kevin Brace
  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
  * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
  *
@@ -16,10 +17,10 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS, COPYRIGHT HOLDERS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #ifndef _VIA_DRM_H_
 #define _VIA_DRM_H_
@@ -81,6 +82,11 @@ extern "C" {
 #define DRM_VIA_DMA_BLIT        0x0e
 #define DRM_VIA_BLIT_SYNC       0x0f
 
+#define	DRM_VIA_GEM_CREATE	0x10
+#define	DRM_VIA_GEM_MAP		0x11
+#define	DRM_VIA_GEM_UNMAP	0x12
+
+
 #define DRM_IOCTL_VIA_ALLOCMEM	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
 #define DRM_IOCTL_VIA_FREEMEM	  DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
 #define DRM_IOCTL_VIA_AGP_INIT	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
@@ -97,6 +103,10 @@ extern "C" {
 #define DRM_IOCTL_VIA_DMA_BLIT    DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
 #define DRM_IOCTL_VIA_BLIT_SYNC   DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
 
+#define	DRM_IOCTL_VIA_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_GEM_CREATE, struct drm_via_gem_create)
+#define	DRM_IOCTL_VIA_GEM_MAP		DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_GEM_MAP, struct drm_via_gem_map)
+#define	DRM_IOCTL_VIA_GEM_UNMAP		DRM_IOR(DRM_COMMAND_BASE + DRM_VIA_GEM_UNMAP, struct drm_via_gem_unmap)
+
 /* Indices into buf.Setup where various bits of state are mirrored per
  * context and per buffer.  These can be fired at the card as a unit,
  * or in a piecewise fashion as required.
@@ -275,6 +285,23 @@ typedef struct drm_via_dmablit {
 	drm_via_blitsync_t sync;
 } drm_via_dmablit_t;
 
+struct drm_via_gem_create {
+	uint64_t size;
+	uint32_t alignment;
+	uint32_t domain;
+	uint32_t handle;
+	uint64_t offset;
+};
+
+struct drm_via_gem_map {
+	uint32_t handle;
+	uint64_t map_offset;
+};
+
+struct drm_via_gem_unmap {
+	uint32_t handle;
+};
+
 #if defined(__cplusplus)
 }
 #endif
diff --git a/src/via_memmgr.c b/src/via_memmgr.c
index 343370e..e1f2a49 100644
--- a/src/via_memmgr.c
+++ b/src/via_memmgr.c
@@ -39,7 +39,6 @@
 #include "via_driver.h"
 #ifdef OPENCHROMEDRI
 #include "via_drm.h"
-#include "openchrome_drm.h"
 
 #else
 #include "drm_fourcc.h"
@@ -149,16 +148,16 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned long size,
                                     obj->handle));
             }
         } else if (pVia->directRenderingType == DRI_2) {
-            struct drm_openchrome_gem_create args;
+            struct drm_via_gem_create args;
 
             memset(&args, 0, sizeof(args));
             args.size = size;
             args.alignment = alignment;
             args.domain = domain;
             ret = drmCommandWriteRead(pVia->drmmode.fd,
-                            DRM_OPENCHROME_GEM_CREATE,
+                            DRM_VIA_GEM_CREATE,
                             &args,
-                            sizeof(struct drm_openchrome_gem_create));
+                            sizeof(struct drm_via_gem_create));
             if (!ret) {
                 /* Okay the X server expects to know the offset because
                  * of non-KMS. Once we have KMS working the offset
@@ -202,7 +201,7 @@ drm_bo_map(ScrnInfoPtr pScrn, struct buffer_object *obj)
 {
     VIAPtr pVia = VIAPTR(pScrn);
 #ifdef OPENCHROMEDRI
-    struct drm_openchrome_gem_map args;
+    struct drm_via_gem_map args;
     int ret;
 #endif /* OPENCHROMEDRI */
 
@@ -229,9 +228,9 @@ drm_bo_map(ScrnInfoPtr pScrn, struct buffer_object *obj)
         memset(&args, 0, sizeof(args));
         args.handle = obj->handle;
         ret = drmCommandWriteRead(pVia->drmmode.fd,
-                        DRM_OPENCHROME_GEM_MAP,
+                        DRM_VIA_GEM_MAP,
                         &args,
-                        sizeof(struct drm_openchrome_gem_map));
+                        sizeof(struct drm_via_gem_map));
         if (ret) {
             obj->ptr = NULL;
             goto exit;
@@ -257,7 +256,7 @@ drm_bo_unmap(ScrnInfoPtr pScrn, struct buffer_object *obj)
 {
     VIAPtr pVia = VIAPTR(pScrn);
 #ifdef OPENCHROMEDRI
-    struct drm_openchrome_gem_unmap args;
+    struct drm_via_gem_unmap args;
     int ret;
 #endif /* OPENCHROMEDRI */
 
@@ -270,12 +269,12 @@ drm_bo_unmap(ScrnInfoPtr pScrn, struct buffer_object *obj)
     } else if (pVia->directRenderingType == DRI_2) {
         munmap(obj->ptr, obj->size);
 
-        memset(&args, 0, sizeof(struct drm_openchrome_gem_unmap));
+        memset(&args, 0, sizeof(struct drm_via_gem_unmap));
         args.handle = obj->handle;
         ret = drmCommandRead(pVia->drmmode.fd,
-                        DRM_OPENCHROME_GEM_UNMAP,
+                        DRM_VIA_GEM_UNMAP,
                         &args,
-                        sizeof(struct drm_openchrome_gem_unmap));
+                        sizeof(struct drm_via_gem_unmap));
         if (ret) {
             goto exit;
         }
commit d9c3bced3495f52b4bab0fef85634e7dd8a8953b
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Jun 8 13:42:37 2022 -0500

    Suppress compile time format specifier warning of via_regs_dump tool
    
    Use an inttypes.h format specifier macro for displaying a uint64_t type.
    This occurs in a 64-bit compilation environment.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/tools/registers.c b/tools/registers.c
index 7b8f8df..4ef5d3c 100644
--- a/tools/registers.c
+++ b/tools/registers.c
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <inttypes.h>
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
@@ -1045,7 +1046,7 @@ static void dump_sl(const char *pfx)
 	temp = (readb_idx_reg(0x3c5, 0x6d) & 0x7f);
 	sl_in_mem_addr |= (temp << 37);
 
-	printf("%sSL in System memory: 0x%llx, RTSF in SL: 0x%lx\n",
+	printf("%sSL in System memory: 0x%"PRIx64", RTSF in SL: 0x%lx\n",
 		pfx, sl_in_mem_addr, rtsf_in_sl_addr);
 }
 


More information about the openchrome-devel mailing list