vesa.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* SPDX-License-Identifier: BSD-2-Clause */
  2. /******************************************************************************
  3. * Copyright (c) 2004, 2008 IBM Corporation
  4. * Copyright (c) 2009 Pattrick Hueper <phueper@hueper.net>
  5. * All rights reserved.
  6. *
  7. * Contributors:
  8. * IBM Corporation - initial implementation
  9. *****************************************************************************/
  10. #ifndef _VESA_H
  11. #define _VESA_H
  12. /* these structs are for input from and output to OF */
  13. struct __packed vesa_screen_info {
  14. u8 display_type; /* 0=NONE, 1= analog, 2=digital */
  15. u16 screen_width;
  16. u16 screen_height;
  17. /* bytes per line in framebuffer, may be more than screen_width */
  18. u16 screen_linebytes;
  19. u8 color_depth; /* color depth in bits per pixel */
  20. u32 framebuffer_address;
  21. u8 edid_block_zero[128];
  22. };
  23. struct __packed vesa_screen_info_input {
  24. u8 signature[4];
  25. u16 size_reserved;
  26. u8 monitor_number;
  27. u16 max_screen_width;
  28. u8 color_depth;
  29. };
  30. /*
  31. * These structs only store the required subset of fields in Vesa BIOS
  32. * Extensions
  33. */
  34. struct __packed vesa_bios_ext_info {
  35. char signature[4];
  36. u16 version;
  37. u32 oem_string_ptr;
  38. u32 capabilities;
  39. u32 modes_ptr;
  40. u16 total_memory;
  41. u16 oem_version;
  42. u32 vendor_name_ptr;
  43. u32 product_name_ptr;
  44. u32 product_rev_ptr;
  45. };
  46. struct __packed vesa_mode_info {
  47. u16 mode_attributes; /* 00 */
  48. u8 win_a_attributes; /* 02 */
  49. u8 win_b_attributes; /* 03 */
  50. u16 win_granularity; /* 04 */
  51. u16 win_size; /* 06 */
  52. u16 win_a_segment; /* 08 */
  53. u16 win_b_segment; /* 0a */
  54. u32 win_func_ptr; /* 0c */
  55. u16 bytes_per_scanline; /* 10 */
  56. u16 x_resolution; /* 12 */
  57. u16 y_resolution; /* 14 */
  58. u8 x_charsize; /* 16 */
  59. u8 y_charsize; /* 17 */
  60. u8 number_of_planes; /* 18 */
  61. u8 bits_per_pixel; /* 19 */
  62. u8 number_of_banks; /* 20 */
  63. u8 memory_model; /* 21 */
  64. u8 bank_size; /* 22 */
  65. u8 number_of_image_pages; /* 23 */
  66. u8 reserved_page;
  67. u8 red_mask_size;
  68. u8 red_mask_pos;
  69. u8 green_mask_size;
  70. u8 green_mask_pos;
  71. u8 blue_mask_size;
  72. u8 blue_mask_pos;
  73. u8 reserved_mask_size;
  74. u8 reserved_mask_pos;
  75. u8 direct_color_mode_info;
  76. u32 phys_base_ptr;
  77. u32 offscreen_mem_offset;
  78. u16 offscreen_mem_size;
  79. u8 reserved[206];
  80. };
  81. struct vesa_state {
  82. u16 video_mode;
  83. bool valid;
  84. union {
  85. struct vesa_mode_info vesa;
  86. u8 mode_info_block[256];
  87. };
  88. };
  89. struct vesa_ddc_info {
  90. u8 port_number; /* i.e. monitor number */
  91. u8 edid_transfer_time;
  92. u8 ddc_level;
  93. u8 edid_block_zero[128];
  94. };
  95. #define VESA_GET_INFO 0x4f00
  96. #define VESA_GET_MODE_INFO 0x4f01
  97. #define VESA_SET_MODE 0x4f02
  98. #define VESA_GET_CUR_MODE 0x4f03
  99. extern struct vesa_state mode_info;
  100. struct video_priv;
  101. struct video_uc_plat;
  102. /**
  103. * vesa_setup_video_priv() - Set up a video device using VESA information
  104. *
  105. * The vesa struct is used by various x86 drivers, so this is a common function
  106. * to use it to set up the video.
  107. *
  108. * @vesa: Vesa information to use (vesa->phys_base_ptr is ignored)
  109. * @fb: Frame buffer address (since vesa->phys_base_ptr is only 32 bits)
  110. * @uc_priv: Video device's uclass-private information
  111. * @plat: Video devices's uclass-private platform data
  112. * Returns: 0 if OK, -ENXIO if the x resolution is 0, -EEPROTONOSUPPORT if the
  113. * pixel format is not supported
  114. */
  115. int vesa_setup_video_priv(struct vesa_mode_info *vesa, u64 fb,
  116. struct video_priv *uc_priv,
  117. struct video_uc_plat *plat);
  118. int vesa_setup_video(struct udevice *dev, int (*int15_handler)(void));
  119. #endif