Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright (c) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * DRM core format related functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Permission to use, copy, modify, distribute, and sell this software and its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * documentation for any purpose is hereby granted without fee, provided that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * the above copyright notice appear in all copies and that both that copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * notice and this permission notice appear in supporting documentation, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * that the name of the copyright holders not be used in advertising or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * publicity pertaining to distribution of the software without specific,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * written prior permission.  The copyright holders make no representations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * about the suitability of this software for any purpose.  It is provided "as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * is" without express or implied warranty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * OF THIS SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/bug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <drm/drm_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <drm/drm_fourcc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static char printable_char(int c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	return isascii(c) && isprint(c) ? c : '?';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * drm_mode_legacy_fb_format - compute drm fourcc code from legacy description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * @bpp: bits per pixels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * @depth: bit depth per pixel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * Computes a drm fourcc pixel format code for the given @bpp/@depth values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * Useful in fbdev emulation code, since that deals in those values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	uint32_t fmt = DRM_FORMAT_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	switch (bpp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	case 8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		if (depth == 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			fmt = DRM_FORMAT_C8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	case 16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		switch (depth) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		case 15:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			fmt = DRM_FORMAT_XRGB1555;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		case 16:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			fmt = DRM_FORMAT_RGB565;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	case 24:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		if (depth == 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 			fmt = DRM_FORMAT_RGB888;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	case 32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		switch (depth) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		case 24:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			fmt = DRM_FORMAT_XRGB8888;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		case 30:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			fmt = DRM_FORMAT_XRGB2101010;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		case 32:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			fmt = DRM_FORMAT_ARGB8888;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) EXPORT_SYMBOL(drm_mode_legacy_fb_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * drm_driver_legacy_fb_format - compute drm fourcc code from legacy description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  * @dev: DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  * @bpp: bits per pixels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  * @depth: bit depth per pixel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * Computes a drm fourcc pixel format code for the given @bpp/@depth values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * Unlike drm_mode_legacy_fb_format() this looks at the drivers mode_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * and depending on the &drm_mode_config.quirk_addfb_prefer_host_byte_order flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * it returns little endian byte order or host byte order framebuffer formats.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) uint32_t drm_driver_legacy_fb_format(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 				     uint32_t bpp, uint32_t depth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	uint32_t fmt = drm_mode_legacy_fb_format(bpp, depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	if (dev->mode_config.quirk_addfb_prefer_host_byte_order) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		if (fmt == DRM_FORMAT_XRGB8888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			fmt = DRM_FORMAT_HOST_XRGB8888;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		if (fmt == DRM_FORMAT_ARGB8888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			fmt = DRM_FORMAT_HOST_ARGB8888;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		if (fmt == DRM_FORMAT_RGB565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			fmt = DRM_FORMAT_HOST_RGB565;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		if (fmt == DRM_FORMAT_XRGB1555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			fmt = DRM_FORMAT_HOST_XRGB1555;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	if (dev->mode_config.quirk_addfb_prefer_xbgr_30bpp &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	    fmt == DRM_FORMAT_XRGB2101010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		fmt = DRM_FORMAT_XBGR2101010;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	return fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) EXPORT_SYMBOL(drm_driver_legacy_fb_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * drm_get_format_name - fill a string with a drm fourcc format's name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  * @format: format to compute name of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  * @buf: caller-supplied buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	snprintf(buf->str, sizeof(buf->str),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		 "%c%c%c%c %s-endian (0x%08x)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		 printable_char(format & 0xff),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		 printable_char((format >> 8) & 0xff),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		 printable_char((format >> 16) & 0xff),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		 printable_char((format >> 24) & 0x7f),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		 format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		 format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return buf->str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) EXPORT_SYMBOL(drm_get_format_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  * Internal function to query information for a given format. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)  * drm_format_info() for the public API.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) const struct drm_format_info *__drm_format_info(u32 format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	static const struct drm_format_info formats[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		{ .format = DRM_FORMAT_C8,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		{ .format = DRM_FORMAT_RGB332,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		{ .format = DRM_FORMAT_BGR233,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		{ .format = DRM_FORMAT_XRGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		{ .format = DRM_FORMAT_XBGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		{ .format = DRM_FORMAT_RGBX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		{ .format = DRM_FORMAT_BGRX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		{ .format = DRM_FORMAT_ARGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		{ .format = DRM_FORMAT_ABGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		{ .format = DRM_FORMAT_RGBA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		{ .format = DRM_FORMAT_BGRA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		{ .format = DRM_FORMAT_XRGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		{ .format = DRM_FORMAT_XBGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		{ .format = DRM_FORMAT_RGBX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		{ .format = DRM_FORMAT_BGRX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		{ .format = DRM_FORMAT_ARGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		{ .format = DRM_FORMAT_ABGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		{ .format = DRM_FORMAT_RGBA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		{ .format = DRM_FORMAT_BGRA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		{ .format = DRM_FORMAT_RGB565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		{ .format = DRM_FORMAT_BGR565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		{ .format = DRM_FORMAT_RGB888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		{ .format = DRM_FORMAT_BGR888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		{ .format = DRM_FORMAT_XRGB8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		{ .format = DRM_FORMAT_XBGR8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		{ .format = DRM_FORMAT_RGBX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		{ .format = DRM_FORMAT_BGRX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		{ .format = DRM_FORMAT_RGB565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		{ .format = DRM_FORMAT_BGR565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		{ .format = DRM_FORMAT_XRGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		{ .format = DRM_FORMAT_XBGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		{ .format = DRM_FORMAT_RGBX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		{ .format = DRM_FORMAT_BGRX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		{ .format = DRM_FORMAT_ARGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		{ .format = DRM_FORMAT_ABGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		{ .format = DRM_FORMAT_RGBA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		{ .format = DRM_FORMAT_BGRA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		{ .format = DRM_FORMAT_ARGB8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		{ .format = DRM_FORMAT_ABGR8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		{ .format = DRM_FORMAT_RGBA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		{ .format = DRM_FORMAT_BGRA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		{ .format = DRM_FORMAT_XRGB16161616F,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		{ .format = DRM_FORMAT_XBGR16161616F,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		{ .format = DRM_FORMAT_ARGB16161616F,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		{ .format = DRM_FORMAT_ABGR16161616F,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		{ .format = DRM_FORMAT_RGB888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		{ .format = DRM_FORMAT_BGR888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		{ .format = DRM_FORMAT_XRGB8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		{ .format = DRM_FORMAT_XBGR8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		{ .format = DRM_FORMAT_RGBX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		{ .format = DRM_FORMAT_BGRX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		{ .format = DRM_FORMAT_YUV410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		{ .format = DRM_FORMAT_YVU410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		{ .format = DRM_FORMAT_YUV411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		{ .format = DRM_FORMAT_YVU411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		{ .format = DRM_FORMAT_YUV420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		{ .format = DRM_FORMAT_YVU420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		{ .format = DRM_FORMAT_YUV422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		{ .format = DRM_FORMAT_YVU422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		{ .format = DRM_FORMAT_YUV444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		{ .format = DRM_FORMAT_YVU444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		{ .format = DRM_FORMAT_NV12,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		{ .format = DRM_FORMAT_NV21,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		{ .format = DRM_FORMAT_NV16,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		{ .format = DRM_FORMAT_NV61,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		{ .format = DRM_FORMAT_NV24,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		{ .format = DRM_FORMAT_NV42,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		{ .format = DRM_FORMAT_YUYV,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		{ .format = DRM_FORMAT_YVYU,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		{ .format = DRM_FORMAT_UYVY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		{ .format = DRM_FORMAT_VYUY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		{ .format = DRM_FORMAT_XYUV8888,	.depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		{ .format = DRM_FORMAT_VUY888,          .depth = 0,  .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		{ .format = DRM_FORMAT_AYUV,		.depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		{ .format = DRM_FORMAT_Y210,            .depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		{ .format = DRM_FORMAT_Y212,            .depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		{ .format = DRM_FORMAT_Y216,            .depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 2, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		{ .format = DRM_FORMAT_Y410,            .depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		{ .format = DRM_FORMAT_Y412,            .depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		{ .format = DRM_FORMAT_Y416,            .depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		{ .format = DRM_FORMAT_XVYU2101010,	.depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		{ .format = DRM_FORMAT_XVYU12_16161616,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		{ .format = DRM_FORMAT_XVYU16161616,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		{ .format = DRM_FORMAT_Y0L0,		.depth = 0,  .num_planes = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		  .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, .block_h = { 2, 0, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		  .hsub = 2, .vsub = 2, .has_alpha = true, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		{ .format = DRM_FORMAT_X0L0,		.depth = 0,  .num_planes = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		  .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, .block_h = { 2, 0, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		  .hsub = 2, .vsub = 2, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		{ .format = DRM_FORMAT_Y0L2,		.depth = 0,  .num_planes = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		  .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, .block_h = { 2, 0, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		  .hsub = 2, .vsub = 2, .has_alpha = true, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		{ .format = DRM_FORMAT_X0L2,		.depth = 0,  .num_planes = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		  .char_per_block = { 8, 0, 0 }, .block_w = { 2, 0, 0 }, .block_h = { 2, 0, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		  .hsub = 2, .vsub = 2, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		{ .format = DRM_FORMAT_P010,            .depth = 0,  .num_planes = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		  .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		  .hsub = 2, .vsub = 2, .is_yuv = true},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		{ .format = DRM_FORMAT_P012,		.depth = 0,  .num_planes = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		  .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		   .hsub = 2, .vsub = 2, .is_yuv = true},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		{ .format = DRM_FORMAT_P016,		.depth = 0,  .num_planes = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		  .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		  .hsub = 2, .vsub = 2, .is_yuv = true},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		{ .format = DRM_FORMAT_P210,		.depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		  .num_planes = 2, .char_per_block = { 2, 4, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		  .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		  .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		{ .format = DRM_FORMAT_VUY101010,	.depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		  .num_planes = 1, .cpp = { 0, 0, 0 }, .hsub = 1, .vsub = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		  .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		{ .format = DRM_FORMAT_YUV420_8BIT,     .depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		  .num_planes = 1, .cpp = { 0, 0, 0 }, .hsub = 2, .vsub = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		  .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		{ .format = DRM_FORMAT_YUV420_10BIT,    .depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		  .num_planes = 1, .cpp = { 0, 0, 0 }, .hsub = 2, .vsub = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		  .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		{ .format = DRM_FORMAT_NV15,		.depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		  .num_planes = 2, .char_per_block = { 5, 5, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		  .block_w = { 4, 2, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		  .vsub = 2, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) #ifdef CONFIG_NO_GKI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		{ .format = DRM_FORMAT_NV20,		.depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		  .num_planes = 2, .char_per_block = { 5, 5, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		  .block_w = { 4, 2, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		  .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		{ .format = DRM_FORMAT_NV30,		.depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		  .num_planes = 2, .char_per_block = { 5, 5, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		  .block_w = { 4, 2, 0 }, .block_h = { 1, 1, 0 }, .hsub = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		  .vsub = 1, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		{ .format = DRM_FORMAT_Q410,		.depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		  .num_planes = 3, .char_per_block = { 2, 2, 2 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		  .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		  .vsub = 0, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		{ .format = DRM_FORMAT_Q401,		.depth = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		  .num_planes = 3, .char_per_block = { 2, 2, 2 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		  .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 }, .hsub = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		  .vsub = 0, .is_yuv = true },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	for (i = 0; i < ARRAY_SIZE(formats); ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		if (formats[i].format == format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			return &formats[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  * drm_format_info - query information for a given format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)  * @format: pixel format (DRM_FORMAT_*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)  * The caller should only pass a supported pixel format to this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  * Unsupported pixel formats will generate a warning in the kernel log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)  * The instance of struct drm_format_info that describes the pixel format, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)  * NULL if the format is unsupported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) const struct drm_format_info *drm_format_info(u32 format)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	const struct drm_format_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	info = __drm_format_info(format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	WARN_ON(!info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	return info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) EXPORT_SYMBOL(drm_format_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  * drm_get_format_info - query information for a given framebuffer configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  * @dev: DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)  * @mode_cmd: metadata from the userspace fb creation request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)  * The instance of struct drm_format_info that describes the pixel format, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)  * NULL if the format is unsupported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) const struct drm_format_info *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) drm_get_format_info(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		    const struct drm_mode_fb_cmd2 *mode_cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	const struct drm_format_info *info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	if (dev->mode_config.funcs->get_format_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		info = dev->mode_config.funcs->get_format_info(mode_cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	if (!info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		info = drm_format_info(mode_cmd->pixel_format);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	return info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) EXPORT_SYMBOL(drm_get_format_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)  * drm_format_info_block_width - width in pixels of block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  * @info: pixel format info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  * @plane: plane index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  * The width in pixels of a block, depending on the plane index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) unsigned int drm_format_info_block_width(const struct drm_format_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 					 int plane)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	if (!info || plane < 0 || plane >= info->num_planes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	if (!info->block_w[plane])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	return info->block_w[plane];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) EXPORT_SYMBOL(drm_format_info_block_width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  * drm_format_info_block_height - height in pixels of a block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)  * @info: pixel format info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  * @plane: plane index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)  * The height in pixels of a block, depending on the plane index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) unsigned int drm_format_info_block_height(const struct drm_format_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 					  int plane)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	if (!info || plane < 0 || plane >= info->num_planes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	if (!info->block_h[plane])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	return info->block_h[plane];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) EXPORT_SYMBOL(drm_format_info_block_height);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)  * drm_format_info_min_pitch - computes the minimum required pitch in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)  * @info: pixel format info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)  * @plane: plane index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)  * @buffer_width: buffer width in pixels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  * The minimum required pitch in bytes for a buffer by taking into consideration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  * the pixel format information and the buffer width.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) uint64_t drm_format_info_min_pitch(const struct drm_format_info *info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 				   int plane, unsigned int buffer_width)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	if (!info || plane < 0 || plane >= info->num_planes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	return DIV_ROUND_UP_ULL((u64)buffer_width * info->char_per_block[plane],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 			    drm_format_info_block_width(info, plane) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			    drm_format_info_block_height(info, plane));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) EXPORT_SYMBOL(drm_format_info_min_pitch);