/* 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;
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) ||
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)
{
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);