1 PC Peripherals for Technicians PC Peripherals for Technicians Chapter Video Graphics Mode Operation Chapter Video Graphics Mode Operation Systems Manufacturing Training and Employee Development Copyright © 1998 Intel Corp.
2 Graphics Mode Operation Overview OBJECTIVES: At the end of this section, the student will be able to do the following: l Discuss Graphics Modes & Video Buffer data format. l List the characteristics of VGA Mode 12 hex. l Discuss Graphics Mode memory organization, Graphics Mode color generation, & character fonts. l Discuss 256 Color Graphics Mode 13 hex. l Describe Super VGA, VESA, & display memory pages. l Discuss the initialization of the Video Subsystem. l Discuss video troubleshooting techniques.
3 Video Display Modes l This chapter is an OVERVIEW on the operation of a Video Controller in GRAPHICS MODES. l Video subsystems operate in multiple display modes. Each display mode controls certain aspects of the video subsystem operation: » Graphics or Text: > Graphics modes are bit-mapped (All Points Addressable) > Text modes display alphanumeric characters only. » Screen Resolution: # of pixels vertically & horizontally. > Often stated with a third number which refers to the color depth. (e.g. 800x600x256 where 256 implies 256 colors) » Number of colors available: Typically 16 to 256. > 16 million colors available for some Super VGA modes.
4 Video Display Modes l Graphics modes are used to display special symbols or images that are not part of the predefined character sets in Text mode. Mathematical symbols, special characters, images, filling areas of screen with colors, etc. l Modes 12h and 13h will be examined in this discussion of graphics modes. Mode 12 hex is a 640 x color mode Mode 13 hex is a 320 x color mode Note: Many other graphics modes are available and discussion of the various memory mapping schemes, register use, and programming techniques is beyond the scope of this course.
5 Modes supported BIOS (Partial list) CGA EGA VGA CGA EGA VGA CGA MDA VGA EGA EGA EGA EGA VGA VGA VGA Text Graphics Text Graphics ModeEmul.Res.Type Max Colors Scheme Char. Box Max. Pages Buff. Start 0,1 2,3 2,3! 4, ! D E F x x x x x x x x x x x x x x x200 Text /256k 4/256k 2/256k MDA Mono VGA Mono 16/256k Mono 16/356k 2/256k 16/256k 256/256k 40x25 80x25 40x25 80x25 40x25 80x25 80x30 40x25 8x8 8x14 9x16 8x8 8x14 9x16 8x8 9x14 9x16 8x8 8x14 8x16 8x8 B8000h B0000h A0000h ! - Indicates power-on default mode 3! - Color monitor is attached 7! - Monochrome monitor is attached
6 Video Data Format - Graphics Mode l In Graphics mode the data stored in video RAM is NOT interpreted as a character code & attribute, but instead directly determines pixel intensity & color. In Graphics mode the microprocessor addresses the display buffer as a series of bits and writes the individual color value of each pixel to be painted on the screen. » Programmers build screens by describing each dot individually - All Points Addressable (APA). l Graphics modes require more memory than text modes because each pixel can be described by one or more bits depending on the video mode. Text modes consume less memory, but you can only manipulate characters.
7 Video Data Format - Graphics Mode l In 640 x 350, 16 color graphics mode 10h with 4 bits per pixel, you need 896,000 bits (640 x 350 x 4) or 112K bytes to represent one screen of information (80 x 25 display using an 8 x 14 character box) In Text Mode 03h with the same 80 x 25 character resolution, you need only 4K bytes (80 x 25 x 2) » 2 bytes per character (Character Code & Attribute) l Note that there is a performance penalty for using graphics modes because of the larger number of bytes that must be manipulated. A program that manipulates 112K bytes in Graphics Mode is much more complex than a program that manipulates 4000 bytes in Text Mode.
8 Characteristics of VGA Mode 12h Video A0000 Resolution = 640 pixels x 480 lines displayed Character size = 8 pixels x 16 pixels (Default VGA font) 80 Characters/line; 30 lines frame (screen) > 80 char/line -> (640 pixels/line) / (8 pixels/char) > 30 char/frame -> (480 lines/frame) / (16 lines/char) 38.4K bytes/page of Memory used (4 pages total) » 38.4K bytes/page = (640 x 480 pixels/page) / (8 pixels/byte) Horizontal Freq. = 31.5 KHz (lines per second) Vertical Freq = 60 Hz (frames per second) Dot Clock = MHz (25,175,000 dots per second) » MHz / 31.5 KHz = 800 dots/line Number of colors = 16 (Pixels stored in 4 color planes)
9 Characteristics of VGA Mode 12h Note: The timing values stored in registers are measured in “Character Clocks”! 1 Character Clock corresponds to 8 pixels in Mode 12 Displayed Video Buffer area Line 0 Line 480 Overscan character Overscan Horiz. Sync clk 84 lasts for 12 Char. clocks 8 x (80 col) = 640 Vert. Sync Line 503 lasts for 2 Scan Lines Character Matrix is 8x16 in Mode 12H 8 x (80 chars) = x (30 rows) = 480 Line 524 Line
10 Mode 12h Memory Organization l In Graphics Mode 12h, the video buffer is a set of four parallel bit planes (one for each color), each of which shares the same addresses starting at A000:0000. Only 1 map in Display Memory can be accessed at a time by the CPU since they all share the same address. » Video Controller registers must be modified by the programmer before accessing an individual bit plane. l You need 38,400 bytes/page in Graphics Mode 12h (640 x 480, 16 color) with 1 bit per pixel, [(640 x 480 pixels) / 8 pixels/byte] = 38,400 bytes/page l 4 pages are needed to generate 16 colors (2 4 =16) 38,400 bytes/page x 4 pages = KB
11 Mode 12h Memory Organization 640 x 480 = 307,200 pixels 38, 400 bytes = (307,200 pixels) / (8 pixels/byte) Color bit 0 Color bit 1 Color bit 2 Color bit 3 A0000 A95FF A9600 AFFFF Display Data Unused 38,400 Bytes Map 0 Map 1 Map 2 Map 3 Bit address 27,135 Bytes Color bit 2 Color bit 1 Color bit 0
12 Graphics Mode Color Generation Pixels are represented by the set of corresponding bits at the same address in each of the bit planes. VGA Video RAM Each pixel is one color or another, there is no foreground or background color. Bit address Color bit 0 Color bit 1 Color bit 2 Color bit 3 38,400 Bytes Map 0 - Blue Map 1 - Green Map 2 - Red Map 3- Intensity 27,135 Bytes Color bit 2 Color bit 1 Color bit 0 Screen
13 Graphics Mode Color Generation l Pixels are represented by the set of corresponding bits at the same address in each of the bit planes. The data in the bit planes is sent to the Attribute controller and generates colors in the same fashion as in text mode. Text and graphics modes use the same colors and intensity options. l In Mode 12h with 4 bits/pixel, the four planes are combined to produce a color for an individual pixel. With four bit planes, a pixel can have any of 16 (2 4 ) different values (16 different colors at the same time). A color is produced by a combination of 3 color components (RGB) plus an intensity component.
14 Graphics Mode Color Generation l Pixel attributes are not always 4 bits in size, but can range from 1 to 8 bits depending on the video mode. Mode 12h bit fields are 4 bits wide. » e.g. - Mode 12: 640 x 480, 16 color mode (2 4 =16) The smallest bit fields are only 1 bit wide. » e.g. - Mode 6: 640 x200, 2 color mode (2 1 = 2) The largest bit fields are 8 bits wide. » e.g. - Mode 13: 320 x 200, 256 color mode (2 8 = 256) l Note: The Palette Registers and the DAC are loaded by the BIOS during POST with default values for the 16 color modes.
15 Graphics Mode Color Generation The following table shows the relationship between the Attribute nibble value, the Palette Register value, and the color displayed. Attribute Nibble 8 9 A B C D E F Palette Value A 3B 3C 3D 3E 3F Default Color Dark Gray/Dim White (r+g+b) Light Blue (r+g+b+B) Light Green (r+g+b+G) Light Cyan (r+g+b+G+B) Light Red (r+g+b+R) Light Magenta (r+g+b+R+B) Yellow (r+g+b+R+G) Intensified White (r+g+b +R+G+B) Attribute Nibble Palette Value Default Color Black Blue (B) Green (G) Cyan (G+B) Red (R) Magenta (R+B) Brown (g+R) White (R+G+B) This chart is same as the Text Mode charts in previous chapter.
16 Graphics Mode Color Generation VGA uses analog signal levels to drive the monitor, and the 6 bits in the Palette Registers are inputs to the Video DAC. The 6-bit Palette Register output combined with 2 bits from a Color Select register to form an 8-bit value passed to the DAC. 4-bit Attribute (1 of 16 Registers) 6-bits (bits 0-5) r,g,b,R,G,B (1 of 64 Registers) 8-bits (1 of 256 Registers) [4 banks of 64 colors] bits 6 & 7 Attr Ctlr Palette Registers 3C0, 3C1 Offsets 00-0Fh Attribute Controller Color Select Register Ports 3C0, 3C1 Offset 14 - Bits 3 & 2 (1 of 4 banks) VIDEO DAC 3C7, 3C8, 3C9 Offsets 00-FFh [Note: 00-3Fh w/ 6 bits] R G B To Monitor Analog Output V Attribute Mode Control Reg Ports 3C0, 3C1 Offset 10 - Bits 7 = 0 (Palette Size Select - 16 color 4 banks of 64 entries)
17 Fonts in Graphics Modes l In Graphics modes, the character set is NOT loaded into the VGA display memory, but resides in host memory space (either the BIOS ROM or in RAM). Graphics modes cannot load the character sets into VGA memory bit plane 2 (as is done in text modes), because bit planes 0-3 store the graphics information » Note: In Text mode Bit plane 0 stored the characters, Bit plane 1 the attributes, and Bit plane 2 the character fonts. l The BIOS provides service through INT 10 and uses the address of a ROM-based character pattern. You can also place a custom bit pattern table in RAM and instruct the BIOS to use it to display your own (downloadable) character set.
18 Character Box - Pixel pattern for “a” 8 X 16 VGA graphics-mode character box (VGA Graphics Video Mode 12h) (480 lines/screen) / (16 lines/char) = 30 char lines /screen (640 pixels / line) / (8 pixels/char) = 80 char/line ROM contains a default table of character pattern bits (typically in the 8x6 to 9x16 range). Bit Pattern of font as stored in memory = Foreground color = Background color Data = 78h b C 7C CC (10h) bytes are reserved for each of the characters.
19 Fonts in Graphics Modes l When you set a graphics modes with INT 10 function 0, the Video BIOS loads a pointer to the appropriate character set into interrupt vector 43h (0000:010C). The location of a character in host memory is determined by locating the starting address of the character set (using the IVT 43h entry) & adding the offset [“a” = 61h]. » Char Addr = Char Set Pointer + Offset to Character » C000:72E0h = C000:6CD0h + (10h * 61h) l In graphics mode, characters are drawn pixel by pixel using software (e.g. BIOS INT 10h) instead of by the hardware character generator used in text modes. Graphics mode fonts are copied from ROM or RAM (pointed to by IVT 43h) to the video buffer (e.g. A000:0)
Color Graphics Mode 13h l Mode 13h has 256 colors with a resolution of 320x200. Every pixel is represented by 8 bits of data and a screen line consists of 320 contiguous bytes in video RAM. » This byte represents the color as a value from 0 to 255. » This byte acts as a direct index to the DAC color table, from which the actual color representing the pixel on the screen is taken. The DAC is equipped with 256 color registers (8 address bits are required to use all 256 colors). » Each DAC color register is composed of Red, Green, & Blue components each 6 bits wide (00-3fh) - 18 bits total. > 18 bits provide up to 256K (2 18 =262,144) possible colors. > Only 256 colors are available at any one time.
Color Graphics Mode 13h Video A0000 Resolution = 320 pixels x 200 lines displayed Character size = 8 pixels x 8 pixels 40 Characters/line; 25 lines frame (screen) > 40 char/line -> (320 pixels/line) / (8 pixels/char) > 25 char/frame -> (200 lines/frame) / (8 lines/char) 64,000 bytes of Memory used » 64K bytes = (320 x 200 x 8 pixels) / (8 pixels/byte) Horizontal Freq. = 31.5 KHz (lines per second) Vertical Freq = 70 Hz (frames per second) Dot Clock = 12.5 MHz (12,500,000 dots per second) » 12.5 MHz / 31.5 KHz = 400 dots/line Number of colors = 256 (Pixels stored in 8 color planes)
Color Graphics Mode 13h Display Data Unused A0000 AF9FF AFA00 AFFFF 64,000 Bytes 1535 Bytes 320 x 200 = 64,000 pixels 64,000 bytes = (64,000 pixels) *(1 byte/pixel) VGA 256 Color Graphics Mode Every pixel in Mode 13h is represented by 8 bits of data. This byte represents the color as a value from 0 to 255. Note: VGA Mode 03h; 720 x 400; 4K of Memory used
Color Graphics Mode 13h Palette Register Addressing in 256 color mode The 8 bits in display memory are split into two 4-bit fields. Bits (0-3) address the Palette Registers; Bits(4-7) address the DAC. The Palette Regs provide a one-to-one transfer of data. The 8-bits in Video Memory effectively directly control the DAC. Video Memory Palette Regs 256 DAC Color Regs Addr 0-3 Addr 4-7 Simplified drawing of 256 Color Generation
24 l In Mode 13h, the Palette Register is loaded with the following default values: l The 8 bits in Video RAM are split into two 4-bit fields. The low-order bits (0-3) address the Palette Registers. » The Palette Registers are restricted to providing a one-to- one transfer of address to data. > This effectively bypasses the Palette Registers and sends the color value of the lower 4 bits directly to the DAC. The high-order bits (4-7) address the DAC Color Regs. 256 Color Graphics Mode 13h
25 Initialization of DAC 256 Color Regs F8-FFhPreload with 0, for black. 20-F7h24 color groups, 9 shades of color h16 evenly spaced shades of gray. 00-0FhIdentical to 16 EGA colors loaded into Palette Regs. F8-FFh <- F7H B0H-> <- AFH 68H-> <- 67H 20 -> 10-1Fh 00-0Fh Black RGB-Low Int. RGB-Med Int. RGB-High Int. Gray Scales EGA Color 24-High Sat. 24-Mid Sat. 24-Low Sat. 24-High Sat. 24-Mid Sat. 24-Low Sat. 24-High Sat. 24-Mid Sat. 24-Low Sat. 8 Black 16 Gray 16 Colors
26 Super VGA, VESA & Beyond Current video controllers exceed the 1987 VGA standard. » Super VGA (SVGA), Extended VGA, and Advanced VGA are informal terms for anything better than VGA. With no “super” standards to go by designers have developed their own specific implementations. » Most programs treat SVGA just like VGA because no standards have been developed to test for SVGA. » Most hardware remains compatible with the VGA register interface and video memory addressing. Standard VGASuper VGA 640 X X K Memory4M bytes Memory 6-bit color DAC8,16,24-bit color DAC 8-bit ISA bus16-bit ISA, VL, & PCI
27 Super VGA, VESA & Beyond l The Video Electronics Standards Association, a consortium of 140+ graphics card and video monitor manufactures, made an after-the-fact attempt (1989) to create a set of standards. VESA introduced a standard for an extension to the original IBM VGA BIOS that supports SVGA hardware called the VESA BIOS Extensions (VBE) using INT 10 function 4Fh (i.e.-Use INT 10 with AH set for 4F.) » VESA BIOS Extensions (VBE) provide a standard method for accessing additional SVGA functionality Unlike the standard video BIOS routines which use an 8- bit mode #, the VESA routines use a 16-bit mode #. » Numbers begin at 100h--e.g., Mode 107h (1280x1024x256)
28 5E 5F 58 6A 5C 5D 60 6C 6D Graphics TEXT Graphics VESA Mode Res.Type Max Colors Char. x Row Char. Box F B 640x x X X x x x x X X x1024 Graphics 256/256k 16/256k 256/256k 16/256k 256/256k 16/256k 256/256k 16/256k 16.8 M 32k 16.8 M 32k 16.8 M 32k 16.8 M 80x25 80x30 100x37 128x48 160x64 132x x16 8x Super VGA, VESA & Beyond In addition to the “standard” modes, a number of higher-resolution video modes available on SVGA hardware has been standardized by VESA. SVGA Modes (Partial list)
29 Super VGA, VESA & Beyond l Graphics accelerators A special type of video adapter that contains its own specialized coprocessor which is capable of specific graphics operation to boost performance levels. » Some accelerator cards include functions for 3D graphics rendering and/or on-the-fly magnification of video clips. » Accelerators require drivers to interpret video commands. l Accelerated Graphics Port (AGP) A new interface specification based on PCI, but designed especially for the throughput demands of 3-D graphics. » AGP shares the main PC memory to hold 3D images which in effect gives AGP an unlimited amount of video memory. » AGP adds a dedicated high-speed bus directly between the chipset and the graphics controller.
30 Accessing Display Memory Pages A PC reserves only 64KB of address space for the video buffer (Graphics Mode: A000:0 -> A000:FFFF) Many of the high resolution Graphics Modes require more than 64-KB of memory. » For VESA mode 101h (640 x 480 x 256) 307,200 bytes of memory are required (64 KB * 4 = 262,144 bytes) » Can address this memory by selecting which portion to map into the 64-KB CPU address range of A000:0->A000:FFFF. > Can be thought of as a hardware window into the video buffer. The following is an example of accessing more than 64 KB of the video buffer in Mode 101h using the ITP to set the Video Mode and write to the Video Buffer. » A proc like “setvidpg” uses VESA BIOS INT 10h, Function 4F, Sub-function 05 to select a display memory page.
31 Accessing > 64 KB of the video buffer 1) Set Video Mode to 101 hex [e.g. vesamode (101)] 2) Fill 64 KB of memory with some pattern: » e.g. byte 0a0000p length 0ffff = 01 > Fills Page Zero with BLUE > Top ~ 1/5th of screen is BLUE (1st 64K of 307,200 bytes) 3) Select another Video Memory Window » Select page 1 [e.g. ITP proc “setvidpg (1)”] 4) Fill the next 64 KB of memory with some other pattern: » e.g. byte 0a0000p length 0ffff = 02 (Fill page 1 with GREEN) 5) Continue until last 5th of screen is filled (Page 4) » e.g Select page 4 [e.g. ITP proc “setvidpg (4)”] » e.g. byte 0a0000p length 0ffff = 04 > Fills page 4 with RED (Bottom ~ 1/5th of screen is RED)
32 Initializing the Video Subsystem Upon power up or reset, access to internal registers and memory is not allowed until the Video Subsystem has been enabled. » Usually accomplished by the BIOS during POST, but can use ITP commands (Required if POST didn’t initialize) The following registers enable the Video Subsystem depending on configuration (ISA, PCI, MCA, etc.). » Port CF8 Offset 4 - PCI Configuration » Port 3C3 - Video Subsystem Enable (on system board) » Port Card Enable (PC/AT adapter based cards) » Port 46E8 - Setup / Adapter Enable (PC/AT adapter) » Once enabled, a write to the Misc. Output Register at port 3C2 enables access to Video Controller I/O & memory.
33 Initializing the Video Subsystem l This is a typical initialization sequence for PCI video. Write 8000xx04 to Port CF8 (xx depends on PCI Dev#) » Point to offset 4 in PCI Video device. Write 3 to Port CFC to enable Mem & I/O accesses. » Example ITP commands for PCI Device # 8: > “dport (cf8) = ” > “dport (cfc) = ” » For PCI video on the System board, also write Port 3C3. > Example ITP command: “port (3c3) = 1” Sets bits 0 & 1 in port 3C2: > Example ITP command: “port (3c2) = 3” VGA Ctlr registers can now be programmed & tested.
34 Troubleshooting Video problems l POST completes and the system boots: Use a diagnostic program such as Testview for a thorough test of the Video Sub-system. » Testview is particularly useful for evaluating functionality in the high resolution video modes, and for testing ALL of the memory in a particular Video Subsystem. » Testview tests are written for a specific Video Controller and perform more comprehensive tests than most ITP procs. » With Testview, you can loop on a failing test to find intermittents and observe Video Controller signals with an O’scope. » Testview has HELP files that describe the test algorithm and give you “debug hints” for the failing tests.
35 Troubleshooting Video problems l POST puts text on screen, but does not boot an O/S (can’t run Testview): The Video Controller was programmed for Text Mode 3. » At least part of the Video Buffer circuitry is functional. > Only the 32K B8000P video buffer is used in Text Mode 3. Observe any display anomaly on the screen that could give clues about the failure mechanism: » Sync problems (CRTC): Jitter or folded images » Memory/Video Controller: Missing characters or pixels. » DAC or connector: Incorrect or missing colors. Use a debug tool such as the ITP to test functionality by reading and writing I/O registers and Video Memory with available ITP procs.
36 Troubleshooting Video problems l POST runs but does not display text on the screen FIRST: Check voltages, clocks, bus functionality, etc. Check strapping/configuration options. » Video controllers often “read” configuration information during reset (e.g.-pull-down resistors installed on MD lines). Use a debug tool such as the ITP to initialize the Video controller and test functionality by reading and writing I/O registers and Video Memory. » Use available ITP procs to program the VGA Controller for Text or Graphics modes to verify register accesses. » Note: Host address/data bus problems could be indicated by failure to correctly read/write some or all of the registers.
37 Troubleshooting Video problems l POST does NOT display text on the screen (cont.) If you could program the Video Controller registers, you should be able to read and write the Video Memory. Use an ITP proc to program the VGA Controller and test the 128K (A000:0-B000:FFFF) range of the Video Buffer. » Loop on a failing memory address to find a bad address line, data line, or memory chip. Note: Isolating memory problems to either the Video controller or the Memory chip(s) can be challenging. » Since access to the Video Buffer is THROUGH the Video Controller, you may have to analyze several of the memory control, address, and data signals to determine if the Video Controller is functioning correctly.
38 REVIEW & SUMMARY WE HAVE DISCUSSED THE FOLLOWING: l Graphics Modes & Video Buffer data format. Graphics modes display special symbols/images that are not part of the predefined character sets in Text mode. Graphics mode data stored in video RAM is NOT interpreted as a character code & attribute, but instead directly determines pixel intensity & color. Graphics modes require more memory than text modes because each pixel can be described by one or more bits l The characteristics of VGA Mode 12 hex. Video A0000; Resolution = 640 pixels x 480 lines 80 Characters/line; 30 lines frame (screen) 38.4K bytes/page of Memory used (4 pages total)
39 REVIEW & SUMMARY l Graphics Mode memory organization, Graphics Mode color generation & character fonts. In Graphics Mode 12h, the video buffer is a set of four parallel bit planes (one for each color), each of which shares the same addresses starting at A000:0000. » A pixel can have any of 16 (2 4 ) different values. Characters are drawn pixel by pixel using software instead of by the character generator used in text modes. l 256 Color Graphics Mode 13 hex. Every pixel is represented by 8 bits of data and this byte acts as a direct index to the DAC color table and represents the color as a value from 0 to 255. Resolution 320x200; 320x200 = 64,000 bytes
40 REVIEW & SUMMARY l Super VGA, VESA, & display memory pages. Super VGA (SVGA), Extended VGA, and Advanced VGA are informal terms for anything better than VGA. VESA BIOS Extensions (VBE) provide a standard method for accessing additional SVGA functionality Many Graphics Modes require more than 64-KB of memory which can be addressed by selecting which portion to map into the 64-KB range of A0000-AFFFFp. l The initialization of the Video Subsystem. Upon power up or reset, access to internal registers and memory is not allowed until the Video Subsystem has been enabled (usually by the BIOS during POST). » If Video Controller registers are NOT programmed, you cannot read and write the Video Memory.
41 REVIEW & SUMMARY l Techniques for troubleshooting video problems. Use Testview for evaluating functionality in the high resolution modes and for testing ALL of the memory. If POST puts text on screen, but does not boot an O/S, observe any display anomaly on the screen that could give clues about the failure mechanism. If POST runs but does not display text on the screen: » Check voltages, clocks, bus functionality, strapping & configuration options, etc. » Use the ITP to initialize the controller and test functionality by reading and writing I/O registers and Video Memory. » If you could program the Video Controller registers, you should be able to read & write the Video Memory. End of Chapter 3-3