mirror of
https://github.com/VirtualDrivers/Virtual-Display-Driver.git
synced 2026-10-20 13:49:58 -05:00
Compare commits
166
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94b35105e4 | ||
|
|
322e36a613 | ||
|
|
80b461b02f | ||
|
|
00e43b5d1f | ||
|
|
e3f58b629a | ||
|
|
e4bc40252a | ||
|
|
976dd165f6 | ||
|
|
5281cef87f | ||
|
|
3a500d8773 | ||
|
|
888f3ae2d2 | ||
|
|
3565152e07 | ||
|
|
cd1445427b | ||
|
|
64602d2aaa | ||
|
|
ef87af27dc | ||
|
|
888387fc72 | ||
|
|
15d229200b | ||
|
|
0318e5399a | ||
|
|
74ca716296 | ||
|
|
44e199935b | ||
|
|
69359ec35c | ||
|
|
c87b0c4f89 | ||
|
|
dcb511f188 | ||
|
|
52bbd2d97c | ||
|
|
8644ed559d | ||
|
|
9ac6074136 | ||
|
|
b07c8cc80c | ||
|
|
cb98721da4 | ||
|
|
3e65bc8749 | ||
|
|
8de4f3b000 | ||
|
|
79810cb48d | ||
|
|
a3564fbf01 | ||
|
|
6c125361ac | ||
|
|
266b4a01c3 | ||
|
|
0d36d2a655 | ||
|
|
5dc87774c5 | ||
|
|
68b92409a6 | ||
|
|
80861064e8 | ||
|
|
2fd04a231b | ||
|
|
1ef82c3e6a | ||
|
|
3895ea6b4b | ||
|
|
13bb8cc323 | ||
|
|
f9f95e319c | ||
|
|
22535e68de | ||
|
|
fc73feaa47 | ||
|
|
698c735bdf | ||
|
|
9cb856f645 | ||
|
|
cdc9ed24d3 | ||
|
|
9f90a294ee | ||
|
|
2f3f3c044c | ||
|
|
63c3899826 | ||
|
|
a28ec0eb51 | ||
|
|
d03bf38ff6 | ||
|
|
4bc7e80234 | ||
|
|
25a53cab3a | ||
|
|
88d36bc1b5 | ||
|
|
68712353e3 | ||
|
|
ec5c792903 | ||
|
|
5573a5f24f | ||
|
|
73007aefab | ||
|
|
df6395d96a | ||
|
|
9d64535682 | ||
|
|
3d025bbe3e | ||
|
|
4f391cde0a | ||
|
|
532d16317f | ||
|
|
8d28e02634 | ||
|
|
15c7136651 | ||
|
|
39ecdb0385 | ||
|
|
978d62abe8 | ||
|
|
6da06791a5 | ||
|
|
ce6e51fa54 | ||
|
|
6655bcffc0 | ||
|
|
fc54221dd3 | ||
|
|
22d12a29fc | ||
|
|
2b2794611a | ||
|
|
d65a9cda83 | ||
|
|
cf9d5e9a06 | ||
|
|
e8a25180d6 | ||
|
|
08ecea131d | ||
|
|
47bc4acf91 | ||
|
|
e65c36ec5f | ||
|
|
d27adb9539 | ||
|
|
c38f348740 | ||
|
|
72cc4d23d2 | ||
|
|
be01feae42 | ||
|
|
ecef4b9c22 | ||
|
|
31dfd6d41d | ||
|
|
e0a8343b77 | ||
|
|
d01f5f7734 | ||
|
|
4723b29257 | ||
|
|
f96c5940fc | ||
|
|
2a8081d6d4 | ||
|
|
c89559acf7 | ||
|
|
2d3749635b | ||
|
|
2bfbb0e043 | ||
|
|
76f6893d69 | ||
|
|
82ee302db4 | ||
|
|
c4045b7c79 | ||
|
|
9abbcd1270 | ||
|
|
e889902057 | ||
|
|
4c31aae067 | ||
|
|
97f06feb43 | ||
|
|
a918f82607 | ||
|
|
54380dddee | ||
|
|
354dde53f6 | ||
|
|
796d737969 | ||
|
|
ba44d43e6e | ||
|
|
f476bedae9 | ||
|
|
be5d4044e5 | ||
|
|
db81ae9a5a | ||
|
|
b564dfdda2 | ||
|
|
3c82dc1d84 | ||
|
|
9630f90bba | ||
|
|
e79a2fff9f | ||
|
|
fcacb8fe40 | ||
|
|
5a04c82cbd | ||
|
|
116e72c0a9 | ||
|
|
7b8b0daee2 | ||
|
|
2b9e65edaf | ||
|
|
2290b1368b | ||
|
|
f0f70d12c8 | ||
|
|
bd5992a49c | ||
|
|
c2622b1208 | ||
|
|
52d9d7ad2e | ||
|
|
a92c69c37f | ||
|
|
a1adb08f0d | ||
|
|
b42b774af1 | ||
|
|
1168e1d9d5 | ||
|
|
ad9693a667 | ||
|
|
d1f762ee5d | ||
|
|
0db50a948e | ||
|
|
faec71ff99 | ||
|
|
3e1af20b7d | ||
|
|
70cbbdfa88 | ||
|
|
ba57a9f150 | ||
|
|
282959aa2b | ||
|
|
224f2a05d4 | ||
|
|
58a942f7be | ||
|
|
3d8bd68f05 | ||
|
|
7670fb9f5c | ||
|
|
b18c2e99a7 | ||
|
|
de33359baf | ||
|
|
540ad48f26 | ||
|
|
a8742af494 | ||
|
|
a04f2ddbee | ||
|
|
41f9d6a1a0 | ||
|
|
7d13448595 | ||
|
|
7ffb7c34e0 | ||
|
|
ada3f545f8 | ||
|
|
191bfaff5c | ||
|
|
de85ea2b41 | ||
|
|
bb671c2375 | ||
|
|
001b869de9 | ||
|
|
23e991bb39 | ||
|
|
a27ae38d60 | ||
|
|
be9433b7a3 | ||
|
|
24fe31b934 | ||
|
|
c733e68325 | ||
|
|
519936dbd9 | ||
|
|
3e911fa113 | ||
|
|
c391cddfa8 | ||
|
|
a3aa68f5a1 | ||
|
|
132528a678 | ||
|
|
8b1992e028 | ||
|
|
dc34d7d472 | ||
|
|
8df9e6c2fb | ||
|
|
85c56c3e69 |
No files matched your search
+1
-1
@@ -1,3 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [itsmikethetech, zjoasan, bud3699]
|
||||
github: [itsmikethetech, zjoasan]
|
||||
@@ -0,0 +1,120 @@
|
||||
name: Help Request
|
||||
description: Request help with an issue.
|
||||
title: "[Help]: "
|
||||
labels: ["help wanted", "triage"]
|
||||
assignees: ["zjoasan", "bud3699", "itsmikethetech"]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for reaching out! Please provide as much detail as possible to help us assist you.
|
||||
|
||||
- type: dropdown
|
||||
id: OS
|
||||
attributes:
|
||||
label: Which OS?
|
||||
description: What version of Windows are you using?
|
||||
options:
|
||||
- Win11 Pro
|
||||
- Win11 Home
|
||||
- Win10 Pro
|
||||
- Win10 Home
|
||||
- Other..
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: Version
|
||||
attributes:
|
||||
label: Which release?
|
||||
description: What version of Windows are you running?
|
||||
options:
|
||||
- 24H2
|
||||
- 23H2
|
||||
- 22H2
|
||||
- 21H2
|
||||
- 1809
|
||||
- 1607
|
||||
- 1507
|
||||
- Other..
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
If you need help finding your Windows version, go to Settings -> System -> About.
|
||||
|
||||
- type: input
|
||||
id: driver-version
|
||||
attributes:
|
||||
label: Driver Version
|
||||
description: What driver version are you using?
|
||||
placeholder: Enter driver version here.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: device-specs
|
||||
attributes:
|
||||
label: Device Specifications
|
||||
description: Provide details about your hardware. This is to help us indentify whether its a potential hardware incompatibility. This isnt needed but helps.
|
||||
placeholder: |
|
||||
CPU: Example CPU
|
||||
GPU: Example GPU
|
||||
RAM: Example Ram
|
||||
MOBO: Example Motherboard
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: issue-info
|
||||
attributes:
|
||||
label: What issue are you experiencing or what do you need help with?
|
||||
description: Describe the issue you need help with.
|
||||
placeholder: |
|
||||
Provide a clear and concise description of the help you need.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: troubleshooting-steps
|
||||
attributes:
|
||||
label: Troubleshooting steps taken
|
||||
description: What have you tried so far to fix the issue?
|
||||
placeholder: |
|
||||
List steps you've taken to resolve/assist the problem.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: expected-outcome
|
||||
attributes:
|
||||
label: Expected outcome
|
||||
description: What were you expecting/want to happen?
|
||||
placeholder: |
|
||||
Describe the behavior you expected/want.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: additional-info
|
||||
attributes:
|
||||
label: Additional information
|
||||
description: Any extra details that might help us assist you.
|
||||
placeholder: |
|
||||
Provide any relevant logs, screenshots, or error messages.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: input
|
||||
id: contact
|
||||
attributes:
|
||||
label: Contact Details
|
||||
description: How can we reach you if we need more information?
|
||||
placeholder: ex. email@example.com
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,44 @@
|
||||
name: Question
|
||||
|
||||
description: Ask a general question.
|
||||
|
||||
title: "[Question]: "
|
||||
|
||||
labels: ["question", "triage"]
|
||||
|
||||
assignees: ["zjoasan", "bud3699", "itsmikethetech"]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for reaching out! Please provide as much detail as possible to help us understand your question.
|
||||
|
||||
- type: textarea
|
||||
id: question-info
|
||||
attributes:
|
||||
label: What is your question?
|
||||
description: Provide details about your question.
|
||||
placeholder: |
|
||||
Describe your question clearly so we can assist you effectively.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: additional-info
|
||||
attributes:
|
||||
label: Additional information
|
||||
description: Any extra details that might help us answer your question.
|
||||
placeholder: |
|
||||
Provide any relevant context, screenshots, or references.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: input
|
||||
id: contact
|
||||
attributes:
|
||||
label: Contact Details
|
||||
description: How can we reach you if we need more information?
|
||||
placeholder: ex. email@example.com
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,124 @@
|
||||
name: Bug Report
|
||||
description: File a bug report.
|
||||
title: "[Bug]: "
|
||||
labels: ["bug", "triage"]
|
||||
assignees: ["zjoasan", "bud3699", "itsmikethetech"]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
|
||||
- type: dropdown
|
||||
id: OS
|
||||
attributes:
|
||||
label: Which OS?
|
||||
description: What version of Windows are you running?
|
||||
options:
|
||||
- Win11 Pro
|
||||
- Win11 Home
|
||||
- Win10 Pro
|
||||
- Win10 Home
|
||||
- Other..
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: Version
|
||||
attributes:
|
||||
label: Which release?
|
||||
description: What version of Windows are you running?
|
||||
options:
|
||||
- 24H2
|
||||
- 23H2
|
||||
- 22H2
|
||||
- 21H2
|
||||
- 1809
|
||||
- 1607
|
||||
- 1507
|
||||
- Other..
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
If you struggle finding Windows edition and version, go to Settings -> System -> About. Under Windows specifications.
|
||||
|
||||
- type: input
|
||||
id: driver-version
|
||||
attributes:
|
||||
label: Driver Version
|
||||
description: What driver version are you using?
|
||||
placeholder: Enter driver version here.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: device-specs
|
||||
attributes:
|
||||
label: Device Specifications
|
||||
description: Provide details about your hardware. This is to help us indentify whether its a potential hardware issue.
|
||||
placeholder: |
|
||||
CPU: Example CPU
|
||||
GPU: Example GPU
|
||||
RAM: Example Ram
|
||||
MOBO: Example Motherboard
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: bug-info
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: Free text description.
|
||||
placeholder: |
|
||||
Tell us what you see!
|
||||
A clear and concise description of what the bug is.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: reproduce-info
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: And if you can, how to reproduce
|
||||
placeholder: |
|
||||
Tell us how to reproduce!
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Observe issue.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: expected-info
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: Please inform us about expected behavior.
|
||||
placeholder: |
|
||||
Description of behavior!
|
||||
When I clicked...
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: log-file
|
||||
attributes:
|
||||
label: Log File
|
||||
description: Please attach the log file to help us diagnose the issue. You can drag and drop the file here or click to upload. The log can be retrieved by enabling the log file in the XML, then restarting the driver.
|
||||
placeholder: Drag and drop the log file here or click to upload.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: input
|
||||
id: contact
|
||||
attributes:
|
||||
label: Contact Details
|
||||
description: How can we get in touch with you if we need more info?
|
||||
placeholder: ex. email@example.com
|
||||
validations:
|
||||
required: false
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Feature Request
|
||||
description: Request a new Feature.
|
||||
title: "[Feature]: "
|
||||
labels: ["remove", "customize", "companion", "enhancement", "newcode"]
|
||||
assignees: ["zjoasan", "bud3699", "itsmikethetech"]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this feature request report!
|
||||
- type: textarea
|
||||
id: frprob
|
||||
attributes:
|
||||
label: Is the feature related to a "problem"?
|
||||
description: Describe the problem, in detail.
|
||||
placeholder: Tell us how to reproduce
|
||||
value: "When start X I wish to.."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: your-solution
|
||||
attributes:
|
||||
label: Your suggestion
|
||||
description: Describe what would solve your problem, as detailed as possible.
|
||||
placeholder: Tell us how to progress!
|
||||
value: "Disable a specific VD via hotkey"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: contact
|
||||
attributes:
|
||||
label: Contact Details
|
||||
description: How can we get in touch with you if we need more info?
|
||||
placeholder: ex. email@example.com
|
||||
validations:
|
||||
required: false
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
name: Virtual Display Driver Signpath Request
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
platform: [x64, ARM64]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
|
||||
- name: Check Chocolatey installation
|
||||
run: choco --version
|
||||
|
||||
- name: Install Visual Studio 2022 dependencies
|
||||
run: |
|
||||
choco install visualstudio2022-workload-manageddesktop -y
|
||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||
|
||||
choco install visualstudio2022-workload-nativedesktop -y
|
||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||
|
||||
choco install visualstudio2022-workload-vctools -y
|
||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||
|
||||
choco install windowsdriverkit11 -y
|
||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||
|
||||
- name: Build the driver
|
||||
run: |
|
||||
msbuild "Virtual Display Driver (HDR)/MTTVDD.sln" /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }}
|
||||
|
||||
- name: List build directory
|
||||
run: dir "Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD"
|
||||
|
||||
- name: Upload built driver
|
||||
id: upload_artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Built-Driver-${{ matrix.configuration }}-${{ matrix.platform }}
|
||||
path: |
|
||||
Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD\MttVDD.dll
|
||||
Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD\MttVDD.inf
|
||||
Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD\mttvdd.cat
|
||||
Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD\vdd_settings.xml
|
||||
|
||||
- name: Generate release tag
|
||||
id: generate_tag
|
||||
run: |
|
||||
$releaseTag = (Get-Date).ToString('yy.MM.dd')
|
||||
echo "RELEASE_TAG=$releaseTag" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Show generated release tag
|
||||
run: |
|
||||
echo "Generated Release Tag: ${{ env.RELEASE_TAG }}"
|
||||
|
||||
- name: Verify Built Artifacts
|
||||
run: dir 'Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD'
|
||||
|
||||
|
||||
- name: Submit signing request to SignPath
|
||||
id: signpath_request
|
||||
uses: signpath/github-action-submit-signing-request@v1
|
||||
with:
|
||||
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
|
||||
organization-id: '${{ vars.SIGNPATH_ORG_ID }}'
|
||||
project-slug: '${{ vars.SIGNPATH_PROJECT_SLUG }}'
|
||||
signing-policy-slug: '${{ vars.SIGNPATH_POLICY_SLUG }}'
|
||||
github-artifact-id: '${{ steps.upload_artifact.outputs.artifact-id }}'
|
||||
wait-for-completion: true
|
||||
output-artifact-directory: '${{ vars.SIGNPATH_OUTPUT_DIR }}'
|
||||
parameters: |
|
||||
Version: ${{ toJSON(matrix.configuration) }}
|
||||
Release_Tag: "${{ env.RELEASE_TAG }}"
|
||||
|
||||
- name: Verify Signed Artifacts
|
||||
run: dir '${{ vars.SIGNPATH_OUTPUT_DIR }}'
|
||||
|
||||
- name: Upload signed artifacts
|
||||
id: upload_signed_artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Signed-Driver-${{ matrix.configuration }}-${{ matrix.platform }}
|
||||
path: |
|
||||
${{ vars.SIGNPATH_OUTPUT_DIR }}\MttVDD.dll
|
||||
${{ vars.SIGNPATH_OUTPUT_DIR }}\MttVDD.inf
|
||||
${{ vars.SIGNPATH_OUTPUT_DIR }}\mttvdd.cat
|
||||
${{ vars.SIGNPATH_OUTPUT_DIR }}\vdd_settings.xml
|
||||
|
||||
- name: Prepare Setup Repository
|
||||
run: |
|
||||
git clone https://${{ secrets.READ_REPO }}@github.com/VirtualDisplay/Virtual-Driver-Installer.git inno-setup
|
||||
|
||||
- name: Prepare Setup
|
||||
run: |
|
||||
copy "${{ vars.SIGNPATH_OUTPUT_DIR }}\*" inno-setup\input\
|
||||
$platform = "${{ matrix.platform }}"
|
||||
(Get-Content "inno-setup\Setup.iss") |
|
||||
ForEach-Object { $_ -replace '1.0.0', '${{ env.RELEASE_TAG }}' } |
|
||||
Set-Content "inno-setup\Setup.iss"
|
||||
|
||||
if ($platform -eq 'ARM64') {
|
||||
(Get-Content "inno-setup\Setup.iss") |
|
||||
ForEach-Object { $_ -replace 'x64compatible', 'arm64' } |
|
||||
Set-Content "inno-setup\Setup.iss"
|
||||
|
||||
(Get-Content "inno-setup\Setup.iss") |
|
||||
ForEach-Object { $_ -replace '-x64', '-arm64' } |
|
||||
Set-Content "inno-setup\Setup.iss"
|
||||
|
||||
if (Test-Path "inno-setup\input\Companion\VDDSysTray.exe") {Remove-Item "inno-setup\input\Companion\VDDSysTray.exe"}
|
||||
copy "inno-setup\input\Companion\arm64\VDDSysTray.exe" "inno-setup\input\Companion\"
|
||||
}
|
||||
|
||||
- name: Compile Installer
|
||||
uses: Minionguyjpro/Inno-Setup-Action@v1.2.2
|
||||
with:
|
||||
path: inno-setup\Setup.iss
|
||||
options: /O+
|
||||
|
||||
- name: Upload Installer as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Installer-${{ matrix.configuration }}-${{ matrix.platform }}
|
||||
path: inno-setup\output\*.exe
|
||||
|
||||
|
||||
celebrate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Celebrate
|
||||
run: |
|
||||
echo "Bud is a god, also hi if you're looking at this!"
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
name: Virtual Display Driver Building
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Debug, Release]
|
||||
platform: [x64, ARM64]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1
|
||||
|
||||
- name: Check Chocolatey installation
|
||||
run: choco --version
|
||||
|
||||
- name: Install Visual Studio 2022 dependencies
|
||||
run: |
|
||||
choco install visualstudio2022-workload-manageddesktop -y
|
||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||
|
||||
choco install visualstudio2022-workload-nativedesktop -y
|
||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||
|
||||
choco install visualstudio2022-workload-vctools -y
|
||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||
|
||||
choco install windowsdriverkit11 -y
|
||||
if ($LASTEXITCODE -ne 0) { exit 1 }
|
||||
|
||||
- name: Build the driver
|
||||
run: |
|
||||
msbuild "Virtual Display Driver (HDR)/MTTVDD.sln" /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }}
|
||||
|
||||
- name: List build directory
|
||||
run: dir "Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD"
|
||||
|
||||
- name: Upload built driver
|
||||
id: upload_artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Built-Driver-${{ matrix.configuration }}-${{ matrix.platform }}
|
||||
path: |
|
||||
Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD\MttVDD.dll
|
||||
Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD\MttVDD.inf
|
||||
Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD\mttvdd.cat
|
||||
Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD\vdd_settings.xml
|
||||
|
||||
- name: Generate release tag
|
||||
id: generate_tag
|
||||
run: |
|
||||
$releaseTag = (Get-Date).ToString('yy.MM.dd')
|
||||
echo "RELEASE_TAG=$releaseTag" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Show generated release tag
|
||||
run: |
|
||||
echo "Generated Release Tag: ${{ env.RELEASE_TAG }}"
|
||||
|
||||
- name: Verify Built Artifacts
|
||||
run: dir 'Virtual Display Driver (HDR)\${{ matrix.platform }}\${{ matrix.configuration }}\MttVDD'
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
#pragma once
|
||||
|
||||
#include <wrl/client.h> // For ComPtr
|
||||
#include <dxgi.h> // For IDXGIAdapter, IDXGIFactory1
|
||||
#include <algorithm> // For sort
|
||||
|
||||
using namespace std;
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
// Structure to vector gpus
|
||||
struct GPUInfo {
|
||||
wstring name; // GPU name
|
||||
ComPtr<IDXGIAdapter> adapter;// COM pointer to the adapter
|
||||
DXGI_ADAPTER_DESC desc; // Adapter description
|
||||
};
|
||||
|
||||
// Sort function for GPUs by dedicated video memory
|
||||
bool CompareGPUs(const GPUInfo& a, const GPUInfo& b) {
|
||||
return a.desc.DedicatedVideoMemory > b.desc.DedicatedVideoMemory;
|
||||
}
|
||||
|
||||
// Get a enumerate list of available GPUs
|
||||
vector<GPUInfo> getAvailableGPUs() {
|
||||
vector<GPUInfo> gpus; // Vector to hold all GPU's information
|
||||
|
||||
ComPtr<IDXGIFactory1> factory;
|
||||
if (!SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) {
|
||||
return gpus;
|
||||
}
|
||||
|
||||
// Enumerate all adapters (GPUs)
|
||||
for (UINT i = 0;; i++) {
|
||||
ComPtr<IDXGIAdapter> adapter;
|
||||
if (!SUCCEEDED(factory->EnumAdapters(i, &adapter))) {
|
||||
break;
|
||||
}
|
||||
|
||||
DXGI_ADAPTER_DESC desc;
|
||||
|
||||
if (!SUCCEEDED(adapter->GetDesc(&desc))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add the adapter information to the list
|
||||
GPUInfo info{ desc.Description, adapter, desc };
|
||||
gpus.push_back(info);
|
||||
}
|
||||
|
||||
return gpus;
|
||||
}
|
||||
|
||||
class AdapterOption {
|
||||
public:
|
||||
bool hasTargetAdapter{}; // Indicates if a target adapter is selected
|
||||
LUID adapterLuid{}; // Adapter's unique identifier (LUID)
|
||||
wstring target_name{}; // Target adapter name
|
||||
|
||||
// Select the best GPU based on dedicated video memory
|
||||
wstring selectBestGPU() {
|
||||
auto gpus = getAvailableGPUs();
|
||||
if (gpus.empty()) {
|
||||
return L""; // Error check for headless / vm
|
||||
}
|
||||
|
||||
// Sort GPUs by dedicated video memory in descending order
|
||||
sort(gpus.begin(), gpus.end(), CompareGPUs);
|
||||
auto bestGPU = gpus.front(); // Get the GPU with the most memory
|
||||
|
||||
return bestGPU.name;
|
||||
}
|
||||
|
||||
// Load friendlyname from a file OR select the best GPU
|
||||
void load(const wchar_t* path) {
|
||||
ifstream ifs{ path };
|
||||
|
||||
if (!ifs.is_open()) {
|
||||
target_name = selectBestGPU();
|
||||
}
|
||||
else {
|
||||
string line;
|
||||
getline(ifs, line);
|
||||
target_name.assign(line.begin(), line.end());
|
||||
}
|
||||
|
||||
// Find and set the adapter based on the target name
|
||||
if (!findAndSetAdapter(target_name)) {
|
||||
// If the adapter is not found, select the best GPU and retry
|
||||
target_name = selectBestGPU();
|
||||
findAndSetAdapter(target_name);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the target adapter from a given name and validate it
|
||||
void xmlprovide(const wstring& xtarg) {
|
||||
target_name = xtarg;
|
||||
if (!findAndSetAdapter(target_name)) {
|
||||
// If the adapter is not found, select the best GPU and retry
|
||||
target_name = selectBestGPU();
|
||||
findAndSetAdapter(target_name);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the adapter settings to the specified adapter
|
||||
void apply(const IDDCX_ADAPTER& adapter) {
|
||||
if (hasTargetAdapter && IDD_IS_FUNCTION_AVAILABLE(IddCxAdapterSetRenderAdapter)) {
|
||||
IDARG_IN_ADAPTERSETRENDERADAPTER arg{};
|
||||
arg.PreferredRenderAdapter = adapterLuid;
|
||||
IddCxAdapterSetRenderAdapter(adapter, &arg);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// Find and set the adapter by its name
|
||||
bool findAndSetAdapter(const wstring& adapterName) {
|
||||
auto gpus = getAvailableGPUs();
|
||||
|
||||
// Iterate through all available GPUs
|
||||
for (const auto& gpu : gpus) {
|
||||
if (_wcsicmp(gpu.name.c_str(), adapterName.c_str()) == 0) {
|
||||
adapterLuid = gpu.desc.AdapterLuid; // Set the adapter LUID
|
||||
hasTargetAdapter = true; // Indicate that a target adapter is selected
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
hasTargetAdapter = false; // Indicate that no target adapter is selected
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
Required include(s). Plans to combine it into the driver to reduce includes.
|
||||
@@ -0,0 +1,28 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
# Install dependencies if required
|
||||
. "$PSScriptRoot\set-dependencies.ps1"
|
||||
|
||||
# Getting the correct display
|
||||
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
|
||||
|
||||
$bpcc = Get-DisplayColorInfo -DisplayId $disp.DisplayId | Select-Object BitsPerColorChannel | Select-Object -ExpandProperty BitsPerColorChannel
|
||||
|
||||
if ( $bpcc -is [int] ) {
|
||||
if ( $bpcc -gt 8 ) {
|
||||
Disable-DisplayAdvancedColor -DisplayId $disp
|
||||
break
|
||||
}
|
||||
if ( $bpcc -lt 10 ) {
|
||||
Enable-DisplayAdvancedColor -DisplayId $disp
|
||||
break
|
||||
}
|
||||
}
|
||||
else { write-error "Something went wrong in identifying the Colormode of the display." ; break }
|
||||
@@ -0,0 +1,9 @@
|
||||
#Scripts
|
||||
|
||||
This is a collection of Powershell scripts, written during the whole driver development. There haven't been a focus on keeping the scripts "up to date" all the time. Which means changes that might have occurred in the modules that these scripts depend upon, haven't been corrected either.
|
||||
|
||||
This is more ment as a framework for "tinkers" to make use of Powershell to change settings on the fly.
|
||||
|
||||
To use these, you should be at least be comfortable with Powershell and understand Admin privilegiets, risk/reward.
|
||||
|
||||
PR's are welcome for improvements or other/more functions.
|
||||
@@ -0,0 +1,27 @@
|
||||
param(
|
||||
[Parameter(Mandatory, Position=0)]
|
||||
[Alias("X","HorizontalResolution")]
|
||||
[int]$xres,
|
||||
[Parameter(Mandatory, Position=1)]
|
||||
[Alias("Y","VerticalResolution")]
|
||||
[int]$yres
|
||||
)
|
||||
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
|
||||
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
|
||||
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# Install dependencies if required
|
||||
. "$PSScriptRoot\set-dependencies.ps1"
|
||||
|
||||
# Getting the correct display
|
||||
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
|
||||
|
||||
# Setting the resolution on the display
|
||||
Set-DisplayResolution -DisplayId $disp.DisplayId -Width $xres -Height $yres
|
||||
@@ -0,0 +1 @@
|
||||
Get-Monitor | Where-Object { $_.InstanceName -like '*MTT1337*' } | Sort-Object { [int] (($_.InstanceName -match 'UID(\d+)') -and $Matches[1]) } | Select-Object -First 1 -ExpandProperty LogicalDisplay | select-object Devicename
|
||||
@@ -0,0 +1,20 @@
|
||||
@echo off
|
||||
|
||||
:: Use PowerShell for elevation check and execution
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
||||
"$elevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator');" ^
|
||||
"if (-not $elevated) {" ^
|
||||
"$CommandLine = '-File \"' + $MyInvocation.MyCommand.Path + '\" ' + $MyInvocation.UnboundArguments;" ^
|
||||
"Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine;" ^
|
||||
"Exit" ^
|
||||
"} else {" ^
|
||||
"Install-Module -Name DisplayConfig -Scope AllUsers -Force -AllowClobber;" ^
|
||||
"Install-Module -Name MonitorConfig -Scope AllUsers -Force -AllowClobber;" ^
|
||||
"if ($?) {" ^
|
||||
"Write-Output 'Modules installed successfully.'" ^
|
||||
"} else {" ^
|
||||
"Write-Output 'An error occurred while installing the modules.'" ^
|
||||
"}" ^
|
||||
"}"
|
||||
|
||||
pause
|
||||
@@ -0,0 +1,15 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
# Install dependencies if required
|
||||
. "$PSScriptRoot\set-dependencies.ps1"
|
||||
|
||||
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
|
||||
|
||||
Set-DisplayPrimary -DisplayId $disp.DisplayId
|
||||
@@ -0,0 +1,34 @@
|
||||
param(
|
||||
[Parameter(Mandatory, Position = 0)]
|
||||
[ValidateSet(
|
||||
30,
|
||||
60,
|
||||
75,
|
||||
90,
|
||||
120,
|
||||
144,
|
||||
165,
|
||||
240,
|
||||
480,
|
||||
500)]
|
||||
[int]$refreshrate
|
||||
)
|
||||
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
|
||||
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
|
||||
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# install dependencies if required
|
||||
. "$PSScriptRoot\set-dependencies.ps1"
|
||||
|
||||
# Getting the correct display
|
||||
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
|
||||
|
||||
# Setting the refresh rate on the correct display.
|
||||
Set-DisplayRefreshRate -DisplayId $disp.DisplayId -RefreshRate $rate
|
||||
@@ -0,0 +1,42 @@
|
||||
param(
|
||||
[Parameter(Mandatory, Position = 0)]
|
||||
[ValidateSet(90, 180, 270)]
|
||||
[int]$rotate
|
||||
)
|
||||
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
|
||||
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
|
||||
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# install dependencies if required.
|
||||
. "$PSScriptRoot\set-dependencies.ps1"
|
||||
|
||||
switch ($rotate) {
|
||||
90 {
|
||||
$degree = "Rotate90"
|
||||
continue
|
||||
}
|
||||
180 {
|
||||
$degree = "Rotate180"
|
||||
continue
|
||||
}
|
||||
270 {
|
||||
$degree = "Rotate270"
|
||||
continue
|
||||
}
|
||||
default { Write-Error "Invalid rotation angle(valid 90,180,270)."; break }
|
||||
}
|
||||
|
||||
|
||||
# Getting the correct display
|
||||
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
|
||||
|
||||
# Setting the resolution on the correct display.
|
||||
Set-DisplayRotation -DisplayId $disp.DisplayId -Rotation $degree
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
[CmdletBinding(DefaultParameterSetName = "UserDefined")]
|
||||
param(
|
||||
[Parameter(Mandatory, Position = 0, ParameterSetName = "UserDefined")]
|
||||
[ValidateSet("100", "125", "150", "175", "200", "225", "250", "300", "350", "400", "450", "500")]
|
||||
[int]$scale,
|
||||
|
||||
[Parameter(Mandatory, ParameterSetName = "Recommended")]
|
||||
[switch]$reset
|
||||
)
|
||||
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
|
||||
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
|
||||
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# Install dependencies if required.
|
||||
. "$PSScriptRoot\set-dependencies.ps1"
|
||||
|
||||
# Getting the correct display
|
||||
$disp = Get-DisplayInfo | Where-Object { $_.DisplayName -eq "VDD by MTT" }
|
||||
|
||||
$maxscale = Get-DisplayScale -DisplayId $disp.DisplayId | Select-Object -ExpandProperty MaxScale
|
||||
if ( $PSCmdlet.ParameterSetName -eq "UserDefined" ) {
|
||||
Write-Host "Setting scale to $scale"
|
||||
if ( $scale -le $maxscale ) {
|
||||
Set-DisplayScale -DisplayId $disp.DisplayId -Scale $scale
|
||||
}
|
||||
else {
|
||||
Write-Error "Scale percentage $scale is higher than max scale $maxscale"
|
||||
}
|
||||
}
|
||||
elseif ( $PSCmdlet.ParameterSetName -eq "Recommended" ) {
|
||||
Set-DisplayScale -DisplayId $disp.DisplayId -Recommended
|
||||
}
|
||||
else {
|
||||
Write-Error "Invalid arguments: 'reset' or a valid percentage value like 150 is acceptable."
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
# Define the repository name and URL
|
||||
$repo = @{Name = "PSGallery"; Url = "https://www.powershellgallery.com/api/v2" }
|
||||
|
||||
# Define the requred modules and their required versions BEFORE using them
|
||||
$modules = @(
|
||||
@{
|
||||
Name = "DisplayConfig"
|
||||
Version = "1.1.1"
|
||||
},
|
||||
@{
|
||||
Name = "MonitorConfig"
|
||||
Version = "1.0.3"
|
||||
}
|
||||
)
|
||||
Write-Output "resolving dependencies"
|
||||
|
||||
# Check if the repository is registered
|
||||
if (-not (Get-PSRepository -Name $repo.Name -ErrorAction SilentlyContinue)) {
|
||||
Write-Host "PSRepository '$($repo.Name)' cannot be found. Make sure it is available."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Trust the repository (this sets the installation policy to Trusted)
|
||||
Set-PSRepository -Name $repo.Name -InstallationPolicy Trusted `
|
||||
-InformationAction Ignore -WarningAction SilentlyContinue
|
||||
|
||||
# Loop through the modules and ensure they are imported & installed
|
||||
foreach ($m in $modules) {
|
||||
|
||||
# If the module is already imported, continue to the next module
|
||||
if (Get-Module -Name $m.Name) {
|
||||
Write-Output "$($m.Name) is imported."
|
||||
continue
|
||||
}
|
||||
|
||||
# If the module is available on disk then import it
|
||||
elseif (Get-Module -ListAvailable -Name $m.Name) {
|
||||
Write-Output "$($m.Name) is installed but not imported: import."
|
||||
Import-Module $m.Name
|
||||
}
|
||||
else {
|
||||
# If the module is not on disk, check if it's available in the online gallery
|
||||
if (Find-Module -Name $m.Name -ErrorAction SilentlyContinue) {
|
||||
Write-Output "$($m.Name) is available online, but not installed or imported: install and import."
|
||||
# Install the module (specifying the required version)
|
||||
Install-Module -Name $m.Name -RequiredVersion $m.Version `
|
||||
-Force -Scope CurrentUser -AllowClobber
|
||||
|
||||
# Import the module after installation
|
||||
Import-Module $m.Name
|
||||
}
|
||||
else {
|
||||
# If the module cannot be found in the online gallery, abort the script.
|
||||
Write-Output "Module '$($m.Name)' is not imported, not available on disk, and not found in the online gallery. Cannot run the script."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
# Save Module for later use
|
||||
if (-not (Get-InstalledModule -Name $m.Name -MinimumVersion $m.Version -ErrorAction SilentlyContinue)) {
|
||||
Write-Output "Saving module $($m.Name)."
|
||||
Save-Module -Name $m.Name -Repository $repo.Name -RequiredVersion $m.Version `
|
||||
-Confirm:$false -InformationAction Ignore -WarningAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
# submitted by zjoasan
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
@@ -7,7 +8,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$device = get-pnpdevice -class Display -FriendlyName 'Virtual Display' -ErrorAction SilentlyContinue
|
||||
$device = Get-PnpDevice -Class Display -ErrorAction SilentlyContinue | Where-Object { $_.FriendlyName -eq 'IddSampleDriver Device HDR' -or $_.FriendlyName -eq 'Virtual Display Driver' }
|
||||
|
||||
if ($device) {
|
||||
if ($device.Status -eq 'OK') {
|
||||
@@ -0,0 +1,23 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" "
|
||||
$MyInvocation.BoundParameters.GetEnumerator() | ForEach-Object { $CommandLine += "-$($_.Key):$($_.Value) " }
|
||||
Start-Process -WorkingDirectory $PSScriptRoot -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# install dependencies if required
|
||||
. "$PSScriptRoot\set-dependencies.ps1"
|
||||
|
||||
$profi = Get-DisplayProfile
|
||||
|
||||
if ( $profi -eq "Extend" ) {
|
||||
Set-DisplayProfile Clone
|
||||
break
|
||||
}
|
||||
if ( $profi -eq "Clone" ) {
|
||||
Set-DisplayProfile Extend
|
||||
break
|
||||
}
|
||||
@@ -1,998 +0,0 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Abstract:
|
||||
|
||||
This module contains a sample implementation of an indirect display driver. See the included README.md file and the
|
||||
various TODO blocks throughout this file and all accompanying files for information on building a production driver.
|
||||
|
||||
MSDN documentation on indirect displays can be found at https://msdn.microsoft.com/en-us/library/windows/hardware/mt761968(v=vs.85).aspx.
|
||||
|
||||
Environment:
|
||||
|
||||
User Mode, UMDF
|
||||
|
||||
--*/
|
||||
|
||||
#include "Driver.h"
|
||||
//#include "Driver.tmh"
|
||||
#include<fstream>
|
||||
#include<sstream>
|
||||
#include<string>
|
||||
#include<tuple>
|
||||
#include<vector>
|
||||
// jocke added for comming dynamic edid loading
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace Microsoft::IndirectDisp;
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
extern "C" DRIVER_INITIALIZE DriverEntry;
|
||||
|
||||
EVT_WDF_DRIVER_DEVICE_ADD IddSampleDeviceAdd;
|
||||
EVT_WDF_DEVICE_D0_ENTRY IddSampleDeviceD0Entry;
|
||||
|
||||
EVT_IDD_CX_ADAPTER_INIT_FINISHED IddSampleAdapterInitFinished;
|
||||
EVT_IDD_CX_ADAPTER_COMMIT_MODES IddSampleAdapterCommitModes;
|
||||
|
||||
EVT_IDD_CX_PARSE_MONITOR_DESCRIPTION IddSampleParseMonitorDescription;
|
||||
EVT_IDD_CX_MONITOR_GET_DEFAULT_DESCRIPTION_MODES IddSampleMonitorGetDefaultModes;
|
||||
EVT_IDD_CX_MONITOR_QUERY_TARGET_MODES IddSampleMonitorQueryModes;
|
||||
|
||||
EVT_IDD_CX_MONITOR_ASSIGN_SWAPCHAIN IddSampleMonitorAssignSwapChain;
|
||||
EVT_IDD_CX_MONITOR_UNASSIGN_SWAPCHAIN IddSampleMonitorUnassignSwapChain;
|
||||
|
||||
EVT_IDD_CX_ADAPTER_QUERY_TARGET_INFO IddSampleEvtIddCxAdapterQueryTargetInfo;
|
||||
EVT_IDD_CX_MONITOR_SET_DEFAULT_HDR_METADATA IddSampleEvtIddCxMonitorSetDefaultHdrMetadata;
|
||||
EVT_IDD_CX_PARSE_MONITOR_DESCRIPTION2 IddSampleEvtIddCxParseMonitorDescription2;
|
||||
EVT_IDD_CX_MONITOR_QUERY_TARGET_MODES2 IddSampleEvtIddCxMonitorQueryTargetModes2;
|
||||
EVT_IDD_CX_ADAPTER_COMMIT_MODES2 IddSampleEvtIddCxAdapterCommitModes2;
|
||||
|
||||
EVT_IDD_CX_MONITOR_SET_GAMMA_RAMP IddSampleEvtIddCxMonitorSetGammaRamp;
|
||||
|
||||
vector<tuple<int, int, int>> monitorModes;
|
||||
vector< DISPLAYCONFIG_VIDEO_SIGNAL_INFO> s_KnownMonitorModes2;
|
||||
UINT numVirtualDisplays;
|
||||
|
||||
|
||||
std::vector<unsigned char>
|
||||
Microsoft::IndirectDisp::IndirectDeviceContext::s_knownMonitorEdidData;
|
||||
|
||||
struct IndirectDeviceContextWrapper
|
||||
{
|
||||
IndirectDeviceContext* pContext;
|
||||
|
||||
void Cleanup()
|
||||
{
|
||||
delete pContext;
|
||||
pContext = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
// This macro creates the methods for accessing an IndirectDeviceContextWrapper as a context for a WDF object
|
||||
WDF_DECLARE_CONTEXT_TYPE(IndirectDeviceContextWrapper);
|
||||
|
||||
extern "C" BOOL WINAPI DllMain(
|
||||
_In_ HINSTANCE hInstance,
|
||||
_In_ UINT dwReason,
|
||||
_In_opt_ LPVOID lpReserved)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hInstance);
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
UNREFERENCED_PARAMETER(dwReason);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
extern "C" NTSTATUS DriverEntry(
|
||||
PDRIVER_OBJECT pDriverObject,
|
||||
PUNICODE_STRING pRegistryPath
|
||||
)
|
||||
{
|
||||
WDF_DRIVER_CONFIG Config;
|
||||
NTSTATUS Status;
|
||||
|
||||
WDF_OBJECT_ATTRIBUTES Attributes;
|
||||
WDF_OBJECT_ATTRIBUTES_INIT(&Attributes);
|
||||
|
||||
WDF_DRIVER_CONFIG_INIT(&Config,
|
||||
IddSampleDeviceAdd
|
||||
);
|
||||
|
||||
Status = WdfDriverCreate(pDriverObject, pRegistryPath, &Attributes, &Config, WDF_NO_HANDLE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
vector<string> split(string& input, char delimiter)
|
||||
{
|
||||
istringstream stream(input);
|
||||
string field;
|
||||
vector<string> result;
|
||||
while (getline(stream, field, delimiter)) {
|
||||
result.push_back(field);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void loadOptions(string filepath) {
|
||||
ifstream ifs(filepath);
|
||||
|
||||
string line;
|
||||
vector<tuple<int, int, int>> res;
|
||||
getline(ifs, line);//num of displays
|
||||
numVirtualDisplays = stoi(line);
|
||||
while (getline(ifs, line)) {
|
||||
vector<string> strvec = split(line, ',');
|
||||
if (strvec.size() == 3 && strvec[0].substr(0, 1) != "#") {
|
||||
res.push_back({ stoi(strvec[0]),stoi(strvec[1]),stoi(strvec[2]) });
|
||||
}
|
||||
}
|
||||
monitorModes = res; return;
|
||||
}
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT pDeviceInit)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
WDF_PNPPOWER_EVENT_CALLBACKS PnpPowerCallbacks;
|
||||
|
||||
UNREFERENCED_PARAMETER(Driver);
|
||||
|
||||
// Register for power callbacks - in this sample only power-on is needed
|
||||
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&PnpPowerCallbacks);
|
||||
PnpPowerCallbacks.EvtDeviceD0Entry = IddSampleDeviceD0Entry;
|
||||
WdfDeviceInitSetPnpPowerEventCallbacks(pDeviceInit, &PnpPowerCallbacks);
|
||||
|
||||
IDD_CX_CLIENT_CONFIG IddConfig;
|
||||
IDD_CX_CLIENT_CONFIG_INIT(&IddConfig);
|
||||
|
||||
// If the driver wishes to handle custom IoDeviceControl requests, it's necessary to use this callback since IddCx
|
||||
// redirects IoDeviceControl requests to an internal queue. This sample does not need this.
|
||||
// IddConfig.EvtIddCxDeviceIoControl = IddSampleIoDeviceControl;
|
||||
loadOptions("C:\\IddSampleDriver\\option.txt");
|
||||
IddConfig.EvtIddCxAdapterInitFinished = IddSampleAdapterInitFinished;
|
||||
|
||||
IddConfig.EvtIddCxMonitorGetDefaultDescriptionModes = IddSampleMonitorGetDefaultModes;
|
||||
IddConfig.EvtIddCxMonitorAssignSwapChain = IddSampleMonitorAssignSwapChain;
|
||||
IddConfig.EvtIddCxMonitorUnassignSwapChain = IddSampleMonitorUnassignSwapChain;
|
||||
|
||||
if (IDD_IS_FIELD_AVAILABLE(IDD_CX_CLIENT_CONFIG, EvtIddCxAdapterQueryTargetInfo))
|
||||
{
|
||||
IddConfig.EvtIddCxAdapterQueryTargetInfo = IddSampleEvtIddCxAdapterQueryTargetInfo;
|
||||
IddConfig.EvtIddCxMonitorSetDefaultHdrMetaData = IddSampleEvtIddCxMonitorSetDefaultHdrMetadata;
|
||||
IddConfig.EvtIddCxParseMonitorDescription2 = IddSampleEvtIddCxParseMonitorDescription2;
|
||||
IddConfig.EvtIddCxMonitorQueryTargetModes2 = IddSampleEvtIddCxMonitorQueryTargetModes2;
|
||||
IddConfig.EvtIddCxAdapterCommitModes2 = IddSampleEvtIddCxAdapterCommitModes2;
|
||||
IddConfig.EvtIddCxMonitorSetGammaRamp = IddSampleEvtIddCxMonitorSetGammaRamp;
|
||||
}
|
||||
else {
|
||||
IddConfig.EvtIddCxParseMonitorDescription = IddSampleParseMonitorDescription;
|
||||
IddConfig.EvtIddCxMonitorQueryTargetModes = IddSampleMonitorQueryModes;
|
||||
IddConfig.EvtIddCxAdapterCommitModes = IddSampleAdapterCommitModes;
|
||||
}
|
||||
|
||||
Status = IddCxDeviceInitConfig(pDeviceInit, &IddConfig);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
WDF_OBJECT_ATTRIBUTES Attr;
|
||||
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attr, IndirectDeviceContextWrapper);
|
||||
Attr.EvtCleanupCallback = [](WDFOBJECT Object)
|
||||
{
|
||||
// Automatically cleanup the context when the WDF object is about to be deleted
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(Object);
|
||||
if (pContext)
|
||||
{
|
||||
pContext->Cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
WDFDEVICE Device = nullptr;
|
||||
Status = WdfDeviceCreate(&pDeviceInit, &Attr, &Device);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = IddCxDeviceInitialize(Device);
|
||||
|
||||
// Create a new device context object and attach it to the WDF device object
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(Device);
|
||||
pContext->pContext = new IndirectDeviceContext(Device);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleDeviceD0Entry(WDFDEVICE Device, WDF_POWER_DEVICE_STATE PreviousState)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(PreviousState);
|
||||
|
||||
// This function is called by WDF to start the device in the fully-on power state.
|
||||
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(Device);
|
||||
pContext->pContext->InitAdapter();
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#pragma region Direct3DDevice
|
||||
|
||||
Direct3DDevice::Direct3DDevice(LUID AdapterLuid) : AdapterLuid(AdapterLuid)
|
||||
{
|
||||
}
|
||||
|
||||
Direct3DDevice::Direct3DDevice()
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT Direct3DDevice::Init()
|
||||
{
|
||||
// The DXGI factory could be cached, but if a new render adapter appears on the system, a new factory needs to be
|
||||
// created. If caching is desired, check DxgiFactory->IsCurrent() each time and recreate the factory if !IsCurrent.
|
||||
HRESULT hr = CreateDXGIFactory2(0, IID_PPV_ARGS(&DxgiFactory));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Find the specified render adapter
|
||||
hr = DxgiFactory->EnumAdapterByLuid(AdapterLuid, IID_PPV_ARGS(&Adapter));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Create a D3D device using the render adapter. BGRA support is required by the WHQL test suite.
|
||||
hr = D3D11CreateDevice(Adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT, nullptr, 0, D3D11_SDK_VERSION, &Device, nullptr, &DeviceContext);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// If creating the D3D device failed, it's possible the render GPU was lost (e.g. detachable GPU) or else the
|
||||
// system is in a transient state.
|
||||
return hr;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region SwapChainProcessor
|
||||
|
||||
SwapChainProcessor::SwapChainProcessor(IDDCX_SWAPCHAIN hSwapChain, shared_ptr<Direct3DDevice> Device, HANDLE NewFrameEvent)
|
||||
: m_hSwapChain(hSwapChain), m_Device(Device), m_hAvailableBufferEvent(NewFrameEvent)
|
||||
{
|
||||
m_hTerminateEvent.Attach(CreateEvent(nullptr, FALSE, FALSE, nullptr));
|
||||
|
||||
// Immediately create and run the swap-chain processing thread, passing 'this' as the thread parameter
|
||||
m_hThread.Attach(CreateThread(nullptr, 0, RunThread, this, 0, nullptr));
|
||||
}
|
||||
|
||||
SwapChainProcessor::~SwapChainProcessor()
|
||||
{
|
||||
// Alert the swap-chain processing thread to terminate
|
||||
SetEvent(m_hTerminateEvent.Get());
|
||||
|
||||
if (m_hThread.Get())
|
||||
{
|
||||
// Wait for the thread to terminate
|
||||
WaitForSingleObject(m_hThread.Get(), INFINITE);
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CALLBACK SwapChainProcessor::RunThread(LPVOID Argument)
|
||||
{
|
||||
reinterpret_cast<SwapChainProcessor*>(Argument)->Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SwapChainProcessor::Run()
|
||||
{
|
||||
// For improved performance, make use of the Multimedia Class Scheduler Service, which will intelligently
|
||||
// prioritize this thread for improved throughput in high CPU-load scenarios.
|
||||
DWORD AvTask = 0;
|
||||
HANDLE AvTaskHandle = AvSetMmThreadCharacteristicsW(L"Distribution", &AvTask);
|
||||
|
||||
RunCore();
|
||||
|
||||
// Always delete the swap-chain object when swap-chain processing loop terminates in order to kick the system to
|
||||
// provide a new swap-chain if necessary.
|
||||
WdfObjectDelete((WDFOBJECT)m_hSwapChain);
|
||||
m_hSwapChain = nullptr;
|
||||
|
||||
AvRevertMmThreadCharacteristics(AvTaskHandle);
|
||||
}
|
||||
|
||||
void SwapChainProcessor::RunCore()
|
||||
{
|
||||
// Get the DXGI device interface
|
||||
ComPtr<IDXGIDevice> DxgiDevice;
|
||||
HRESULT hr = m_Device->Device.As(&DxgiDevice);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IDARG_IN_SWAPCHAINSETDEVICE SetDevice = {};
|
||||
SetDevice.pDevice = DxgiDevice.Get();
|
||||
|
||||
hr = IddCxSwapChainSetDevice(m_hSwapChain, &SetDevice);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Acquire and release buffers in a loop
|
||||
for (;;)
|
||||
{
|
||||
ComPtr<IDXGIResource> AcquiredBuffer;
|
||||
|
||||
// Ask for the next buffer from the producer
|
||||
IDARG_IN_RELEASEANDACQUIREBUFFER2 BufferInArgs = {};
|
||||
BufferInArgs.Size = sizeof(BufferInArgs);
|
||||
IDXGIResource* pSurface;
|
||||
|
||||
if (IDD_IS_FUNCTION_AVAILABLE(IddCxSwapChainReleaseAndAcquireBuffer2)) {
|
||||
IDARG_OUT_RELEASEANDACQUIREBUFFER2 Buffer = {};
|
||||
hr = IddCxSwapChainReleaseAndAcquireBuffer2(m_hSwapChain, &BufferInArgs, &Buffer);
|
||||
pSurface = Buffer.MetaData.pSurface;
|
||||
}
|
||||
else
|
||||
{
|
||||
IDARG_OUT_RELEASEANDACQUIREBUFFER Buffer = {};
|
||||
hr = IddCxSwapChainReleaseAndAcquireBuffer(m_hSwapChain, &Buffer);
|
||||
pSurface = Buffer.MetaData.pSurface;
|
||||
}
|
||||
// AcquireBuffer immediately returns STATUS_PENDING if no buffer is yet available
|
||||
if (hr == E_PENDING)
|
||||
{
|
||||
// We must wait for a new buffer
|
||||
HANDLE WaitHandles[] =
|
||||
{
|
||||
m_hAvailableBufferEvent,
|
||||
m_hTerminateEvent.Get()
|
||||
};
|
||||
DWORD WaitResult = WaitForMultipleObjects(ARRAYSIZE(WaitHandles), WaitHandles, FALSE, 16);
|
||||
if (WaitResult == WAIT_OBJECT_0 || WaitResult == WAIT_TIMEOUT)
|
||||
{
|
||||
// We have a new buffer, so try the AcquireBuffer again
|
||||
continue;
|
||||
}
|
||||
else if (WaitResult == WAIT_OBJECT_0 + 1)
|
||||
{
|
||||
// We need to terminate
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The wait was cancelled or something unexpected happened
|
||||
hr = HRESULT_FROM_WIN32(WaitResult);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (SUCCEEDED(hr))
|
||||
{
|
||||
AcquiredBuffer.Attach(pSurface);
|
||||
|
||||
// ==============================
|
||||
// TODO: Process the frame here
|
||||
//
|
||||
// This is the most performance-critical section of code in an IddCx driver. It's important that whatever
|
||||
// is done with the acquired surface be finished as quickly as possible. This operation could be:
|
||||
// * a GPU copy to another buffer surface for later processing (such as a staging surface for mapping to CPU memory)
|
||||
// * a GPU encode operation
|
||||
// * a GPU VPBlt to another surface
|
||||
// * a GPU custom compute shader encode operation
|
||||
// ==============================
|
||||
|
||||
AcquiredBuffer.Reset();
|
||||
hr = IddCxSwapChainFinishedProcessingFrame(m_hSwapChain);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// ==============================
|
||||
// TODO: Report frame statistics once the asynchronous encode/send work is completed
|
||||
//
|
||||
// Drivers should report information about sub-frame timings, like encode time, send time, etc.
|
||||
// ==============================
|
||||
// IddCxSwapChainReportFrameStatistics(m_hSwapChain, ...);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The swap-chain was likely abandoned (e.g. DXGI_ERROR_ACCESS_LOST), so exit the processing loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region IndirectDeviceContext
|
||||
|
||||
const UINT64 MHZ = 1000000;
|
||||
const UINT64 KHZ = 1000;
|
||||
|
||||
constexpr DISPLAYCONFIG_VIDEO_SIGNAL_INFO dispinfo(UINT32 h, UINT32 v, UINT32 r) {
|
||||
const UINT32 clock_rate = r * (v + 4) * (v + 4) + 1000;
|
||||
return {
|
||||
clock_rate, // pixel clock rate [Hz]
|
||||
{ clock_rate, v + 4 }, // fractional horizontal refresh rate [Hz]
|
||||
{ clock_rate, (v + 4) * (v + 4) }, // fractional vertical refresh rate [Hz]
|
||||
{ h, v }, // (horizontal, vertical) active pixel resolution
|
||||
{ h + 4, v + 4 }, // (horizontal, vertical) total pixel resolution
|
||||
{ { 255, 0 }}, // video standard and vsync divider
|
||||
DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Jocke, createing a 512 byte array filled with 0 values (largest edid bin without breaking standards)
|
||||
|
||||
std::vector<BYTE> s_knownMonitorEdidData;
|
||||
|
||||
static void edidLoad(const std::string& filename) {
|
||||
std::wofstream logFile("C:\\IddSampleDriver\\lddlog.txt", std::ios::app);
|
||||
logFile << L"Entered EDIDLoad" << std::endl;
|
||||
|
||||
std::ifstream file(filename, std::ios::binary);
|
||||
if (file.is_open()) {
|
||||
logFile << L"Filename found for custom edid" << std::endl;
|
||||
// Read file into vector
|
||||
s_knownMonitorEdidData = std::vector<BYTE>(std::istreambuf_iterator<char>(file), {});
|
||||
logFile << L"Replacing edid data in custom bin" << std::endl;
|
||||
// Modify bytes at positions 8, 9, 10, and 11
|
||||
s_knownMonitorEdidData[8] = 0x36;
|
||||
s_knownMonitorEdidData[9] = 0x94;
|
||||
s_knownMonitorEdidData[10] = 0x37;
|
||||
s_knownMonitorEdidData[11] = 0x13;
|
||||
logFile << L"calculating new checksum" << std::endl;
|
||||
|
||||
// Calculate checksum
|
||||
int checksum = 0;
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
checksum += s_knownMonitorEdidData[i];
|
||||
}
|
||||
checksum %= 256;
|
||||
uint8_t bytesum = static_cast<BYTE>(checksum);
|
||||
s_knownMonitorEdidData[127] = bytesum; // Store checksum as a byte, all byte number might be off by 1 (don't knwo how c++ handles array/vector position 0, if it's resereved or filed with data
|
||||
logFile << L"Checksum calculated and placed on last byte of edid data" << std::endl;
|
||||
}
|
||||
else {
|
||||
logFile << L"CustomEdid not found, checking default" << std::endl;
|
||||
std::ifstream filedef("default.bin", std::ios::binary);
|
||||
if (filedef.is_open()) {
|
||||
// Read file into vector this is our pre patched default edid
|
||||
s_knownMonitorEdidData = std::vector<BYTE>(std::istreambuf_iterator<char>(filedef), {});
|
||||
logFile << L"Default.bin loaded into edid data" << std::endl;
|
||||
}
|
||||
else { // if all files are gone from install folder then use our minimal hardcoded edid
|
||||
logFile << L"Defaulting to hardcoded edid" << std::endl;
|
||||
string incode = " {\
|
||||
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x36,0x94,0x37,0x13,0x00,0x00,0x00,0x00,\
|
||||
0x05,0x16,0x01,0x03,0x6D,0x32,0x1C,0x78,0xEA,0x5E,0xC0,0xA4,0x59,0x4A,0x98,0x25,\
|
||||
0x20,0x50,0x54,0x00,0x00,0x00,0xD1,0xC0,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,\
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x3A,0x80,0x18,0x71,0x38,0x2D,0x40,0x58,0x2C,\
|
||||
0x45,0x00,0xF4,0x19,0x11,0x00,0x00,0x1E,0x00,0x00,0x00,0xFF,0x00,0x4D,0x54,0x54,\
|
||||
0x31,0x33,0x33,0x37,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFD,0x00,0x3B,\
|
||||
0x3D,0x42,0x44,0x0F,0x00,0x0A,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xFC,\
|
||||
0x00,0x4D,0x54,0x54,0x31,0x33,0x33,0x37,0x0A,0x20,0x20,0x20,0x20,0x20,0x00,0x83}";
|
||||
|
||||
s_knownMonitorEdidData = std::vector<BYTE>(incode.begin(), incode.end());
|
||||
}
|
||||
}
|
||||
logFile << L"Exiting EDID Load and closing log" << std::endl;
|
||||
logFile.close();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// This is a sample monitor EDID - FOR SAMPLE PURPOSES ONLY
|
||||
/*
|
||||
const BYTE IndirectDeviceContext::s_KnownMonitorEdid[] = {
|
||||
0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x36,0x94,0x37,0x13,0x37,0x13,0x37,0x13,
|
||||
0x0d,0x22,0x01,0x03,0x80,0x32,0x1f,0x78,0x07,0xee,0x95,0xa3,0x54,0x4c,0x99,0x26,
|
||||
0x0f,0x50,0x54,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
|
||||
0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x3a,0x80,0x18,0x71,0x38,0x2d,0x40,0x58,0x2c,
|
||||
0x45,0x00,0x63,0xc8,0x10,0x00,0x00,0x06,0x00,0x00,0x00,0xfd,0x00,0x17,0xf0,0x0f,
|
||||
0xff,0x37,0x00,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0xfc,0x00,0x4d,
|
||||
0x54,0x54,0x31,0x33,0x33,0x37,0x0a,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x10,
|
||||
0x00,0x13,0x37,0x13,0x37,0x13,0x37,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x33,
|
||||
0x02,0x03,0x23,0x40,0x23,0x09,0x00,0x00,0xe6,0x06,0x0d,0x01,0xb4,0x78,0x01,0x67,
|
||||
0x03,0x0c,0x00,0x00,0x00,0x10,0x6e,0xe3,0x05,0x80,0x00,0x67,0xd8,0x5d,0xc4,0x01,
|
||||
0x6e,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9a,
|
||||
0x70,0x13,0x79,0x00,0x00,0x00,0x00,0x1e,0x4d,0x54,0x54,0x0d,0x00,0x39,0x05,0x00,
|
||||
0x00,0x0e,0x18,0x12,0x56,0x44,0x44,0x20,0x62,0x79,0x20,0x4d,0x69,0x6b,0x65,0x54,
|
||||
0x68,0x65,0x54,0x65,0x63,0x68,0x03,0x01,0x14,0x72,0xd6,0x00,0x84,0xff,0x1d,0x9f,
|
||||
0x00,0x2f,0x80,0x1f,0x00,0xdf,0x10,0x18,0x02,0x02,0x00,0x04,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x90
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
IndirectDeviceContext::IndirectDeviceContext(_In_ WDFDEVICE WdfDevice) :
|
||||
m_WdfDevice(WdfDevice)
|
||||
{
|
||||
m_Adapter = {};
|
||||
}
|
||||
|
||||
IndirectDeviceContext::~IndirectDeviceContext()
|
||||
{
|
||||
m_ProcessingThread.reset();
|
||||
}
|
||||
|
||||
#define NUM_VIRTUAL_DISPLAYS 1
|
||||
|
||||
void IndirectDeviceContext::InitAdapter()
|
||||
{
|
||||
edidLoad("C:\\IddSampleDriver\\user_edid.bin");
|
||||
// ==============================
|
||||
// TODO: Update the below diagnostic information in accordance with the target hardware. The strings and version
|
||||
// numbers are used for telemetry and may be displayed to the user in some situations.
|
||||
//
|
||||
// This is also where static per-adapter capabilities are determined.
|
||||
// ==============================
|
||||
|
||||
IDDCX_ADAPTER_CAPS AdapterCaps = {};
|
||||
AdapterCaps.Size = sizeof(AdapterCaps);
|
||||
|
||||
if (IDD_IS_FUNCTION_AVAILABLE(IddCxSwapChainReleaseAndAcquireBuffer2)) {
|
||||
AdapterCaps.Flags = IDDCX_ADAPTER_FLAGS_CAN_PROCESS_FP16;
|
||||
}
|
||||
|
||||
// Declare basic feature support for the adapter (required)
|
||||
AdapterCaps.MaxMonitorsSupported = numVirtualDisplays;
|
||||
AdapterCaps.EndPointDiagnostics.Size = sizeof(AdapterCaps.EndPointDiagnostics);
|
||||
AdapterCaps.EndPointDiagnostics.GammaSupport = IDDCX_FEATURE_IMPLEMENTATION_NONE;
|
||||
AdapterCaps.EndPointDiagnostics.TransmissionType = IDDCX_TRANSMISSION_TYPE_WIRED_OTHER;
|
||||
|
||||
// Declare your device strings for telemetry (required)
|
||||
AdapterCaps.EndPointDiagnostics.pEndPointFriendlyName = L"IddSample Device";
|
||||
AdapterCaps.EndPointDiagnostics.pEndPointManufacturerName = L"Microsoft";
|
||||
AdapterCaps.EndPointDiagnostics.pEndPointModelName = L"IddSample Model";
|
||||
|
||||
// Declare your hardware and firmware versions (required)
|
||||
IDDCX_ENDPOINT_VERSION Version = {};
|
||||
Version.Size = sizeof(Version);
|
||||
Version.MajorVer = 1;
|
||||
AdapterCaps.EndPointDiagnostics.pFirmwareVersion = &Version;
|
||||
AdapterCaps.EndPointDiagnostics.pHardwareVersion = &Version;
|
||||
|
||||
// Initialize a WDF context that can store a pointer to the device context object
|
||||
WDF_OBJECT_ATTRIBUTES Attr;
|
||||
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attr, IndirectDeviceContextWrapper);
|
||||
|
||||
IDARG_IN_ADAPTER_INIT AdapterInit = {};
|
||||
AdapterInit.WdfDevice = m_WdfDevice;
|
||||
AdapterInit.pCaps = &AdapterCaps;
|
||||
AdapterInit.ObjectAttributes = &Attr;
|
||||
|
||||
// Start the initialization of the adapter, which will trigger the AdapterFinishInit callback later
|
||||
IDARG_OUT_ADAPTER_INIT AdapterInitOut;
|
||||
NTSTATUS Status = IddCxAdapterInitAsync(&AdapterInit, &AdapterInitOut);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
// Store a reference to the WDF adapter handle
|
||||
m_Adapter = AdapterInitOut.AdapterObject;
|
||||
|
||||
// Store the device context object into the WDF object context
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(AdapterInitOut.AdapterObject);
|
||||
pContext->pContext = this;
|
||||
}
|
||||
}
|
||||
|
||||
void IndirectDeviceContext::FinishInit()
|
||||
{
|
||||
for (unsigned int i = 0; i < numVirtualDisplays; i++) {
|
||||
CreateMonitor(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IndirectDeviceContext::CreateMonitor(unsigned int index) {
|
||||
// ==============================
|
||||
// TODO: In a real driver, the EDID should be retrieved dynamically from a connected physical monitor. The EDID
|
||||
// provided here is purely for demonstration, as it describes only 640x480 @ 60 Hz and 800x600 @ 60 Hz. Monitor
|
||||
// manufacturers are required to correctly fill in physical monitor attributes in order to allow the OS to optimize
|
||||
// settings like viewing distance and scale factor. Manufacturers should also use a unique serial number every
|
||||
// single device to ensure the OS can tell the monitors apart.
|
||||
// ==============================
|
||||
std::wofstream logFile("C:\\IddSampleDriver\\lddlog.txt", std::ios::app);
|
||||
|
||||
logFile << L"Creating a monitor start at " << std::endl;
|
||||
|
||||
WDF_OBJECT_ATTRIBUTES Attr;
|
||||
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attr, IndirectDeviceContextWrapper);
|
||||
|
||||
logFile << L"Initialized WDF object attributes at " << std::endl;
|
||||
|
||||
IDDCX_MONITOR_INFO MonitorInfo = {};
|
||||
MonitorInfo.Size = sizeof(MonitorInfo);
|
||||
MonitorInfo.MonitorType = DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI;
|
||||
MonitorInfo.ConnectorIndex = index;
|
||||
MonitorInfo.MonitorDescription.Size = sizeof(MonitorInfo.MonitorDescription);
|
||||
MonitorInfo.MonitorDescription.Type = IDDCX_MONITOR_DESCRIPTION_TYPE_EDID;
|
||||
MonitorInfo.MonitorDescription.DataSize = sizeof(s_knownMonitorEdidData);
|
||||
MonitorInfo.MonitorDescription.pData = s_knownMonitorEdidData.data();
|
||||
|
||||
|
||||
// ==============================
|
||||
// TODO: The monitor's container ID should be distinct from "this" device's container ID if the monitor is not
|
||||
// permanently attached to the display adapter device object. The container ID is typically made unique for each
|
||||
// monitor and can be used to associate the monitor with other devices, like audio or input devices. In this
|
||||
// sample we generate a random container ID GUID, but it's best practice to choose a stable container ID for a
|
||||
// unique monitor or to use "this" device's container ID for a permanent/integrated monitor.
|
||||
// ==============================
|
||||
|
||||
|
||||
logFile << L"Initialized monitor info at " << std::endl;
|
||||
|
||||
CoCreateGuid(&MonitorInfo.MonitorContainerId);
|
||||
|
||||
logFile << L"Created container ID at " << std::endl;
|
||||
|
||||
IDARG_IN_MONITORCREATE MonitorCreate = {};
|
||||
MonitorCreate.ObjectAttributes = &Attr;
|
||||
MonitorCreate.pMonitorInfo = &MonitorInfo;
|
||||
IDARG_OUT_MONITORCREATE MonitorCreateOut;
|
||||
NTSTATUS Status = IddCxMonitorCreate(m_Adapter, &MonitorCreate, &MonitorCreateOut);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
logFile << L"Failed to create monitor object. Status code: " << Status << std::endl;
|
||||
}
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
m_Monitor = MonitorCreateOut.MonitorObject;
|
||||
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(MonitorCreateOut.MonitorObject);
|
||||
pContext->pContext = this;
|
||||
|
||||
logFile << L"Created monitor object and associated it with this device context at " << std::endl;
|
||||
|
||||
IDARG_OUT_MONITORARRIVAL ArrivalOut;
|
||||
Status = IddCxMonitorArrival(m_Monitor, &ArrivalOut);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
logFile << L"Failed to plug in monitor. Status code: " << Status << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
logFile << L"Monitor has been plugged in at " << std::endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
logFile << L"Weird " << std::endl;
|
||||
}
|
||||
|
||||
|
||||
logFile << L"Creating a monitor end at " << std::endl;
|
||||
logFile.close();
|
||||
}
|
||||
|
||||
|
||||
void IndirectDeviceContext::AssignSwapChain(IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent) // Jocke, is it here we could assign rendering gpu?
|
||||
{
|
||||
m_ProcessingThread.reset();
|
||||
|
||||
auto Device = make_shared<Direct3DDevice>(RenderAdapter);
|
||||
if (FAILED(Device->Init()))
|
||||
{
|
||||
// It's important to delete the swap-chain if D3D initialization fails, so that the OS knows to generate a new
|
||||
// swap-chain and try again.
|
||||
WdfObjectDelete(SwapChain);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new swap-chain processing thread
|
||||
m_ProcessingThread.reset(new SwapChainProcessor(SwapChain, Device, NewFrameEvent));
|
||||
}
|
||||
}
|
||||
|
||||
void IndirectDeviceContext::UnassignSwapChain()
|
||||
{
|
||||
// Stop processing the last swap-chain
|
||||
m_ProcessingThread.reset();
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region DDI Callbacks
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleAdapterInitFinished(IDDCX_ADAPTER AdapterObject, const IDARG_IN_ADAPTER_INIT_FINISHED* pInArgs)
|
||||
{
|
||||
// This is called when the OS has finished setting up the adapter for use by the IddCx driver. It's now possible
|
||||
// to report attached monitors.
|
||||
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(AdapterObject);
|
||||
if (NT_SUCCESS(pInArgs->AdapterInitStatus))
|
||||
{
|
||||
pContext->pContext->FinishInit();
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleAdapterCommitModes(IDDCX_ADAPTER AdapterObject, const IDARG_IN_COMMITMODES* pInArgs)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(AdapterObject);
|
||||
UNREFERENCED_PARAMETER(pInArgs);
|
||||
|
||||
// For the sample, do nothing when modes are picked - the swap-chain is taken care of by IddCx
|
||||
|
||||
// ==============================
|
||||
// TODO: In a real driver, this function would be used to reconfigure the device to commit the new modes. Loop
|
||||
// through pInArgs->pPaths and look for IDDCX_PATH_FLAGS_ACTIVE. Any path not active is inactive (e.g. the monitor
|
||||
// should be turned off).
|
||||
// ==============================
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleParseMonitorDescription(const IDARG_IN_PARSEMONITORDESCRIPTION* pInArgs, IDARG_OUT_PARSEMONITORDESCRIPTION* pOutArgs)
|
||||
{
|
||||
// ==============================
|
||||
// TODO: In a real driver, this function would be called to generate monitor modes for an EDID by parsing it. In
|
||||
// this sample driver, we hard-code the EDID, so this function can generate known modes.
|
||||
// ==============================
|
||||
|
||||
for (int i = 0; i < monitorModes.size(); i++) {
|
||||
s_KnownMonitorModes2.push_back(dispinfo(std::get<0>(monitorModes[i]), std::get<1>(monitorModes[i]), std::get<2>(monitorModes[i])));
|
||||
}
|
||||
pOutArgs->MonitorModeBufferOutputCount = (UINT)monitorModes.size();
|
||||
|
||||
if (pInArgs->MonitorModeBufferInputCount < monitorModes.size())
|
||||
{
|
||||
// Return success if there was no buffer, since the caller was only asking for a count of modes
|
||||
return (pInArgs->MonitorModeBufferInputCount > 0) ? STATUS_BUFFER_TOO_SMALL : STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy the known modes to the output buffer
|
||||
for (DWORD ModeIndex = 0; ModeIndex < monitorModes.size(); ModeIndex++)
|
||||
{
|
||||
pInArgs->pMonitorModes[ModeIndex].Size = sizeof(IDDCX_MONITOR_MODE);
|
||||
pInArgs->pMonitorModes[ModeIndex].Origin = IDDCX_MONITOR_MODE_ORIGIN_MONITORDESCRIPTOR;
|
||||
pInArgs->pMonitorModes[ModeIndex].MonitorVideoSignalInfo = s_KnownMonitorModes2[ModeIndex];
|
||||
}
|
||||
|
||||
// Set the preferred mode as represented in the EDID
|
||||
pOutArgs->PreferredMonitorModeIdx = 0;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleMonitorGetDefaultModes(IDDCX_MONITOR MonitorObject, const IDARG_IN_GETDEFAULTDESCRIPTIONMODES* pInArgs, IDARG_OUT_GETDEFAULTDESCRIPTIONMODES* pOutArgs)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(MonitorObject);
|
||||
UNREFERENCED_PARAMETER(pInArgs);
|
||||
UNREFERENCED_PARAMETER(pOutArgs);
|
||||
|
||||
// Should never be called since we create a single monitor with a known EDID in this sample driver.
|
||||
|
||||
// ==============================
|
||||
// TODO: In a real driver, this function would be called to generate monitor modes for a monitor with no EDID.
|
||||
// Drivers should report modes that are guaranteed to be supported by the transport protocol and by nearly all
|
||||
// monitors (such 640x480, 800x600, or 1024x768). If the driver has access to monitor modes from a descriptor other
|
||||
// than an EDID, those modes would also be reported here.
|
||||
// ==============================
|
||||
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a target mode from the fundamental mode attributes.
|
||||
/// </summary>
|
||||
void CreateTargetMode(DISPLAYCONFIG_VIDEO_SIGNAL_INFO& Mode, UINT Width, UINT Height, UINT VSync) // Jocke, is it her we have the issue with 640*480 init when multiple vdds are chosen
|
||||
{
|
||||
Mode.totalSize.cx = Mode.activeSize.cx = Width;
|
||||
Mode.totalSize.cy = Mode.activeSize.cy = Height;
|
||||
Mode.AdditionalSignalInfo.vSyncFreqDivider = 1;
|
||||
Mode.AdditionalSignalInfo.videoStandard = 255;
|
||||
Mode.vSyncFreq.Numerator = VSync;
|
||||
Mode.vSyncFreq.Denominator = Mode.hSyncFreq.Denominator = 1;
|
||||
Mode.hSyncFreq.Numerator = VSync * Height;
|
||||
Mode.scanLineOrdering = DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE;
|
||||
Mode.pixelRate = VSync * Width * Height;
|
||||
}
|
||||
|
||||
void CreateTargetMode(IDDCX_TARGET_MODE& Mode, UINT Width, UINT Height, UINT VSync)
|
||||
{
|
||||
Mode.Size = sizeof(Mode);
|
||||
CreateTargetMode(Mode.TargetVideoSignalInfo.targetVideoSignalInfo, Width, Height, VSync);
|
||||
}
|
||||
|
||||
void CreateTargetMode2(IDDCX_TARGET_MODE2& Mode, UINT Width, UINT Height, UINT VSync)
|
||||
{
|
||||
Mode.Size = sizeof(Mode);
|
||||
Mode.BitsPerComponent.Rgb = IDDCX_BITS_PER_COMPONENT_8 | IDDCX_BITS_PER_COMPONENT_10;
|
||||
CreateTargetMode(Mode.TargetVideoSignalInfo.targetVideoSignalInfo, Width, Height, VSync);
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleMonitorQueryModes(IDDCX_MONITOR MonitorObject, const IDARG_IN_QUERYTARGETMODES* pInArgs, IDARG_OUT_QUERYTARGETMODES* pOutArgs)////////////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
UNREFERENCED_PARAMETER(MonitorObject);
|
||||
|
||||
vector<IDDCX_TARGET_MODE> TargetModes(monitorModes.size());
|
||||
|
||||
// Create a set of modes supported for frame processing and scan-out. These are typically not based on the
|
||||
// monitor's descriptor and instead are based on the static processing capability of the device. The OS will
|
||||
// report the available set of modes for a given output as the intersection of monitor modes with target modes.
|
||||
|
||||
for (int i = 0; i < monitorModes.size(); i++) {
|
||||
CreateTargetMode(TargetModes[i], std::get<0>(monitorModes[i]), std::get<1>(monitorModes[i]), std::get<2>(monitorModes[i]));
|
||||
}
|
||||
|
||||
pOutArgs->TargetModeBufferOutputCount = (UINT)TargetModes.size();
|
||||
|
||||
if (pInArgs->TargetModeBufferInputCount >= TargetModes.size())
|
||||
{
|
||||
copy(TargetModes.begin(), TargetModes.end(), pInArgs->pTargetModes);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleMonitorAssignSwapChain(IDDCX_MONITOR MonitorObject, const IDARG_IN_SETSWAPCHAIN* pInArgs)
|
||||
{
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(MonitorObject);
|
||||
pContext->pContext->AssignSwapChain(pInArgs->hSwapChain, pInArgs->RenderAdapterLuid, pInArgs->hNextSurfaceAvailable);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleMonitorUnassignSwapChain(IDDCX_MONITOR MonitorObject)
|
||||
{
|
||||
auto* pContext = WdfObjectGet_IndirectDeviceContextWrapper(MonitorObject);
|
||||
pContext->pContext->UnassignSwapChain();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleEvtIddCxAdapterQueryTargetInfo(
|
||||
IDDCX_ADAPTER AdapterObject,
|
||||
IDARG_IN_QUERYTARGET_INFO* pInArgs,
|
||||
IDARG_OUT_QUERYTARGET_INFO* pOutArgs
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(AdapterObject);
|
||||
UNREFERENCED_PARAMETER(pInArgs);
|
||||
pOutArgs->TargetCaps = IDDCX_TARGET_CAPS_HIGH_COLOR_SPACE;
|
||||
pOutArgs->DitheringSupport.Rgb = IDDCX_BITS_PER_COMPONENT_10;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleEvtIddCxMonitorSetDefaultHdrMetadata(
|
||||
IDDCX_MONITOR MonitorObject,
|
||||
const IDARG_IN_MONITOR_SET_DEFAULT_HDR_METADATA* pInArgs
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(MonitorObject);
|
||||
UNREFERENCED_PARAMETER(pInArgs);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleEvtIddCxParseMonitorDescription2(
|
||||
const IDARG_IN_PARSEMONITORDESCRIPTION2* pInArgs,
|
||||
IDARG_OUT_PARSEMONITORDESCRIPTION* pOutArgs
|
||||
)
|
||||
{
|
||||
// ==============================
|
||||
// TODO: In a real driver, this function would be called to generate monitor modes for an EDID by parsing it. In
|
||||
// this sample driver, we hard-code the EDID, so this function can generate known modes.
|
||||
// ==============================
|
||||
|
||||
for (int i = 0; i < monitorModes.size(); i++) {
|
||||
s_KnownMonitorModes2.push_back(dispinfo(std::get<0>(monitorModes[i]), std::get<1>(monitorModes[i]), std::get<2>(monitorModes[i])));
|
||||
}
|
||||
pOutArgs->MonitorModeBufferOutputCount = (UINT)monitorModes.size();
|
||||
|
||||
if (pInArgs->MonitorModeBufferInputCount < monitorModes.size())
|
||||
{
|
||||
// Return success if there was no buffer, since the caller was only asking for a count of modes
|
||||
return (pInArgs->MonitorModeBufferInputCount > 0) ? STATUS_BUFFER_TOO_SMALL : STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy the known modes to the output buffer
|
||||
for (DWORD ModeIndex = 0; ModeIndex < monitorModes.size(); ModeIndex++)
|
||||
{
|
||||
pInArgs->pMonitorModes[ModeIndex].Size = sizeof(IDDCX_MONITOR_MODE2);
|
||||
pInArgs->pMonitorModes[ModeIndex].Origin = IDDCX_MONITOR_MODE_ORIGIN_MONITORDESCRIPTOR;
|
||||
pInArgs->pMonitorModes[ModeIndex].MonitorVideoSignalInfo = s_KnownMonitorModes2[ModeIndex];
|
||||
pInArgs->pMonitorModes[ModeIndex].BitsPerComponent.Rgb = IDDCX_BITS_PER_COMPONENT_8 | IDDCX_BITS_PER_COMPONENT_10;
|
||||
}
|
||||
|
||||
// Set the preferred mode as represented in the EDID
|
||||
pOutArgs->PreferredMonitorModeIdx = 0;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleEvtIddCxMonitorQueryTargetModes2(
|
||||
IDDCX_MONITOR MonitorObject,
|
||||
const IDARG_IN_QUERYTARGETMODES2* pInArgs,
|
||||
IDARG_OUT_QUERYTARGETMODES* pOutArgs
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(MonitorObject);
|
||||
|
||||
vector<IDDCX_TARGET_MODE2> TargetModes(monitorModes.size());
|
||||
|
||||
// Create a set of modes supported for frame processing and scan-out. These are typically not based on the
|
||||
// monitor's descriptor and instead are based on the static processing capability of the device. The OS will
|
||||
// report the available set of modes for a given output as the intersection of monitor modes with target modes.
|
||||
|
||||
for (int i = 0; i < monitorModes.size(); i++) {
|
||||
CreateTargetMode2(TargetModes[i], std::get<0>(monitorModes[i]), std::get<1>(monitorModes[i]), std::get<2>(monitorModes[i]));
|
||||
}
|
||||
|
||||
pOutArgs->TargetModeBufferOutputCount = (UINT)TargetModes.size();
|
||||
|
||||
if (pInArgs->TargetModeBufferInputCount >= TargetModes.size())
|
||||
{
|
||||
copy(TargetModes.begin(), TargetModes.end(), pInArgs->pTargetModes);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleEvtIddCxAdapterCommitModes2(
|
||||
IDDCX_ADAPTER AdapterObject,
|
||||
const IDARG_IN_COMMITMODES2* pInArgs
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(AdapterObject);
|
||||
UNREFERENCED_PARAMETER(pInArgs);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
NTSTATUS IddSampleEvtIddCxMonitorSetGammaRamp(
|
||||
IDDCX_MONITOR MonitorObject,
|
||||
const IDARG_IN_SET_GAMMARAMP* pInArgs
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(MonitorObject);
|
||||
UNREFERENCED_PARAMETER(pInArgs);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0
|
||||
MinimumVisualStudioVersion = 12.0
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleDisplay", "Sample\SampleDisplay.vcxproj", "{D3C62015-3845-4DA8-8522-5DC45B735063}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D3C62015-3845-4DA8-8522-5DC45B735063}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D3C62015-3845-4DA8-8522-5DC45B735063}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D3C62015-3845-4DA8-8522-5DC45B735063}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D3C62015-3845-4DA8-8522-5DC45B735063}.Release|Win32.Build.0 = Release|Win32
|
||||
{D3C62015-3845-4DA8-8522-5DC45B735063}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D3C62015-3845-4DA8-8522-5DC45B735063}.Debug|x64.Build.0 = Debug|x64
|
||||
{D3C62015-3845-4DA8-8522-5DC45B735063}.Release|x64.ActiveCfg = Release|x64
|
||||
{D3C62015-3845-4DA8-8522-5DC45B735063}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,71 +0,0 @@
|
||||
### THIS SAMPLE IS INCOMPLETE - Currently a Work in Progress attempt at HDR and 10-bit video support.
|
||||
|
||||
---
|
||||
page_type: sample
|
||||
description: "Implements most DDIs that a display-only miniport driver should provide to the Windows Display Driver Model (WDDM)."
|
||||
languages:
|
||||
- cpp
|
||||
products:
|
||||
- windows
|
||||
- windows-wdk
|
||||
---
|
||||
|
||||
# Kernel mode display-only miniport driver (KMDOD) sample
|
||||
|
||||
The kernel mode display-only miniport driver (KMDOD) sample implements most of the device driver interfaces (DDIs) that a display-only miniport driver should provide to the Windows Display Driver Model (WDDM). The code is useful to understand how to write a miniport driver for a display-only device, or how to develop a full WDDM driver.
|
||||
|
||||
For more info on WDDM drivers, see [Windows Display Driver Model (WDDM) Design Guide](https://docs.microsoft.com/windows-hardware/drivers/display/windows-vista-display-driver-model-design-guide).
|
||||
|
||||
This code can also help you to understand the use and implementation of display-related DDIs. The INF file shows how to make a display miniport driver visible to other WDDM components.
|
||||
|
||||
The sample can be installed on top of a VESA-capable graphics adapter, or on top of a graphics device that supports access to frame buffer memory through the Unified Extensible Firmware Interface (UEFI).
|
||||
|
||||
The sample driver does not support the *sleep* power state. If it is placed in the sleep state, the driver will cause a system bugcheck to occur. There is no workaround available, by design.
|
||||
|
||||
If the current display driver is not a WDDM 1.2 compliant driver, the sample driver might fail to install, with error code 43 displayed. The KMDOD driver is actually installed, but it cannot be started. The workaround for this issue is to switch to the Microsoft Basic Display Adapter Driver before installing the KMDOD sample driver, or simply to reboot your system after installing the KMDOD sample.
|
||||
|
||||
## Installation
|
||||
|
||||
In Microsoft Visual Studio, press **F5** to build the sample and then deploy it to a target machine. For more info, see [Deploying a Driver to a Test Computer](https://docs.microsoft.com/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer).
|
||||
|
||||
In some cases you might need to install the driver manually, as follows.
|
||||
|
||||
1. Add the following files to the directory given by ...\\[x64]\\C++\\Package:
|
||||
|
||||
- SampleDriver.cat
|
||||
|
||||
- SampleDriver.inf
|
||||
|
||||
- SampleDriver.sys
|
||||
|
||||
- SampleDriver.cer
|
||||
|
||||
1. Unless you've provided a production certificate, you should manually install the SampleDriver.cer digital certificate with the following command:
|
||||
|
||||
`Certutil.exe -addstore root SampleDriver.cer`
|
||||
|
||||
1. Then enable test signing by running the following BCDEdit command:
|
||||
|
||||
`Bcdedit.exe -set TESTSIGNING ON`
|
||||
|
||||
> [!NOTE]
|
||||
> After you change the TESTSIGNING boot configuration option, restart the computer for the change to take effect.
|
||||
|
||||
For more info, see [The TESTSIGNING Boot Configuration Option](https://docs.microsoft.com/windows-hardware/drivers/install/the-testsigning-boot-configuration-option).
|
||||
|
||||
1. Manually install the driver using Device Manager, which is available from Control Panel.
|
||||
|
||||
### ACPI-based GPUs
|
||||
|
||||
To install the KMDOD sample driver on a GPU that is an Advanced Configuration and Power Interface (ACPI) device, add these lines to the `[MS]`, `[MS.NTamd64]`, and `[MS.NTarm]` sections of the Sampledisplay.inf file:
|
||||
|
||||
```inf
|
||||
Text
|
||||
" Kernel mode display only sample driver " = KDODSamp_Inst, ACPI\CLS_0003&SUBCLS_0000
|
||||
" Kernel mode display only sample driver " = KDODSamp_Inst, ACPI\CLS_0003&SUBCLS_0001
|
||||
" Kernel mode display only sample driver " = KDODSamp_Inst, ACPI\CLS_0003&SUBCLS_0003
|
||||
```
|
||||
|
||||
This new code provides generic identifiers for ACPI hardware.
|
||||
|
||||
You can optionally delete the original lines of code within these sections of the INF file.
|
||||
@@ -1,209 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D3C62015-3845-4DA8-8522-5DC45B735063}</ProjectGuid>
|
||||
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
|
||||
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
|
||||
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
|
||||
<SampleGuid>{4E49D9DD-F772-41AD-9367-F225BF8261D3}</SampleGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>False</UseDebugLibraries>
|
||||
<DriverTargetPlatform>Universal</DriverTargetPlatform>
|
||||
<DriverType>WDM</DriverType>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>Driver</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>True</UseDebugLibraries>
|
||||
<DriverTargetPlatform>Universal</DriverTargetPlatform>
|
||||
<DriverType>WDM</DriverType>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>Driver</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>False</UseDebugLibraries>
|
||||
<DriverTargetPlatform>Universal</DriverTargetPlatform>
|
||||
<DriverType>WDM</DriverType>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>Driver</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>True</UseDebugLibraries>
|
||||
<DriverTargetPlatform>Universal</DriverTargetPlatform>
|
||||
<DriverType>WDM</DriverType>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>Driver</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<PropertyGroup>
|
||||
<OutDir>$(IntDir)</OutDir>
|
||||
</PropertyGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
|
||||
</ImportGroup>
|
||||
<ItemGroup Label="WrappedTaskItems" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\displib.lib;$(DDK_LIB_PATH)\ntoskrnl.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Midl>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</Midl>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\displib.lib;$(DDK_LIB_PATH)\ntoskrnl.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Midl>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</Midl>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\displib.lib;$(DDK_LIB_PATH)\ntoskrnl.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Midl>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</Midl>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\displib.lib;$(DDK_LIB_PATH)\ntoskrnl.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Midl>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)</AdditionalIncludeDirectories>
|
||||
</Midl>
|
||||
</ItemDefinitionGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetName>SampleDisplay</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetName>SampleDisplay</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>SampleDisplay</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetName>SampleDisplay</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
</ClCompile>
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
</ClCompile>
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
</ClCompile>
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
</ClCompile>
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\BDD.cxx" />
|
||||
<ClCompile Include="..\BDD_DDI.cxx" />
|
||||
<ClCompile Include="..\BDD_DMM.cxx" />
|
||||
<ClCompile Include="..\BDD_Util.cxx" />
|
||||
<ClCompile Include="..\BltFuncs.cxx" />
|
||||
<ClCompile Include="..\BltHw.cxx" />
|
||||
<ClCompile Include="..\memory.cxx" />
|
||||
<ResourceCompile Include="..\sampledisplay.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Inf Exclude="@(Inf)" Include="*.inf" />
|
||||
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
|
||||
<None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" />
|
||||
<None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>
|
||||
<UniqueIdentifier>{8B6C0A00-F837-4D16-A67B-98E6936A2729}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
<UniqueIdentifier>{0D809CEB-9E9B-4357-B44D-BCDCA1D0A4A5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>
|
||||
<UniqueIdentifier>{E61D9490-5CC2-4F32-AC2B-BCE3922E65F7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Driver Files">
|
||||
<Extensions>inf;inv;inx;mof;mc;</Extensions>
|
||||
<UniqueIdentifier>{5A656697-E252-49C1-BF4E-B06BA46DF394}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\BDD.cxx">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\BDD_DDI.cxx">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\BDD_DMM.cxx">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\BDD_Util.cxx">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\BltFuncs.cxx">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\BltHw.cxx">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\memory.cxx">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\sampledisplay.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Binary file not shown.
-854
@@ -1,854 +0,0 @@
|
||||
/******************************Module*Header*******************************\
|
||||
* Module Name: bdd.cxx
|
||||
*
|
||||
* Basic Display Driver functions implementation
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2010 Microsoft Corporation
|
||||
\**************************************************************************/
|
||||
|
||||
|
||||
#include "BDD.hxx"
|
||||
|
||||
#pragma code_seg("PAGE")
|
||||
|
||||
|
||||
BASIC_DISPLAY_DRIVER::BASIC_DISPLAY_DRIVER(_In_ DEVICE_OBJECT* pPhysicalDeviceObject) : m_pPhysicalDevice(pPhysicalDeviceObject),
|
||||
m_MonitorPowerState(PowerDeviceD0),
|
||||
m_AdapterPowerState(PowerDeviceD0)
|
||||
{
|
||||
PAGED_CODE();
|
||||
*((UINT*)&m_Flags) = 0;
|
||||
m_Flags._LastFlag = TRUE;
|
||||
RtlZeroMemory(&m_DxgkInterface, sizeof(m_DxgkInterface));
|
||||
RtlZeroMemory(&m_StartInfo, sizeof(m_StartInfo));
|
||||
RtlZeroMemory(m_CurrentModes, sizeof(m_CurrentModes));
|
||||
RtlZeroMemory(&m_DeviceInfo, sizeof(m_DeviceInfo));
|
||||
|
||||
|
||||
for (UINT i=0;i<MAX_VIEWS;i++)
|
||||
{
|
||||
m_HardwareBlt[i].Initialize(this,i);
|
||||
}
|
||||
}
|
||||
|
||||
BASIC_DISPLAY_DRIVER::~BASIC_DISPLAY_DRIVER()
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::StartDevice(_In_ DXGK_START_INFO* pDxgkStartInfo,
|
||||
_In_ DXGKRNL_INTERFACE* pDxgkInterface,
|
||||
_Out_ ULONG* pNumberOfViews,
|
||||
_Out_ ULONG* pNumberOfChildren)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pDxgkStartInfo != NULL);
|
||||
BDD_ASSERT(pDxgkInterface != NULL);
|
||||
BDD_ASSERT(pNumberOfViews != NULL);
|
||||
BDD_ASSERT(pNumberOfChildren != NULL);
|
||||
|
||||
RtlCopyMemory(&m_StartInfo, pDxgkStartInfo, sizeof(m_StartInfo));
|
||||
RtlCopyMemory(&m_DxgkInterface, pDxgkInterface, sizeof(m_DxgkInterface));
|
||||
RtlZeroMemory(m_CurrentModes, sizeof(m_CurrentModes));
|
||||
m_CurrentModes[0].DispInfo.TargetId = D3DDDI_ID_UNINITIALIZED;
|
||||
|
||||
// Get device information from OS.
|
||||
NTSTATUS Status = m_DxgkInterface.DxgkCbGetDeviceInformation(m_DxgkInterface.DeviceHandle, &m_DeviceInfo);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BDD_LOG_ASSERTION1("DxgkCbGetDeviceInformation failed with status 0x%I64x",
|
||||
Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Ignore return value, since it's not the end of the world if we failed to write these values to the registry
|
||||
RegisterHWInfo();
|
||||
|
||||
// TODO: Uncomment the line below after updating the TODOs in the function CheckHardware
|
||||
// Status = CheckHardware();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
// This sample driver only uses the frame buffer of the POST device. DxgkCbAcquirePostDisplayOwnership
|
||||
// gives you the frame buffer address and ensures that no one else is drawing to it. Be sure to give it back!
|
||||
Status = m_DxgkInterface.DxgkCbAcquirePostDisplayOwnership(m_DxgkInterface.DeviceHandle, &(m_CurrentModes[0].DispInfo));
|
||||
if (!NT_SUCCESS(Status) || m_CurrentModes[0].DispInfo.Width == 0)
|
||||
{
|
||||
// The most likely cause of failure is that the driver is simply not running on a POST device, or we are running
|
||||
// after a pre-WDDM 1.2 driver. Since we can't draw anything, we should fail to start.
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
m_Flags.DriverStarted = TRUE;
|
||||
*pNumberOfViews = MAX_VIEWS;
|
||||
*pNumberOfChildren = MAX_CHILDREN;
|
||||
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::StopDevice(VOID)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
CleanUp();
|
||||
|
||||
m_Flags.DriverStarted = FALSE;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
VOID BASIC_DISPLAY_DRIVER::CleanUp()
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
for (UINT Source = 0; Source < MAX_VIEWS; ++Source)
|
||||
{
|
||||
if (m_CurrentModes[Source].FrameBuffer.Ptr)
|
||||
{
|
||||
UnmapFrameBuffer(m_CurrentModes[Source].FrameBuffer.Ptr, m_CurrentModes[Source].DispInfo.Height * m_CurrentModes[Source].DispInfo.Pitch);
|
||||
m_CurrentModes[Source].FrameBuffer.Ptr = NULL;
|
||||
m_CurrentModes[Source].Flags.FrameBufferIsActive = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::DispatchIoRequest(_In_ ULONG VidPnSourceId,
|
||||
_In_ VIDEO_REQUEST_PACKET* pVideoRequestPacket)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pVideoRequestPacket != NULL);
|
||||
BDD_ASSERT(VidPnSourceId < MAX_VIEWS);
|
||||
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::SetPowerState(_In_ ULONG HardwareUid,
|
||||
_In_ DEVICE_POWER_STATE DevicePowerState,
|
||||
_In_ POWER_ACTION ActionType)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
UNREFERENCED_PARAMETER(ActionType);
|
||||
|
||||
BDD_ASSERT((HardwareUid < MAX_CHILDREN) || (HardwareUid == DISPLAY_ADAPTER_HW_ID));
|
||||
|
||||
if (HardwareUid == DISPLAY_ADAPTER_HW_ID)
|
||||
{
|
||||
if (DevicePowerState == PowerDeviceD0)
|
||||
{
|
||||
|
||||
// When returning from D3 the device visibility defined to be off for all targets
|
||||
if (m_AdapterPowerState == PowerDeviceD3)
|
||||
{
|
||||
DXGKARG_SETVIDPNSOURCEVISIBILITY Visibility;
|
||||
Visibility.VidPnSourceId = D3DDDI_ID_ALL;
|
||||
Visibility.Visible = FALSE;
|
||||
SetVidPnSourceVisibility(&Visibility);
|
||||
}
|
||||
}
|
||||
|
||||
// Store new adapter power state
|
||||
m_AdapterPowerState = DevicePowerState;
|
||||
|
||||
// There is nothing to do to specifically power up/down the display adapter
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: This is where the specified monitor should be powered up/down
|
||||
NOTHING;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::QueryChildRelations(_Out_writes_bytes_(ChildRelationsSize) DXGK_CHILD_DESCRIPTOR* pChildRelations,
|
||||
_In_ ULONG ChildRelationsSize)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pChildRelations != NULL);
|
||||
|
||||
// The last DXGK_CHILD_DESCRIPTOR in the array of pChildRelations must remain zeroed out, so we subtract this from the count
|
||||
ULONG ChildRelationsCount = (ChildRelationsSize / sizeof(DXGK_CHILD_DESCRIPTOR)) - 1;
|
||||
BDD_ASSERT(ChildRelationsCount <= MAX_CHILDREN);
|
||||
|
||||
for (UINT ChildIndex = 0; ChildIndex < ChildRelationsCount; ++ChildIndex)
|
||||
{
|
||||
pChildRelations[ChildIndex].ChildDeviceType = TypeVideoOutput;
|
||||
pChildRelations[ChildIndex].ChildCapabilities.HpdAwareness = HpdAwarenessInterruptible;
|
||||
pChildRelations[ChildIndex].ChildCapabilities.Type.VideoOutput.InterfaceTechnology = m_CurrentModes[0].Flags.IsInternal ? D3DKMDT_VOT_INTERNAL : D3DKMDT_VOT_OTHER;
|
||||
pChildRelations[ChildIndex].ChildCapabilities.Type.VideoOutput.MonitorOrientationAwareness = D3DKMDT_MOA_NONE;
|
||||
pChildRelations[ChildIndex].ChildCapabilities.Type.VideoOutput.SupportsSdtvModes = FALSE;
|
||||
// TODO: Replace 0 with the actual ACPI ID of the child device, if available
|
||||
pChildRelations[ChildIndex].AcpiUid = 0;
|
||||
pChildRelations[ChildIndex].ChildUid = ChildIndex;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::QueryChildStatus(_Inout_ DXGK_CHILD_STATUS* pChildStatus,
|
||||
_In_ BOOLEAN NonDestructiveOnly)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
UNREFERENCED_PARAMETER(NonDestructiveOnly);
|
||||
BDD_ASSERT(pChildStatus != NULL);
|
||||
BDD_ASSERT(pChildStatus->ChildUid < MAX_CHILDREN);
|
||||
|
||||
switch (pChildStatus->Type)
|
||||
{
|
||||
case StatusConnection:
|
||||
{
|
||||
// HpdAwarenessInterruptible was reported since HpdAwarenessNone is deprecated.
|
||||
// However, BDD has no knowledge of HotPlug events, so just always return connected.
|
||||
pChildStatus->HotPlug.Connected = IsDriverActive();
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
case StatusRotation:
|
||||
{
|
||||
// D3DKMDT_MOA_NONE was reported, so this should never be called
|
||||
BDD_LOG_ERROR0("Child status being queried for StatusRotation even though D3DKMDT_MOA_NONE was reported");
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
BDD_LOG_WARNING1("Unknown pChildStatus->Type (0x%I64x) requested.", pChildStatus->Type);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EDID retrieval
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::QueryDeviceDescriptor(_In_ ULONG ChildUid,
|
||||
_Inout_ DXGK_DEVICE_DESCRIPTOR* pDeviceDescriptor)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pDeviceDescriptor != NULL);
|
||||
BDD_ASSERT(ChildUid < MAX_CHILDREN);
|
||||
|
||||
// If we haven't successfully retrieved an EDID yet (invalid ones are ok, so long as it was retrieved)
|
||||
if (!m_Flags.EDID_Attempted)
|
||||
{
|
||||
GetEdid(ChildUid);
|
||||
}
|
||||
|
||||
if (!m_Flags.EDID_Retrieved || !m_Flags.EDID_ValidHeader || !m_Flags.EDID_ValidChecksum)
|
||||
{
|
||||
// Report no EDID if a valid one wasn't retrieved
|
||||
return STATUS_GRAPHICS_CHILD_DESCRIPTOR_NOT_SUPPORTED;
|
||||
}
|
||||
else if (pDeviceDescriptor->DescriptorOffset == 0)
|
||||
{
|
||||
// Only the base block is supported
|
||||
RtlCopyMemory(pDeviceDescriptor->DescriptorBuffer,
|
||||
m_EDIDs[ChildUid],
|
||||
min(pDeviceDescriptor->DescriptorLength, EDID_V1_BLOCK_SIZE));
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return STATUS_MONITOR_NO_MORE_DESCRIPTOR_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::QueryAdapterInfo(_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pQueryAdapterInfo != NULL);
|
||||
|
||||
switch (pQueryAdapterInfo->Type)
|
||||
{
|
||||
case DXGKQAITYPE_DRIVERCAPS:
|
||||
{
|
||||
if (pQueryAdapterInfo->OutputDataSize < sizeof(DXGK_DRIVERCAPS))
|
||||
{
|
||||
BDD_LOG_ERROR2("pQueryAdapterInfo->OutputDataSize (0x%I64x) is smaller than sizeof(DXGK_DRIVERCAPS) (0x%I64x)", pQueryAdapterInfo->OutputDataSize, sizeof(DXGK_DRIVERCAPS));
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
DXGK_DRIVERCAPS* pDriverCaps = (DXGK_DRIVERCAPS*)pQueryAdapterInfo->pOutputData;
|
||||
|
||||
// Nearly all fields must be initialized to zero, so zero out to start and then change those that are non-zero.
|
||||
// Fields are zero since BDD is Display-Only and therefore does not support any of the render related fields.
|
||||
// It also doesn't support hardware interrupts, gamma ramps, etc.
|
||||
RtlZeroMemory(pDriverCaps, sizeof(DXGK_DRIVERCAPS));
|
||||
|
||||
pDriverCaps->WDDMVersion = DXGKDDI_WDDMv1_2;
|
||||
pDriverCaps->HighestAcceptableAddress.QuadPart = -1;
|
||||
|
||||
pDriverCaps->SupportNonVGA = TRUE;
|
||||
pDriverCaps->SupportSmoothRotation = TRUE;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
case DXGKQAITYPE_DISPLAY_DRIVERCAPS_EXTENSION:
|
||||
{
|
||||
DXGK_DISPLAY_DRIVERCAPS_EXTENSION* pDriverDisplayCaps;
|
||||
|
||||
if (pQueryAdapterInfo->OutputDataSize < sizeof(*pDriverDisplayCaps))
|
||||
{
|
||||
BDD_LOG_ERROR2("pQueryAdapterInfo->OutputDataSize (0x%I64x) is smaller than sizeof(DXGK_DISPLAY_DRIVERCAPS_EXTENSION) (0x%I64x)",
|
||||
pQueryAdapterInfo->OutputDataSize,
|
||||
sizeof(DXGK_DISPLAY_DRIVERCAPS_EXTENSION));
|
||||
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
pDriverDisplayCaps = (DXGK_DISPLAY_DRIVERCAPS_EXTENSION*)pQueryAdapterInfo->pOutputData;
|
||||
|
||||
// Reset all caps values
|
||||
RtlZeroMemory(pDriverDisplayCaps, pQueryAdapterInfo->OutputDataSize);
|
||||
|
||||
// We claim to support virtual display mode.
|
||||
pDriverDisplayCaps->VirtualModeSupport = 1;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
// BDD does not need to support any other adapter information types
|
||||
BDD_LOG_WARNING1("Unknown QueryAdapterInfo Type (0x%I64x) requested", pQueryAdapterInfo->Type);
|
||||
return STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::CheckHardware()
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
NTSTATUS Status;
|
||||
ULONG VendorID;
|
||||
ULONG DeviceID;
|
||||
|
||||
// TODO: If developing a driver for PCI based hardware, then use the second method to retrieve Vendor/Device IDs.
|
||||
// If developing for non-PCI based hardware (i.e. ACPI based hardware), use the first method to retrieve the IDs.
|
||||
#if 1 // ACPI-based device
|
||||
|
||||
// Get the Vendor & Device IDs on non-PCI system
|
||||
ACPI_EVAL_INPUT_BUFFER_COMPLEX AcpiInputBuffer = {0};
|
||||
AcpiInputBuffer.Signature = ACPI_EVAL_INPUT_BUFFER_COMPLEX_SIGNATURE;
|
||||
AcpiInputBuffer.MethodNameAsUlong = ACPI_METHOD_HARDWARE_ID;
|
||||
AcpiInputBuffer.Size = 0;
|
||||
AcpiInputBuffer.ArgumentCount = 0;
|
||||
|
||||
BYTE OutputBuffer[sizeof(ACPI_EVAL_OUTPUT_BUFFER) + 0x10];
|
||||
RtlZeroMemory(OutputBuffer, sizeof(OutputBuffer));
|
||||
ACPI_EVAL_OUTPUT_BUFFER* pAcpiOutputBuffer = reinterpret_cast<ACPI_EVAL_OUTPUT_BUFFER*>(&OutputBuffer);
|
||||
|
||||
Status = m_DxgkInterface.DxgkCbEvalAcpiMethod(m_DxgkInterface.DeviceHandle,
|
||||
DISPLAY_ADAPTER_HW_ID,
|
||||
&AcpiInputBuffer,
|
||||
sizeof(AcpiInputBuffer),
|
||||
pAcpiOutputBuffer,
|
||||
sizeof(OutputBuffer));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BDD_LOG_ERROR1("DxgkCbReadDeviceSpace failed to get hardware IDs with status 0x%I64x", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
VendorID = ((ULONG*)(pAcpiOutputBuffer->Argument[0].Data))[0];
|
||||
DeviceID = ((ULONG*)(pAcpiOutputBuffer->Argument[0].Data))[1];
|
||||
|
||||
#else // PCI-based device
|
||||
|
||||
// Get the Vendor & Device IDs on PCI system
|
||||
PCI_COMMON_HEADER Header = {0};
|
||||
ULONG BytesRead;
|
||||
|
||||
Status = m_DxgkInterface.DxgkCbReadDeviceSpace(m_DxgkInterface.DeviceHandle,
|
||||
DXGK_WHICHSPACE_CONFIG,
|
||||
&Header,
|
||||
0,
|
||||
sizeof(Header),
|
||||
&BytesRead);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BDD_LOG_ERROR1("DxgkCbReadDeviceSpace failed with status 0x%I64x", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
VendorID = Header.VendorID;
|
||||
DeviceID = Header.DeviceID;
|
||||
|
||||
#endif
|
||||
|
||||
// TODO: Replace 0x1414 with your Vendor ID
|
||||
if (VendorID == 0x1414)
|
||||
{
|
||||
switch (DeviceID)
|
||||
{
|
||||
// TODO: Replace the case statements below with the Device IDs supported by this driver
|
||||
case 0x0000:
|
||||
case 0xFFFF: return STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_GRAPHICS_DRIVER_MISMATCH;
|
||||
}
|
||||
|
||||
// Even though Sample Basic Display Driver does not support hardware cursors, and reports such
|
||||
// in QueryAdapterInfo. This function can still be called to set the pointer to not visible
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pSetPointerPosition != NULL);
|
||||
BDD_ASSERT(pSetPointerPosition->VidPnSourceId < MAX_VIEWS);
|
||||
|
||||
if (!(pSetPointerPosition->Flags.Visible))
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
BDD_LOG_ASSERTION0("SetPointerPosition should never be called to set the pointer to visible since BDD doesn't support hardware cursors.");
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
// Basic Sample Display Driver does not support hardware cursors, and reports such
|
||||
// in QueryAdapterInfo. Therefore this function should never be called.
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pSetPointerShape != NULL);
|
||||
BDD_LOG_ASSERTION0("SetPointerShape should never be called since BDD doesn't support hardware cursors.");
|
||||
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::PresentDisplayOnly(_In_ CONST DXGKARG_PRESENT_DISPLAYONLY* pPresentDisplayOnly)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pPresentDisplayOnly != NULL);
|
||||
BDD_ASSERT(pPresentDisplayOnly->VidPnSourceId < MAX_VIEWS);
|
||||
|
||||
if (pPresentDisplayOnly->BytesPerPixel < MIN_BYTES_PER_PIXEL_REPORTED)
|
||||
{
|
||||
// Only >=32bpp modes are reported, therefore this Present should never pass anything less than 4 bytes per pixel
|
||||
BDD_LOG_ERROR1("pPresentDisplayOnly->BytesPerPixel is 0x%I64x, which is lower than the allowed.", pPresentDisplayOnly->BytesPerPixel);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// If it is in monitor off state or source is not supposed to be visible, don't present anything to the screen
|
||||
if ((m_MonitorPowerState > PowerDeviceD0) ||
|
||||
(m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Flags.SourceNotVisible))
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Present is only valid if the target is actively connected to this source
|
||||
if (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Flags.FrameBufferIsActive)
|
||||
{
|
||||
|
||||
// If actual pixels are coming through, will need to completely zero out physical address next time in BlackOutScreen
|
||||
m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].ZeroedOutStart.QuadPart = 0;
|
||||
m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].ZeroedOutEnd.QuadPart = 0;
|
||||
|
||||
|
||||
D3DKMDT_VIDPN_PRESENT_PATH_ROTATION RotationNeededByFb = pPresentDisplayOnly->Flags.Rotate ?
|
||||
m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Rotation :
|
||||
D3DKMDT_VPPR_IDENTITY;
|
||||
BYTE* pDst = (BYTE*)m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].FrameBuffer.Ptr;
|
||||
UINT DstBitPerPixel = BPPFromPixelFormat(m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.ColorFormat);
|
||||
if (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Scaling == D3DKMDT_VPPS_CENTERED)
|
||||
{
|
||||
UINT CenterShift = (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Height -
|
||||
m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].SrcModeHeight)*m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Pitch;
|
||||
CenterShift += (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Width -
|
||||
m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].SrcModeWidth)*DstBitPerPixel/8;
|
||||
pDst += (int)CenterShift/2;
|
||||
}
|
||||
return m_HardwareBlt[pPresentDisplayOnly->VidPnSourceId].ExecutePresentDisplayOnly(pDst,
|
||||
DstBitPerPixel,
|
||||
(BYTE*)pPresentDisplayOnly->pSource,
|
||||
pPresentDisplayOnly->BytesPerPixel,
|
||||
pPresentDisplayOnly->Pitch,
|
||||
pPresentDisplayOnly->NumMoves,
|
||||
pPresentDisplayOnly->pMoves,
|
||||
pPresentDisplayOnly->NumDirtyRects,
|
||||
pPresentDisplayOnly->pDirtyRect,
|
||||
RotationNeededByFb);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::StopDeviceAndReleasePostDisplayOwnership(_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
|
||||
_Out_ DXGK_DISPLAY_INFORMATION* pDisplayInfo)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(TargetId < MAX_CHILDREN);
|
||||
|
||||
|
||||
D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceId = FindSourceForTarget(TargetId, TRUE);
|
||||
|
||||
// In case BDD is the next driver to run, the monitor should not be off, since
|
||||
// this could cause the BIOS to hang when the EDID is retrieved on Start.
|
||||
if (m_MonitorPowerState > PowerDeviceD0)
|
||||
{
|
||||
SetPowerState(TargetId, PowerDeviceD0, PowerActionNone);
|
||||
}
|
||||
|
||||
// The driver has to black out the display and ensure it is visible when releasing ownership
|
||||
BlackOutScreen(SourceId);
|
||||
|
||||
*pDisplayInfo = m_CurrentModes[SourceId].DispInfo;
|
||||
|
||||
return StopDevice();
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::QueryVidPnHWCapability(_Inout_ DXGKARG_QUERYVIDPNHWCAPABILITY* pVidPnHWCaps)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT(pVidPnHWCaps != NULL);
|
||||
BDD_ASSERT(pVidPnHWCaps->SourceId < MAX_VIEWS);
|
||||
BDD_ASSERT(pVidPnHWCaps->TargetId < MAX_CHILDREN);
|
||||
|
||||
pVidPnHWCaps->VidPnHWCaps.DriverRotation = 1; // BDD does rotation in software
|
||||
pVidPnHWCaps->VidPnHWCaps.DriverScaling = 0; // BDD does not support scaling
|
||||
pVidPnHWCaps->VidPnHWCaps.DriverCloning = 0; // BDD does not support clone
|
||||
pVidPnHWCaps->VidPnHWCaps.DriverColorConvert = 1; // BDD does color conversions in software
|
||||
pVidPnHWCaps->VidPnHWCaps.DriverLinkedAdapaterOutput = 0; // BDD does not support linked adapters
|
||||
pVidPnHWCaps->VidPnHWCaps.DriverRemoteDisplay = 0; // BDD does not support remote displays
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::GetEdid(D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BDD_ASSERT_CHK(!m_Flags.EDID_Attempted);
|
||||
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
RtlZeroMemory(m_EDIDs[TargetId], sizeof(m_EDIDs[TargetId]));
|
||||
|
||||
|
||||
m_Flags.EDID_Attempted = TRUE;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
VOID BASIC_DISPLAY_DRIVER::BlackOutScreen(D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceId)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
|
||||
UINT ScreenHeight = m_CurrentModes[SourceId].DispInfo.Height;
|
||||
UINT ScreenPitch = m_CurrentModes[SourceId].DispInfo.Pitch;
|
||||
|
||||
PHYSICAL_ADDRESS NewPhysAddrStart = m_CurrentModes[SourceId].DispInfo.PhysicAddress;
|
||||
PHYSICAL_ADDRESS NewPhysAddrEnd;
|
||||
NewPhysAddrEnd.QuadPart = NewPhysAddrStart.QuadPart + (ScreenHeight * ScreenPitch);
|
||||
|
||||
if (m_CurrentModes[SourceId].Flags.FrameBufferIsActive)
|
||||
{
|
||||
BYTE* MappedAddr = reinterpret_cast<BYTE*>(m_CurrentModes[SourceId].FrameBuffer.Ptr);
|
||||
|
||||
// Zero any memory at the start that hasn't been zeroed recently
|
||||
if (NewPhysAddrStart.QuadPart < m_CurrentModes[SourceId].ZeroedOutStart.QuadPart)
|
||||
{
|
||||
if (NewPhysAddrEnd.QuadPart < m_CurrentModes[SourceId].ZeroedOutStart.QuadPart)
|
||||
{
|
||||
// No overlap
|
||||
RtlZeroMemory(MappedAddr, ScreenHeight * ScreenPitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlZeroMemory(MappedAddr, (UINT)(m_CurrentModes[SourceId].ZeroedOutStart.QuadPart - NewPhysAddrStart.QuadPart));
|
||||
}
|
||||
}
|
||||
|
||||
// Zero any memory at the end that hasn't been zeroed recently
|
||||
if (NewPhysAddrEnd.QuadPart > m_CurrentModes[SourceId].ZeroedOutEnd.QuadPart)
|
||||
{
|
||||
if (NewPhysAddrStart.QuadPart > m_CurrentModes[SourceId].ZeroedOutEnd.QuadPart)
|
||||
{
|
||||
// No overlap
|
||||
// NOTE: When actual pixels were the most recent thing drawn, ZeroedOutStart & ZeroedOutEnd will both be 0
|
||||
// and this is the path that will be used to black out the current screen.
|
||||
RtlZeroMemory(MappedAddr, ScreenHeight * ScreenPitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlZeroMemory(MappedAddr, (UINT)(NewPhysAddrEnd.QuadPart - m_CurrentModes[SourceId].ZeroedOutEnd.QuadPart));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_CurrentModes[SourceId].ZeroedOutStart.QuadPart = NewPhysAddrStart.QuadPart;
|
||||
m_CurrentModes[SourceId].ZeroedOutEnd.QuadPart = NewPhysAddrEnd.QuadPart;
|
||||
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::WriteHWInfoStr(_In_ HANDLE DevInstRegKeyHandle, _In_ PCWSTR pszwValueName, _In_ PCSTR pszValue)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
NTSTATUS Status;
|
||||
ANSI_STRING AnsiStrValue;
|
||||
UNICODE_STRING UnicodeStrValue;
|
||||
UNICODE_STRING UnicodeStrValueName;
|
||||
|
||||
// ZwSetValueKey wants the ValueName as a UNICODE_STRING
|
||||
RtlInitUnicodeString(&UnicodeStrValueName, pszwValueName);
|
||||
|
||||
// REG_SZ is for WCHARs, there is no equivalent for CHARs
|
||||
// Use the ansi/unicode conversion functions to get from PSTR to PWSTR
|
||||
RtlInitAnsiString(&AnsiStrValue, pszValue);
|
||||
Status = RtlAnsiStringToUnicodeString(&UnicodeStrValue, &AnsiStrValue, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BDD_LOG_ERROR1("RtlAnsiStringToUnicodeString failed with Status: 0x%I64x", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Write the value to the registry
|
||||
Status = ZwSetValueKey(DevInstRegKeyHandle,
|
||||
&UnicodeStrValueName,
|
||||
0,
|
||||
REG_SZ,
|
||||
UnicodeStrValue.Buffer,
|
||||
UnicodeStrValue.MaximumLength);
|
||||
|
||||
// Free the earlier allocated unicode string
|
||||
RtlFreeUnicodeString(&UnicodeStrValue);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BDD_LOG_ERROR1("ZwSetValueKey failed with Status: 0x%I64x", Status);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::RegisterHWInfo()
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
NTSTATUS Status;
|
||||
|
||||
// TODO: Replace these strings with proper information
|
||||
PCSTR StrHWInfoChipType = "Replace with the chip name";
|
||||
PCSTR StrHWInfoDacType = "Replace with the DAC name or identifier (ID)";
|
||||
PCSTR StrHWInfoAdapterString = "Replace with the name of the adapter";
|
||||
PCSTR StrHWInfoBiosString = "Replace with information about the BIOS";
|
||||
|
||||
HANDLE DevInstRegKeyHandle;
|
||||
Status = IoOpenDeviceRegistryKey(m_pPhysicalDevice, PLUGPLAY_REGKEY_DRIVER, KEY_SET_VALUE, &DevInstRegKeyHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BDD_LOG_ERROR2("IoOpenDeviceRegistryKey failed for PDO: 0x%I64x, Status: 0x%I64x", m_pPhysicalDevice, Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = WriteHWInfoStr(DevInstRegKeyHandle, L"HardwareInformation.ChipType", StrHWInfoChipType);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = WriteHWInfoStr(DevInstRegKeyHandle, L"HardwareInformation.DacType", StrHWInfoDacType);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = WriteHWInfoStr(DevInstRegKeyHandle, L"HardwareInformation.AdapterString", StrHWInfoAdapterString);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = WriteHWInfoStr(DevInstRegKeyHandle, L"HardwareInformation.BiosString", StrHWInfoBiosString);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
// MemorySize is a ULONG, unlike the others which are all strings
|
||||
UNICODE_STRING ValueNameMemorySize;
|
||||
RtlInitUnicodeString(&ValueNameMemorySize, L"HardwareInformation.MemorySize");
|
||||
DWORD MemorySize = 0; // BDD has no access to video memory
|
||||
Status = ZwSetValueKey(DevInstRegKeyHandle,
|
||||
&ValueNameMemorySize,
|
||||
0,
|
||||
REG_DWORD,
|
||||
&MemorySize,
|
||||
sizeof(MemorySize));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BDD_LOG_ERROR1("ZwSetValueKey for MemorySize failed with Status: 0x%I64x", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Non-Paged Code
|
||||
//
|
||||
#pragma code_seg(push)
|
||||
#pragma code_seg()
|
||||
D3DDDI_VIDEO_PRESENT_SOURCE_ID BASIC_DISPLAY_DRIVER::FindSourceForTarget(D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId, BOOLEAN DefaultToZero)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(TargetId);
|
||||
BDD_ASSERT_CHK(TargetId < MAX_CHILDREN);
|
||||
|
||||
for (UINT SourceId = 0; SourceId < MAX_VIEWS; ++SourceId)
|
||||
{
|
||||
if (m_CurrentModes[SourceId].FrameBuffer.Ptr != NULL)
|
||||
{
|
||||
return SourceId;
|
||||
}
|
||||
}
|
||||
|
||||
return DefaultToZero ? 0 : D3DDDI_ID_UNINITIALIZED;
|
||||
}
|
||||
|
||||
VOID BASIC_DISPLAY_DRIVER::DpcRoutine(VOID)
|
||||
{
|
||||
m_DxgkInterface.DxgkCbNotifyDpc((HANDLE)m_DxgkInterface.DeviceHandle);
|
||||
}
|
||||
|
||||
BOOLEAN BASIC_DISPLAY_DRIVER::InterruptRoutine(_In_ ULONG MessageNumber)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(MessageNumber);
|
||||
|
||||
// BDD cannot handle interrupts
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID BASIC_DISPLAY_DRIVER::ResetDevice(VOID)
|
||||
{
|
||||
}
|
||||
|
||||
// Must be Non-Paged, as it sets up the display for a bugcheck
|
||||
NTSTATUS BASIC_DISPLAY_DRIVER::SystemDisplayEnable(_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
|
||||
_In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS Flags,
|
||||
_Out_ UINT* pWidth,
|
||||
_Out_ UINT* pHeight,
|
||||
_Out_ D3DDDIFORMAT* pColorFormat)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(Flags);
|
||||
|
||||
m_SystemDisplaySourceId = D3DDDI_ID_UNINITIALIZED;
|
||||
|
||||
BDD_ASSERT((TargetId < MAX_CHILDREN) || (TargetId == D3DDDI_ID_UNINITIALIZED));
|
||||
|
||||
// Find the frame buffer for displaying the bugcheck, if it was successfully mapped
|
||||
if (TargetId == D3DDDI_ID_UNINITIALIZED)
|
||||
{
|
||||
for (UINT SourceIdx = 0; SourceIdx < MAX_VIEWS; ++SourceIdx)
|
||||
{
|
||||
if (m_CurrentModes[SourceIdx].FrameBuffer.Ptr != NULL)
|
||||
{
|
||||
m_SystemDisplaySourceId = SourceIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_SystemDisplaySourceId = FindSourceForTarget(TargetId, FALSE);
|
||||
}
|
||||
|
||||
if (m_SystemDisplaySourceId == D3DDDI_ID_UNINITIALIZED)
|
||||
{
|
||||
{
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_CurrentModes[m_SystemDisplaySourceId].Rotation == D3DKMDT_VPPR_ROTATE90) ||
|
||||
(m_CurrentModes[m_SystemDisplaySourceId].Rotation == D3DKMDT_VPPR_ROTATE270))
|
||||
{
|
||||
*pHeight = m_CurrentModes[m_SystemDisplaySourceId].DispInfo.Width;
|
||||
*pWidth = m_CurrentModes[m_SystemDisplaySourceId].DispInfo.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pWidth = m_CurrentModes[m_SystemDisplaySourceId].DispInfo.Width;
|
||||
*pHeight = m_CurrentModes[m_SystemDisplaySourceId].DispInfo.Height;
|
||||
}
|
||||
|
||||
*pColorFormat = m_CurrentModes[m_SystemDisplaySourceId].DispInfo.ColorFormat;
|
||||
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Must be Non-Paged, as it is called to display the bugcheck screen
|
||||
VOID BASIC_DISPLAY_DRIVER::SystemDisplayWrite(_In_reads_bytes_(SourceHeight * SourceStride) VOID* pSource,
|
||||
_In_ UINT SourceWidth,
|
||||
_In_ UINT SourceHeight,
|
||||
_In_ UINT SourceStride,
|
||||
_In_ INT PositionX,
|
||||
_In_ INT PositionY)
|
||||
{
|
||||
|
||||
// Rect will be Offset by PositionX/Y in the src to reset it back to 0
|
||||
RECT Rect;
|
||||
Rect.left = PositionX;
|
||||
Rect.top = PositionY;
|
||||
Rect.right = Rect.left + SourceWidth;
|
||||
Rect.bottom = Rect.top + SourceHeight;
|
||||
|
||||
// Set up destination blt info
|
||||
BLT_INFO DstBltInfo;
|
||||
DstBltInfo.pBits = m_CurrentModes[m_SystemDisplaySourceId].FrameBuffer.Ptr;
|
||||
DstBltInfo.Pitch = m_CurrentModes[m_SystemDisplaySourceId].DispInfo.Pitch;
|
||||
DstBltInfo.BitsPerPel = BPPFromPixelFormat(m_CurrentModes[m_SystemDisplaySourceId].DispInfo.ColorFormat);
|
||||
DstBltInfo.Offset.x = 0;
|
||||
DstBltInfo.Offset.y = 0;
|
||||
DstBltInfo.Rotation = m_CurrentModes[m_SystemDisplaySourceId].Rotation;
|
||||
DstBltInfo.Width = m_CurrentModes[m_SystemDisplaySourceId].DispInfo.Width;
|
||||
DstBltInfo.Height = m_CurrentModes[m_SystemDisplaySourceId].DispInfo.Height;
|
||||
|
||||
// Set up source blt info
|
||||
BLT_INFO SrcBltInfo;
|
||||
SrcBltInfo.pBits = pSource;
|
||||
SrcBltInfo.Pitch = SourceStride;
|
||||
SrcBltInfo.BitsPerPel = 32;
|
||||
|
||||
SrcBltInfo.Offset.x = -PositionX;
|
||||
SrcBltInfo.Offset.y = -PositionY;
|
||||
SrcBltInfo.Rotation = D3DKMDT_VPPR_IDENTITY;
|
||||
SrcBltInfo.Width = SourceWidth;
|
||||
SrcBltInfo.Height = SourceHeight;
|
||||
|
||||
BltBits(&DstBltInfo,
|
||||
&SrcBltInfo,
|
||||
1, // NumRects
|
||||
&Rect);
|
||||
}
|
||||
|
||||
#pragma code_seg(pop) // End Non-Paged Code
|
||||
|
||||
-650
@@ -1,650 +0,0 @@
|
||||
/******************************Module*Header*******************************\
|
||||
* Module Name: BDD.hxx
|
||||
*
|
||||
* Basic Display Driver header file
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2010 Microsoft Corporation
|
||||
\**************************************************************************/
|
||||
|
||||
#ifndef _BDD_HXX_
|
||||
#define _BDD_HXX_
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#define __CPLUSPLUS
|
||||
|
||||
// Standard C-runtime headers
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <initguid.h>
|
||||
|
||||
// NTOS headers
|
||||
#include <ntddk.h>
|
||||
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#endif
|
||||
|
||||
// Windows headers
|
||||
#include <windef.h>
|
||||
#include <winerror.h>
|
||||
|
||||
// Windows GDI headers
|
||||
#include <wingdi.h>
|
||||
|
||||
// Windows DDI headers
|
||||
#include <winddi.h>
|
||||
#include <ntddvdeo.h>
|
||||
|
||||
#include <d3dkmddi.h>
|
||||
#include <d3dkmthk.h>
|
||||
|
||||
#include <ntstrsafe.h>
|
||||
#include <ntintsafe.h>
|
||||
|
||||
#include <dispmprt.h>
|
||||
};
|
||||
|
||||
#define EDID_V1_BLOCK_SIZE 128
|
||||
|
||||
#include "BDD_ErrorLog.hxx"
|
||||
|
||||
#define MIN_WIDTH 640
|
||||
#define MIN_HEIGHT 480
|
||||
#define MIN_BITS_PER_PIXEL_ALLOWED 8
|
||||
#define MIN_BYTES_PER_PIXEL_REPORTED 4
|
||||
|
||||
#define DEFAULT_WIDTH 1024
|
||||
#define DEFAULT_HEIGHT 768
|
||||
|
||||
#define MAX_INVALID_INHERITED_WIDTH 1024
|
||||
#define MAX_INVALID_INHERITED_HEIGHT 768
|
||||
|
||||
#define BITS_PER_BYTE 8
|
||||
|
||||
typedef struct _BLT_INFO
|
||||
{
|
||||
PVOID pBits;
|
||||
UINT Pitch;
|
||||
UINT BitsPerPel;
|
||||
POINT Offset; // To unrotated top-left of dirty rects
|
||||
D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation;
|
||||
UINT Width; // For the unrotated image
|
||||
UINT Height; // For the unrotated image
|
||||
} BLT_INFO;
|
||||
|
||||
#define MAX_CHILDREN 1
|
||||
#define MAX_VIEWS 1
|
||||
|
||||
typedef struct _BDD_FLAGS
|
||||
{
|
||||
UINT DriverStarted : 1; // ( 1) 1 after StartDevice and 0 after StopDevice
|
||||
UINT EDID_Retrieved : 1; // ( 2) EDID was successfully retrieved
|
||||
UINT EDID_ValidChecksum : 1; // ( 3) Retrieved EDID has a valid checksum
|
||||
UINT EDID_ValidHeader : 1; // ( 4) Retrieved EDID has a valid header
|
||||
UINT EDID_Attempted : 1; // ( 5) 1 if an attempt was made to retrieve the EDID, successful or not
|
||||
|
||||
// IMPORTANT: All new flags must be added to just before _LastFlag (i.e. right above this comment), this allows different versions of diagnostics to still be useful.
|
||||
UINT _LastFlag : 1; // ( 6) Always set to 1, is used to ensure that diagnostic version matches binary version
|
||||
UINT Unused : 26;
|
||||
} BDD_FLAGS;
|
||||
|
||||
// Represents the current mode, may not always be set (i.e. frame buffer mapped) if representing the mode passed in on single mode setups.
|
||||
typedef struct _CURRENT_BDD_MODE
|
||||
{
|
||||
// The source mode currently set for HW Framebuffer
|
||||
// For sample driver this info filled in StartDevice by the OS and never changed.
|
||||
DXGK_DISPLAY_INFORMATION DispInfo;
|
||||
|
||||
// The rotation of the current mode. Rotation is performed in software during Present call
|
||||
D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation;
|
||||
|
||||
D3DKMDT_VIDPN_PRESENT_PATH_SCALING Scaling;
|
||||
// This mode might be different from one which are supported for HW frame buffer
|
||||
// Scaling/displasment might be needed (if supported)
|
||||
UINT SrcModeWidth;
|
||||
UINT SrcModeHeight;
|
||||
|
||||
// Various boolean flags the struct uses
|
||||
struct _CURRENT_BDD_MODE_FLAGS
|
||||
{
|
||||
UINT SourceNotVisible : 1; // 0 if source is visible
|
||||
UINT FullscreenPresent : 1; // 0 if should use dirty rects for present
|
||||
UINT FrameBufferIsActive : 1; // 0 if not currently active (i.e. target not connected to source)
|
||||
UINT DoNotMapOrUnmap : 1; // 1 if the FrameBuffer should not be (un)mapped during normal execution
|
||||
UINT IsInternal : 1; // 1 if it was determined (i.e. through ACPI) that an internal panel is being driven
|
||||
UINT Unused : 27;
|
||||
} Flags;
|
||||
|
||||
// The start and end of physical memory known to be all zeroes. Used to optimize the BlackOutScreen function to not write
|
||||
// zeroes to memory already known to be zero. (Physical address is located in DispInfo)
|
||||
PHYSICAL_ADDRESS ZeroedOutStart;
|
||||
PHYSICAL_ADDRESS ZeroedOutEnd;
|
||||
|
||||
// Linear frame buffer pointer
|
||||
// A union with a ULONG64 is used here to ensure this struct looks the same on 32bit and 64bit builds
|
||||
// since the size of a VOID* changes depending on the build.
|
||||
union
|
||||
{
|
||||
VOID* Ptr;
|
||||
ULONG64 Force8Bytes;
|
||||
} FrameBuffer;
|
||||
} CURRENT_BDD_MODE;
|
||||
|
||||
class BASIC_DISPLAY_DRIVER;
|
||||
|
||||
class BDD_HWBLT
|
||||
{
|
||||
public:
|
||||
D3DDDI_VIDEO_PRESENT_SOURCE_ID m_SourceId;
|
||||
BASIC_DISPLAY_DRIVER* m_DevExt;
|
||||
BOOLEAN m_SynchExecution;
|
||||
HANDLE m_hPresentWorkerThread;
|
||||
PVOID m_pPresentWorkerThread;
|
||||
|
||||
// Events to contol thread execution
|
||||
KEVENT m_hThreadStartupEvent;
|
||||
KEVENT m_hThreadSuspendEvent;
|
||||
|
||||
BDD_HWBLT();
|
||||
|
||||
~BDD_HWBLT();
|
||||
|
||||
void Initialize(_In_ BASIC_DISPLAY_DRIVER* DevExt, _In_ UINT IdSrc) { m_DevExt = DevExt; m_SourceId = IdSrc; }
|
||||
void SetPresentWorkerThreadInfo(HANDLE hWorkerThread);
|
||||
NTSTATUS ExecutePresentDisplayOnly(_In_ BYTE* DstAddr,
|
||||
_In_ UINT DstBitPerPixel,
|
||||
_In_ BYTE* SrcAddr,
|
||||
_In_ UINT SrcBytesPerPixel,
|
||||
_In_ LONG SrcPitch,
|
||||
_In_ ULONG NumMoves,
|
||||
_In_ D3DKMT_MOVE_RECT* pMoves,
|
||||
_In_ ULONG NumDirtyRects,
|
||||
_In_ RECT* pDirtyRect,
|
||||
_In_ D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation);
|
||||
|
||||
};
|
||||
|
||||
class BASIC_DISPLAY_DRIVER
|
||||
{
|
||||
private:
|
||||
DEVICE_OBJECT* m_pPhysicalDevice;
|
||||
DXGKRNL_INTERFACE m_DxgkInterface;
|
||||
|
||||
// Information passed in by StartDevice DDI
|
||||
DXGK_START_INFO m_StartInfo;
|
||||
|
||||
|
||||
// Array of EDIDs, currently only supporting base block, hence EDID_V1_BLOCK_SIZE for size of each EDID
|
||||
BYTE m_EDIDs[MAX_CHILDREN][EDID_V1_BLOCK_SIZE];
|
||||
|
||||
CURRENT_BDD_MODE m_CurrentModes[MAX_VIEWS];
|
||||
|
||||
|
||||
BDD_HWBLT m_HardwareBlt[MAX_VIEWS];
|
||||
|
||||
// Current monitorpower state (this needs to be changed if MAX_CHILDREN != 1)
|
||||
DEVICE_POWER_STATE m_MonitorPowerState;
|
||||
|
||||
// Current adapter power state
|
||||
DEVICE_POWER_STATE m_AdapterPowerState;
|
||||
|
||||
// Source ID to be used by SystemDisplay functions
|
||||
D3DDDI_VIDEO_PRESENT_SOURCE_ID m_SystemDisplaySourceId;
|
||||
|
||||
// Various boolean flags the class uses
|
||||
BDD_FLAGS m_Flags;
|
||||
|
||||
// Device information
|
||||
DXGK_DEVICE_INFO m_DeviceInfo;
|
||||
|
||||
public:
|
||||
BASIC_DISPLAY_DRIVER(_In_ DEVICE_OBJECT* pPhysicalDeviceObject);
|
||||
~BASIC_DISPLAY_DRIVER();
|
||||
|
||||
#pragma code_seg(push)
|
||||
#pragma code_seg()
|
||||
BOOLEAN IsDriverActive() const
|
||||
{
|
||||
return m_Flags.DriverStarted;
|
||||
}
|
||||
#pragma code_seg(pop)
|
||||
|
||||
NTSTATUS StartDevice(_In_ DXGK_START_INFO* pDxgkStartInfo,
|
||||
_In_ DXGKRNL_INTERFACE* pDxgkInterface,
|
||||
_Out_ ULONG* pNumberOfViews,
|
||||
_Out_ ULONG* pNumberOfChildren);
|
||||
|
||||
NTSTATUS StopDevice(VOID);
|
||||
|
||||
// Must be Non-Paged
|
||||
VOID ResetDevice(VOID);
|
||||
|
||||
|
||||
const CURRENT_BDD_MODE* GetCurrentMode(UINT SourceId) const
|
||||
{
|
||||
return (SourceId < MAX_VIEWS)?&m_CurrentModes[SourceId]:NULL;
|
||||
}
|
||||
const DXGKRNL_INTERFACE* GetDxgkInterface() const { return &m_DxgkInterface;}
|
||||
|
||||
// Not implemented since no IOCTLs currently handled.
|
||||
NTSTATUS DispatchIoRequest(_In_ ULONG VidPnSourceId,
|
||||
_In_ VIDEO_REQUEST_PACKET* pVideoRequestPacket);
|
||||
|
||||
// Used to either turn off/on monitor (if possible), or mark that system is going into hibernate
|
||||
NTSTATUS SetPowerState(_In_ ULONG HardwareUid,
|
||||
_In_ DEVICE_POWER_STATE DevicePowerState,
|
||||
_In_ POWER_ACTION ActionType);
|
||||
|
||||
// Report back child capabilities
|
||||
NTSTATUS QueryChildRelations(_Out_writes_bytes_(ChildRelationsSize) DXGK_CHILD_DESCRIPTOR* pChildRelations,
|
||||
_In_ ULONG ChildRelationsSize);
|
||||
|
||||
NTSTATUS QueryChildStatus(_Inout_ DXGK_CHILD_STATUS* pChildStatus,
|
||||
_In_ BOOLEAN NonDestructiveOnly);
|
||||
|
||||
// Return EDID if previously retrieved
|
||||
NTSTATUS QueryDeviceDescriptor(_In_ ULONG ChildUid,
|
||||
_Inout_ DXGK_DEVICE_DESCRIPTOR* pDeviceDescriptor);
|
||||
|
||||
// Must be Non-Paged
|
||||
// BDD doesn't have interrupts, so just returns false
|
||||
BOOLEAN InterruptRoutine(_In_ ULONG MessageNumber);
|
||||
|
||||
VOID DpcRoutine(VOID);
|
||||
|
||||
// Return DriverCaps, doesn't support other queries though
|
||||
NTSTATUS QueryAdapterInfo(_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo);
|
||||
|
||||
NTSTATUS SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition);
|
||||
|
||||
NTSTATUS SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape);
|
||||
|
||||
NTSTATUS PresentDisplayOnly(_In_ CONST DXGKARG_PRESENT_DISPLAYONLY* pPresentDisplayOnly);
|
||||
|
||||
NTSTATUS IsSupportedVidPn(_Inout_ DXGKARG_ISSUPPORTEDVIDPN* pIsSupportedVidPn);
|
||||
|
||||
NTSTATUS RecommendFunctionalVidPn(_In_ CONST DXGKARG_RECOMMENDFUNCTIONALVIDPN* CONST pRecommendFunctionalVidPn);
|
||||
|
||||
NTSTATUS RecommendVidPnTopology(_In_ CONST DXGKARG_RECOMMENDVIDPNTOPOLOGY* CONST pRecommendVidPnTopology);
|
||||
|
||||
NTSTATUS RecommendMonitorModes(_In_ CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModes);
|
||||
|
||||
NTSTATUS EnumVidPnCofuncModality(_In_ CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModality);
|
||||
|
||||
NTSTATUS SetVidPnSourceVisibility(_In_ CONST DXGKARG_SETVIDPNSOURCEVISIBILITY* pSetVidPnSourceVisibility);
|
||||
|
||||
NTSTATUS CommitVidPn(_In_ CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPn);
|
||||
|
||||
NTSTATUS UpdateActiveVidPnPresentPath(_In_ CONST DXGKARG_UPDATEACTIVEVIDPNPRESENTPATH* CONST pUpdateActiveVidPnPresentPath);
|
||||
|
||||
NTSTATUS QueryVidPnHWCapability(_Inout_ DXGKARG_QUERYVIDPNHWCAPABILITY* pVidPnHWCaps);
|
||||
|
||||
// Part of PnPStop (PnP instance only), returns current mode information (which will be passed to fallback instance by dxgkrnl)
|
||||
NTSTATUS StopDeviceAndReleasePostDisplayOwnership(_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
|
||||
_Out_ DXGK_DISPLAY_INFORMATION* pDisplayInfo);
|
||||
|
||||
// Must be Non-Paged
|
||||
// Call to initialize as part of bugcheck
|
||||
NTSTATUS SystemDisplayEnable(_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
|
||||
_In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS Flags,
|
||||
_Out_ UINT* pWidth,
|
||||
_Out_ UINT* pHeight,
|
||||
_Out_ D3DDDIFORMAT* pColorFormat);
|
||||
|
||||
// Must be Non-Paged
|
||||
// Write out pixels as part of bugcheck
|
||||
VOID SystemDisplayWrite(_In_reads_bytes_(SourceHeight * SourceStride) VOID* pSource,
|
||||
_In_ UINT SourceWidth,
|
||||
_In_ UINT SourceHeight,
|
||||
_In_ UINT SourceStride,
|
||||
_In_ INT PositionX,
|
||||
_In_ INT PositionY);
|
||||
|
||||
|
||||
private:
|
||||
VOID CleanUp();
|
||||
|
||||
NTSTATUS CommonStart();
|
||||
|
||||
NTSTATUS GetEdid(D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId);
|
||||
|
||||
|
||||
// Given pixel format, give back the bits per pixel. Only supports pixel formats expected by BDD
|
||||
// (i.e. the ones found below in PixelFormatFromBPP or that may come in from FallbackStart)
|
||||
// This is because these two functions combine to allow BDD to store the bpp of a VBE mode in the
|
||||
// ColorFormat field of a DispInfo
|
||||
UINT BPPFromPixelFormat(D3DDDIFORMAT Format) const
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case D3DDDIFMT_UNKNOWN: return 0;
|
||||
case D3DDDIFMT_P8: return 8;
|
||||
case D3DDDIFMT_R5G6B5: return 16;
|
||||
case D3DDDIFMT_R8G8B8: return 24;
|
||||
case D3DDDIFMT_X8R8G8B8: // fall through
|
||||
case D3DDDIFMT_A8R8G8B8: return 32;
|
||||
default: BDD_LOG_ASSERTION1("Unknown D3DDDIFORMAT 0x%I64x", Format); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Given bits per pixel, return the pixel format at the same bpp
|
||||
D3DDDIFORMAT PixelFormatFromBPP(UINT BPP) const
|
||||
{
|
||||
switch (BPP)
|
||||
{
|
||||
case 8: return D3DDDIFMT_P8;
|
||||
case 16: return D3DDDIFMT_R5G6B5;
|
||||
case 24: return D3DDDIFMT_R8G8B8;
|
||||
case 32: return D3DDDIFMT_X8R8G8B8;
|
||||
default: BDD_LOG_ASSERTION1("A bit per pixel of 0x%I64x is not supported.", BPP); return D3DDDIFMT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// These two functions make checks on the values of some of the fields of their respective structures to ensure
|
||||
// that the specified fields are supported by BDD, i.e. gamma ramp must be D3DDDI_GAMMARAMP_DEFAULT
|
||||
NTSTATUS IsVidPnPathFieldsValid(CONST D3DKMDT_VIDPN_PRESENT_PATH* pPath) const;
|
||||
NTSTATUS IsVidPnSourceModeFieldsValid(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMode) const;
|
||||
|
||||
VOID BlackOutScreen(D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceId);
|
||||
|
||||
// Returns the index into gBddBiosData.BddModes of the VBE mode that matches the given VidPnSourceMode.
|
||||
// If such a mode cannot be found, returns a number outside of [0, gBddBiosData.CountBddModes)
|
||||
UINT FindMatchingVBEMode(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMode) const;
|
||||
|
||||
// Must be Non-Paged
|
||||
// Returns the SourceId that has TargetId as a valid frame buffer or D3DDDI_ID_UNINITIALIZED if no such SourceId exists
|
||||
D3DDDI_VIDEO_PRESENT_SOURCE_ID FindSourceForTarget(D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId, BOOLEAN DefaultToZero);
|
||||
|
||||
// Set the given source mode on the given path
|
||||
NTSTATUS SetSourceModeAndPath(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMode,
|
||||
CONST D3DKMDT_VIDPN_PRESENT_PATH* pPath);
|
||||
|
||||
|
||||
// Add the current mode to the given monitor source mode set
|
||||
NTSTATUS AddSingleMonitorMode(_In_ CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModes);
|
||||
|
||||
|
||||
// Add the current mode to the given VidPn source mode set
|
||||
NTSTATUS AddSingleSourceMode(_In_ CONST DXGK_VIDPNSOURCEMODESET_INTERFACE* pVidPnSourceModeSetInterface,
|
||||
D3DKMDT_HVIDPNSOURCEMODESET hVidPnSourceModeSet,
|
||||
D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceId);
|
||||
|
||||
// Add the current mode (or the matching to pinned source mode) to the give VidPn target mode set
|
||||
NTSTATUS AddSingleTargetMode(_In_ CONST DXGK_VIDPNTARGETMODESET_INTERFACE* pVidPnTargetModeSetInterface,
|
||||
D3DKMDT_HVIDPNTARGETMODESET hVidPnTargetModeSet,
|
||||
_In_opt_ CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnPinnedSourceModeInfo,
|
||||
D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceId);
|
||||
|
||||
// Check that the hardware the driver is running on is hardware it is capable of driving.
|
||||
NTSTATUS CheckHardware();
|
||||
|
||||
// Helper function for RegisterHWInfo
|
||||
NTSTATUS WriteHWInfoStr(_In_ HANDLE DevInstRegKeyHandle, _In_ PCWSTR pszwValueName, _In_ PCSTR pszValue);
|
||||
|
||||
// Set the information in the registry as described here: http://msdn.microsoft.com/en-us/library/windows/hardware/ff569240(v=vs.85).aspx
|
||||
NTSTATUS RegisterHWInfo();
|
||||
};
|
||||
|
||||
//
|
||||
// Blt functions
|
||||
//
|
||||
|
||||
// Must be Non-Paged
|
||||
VOID BltBits(
|
||||
BLT_INFO* pDst,
|
||||
CONST BLT_INFO* pSrc,
|
||||
UINT NumRects,
|
||||
_In_reads_(NumRects) CONST RECT *pRects);
|
||||
|
||||
//
|
||||
// Driver Entry point
|
||||
//
|
||||
|
||||
extern "C"
|
||||
DRIVER_INITIALIZE DriverEntry;
|
||||
|
||||
//
|
||||
// PnP DDIs
|
||||
//
|
||||
|
||||
VOID
|
||||
BddDdiUnload(VOID);
|
||||
|
||||
// If uncommenting ENABLE_DXGK_SAL in the sources file, all the below function prototypes should be updated to use
|
||||
// the function typedef's from the header files. Additionally, annotations on the function definitions can be removed
|
||||
// as they are inherited from the prototype definition here. As an example the entire 4-line prototype for BddDdiAddDevice
|
||||
// is replaced by the single commented line below:
|
||||
// DXGKDDI_ADD_DEVICE BddDdiAddDevice;
|
||||
NTSTATUS
|
||||
BddDdiAddDevice(
|
||||
_In_ DEVICE_OBJECT* pPhysicalDeviceObject,
|
||||
_Outptr_ PVOID* ppDeviceContext);
|
||||
|
||||
NTSTATUS
|
||||
BddDdiRemoveDevice(
|
||||
_In_ VOID* pDeviceContext);
|
||||
|
||||
NTSTATUS
|
||||
BddDdiStartDevice(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ DXGK_START_INFO* pDxgkStartInfo,
|
||||
_In_ DXGKRNL_INTERFACE* pDxgkInterface,
|
||||
_Out_ ULONG* pNumberOfViews,
|
||||
_Out_ ULONG* pNumberOfChildren);
|
||||
|
||||
NTSTATUS
|
||||
BddDdiStopDevice(
|
||||
_In_ VOID* pDeviceContext);
|
||||
|
||||
VOID
|
||||
BddDdiResetDevice(
|
||||
_In_ VOID* pDeviceContext);
|
||||
|
||||
|
||||
NTSTATUS
|
||||
BddDdiDispatchIoRequest(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ ULONG VidPnSourceId,
|
||||
_In_ VIDEO_REQUEST_PACKET* pVideoRequestPacket);
|
||||
|
||||
NTSTATUS
|
||||
BddDdiSetPowerState(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ ULONG HardwareUid,
|
||||
_In_ DEVICE_POWER_STATE DevicePowerState,
|
||||
_In_ POWER_ACTION ActionType);
|
||||
|
||||
NTSTATUS
|
||||
BddDdiQueryChildRelations(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_Out_writes_bytes_(ChildRelationsSize) DXGK_CHILD_DESCRIPTOR* pChildRelations,
|
||||
_In_ ULONG ChildRelationsSize);
|
||||
|
||||
NTSTATUS
|
||||
BddDdiQueryChildStatus(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_Inout_ DXGK_CHILD_STATUS* pChildStatus,
|
||||
_In_ BOOLEAN NonDestructiveOnly);
|
||||
|
||||
NTSTATUS
|
||||
BddDdiQueryDeviceDescriptor(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ ULONG ChildUid,
|
||||
_Inout_ DXGK_DEVICE_DESCRIPTOR* pDeviceDescriptor);
|
||||
|
||||
// Must be Non-Paged
|
||||
BOOLEAN
|
||||
BddDdiInterruptRoutine(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ ULONG MessageNumber);
|
||||
|
||||
VOID
|
||||
BddDdiDpcRoutine(
|
||||
_In_ VOID* pDeviceContext);
|
||||
|
||||
//
|
||||
// WDDM Display Only Driver DDIs
|
||||
//
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiQueryAdapterInfo(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiSetPointerPosition(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiSetPointerShape(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiPresentDisplayOnly(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_PRESENT_DISPLAYONLY* pPresentDisplayOnly);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiIsSupportedVidPn(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_Inout_ DXGKARG_ISSUPPORTEDVIDPN* pIsSupportedVidPn);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiRecommendFunctionalVidPn(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_RECOMMENDFUNCTIONALVIDPN* CONST pRecommendFunctionalVidPn);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiRecommendVidPnTopology(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_RECOMMENDVIDPNTOPOLOGY* CONST pRecommendVidPnTopology);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiRecommendMonitorModes(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModes);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiEnumVidPnCofuncModality(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModality);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiSetVidPnSourceVisibility(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_SETVIDPNSOURCEVISIBILITY* pSetVidPnSourceVisibility);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiCommitVidPn(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPn);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiUpdateActiveVidPnPresentPath(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_UPDATEACTIVEVIDPNPRESENTPATH* CONST pUpdateActiveVidPnPresentPath);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiQueryVidPnHWCapability(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_Inout_ DXGKARG_QUERYVIDPNHWCAPABILITY* pVidPnHWCaps);
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiStopDeviceAndReleasePostDisplayOwnership(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
|
||||
_Out_ DXGK_DISPLAY_INFORMATION* DisplayInfo);
|
||||
|
||||
// Must be Non-Paged
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiSystemDisplayEnable(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
|
||||
_In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS Flags,
|
||||
_Out_ UINT* Width,
|
||||
_Out_ UINT* Height,
|
||||
_Out_ D3DDDIFORMAT* ColorFormat);
|
||||
|
||||
// Must be Non-Paged
|
||||
VOID
|
||||
APIENTRY
|
||||
BddDdiSystemDisplayWrite(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ VOID* Source,
|
||||
_In_ UINT SourceWidth,
|
||||
_In_ UINT SourceHeight,
|
||||
_In_ UINT SourceStride,
|
||||
_In_ UINT PositionX,
|
||||
_In_ UINT PositionY);
|
||||
|
||||
//
|
||||
// Frame buffer map/unmap
|
||||
//
|
||||
|
||||
NTSTATUS
|
||||
MapFrameBuffer(
|
||||
_In_ PHYSICAL_ADDRESS PhysicalAddress,
|
||||
_In_ ULONG Length,
|
||||
_Outptr_result_bytebuffer_(Length) VOID** VirtualAddress);
|
||||
|
||||
NTSTATUS
|
||||
UnmapFrameBuffer(
|
||||
_In_reads_bytes_(Length) VOID* VirtualAddress,
|
||||
_In_ ULONG Length);
|
||||
|
||||
|
||||
BOOLEAN
|
||||
IsEdidHeaderValid(_In_reads_bytes_(EDID_V1_BLOCK_SIZE) const BYTE* pEdid);
|
||||
|
||||
BOOLEAN
|
||||
IsEdidChecksumValid(_In_reads_bytes_(EDID_V1_BLOCK_SIZE) const BYTE* pEdid);
|
||||
|
||||
//
|
||||
// Memory handling
|
||||
//
|
||||
|
||||
// Defaulting the value of PoolType means that any call to new Foo()
|
||||
// will raise a compiler error for being ambiguous. This is to help keep
|
||||
// any calls to allocate memory from accidentally NOT going through
|
||||
// these functions.
|
||||
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
|
||||
__drv_reportError("Must succeed pool allocations are forbidden. "
|
||||
"Allocation failures cause a system crash"))
|
||||
void* __cdecl operator new(size_t Size, POOL_TYPE PoolType = PagedPool);
|
||||
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
|
||||
__drv_reportError("Must succeed pool allocations are forbidden. "
|
||||
"Allocation failures cause a system crash"))
|
||||
void* __cdecl operator new[](size_t Size, POOL_TYPE PoolType = PagedPool);
|
||||
void __cdecl operator delete(void* pObject);
|
||||
void __cdecl operator delete(void* pObject, size_t s);
|
||||
void __cdecl operator delete[](void* pObject);
|
||||
|
||||
// Pool allocation tag for the Sample Display Driver. All allocations use this tag.
|
||||
#define BDDTAG 'DDBS'
|
||||
|
||||
#endif // _BDD_HXX_
|
||||
|
||||
|
||||
@@ -1,579 +0,0 @@
|
||||
/******************************Module*Header*******************************\
|
||||
* Module Name: BDD_DDI.cxx
|
||||
*
|
||||
* Basic Display Driver DDI entry points redirects
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2010 Microsoft Corporation
|
||||
\**************************************************************************/
|
||||
|
||||
#include "BDD.hxx"
|
||||
|
||||
|
||||
#pragma code_seg(push)
|
||||
#pragma code_seg("INIT")
|
||||
// BEGIN: Init Code
|
||||
|
||||
//
|
||||
// Driver Entry point
|
||||
//
|
||||
|
||||
extern "C"
|
||||
NTSTATUS
|
||||
DriverEntry(
|
||||
_In_ DRIVER_OBJECT* pDriverObject,
|
||||
_In_ UNICODE_STRING* pRegistryPath)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
|
||||
// Initialize DDI function pointers and dxgkrnl
|
||||
KMDDOD_INITIALIZATION_DATA InitialData = {0};
|
||||
|
||||
InitialData.Version = DXGKDDI_INTERFACE_VERSION;
|
||||
|
||||
InitialData.DxgkDdiAddDevice = BddDdiAddDevice;
|
||||
InitialData.DxgkDdiStartDevice = BddDdiStartDevice;
|
||||
InitialData.DxgkDdiStopDevice = BddDdiStopDevice;
|
||||
InitialData.DxgkDdiResetDevice = BddDdiResetDevice;
|
||||
InitialData.DxgkDdiRemoveDevice = BddDdiRemoveDevice;
|
||||
InitialData.DxgkDdiDispatchIoRequest = BddDdiDispatchIoRequest;
|
||||
InitialData.DxgkDdiInterruptRoutine = BddDdiInterruptRoutine;
|
||||
InitialData.DxgkDdiDpcRoutine = BddDdiDpcRoutine;
|
||||
InitialData.DxgkDdiQueryChildRelations = BddDdiQueryChildRelations;
|
||||
InitialData.DxgkDdiQueryChildStatus = BddDdiQueryChildStatus;
|
||||
InitialData.DxgkDdiQueryDeviceDescriptor = BddDdiQueryDeviceDescriptor;
|
||||
InitialData.DxgkDdiSetPowerState = BddDdiSetPowerState;
|
||||
InitialData.DxgkDdiUnload = BddDdiUnload;
|
||||
InitialData.DxgkDdiQueryAdapterInfo = BddDdiQueryAdapterInfo;
|
||||
InitialData.DxgkDdiSetPointerPosition = BddDdiSetPointerPosition;
|
||||
InitialData.DxgkDdiSetPointerShape = BddDdiSetPointerShape;
|
||||
InitialData.DxgkDdiIsSupportedVidPn = BddDdiIsSupportedVidPn;
|
||||
InitialData.DxgkDdiRecommendFunctionalVidPn = BddDdiRecommendFunctionalVidPn;
|
||||
InitialData.DxgkDdiEnumVidPnCofuncModality = BddDdiEnumVidPnCofuncModality;
|
||||
InitialData.DxgkDdiSetVidPnSourceVisibility = BddDdiSetVidPnSourceVisibility;
|
||||
InitialData.DxgkDdiCommitVidPn = BddDdiCommitVidPn;
|
||||
InitialData.DxgkDdiUpdateActiveVidPnPresentPath = BddDdiUpdateActiveVidPnPresentPath;
|
||||
InitialData.DxgkDdiRecommendMonitorModes = BddDdiRecommendMonitorModes;
|
||||
InitialData.DxgkDdiQueryVidPnHWCapability = BddDdiQueryVidPnHWCapability;
|
||||
InitialData.DxgkDdiPresentDisplayOnly = BddDdiPresentDisplayOnly;
|
||||
InitialData.DxgkDdiStopDeviceAndReleasePostDisplayOwnership = BddDdiStopDeviceAndReleasePostDisplayOwnership;
|
||||
InitialData.DxgkDdiSystemDisplayEnable = BddDdiSystemDisplayEnable;
|
||||
InitialData.DxgkDdiSystemDisplayWrite = BddDdiSystemDisplayWrite;
|
||||
|
||||
NTSTATUS Status = DxgkInitializeDisplayOnlyDriver(pDriverObject, pRegistryPath, &InitialData);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BDD_LOG_ERROR1("DxgkInitializeDisplayOnlyDriver failed with Status: 0x%I64x", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
||||
// END: Init Code
|
||||
#pragma code_seg(pop)
|
||||
|
||||
#pragma code_seg(push)
|
||||
#pragma code_seg("PAGE")
|
||||
|
||||
//
|
||||
// PnP DDIs
|
||||
//
|
||||
|
||||
VOID
|
||||
BddDdiUnload(VOID)
|
||||
{
|
||||
PAGED_CODE();
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
BddDdiAddDevice(
|
||||
_In_ DEVICE_OBJECT* pPhysicalDeviceObject,
|
||||
_Outptr_ PVOID* ppDeviceContext)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
if ((pPhysicalDeviceObject == NULL) ||
|
||||
(ppDeviceContext == NULL))
|
||||
{
|
||||
BDD_LOG_ERROR2("One of pPhysicalDeviceObject (0x%I64x), ppDeviceContext (0x%I64x) is NULL",
|
||||
pPhysicalDeviceObject, ppDeviceContext);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
*ppDeviceContext = NULL;
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = new(NonPagedPoolNx) BASIC_DISPLAY_DRIVER(pPhysicalDeviceObject);
|
||||
if (pBDD == NULL)
|
||||
{
|
||||
BDD_LOG_LOW_RESOURCE0("pBDD failed to be allocated");
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
*ppDeviceContext = pBDD;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
BddDdiRemoveDevice(
|
||||
_In_ VOID* pDeviceContext)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
|
||||
if (pBDD)
|
||||
{
|
||||
delete pBDD;
|
||||
pBDD = NULL;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
BddDdiStartDevice(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ DXGK_START_INFO* pDxgkStartInfo,
|
||||
_In_ DXGKRNL_INTERFACE* pDxgkInterface,
|
||||
_Out_ ULONG* pNumberOfViews,
|
||||
_Out_ ULONG* pNumberOfChildren)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
return pBDD->StartDevice(pDxgkStartInfo, pDxgkInterface, pNumberOfViews, pNumberOfChildren);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
BddDdiStopDevice(
|
||||
_In_ VOID* pDeviceContext)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
return pBDD->StopDevice();
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
BddDdiDispatchIoRequest(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ ULONG VidPnSourceId,
|
||||
_In_ VIDEO_REQUEST_PACKET* pVideoRequestPacket)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->DispatchIoRequest(VidPnSourceId, pVideoRequestPacket);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
BddDdiSetPowerState(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ ULONG HardwareUid,
|
||||
_In_ DEVICE_POWER_STATE DevicePowerState,
|
||||
_In_ POWER_ACTION ActionType)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
// If the driver isn't active, SetPowerState can still be called, however in BDD's case
|
||||
// this shouldn't do anything, as it could for instance be called on BDD Fallback after
|
||||
// Fallback has been stopped and BDD PnP is being started. Fallback doesn't have control
|
||||
// of the hardware in this case.
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
return pBDD->SetPowerState(HardwareUid, DevicePowerState, ActionType);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
BddDdiQueryChildRelations(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_Out_writes_bytes_(ChildRelationsSize) DXGK_CHILD_DESCRIPTOR* pChildRelations,
|
||||
_In_ ULONG ChildRelationsSize)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
return pBDD->QueryChildRelations(pChildRelations, ChildRelationsSize);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
BddDdiQueryChildStatus(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_Inout_ DXGK_CHILD_STATUS* pChildStatus,
|
||||
_In_ BOOLEAN NonDestructiveOnly)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
return pBDD->QueryChildStatus(pChildStatus, NonDestructiveOnly);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
BddDdiQueryDeviceDescriptor(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ ULONG ChildUid,
|
||||
_Inout_ DXGK_DEVICE_DESCRIPTOR* pDeviceDescriptor)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
// During stress testing of PnPStop, it is possible for BDD Fallback to get called to start then stop in quick succession.
|
||||
// The first call queues a worker thread item indicating that it now has a child device, the second queues a worker thread
|
||||
// item that it no longer has any child device. This function gets called based on the first worker thread item, but after
|
||||
// the driver has been stopped. Therefore instead of asserting like other functions, we only warn.
|
||||
BDD_LOG_WARNING1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->QueryDeviceDescriptor(ChildUid, pDeviceDescriptor);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// WDDM Display Only Driver DDIs
|
||||
//
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiQueryAdapterInfo(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
return pBDD->QueryAdapterInfo(pQueryAdapterInfo);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiSetPointerPosition(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->SetPointerPosition(pSetPointerPosition);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiSetPointerShape(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->SetPointerShape(pSetPointerShape);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiPresentDisplayOnly(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_PRESENT_DISPLAYONLY* pPresentDisplayOnly)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->PresentDisplayOnly(pPresentDisplayOnly);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiStopDeviceAndReleasePostDisplayOwnership(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
|
||||
_Out_ DXGK_DISPLAY_INFORMATION* DisplayInfo)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
return pBDD->StopDeviceAndReleasePostDisplayOwnership(TargetId, DisplayInfo);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiIsSupportedVidPn(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_Inout_ DXGKARG_ISSUPPORTEDVIDPN* pIsSupportedVidPn)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
// This path might hit because win32k/dxgport doesn't check that an adapter is active when taking the adapter lock.
|
||||
// The adapter lock is the main thing BDD Fallback relies on to not be called while it's inactive. It is still a rare
|
||||
// timing issue around PnpStart/Stop and isn't expected to have any effect on the stability of the system.
|
||||
BDD_LOG_WARNING1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->IsSupportedVidPn(pIsSupportedVidPn);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiRecommendFunctionalVidPn(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_RECOMMENDFUNCTIONALVIDPN* CONST pRecommendFunctionalVidPn)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->RecommendFunctionalVidPn(pRecommendFunctionalVidPn);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiRecommendVidPnTopology(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_RECOMMENDVIDPNTOPOLOGY* CONST pRecommendVidPnTopology)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->RecommendVidPnTopology(pRecommendVidPnTopology);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiRecommendMonitorModes(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModes)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->RecommendMonitorModes(pRecommendMonitorModes);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiEnumVidPnCofuncModality(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModality)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->EnumVidPnCofuncModality(pEnumCofuncModality);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiSetVidPnSourceVisibility(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_SETVIDPNSOURCEVISIBILITY* pSetVidPnSourceVisibility)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->SetVidPnSourceVisibility(pSetVidPnSourceVisibility);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiCommitVidPn(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPn)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->CommitVidPn(pCommitVidPn);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiUpdateActiveVidPnPresentPath(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_In_ CONST DXGKARG_UPDATEACTIVEVIDPNPRESENTPATH* CONST pUpdateActiveVidPnPresentPath)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->UpdateActiveVidPnPresentPath(pUpdateActiveVidPnPresentPath);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiQueryVidPnHWCapability(
|
||||
_In_ CONST HANDLE hAdapter,
|
||||
_Inout_ DXGKARG_QUERYVIDPNHWCAPABILITY* pVidPnHWCaps)
|
||||
{
|
||||
PAGED_CODE();
|
||||
BDD_ASSERT_CHK(hAdapter != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(hAdapter);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
return pBDD->QueryVidPnHWCapability(pVidPnHWCaps);
|
||||
}
|
||||
//END: Paged Code
|
||||
#pragma code_seg(pop)
|
||||
|
||||
#pragma code_seg(push)
|
||||
#pragma code_seg()
|
||||
// BEGIN: Non-Paged Code
|
||||
|
||||
VOID
|
||||
BddDdiDpcRoutine(
|
||||
_In_ VOID* pDeviceContext)
|
||||
{
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
if (!pBDD->IsDriverActive())
|
||||
{
|
||||
BDD_LOG_ASSERTION1("BDD (0x%I64x) is being called when not active!", pBDD);
|
||||
return;
|
||||
}
|
||||
pBDD->DpcRoutine();
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
BddDdiInterruptRoutine(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ ULONG MessageNumber)
|
||||
{
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
return pBDD->InterruptRoutine(MessageNumber);
|
||||
}
|
||||
|
||||
VOID
|
||||
BddDdiResetDevice(
|
||||
_In_ VOID* pDeviceContext)
|
||||
{
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
pBDD->ResetDevice();
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
BddDdiSystemDisplayEnable(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
|
||||
_In_ PDXGKARG_SYSTEM_DISPLAY_ENABLE_FLAGS Flags,
|
||||
_Out_ UINT* Width,
|
||||
_Out_ UINT* Height,
|
||||
_Out_ D3DDDIFORMAT* ColorFormat)
|
||||
{
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
return pBDD->SystemDisplayEnable(TargetId, Flags, Width, Height, ColorFormat);
|
||||
}
|
||||
|
||||
VOID
|
||||
APIENTRY
|
||||
BddDdiSystemDisplayWrite(
|
||||
_In_ VOID* pDeviceContext,
|
||||
_In_ VOID* Source,
|
||||
_In_ UINT SourceWidth,
|
||||
_In_ UINT SourceHeight,
|
||||
_In_ UINT SourceStride,
|
||||
_In_ UINT PositionX,
|
||||
_In_ UINT PositionY)
|
||||
{
|
||||
BDD_ASSERT_CHK(pDeviceContext != NULL);
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pBDD = reinterpret_cast<BASIC_DISPLAY_DRIVER*>(pDeviceContext);
|
||||
pBDD->SystemDisplayWrite(Source, SourceWidth, SourceHeight, SourceStride, PositionX, PositionY);
|
||||
}
|
||||
|
||||
// END: Non-Paged Code
|
||||
#pragma code_seg(pop)
|
||||
|
||||
-1083
File diff suppressed because it is too large.
Load diff
@@ -1,84 +0,0 @@
|
||||
/******************************Module*Header*******************************\
|
||||
* Module Name: BDD_ErrorLog.hxx
|
||||
*
|
||||
* Basic Display Driver Logging Macros
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2010 Microsoft Corporation
|
||||
*
|
||||
\**************************************************************************/
|
||||
#ifndef _BDD_ERRORLOG_HXX_
|
||||
#define _BDD_ERRORLOG_HXX_
|
||||
|
||||
#define BDD_LOG_ERROR0(Msg)
|
||||
#define BDD_LOG_ERROR1(Msg,Param1)
|
||||
#define BDD_LOG_ERROR2(Msg,Param1,Param2)
|
||||
#define BDD_LOG_ERROR3(Msg,Param1,Param2,Param3)
|
||||
#define BDD_LOG_ERROR4(Msg,Param1,Param2,Param3,Param4)
|
||||
#define BDD_LOG_ERROR5(Msg,Param1,Param2,Param3,Param4,Param5)
|
||||
|
||||
//
|
||||
// Warnings
|
||||
//
|
||||
|
||||
#define BDD_LOG_WARNING0(Msg)
|
||||
#define BDD_LOG_WARNING1(Msg,Param1)
|
||||
#define BDD_LOG_WARNING2(Msg,Param1,Param2)
|
||||
#define BDD_LOG_WARNING3(Msg,Param1,Param2,Param3)
|
||||
#define BDD_LOG_WARNING4(Msg,Param1,Param2,Param3,Param4)
|
||||
#define BDD_LOG_WARNING5(Msg,Param1,Param2,Param3,Param4,Param5)
|
||||
|
||||
//
|
||||
// Events (i.e. low-frequency tracing)
|
||||
//
|
||||
|
||||
#define BDD_LOG_EVENT0(Msg)
|
||||
#define BDD_LOG_EVENT1(Msg,Param1)
|
||||
#define BDD_LOG_EVENT2(Msg,Param1,Param2)
|
||||
#define BDD_LOG_EVENT3(Msg,Param1,Param2,Param3)
|
||||
#define BDD_LOG_EVENT4(Msg,Param1,Param2,Param3,Param4)
|
||||
#define BDD_LOG_EVENT5(Msg,Param1,Param2,Param3,Param4,Param5)
|
||||
|
||||
//
|
||||
// Information (i.e. high-frequency tracing)
|
||||
//
|
||||
|
||||
#define BDD_LOG_INFORMATION0(Msg)
|
||||
#define BDD_LOG_INFORMATION1(Msg,Param1)
|
||||
#define BDD_LOG_INFORMATION2(Msg,Param1,Param2)
|
||||
#define BDD_LOG_INFORMATION3(Msg,Param1,Param2,Param3)
|
||||
#define BDD_LOG_INFORMATION4(Msg,Param1,Param2,Param3,Param4)
|
||||
#define BDD_LOG_INFORMATION5(Msg,Param1,Param2,Param3,Param4,Param5)
|
||||
|
||||
//
|
||||
// Low resource logging macros.
|
||||
//
|
||||
|
||||
#define BDD_LOG_LOW_RESOURCE0(Msg)
|
||||
#define BDD_LOG_LOW_RESOURCE1(Msg,Param1)
|
||||
#define BDD_LOG_LOW_RESOURCE2(Msg,Param1,Param2)
|
||||
#define BDD_LOG_LOW_RESOURCE3(Msg,Param1,Param2,Param3)
|
||||
#define BDD_LOG_LOW_RESOURCE4(Msg,Param1,Param2,Param3,Param4)
|
||||
#define BDD_LOG_LOW_RESOURCE5(Msg,Param1,Param2,Param3,Param4,Param5)
|
||||
|
||||
//
|
||||
// Assertion logging macros.
|
||||
//
|
||||
|
||||
#define BDD_LOG_ASSERTION0(Msg) NT_ASSERT(FALSE)
|
||||
#define BDD_LOG_ASSERTION1(Msg,Param1) NT_ASSERT(FALSE)
|
||||
#define BDD_LOG_ASSERTION2(Msg,Param1,Param2) NT_ASSERT(FALSE)
|
||||
#define BDD_LOG_ASSERTION3(Msg,Param1,Param2,Param3) NT_ASSERT(FALSE)
|
||||
#define BDD_LOG_ASSERTION4(Msg,Param1,Param2,Param3,Param4) NT_ASSERT(FALSE)
|
||||
#define BDD_LOG_ASSERTION5(Msg,Param1,Param2,Param3,Param4,Param5) NT_ASSERT(FALSE)
|
||||
#define BDD_ASSERT(exp) {if (!(exp)) {BDD_LOG_ASSERTION0(#exp);}}
|
||||
|
||||
#if DBG
|
||||
#define BDD_ASSERT_CHK(exp) BDD_ASSERT(exp)
|
||||
#else
|
||||
#define BDD_ASSERT_CHK(exp) {}
|
||||
#endif
|
||||
|
||||
|
||||
#endif //_BDD_ERRORLOG_HXX_
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
/******************************Module*Header*******************************\
|
||||
* Module Name: bdd_util.cxx
|
||||
*
|
||||
* Basic Display Driver utility functions
|
||||
*
|
||||
* Created: 29-Mar-2011
|
||||
* Author: Amos Eshel [amosesh]
|
||||
*
|
||||
* Copyright (c) 2011 Microsoft Corporation
|
||||
\**************************************************************************/
|
||||
|
||||
#include "BDD.hxx"
|
||||
|
||||
|
||||
#pragma code_seg("PAGE")
|
||||
|
||||
//
|
||||
// EDID validation
|
||||
//
|
||||
|
||||
BOOLEAN IsEdidHeaderValid(_In_reads_bytes_(EDID_V1_BLOCK_SIZE) const BYTE* pEdid)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
static const UCHAR EDID1Header[8] = {0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0};
|
||||
return memcmp(pEdid, EDID1Header, sizeof(EDID1Header)) == 0;
|
||||
}
|
||||
|
||||
BOOLEAN IsEdidChecksumValid(_In_reads_bytes_(EDID_V1_BLOCK_SIZE) const BYTE* pEdid)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BYTE CheckSum = 0;
|
||||
for (const BYTE* pEdidStart = pEdid; pEdidStart < (pEdid + EDID_V1_BLOCK_SIZE); ++pEdidStart)
|
||||
{
|
||||
CheckSum += *pEdidStart;
|
||||
}
|
||||
|
||||
return CheckSum == 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Frame buffer map/unmap
|
||||
//
|
||||
|
||||
NTSTATUS
|
||||
MapFrameBuffer(
|
||||
_In_ PHYSICAL_ADDRESS PhysicalAddress,
|
||||
_In_ ULONG Length,
|
||||
_Outptr_result_bytebuffer_(Length) VOID** VirtualAddress)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
//
|
||||
// Check for parameters
|
||||
//
|
||||
if ((PhysicalAddress.QuadPart == (ULONGLONG)0) ||
|
||||
(Length == 0) ||
|
||||
(VirtualAddress == NULL))
|
||||
{
|
||||
BDD_LOG_ERROR3("One of PhysicalAddress.QuadPart (0x%I64x), Length (0x%I64x), VirtualAddress (0x%I64x) is NULL or 0",
|
||||
PhysicalAddress.QuadPart, Length, VirtualAddress);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*VirtualAddress = MmMapIoSpaceEx(PhysicalAddress,
|
||||
Length,
|
||||
PAGE_READWRITE | PAGE_WRITECOMBINE);
|
||||
if (*VirtualAddress == NULL)
|
||||
{
|
||||
// The underlying call to MmMapIoSpace failed. This may be because, MmWriteCombined
|
||||
// isn't supported, so try again with MmNonCached
|
||||
|
||||
*VirtualAddress = MmMapIoSpaceEx(PhysicalAddress,
|
||||
Length,
|
||||
PAGE_READWRITE | PAGE_NOCACHE);
|
||||
if (*VirtualAddress == NULL)
|
||||
{
|
||||
BDD_LOG_LOW_RESOURCE1("MmMapIoSpace returned a NULL buffer when trying to allocate 0x%I64x bytes", Length);
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
UnmapFrameBuffer(
|
||||
_In_reads_bytes_(Length) VOID* VirtualAddress,
|
||||
_In_ ULONG Length)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
|
||||
//
|
||||
// Check for parameters
|
||||
//
|
||||
if ((VirtualAddress == NULL) && (Length == 0))
|
||||
{
|
||||
// Allow this function to be called when there's no work to do, and treat as successful
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
else if ((VirtualAddress == NULL) || (Length == 0))
|
||||
{
|
||||
BDD_LOG_ERROR2("Only one of Length (0x%I64x), VirtualAddress (0x%I64x) is NULL or 0",
|
||||
Length, VirtualAddress);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
MmUnmapIoSpace(VirtualAddress,
|
||||
Length);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,346 +0,0 @@
|
||||
/******************************Module*Header*******************************\
|
||||
* Module Name: BltFuncs.cxx
|
||||
*
|
||||
* Basic Display Driver copying functionality
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2010 Microsoft Corporation
|
||||
\**************************************************************************/
|
||||
|
||||
#include "BDD.hxx"
|
||||
|
||||
// For the following macros, c must be a UCHAR.
|
||||
#define UPPER_6_BITS(c) (((c) & rMaskTable[6 - 1]) >> 2)
|
||||
#define UPPER_5_BITS(c) (((c) & rMaskTable[5 - 1]) >> 3)
|
||||
#define LOWER_6_BITS(c) (((BYTE)(c)) & lMaskTable[BITS_PER_BYTE - 6])
|
||||
#define LOWER_5_BITS(c) (((BYTE)(c)) & lMaskTable[BITS_PER_BYTE - 5])
|
||||
|
||||
|
||||
#define SHIFT_FOR_UPPER_5_IN_565 (6 + 5)
|
||||
#define SHIFT_FOR_MIDDLE_6_IN_565 (5)
|
||||
#define SHIFT_UPPER_5_IN_565_BACK ((BITS_PER_BYTE * 2) + (BITS_PER_BYTE - 5))
|
||||
#define SHIFT_MIDDLE_6_IN_565_BACK ((BITS_PER_BYTE * 1) + (BITS_PER_BYTE - 6))
|
||||
#define SHIFT_LOWER_5_IN_565_BACK ((BITS_PER_BYTE * 0) + (BITS_PER_BYTE - 5))
|
||||
|
||||
// For the following macros, pPixel must be a BYTE* pointing to the start of a 32 bit pixel
|
||||
#define CONVERT_32BPP_TO_16BPP(pPixel) ((UPPER_5_BITS(pPixel[2]) << SHIFT_FOR_UPPER_5_IN_565) | \
|
||||
(UPPER_6_BITS(pPixel[1]) << SHIFT_FOR_MIDDLE_6_IN_565) | \
|
||||
(UPPER_5_BITS(pPixel[0])))
|
||||
|
||||
// 8bpp is done with 6 levels per color channel since this gives true grays, even if it leaves 40 empty palette entries
|
||||
// The 6 levels per color is the reason for dividing below by 43 (43 * 6 == 258, closest multiple of 6 to 256)
|
||||
// It is also the reason for multiplying the red channel by 36 (== 6*6) and the green channel by 6, as this is the
|
||||
// equivalent to bit shifting in a 3:3:2 model. Changes to this must be reflected in vesasup.cxx with the Blues/Greens/Reds arrays
|
||||
#define CONVERT_32BPP_TO_8BPP(pPixel) (((pPixel[2] / 43) * 36) + \
|
||||
((pPixel[1] / 43) * 6) + \
|
||||
((pPixel[0] / 43)))
|
||||
|
||||
// 4bpp is done with strict grayscale since this has been found to be usable
|
||||
// 30% of the red value, 59% of the green value, and 11% of the blue value is the standard way to convert true color to grayscale
|
||||
#define CONVERT_32BPP_TO_4BPP(pPixel) ((BYTE)(((pPixel[2] * 30) + \
|
||||
(pPixel[1] * 59) + \
|
||||
(pPixel[0] * 11)) / (100 * 16)))
|
||||
|
||||
|
||||
// For the following macro, Pixel must be a WORD representing a 16 bit pixel
|
||||
#define CONVERT_16BPP_TO_32BPP(Pixel) (((ULONG)LOWER_5_BITS((Pixel) >> SHIFT_FOR_UPPER_5_IN_565) << SHIFT_UPPER_5_IN_565_BACK) | \
|
||||
((ULONG)LOWER_6_BITS((Pixel) >> SHIFT_FOR_MIDDLE_6_IN_565) << SHIFT_MIDDLE_6_IN_565_BACK) | \
|
||||
((ULONG)LOWER_5_BITS((Pixel)) << SHIFT_LOWER_5_IN_565_BACK))
|
||||
|
||||
#pragma code_seg(push)
|
||||
#pragma code_seg()
|
||||
// BEGIN: Non-Paged Code
|
||||
|
||||
// Bit is 1 from Idx to end of byte, with bit count starting at high order
|
||||
BYTE lMaskTable[BITS_PER_BYTE] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
|
||||
|
||||
// Bit is 1 from Idx to start of byte, with bit count starting at high order
|
||||
BYTE rMaskTable[BITS_PER_BYTE] = {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff};
|
||||
|
||||
// Bit of Idx is 1, with bit count starting at high order
|
||||
BYTE PixelMask[BITS_PER_BYTE] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
|
||||
|
||||
/****************************Internal*Routine******************************\
|
||||
* CopyBits32_32
|
||||
*
|
||||
*
|
||||
* Copies rectangles from one surface to another. Both surfaces must have
|
||||
* the same resolution.
|
||||
*
|
||||
* OffsetX, OffsetY - to add to the rectangle coordinates.
|
||||
*
|
||||
* Copied from %SDXROOT%\windows\Core\dxkernel\cdd\enable.cxx (CopySurfBits)
|
||||
*
|
||||
\**************************************************************************/
|
||||
|
||||
VOID CopyBits32_32(
|
||||
BLT_INFO* pDst,
|
||||
CONST BLT_INFO* pSrc,
|
||||
UINT NumRects,
|
||||
_In_reads_(NumRects) CONST RECT *pRects)
|
||||
{
|
||||
NT_ASSERT((pDst->BitsPerPel == 32) &&
|
||||
(pSrc->BitsPerPel == 32));
|
||||
NT_ASSERT((pDst->Rotation == D3DKMDT_VPPR_IDENTITY) &&
|
||||
(pSrc->Rotation == D3DKMDT_VPPR_IDENTITY));
|
||||
|
||||
for (UINT iRect = 0; iRect < NumRects; iRect++)
|
||||
{
|
||||
CONST RECT* pRect = &pRects[iRect];
|
||||
|
||||
NT_ASSERT(pRect->right >= pRect->left);
|
||||
NT_ASSERT(pRect->bottom >= pRect->top);
|
||||
|
||||
UINT NumPixels = pRect->right - pRect->left;
|
||||
UINT NumRows = pRect->bottom - pRect->top;
|
||||
UINT BytesToCopy = NumPixels * 4;
|
||||
BYTE* pStartDst = ((BYTE*)pDst->pBits +
|
||||
(pRect->top + pDst->Offset.y) * pDst->Pitch +
|
||||
(pRect->left + pDst->Offset.x) * 4);
|
||||
CONST BYTE* pStartSrc = ((BYTE*)pSrc->pBits +
|
||||
(pRect->top + pSrc->Offset.y) * pSrc->Pitch +
|
||||
(pRect->left + pSrc->Offset.x) * 4);
|
||||
|
||||
for (UINT i = 0; i < NumRows; ++i)
|
||||
{
|
||||
RtlCopyMemory(pStartDst, pStartSrc, BytesToCopy);
|
||||
pStartDst += pDst->Pitch;
|
||||
pStartSrc += pSrc->Pitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID GetPitches(_In_ CONST BLT_INFO* pBltInfo, _Out_ LONG* pPixelPitch, _Out_ LONG* pRowPitch)
|
||||
{
|
||||
switch (pBltInfo->Rotation)
|
||||
{
|
||||
case D3DKMDT_VPPR_IDENTITY:
|
||||
{
|
||||
*pPixelPitch = (pBltInfo->BitsPerPel / BITS_PER_BYTE);
|
||||
*pRowPitch = pBltInfo->Pitch;
|
||||
return;
|
||||
}
|
||||
case D3DKMDT_VPPR_ROTATE90:
|
||||
{
|
||||
*pPixelPitch = -((LONG)pBltInfo->Pitch);
|
||||
*pRowPitch = (pBltInfo->BitsPerPel / BITS_PER_BYTE);
|
||||
return;
|
||||
}
|
||||
case D3DKMDT_VPPR_ROTATE180:
|
||||
{
|
||||
*pPixelPitch = -((LONG)pBltInfo->BitsPerPel / BITS_PER_BYTE);
|
||||
*pRowPitch = -((LONG)pBltInfo->Pitch);
|
||||
return;
|
||||
}
|
||||
case D3DKMDT_VPPR_ROTATE270:
|
||||
{
|
||||
*pPixelPitch = pBltInfo->Pitch;
|
||||
*pRowPitch = -((LONG)pBltInfo->BitsPerPel / BITS_PER_BYTE);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
{
|
||||
BDD_LOG_ASSERTION1("Invalid rotation (0x%I64x) specified", pBltInfo->Rotation);
|
||||
*pPixelPitch = 0;
|
||||
*pRowPitch = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BYTE* GetRowStart(_In_ CONST BLT_INFO* pBltInfo, CONST RECT* pRect)
|
||||
{
|
||||
BYTE* pRet = NULL;
|
||||
LONG OffLeft = pRect->left + pBltInfo->Offset.x;
|
||||
LONG OffTop = pRect->top + pBltInfo->Offset.y;
|
||||
LONG BytesPerPixel = (pBltInfo->BitsPerPel / BITS_PER_BYTE);
|
||||
switch (pBltInfo->Rotation)
|
||||
{
|
||||
case D3DKMDT_VPPR_IDENTITY:
|
||||
{
|
||||
pRet = ((BYTE*)pBltInfo->pBits +
|
||||
OffTop * pBltInfo->Pitch +
|
||||
OffLeft * BytesPerPixel);
|
||||
break;
|
||||
}
|
||||
case D3DKMDT_VPPR_ROTATE90:
|
||||
{
|
||||
pRet = ((BYTE*)pBltInfo->pBits +
|
||||
(pBltInfo->Height - 1 - OffLeft) * pBltInfo->Pitch +
|
||||
OffTop * BytesPerPixel);
|
||||
break;
|
||||
}
|
||||
case D3DKMDT_VPPR_ROTATE180:
|
||||
{
|
||||
pRet = ((BYTE*)pBltInfo->pBits +
|
||||
(pBltInfo->Height - 1 - OffTop) * pBltInfo->Pitch +
|
||||
(pBltInfo->Width - 1 - OffLeft) * BytesPerPixel);
|
||||
break;
|
||||
}
|
||||
case D3DKMDT_VPPR_ROTATE270:
|
||||
{
|
||||
pRet = ((BYTE*)pBltInfo->pBits +
|
||||
OffLeft * pBltInfo->Pitch +
|
||||
(pBltInfo->Width - 1 - OffTop) * BytesPerPixel);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
BDD_LOG_ASSERTION1("Invalid rotation (0x%I64x) specified", pBltInfo->Rotation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/****************************Internal*Routine******************************\
|
||||
* CopyBitsGeneric
|
||||
*
|
||||
*
|
||||
* Blt function which can handle a rotated dst/src, offset rects in dst/src
|
||||
* and bpp combinations of:
|
||||
* dst | src
|
||||
* 32 | 32 // For identity rotation this is much faster in CopyBits32_32
|
||||
* 32 | 24
|
||||
* 32 | 16
|
||||
* 24 | 32
|
||||
* 16 | 32
|
||||
* 8 | 32
|
||||
* 24 | 24 // untested
|
||||
*
|
||||
\**************************************************************************/
|
||||
|
||||
VOID CopyBitsGeneric(
|
||||
BLT_INFO* pDst,
|
||||
CONST BLT_INFO* pSrc,
|
||||
UINT NumRects,
|
||||
_In_reads_(NumRects) CONST RECT *pRects)
|
||||
{
|
||||
LONG DstPixelPitch = 0;
|
||||
LONG DstRowPitch = 0;
|
||||
LONG SrcPixelPitch = 0;
|
||||
LONG SrcRowPitch = 0;
|
||||
|
||||
GetPitches(pDst, &DstPixelPitch, &DstRowPitch);
|
||||
GetPitches(pSrc, &SrcPixelPitch, &SrcRowPitch);
|
||||
|
||||
for (UINT iRect = 0; iRect < NumRects; iRect++)
|
||||
{
|
||||
CONST RECT* pRect = &pRects[iRect];
|
||||
|
||||
NT_ASSERT(pRect->right >= pRect->left);
|
||||
NT_ASSERT(pRect->bottom >= pRect->top);
|
||||
|
||||
UINT NumPixels = pRect->right - pRect->left;
|
||||
UINT NumRows = pRect->bottom - pRect->top;
|
||||
|
||||
BYTE* pDstRow = GetRowStart(pDst, pRect);
|
||||
CONST BYTE* pSrcRow = GetRowStart(pSrc, pRect);
|
||||
|
||||
for (UINT y=0; y < NumRows; y++)
|
||||
{
|
||||
BYTE* pDstPixel = pDstRow;
|
||||
CONST BYTE* pSrcPixel = pSrcRow;
|
||||
|
||||
for (UINT x=0; x < NumPixels; x++)
|
||||
{
|
||||
if ((pDst->BitsPerPel == 24) ||
|
||||
(pSrc->BitsPerPel == 24))
|
||||
{
|
||||
pDstPixel[0] = pSrcPixel[0];
|
||||
pDstPixel[1] = pSrcPixel[1];
|
||||
pDstPixel[2] = pSrcPixel[2];
|
||||
// pPixel[3] is the alpha channel and is ignored for whichever of Src/Dst is 32bpp
|
||||
}
|
||||
else if (pDst->BitsPerPel == 32)
|
||||
{
|
||||
if (pSrc->BitsPerPel == 32)
|
||||
{
|
||||
UINT32* pDstPixelAs32 = (UINT32*)pDstPixel;
|
||||
UINT32* pSrcPixelAs32 = (UINT32*)pSrcPixel;
|
||||
*pDstPixelAs32 = *pSrcPixelAs32;
|
||||
}
|
||||
else if (pSrc->BitsPerPel == 16)
|
||||
{
|
||||
UINT32* pDstPixelAs32 = (UINT32*)pDstPixel;
|
||||
UINT16* pSrcPixelAs16 = (UINT16*)pSrcPixel;
|
||||
|
||||
*pDstPixelAs32 = CONVERT_16BPP_TO_32BPP(*pSrcPixelAs16);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid pSrc->BitsPerPel on a pDst->BitsPerPel of 32
|
||||
NT_ASSERT(FALSE);
|
||||
}
|
||||
}
|
||||
else if (pDst->BitsPerPel == 16)
|
||||
{
|
||||
NT_ASSERT(pSrc->BitsPerPel == 32);
|
||||
|
||||
UINT16* pDstPixelAs16 = (UINT16*)pDstPixel;
|
||||
*pDstPixelAs16 = CONVERT_32BPP_TO_16BPP(pSrcPixel);
|
||||
}
|
||||
else if (pDst->BitsPerPel == 8)
|
||||
{
|
||||
NT_ASSERT(pSrc->BitsPerPel == 32);
|
||||
|
||||
*pDstPixel = CONVERT_32BPP_TO_8BPP(pSrcPixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid pDst->BitsPerPel
|
||||
NT_ASSERT(FALSE);
|
||||
}
|
||||
pDstPixel += DstPixelPitch;
|
||||
pSrcPixel += SrcPixelPitch;
|
||||
}
|
||||
|
||||
pDstRow += DstRowPitch;
|
||||
pSrcRow += SrcRowPitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************Internal*Routine******************************\
|
||||
* BltBits
|
||||
*
|
||||
*
|
||||
* Logic to decide which of the above functions to call based on Rotation/BPP
|
||||
*
|
||||
\**************************************************************************/
|
||||
VOID BltBits(
|
||||
BLT_INFO* pDst,
|
||||
CONST BLT_INFO* pSrc,
|
||||
UINT NumRects,
|
||||
_In_reads_(NumRects) CONST RECT *pRects)
|
||||
{
|
||||
// pSrc->pBits might be coming from user-mode. User-mode addresses when accessed by kernel need to be protected by a __try/__except.
|
||||
// This usage is redundant in the sample driver since it is already being used for MmProbeAndLockPages. However, it is very important
|
||||
// to have this in place and to make sure developers don't miss it, it is in these two locations.
|
||||
__try
|
||||
{
|
||||
if (pDst->BitsPerPel == 32 &&
|
||||
pSrc->BitsPerPel == 32 &&
|
||||
pDst->Rotation == D3DKMDT_VPPR_IDENTITY &&
|
||||
pSrc->Rotation == D3DKMDT_VPPR_IDENTITY)
|
||||
{
|
||||
// This is by far the most common copy function being called
|
||||
CopyBits32_32(pDst, pSrc, NumRects, pRects);
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyBitsGeneric(pDst, pSrc, NumRects, pRects);
|
||||
}
|
||||
}
|
||||
#pragma prefast(suppress: __WARNING_EXCEPTIONEXECUTEHANDLER, "try/except is only able to protect against user-mode errors and these are the only errors we try to catch here");
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
BDD_LOG_ERROR2("Either dst (0x%I64x) or src (0x%I64x) bits encountered exception during access.", pDst->pBits, pSrc->pBits);
|
||||
}
|
||||
}
|
||||
|
||||
// END: Non-Paged Code
|
||||
#pragma code_seg(pop)
|
||||
|
||||
-556
@@ -1,556 +0,0 @@
|
||||
/******************************Module*Header*******************************\
|
||||
* Module Name: blthw.cxx
|
||||
*
|
||||
* Sample display driver functions for a HW blt simulation. This file is
|
||||
* only provided to simulate how a real hardware-accelerated display-only
|
||||
* driver functions, and should not be used in a real driver.
|
||||
*
|
||||
* Copyright (c) 2011 Microsoft Corporation
|
||||
\**************************************************************************/
|
||||
|
||||
#include "BDD.hxx"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CONST DXGKRNL_INTERFACE* DxgkInterface;
|
||||
DXGKARGCB_NOTIFY_INTERRUPT_DATA NotifyInterrupt;
|
||||
} SYNC_NOTIFY_INTERRUPT;
|
||||
|
||||
KSYNCHRONIZE_ROUTINE SynchronizeVidSchNotifyInterrupt;
|
||||
|
||||
BOOLEAN SynchronizeVidSchNotifyInterrupt(_In_opt_ PVOID params)
|
||||
{
|
||||
// This routine is non-paged code called at the device interrupt level (DIRQL)
|
||||
// to notify VidSch and schedule a DPC. It is meant as a demonstration of handling
|
||||
// a real hardware interrupt, even though it is actually called from asynchronous
|
||||
// present worker threads in this sample.
|
||||
SYNC_NOTIFY_INTERRUPT* pParam = reinterpret_cast<SYNC_NOTIFY_INTERRUPT*>(params);
|
||||
|
||||
// The context is known to be non-NULL
|
||||
__analysis_assume(pParam != NULL);
|
||||
|
||||
// Update driver information related to fences
|
||||
switch(pParam->NotifyInterrupt.InterruptType)
|
||||
{
|
||||
case DXGK_INTERRUPT_DISPLAYONLY_VSYNC:
|
||||
case DXGK_INTERRUPT_DISPLAYONLY_PRESENT_PROGRESS:
|
||||
break;
|
||||
default:
|
||||
NT_ASSERT(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Callback OS to report about the interrupt
|
||||
pParam->DxgkInterface->DxgkCbNotifyInterrupt(pParam->DxgkInterface->DeviceHandle,&pParam->NotifyInterrupt);
|
||||
|
||||
// Now queue a DPC for this interrupt (to callback schedule at DCP level and let it do more work there)
|
||||
// DxgkCbQueueDpc can return FALSE if there is already a DPC queued
|
||||
// this is an acceptable condition
|
||||
pParam->DxgkInterface->DxgkCbQueueDpc(pParam->DxgkInterface->DeviceHandle);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#pragma code_seg("PAGE")
|
||||
|
||||
KSTART_ROUTINE HwContextWorkerThread;
|
||||
|
||||
struct DoPresentMemory
|
||||
{
|
||||
PVOID DstAddr;
|
||||
UINT DstStride;
|
||||
ULONG DstBitPerPixel;
|
||||
UINT SrcWidth;
|
||||
UINT SrcHeight;
|
||||
BYTE* SrcAddr;
|
||||
LONG SrcPitch;
|
||||
ULONG NumMoves; // in: Number of screen to screen moves
|
||||
D3DKMT_MOVE_RECT* Moves; // in: Point to the list of moves
|
||||
ULONG NumDirtyRects; // in: Number of direct rects
|
||||
RECT* DirtyRect; // in: Point to the list of dirty rects
|
||||
D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation;
|
||||
BOOLEAN SynchExecution;
|
||||
D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceID;
|
||||
HANDLE hAdapter;
|
||||
PMDL Mdl;
|
||||
BDD_HWBLT* DisplaySource;
|
||||
};
|
||||
|
||||
void
|
||||
HwExecutePresentDisplayOnly(
|
||||
HANDLE Context);
|
||||
|
||||
NTSTATUS
|
||||
StartHwBltPresentWorkerThread(
|
||||
_In_ PKSTART_ROUTINE StartRoutine,
|
||||
_In_ _When_(return==0, __drv_aliasesMem) PVOID StartContext)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine creates the worker thread to execute a single present
|
||||
command. Creating a new thread on every asynchronous present is not
|
||||
efficient, but this file is only meant as a simulation, not an example
|
||||
of implementation.
|
||||
|
||||
Arguments:
|
||||
|
||||
StartRoutine - start routine
|
||||
StartContext - start context
|
||||
|
||||
Return Value:
|
||||
|
||||
Status
|
||||
|
||||
--*/
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
InitializeObjectAttributes(&ObjectAttributes, NULL, OBJ_KERNEL_HANDLE, NULL, NULL);
|
||||
HANDLE hWorkerThread = NULL;
|
||||
|
||||
// copy data from the context which is need here, as it will be deleted in separate thread
|
||||
DoPresentMemory* ctx = reinterpret_cast<DoPresentMemory*>(StartContext);
|
||||
BDD_HWBLT* displaySource = ctx->DisplaySource;
|
||||
|
||||
NTSTATUS Status = PsCreateSystemThread(
|
||||
&hWorkerThread,
|
||||
THREAD_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
NULL,
|
||||
NULL,
|
||||
StartRoutine,
|
||||
StartContext);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
// wait for thread to start - infinite wait -
|
||||
// need to make sure the tread is running before OS stars submitting the work items to it
|
||||
KeWaitForSingleObject(&displaySource->m_hThreadStartupEvent, Executive, KernelMode, FALSE, NULL);
|
||||
|
||||
// Handle is passed to the parent object which must close it
|
||||
displaySource->SetPresentWorkerThreadInfo(hWorkerThread);
|
||||
|
||||
// Resume context thread, this is done by setting the event the thread is waiting on
|
||||
KeSetEvent(&displaySource->m_hThreadSuspendEvent, 0, FALSE);
|
||||
|
||||
return STATUS_PENDING;
|
||||
}
|
||||
|
||||
BDD_HWBLT::BDD_HWBLT():m_DevExt (NULL),
|
||||
m_SynchExecution(TRUE),
|
||||
m_hPresentWorkerThread(NULL),
|
||||
m_pPresentWorkerThread(NULL)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
KeInitializeEvent(&m_hThreadStartupEvent, NotificationEvent, FALSE);
|
||||
KeInitializeEvent(&m_hThreadSuspendEvent, SynchronizationEvent, FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
BDD_HWBLT::~BDD_HWBLT()
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine waits on present worker thread to exit before
|
||||
destroying the object
|
||||
|
||||
Arguments:
|
||||
|
||||
None
|
||||
|
||||
Return Value:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
// make sure the worker thread has exited
|
||||
SetPresentWorkerThreadInfo(NULL);
|
||||
}
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:26135) // The function doesn't lock anything
|
||||
|
||||
void
|
||||
BDD_HWBLT::SetPresentWorkerThreadInfo(
|
||||
HANDLE hWorkerThread)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
The method is updating present worker information
|
||||
It is called in following cases:
|
||||
- In ExecutePresent to update worker thread information
|
||||
- In Dtor to wait on worker thread to exit
|
||||
|
||||
Arguments:
|
||||
|
||||
hWorkerThread - handle of the present worker thread
|
||||
|
||||
Return Value:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
if (m_pPresentWorkerThread)
|
||||
{
|
||||
// Wait for thread to exit
|
||||
KeWaitForSingleObject(m_pPresentWorkerThread, Executive, KernelMode,
|
||||
FALSE, NULL);
|
||||
// Dereference thread object
|
||||
ObDereferenceObject(m_pPresentWorkerThread);
|
||||
m_pPresentWorkerThread = NULL;
|
||||
|
||||
NT_ASSERT(m_hPresentWorkerThread);
|
||||
ZwClose(m_hPresentWorkerThread);
|
||||
m_hPresentWorkerThread = NULL;
|
||||
}
|
||||
|
||||
if (hWorkerThread)
|
||||
{
|
||||
// Make sure that thread's handle would be valid even if the thread exited
|
||||
ObReferenceObjectByHandle(hWorkerThread, THREAD_ALL_ACCESS, NULL,
|
||||
KernelMode, &m_pPresentWorkerThread, NULL);
|
||||
NT_ASSERT(m_pPresentWorkerThread);
|
||||
m_hPresentWorkerThread = hWorkerThread;
|
||||
}
|
||||
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
NTSTATUS
|
||||
BDD_HWBLT::ExecutePresentDisplayOnly(
|
||||
_In_ BYTE* DstAddr,
|
||||
_In_ UINT DstBitPerPixel,
|
||||
_In_ BYTE* SrcAddr,
|
||||
_In_ UINT SrcBytesPerPixel,
|
||||
_In_ LONG SrcPitch,
|
||||
_In_ ULONG NumMoves,
|
||||
_In_ D3DKMT_MOVE_RECT* Moves,
|
||||
_In_ ULONG NumDirtyRects,
|
||||
_In_ RECT* DirtyRect,
|
||||
_In_ D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
The method creates present worker thread and provides context
|
||||
for it filled with present commands
|
||||
|
||||
Arguments:
|
||||
|
||||
DstAddr - address of destination surface
|
||||
DstBitPerPixel - color depth of destination surface
|
||||
SrcAddr - address of source surface
|
||||
SrcBytesPerPixel - bytes per pixel of source surface
|
||||
SrcPitch - source surface pitch (bytes in a row)
|
||||
NumMoves - number of moves to be copied
|
||||
Moves - moves' data
|
||||
NumDirtyRects - number of rectangles to be copied
|
||||
DirtyRect - rectangles' data
|
||||
Rotation - roatation to be performed when executing copy
|
||||
CallBack - callback for present worker thread to report execution status
|
||||
|
||||
Return Value:
|
||||
|
||||
Status
|
||||
|
||||
--*/
|
||||
{
|
||||
|
||||
PAGED_CODE();
|
||||
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
SIZE_T sizeMoves = NumMoves*sizeof(D3DKMT_MOVE_RECT);
|
||||
SIZE_T sizeRects = NumDirtyRects*sizeof(RECT);
|
||||
SIZE_T size = sizeof(DoPresentMemory) + sizeMoves + sizeRects;
|
||||
|
||||
DoPresentMemory* ctx = reinterpret_cast<DoPresentMemory*>
|
||||
(new (PagedPool) BYTE[size]);
|
||||
|
||||
if (!ctx)
|
||||
{
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
RtlZeroMemory(ctx,size);
|
||||
|
||||
const CURRENT_BDD_MODE* pModeCur = m_DevExt->GetCurrentMode(m_SourceId);
|
||||
|
||||
ctx->DstAddr = DstAddr;
|
||||
ctx->DstBitPerPixel = DstBitPerPixel;
|
||||
ctx->DstStride = pModeCur->DispInfo.Pitch;
|
||||
ctx->SrcWidth = pModeCur->SrcModeWidth;
|
||||
ctx->SrcHeight = pModeCur->SrcModeHeight;
|
||||
ctx->SrcAddr = NULL;
|
||||
ctx->SrcPitch = SrcPitch;
|
||||
ctx->Rotation = Rotation;
|
||||
ctx->NumMoves = NumMoves;
|
||||
ctx->Moves = Moves;
|
||||
ctx->NumDirtyRects = NumDirtyRects;
|
||||
ctx->DirtyRect = DirtyRect;
|
||||
ctx->SourceID = m_SourceId;
|
||||
ctx->hAdapter = m_DevExt;
|
||||
ctx->Mdl = NULL;
|
||||
ctx->DisplaySource = this;
|
||||
|
||||
// Alternate between synch and asynch execution, for demonstrating
|
||||
// that a real hardware implementation can do either
|
||||
m_SynchExecution = !m_SynchExecution;
|
||||
|
||||
ctx->SynchExecution = m_SynchExecution;
|
||||
|
||||
{
|
||||
// Map Source into kernel space, as Blt will be executed by system worker thread
|
||||
UINT sizeToMap = SrcBytesPerPixel*pModeCur->SrcModeWidth*pModeCur->SrcModeHeight;
|
||||
|
||||
PMDL mdl = IoAllocateMdl((PVOID)SrcAddr, sizeToMap, FALSE, FALSE, NULL);
|
||||
if(!mdl)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
KPROCESSOR_MODE AccessMode = static_cast<KPROCESSOR_MODE>(( SrcAddr <=
|
||||
(BYTE* const) MM_USER_PROBE_ADDRESS)?UserMode:KernelMode);
|
||||
__try
|
||||
{
|
||||
// Probe and lock the pages of this buffer in physical memory.
|
||||
// We need only IoReadAccess.
|
||||
MmProbeAndLockPages(mdl, AccessMode, IoReadAccess);
|
||||
}
|
||||
#pragma prefast(suppress: __WARNING_EXCEPTIONEXECUTEHANDLER, "try/except is only able to protect against user-mode errors and these are the only errors we try to catch here");
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = GetExceptionCode();
|
||||
IoFreeMdl(mdl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Map the physical pages described by the MDL into system space.
|
||||
// Note: double mapping the buffer this way causes lot of system
|
||||
// overhead for large size buffers.
|
||||
ctx->SrcAddr = reinterpret_cast<BYTE*>
|
||||
(MmGetSystemAddressForMdlSafe(mdl, NormalPagePriority ));
|
||||
|
||||
if(!ctx->SrcAddr) {
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
MmUnlockPages(mdl);
|
||||
IoFreeMdl(mdl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Save Mdl to unmap and unlock the pages in worker thread
|
||||
ctx->Mdl = mdl;
|
||||
}
|
||||
|
||||
BYTE* rects = reinterpret_cast<BYTE*>(ctx+1);
|
||||
|
||||
// copy moves and update pointer
|
||||
if (Moves)
|
||||
{
|
||||
memcpy(rects,Moves,sizeMoves);
|
||||
ctx->Moves = reinterpret_cast<D3DKMT_MOVE_RECT*>(rects);
|
||||
rects += sizeMoves;
|
||||
}
|
||||
|
||||
// copy dirty rects and update pointer
|
||||
if (DirtyRect)
|
||||
{
|
||||
memcpy(rects,DirtyRect,sizeRects);
|
||||
ctx->DirtyRect = reinterpret_cast<RECT*>(rects);
|
||||
}
|
||||
|
||||
|
||||
if (m_SynchExecution)
|
||||
{
|
||||
HwExecutePresentDisplayOnly((PVOID)ctx);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a worker thread to perform the present asynchronously
|
||||
// Ctx will be deleted in worker thread (on exit)
|
||||
return StartHwBltPresentWorkerThread(HwContextWorkerThread,(PVOID)ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ReportPresentProgress(
|
||||
_In_ HANDLE Adapter,
|
||||
_In_ D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
|
||||
_In_ BOOLEAN CompletedOrFailed)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
This routine runs a fake interrupt routine in order to tell the OS about the present progress.
|
||||
|
||||
Arguments:
|
||||
|
||||
Adapter - Handle to the adapter (Device Extension)
|
||||
VidPnSourceId - Video present source id for the callback
|
||||
CompletedOrFailed - Present progress status for the source
|
||||
|
||||
Return Value:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
BASIC_DISPLAY_DRIVER* pDevExt =
|
||||
reinterpret_cast<BASIC_DISPLAY_DRIVER*>(Adapter);
|
||||
|
||||
SYNC_NOTIFY_INTERRUPT SyncNotifyInterrupt = {};
|
||||
SyncNotifyInterrupt.DxgkInterface = pDevExt->GetDxgkInterface();
|
||||
SyncNotifyInterrupt.NotifyInterrupt.InterruptType = DXGK_INTERRUPT_DISPLAYONLY_PRESENT_PROGRESS;
|
||||
SyncNotifyInterrupt.NotifyInterrupt.DisplayOnlyPresentProgress.VidPnSourceId = VidPnSourceId;
|
||||
|
||||
SyncNotifyInterrupt.NotifyInterrupt.DisplayOnlyPresentProgress.ProgressId =
|
||||
(CompletedOrFailed)?DXGK_PRESENT_DISPLAYONLY_PROGRESS_ID_COMPLETE:
|
||||
DXGK_PRESENT_DISPLAYONLY_PROGRESS_ID_FAILED;
|
||||
|
||||
// Execute the SynchronizeVidSchNotifyInterrupt function at the interrupt
|
||||
// IRQL in order to fake a real present progress interrupt
|
||||
BOOLEAN bRet = FALSE;
|
||||
NT_VERIFY(NT_SUCCESS(pDevExt->GetDxgkInterface()->DxgkCbSynchronizeExecution(
|
||||
pDevExt->GetDxgkInterface()->DeviceHandle,
|
||||
(PKSYNCHRONIZE_ROUTINE)SynchronizeVidSchNotifyInterrupt,
|
||||
(PVOID)&SyncNotifyInterrupt,0,&bRet)));
|
||||
NT_ASSERT(bRet);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HwContextWorkerThread(
|
||||
HANDLE Context)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
DoPresentMemory* ctx = reinterpret_cast<DoPresentMemory*>(Context);
|
||||
BDD_HWBLT* displaySource = ctx->DisplaySource;
|
||||
|
||||
// Signal event to indicate that the tread has started
|
||||
KeSetEvent(&displaySource->m_hThreadStartupEvent, 0, FALSE);
|
||||
|
||||
// Suspend context thread, do this by waiting on the suspend event
|
||||
KeWaitForSingleObject(&displaySource->m_hThreadSuspendEvent, Executive, KernelMode, FALSE, NULL);
|
||||
|
||||
HwExecutePresentDisplayOnly(Context);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HwExecutePresentDisplayOnly(
|
||||
HANDLE Context)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
The routine executes present's commands and report progress to the OS
|
||||
|
||||
Arguments:
|
||||
|
||||
Context - Context with present's command
|
||||
|
||||
Return Value:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
DoPresentMemory* ctx = reinterpret_cast<DoPresentMemory*>(Context);
|
||||
|
||||
// Set up destination blt info
|
||||
BLT_INFO DstBltInfo;
|
||||
DstBltInfo.pBits = ctx->DstAddr;
|
||||
DstBltInfo.Pitch = ctx->DstStride;
|
||||
DstBltInfo.BitsPerPel = ctx->DstBitPerPixel;
|
||||
DstBltInfo.Offset.x = 0;
|
||||
DstBltInfo.Offset.y = 0;
|
||||
DstBltInfo.Rotation = ctx->Rotation;
|
||||
DstBltInfo.Width = ctx->SrcWidth;
|
||||
DstBltInfo.Height = ctx->SrcHeight;
|
||||
|
||||
// Set up source blt info
|
||||
BLT_INFO SrcBltInfo;
|
||||
SrcBltInfo.pBits = ctx->SrcAddr;
|
||||
SrcBltInfo.Pitch = ctx->SrcPitch;
|
||||
SrcBltInfo.BitsPerPel = 32;
|
||||
SrcBltInfo.Offset.x = 0;
|
||||
SrcBltInfo.Offset.y = 0;
|
||||
SrcBltInfo.Rotation = D3DKMDT_VPPR_IDENTITY;
|
||||
if (ctx->Rotation == D3DKMDT_VPPR_ROTATE90 ||
|
||||
ctx->Rotation == D3DKMDT_VPPR_ROTATE270)
|
||||
{
|
||||
SrcBltInfo.Width = DstBltInfo.Height;
|
||||
SrcBltInfo.Height = DstBltInfo.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
SrcBltInfo.Width = DstBltInfo.Width;
|
||||
SrcBltInfo.Height = DstBltInfo.Height;
|
||||
}
|
||||
|
||||
|
||||
// Copy all the scroll rects from source image to video frame buffer.
|
||||
for (UINT i = 0; i < ctx->NumMoves; i++)
|
||||
{
|
||||
BltBits(&DstBltInfo,
|
||||
&SrcBltInfo,
|
||||
1, // NumRects
|
||||
&ctx->Moves[i].DestRect);
|
||||
}
|
||||
|
||||
// Copy all the dirty rects from source image to video frame buffer.
|
||||
for (UINT i = 0; i < ctx->NumDirtyRects; i++)
|
||||
{
|
||||
|
||||
BltBits(&DstBltInfo,
|
||||
&SrcBltInfo,
|
||||
1, // NumRects
|
||||
&ctx->DirtyRect[i]);
|
||||
}
|
||||
|
||||
// Unmap unmap and unlock the pages.
|
||||
if (ctx->Mdl)
|
||||
{
|
||||
MmUnlockPages(ctx->Mdl);
|
||||
IoFreeMdl(ctx->Mdl);
|
||||
}
|
||||
|
||||
if(ctx->SynchExecution)
|
||||
{
|
||||
// This code simulates Blt executed synchronously
|
||||
// nothing should be done here, just exit
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TRUE == completed
|
||||
// This code is emulates interrupt which HW should generate
|
||||
ReportPresentProgress(ctx->hAdapter,ctx->SourceID,TRUE);
|
||||
}
|
||||
|
||||
delete [] reinterpret_cast<BYTE*>(ctx);
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/******************************Module*Header*******************************\
|
||||
* Module Name: bdd.h
|
||||
*
|
||||
* Basic Display Driver memory allocation, deletion, and tracking
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2010 Microsoft Corporation
|
||||
\**************************************************************************/
|
||||
|
||||
#include "BDD.hxx"
|
||||
|
||||
#pragma code_seg("PAGE")
|
||||
|
||||
//
|
||||
// New and delete operators
|
||||
//
|
||||
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
|
||||
__drv_reportError("Must succeed pool allocations are forbidden. "
|
||||
"Allocation failures cause a system crash"))
|
||||
void* __cdecl operator new(size_t Size, POOL_TYPE PoolType)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
Size = (Size != 0) ? Size : 1;
|
||||
|
||||
void* pObject = ExAllocatePool2(PoolType, Size, BDDTAG);
|
||||
|
||||
#if DBG
|
||||
if (pObject != NULL)
|
||||
{
|
||||
RtlFillMemory(pObject, Size, 0xCD);
|
||||
}
|
||||
#endif // DBG
|
||||
|
||||
return pObject;
|
||||
}
|
||||
|
||||
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
|
||||
__drv_reportError("Must succeed pool allocations are forbidden. "
|
||||
"Allocation failures cause a system crash"))
|
||||
void* __cdecl operator new[](size_t Size, POOL_TYPE PoolType)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
Size = (Size != 0) ? Size : 1;
|
||||
|
||||
void* pObject = ExAllocatePool2(PoolType, Size, BDDTAG);
|
||||
|
||||
#if DBG
|
||||
if (pObject != NULL)
|
||||
{
|
||||
RtlFillMemory(pObject, Size, 0xCD);
|
||||
}
|
||||
#endif // DBG
|
||||
|
||||
return pObject;
|
||||
}
|
||||
|
||||
void __cdecl operator delete(void* pObject)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
if (pObject != NULL)
|
||||
{
|
||||
ExFreePool(pObject);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// size_t version is needed for VS2015(C++ 14).
|
||||
//
|
||||
void __cdecl operator delete(void* pObject, size_t s)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
UNREFERENCED_PARAMETER( s );
|
||||
|
||||
::operator delete( pObject );
|
||||
}
|
||||
|
||||
void __cdecl operator delete[](void* pObject)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
if (pObject != NULL)
|
||||
{
|
||||
ExFreePool(pObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2011 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
SampleDisplay.rc
|
||||
|
||||
Abstract:
|
||||
|
||||
This modules contains the version information for the Sample Display Driver
|
||||
|
||||
Environment:
|
||||
|
||||
Kernel mode only
|
||||
|
||||
--*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <ntverp.h>
|
||||
|
||||
#define VER_FILETYPE VFT_DRV
|
||||
#define VER_FILESUBTYPE VFT2_DRV_DISPLAY
|
||||
#define VER_FILEDESCRIPTION_STR "Microsoft Sample Display Driver"
|
||||
#define VER_INTERNALNAME_STR "SampleDisplay.sys"
|
||||
#define VER_ORIGINALFILENAME_STR "SampleDisplay.sys"
|
||||
|
||||
#define VER_LANGNEUTRAL
|
||||
#include "common.ver"
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Virtual Display
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,186 +1,101 @@
|
||||
# THIS IS A DEVELOPMENT BRANCH. THIS BRANCH MAY BE UNSTABLE AND CAUSE ISSUES. WE ARE NOT LIABLE FOR ANY ISSUES IF YOU CHOOSE TO ATTEMPT TO BUILD THIS BRANCH
|
||||
# 🛠️ Virtual Display Driver Development Team
|
||||
|
||||
# Virtual Display Driver
|
||||
based on Microsoft Indirect Display Driver Sample. This creates a virtual display in Windows that acts and functions just like a real one. It's useful for streaming, virtual reality applications, recording, headless servers, etc. The benefit over a physical display is the ability to adjust resolutions and refresh rates beyond the physical displays capabilities. For example, this would enable the ability to stream a game from your home PC using game streaming software at 240hz at 8K while owning a 60hz 1080p monitor (unrealistic, but explains the abilities well). For servers without displays, this enabled remote desktop and screen streaming to other systems as if there were a display installed.
|
||||
| 👤 Developer | 🏷️ Role | 💖 Support Us |
|
||||
| --------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| **[MikeTheTech](https://github.com/itsmikethetech)** | Project Manager, Programmer | [Patreon](https://www.patreon.com/mikethetech) :gem: / [GitHub Sponsors](https://github.com/sponsors/itsmikethetech/) 💖 |
|
||||
| **[Bud3699](https://github.com/bud3699)** | Lead Programmer | [Buy Me a Beer](https://buymeacoffee.com/bud3699) :beer: |
|
||||
| **[Jocke](https://github.com/zjoasan)** | Programmer, Concept Design | [GitHub Sponsors ](https://github.com/sponsors/zjoasan) 💖 |
|
||||
|
||||
Supports emulating resolutions from **640 x 480** to **7680 x 4320 (8K)**, and refresh rates including **60hz, 75hz, 90hz, 120hz, 144hz, 165hz, 240hz, 480hz,** and **500hz.**
|
||||
:bulb: *We appreciate your support—every contribution helps us keep building amazing experiences!*
|
||||
|
||||
This project uses the official Windows Indirect Display Driver combined with the IddCx class extension driver.
|
||||
# <img src="https://github.com/user-attachments/assets/22ff37ba-a8ea-4b65-b7b2-e7fcb09d858b" height="32" width="32"></img> Virtual Display Driver
|
||||
This project creates a _virtual monitor_ in Windows that functions just like a physical display. It is particularly useful for applications such as **streaming, virtual reality, screen recording,** and **headless servers—systems** that operate without a physical display attached.
|
||||
|
||||
## Download
|
||||
Unlike traditional monitors, this virtual display supports custom resolutions and refresh rates beyond hardware limitations—offering greater flexibility for advanced setups. You can also use custom EDIDs to simulate or emulate existing hardware displays.
|
||||
|
||||
- [Windows 10 and 11 (no HDR)](https://github.com/itsmikethetech/Virtual-Display-Driver/releases/tag/23.10.20.2)
|
||||
- [Windows 11 22H2+ (HDR)](https://github.com/itsmikethetech/Virtual-Display-Driver/releases/tag/23.12.2HDR)
|
||||
|
||||
## Installation
|
||||
## ⬇️ Download Latest Version
|
||||
|
||||
1. Download the latest version from the releases page, and extract the contents to a folder.
|
||||
2. Copy `option.txt` to `C:\IddSampleDriver\option.txt` before installing the driver **(important!)**.
|
||||
3. Right click and run the *.bat file **as an Administrator** to add the driver certificate as a trusted root certificate.
|
||||
4. Don't install the inf. Open device manager, click on any device, then click on the "Action" menu and click "Add Legacy Hardware".
|
||||
5. Select "Add hardware from a list (Advanced)" and then select Display adapters
|
||||
6. Click "Have Disk..." and click the "Browse..." button. Navigate to the extracted files and select the inf file.
|
||||
7. You are done! Go to display settings to customize the resolution of the additional displays. These displays show up in Sunshine, your Oculus or VR settings, and should be able to be streamed from.
|
||||
8. You can enable/disable the display adapter to toggle the monitors.
|
||||
- [Driver Installer (Windows 10/11)](https://github.com/VirtualDisplay/Virtual-Display-Driver/releases) - Check the [Releases](https://github.com/VirtualDisplay/Virtual-Display-Driver/releases) page for the latest version and release notes.
|
||||
|
||||
Ps. Make sure that options.txt is accesible for the system at `C:\IddSampleDriver\option.txt` or the installation will fail.
|
||||
> [!IMPORTANT]
|
||||
> Before using the Virtual Display Driver, ensure the following dependencies are installed:
|
||||
> - **Microsoft Visual C++ Redistributable**
|
||||
> If you encounter the error `vcruntime140.dll not found`, download and install the latest version from the [Microsoft Visual C++ Redistributable page](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170).
|
||||
|
||||
## Uninstalling
|
||||
## 🖥️ EDID Database
|
||||
- [EDID Database by Bud3699](https://edid.mikethetech.com/)
|
||||
|
||||
1. Open device manager
|
||||
2. Locate Display Adapters
|
||||
3. Right click on IddSampleDriver, choose "Uninstall device"
|
||||
4. There is a new popup window, in there click Attempt to remove driver for this device.
|
||||
You can use this database to load custom edid's into the driver! Or just general edid usage :)
|
||||
|
||||
Next instructions are for those cases where the device is removed from the system, but driver stil remains. This happens when there is a connection to the device while trying to remove the drivers. To
|
||||
remedy this, there is a a few tricks built into windows. So here goes:
|
||||
## 🛠️ Installation
|
||||
|
||||
5. Open up a powershell terminal and input this:
|
||||
6. ```pnputil /enum-drivers```
|
||||
6. Locate iddsampledriver.inf, there might be multiple pages of text. Make a note of the "published name", it's often unique for your system, but might look like "oem139.inf"
|
||||
7. ```pnputil /delete-driver oem139.inf```
|
||||
- Step 1: Download the Installer
|
||||
- You can download the installer directly from the [Releases](https://github.com/VirtualDisplay/Virtual-Display-Driver/releases) page.
|
||||
|
||||
## HDR Support Now Available for Windows 11 22H2+
|
||||
- Step 2: Run the Installer
|
||||
- Launch the installer.
|
||||
- Follow the on-screen instructions to complete the installation.
|
||||
|
||||
### Resolutions:
|
||||
- Step 3: Verify the Installation (Optional)
|
||||
- Check if the Virtual Display Driver is correctly installed by running the following:
|
||||
- **Device Manager:** Check "Device Manager" under "Display Adapters."
|
||||
- **Settings:** Check display settings under system settings and see if the virtual displays show.
|
||||
|
||||
640 x 480
|
||||
800 x 600
|
||||
1024 x 768
|
||||
1152 x 864
|
||||
1280 x 720
|
||||
1280 x 768
|
||||
1280 x 800
|
||||
1280 x 960
|
||||
1280 x 1024
|
||||
1360 x 768
|
||||
1366 x 768
|
||||
1440 x 900
|
||||
1400 x 1050
|
||||
1440 x 1440
|
||||
1600 x 900
|
||||
1600 x 1024
|
||||
1680 x 1050
|
||||
1920 x 1080
|
||||
1920 x 1200
|
||||
2560 x 1440
|
||||
2560 x 1600
|
||||
2732 x 2048
|
||||
2880 x 1620
|
||||
2880 x 1800
|
||||
3008 x 1692
|
||||
3840 x 2160
|
||||
3840 x 2400
|
||||
4096 x 2304
|
||||
5120 x 2880
|
||||
6016 x 3384
|
||||
7680 x 4320
|
||||
Manual installation can be found in the wiki
|
||||
|
||||
### Just Added!
|
||||
## 🤔 Comparison with other IDDs
|
||||
|
||||
2732 x 2048
|
||||
2560 x 1080
|
||||
2880 x 1200
|
||||
3440 x 1440
|
||||
3840 x 1600
|
||||
4320 x 1800
|
||||
5120 x 2160
|
||||
5760 x 2400
|
||||
6880 x 2880
|
||||
7680 x 3200
|
||||
8640 x 3600
|
||||
10240 x 432
|
||||
2880 x 900
|
||||
3840 x 1080
|
||||
3840 x 1200
|
||||
4320 x 1200
|
||||
5120 x 1440
|
||||
5120 x 1600
|
||||
5760 x 1600
|
||||
5760 x 1800
|
||||
6400 x 1800
|
||||
6480 x 1800
|
||||
7680 x 2160
|
||||
7680 x 2400
|
||||
8640 x 2400
|
||||
2388 x 1668
|
||||
2400 x 1080
|
||||
3456 x 2234
|
||||
3456 x 2234
|
||||
The table below shows a comparison with other popular Indirect Display Driver
|
||||
projects.
|
||||
|
||||
### Refresh Rates:
|
||||

|
||||
|
||||
30Hz
|
||||
60Hz
|
||||
75Hz
|
||||
90Hz (Great for VR!)
|
||||
120Hz
|
||||
144Hz
|
||||
165Hz
|
||||
240Hz
|
||||
480Hz
|
||||
500Hz
|
||||
¹ ARM64 Support in Windows 11 24H2 or later may require test signing be enabled.
|
||||
|
||||
### Videos
|
||||
HDR Support Now Available for Windows 11 23H2+
|
||||
|
||||
[](https://youtu.be/nNWpbRUPkn4 "How to install a virtual display")
|
||||
## ▶️ Videos and Tutorials
|
||||
|
||||
[Previous Video: How to install a virtual display](https://youtu.be/byfBWDnToYk "How to install a virtual display")
|
||||
### Installation Video
|
||||
|
||||
### Screenshots:
|
||||
[](https://youtu.be/Oz_cfbfUx0E)
|
||||
|
||||

|
||||
## More Videos and Resources
|
||||
- 24.12.24 (Stable): MikeTheTech: [How to install the New Virtual Display Driver](https://youtu.be/Oz_cfbfUx0E)
|
||||
- 24.12.24 (Stable): MikeTheTech: [How to manually install the New Virtual Display Driver](https://youtu.be/sM9rNJWssAI)
|
||||
- 24.12.24 (Stable): Bud3699: [How to configure the VDD using the new Companion App](https://youtu.be/p_gfjE_cwjk)
|
||||
- 24.10.27 (Beta): [MikeTheTech: How to install a virtual display](https://youtu.be/byfBWDnToYk "How to install a virtual display")
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||
## 🤝 Sponsors
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://github.com/user-attachments/assets/ca93d971-67dc-41dd-b945-ab4f372ea72a" /></td>
|
||||
<td>Free code signing on Windows provided by <a href="https://signpath.io">SignPath.io</a>, certificate by <a href="https://signpath.org">SignPath Foundation</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Background reading ##
|
||||
## Developers
|
||||
|
||||
Start at the [Indirect Display Driver Model Overview](https://msdn.microsoft.com/en-us/library/windows/hardware/mt761968(v=vs.85).aspx) on MSDN.
|
||||
|
||||
### Code structure ###
|
||||
|
||||
The sample driver code is very simplistic and does nothing more than enumerate a single monitor when its device enters the D0/started power state. The IDD runs in Session 0 without any components running in the user session, so any driver instability will not affect the stability of the system as a whole. The IDD is a user-mode only model with no support for kernel-mode components. As such, the driver is able to use any DirectX APIs in order to process the desktop image. In fact, the IddCx provides the desktop image to encode in a DirectX surface.
|
||||
|
||||
* `Direct3DDevice` class
|
||||
* Contains logic for enumerating the correct render GPU from DXGI and creating a D3D device.
|
||||
* Manages the lifetime of a DXGI factory and a D3D device created for the render GPU the system is using to render frames for your indirect display device's swap-chain.
|
||||
* `SwapChainProcessor` class
|
||||
* Processes frames for a swap-chain assigned to the monitor object on a dedicated thread.
|
||||
* The sample code does nothing with the frames, but demonstrates a correct processing loop with error handling and notifying the OS of frame completion.
|
||||
* `IndirectDeviceContext` class
|
||||
* Processes device callbacks from IddCx.
|
||||
* Manages the creation and arrival of the sample monitor.
|
||||
* Handles swap-chain arrival and departure by creating a `Direct3DDevice` and handing it off to a `SwapChainProcessor`.
|
||||
|
||||
## License
|
||||
|
||||
MIT and CC0 or Public Domain (for changes I made, please consult Microsoft for their license), choose the least restrictive option.
|
||||
|
||||
## Disclaimer:
|
||||
|
||||
This software is provided "AS IS" with NO IMPLICIT OR EXPLICIT warranty. It's worth noting that while this software functioned without issues on my system, there is no guarantee that it will not impact your computer. It operates in User Mode, which reduces the likelihood of causing system instability, such as the Blue Screen of Death. However, exercise caution when using this software.
|
||||
- Shoutout to **[MikeTheTech](https://github.com/itsmikethetech)** Project Manager, Owner, and Programmer!
|
||||
- Shoutout to **[Bud](https://github.com/bud3699)** Lead Programmer and author of a ton of features, the companion & installer work.
|
||||
- Shoutout to **[zjoasan](https://github.com/zjoasan)** Programmer. For scripts, EDID integration, and parts of installer.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Shoutout to **Roshkins** for the original repo:
|
||||
https://github.com/roshkins/IddSampleDriver
|
||||
|
||||
Shoutout to **Baloukj** for the 8-bit / 10-bit support. (Also, first to push the new Microsoft Driver public!)
|
||||
https://github.com/baloukj/IddSampleDriver
|
||||
|
||||
Shoutout to **Anakngtokwa** for assisting with finding driver sources.
|
||||
|
||||
**Microsoft** Indirect Display Driver/Sample (Driver code):
|
||||
https://github.com/microsoft/Windows-driver-samples/tree/master/video/IndirectDisplay
|
||||
|
||||
Thanks to **AKATrevorJay** https://github.com/akatrevorjay/edid-generator for the hi-res EDID.
|
||||
|
||||
Shoutout to **zjoasan** and **Bud** for the helper scripts and build support!
|
||||
- Shoutout to **[Roshkins](https://github.com/roshkins/IddSampleDriver)** for the original repo.
|
||||
- Shoutout to **[Baloukj](https://github.com/baloukj/IddSampleDriver)** for the 8-bit / 10-bit support. (Also, first to push the new Microsoft Driver public!)
|
||||
- Shoutout to **[Anakngtokwa](https://github.com/Anakngtokwa)** for assisting with finding driver sources.
|
||||
- **[Microsoft](https://github.com/microsoft/Windows-driver-samples/tree/master/video/IndirectDisplay)** Indirect Display Driver/Sample (Driver code)
|
||||
- Thanks to **[AKATrevorJay](https://github.com/akatrevorjay/edid-generator)** for the hi-res EDID.
|
||||
- Shoutout to **[LexTrack](https://github.com/lextrack/)** for the MiniScreenRecorder script.
|
||||
|
||||
## Star History
|
||||
|
||||
[](https://star-history.com/#itsmikethetech/Virtual-Display-Driver&Date)
|
||||
[](https://star-history.com/#VirtualDisplay/Virtual-Display-Driver&Date)
|
||||
|
||||
## Disclaimer:
|
||||
|
||||
This software is provided "AS IS" with NO IMPLICIT OR EXPLICIT warranty. It's worth noting that while this software functioned without issues on our systems, there is no guarantee that it will not impact your computer. It operates in User Mode(Session0), which reduces the likelihood of causing system instability, such as the Blue Screen of Death. However, exercise caution when using this software.
|
||||
File renamed without changes.
File renamed without changes.
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31129.286
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IddSampleDriver", "IddSampleDriver\IddSampleDriver.vcxproj", "{2D54CB75-8B17-4F11-97DC-847B0244CD46}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MttVDD", "MttVDD\MttVDD.vcxproj", "{2D54CB75-8B17-4F11-97DC-847B0244CD46}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
File diff suppressed because it is too large.
Load diff
@@ -80,14 +80,13 @@ namespace Microsoft
|
||||
public:
|
||||
IndirectDeviceContext(_In_ WDFDEVICE WdfDevice);
|
||||
virtual ~IndirectDeviceContext();
|
||||
static std::vector<BYTE> s_knownMonitorEdidData;
|
||||
|
||||
void InitAdapter();
|
||||
void FinishInit();
|
||||
|
||||
void CreateMonitor(unsigned int index);
|
||||
|
||||
void AssignSwapChain(IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent);
|
||||
void AssignSwapChain(IDDCX_MONITOR& Monitor, IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent);
|
||||
void UnassignSwapChain();
|
||||
|
||||
protected:
|
||||
@@ -101,8 +100,7 @@ namespace Microsoft
|
||||
|
||||
public:
|
||||
static const DISPLAYCONFIG_VIDEO_SIGNAL_INFO s_KnownMonitorModes[];
|
||||
static BYTE* s_KnownMonitorEdid();
|
||||
|
||||
static std::vector<BYTE> s_KnownMonitorEdid;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
Binary file not shown.
File renamed without changes.
+48
-3
@@ -45,7 +45,7 @@
|
||||
<ClInclude Include="Trace.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Inf Include="IddSampleDriver.inf" />
|
||||
<Inf Include="MttVDD.inf" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2D54CB75-8B17-4F11-97DC-847B0244CD46}</ProjectGuid>
|
||||
@@ -132,6 +132,7 @@
|
||||
<IDDCX_VERSION_MINOR>10</IDDCX_VERSION_MINOR>
|
||||
<Driver_SpectreMitigation>Spectre</Driver_SpectreMitigation>
|
||||
<UMDF_VERSION_MINOR>25</UMDF_VERSION_MINOR>
|
||||
<UMDF_MINIMUM_VERSION_REQUIRED>25</UMDF_MINIMUM_VERSION_REQUIRED>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
@@ -155,7 +156,9 @@
|
||||
<UMDF_VERSION_MAJOR>2</UMDF_VERSION_MAJOR>
|
||||
<IndirectDisplayDriver>true</IndirectDisplayDriver>
|
||||
<IDDCX_VERSION_MAJOR>1</IDDCX_VERSION_MAJOR>
|
||||
<IDDCX_VERSION_MINOR>0</IDDCX_VERSION_MINOR>
|
||||
<IDDCX_VERSION_MINOR>10</IDDCX_VERSION_MINOR>
|
||||
<Driver_SpectreMitigation>Spectre</Driver_SpectreMitigation>
|
||||
<UMDF_VERSION_MINOR>25</UMDF_VERSION_MINOR>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
@@ -163,7 +166,10 @@
|
||||
<UMDF_VERSION_MAJOR>2</UMDF_VERSION_MAJOR>
|
||||
<IndirectDisplayDriver>true</IndirectDisplayDriver>
|
||||
<IDDCX_VERSION_MAJOR>1</IDDCX_VERSION_MAJOR>
|
||||
<IDDCX_VERSION_MINOR>0</IDDCX_VERSION_MINOR>
|
||||
<IDDCX_VERSION_MINOR>10</IDDCX_VERSION_MINOR>
|
||||
<Driver_SpectreMitigation>Spectre</Driver_SpectreMitigation>
|
||||
<UMDF_VERSION_MINOR>25</UMDF_VERSION_MINOR>
|
||||
<UMDF_MINIMUM_VERSION_REQUIRED>25</UMDF_MINIMUM_VERSION_REQUIRED>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@@ -202,10 +208,12 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
<Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -214,6 +222,7 @@
|
||||
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Common\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib;avrt.lib</AdditionalDependencies>
|
||||
@@ -226,6 +235,7 @@
|
||||
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Common\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib;avrt.lib</AdditionalDependencies>
|
||||
@@ -239,6 +249,8 @@
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/D_ATL_NO_WIN_SUPPORT /DUMDF_DRIVER /DIDDCX_VERSION_MAJOR=1 /DIDDCX_VERSION_MINOR=4 /DIDDCX_MINIMUM_VERSION_REQUIRED=4 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Common\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib;avrt.lib</AdditionalDependencies>
|
||||
@@ -246,6 +258,9 @@
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>SHA1</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(ProjectDir)..\vdd_settings.xml" "$(TargetDir)\MttVDD"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
@@ -255,6 +270,7 @@
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/D_ATL_NO_WIN_SUPPORT /DUMDF_DRIVER /DIDDCX_VERSION_MAJOR=1 /DIDDCX_VERSION_MINOR=10 /DIDDCX_MINIMUM_VERSION_REQUIRED=3 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Common\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib;avrt.lib</AdditionalDependencies>
|
||||
@@ -262,6 +278,9 @@
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>SHA256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(ProjectDir)..\vdd_settings.xml" "$(TargetDir)\MttVDD"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<ClCompile>
|
||||
@@ -294,10 +313,22 @@
|
||||
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/D_ATL_NO_WIN_SUPPORT /DUMDF_DRIVER /DIDDCX_VERSION_MAJOR=1 /DIDDCX_VERSION_MINOR=4 /DIDDCX_MINIMUM_VERSION_REQUIRED=4 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Common\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib;avrt.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>SHA1</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(ProjectDir)..\vdd_settings.xml" "$(TargetDir)\MttVDD"</Command>
|
||||
</PostBuildEvent>
|
||||
<Inf>
|
||||
<DateStamp>10/16/2024</DateStamp>
|
||||
</Inf>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<ClCompile>
|
||||
@@ -306,10 +337,21 @@
|
||||
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
|
||||
<ExceptionHandling>Async</ExceptionHandling>
|
||||
<EnablePREfast>true</EnablePREfast>
|
||||
<AdditionalOptions>/D_ATL_NO_WIN_SUPPORT /DUMDF_DRIVER /DIDDCX_VERSION_MAJOR=1 /DIDDCX_VERSION_MINOR=10 /DIDDCX_MINIMUM_VERSION_REQUIRED=3 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\Common\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>%(AdditionalDependencies);OneCoreUAP.lib;avrt.lib</AdditionalDependencies>
|
||||
</Link>
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>SHA256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(ProjectDir)..\vdd_settings.xml" "$(TargetDir)\MttVDD"</Command>
|
||||
</PostBuildEvent>
|
||||
<Inf>
|
||||
<DateStamp>10/16/2024</DateStamp>
|
||||
</Inf>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<FilesToPackage Include="$(TargetPath)" />
|
||||
@@ -317,6 +359,9 @@
|
||||
<ItemGroup>
|
||||
<None Include="readme.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="..\vdd_settings.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
+6
-1
@@ -19,7 +19,7 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Inf Include="IddSampleDriver.inf">
|
||||
<Inf Include="MttVDD.inf">
|
||||
<Filter>Driver Files</Filter>
|
||||
</Inf>
|
||||
</ItemGroup>
|
||||
@@ -42,4 +42,9 @@
|
||||
<ItemGroup>
|
||||
<None Include="readme.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="..\vdd_settings.xml">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Xml>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,97 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<vdd_settings>
|
||||
<monitors>
|
||||
<count>1</count>
|
||||
</monitors>
|
||||
<gpu>
|
||||
<friendlyname>default</friendlyname>
|
||||
</gpu>
|
||||
<global>
|
||||
<!--These are global refreshrates, any you add in here, will be replicated to all resolutions-->
|
||||
<g_refresh_rate>60</g_refresh_rate>
|
||||
<g_refresh_rate>90</g_refresh_rate>
|
||||
<g_refresh_rate>120</g_refresh_rate>
|
||||
<g_refresh_rate>144</g_refresh_rate>
|
||||
<g_refresh_rate>165</g_refresh_rate>
|
||||
<g_refresh_rate>244</g_refresh_rate>
|
||||
</global>
|
||||
<resolutions>
|
||||
<resolution>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
<refresh_rate>30</refresh_rate>
|
||||
</resolution>
|
||||
<resolution>
|
||||
<width>1366</width>
|
||||
<height>768</height>
|
||||
<refresh_rate>30</refresh_rate>
|
||||
</resolution>
|
||||
<resolution>
|
||||
<width>1920</width>
|
||||
<height>1080</height>
|
||||
<refresh_rate>30</refresh_rate>
|
||||
</resolution>
|
||||
<resolution>
|
||||
<width>2560</width>
|
||||
<height>1440</height>
|
||||
<refresh_rate>30</refresh_rate>
|
||||
</resolution>
|
||||
<resolution>
|
||||
<width>3840</width>
|
||||
<height>2160</height>
|
||||
<refresh_rate>30</refresh_rate>
|
||||
</resolution>
|
||||
|
||||
|
||||
</resolutions>
|
||||
<logging>
|
||||
<SendLogsThroughPipe>true</SendLogsThroughPipe> <!-- Can only send logs through pipe if logging is enabled-->
|
||||
<logging>false</logging>
|
||||
<!-- DEBUG LOGGING FOR EXPERTS ONLY!-->
|
||||
<debuglogging>false</debuglogging>
|
||||
<!-- DEBUG LOGS CAN GENERATE 1000+ LINES-->
|
||||
<!-- Warning: Leaving logging on too long can lead to excessive filesize. Especially DebugLogging, which should only be used for short periods to log errors. -->
|
||||
<!-- Logging: Useful to troubleshoot and determine which GPUs are being used, and if displays are working as intended.-->
|
||||
<!-- Debug Logging: Logs local system information with every driver function/event/process. Useful for GitHub Help Tickets.-->
|
||||
</logging>
|
||||
<colour>
|
||||
<SDR10bit>false</SDR10bit>
|
||||
<HDRPlus>false</HDRPlus> <!-- If you have SDR10 bit enabled, HDRPlus wont work - there’s a conflict because the display system cannot simultaneously handle both high dynamic range 12-bit and standard dynamic range 10-bit settings. -->
|
||||
<ColourFormat>RGB</ColourFormat>
|
||||
<!--
|
||||
Supported colour formats:
|
||||
RGB
|
||||
YCbCr444
|
||||
YCbCr422
|
||||
YCbCr420
|
||||
|
||||
Any invalid colour formats which are used will default to use RGB
|
||||
-->
|
||||
</colour>
|
||||
<cursor>
|
||||
<HardwareCursor>true</HardwareCursor>
|
||||
<!--Whether to display a hardware cursor in the buffer (If disabled streaming apps will use client cursor)-->
|
||||
<CursorMaxY>128</CursorMaxY>
|
||||
<!--The maximum height support for all cursor types. Older intel cpus may be limited to 64x64 -->
|
||||
<CursorMaxX>128</CursorMaxX>
|
||||
<!--The maximum width supported for all supported cursor types.-->
|
||||
<AlphaCursorSupport>true</AlphaCursorSupport>
|
||||
<!--Indicates if the adapter supports the 32-bit alpha cursor format. Most cursors are alpha format.-->
|
||||
<XorCursorSupportLevel>2</XorCursorSupportLevel>
|
||||
<!-- Do not change if you don't know what you're doing -->
|
||||
<!--
|
||||
0 = IDDCX_XOR_CURSOR_SUPPORT_UNINITIALIZED
|
||||
1 = IDDCX_XOR_CURSOR_SUPPORT_NONE
|
||||
2 = IDDCX_XOR_CURSOR_SUPPORT_FULL
|
||||
3 = IDDCX_XOR_CURSOR_SUPPORT_EMULATION
|
||||
-->
|
||||
</cursor>
|
||||
<edid>
|
||||
<CustomEdid>false</CustomEdid>
|
||||
<!-- Custom Edid should be named "user_edid.bin"! This does not support emulating resolutions!-->
|
||||
<PreventSpoof>false</PreventSpoof>
|
||||
<!--Enable this to prevent manufacturer spoofing when using custom edid. Please only do so if you need to!-->
|
||||
<EdidCeaOverride>false</EdidCeaOverride>
|
||||
<!--Enable this to override or add hard coded cea-extension block to custom Edid support allowing you to enable HDR-->
|
||||
</edid>
|
||||
</vdd_settings>
|
||||
@@ -1,38 +0,0 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue
|
||||
|
||||
$disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
$bpcc = Get-DisplayColorInfo -DisplayId $disp | Select-Object BitsPerColorChannel | Select-Object -ExpandProperty BitsPerColorChannel
|
||||
|
||||
if ( $bpcc -is [int] ) {
|
||||
if ( $bpcc -gt 8 ) {
|
||||
Disable-DisplayAdvancedColor -DisplayId $disp
|
||||
break
|
||||
}
|
||||
if ( $bpcc -lt 10 ) {
|
||||
Enable-DisplayAdvancedColor -DisplayId $disp
|
||||
break
|
||||
}
|
||||
}
|
||||
else { write-error "Something went wrong in identifying the Colormode of the display." ; break }
|
||||
@@ -1,39 +0,0 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Check if there are enough arguments
|
||||
$numArgs = $args.Count
|
||||
switch ($numArgs) {
|
||||
0 { Write-Error "This script requires at least 2 arguments Xres Yres."; break }
|
||||
1 { Write-Error "This script requires at least 2 arguments Xres Yres."; break }
|
||||
2 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
$vres = $args[0]
|
||||
$hres = $args[1]
|
||||
continue
|
||||
}
|
||||
default { Write-Error "Invalid number of arguments: $numArgs"; break }
|
||||
}
|
||||
# Setting the resolution on the correct display.
|
||||
Get-DisplayConfig | Set-DisplayResolution -DisplayId $disp -Width $vres -Height $hres | Use-DisplayConfig
|
||||
@@ -1,32 +0,0 @@
|
||||
# Define the repository name and URL
|
||||
$repoName = "PSGallery"
|
||||
$repoUrl = "https://www.powershellgallery.com/api/v2"
|
||||
|
||||
# Check if the repository is registered
|
||||
if (-not (Get-PSRepository -Name $repoName)) {
|
||||
# Register the repository
|
||||
Register-PSRepository -Name $repoName -SourceLocation $repoUrl -Confirm:$false -InformationAction:Ignore -WarningAction:SilentlyContinue
|
||||
}
|
||||
#Trust the repo, either its allready installed or newly added
|
||||
Set-PSRepository -Name $repoName -InstallationPolicy Trusted -InformationAction:Ignore -WarningAction:SilentlyContinue
|
||||
|
||||
# Define the module name and version
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$version1 = "1.0.5"
|
||||
|
||||
# Define the module name and version
|
||||
$moduleName2 = "MonitorConfig"
|
||||
$version2 = "1.0.3"
|
||||
|
||||
# Check if the module1 is installed
|
||||
if (-not (Get-InstalledModule -Name $moduleName1 -MinimumVersion $version1)) {
|
||||
# Save the module
|
||||
Save-Module -Name $moduleName1 -Repository $repoName -RequiredVersion $version1 -Confirm:$false -InformationAction:Ignore -WarningAction:SilentlyContinue
|
||||
}
|
||||
|
||||
# Check if the module2 is installed
|
||||
if (-not (Get-InstalledModule -Name $moduleName2 -MinimumVersion $version2)) {
|
||||
# Save the module
|
||||
Save-Module -Name $moduleName2 -Repository $repoName -RequiredVersion $version2 -Confirm:$false -InformationAction:Ignore -WarningAction:SilentlyContinue
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path; import-module -name $dpth
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path; import-module -name $mpth
|
||||
|
||||
|
||||
$disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
Set-DisplayPrimary -DisplayId $disp
|
||||
@@ -1,39 +0,0 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
|
||||
# Use the module's functions and cmdlets in your script
|
||||
# Check if there are enough arguments
|
||||
$numArgs = $args.Count
|
||||
switch ($numArgs) {
|
||||
0 { Write-Error "This script requires a refreshrate above 59 or reset"; break }
|
||||
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
$rate = $args[0]
|
||||
continue
|
||||
}
|
||||
default { Write-Error "Invalid number of arguments: $numArgs"; break }
|
||||
}
|
||||
# Setting the resolution on the correct display.
|
||||
Get-DisplayConfig | Set-DisplayRefreshRate -DisplayId $disp -RefreshRate $rate | Use-DisplayConfig
|
||||
@@ -1,46 +0,0 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Check if there are enough arguments
|
||||
$numArgs = $args.Count
|
||||
switch ($numArgs) {
|
||||
0 { Write-Error "This script requires at least 1, rotation in degrees ex. 90/180/270."; break }
|
||||
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
switch ($args[0]) {
|
||||
90 { $degree = "Rotate90"
|
||||
continue
|
||||
}
|
||||
180 { $degree = "Rotate180"
|
||||
continue
|
||||
}
|
||||
270 { $degree = "Rotate270"
|
||||
continue
|
||||
}
|
||||
default { Write-Error "Invalid rotation angle(valid 90,180,270)."; break }
|
||||
}
|
||||
default { Write-Error "Invalid number of arguments: $numArgs"; break }
|
||||
}
|
||||
# Setting the resolution on the correct display.
|
||||
Get-DisplayConfig | Set-DisplayRotation -DisplayId $disp -Rotation $degree | Use-DisplayConfig
|
||||
@@ -1,54 +0,0 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Check if there are enough arguments
|
||||
$numArgs = $args.Count
|
||||
switch ($numArgs) {
|
||||
0 { Write-Error "This script requires a scale 'reset' or an accepted percfentage value (100, 125, 150, 175, 200, 225, 250, 300, 350, 400, 450, 500) limited by the device max scale."; break }
|
||||
1 { $disp = Get-Monitor | Select-String -Pattern "MTT1337" | Select-Object LineNumber | Select-Object -ExpandProperty LineNumber
|
||||
$maxscale = Get-DisplayScale -DisplayId $disp | Select-Object -ExpandProperty MaxScale
|
||||
if ( $args[0] -is [int] ) {
|
||||
if ( $args[0] -le $maxscale -And $args[0] -ge 100 ) {
|
||||
Set-DisplayScale -DisplayId $disp -Scale $args[0]
|
||||
break
|
||||
}
|
||||
else {
|
||||
Write-Error "Invalid scale percentage."
|
||||
break
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( $args[0] -eq "reset" ) {
|
||||
Set-DisplayScale -DisplayId $disp -Recommended
|
||||
break
|
||||
}
|
||||
else {
|
||||
Write-Error "Invalid arguments: 'reset' or a valid percentage value like 150 is acceptable."
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
default { Write-Error "Invalid number of arguments: $numArgs"; break }
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
# Self-elevate the script if required
|
||||
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
||||
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
||||
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
||||
Exit
|
||||
}
|
||||
}
|
||||
|
||||
$repoName = "PSGallery"
|
||||
$moduleName1 = "DisplayConfig"
|
||||
$moduleName2 = "MonitorConfig"
|
||||
if (!(Get-PSRepository -Name $repoName) -OR !(Find-Module -Name $moduleName1 | Where-Object {$_.Name -eq $moduleName1}) -OR !(Find-Module -Name $moduleName2 | Where-Object {$_.Name -eq $moduleName2})) {
|
||||
& .\dep_fix.ps1
|
||||
}
|
||||
|
||||
|
||||
# Import the local module
|
||||
$dpth = Get-Module -ListAvailable $moduleName1 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $dpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
# Import the other localmodule
|
||||
$mpth = Get-Module -ListAvailable $moduleName2 | select path | Select-Object -ExpandProperty path
|
||||
import-module -name $mpth -InformationAction:Ignore -Verbose:$false -WarningAction:SilentlyContinue -Confirm:$false
|
||||
|
||||
|
||||
$profi = Get-DisplayProfile
|
||||
|
||||
if ( $profi -eq "Extend" ) {
|
||||
Set-DisplayProfile Clone
|
||||
break
|
||||
}
|
||||
if ( $profi -eq "Clone" ) {
|
||||
Set-DisplayProfile Extend
|
||||
break
|
||||
}
|
||||
Reference in new issue
Block a user