Commit Graph

192 Commits (3bede5dbbcd307d9fb675562f780bf9525efb3d4)

Author SHA1 Message Date
Eleni Maria Stea 4caec56fb8 modeprint, modetest, proptest: cast __u64 to uint64_t
It seems that __u64 values are defined differently across systems. In
glibc it's defined as unsigned long, in Linux kernel headers
(int-ll64.h) as unsigned long long, and on FreeBSD as uint64_t so it
matches glibc. A temporal solution is to cast all __u64 values to
uint64_t to avoid warnings on Linux, but ideally we'd like a better fix
in the future.

See also: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/212
for discussion.

Signed-off-by: Eleni Maria Stea <elene.mst@gmail.com>
2022-05-09 15:53:56 +03:00
Luigi Santivetti e641e2a632 xf86drm: add iterator API for DRM/KMS IN_FORMATS blobs
Add support for parsing IN_FORMATS property blobs. Providing libdrm
with this functionality helps to standardise how user-space reads
kernel blobs and decreases duplication on the client side.

drmModeFormatModifierBlobIterNext() allows the caller to view
formats and associated modifiers given a valid property blob.
An example is available inside the libdrm unit test, modetest.c.

Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
2021-11-08 16:20:04 +00:00
Alex Richardson fda3d0010f Fix -Werror=format build errors on FreeBSD
On 64-bit FreeBSD targets uint64_t is generally defined as `unsigned long`
and not `unsigned long long`. Use the PRI macros to fix -Wformat.

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Reviewed-by: Simon Ser <contact@emersion.fr>
2021-11-02 10:44:30 +00:00
ZhiJie.Zhang d201a41d1a tests/modetest: get cursor width and height by drmGetCap
Should get cursor width and height by drmGetCap.

Signed-off-by: ZhiJie.Zhang <zhangzhijie@loongson.cn>
2021-09-02 09:26:17 +00:00
Marius Vlad 67e911977f xf86drm: Add a human readable representation for format modifiers
Introduces two new methods to retrieve a human readable representation of a
format modifier:

drmGetFormatModifierName() - returns a format modifier as a string,
from a token modifier
drmGetFormatModifierVendor() - returns the vendor as a string, from a
token modifier

and the fourcc_mod_get_vendor macro that returns the vendor.

New format modifiers added in drm_fourcc.h uapi kernel header should be
sync'ed up with libdrm and should include a human readable
representation for that format modifier, in order to display it
correctly as a string.

That happens with the help of a python script that reads up drm_fourcc
header file and outputs a static table comprised of token modifiers
alongside a vendor table (Suggested-by Simon Ser <contact@emersion.fr>).

The reason for doing it in libdrm is to have a unified place instead of each
user of libdrm having a way to keep track of the format modifiers.

With this patch, modetest has also been modified to make use of it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2021-06-22 11:16:04 +00:00
Nicolas Caramelli 1a2b1a6cac tests/modetest: remove bracket in dump_connectors()
Signed-off-by: Nicolas Caramelli <caramelli.devel@gmail.com>
2020-12-11 16:35:20 +00:00
Emil Velikov bf602a2d67 modetest: Add a new "-r" option to set a default mode
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>
2020-05-19 21:09:35 +01:00
Emil Velikov a04c8abb86 modetest: reorder atomic path alike the non-atomic
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>
2020-05-19 21:09:35 +01:00
Emil Velikov e341176d9f modetest: don't error out of final AtomicCommit
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>
2020-05-19 21:09:35 +01:00
Emil Velikov 3d88c993a4 modetest: factor out atomic pageflip test
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>
2020-05-19 21:09:35 +01:00
Emil Velikov d928cd803a modetest: push pipe_resolve_connectors() to set_mode
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>
2020-05-19 21:09:35 +01:00
Emil Velikov 3b9585d88e modetest: move pipe_resolve_connectors() further up
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>
2020-05-19 21:09:35 +01:00
Emil Velikov bdb9b82cf7 modetest: unify {,atomic_}set_mode()
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>
2020-05-19 21:09:35 +01:00
Emil Velikov 544fab624d modetest: get the crtc_id from the pipe_arg
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>
2020-05-19 21:09:35 +01:00
Emil Velikov 336c04220c modetest: introduce and use get_crtc_by_id() and get_crtc_mask()
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>
2020-05-19 21:09:14 +01:00
Emil Velikov ef58af6dfc modetest: close the device on exit
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
2020-05-19 21:04:01 +01:00
Emil Velikov 53fde76ce3 modetest: remove drmMode{,Plane}Res
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>
2020-05-19 21:03:52 +01:00
Emil Velikov 823669c6c0 modetest: add and use bo_fb_create() helper
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>
2020-05-19 21:03:41 +01:00
Emil Velikov 900ed60848 modetest: set atomic cap, _only_ when needed
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
2020-05-19 21:03:32 +01:00
Emil Velikov 69f25d6a29 modetest: move basic args check before open()
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>
2020-05-19 21:03:27 +01:00
Emil Velikov 24c0c44c8d modetest: remove cursor/page_flipping_supported stubs
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>
2020-05-19 21:03:18 +01:00
Emil Velikov 9ffcbf5cd9 modetest: simplify "dump all" logic
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Ezequiel Garcia <ezequiel@collabora.com>
2020-05-19 21:02:45 +01:00
Eric Engestrom 074947ee4b meson: always define whether headers exist
Combined with -Wundef (added in 75758d2ccf & enforced in ba17673eed),
this provides absolute safety against #ifdef typos.

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2020-01-23 17:00:12 +00:00
Ezequiel Garcia 07d48a4c00 modetest: Fix segmentation fault
When a mode is set with just a connector "-s foo",
we get a nasty segmentation fault. Fix it.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2020-01-21 17:56:23 +00:00
John Stultz 899da0f486 libdrm: modetest: Allow selecting modes by index
Often there are many similar modes, which cannot be selected
via modetest due to its simple string matching.

