Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2958205imm; Mon, 28 May 2018 20:57:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ+u/UKoDDKcS6BkL02Vk5xQg2NPLE+jQLvSiVmaIqEgH8BHRGNoOzT7bmyAtraSvCb++Tf X-Received: by 2002:a17:902:4464:: with SMTP id k91-v6mr2857241pld.219.1527566244872; Mon, 28 May 2018 20:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527566244; cv=none; d=google.com; s=arc-20160816; b=SffCvLmk6FanTOXP3NdZOSLw8sVq8cuJD+dXycAWeuwDPzuBOkEMdAgs2244vhE5As Ma9vFQiC/v9H6dLxEFnameCB7bt/trHWDSLrH/gvLMQrapxGRSkTGUe5a5ksYyZ3Y4Jj WL29av2QTIeyyIg2gYsGPpxohHPlOlMCBWDDeDMBQFS9PoWysepZxooK/qCYaG8STxtp 26hGp2YhUOq9E5FNBcN1KP4xASmcDlFi2wX4c78EEZtJVRU2e4Qsx6iiDYC7H0fSn13v QcZbhKxwBju9JXqz2kbsmo/t2HJl7tY6xuWtcpzMAV7dSjMWNEa0Qmb5LhHqm5RoLBtS 7qmw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=OvPAQui+jgqTYTD8vOayFgxIQV9VMrU9FeQ+NzC3qXc=; b=X1uY5eeWT1wBQSHfhqU01vCdrvC2v5V/JYJNaBf9FdOWLBzDyu7Fr6CtrIds73g8sA 1ptdeHlMaAbTPT2NmwcUfmA5y4QYc0VNKM0jz3I9rpy2H1kbkMXsZvY75vlon0Dq6vIs K4nmjYK8ocJA9deW2+JFuUBPuLK/kHrnHAkueR7lrhef6DWRgHarX33636/Xkzf6TJ7f IiBMwyu4Ivo1KtydcGlhL7y0PiQ1rcXlLTTfEvgbouvYuYRIRC7zqyiWq6PP4Yh0BiZ0 AaT5AJFIyy4EujqYaau0zqrcipH9rEpO2PSqyV4OexAbzIf6YanIWAm/EVGUJavrWLfG jmaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=utWfmG2M; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10-v6si4110324ply.482.2018.05.28.20.57.10; Mon, 28 May 2018 20:57:24 -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=pass header.i=@gmail.com header.s=20161025 header.b=utWfmG2M; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936465AbeE1Xsb (ORCPT + 99 others); Mon, 28 May 2018 19:48:31 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:51071 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932360AbeE1Xs0 (ORCPT ); Mon, 28 May 2018 19:48:26 -0400 Received: by mail-wm0-f68.google.com with SMTP id t11-v6so35670662wmt.0; Mon, 28 May 2018 16:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OvPAQui+jgqTYTD8vOayFgxIQV9VMrU9FeQ+NzC3qXc=; b=utWfmG2MiMX5VZ1m4sZWwtbEiX2l6K+hv9nNZlmFtEQ29xvoiiZr1grnfx7lY6uWqK DJNhK0Isx2dnnVcy9Gh5/FDQMbXBnZLzdNhw6ll3iolB8bcONpnSdfWkAf199Plsi8pA ptDJTHkBKNoaK0c5SRsLFK1Cxu27MvnGLhtEpx82KpHErED7s1/pnjlh8CMZEjJwNYIM QHOmY/4WCYMrb1pIBvNTJbpiorRTRNOWm/7r5TRtPkI1Y7XLYCrRMfCt5M8VA5B2k2sP BzMFJp2IfhmUz5i96A+JFNL9TdqrQVgMUuYdyN2ELEJYrebBH+KycOU4AAOjWoT7lttJ qPJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=OvPAQui+jgqTYTD8vOayFgxIQV9VMrU9FeQ+NzC3qXc=; b=oOd3p6Qx6F09UA4jyTb8L4uHsd74zO0dV2JlCsEO30CHnsxgiUOeqeAlkcqIswe31V VS+OkIdgoYo6nXH7o2yxvZkk6YsLcPIdFlvpOWkr180QzS89G1kxETAGqEY4QJn0ZDuW YnQ7oReKc/+IxSbYz6G6WtyMQIVnQo9YzmHLUTi5uPhud2bAb3sDwv5uT2dyW1lXaP7D 8PLDZaYilA0pblZoY4XgT2c8axYSJBxwa2BJSvuniuzJgkIrYIwU115Ar/omGNxINrNd sqDZO3w/evpTgndIEFoIdcneDa45v9LlBMvM0lDpyopin82H6btSVMg8eEP45MDlj23M QezQ== X-Gm-Message-State: ALKqPwdTszfKOmDkLp9iBDqrbS8dXjk1yMwFUQKM7GSW0sPDwJrVqVOO TTTnu/VVNu2oavKgz8AhKfMwvYRO X-Received: by 2002:a2e:7310:: with SMTP id o16-v6mr9479049ljc.29.1527551304497; Mon, 28 May 2018 16:48:24 -0700 (PDT) Received: from [192.168.2.145] (109-252-91-41.nat.spd-mgts.ru. [109.252.91.41]) by smtp.googlemail.com with ESMTPSA id i29-v6sm7109471lfb.89.2018.05.28.16.48.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 16:48:23 -0700 (PDT) Subject: Re: [RFC PATCH v2 1/2] drm: Add generic colorkey properties To: =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= Cc: Laurent Pinchart , Thierry Reding , Neil Armstrong , Maxime Ripard , dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Alexandru Gheorghe , Russell King , Ben Skeggs , Sinclair Yeh , Thomas Hellstrom , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180526155623.12610-1-digetx@gmail.com> <20180526155623.12610-2-digetx@gmail.com> <20180528131501.GK23723@intel.com> From: Dmitry Osipenko Openpgp: preference=signencrypt Autocrypt: addr=digetx@gmail.com; prefer-encrypt=mutual; keydata= xsBNBFpX5TwBCADQhg+lBnTunWSPbP5I+rM9q6EKPm5fu2RbqyVAh/W3fRvLyghdb58Yrmjm KpDYUhBIZvAQoFLEL1IPAgJBtmPvemO1XUGPxfYNh/3BlcDFBAgERrI3BfA/6pk7SAFn8u84 p+J1TW4rrPYcusfs44abJrn8CH0GZKt2AZIsGbGQ79O2HHXKHr9V95ZEPWH5AR0UtL6wxg6o O56UNG3rIzSL5getRDQW3yCtjcqM44mz6GPhSE2sxNgqureAbnzvr4/93ndOHtQUXPzzTrYB z/WqLGhPdx5Ouzn0Q0kSVCQiqeExlcQ7i7aKRRrELz/5/IXbCo2O+53twlX8xOps9iMfABEB AAHNIkRtaXRyeSBPc2lwZW5rbyA8ZGlnZXR4QGdtYWlsLmNvbT7CwJQEEwEIAD4WIQSczHcO 3uc4K1eb3yvTNNaPsNRzvAUCWlflPAIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIX gAAKCRDTNNaPsNRzvFjTCACqAh1M9/YPq73/ai5h2ExDquTgJnjegL8KL2yHL3G+XINwzN5E nPI7esoYm+zVWDJbv3UuRqylpookLNSRA01yyvkaMcipB/B128UnqmUiGRqezj9QE20yIauo uHRuwHPE2q+UkfUhRX9iuOaEyQtZDiCa0myMjmRkJ+Z8ZetclEPG8dYZu47w04phuMlu1QAt a0gkZOaMKvXgj21ushALS6nYnvm7HiIPQXfnEXThartatRvFdmbG4PCn0IoICkQBizwJtXrL HEjELIFap0M8krVJlUoZTFaZnaZkGpUDWikeFtAuie2KuIxmVBYPM4X7pM3eP3AVvIPGS7EE UUFuzsBNBFpX5TwBCADFNDou220thijaLLGaQsebWjzc/gPRxMixIpk856MRyRaQin+IbGD6 YskMb5ZSD3nS88LIKNfY4MMH0LwfYztI++ICG2vdFLkbBt78E+LqEa+kZ9072l4W5KO3mWQo +jMfxXbpgGlc7iuEReDgl8iyZ27r51kSW665CYvvu2YJhLqgdj6QM1lN2D1UnhEhkkU+pRAj 1rJVOxdfJaQNQS4+204p3TrURovzNGkN/brqakpNIcqGOAGQqb8F0tuwwuP7ERq/BzDNkbdr qJOrVC/wkHRq1jfabQczWKf8MwYOvivR3HY8d3CpSQxmUXDtdOWfg0XGm1dxYnVfqPjuJaZt ABEBAAHCwHwEGAEIACYWIQSczHcO3uc4K1eb3yvTNNaPsNRzvAUCWlflPAIbDAUJA8JnAAAK CRDTNNaPsNRzvJzuB/9d+sxcwHbO8ZDcgaLX9N+bXFqN9fIRVmBUyWa+qqTSREA4uVAtYcRT lfPE2OQ7aMFxaYPwo+/z5SLpu8HcEhN/FG9uIkfYwK0mdCO0vgvlfvBJm4VHe7C6vyAeEPJQ DKbBvdgeqFqO+PsLkk2sawF/9sontMJ5iFfjNDj4UeAo4VsdlduTBZv5hHFvIbv/p7jKH6OT 90FsgUSVbShh7SH5OzAcgqSy4kxuS1AHizWo6P3f9vei987LZWTyhuEuhJsOfivDsjKIq7qQ c5eR+JJtyLEA0Jt4cQGhpzHtWB0yB3XxXzHVa4QUp00BNVWyiJ/t9JHT4S5mdyLfcKm7ddc9 Message-ID: Date: Tue, 29 May 2018 02:48:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180528131501.GK23723@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28.05.2018 16:15, Ville Syrjälä wrote: > On Sat, May 26, 2018 at 06:56:22PM +0300, Dmitry Osipenko wrote: >> 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 nine generic DRM plane >> properties related to the color keying to cover various HW capabilities. >> >> This patch is based on the initial work done by Laurent Pinchart, most of >> credits for this patch goes to him. >> >> Signed-off-by: Dmitry Osipenko >> --- >> drivers/gpu/drm/drm_atomic.c | 36 ++++++ >> drivers/gpu/drm/drm_blend.c | 229 +++++++++++++++++++++++++++++++++++ >> include/drm/drm_blend.h | 3 + >> include/drm/drm_plane.h | 77 ++++++++++++ >> 4 files changed, 345 insertions(+) >> >> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c >> index 895741e9cd7d..5b808cb68654 100644 >> --- a/drivers/gpu/drm/drm_atomic.c >> +++ b/drivers/gpu/drm/drm_atomic.c >> @@ -799,6 +799,24 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, >> state->rotation = val; >> } else if (property == plane->zpos_property) { >> state->zpos = val; >> + } else if (property == plane->colorkey.mode_property) { >> + state->colorkey.mode = val; >> + } else if (property == plane->colorkey.min_property) { >> + state->colorkey.min = val; >> + } else if (property == plane->colorkey.max_property) { >> + state->colorkey.max = val; >> + } else if (property == plane->colorkey.format_property) { >> + state->colorkey.format = val; >> + } else if (property == plane->colorkey.mask_property) { >> + state->colorkey.mask = val; >> + } else if (property == plane->colorkey.inverted_match_property) { >> + state->colorkey.inverted_match = val; >> + } else if (property == plane->colorkey.replacement_mask_property) { >> + state->colorkey.replacement_mask = val; >> + } else if (property == plane->colorkey.replacement_value_property) { >> + state->colorkey.replacement_value = val; >> + } else if (property == plane->colorkey.replacement_format_property) { >> + state->colorkey.replacement_format = val; >> } else if (property == plane->color_encoding_property) { >> state->color_encoding = val; >> } else if (property == plane->color_range_property) { >> @@ -864,6 +882,24 @@ drm_atomic_plane_get_property(struct drm_plane *plane, >> *val = state->rotation; >> } else if (property == plane->zpos_property) { >> *val = state->zpos; >> + } else if (property == plane->colorkey.mode_property) { >> + *val = state->colorkey.mode; >> + } else if (property == plane->colorkey.min_property) { >> + *val = state->colorkey.min; >> + } else if (property == plane->colorkey.max_property) { >> + *val = state->colorkey.max; >> + } else if (property == plane->colorkey.format_property) { >> + *val = state->colorkey.format; >> + } else if (property == plane->colorkey.mask_property) { >> + *val = state->colorkey.mask; >> + } else if (property == plane->colorkey.inverted_match_property) { >> + *val = state->colorkey.inverted_match; >> + } else if (property == plane->colorkey.replacement_mask_property) { >> + *val = state->colorkey.replacement_mask; >> + } else if (property == plane->colorkey.replacement_value_property) { >> + *val = state->colorkey.replacement_value; >> + } else if (property == plane->colorkey.replacement_format_property) { >> + *val = state->colorkey.replacement_format; >> } else if (property == plane->color_encoding_property) { >> *val = state->color_encoding; >> } else if (property == plane->color_range_property) { >> diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c >> index a16a74d7e15e..05e5632ce375 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 replacing a range of colors with a transparent >> + * color in the plane. >> + * >> * 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,227 @@ 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_SRC] = "src-match-src-replace", >> + [DRM_PLANE_COLORKEY_MODE_DST] = "dst-match-src-replace", > > This list seems way more limited than I was expecting, at least when > compared to all the different props you're proposing to add. > What else are you expecting to see in the list? >> +}; >> + >> +/** >> + * 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 attach them to >> + * the plane to enable color keying control for blending operations. >> + * >> + * Color keying is controlled through nine properties: >> + * >> + * colorkey.mode: >> + * The mode is an enumerated property that controls how color keying >> + * operates. The "disabled" mode that disables color keying and is >> + * very likely to exist if color keying is supported, it should be the >> + * default mode. >> + * >> + * 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 AXYZ16161616 format, where A is the alpha value and >> + * X, Y and Z correspond to the color components of the colorkey.format. >> + * In most cases XYZ will be either RGB or YUV. >> + * >> + * 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. >> + * >> + * colorkey.format: >> + * This property specifies the pixel format for the colorkey.min / max >> + * properties. The format is given in a form of DRM fourcc code. > > Umm. Why we do even need this? This seems incompatible with your earlier > "min/max are specified in 16bpc format" statement. > AXYZ16161616 is just an abstraction of a pixel format, at least that's how I'm interpreting the AXYZ16161616. Previously Laurent specified that min/max values should be given in the format of the planes framebuffer. This doesn't work for a case of setting property for a disabled plane because disabled plane doesn't have a framebuffer. This also doesn't work for Tegra that can take only XRGB8888 format for a color key, AFAIK HW internally converts all pixel formats to ARGB8888 and RGB part participates in the color matching (later Tegra's support alpha channel matching as well). Hence I added the format property that explicitly tells in what format the color key integer value is given. I'm now thinking that format property should be exposed to userspace in a form of a ENUM-list, because otherwise userspace doesn't know what color key formats are supported by the DRM driver. And probably somehow userspace should be informed about that colorkey format should match the framebuffers format if that's what driver expects. Maybe a read-only property? >> + * >> + * Drivers return an error from their plane atomic check if pixel format >> + * is unsupported. >> + * >> + * 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 >> + * form of DRM fourcc code corresponding to the colorkey.format property. >> + * >> + * For example: userspace shall set the colorkey.mask to 0x0000ff00 >> + * to match only the green component if colorkey.format is set to >> + * DRM_FORMAT_XRGB8888. >> + * >> + * Drivers return an error from their plane atomic check if mask value >> + * can't be handled. >> + * >> + * colorkey.inverted-match: >> + * This property specifies whether the matching min-max range should >> + * be inverted, i.e. pixels outside of the given color range become >> + * the color key match. >> + * >> + * Drivers return an error from their plane atomic check if inversion >> + * mode can't be handled. > > Hmm. I'm trying to figure out what this means for the src vs. dst > colorkey modes. Those pretty much already have an inverted meaning when > compared to each other. So I can't figure out from these docs whether > you're supposed to use this when you want a normal dst ckey or normal > src key semantics. > I also couldn't understand what initial semantic to src/dst was given by Laurent. In a case of this patch: The src/dst-match specifies the "source" plane for which the color matching is performed. Src means the plane to which the colorkey properties are applied. Dst means planes other than plane X to which the colorkey properties are applied, in particular the planes that are Z-positioned under the plane X. Hope that's more clear now. The src-replace part specifies that pixels of the plane to which the colorkey properties are applied will be replaced. I'll try to re-work the doc if the above sounds good. The inverted-match property controls whether given color-match range shall be inverted, like for example: if given color key is a red color, then all colors expect the red will be matched as a color key. Actually maybe inversion could be expressed using the mask solely. Like we could add a helper that converts "value+mask" into "value=(value & ~mask), inversion=true" if mask has form of 0x11000111, though this could be not applicable to all possible pixel formats.. not sure. >> + * >> + * colorkey.replacement-value: >> + * This property specifies the color value that replaces pixels matching >> + * the color key. The value is expressed in AXYZ16161616 format, where A >> + * is the alpha value and X, Y and Z correspond to the color components >> + * of the colorkey.replacement-format. >> + * >> + * Drivers return an error from their plane atomic check if replacement >> + * value can't be handled. >> + * >> + * colorkey.replacement-format: >> + * This property specifies the pixel format for the >> + * colorkey.replacement-value property. The format is given in a form of >> + * DRM fourcc code. > > Again this seems at odds with the 16bpc replacement-value. > >> + * >> + * Drivers return an error from their plane atomic check if replacement >> + * pixel format is unsupported. >> + * >> + * colorkey.replacement-mask: >> + * This property specifies the pixel components mask that defines >> + * what components of the colorkey.replacement-value will participate in >> + * replacement of the pixels color. Unmasked pixel components are not >> + * participating in the replacement. > > Does that mean that the data for the unmasked bits will be coming > from the source? > Yeah, I see that "source" is vaguely defined. Yes, the unmasked bits are coming from the source. The "source" is defined by the mode. src-match- -->SRC<-- -replace dst-match- -->SRC<-- -replace Src means the plane to which the colorkey properties are applied, as I stated above. >> The mask value is given in a form of >> + * DRM fourcc code corresponding to the colorkey.replacement-format >> + * property. >> + * >> + * For example: userspace shall set the colorkey.replacement-mask to >> + * 0x0000ff00 to replace only the green component if >> + * colorkey.replacement-format is set to DRM_FORMAT_XRGB8888. >> + * >> + * Userspace shall set colorkey.replacement-mask to 0 to disable the color >> + * replacement. In this case matching pixels become transparent. >> + * >> + * Drivers return an error from their plane atomic check if replacement >> + * mask value can't be handled. >> + * >> + * Returns: >> + * Zero on success, negative errno on failure. >> + */ >> +int drm_plane_create_colorkey_properties(struct drm_plane *plane, >> + u32 supported_modes) >> +{ >> + struct drm_prop_enum_list modes_list[DRM_PLANE_COLORKEY_MODES_NUM]; >> + struct drm_property *replacement_format_prop; >> + struct drm_property *replacement_value_prop; >> + struct drm_property *replacement_mask_prop; >> + struct drm_property *inverted_match_prop; >> + struct drm_property *format_prop; >> + struct drm_property *mask_prop; >> + struct drm_property *mode_prop; >> + struct drm_property *min_prop; >> + struct drm_property *max_prop; >> + unsigned int modes_num = 0; >> + unsigned int i; >> + >> + /* at least two modes should be supported */ >> + if (!supported_modes) >> + return -EINVAL; >> + >> + /* modes are driver-specific, build the list of supported modes */ >> + for (i = 0; i < DRM_PLANE_COLORKEY_MODES_NUM; i++) { >> + if (!(supported_modes & BIT(i))) >> + continue; >> + >> + modes_list[modes_num].name = plane_colorkey_mode_name[i]; >> + modes_list[modes_num].type = i; >> + modes_num++; >> + } >> + >> + mode_prop = drm_property_create_enum(plane->dev, 0, "colorkey.mode", >> + modes_list, modes_num); >> + if (!mode_prop) >> + return -ENOMEM; >> + >> + mask_prop = drm_property_create_range(plane->dev, 0, "colorkey.mask", >> + 0, U64_MAX); >> + if (!mask_prop) >> + goto err_destroy_mode_prop; >> + >> + min_prop = drm_property_create_range(plane->dev, 0, "colorkey.min", >> + 0, U64_MAX); >> + if (!min_prop) >> + goto err_destroy_mask_prop; >> + >> + max_prop = drm_property_create_range(plane->dev, 0, "colorkey.max", >> + 0, U64_MAX); >> + if (!max_prop) >> + goto err_destroy_min_prop; >> + >> + format_prop = drm_property_create_range(plane->dev, 0, >> + "colorkey.format", >> + 0, U32_MAX); >> + if (!format_prop) >> + goto err_destroy_max_prop; >> + >> + inverted_match_prop = drm_property_create_bool(plane->dev, 0, >> + "colorkey.inverted-match"); >> + if (!inverted_match_prop) >> + goto err_destroy_format_prop; >> + >> + replacement_mask_prop = drm_property_create_range(plane->dev, 0, >> + "colorkey.replacement-mask", >> + 0, U64_MAX); >> + if (!replacement_mask_prop) >> + goto err_destroy_inverted_match_prop; >> + >> + replacement_value_prop = drm_property_create_range(plane->dev, 0, >> + "colorkey.replacement-value", >> + 0, U64_MAX); >> + if (!replacement_value_prop) >> + goto err_destroy_replacement_mask_prop; >> + >> + replacement_format_prop = drm_property_create_range(plane->dev, 0, >> + "colorkey.replacement-format", >> + 0, U64_MAX); >> + if (!replacement_format_prop) >> + goto err_destroy_replacement_value_prop; > > I don't think we want to add all these props for every driver/hardware. > IMO the set of props we expose should depend on the supported set of > colorkeying modes. > Probably, I don't mind. This should be documented then, I can address that in the next iteration. /I think/ all of the currently-defined properties are relevant to the defined color keying modes. Later, if the list of modes will be extended with new modes, the creation of properties could be conditionalized. Though maybe "color components replacement" and "replacement with a complete transparency" could be factored out into a specific color keying modes. I'm open for suggestions. [snip]