compositor-drm: parse all DRM format names

Use the pixel format table to parse format names. This makes the parser
recognize almost all DRM format names.

Not all formats are usable, but we rely on the use to fail
appropriately. What we can use depends on the drivers anyway.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Pekka Paalanen 6 years ago committed by Marius Vlad
parent f5ed7431e5
commit 62a9436417
  1. 26
      libweston/compositor-drm.c

@ -3,6 +3,7 @@
* Copyright © 2011 Intel Corporation
* Copyright © 2017, 2018 Collabora, Ltd.
* Copyright © 2017, 2018 General Electric Company
* Copyright (c) 2018 DisplayLink (UK) Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -5390,22 +5391,25 @@ drm_output_detach_head(struct weston_output *output_base,
static int
parse_gbm_format(const char *s, uint32_t default_value, uint32_t *gbm_format)
{
int ret = 0;
const struct pixel_format_info *pinfo;
if (s == NULL)
if (s == NULL) {
*gbm_format = default_value;
else if (strcmp(s, "xrgb8888") == 0)
*gbm_format = GBM_FORMAT_XRGB8888;
else if (strcmp(s, "rgb565") == 0)
*gbm_format = GBM_FORMAT_RGB565;
else if (strcmp(s, "xrgb2101010") == 0)
*gbm_format = GBM_FORMAT_XRGB2101010;
else {
return 0;
}
pinfo = pixel_format_get_info_by_drm_name(s);
if (!pinfo) {
weston_log("fatal: unrecognized pixel format: %s\n", s);
ret = -1;
return -1;
}
return ret;
/* GBM formats and DRM formats are identical. */
*gbm_format = pinfo->format;
return 0;
}
static uint32_t

Loading…
Cancel
Save