[22cf454d] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2006 Jakub Vana
|
---|
[22cf454d] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[a71c158] | 29 | /** @addtogroup ia32
|
---|
[b45c443] | 30 | * @{
|
---|
| 31 | */
|
---|
[3c5006a0] | 32 | /**
|
---|
| 33 | * @file
|
---|
| 34 | * @brief VESA frame buffer driver.
|
---|
[b45c443] | 35 | */
|
---|
| 36 |
|
---|
[22cf454d] | 37 | #ifdef CONFIG_FB
|
---|
| 38 |
|
---|
| 39 | #include <genarch/fb/fb.h>
|
---|
[2bc137c2] | 40 | #include <genarch/fb/visuals.h>
|
---|
[80d31883] | 41 | #include <arch/drivers/vesa.h>
|
---|
[a71c158] | 42 | #include <console/chardev.h>
|
---|
| 43 | #include <console/console.h>
|
---|
[22cf454d] | 44 | #include <putchar.h>
|
---|
| 45 | #include <mm/page.h>
|
---|
[de07bcf] | 46 | #include <mm/frame.h>
|
---|
[22cf454d] | 47 | #include <mm/as.h>
|
---|
| 48 | #include <arch/mm/page.h>
|
---|
| 49 | #include <synch/spinlock.h>
|
---|
| 50 | #include <arch/asm.h>
|
---|
[5f0c664] | 51 | #include <arch/types.h>
|
---|
[22cf454d] | 52 | #include <memstr.h>
|
---|
[5f0c664] | 53 | #include <bitops.h>
|
---|
[22cf454d] | 54 |
|
---|
[7f1c620] | 55 | uint32_t vesa_ph_addr;
|
---|
| 56 | uint16_t vesa_width;
|
---|
| 57 | uint16_t vesa_height;
|
---|
| 58 | uint16_t vesa_bpp;
|
---|
| 59 | uint16_t vesa_scanline;
|
---|
[22cf454d] | 60 |
|
---|
[1496f87] | 61 | uint8_t vesa_red_mask;
|
---|
| 62 | uint8_t vesa_red_pos;
|
---|
| 63 |
|
---|
| 64 | uint8_t vesa_green_mask;
|
---|
| 65 | uint8_t vesa_green_pos;
|
---|
| 66 |
|
---|
| 67 | uint8_t vesa_blue_mask;
|
---|
| 68 | uint8_t vesa_blue_pos;
|
---|
| 69 |
|
---|
[a71c158] | 70 | bool vesa_init(void)
|
---|
[22cf454d] | 71 | {
|
---|
[a71c158] | 72 | if ((vesa_width == 0xffff) || (vesa_height == 0xffff))
|
---|
| 73 | return false;
|
---|
[4a26e39] | 74 |
|
---|
[a71c158] | 75 | visual_t visual;
|
---|
[2bc137c2] | 76 |
|
---|
| 77 | switch (vesa_bpp) {
|
---|
| 78 | case 8:
|
---|
| 79 | visual = VISUAL_INDIRECT_8;
|
---|
| 80 | break;
|
---|
| 81 | case 16:
|
---|
[1496f87] | 82 | if ((vesa_red_mask == 5) && (vesa_red_pos == 10)
|
---|
| 83 | && (vesa_green_mask == 5) && (vesa_green_pos == 5)
|
---|
| 84 | && (vesa_blue_mask == 5) && (vesa_blue_pos == 0))
|
---|
[19490ce] | 85 | visual = VISUAL_RGB_5_5_5_LE;
|
---|
[1496f87] | 86 | else
|
---|
[19490ce] | 87 | visual = VISUAL_RGB_5_6_5_LE;
|
---|
[2bc137c2] | 88 | break;
|
---|
| 89 | case 24:
|
---|
[30885b9] | 90 | visual = VISUAL_BGR_8_8_8;
|
---|
[2bc137c2] | 91 | break;
|
---|
| 92 | case 32:
|
---|
[30885b9] | 93 | visual = VISUAL_BGR_8_8_8_0;
|
---|
[2bc137c2] | 94 | break;
|
---|
| 95 | default:
|
---|
[a71c158] | 96 | LOG("Unsupported bits per pixel.");
|
---|
| 97 | return false;
|
---|
[2bc137c2] | 98 | }
|
---|
| 99 |
|
---|
[965dc18] | 100 | fb_properties_t vesa_props = {
|
---|
| 101 | .addr = vesa_ph_addr,
|
---|
| 102 | .offset = 0,
|
---|
| 103 | .x = vesa_width,
|
---|
| 104 | .y = vesa_height,
|
---|
| 105 | .scan = vesa_scanline,
|
---|
| 106 | .visual = visual,
|
---|
| 107 | };
|
---|
[a71c158] | 108 |
|
---|
| 109 | outdev_t *fbdev = fb_init(&vesa_props);
|
---|
| 110 | if (!fbdev)
|
---|
| 111 | return false;
|
---|
| 112 |
|
---|
| 113 | stdout_wire(fbdev);
|
---|
| 114 | return true;
|
---|
[76fca31] | 115 | }
|
---|
| 116 |
|
---|
[22cf454d] | 117 | #endif
|
---|
[b45c443] | 118 |
|
---|
[3c5006a0] | 119 | /** @}
|
---|
[b45c443] | 120 | */
|
---|