summaryrefslogtreecommitdiff
path: root/src/video_out/libdha/mmi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_out/libdha/mmi.c')
-rw-r--r--src/video_out/libdha/mmi.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/video_out/libdha/mmi.c b/src/video_out/libdha/mmi.c
new file mode 100644
index 000000000..68d3429f2
--- /dev/null
+++ b/src/video_out/libdha/mmi.c
@@ -0,0 +1,57 @@
+/* Memory manager interface */
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "libdha.h"
+#include "kernelhelper/dhahelper.h"
+
+static int libdha_fd=-1;
+
+#define ALLOWED_VER 2
+int bm_open( void )
+{
+ int retv;
+ libdha_fd = open("/dev/dhahelper",O_RDWR);
+ retv = libdha_fd > 0 ? 0 : ENXIO;
+ if(!retv)
+ {
+ int ver;
+ ioctl(libdha_fd,DHAHELPER_GET_VERSION,&ver);
+ if(ver < ALLOWED_VER)
+ {
+ printf("libdha: You have wrong version (%i) of /dev/dhahelper\n"
+ "libdha: Please upgrade your driver up to ver=%i\n",ver,ALLOWED_VER);
+ retv = EINVAL;
+ close(libdha_fd);
+ }
+ }
+ else printf("libdha: Can't open /dev/dhahelper\n");
+ return retv;
+}
+
+void bm_close( void )
+{
+ close(libdha_fd);
+}
+
+int bm_virt_to_phys( void * virt_addr, unsigned long length, unsigned long * parray )
+{
+ dhahelper_vmi_t vmi;
+ vmi.virtaddr = virt_addr;
+ vmi.length = length;
+ vmi.realaddr = parray;
+ if(libdha_fd > 0) return ioctl(libdha_fd,DHAHELPER_VIRT_TO_PHYS,&vmi);
+ return ENXIO;
+}
+
+int bm_virt_to_bus( void * virt_addr, unsigned long length, unsigned long * barray )
+{
+ dhahelper_vmi_t vmi;
+ vmi.virtaddr = virt_addr;
+ vmi.length = length;
+ vmi.realaddr = barray;
+ if(libdha_fd > 0) return ioctl(libdha_fd,DHAHELPER_VIRT_TO_BUS,&vmi);
+ return ENXIO;
+}