From 528069dc5992bd069a3c1783db50d630c3d355b4 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 15 Apr 2022 09:32:31 +0200 Subject: use different buffer sizes for vbx mouse & sf --- vbox.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'vbox.c') diff --git a/vbox.c b/vbox.c index eb05f1b..8c6d28a 100644 --- a/vbox.c +++ b/vbox.c @@ -77,18 +77,19 @@ int vbox_init_device(LPVBOXCOMM vb) return 0; } -int vbox_init_buffer(LPVBOXCOMM vb) +int vbox_init_buffer(LPVBOXCOMM vb, unsigned size) { + vb->dds.regionSize = size; + vb->dds.segOrSelector = FP_SEG(&vb->buf); + vb->dds.offset = FP_OFF(&vb->buf); + vb->dds.bufferId = 0; + vb->dds.physicalAddress = 0; + vb->vds = false; + if (vds_available()) { // Use the Virtual DMA Service to get the physical address of this buffer int err; - vb->dds.regionSize = sizeof(vb->buf); - vb->dds.segOrSelector = FP_SEG(&vb->buf); - vb->dds.offset = FP_OFF(&vb->buf); - vb->dds.bufferId = 0; - vb->dds.physicalAddress = 0; - err = vds_lock_dma_buffer_region(&vb->dds, VDS_NO_AUTO_ALLOC); if (err) { // As far as I have seen, most VDS providers always keep low memory contiguous, @@ -98,12 +99,11 @@ int vbox_init_buffer(LPVBOXCOMM vb) dlog_endline(); return err; } - } else { - vb->dds.regionSize = 0; // So that we don't try to unlock it later - vb->dds.segOrSelector = FP_SEG(&vb->buf); - vb->dds.offset = FP_OFF(&vb->buf); - vb->dds.bufferId = 0; + vb->vds = true; + } else { + // If VDS is not available, + // we assume a 1:1 mapping between linear and physical addresses vb->dds.physicalAddress = linear_addr(&vb->buf); } @@ -112,8 +112,7 @@ int vbox_init_buffer(LPVBOXCOMM vb) int vbox_release_buffer(LPVBOXCOMM vb) { - if (vds_available() && vb->dds.regionSize) { - + if (vb->vds && vds_available()) { int err = vds_unlock_dma_buffer_region(&vb->dds, 0); if (err) { dlog_print("Error while VDS unlocking, err="); @@ -122,6 +121,7 @@ int vbox_release_buffer(LPVBOXCOMM vb) // Ignore the error, it's not like we can do anything } } + vb->vds = false; vb->dds.regionSize = 0; vb->dds.segOrSelector = 0; vb->dds.offset = 0; -- cgit v1.2.3