📄 aticonsole.c
字号:
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c,v 1.22 2003/11/13 18:42:47 tsi Exp $ *//* * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting documentation, and * that the name of Marc Aurele La France not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. Marc Aurele La France makes no representations * about the suitability of this software for any purpose. It is provided * "as-is" without express or implied warranty. * * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * DRI support by: * Manuel Teira * Leif Delgass <ldelgass@retinalburn.net> */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "ati.h"#include "atiadapter.h"#include "aticonsole.h"#include "aticrtc.h"#include "atii2c.h"#include "atilock.h"#include "atimach64.h"#include "atimach64io.h"#include "atimode.h"#include "atistruct.h"#include "ativga.h"#include "atividmem.h"#ifdef XF86DRI_DEVEL#include "mach64_common.h"#include "atidri.h"#endif#include "mach64_common.h"#include "xf86.h"#ifdef TV_OUT#include "atichip.h"#include "atiprint.h"#include "atioption.h"#include "vbe.h"static const char *vbeSymbols[] = { "VBEGetVBEMode", NULL};#endif /* TV_OUT *//* * ATISaveScreen -- * * This function is a screen saver hook for DIX. */BoolATISaveScreen( ScreenPtr pScreen, int Mode){ ScrnInfoPtr pScreenInfo; ATIPtr pATI; if ((Mode != SCREEN_SAVER_ON) && (Mode != SCREEN_SAVER_CYCLE)) SetTimeSinceLastInputEvent(); if (!pScreen) return TRUE; pScreenInfo = xf86Screens[pScreen->myNum]; if (!pScreenInfo->vtSema) return TRUE; pATI = ATIPTR(pScreenInfo); switch (pATI->NewHW.crtc) {#ifndef AVOID_CPIO case ATI_CRTC_VGA: ATIVGASaveScreen(pATI, Mode); break;#endif /* AVOID_CPIO */ case ATI_CRTC_MACH64: ATIMach64SaveScreen(pATI, Mode); break; default: break; } return TRUE;}/* * ATISetDPMSMode -- * * This function sets the adapter's VESA Display Power Management Signaling * mode. */voidATISetDPMSMode( ScrnInfoPtr pScreenInfo, int DPMSMode, int flags){ ATIPtr pATI; if (!pScreenInfo || !pScreenInfo->vtSema) return; pATI = ATIPTR(pScreenInfo); switch (pATI->Adapter) { case ATI_ADAPTER_MACH64: ATIMach64SetDPMSMode(pScreenInfo, pATI, DPMSMode); break; default:#ifndef AVOID_CPIO /* Assume EGA/VGA */ ATIVGASetDPMSMode(pATI, DPMSMode); break; case ATI_ADAPTER_NONE: case ATI_ADAPTER_8514A: case ATI_ADAPTER_MACH8:#endif /* AVOID_CPIO */ break; }}#ifdef TV_OUTstatic voidATIProbeAndSetActiveDisplays( ScrnInfoPtr pScreenInfo, ATIPtr pATI){ vbeInfoPtr pVbe; Bool tv_attached, crt_attached, lcd_attached; int disp_request; ATITVStandard tv_std, tv_std_request; xf86LoaderRefSymLists(vbeSymbols, NULL); if (xf86GetVerbosity() > 3) { xf86ErrorFVerb(4, "\n Before TV-Out queries\n\n"); ATIPrintRegisters(pATI); } pATI->tvActive = FALSE; pVbe = pATI->pVBE; if (pVbe) { /* LT Pro, XL, Mobility specific BIOS functions */ if (pATI->Chip == ATI_CHIP_264LTPRO || pATI->Chip == ATI_CHIP_264XL || pATI->Chip == ATI_CHIP_MOBILITY) { /* Get attached display(s) - LTPro, XL, Mobility */ pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0xa083; pVbe->pInt10->cx = 0x0700; /* ch=0x07 - probe all, 0x01 CRT, 0x02 TV, 0x04 LCD */ xf86ExecX86int10(pVbe->pInt10); xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Attached displays: ax=0x%04x, cx=0x%04x\n", pVbe->pInt10->ax, pVbe->pInt10->cx); tv_attached = crt_attached = lcd_attached = FALSE; if (pVbe->pInt10->ax & 0xff00) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Failed to detect attached displays\n"); } else { if (pVbe->pInt10->cx & 0x3) { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " CRT attached\n"); crt_attached = TRUE; } else crt_attached = FALSE; if ((pVbe->pInt10->cx >> 2) & 0x3) { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " DFP/LCD attached\n"); lcd_attached = TRUE; } else lcd_attached = FALSE; switch ((pVbe->pInt10->cx >> 4) & 0x3) { case 0: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " No TV attached\n"); break; case 1: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " TV attached (composite connector)\n"); tv_attached = TRUE; break; case 2: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " TV attached (S-video connector)\n"); tv_attached = TRUE; break; case 3: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " TV attached (S-video/composite connectors)\n"); tv_attached = TRUE; break; default: xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Unrecognized return code: 0x%04x\n", pVbe->pInt10->cx); } } /* Get active display - LTPro, XL, Mobility */ pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0xa084; pVbe->pInt10->bx = 0x0000; /* bh=0x00 get active, bh=0x01 set active */ xf86ExecX86int10(pVbe->pInt10); xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Active displays: ax=0x%04x, bx=0x%04x, cx=0x%04x\n", pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx); if (pVbe->pInt10->ax & 0xff00) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Failed to detect active display\n"); } else { if (pVbe->pInt10->bx & 0x1) xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " DFP/LCD is active\n"); if (pVbe->pInt10->bx & 0x2) xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " CRT is active\n"); if (pVbe->pInt10->bx & 0x4) { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, " TV is active\n"); if (!tv_attached) { /* tv not connected - disable tv */ disp_request = 0x00; if (crt_attached) disp_request |= 0x02; /* enable CRT */ if (lcd_attached && pATI->OptionPanelDisplay) disp_request |= 0x01; /* enable DFP/LCD */ pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0xa084; pVbe->pInt10->bx = 0x0100; /* bh=0x01 set active */ pVbe->pInt10->cx = disp_request; xf86ExecX86int10(pVbe->pInt10); xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV not present, disabling: ax=0x%04x, bx=0x%04x, cx=0x%04x\n", pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx); if (pVbe->pInt10->ax & 0xff00) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Disabling TV failed\n"); } } else { pATI->tvActive = TRUE; } } else if (tv_attached && (pVbe->pInt10->bx & 0x0400)) { /* tv connected and available - enable TV */ disp_request = 0x04; /* enable TV */#if 0 /* This works, but CRT image is vertically compressed */ if (crt_attached) disp_request |= 0x02; /* enable CRT */ /* NOTE: For me, LCD+TV does NOT work */ /*if (lcd_attached && pATI->OptionPanelDisplay) disp_request |= 0x01; * enable DFP/LCD */#endif pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0xa084; pVbe->pInt10->bx = 0x0100; /* bh=0x01 set active */ pVbe->pInt10->cx = disp_request; /* try to activate TV */ xf86ExecX86int10(pVbe->pInt10); xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Setting TV active: ax=0x%04x, bx=0x%04x, cx=0x%04x\n", pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx); if (pVbe->pInt10->ax & 0xff00) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Setting TV active failed\n"); } else { pATI->tvActive = TRUE; } } } } else { /* pATI->Chip < ATI_CHIP_264LTPRO */ /* TVOut Hooks - Check for TVOut BIOS/hardware */ pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0xa019; pVbe->pInt10->cx = 0x0000; /* TVOut BIOS query */ xf86ExecX86int10(pVbe->pInt10); tv_attached = FALSE; if (pVbe->pInt10->ax & 0xff00) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Failed to detect TV-Out BIOS\n"); } else { switch (pVbe->pInt10->ax & 0x0003) { case 3: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV-Out BIOS detected and active\n"); /* TV attached query */ pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0xa070; pVbe->pInt10->bx = 0x0002; /* Sub-function: return tv attached info */ xf86ExecX86int10(pVbe->pInt10); if (pVbe->pInt10->ax & 0xff00) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Failed to detect if TV is attached\n"); } else { switch (pVbe->pInt10->cx & 0x0003) { case 3: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV attached to composite and S-video connectors\n"); tv_attached = TRUE; break; case 2: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV attached to S-video connector\n"); tv_attached = TRUE; break; case 1: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV attached to composite connector\n"); tv_attached = TRUE; break; default: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV is not attached\n"); } } break; case 1: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV-Out BIOS service is not available due to" "a system BIOS error or TV-Out hardware not being installed\n"); break; default: xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "No TV-Out BIOS or hardware detected\n"); } } } /* Return TV-Out configuration * see Programmer's Guide under "TV Out Specific Functions" * It's not clear exactly which adapters support these */ pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0xa070; pVbe->pInt10->bx = 0x00; xf86ExecX86int10(pVbe->pInt10); xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV-Out query: ax=0x%04x, bx=0x%04x, cx=0x%04x, dx=0x%04x\n", pVbe->pInt10->ax, pVbe->pInt10->bx, pVbe->pInt10->cx, pVbe->pInt10->dx); if (pVbe->pInt10->ax & 0xff00) { xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING, "Failed to detect TV-Out configuration.\n"); } else if (pVbe->pInt10->bx == 0) { if (pVbe->pInt10->dx == 0) { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV-Out is not detected.\n"); } else { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV-Out is detected but not supported.\n"); } } else if ((pVbe->pInt10->cx & 0xff) == 0) { xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "TV-Out is currently disabled.\n"); if (tv_attached && pATI->Chip < ATI_CHIP_264LTPRO) { /* Try to enable TV-Out */ pVbe->pInt10->num = 0x10; pVbe->pInt10->ax = 0xa070; pVbe->pInt10->bx = 0x0001; /* Sub-function: Select TV Out */ /* cl=0x001 enable, cl=0x000 disable, * cl=0x080 disable with feature connector bit preserved
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -