Hi,

the patch below update the amdgpu(4) X.Org driver to version 23.0.0

To test (on machines with an AMD / Radeon GPU) 

# cd /usr/xenocara/driver/xf86-video-amdgpu
# patch -p0 -E < /path/to/this/file
# make -f Makefile.bsd-wrapper obj
# make -f Makefile.bsd-wrapper build

and restart xenodm(1)

Tests and oks welcome...

Index: ChangeLog
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/ChangeLog,v
retrieving revision 1.3
diff -u -p -u -r1.3 ChangeLog
--- ChangeLog   8 Mar 2022 03:56:50 -0000       1.3
+++ ChangeLog   27 Feb 2023 20:09:46 -0000
@@ -1,3 +1,170 @@
+commit 7025aefcdf9673665588cf291c5d71beb39cce89
+Author: Shashank Sharma <shashank.sha...@amd.com>
+Date:   Wed Feb 22 18:00:23 2023 +0100
+
+    Bump version for the 23.0.0 release
+    
+    This release includes some bug fixes.
+    
+    Signed-off-by: Shashank Sharma <shashank.sha...@amd.com>
+
+commit 6ee320917093ad0f7d68e516d3224d3c04ca13ee
+Author: Shashank Sharma <shashank.sha...@amd.com>
+Date:   Mon Nov 28 13:08:36 2022 +0100
+
+    config: Add hotplug driver name
+    
+    This patch adds the PCI-hotplug handler driver name in the
+    DDX config file with respect to Xorg commit:82bf391c
+    
+    Cc: Alexander Deucher <alexander.deuc...@amd.com>
+    Signed-off-by: Shashank Sharma <shashank.sha...@amd.com>
+
+commit 2ec854d48e0e44fc60c3955663f700cbefea3553
+Author: Mario Kleiner <mario.kleiner...@gmail.com>
+Date:   Fri Nov 11 02:18:07 2022 +0100
+
+    Fix primary output handling in amdgpu_crtc_covering_box().
+    
+    Commit e39a3ee07c9dea73b0452b71b1ef633b6cd6f389
+    tries to reintroduce the RandR primary output as a tie breaker
+    in amdgpu_crtc_covering_box(), but that function wrongly
+    assigns a void* devPrivate, which is actually a xf86CrtcPtr,
+    to the RRCrtcPtr primary_crtc, a pointer target type mismatch!
+    
+    This causes a later pointer comparison of primary_crtc with
+    RRCrtcPtr crtc to always fail, so that the user selected
+    primary output can not ever successfully act as a tie-breaker
+    when multiple candidate crtcs cover the same box area,
+    defeating the whole purpose of that commit! Not sure how
+    this failure could have ever evaded any basic testing.
+    
+    Fix this trivially by assigning the right variable.
+    
+    Successfully tested on a multi-display setup, verifying
+    that the primary output now works as tie breaker as
+    intended.
+    
+    Signed-off-by: Mario Kleiner <mario.kleiner...@gmail.com>
+    Fixes: e39a3ee07c9d ("Prefer crtc of primary output for synchronization 
when screen has to crtcs with the same coverage")
+
+commit 9c959fac3af28d191105f63236096ad456dca614
+Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-pra...@amd.com>
+Date:   Thu Sep 29 16:42:09 2022 +0200
+
+    Use DRM_CAP_CURSOR_WIDTH/HEIGHT if possible
+    
+    There's no need to hardcode the cursor size if the kernel can
+    report the value it wants.
+
+commit 4e011b91fa3ef58b85327d3429889efd934b3531
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Tue Aug 2 15:03:19 2022 -0700
+
+    gitlab CI: enable gitlab's builtin static analysis
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
+commit dc81177ef342bf8c2aa5a6fd6687c7a09b4f9709
+Author: tiancyin <tianci....@amd.com>
+Date:   Wed Aug 10 16:46:15 2022 +0800
+
+    Fix screen corruption on secondary GPU
+    
+    [why]
+    On RHEL9+, xorg-server.pc shows that the Xorg no longer depends on dri,
+    and dri.pc provides "/opt/amdgpu/include" path for pkg-config, this
+    cause pkg-config no longer output "-I/opt/amdgpu/include", consequently
+    the configure can't find gbm.h and HAVE_GBM_BO_USE_LINEAR is not
+    declared, that cause the corruption.
+    
+    [how]
+    Since the gbm.pc also provides the "/opt/amdgpu/include" path, in module
+    dependence checking, GBM_CFLAGS get this path, so just explicitly add
+    GBM_CFLAGS into CPPFLAGS can fix this issue.
+    
+    Signed-off-by: tiancyin <tianci....@amd.com>
+
+commit a3a012b649eb9b3066abefe163a72854514792fa
+Author: Kai-Heng Feng <kai.heng.f...@canonical.com>
+Date:   Mon Aug 8 10:49:11 2022 +0800
+
+    Initialize present extension for GPU screen
+    
+    Some laptops have the external outputs routed to dGPU, when the external
+    output over dGPU is the only display in reverse prime mode, we need
+    present extension so fake CRTC won't be used.
+
+commit f3f57a58342c286808220bdbe6dc6bb7098763b9
+Author: Lukasz Spintzyk <lukasz.spint...@displaylink.com>
+Date:   Fri Jun 11 14:54:35 2021 +0200
+
+    Do not consider disabled crtc anymore when looking for xf86crtc covering 
drawable.
+    
+    This is commit is removing obsolete switch done in
+    
+    xf86-video-ati at sha 61d0aec40e2521488c2fe43e7a6823e5c87d94d7:  video: 
add option to include disabled CRTCs in best CRTC search
+    This is not required anymore as with commit done in
+    xorg-server at sha 5c5c1b77982a9af7279a90bc3c2be48adaa9c778:     present: 
Add Present extension
+    That in case of lack of crtc is using fake_crtc with render 1Hz frequency
+    
+    When consider_disabled is removed then amdgpu_pick_best_crtc is doing the 
same what rr_crtc_covering_box is doing
+    so it can be reimplemented to reuse that function.
+    
+    Signed-off-by: Łukasz Spintzyk <lukasz.spint...@synaptics.com>
+    Signed-off-by: Shashank Sharma <contactshashanksha...@gmail.com>
+    Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
+
+commit e39a3ee07c9dea73b0452b71b1ef633b6cd6f389
+Author: Lukasz Spintzyk <lukasz.spint...@displaylink.com>
+Date:   Mon Jun 21 11:41:40 2021 +0200
+
+    Prefer crtc of primary output for synchronization when screen has to crtcs 
with the same coverage
+    
+    This is adjusting randr_crtc_covering_drawable to cover scenario fixed in
+    9151f3b1c2ebcc34e63195888ba696f2183ba5e2
+    
+    Signed-off-by: Łukasz Spintzyk <lukasz.spint...@synaptics.com>
+    Signed-off-by: Shashank Sharma <contactshashanksha...@gmail.com>
+    Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
+
+commit 92fb43b8e96bbda77e03b7313ccbba75a304a1b1
+Author: Lukasz Spintzyk <lukasz.spint...@displaylink.com>
+Date:   Fri Jun 11 08:52:58 2021 +0200
+
+    Use randr_crtc_covering_drawable used in modesetting
+    
+    Use implementation from modesetting driver that is fixing issue:
+    https://gitlab.freedesktop.org/xorg/xserver/-/issues/1028
+    
+    Instead of returning primary crtc as fallback we can now find and return 
crtc that belongs to secondary outputs.
+    
+    v2:
+      restore original naming scheme for amdgpu_crtc_is_enabled, 
amdgpu_box_intersect, amdgpu_box_area functions
+    
+    Signed-off-by: Łukasz Spintzyk <lukasz.spint...@synaptics.com>
+    Signed-off-by: Emilia Majewska <emilia.majew...@synaptics.com>
+    Signed-off-by: Shashank Sharma <contactshashanksha...@gmail.com>
+    Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
+
+commit 57740ae2357ca7b973f78be31327365aaa60ed41
+Author: Łukasz Spintzyk <lukasz.spint...@synaptics.com>
+Date:   Tue Jun 22 07:36:42 2021 +0200
+
+    amdgpu: fixup driver for new X server ABI
+    
+    Signed-off-by: Łukasz Spintzyk <lukasz.spint...@synaptics.com>
+    Signed-off-by: Shashank Sharma <contactshashanksha...@gmail.com>
+    Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
+
+commit 89b3eb9fffe2ead4257eee6d65accbac135aedc9
+Author: Alan Coopersmith <alan.coopersm...@oracle.com>
+Date:   Sat Feb 19 12:07:46 2022 -0800
+
+    Update URLs to reflect gitlab migration
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
+
 commit 533bd30ceaa373788b3d0bfd4d486f0f1c624d0c
 Author: Shashank Sharma <shashank.sha...@amd.com>
 Date:   Tue Feb 22 16:25:01 2022 +0100
Index: README.md
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/README.md,v
retrieving revision 1.2
diff -u -p -u -r1.2 README.md
--- README.md   3 Aug 2021 05:35:52 -0000       1.2
+++ README.md   27 Feb 2023 20:09:46 -0000
@@ -4,15 +4,11 @@ xf86-video-amdgpu - Xorg driver for AMD 
 Questions regarding this software should be directed at the
 [amd-gfx mailing list](https://lists.freedesktop.org/mailman/listinfo/amd-gfx).
 
-Please
-[submit bug 
reports](https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu)
-to the Xorg bugzilla.
-
 The
 [main development code 
repository](https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu)
 can be found at FreeDesktop Gitlab.
 
-Please use merge requests for patch submission.
+Please submit bug reports there and use merge requests for patch submission.
 
 See the X.org wiki for
 [further patch submission 
instructions](https://www.x.org/wiki/Development/Documentation/SubmittingPatches)
Index: configure
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/configure,v
retrieving revision 1.5
diff -u -p -u -r1.5 configure
--- configure   8 Mar 2022 03:56:50 -0000       1.5
+++ configure   27 Feb 2023 20:09:46 -0000
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for xf86-video-amdgpu 22.0.0.
+# Generated by GNU Autoconf 2.69 for xf86-video-amdgpu 23.0.0.
 #
-# Report bugs to 
<https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu>.
+# Report bugs to 
<https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/issues>.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -275,7 +275,7 @@ fi
     $as_echo "$0: be upgraded to zsh 4.3.4 or later."
   else
     $as_echo "$0: Please tell bug-autoc...@gnu.org and
-$0: 
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu
+$0: https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/issues
 $0: about your system, including any error possibly output
 $0: before this message. Then install a modern shell, or
 $0: manually run the script under such a shell if you do
@@ -591,9 +591,9 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='xf86-video-amdgpu'
 PACKAGE_TARNAME='xf86-video-amdgpu'
-PACKAGE_VERSION='22.0.0'
-PACKAGE_STRING='xf86-video-amdgpu 22.0.0'
-PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu'
+PACKAGE_VERSION='23.0.0'
+PACKAGE_STRING='xf86-video-amdgpu 23.0.0'
+PACKAGE_BUGREPORT='https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/issues'
 PACKAGE_URL=''
 
 ac_unique_file="Makefile.am"
@@ -1405,7 +1405,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures xf86-video-amdgpu 22.0.0 to adapt to many kinds of 
systems.
+\`configure' configures xf86-video-amdgpu 23.0.0 to adapt to many kinds of 
systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1477,7 +1477,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of xf86-video-amdgpu 22.0.0:";;
+     short | recursive ) echo "Configuration of xf86-video-amdgpu 23.0.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1571,7 +1571,7 @@ Some influential environment variables:
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
-Report bugs to 
<https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu>.
+Report bugs to 
<https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/issues>.
 _ACEOF
 ac_status=$?
 fi
@@ -1634,7 +1634,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-xf86-video-amdgpu configure 22.0.0
+xf86-video-amdgpu configure 23.0.0
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2025,9 +2025,9 @@ $as_echo "$as_me: WARNING: $2: see the A
 $as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" 
>&2;}
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the 
compiler's result" >&5
 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-( $as_echo "## 
----------------------------------------------------------------------------------------------
 ##
-## Report this to 
https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu 
##
-## 
----------------------------------------------------------------------------------------------
 ##"
+( $as_echo "## 
------------------------------------------------------------------------------------
 ##
+## Report this to 
https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/issues ##
+## 
------------------------------------------------------------------------------------
 ##"
      ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
@@ -2049,7 +2049,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by xf86-video-amdgpu $as_me 22.0.0, which was
+It was created by xf86-video-amdgpu $as_me 23.0.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2881,7 +2881,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='xf86-video-amdgpu'
- VERSION='22.0.0'
+ VERSION='23.0.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -18882,7 +18882,7 @@ fi
 
 
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
+CPPFLAGS="$CPPFLAGS $XORG_CFLAGS $GBM_CFLAGS"
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to include GLAMOR 
support" >&5
 $as_echo_n "checking whether to include GLAMOR support... " >&6; }
@@ -20024,7 +20024,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_wri
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by xf86-video-amdgpu $as_me 22.0.0, which was
+This file was extended by xf86-video-amdgpu $as_me 23.0.0, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20084,13 +20084,13 @@ $config_headers
 Configuration commands:
 $config_commands
 
-Report bugs to 
<https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu>."
+Report bugs to 
<https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/issues>."
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; 
s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-xf86-video-amdgpu config.status 22.0.0
+xf86-video-amdgpu config.status 23.0.0
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
Index: configure.ac
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/configure.ac,v
retrieving revision 1.4
diff -u -p -u -r1.4 configure.ac
--- configure.ac        8 Mar 2022 03:56:50 -0000       1.4
+++ configure.ac        27 Feb 2023 20:09:46 -0000
@@ -23,8 +23,8 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-amdgpu],
-        [22.0.0],
-        
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu],
+        [23.0.0],
+        
[https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/issues],
         [xf86-video-amdgpu])
 
 AC_CONFIG_SRCDIR([Makefile.am])
@@ -110,7 +110,7 @@ fi
 AM_CONDITIONAL(LIBUDEV, test x$LIBUDEV = xyes)
 
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
+CPPFLAGS="$CPPFLAGS $XORG_CFLAGS $GBM_CFLAGS"
 
 AC_MSG_CHECKING([whether to include GLAMOR support])
 AC_ARG_ENABLE(glamor,
Index: conf/10-amdgpu.conf
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/conf/10-amdgpu.conf,v
retrieving revision 1.1.1.1
diff -u -p -u -r1.1.1.1 10-amdgpu.conf
--- conf/10-amdgpu.conf 16 Apr 2019 01:49:28 -0000      1.1.1.1
+++ conf/10-amdgpu.conf 27 Feb 2023 20:09:46 -0000
@@ -2,4 +2,5 @@ Section "OutputClass"
        Identifier "AMDgpu"
        MatchDriver "amdgpu"
        Driver "amdgpu"
-EndSection
\ No newline at end of file
+       Option "HotplugDriver" "amdgpu"
+EndSection
Index: man/amdgpu.man
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/man/amdgpu.man,v
retrieving revision 1.3
diff -u -p -u -r1.3 amdgpu.man
--- man/amdgpu.man      8 Mar 2022 03:56:50 -0000       1.3
+++ man/amdgpu.man      27 Feb 2023 20:09:46 -0000
@@ -140,7 +140,7 @@ https://www.x.org/wiki/radeon
 .IP " 2." 4
 Overview about amdgpu development code:
 .RS 4
-https://cgit.freedesktop.org/xorg/driver/xf86-video-amdgpu/
+https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu
 .RE
 .IP " 3." 4
 Mailing list:
@@ -153,14 +153,14 @@ IRC channel:
 #radeon on irc.freenode.net
 .RE
 .IP " 5." 4
-Query the bugtracker for amdgpu bugs:
+The bugtracker for amdgpu bugs:
 .RS 4
-https://bugs.freedesktop.org/query.cgi?product=xorg&component=Driver/AMDgpu
+https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/issues
 .RE
 .IP " 6." 4
-Submit bugs & patches:
+Submit merge requests:
 .RS 4
-https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/AMDgpu
+https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/merge_requests
 .RE
 
 .SH AUTHORS
Index: src/amdgpu_dri2.c
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/src/amdgpu_dri2.c,v
retrieving revision 1.2
diff -u -p -u -r1.2 amdgpu_dri2.c
--- src/amdgpu_dri2.c   26 Oct 2019 09:36:38 -0000      1.2
+++ src/amdgpu_dri2.c   27 Feb 2023 20:09:46 -0000
@@ -417,8 +417,7 @@ static
 xf86CrtcPtr amdgpu_dri2_drawable_crtc(DrawablePtr pDraw)
 {
        ScreenPtr pScreen = pDraw->pScreen;
-       ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
-       xf86CrtcPtr crtc = amdgpu_pick_best_crtc(pScrn, TRUE,
+       xf86CrtcPtr crtc = amdgpu_pick_best_crtc(pScreen,
                                                 pDraw->x, pDraw->x + 
pDraw->width,
                                                 pDraw->y, pDraw->y + 
pDraw->height);
 
Index: src/amdgpu_drv.h
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/src/amdgpu_drv.h,v
retrieving revision 1.3
diff -u -p -u -r1.3 amdgpu_drv.h
--- src/amdgpu_drv.h    8 Mar 2022 03:56:50 -0000       1.3
+++ src/amdgpu_drv.h    27 Feb 2023 20:09:46 -0000
@@ -372,9 +372,9 @@ extern void amdgpu_sync_close(ScreenPtr 
 /* amdgpu_video.c */
 extern void AMDGPUInitVideo(ScreenPtr pScreen);
 extern void AMDGPUResetVideo(ScrnInfoPtr pScrn);
-extern xf86CrtcPtr amdgpu_pick_best_crtc(ScrnInfoPtr pScrn,
-                                        Bool consider_disabled,
+extern xf86CrtcPtr amdgpu_pick_best_crtc(ScreenPtr pScreen,
                                         int x1, int x2, int y1, int y2);
+extern RRCrtcPtr amdgpu_randr_crtc_covering_drawable(DrawablePtr pDraw);
 
 extern AMDGPUEntPtr AMDGPUEntPriv(ScrnInfoPtr pScrn);
 
Index: src/amdgpu_kms.c
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/src/amdgpu_kms.c,v
retrieving revision 1.5
diff -u -p -u -r1.5 amdgpu_kms.c
--- src/amdgpu_kms.c    5 Dec 2022 16:41:17 -0000       1.5
+++ src/amdgpu_kms.c    27 Feb 2023 20:09:46 -0000
@@ -1503,6 +1503,25 @@ static Bool AMDGPUCreateWindow_oneshot(W
        return ret;
 }
 
+static void amdgpu_determine_cursor_size(int fd, AMDGPUInfoPtr info)
+{
+       uint64_t value;
+
+       if (drmGetCap(fd, DRM_CAP_CURSOR_WIDTH, &value) == 0)
+               info->cursor_w = value;
+       else if (info->family < AMDGPU_FAMILY_CI)
+               info->cursor_w = CURSOR_WIDTH;
+       else
+               info->cursor_w = CURSOR_WIDTH_CIK;
+
+       if (drmGetCap(fd, DRM_CAP_CURSOR_HEIGHT, &value) == 0)
+               info->cursor_h = value;
+       else if (info->family < AMDGPU_FAMILY_CI)
+               info->cursor_h = CURSOR_HEIGHT;
+       else
+               info->cursor_h = CURSOR_HEIGHT_CIK;
+}
+
 /* When the root window is mapped, set the initial modes */
 void AMDGPUWindowExposures_oneshot(WindowPtr pWin, RegionPtr pRegion
 #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,16,99,901,0)
@@ -1686,13 +1705,7 @@ Bool AMDGPUPreInit_KMS(ScrnInfoPtr pScrn
        else
                pAMDGPUEnt->HasCRTC2 = TRUE;
 
-       if (info->family < AMDGPU_FAMILY_CI) {
-               info->cursor_w = CURSOR_WIDTH;
-               info->cursor_h = CURSOR_HEIGHT;
-       } else {
-               info->cursor_w = CURSOR_WIDTH_CIK;
-               info->cursor_h = CURSOR_HEIGHT_CIK;
-       }
+       amdgpu_determine_cursor_size(pAMDGPUEnt->fd, info);
 
        amdgpu_query_heap_size(pAMDGPUEnt->pDev, AMDGPU_GEM_DOMAIN_GTT,
                                &heap_size, &max_allocation);
@@ -2048,35 +2061,33 @@ Bool AMDGPUScreenInit_KMS(ScreenPtr pScr
        }
 #endif
 
-       if (!pScreen->isGPU) {
-               if (xorgGetVersion() >= XORG_VERSION_NUMERIC(1,18,3,0,0))
-                       value = info->use_glamor;
-               else
-                       value = FALSE;
-               from = X_DEFAULT;
-
-               if (info->use_glamor) {
-                       if (xf86GetOptValBool(info->Options, OPTION_DRI3, 
&value))
-                               from = X_CONFIG;
-
-                       if (xf86GetOptValInteger(info->Options, OPTION_DRI, 
&driLevel) &&
-                           (driLevel == 2 || driLevel == 3)) {
-                               from = X_CONFIG;
-                               value = driLevel == 3;
-                       }
-               }
+       if (xorgGetVersion() >= XORG_VERSION_NUMERIC(1,18,3,0,0))
+               value = info->use_glamor;
+       else
+               value = FALSE;
+       from = X_DEFAULT;
 
-               if (value) {
-                       value = amdgpu_sync_init(pScreen) &&
-                               amdgpu_present_screen_init(pScreen) &&
-                               amdgpu_dri3_screen_init(pScreen);
+       if (info->use_glamor) {
+               if (xf86GetOptValBool(info->Options, OPTION_DRI3, &value))
+                       from = X_CONFIG;
 
-                       if (!value)
-                               from = X_WARNING;
+               if (xf86GetOptValInteger(info->Options, OPTION_DRI, &driLevel) 
&&
+                               (driLevel == 2 || driLevel == 3)) {
+                       from = X_CONFIG;
+                       value = driLevel == 3;
                }
+       }
+
+       if (value) {
+               value = amdgpu_sync_init(pScreen) &&
+                       amdgpu_present_screen_init(pScreen) &&
+                       amdgpu_dri3_screen_init(pScreen);
 
-               xf86DrvMsg(pScrn->scrnIndex, from, "DRI3 %sabled\n", value ? 
"en" : "dis");
+               if (!value)
+                       from = X_WARNING;
        }
+
+       xf86DrvMsg(pScrn->scrnIndex, from, "DRI3 %sabled\n", value ? "en" : 
"dis");
 
        pScrn->vtSema = TRUE;
        xf86SetBackingStore(pScreen);
Index: src/amdgpu_present.c
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/src/amdgpu_present.c,v
retrieving revision 1.3
diff -u -p -u -r1.3 amdgpu_present.c
--- src/amdgpu_present.c        8 Mar 2022 03:56:50 -0000       1.3
+++ src/amdgpu_present.c        27 Feb 2023 20:09:46 -0000
@@ -58,21 +58,7 @@ struct amdgpu_present_vblank_event {
 static RRCrtcPtr
 amdgpu_present_get_crtc(WindowPtr window)
 {
-       ScreenPtr screen = window->drawable.pScreen;
-       ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
-       xf86CrtcPtr crtc;
-       RRCrtcPtr randr_crtc = NULL;
-
-       crtc = amdgpu_pick_best_crtc(pScrn, FALSE,
-                                    window->drawable.x,
-                                    window->drawable.x + 
window->drawable.width,
-                                    window->drawable.y,
-                                    window->drawable.y + 
window->drawable.height);
-
-       if (crtc)
-               randr_crtc = crtc->randr_crtc;
-
-       return randr_crtc;
+       return amdgpu_randr_crtc_covering_drawable(&window->drawable);
 }
 
 static int
Index: src/amdgpu_video.c
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/src/amdgpu_video.c,v
retrieving revision 1.1.1.1
diff -u -p -u -r1.1.1.1 amdgpu_video.c
--- src/amdgpu_video.c  16 Apr 2019 01:49:36 -0000      1.1.1.1
+++ src/amdgpu_video.c  27 Feb 2023 20:09:46 -0000
@@ -39,89 +39,180 @@ static void amdgpu_box_intersect(BoxPtr 
 {
        dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1;
        dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2;
+       if (dest->x1 >= dest->x2) {
+               dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+               return;
+       }
+
        dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1;
        dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
-
-       if (dest->x1 >= dest->x2 || dest->y1 >= dest->y2)
+       if (dest->y1 >= dest->y2)
                dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
 }
 
-static void amdgpu_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box)
+static int amdgpu_box_area(BoxPtr box)
+{
+       return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1);
+}
+
+Bool
+amdgpu_crtc_is_enabled(xf86CrtcPtr crtc)
+{
+       drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+       return crtc->enabled && drmmode_crtc->dpms_mode == DPMSModeOn;
+}
+
+static void amdgpu_crtc_box(RRCrtcPtr crtc, BoxPtr crtc_box)
 {
-       if (crtc->enabled) {
+       if (crtc->mode) {
                crtc_box->x1 = crtc->x;
-               crtc_box->x2 =
-                   crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
                crtc_box->y1 = crtc->y;
-               crtc_box->y2 =
-                   crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
+               switch (crtc->rotation) {
+               case RR_Rotate_0:
+               case RR_Rotate_180:
+               default:
+                       crtc_box->x2 = crtc->x + crtc->mode->mode.width;
+                       crtc_box->y2 = crtc->y + crtc->mode->mode.height;
+                       break;
+               case RR_Rotate_90:
+               case RR_Rotate_270:
+                       crtc_box->x2 = crtc->x + crtc->mode->mode.height;
+                       crtc_box->y2 = crtc->y + crtc->mode->mode.width;
+                       break;
+               }
        } else
                crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0;
 }
 
-static int amdgpu_box_area(BoxPtr box)
+static Bool amdgpu_crtc_on(RRCrtcPtr crtc, Bool crtc_is_xf86_hint)
 {
-       return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1);
+       if (!crtc) {
+               return FALSE;
+       }
+       if (crtc_is_xf86_hint && crtc->devPrivate) {
+               return amdgpu_crtc_is_enabled(crtc->devPrivate);
+       } else {
+               return !!crtc->mode;
+       }
 }
 
-Bool amdgpu_crtc_is_enabled(xf86CrtcPtr crtc)
+/*
+ * Return the crtc covering 'box'. If two crtcs cover a portion of
+ * 'box', then prefer the crtc with greater coverage.
+ */
+static RRCrtcPtr
+amdgpu_crtc_covering_box(ScreenPtr pScreen, BoxPtr box, Bool 
screen_is_xf86_hint)
 {
-       drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-       return drmmode_crtc->dpms_mode == DPMSModeOn;
+       rrScrPrivPtr pScrPriv;
+       RRCrtcPtr crtc, best_crtc, primary_crtc;
+       int coverage, best_coverage;
+       int c;
+       BoxRec crtc_box, cover_box;
+       RROutputPtr primary_output;
+
+       best_crtc = NULL;
+       best_coverage = 0;
+       primary_crtc = NULL;
+       primary_output = NULL;
+
+       if (!dixPrivateKeyRegistered(rrPrivKey))
+               return NULL;
+
+       pScrPriv = rrGetScrPriv(pScreen);
+
+       if (!pScrPriv)
+               return NULL;
+
+       primary_output = RRFirstOutput(pScreen);
+       if (primary_output && primary_output->crtc)
+               primary_crtc = primary_output->crtc;
+
+       for (c = 0; c < pScrPriv->numCrtcs; c++) {
+               crtc = pScrPriv->crtcs[c];
+
+               /* If the CRTC is off, treat it as not covering */
+               if (!amdgpu_crtc_on(crtc, screen_is_xf86_hint))
+                       continue;
+
+               amdgpu_crtc_box(crtc, &crtc_box);
+               amdgpu_box_intersect(&cover_box, &crtc_box, box);
+               coverage = amdgpu_box_area(&cover_box);
+               if (coverage > best_coverage ||
+                  (crtc == primary_crtc && coverage == best_coverage)) {
+                       best_crtc = crtc;
+                       best_coverage = coverage;
+               }
+       }
+
+       return best_crtc;
+}
+
+#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(23, 0)
+static RRCrtcPtr
+amdgpu_crtc_covering_box_on_secondary(ScreenPtr pScreen, BoxPtr box)
+{
+       if (!pScreen->isGPU) {
+               ScreenPtr secondary;
+               RRCrtcPtr crtc = NULL;
+
+               xorg_list_for_each_entry(secondary, &pScreen->secondary_list, 
secondary_head) {
+                       if (!secondary->is_output_secondary)
+                               continue;
+
+                       crtc = amdgpu_crtc_covering_box(secondary, box, FALSE);
+                       if (crtc)
+                               return crtc;
+               }
+       }
+
+       return NULL;
+}
+#endif
+
+RRCrtcPtr
+amdgpu_randr_crtc_covering_drawable(DrawablePtr pDraw)
+{
+       ScreenPtr pScreen = pDraw->pScreen;
+       RRCrtcPtr crtc = NULL;
+       BoxRec box;
+
+       box.x1 = pDraw->x;
+       box.y1 = pDraw->y;
+       box.x2 = box.x1 + pDraw->width;
+       box.y2 = box.y1 + pDraw->height;
+
+       crtc = amdgpu_crtc_covering_box(pScreen, &box, TRUE);
+#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(23, 0)
+       if (!crtc) {
+               crtc = amdgpu_crtc_covering_box_on_secondary(pScreen, &box);
+       }
+#endif
+       return crtc;
 }
 
 xf86CrtcPtr
-amdgpu_pick_best_crtc(ScrnInfoPtr pScrn, Bool consider_disabled,
+amdgpu_pick_best_crtc(ScreenPtr pScreen,
                      int x1, int x2, int y1, int y2)
 {
-       xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-       int coverage, best_coverage, c, cd;
-       BoxRec box, crtc_box, cover_box;
-       RROutputPtr primary_output = NULL;
-       xf86CrtcPtr best_crtc = NULL, primary_crtc = NULL;
+       ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
        if (!pScrn->vtSema)
                return NULL;
 
+       RRCrtcPtr crtc = NULL;
+       BoxRec box;
+
        box.x1 = x1;
        box.x2 = x2;
        box.y1 = y1;
        box.y2 = y2;
-       best_coverage = 0;
 
-       /* Prefer the CRTC of the primary output */
-       if (dixPrivateKeyRegistered(rrPrivKey))
-       {
-               primary_output = RRFirstOutput(pScrn->pScreen);
+       crtc = amdgpu_crtc_covering_box(pScreen, &box, TRUE);
+       if (crtc) {
+               return crtc->devPrivate;
        }
-       if (primary_output && primary_output->crtc)
-               primary_crtc = primary_output->crtc->devPrivate;
-
-       /* first consider only enabled CRTCs
-        * then on second pass consider disabled ones
-        */
-       for (cd = 0; cd < (consider_disabled ? 2 : 1); cd++) {
-               for (c = 0; c < xf86_config->num_crtc; c++) {
-                       xf86CrtcPtr crtc = xf86_config->crtc[c];
-
-                       if (!cd && !amdgpu_crtc_is_enabled(crtc))
-                               continue;
-
-                       amdgpu_crtc_box(crtc, &crtc_box);
-                       amdgpu_box_intersect(&cover_box, &crtc_box, &box);
-                       coverage = amdgpu_box_area(&cover_box);
-                       if (coverage > best_coverage ||
-                           (coverage == best_coverage &&
-                            crtc == primary_crtc)) {
-                               best_crtc = crtc;
-                               best_coverage = coverage;
-                       }
-               }
-               if (best_crtc)
-                       break;
-       }
-
-       return best_crtc;
+       return NULL;
 }
 
 void AMDGPUInitVideo(ScreenPtr pScreen)
Index: src/compat-api.h
===================================================================
RCS file: /local/cvs/xenocara/driver/xf86-video-amdgpu/src/compat-api.h,v
retrieving revision 1.2
diff -u -p -u -r1.2 compat-api.h
--- src/compat-api.h    3 Aug 2021 05:35:52 -0000       1.2
+++ src/compat-api.h    27 Feb 2023 20:09:46 -0000
@@ -42,6 +42,9 @@
 #define current_primary current_master
 #define primary_pixmap master_pixmap
 #define secondary_dst slave_dst
+#define secondary_list slave_list
+#define secondary_head slave_head
+#define is_output_secondary is_output_slave
 #endif
 
 #endif

-- 
Matthieu Herrb

Reply via email to