mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-07 17:48:01 +02:00
Merge branch 'drm-guess-device-scale' into 'main'
drm: Guess device-scale when using simpledrm See merge request plymouth/plymouth!242
This commit is contained in:
commit
4a6fcf0b52
3 changed files with 55 additions and 9 deletions
|
|
@ -868,12 +868,20 @@ ply_set_device_scale (int device_scale)
|
|||
/* The minimum resolution at which we turn on a device-scale of 2 */
|
||||
#define HIDPI_LIMIT 192
|
||||
#define HIDPI_MIN_HEIGHT 1200
|
||||
#define HIDPI_MIN_WIDTH 2560 /* For heuristic / guessed device-scale */
|
||||
|
||||
int
|
||||
ply_get_device_scale (uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t width_mm,
|
||||
uint32_t height_mm)
|
||||
/*
|
||||
* If we have guessed the scale once, keep guessing to avoid
|
||||
* changing the scale on simpledrm -> native driver switch.
|
||||
*/
|
||||
static bool guess_device_scale;
|
||||
|
||||
static int
|
||||
get_device_scale (uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t width_mm,
|
||||
uint32_t height_mm,
|
||||
bool guess)
|
||||
{
|
||||
int device_scale;
|
||||
double dpi_x, dpi_y;
|
||||
|
|
@ -890,6 +898,9 @@ ply_get_device_scale (uint32_t width,
|
|||
if (height < HIDPI_MIN_HEIGHT)
|
||||
return 1;
|
||||
|
||||
if (guess)
|
||||
return (width >= HIDPI_MIN_WIDTH) ? 2 : 1;
|
||||
|
||||
/* Somebody encoded the aspect ratio (16/9 or 16/10)
|
||||
* instead of the physical size */
|
||||
if ((width_mm == 160 && height_mm == 90) ||
|
||||
|
|
@ -911,6 +922,23 @@ ply_get_device_scale (uint32_t width,
|
|||
return device_scale;
|
||||
}
|
||||
|
||||
int
|
||||
ply_get_device_scale (uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t width_mm,
|
||||
uint32_t height_mm)
|
||||
{
|
||||
return get_device_scale (width, height, width_mm, height_mm,
|
||||
guess_device_scale);
|
||||
}
|
||||
|
||||
int ply_guess_device_scale (uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
guess_device_scale = true;
|
||||
return get_device_scale (width, height, 0, 0, true);
|
||||
}
|
||||
|
||||
static const char *
|
||||
ply_get_kernel_command_line (void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -127,6 +127,9 @@ int ply_get_device_scale (uint32_t width,
|
|||
uint32_t width_mm,
|
||||
uint32_t height_mm);
|
||||
|
||||
int ply_guess_device_scale (uint32_t width,
|
||||
uint32_t height);
|
||||
|
||||
const char *ply_kernel_command_line_get_string_after_prefix (const char *prefix);
|
||||
bool ply_kernel_command_line_has_argument (const char *argument);
|
||||
void ply_kernel_command_line_override (const char *command_line);
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ struct _ply_renderer_backend
|
|||
ply_terminal_t *terminal;
|
||||
|
||||
int device_fd;
|
||||
bool simpledrm;
|
||||
char *device_name;
|
||||
drmModeRes *resources;
|
||||
|
||||
|
|
@ -415,7 +416,7 @@ get_primary_plane_rotation (ply_renderer_backend_t *backend,
|
|||
drmModePlaneResPtr plane_resources;
|
||||
drmModePropertyPtr prop;
|
||||
drmModePlanePtr plane;
|
||||
uint64_t rotation;
|
||||
uint64_t rotation = 0;
|
||||
uint32_t i, j;
|
||||
int rotation_prop_id = -1;
|
||||
int primary_id = -1;
|
||||
|
|
@ -971,6 +972,7 @@ on_active_vt_changed (ply_renderer_backend_t *backend)
|
|||
static bool
|
||||
load_driver (ply_renderer_backend_t *backend)
|
||||
{
|
||||
drmVersion *version;
|
||||
int device_fd;
|
||||
|
||||
ply_trace ("Opening '%s'", backend->device_name);
|
||||
|
|
@ -981,6 +983,15 @@ load_driver (ply_renderer_backend_t *backend)
|
|||
return false;
|
||||
}
|
||||
|
||||
version = drmGetVersion (device_fd);
|
||||
if (version) {
|
||||
ply_trace ("drm driver: %s", version->name);
|
||||
if (strcmp (version->name, "simpledrm") == 0)
|
||||
backend->simpledrm = true;
|
||||
|
||||
drmFreeVersion (version);
|
||||
}
|
||||
|
||||
backend->device_fd = device_fd;
|
||||
|
||||
drmDropMaster (device_fd);
|
||||
|
|
@ -1219,9 +1230,13 @@ get_output_info (ply_renderer_backend_t *backend,
|
|||
mode = &connector->modes[0];
|
||||
}
|
||||
output->mode = *mode;
|
||||
output->device_scale = ply_get_device_scale (mode->hdisplay, mode->vdisplay,
|
||||
(!has_90_rotation) ? connector->mmWidth : connector->mmHeight,
|
||||
(!has_90_rotation) ? connector->mmHeight : connector->mmWidth);
|
||||
|
||||
if (backend->simpledrm)
|
||||
output->device_scale = ply_guess_device_scale (mode->hdisplay, mode->vdisplay);
|
||||
else
|
||||
output->device_scale = ply_get_device_scale (mode->hdisplay, mode->vdisplay,
|
||||
(!has_90_rotation) ? connector->mmWidth : connector->mmHeight,
|
||||
(!has_90_rotation) ? connector->mmHeight : connector->mmWidth);
|
||||
output->connector_type = connector->connector_type;
|
||||
output->connected = true;
|
||||
out:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue