drm/fourcc: Add macros to determine the modifier vendor
Subsystems (5)
PATCH 1/3 drm/fourcc: Add macros to determine the modifier vendor
From: Thierry Reding <[email protected]>
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.
--- include/uapi/drm/drm_fourcc.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/uapi/drm/drm_fourcc.h +6 -0
@@ -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))
Signature · 1 line
2.31.1
PATCH 2/3 drm/arm: malidp: Use fourcc_mod_is_vendor() helper
From: Thierry Reding <[email protected]>
Rather than open-coding the vendor extraction operation, use the newly introduced helper macro.
--- drivers/gpu/drm/arm/malidp_planes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/arm/malidp_planes.c +1 -1
@@ -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; }
Signature · 1 line
2.31.1
PATCH 3/3 drm/tegra: Use fourcc_mod_is_vendor() helper
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
Rather than open-coding the vendor extraction operation, use the newly introduced helper macro.
--- drivers/gpu/drm/tegra/fb.c | 2 +- drivers/gpu/drm/tegra/plane.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tegra/fb.c +1 -1
@@ -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
drivers/gpu/drm/tegra/plane.c +1 -1
@@ -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;
Signature · 1 line
2.31.1
Re: [PATCH 3/3] drm/tegra: Use fourcc_mod_is_vendor() helper
Quoted 6 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Rather than open-coding the vendor extraction operation, use the newly introduced helper macro.
Signed-off-by Thierry Reding <[email protected]>
Quoted 34 lines
--- drivers/gpu/drm/tegra/fb.c | 2 +- drivers/gpu/drm/tegra/plane.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/tegra/fb.c +1
-1@@ -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 drivers/gpu/drm/tegra/plane.c +1
-1@@ -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;Signature · 1 line
2.31.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 7 lines · Thierry Reding
From: Thierry Reding <[email protected]>
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.
Quoted 6 lines
Reviewed-by Daniel Vetter <[email protected]>Acked-by Daniel Stone <[email protected]>Signed-off-by Thierry Reding <[email protected]>--- 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