aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_plane.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_plane.c')
-rw-r--r--drivers/gpu/drm/drm_plane.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index affe1cfed009..e6231947f987 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -1231,3 +1231,76 @@ out:
return ret;
}
+
+struct drm_property *
+drm_create_scaling_filter_prop(struct drm_device *dev,
+ unsigned int supported_filters)
+{
+ struct drm_property *prop;
+ static const struct drm_prop_enum_list props[] = {
+ { DRM_SCALING_FILTER_DEFAULT, "Default" },
+ { DRM_SCALING_FILTER_NEAREST_NEIGHBOR, "Nearest Neighbor" },
+ };
+ unsigned int valid_mode_mask = BIT(DRM_SCALING_FILTER_DEFAULT) |
+ BIT(DRM_SCALING_FILTER_NEAREST_NEIGHBOR);
+ int i;
+
+ if (WARN_ON((supported_filters & ~valid_mode_mask) ||
+ ((supported_filters & BIT(DRM_SCALING_FILTER_DEFAULT)) == 0)))
+ return ERR_PTR(-EINVAL);
+
+ prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,
+ "SCALING_FILTER",
+ hweight32(supported_filters));
+ if (!prop)
+ return ERR_PTR(-ENOMEM);
+
+ for (i = 0; i < ARRAY_SIZE(props); i++) {
+ int ret;
+
+ if (!(BIT(props[i].type) & supported_filters))
+ continue;
+
+ ret = drm_property_add_enum(prop, props[i].type,
+ props[i].name);
+
+ if (ret) {
+ drm_property_destroy(dev, prop);
+
+ return ERR_PTR(ret);
+ }
+ }
+
+ return prop;
+}
+
+/**
+ * drm_plane_create_scaling_filter_property - create a new scaling filter
+ * property
+ *
+ * @plane: drm plane
+ * @supported_filters: bitmask of supported scaling filters, must include
+ * BIT(DRM_SCALING_FILTER_DEFAULT).
+ *
+ * This function lets driver to enable the scaling filter property on a given
+ * plane.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
+ unsigned int supported_filters)
+{
+ struct drm_property *prop =
+ drm_create_scaling_filter_prop(plane->dev, supported_filters);
+
+ if (IS_ERR(prop))
+ return PTR_ERR(prop);
+
+ drm_object_attach_property(&plane->base, prop,
+ DRM_SCALING_FILTER_DEFAULT);
+ plane->scaling_filter_property = prop;
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);