drivers/staging/fbtft/fbtft-core.c

Source file repositories/reference/linux-study-clean/drivers/staging/fbtft/fbtft-core.c

File Facts

System
Linux kernel
Corpus path
drivers/staging/fbtft/fbtft-core.c
Extension
.c
Size
33428 bytes
Lines
1272
Domain
Driver Families
Bucket
drivers/staging
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

if (regno < 16) {
			u32 *pal = info->pseudo_palette;

			val  = chan_to_field(red,   &info->var.red);
			val |= chan_to_field(green, &info->var.green);
			val |= chan_to_field(blue,  &info->var.blue);

			pal[regno] = val;
			ret = 0;
		}
		break;
	}
	return ret;
}

static int fbtft_fb_blank(int blank, struct fb_info *info)
{
	struct fbtft_par *par = info->par;
	int ret = -EINVAL;

	fb_dbg(info, "blank=%d\n", blank);

	if (!par->fbtftops.blank)
		return ret;

	switch (blank) {
	case FB_BLANK_POWERDOWN:
	case FB_BLANK_VSYNC_SUSPEND:
	case FB_BLANK_HSYNC_SUSPEND:
	case FB_BLANK_NORMAL:
		ret = par->fbtftops.blank(par, true);
		break;
	case FB_BLANK_UNBLANK:
		ret = par->fbtftops.blank(par, false);
		break;
	}
	return ret;
}

static void fbtft_ops_damage_range(struct fb_info *info, off_t off, size_t len)
{
	struct fbtft_par *par = info->par;
	u32 start, end;

	start = off / info->fix.line_length;
	end = (off + len - 1) / info->fix.line_length;

	par->fbtftops.mkdirty(info, start, end - start + 1);
}

static void fbtft_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 width, u32 height)
{
	struct fbtft_par *par = info->par;

	par->fbtftops.mkdirty(info, y, height);
}

FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(fbtft_ops,
				   fbtft_ops_damage_range,
				   fbtft_ops_damage_area)

static const struct fb_ops fbtft_ops = {
	.owner        = THIS_MODULE,
	FB_DEFAULT_DEFERRED_OPS(fbtft_ops),
	.fb_setcolreg = fbtft_fb_setcolreg,
	.fb_blank     = fbtft_fb_blank,
};

static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
{
	if (src->write)
		dst->write = src->write;
	if (src->read)
		dst->read = src->read;
	if (src->write_vmem)
		dst->write_vmem = src->write_vmem;
	if (src->write_register)
		dst->write_register = src->write_register;
	if (src->set_addr_win)
		dst->set_addr_win = src->set_addr_win;
	if (src->reset)
		dst->reset = src->reset;
	if (src->mkdirty)
		dst->mkdirty = src->mkdirty;
	if (src->update_display)
		dst->update_display = src->update_display;
	if (src->init_display)
		dst->init_display = src->init_display;
	if (src->blank)
		dst->blank = src->blank;

Annotation

Implementation Notes