-
-
Notifications
You must be signed in to change notification settings - Fork 169
Add --drm-vout-display Parameter #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This PR is redeay for review. |
Hey, thanks for the contribution! I'm currently on vacation so didn't have time to give it a thorough look yet, but I'll be back in a few days and then I'll review. |
though one small thing is the name of the cmdline argument, I'd just call it |
Good catch! Changed to |
} | ||
return true; | ||
} | ||
|
||
static struct drmdev *find_drmdev(struct libseat *libseat) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static struct drmdev *find_drmdev(struct libseat *libseat) { | |
static struct drmdev *find_drmdev(struct libseat *libseat, const char *connector_name) { |
I think passing via argument here is better, generally I don't want to add new code that uses the flutterpi global variable. (Especially since find_drmdev
is called from the initialization of that same flutterpi
instance, so it's very easy to make mistakes and e.g. use something before it's initialized)
@@ -2137,7 +2182,21 @@ static struct drmdev *find_drmdev(struct libseat *libseat) { | |||
|
|||
for_each_connector_in_drmdev(drmdev, connector) { | |||
if (connector->variable_state.connection_state == kConnected_DrmConnectionState) { | |||
goto found_connected_connector; | |||
if (flutterpi->drm_vout_display != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (flutterpi->drm_vout_display != NULL) { | |
if (connector_name != NULL) { |
int expected_type, expected_type_id; | ||
if (!parse_drm_vout_display(flutterpi->drm_vout_display, &expected_type, &expected_type_id)) { | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a bit counter-intuitive but what could also be done here is converting the current connector to a string and comparing that to the passed in name:
char *connector_type_name = drmModeGetConnectorTypeName(connector->type);
if (connector_type_name == null) continue;
char *connector_name = NULL;
int ok = asprintf(&connector_name, "%s-%d", connector_name, connector->type_id);
if (ok == -1) continue;
if (strcmp(connector_name) == desired_connector_name)) {
// found connector
}
Has the benefit that it's compatible to all the connectors: https://github.com/torvalds/linux/blob/master/include/uapi/drm/drm_mode.h#L403-L423 and not just the ones present on the Pi, and it's also future-proof since we don't need to change the code to recognize new connector types, drmModeGetConnectorTypeName
(which is from libdrm
, not flutter-pi) will handle that for us. But that's your choice, I think this is good enough for now. :)
I think there's some more functionality required unfortunately :/ This code currently helps choosing the correct DRM device node, by looking if the desired connector is present. However, individual DRM device nodes can (and will) have multiple displays attached. So only selecting the correct device node is not enough, you also need to make the rest of the code use the correct display of that node. This code here chooses the DRM connector that should be used for display: Lines 724 to 869 in c7e0ff5
It has a |
Add
--drm-vout-display
Parameter for Selecting Specific DRM OutputsThis pull request introduces a new command-line parameter,
--drm-vout-display
, to allow users to specify the desired DRM output display when running Flutter applications on Raspberry Pi.This change is implemented in response to issue #201.
Supported Options
The supported values for this parameter are:
HDMI-A-1
HDMI-A-2
DSI-1
DSI-2
If the
--drm-vout-display
parameter is not provided, the code will behave as before, automatically selecting the first available connected display.Key Changes
New Command-Line Argument
--drm-vout-display
option to the command-line arguments.Validation and Parsing
HDMI-A-1
,HDMI-A-2
,DSI-1
,DSI-2
).flutterpi
struct now includes adrm_vout_display
field to store the selected display.Behavior
Documentation
--help
output to include the new--drm-vout-display
option.Example Usage
Backward Compatibility
This change is fully backward-compatible. If the
--drm-vout-display
parameter is not provided, the application will function as it did previously, automatically selecting the first available connected display.Motivation
This feature provides users with greater control over which display output is used, especially in multi-display setups or when specific outputs are required for certain use cases.