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

Kevin Brace kevinbrace at kemper.freedesktop.org
Tue Aug 11 04:48:59 UTC 2020


 configure.ac         |    2 
 src/openchrome_drm.h |   69 ++++++++++++++++++++++++++++++
 src/via_driver.c     |    2 
 src/via_drm.h        |  116 +++++++++------------------------------------------
 src/via_memmgr.c     |   41 +++++++++++++-----
 src/via_memmgr.h     |    8 +--
 6 files changed, 125 insertions(+), 113 deletions(-)

New commits:
commit fa8cf643ac111785cfb7a408e377c0ac5c2d05b9
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Aug 10 21:32:16 2020 -0700

    Version bumped to 0.6.300
    
    Starting with this version, KMS support will require OpenChrome DRM
    Version 3.2.0 or later.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/configure.ac b/configure.ac
index 4453b20..a4ae929 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-openchrome],
-        [0.6.226],
+        [0.6.300],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/openchrome],
         [xf86-video-openchrome])
 
commit 644b9eaafb1ae21a8061e1cc0903c5f0340b1c1c
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Aug 10 21:27:44 2020 -0700

    Restore the original VIA DRM uAPI header file
    
    The header file is now identical to the one drm-openchrome (OpenChrome
    DRM development tree) has.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/via_drm.h b/src/via_drm.h
index b85b2ff..a1e125d 100644
--- a/src/via_drm.h
+++ b/src/via_drm.h
@@ -16,7 +16,7 @@
  * 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
- * THE AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * 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.
@@ -26,6 +26,10 @@
 
 #include "drm.h"
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
 /* WARNING: These defines must be the same as what the Xserver uses.
  * if you change them, you must change the defines in the Xserver.
  */
@@ -33,10 +37,11 @@
 #ifndef _VIA_DEFINES_
 #define _VIA_DEFINES_
 
+
 #define VIA_NR_SAREA_CLIPRECTS		8
