dri-devel Archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor
@ 2021-06-10 11:12 Thierry Reding
  2021-06-10 11:12 ` [PATCH 2/3] drm/arm: malidp: Use fourcc_mod_is_vendor() helper Thierry Reding
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Thierry Reding @ 2021-06-10 11:12 UTC (permalink / raw)
  To: dri-devel; +Cc: David Airlie, Thomas Zimmermann, Daniel Vetter, Daniel Stone

From: Thierry Reding <treding@nvidia.com>

When working with framebuffer modifiers, it can be useful to extract the
vendor identifier or check a modifier against a given vendor identifier.
Add one macro that extracts the vendor identifier and a helper to check
a modifier against a given vendor identifier.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 include/uapi/drm/drm_fourcc.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index f7156322aba5..36771d8ffc4a 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -373,6 +373,12 @@ extern "C" {
 
 #define DRM_FORMAT_RESERVED	      ((1ULL << 56) - 1)
 
+#define fourcc_mod_get_vendor(modifier) \
+	(((modifier) >> 56) & 0xff)
+
+#define fourcc_mod_is_vendor(modifier, vendor) \
+	(fourcc_mod_get_vendor(modifier) == DRM_FORMAT_MOD_VENDOR_## vendor)
+
 #define fourcc_mod_code(vendor, val) \
 	((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | ((val) & 0x00ffffffffffffffULL))
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] drm/arm: malidp: Use fourcc_mod_is_vendor() helper
  2021-06-10 11:12 [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor Thierry Reding
@ 2021-06-10 11:12 ` Thierry Reding
  2021-06-10 11:12 ` [PATCH 3/3] drm/tegra: " Thierry Reding
  2021-08-16 10:37 ` [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor Thierry Reding
  2 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2021-06-10 11:12 UTC (permalink / raw)
  To: dri-devel; +Cc: David Airlie, Thomas Zimmermann, Daniel Vetter

From: Thierry Reding <treding@nvidia.com>

Rather than open-coding the vendor extraction operation, use the newly
introduced helper macro.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/arm/malidp_planes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index 8c2ab3d653b7..0562bdaac00c 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -165,7 +165,7 @@ bool malidp_format_mod_supported(struct drm_device *drm,
 		return !malidp_hw_format_is_afbc_only(format);
 	}
 
-	if ((modifier >> 56) != DRM_FORMAT_MOD_VENDOR_ARM) {
+	if (!fourcc_mod_is_vendor(modifier, ARM)) {
 		DRM_ERROR("Unknown modifier (not Arm)\n");
 		return false;
 	}
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] drm/tegra: Use fourcc_mod_is_vendor() helper
  2021-06-10 11:12 [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor Thierry Reding
  2021-06-10 11:12 ` [PATCH 2/3] drm/arm: malidp: Use fourcc_mod_is_vendor() helper Thierry Reding
@ 2021-06-10 11:12 ` Thierry Reding
  2021-06-10 17:37   ` Daniel Vetter
  2021-08-16 10:37 ` [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor Thierry Reding
  2 siblings, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2021-06-10 11:12 UTC (permalink / raw)
  To: dri-devel; +Cc: David Airlie, Thomas Zimmermann

From: Thierry Reding <treding@nvidia.com>

Rather than open-coding the vendor extraction operation, use the newly
introduced helper macro.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/tegra/fb.c    | 2 +-
 drivers/gpu/drm/tegra/plane.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index cae8b8cbe9dd..c04dda8353fd 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -44,7 +44,7 @@ int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
 {
 	uint64_t modifier = framebuffer->modifier;
 
-	if ((modifier >> 56) == DRM_FORMAT_MOD_VENDOR_NVIDIA) {
+	if (fourcc_mod_is_vendor(modifier, NVIDIA)) {
 		if ((modifier & DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT) == 0)
 			tiling->sector_layout = TEGRA_BO_SECTOR_LAYOUT_TEGRA;
 		else
diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c
index 2e65b4075ce6..f7496425fa83 100644
--- a/drivers/gpu/drm/tegra/plane.c
+++ b/drivers/gpu/drm/tegra/plane.c
@@ -109,7 +109,7 @@ static bool tegra_plane_format_mod_supported(struct drm_plane *plane,
 		return true;
 
 	/* check for the sector layout bit */
-	if ((modifier >> 56) == DRM_FORMAT_MOD_VENDOR_NVIDIA) {
+	if (fourcc_mod_is_vendor(modifier, NVIDIA)) {
 		if (modifier & DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT) {
 			if (!tegra_plane_supports_sector_layout(plane))
 				return false;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] drm/tegra: Use fourcc_mod_is_vendor() helper
  2021-06-10 11:12 ` [PATCH 3/3] drm/tegra: " Thierry Reding
@ 2021-06-10 17:37   ` Daniel Vetter
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2021-06-10 17:37 UTC (permalink / raw)
  To: Thierry Reding; +Cc: David Airlie, dri-devel, Thomas Zimmermann

On Thu, Jun 10, 2021 at 01:12:36PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Rather than open-coding the vendor extraction operation, use the newly
> introduced helper macro.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/tegra/fb.c    | 2 +-
>  drivers/gpu/drm/tegra/plane.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
> index cae8b8cbe9dd..c04dda8353fd 100644
> --- a/drivers/gpu/drm/tegra/fb.c
> +++ b/drivers/gpu/drm/tegra/fb.c
> @@ -44,7 +44,7 @@ int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
>  {
>  	uint64_t modifier = framebuffer->modifier;
>  
> -	if ((modifier >> 56) == DRM_FORMAT_MOD_VENDOR_NVIDIA) {
> +	if (fourcc_mod_is_vendor(modifier, NVIDIA)) {
>  		if ((modifier & DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT) == 0)
>  			tiling->sector_layout = TEGRA_BO_SECTOR_LAYOUT_TEGRA;
>  		else
> diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c
> index 2e65b4075ce6..f7496425fa83 100644
> --- a/drivers/gpu/drm/tegra/plane.c
> +++ b/drivers/gpu/drm/tegra/plane.c
> @@ -109,7 +109,7 @@ static bool tegra_plane_format_mod_supported(struct drm_plane *plane,
>  		return true;
>  
>  	/* check for the sector layout bit */
> -	if ((modifier >> 56) == DRM_FORMAT_MOD_VENDOR_NVIDIA) {
> +	if (fourcc_mod_is_vendor(modifier, NVIDIA)) {
>  		if (modifier & DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT) {
>  			if (!tegra_plane_supports_sector_layout(plane))
>  				return false;
> -- 
> 2.31.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor
  2021-06-10 11:12 [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor Thierry Reding
  2021-06-10 11:12 ` [PATCH 2/3] drm/arm: malidp: Use fourcc_mod_is_vendor() helper Thierry Reding
  2021-06-10 11:12 ` [PATCH 3/3] drm/tegra: " Thierry Reding
@ 2021-08-16 10:37 ` Thierry Reding
  2 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2021-08-16 10:37 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, Daniel Vetter, Daniel Stone, Maarten Lankhorst,
	Thomas Zimmermann, Maxime Ripard, Simon Ser, Daniel Vetter,
	Daniel Stone

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

On Thu, Jun 10, 2021 at 01:12:34PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> When working with framebuffer modifiers, it can be useful to extract the
> vendor identifier or check a modifier against a given vendor identifier.
> Add one macro that extracts the vendor identifier and a helper to check
> a modifier against a given vendor identifier.
> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Acked-by: Daniel Stone <daniels@collabora.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  include/uapi/drm/drm_fourcc.h | 6 ++++++
>  1 file changed, 6 insertions(+)

Sorry for this taking so long, I've finally applied this to
drm-misc-next.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-16 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 11:12 [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor Thierry Reding
2021-06-10 11:12 ` [PATCH 2/3] drm/arm: malidp: Use fourcc_mod_is_vendor() helper Thierry Reding
2021-06-10 11:12 ` [PATCH 3/3] drm/tegra: " Thierry Reding
2021-06-10 17:37   ` Daniel Vetter
2021-08-16 10:37 ` [PATCH 1/3] drm/fourcc: Add macros to determine the modifier vendor Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).