[MPlayer-dev-eng] libdha rewrite

Dmitry Baryshkov mitya at school.ioffe.ru
Sun Aug 22 14:57:14 CEST 2004


Hello,

Please test with attached patch applied.

On Sun, Aug 22, 2004 at 04:23:24PM +0400, Dmitry Baryshkov wrote:
> 
> P.S. Can VIDIX/dha be used at ARM32? non-linux ppc? VIDIX is disabled
> on that platforms, libdha for that platforms looks strange.

Now looking to xfree86's os-support. Will try to fix them.

> 
> P.P.S. Is MPlayer at all ported to LynxOS?

-- 
With best wishes
Dmitry Baryshkov
-------------- next part --------------
diff -Npur dha2.old/dha2.c dha2/dha2.c
--- dha2.old/dha2.c	2004-08-20 15:56:38 +0400
+++ dha2/dha2.c	2004-08-22 16:37:11 +0400
@@ -53,6 +53,7 @@ extern dha2_mtrr_driver_t dha2_mtrr_netb
 #if defined WIN32
 extern dha2_mmap_driver_t dha2_win9x_mmap;
 extern dha2_mmap_driver_t dha2_windha_mmap;
+extern dha2_ports_driver_t dha2_windha_ports;
 #elif defined __EMX__
 extern dha2_mmap_driver_t dha2_os2_mmap;
 #else
@@ -74,6 +75,9 @@ static dha2_ports_driver_t *dha2_ports_d
 	&dha2_svgahelper_ports,
 	&dha2_dhahelper_ports,
 #endif
+#ifdef WIN32
+	&dha2_windha_ports,
+#endif
 	&dha2_ports_direct_ports,
 	NULL
 };
@@ -383,3 +387,16 @@ int disable_app_io(void)
 		close_drivers();
 	return 0;
 }
+
+#ifdef WIN32
+#include <windows.h>
+int IsWinNT()
+{
+  OSVERSIONINFO OSVersionInfo;
+  OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+  GetVersionEx(&OSVersionInfo);
+  return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT;
+}  
+#else
+int IsWinNT(){return 0;}
+#endif
diff -Npur dha2.old/dha2_win9x_mmap.c dha2/dha2_win9x_mmap.c
--- dha2.old/dha2_win9x_mmap.c	2004-08-20 01:19:37 +0400
+++ dha2/dha2_win9x_mmap.c	2004-08-22 16:30:29 +0400
@@ -13,7 +13,6 @@
 #include "dha2.h"
 #include "dha2_internal.h"
 
