[RFC weston 2/3] drm-backend: drm-backend changes for setting scaling_fitler
Sameer Lattannavar
sameer.lattannavar at intel.com
Fri Dec 20 06:56:08 UTC 2019
Modify existing drm-backend to set_scaling_filter property that
client has requested compositor to do.
drm-backend calls drmset property api of libdrm to do so.
Signed-off-by: Sameer Lattannavar <sameer.lattannavar at intel.com>
---
libweston/backend-drm/drm-internal.h | 18 ++++++++++++
libweston/backend-drm/drm.c | 41 ++++++++++++++++++++++++++--
libweston/backend-drm/kms.c | 14 ++++++++++
3 files changed, 71 insertions(+), 2 deletions(-)
diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h
index 2384a9ac..6cda84f1 100644
--- a/libweston/backend-drm/drm-internal.h
+++ b/libweston/backend-drm/drm-internal.h
@@ -224,12 +224,24 @@ enum wdrm_dpms_state {
WDRM_DPMS_STATE__COUNT
};
+enum wdrm_scaling_filters {
+ WDRM_SCALING_FILTER_DEFAULT,
+ WDRM_SCALING_FILTER_MEDIUM,
+ WDRM_SCALING_FILTER_BILINEAR,
+ WDRM_SCALING_FILTER_NN,
+ WDRM_SCALING_FILTER_NN_IS_ONLY,
+ WDRM_SCALING_FILTER_EDGE_ENHANCE,
+ WDRM_SCALING_FILTER_INVALID,
+ WDRM_SCALING_FILTER__COUNT
+};
+
/**
* List of properties attached to DRM CRTCs
*/
enum wdrm_crtc_property {
WDRM_CRTC_MODE_ID = 0,
WDRM_CRTC_ACTIVE,
+ WDRM_SCALING_FILTER,
WDRM_CRTC__COUNT
};
@@ -484,6 +496,12 @@ struct drm_output {
/* Holds the properties for the CRTC */
struct drm_property_info props_crtc[WDRM_CRTC__COUNT];
+ /*To flag if HW supports the Scaling filter as one of the CRTC
+ *properties for scailing the output
+ */
+ bool flag_scaling_filter;
+ int scaling_filter_type;
+
bool page_flip_pending;
bool atomic_complete_pending;
bool destroy_pending;
diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
index e0b1cbd7..6e6ddd72 100644
--- a/libweston/backend-drm/drm.c
+++ b/libweston/backend-drm/drm.c
@@ -768,7 +768,7 @@ drm_plane_create(struct drm_backend *b, const drmModePlane *kplane,
WDRM_PLANE_TYPE__COUNT);
zpos_range_values =
- drm_property_get_range_values(&plane->props[WDRM_PLANE_ZPOS],
+ drm_property_get_range_values(&plane->props[WDRM_PLANE_ZPOS],
props);
if (zpos_range_values) {
@@ -1120,6 +1120,34 @@ drm_set_dpms(struct weston_output *output_base, enum dpms_enum level)
weston_log("drm_set_dpms: couldn't disable output?\n");
}
+/*
+ * If we are upscaling, and the scaling ratios are integer, we can
+ * pick nearest-neighbour method in HW for scaling, which produces
+ * blurless outputs in such scenarios.
+ */
+static void
+drm_set_scaling_filter(struct weston_output *output_base,
+ enum wdrm_scaling_filters filter)
+{
+ weston_log("drm_set_integer_scaling: to set the scaling_filter\n");
+ struct drm_output *output = to_drm_output(output_base);
+ struct drm_backend *b = to_drm_backend(output_base->compositor);
+ int ret;
+
+ if (output->flag_scaling_filter) {
+ ret = drmModeObjectSetProperty(b->drm.fd, output->crtc_id,
+ DRM_MODE_OBJECT_CRTC,
+ output->props_crtc->prop_id,
+ output->scaling_filter_type);
+ if (ret) {
+ weston_log("drmModeObjectSetProperty: FAILED!!!\n");
+ output->scaling_filter_type =
+ WDRM_SCALING_FILTER_DEFAULT;
+ }
+ weston_log("drmModeObjectSetProperty: Succeeded\n");
+ }
+}
+
static const char * const connector_type_names[] = {
[DRM_MODE_CONNECTOR_Unknown] = "Unknown",
[DRM_MODE_CONNECTOR_VGA] = "VGA",
@@ -1592,7 +1620,7 @@ drm_output_init_crtc(struct drm_output *output, drmModeRes *resources)
{
struct drm_backend *b = to_drm_backend(output->base.compositor);
drmModeObjectPropertiesPtr props;
- int i;
+ int i, x;
assert(output->crtc_id == 0);
@@ -1614,6 +1642,14 @@ drm_output_init_crtc(struct drm_output *output, drmModeRes *resources)
}
drm_property_info_populate(b, crtc_props, output->props_crtc,
WDRM_CRTC__COUNT, props);
+ if (output->props_crtc) {
+ for (x = 0; x < WDRM_CRTC__COUNT; x++) {
+ if (strcmp(output->props_crtc->name, "SCALING_FILTERS"))
+ continue;
+ output->flag_scaling_filter = true;
+ output->scaling_filter_type = WDRM_SCALING_FILTER_NN;
+ }
+ }
drmModeFreeObjectProperties(props);
output->scanout_plane =
@@ -1732,6 +1768,7 @@ drm_output_enable(struct weston_output *base)
output->base.set_dpms = drm_set_dpms;
output->base.switch_mode = drm_output_switch_mode;
output->base.set_gamma = drm_output_set_gamma;
+ output->base.set_scaling_filter = drm_set_scaling_filter;
if (output->cursor_plane)
weston_compositor_stack_plane(b->compositor,
diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c
index 192435c7..138b7bf0 100644
--- a/libweston/backend-drm/kms.c
+++ b/libweston/backend-drm/kms.c
@@ -137,9 +137,23 @@ const struct drm_property_info connector_props[] = {
},
};
+static struct drm_property_enum_info scaling_filter_enums[] = {
+ [WDRM_SCALING_FILTER_DEFAULT] = { .name = "Default" },
+ [WDRM_SCALING_FILTER_MEDIUM] = { .name = "Medium" },
+ [WDRM_SCALING_FILTER_BILINEAR] = { .name = "Bilinear" },
+ [WDRM_SCALING_FILTER_NN] = { .name = "Nearest Neighbor" },
+ [WDRM_SCALING_FILTER_NN_IS_ONLY] = { .name = "Integer Mode Scaling" },
+ [WDRM_SCALING_FILTER_INVALID] = { .name = "Invalid" },
+};
+
const struct drm_property_info crtc_props[] = {
[WDRM_CRTC_MODE_ID] = { .name = "MODE_ID", },
[WDRM_CRTC_ACTIVE] = { .name = "ACTIVE", },
+ [WDRM_SCALING_FILTER] = {
+ .name = "SCALING_FILTERS",
+ .enum_values = scaling_filter_enums,
+ .num_enum_values = WDRM_SCALING_FILTER__COUNT,
+ },
};
--
2.17.1
More information about the wayland-devel
mailing list