Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2012 Google Inc. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <x86emu/x86emu.h> |
| 18 | #include <arch/interrupt.h> |
| 19 | #include "int15.h" |
| 20 | |
| 21 | static int active_lfp, pfit, display, panel_type; |
| 22 | |
| 23 | int intel_vga_int15_handler(void) |
| 24 | { |
| 25 | int res = 0; |
| 26 | |
| 27 | printk(BIOS_DEBUG, "%s: AX=%04x BX=%04x CX=%04x DX=%04x\n", |
| 28 | __func__, X86_AX, X86_BX, X86_CX, X86_DX); |
| 29 | |
| 30 | switch (X86_AX) { |
| 31 | case 0x5f34: |
| 32 | /* |
| 33 | * Set Panel Fitting Hook: |
| 34 | * bit 2 = Graphics Stretching |
| 35 | * bit 1 = Text Stretching |
| 36 | * bit 0 = Centering (do not set with bit1 or bit2) |
| 37 | * 0 = video bios default |
| 38 | */ |
| 39 | X86_AX = 0x005f; |
| 40 | X86_CX = pfit; |
| 41 | res = 1; |
| 42 | break; |
| 43 | case 0x5f35: |
| 44 | /* |
| 45 | * Boot Display Device Hook: |
| 46 | * bit 0 = CRT |
| 47 | * bit 1 = TV (eDP) * |
| 48 | * bit 2 = EFP * |
| 49 | * bit 3 = LFP |
| 50 | * bit 4 = CRT2 |
| 51 | * bit 5 = TV2 (eDP) * |
| 52 | * bit 6 = EFP2 * |
| 53 | * bit 7 = LFP2 |
| 54 | */ |
| 55 | X86_AX = 0x005f; |
| 56 | X86_CX = display; |
| 57 | res = 1; |
| 58 | break; |
| 59 | case 0x5f40: /* Boot Panel Type */ |
| 60 | X86_AX = 0x005f; // Success |
| 61 | X86_CL = panel_type; |
| 62 | printk(BIOS_DEBUG, "DISPLAY=%x\n", X86_CL); |
Konstantin Aladyshev | 3c47e8a | 2015-01-24 21:02:19 +0400 | [diff] [blame] | 63 | res = 1; |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 64 | break; |
| 65 | case 0x5f51: |
| 66 | /* |
| 67 | * Hook to select active LFP configuration: |
| 68 | * 00h = No LVDS, VBIOS does not enable LVDS |
| 69 | * 01h = Int-LVDS, LFP driven by integrated LVDS decoder |
| 70 | * 02h = SVDO-LVDS, LFP driven by SVDO decoder |
| 71 | * 03h = eDP, LFP Driven by Int-DisplayPort encoder |
| 72 | */ |
| 73 | X86_AX = 0x005f; |
| 74 | X86_CX = active_lfp; |
| 75 | res = 1; |
| 76 | break; |
| 77 | case 0x5f70: |
| 78 | switch ((X86_CX >> 8) & 0xff) { |
| 79 | case 0: |
| 80 | /* Get Mux */ |
| 81 | X86_AX = 0x005f; |
| 82 | X86_CX = 0x0000; |
| 83 | res = 1; |
| 84 | break; |
| 85 | case 1: |
| 86 | /* Set Mux */ |
| 87 | X86_AX = 0x005f; |
| 88 | X86_CX = 0x0000; |
| 89 | res = 1; |
| 90 | break; |
| 91 | case 2: |
| 92 | /* Get SG/Non-SG mode */ |
| 93 | X86_AX = 0x005f; |
| 94 | X86_CX = 0x0000; |
| 95 | res = 1; |
| 96 | break; |
| 97 | default: |
| 98 | /* Interrupt was not handled */ |
| 99 | printk(BIOS_DEBUG, |
| 100 | "Unknown INT15 5f70 function: 0x%02x\n", |
| 101 | ((X86_CX >> 8) & 0xff)); |
| 102 | break; |
| 103 | } |
| 104 | break; |
| 105 | |
Elyes HAOUAS | 88607a4 | 2018-10-05 10:36:45 +0200 | [diff] [blame^] | 106 | default: |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 107 | printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n", X86_AX); |
| 108 | break; |
| 109 | } |
| 110 | return res; |
| 111 | } |
| 112 | |
| 113 | |
| 114 | void install_intel_vga_int15_handler(int active_lfp_, int pfit_, int display_, int panel_type_) |
| 115 | { |
| 116 | active_lfp = active_lfp_; |
| 117 | pfit = pfit_; |
| 118 | display = display_; |
| 119 | panel_type = panel_type_; |
| 120 | mainboard_interrupt_handlers(0x15, &intel_vga_int15_handler); |
| 121 | } |