From patchwork Fri Apr 29 09:29:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kulkarni, Vandita" X-Patchwork-Id: 8986091 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 083D7BF29F for ; Sat, 30 Apr 2016 01:18:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EBA7201ED for ; Sat, 30 Apr 2016 01:18:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F2F7D201CE for ; Sat, 30 Apr 2016 01:18:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76B9D6F002; Sat, 30 Apr 2016 01:18:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 310C86EE83; Fri, 29 Apr 2016 09:29:27 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 29 Apr 2016 02:29:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,551,1455004800"; d="scan'208";a="794896287" Received: from vandita-desktop.iind.intel.com ([10.223.26.11]) by orsmga003.jf.intel.com with ESMTP; 29 Apr 2016 02:29:25 -0700 From: Vandita Kulkarni To: intel-gfx@lists.freedesktop.org Subject: [PATCHv2 1/5] drm: Introduce the blend-func property Date: Fri, 29 Apr 2016 14:59:13 +0530 Message-Id: <1461922157-32553-2-git-send-email-vandita.kulkarni@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461922157-32553-1-git-send-email-vandita.kulkarni@intel.com> References: <1461922157-32553-1-git-send-email-vandita.kulkarni@intel.com> MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 30 Apr 2016 01:16:05 +0000 Cc: corbet@lwn.net, Vandita Kulkarni , dri-devel@lists.freedesktop.org, daniel.vetter@intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Damien Lespiau We'd like to be able to program the blending modes of display planes. Ville suggested to use something similar to the GL blend states, which does seem like a good idea. For now, we only consider blend factors, but room is left for extensions: blend equation, separate rgb/alpha blend factors, blend color. V2: Added the belnd func property support in get property. Suggested-by: Ville Syrjälä Signed-off-by: Damien Lespiau Signed-off-by: Vandita Kulkarni --- Documentation/DocBook/gpu.tmpl | 11 +++++++++-- drivers/gpu/drm/drm_atomic.c | 14 ++++++++++++++ drivers/gpu/drm/drm_crtc.c | 5 +++++ include/drm/drm_crtc.h | 20 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl index 1464fb2..f673989 100644 --- a/Documentation/DocBook/gpu.tmpl +++ b/Documentation/DocBook/gpu.tmpl @@ -1816,7 +1816,7 @@ void intel_crt_init(struct drm_device *dev) Description/Restrictions - DRM + DRM Generic “rotation” BITMASK @@ -1868,7 +1868,7 @@ void intel_crt_init(struct drm_device *dev) CRTC that connector is attached to (atomic) - Plane + Plane “type” ENUM | IMMUTABLE { "Overlay", "Primary", "Cursor" } @@ -1946,6 +1946,13 @@ void intel_crt_init(struct drm_device *dev) CRTC that plane is attached to (atomic) + “blend_func” + None + DRM_BLEND_FUNC() + Plane + Source and destination blending factors + + DVI-I “subconnector” ENUM diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 8ee1db8..c2ead2d 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -701,6 +701,18 @@ int drm_atomic_plane_set_property(struct drm_plane *plane, state->src_h = val; } else if (property == config->rotation_property) { state->rotation = val; + } else if (property == config->prop_blend_func) { + enum drm_blend_factor src_factor, dst_factor; + + src_factor = DRM_BLEND_FUNC_SRC_FACTOR(val); + dst_factor = DRM_BLEND_FUNC_DST_FACTOR(val); + + if (src_factor != dst_factor && + (src_factor == DRM_BLEND_FACTOR_AUTO || + dst_factor == DRM_BLEND_FACTOR_AUTO)) + return -EINVAL; + + state->blend_mode.func = val & GENMASK(31, 0); } else if (plane->funcs->atomic_set_property) { return plane->funcs->atomic_set_property(plane, state, property, val); @@ -757,6 +769,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane, *val = state->src_h; } else if (property == config->rotation_property) { *val = state->rotation; + } else if (property == config->prop_blend_func) { + *val = state->blend_mode.func; } 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 f7fe9e1..2cac5e1 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1587,6 +1587,11 @@ static int drm_mode_create_standard_properties(struct drm_device *dev) return -ENOMEM; dev->mode_config.gamma_lut_size_property = prop; + prop = drm_property_create_range(dev, 0, "blend_func", 0, U32_MAX); + if (!prop) + return -ENOMEM; + dev->mode_config.prop_blend_func = prop; + return 0; } diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 6d46842..269f660 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -89,6 +89,23 @@ static inline uint64_t I642U64(int64_t val) #define DRM_REFLECT_X 4 #define DRM_REFLECT_Y 5 +enum drm_blend_factor { + DRM_BLEND_FACTOR_AUTO, + DRM_BLEND_FACTOR_ZERO, + DRM_BLEND_FACTOR_ONE, + DRM_BLEND_FACTOR_SRC_ALPHA, + DRM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, +}; + +#define DRM_BLEND_FUNC(src_factor, dst_factor) \ + (DRM_BLEND_FACTOR_##src_factor << 16 | DRM_BLEND_FACTOR_##dst_factor) +#define DRM_BLEND_FUNC_SRC_FACTOR(val) (((val) >> 16) & 0xffff) +#define DRM_BLEND_FUNC_DST_FACTOR(val) ((val) & 0xffff) + +struct drm_blend_mode { + uint64_t func; +}; + enum drm_connector_force { DRM_FORCE_UNSPECIFIED, DRM_FORCE_OFF, @@ -1273,6 +1290,8 @@ struct drm_plane_state { /* Plane rotation */ unsigned int rotation; + struct drm_blend_mode blend_mode; + struct drm_atomic_state *state; }; @@ -2125,6 +2144,7 @@ struct drm_mode_config { struct drm_property *prop_crtc_id; struct drm_property *prop_active; struct drm_property *prop_mode_id; + struct drm_property *prop_blend_func; /* DVI-I properties */ struct drm_property *dvi_i_subconnector_property;