uboot/drivers/video/coreboot_fb.c
<<
>>
Prefs
   1/*
   2 * coreboot Framebuffer driver.
   3 *
   4 * Copyright (C) 2011 The Chromium OS authors
   5 *
   6 * SPDX-License-Identifier:     GPL-2.0+
   7 */
   8
   9#include <common.h>
  10#include <asm/arch/tables.h>
  11#include <asm/arch/sysinfo.h>
  12#include <video_fb.h>
  13#include "videomodes.h"
  14
  15/*
  16 * The Graphic Device
  17 */
  18GraphicDevice ctfb;
  19
  20static int parse_coreboot_table_fb(GraphicDevice *gdev)
  21{
  22        struct cb_framebuffer *fb = lib_sysinfo.framebuffer;
  23
  24        /* If there is no framebuffer structure, bail out and keep
  25         * running on the serial console.
  26         */
  27        if (!fb)
  28                return 0;
  29
  30        gdev->winSizeX = fb->x_resolution;
  31        gdev->winSizeY = fb->y_resolution;
  32
  33        gdev->plnSizeX = fb->x_resolution;
  34        gdev->plnSizeY = fb->y_resolution;
  35
  36        gdev->gdfBytesPP = fb->bits_per_pixel / 8;
  37
  38        switch (fb->bits_per_pixel) {
  39        case 24:
  40                gdev->gdfIndex = GDF_32BIT_X888RGB;
  41                break;
  42        case 16:
  43                gdev->gdfIndex = GDF_16BIT_565RGB;
  44                break;
  45        default:
  46                gdev->gdfIndex = GDF__8BIT_INDEX;
  47                break;
  48        }
  49
  50        gdev->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS;
  51        gdev->pciBase = (unsigned int)fb->physical_address;
  52
  53        gdev->frameAdrs = (unsigned int)fb->physical_address;
  54        gdev->memSize = fb->bytes_per_line * fb->y_resolution;
  55
  56        gdev->vprBase = (unsigned int)fb->physical_address;
  57        gdev->cprBase = (unsigned int)fb->physical_address;
  58
  59        return 1;
  60}
  61
  62void *video_hw_init(void)
  63{
  64        GraphicDevice *gdev = &ctfb;
  65        int bits_per_pixel;
  66
  67        printf("Video: ");
  68
  69        if (!parse_coreboot_table_fb(gdev)) {
  70                printf("No video mode configured in coreboot!\n");
  71                return NULL;
  72        }
  73
  74        bits_per_pixel = gdev->gdfBytesPP * 8;
  75
  76        /* fill in Graphic device struct */
  77        sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
  78                 bits_per_pixel);
  79        printf("%s\n", gdev->modeIdent);
  80
  81        memset((void *)gdev->pciBase, 0,
  82                gdev->winSizeX * gdev->winSizeY * gdev->gdfBytesPP);
  83
  84        return (void *)gdev;
  85}
  86