diff options
author | Mateusz Majewski <m.majewski2@samsung.com> | 2024-02-09 13:48:39 +0100 |
---|---|---|
committer | Mateusz Majewski <m.majewski2@samsung.com> | 2024-02-09 13:48:39 +0100 |
commit | 765e6e7165355191627f451a7e4738d0dc7f2999 (patch) | |
tree | 48d962ea5267ff1831db5a6f5024011ad288b7f1 | |
parent | 280ced031cea116524cc90319d1dca04e5281d60 (diff) | |
download | libtbm-dumb-sandbox/mmajewski2/hardcode.tar.gz libtbm-dumb-sandbox/mmajewski2/hardcode.tar.bz2 libtbm-dumb-sandbox/mmajewski2/hardcode.zip |
hardcodesandbox/mmajewski2/hardcode
-rw-r--r-- | src/tbm_backend_dumb.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tbm_backend_dumb.c b/src/tbm_backend_dumb.c index 0edb5dc..0f7eea6 100644 --- a/src/tbm_backend_dumb.c +++ b/src/tbm_backend_dumb.c @@ -678,6 +678,43 @@ tbm_dumb_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size, dumb_flags = _get_dumb_flag_from_tbm(flags); + const struct { + int w; + int h; + } hardcoded_sizes[] = { + // These are the modes that are available. + { 640, 480 }, + { 800, 600 }, + { 1024, 768 }, + { 1280, 1024 }, + { 1280, 768 }, + { 1280, 960 }, + { 1360, 768 }, + { 1400, 1050 }, + { 1440, 900 }, + { 1600, 1200 }, + { 1680, 1050 }, + { 1792, 1344 }, + { 1856, 1392 }, + { 1920, 1080 }, + { 1920, 1200 }, + { 1920, 1440 }, + { 2048, 1152 }, + { 2560, 1080 }, + { 3840, 2160 }, + { 4096, 2160 }, + { 5120, 2160 }, + + // This are some random sizes that Enlightenment creates. + { 1, 1 }, + { 190, 32 }, + { 245, 137 }, + { 408, 32 }, + { 409, 32 }, + { 1024, 256 }, + }; + const int hardcoded_sizes_count = sizeof(hardcoded_sizes) / sizeof(hardcoded_sizes[0]); + //as we know only size for new bo set height=1 and bpp=8 and in this case //width will by equal to size in bytes; create_dumb_arg.bpp = 32; // virtio-gpu refuses to accept bpp=8 @@ -691,6 +728,13 @@ tbm_dumb_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size, create_dumb_arg.height = root; create_dumb_arg.width = (words + root - 1) / root; } + for (int i = 0; i < hardcoded_sizes_count; ++i) { + if (hardcoded_sizes[i].w * hardcoded_sizes[i].h * 4 == size) { + create_dumb_arg.height = hardcoded_sizes[i].h; + create_dumb_arg.width = hardcoded_sizes[i].w; + break; + } + } create_dumb_arg.flags = dumb_flags; if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb_arg)) { |