modetest: add C8 support to generate SMPTE pattern
PATCH 1/1 modetest: add C8 support to generate SMPTE pattern
Tested on nouveau with the CRTC only.
---
Please note that I have no clue what the proper way to operate the gamma interface is. This seemed OK, but the 256 seems awefully hardcoded. Perhaps that won't work on other HW?
tests/modetest/buffers.c | 2 ++ tests/modetest/modetest.c | 13 +++++++++ tests/util/format.c | 2 ++ tests/util/pattern.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ tests/util/pattern.h | 2 ++ 5 files changed, 92 insertions(+)
tests/modetest/buffers.c +2 -0
@@ -139,6 +139,7 @@ bo_create(int fd, unsigned int format,int ret;switch (format) { +case DRM_FORMAT_C8 :case DRM_FORMAT_NV12 :case DRM_FORMAT_NV21 :case DRM_FORMAT_NV16 :
@@ -279,6 +280,7 @@ bo_create(int fd, unsigned int format, planes[2 ] = virtual + offsets[2 ];break ; +case DRM_FORMAT_C8 :case DRM_FORMAT_ARGB4444 :case DRM_FORMAT_XRGB4444 :case DRM_FORMAT_ABGR4444 :
tests/modetest/modetest.c +13 -0
@@ -1228,6 +1228,19 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int cofprintf (stderr,"failed to set mode: %s\n" ,strerror (errno));return ; } + +if (pipes[0 ].fourcc ==DRM_FORMAT_C8 ) { +uint16_t r[256 ], g[256 ], b[256 ]; + +util_smpte_c8_gamma (256 , r, g, b); + ret =drmModeCrtcSetGamma ( + dev->fd, pipe->crtc->crtc->crtc_id, +256 , r, g, b); +if (ret) { +fprintf (stderr,"failed to set gamma: %s\n" ,strerror (errno)); +return ; + } + } } }
tests/util/format.c +2 -0
@@ -43,6 +43,8 @@ .yuv = { (order), (xsub), (ysub), (chroma_stride) }static const struct util_format_info format_info[] = { +/* Indexed */ + {DRM_FORMAT_C8 ,"C8" },/* YUV packed */ {DRM_FORMAT_UYVY ,"UYVY" ,MAKE_YUV_INFO (YUV_YCbCr |YUV_CY ,2 ,2 ,2 ) }, {DRM_FORMAT_VYUY ,"VYUY" ,MAKE_YUV_INFO (YUV_YCrCb |YUV_CY ,2 ,2 ,2 ) },
tests/util/pattern.c +73 -0
85 lines not on this page · raw message
tests/util/pattern.h +2 -0
@@ -36,4 +36,6 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, void *planes[3], unsigned int width, unsigned int height, unsigned int stride); +void util_smpte_c8_gamma (unsigned size,uint16_t *r,uint16_t *g,uint16_t *b); +#endif /* UTIL_PATTERN_H */
Signature · 6 lines
2.13.6 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 46 lines · Ilia Mirkin
Tested on nouveau with the CRTC only.
Signed-off-by Ilia Mirkin <[email protected]>---
Please note that I have no clue what the proper way to operate the gamma interface is. This seemed OK, but the 256 seems awefully hardcoded. Perhaps that won't work on other HW?
tests/modetest/buffers.c | 2 ++ tests/modetest/modetest.c | 13 +++++++++ tests/util/format.c | 2 ++ tests/util/pattern.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ tests/util/pattern.h | 2 ++ 5 files changed, 92 insertions(+)tests/modetest/buffers.c +2
-0@@ -139,6 +139,7 @@ bo_create(int fd, unsigned int format,int ret;switch (format) { +case DRM_FORMAT_C8 :case DRM_FORMAT_NV12 :case DRM_FORMAT_NV21 :case DRM_FORMAT_NV16 :@@ -279,6 +280,7 @@ bo_create(int fd, unsigned int format, planes[2 ] = virtual + offsets[2 ];break ; +case DRM_FORMAT_C8 :case DRM_FORMAT_ARGB4444 :case DRM_FORMAT_XRGB4444 :case DRM_FORMAT_ABGR4444 :tests/modetest/modetest.c +2
-0@@ -1228,6 +1228,19 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int cofprintf (stderr,"failed to set mode: %s\n" ,strerror (errno));return ; } + +if (pipes[0 ].fourcc ==DRM_FORMAT_C8 ) {
tests/modetest/modetest.c static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co · line 1242
Quoted 10 lines
tests/modetest/modetest.c +10
-0+uint16_t r[256 ], g[256 ], b[256 ]; + +util_smpte_c8_gamma (256 , r, g, b); + ret =drmModeCrtcSetGamma ( + dev->fd, pipe->crtc->crtc->crtc_id, +256 , r, g, b); +if (ret) { +fprintf (stderr,"failed to set gamma: %s\n" ,strerror (errno)); +return ; + }
Of course once you start messing around with gamma, something has to undo that. I've added
} else {uint16_t r[256], g[256], b[256];
for (j = 0; j < 256; j++)
r[j] = g[j] = b[j] = j << 8;
drmModeCrtcSetGamma(dev->fd, pipe->crtc->crtc->crtc_id,
256, r, g, b);
But that seems like a hack here. Where should it go? clear_mode?
Quoted 120 lines
tests/modetest/modetest.c +1
-0+ } } }tests/util/format.c +2
-0@@ -43,6 +43,8 @@ .yuv = { (order), (xsub), (ysub), (chroma_stride) }static const struct util_format_info format_info[] = { +/* Indexed */ + {DRM_FORMAT_C8 ,"C8" },/* YUV packed */ {DRM_FORMAT_UYVY ,"UYVY" ,MAKE_YUV_INFO (YUV_YCbCr |YUV_CY ,2 ,2 ,2 ) }, {DRM_FORMAT_VYUY ,"VYUY" ,MAKE_YUV_INFO (YUV_YCrCb |YUV_CY ,2 ,2 ,2 ) },tests/util/pattern.c +73
-0@@ -461,6 +461,77 @@ static void fill_smpte_rgb32(const struct util_rgb_info *rgb, void *mem, } } +static void fill_smpte_c8 (void *mem,unsigned int width,unsigned int height, +unsigned int stride) +{ +unsigned int x; +unsigned int y; + +for (y =0 ; y < height *6 /9 ; ++y) { +for (x =0 ; x < width; ++x) + ((uint8_t *)mem)[x] = x *7 / width; + mem += stride; + } + +for (; y < height *7 /9 ; ++y) { +for (x =0 ; x < width; ++x) + ((uint8_t *)mem)[x] =7 + (x *7 / width); + mem += stride; + } + +for (; y < height; ++y) { +for (x =0 ; x < width *5 /7 ; ++x) + ((uint8_t *)mem)[x] = +14 + (x *4 / (width *5 /7 )); +for (; x < width *6 /7 ; ++x) + ((uint8_t *)mem)[x] = +14 + ((x - width *5 /7 ) *3 + / (width /7 ) +4 ); +for (; x < width; ++x) + ((uint8_t *)mem)[x] =14 +7 ; + mem += stride; + } +} + +void util_smpte_c8_gamma (unsigned size,uint16_t *r,uint16_t *g,uint16_t *b) +{ +if (size <7 +7 +8 ) { +printf ("Error: gamma too small: %d < %d\n" , size,7 +7 +8 ); +return ; + } +#define FILL_COLOR (idx, red, green, blue) \ + r[idx] = red << 8; \ + g[idx] = green << 8; \ + b[idx] = blue << 8 + +FILL_COLOR (0 ,192 ,192 ,192 );/* grey */ +FILL_COLOR (1 ,192 ,192 ,0 );/* yellow */ +FILL_COLOR (2 ,0 ,192 ,192 );/* cyan */ +FILL_COLOR (3 ,0 ,192 ,0 );/* green */ +FILL_COLOR (4 ,192 ,0 ,192 );/* magenta */ +FILL_COLOR (5 ,192 ,0 ,0 );/* red */ +FILL_COLOR (6 ,0 ,0 ,192 );/* blue */ + +FILL_COLOR (7 ,0 ,0 ,192 );/* blue */ +FILL_COLOR (8 ,19 ,19 ,19 );/* black */ +FILL_COLOR (9 ,192 ,0 ,192 );/* magenta */ +FILL_COLOR (10 ,19 ,19 ,19 );/* black */ +FILL_COLOR (11 ,0 ,192 ,192 );/* cyan */ +FILL_COLOR (12 ,19 ,19 ,19 );/* black */ +FILL_COLOR (13 ,192 ,192 ,192 );/* grey */ + +FILL_COLOR (14 ,0 ,33 ,76 );/* in-phase */ +FILL_COLOR (15 ,255 ,255 ,255 );/* super white */ +FILL_COLOR (16 ,50 ,0 ,106 );/* quadrature */ +FILL_COLOR (17 ,19 ,19 ,19 );/* black */ +FILL_COLOR (18 ,9 ,9 ,9 );/* 3.5% */ +FILL_COLOR (19 ,19 ,19 ,19 );/* 7.5% */ +FILL_COLOR (20 ,29 ,29 ,29 );/* 11.5% */ +FILL_COLOR (21 ,19 ,19 ,19 );/* black */ + +#undef FILL_COLOR +} +static void fill_smpte (const struct util_format_info *info,void *planes[3 ],unsigned int width,unsigned int height,unsigned int stride)@@ -468,6 +539,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],unsigned char *u, *v;switch (info->format) { +case DRM_FORMAT_C8 : +return fill_smpte_c8 (planes[0 ], width, height, stride);case DRM_FORMAT_UYVY :case DRM_FORMAT_VYUY :case DRM_FORMAT_YUYV :tests/util/pattern.h +2
-1@@ -36,4 +36,6 @@ void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern, void *planes[3], unsigned int width, unsigned int height, unsigned int stride); +void util_smpte_c8_gamma (unsigned size,uint16_t *r,uint16_t *g,uint16_t *b); +#endif /* UTIL_PATTERN_H */ --
Quoted 2 lines
2.13.6
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel