Message ID | c9b62e081b77b625654e7d4477bfd63fe3833c35.1646683737.git.geert@linux-m68k.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Add support for low-color frame buffer formats | expand |
On Mon, 7 Mar 2022 21:53:17 +0100 Geert Uytterhoeven <geert@linux-m68k.org> wrote: > Add fourcc codes for color-indexed frame buffer formats with two, four, > and sixteen colors. Add support for creating buffers using these > formats. > > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> > --- > include/drm/drm_fourcc.h | 5 ++++- > tests/modetest/buffers.c | 15 +++++++++++++++ > tests/util/format.c | 3 +++ > 3 files changed, 22 insertions(+), 1 deletion(-) > > diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h > index 957c7be29239c0a1..f8b18d28a71dabff 100644 > --- a/include/drm/drm_fourcc.h > +++ b/include/drm/drm_fourcc.h > @@ -99,7 +99,10 @@ extern "C" { > #define DRM_FORMAT_INVALID 0 > > /* color index */ > -#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ > +#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */ > +#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */ > +#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 two pixels/byte */ > +#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C 8 one pixel/byte */ Hi Geert, I believe updates to drm_fourcc.h in libdrm must be done with the specific process, please see https://gitlab.freedesktop.org/mesa/drm/-/blob/main/include/drm/README section "When and how to update these files". Thanks, pq > > /* 8 bpp Red */ > #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ > diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c > index 8a8d9e0143474378..af7f60b4fb4d09ad 100644 > --- a/tests/modetest/buffers.c > +++ b/tests/modetest/buffers.c > @@ -135,6 +135,18 @@ bo_create(int fd, unsigned int format, > int ret; > > switch (format) { > + case DRM_FORMAT_C1: > + bpp = 1; > + break; > + > + case DRM_FORMAT_C2: > + bpp = 2; > + break; > + > + case DRM_FORMAT_C4: > + bpp = 4; > + break; > + > case DRM_FORMAT_C8: > case DRM_FORMAT_NV12: > case DRM_FORMAT_NV21: > @@ -283,6 +295,9 @@ bo_create(int fd, unsigned int format, > planes[2] = virtual + offsets[2]; > break; > > + case DRM_FORMAT_C1: > + case DRM_FORMAT_C2: > + case DRM_FORMAT_C4: > case DRM_FORMAT_C8: > case DRM_FORMAT_ARGB4444: > case DRM_FORMAT_XRGB4444: > diff --git a/tests/util/format.c b/tests/util/format.c > index 1ca1b82ce947b2f4..4b984af9bce8ac6f 100644 > --- a/tests/util/format.c > +++ b/tests/util/format.c > @@ -40,6 +40,9 @@ > > static const struct util_format_info format_info[] = { > /* Indexed */ > + { DRM_FORMAT_C1, "C1" }, > + { DRM_FORMAT_C2, "C2" }, > + { DRM_FORMAT_C4, "C4" }, > { DRM_FORMAT_C8, "C8" }, > /* YUV packed */ > { DRM_FORMAT_UYVY, "UYVY", MAKE_YUV_INFO(YUV_YCbCr | YUV_CY, 2, 2, 2) },
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h index 957c7be29239c0a1..f8b18d28a71dabff 100644 --- a/include/drm/drm_fourcc.h +++ b/include/drm/drm_fourcc.h @@ -99,7 +99,10 @@ extern "C" { #define DRM_FORMAT_INVALID 0 /* color index */ -#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ +#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */ +#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */ +#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 two pixels/byte */ +#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C 8 one pixel/byte */ /* 8 bpp Red */ #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c index 8a8d9e0143474378..af7f60b4fb4d09ad 100644 --- a/tests/modetest/buffers.c +++ b/tests/modetest/buffers.c @@ -135,6 +135,18 @@ bo_create(int fd, unsigned int format, int ret; switch (format) { + case DRM_FORMAT_C1: + bpp = 1; + break; + + case DRM_FORMAT_C2: + bpp = 2; + break; + + case DRM_FORMAT_C4: + bpp = 4; + break; + case DRM_FORMAT_C8: case DRM_FORMAT_NV12: case DRM_FORMAT_NV21: @@ -283,6 +295,9 @@ bo_create(int fd, unsigned int format, planes[2] = virtual + offsets[2]; break; + case DRM_FORMAT_C1: + case DRM_FORMAT_C2: + case DRM_FORMAT_C4: case DRM_FORMAT_C8: case DRM_FORMAT_ARGB4444: case DRM_FORMAT_XRGB4444: diff --git a/tests/util/format.c b/tests/util/format.c index 1ca1b82ce947b2f4..4b984af9bce8ac6f 100644 --- a/tests/util/format.c +++ b/tests/util/format.c @@ -40,6 +40,9 @@ static const struct util_format_info format_info[] = { /* Indexed */ + { DRM_FORMAT_C1, "C1" }, + { DRM_FORMAT_C2, "C2" }, + { DRM_FORMAT_C4, "C4" }, { DRM_FORMAT_C8, "C8" }, /* YUV packed */ { DRM_FORMAT_UYVY, "UYVY", MAKE_YUV_INFO(YUV_YCbCr | YUV_CY, 2, 2, 2) },
Add fourcc codes for color-indexed frame buffer formats with two, four, and sixteen colors. Add support for creating buffers using these formats. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> --- include/drm/drm_fourcc.h | 5 ++++- tests/modetest/buffers.c | 15 +++++++++++++++ tests/util/format.c | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-)