mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
monitor: Include the refresh rate mode in the mode spec
Variable refresh rate modes are preferred over their fixed refresh rate counterparts. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1154>
This commit is contained in:
parent
be36c18787
commit
1721dad5ec
@ -622,16 +622,21 @@ generate_mode_id (MetaMonitorModeSpec *monitor_mode_spec)
|
|||||||
{
|
{
|
||||||
gboolean is_interlaced;
|
gboolean is_interlaced;
|
||||||
char rate_str[G_ASCII_DTOSTR_BUF_SIZE];
|
char rate_str[G_ASCII_DTOSTR_BUF_SIZE];
|
||||||
|
gboolean is_vrr;
|
||||||
|
|
||||||
is_interlaced = !!(monitor_mode_spec->flags & META_CRTC_MODE_FLAG_INTERLACE);
|
is_interlaced = !!(monitor_mode_spec->flags & META_CRTC_MODE_FLAG_INTERLACE);
|
||||||
g_ascii_formatd (rate_str, sizeof (rate_str),
|
g_ascii_formatd (rate_str, sizeof (rate_str),
|
||||||
"%.3f", monitor_mode_spec->refresh_rate);
|
"%.3f", monitor_mode_spec->refresh_rate);
|
||||||
|
|
||||||
return g_strdup_printf ("%dx%d%s@%s",
|
is_vrr = monitor_mode_spec->refresh_rate_mode ==
|
||||||
|
META_CRTC_REFRESH_RATE_MODE_VARIABLE;
|
||||||
|
|
||||||
|
return g_strdup_printf ("%dx%d%s@%s%s",
|
||||||
monitor_mode_spec->width,
|
monitor_mode_spec->width,
|
||||||
monitor_mode_spec->height,
|
monitor_mode_spec->height,
|
||||||
is_interlaced ? "i" : "",
|
is_interlaced ? "i" : "",
|
||||||
rate_str);
|
rate_str,
|
||||||
|
is_vrr ? "+vrr" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -678,6 +683,7 @@ meta_monitor_create_spec (MetaMonitor *monitor,
|
|||||||
.width = width,
|
.width = width,
|
||||||
.height = height,
|
.height = height,
|
||||||
.refresh_rate = crtc_mode_info->refresh_rate,
|
.refresh_rate = crtc_mode_info->refresh_rate,
|
||||||
|
.refresh_rate_mode = crtc_mode_info->refresh_rate_mode,
|
||||||
.flags = crtc_mode_info->flags & HANDLED_CRTC_MODE_FLAGS
|
.flags = crtc_mode_info->flags & HANDLED_CRTC_MODE_FLAGS
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1141,6 +1147,9 @@ find_tiled_crtc_mode (MetaOutput *output,
|
|||||||
if (crtc_mode_info->refresh_rate != reference_crtc_mode_info->refresh_rate)
|
if (crtc_mode_info->refresh_rate != reference_crtc_mode_info->refresh_rate)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (crtc_mode_info->refresh_rate_mode != reference_crtc_mode_info->refresh_rate_mode)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (crtc_mode_info->flags != reference_crtc_mode_info->flags)
|
if (crtc_mode_info->flags != reference_crtc_mode_info->flags)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1255,9 +1264,24 @@ generate_tiled_monitor_modes (MetaMonitorTiled *monitor_tiled)
|
|||||||
|
|
||||||
if (!monitor_priv->preferred_mode)
|
if (!monitor_priv->preferred_mode)
|
||||||
{
|
{
|
||||||
if (!best_mode ||
|
if (!best_mode)
|
||||||
mode->spec.refresh_rate > best_mode->spec.refresh_rate)
|
{
|
||||||
best_mode = mode;
|
best_mode = mode;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode->spec.refresh_rate > best_mode->spec.refresh_rate)
|
||||||
|
{
|
||||||
|
best_mode = mode;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode->spec.refresh_rate == best_mode->spec.refresh_rate &&
|
||||||
|
mode->spec.refresh_rate_mode > best_mode->spec.refresh_rate_mode)
|
||||||
|
{
|
||||||
|
best_mode = mode;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1443,6 +1467,13 @@ find_best_mode (MetaMonitor *monitor)
|
|||||||
best_mode = mode;
|
best_mode = mode;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode->spec.refresh_rate == best_mode->spec.refresh_rate &&
|
||||||
|
mode->spec.refresh_rate_mode > best_mode->spec.refresh_rate_mode)
|
||||||
|
{
|
||||||
|
best_mode = mode;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return best_mode;
|
return best_mode;
|
||||||
@ -1711,6 +1742,8 @@ meta_monitor_mode_spec_equals (MetaMonitorModeSpec *monitor_mode_spec,
|
|||||||
monitor_mode_spec->height == other_monitor_mode_spec->height &&
|
monitor_mode_spec->height == other_monitor_mode_spec->height &&
|
||||||
ABS (monitor_mode_spec->refresh_rate -
|
ABS (monitor_mode_spec->refresh_rate -
|
||||||
other_monitor_mode_spec->refresh_rate) < MAXIMUM_REFRESH_RATE_DIFF &&
|
other_monitor_mode_spec->refresh_rate) < MAXIMUM_REFRESH_RATE_DIFF &&
|
||||||
|
monitor_mode_spec->refresh_rate_mode ==
|
||||||
|
other_monitor_mode_spec->refresh_rate_mode &&
|
||||||
monitor_mode_spec->flags == other_monitor_mode_spec->flags);
|
monitor_mode_spec->flags == other_monitor_mode_spec->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2119,6 +2152,12 @@ meta_monitor_mode_get_refresh_rate (MetaMonitorMode *monitor_mode)
|
|||||||
return monitor_mode->spec.refresh_rate;
|
return monitor_mode->spec.refresh_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaCrtcRefreshRateMode
|
||||||
|
meta_monitor_mode_get_refresh_rate_mode (MetaMonitorMode *monitor_mode)
|
||||||
|
{
|
||||||
|
return monitor_mode->spec.refresh_rate_mode;
|
||||||
|
}
|
||||||
|
|
||||||
MetaCrtcModeFlag
|
MetaCrtcModeFlag
|
||||||
meta_monitor_mode_get_flags (MetaMonitorMode *monitor_mode)
|
meta_monitor_mode_get_flags (MetaMonitorMode *monitor_mode)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@ typedef struct _MetaMonitorModeSpec
|
|||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
float refresh_rate;
|
float refresh_rate;
|
||||||
|
MetaCrtcRefreshRateMode refresh_rate_mode;
|
||||||
MetaCrtcModeFlag flags;
|
MetaCrtcModeFlag flags;
|
||||||
} MetaMonitorModeSpec;
|
} MetaMonitorModeSpec;
|
||||||
|
|
||||||
@ -252,6 +253,9 @@ void meta_monitor_mode_get_resolution (MetaMonitorMode *monitor_mode,
|
|||||||
META_EXPORT_TEST
|
META_EXPORT_TEST
|
||||||
float meta_monitor_mode_get_refresh_rate (MetaMonitorMode *monitor_mode);
|
float meta_monitor_mode_get_refresh_rate (MetaMonitorMode *monitor_mode);
|
||||||
|
|
||||||
|
META_EXPORT_TEST
|
||||||
|
MetaCrtcRefreshRateMode meta_monitor_mode_get_refresh_rate_mode (MetaMonitorMode *monitor_mode);
|
||||||
|
|
||||||
META_EXPORT_TEST
|
META_EXPORT_TEST
|
||||||
MetaCrtcModeFlag meta_monitor_mode_get_flags (MetaMonitorMode *monitor_mode);
|
MetaCrtcModeFlag meta_monitor_mode_get_flags (MetaMonitorMode *monitor_mode);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user