This fixes the logic that decides if a node name is valid to use the
same length restrictions that are used in drmDeviceAlloc, which expects
node names to conform to a specific naming scheme (On OSes except
OpenBSD this means `/dev/dri/renderD123`). This addresses the problem of
node names that are longer than expected, while still allowing symlinks
to work.
I've also applied the same fix to the OpenBSD path, while bringing the
check that `snprintf` didn't error from OpenBSD to the main path.
Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Tested-by: Mark Janes <markjanes@swizzler.org>
Tested-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
This reverts commit 7ab1cdac90.
This breaks numerous tools that rely on being able to read symlinks, and
constitutes a regression.
Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Tested-by: Mark Janes <markjanes@swizzler.org>
Tested-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Closes: #103
If the user has some UDev rules in place that creates symlinks for
one of the card or render nodes, and the name of the symlink is
too long, then drmDeviceAlloc() ends up truncating the name of
the node.
This in turn results in chaos in different subsystems. E.g.
vulkaninfo dies early with this:
Code 0 : failed to stat DRM primary node /dev/dri/my-favorite- (VK_ERROR_INITIALIZATION_FAILED)
(if the symlink is called /dev/dri/my-favorite-card-node)
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Synchronize drm.h and drm_mode.h to drm-next.
Generated using make headers_install.
Generated from drm-next branch commit a60501d7c2d3e70b3545b9b96576628e369d8e85
Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Simon Zeni <simon.zeni@collabora.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Synchronize drm.h, drm_mode.h and drm_fourcc.h to drm-next.
Generated using make headers_install.
Generated from drm-next branch commit c79b972eb88b077d2765e7790d0902b3dc94d55c
Signed-off-by: Simon Ser <contact@emersion.fr>
This is useful to figure out whether the dev_t refers to a primary
node or a render node. Indeed, drmGetDeviceFromDevId returns a
drmDevice, which holds both the primary and render nodes.
Signed-off-by: Simon Ser <contact@emersion.fr>
Add support for creating buffers using big-endian formats.
For now this is limited to XRGB1555 and RGB565, which are the most
common big-endian formats.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- No changes,
v2:
- New.
Add support for rendering the crosshairs in a buffer using the
big-endian RGB565 format.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- No changes,
v2:
- New.
Cairo always uses native byte order for rendering.
Hence if the byte order of the frame buffer differs from the byte order
of the CPU, the frame buffer contents need to be byteswapped twice: once
before rendering, to convert to native byte order, and a second time
after rendering, to restore the frame buffer format's byte order.
Note that byte swapping is not done for ARGB32 formats, as for these
formats, byte order only affects the order of the red, green, and blue
channels, which we do not care about here.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Wrap byteswap_buffer{16,32}() implementation inside #if HAVE_CAIRO
to avoid defined-but-not-used compiler warnings,
v2:
- RGB30 is untested.
Add support for drawing the SMPTE and tiles test patterns in buffers
using big-endian formats.
For now this is limited to XRGB1555 and RGB565, which are the most
common big-endian formats.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Increase indentation after definition of cpu_to_be16(),
v2:
- New.
When specifying a frame buffer format like "RG16_BE" (big-endian RG16),
modetest still uses the little-endian variant, as the format string is
truncated to four characters.
Fix this by increasing the format string size to 8 bytes (7 characters +
NUL terminator).
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Update for suffix change from "be" to "_BE", cfr. commit
ffb9375a50 ("xf86drm: handle DRM_FORMAT_BIG_ENDIAN in
drmGetFormatName()"),
- Replace hardcoded numbers in code by sizeof(),
v2:
- New.
DRM formats are defined to be little-endian, unless the
DRM_FORMAT_BIG_ENDIAN flag is set. Hence writes of multi-byte pixel
values need to take endianness into account.
Introduce a swap16() helper to byteswap 16-bit values, and a
cpu_to_le16() helper to convert 16-bit values from CPU-endian to
little-endian, and use the latter in the various pattern fill functions
for 16-bit formats.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Increase indentation after definition of cpu_to_le16(),
v2:
- New.
DRM formats are defined to be little-endian, unless the
DRM_FORMAT_BIG_ENDIAN flag is set. Hence writes of multi-byte pixel
values need to take endianness into account.
Introduce a swap32() helper to byteswap 32-bit values, and a
cpu_to_le32() helper to convert 32-bit values from CPU-endian to
little-endian, and use the latter in the various pattern fill functions
for 32-bit formats.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- Use new HAVE_BIG_ENDIAN symbol,
v3:
- Increase indentation after definition of cpu_to_le32(),
v2:
- Add Acked-by,
- Add swap32() intermediate helper,
- Add __ARM_BIG_ENDIAN and __s390__.
The endianness of the target is currently determined based on
preprocessor symbols. Unfortunately some symbols checked are wrong
(sparc64-linux-gnu-gcc does not define __BIG_ENDIAN__ or SPARC), and
several checks for big-endian architectures are missing.
Fix this by introducing a new preprocessor symbol HAVE_BIG_ENDIAN, which
is set based on meson's knowledge of the target endianness.
Android.common.mk does not need an update, as Android is always
little-endian (https://developer.android.com/ndk/guides/abis.html).
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- Replace explicit #ifdef checks by a define set by meson,
v3:
- No changes,
v2:
- Add arm, aarch64, microblaze, s390, and sh.
Add smpte and tiles pattern for 10-bit NV15, NV20 and NV30 pixel formats
based on the existing pattern for NV12 with colors simply scaled from
8-bit to 10-bit.
These pixel formats are typically used by video decoder and display
pipeline on Rockchip SoCs, e.g. on RK322X, RK3288, RK3328 and RK3399
the video decoder produce 10-bit video frames in NV15 and NV20 format.
NV20 and NV30 pixel formats was added in drm-misc commit 728c15b4b5f3
("drm/fourcc: Add NV20 and NV30 YUV formats").
This can be tested/validated on Rockchip SoCs with drm-misc commit
d4b384228562 ("drm/rockchip: vop: Add NV15, NV20 and NV30 support").
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Christopher Obbard <chris.obbard@collabora.com>
Tested-by: Christopher Obbard <chris.obbard@collabora.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Replace system() with cpu_family() for libdrm_intel
This restore libdrm_intel to be built by default
Closes: #93
Signed-off-by: David Jagu <marav8@free.fr>
Add support for drawing the SMPTE pattern in buffers using a
color-indexed frame buffer formats with two, four, or sixteen colors.
Note that this still uses 256 as the CLUT size, as
DRM_IOCTL_MODE_SETGAMMA enforces that the size matches against the
(fixed) gamma size, while the CLUT size depends on the format.
Move clearing the color LUT entries from util_smpte_index_gamma() to its
caller, as only the caller knows how many entries there really are
(currently DRM always assumes 256 entries).
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- Add missing C[12] to oneline-summary,
- Do not remove memset() of full lut, else some entries may stay
uninitialized,
v3:
- Add Acked-by,
v2:
- Split off changes to tests/modetest/modetest.c,
- Add C1 and C2 support.
The linuxdoc comments say userspace can query the gamma size:
* drm_mode_gamma_set_ioctl - set the gamma table
*
* Set the gamma table of a CRTC to the one passed in by the user. Userspace can
* inquire the required gamma table size through drm_mode_gamma_get_ioctl.
* drm_mode_gamma_get_ioctl - get the gamma table
*
* Copy the current gamma table into the storage provided. This also provides
* the gamma table size the driver expects, which can be used to size the
* allocated storage.
but the code doesn't seem to support that in an easy way (like setting
red/green/blue to NULL on input, retrieving gamma_size on output), only
by providing big enough buffers for red/green/blue, and looping over
gamma_size until -EINVAL is no longer returned.
Add support for creating buffers using the new color-indexed frame
buffer formats with two, four, and sixteen colors.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Add Acked-by,
v2:
- Split off changes to tests/modetest/buffers.c.
Add support for drawing the SMPTE pattern in a buffer using the C2
indexed format.
As only four colors are available, resolution is halved, and the pattern
is drawn in a PenTile RG-GB matrix, using Floyd-Steinberg dithering.
The magnitude of the green subpixels is reduced, as there are twice as
many green subpixels as red or blue subpixels.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
Dithering example at https://drive.google.com/file/d/1g5O8XeacrjrC8rgaVENvR65YeI6QvmtO/view
v5:
- Add Reviewed-by,
v4:
- Replace FILL_COLOR() use by pentile_color_lut[],
v3:
- Add Acked-by,
v2:
- New.
Add support for drawing the SMPTE pattern in a buffer using the C1
indexed format.
As only two colors are available, the pattern is drawn in black and
white, using Floyd-Steinberg dithering[1].
[1] https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
Dithering example at https://drive.google.com/file/d/1waJczErrIaEKRhBCCU1ynxRG8agpo0Xx/view
v5:
- Add Reviewed-by,
v4:
- Replace FILL_COLOR() use by bw_color_lut[],
v3:
- Add Acked-by,
- Add Wikipedia link,
v2:
New.
Add support for drawing the SMPTE pattern in a buffer using the C4
indexed format.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Add Acked-by,
v2:
- Use new smpte_top[],
- Split off changes to tests/util/pattern.c.
Store the number of available colors for color-indexed frame
buffer formats in the format_info[] array. This avoids the need of test
code for having to use switch statements all the time to obtain the
number of colors, or to check if a mode is color-indexed or not.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Add Acked-by,
v2:
- New.
Add support for creating buffers using the new color-indexed frame
buffer formats with two, four, and sixteen colors.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Add Acked-by,
v2:
- Split off changes to tests/util/format.c.
The color LUT for the SMPTE pattern in indexed mode contains 22 entries,
although only 13 are non-unique.
Reduce the size of the color LUT by dropping duplicate entries, so it
can be reused for formats supporting e.g. 16 colors. Rename the
function util_smpte_c8_gamma() to util_smpte_fill_lut(), and its first
parameter size to ncolors, to match their actual use.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- Rename util_smpte_index_gamma() to util_smpte_fill_lut(), and its
first parameter from size to ncolors,
- Move smpte_color_lut[] down,
- Kill FILL_COLOR() macro,
- Add and use EXPAND_COLOR() macro,
v3:
- Add Acked-by,
v2:
- Factor out smpte color LUT.
Fill in the LSB when converting color components from 8-bit to 16-bit.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
v5:
- Add Reviewed-by,
v4:
- No changes,
v3:
- Add Acked-by,
v2:
- New.
To reduce the size and complexity of checks. require() allows combining
auto and enabled checks(), so that something like
```meson
x = get_option('feature')
y = false
if x.enabled()
if not condition
error(...)
endif
y = condition
endif
```
can be rewritten as:
```meson
y = get_option('feature').require(condition, error_message : ...).allowed()
```
require checks the condition, then if the feature is required it emits
an error with the given message otherwise it returns a disabled feature.
allowed then returns whether the feature is not disabled, and returns
that (ie, .allowed() == not .disabled()). This is especially helpful for
longer more complex conditions
Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Intel requires libpciaccess and an x86/x86_64 host, so if those
aren't found and it's enabled we need to error
Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
13.0 is no longer supported and causes a 404 when fetching the
image, see e.g. [1] for example failure.
[1]: https://gitlab.freedesktop.org/mesa/drm/-/jobs/45849458
Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
With the work in [1], libdrm users should no longer rely on the
minor numbering scheme we've used so far. Instead, they should use
drmGetDevices2().
[1]: https://lore.kernel.org/lkml/20230724211428.3831636-1-michal.winiarski@intel.com/
Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Print modifiers in hex in addtion to in strings returned by
drmGetFormatModifierName. In some cases, hex numbers can be more easily
compared visually.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Currently the atomic request is only assigned after `set_property()` is
called, leaving `dev.req` in its uninitialized state causing
`drmModeAtomicAddProperty()` to return an error code, which is printed
as `"Success"` because `errno` is not set by `libdrm` (but it would have
been when non-atomic `drmModeObjectSetProperty()` called an IOCTL
immediately):
sony-akatsuki-row ~ $ modetest -M msm -a -w 81:ACTIVE:0
failed to set CRTC 81 property ACTIVE to 0: Success
Solve this by assigning a new atomic request object before calling
`set_property()`, when there are properties to set. Likewise, commit
these properties after `set_property()` even if there is no other
operation (setting modes or planes) specified.
Furthermore `drmModeObjectSetProperty()` is implemented in terms of
`DRM_IOCTL()` which already returns `-errno` when `ioctl()` returns
`-1`, so we should instead pass `ret` to `strerror()` and get an
accurate error string out of `drmModeAtomicAddProperty()` too.
Fixes: 93220283 ("tests/modetest: Add atomic support")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>