Skip to content

Commit 1e4c82e

Browse files
committed
Improved legacy fourcc guessing
1 parent 15de305 commit 1e4c82e

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

src/kms-utils.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,29 @@ bool kms_get_fb2(int fd, uint32_t fb_id, kms_fb_t *out)
285285
out->height = old_fb->height;
286286
out->flags = 0;
287287

288-
/* Infer a basic fourcc since legacy GETFB only returns depth/bpp */
289-
if (old_fb->depth == 24 && old_fb->bpp == 32)
290-
out->fourcc = DRM_FORMAT_XRGB8888;
291-
else if (old_fb->depth == 32 && old_fb->bpp == 32)
292-
out->fourcc = DRM_FORMAT_ARGB8888;
293-
else if (old_fb->depth == 16 && old_fb->bpp == 16)
294-
out->fourcc = DRM_FORMAT_RGB565;
295-
else
288+
/* Infer fourcc since legacy GETFB only returns depth/bpp */
289+
switch (old_fb->bpp) {
290+
case 8:
291+
out->fourcc = DRM_FORMAT_C8;
292+
break;
293+
case 16:
294+
out->fourcc = (old_fb->depth == 15) ? DRM_FORMAT_XRGB1555 : DRM_FORMAT_RGB565;
295+
break;
296+
case 24:
297+
out->fourcc = DRM_FORMAT_RGB888;
298+
break;
299+
case 32:
300+
if (old_fb->depth == 24)
301+
out->fourcc = DRM_FORMAT_XRGB8888;
302+
else if (old_fb->depth == 30)
303+
out->fourcc = DRM_FORMAT_XRGB2101010;
304+
else
305+
out->fourcc = DRM_FORMAT_ARGB8888;
306+
break;
307+
default:
296308
out->fourcc = DRM_FORMAT_XRGB8888; /* fallback */
309+
break;
310+
}
297311

298312
out->num_planes = 1;
299313
out->handles[0] = old_fb->handle;
@@ -427,6 +441,9 @@ int kms_fourcc_to_gs_format(uint32_t fourcc)
427441
return GS_RGBA;
428442
case DRM_FORMAT_XBGR8888:
429443
return GS_RGBA; /* closest available */
444+
case DRM_FORMAT_XRGB2101010:
445+
case DRM_FORMAT_ARGB2101010:
446+
return GS_R10G10B10A2;
430447
default:
431448
/* RGB565 and other formats not in gs_color_format — pass the
432449
* DRM fourcc directly to EGL and use GS_BGRA as a hint. */

0 commit comments

Comments
 (0)