Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
4.9 KiB

  1. /***************************************************************************
  2. *
  3. * ******************************************
  4. * * Copyright (c) 1997, Cirrus Logic, Inc. *
  5. * * All Rights Reserved *
  6. * ******************************************
  7. *
  8. * PROJECT: Laguna (CL-GD546X) -
  9. *
  10. * FILE: pwrmgr.c
  11. *
  12. * AUTHOR: Benny Ng
  13. *
  14. * DESCRIPTION:
  15. * This module contains Power manager code for both
  16. * Laguna Win95 and NT drivers.
  17. *
  18. * MODULES:
  19. * LgPM_SetHwModuleState()
  20. * LgPM_GetHwModuleState()
  21. *
  22. * REVISION HISTORY:
  23. * $Log: X:/log/laguna/powermgr/src/pwrmgr.c $
  24. *
  25. * Rev 1.3 20 Jun 1997 13:37:16 bennyn
  26. *
  27. * Moved power manager functions to Miniport
  28. *
  29. * Rev 1.2 23 Apr 1997 08:01:42 SueS
  30. * Enable MMIO access to PCI configuration registers before VS_Clk_Control
  31. * and VS_Control are referenced. Disable MMIO access after they're
  32. * referenced.
  33. *
  34. * Rev 1.1 23 Jan 1997 16:29:28 bennyn
  35. * Use bit-11 instead of bit-15 to enable VS_CLK_CNTL
  36. *
  37. * Rev 1.0 16 Jan 1997 11:48:20 bennyn
  38. * Initial revision.
  39. *
  40. *
  41. ****************************************************************************
  42. ****************************************************************************/
  43. #include "precomp.h"
  44. #include "clioctl.h"
  45. #if defined WINNT_VER35 // WINNT_VER35
  46. // If WinNT 3.5 skip all the source code
  47. #else
  48. /*----------------------------- INCLUDES ----------------------------------*/
  49. #ifndef WINNT_VER40
  50. #include <pwrmgr.h>
  51. #endif
  52. /*----------------------------- DEFINES -----------------------------------*/
  53. /*--------------------- STATIC FUNCTION PROTOTYPES ------------------------*/
  54. /*--------------------------- ENUMERATIONS --------------------------------*/
  55. /*----------------------------- TYPEDEFS ----------------------------------*/
  56. /*-------------------------- STATIC VARIABLES -----------------------------*/
  57. /*-------------------------- GLOBAL FUNCTIONS -----------------------------*/
  58. /****************************************************************************
  59. * FUNCTION NAME: LgPM_SetHwModuleState()
  60. *
  61. * DESCRIPTION: This routine validates the request for any conflict between
  62. * the request and the current chip operation. If it is valid,
  63. * it will enable or disable the specified HW module by turning
  64. * on or off appropriate HW clocks and returns TRUE. If it is
  65. * invalid or there is a conflict to the current chip operation,
  66. * it ignores the request and return FAIL.
  67. *
  68. * Input:
  69. * hwmod - can be one of the following HW modules
  70. * MOD_2D
  71. * MOD_3D
  72. * MOD_TVOUT
  73. * MOD_VPORT
  74. * MOD_VGA
  75. * MOD_EXTMODE
  76. * MOD_STRETCH
  77. *
  78. * state - Ether ENABLE or DISABLE.
  79. *
  80. * Return: TRUE - succeed, FALSE - failed.
  81. *
  82. *****************************************************************************/
  83. BOOL LgPM_SetHwModuleState (PPDEV ppdev, ULONG hwmod, ULONG state)
  84. {
  85. LGPM_IN_STRUCT InBuf;
  86. LGPM_OUT_STRUCT OutBuf;
  87. DWORD cbBytesReturned;
  88. InBuf.arg1 = hwmod;
  89. InBuf.arg2 = state;
  90. OutBuf.status = FALSE;
  91. OutBuf.retval = 0;
  92. if (DEVICE_IO_CTRL(ppdev->hDriver,
  93. IOCTL_SET_HW_MODULE_POWER_STATE,
  94. (LPVOID)&InBuf, sizeof(InBuf),
  95. (LPVOID)&OutBuf, sizeof(OutBuf),
  96. &cbBytesReturned, NULL))
  97. return TRUE;
  98. else
  99. return FALSE;
  100. }; // LgPM_SetHwModuleState
  101. /****************************************************************************
  102. * FUNCTION NAME: LgPM_GetHwModuleState()
  103. *
  104. * DESCRIPTION: This routine returns the current state of a particular
  105. * hardware module.
  106. *
  107. * Input:
  108. * hwmod - can be one of the following HW modules
  109. * MOD_2D
  110. * MOD_3D
  111. * MOD_TVOUT
  112. * MOD_VPORT
  113. * MOD_VGA
  114. * MOD_EXTMODE
  115. * MOD_STRETCH
  116. *
  117. * state - Pointer to ULONG variable for returning the HW module state
  118. * (ENABLE or DISABLE).
  119. *
  120. * Return: TRUE - succeed, FALSE - failed.
  121. *
  122. ****************************************************************************/
  123. BOOL LgPM_GetHwModuleState (PPDEV ppdev, ULONG hwmod, ULONG* state)
  124. {
  125. LGPM_IN_STRUCT InBuf;
  126. LGPM_OUT_STRUCT OutBuf;
  127. DWORD cbBytesReturned;
  128. InBuf.arg1 = hwmod;
  129. InBuf.arg2 = (ULONG) state;
  130. OutBuf.status = FALSE;
  131. OutBuf.retval = 0;
  132. if (DEVICE_IO_CTRL(ppdev->hDriver,
  133. IOCTL_GET_HW_MODULE_POWER_STATE,
  134. (LPVOID)&InBuf, sizeof(InBuf),
  135. (LPVOID)&OutBuf, sizeof(OutBuf),
  136. &cbBytesReturned, NULL))
  137. return TRUE;
  138. else
  139. return FALSE;
  140. }; // LgPM_GetHwModuleState
  141. #endif // WINNT_VER35
  142.