| 1 | |
| 2 | *
|
| 3 | * I/O memory framebuffer access for drawing routines
|
| 4 | *
|
| 5 | * Copyright (C) 2025 Zsolt Kajtar ([email protected])
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 | struct fb_address {
|
| 10 | void __iomem *address;
|
| 11 | int bits;
|
| 12 | };
|
| 13 |
|
| 14 |
|
| 15 | static inline struct fb_address fb_address_init(struct fb_info *p)
|
| 16 | {
|
| 17 | void __iomem *base = p->screen_base;
|
| 18 | struct fb_address ptr;
|
| 19 |
|
| 20 | ptr.address = PTR_ALIGN_DOWN(base, BITS_PER_LONG / BITS_PER_BYTE);
|
| 21 | ptr.bits = (base - ptr.address) * BITS_PER_BYTE;
|
| 22 | return ptr;
|
| 23 | }
|
| 24 |
|
| 25 |
|
| 26 | static inline void fb_write_offset(unsigned long val, int offset, const struct fb_address *dst)
|
| 27 | {
|
| 28 | #if BITS_PER_LONG == 32
|
| 29 | fb_writel(val, dst->address + offset * (BITS_PER_LONG / BITS_PER_BYTE));
|
| 30 | #else
|
| 31 | fb_writeq(val, dst->address + offset * (BITS_PER_LONG / BITS_PER_BYTE));
|
| 32 | #endif
|
| 33 | }
|
| 34 |
|
| 35 |
|
| 36 | static inline unsigned long fb_read_offset(int offset, const struct fb_address *src)
|
| 37 | {
|
| 38 | #if BITS_PER_LONG == 32
|
| 39 | return fb_readl(src->address + offset * (BITS_PER_LONG / BITS_PER_BYTE));
|
| 40 | #else
|
| 41 | return fb_readq(src->address + offset * (BITS_PER_LONG / BITS_PER_BYTE));
|
| 42 | #endif
|
| 43 | }
|