Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3336440ybv; Mon, 24 Feb 2020 23:17:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxe4dO5VLl3TfBLFDd2+9bZB09+oAxN7mOiN+1Pmwa+vn1k6x/57JLZcfUSL4LtJfY+DL5w X-Received: by 2002:a9d:1ca3:: with SMTP id l35mr42374346ota.271.1582615040130; Mon, 24 Feb 2020 23:17:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582615040; cv=none; d=google.com; s=arc-20160816; b=WjUQdf15G2j1MRemy1Y2sy7oYEYHU7mh3QW2REQR0K74CZSbgW85n8uV0ktlpAP0uM dSRFTegby6Bc4dyZ/MdWyjuceNIiCV2yJbSdM/kwF4IPSe2GQoTuo5XMB4E0ZMBCdkIo Gii6Lam9tzq7+vkI7WqCBGMr2/E/lf0lNpfKTYRHPaV2ao/u/5f5FttnhlJHho/ykVIa fGbkR95G5/hyrp1Em3TWLCmyGRy4tXDKIdEekG7PR/zy7FbXrgDX5kZrmPM+gLZ6xPOa OKpS2ShlVbRGq0nSBwEqCNvGsGnEXmV80vgc2Q2kPiKnEefGLA2cht+0fp+cwW9wgEDL yidg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2x+4jBFk2fDqxwy+orHGc0jRtH+t9PTIHwcxKHETFpg=; b=PpZjwIIu/SIfA2Rb+LvkAWKJXph3vgmlroYAYMCSgIreCfGuUsqKbxYcelbeRUKatN 51s9pTDg0QDzN2MsxbJ/zTYGpnm6kgYT6vswbly2ORS8LWzY6FAdzeuSwqfZ5H5GvfMi PpPSF5cm5b85xSrFkwk1nSiiGy7w08zb0uRyIvBOMvFQj/PPQPMmwMhq+0/jR5PBVbRv iDE6zrc70Bc8SBDvoUxAg91+U18VwV5H9tXPcxW2kBqvChSyAdayK6ZJL7GoHDymRPm1 N/Y+gH+DXQiYmVeKCgblsA7Hp8kPs/PNPeWijkeHxzRHflWGm5Jq8skUrYlSQPw/qxWT MkiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l65si5980412oih.23.2020.02.24.23.17.08; Mon, 24 Feb 2020 23:17:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729344AbgBYHQZ (ORCPT + 99 others); Tue, 25 Feb 2020 02:16:25 -0500 Received: from mga14.intel.com ([192.55.52.115]:17888 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbgBYHQZ (ORCPT ); Tue, 25 Feb 2020 02:16:25 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Feb 2020 23:16:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,483,1574150400"; d="scan'208";a="230068112" Received: from plaxmina-desktop.iind.intel.com ([10.145.162.62]) by fmsmga007.fm.intel.com with ESMTP; 24 Feb 2020 23:16:19 -0800 From: Pankaj Bharadiya To: jani.nikula@linux.intel.com, daniel@ffwll.ch, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ville.syrjala@linux.intel.com, airlied@linux.ie, maarten.lankhorst@linux.intel.com, tzimmermann@suse.de, mripard@kernel.org, mihail.atanassov@arm.com Cc: pankaj.laxminarayan.bharadiya@intel.com, linux-kernel@vger.kernel.org, ankit.k.nautiyal@intel.com Subject: [RFC][PATCH 1/5] drm: Introduce scaling filter property Date: Tue, 25 Feb 2020 12:35:41 +0530 Message-Id: <20200225070545.4482-2-pankaj.laxminarayan.bharadiya@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200225070545.4482-1-pankaj.laxminarayan.bharadiya@intel.com> References: <20200225070545.4482-1-pankaj.laxminarayan.bharadiya@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce new scaling filter property to allow userspace to select the driver's default scaling filter or Nearest-neighbor(NN) filter for upscaling operations on crtc/plane. Drivers can set up this property for a plane by calling drm_plane_enable_scaling_filter() and for a CRTC by calling drm_crtc_enable_scaling_filter(). NN filter works by filling in the missing color values in the upscaled image with that of the coordinate-mapped nearest source pixel value. NN filter for integer multiple scaling can be particularly useful for for pixel art games that rely on sharp, blocky images to deliver their distinctive look. Signed-off-by: Pankaj Bharadiya Signed-off-by: Shashank Sharma Signed-off-by: Ankit Nautiyal --- drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++++ drivers/gpu/drm/drm_crtc.c | 16 ++++++++++++++ drivers/gpu/drm/drm_mode_config.c | 13 ++++++++++++ drivers/gpu/drm/drm_plane.c | 35 +++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 10 +++++++++ include/drm/drm_mode_config.h | 6 ++++++ include/drm/drm_plane.h | 14 +++++++++++++ 7 files changed, 102 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index a1e5e262bae2..4e3c1f3176e4 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -435,6 +435,8 @@ static int drm_atomic_crtc_set_property(struct drm_crtc *crtc, return ret; } else if (property == config->prop_vrr_enabled) { state->vrr_enabled = val; + } else if (property == config->scaling_filter_property) { + state->scaling_filter = val; } else if (property == config->degamma_lut_property) { ret = drm_atomic_replace_property_blob_from_id(dev, &state->degamma_lut, @@ -503,6 +505,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc, *val = (state->gamma_lut) ? state->gamma_lut->base.id : 0; else if (property == config->prop_out_fence_ptr) *val = 0; + else if (property == config->scaling_filter_property) + *val = state->scaling_filter; else if (crtc->funcs->atomic_get_property) return crtc->funcs->atomic_get_property(crtc, state, property, val); else @@ -583,6 +587,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, sizeof(struct drm_rect), &replaced); return ret; + } else if (property == config->scaling_filter_property) { + state->scaling_filter = val; } else if (plane->funcs->atomic_set_property) { return plane->funcs->atomic_set_property(plane, state, property, val); @@ -641,6 +647,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane, } else if (property == config->prop_fb_damage_clips) { *val = (state->fb_damage_clips) ? state->fb_damage_clips->base.id : 0; + } else if (property == config->scaling_filter_property) { + *val = state->scaling_filter; } else if (plane->funcs->atomic_get_property) { return plane->funcs->atomic_get_property(plane, state, property, val); } else { diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 4936e1080e41..1ce7b2ac9eb5 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -748,3 +748,19 @@ int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj, return ret; } + +/** + * drm_crtc_enable_scaling_filter - Enables crtc scaling filter property. + * @crtc: CRTC on which to enable scaling filter property. + * + * This function lets driver to enable the scaling filter property on a crtc. + */ +void drm_crtc_enable_scaling_filter(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + + drm_object_attach_property(&crtc->base, + dev->mode_config.scaling_filter_property, + 0); +} +EXPORT_SYMBOL(drm_crtc_enable_scaling_filter); diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 08e6eff6a179..1024a8d1cd5d 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -214,6 +214,11 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] = { { DRM_PLANE_TYPE_CURSOR, "Cursor" }, }; +static const struct drm_prop_enum_list drm_scaling_filter_enum_list[] = { + { DRM_SCALING_FILTER_DEFAULT, "Default" }, + { DRM_SCALING_FILTER_NEAREST_NEIGHBOR, "Nearest Neighbor" }, +}; + static int drm_mode_create_standard_properties(struct drm_device *dev) { struct drm_property *prop; @@ -370,6 +375,14 @@ static int drm_mode_create_standard_properties(struct drm_device *dev) return -ENOMEM; dev->mode_config.modifiers_property = prop; + prop = drm_property_create_enum(dev, 0, + "SCALING_FILTER", + drm_scaling_filter_enum_list, + ARRAY_SIZE(drm_scaling_filter_enum_list)); + if (!prop) + return -ENOMEM; + dev->mode_config.scaling_filter_property = prop; + return 0; } diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index d6ad60ab0d38..ace7ee2775c8 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -1221,3 +1221,38 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, return ret; } + +/** + * DOC: Scaling filter property + * + * + * SCALING_FILTER: + * + * Indicates scaling filter to be used for CRTC/plane scaler + * + * The value of this property can be one of the following: + * Default: + * Driver's default scaling filter + * Nearest Neighbor: + * Nearest Neighbor scaling filter + * + * Drivers can set up this property for a plane by calling + * drm_plane_enable_scaling_filter() and for a CRTC by calling + * drm_crtc_enable_scaling_filter() + */ + +/** + * drm_plane_enable_scaling_filter - Enables plane scaling filter property. + * @plane: Plane on which to enable scaling filter property. + * + * This function lets driver to enable the scaling filter property on a plane. + */ +void drm_plane_enable_scaling_filter(struct drm_plane *plane) +{ + struct drm_device *dev = plane->dev; + + drm_object_attach_property(&plane->base, + dev->mode_config.scaling_filter_property, + 0); +} +EXPORT_SYMBOL(drm_plane_enable_scaling_filter); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 59b51a09cae6..770f9328a5ba 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -58,6 +58,7 @@ struct device_node; struct dma_fence; struct edid; + static inline int64_t U642I64(uint64_t val) { return (int64_t)*((int64_t *)&val); @@ -296,6 +297,13 @@ struct drm_crtc_state { */ u32 target_vblank; + /** + * @scaling_filter: + * + * Scaling filter mode to be applied + */ + enum drm_scaling_filter scaling_filter; + /** * @async_flip: * @@ -1266,4 +1274,6 @@ static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, #define drm_for_each_crtc(crtc, dev) \ list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) +void drm_crtc_enable_scaling_filter(struct drm_crtc *crtc); + #endif /* __DRM_CRTC_H__ */ diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 3bcbe30339f0..8c308ae1056d 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -914,6 +914,12 @@ struct drm_mode_config { */ struct drm_property *modifiers_property; + /** + * @scaling_filter_property: CRTC/plane property to apply a particular + * filter while scaling. + */ + struct drm_property *scaling_filter_property; + /* cursor size */ uint32_t cursor_width, cursor_height; diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 3f396d94afe4..2bc665cc6071 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -35,6 +35,11 @@ struct drm_crtc; struct drm_printer; struct drm_modeset_acquire_ctx; + +enum drm_scaling_filter { + DRM_SCALING_FILTER_DEFAULT, + DRM_SCALING_FILTER_NEAREST_NEIGHBOR, +}; /** * struct drm_plane_state - mutable plane state * @@ -214,6 +219,13 @@ struct drm_plane_state { */ bool visible; + /** + * @scaling_filter: + * + * Scaling filter mode to be applied + */ + enum drm_scaling_filter scaling_filter; + /** * @commit: Tracks the pending commit to prevent use-after-free conditions, * and for async plane updates. @@ -862,4 +874,6 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state) state->fb_damage_clips->data : NULL); } +void drm_plane_enable_scaling_filter(struct drm_plane *plane); + #endif -- 2.23.0