Skip to content

Commit 6522d1c

Browse files
authored
Merge pull request #1 from qwiek/feature-change-monitor
Feature change monitor
2 parents c7e0ff5 + 70f7f88 commit 6522d1c

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ OPTIONS:
382382
--dummy-display-size "width,height" The width & height of the dummy display
383383
in pixels.
384384

385+
--drm-vout-display <drm-device> The DRM display to use.\n\
386+
HDMI-A-1, HDMI-A-2, DSI-1, DSI-2.\n\
387+
385388
-h, --help Show this help and exit.
386389

387390
EXAMPLES:

src/flutter-pi.c

Lines changed: 62 additions & 1 deletion
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+
--drm-vout-display <drm-device> The DRM display to use.\n\
145+
HDMI-A-1, HDMI-A-2, DSI-1, DSI-2.\n\
144146
\n\
145147
-h, --help Show this help and exit.\n\
146148
\n\
@@ -262,6 +264,8 @@ struct flutterpi {
262264
bool session_active;
263265

264266
char *desired_videomode;
267+
268+
char *drm_vout_display;
265269
};
266270

267271
struct device_id_and_fd {
@@ -1853,6 +1857,16 @@ static bool parse_vec2i(const char *str, struct vec2i *out) {
18531857
return true;
18541858
}
18551859

1860+
bool is_valid_drm_display(const char *display) {
1861+
const char *valid_displays[] = { "HDMI-A-1", "HDMI-A-2", "DSI-1", "DSI-2" };
1862+
for (size_t i = 0; i < sizeof(valid_displays) / sizeof(valid_displays[0]); i++) {
1863+
if (strcmp(display, valid_displays[i]) == 0) {
1864+
return true;
1865+
}
1866+
}
1867+
return false;
1868+
}
1869+
18561870
bool flutterpi_parse_cmdline_args(int argc, char **argv, struct flutterpi_cmdline_args *result_out) {
18571871
bool finished_parsing_options;
18581872
int runtime_mode_int = FLUTTER_RUNTIME_MODE_DEBUG;
@@ -1876,6 +1890,7 @@ bool flutterpi_parse_cmdline_args(int argc, char **argv, struct flutterpi_cmdlin
18761890
{ "videomode", required_argument, NULL, 'v' },
18771891
{ "dummy-display", no_argument, &dummy_display_int, 1 },
18781892
{ "dummy-display-size", required_argument, NULL, 's' },
1893+
{ "drm-vout-display", required_argument, NULL, 'i' },
18791894
{ 0, 0, 0, 0 },
18801895
};
18811896

@@ -1997,6 +2012,17 @@ bool flutterpi_parse_cmdline_args(int argc, char **argv, struct flutterpi_cmdlin
19972012

19982013
break;
19992014

2015+
case 'i': // --drm-vout-display
2016+
result_out->drm_vout_display = strdup(optarg);
2017+
if (result_out->drm_vout_display == NULL) {
2018+
return false;
2019+
}
2020+
if (!is_valid_drm_display(result_out->drm_vout_display)) {
2021+
LOG_ERROR("Invalid DRM display specified: %s. Valid options are HDMI-A-1, HDMI-A-2, DSI-1, DSI-2.\n", optarg);
2022+
return false;
2023+
}
2024+
break;
2025+
20002026
case 'h': printf("%s", usage); return false;
20012027

20022028
case '?':
@@ -2099,6 +2125,25 @@ static void on_drmdev_close(int fd, void *fd_metadata, void *userdata) {
20992125

21002126
static const struct drmdev_interface drmdev_interface = { .open = on_drmdev_open, .close = on_drmdev_close };
21012127

2128+
bool parse_drm_vout_display(const char *display, int *type_out, int *type_id_out) {
2129+
if (strcmp(display, "HDMI-A-1") == 0) {
2130+
*type_out = DRM_MODE_CONNECTOR_HDMIA;
2131+
*type_id_out = 1;
2132+
} else if (strcmp(display, "HDMI-A-2") == 0) {
2133+
*type_out = DRM_MODE_CONNECTOR_HDMIA;
2134+
*type_id_out = 2;
2135+
} else if (strcmp(display, "DSI-1") == 0) {
2136+
*type_out = DRM_MODE_CONNECTOR_DSI;
2137+
*type_id_out = 1;
2138+
} else if (strcmp(display, "DSI-2") == 0) {
2139+
*type_out = DRM_MODE_CONNECTOR_DSI;
2140+
*type_id_out = 2;
2141+
} else {
2142+
return false;
2143+
}
2144+
return true;
2145+
}
2146+
21022147
static struct drmdev *find_drmdev(struct libseat *libseat) {
21032148
struct drm_connector *connector;
21042149
struct drmdev *drmdev;
@@ -2137,7 +2182,21 @@ static struct drmdev *find_drmdev(struct libseat *libseat) {
21372182

21382183
for_each_connector_in_drmdev(drmdev, connector) {
21392184
if (connector->variable_state.connection_state == kConnected_DrmConnectionState) {
2140-
goto found_connected_connector;
2185+
if (flutterpi->drm_vout_display != NULL) {
2186+
// We only want to use the display that was specified on the command line.
2187+
int expected_type, expected_type_id;
2188+
if (!parse_drm_vout_display(flutterpi->drm_vout_display, &expected_type, &expected_type_id)) {
2189+
continue;
2190+
}
2191+
2192+
if (connector->type == expected_type && connector->type_id == expected_type_id) {
2193+
goto found_connected_connector;
2194+
} else {
2195+
continue;
2196+
}
2197+
} else {
2198+
goto found_connected_connector;
2199+
}
21412200
}
21422201
}
21432202
LOG_ERROR("Device \"%s\" doesn't have a display connected. Skipping.\n", device->nodes[DRM_NODE_PRIMARY]);
@@ -2335,6 +2394,8 @@ struct flutterpi *flutterpi_new_from_args(int argc, char **argv) {
23352394
goto fail_free_fpi;
23362395
}
23372396

2397+
fpi->drm_vout_display = cmd_args.drm_vout_display ? strdup(cmd_args.drm_vout_display) : NULL;
2398+
23382399
#ifndef HAVE_VULKAN
23392400
if (cmd_args.use_vulkan == true) {
23402401
LOG_ERROR("ERROR: --vulkan was specified, but flutter-pi was built without vulkan support.\n");

src/flutter-pi.h

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

142142
bool dummy_display;
143143
struct vec2i dummy_display_size;
144+
145+
char *drm_vout_display;
144146
};
145147

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

0 commit comments

Comments
 (0)