-
 /*
   This is the request structure that applications use
   to request services from the MAPDEV VxD.
@@ -45,14 +44,6 @@ typedef struct _MapDevRequest
     ((DeviceType)<<16) | ((Access)<<14) | ((Function)<<2) | (Method) )
 #endif
 
-    
-static int IsWinNT(){
-  OSVERSIONINFO OSVersionInfo;
-  OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-  GetVersionEx(&OSVersionInfo);
-  return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT;
-}  
-
 static HANDLE hDriver = INVALID_HANDLE_VALUE;  
     
 extern dha2_mmap_driver_t dha2_win9x_mmap;
diff -Npur dha2.old/dha2_windha.c dha2/dha2_windha.c
--- dha2.old/dha2_windha.c	1970-01-01 03:00:00 +0300
+++ dha2/dha2_windha.c	2004-08-22 16:39:22 +0400
@@ -0,0 +1,112 @@
+#ifdef WIN32
+/*
+  MAPDEV.h - include file for VxD MAPDEV
+  Copyright (c) 1996 Vireo Software, Inc.
+  Modified for libdha by Nick Kurshev.
+*/
+
+#include <windows.h>
+#include <ddk/ntddk.h>
+#include "dhahelperwin/dhahelper.h"
+#include <stdio.h>
+
+#include "dha2.h"
+#include "dha2_internal.h"
+
+static HANDLE hDriver = INVALID_HANDLE_VALUE;  
+    
+extern dha2_ports_driver_t dha2_windha_ports;
+extern dha2_mmap_driver_t dha2_windha_mmap;
+
+static int dha2_windha_init(void)
+{
+	if(!IsWinNT())
+	{
+		dha2_windha_ports.status = -1;
+		dha2_windha_mmap.status = -1;
+		return -1;
+	}
+
+	if (hDriver == INVALID_HANDLE_VALUE)
+		hDriver = CreateFile("\\\\.\\DHAHELPER",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
+	if (hDriver == INVALID_HANDLE_VALUE)
+	{
+		fprintf(stderr, "Cannot open driver, error=%08lx\n", GetLastError()) ;
+		dha2_windha_ports.status = -1;
+		dha2_windha_mmap.status = -1;
+		return -1;
+	}
+
+	dha2_windha_mmap.status = 1;
+	return 0;
+}
+
+static void dha2_windha_shutdown(void)
+{
+	if (hDriver != INVALID_HANDLE_VALUE)
+	{
+		dha2_windha_ports.status = 0;
+		dha2_windha_mmap.status = 0;
+
+		/* FIXME I'm not sure if the right call is CloseHandle. */
+		CloseHandle(hDriver);
+
+		hDriver = INVALID_HANDLE_VALUE;
+	}
+}
+
+#include "portio/portio_x86.h"
+
+dha2_ports_driver_t dha2_windha_ports =
+{
+	.name = "DHA windows helper driver (IO)",
+	.status = 0,
+	.init = dha2_windha_init,
+	.shutdown = dha2_windha_shutdown,
+
+	.dha2_inb = dha2_ports_direct_inb,
+	.dha2_inw = dha2_ports_direct_inw,
+	.dha2_inl = dha2_ports_direct_inl,
+
+	.dha2_outb = dha2_ports_direct_outb,
+	.dha2_outw = dha2_ports_direct_outw,
+	.dha2_outl = dha2_ports_direct_outl,
+};
+
+/* Memory Map a piece of Real Memory */
+static void *dha2_windha_map_phys_mem(unsigned long base, unsigned long size)
+{
+	dhahelper_t dhahelper_priv;
+	DWORD dwBytesReturned;
+	dhahelper_priv.size = size;
+	dhahelper_priv.base = (void*)base;
+
+	if (!DeviceIoControl(hDriver, IOCTL_DHAHELPER_MAPPHYSTOLIN, &dhahelper_priv,sizeof(dhahelper_t), &dhahelper_priv, sizeof(dhahelper_t),&dwBytesReturned, NULL))
+	{
+		printf("unable to map thre requested memory region\n");
+		return MAP_FAILED;
+	}
+	else
+		return dhahelper_priv.ptr;
+}
+
+static void dha2_windha_unmap_phys_mem(void *ptr, unsigned long size)
+{
+	dhahelper_t dhahelper_priv;
+	DWORD dwBytesReturned;
+	dhahelper_priv.ptr = ptr;
+	DeviceIoControl(hDriver, IOCTL_DHAHELPER_UNMAPPHYSADDR, &dhahelper_priv,sizeof(dhahelper_t), NULL, 0, &dwBytesReturned, NULL);
+}
+
+dha2_mmap_driver_t dha2_windha_mmap =
+{
+	.name = "DHA windows helper driver (mmap)",
+	.status = 0,
+	.init = dha2_windha_init,
+	.shutdown = dha2_windha_shutdown,
+
+	.map_phys_mem = dha2_windha_map_phys_mem,
+	.unmap_phys_mem = dha2_windha_unmap_phys_mem,
+};
+
+#endif
diff -Npur dha2.old/dha2_windha_mmap.c dha2/dha2_windha_mmap.c
--- dha2.old/dha2_windha_mmap.c	2004-08-20 13:11:01 +0400
+++ dha2/dha2_windha_mmap.c	1970-01-01 03:00:00 +0300
@@ -1,97 +0,0 @@
-#ifdef WIN32
-/*
-  MAPDEV.h - include file for VxD MAPDEV
-  Copyright (c) 1996 Vireo Software, Inc.
-  Modified for libdha by Nick Kurshev.
-*/
-
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include "dhahelperwin/dhahelper.h"
-#include <stdio.h>
-
-#include "dha2.h"
-#include "dha2_internal.h"
-
-static int IsWinNT(){
-  OSVERSIONINFO OSVersionInfo;
-  OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-  GetVersionEx(&OSVersionInfo);
-  return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT;
-}  
-
-static HANDLE hDriver = INVALID_HANDLE_VALUE;  
-    
-extern dha2_mmap_driver_t dha2_windha_mmap;
-
-static int dha2_windha_init(void)
-{
-	if(!IsWinNT())
-	{
-		dha2_windha_mmap.status = -1;
-		return -1;
-	}
-
-	if (hDriver == INVALID_HANDLE_VALUE)
-		hDriver = CreateFile("\\\\.\\DHAHELPER",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
-	if (hDriver == INVALID_HANDLE_VALUE)
-	{
-		fprintf(stderr, "Cannot open driver, error=%08lx\n", GetLastError()) ;
-		dha2_windha_mmap.status = -1;
-		return -1;
-	}
-
-	dha2_windha_mmap.status = 1;
-	return 0;
-}
-
-static void dha2_windha_shutdown(void)
-{
-	if (hDriver != INVALID_HANDLE_VALUE)
-	{
-		dha2_windha_mmap.status = 0;
-
-		/* FIXME I'm not sure if the right call is CloseHandle. */
-		CloseHandle(hDriver);
-
-		hDriver = INVALID_HANDLE_VALUE;
-	}
-}
-
-/* Memory Map a piece of Real Memory */
-static void *dha2_windha_map_phys_mem(unsigned long base, unsigned long size)
-{
-	dhahelper_t dhahelper_priv;
-	DWORD dwBytesReturned;
-	dhahelper_priv.size = size;
-	dhahelper_priv.base = (void*)base;
-
-	if (!DeviceIoControl(hDriver, IOCTL_DHAHELPER_MAPPHYSTOLIN, &dhahelper_priv,sizeof(dhahelper_t), &dhahelper_priv, sizeof(dhahelper_t),&dwBytesReturned, NULL))
-	{
-		printf("unable to map thre requested memory region\n");
-		return MAP_FAILED;
-	}
-	else
-		return dhahelper_priv.ptr;
-}
-
-static void dha2_windha_unmap_phys_mem(void *ptr, unsigned long size)
-{
-	dhahelper_t dhahelper_priv;
-	DWORD dwBytesReturned;
-	dhahelper_priv.ptr = ptr;
-	DeviceIoControl(hDriver, IOCTL_DHAHELPER_UNMAPPHYSADDR, &dhahelper_priv,sizeof(dhahelper_t), NULL, 0, &dwBytesReturned, NULL);
-}
-
-dha2_mmap_driver_t dha2_windha_mmap =
-{
-	.name = "DHA windows helper driver (mmap)",
-	.status = 0,
-	.init = dha2_windha_init,
-	.shutdown = dha2_windha_shutdown,
-
-	.map_phys_mem = dha2_windha_map_phys_mem,
-	.unmap_phys_mem = dha2_windha_unmap_phys_mem,
-};
-
-#endif
diff -Npur dha2.old/include/dha2_internal.h dha2/include/dha2_internal.h
--- dha2.old/include/dha2_internal.h	2004-08-20 14:32:29 +0400
+++ dha2/include/dha2_internal.h	2004-08-22 16:29:49 +0400
@@ -113,6 +113,8 @@ int pci_get_vendor(unsigned char bus, un
 #define PCI_EN 0x80000000
 #endif
 
+int IsWinNT();
+
 #ifndef DONT_POISON_PORTS
 #if defined __GNUC__ && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
 #pragma GCC poison inb inw inl outb outw outl
diff -Npur dha2.old/io/io_win32.c dha2/io/io_win32.c
--- dha2.old/io/io_win32.c	2004-08-20 16:35:51 +0400
+++ dha2/io/io_win32.c	2004-08-22 16:31:27 +0400
@@ -3,41 +3,21 @@
    $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
    Modified for readability by Nick Kurshev
 */
-#include <windows.h>
-#include <ddk/ntddk.h>
-#include "../dhahelperwin/dhahelper.h"
 
-#include <stdio.h>
-
-static HANDLE hDriver;
-
-static int IsWinNT(){
-  OSVERSIONINFO OSVersionInfo;
-  OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-  GetVersionEx(&OSVersionInfo);
-  return OSVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT;
-}  
+#include "dha2_internal.h"
 
+#include <stdio.h>
 
 static int start_port_access(void)
 {
     if(IsWinNT()){
-      DWORD dwBytesReturned;
-      hDriver = CreateFile("\\\\.\\DHAHELPER",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
-      if(!DeviceIoControl(hDriver, IOCTL_DHAHELPER_ENABLEDIRECTIO, NULL,0, NULL, 0, &dwBytesReturned, NULL)){
-        printf("unable to enable directio please install dhahelper.sys\n");
+        printf("unable to use directio please install dhahelper.sys\n");
         return(1);       
-      }
     }
     return(0);
 }
 
 static int stop_port_access(void)
 {
-    if(IsWinNT()){
-      DWORD dwBytesReturned;
-      DeviceIoControl(hDriver, IOCTL_DHAHELPER_DISABLEDIRECTIO, NULL,0, NULL, 0, &dwBytesReturned, NULL);
-      CloseHandle(hDriver);
-    }
     return(0);
 }
diff -Npur dha2.old/Makefile dha2/Makefile
--- dha2.old/Makefile	2004-08-20 16:36:35 +0400
+++ dha2/Makefile	2004-08-22 16:35:56 +0400
@@ -31,7 +31,7 @@ LIBS += -li386
 endif
 endif
 
-SRCS = dha2.c pciscan.c pci_names.c dha2_svgahelper.c dha2_dhahelper.c dha2_mtrr_linux.c dha2_pci_proc_linux.c dha2_devmem_mmap.c dha2_os2_mmap.c dha2_win9x_mmap.c dha2_windha_mmap.c dha2_pci_generic.c dha2_ports_direct.c dha2_mtrr_netbsd.c dha2_pciconfig_pci.c
+SRCS = dha2.c pciscan.c pci_names.c dha2_svgahelper.c dha2_dhahelper.c dha2_mtrr_linux.c dha2_pci_proc_linux.c dha2_devmem_mmap.c dha2_os2_mmap.c dha2_win9x_mmap.c dha2_windha.c dha2_pci_generic.c dha2_ports_direct.c dha2_mtrr_netbsd.c dha2_pciconfig_pci.c
 
 OBJS=$(SRCS:.c=.o)
 


More information about the MPlayer-dev-eng mailing list