drivers/video/fbdev/omap2/omapfb/vrfb.c

Source file repositories/reference/linux-study-clean/drivers/video/fbdev/omap2/omapfb/vrfb.c

File Facts

System
Linux kernel
Corpus path
drivers/video/fbdev/omap2/omapfb/vrfb.c
Extension
.c
Size
8635 bytes
Lines
380
Domain
Driver Families
Bucket
drivers/video
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

struct vrfb_ctx {
	u32 base;
	u32 physical_ba;
	u32 control;
	u32 size;
};

static DEFINE_MUTEX(ctx_lock);

/*
 * Access to this happens from client drivers or the PM core after wake-up.
 * For the first case we require locking at the driver level, for the second
 * we don't need locking, since no drivers will run until after the wake-up
 * has finished.
 */

static void __iomem *vrfb_base;

static int num_ctxs;
static struct vrfb_ctx *ctxs;

static bool vrfb_loaded;

static void omap2_sms_write_rot_control(u32 val, unsigned ctx)
{
	__raw_writel(val, vrfb_base + SMS_ROT_CONTROL(ctx));
}

static void omap2_sms_write_rot_size(u32 val, unsigned ctx)
{
	__raw_writel(val, vrfb_base + SMS_ROT_SIZE(ctx));
}

static void omap2_sms_write_rot_physical_ba(u32 val, unsigned ctx)
{
	__raw_writel(val, vrfb_base + SMS_ROT_PHYSICAL_BA(ctx));
}

static inline void restore_hw_context(int ctx)
{
	omap2_sms_write_rot_control(ctxs[ctx].control, ctx);
	omap2_sms_write_rot_size(ctxs[ctx].size, ctx);
	omap2_sms_write_rot_physical_ba(ctxs[ctx].physical_ba, ctx);
}

static u32 get_image_width_roundup(u16 width, u8 bytespp)
{
	unsigned long stride = width * bytespp;
	unsigned long ceil_pages_per_stride = (stride / VRFB_PAGE_WIDTH) +
		(stride % VRFB_PAGE_WIDTH != 0);

	return ceil_pages_per_stride * VRFB_PAGE_WIDTH / bytespp;
}

/*
 * This the extra space needed in the VRFB physical area for VRFB to safely wrap
 * any memory accesses to the invisible part of the virtual view to the physical
 * area.
 */
static inline u32 get_extra_physical_size(u16 image_width_roundup, u8 bytespp)
{
	return (OMAP_VRFB_LINE_LEN - image_width_roundup) * VRFB_PAGE_HEIGHT *
		bytespp;
}

void omap_vrfb_restore_context(void)
{
	int i;
	unsigned long map = ctx_map;

	for (i = ffs(map); i; i = ffs(map)) {
		/* i=1..32 */
		i--;
		map &= ~(1 << i);
		restore_hw_context(i);
	}
}

void omap_vrfb_adjust_size(u16 *width, u16 *height,
		u8 bytespp)
{
	*width = ALIGN(*width * bytespp, VRFB_PAGE_WIDTH) / bytespp;
	*height = ALIGN(*height, VRFB_PAGE_HEIGHT);
}
EXPORT_SYMBOL(omap_vrfb_adjust_size);

u32 omap_vrfb_min_phys_size(u16 width, u16 height, u8 bytespp)
{
	unsigned long image_width_roundup = get_image_width_roundup(width,
		bytespp);

Annotation

Implementation Notes