Skip to contentSkip to conversation

media: Add AFBC pixel formats

RFC New Benjamin Gaignard 1 participant 1 message Apr 17 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

RFC v2 1/1 media: Add AFBC pixel formats

Add 8-bit and 10-bit YUV420 Arm Frame Buffer Compression (AFBC) pixel formats.

AFBC stride and image size computation needed to be done by specific helpers functions which are also exported to be used by drivers.

Add documentation for each of the formats.

---
 .../userspace-api/media/v4l/pixfmt-afbc.rst   |  74 +++++++++++++
 .../userspace-api/media/v4l/pixfmt.rst        |   1 +
 drivers/media/v4l2-core/v4l2-common.c         | 104 ++++++++++++++++++
 drivers/media/v4l2-core/v4l2-ioctl.c          |   4 +
 include/media/v4l2-common.h                   |   4 +
 include/uapi/linux/videodev2.h                |   6 +
 6 files changed, 193 insertions(+)
 create mode 100644 Documentation/userspace-api/media/v4l/pixfmt-afbc.rst
Documentation/userspace-api/media/v4l/pixfmt-afbc.rst new file +74 -0
new file mode 100644
index 000000000000..7fad401b95ce
@@ -0,0 +1,74 @@
+.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
+
+.. afbc:
+
+*******************************************
+ARM Frame Buffer Compression formats (AFBC)
+*******************************************
+
+The AFBC format is a lossless compression format which can support
+up to four components. It could compress 8 bits to 64 bits per pixel.
+The internal superblock size could be:
+
+- 16x16 pixels
+
+- 32x8 pixels
+
+- 64x4 pixels.
+
+The memory layout is composed of a header block followed by payload data.
+
+AFBC Formats
+============
+
+.. tabularcolumns:: |p{5.2cm}|p{1.0cm}|p{1.5cm}|p{5.0cm}|p{1.2cm}|p{1.8cm}|p{10.0cm}|
+
+.. flat-table:: Overview of AFBC formats
+    :header-rows:  1
+    :stub-columns: 0
+
+    * - Identifier
+      - Code
+      - Colorspace
+      - Bits per component
+      - Superblock size
+      - Compression parameters
+      - DRM format (modifier)
+    * - V4L2_PIX_FMT_AFBC_YUV420_16x16_SPLIT
+      - 'A168'
+      - YUV420
+      - 8 bits
+      - 16x16
+      - Sparse, Split
+      - DRM_FORMAT_YUV420_8BIT (AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE | AFBC_FORMAT_MOD_SPLIT)
+    * - V4L2_PIX_FMT_AFBC_YUV420_32x8
+      - 'A328'
+      - YUV420
+      - 8 bits
+      - 32x8
+      - Sparse
+      - DRM_FORMAT_YUV420_8BIT (AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 | AFBC_FORMAT_MOD_SPARSE)
+    * - V4L2_PIX_FMT_AFBC_YUV420_16x16_10_SPLIT
+      - 'A16a'
+      - YUV420
+      - 10 bits
+      - 16x16
+      - Sparse, Split
+      - DRM_FORMAT_YUV420_10BIT (AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE | AFBC_FORMAT_MOD_SPLIT)
+    * - V4L2_PIX_FMT_AFBC_YUV420_32x8_10
+      - 'A32a'
+      - YUV420
+      - 10 bits
+      - 32x8
+      - Sparse
+      - DRM_FORMAT_YUV420_10BIT (AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 | AFBC_FORMAT_MOD_SPARSE)
+
+AFBC Stride computation
+=======================
+
+Stride is equal to the aligned width * 3 * bits per component / 2 / 8.
+
+.. _V4L2-PIX-FMT-AFBC-YUV420-16x16-SPLIT:
+.. _V4L2-PIX-FMT-AFBC-YUV420-32x8:
+.. _V4L2-PIX-FMT-AFBC-YUV420-16x16-10-SPLIT:
+.. _V4L2-PIX-FMT-AFBC-YUV420-32x8-10:
Documentation/userspace-api/media/v4l/pixfmt.rst +1 -0
index 71b29267488f..c6728b91b74f 100644
@@ -26,6 +26,7 @@ see also :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>`.)
     pixfmt-indexed
     pixfmt-rgb
     pixfmt-bayer
+    pixfmt-afbc
     yuv-formats
     hsv-formats
     depth-formats
drivers/media/v4l2-core/v4l2-common.c +104 -0

122 lines not on this page · raw message

drivers/media/v4l2-core/v4l2-ioctl.c +4 -0
index a2b650f4ec3c..e731c7e4fba9 100644
@@ -1387,6 +1387,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 	case V4L2_PIX_FMT_YVU422M:	descr = "Planar YVU 4:2:2 (N-C)"; break;
 	case V4L2_PIX_FMT_YUV444M:	descr = "Planar YUV 4:4:4 (N-C)"; break;
 	case V4L2_PIX_FMT_YVU444M:	descr = "Planar YVU 4:4:4 (N-C)"; break;
+	case V4L2_PIX_FMT_AFBC_YUV420_16x16_SPLIT: descr = "AFBC 8-bit YUV420 16x16 split"; break;
+	case V4L2_PIX_FMT_AFBC_YUV420_32x8: descr = "AFBC 8-bit YUV420 32x8"; break;
+	case V4L2_PIX_FMT_AFBC_YUV420_16x16_10_SPLIT: descr = "AFBC 10-bit YUV420 16x16 split"; break;
+	case V4L2_PIX_FMT_AFBC_YUV420_32x8_10: descr = "AFBC 10-bit YUV420 32x8"; break;
 	case V4L2_PIX_FMT_SBGGR8:	descr = "8-bit Bayer BGBG/GRGR"; break;
 	case V4L2_PIX_FMT_SGBRG8:	descr = "8-bit Bayer GBGB/RGRG"; break;
 	case V4L2_PIX_FMT_SGRBG8:	descr = "8-bit Bayer GRGR/BGBG"; break;
include/media/v4l2-common.h +4 -0
index f8b1faced79c..d1a75e6a7d4c 100644
@@ -549,6 +549,10 @@ static inline bool v4l2_is_format_bayer(const struct v4l2_format_info *f)
 	return f && f->pixel_enc == V4L2_PIXEL_ENC_BAYER;
 }
 
+bool v4l2_is_format_afbc(int fourcc);
+size_t v4l2_pixfmt_afbc_header_size(int fourcc, int width, int height);
+size_t v4l2_pixfmt_afbc_payload_size(int fourcc, int width, int height);
+
 const struct v4l2_format_info *v4l2_format_info(u32 format);
 void v4l2_apply_frmsize_constraints(u32 *width, u32 *height,
 				    const struct v4l2_frmsize_stepwise *frmsize);
include/uapi/linux/videodev2.h +6 -0
index eda4492e40dc..ffaaaa955156 100644
@@ -698,6 +698,12 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_NV12M_8L128      v4l2_fourcc('N', 'A', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */
 #define V4L2_PIX_FMT_NV12M_10BE_8L128 v4l2_fourcc_be('N', 'T', '1', '2') /* Y/CbCr 4:2:0 10-bit 8x128 tiles */
 
+/* AFBC formats */
+#define V4L2_PIX_FMT_AFBC_YUV420_16x16_SPLIT	v4l2_fourcc('A', '1', '6', '8') /* AFBC containing 8-bit YUV420 in 16x16 blocks, sparse, split */
+#define V4L2_PIX_FMT_AFBC_YUV420_32x8		v4l2_fourcc('A', '3', '2', '8') /* AFBC containing 8-bit YUV420 in 32x8 blocks, sparse */
+#define V4L2_PIX_FMT_AFBC_YUV420_16x16_10_SPLIT v4l2_fourcc('A', '1', '6', 'a') /* AFBC containing 10-bit YUV420 in 16x16 blocks, sparse, split */
+#define V4L2_PIX_FMT_AFBC_YUV420_32x8_10	v4l2_fourcc('A', '3', '2', 'a') /* AFBC containing 10-bit YUV420 in 32x8 blocks, sparse */
+
 /* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
 #define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B', 'A', '8', '1') /*  8  BGBG.. GRGR.. */
 #define V4L2_PIX_FMT_SGBRG8  v4l2_fourcc('G', 'B', 'R', 'G') /*  8  GBGB.. RGRG.. */
Signature · 1 line
2.43.0