coreboot_fb.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * coreboot Framebuffer driver.
  3. *
  4. * Copyright (C) 2011 The Chromium OS authors
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <asm/arch/tables.h>
  26. #include <asm/arch/sysinfo.h>
  27. #include <video_fb.h>
  28. #include "videomodes.h"
  29. /*
  30. * The Graphic Device
  31. */
  32. GraphicDevice ctfb;
  33. static int parse_coreboot_table_fb(GraphicDevice *gdev)
  34. {
  35. struct cb_framebuffer *fb = lib_sysinfo.framebuffer;
  36. /* If there is no framebuffer structure, bail out and keep
  37. * running on the serial console.
  38. */
  39. if (!fb)
  40. return 0;
  41. gdev->winSizeX = fb->x_resolution;
  42. gdev->winSizeY = fb->y_resolution;
  43. gdev->plnSizeX = fb->x_resolution;
  44. gdev->plnSizeY = fb->y_resolution;
  45. gdev->gdfBytesPP = fb->bits_per_pixel / 8;
  46. switch (fb->bits_per_pixel) {
  47. case 24:
  48. gdev->gdfIndex = GDF_32BIT_X888RGB;
  49. break;
  50. case 16:
  51. gdev->gdfIndex = GDF_16BIT_565RGB;
  52. break;
  53. default:
  54. gdev->gdfIndex = GDF__8BIT_INDEX;
  55. break;
  56. }
  57. gdev->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS;
  58. gdev->pciBase = (unsigned int)fb->physical_address;
  59. gdev->frameAdrs = (unsigned int)fb->physical_address;
  60. gdev->memSize = fb->bytes_per_line * fb->y_resolution;
  61. gdev->vprBase = (unsigned int)fb->physical_address;
  62. gdev->cprBase = (unsigned int)fb->physical_address;
  63. return 1;
  64. }
  65. void *video_hw_init(void)
  66. {
  67. GraphicDevice *gdev = &ctfb;
  68. int bits_per_pixel;
  69. printf("Video: ");
  70. if (!parse_coreboot_table_fb(gdev)) {
  71. printf("No video mode configured in coreboot!\n");
  72. return NULL;
  73. }
  74. bits_per_pixel = gdev->gdfBytesPP * 8;
  75. /* fill in Graphic device struct */
  76. sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
  77. bits_per_pixel);
  78. printf("%s\n", gdev->modeIdent);
  79. memset((void *)gdev->pciBase, 0,
  80. gdev->winSizeX * gdev->winSizeY * gdev->gdfBytesPP);
  81. return (void *)gdev;
  82. }