-#define VIA_NR_XVMC_PORTS		10
-#define VIA_NR_XVMC_LOCKS		5
-#define VIA_MAX_CACHELINE_SIZE		64
+#define VIA_NR_XVMC_PORTS               10
+#define VIA_NR_XVMC_LOCKS               5
+#define VIA_MAX_CACHELINE_SIZE          64
 #define XVMCLOCKPTR(saPriv,lockNo)					\
 	((volatile struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
 				      (VIA_MAX_CACHELINE_SIZE - 1)) &	\
@@ -60,28 +65,21 @@
 
 /* VIA specific ioctls */
 #define DRM_VIA_ALLOCMEM	0x00
-#define DRM_VIA_FREEMEM		0x01
+#define DRM_VIA_FREEMEM	        0x01
 #define DRM_VIA_AGP_INIT	0x02
-#define DRM_VIA_FB_INIT		0x03
+#define DRM_VIA_FB_INIT	        0x03
 #define DRM_VIA_MAP_INIT	0x04
-#define DRM_VIA_DEC_FUTEX	0x05
-#define DRM_VIA_OLD_GEM_CREATE	0x06
+#define DRM_VIA_DEC_FUTEX       0x05
+#define NOT_USED
 #define DRM_VIA_DMA_INIT	0x07
 #define DRM_VIA_CMDBUFFER	0x08
-#define DRM_VIA_FLUSH		0x09
-#define DRM_VIA_PCICMD		0x0a
+#define DRM_VIA_FLUSH	        0x09
+#define DRM_VIA_PCICMD	        0x0a
 #define DRM_VIA_CMDBUF_SIZE	0x0b
 #define NOT_USED
-#define DRM_VIA_WAIT_IRQ	0x0d
-#define DRM_VIA_DMA_BLIT	0x0e
-#define DRM_VIA_BLIT_SYNC	0x0f
-
-/* KMS ioctls */
-#define DRM_VIA_GETPARAM	0x10
-#define DRM_VIA_SETPARAM	0x11
-#define DRM_VIA_GEM_CREATE	0x12
-#define DRM_VIA_GEM_WAIT	0x13
-#define DRM_VIA_GEM_STATE	0x14
+#define DRM_VIA_WAIT_IRQ        0x0d
+#define DRM_VIA_DMA_BLIT        0x0e
+#define DRM_VIA_BLIT_SYNC       0x0f
 
 #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)
@@ -89,7 +87,6 @@
 #define DRM_IOCTL_VIA_FB_INIT	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
 #define DRM_IOCTL_VIA_MAP_INIT	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
 #define DRM_IOCTL_VIA_DEC_FUTEX   DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
-#define DRM_IOCTL_VIA_OLD_GEM_CREATE  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_OLD_GEM_CREATE, struct drm_via_gem_object)
 #define DRM_IOCTL_VIA_DMA_INIT	  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
 #define DRM_IOCTL_VIA_CMDBUFFER	  DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
 #define DRM_IOCTL_VIA_FLUSH	  DRM_IO(  DRM_COMMAND_BASE + DRM_VIA_FLUSH)
@@ -100,13 +97,6 @@
 #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)
 
-/* KMS ioctls */
-#define DRM_IOCTL_VIA_GETPARAM    DRM_IOR(DRM_COMMAND_BASE + DRM_VIA_GETPARAM, struct drm_via_param)
-#define DRM_IOCTL_VIA_SETPARAM    DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_SETPARAM, struct drm_via_param)
-#define DRM_IOCTL_VIA_GEM_CREATE  DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_GEM_CREATE, struct drm_via_gem_object)
-#define DRM_IOCTL_VIA_GEM_WAIT    DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_GEM_WAIT, struct drm_via_gem_wait)
-#define DRM_IOCTL_VIA_GEM_STATE   DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_GEM_STATE, struct drm_via_gem_object)
-
 /* 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.
@@ -120,7 +110,6 @@
 #define VIA_BACK    0x2
 #define VIA_DEPTH   0x4
 #define VIA_STENCIL 0x8
-
 #define VIA_MEM_VIDEO   0	/* matches drm constant */
 #define VIA_MEM_AGP     1	/* matches drm constant */
 #define VIA_MEM_SYSTEM  2
@@ -286,71 +275,8 @@ typedef struct drm_via_dmablit {
 	drm_via_blitsync_t sync;
 } drm_via_dmablit_t;
 
-/* Ioctl to query kernel params:
- */
-#define VIA_PARAM_CHIPSET_ID		0
-#define VIA_PARAM_REVISION_ID		1
-
-struct drm_via_param {
-	uint64_t param;
-	uint64_t value;
-};
-
-struct drm_via_gem_object {
-	/**
-	 * Requested size for the object.
-	 *
-	 * The (page-aligned) allocated size for the object will be returned.
-	 */
-	uint64_t size;
-
-	/*
-	 * Place the memory at the proper byte alignment.
-	 */
-	uint32_t alignment;
-
-	/**
-	 * Format of data i.e tile pitch, for linear it is zero
-	 */
-	uint32_t pitch;
-
-	/**
-	 * Give hints where to allocate this object.
-	 */
-	uint32_t domains;
-
-	/**
-	 * chmod values applied to a buffer.
-	 */
-	uint32_t mode_t;
-
-	/**
-	 * Offset to start of memory region.
-	 */
-	uint64_t offset;
-
-	/**
-	 * Returned handle need to mmap the buffer.
-	 */
-	uint64_t map_handle;
-
-	/**
-	 * Returned handle for the object.
-	 *
-	 * Object handles are nonzero.
-	 */
-	uint32_t handle;
-
-	/**
-	 * Version to tell how to handle this data.
-	 */
-	uint32_t version;
-};
-
-struct drm_via_gem_wait {
-	/* the buffer object handle */
-	uint32_t handle;
-	uint32_t no_wait;
-};
+#if defined(__cplusplus)
+}
+#endif
 
 #endif				/* _VIA_DRM_H_ */
commit a83e6cedfc9760a6c0464eecd67a54aeafb262d4
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Mon Aug 10 21:21:27 2020 -0700

    Switch to OpenChrome DRM uAPI
    
    Remove the stillborn KMS supporting VIA DRM uAPI, and replace it with
    OpenChrome DRM uAPI.  Also, require the use of OpenChrome DRM Version
    3.2.0 or later for accessing OpenChrome DRM uAPI.  The use of
    OpenChrome DRM is required for KMS support.
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/src/openchrome_drm.h b/src/openchrome_drm.h
new file mode 100644
index 0000000..06f7f2a
--- /dev/null
+++ b/src/openchrome_drm.h
@@ -0,0 +1,69 @@
+/*
+ * 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/drm.h>
+
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+#define DRM_OPENCHROME_GEM_CREATE	0x00
+#define DRM_OPENCHROME_GEM_MAP		0x01
+
+
+#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)
+
+
+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;
+};
+
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __OPENCHROME_DRM_H__ */
diff --git a/src/via_driver.c b/src/via_driver.c
index 6919d33..e2c1138 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -67,7 +67,7 @@ typedef struct
 
 static const ViaDRMVersion drmVIADRMExpected = { 1, 3, 0 };
 static const ViaDRMVersion drmVIADRMCompat = { 3, 0, 0 };
