drivers/video/fbdev/core/fb_draw.h

Source file repositories/reference/linux-study-clean/drivers/video/fbdev/core/fb_draw.h

File Facts

System
Linux kernel
Corpus path
drivers/video/fbdev/core/fb_draw.h
Extension
.h
Size
4744 bytes
Lines
164
Domain
Driver Families
Bucket
drivers/video
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct fb_reverse {
	bool byte, pixel;
};

/* reverse bits of each byte in a long */
static inline unsigned long fb_reverse_bits_long(unsigned long val)
{
#if defined(CONFIG_HAVE_ARCH_BITREVERSE) && BITS_PER_LONG == 32
	return bitrev8x4(val);
#else
	val = fb_comp(val >> 1, val << 1, ~0UL / 3);
	val = fb_comp(val >> 2, val << 2, ~0UL / 5);
	return fb_comp(val >> 4, val << 4, ~0UL / 17);
#endif
}

/* apply byte and bit reversals as necessary */
static inline unsigned long fb_reverse_long(unsigned long val,
					    struct fb_reverse reverse)
{
	if (reverse.pixel)
		val = fb_reverse_bits_long(val);
	return reverse.byte ? swab_long(val) : val;
}

/* calculate a pixel mask for the given reversal */
static inline unsigned long fb_pixel_mask(int index, struct fb_reverse reverse)
{
#ifdef FB_REV_PIXELS_IN_BYTE
	if (reverse.byte)
		return reverse.pixel ? fb_left(~0UL, index) : swab_long(fb_right(~0UL, index));
	else
		return reverse.pixel ? swab_long(fb_left(~0UL, index)) : fb_right(~0UL, index);
#else
	return reverse.byte ? swab_long(fb_right(~0UL, index)) : fb_right(~0UL, index);
#endif
}


/*
 * initialise reversals based on info
 *
 * Normally the first byte is the low byte on little endian and in the high
 * on big endian. If it's the other way around then that's reverse byte order.
 *
 * Normally the first pixel is the LSB on little endian and the MSB on big
 * endian. If that's not the case that's reverse pixel order.
 */
static inline struct fb_reverse fb_reverse_init(struct fb_info *info)
{
	struct fb_reverse reverse;
#ifdef __LITTLE_ENDIAN
	reverse.byte = fb_be_math(info) != 0;
#else
	reverse.byte = fb_be_math(info) == 0;
#endif
#ifdef FB_REV_PIXELS_IN_BYTE
	reverse.pixel = info->var.bits_per_pixel < BITS_PER_BYTE
		&& (info->var.nonstd & FB_NONSTD_REV_PIX_IN_B);
#else
	reverse.pixel = false;
#endif
	return reverse;
}

#endif /* FB_DRAW_H */

Annotation

Implementation Notes