mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-21 22:23:05 +00:00
fb: Add A7-A11 device support
This includes: - Do not treat iPhone 5 buffer as dummy on 5s - Added support for 24-bit framebuffer - When we have a vertical display, use whole fb as console Signed-off-by: Nick Chan <towinchenmi@gmail.com>
This commit is contained in:
parent
c28d6b7172
commit
d0889bda14
1 changed files with 42 additions and 7 deletions
49
src/fb.c
49
src/fb.c
|
@ -104,14 +104,42 @@ static inline rgb_t pixel2rgb_30(u32 c)
|
||||||
return (rgb_t){(c >> 22) & 0xff, (c >> 12) & 0xff, c >> 2};
|
return (rgb_t){(c >> 22) & 0xff, (c >> 12) & 0xff, c >> 2};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline u32 rgb2pixel_24(rgb_t c)
|
||||||
|
{
|
||||||
|
return c.b | (c.g << 8) | (c.r << 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline rgb_t pixel2rgb_24(u32 c)
|
||||||
|
{
|
||||||
|
return (rgb_t){(c >> 16) & 0xff, (c >> 8) & 0xff, c};
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32 rgb2pixel(rgb_t c)
|
||||||
|
{
|
||||||
|
if ((cur_boot_args.video.depth & 0xff) == 32) {
|
||||||
|
return rgb2pixel_24(c);
|
||||||
|
} else {
|
||||||
|
return rgb2pixel_30(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline rgb_t pixel2rgb(u32 c)
|
||||||
|
{
|
||||||
|
if ((cur_boot_args.video.depth & 0xff) == 32) {
|
||||||
|
return pixel2rgb_24(c);
|
||||||
|
} else {
|
||||||
|
return pixel2rgb_30(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void fb_set_pixel(u32 x, u32 y, rgb_t c)
|
static inline void fb_set_pixel(u32 x, u32 y, rgb_t c)
|
||||||
{
|
{
|
||||||
fb.ptr[x + y * fb.stride] = rgb2pixel_30(c);
|
fb.ptr[x + y * fb.stride] = rgb2pixel(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline rgb_t fb_get_pixel(u32 x, u32 y)
|
static inline rgb_t fb_get_pixel(u32 x, u32 y)
|
||||||
{
|
{
|
||||||
return pixel2rgb_30(fb.ptr[x + y * fb.stride]);
|
return pixel2rgb(fb.ptr[x + y * fb.stride]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fb_blit(u32 x, u32 y, u32 w, u32 h, void *data, u32 stride, pix_fmt_t pix_fmt)
|
void fb_blit(u32 x, u32 y, u32 w, u32 h, void *data, u32 stride, pix_fmt_t pix_fmt)
|
||||||
|
@ -163,7 +191,7 @@ void fb_fill(u32 x, u32 y, u32 w, u32 h, rgb_t color)
|
||||||
if (!console.initialized)
|
if (!console.initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u32 c = rgb2pixel_30(color);
|
u32 c = rgb2pixel(color);
|
||||||
for (u32 i = 0; i < h; i++)
|
for (u32 i = 0; i < h; i++)
|
||||||
memset32(&fb.ptr[x + (y + i) * fb.stride], c, w * 4);
|
memset32(&fb.ptr[x + (y + i) * fb.stride], c, w * 4);
|
||||||
fb_update();
|
fb_update();
|
||||||
|
@ -174,7 +202,7 @@ void fb_clear(rgb_t color)
|
||||||
if (!console.initialized)
|
if (!console.initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u32 c = rgb2pixel_30(color);
|
u32 c = rgb2pixel(color);
|
||||||
memset32(fb.ptr, c, fb.stride * fb.height * 4);
|
memset32(fb.ptr, c, fb.stride * fb.height * 4);
|
||||||
fb_update();
|
fb_update();
|
||||||
}
|
}
|
||||||
|
@ -412,9 +440,16 @@ void fb_init(bool clear)
|
||||||
console.cursor.col = 0;
|
console.cursor.col = 0;
|
||||||
console.cursor.row = 0;
|
console.cursor.row = 0;
|
||||||
|
|
||||||
console.cursor.max_row = (fb.height / console.font.height) - 2 * console.margin.rows;
|
if (fb.height < fb.width) {
|
||||||
console.cursor.max_col =
|
console.cursor.max_row = (fb.height / console.font.height) - 2 * console.margin.rows;
|
||||||
((fb.width - logo->width) / 2) / console.font.width - 2 * console.margin.cols;
|
console.cursor.max_col =
|
||||||
|
((fb.width - logo->width) / 2) / console.font.width - 2 * console.margin.cols;
|
||||||
|
} else { // there aren't much screen real estate for us to waste here
|
||||||
|
console.cursor.max_row = (fb.height / console.font.height);
|
||||||
|
console.cursor.max_col = (fb.width / console.font.width);
|
||||||
|
console.margin.rows = 0;
|
||||||
|
console.margin.cols = 0;
|
||||||
|
}
|
||||||
|
|
||||||
console.initialized = true;
|
console.initialized = true;
|
||||||
console.active = false;
|
console.active = false;
|
||||||
|
|
Loading…
Reference in a new issue