video.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* -*- linux-c -*- ------------------------------------------------------- *
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. * Copyright 2007 rPath, Inc. - All Rights Reserved
  6. *
  7. * ----------------------------------------------------------------------- */
  8. /*
  9. * Header file for the real-mode video probing code
  10. */
  11. #ifndef BOOT_VIDEO_H
  12. #define BOOT_VIDEO_H
  13. #include <linux/types.h>
  14. /*
  15. * This code uses an extended set of video mode numbers. These include:
  16. * Aliases for standard modes
  17. * NORMAL_VGA (-1)
  18. * EXTENDED_VGA (-2)
  19. * ASK_VGA (-3)
  20. * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
  21. * of compatibility when extending the table. These are between 0x00 and 0xff.
  22. */
  23. #define VIDEO_FIRST_MENU 0x0000
  24. /* Standard BIOS video modes (BIOS number + 0x0100) */
  25. #define VIDEO_FIRST_BIOS 0x0100
  26. /* VESA BIOS video modes (VESA number + 0x0200) */
  27. #define VIDEO_FIRST_VESA 0x0200
  28. /* Video7 special modes (BIOS number + 0x0900) */
  29. #define VIDEO_FIRST_V7 0x0900
  30. /* Special video modes */
  31. #define VIDEO_FIRST_SPECIAL 0x0f00
  32. #define VIDEO_80x25 0x0f00
  33. #define VIDEO_8POINT 0x0f01
  34. #define VIDEO_80x43 0x0f02
  35. #define VIDEO_80x28 0x0f03
  36. #define VIDEO_CURRENT_MODE 0x0f04
  37. #define VIDEO_80x30 0x0f05
  38. #define VIDEO_80x34 0x0f06
  39. #define VIDEO_80x60 0x0f07
  40. #define VIDEO_GFX_HACK 0x0f08
  41. #define VIDEO_LAST_SPECIAL 0x0f09
  42. /* Video modes given by resolution */
  43. #define VIDEO_FIRST_RESOLUTION 0x1000
  44. /* The "recalculate timings" flag */
  45. #define VIDEO_RECALC 0x8000
  46. void store_screen(void);
  47. #define DO_STORE() store_screen()
  48. /*
  49. * Mode table structures
  50. */
  51. struct mode_info {
  52. u16 mode; /* Mode number (vga= style) */
  53. u16 x, y; /* Width, height */
  54. u16 depth; /* Bits per pixel, 0 for text mode */
  55. };
  56. struct card_info {
  57. const char *card_name;
  58. int (*set_mode)(struct mode_info *mode);
  59. int (*probe)(void);
  60. struct mode_info *modes;
  61. int nmodes; /* Number of probed modes so far */
  62. int unsafe; /* Probing is unsafe, only do after "scan" */
  63. u16 xmode_first; /* Unprobed modes to try to call anyway */
  64. u16 xmode_n; /* Size of unprobed mode range */
  65. };
  66. #define __videocard struct card_info __section(".videocards") __attribute__((used))
  67. extern struct card_info video_cards[], video_cards_end[];
  68. int mode_defined(u16 mode); /* video.c */
  69. /* Basic video information */
  70. #define ADAPTER_CGA 0 /* CGA/MDA/HGC */
  71. #define ADAPTER_EGA 1
  72. #define ADAPTER_VGA 2
  73. extern int adapter;
  74. extern int force_x, force_y; /* Don't query the BIOS for cols/rows */
  75. extern int do_restore; /* Restore screen contents */
  76. extern int graphic_mode; /* Graphics mode with linear frame buffer */
  77. /* Accessing VGA indexed registers */
  78. static inline u8 in_idx(u16 port, u8 index)
  79. {
  80. outb(index, port);
  81. return inb(port+1);
  82. }
  83. static inline void out_idx(u8 v, u16 port, u8 index)
  84. {
  85. outw(index+(v << 8), port);
  86. }
  87. /* Writes a value to an indexed port and then reads the port again */
  88. static inline u8 tst_idx(u8 v, u16 port, u8 index)
  89. {
  90. out_idx(port, index, v);
  91. return in_idx(port, index);
  92. }
  93. /* Get the I/O port of the VGA CRTC */
  94. u16 vga_crtc(void); /* video-vga.c */
  95. #endif /* BOOT_VIDEO_H */