-static const ViaDRMVersion drmOpenChromeDRMVersion = { 3, 0, 0 };
+static const ViaDRMVersion drmOpenChromeDRMVersion = { 3, 2, 0 };
 
 /* Prototypes. */
 static void VIAIdentify(int flags);
diff --git a/src/via_memmgr.c b/src/via_memmgr.c
index 70cf6ad..45bd2ba 100644
--- a/src/via_memmgr.c
+++ b/src/via_memmgr.c
@@ -38,6 +38,8 @@
 #include "via_driver.h"
 #ifdef HAVE_DRI
 #include "via_drm.h"
+#include "openchrome_drm.h"
+
 #else
 #include "drm_fourcc.h"
 #endif
@@ -146,23 +148,24 @@ drm_bo_alloc(ScrnInfoPtr pScrn, unsigned long size,
                                     obj->handle));
             }
         } else if (pVia->directRenderingType == DRI_2) {
-            struct drm_via_gem_object args;
+            struct drm_openchrome_gem_create args;
 
-            /* Some day this will be moved to libdrm. */
-            args.domains = domain;
-            args.alignment = alignment;
+            memset(&args, 0, sizeof(args));
             args.size = size;
-            ret = drmCommandWriteRead(pVia->drmmode.fd, DRM_VIA_GEM_CREATE,
-                                    &args, sizeof(struct drm_via_gem_object));
+            args.alignment = alignment;
+            args.domain = domain;
+            ret = drmCommandWriteRead(pVia->drmmode.fd,
+                            DRM_OPENCHROME_GEM_CREATE,
+                            &args,
+                            sizeof(struct drm_openchrome_gem_create));
             if (!ret) {
                 /* Okay the X server expects to know the offset because
                  * of non-KMS. Once we have KMS working the offset
                  * will not be valid. */
-                obj->map_offset = args.map_handle;
-                obj->offset = args.offset;
-                obj->handle = args.handle;
                 obj->size = args.size;
-                obj->domain = domain;
+                obj->domain = args.domain;
+                obj->handle = args.handle;
+                obj->offset = args.offset;
                 DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                                     "%lu bytes of DRI2 memory "
                                     "allocated at 0x%lx, "
@@ -197,10 +200,24 @@ void*
 drm_bo_map(ScrnInfoPtr pScrn, struct buffer_object *obj)
 {
     VIAPtr pVia = VIAPTR(pScrn);
+    int ret;
 
     if (pVia->directRenderingType == DRI_2) {
+        struct drm_openchrome_gem_map args;
+
+        memset(&args, 0, sizeof(args));
+        args.handle = obj->handle;
+        ret = drmCommandWriteRead(pVia->drmmode.fd,
+                        DRM_OPENCHROME_GEM_MAP,
+                        &args,
+                        sizeof(struct drm_openchrome_gem_map));
+        if (ret) {
+            obj->ptr = NULL;
+            goto exit;
+        }
+
         obj->ptr = mmap(0, obj->size, PROT_READ | PROT_WRITE,
-                        MAP_SHARED, pVia->drmmode.fd, obj->map_offset);
+                        MAP_SHARED, pVia->drmmode.fd, args.map_offset);
         if (obj->ptr == MAP_FAILED) {
             DEBUG(ErrorF("mmap failed with error %d\n", -errno));
             obj->ptr = NULL;
@@ -220,6 +237,8 @@ drm_bo_map(ScrnInfoPtr pScrn, struct buffer_object *obj)
             break;
         }
     }
+
+exit:
     return obj->ptr;
 }
 
diff --git a/src/via_memmgr.h b/src/via_memmgr.h
index 54199f5..e1be32d 100644
--- a/src/via_memmgr.h
+++ b/src/via_memmgr.h
@@ -30,13 +30,11 @@
 #define TTM_PL_FLAG_VRAM	4
 
 struct buffer_object {
-    off_t           map_offset;
-    unsigned long   handle;
-    unsigned long   offset;             /* Offset into fb */
-    unsigned long   pitch;              /* No longer used. */
-    unsigned long   size;
     void            *ptr;
+    unsigned long   size;
     int             domain;
+    unsigned long   handle;
+    unsigned long   offset;             /* Offset into fb */
 };
 
 


More information about the openchrome-devel mailing list