This change adds a mode index in the display output, which can
then be used to specify a specific modeline to be set.

Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: Rob Clark <robdclark@chromium.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: John Stultz <john.stultz@linaro.org>
[emil: rebase]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
2020-01-21 17:56:23 +00:00
Devarsh Thakkar 7f82714522 modetest: Use floating vrefresh while dumping mode
Add function to derive floating value of vertical
refresh rate from drm mode using pixel clock,
horizontal total size and vertical total size.

Use this function to find suitable mode having vrefresh
value which is matching with user provided vrefresh value.

If user doesn't provide any vrefresh value in args then
update vertical refresh rate value in pipe args using this
function.

Also use this function for printing floating vrefresh while
dumping all available modes.

This will give more accurate picture to user for available modes
differentiated by floating vertical refresh rate and help user
select more appropriate mode using suitable refresh rate value.

V4:
1) While setting mode, print mode name and vrefresh using struct
   drmModeModeInfo instead of struct pipe_args.
2) Revert back to using a float value instead of float *
   for vrefresh arg in connector_find_mode().

V3:
1) Change name of function used to derive refresh rate.

V2:
1) Don't use inline function for deriving refresh rate from mode.
2) If requested mode not found, print refresh rate only
   if user had provided it in args.

Signed-off-by: Devarsh Thakkar <devarsh.thakkar@xilinx.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-12-11 17:47:31 +02:00
Devarsh Thakkar a2d588fe12 modetest: Add support for setting mode having floating vertical refresh rate
For the scenario where user may require to modeset with a mode
supporting a fractional value for vertical refresh-rate,
appropriate mode can be selected by searching for mode
having matching fractional vertical refresh rate using
below equation.

vrefresh = (1000 * pixel clock) / (htotal * vtotal) Hz.

We do this way since driver doesn't return float value of vrefresh
as it use int for vrefresh in struct drm_mode_info, but we can derive
the actual value using pixel clock, horizontal total size and
vertical total size values.

So for e.g. if user want to select mode having 59.94 Hz as refresh rate
then with this patch it be can done as shown in below command,
given there is an appropriate mode is available :

modetest -M xlnx -s 39:1920x1080-59.94@BG24 -v

NOTE: Above command was tested on xilinx DRM driver with DP
monitor which was supporting mode having 59.94 Hz refresh rate.

V2: Update commit message
V3: Update with below changes as per review comments :
  1) Use epsilon for vrefresh comparison
  2) Use implicit type-casting wherever possible
V4: Keep patch version history on main commit message

Signed-off-by: Devarsh Thakkar <devarsh.thakkar@xilinx.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2019-11-25 16:13:43 +02:00
Eric Engestrom fc933651b1 Revert "Revert "libdrm: remove autotools support""
The external tooling issue has been fixed, so we can delete autotools
again :)
2019-10-18 18:05:45 +01:00
Marek Olšák 51e3bb5665 Revert "libdrm: remove autotools support"
This reverts commit f057dc91e9.
2019-10-16 17:33:28 -04:00
Eric Engestrom f057dc91e9 libdrm: remove autotools support
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
2019-10-14 16:07:20 +00:00
Ilia Mirkin f2da507a04 modetest: add FP16 format support
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-06-22 13:34:36 -04:00
Ilia Mirkin 5d0e9dec3f modetest: add the ability to specify fill patterns on the commandline
Instead of hacking the binary every time, we can now specify directly.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-06-22 13:34:33 -04:00
Ilia Mirkin bfc469f241 modetest: add C8 support to generate SMPTE pattern
This includes logic to configure the LUT accordingly.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-06-22 13:34:29 -04:00
Ilia Mirkin 557d1a2e6f modetest: add an add_property_optional variant that does not print errors
As new features are added and others are declared to be legacy, it's
nice to be able to implement fallbacks. As such, create a
property-setting variant that does not generate errors which can very
well be entirely expected.

