Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4263381ooa; Tue, 14 Aug 2018 03:41:19 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyQ5mGtn0MgJKgTQbyhkNVo4zosIvkIlRkY1Na4+xaj5LEhifUdzbdNhSY6Oie6LTfLpN79 X-Received: by 2002:a65:5c4b:: with SMTP id v11-v6mr20730873pgr.445.1534243279442; Tue, 14 Aug 2018 03:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534243279; cv=none; d=google.com; s=arc-20160816; b=DnAwmxNCPUFEv5olu7fUQMdoX2OVZhRMyC2fuj7o9hOAmPZO36gP4kV5E36T2ZnrAm No3KznH34jIOMx+NEuzbVj+cD4j3elm/mbjMJ/mIrMhcvjlfy5t7LDBqojFY3t6iQi/E +fKEYNAwZKK4IGaulc4UHuueB4ONAlcXcxC+RXI7UAHuDBp8s890jdS92BG2cfAzKqD8 XwXuprYsyyG3aX3M1HOH0Sr7K1jHOo+dA4KnLZP/orUZ8G3BbZejyWhqRd3SleIS/QpA OQZNQgUgjc+4b7qWKzL9/l5ZzX2XyQcwmMAaIuQT2kp2gEPYqH9tEFz/QaIalfqUsGNW 7TcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=52nL/tQDNqCAtXoLF1coyvAokmAoL6Vab6PKvpTSUdg=; b=hgOl89uszAns+RhLbQUJGiY+XAFrGL9WCcih8eCyoeKZKAGYLwkhw1bsU+sB6Qup/U bTYnV3qB0ZvuPFGOst6kTQcBa9lkKidt2dlvtwkqtLa+LHaSjV9wdNo0wy4NlLJScoNI QiWZ7W3pn2fexaVkT7e9xXoYS+rWgpzcgP/Q0hDd48ybw8O1ks0GDPLGZFKTUXKpmZyz hHMBBQNr2j9MkiTjp76e1/K0h1XiLzTH5ZGPUDaiFxfdmq8XV10PSfNLyRx9nc3n+FMP zlyj2TfmvpqSmVCUtEYi7OPsV+/+CypCuRgTmRljoVRGIYfIFRGva7g5XnhGpHOgBStY /sJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=b5HOZEW7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h65-v6si23426885pfb.70.2018.08.14.03.41.03; Tue, 14 Aug 2018 03:41:19 -0700 (PDT) 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; dkim=fail header.i=@ffwll.ch header.s=google header.b=b5HOZEW7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732287AbeHNNZO (ORCPT + 99 others); Tue, 14 Aug 2018 09:25:14 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40730 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732190AbeHNNZO (ORCPT ); Tue, 14 Aug 2018 09:25:14 -0400 Received: by mail-ed1-f68.google.com with SMTP id e19-v6so9847194edq.7 for ; Tue, 14 Aug 2018 03:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=52nL/tQDNqCAtXoLF1coyvAokmAoL6Vab6PKvpTSUdg=; b=b5HOZEW7zwFF0LD73eEDJHbxGoUAOY56KLRTA7l3kz3DLEFRVqHNz/wDLcibK+1PP7 i/ho8SBg1Hh9/MiNZx3csfCLxt8aOhNcmJ5IBEh9d64oTyIGzb0D6+NJHmW8rdfs4R7G QTlpZSp2wl8/oUCiXOq1z90zbWeIJd313L1+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=52nL/tQDNqCAtXoLF1coyvAokmAoL6Vab6PKvpTSUdg=; b=rR6MLSmUXqKLGfWJu0970ee7kCwbWnNuacExVpzsRTlYpCvC04LAeusbpQ/yvabPAg T7McgnnKztepadQsxwLVg1alzCznK4y+uV6xLh9YvZxvTxLMjFbsO5/76S2oiW1FW1DF 1SwtgJdTlKNgGQz7DHTzkp2T6yplQHcR/cSu9DagWluSsVfGyYSI+/tJ7r5qSqc7+nJ3 hJu93WPiNo54hiByyq1H6x1wIhwH63WxegiPoXJxyU1/iy9gZI4xR9tWAi5h+wfoXFB4 f8ptsYnEeENZxbtLVvERHMqljfFcg9/MNc/gzmBj2TrdjUl60t8jsRMiv7zcvv61yHln Pp2A== X-Gm-Message-State: AOUpUlFMO1Unox/yNCB1F6v9IK+lbzS8vEJUFBexqNC+Mb+kVcflXadT /kqgN2V8YCCbKCNbMAqpYpNb6A== X-Received: by 2002:a50:955e:: with SMTP id v30-v6mr27038934eda.268.1534243116807; Tue, 14 Aug 2018 03:38:36 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56fc:0:d707:d7d8:b180:96e5]) by smtp.gmail.com with ESMTPSA id r11-v6sm6961274edh.32.2018.08.14.03.38.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 03:38:36 -0700 (PDT) Date: Tue, 14 Aug 2018 12:38:33 +0200 From: Daniel Vetter To: Laurent Pinchart Cc: Dmitry Osipenko , linux-renesas-soc@vger.kernel.org, Thomas Hellstrom , Laurent Pinchart , Neil Armstrong , Russell King , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Paul Kocialkowski , linux-tegra@vger.kernel.org, Thierry Reding , Ben Skeggs , Rodrigo Vivi , Maxime Ripard , linux-media@vger.kernel.org Subject: Re: [RFC PATCH v4 1/2] drm: Add generic colorkey properties for display planes Message-ID: <20180814103833.GN21634@phenom.ffwll.local> Mail-Followup-To: Laurent Pinchart , Dmitry Osipenko , linux-renesas-soc@vger.kernel.org, Thomas Hellstrom , Laurent Pinchart , Neil Armstrong , Russell King , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Paul Kocialkowski , linux-tegra@vger.kernel.org, Thierry Reding , Ben Skeggs , Rodrigo Vivi , Maxime Ripard , linux-media@vger.kernel.org References: <20180807172202.1961-1-digetx@gmail.com> <20180807172202.1961-2-digetx@gmail.com> <7041537.TPdt8DIvGD@avalon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7041537.TPdt8DIvGD@avalon> X-Operating-System: Linux phenom 4.14.0-3-amd64 User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 14, 2018 at 12:48:08PM +0300, Laurent Pinchart wrote: > Hi Dmitry, > > Thank you for the patch. > > On Tuesday, 7 August 2018 20:22:01 EEST Dmitry Osipenko wrote: > > From: Laurent Pinchart > > > > Color keying is the action of replacing pixels matching a given color > > (or range of colors) with transparent pixels in an overlay when > > performing blitting. Depending on the hardware capabilities, the > > matching pixel can either become fully transparent or gain adjustment > > of the pixels component values. > > > > Color keying is found in a large number of devices whose capabilities > > often differ, but they still have enough common features in range to > > standardize color key properties. This commit adds new generic DRM plane > > properties related to the color keying, providing initial color keying > > support. > > > > Signed-off-by: Laurent Pinchart > > Signed-off-by: Dmitry Osipenko > > --- > > drivers/gpu/drm/drm_atomic.c | 20 +++++ > > drivers/gpu/drm/drm_blend.c | 150 +++++++++++++++++++++++++++++++++++ > > include/drm/drm_blend.h | 3 + > > include/drm/drm_plane.h | 91 +++++++++++++++++++++ > > 4 files changed, 264 insertions(+) > > [snip] > > > diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c > > index a16a74d7e15e..13c61dd0d9b7 100644 > > --- a/drivers/gpu/drm/drm_blend.c > > +++ b/drivers/gpu/drm/drm_blend.c > > @@ -107,6 +107,11 @@ > > * planes. Without this property the primary plane is always below the > > cursor * plane, and ordering between all other planes is undefined. > > * > > + * colorkey: > > + * Color keying is set up with drm_plane_create_colorkey_properties(). > > + * It adds support for actions like replacing a range of colors with a > > + * transparent color in the plane. Color keying is disabled by default. > > + * > > * Note that all the property extensions described here apply either to the > > * plane or the CRTC (e.g. for the background color, which currently is not > > * exposed and assumed to be black). > > @@ -448,3 +453,148 @@ int drm_atomic_normalize_zpos(struct drm_device *dev, > > return 0; > > } > > EXPORT_SYMBOL(drm_atomic_normalize_zpos); > > + > > +static const char * const plane_colorkey_mode_name[] = { > > + [DRM_PLANE_COLORKEY_MODE_DISABLED] = "disabled", > > + [DRM_PLANE_COLORKEY_MODE_TRANSPARENT] = "transparent", > > +}; > > + > > +/** > > + * drm_plane_create_colorkey_properties - create colorkey properties > > + * @plane: drm plane > > + * @supported_modes: bitmask of supported color keying modes > > + * > > + * This function creates the generic color keying properties and attaches > > them > > + * to the @plane to enable color keying control for blending operations. > > + * > > + * Glossary: > > + * > > + * Destination plane: > > + * Plane to which color keying properties are applied, this planes takes > > + * the effect of color keying operation. The effect is determined by a > > + * given color keying mode. > > + * > > + * Source plane: > > + * Pixels of this plane are the source for color key matching operation. > > + * > > + * Color keying is controlled by these properties: > > + * > > + * colorkey.plane_mask: > > + * The mask property specifies which planes participate in color key > > + * matching process, these planes are the color key sources. > > + * > > + * Drivers return an error from their plane atomic check if plane can't be > > + * handled. > > This seems fragile to me. We don't document how userspace determines which > planes need to be specified here, and we don't document what happens if a > plane underneath the destination plane is not specified in the mask. More > precise documentation is needed if we want to use such a property. > > It also seems quite complex. Is an explicit plane mask really the best option > ? What's the reason why planes couldn't be handled ? How do drivers determine > that ? General comment: This is why we need the reference userspace. I also think that any feature throwing up so many tricky questions should come with a full set of igt testcases. Since the reference userspace cannot answer how the new uapi should work in all corner-cases (failures and stuff like that). -Daniel > > > + * colorkey.mode: > > + * The mode is an enumerated property that controls how color keying > > + * operates. > > A link to the drm_plane_colorkey_mode enum documentation would be useful. > > > + * colorkey.mask: > > + * This property specifies the pixel components mask. Unmasked pixel > > + * components are not participating in the matching. This mask value is > > + * applied to colorkey.min / max values. The mask value is given in a > > + * 64-bit integer in ARGB16161616 format, where A is the alpha value and > > + * R, G and B correspond to the color components. Drivers shall convert > > + * ARGB16161616 value into appropriate format within planes atomic check. > > + * > > + * Drivers return an error from their plane atomic check if mask can't be > > + * handled. > > + * > > + * colorkey.min, colorkey.max: > > + * These two properties specify the colors that are treated as the color > > + * key. Pixel whose value is in the [min, max] range is the color key > > + * matching pixel. The minimum and maximum values are expressed as a > > + * 64-bit integer in ARGB16161616 format, where A is the alpha value and > > + * R, G and B correspond to the color components. Drivers shall convert > > + * ARGB16161616 value into appropriate format within planes atomic check. > > + * The converted value shall be *rounded up* to the nearest value. > > + * > > + * When a single color key is desired instead of a range, userspace shall > > + * set the min and max properties to the same value. > > + * > > + * Drivers return an error from their plane atomic check if range can't be > > + * handled. > > + * > > + * Returns: > > + * Zero on success, negative errno on failure. > > + */ > > While you're defining the concept of source and destination planes, it's not > clear from the documentation how all this maps to the usual source and > destination color keying concepts. I think that should be documented as well > or users will be confused. Examples could help in this area. > > [snip] > > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h > > index 8a152dc16ea5..ab6a91e6b54e 100644 > > --- a/include/drm/drm_plane.h > > +++ b/include/drm/drm_plane.h > > [snip] > > > @@ -32,6 +33,52 @@ struct drm_crtc; > > struct drm_printer; > > struct drm_modeset_acquire_ctx; > > > > +/** > > + * enum drm_plane_colorkey_mode - uapi plane colorkey mode enumeration > > + */ > > If it's uAPI, should it be moved to include/uapi/drm/ ? > > > +enum drm_plane_colorkey_mode { > > + /** > > + * @DRM_PLANE_COLORKEY_MODE_DISABLED: > > + * > > + * No color matching performed in this mode. > > Do you mean "No color keying" ? > > > + */ > > + DRM_PLANE_COLORKEY_MODE_DISABLED, > > + > > + /** > > + * @DRM_PLANE_COLORKEY_MODE_TRANSPARENT: > > + * > > + * Destination plane pixels are completely transparent in areas > > + * where pixels of a source plane are matching a given color key > > + * range, in other cases pixels of a destination plane are unaffected. > > How do we handle hardware that performs configurable color replacement instead > of a fixed fully transparency ? That was included in my original proposal and > available in R-Car hardware. > > > + * In areas where two or more source planes overlap, the topmost > > + * plane takes precedence. > > + */ > > + DRM_PLANE_COLORKEY_MODE_TRANSPARENT, > > + > > + /** > > + * @DRM_PLANE_COLORKEY_MODES_NUM: > > + * > > + * Total number of color keying modes. > > + */ > > + DRM_PLANE_COLORKEY_MODES_NUM, > > This one, however, shouldn't be part of the uAPI as it will change when we > will add new modes. > > > +}; > > [snip] > > > @@ -779,5 +846,29 @@ static inline struct drm_plane *drm_plane_find(struct > > drm_device *dev, #define drm_for_each_plane(plane, dev) \ > > list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) > > > > +/** > > + * drm_colorkey_extract_component - get color key component value > > + * @ckey64: 64bit color key value > > + * @comp_name: name of 16bit color component to extract > > + * @nbits: size in bits of extracted component value > > + * > > + * Extract 16bit color component of @ckey64 given by @comp_name (alpha, > > red, > > + * green or blue) and convert it to an unsigned integer that has bit-width > > + * of @nbits (result is rounded-up). > > + */ > > +#define drm_colorkey_extract_component(ckey64, comp_name, nbits) \ > > + __DRM_CKEY_CLAMP(__DRM_CKEY_CONV(ckey64, comp_name, nbits), nbits) > > + > > +#define __drm_ckey_alpha_shift 48 > > +#define __drm_ckey_red_shift 32 > > +#define __drm_ckey_green_shift 16 > > +#define __drm_ckey_blue_shift 0 > > + > > +#define __DRM_CKEY_CONV(ckey64, comp_name, nbits) \ > > + DIV_ROUND_UP((u16)((ckey64) >> __drm_ckey_ ## comp_name ## _shift), \ > > + 1 << (16 - (nbits))) > > As the divisor is a power of two, could we use masking instead of a division ? > Or do you expect the compiler to optimize it properly ? > > > +#define __DRM_CKEY_CLAMP(value, nbits) \ > > + min_t(u16, (value), (1 << (nbits)) - 1) > > Would the following be simpler to read and a bit more efficient as it avoids > the division ? > > static inline u16 __drm_colorkey_extract_component(u64 ckey64, > unsigned int shift, > unsigned int nbits) > { > u16 mask = (1 << (16 - nbits)) - 1; > > return ((u16)(ckey >> shift) + mask) >> (16 - nbits); > } > > #define drm_colorkey_extract_component(ckey64, comp_name, nbits) \ > __drm_colorkey_extract_component(ckey64, __drm_ckey_ ## comp_name ## > _shift, nbits) > > > #endif > > -- > Regards, > > Laurent Pinchart > > > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch