⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dalgdo.c

📁 此代码为WCE5.0下显示器的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
* Function creates the key name used for display adjustments sizing and
* and positioning as saved into the registry.
*
* Notes:
*
\**************************************************************************/

VOID vGetDisplayPerModeValueName(
    LPHW_DAL_EXTENSION lpHDE,
    LPUCHAR            lpTypeName,
    LPDEVMODE_INFO     lpMI,
    LPUCHAR            lpValueName
    )
{
  ULONG ulWidth;
  ULONG ulHeight;
  ULONG ulRefresh;
  int   i;

  char szWidth[5];
  char szHeight[5];
  char szRefresh[5];

  DALASSERT(lpTypeName != NULL,
            "vGetDisplayPerModeValueName - does not have a name!");
  DALASSERT(lpMI->ulPelsWidth != 0,
            "vGetDisplayPerModeValueName - invalid mode!");
  DALASSERT(lpMI->ulPelsHeight != 0,
            "vGetDisplayPerModeValueName - invalid mode!");

  strcpy(szWidth, "0000");
  strcpy(szHeight, "0000");
  strcpy(szRefresh, "0000");

  ulWidth   = lpMI->ulPelsWidth;
  ulHeight  = lpMI->ulPelsHeight;
  ulRefresh = lpMI->ulDisplayFrequency;

  for (i = 0; i < 4; i++)
  {
    szWidth[3-i]   += (char)(ulWidth % 10);
    szHeight[3-i]  += (char)(ulHeight % 10);
    szRefresh[3-i] += (char)(ulRefresh % 10);

    ulWidth   /= 10;
    ulHeight  /= 10;
    ulRefresh /= 10;
  }

  strcpy(lpValueName, DALREGKEY_DAL);
  strcat(lpValueName, lpTypeName);
  strcat(lpValueName, "x");
  strcat(lpValueName, szWidth);
  strcat(lpValueName, "x");
  strcat(lpValueName, szHeight);
  strcat(lpValueName, "x0x");
  strcat(lpValueName, szRefresh);
}


/****************************Private*Routine*******************************\
*
* VOID vGetDisplayPerModeAdjustments()
*
* Function queries the registry and references the display adjustments
* for all the per mode adjustments for the mode requested.
*
* Notes:
*
\**************************************************************************/

VOID vGetDisplayPerModeAdjustments(
LPHW_DAL_EXTENSION lpHDE,
LPDEVGDO lpDisplay,
LPDEVMODE_INFO lpMI)
{
  UCHAR aBuffer[MAX_REGISTRY_VALUENAME];
  ULONG ulSize;
  LONG  alAdjustmentBufffer[DAL_MAX_GDO_PER_MODE_ADJUSTMENTS];
  ULONG ulPerModeAdjustments;

  ZEROMEMORY((LPVOID)&alAdjustmentBufffer[0], 
             (sizeof(LONG) * DAL_MAX_GDO_PER_MODE_ADJUSTMENTS));

  vGetDisplayPerModeValueName(lpHDE, lpDisplay->lpHWED->lpDisplayName, lpMI, aBuffer);

  // Specify which adjustments to update
  ulPerModeAdjustments = GDO_HOOK_VERTICAL_POSITION_ADJUSTMENT    |
                         GDO_HOOK_HORIZONTAL_POSITION_ADJUSTMENT  |
                         GDO_HOOK_VERTICAL_SIZE_ADJUSTMENT        |
                         GDO_HOOK_HORIZONTAL_SIZE_ADJUSTMENT      |
                         GDO_HOOK_HORIZONTAL_SYNC                 |
                         GDO_HOOK_VERTICAL_SYNC;

  // DAL_MAX_GDO_PER_MODE_ADJUSTMENTS must correspond to the number
  // of adjustments specified above. Currently it is 6.
  ulSize = sizeof(LONG) * DAL_MAX_GDO_PER_MODE_ADJUSTMENTS;

  if(!(DDLGetRegistryParameters(lpHDE->hDDL,
                                (LPUCHAR) aBuffer,
                                (LPVOID)&alAdjustmentBufffer[0],
                                (LPULONG)&ulSize)) ||
      (ulSize != (sizeof(LONG) * DAL_MAX_GDO_PER_MODE_ADJUSTMENTS)))
  {
    // no user adjusted values in the registry, so read the values from
    // the defaults.

   // Update GDO adjustments from the saved defaults 
    vUpdatePerModeDisplayAdjustments(lpDisplay, ulPerModeAdjustments, 
                                     (LPLONG) &alAdjustmentBufffer[0], 
                                     DAL_SET_DISPLAY_DEFAULT_ADJUSTMENTS);
  }
  else
  {
    // Adjustment exists for this mode in the registry.
    // Buffer is filled with the registry value so fill
    // the GDO adjustment structure with these value.

    // Update GDO adjustments from registry 
    vUpdatePerModeDisplayAdjustments(lpDisplay, ulPerModeAdjustments, 
                                     (LPLONG) &alAdjustmentBufffer[0], 
                                     DAL_SET_DISPLAY_ADJUSTMENTS);
  }
}

/****************************Private*Routine*******************************\
*
* ULONG ulGetDisplayTVStandard()
*
* Reads the TV standard from the display structure, provided the display is
* of TYPE TV.
*
* Notes: the adjutsment structure needs already be initialized
*
*
\**************************************************************************/

