diff options
Diffstat (limited to 'src/drmmode_pl111/drmmode_pl111.c')
-rw-r--r-- | src/drmmode_pl111/drmmode_pl111.c | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/src/drmmode_pl111/drmmode_pl111.c b/src/drmmode_pl111/drmmode_pl111.c index 424eb16..d8a16a5 100644 --- a/src/drmmode_pl111/drmmode_pl111.c +++ b/src/drmmode_pl111/drmmode_pl111.c @@ -33,9 +33,11 @@ */ #define CURSORW (64) #define CURSORH (64) -#define CURSORPAD (0) /* Padding added down each side of cursor image */ +/* Padding added down each side of cursor image */ +#define CURSORPAD (0) -/*#define ARGB_LBBP_CONVERSION_DEBUG un-comment to enable cursor format conversion debugging.*/ +/* un-comment to enable cursor format conversion debugging.*/ +/* #define ARGB_LBBP_CONVERSION_DEBUG */ #define LBBP_BACKGROUND (0x0) #define LBBP_FOREGROUND (0x1) @@ -48,21 +50,23 @@ #define LBBP_WORDS_PER_LINE (4) #define LBBP_PIXELS_PER_WORD (16) -/* shift required to locate pixel into the correct position in a cursor LBBP word, - * indexed by x mod 16.*/ +/* shift required to locate pixel into the correct position in + * a cursor LBBP word, indexed by x mod 16. + */ const unsigned char x_mod_16_to_value_shift[LBBP_PIXELS_PER_WORD] = { - 6,4,2,0,14,12,10,8,22,20,18,16,30,28,26,24 + 6, 4, 2, 0, 14, 12, 10, 8, 22, 20, 18, 16, 30, 28, 26, 24 }; /* Pack the pixel value into its correct position in the buffer as specified * for LBBP */ static inline void -set_lbbp_pixel(uint32_t * buffer, unsigned int x, unsigned int y, uint32_t value ) +set_lbbp_pixel(uint32_t *buffer, unsigned int x, unsigned int y, + uint32_t value) { - uint32_t * p; + uint32_t *p; uint32_t shift; - assert( (x < CURSORW) && (y < CURSORH) ); + assert((x < CURSORW) && (y < CURSORH)); shift = x_mod_16_to_value_shift[x % LBBP_PIXELS_PER_WORD]; @@ -75,14 +79,16 @@ set_lbbp_pixel(uint32_t * buffer, unsigned int x, unsigned int y, uint32_t value } /* - * The PL111 hardware cursor supports only LBBP which is a 2bpp format but there are - * no drm fourcc formats that are compatible with this so instead the PL111 DRM - * reports (to DRM core) that it supports only DRM_FORMAT_ARGB8888 and expects the - * DDX to supply an LBPP image in the first 1/16th of the buffer, the rest being unused. - * Ideally we would want to receive the image in this format from X, but currently the - * X cursor image is 32bpp ARGB so we need to convert to LBBP here. + * The PL111 hardware cursor supports only LBBP which is a 2bpp format but + * there are no drm fourcc formats that are compatible with this so instead + * the PL111 DRM reports (to DRM core) that it supports only + * DRM_FORMAT_ARGB8888 and expects the DDX to supply an LBPP image in the + * first 1/16th of the buffer, the rest being unused. + * Ideally we would want to receive the image in this format from X, but + * currently the X cursor image is 32bpp ARGB so we need to convert + * to LBBP here. */ -static void set_cursor_image( xf86CrtcPtr crtc, uint32_t * d, CARD32 *s ) +static void set_cursor_image(xf86CrtcPtr crtc, uint32_t *d, CARD32 *s) { #ifdef ARGB_LBBP_CONVERSION_DEBUG /* Add 1 on width to insert trailing NULL */ @@ -91,34 +97,37 @@ static void set_cursor_image( xf86CrtcPtr crtc, uint32_t * d, CARD32 *s ) unsigned int x; unsigned int y; - for ( y = 0; y < CURSORH ; y++) { - for ( x = 0; x < CURSORW ; x++) { + for (y = 0; y < CURSORH ; y++) { + for (x = 0; x < CURSORW ; x++) { uint32_t value = LBBP_TRANSPARENT; /* If pixel visible foreground/background */ - if ( ( *s & ARGB_ALPHA ) != 0 ) { - /* Any color set then just convert to foreground for now */ - if ( ( *s & ARGB_RGB ) != 0 ) + if ((*s & ARGB_ALPHA) != 0) { + /* Any color set then just convert to + * foreground for now + */ + if ((*s & ARGB_RGB) != 0) value = LBBP_FOREGROUND; else value = LBBP_BACKGROUND; } #ifdef ARGB_LBBP_CONVERSION_DEBUG - if ( value == LBBP_TRANSPARENT ) { + if (value == LBBP_TRANSPARENT) string_cursor[x] = 'T'; - } else if ( value == LBBP_FOREGROUND ) { + else if (value == LBBP_FOREGROUND) string_cursor[x] = 'F'; - } else if ( value == LBBP_INVERSE ) { + else if (value == LBBP_INVERSE) string_cursor[x] = 'I'; - } else { + else string_cursor[x] = 'B'; - } + #endif /* ARGB_LBBP_CONVERSION_DEBUG */ - set_lbbp_pixel( d, x, y, value ); + set_lbbp_pixel(d, x, y, value); ++s; } #ifdef ARGB_LBBP_CONVERSION_DEBUG string_cursor[CURSORW] = '\0'; - xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO, "%s\n", string_cursor ); + xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO, "%s\n", + string_cursor); #endif /* ARGB_LBBP_CONVERSION_DEBUG */ } } |