video.h 3.2 KB

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