/* Copyright 1996 Acorn Computers Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* modex.h */ /* * Internal definitions used by ScreenModes module. */ #ifndef DODEBUG #define DODEBUG 0 #endif #if DODEBUG #define IFDEBUG if (!1) {} else #else #define IFDEBUG if (1) {} else #endif /* When defined, we can derive monitor definitions from the * DMT set using the 3-byte lookup table. */ #define DERIVE_CVT3_FROM_DMT /* When defined, set the value to force a particular timing * calculation type from the available set. */ #undef FORCE_TIMINGS /* eg. EDID_USE_CVTRB */ /* When defined, force calculated values (ie. don't prefer DMT) */ #undef FORCE_CALCULATED_VALUES /* HSync & VSync polarities for use by display_monitor_timings */ #define HSync_Positive 0 #define HSync_Negative SyncPol_InvertHSync #define VSync_Positive 0 #define VSync_Negative SyncPol_InvertVSync #define PP HSync_Positive+VSync_Positive #define PN HSync_Positive+VSync_Negative #define NP HSync_Negative+VSync_Positive #define NN HSync_Negative+VSync_Negative /* Defines which is the most advanced timing calculation available * We use DMT if defined for that mode and calculate using the timing * If not. If USE_DMT is highest it is DMT or nothing. */ #define EDID_USE_DMT (0) /* Display monitor timings */ #define EDID_USE_GTF (1) /* Generalised timing formula */ #define EDID_USE_GTF2 (2) #define EDID_USE_CVT (3) /* Coordinated video timings from VESA */ #define EDID_USE_CVTRB (4) /* CVT with reduced blanking */ /* * The 6 field framing parameters for each direction, horizontal and * vertical. In horizontal case, the parameters are measured in VIDC * pixel times; for vertical, VIDC raster times. */ #define FR_SYNC 0 /* sync pulse width */ #define FR_BPCH 1 /* back porch */ #define FR_BDR1 2 /* top (V) / left (H) border height/width */ #define FR_DISP 3 /* active data display height/width */ #define FR_BDR2 4 /* bottom (V) / right (H) border height/width */ #define FR_FPCH 5 /* front porch */ #define FR__COUNT 6 /* how many parameters altogether */ /* * The video control list parameter index for indicating DPMS state */ /**Added by WT 13-1-95 for Stork **/ #define LCDMODE_INDEX 01 #define LCDMODE_VALUE 1 /*Enable*/ #define LCDDUAL_INDEX 02 #define LCDDUAL_VALUE 1 /*Enable*/ #define LCDOFF0_INDEX 03 #define LCDOFF0_VALUE 6 /*Defining a 640x480 dual-panel LCD as used in Stork*/ #define LCDOFF1_INDEX 04 #define LCDOFF1_VALUE 129 /*Defining a 640x480 dual-panel LCD as used in Stork*/ #define DACCTRL_INDEX 06 #define DACCTRL_VALUE 1 /*Enable - testing only*/ /**End of additions**/ #define HCLK_INDEX 9 #define DPMS_INDEX 11 #define INTERLACED_INDEX 12 #define OPFORMAT_INDEX 13 #define NCOLOUR_INDEX 15 #define MODEFLAGS_INDEX 16 /* Pixel format representation used by GraphicsV */ typedef struct { int32_t ncolour; /* NColour mode variable */ uint32_t modeflags; /* relevant ModeFlags */ uint32_t log2bpp; /* Log2BPP mode variable */ } PixelFormat, *PixelFormatRef; /* Two-word structure in a mode selector or VIDC list */ typedef struct { int32_t index; /* -1 as index is invalid & marks end of list */ int32_t value; } ModeParam; typedef struct { uint32_t bit0:1, format:7, flags:24; uint32_t xresol; uint32_t yresol; uint32_t depth; /* as log2(bpp) */ int32_t framerate; /* in integer Hz */ ModeParam param[1]; /* minimum case + 1 word: may be 0 params + 1 term */ } ModeSelector, *ModeSelectorRef; /* VIDC list as filled in when handling Service_ModeExtension */ typedef struct { uint32_t format; /* type 3 for Medusa */ uint32_t depth; /* log code, 0=1bpp to 5=32bpp */ uint32_t hpar[FR__COUNT]; /* horizontal parameters */ uint32_t vpar[FR__COUNT]; /* vertical parameters */ uint32_t pixelrate; /* pixel rate measured in kHz */ uint32_t syncpol; /* sync polarity code, 0..3 */ ModeParam vcparam[12]; /* Holds VCparameters: LCD mode, LCD dual-panel, LCD offsets(2), DAC control, -1 * with optional NColour, ModeFlags, DPMS, HCLK Interlaced and/or output_format fields */ } VIDCList, *VIDCListRef; /* Mode information block as filled in when handling Service_EnumerateScreenModes */ typedef struct { uint32_t blocksize; /* size of this block in bytes */ uint32_t bit0:1, format:7, flags:24; /* format == 0 */ uint32_t xresol; /* user-pixels */ uint32_t yresol; /* user-lines */ uint32_t depth; /* as log2(bpp) */ uint32_t framerate; /* to nearest whole Hz value */ char name[1]; /* name starts here (dummy size for struct def) */ } ModeInfoBlock, *ModeInfoBlockRef; /* New format block for specifying new pixel formats */ typedef struct { uint32_t blocksize; /* size of this block in bytes */ uint32_t bit0:1, format:7, flags:24; /* format == 1 */ uint32_t xresol; /* user-pixels */ uint32_t yresol; /* user-lines */ PixelFormat pixelformat; /* pixel format */ uint32_t framerate; /* to nearest whole Hz value */ char name[1]; /* name starts here (dummy size for struct def) */ } ModeInfoBlock1, *ModeInfoBlock1Ref; #define IS_MODE_NUMBER(p) ((uint32_t)(p) < 256) #define IS_MODE_SEL_PTR(p) (!IS_MODE_NUMBER(p)) #define UNUSED(k) ((k)=(k)) #define MODESEL(p) ((ModeSelectorRef)(p)) #define MAX(a,b) (((a)<(b))?(b):(a)) #define MIN(a,b) (((a)>(b))?(b):(a)) /* * Monitor & modes description as loaded from ModeInfo file: note, * this does not include pixel depth. */ #define MAXMONITORNAME 31 /* arbitrary, but careful not to overrun Display Manager title bar */ #define MAXMODENAME 31 /* arbitrary, but careful not to clip Display Manager menu width */ typedef struct { uint32_t xres; /* User quoted xres (may differ from hpar[FR_DISP], especially in interlaced modes) */ uint32_t yres; /* User quoted yres (may differ from vpar[FR_DISP], ... */ uint16_t hpar[FR__COUNT]; /* H. framing in pixel times */ uint16_t vpar[FR__COUNT]; /* V. framing in raster times */ uint32_t pixel_khz; /* pixel rate in kHz */ uint32_t external_clock; /* rate of external clock in kHz (use it instead of VCO), or -1 */ uint8_t syncpol; /* sync polarity code (0..3 for now) */ uint8_t interlaced; /* whether mode is interlaced using two seperate framebuffers (0 or 1) */ uint8_t freq, spare2; /* explicit padding so struct is N*4 bytes long */ } ModeDef; /* Abbreviated form, without the name */ typedef struct { char name[MAXMODENAME+1]; ModeDef timings; } ModeDefinition; /* As stored internally by ScreenModes module */ typedef struct mode_description_ { struct mode_description_ *next; /* in list built during file parsing */ ModeDefinition definition; /* as extracted from the file */ /* The following are computed once the mode definition is read in from the file */ uint32_t line_hz; /* line rate in Hz (for diagnostics only) */ uint32_t frame_hz:8; /* frame rate in Hz, for user frame rate selection */ uint32_t frame_mhz:24; /* also in mHz (millihertz), for more precise cmp */ uint8_t priority; /* Bits 0-2 = 'Parameter type' from? (EDID 1.4 Section 5) */ /* 0 = Undefined (MDF or something which overrides all else) */ /* 1 = Preferred Timing Mode from base EDID */ /* 2 = Detailed Timing Mode in the base EDID */ /* 3 = Any detailed timing modes in extension blocks */ /* 4 = Any optional 3-byte CVT codes in the base EDID or extension block */ /* 5 = Standard Timings listed in base EDID or extension blocks */ /* 6 = Additional timing mode information: Established Timings I, II, III, */ /* default GTF, GTF secondary curve and CVT */ /* 7 = Base VIDEO MODE (defined as 640 x 480 x 60Hz). */ } ModeDescription, *ModeDescriptionRef; /* Audio format information extracted from EDID */ typedef struct { uint8_t format_code; /* As per CEA 861-D */ uint8_t max_channels; uint8_t sample_rates; /* Byte #2 of short audio descriptor */ uint8_t format_specific; /* Byte #3 of short audio descriptor */ } AudioFormat; /* Description of a monitor & its associated modes */ typedef struct { char name[MAXMONITORNAME+1]; ModeDescriptionRef modelist; uint32_t dpms_state; /* value specified by DPMS_state keyword, or 0 if none */ uint32_t lcd_support; /* 0=>modefile is CRT, 1=>LCD single-panel, 2=>LCD dual panel [WT13-01-95] */ uint32_t external_clock; /* rate of external clock in kHz (use it instead of VCO) */ uint32_t output_format; /* 0=analogue, 1=digital */ AudioFormat *audio_formats; /* (Optional) list of supported audio formats */ int audio_format_count; /* Length of list */ uint8_t speaker_mask; /* (Optional) speaker mask (as per CEA 861-D) */ bool speaker_mask_provided; } MonitorDescription, *MonitorDescriptionRef; /* Maps a 2-byte 'STD code' to a DMT (STD codes defined in EDID spec) */ typedef struct { char stdcode[2]; /* TODO: comment required here */ char dmt; /* TODO: comment required here */ } STDTiming; /* Maps a 3-byte 'CVT code' to a DMT (CVT codes defined in EDID spec) */ typedef struct { char cvtcode[3]; /* TODO: comment required here */ char dmt; /* TODO: comment required here */ } CVTTiming; /* Extern variables and functions */ extern ModeSelectorRef preferred_mode; extern MonitorDescriptionRef current_monitor; extern bool EDIDEnabled; extern int old_monitortype; extern int preferred_sync_type; _kernel_oserror *error(int, const char *, const char *, const char *); void release_currentmonitor(void); void free_monitordescription(MonitorDescriptionRef); void compute_modedescription(ModeDescriptionRef); void sort_modelist(ModeDescriptionRef *); _kernel_oserror *set_monitortype(int); int read_monitortype(void); _kernel_oserror *restore_monitortype(void); /* EOF modex.h */