diff options
author | Simon Ser <contact@emersion.fr> | 2022-09-05 16:56:47 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-09-22 09:38:27 +0200 |
commit | 0cabc83046474618b9ed619649b819dc7ef23d28 (patch) | |
tree | fb6126e68ea7b75b2cc96e0015caffb38e96f15e | |
parent | 2178573b0a5a8160564da1fd85c1f16f7d4d7bdd (diff) |
backend/drm: pass through mode picture aspect ratio
-rw-r--r-- | backend/drm/drm.c | 1 | ||||
-rw-r--r-- | backend/drm/util.c | 19 | ||||
-rw-r--r-- | include/backend/drm/util.h | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index d113aa12..3b14c63e 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -760,6 +760,7 @@ static struct wlr_drm_mode *drm_mode_create(const drmModeModeInfo *modeinfo) { mode->wlr_mode.width = mode->drm_mode.hdisplay; mode->wlr_mode.height = mode->drm_mode.vdisplay; mode->wlr_mode.refresh = calculate_refresh_rate(modeinfo); + mode->wlr_mode.picture_aspect_ratio = get_picture_aspect_ratio(modeinfo); if (modeinfo->type & DRM_MODE_TYPE_PREFERRED) { mode->wlr_mode.preferred = true; } diff --git a/backend/drm/util.c b/backend/drm/util.c index 2083e617..3f460317 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -30,6 +30,25 @@ int32_t calculate_refresh_rate(const drmModeModeInfo *mode) { return refresh; } +enum wlr_output_mode_aspect_ratio get_picture_aspect_ratio(const drmModeModeInfo *mode) { + switch (mode->flags & DRM_MODE_FLAG_PIC_AR_MASK) { + case DRM_MODE_FLAG_PIC_AR_NONE: + return WLR_OUTPUT_MODE_ASPECT_RATIO_NONE; + case DRM_MODE_FLAG_PIC_AR_4_3: + return WLR_OUTPUT_MODE_ASPECT_RATIO_4_3; + case DRM_MODE_FLAG_PIC_AR_16_9: + return WLR_OUTPUT_MODE_ASPECT_RATIO_16_9; + case DRM_MODE_FLAG_PIC_AR_64_27: + return WLR_OUTPUT_MODE_ASPECT_RATIO_64_27; + case DRM_MODE_FLAG_PIC_AR_256_135: + return WLR_OUTPUT_MODE_ASPECT_RATIO_256_135; + default: + wlr_log(WLR_ERROR, "Unknown mode picture aspect ratio: %u", + mode->flags & DRM_MODE_FLAG_PIC_AR_MASK); + return WLR_OUTPUT_MODE_ASPECT_RATIO_NONE; + } +} + static const char *get_manufacturer(struct udev_hwdb *hwdb, uint16_t code) { static char pnp_id[4]; diff --git a/include/backend/drm/util.h b/include/backend/drm/util.h index fc632e12..0d4c3d74 100644 --- a/include/backend/drm/util.h +++ b/include/backend/drm/util.h @@ -9,6 +9,7 @@ struct wlr_drm_connector; // Calculates a more accurate refresh rate (mHz) than what mode itself provides int32_t calculate_refresh_rate(const drmModeModeInfo *mode); +enum wlr_output_mode_aspect_ratio get_picture_aspect_ratio(const drmModeModeInfo *mode); // Populates the make/model/phys_{width,height} of output from the edid data void parse_edid(struct wlr_drm_connector *conn, size_t len, const uint8_t *data); |