/* SPDX-License-Identifier: GPL-2.0-only */1/* -*- linux-c -*- ------------------------------------------------------- *2*3* Copyright (C) 1991, 1992 Linus Torvalds4* Copyright 2007 rPath, Inc. - All Rights Reserved5*6* ----------------------------------------------------------------------- */78/*9* Header file for the real-mode video probing code10*/1112#ifndef BOOT_VIDEO_H13#define BOOT_VIDEO_H1415#include <linux/types.h>1617/*18* This code uses an extended set of video mode numbers. These include:19* Aliases for standard modes20* NORMAL_VGA (-1)21* EXTENDED_VGA (-2)22* ASK_VGA (-3)23* Video modes numbered by menu position -- NOT RECOMMENDED because of lack24* of compatibility when extending the table. These are between 0x00 and 0xff.25*/26#define VIDEO_FIRST_MENU 0x00002728/* Standard BIOS video modes (BIOS number + 0x0100) */29#define VIDEO_FIRST_BIOS 0x01003031/* VESA BIOS video modes (VESA number + 0x0200) */32#define VIDEO_FIRST_VESA 0x02003334/* Video7 special modes (BIOS number + 0x0900) */35#define VIDEO_FIRST_V7 0x09003637/* Special video modes */38#define VIDEO_FIRST_SPECIAL 0x0f0039#define VIDEO_80x25 0x0f0040#define VIDEO_8POINT 0x0f0141#define VIDEO_80x43 0x0f0242#define VIDEO_80x28 0x0f0343#define VIDEO_CURRENT_MODE 0x0f0444#define VIDEO_80x30 0x0f0545#define VIDEO_80x34 0x0f0646#define VIDEO_80x60 0x0f0747#define VIDEO_GFX_HACK 0x0f0848#define VIDEO_LAST_SPECIAL 0x0f094950/* Video modes given by resolution */51#define VIDEO_FIRST_RESOLUTION 0x10005253/* The "recalculate timings" flag */54#define VIDEO_RECALC 0x80005556void store_screen(void);57#define DO_STORE() store_screen()5859/*60* Mode table structures61*/6263struct mode_info {64u16 mode; /* Mode number (vga= style) */65u16 x, y; /* Width, height */66u16 depth; /* Bits per pixel, 0 for text mode */67};6869struct card_info {70const char *card_name;71int (*set_mode)(struct mode_info *mode);72int (*probe)(void);73struct mode_info *modes;74int nmodes; /* Number of probed modes so far */75int unsafe; /* Probing is unsafe, only do after "scan" */76u16 xmode_first; /* Unprobed modes to try to call anyway */77u16 xmode_n; /* Size of unprobed mode range */78};7980#define __videocard struct card_info __section(".videocards") __attribute__((used))81extern struct card_info video_cards[], video_cards_end[];8283int mode_defined(u16 mode); /* video.c */8485/* Basic video information */86#define ADAPTER_CGA 0 /* CGA/MDA/HGC */87#define ADAPTER_EGA 188#define ADAPTER_VGA 28990extern int adapter;91extern int force_x, force_y; /* Don't query the BIOS for cols/rows */92extern int do_restore; /* Restore screen contents */93extern int graphic_mode; /* Graphics mode with linear frame buffer */9495/* Accessing VGA indexed registers */96static inline u8 in_idx(u16 port, u8 index)97{98outb(index, port);99return inb(port+1);100}101102static inline void out_idx(u8 v, u16 port, u8 index)103{104outw(index+(v << 8), port);105}106107/* Writes a value to an indexed port and then reads the port again */108static inline u8 tst_idx(u8 v, u16 port, u8 index)109{110out_idx(port, index, v);111return in_idx(port, index);112}113114/* Get the I/O port of the VGA CRTC */115u16 vga_crtc(void); /* video-vga.c */116117#endif /* BOOT_VIDEO_H */118119120