Skip to content

Commit b7378cd

Browse files
Renaud-BarrauRenaud Barrau
andauthored
[add] Add Drm fd support (#501)
* [add] Add "--drm-fd" option to flutter-pi. This allows to start flutter-pi on a specific DRM fd, instead of letting the tool locking the DRM master. This can be useful if we have several screens and we want to display the flutter-pi content on a specific one, while not locking others. This works well with the drm-lease-manager project (https://github.com/AGLExport/drm-lease-manager/tree/master) * [update] Update README.md --------- Co-authored-by: Renaud Barrau <[email protected]>
1 parent 0d1f85a commit b7378cd

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ OPTIONS:
381381
without a display attached.
382382
--dummy-display-size "width,height" The width & height of the dummy display
383383
in pixels.
384+
--drm-fd <fd> An opened and valid DRM file descriptor
384385

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

src/flutter-pi.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ OPTIONS:\n\
141141
without a display attached.\n\
142142
--dummy-display-size \"width,height\" The width & height of the dummy display\n\
143143
in pixels.\n\
144+
\n\
145+
--drm-fd An opened and valid DRM file descriptor\n\
144146
\n\
145147
-h, --help Show this help and exit.\n\
146148
\n\
@@ -1876,24 +1878,26 @@ bool flutterpi_parse_cmdline_args(int argc, char **argv, struct flutterpi_cmdlin
18761878
{ "videomode", required_argument, NULL, 'v' },
18771879
{ "dummy-display", no_argument, &dummy_display_int, 1 },
18781880
{ "dummy-display-size", required_argument, NULL, 's' },
1881+
{ "drm-fd", required_argument, NULL, 'f' },
18791882
{ 0, 0, 0, 0 },
18801883
};
1881-
18821884
memset(result_out, 0, sizeof *result_out);
18831885

18841886
result_out->has_orientation = false;
18851887
result_out->has_rotation = false;
18861888
result_out->has_physical_dimensions = false;
18871889
result_out->has_pixel_format = false;
18881890
result_out->has_runtime_mode = false;
1891+
result_out->has_drm_fd = false;
18891892
result_out->bundle_path = NULL;
18901893
result_out->engine_argc = 0;
18911894
result_out->engine_argv = NULL;
1895+
result_out->drm_fd = -1;
18921896

18931897
finished_parsing_options = false;
18941898
while (!finished_parsing_options) {
18951899
longopt_index = 0;
1896-
opt = getopt_long(argc, argv, "+i:o:r:d:h", long_options, &longopt_index);
1900+
opt = getopt_long(argc, argv, "+i:o:r:d:h:f", long_options, &longopt_index);
18971901

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

19982002
break;
19992003

2004+
case 'f':; // --drm-fd
2005+
char *drm_fd = strdup(optarg);
2006+
int fd = atoi(drm_fd);
2007+
if(fd <= 0){
2008+
LOG_ERROR("ERROR: Invalid argument for --drm-fd passed.\n");
2009+
return false;
2010+
}
2011+
result_out->has_drm_fd = true;
2012+
result_out->drm_fd = fd;
2013+
break;
2014+
20002015
case 'h': printf("%s", usage); return false;
20012016

20022017
case '?':
@@ -2448,7 +2463,13 @@ struct flutterpi *flutterpi_new_from_args(int argc, char **argv) {
24482463
goto fail_destroy_locales;
24492464
}
24502465
} else {
2451-
drmdev = find_drmdev(libseat);
2466+
if(cmd_args.has_drm_fd){
2467+
/* --drm-fd is passed, we don't want flutter-pi to handle the DRM choice */
2468+
drmdev = drmdev_new_from_interface_fd(cmd_args.drm_fd, NULL, &drmdev_interface, libseat);
2469+
}
2470+
else{
2471+
drmdev = find_drmdev(libseat);
2472+
}
24522473
if (drmdev == NULL) {
24532474
goto fail_destroy_locales;
24542475
}

src/flutter-pi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ struct flutterpi_cmdline_args {
141141

142142
bool dummy_display;
143143
struct vec2i dummy_display_size;
144+
145+
bool has_drm_fd;
146+
int drm_fd;
144147
};
145148

146149
int flutterpi_fill_view_properties(bool has_orientation, enum device_orientation orientation, bool has_rotation, int rotation);

0 commit comments

Comments
 (0)