Will be used for gamma control in a future change.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-06-22 13:34:25 -04:00
Ilia Mirkin 78ea933460 modetest: don't pretend that atomic mode includes a format
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-06-22 13:34:20 -04:00
Fritz Koenig f8f8b2b9b0 tests/modetest: add QCOM_COMPRESSED to supported modifiers list
Signed-off-by: Fritz Koenig <frkoenig@google.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2019-04-17 18:28:08 +01:00
Lucas De Marchi 1e3fcc495b autotools: make symbols hidden by default
Now that symbols that should be exported are annotated accordingly, make
all the rest hidden by default.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Eric Engestrom <eric.engestrom@intel.com>
2018-09-19 22:46:45 -07:00
Lucas De Marchi ba808253bc meson: make symbols hidden by default
Now that symbols that should be exported are annotated accordingly, make
all the rest hidden by default.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-09-19 22:46:45 -07:00
Benjamin Gaignard 93220283cb tests/modetest: Add atomic support
If "-a" option is set this make modetest use atomic API instead
of legacy API.

Test the frame rate ("-v") it does a loop and swap between two
framebuffer for each active planes.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-08-07 13:39:20 +01:00
Eric Engestrom 0926f0af54 meson,configure: include config.h automatically
This will prevent any more missing `#include "config.h"` bug, at the
cost of having to recompile some files that didn't need to be when
changing build options.

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-03-20 18:19:26 +00:00
Thierry Reding ab5aaf6c8e drm/tegra: Sanitize format modifiers
The existing format modifier definitions were merged prematurely, and
recent work has unveiled that the definitions are suboptimal in several
ways:

  - The format specifiers, except for one, are not Tegra specific, but
    the names don't reflect that.
  - The number space is split into two, reserving 32 bits for some
    "parameter" which most of the modifiers are not going to have.
  - Symbolic names for the modifiers are not using the standard
    DRM_FORMAT_MOD_* prefix, which makes them awkward to use.
  - The vendor prefix NV is somewhat ambiguous.

Fortunately, nobody's started using these modifiers, so we can still fix
the above issues. Do so by using the standard prefix. Also, remove TEGRA
from the name of those modifiers that exist on NVIDIA GPUs as well. In
case of the block linear modifiers, make the "parameter" smaller (4
bits, though only 6 values are valid) and don't let that leak into any
of the other modifiers.

Finally, also use the more canonical NVIDIA instead of the ambiguous NV
prefix.

This is based on commit 5843f4e02fbe86a59981e35adc6cabebee46fdc0 from
Linux v4.16-rc1 and also updates modetest to use the new defines.

Acked-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
2018-02-19 14:58:57 +01:00
Seung-Woo Kim 6736ad45d8 modetest: Fix to check return value of asprintf()
There is warning about ignoring return value of 'asprintf'. Fix to
check return value of asprintf().

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2018-01-25 10:39:30 +00:00
Dylan Baker 5f7deb5078 Add meson build system
This patch adds a complete meson build system, including tests and
install. It has the necessary hooks to allow it be used as a subproject
for other meson based builds such as mesa.

Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-and-tested-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2018-01-12 09:40:48 -08:00
Ville Syrjälä ba68d7bf60 modetest: Allow full testing of primary planes
Allow the user to override the default configuration set by setcrtc
for the primary plane. On some hardware primary planes can be freely
positioned/sized, and it'd be nice if we can actually test that feature.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2017-10-19 19:16:16 +03:00
Kristian H. Kristensen 511c71c868 modetest: Decode IN_FORMATS plane blob property
This teaches modetest about the new IN_FORMATS blob and decodes the
blob to show supported formats and modifiers.

Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
2017-10-18 12:32:40 -07:00
Ilia Mirkin 691a215799 modetest: fix printing of fourcc on BE machines
fourcc is not a string, it's a packed integer. This happens to work out
on LE, but gets reversed on BE.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
2017-04-19 23:25:43 -04:00
Tomasz Figa 8ef7e5b702 tests: Use -pthread in CFLAGS instead of -lpthread
-lpthread is not always a valid flag to pull pthread support, especially
on Android it will fail to link due to a missing libpthread.so. The more
generic way to build-in pthread support is to use the -pthread CFLAG, so
let's use it instead.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
[Emil Velikov: rebase on top of previous commit]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2017-01-27 16:18:02 +00:00
Emil Velikov 03d2e91d00 android: introduce Android.common.mk to reduce boilerplate
... across the makefiles. Currently this isn't much but that will change
shortly.

As an added bonus this fixes all present and future cases where we've
forgotten to strip out the headers from LOCAL_SRC_FILES.

In a couple of cases (the tests) we start setting
LOCAL_EXPORT_C_INCLUDE_DIRS, which shouldn't be an issue.

Cc: Chih-Wei Huang <cwhuang@android-x86.org>
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
2017-01-27 15:48:16 +00:00
Ville Syrjälä e3af5368b2 modetest: Allow the user to specify the plane ID
Devices can have multiple planes, so allow the user to choose between
them.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2016-12-19 15:14:07 +02:00
Stéphane Marchesin 72a041694e modetest: Also print the pixel clock
This can be useful for debugging. xrandr prints it, so why not.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2016-09-01 16:02:46 +01:00