drivers/video/fbdev/core/fb_fillrect.h

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

File Facts

System
Linux kernel
Corpus path
drivers/video/fbdev/core/fb_fillrect.h
Extension
.h
Size
7962 bytes
Lines
280
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_pattern {
	unsigned long pixels;
	int left, right;
	struct fb_reverse reverse;
};

/* used to get the pattern in native order */
static unsigned long fb_pattern_get(struct fb_pattern *pattern)
{
	return pattern->pixels;
}

/* used to get the pattern in reverse order */
static unsigned long fb_pattern_get_reverse(struct fb_pattern *pattern)
{
	return swab_long(pattern->pixels);
}

/* next static pattern */
static void fb_pattern_static(struct fb_pattern *pattern)
{
	/* nothing to do */
}

/* next rotating pattern */
static void fb_pattern_rotate(struct fb_pattern *pattern)
{
	pattern->pixels = fb_left(pattern->pixels, pattern->left)
		| fb_right(pattern->pixels, pattern->right);
}

#define FB_PAT(i) (((1UL<<(BITS_PER_LONG-1)/(i)*(i))/((1<<(i))-1)<<(i))|1)

/* create the filling pattern from a given color */
static unsigned long pixel_to_pat(int bpp, u32 color)
{
	static const unsigned long mulconst[BITS_PER_LONG/4] = {
		0, ~0UL, FB_PAT(2), FB_PAT(3),
		FB_PAT(4), FB_PAT(5), FB_PAT(6), FB_PAT(7),
#if BITS_PER_LONG == 64
		FB_PAT(8), FB_PAT(9), FB_PAT(10), FB_PAT(11),
		FB_PAT(12), FB_PAT(13), FB_PAT(14), FB_PAT(15),
#endif
	};
	unsigned long pattern;

	switch (bpp) {
	case 0 ... BITS_PER_LONG/4-1:
		pattern = mulconst[bpp] * color;
		break;
	case BITS_PER_LONG/4 ... BITS_PER_LONG/2-1:
		pattern = color;
		pattern = pattern | pattern << bpp;
		pattern = pattern | pattern << bpp*2;
		break;
	case BITS_PER_LONG/2 ... BITS_PER_LONG-1:
		pattern = color;
		pattern = pattern | pattern << bpp;
		break;
	default:
		return color;
	}
#ifndef __LITTLE_ENDIAN
	pattern <<= (BITS_PER_LONG % bpp);
	pattern |= pattern >> bpp;
#endif
	return pattern;
}

/* overwrite bits according to a pattern in a line */
static __always_inline void bitfill(const struct fb_address *dst,
				    struct fb_pattern *pattern,
				    unsigned long (*get)(struct fb_pattern *pattern),
				    void (*rotate)(struct fb_pattern *pattern),
				    int end)
{
	unsigned long first, last;

	end += dst->bits;
	first = fb_pixel_mask(dst->bits, pattern->reverse);
	last = ~fb_pixel_mask(end & (BITS_PER_LONG-1), pattern->reverse);

	if (end <= BITS_PER_LONG) {
		last = last ? (last & first) : first;
		first = get(pattern);
		if (last == ~0UL)
			fb_write_offset(first, 0, dst);
		else if (last)
			fb_modify_offset(first, last, 0, dst);
	} else {

Annotation

Implementation Notes