/trunk/uspace/fb/fb.c |
---|
49,9 → 49,7 |
#include <ipc/ns.h> |
#include <ipc/services.h> |
#include <kernel/errno.h> |
#include <kernel/genarch/fb/visuals.h> |
#include <async.h> |
#include <bool.h> |
#include "font-8x16.h" |
#include "fb.h" |
149,17 → 147,17 |
} |
/* Conversion routines between different color representations */ |
static void rgb_byte0888(void *dst, int rgb) |
static void rgb_4byte(void *dst, int rgb) |
{ |
*(int *)dst = rgb; |
} |
static int byte0888_rgb(void *src) |
static int byte4_rgb(void *src) |
{ |
return (*(int *)src) & 0xffffff; |
} |
static void rgb_byte888(void *dst, int rgb) |
static void rgb_3byte(void *dst, int rgb) |
{ |
uint8_t *scr = dst; |
#if defined(FB_INVERT_ENDIAN) |
173,7 → 171,7 |
#endif |
} |
static int byte888_rgb(void *src) |
static int byte3_rgb(void *src) |
{ |
uint8_t *scr = src; |
#if defined(FB_INVERT_ENDIAN) |
183,22 → 181,8 |
#endif |
} |
/** 16-bit depth (5:5:5) */ |
static void rgb_byte555(void *dst, int rgb) |
{ |
/* 5-bit, 5-bits, 5-bits */ |
*((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5); |
} |
/** 16-bit depth (5:5:5) */ |
static int byte555_rgb(void *src) |
{ |
int color = *(uint16_t *)(src); |
return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); |
} |
/** 16-bit depth (5:6:5) */ |
static void rgb_byte565(void *dst, int rgb) |
static void rgb_2byte(void *dst, int rgb) |
{ |
/* 5-bit, 6-bits, 5-bits */ |
*((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5); |
205,7 → 189,7 |
} |
/** 16-bit depth (5:6:5) */ |
static int byte565_rgb(void *src) |
static int byte2_rgb(void *src) |
{ |
int color = *(uint16_t *)(src); |
return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
212,13 → 196,13 |
} |
/** Put pixel - 8-bit depth (3:2:3) */ |
static void rgb_byte8(void *dst, int rgb) |
static void rgb_1byte(void *dst, int rgb) |
{ |
*(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); |
} |
/** Return pixel color - 8-bit depth (3:2:3) */ |
static int byte8_rgb(void *src) |
static int byte1_rgb(void *src) |
{ |
int color = *(uint8_t *)src; |
return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
468,49 → 452,43 |
/** Initialize framebuffer as a chardev output device |
* |
* @param addr Address of theframebuffer |
* @param xres Screen width in pixels |
* @param yres Screen height in pixels |
* @param visual Bits per pixel (8, 16, 24, 32) |
* @param scan Bytes per one scanline |
* @param addr Address of theframebuffer |
* @param xres Screen width in pixels |
* @param yres Screen height in pixels |
* @param bpp Bits per pixel (8, 16, 24, 32) |
* @param scan Bytes per one scanline |
* @param align Alignment for 24bpp mode. |
* @param invert_colors Inverted colors. |
* |
*/ |
static bool screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int scan, unsigned int visual, bool invert_colors) |
static void |
screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan, |
int align, int invert_colors) |
{ |
switch (visual) { |
case VISUAL_INDIRECT_8: |
screen.rgb2scr = rgb_byte8; |
screen.scr2rgb = byte8_rgb; |
switch (bpp) { |
case 8: |
screen.rgb2scr = rgb_1byte; |
screen.scr2rgb = byte1_rgb; |
screen.pixelbytes = 1; |
break; |
case VISUAL_RGB_5_5_5: |
screen.rgb2scr = rgb_byte555; |
screen.scr2rgb = byte555_rgb; |
case 16: |
screen.rgb2scr = rgb_2byte; |
screen.scr2rgb = byte2_rgb; |
screen.pixelbytes = 2; |
break; |
case VISUAL_RGB_5_6_5: |
screen.rgb2scr = rgb_byte565; |
screen.scr2rgb = byte565_rgb; |
screen.pixelbytes = 2; |
case 24: |
screen.rgb2scr = rgb_3byte; |
screen.scr2rgb = byte3_rgb; |
if (!align) |
screen.pixelbytes = 3; |
else |
screen.pixelbytes = 4; |
break; |
case VISUAL_RGB_8_8_8: |
screen.rgb2scr = rgb_byte888; |
screen.scr2rgb = byte888_rgb; |
screen.pixelbytes = 3; |
break; |
case VISUAL_RGB_8_8_8_0: |
screen.rgb2scr = rgb_byte888; |
screen.scr2rgb = byte888_rgb; |
case 32: |
screen.rgb2scr = rgb_4byte; |
screen.scr2rgb = byte4_rgb; |
screen.pixelbytes = 4; |
break; |
case VISUAL_RGB_0_8_8_8: |
screen.rgb2scr = rgb_byte0888; |
screen.scr2rgb = byte0888_rgb; |
screen.pixelbytes = 4; |
break; |
default: |
return false; |
} |
screen.fbaddress = (unsigned char *) addr; |
520,9 → 498,7 |
screen.invert_colors = invert_colors; |
/* Create first viewport */ |
viewport_create(0, 0, xres, yres); |
return true; |
viewport_create(0,0,xres,yres); |
} |
/** Hide cursor if it is shown */ |
1250,9 → 1226,10 |
void *fb_ph_addr; |
unsigned int fb_width; |
unsigned int fb_height; |
unsigned int fb_bpp; |
unsigned int fb_bpp_align; |
unsigned int fb_scanline; |
unsigned int fb_visual; |
bool fb_invert_colors; |
unsigned int fb_invert_colors; |
void *fb_addr; |
size_t asz; |
1261,20 → 1238,19 |
fb_ph_addr = (void *) sysinfo_value("fb.address.physical"); |
fb_width = sysinfo_value("fb.width"); |
fb_height = sysinfo_value("fb.height"); |
fb_bpp = sysinfo_value("fb.bpp"); |
fb_bpp_align = sysinfo_value("fb.bpp-align"); |
fb_scanline = sysinfo_value("fb.scanline"); |
fb_visual = sysinfo_value("fb.visual"); |
fb_invert_colors = sysinfo_value("fb.invert-colors"); |
asz = fb_scanline * fb_height; |
asz = fb_scanline*fb_height; |
fb_addr = as_get_mappable_page(asz); |
map_physmem(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >> PAGE_WIDTH, |
AS_AREA_READ | AS_AREA_WRITE); |
if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual, fb_invert_colors)) |
return 0; |
return -1; |
screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline, fb_bpp_align, fb_invert_colors); |
return 0; |
} |
/** |
/trunk/kernel/genarch/src/fb/fb.c |
---|
33,7 → 33,6 |
*/ |
#include <genarch/fb/font-8x16.h> |
#include <genarch/fb/visuals.h> |
#include <genarch/fb/fb.h> |
#include <console/chardev.h> |
#include <console/console.h> |
59,6 → 58,7 |
static unsigned int xres = 0; |
static unsigned int yres = 0; |
static unsigned int scanline = 0; |
static unsigned int bitspp = 0; |
static unsigned int pixelbytes = 0; |
#ifdef FB_INVERT_COLORS |
static bool invert_colors = true; |
95,17 → 95,17 |
} |
/* Conversion routines between different color representations */ |
static void rgb_byte0888(void *dst, int rgb) |
static void rgb_4byte(void *dst, int rgb) |
{ |
*((int *) dst) = rgb; |
} |
static int byte0888_rgb(void *src) |
static int byte4_rgb(void *src) |
{ |
return (*((int *) src)) & 0xffffff; |
} |
static void rgb_byte888(void *dst, int rgb) |
static void rgb_3byte(void *dst, int rgb) |
{ |
uint8_t *scr = dst; |
#if defined(FB_INVERT_ENDIAN) |
119,7 → 119,7 |
#endif |
} |
static int byte888_rgb(void *src) |
static int byte3_rgb(void *src) |
{ |
uint8_t *scr = src; |
#if defined(FB_INVERT_ENDIAN) |
129,22 → 129,8 |
#endif |
} |
/** 16-bit depth (5:5:5) */ |
static void rgb_byte555(void *dst, int rgb) |
{ |
/* 5-bit, 5-bits, 5-bits */ |
*((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5); |
} |
/** 16-bit depth (5:5:5) */ |
static int byte555_rgb(void *src) |
{ |
int color = *(uint16_t *)(src); |
return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); |
} |
/** 16-bit depth (5:6:5) */ |
static void rgb_byte565(void *dst, int rgb) |
static void rgb_2byte(void *dst, int rgb) |
{ |
/* 5-bit, 6-bits, 5-bits */ |
*((uint16_t *) dst) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5); |
151,7 → 137,7 |
} |
/** 16-bit depth (5:6:5) */ |
static int byte565_rgb(void *src) |
static int byte2_rgb(void *src) |
{ |
int color = *(uint16_t *)(src); |
return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
165,7 → 151,7 |
* palette. This could be fixed by supporting custom palette |
* and setting it to simulate the 8-bit truecolor. |
*/ |
static void rgb_byte8(void *dst, int rgb) |
static void rgb_1byte(void *dst, int rgb) |
{ |
*((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); |
} |
172,9 → 158,9 |
/** Return pixel color - 8-bit depth (color palette/3:2:3) |
* |
* See the comment for rgb_byte(). |
* See the comment for rgb_1byte(). |
*/ |
static int byte8_rgb(void *src) |
static int byte1_rgb(void *src) |
{ |
int color = *(uint8_t *)src; |
return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
221,7 → 207,7 |
int firstsz; |
if (dbbuffer) { |
memcpy(&dbbuffer[dboffset * scanline], blankline, ROW_BYTES); |
memcpy(&dbbuffer[dboffset * scanline], blankline, FONT_SCANLINES * scanline); |
dboffset = (dboffset + FONT_SCANLINES) % yres; |
firstsz = yres - dboffset; |
362,48 → 348,41 |
/** Initialize framebuffer as a chardev output device |
* |
* @param addr Physical address of the framebuffer |
* @param x Screen width in pixels |
* @param y Screen height in pixels |
* @param scan Bytes per one scanline |
* @param visual Color model |
* |
* @param addr Physical address of the framebuffer |
* @param x Screen width in pixels |
* @param y Screen height in pixels |
* @param bpp Bits per pixel (8, 16, 24, 32) |
* @param scan Bytes per one scanline |
* @param align Request alignment for 24bpp mode. |
*/ |
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual) |
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, bool align) |
{ |
switch (visual) { |
case VISUAL_INDIRECT_8: |
rgb2scr = rgb_byte8; |
scr2rgb = byte8_rgb; |
switch (bpp) { |
case 8: |
rgb2scr = rgb_1byte; |
scr2rgb = byte1_rgb; |
pixelbytes = 1; |
break; |
case VISUAL_RGB_5_5_5: |
rgb2scr = rgb_byte555; |
scr2rgb = byte555_rgb; |
case 16: |
rgb2scr = rgb_2byte; |
scr2rgb = byte2_rgb; |
pixelbytes = 2; |
break; |
case VISUAL_RGB_5_6_5: |
rgb2scr = rgb_byte565; |
scr2rgb = byte565_rgb; |
pixelbytes = 2; |
case 24: |
rgb2scr = rgb_3byte; |
scr2rgb = byte3_rgb; |
if (align) |
pixelbytes = 4; |
else |
pixelbytes = 3; |
break; |
case VISUAL_RGB_8_8_8: |
rgb2scr = rgb_byte888; |
scr2rgb = byte888_rgb; |
pixelbytes = 3; |
break; |
case VISUAL_RGB_8_8_8_0: |
rgb2scr = rgb_byte888; |
scr2rgb = byte888_rgb; |
case 32: |
rgb2scr = rgb_4byte; |
scr2rgb = byte4_rgb; |
pixelbytes = 4; |
break; |
case VISUAL_RGB_0_8_8_8: |
rgb2scr = rgb_byte0888; |
scr2rgb = byte0888_rgb; |
pixelbytes = 4; |
break; |
default: |
panic("Unsupported visual.\n"); |
panic("Unsupported bpp.\n"); |
} |
unsigned int fbsize = scan * y; |
413,6 → 392,7 |
xres = x; |
yres = y; |
bitspp = bpp; |
scanline = scan; |
rows = y / FONT_SCANLINES; |
422,8 → 402,9 |
sysinfo_set_item_val("fb.kind", NULL, 1); |
sysinfo_set_item_val("fb.width", NULL, xres); |
sysinfo_set_item_val("fb.height", NULL, yres); |
sysinfo_set_item_val("fb.bpp", NULL, bpp); |
sysinfo_set_item_val("fb.bpp-align", NULL, align); |
sysinfo_set_item_val("fb.scanline", NULL, scan); |
sysinfo_set_item_val("fb.visual", NULL, visual); |
sysinfo_set_item_val("fb.address.physical", NULL, addr); |
sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors); |
/trunk/kernel/genarch/include/fb/visuals.h |
---|
File deleted |
/trunk/kernel/genarch/include/fb/fb.h |
---|
39,7 → 39,7 |
#include <arch/types.h> |
extern spinlock_t fb_lock; |
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual); |
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, bool align); |
#endif |
/trunk/kernel/arch/sparc64/src/drivers/scr.c |
---|
35,7 → 35,6 |
#include <arch/drivers/scr.h> |
#include <genarch/ofw/ofw_tree.h> |
#include <genarch/fb/fb.h> |
#include <genarch/fb/visuals.h> |
#include <arch/types.h> |
#include <typedefs.h> |
#include <func.h> |
76,7 → 75,6 |
uint32_t fb_depth = 0; |
uint32_t fb_linebytes = 0; |
uint32_t fb_scanline = 0; |
unsigned int visual; |
prop = ofw_tree_getprop(node, "width"); |
if (prop && prop->value) |
117,33 → 115,16 |
printf("Failed to determine screen address.\n"); |
return; |
} |
switch (fb_depth) { |
case 8: |
fb_scanline = fb_linebytes * (fb_depth >> 3); |
visual = VISUAL_INDIRECT_8; |
break; |
case 16: |
fb_scanline = fb_linebytes * (fb_depth >> 3); |
visual = VISUAL_RGB_5_6_5; |
break; |
case 24: |
if (fb_depth == 24) |
fb_scanline = fb_linebytes * 4; |
visual = VISUAL_RGB_8_8_8_0; |
break; |
case 32: |
else |
fb_scanline = fb_linebytes * (fb_depth >> 3); |
visual = VISUAL_RGB_0_8_8_8; |
break; |
default: |
printf("Unsupported bits per pixel.\n"); |
return; |
} |
break; |
case SCR_FFB: |
fb_depth = 32; |
fb_scanline = 8192; |
visual = VISUAL_RGB_0_8_8_8; |
ofw_upa_reg_t *reg = &((ofw_upa_reg_t *) prop->value)[FFB_REG_24BPP]; |
if (!ofw_upa_apply_ranges(node->parent, reg, &fb_addr)) { |
156,7 → 137,7 |
panic("Unexpected type.\n"); |
} |
fb_init(fb_addr, fb_width, fb_height, fb_scanline, visual); |
fb_init(fb_addr, fb_width, fb_height, fb_depth, fb_scanline, true); |
} |
/** @} |
/trunk/kernel/arch/mips32/src/mips32.c |
---|
53,7 → 53,6 |
#include <console/chardev.h> |
#include <arch/debugger.h> |
#include <genarch/fb/fb.h> |
#include <genarch/fb/visuals.h> |
#include <macros.h> |
#include <ddi/device.h> |
123,7 → 122,7 |
interrupt_init(); |
console_init(device_assign_devno()); |
#ifdef CONFIG_FB |
fb_init(0x12000000, 640, 480, 1920, VISUAL_RGB_8_8_8); // gxemul framebuffer |
fb_init(0x12000000, 640, 480, 24, 1920, false); // gxemul framebuffer |
#endif |
sysinfo_set_item_val("machine." STRING(MACHINE), NULL, 1); |
} |
/trunk/kernel/arch/ia32/src/drivers/vesa.c |
---|
37,7 → 37,6 |
#ifdef CONFIG_FB |
#include <genarch/fb/fb.h> |
#include <genarch/fb/visuals.h> |
#include <arch/drivers/vesa.h> |
#include <putchar.h> |
#include <mm/page.h> |
68,26 → 67,7 |
void vesa_init(void) |
{ |
unsigned int visual; |
switch (vesa_bpp) { |
case 8: |
visual = VISUAL_INDIRECT_8; |
break; |
case 16: |
visual = VISUAL_RGB_5_6_5; |
break; |
case 24: |
visual = VISUAL_RGB_8_8_8; |
break; |
case 32: |
visual = VISUAL_RGB_0_8_8_8; |
break; |
default: |
panic("Unsupported bits per pixel"); |
} |
fb_init(vesa_ph_addr, vesa_width, vesa_height, vesa_scanline, visual); |
fb_init(vesa_ph_addr, vesa_width, vesa_height, vesa_bpp, vesa_scanline, false); |
} |
#endif |
/trunk/kernel/arch/ppc32/src/ppc32.c |
---|
38,7 → 38,6 |
#include <arch/mm/memory_init.h> |
#include <arch/interrupt.h> |
#include <genarch/fb/fb.h> |
#include <genarch/fb/visuals.h> |
#include <userspace.h> |
#include <proc/uarg.h> |
#include <console/console.h> |
76,26 → 75,8 |
{ |
if (config.cpu_active == 1) { |
/* Initialize framebuffer */ |
unsigned int visual; |
fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline, false); |
switch (bootinfo.screen.bpp) { |
case 8: |
visual = VISUAL_INDIRECT_8; |
break; |
case 16: |
visual = VISUAL_RGB_5_5_5; |
break; |
case 24: |
visual = VISUAL_RGB_8_8_8; |
break; |
case 32: |
visual = VISUAL_RGB_0_8_8_8; |
break; |
default: |
panic("Unsupported bits per pixel"); |
} |
fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.scanline, visual); |
/* Initialize IRQ routing */ |
irq_init(IRQ_COUNT, IRQ_COUNT); |
/trunk/kernel/arch/ppc64/src/ppc64.c |
---|
37,7 → 37,6 |
#include <arch/mm/memory_init.h> |
#include <arch/interrupt.h> |
#include <genarch/fb/fb.h> |
#include <genarch/fb/visuals.h> |
#include <userspace.h> |
#include <proc/uarg.h> |
#include <console/console.h> |
69,27 → 68,7 |
void arch_post_mm_init(void) |
{ |
if (config.cpu_active == 1) { |
/* Initialize framebuffer */ |
unsigned int visual; |
switch (bootinfo.screen.bpp) { |
case 8: |
visual = VISUAL_INDIRECT_8; |
break; |
case 16: |
visual = VISUAL_RGB_5_5_5; |
break; |
case 24: |
visual = VISUAL_RGB_8_8_8; |
break; |
case 32: |
visual = VISUAL_RGB_0_8_8_8; |
break; |
default: |
panic("Unsupported bits per pixel"); |
} |
fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.scanline, visual); |
fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline, false); |
/* Merge all zones to 1 big zone */ |
zone_merge_all(); |