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.

172 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. modeset.c
  5. Abstract:
  6. This is the modeset code for the headless miniport driver.
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. --*/
  11. #include "dderror.h"
  12. #include "devioctl.h"
  13. #include "miniport.h"
  14. #include "ntddvdeo.h"
  15. #include "video.h"
  16. #include "headless.h"
  17. #if defined(ALLOC_PRAGMA)
  18. #pragma alloc_text(PAGE,HeadlessQueryAvailableModes)
  19. #pragma alloc_text(PAGE,HeadlessQueryNumberOfAvailableModes)
  20. #endif
  21. VP_STATUS
  22. HeadlessQueryAvailableModes(
  23. PVIDEO_MODE_INFORMATION ModeInformation,
  24. ULONG ModeInformationSize,
  25. PULONG OutputSize
  26. )
  27. /*++
  28. Routine Description:
  29. This routine returns the list of all available available modes on the
  30. card.
  31. Arguments:
  32. ModeInformation - Pointer to the output buffer supplied by the user.
  33. This is where the list of all valid modes is stored.
  34. ModeInformationSize - Length of the output buffer supplied by the user.
  35. OutputSize - Pointer to a buffer in which to return the actual size of
  36. the data in the buffer. If the buffer was not large enough, this
  37. contains the minimum required buffer size.
  38. Return Value:
  39. ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
  40. for the data being returned.
  41. NO_ERROR if the operation completed successfully.
  42. --*/
  43. {
  44. PVIDEO_MODE_INFORMATION videoModes = ModeInformation;
  45. ULONG i;
  46. //
  47. // Find out the size of the data to be put in the buffer and return
  48. // that in the status information (whether or not the information is
  49. // there). If the buffer passed in is not large enough return an
  50. // appropriate error code.
  51. //
  52. if (ModeInformationSize < (*OutputSize =
  53. NumVideoModes * sizeof(VIDEO_MODE_INFORMATION)) ) {
  54. return ERROR_INSUFFICIENT_BUFFER;
  55. }
  56. //
  57. // For each mode supported by the card, store the mode characteristics
  58. // in the output buffer.
  59. //
  60. for (i = 0; i < NumVideoModes; i++, videoModes++) {
  61. videoModes->Length = sizeof(VIDEO_MODE_INFORMATION);
  62. videoModes->ModeIndex = i;
  63. videoModes->VisScreenWidth = ModesHeadless[i].hres;
  64. videoModes->VisScreenHeight = ModesHeadless[i].vres;
  65. videoModes->NumberOfPlanes = 1;
  66. videoModes->BitsPerPlane = 4;
  67. videoModes->Frequency = 60;
  68. videoModes->XMillimeter = 320; // temporary hardcoded constant
  69. videoModes->YMillimeter = 240; // temporary hardcoded constant
  70. videoModes->NumberRedBits = 6;
  71. videoModes->NumberGreenBits = 6;
  72. videoModes->NumberBlueBits = 6;
  73. videoModes->RedMask = 0;
  74. videoModes->GreenMask = 0;
  75. videoModes->BlueMask = 0;
  76. videoModes->AttributeFlags = VIDEO_MODE_COLOR | VIDEO_MODE_GRAPHICS |
  77. VIDEO_MODE_PALETTE_DRIVEN | VIDEO_MODE_MANAGED_PALETTE;
  78. }
  79. return NO_ERROR;
  80. }
  81. VP_STATUS
  82. HeadlessQueryNumberOfAvailableModes(
  83. PVIDEO_NUM_MODES NumModes,
  84. ULONG NumModesSize,
  85. PULONG OutputSize
  86. )
  87. /*++
  88. Routine Description:
  89. This routine returns the number of available modes for this particular
  90. video card.
  91. Arguments:
  92. NumModes - Pointer to the output buffer supplied by the user. This is
  93. where the number of modes is stored.
  94. NumModesSize - Length of the output buffer supplied by the user.
  95. OutputSize - Pointer to a buffer in which to return the actual size of
  96. the data in the buffer.
  97. Return Value:
  98. ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
  99. for the data being returned.
  100. NO_ERROR if the operation completed successfully.
  101. --*/
  102. {
  103. //
  104. // Find out the size of the data to be put in the the buffer and return
  105. // that in the status information (whether or not the information is
  106. // there). If the buffer passed in is not large enough return an
  107. // appropriate error code.
  108. //
  109. if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) {
  110. return ERROR_INSUFFICIENT_BUFFER;
  111. }
  112. //
  113. // Store the number of modes into the buffer.
  114. //
  115. NumModes->NumModes = NumVideoModes;
  116. NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
  117. return NO_ERROR;
  118. }