diff options
author | Ilia Mirkin <imirkin@alum.mit.edu> | 2019-08-28 20:35:15 -0400 |
---|---|---|
committer | Ilia Mirkin <imirkin@alum.mit.edu> | 2019-08-30 20:49:58 -0400 |
commit | be24eadef7c8f71ede52997fa477ae94600efa9d (patch) | |
tree | 6dbe47ef5c815a907b6b4ca72c02511f4049500d | |
parent | f632b23a528ed6b4e1fddd774db005c30ab65568 (diff) |
kmscube: make fb/gl config format settable on cmdline
Instead of changing the code each time, allow the fourcc to be passed
in as an argument.
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Rob Clark <robdclark@gmail.com>
-rw-r--r-- | common.c | 4 | ||||
-rw-r--r-- | common.h | 2 | ||||
-rw-r--r-- | kmscube.c | 20 | ||||
-rw-r--r-- | texturator.c | 2 |
4 files changed, 23 insertions, 5 deletions
@@ -40,10 +40,10 @@ gbm_surface_create_with_modifiers(struct gbm_device *gbm, const uint64_t *modifiers, const unsigned int count); -const struct gbm * init_gbm(int drm_fd, int w, int h, uint64_t modifier) +const struct gbm * init_gbm(int drm_fd, int w, int h, uint32_t format, uint64_t modifier) { gbm.dev = gbm_create_device(drm_fd); - gbm.format = GBM_FORMAT_XRGB8888; + gbm.format = format; gbm.surface = NULL; if (gbm_surface_create_with_modifiers) { @@ -99,7 +99,7 @@ struct gbm { int width, height; }; -const struct gbm * init_gbm(int drm_fd, int w, int h, uint64_t modifier); +const struct gbm * init_gbm(int drm_fd, int w, int h, uint32_t format, uint64_t modifier); struct egl { @@ -46,6 +46,7 @@ static const char *shortopts = "AD:M:m:V:v:"; static const struct option longopts[] = { {"atomic", no_argument, 0, 'A'}, {"device", required_argument, 0, 'D'}, + {"format", required_argument, 0, 'f'}, {"mode", required_argument, 0, 'M'}, {"modifier", required_argument, 0, 'm'}, {"samples", required_argument, 0, 's'}, @@ -66,6 +67,7 @@ static void usage(const char *name) " rgba - rgba textured cube\n" " nv12-2img - yuv textured (color conversion in shader)\n" " nv12-1img - yuv textured (single nv12 texture)\n" + " -f, --format=FOURCC framebuffer format\n" " -m, --modifier=MODIFIER hardcode the selected modifier\n" " -s, --samples=N use MSAA\n" " -V, --video=FILE video textured cube\n" @@ -81,6 +83,7 @@ int main(int argc, char *argv[]) char mode_str[DRM_DISPLAY_MODE_LEN] = ""; char *p; enum mode mode = SMOOTH; + uint32_t format = DRM_FORMAT_XRGB8888; uint64_t modifier = DRM_FORMAT_MOD_LINEAR; int samples = 0; int atomic = 0; @@ -101,6 +104,21 @@ int main(int argc, char *argv[]) case 'D': device = optarg; break; + case 'f': { + char fourcc[4] = " "; + int length = strlen(optarg); + if (length > 0) + fourcc[0] = optarg[0]; + if (length > 1) + fourcc[1] = optarg[1]; + if (length > 2) + fourcc[2] = optarg[2]; + if (length > 3) + fourcc[3] = optarg[3]; + format = fourcc_code(fourcc[0], fourcc[1], + fourcc[2], fourcc[3]); + break; + } case 'M': if (strcmp(optarg, "smooth") == 0) { mode = SMOOTH; @@ -155,7 +173,7 @@ int main(int argc, char *argv[]) } gbm = init_gbm(drm->fd, drm->mode->hdisplay, drm->mode->vdisplay, - modifier); + format, modifier); if (!gbm) { printf("failed to initialize GBM\n"); return -1; diff --git a/texturator.c b/texturator.c index ddd8014..555f81f 100644 --- a/texturator.c +++ b/texturator.c @@ -955,7 +955,7 @@ int main(int argc, char *argv[]) } gbm = init_gbm(drm->fd, drm->mode->hdisplay, drm->mode->vdisplay, - DRM_FORMAT_MOD_LINEAR); + DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR); if (!gbm) { printf("failed to initialize GBM\n"); return -1; |