This is workaround of firmware issue, and the change has no impact
on the legacy HW.
Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Thong Thai <thong.thai@amd.com>
Reviewed-by: James Zhu <James.Zhu@amd.com>
It is not used for VCN from VCN1, but VCN3 use it
for other feature, so clear it, because we don't
use the feature for now
Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Thong Thai <thong.thai@amd.com>
Reviewed-by: James Zhu <James.Zhu@amd.com>
VCN3.0 has its own set of internal regs
Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Thong Thai <thong.thai@amd.com>
Reviewed-by: James Zhu <James.Zhu@amd.com>
./xf86drm.c: In function 'drmNodeIsDRM':
../xf86drm.c:2825:7: error: "__FreeBSD__" is not defined [-Werror=undef]
#elif __FreeBSD__
^
../xf86drm.c: In function 'drmGetMinorNameForFD':
../xf86drm.c:2938:7: error: "__FreeBSD__" is not defined [-Werror=undef]
#elif __FreeBSD__
^
../xf86drm.c: In function 'drmParsePciBusInfo':
../xf86drm.c:3258:7: error: "__FreeBSD__" is not defined [-Werror=undef]
#elif __FreeBSD__
^
../xf86drm.c: In function 'drmParsePciDeviceInfo':
../xf86drm.c:3427:7: error: "__FreeBSD__" is not defined [-Werror=undef]
#elif __FreeBSD__
^
../xf86drm.c: In function 'drmGetDeviceNameFromFd2':
../xf86drm.c:4305:7: error: "__FreeBSD__" is not defined [-Werror=undef]
#elif __FreeBSD__
^
Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
This option finds all connected connector and then sets its preferred
mode on it. If no preferred mode is available, first mode is used.
This option must be set w/o any mode or plane.
This allows for a quick test on all connected outputs.
Loosely based on the work by Ezequiel Garcia <ezequiel@collabora.com>
Changes since Ezequiel's work:
- implement atomic codepath
- set all connectors
- pick correct crtc
- don't set -r by default
- nearly identical output in atomic and non-atomic codepaths
v2:
- Use the crtc->crtc_id, instead of the plane's current crtc_id
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Makes the code a tiny bit more symmetrical.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
The very final drmModeAtommicCommit tears down the existing mode/plane
setup. Following it we clean up other misc state laying around.
Chances are that it will not fail, but in the extremely unlikely case it
does, there's nothing one can do.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Move the hunk of code into a function, making the overall flow easier to
follow and providing some symmetry to the non-atomic path.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
The function is closely related to pipe_find_crtc_and_mode() so we might
as well keep them together.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Move the function above set_mode, since we'll be using it from there as
of next commit.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Instead of duplicating the exact same code across the two functions,
fold them into one.
For some strange reason git diff may show atomic_clear_mode() as changed
The function in untouched, despite the misleading output.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Makes the code shorter and easier to read.
Currently if the user has not set the crtc_id, we fetch the crtc yet do
not "bother" setting the id - do so.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Let's make the code shorter, this avoid crashes (when drmModeGetCrtc()
fails) by using a couple of helpers. As get_resources() considers the
drmModeGetCrtc() fail non-fatal, we might as well handle it properly.
v2: Add a comment above the unreachable abort() (Eze)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
There's no point in keeping these around since we already fetch the
complete data set. Add respective count_ variables and greatly simplify
the existing code.
Extra brownie points for:
- using the inverse order in free_resources()
- don't memory leak the connector properties
- free the properties themselves, instead of only the objects
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Flesh out the bo_create + drmModeAddFB2 dance into a helper and use it.
Currently we're duplicating that in 4 places, many of which leaking et
al.
As a bonus point this highlights that the atomic_set_plane() seems tad
buggy. That'll be fixed with separate commit.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Don't bother opening the device node, if the args combination is invalid
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
The two functions have been stubs for ages. The alluded generic ioctls
never came to be, assumingly because all new drivers support those.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
Freedreno uses VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE that was
introduced in Valgrind 3.10.0
Raspbian Buster includes Valgrind 3.7.0, so when valgrind is installed
as freedreno is build by default the build becomes broken. So lets
require 3.10 to enable valgrind when freedreno is built.
v2: Keep the arguments listed in the same order (Emil Velikov)
Closes: https://gitlab.freedesktop.org/mesa/drm/-/issues/37
Signed-off-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Since we now always returns the /dev/dri/ node for
drmGet<nodetype>DeviceNameFromFd, be consistant with the names returned
in drmGetDeviceNameFromFd.
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Fix the FreeBSD variant by getting the node type represented by fd to deduce
the target minor name.
We then return the full /dev/dri/<minorname><id> version.
Fix: #41
Fixes: 6818a50b12
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
This is similar to b81d44d587d1706d5c7568e539340632a748782b: the
DRM_RDWR flag is needed for mmap to work.
Signed-off-by: Nicholas Bishop <nicholasbishop@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
The sed was incorrectly modifying e.g. "nicholasbishop" to
"nicholasbop". The updated pattern will only match `.sh` at the end of
the string.
Signed-off-by: Nicholas Bishop <nicholasbishop@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Renoir is the same family as Raven, but it's with VCN2.0,
so it has to use VCN2.0 reg set
Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-By: Thong Thai <thong.thai@amd.com>
Currently the code expects that the device found at
/sys/char/$maj:$min/device for USB devices is a "usb_device". However,
at least for some devices, such as for the udl driver, they are instead
a "usb_interface".
A usb_interface is a child of the usb_device we're interested in, so we
walk up one in the /sys path to get there.
For example, with a USB device I have, trimmed to show the relevant
information:
```
$ udevadm info /dev/dri/card1
P: /devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4:1.0/drm/card1
E: DEVTYPE=drm_minor
$ udevadm info /sys/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4/1-4:1.0
E: DEVTYPE=usb_interface
E: DRIVER=udl
$ udevadm info /sys/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-4
E: DEVTYPE=usb_device
E: DRIVER=usb
E: BUSNUM=001
E: DEVNUM=009
```
Signed-off-by: Scott Anderson <scott@anderso.nz>
This fixes bug in drmParseSubsystemType() that cases situation when
subsequent call to readlink() from get_subsystem_type() will result in
EACCESS.
Signed-off-by: Mikhail Golubev <mikhail.golubev@opensynergy.com>
Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Acked-by: Alex Deucher alexander.deucher@amd.com
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Just like the other tests (tools really) install drmdevice. It is a
simple tool which is useful for basic check/testing.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Eric Engestrom <eric@engestrom.ch>
FreeBSD also use (int, unsigned long int, ...) like GLIBC.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
The FreeBSD kernel expose a pseudo-device /dev/pci to obtain information
about present PCI device.
Uee the PCIOCGETCONF ioctl on this device to look up the desired device
information.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
The FreeBSD drm driver expose a sysctl hw.dri.%d.busid which contain
the busid.
Use this sysctl to parse the busid information based on the major/minor
that allow us to implement FreeBSD support for drmParsePciBusInfo.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
FreeBSD only support up to 10 GPUs not 16.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
The FreeBSD variant of drmGetDeviceNameFromFd can already handle
the different node type so just call it.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
FreeBSD have some support for DRM on !PCI device but no code is currently
upstream. Default to PCI for now.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Use the FreeBSD variant function to obtain the minor name and the
device node.
Return the correct path based on where the node is (drm/ versus dri/).
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Get the major/minor via fstat and after checking that this is a drm node
construct the full device node name using devname.
Note that we should be able to use fdevname to avoid calling fstat + devname
but for some reason it doesn't work on drm node (probably due to how the device
node are created in the linux compat code for drm on FreeBSD).
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Resolve the minor type based on the device node path.
The minor type is either in /dev/drm/X where X is the type or
in a Linux-compatible device node in /dev/dri/
This means we need the major number on FreeBSD so add it to the function
arguments.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
FreeBSD devfs only provides on the fly generated major/minor.
The major number is irrelevant for FreeBSD so remove the special case.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
FreeBSD devfs have on the gly generated major minor so we cannot use them
to test if the device is a drm node.
Instead get the devfs node name and test if it is in a subdirectory "drm/"
or "dri/".
Historycally DRM device on FreeBSD are created in /dev/drm/ and link are
present in /dev/dri/ for compatibility reason.
Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
The header is not required on Linux, and is in fact deprecated in glibc 2.30+
Reported-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Niclas Zeising <zeising@daemonic.se>
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Tested-by: Niclas Zeising <zeising@daemonc.se>