All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: add drm_format_alpha_bits
@ 2018-01-12 14:21 ` Ayan Halder
  0 siblings, 0 replies; 12+ messages in thread
From: Ayan Halder @ 2018-01-12 14:21 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, daniel.vetter,
	jani.nikula, seanpaul, airlied, dri-devel, linux-kernel
  Cc: nd

drm_format_info does not describe the number of bits used for the alpha
channel. That information is useful in a central place like drm_fourcc.c
where it can be queried by the drivers that want to determine if 'alpha
blending' is to be enabled or not.

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
---
 drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
 include/drm/drm_fourcc.h     |   3 +
 2 files changed, 89 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 9c0152d..073001b 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -105,74 +105,74 @@ EXPORT_SYMBOL(drm_get_format_name);
 const struct drm_format_info *__drm_format_info(u32 format)
 {
 	static const struct drm_format_info formats[] = {
-		{ .format = DRM_FORMAT_C8,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB332,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR233,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ARGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ABGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ARGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ABGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ARGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ABGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ARGB8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ABGR8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_YUV410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4 },
-		{ .format = DRM_FORMAT_YVU410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4 },
-		{ .format = DRM_FORMAT_YUV411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1 },
-		{ .format = DRM_FORMAT_YVU411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1 },
-		{ .format = DRM_FORMAT_YUV420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2 },
-		{ .format = DRM_FORMAT_YVU420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2 },
-		{ .format = DRM_FORMAT_YUV422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_YVU422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_YUV444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_YVU444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_NV12,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2 },
-		{ .format = DRM_FORMAT_NV21,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2 },
-		{ .format = DRM_FORMAT_NV16,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_NV61,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_NV24,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_NV42,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_YUYV,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_YVYU,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_UYVY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_VYUY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_AYUV,		.depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
+		{ .format = DRM_FORMAT_C8,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGB332,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGR233,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XRGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XBGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGBX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGRX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_ARGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 4 },
+		{ .format = DRM_FORMAT_ABGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 4 },
+		{ .format = DRM_FORMAT_RGBA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 4 },
+		{ .format = DRM_FORMAT_BGRA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 4 },
+		{ .format = DRM_FORMAT_XRGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XBGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGBX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGRX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_ARGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 1 },
+		{ .format = DRM_FORMAT_ABGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 1 },
+		{ .format = DRM_FORMAT_RGBA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 1 },
+		{ .format = DRM_FORMAT_BGRA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 1 },
+		{ .format = DRM_FORMAT_RGB565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGR565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGB888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGR888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XRGB8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XBGR8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGBX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGRX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGB565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_BGR565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_XRGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XBGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGBX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGRX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_ARGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 2 },
+		{ .format = DRM_FORMAT_ABGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 2 },
+		{ .format = DRM_FORMAT_RGBA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 2 },
+		{ .format = DRM_FORMAT_BGRA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 2 },
+		{ .format = DRM_FORMAT_ARGB8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_ABGR8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_RGBA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_BGRA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_RGB888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_BGR888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_XRGB8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_XBGR8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_RGBX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_BGRX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_YUV410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUV411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUV420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUV422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUV444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV12,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV21,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV16,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV61,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV24,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV42,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUYV,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVYU,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_UYVY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_VYUY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_AYUV,		.depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
 	};
 
 	unsigned int i;
@@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
 	return height / info->vsub;
 }
 EXPORT_SYMBOL(drm_format_plane_height);
+
+/**
+ * drm_format_alpha_bits - get the number of bits per pixel
+ * representing alpha for format
+ * @format: pixel format (DRM_FORMAT_*)
+ *
+ * Returns:
+ * The number of bits per pixel representing alpha used by the
+ * specified pixel format.
+ */
+int drm_format_alpha_bits(uint32_t format)
+{
+	const struct drm_format_info *info;
+
+	info = drm_format_info(format);
+	return info ? info->alpha : 0;
+}
+EXPORT_SYMBOL(drm_format_alpha_bits);
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index 6942e84..5513510 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
  * @cpp: Number of bytes per pixel (per plane)
  * @hsub: Horizontal chroma subsampling factor
  * @vsub: Vertical chroma subsampling factor
+ * @alpha: Number of bits per pixel representing alpha
  */
 struct drm_format_info {
 	u32 format;
@@ -46,6 +47,7 @@ struct drm_format_info {
 	u8 cpp[3];
 	u8 hsub;
 	u8 vsub;
+	u8 alpha;
 };
 
 /**
@@ -57,6 +59,7 @@ struct drm_format_name_buf {
 };
 
 const struct drm_format_info *__drm_format_info(u32 format);
+int drm_format_alpha_bits(u32 format);
 const struct drm_format_info *drm_format_info(u32 format);
 const struct drm_format_info *
 drm_get_format_info(struct drm_device *dev,
-- 
2.7.4

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

* [PATCH] drm: add drm_format_alpha_bits
@ 2018-01-12 14:21 ` Ayan Halder
  0 siblings, 0 replies; 12+ messages in thread
From: Ayan Halder @ 2018-01-12 14:21 UTC (permalink / raw)
  To: ayan.halder, liviu.dudau, brian.starkey, daniel.vetter,
	jani.nikula, seanpaul, airlied, dri-devel, linux-kernel
  Cc: nd

