Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* -*- linux-c -*- ------------------------------------------------------- *
0003  *
0004  *   Copyright (C) 1991, 1992 Linus Torvalds
0005  *   Copyright 2007 rPath, Inc. - All Rights Reserved
0006  *
0007  * ----------------------------------------------------------------------- */
0008 
0009 /*
0010  * Header file for the real-mode video probing code
0011  */
0012 
0013 #ifndef BOOT_VIDEO_H
0014 #define BOOT_VIDEO_H
0015 
0016 #include <linux/types.h>
0017 
0018 /*
0019  * This code uses an extended set of video mode numbers. These include:
0020  * Aliases for standard modes
0021  *      NORMAL_VGA (-1)
0022  *      EXTENDED_VGA (-2)
0023  *      ASK_VGA (-3)
0024  * Video modes numbered by menu position -- NOT RECOMMENDED because of lack
0025  * of compatibility when extending the table. These are between 0x00 and 0xff.
0026  */
0027 #define VIDEO_FIRST_MENU 0x0000
0028 
0029 /* Standard BIOS video modes (BIOS number + 0x0100) */
0030 #define VIDEO_FIRST_BIOS 0x0100
0031 
0032 /* VESA BIOS video modes (VESA number + 0x0200) */
0033 #define VIDEO_FIRST_VESA 0x0200
0034 
0035 /* Video7 special modes (BIOS number + 0x0900) */
0036 #define VIDEO_FIRST_V7 0x0900
0037 
0038 /* Special video modes */
0039 #define VIDEO_FIRST_SPECIAL 0x0f00
0040 #define VIDEO_80x25 0x0f00
0041 #define VIDEO_8POINT 0x0f01
0042 #define VIDEO_80x43 0x0f02
0043 #define VIDEO_80x28 0x0f03
0044 #define VIDEO_CURRENT_MODE 0x0f04
0045 #define VIDEO_80x30 0x0f05
0046 #define VIDEO_80x34 0x0f06
0047 #define VIDEO_80x60 0x0f07
0048 #define VIDEO_GFX_HACK 0x0f08
0049 #define VIDEO_LAST_SPECIAL 0x0f09
0050 
0051 /* Video modes given by resolution */
0052 #define VIDEO_FIRST_RESOLUTION 0x1000
0053 
0054 /* The "recalculate timings" flag */
0055 #define VIDEO_RECALC 0x8000
0056 
0057 void store_screen(void);
0058 #define DO_STORE() store_screen()
0059 
0060 /*
0061  * Mode table structures
0062  */
0063 
0064 struct mode_info {
0065     u16 mode;       /* Mode number (vga= style) */
0066     u16 x, y;       /* Width, height */
0067     u16 depth;      /* Bits per pixel, 0 for text mode */
0068 };
0069 
0070 struct card_info {
0071     const char *card_name;
0072     int (*set_mode)(struct mode_info *mode);
0073     int (*probe)(void);
0074     struct mode_info *modes;
0075     int nmodes;     /* Number of probed modes so far */
0076     int unsafe;     /* Probing is unsafe, only do after "scan" */
0077     u16 xmode_first;    /* Unprobed modes to try to call anyway */
0078     u16 xmode_n;        /* Size of unprobed mode range */
0079 };
0080 
0081 #define __videocard struct card_info __section(".videocards") __attribute__((used))
0082 extern struct card_info video_cards[], video_cards_end[];
0083 
0084 int mode_defined(u16 mode); /* video.c */
0085 
0086 /* Basic video information */
0087 #define ADAPTER_CGA 0   /* CGA/MDA/HGC */
0088 #define ADAPTER_EGA 1
0089 #define ADAPTER_VGA 2
0090 
0091 extern int adapter;
0092 extern int force_x, force_y;    /* Don't query the BIOS for cols/rows */
0093 extern int do_restore;      /* Restore screen contents */
0094 extern int graphic_mode;    /* Graphics mode with linear frame buffer */
0095 
0096 /* Accessing VGA indexed registers */
0097 static inline u8 in_idx(u16 port, u8 index)
0098 {
0099     outb(index, port);
0100     return inb(port+1);
0101 }
0102 
0103 static inline void out_idx(u8 v, u16 port, u8 index)
0104 {
0105     outw(index+(v << 8), port);
0106 }
0107 
0108 /* Writes a value to an indexed port and then reads the port again */
0109 static inline u8 tst_idx(u8 v, u16 port, u8 index)
0110 {
0111     out_idx(port, index, v);
0112     return in_idx(port, index);
0113 }
0114 
0115 /* Get the I/O port of the VGA CRTC */
0116 u16 vga_crtc(void);     /* video-vga.c */
0117 
0118 #endif /* BOOT_VIDEO_H */