Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ OPTIONS:
without a display attached.
--dummy-display-size "width,height" The width & height of the dummy display
in pixels.
--drm-fd <fd> An opened and valid DRM file descriptor

-h, --help Show this help and exit.

Expand Down
27 changes: 24 additions & 3 deletions src/flutter-pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ OPTIONS:\n\
without a display attached.\n\
--dummy-display-size \"width,height\" The width & height of the dummy display\n\
in pixels.\n\
\n\
--drm-fd An opened and valid DRM file descriptor\n\
\n\
-h, --help Show this help and exit.\n\
\n\
Expand Down Expand Up @@ -1876,24 +1878,26 @@ bool flutterpi_parse_cmdline_args(int argc, char **argv, struct flutterpi_cmdlin
{ "videomode", required_argument, NULL, 'v' },
{ "dummy-display", no_argument, &dummy_display_int, 1 },
{ "dummy-display-size", required_argument, NULL, 's' },
{ "drm-fd", required_argument, NULL, 'f' },
{ 0, 0, 0, 0 },
};

memset(result_out, 0, sizeof *result_out);

result_out->has_orientation = false;
result_out->has_rotation = false;
result_out->has_physical_dimensions = false;
result_out->has_pixel_format = false;
result_out->has_runtime_mode = false;
result_out->has_drm_fd = false;
result_out->bundle_path = NULL;
result_out->engine_argc = 0;
result_out->engine_argv = NULL;
result_out->drm_fd = -1;

finished_parsing_options = false;
while (!finished_parsing_options) {
longopt_index = 0;
opt = getopt_long(argc, argv, "+i:o:r:d:h", long_options, &longopt_index);
opt = getopt_long(argc, argv, "+i:o:r:d:h:f", long_options, &longopt_index);

switch (opt) {
case 0:
Expand Down Expand Up @@ -1997,6 +2001,17 @@ bool flutterpi_parse_cmdline_args(int argc, char **argv, struct flutterpi_cmdlin

break;

case 'f':; // --drm-fd
char *drm_fd = strdup(optarg);
int fd = atoi(drm_fd);
if(fd <= 0){
LOG_ERROR("ERROR: Invalid argument for --drm-fd passed.\n");
return false;
}
result_out->has_drm_fd = true;
result_out->drm_fd = fd;
break;

case 'h': printf("%s", usage); return false;

case '?':
Expand Down Expand Up @@ -2448,7 +2463,13 @@ struct flutterpi *flutterpi_new_from_args(int argc, char **argv) {
goto fail_destroy_locales;
}
} else {
drmdev = find_drmdev(libseat);
if(cmd_args.has_drm_fd){
/* --drm-fd is passed, we don't want flutter-pi to handle the DRM choice */
drmdev = drmdev_new_from_interface_fd(cmd_args.drm_fd, NULL, &drmdev_interface, libseat);
}
else{
drmdev = find_drmdev(libseat);
}
if (drmdev == NULL) {
goto fail_destroy_locales;
}
Expand Down
3 changes: 3 additions & 0 deletions src/flutter-pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ struct flutterpi_cmdline_args {

bool dummy_display;
struct vec2i dummy_display_size;

bool has_drm_fd;
int drm_fd;
};

int flutterpi_fill_view_properties(bool has_orientation, enum device_orientation orientation, bool has_rotation, int rotation);
Expand Down
Loading