drm-backend: stop parsing IN_FORMATS blobs, use libdrm instead
Before this change the drm-backend in Weston did the work of parsing DRM blobs in order to query IN_FORMATS data, if available. This is also the case for other DRM/KMS clients that use IN_FORMATS (i.e. X). libdrm 2.4.108 with e641e2a6 ("xf86drm: add iterator API for DRM/KMS IN_FORMATS blobs") introduced a dedicated API for querying IN_FORMATS data. Bump the minimum required version to 2.4.108, stop parsing IN_FORMATS in Weston and start using DRM iterators. In addition, remove fallback code for libdrm <2.4.107. Signed-off-by: Luigi Santivetti <luigi.santivetti@imgtec.com>
This commit is contained in:
parent
08a821f291
commit
a62bf5ff48
@ -414,19 +414,6 @@ drm_property_info_free(struct drm_property_info *info, int num_props)
|
||||
memset(info, 0, sizeof(*info) * num_props);
|
||||
}
|
||||
|
||||
static inline uint32_t *
|
||||
formats_ptr(struct drm_format_modifier_blob *blob)
|
||||
{
|
||||
return (uint32_t *)(((char *)blob) + blob->formats_offset);
|
||||
}
|
||||
|
||||
static inline struct drm_format_modifier *
|
||||
modifiers_ptr(struct drm_format_modifier_blob *blob)
|
||||
{
|
||||
return (struct drm_format_modifier *)
|
||||
(((char *)blob) + blob->modifiers_offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the plane's formats array, using either the IN_FORMATS blob
|
||||
* property (if available), or the plane's format list if not.
|
||||
@ -437,13 +424,10 @@ drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
|
||||
const bool use_modifiers)
|
||||
{
|
||||
struct drm_device *device = plane->device;
|
||||
unsigned i, j;
|
||||
uint32_t i, blob_id, fmt_prev = DRM_FORMAT_INVALID;
|
||||
drmModeFormatModifierIterator drm_iter = {0};
|
||||
struct weston_drm_format *fmt = NULL;
|
||||
drmModePropertyBlobRes *blob = NULL;
|
||||
struct drm_format_modifier_blob *fmt_mod_blob;
|
||||
struct drm_format_modifier *blob_modifiers;
|
||||
uint32_t *blob_formats;
|
||||
uint32_t blob_id;
|
||||
struct weston_drm_format *fmt;
|
||||
int ret = 0;
|
||||
|
||||
if (!use_modifiers)
|
||||
@ -459,35 +443,22 @@ drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
|
||||
if (!blob)
|
||||
goto fallback;
|
||||
|
||||
fmt_mod_blob = blob->data;
|
||||
blob_formats = formats_ptr(fmt_mod_blob);
|
||||
blob_modifiers = modifiers_ptr(fmt_mod_blob);
|
||||
|
||||
assert(kplane->count_formats == fmt_mod_blob->count_formats);
|
||||
|
||||
for (i = 0; i < fmt_mod_blob->count_formats; i++) {
|
||||
fmt = weston_drm_format_array_add_format(&plane->formats,
|
||||
blob_formats[i]);
|
||||
if (!fmt) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (j = 0; j < fmt_mod_blob->count_modifiers; j++) {
|
||||
struct drm_format_modifier *mod = &blob_modifiers[j];
|
||||
|
||||
if ((i < mod->offset) || (i > mod->offset + 63))
|
||||
continue;
|
||||
if (!(mod->formats & (1 << (i - mod->offset))))
|
||||
continue;
|
||||
|
||||
ret = weston_drm_format_add_modifier(fmt, mod->modifier);
|
||||
if (ret < 0)
|
||||
while (drmModeFormatModifierBlobIterNext(blob, &drm_iter)) {
|
||||
if (fmt_prev != drm_iter.fmt) {
|
||||
fmt = weston_drm_format_array_add_format(&plane->formats,
|
||||
drm_iter.fmt);
|
||||
if (!fmt) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
fmt_prev = drm_iter.fmt;
|
||||
}
|
||||
|
||||
if (fmt->modifiers.size == 0)
|
||||
weston_drm_format_array_remove_latest_format(&plane->formats);
|
||||
ret = weston_drm_format_add_modifier(fmt, drm_iter.mod);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -708,7 +708,6 @@ pixel_format_height_for_plane(const struct pixel_format_info *info,
|
||||
return height / pixel_format_vsub(info, plane);
|
||||
}
|
||||
|
||||
#ifdef HAVE_HUMAN_FORMAT_MODIFIER
|
||||
WL_EXPORT char *
|
||||
pixel_format_get_modifier(uint64_t modifier)
|
||||
{
|
||||
@ -748,12 +747,3 @@ pixel_format_get_modifier(uint64_t modifier)
|
||||
|
||||
return mod_str;
|
||||
}
|
||||
#else
|
||||
WL_EXPORT char *
|
||||
pixel_format_get_modifier(uint64_t modifier)
|
||||
{
|
||||
char *mod_str;
|
||||
str_printf(&mod_str, "0x%llx", (unsigned long long) modifier);
|
||||
return mod_str;
|
||||
}
|
||||
#endif
|
||||
|
@ -148,16 +148,10 @@ dep_libinput = dependency('libinput', version: '>= 0.8.0')
|
||||
dep_libevdev = dependency('libevdev')
|
||||
dep_libm = cc.find_library('m')
|
||||
dep_libdl = cc.find_library('dl')
|
||||
dep_libdrm = dependency('libdrm', version: '>= 2.4.95')
|
||||
dep_libdrm = dependency('libdrm', version: '>= 2.4.108')
|
||||
dep_libdrm_headers = dep_libdrm.partial_dependency(compile_args: true)
|
||||
dep_threads = dependency('threads')
|
||||
|
||||
dep_libdrm_version = dep_libdrm.version()
|
||||
if dep_libdrm_version.version_compare('>=2.4.107')
|
||||
message('Found libdrm with human format modifier support.')
|
||||
config_h.set('HAVE_HUMAN_FORMAT_MODIFIER', '1')
|
||||
endif
|
||||
|
||||
dep_lcms2 = dependency('lcms2', version: '>= 2.9', required: false)
|
||||
|
||||
prog_python = import('python').find_installation('python3')
|
||||
|
Loading…
Reference in New Issue
Block a user