Skip to content

Commit 5c9b87d

Browse files
sraman4malayaku
authored andcommitted
ZC v1111 : Filtered invalid modes during QEMU resize
1 parent 86fd92c commit 5c9b87d

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed

DVServerUMD/DVServer/DVServeredid.cpp

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ int get_edid_data(HANDLE devHandle, void* m, DWORD id)
105105

106106
DBGPRINT("Modes\n");
107107
for (i = 0; i < edata->mode_size; i++) {
108-
//TRIMMING LOGIC: Restricting EDID size to 32 and discarding modes with width more than 3840 & less than 1024
108+
//TRIMMING LOGIC:
109+
//Restricting EDID size to 32
110+
//Discarding modes with width more than 3840 & less than 1024
111+
//Discarding blacklisted modes
112+
//Discarding the modes for which kmd & umd strides are not equal
109113
if ((edata->mode_list[i].width <= WIDTH_UPPER_CAP) &&
110114
(edata->mode_list[i].width >= WIDTH_LOWER_CAP) &&
111115
(edid_mode_index < monitor->szModeList) &&
112-
(is_blacklist(edata->mode_list[i].width, edata->mode_list[i].height) == 0)) {
116+
(is_blacklist(edata->mode_list[i].width, edata->mode_list[i].height) == 0) &&
117+
(is_samestride(edata->mode_list[i].width) == 0)) {
113118
monitor->pModeList[edid_mode_index].Width = edata->mode_list[i].width;
114119
monitor->pModeList[edid_mode_index].Height = edata->mode_list[i].height;
115120
if ((DWORD)edata->mode_list[i].refreshrate == REFRESH_RATE_59)
@@ -198,3 +203,45 @@ int is_blacklist(unsigned int width, unsigned int height)
198203
}
199204
return DVSERVERUMD_SUCCESS;
200205
}
206+
207+
/*******************************************************************************
208+
*
209+
* Description
210+
*
211+
* is_samestride - This function generates kmd, umd strides & compare them
212+
* It returns SUCCESS if both are same
213+
*
214+
* Parameters
215+
* width - resolution width
216+
*
217+
* Return val
218+
* int - 0 == SUCCESS, -1 = ERROR
219+
*
220+
******************************************************************************/
221+
int is_samestride(unsigned int width)
222+
{
223+
UINT kmdstride = 0;
224+
UINT bytes_pp = 0;
225+
UINT umdstride = 0;
226+
UINT rem = 0;
227+
UINT padding = 0;
228+
229+
bytes_pp = (VGPU_BPP + 7) / 8;
230+
kmdstride = (width * bytes_pp + 3) & ~0x3;
231+
232+
rem = width % BYTE_ALIGN_16;
233+
if (rem != 0) {
234+
padding = BYTE_ALIGN_16 - rem;
235+
}
236+
else {
237+
padding = 0;
238+
}
239+
umdstride = 4 * (width + padding);
240+
241+
if (kmdstride == umdstride) {
242+
return DVSERVERUMD_SUCCESS;
243+
}
244+
else {
245+
return DVSERVERUMD_FAILURE;
246+
}
247+
}

DVServerUMD/DVServer/DVServeredid.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727
#define REFRESH_RATE_59 59 //59Hz
2828
#define REFRESH_RATE_60 60 //60Hz
2929
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
30+
#define VGPU_BPP 32
31+
#define BYTE_ALIGN_16 16
3032

3133
int get_total_screens(HANDLE devHandle);
3234
int get_edid_data(HANDLE devHandle, void* m, DWORD id);
3335
int is_blacklist(unsigned int width, unsigned int height);
36+
int is_samestride(unsigned int width);
3437

3538
#endif /* __DVSERVER_EDID_H__ */

Readme.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88
-----------------------------------------------------------
99
##### Windows VM QEMU CMD Example #####
1010
-----------------------------------------------------------
11+
12+
1) Direct QEMU command without "connectors" parameter (no association with external physical display)
13+
sudo qemu-system-x86_64 -m 4096 -enable-kvm -cpu host -smp cores=4,threads=2,sockets=1 -drive file=<WindowsOS.img>.img,format=qcow2,cache=none -device vfio-pci,host=0000:00:02.2 -device e1000,netdev=net0,mac=DE:AD:BE:EF:1C:00 -netdev tap,id=net0 -device virtio-vga,max_outputs=4,blob=true -display gtk,gl=on,full-screen=<on/off>, show-fps=on -object memory-backend-memfd,id=mem1,hugetlb=on,size=4096M -machine memory-backend=mem1
14+
15+
2) Associate QEMU with External Physical Display: For this we need to use customized QEMU version with "connectors" parameter enabled
1116
sudo qemu-system-x86_64 -m 4096 -enable-kvm -cpu host -smp cores=4,threads=2,sockets=1 -drive file=<WindowsOS.img>.img,format=qcow2,cache=none -device vfio-pci,host=0000:00:02.2 -device e1000,netdev=net0,mac=DE:AD:BE:EF:1C:00 -netdev tap,id=net0 -device virtio-vga,max_outputs=4,blob=true -display gtk,gl=on,full-screen=<on/off>,connectors.0 = <display-port-name>, connectors.1=<display-port-name>, connectors.2=<display-port-name>, connectors.3=<display-port-name>, show-fps=on -object memory-backend-memfd,id=mem1,hugetlb=on,size=4096M -machine memory-backend=mem1
1217

1318
Note:
14-
use the below command to get the display port name for that particular board
19+
use the below command to get the display port name for that particular board (for "connectors" parameter)
1520
“cat /sys/kernel/debug/dri/0/i915_display_info”
1621

1722
-----------------------------------------------------------

0 commit comments

Comments
 (0)