drm_format_info does not describe the number of bits used for the alpha
channel. That information is useful in a central place like drm_fourcc.c
where it can be queried by the drivers that want to determine if 'alpha
blending' is to be enabled or not.

Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
---
 drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
 include/drm/drm_fourcc.h     |   3 +
 2 files changed, 89 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 9c0152d..073001b 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -105,74 +105,74 @@ EXPORT_SYMBOL(drm_get_format_name);
 const struct drm_format_info *__drm_format_info(u32 format)
 {
 	static const struct drm_format_info formats[] = {
-		{ .format = DRM_FORMAT_C8,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB332,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR233,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ARGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ABGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ARGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ABGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ARGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ABGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ARGB8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_ABGR8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGB888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGR888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XRGB8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_XBGR8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_RGBX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_BGRX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_YUV410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4 },
-		{ .format = DRM_FORMAT_YVU410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4 },
-		{ .format = DRM_FORMAT_YUV411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1 },
-		{ .format = DRM_FORMAT_YVU411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1 },
-		{ .format = DRM_FORMAT_YUV420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2 },
-		{ .format = DRM_FORMAT_YVU420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2 },
-		{ .format = DRM_FORMAT_YUV422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_YVU422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_YUV444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_YVU444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_NV12,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2 },
-		{ .format = DRM_FORMAT_NV21,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2 },
-		{ .format = DRM_FORMAT_NV16,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_NV61,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_NV24,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_NV42,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1 },
-		{ .format = DRM_FORMAT_YUYV,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_YVYU,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_UYVY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_VYUY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
-		{ .format = DRM_FORMAT_AYUV,		.depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
+		{ .format = DRM_FORMAT_C8,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGB332,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGR233,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XRGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XBGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGBX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGRX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_ARGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 4 },
+		{ .format = DRM_FORMAT_ABGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 4 },
+		{ .format = DRM_FORMAT_RGBA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 4 },
+		{ .format = DRM_FORMAT_BGRA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 4 },
+		{ .format = DRM_FORMAT_XRGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XBGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGBX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGRX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_ARGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 1 },
+		{ .format = DRM_FORMAT_ABGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 1 },
+		{ .format = DRM_FORMAT_RGBA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 1 },
+		{ .format = DRM_FORMAT_BGRA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 1 },
+		{ .format = DRM_FORMAT_RGB565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGR565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGB888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGR888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XRGB8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XBGR8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGBX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGRX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGB565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_BGR565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_XRGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_XBGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_RGBX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_BGRX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_ARGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 2 },
+		{ .format = DRM_FORMAT_ABGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 2 },
+		{ .format = DRM_FORMAT_RGBA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 2 },
+		{ .format = DRM_FORMAT_BGRA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 2 },
+		{ .format = DRM_FORMAT_ARGB8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_ABGR8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_RGBA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_BGRA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_RGB888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_BGR888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_XRGB8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_XBGR8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_RGBX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_BGRX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
+		{ .format = DRM_FORMAT_YUV410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUV411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUV420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUV422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUV444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVU444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV12,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV21,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV16,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV61,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV24,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_NV42,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YUYV,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_YVYU,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_UYVY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_VYUY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .alpha = 0 },
+		{ .format = DRM_FORMAT_AYUV,		.depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .alpha = 8 },
 	};
 
 	unsigned int i;
@@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
 	return height / info->vsub;
 }
 EXPORT_SYMBOL(drm_format_plane_height);
+
+/**
+ * drm_format_alpha_bits - get the number of bits per pixel
+ * representing alpha for format
+ * @format: pixel format (DRM_FORMAT_*)
+ *
+ * Returns:
+ * The number of bits per pixel representing alpha used by the
+ * specified pixel format.
+ */
+int drm_format_alpha_bits(uint32_t format)
+{
+	const struct drm_format_info *info;
+
+	info = drm_format_info(format);
+	return info ? info->alpha : 0;
+}
+EXPORT_SYMBOL(drm_format_alpha_bits);
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index 6942e84..5513510 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
  * @cpp: Number of bytes per pixel (per plane)
  * @hsub: Horizontal chroma subsampling factor
  * @vsub: Vertical chroma subsampling factor
+ * @alpha: Number of bits per pixel representing alpha
  */
 struct drm_format_info {
 	u32 format;
@@ -46,6 +47,7 @@ struct drm_format_info {
 	u8 cpp[3];
 	u8 hsub;
 	u8 vsub;
+	u8 alpha;
 };
 
 /**
@@ -57,6 +59,7 @@ struct drm_format_name_buf {
 };
 
 const struct drm_format_info *__drm_format_info(u32 format);
+int drm_format_alpha_bits(u32 format);
 const struct drm_format_info *drm_format_info(u32 format);
 const struct drm_format_info *
 drm_get_format_info(struct drm_device *dev,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: add drm_format_alpha_bits
  2018-01-12 14:21 ` Ayan Halder
@ 2018-01-12 14:28   ` Ville Syrjälä
  -1 siblings, 0 replies; 12+ messages in thread
From: Ville Syrjälä @ 2018-01-12 14:28 UTC (permalink / raw)
  To: Ayan Halder
  Cc: liviu.dudau, brian.starkey, daniel.vetter, jani.nikula, seanpaul,
	airlied, dri-devel, linux-kernel, nd

On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> drm_format_info does not describe the number of bits used for the alpha
> channel. That information is useful in a central place like drm_fourcc.c
> where it can be queried by the drivers that want to determine if 'alpha
> blending' is to be enabled or not.
> 
> Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> ---
>  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
>  include/drm/drm_fourcc.h     |   3 +
>  2 files changed, 89 insertions(+), 68 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> index 9c0152d..073001b 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
<snip>
> @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
>  	return height / info->vsub;
>  }
>  EXPORT_SYMBOL(drm_format_plane_height);
> +
> +/**
> + * drm_format_alpha_bits - get the number of bits per pixel
> + * representing alpha for format
> + * @format: pixel format (DRM_FORMAT_*)
> + *
> + * Returns:
> + * The number of bits per pixel representing alpha used by the
> + * specified pixel format.
> + */
> +int drm_format_alpha_bits(uint32_t format)
> +{
> +	const struct drm_format_info *info;
> +
> +	info = drm_format_info(format);
> +	return info ? info->alpha : 0;
> +}
> +EXPORT_SYMBOL(drm_format_alpha_bits);

Do you have an actual use for this function somewhere?

> diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> index 6942e84..5513510 100644
> --- a/include/drm/drm_fourcc.h
> +++ b/include/drm/drm_fourcc.h
> @@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
>   * @cpp: Number of bytes per pixel (per plane)
>   * @hsub: Horizontal chroma subsampling factor
>   * @vsub: Vertical chroma subsampling factor
> + * @alpha: Number of bits per pixel representing alpha
>   */
>  struct drm_format_info {
>  	u32 format;
> @@ -46,6 +47,7 @@ struct drm_format_info {
>  	u8 cpp[3];
>  	u8 hsub;
>  	u8 vsub;
> +	u8 alpha;
>  };
>  
>  /**
> @@ -57,6 +59,7 @@ struct drm_format_name_buf {
>  };
>  
>  const struct drm_format_info *__drm_format_info(u32 format);
> +int drm_format_alpha_bits(u32 format);
>  const struct drm_format_info *drm_format_info(u32 format);
>  const struct drm_format_info *
>  drm_get_format_info(struct drm_device *dev,
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC

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

* Re: [PATCH] drm: add drm_format_alpha_bits
@ 2018-01-12 14:28   ` Ville Syrjälä
  0 siblings, 0 replies; 12+ messages in thread
From: Ville Syrjälä @ 2018-01-12 14:28 UTC (permalink / raw)
  To: Ayan Halder
  Cc: airlied, liviu.dudau, linux-kernel, dri-devel, daniel.vetter, nd

On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> drm_format_info does not describe the number of bits used for the alpha
> channel. That information is useful in a central place like drm_fourcc.c
> where it can be queried by the drivers that want to determine if 'alpha
> blending' is to be enabled or not.
> 
> Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> ---
>  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
>  include/drm/drm_fourcc.h     |   3 +
>  2 files changed, 89 insertions(+), 68 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> index 9c0152d..073001b 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
<snip>
> @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
>  	return height / info->vsub;
>  }
>  EXPORT_SYMBOL(drm_format_plane_height);
> +
> +/**
> + * drm_format_alpha_bits - get the number of bits per pixel
> + * representing alpha for format
> + * @format: pixel format (DRM_FORMAT_*)
> + *
> + * Returns:
> + * The number of bits per pixel representing alpha used by the
> + * specified pixel format.
> + */
> +int drm_format_alpha_bits(uint32_t format)
> +{
> +	const struct drm_format_info *info;
> +
> +	info = drm_format_info(format);
> +	return info ? info->alpha : 0;
> +}
> +EXPORT_SYMBOL(drm_format_alpha_bits);

Do you have an actual use for this function somewhere?

> diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> index 6942e84..5513510 100644
> --- a/include/drm/drm_fourcc.h
> +++ b/include/drm/drm_fourcc.h
> @@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
>   * @cpp: Number of bytes per pixel (per plane)
>   * @hsub: Horizontal chroma subsampling factor
>   * @vsub: Vertical chroma subsampling factor
> + * @alpha: Number of bits per pixel representing alpha
>   */
>  struct drm_format_info {
>  	u32 format;
> @@ -46,6 +47,7 @@ struct drm_format_info {
>  	u8 cpp[3];
>  	u8 hsub;
>  	u8 vsub;
> +	u8 alpha;
>  };
>  
>  /**
> @@ -57,6 +59,7 @@ struct drm_format_name_buf {
>  };
>  
>  const struct drm_format_info *__drm_format_info(u32 format);
> +int drm_format_alpha_bits(u32 format);
>  const struct drm_format_info *drm_format_info(u32 format);
>  const struct drm_format_info *
>  drm_get_format_info(struct drm_device *dev,
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: add drm_format_alpha_bits
  2018-01-12 14:28   ` Ville Syrjälä
  (?)
@ 2018-01-12 15:43   ` Ayan Halder
  2018-01-12 15:51     ` Maxime Ripard
  2018-01-12 15:53     ` Ville Syrjälä
  -1 siblings, 2 replies; 12+ messages in thread
From: Ayan Halder @ 2018-01-12 15:43 UTC (permalink / raw)
  To: Ville Syrj?l?
  Cc: nd, airlied, liviu.dudau, linux-kernel, dri-devel, daniel.vetter,
	maxime.ripard, ayan.halder

On Fri, Jan 12, 2018 at 04:28:34PM +0200, Ville Syrj?l? wrote:
> On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> > drm_format_info does not describe the number of bits used for the alpha
> > channel. That information is useful in a central place like drm_fourcc.c
> > where it can be queried by the drivers that want to determine if 'alpha
> > blending' is to be enabled or not.
> > 
> > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > ---
> >  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
> >  include/drm/drm_fourcc.h     |   3 +
> >  2 files changed, 89 insertions(+), 68 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > index 9c0152d..073001b 100644
> > --- a/drivers/gpu/drm/drm_fourcc.c
> > +++ b/drivers/gpu/drm/drm_fourcc.c
> <snip>
> > @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
> >  	return height / info->vsub;
> >  }
> >  EXPORT_SYMBOL(drm_format_plane_height);
> > +
> > +/**
> > + * drm_format_alpha_bits - get the number of bits per pixel
> > + * representing alpha for format
> > + * @format: pixel format (DRM_FORMAT_*)
> > + *
> > + * Returns:
> > + * The number of bits per pixel representing alpha used by the
> > + * specified pixel format.
> > + */
> > +int drm_format_alpha_bits(uint32_t format)
> > +{
> > +	const struct drm_format_info *info;
> > +
> > +	info = drm_format_info(format);
> > +	return info ? info->alpha : 0;
> > +}
> > +EXPORT_SYMBOL(drm_format_alpha_bits);
> 
> Do you have an actual use for this function somewhere?
Currently, we do not have a usage for this function. We need 'alpha'
field for each entry in 'drm_format_info' so as to determine whether
to enable/disable alpha blending in Mali display processor for the
particular color format. 
> 
> > diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> > index 6942e84..5513510 100644
> > --- a/include/drm/drm_fourcc.h
> > +++ b/include/drm/drm_fourcc.h
> > @@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
> >   * @cpp: Number of bytes per pixel (per plane)
> >   * @hsub: Horizontal chroma subsampling factor
> >   * @vsub: Vertical chroma subsampling factor
> > + * @alpha: Number of bits per pixel representing alpha
> >   */
> >  struct drm_format_info {
> >  	u32 format;
> > @@ -46,6 +47,7 @@ struct drm_format_info {
> >  	u8 cpp[3];
> >  	u8 hsub;
> >  	u8 vsub;
> > +	u8 alpha;
> >  };
> >  
> >  /**
> > @@ -57,6 +59,7 @@ struct drm_format_name_buf {
> >  };
> >  
> >  const struct drm_format_info *__drm_format_info(u32 format);
> > +int drm_format_alpha_bits(u32 format);
> >  const struct drm_format_info *drm_format_info(u32 format);
> >  const struct drm_format_info *
> >  drm_get_format_info(struct drm_device *dev,
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Ville Syrj??l??
> Intel OTC
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: add drm_format_alpha_bits
  2018-01-12 15:43   ` Ayan Halder
@ 2018-01-12 15:51     ` Maxime Ripard
  2018-01-12 16:18         ` Ayan Halder
  2018-01-12 15:53     ` Ville Syrjälä
  1 sibling, 1 reply; 12+ messages in thread
From: Maxime Ripard @ 2018-01-12 15:51 UTC (permalink / raw)
  To: Ayan Halder
  Cc: airlied, liviu.dudau, linux-kernel, dri-devel, daniel.vetter, nd


[-- Attachment #1.1: Type: text/plain, Size: 2424 bytes --]

Hi,

On Fri, Jan 12, 2018 at 03:43:49PM +0000, Ayan Halder wrote:
> On Fri, Jan 12, 2018 at 04:28:34PM +0200, Ville Syrj?l? wrote:
> > On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> > > drm_format_info does not describe the number of bits used for the alpha
> > > channel. That information is useful in a central place like drm_fourcc.c
> > > where it can be queried by the drivers that want to determine if 'alpha
> > > blending' is to be enabled or not.
> > > 
> > > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > > ---
> > >  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
> > >  include/drm/drm_fourcc.h     |   3 +
> > >  2 files changed, 89 insertions(+), 68 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > > index 9c0152d..073001b 100644
> > > --- a/drivers/gpu/drm/drm_fourcc.c
> > > +++ b/drivers/gpu/drm/drm_fourcc.c
> > <snip>
> > > @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
> > >  	return height / info->vsub;
> > >  }
> > >  EXPORT_SYMBOL(drm_format_plane_height);
> > > +
> > > +/**
> > > + * drm_format_alpha_bits - get the number of bits per pixel
> > > + * representing alpha for format
> > > + * @format: pixel format (DRM_FORMAT_*)
> > > + *
> > > + * Returns:
> > > + * The number of bits per pixel representing alpha used by the
> > > + * specified pixel format.
> > > + */
> > > +int drm_format_alpha_bits(uint32_t format)
> > > +{
> > > +	const struct drm_format_info *info;
> > > +
> > > +	info = drm_format_info(format);
> > > +	return info ? info->alpha : 0;
> > > +}
> > > +EXPORT_SYMBOL(drm_format_alpha_bits);
> > 
> > Do you have an actual use for this function somewhere?
>
> Currently, we do not have a usage for this function. We need 'alpha'
> field for each entry in 'drm_format_info' so as to determine whether
> to enable/disable alpha blending in Mali display processor for the
> particular color format.

Do you need only the info that a particular channel has an alpha
component, or do you also need the number of bits?

In the former case, then my serie sent earlier this week would help I
guess.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: add drm_format_alpha_bits
  2018-01-12 15:43   ` Ayan Halder
  2018-01-12 15:51     ` Maxime Ripard
@ 2018-01-12 15:53     ` Ville Syrjälä
  2018-01-12 16:11       ` Ayan Halder
  1 sibling, 1 reply; 12+ messages in thread
From: Ville Syrjälä @ 2018-01-12 15:53 UTC (permalink / raw)
  To: Ayan Halder
  Cc: airlied, liviu.dudau, linux-kernel, dri-devel, daniel.vetter,
	maxime.ripard, nd

On Fri, Jan 12, 2018 at 03:43:49PM +0000, Ayan Halder wrote:
> On Fri, Jan 12, 2018 at 04:28:34PM +0200, Ville Syrj?l? wrote:
> > On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> > > drm_format_info does not describe the number of bits used for the alpha
> > > channel. That information is useful in a central place like drm_fourcc.c
> > > where it can be queried by the drivers that want to determine if 'alpha
> > > blending' is to be enabled or not.
> > > 
> > > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > > ---
> > >  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
> > >  include/drm/drm_fourcc.h     |   3 +
> > >  2 files changed, 89 insertions(+), 68 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > > index 9c0152d..073001b 100644
> > > --- a/drivers/gpu/drm/drm_fourcc.c
> > > +++ b/drivers/gpu/drm/drm_fourcc.c
> > <snip>
> > > @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
> > >  	return height / info->vsub;
> > >  }
> > >  EXPORT_SYMBOL(drm_format_plane_height);
> > > +
> > > +/**
> > > + * drm_format_alpha_bits - get the number of bits per pixel
> > > + * representing alpha for format
> > > + * @format: pixel format (DRM_FORMAT_*)
> > > + *
> > > + * Returns:
> > > + * The number of bits per pixel representing alpha used by the
> > > + * specified pixel format.
> > > + */
> > > +int drm_format_alpha_bits(uint32_t format)
> > > +{
> > > +	const struct drm_format_info *info;
> > > +
> > > +	info = drm_format_info(format);
> > > +	return info ? info->alpha : 0;
> > > +}
> > > +EXPORT_SYMBOL(drm_format_alpha_bits);
> > 
> > Do you have an actual use for this function somewhere?
> Currently, we do not have a usage for this function.

No point in adding the function then IMO.

> We need 'alpha'
> field for each entry in 'drm_format_info' so as to determine whether
> to enable/disable alpha blending in Mali display processor for the
> particular color format. 

I think that's OK. Not sure if it really helps much though since you
generally have to configure other things based on the format as well, so
I would expect almost everyone will end up with some kind of
swicth/table to configure the hardware based on the format. Based on a
quick look this doesn't really help i915 at least.

> > 
> > > diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> > > index 6942e84..5513510 100644
> > > --- a/include/drm/drm_fourcc.h
> > > +++ b/include/drm/drm_fourcc.h
> > > @@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
> > >   * @cpp: Number of bytes per pixel (per plane)
> > >   * @hsub: Horizontal chroma subsampling factor
> > >   * @vsub: Vertical chroma subsampling factor
> > > + * @alpha: Number of bits per pixel representing alpha
> > >   */
> > >  struct drm_format_info {
> > >  	u32 format;
> > > @@ -46,6 +47,7 @@ struct drm_format_info {
> > >  	u8 cpp[3];
> > >  	u8 hsub;
> > >  	u8 vsub;
> > > +	u8 alpha;
> > >  };
> > >  
> > >  /**
> > > @@ -57,6 +59,7 @@ struct drm_format_name_buf {
> > >  };
> > >  
> > >  const struct drm_format_info *__drm_format_info(u32 format);
> > > +int drm_format_alpha_bits(u32 format);
> > >  const struct drm_format_info *drm_format_info(u32 format);
> > >  const struct drm_format_info *
> > >  drm_get_format_info(struct drm_device *dev,
> > > -- 
> > > 2.7.4
> > > 
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > 
> > -- 
> > Ville Syrj??l??
> > Intel OTC
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: add drm_format_alpha_bits
  2018-01-12 15:53     ` Ville Syrjälä
@ 2018-01-12 16:11       ` Ayan Halder
  2018-01-12 16:25           ` Ville Syrjälä
  0 siblings, 1 reply; 12+ messages in thread
From: Ayan Halder @ 2018-01-12 16:11 UTC (permalink / raw)
  To: Ville Syrj?l?
  Cc: liviu.dudau, brian.starkey, daniel.vetter, jani.nikula, seanpaul,
	airlied, dri-devel, linux-kernel, maxime.ripard, nd

On Fri, Jan 12, 2018 at 05:53:33PM +0200, Ville Syrj?l? wrote:
> On Fri, Jan 12, 2018 at 03:43:49PM +0000, Ayan Halder wrote:
> > On Fri, Jan 12, 2018 at 04:28:34PM +0200, Ville Syrj?l? wrote:
> > > On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> > > > drm_format_info does not describe the number of bits used for the alpha
> > > > channel. That information is useful in a central place like drm_fourcc.c
> > > > where it can be queried by the drivers that want to determine if 'alpha
> > > > blending' is to be enabled or not.
> > > > 
> > > > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > > > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
> > > >  include/drm/drm_fourcc.h     |   3 +
> > > >  2 files changed, 89 insertions(+), 68 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > > > index 9c0152d..073001b 100644
> > > > --- a/drivers/gpu/drm/drm_fourcc.c
> > > > +++ b/drivers/gpu/drm/drm_fourcc.c
> > > <snip>
> > > > @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
> > > >  	return height / info->vsub;
> > > >  }
> > > >  EXPORT_SYMBOL(drm_format_plane_height);
> > > > +
> > > > +/**
> > > > + * drm_format_alpha_bits - get the number of bits per pixel
> > > > + * representing alpha for format
> > > > + * @format: pixel format (DRM_FORMAT_*)
> > > > + *
> > > > + * Returns:
> > > > + * The number of bits per pixel representing alpha used by the
> > > > + * specified pixel format.
> > > > + */
> > > > +int drm_format_alpha_bits(uint32_t format)
> > > > +{
> > > > +	const struct drm_format_info *info;
> > > > +
> > > > +	info = drm_format_info(format);
> > > > +	return info ? info->alpha : 0;
> > > > +}
> > > > +EXPORT_SYMBOL(drm_format_alpha_bits);
> > > 
> > > Do you have an actual use for this function somewhere?
> > Currently, we do not have a usage for this function.
> 
> No point in adding the function then IMO.
We have helper functions for the other fields so I followed the same
and added the helper function for the new field ('alpha') too.
> 
> > We need 'alpha'
> > field for each entry in 'drm_format_info' so as to determine whether
> > to enable/disable alpha blending in Mali display processor for the
> > particular color format. 
> 
> I think that's OK. Not sure if it really helps much though since you
> generally have to configure other things based on the format as well, so
> I would expect almost everyone will end up with some kind of
> swicth/table to configure the hardware based on the format. Based on a
> quick look this doesn't really help i915 at least.

My understanding was based on the fact that alpha blending could be a
common feature for all the drivers (I might be wrong). So, if we keep
the number of 'alpha' bits in 'drm_format_info', it would be useful to
fetch this info similar to the existing fields.
> > > 
> > > > diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> > > > index 6942e84..5513510 100644
> > > > --- a/include/drm/drm_fourcc.h
> > > > +++ b/include/drm/drm_fourcc.h
> > > > @@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
> > > >   * @cpp: Number of bytes per pixel (per plane)
> > > >   * @hsub: Horizontal chroma subsampling factor
> > > >   * @vsub: Vertical chroma subsampling factor
> > > > + * @alpha: Number of bits per pixel representing alpha
> > > >   */
> > > >  struct drm_format_info {
> > > >  	u32 format;
> > > > @@ -46,6 +47,7 @@ struct drm_format_info {
> > > >  	u8 cpp[3];
> > > >  	u8 hsub;
> > > >  	u8 vsub;
> > > > +	u8 alpha;
> > > >  };
> > > >  
> > > >  /**
> > > > @@ -57,6 +59,7 @@ struct drm_format_name_buf {
> > > >  };
> > > >  
> > > >  const struct drm_format_info *__drm_format_info(u32 format);
> > > > +int drm_format_alpha_bits(u32 format);
> > > >  const struct drm_format_info *drm_format_info(u32 format);
> > > >  const struct drm_format_info *
> > > >  drm_get_format_info(struct drm_device *dev,
> > > > -- 
> > > > 2.7.4
> > > > 
> > > > _______________________________________________
> > > > dri-devel mailing list
> > > > dri-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > > 
> > > -- 
> > > Ville Syrj??l??
> > > Intel OTC
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Ville Syrj?l?
> Intel OTC

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

* Re: [PATCH] drm: add drm_format_alpha_bits
  2018-01-12 15:51     ` Maxime Ripard
@ 2018-01-12 16:18         ` Ayan Halder
  0 siblings, 0 replies; 12+ messages in thread
From: Ayan Halder @ 2018-01-12 16:18 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Ville Syrj?l?,
	nd, airlied, liviu.dudau, linux-kernel, dri-devel, daniel.vetter

On Fri, Jan 12, 2018 at 04:51:16PM +0100, Maxime Ripard wrote:
> Hi,
> 
> On Fri, Jan 12, 2018 at 03:43:49PM +0000, Ayan Halder wrote:
> > On Fri, Jan 12, 2018 at 04:28:34PM +0200, Ville Syrj?l? wrote:
> > > On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> > > > drm_format_info does not describe the number of bits used for the alpha
> > > > channel. That information is useful in a central place like drm_fourcc.c
> > > > where it can be queried by the drivers that want to determine if 'alpha
> > > > blending' is to be enabled or not.
> > > > 
> > > > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > > > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
> > > >  include/drm/drm_fourcc.h     |   3 +
> > > >  2 files changed, 89 insertions(+), 68 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > > > index 9c0152d..073001b 100644
> > > > --- a/drivers/gpu/drm/drm_fourcc.c
> > > > +++ b/drivers/gpu/drm/drm_fourcc.c
> > > <snip>
> > > > @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
> > > >  	return height / info->vsub;
> > > >  }
> > > >  EXPORT_SYMBOL(drm_format_plane_height);
> > > > +
> > > > +/**
> > > > + * drm_format_alpha_bits - get the number of bits per pixel
> > > > + * representing alpha for format
> > > > + * @format: pixel format (DRM_FORMAT_*)
> > > > + *
> > > > + * Returns:
> > > > + * The number of bits per pixel representing alpha used by the
> > > > + * specified pixel format.
> > > > + */
> > > > +int drm_format_alpha_bits(uint32_t format)
> > > > +{
> > > > +	const struct drm_format_info *info;
> > > > +
> > > > +	info = drm_format_info(format);
> > > > +	return info ? info->alpha : 0;
> > > > +}
> > > > +EXPORT_SYMBOL(drm_format_alpha_bits);
> > > 
> > > Do you have an actual use for this function somewhere?
> >
> > Currently, we do not have a usage for this function. We need 'alpha'
> > field for each entry in 'drm_format_info' so as to determine whether
> > to enable/disable alpha blending in Mali display processor for the
> > particular color format.
> 
> Do you need only the info that a particular channel has an alpha
> component, or do you also need the number of bits?

Currently, only the info whether alpha component is present in a
particular channel. I saw your patch and thought that instead of
returning true/false, it might be useful to capture the number of
alpha bits for each format.
> In the former case, then my serie sent earlier this week would help I
> guess.
> 
> Maxime
> 
> -- 
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

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

* Re: [PATCH] drm: add drm_format_alpha_bits
@ 2018-01-12 16:18         ` Ayan Halder
  0 siblings, 0 replies; 12+ messages in thread
From: Ayan Halder @ 2018-01-12 16:18 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: airlied, liviu.dudau, linux-kernel, dri-devel, daniel.vetter, nd

On Fri, Jan 12, 2018 at 04:51:16PM +0100, Maxime Ripard wrote:
> Hi,
> 
> On Fri, Jan 12, 2018 at 03:43:49PM +0000, Ayan Halder wrote:
> > On Fri, Jan 12, 2018 at 04:28:34PM +0200, Ville Syrj?l? wrote:
> > > On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> > > > drm_format_info does not describe the number of bits used for the alpha
> > > > channel. That information is useful in a central place like drm_fourcc.c
> > > > where it can be queried by the drivers that want to determine if 'alpha
> > > > blending' is to be enabled or not.
> > > > 
> > > > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > > > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
> > > >  include/drm/drm_fourcc.h     |   3 +
> > > >  2 files changed, 89 insertions(+), 68 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > > > index 9c0152d..073001b 100644
> > > > --- a/drivers/gpu/drm/drm_fourcc.c
> > > > +++ b/drivers/gpu/drm/drm_fourcc.c
> > > <snip>
> > > > @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
> > > >  	return height / info->vsub;
> > > >  }
> > > >  EXPORT_SYMBOL(drm_format_plane_height);
> > > > +
> > > > +/**
> > > > + * drm_format_alpha_bits - get the number of bits per pixel
> > > > + * representing alpha for format
> > > > + * @format: pixel format (DRM_FORMAT_*)
> > > > + *
> > > > + * Returns:
> > > > + * The number of bits per pixel representing alpha used by the
> > > > + * specified pixel format.
> > > > + */
> > > > +int drm_format_alpha_bits(uint32_t format)
> > > > +{
> > > > +	const struct drm_format_info *info;
> > > > +
> > > > +	info = drm_format_info(format);
> > > > +	return info ? info->alpha : 0;
> > > > +}
> > > > +EXPORT_SYMBOL(drm_format_alpha_bits);
> > > 
> > > Do you have an actual use for this function somewhere?
> >
> > Currently, we do not have a usage for this function. We need 'alpha'
> > field for each entry in 'drm_format_info' so as to determine whether
> > to enable/disable alpha blending in Mali display processor for the
> > particular color format.
> 
> Do you need only the info that a particular channel has an alpha
> component, or do you also need the number of bits?

Currently, only the info whether alpha component is present in a
particular channel. I saw your patch and thought that instead of
returning true/false, it might be useful to capture the number of
alpha bits for each format.
> In the former case, then my serie sent earlier this week would help I
> guess.
> 
> Maxime
> 
> -- 
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm: add drm_format_alpha_bits
  2018-01-12 16:11       ` Ayan Halder
@ 2018-01-12 16:25           ` Ville Syrjälä
  0 siblings, 0 replies; 12+ messages in thread
From: Ville Syrjälä @ 2018-01-12 16:25 UTC (permalink / raw)
  To: Ayan Halder
  Cc: liviu.dudau, brian.starkey, daniel.vetter, jani.nikula, seanpaul,
	airlied, dri-devel, linux-kernel, maxime.ripard, nd

On Fri, Jan 12, 2018 at 04:11:38PM +0000, Ayan Halder wrote:
> On Fri, Jan 12, 2018 at 05:53:33PM +0200, Ville Syrj?l? wrote:
> > On Fri, Jan 12, 2018 at 03:43:49PM +0000, Ayan Halder wrote:
> > > On Fri, Jan 12, 2018 at 04:28:34PM +0200, Ville Syrj?l? wrote:
> > > > On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> > > > > drm_format_info does not describe the number of bits used for the alpha
> > > > > channel. That information is useful in a central place like drm_fourcc.c
> > > > > where it can be queried by the drivers that want to determine if 'alpha
> > > > > blending' is to be enabled or not.
> > > > > 
> > > > > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > > > > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > > > > ---
> > > > >  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
> > > > >  include/drm/drm_fourcc.h     |   3 +
> > > > >  2 files changed, 89 insertions(+), 68 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > > > > index 9c0152d..073001b 100644
> > > > > --- a/drivers/gpu/drm/drm_fourcc.c
> > > > > +++ b/drivers/gpu/drm/drm_fourcc.c
> > > > <snip>
> > > > > @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
> > > > >  	return height / info->vsub;
> > > > >  }
> > > > >  EXPORT_SYMBOL(drm_format_plane_height);
> > > > > +
> > > > > +/**
> > > > > + * drm_format_alpha_bits - get the number of bits per pixel
> > > > > + * representing alpha for format
> > > > > + * @format: pixel format (DRM_FORMAT_*)
> > > > > + *
> > > > > + * Returns:
> > > > > + * The number of bits per pixel representing alpha used by the
> > > > > + * specified pixel format.
> > > > > + */
> > > > > +int drm_format_alpha_bits(uint32_t format)
> > > > > +{
> > > > > +	const struct drm_format_info *info;
> > > > > +
> > > > > +	info = drm_format_info(format);
> > > > > +	return info ? info->alpha : 0;
> > > > > +}
> > > > > +EXPORT_SYMBOL(drm_format_alpha_bits);
> > > > 
> > > > Do you have an actual use for this function somewhere?
> > > Currently, we do not have a usage for this function.
> > 
> > No point in adding the function then IMO.
> We have helper functions for the other fields so I followed the same
> and added the helper function for the new field ('alpha') too.

Those helpers are mostly there for legacy reasons. Ideally someone would
go over all the code and clean up the cases where using those helpers
makes no sense (ie. when you already have the format structure around)
and then remove the helpers if/when they're no longer needed. This sort
of stuff tends to linger around for a while after bigger mechanical
conversions like the addition of the format info structure.

> > 
> > > We need 'alpha'
> > > field for each entry in 'drm_format_info' so as to determine whether
> > > to enable/disable alpha blending in Mali display processor for the
> > > particular color format. 
> > 
> > I think that's OK. Not sure if it really helps much though since you
> > generally have to configure other things based on the format as well, so
> > I would expect almost everyone will end up with some kind of
> > swicth/table to configure the hardware based on the format. Based on a
> > quick look this doesn't really help i915 at least.
> 
> My understanding was based on the fact that alpha blending could be a
> common feature for all the drivers (I might be wrong). So, if we keep
> the number of 'alpha' bits in 'drm_format_info', it would be useful to
> fetch this info similar to the existing fields.

I'm just saying that ut doesn't really provide much extra help if
the driver already has eg. a switch statement for all the formats
anyway.

> > > > 
> > > > > diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> > > > > index 6942e84..5513510 100644
> > > > > --- a/include/drm/drm_fourcc.h
> > > > > +++ b/include/drm/drm_fourcc.h
> > > > > @@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
> > > > >   * @cpp: Number of bytes per pixel (per plane)
> > > > >   * @hsub: Horizontal chroma subsampling factor
> > > > >   * @vsub: Vertical chroma subsampling factor
> > > > > + * @alpha: Number of bits per pixel representing alpha
> > > > >   */
> > > > >  struct drm_format_info {
> > > > >  	u32 format;
> > > > > @@ -46,6 +47,7 @@ struct drm_format_info {
> > > > >  	u8 cpp[3];
> > > > >  	u8 hsub;
> > > > >  	u8 vsub;
> > > > > +	u8 alpha;
> > > > >  };
> > > > >  
> > > > >  /**
> > > > > @@ -57,6 +59,7 @@ struct drm_format_name_buf {
> > > > >  };
> > > > >  
> > > > >  const struct drm_format_info *__drm_format_info(u32 format);
> > > > > +int drm_format_alpha_bits(u32 format);
> > > > >  const struct drm_format_info *drm_format_info(u32 format);
> > > > >  const struct drm_format_info *
> > > > >  drm_get_format_info(struct drm_device *dev,
> > > > > -- 
> > > > > 2.7.4
> > > > > 
> > > > > _______________________________________________
> > > > > dri-devel mailing list
> > > > > dri-devel@lists.freedesktop.org
> > > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > > > 
> > > > -- 
> > > > Ville Syrj??l??
> > > > Intel OTC
> > > > _______________________________________________
> > > > dri-devel mailing list
> > > > dri-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > 
> > -- 
> > Ville Syrj?l?
> > Intel OTC

-- 
Ville Syrjälä
Intel OTC

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

* Re: [PATCH] drm: add drm_format_alpha_bits
@ 2018-01-12 16:25           ` Ville Syrjälä
  0 siblings, 0 replies; 12+ messages in thread
From: Ville Syrjälä @ 2018-01-12 16:25 UTC (permalink / raw)
  To: Ayan Halder
  Cc: airlied, liviu.dudau, linux-kernel, dri-devel, daniel.vetter,
	maxime.ripard, nd

On Fri, Jan 12, 2018 at 04:11:38PM +0000, Ayan Halder wrote:
> On Fri, Jan 12, 2018 at 05:53:33PM +0200, Ville Syrj?l? wrote:
> > On Fri, Jan 12, 2018 at 03:43:49PM +0000, Ayan Halder wrote:
> > > On Fri, Jan 12, 2018 at 04:28:34PM +0200, Ville Syrj?l? wrote:
> > > > On Fri, Jan 12, 2018 at 02:21:16PM +0000, Ayan Halder wrote:
> > > > > drm_format_info does not describe the number of bits used for the alpha
> > > > > channel. That information is useful in a central place like drm_fourcc.c
> > > > > where it can be queried by the drivers that want to determine if 'alpha
> > > > > blending' is to be enabled or not.
> > > > > 
> > > > > Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
> > > > > Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> > > > > ---
> > > > >  drivers/gpu/drm/drm_fourcc.c | 154 ++++++++++++++++++++++++-------------------
> > > > >  include/drm/drm_fourcc.h     |   3 +
> > > > >  2 files changed, 89 insertions(+), 68 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> > > > > index 9c0152d..073001b 100644
> > > > > --- a/drivers/gpu/drm/drm_fourcc.c
> > > > > +++ b/drivers/gpu/drm/drm_fourcc.c
> > > > <snip>
> > > > > @@ -348,3 +348,21 @@ int drm_format_plane_height(int height, uint32_t format, int plane)
> > > > >  	return height / info->vsub;
> > > > >  }
> > > > >  EXPORT_SYMBOL(drm_format_plane_height);
> > > > > +
> > > > > +/**
> > > > > + * drm_format_alpha_bits - get the number of bits per pixel
> > > > > + * representing alpha for format
> > > > > + * @format: pixel format (DRM_FORMAT_*)
> > > > > + *
> > > > > + * Returns:
> > > > > + * The number of bits per pixel representing alpha used by the
> > > > > + * specified pixel format.
> > > > > + */
> > > > > +int drm_format_alpha_bits(uint32_t format)
> > > > > +{
> > > > > +	const struct drm_format_info *info;
> > > > > +
> > > > > +	info = drm_format_info(format);
> > > > > +	return info ? info->alpha : 0;
> > > > > +}
> > > > > +EXPORT_SYMBOL(drm_format_alpha_bits);
> > > > 
> > > > Do you have an actual use for this function somewhere?
> > > Currently, we do not have a usage for this function.
> > 
> > No point in adding the function then IMO.
> We have helper functions for the other fields so I followed the same
> and added the helper function for the new field ('alpha') too.

Those helpers are mostly there for legacy reasons. Ideally someone would
go over all the code and clean up the cases where using those helpers
makes no sense (ie. when you already have the format structure around)
and then remove the helpers if/when they're no longer needed. This sort
of stuff tends to linger around for a while after bigger mechanical
conversions like the addition of the format info structure.

> > 
> > > We need 'alpha'
> > > field for each entry in 'drm_format_info' so as to determine whether
> > > to enable/disable alpha blending in Mali display processor for the
> > > particular color format. 
> > 
> > I think that's OK. Not sure if it really helps much though since you
> > generally have to configure other things based on the format as well, so
> > I would expect almost everyone will end up with some kind of
> > swicth/table to configure the hardware based on the format. Based on a
> > quick look this doesn't really help i915 at least.
> 
> My understanding was based on the fact that alpha blending could be a
> common feature for all the drivers (I might be wrong). So, if we keep
> the number of 'alpha' bits in 'drm_format_info', it would be useful to
> fetch this info similar to the existing fields.

I'm just saying that ut doesn't really provide much extra help if
the driver already has eg. a switch statement for all the formats
anyway.

> > > > 
> > > > > diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> > > > > index 6942e84..5513510 100644
> > > > > --- a/include/drm/drm_fourcc.h
> > > > > +++ b/include/drm/drm_fourcc.h
> > > > > @@ -38,6 +38,7 @@ struct drm_mode_fb_cmd2;
> > > > >   * @cpp: Number of bytes per pixel (per plane)
> > > > >   * @hsub: Horizontal chroma subsampling factor
> > > > >   * @vsub: Vertical chroma subsampling factor
> > > > > + * @alpha: Number of bits per pixel representing alpha
> > > > >   */
> > > > >  struct drm_format_info {
> > > > >  	u32 format;
> > > > > @@ -46,6 +47,7 @@ struct drm_format_info {
> > > > >  	u8 cpp[3];
> > > > >  	u8 hsub;
> > > > >  	u8 vsub;
> > > > > +	u8 alpha;
> > > > >  };
> > > > >  
> > > > >  /**
> > > > > @@ -57,6 +59,7 @@ struct drm_format_name_buf {
> > > > >  };
> > > > >  
> > > > >  const struct drm_format_info *__drm_format_info(u32 format);
> > > > > +int drm_format_alpha_bits(u32 format);
> > > > >  const struct drm_format_info *drm_format_info(u32 format);
> > > > >  const struct drm_format_info *
> > > > >  drm_get_format_info(struct drm_device *dev,
> > > > > -- 
> > > > > 2.7.4
> > > > > 
> > > > > _______________________________________________
> > > > > dri-devel mailing list
> > > > > dri-devel@lists.freedesktop.org
> > > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > > > 
> > > > -- 
> > > > Ville Syrj??l??
> > > > Intel OTC
> > > > _______________________________________________
> > > > dri-devel mailing list
> > > > dri-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > 
> > -- 
> > Ville Syrj?l?
> > Intel OTC

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2018-01-12 16:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-12 14:21 [PATCH] drm: add drm_format_alpha_bits Ayan Halder
2018-01-12 14:21 ` Ayan Halder
2018-01-12 14:28 ` Ville Syrjälä
2018-01-12 14:28   ` Ville Syrjälä
2018-01-12 15:43   ` Ayan Halder
2018-01-12 15:51     ` Maxime Ripard
2018-01-12 16:18       ` Ayan Halder
2018-01-12 16:18         ` Ayan Halder
2018-01-12 15:53     ` Ville Syrjälä
2018-01-12 16:11       ` Ayan Halder
2018-01-12 16:25         ` Ville Syrjälä
2018-01-12 16:25           ` Ville Syrjälä

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.