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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/export.hlinux/kernel.hlinux/module.hlinux/ioport.hlinux/io.hlinux/bitops.hlinux/mutex.hlinux/platform_device.hvideo/omapvrfb.h
Detected Declarations
struct vrfb_ctxfunction omap2_sms_write_rot_controlfunction omap2_sms_write_rot_sizefunction omap2_sms_write_rot_physical_bafunction restore_hw_contextfunction get_image_width_roundupfunction get_extra_physical_sizefunction omap_vrfb_restore_contextfunction omap_vrfb_adjust_sizefunction omap_vrfb_min_phys_sizefunction omap_vrfb_max_heightfunction omap_vrfb_setupfunction omap_vrfb_map_anglefunction omap_vrfb_release_ctxfunction omap_vrfb_request_ctxfunction omap_vrfb_supportedfunction vrfb_probeexport omap_vrfb_adjust_sizeexport omap_vrfb_min_phys_sizeexport omap_vrfb_max_heightexport omap_vrfb_setupexport omap_vrfb_map_angleexport omap_vrfb_release_ctxexport omap_vrfb_request_ctxexport omap_vrfb_supported
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
- Immediate include surface: `linux/err.h`, `linux/export.h`, `linux/kernel.h`, `linux/module.h`, `linux/ioport.h`, `linux/io.h`, `linux/bitops.h`, `linux/mutex.h`.
- Detected declarations: `struct vrfb_ctx`, `function omap2_sms_write_rot_control`, `function omap2_sms_write_rot_size`, `function omap2_sms_write_rot_physical_ba`, `function restore_hw_context`, `function get_image_width_roundup`, `function get_extra_physical_size`, `function omap_vrfb_restore_context`, `function omap_vrfb_adjust_size`, `function omap_vrfb_min_phys_size`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.