modetest: add C8 support to generate SMPTE pattern
PATCH v2 1/1 modetest: add C8 support to generate SMPTE pattern
Tested on nouveau with the CRTC only (no planes).
Signed-off-by Ilia Mirkin <[email protected]>
---
v1 -> v2: always set a flat gamma ramp for non-indexed modes
tests/modetest/buffers.c | 2 ++ tests/modetest/modetest.c | 24 ++++++++++++++++ tests/util/format.c | 2 ++ tests/util/pattern.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ tests/util/pattern.h | 2 ++ 5 files changed, 103 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 +24 -0
@@ -1228,6 +1228,30 @@ 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 ) { +/* the pattern relies on colors being set properly */ +uint16_t r[256 ] = {0 }, g[256 ] = {0 }, b[256 ] = {0 }; + +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 ; + } + }else { +/* gamma may be left over from a previous modeset */ +uint16_t r[256 ], g[256 ], b[256 ]; + +for (j =0 ; j <256 ; j++) + r[j] = g[j] = b[j] = j <<8 ; +/* errors are probably ok */ +drmModeCrtcSetGamma ( + dev->fd, pipe->crtc->crtc->crtc_id, +256 , r, g, b); + } } }
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