ULONG ulGetDisplayTVStandard(
LPHW_DAL_EXTENSION lpHDE,
LPDEVGDO lpDisplay)
{
  ULONG i;

  DALASSERT((lpDisplay->lpHWED->ulDisplayType & HW_DISPLAY_TYPE_TV),
            "ulGetDisplayTVStandard - display not type TV!");

  for (i = 0; (VECTORFROMINDEX(i) != GDO_HOOK_VIDEO_STANDARD_ADJUSTMENT); i++);

  return(lpDisplay->alAdjustments[i]);
}



/****************************Private*Routine*******************************\
*
* VOID vGetDisplayAdjustmentDefaults()
*
* Walks all the adjustments available for the display and retrieves the
* defaults for the adjustments.
*
* Note: function has side effect of updating adjustment structures in the
*       DAL private GDO information.
*
\**************************************************************************/

VOID vGetDisplayAdjustmentDefaults(
LPHW_DAL_EXTENSION lpHDE,
LPDEVGDO lpDisplay,
LPDEVMODE_INFO lpMI)
{
  LPHW_ADJUSTMENT lpAdjustment;
  ULONG           ulIndex;
  ULONG           ulHook;

  for (ulIndex = 0, ulHook = 1;
       ulHook < GDO_ENDOF_ADJUSTMENTS;
       ulIndex ++, ulHook = (ulHook << 1))
  {
    // loop through each possible adjustment for the display, and query
    // the defaults for the adjustment functions hooked by the display.

    if (lpDisplay->lpHWED->ulFunctionHooks & ulHook)
    {
      // adjustment was hooked by the display, query it's defaults

      lpAdjustment = (LPHW_ADJUSTMENT) &lpDisplay->aAdjustment[ulIndex];

      switch(ulHook)
      {
        case GDO_HOOK_BRIGHTNESS_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetBrightnessAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_CHROMA_FLICKER_REMOVAL_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetChromaFlickerAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_COLOR_CONTROL_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetColorControlAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_CONTRAST_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetContrastAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_VERTICAL_POSITION_ADJUSTMENT:
          // lpAdjustment is 2 elements in size for this function, so both
          // horizontal and vertical are programmed with this one call.
          (*lpDisplay->lpHWED->pfnGetDisplayPositionAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_HORIZONTAL_POSITION_ADJUSTMENT:
          // GDO's have a single call for positioning, hence let the vertical
          // hook catch both.
          break;

        case GDO_HOOK_VERTICAL_SIZE_ADJUSTMENT:
          // lpAdjustment is 2 elements in size for this function, so both
          // horizontal and vertical are programmed with this one call.
          (*lpDisplay->lpHWED->pfnGetDisplaySizeAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_HORIZONTAL_SIZE_ADJUSTMENT:
          // GDO's have a single call for sizing, hence let the vertical
          // hook catch both.
          break;

        case GDO_HOOK_DOT_CRAWL_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetDotCrawlAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_FILTER_SVIDEO_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetFilterSVideoAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_FILTER_COMP_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetFilterCompAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_GAMMA_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetGammaAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_LUMA_FLICKER_REMOVAL_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetLumaFlickerAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_VIDEO_STANDARD_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetVideoStandardAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_VIDEO_SIGNAL_STANDARD_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetVideoSignalStandardAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_OVERSCAN_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetOverscanAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_MULTIMEDIAPASSTHRU_ADJUSTMENT:
          (*lpDisplay->lpHWED->pfnGetMultimediaPassThruAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_HORIZONTAL_SYNC:
          (*lpDisplay->lpHWED->pfnGetSyncHorizontalAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_VERTICAL_SYNC:
          (*lpDisplay->lpHWED->pfnGetSyncVerticalAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_COMPOSITE_SYNC:
          (*lpDisplay->lpHWED->pfnGetSyncCompositeAdjustment)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        case GDO_HOOK_FRAMEMODULATION:
          (*lpDisplay->lpHWED->pfnGetFrameModulation)
                       (lpDisplay->hGDO,
                        lpAdjustment,
                        lpMI);
          break;

        default:
          lpAdjustment->lMin = 0;
          lpAdjustment->lMax = 0;
          lpAdjustment->lStep = 0;
          lpAdjustment->lDefault = 0;
          break;

      }

      // some GDO's are passing back bogus adjustments which need be fixed.

      DALASSERT((lpAdjustment->lMin <= lpAdjustment->lMax),
                "vGetDisplayAdjustmentDefaults - error in GDOGetAdjustment data");

      DALASSERT((lpAdjustment->lDefault <= lpAdjustment->lMax),
                "vGetDisplayAdjustmentDefaults - error in GDOGetAdjustment data");

      DALASSERT((lpAdjustment->lDefault >= lpAdjustment->lMin),
                "vGetDisplayAdjustmentDefaults - error in GDOGetAdjustment data");

    }
  }
}



/****************************Private*Routine*******************************\
*
* VOID ulDetectConnectedDisplays()
*
* Function determines which displays are physically connected, by updating
* information for each display
*
* Note: Function rebuilds parts of the mode table when a display was
*       detected previously as not connected and is not detected as
*       as connected.
*
\**************************************************************************/

ULONG ulDetectConnectedDisplays(
LPHW_DAL_EXTENSION lpHDE)
{
  LPDEVGDO lpDisplay;
  LPDEVGDO lpCRTDisplay;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -