From 162287708802f379921486865c5c29af3cdba0e8 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 7 Aug 2015 13:20:51 +0100 Subject: [PATCH] V36 --- pigpio.c | 23 +++++++++++++++-------- pigpio.h | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pigpio.c b/pigpio.c index 4e2f9fa..2f43b95 100644 --- a/pigpio.c +++ b/pigpio.c @@ -786,7 +786,8 @@ Assumes two counters per block. Each counter 4 * 16 (16^4=65536) #define MB_IOCTL _IOWR(MB_DEV_MAJOR, 0, char *) -#define MB_DEV "/dev/pigpio-mb" +#define MB_DEV1 "/dev/vcio" +#define MB_DEV2 "/dev/pigpio-mb" #define BUS_TO_PHYS(x) ((x)&~0xC0000000) @@ -2284,20 +2285,29 @@ static void myGpioSetServo(unsigned gpio, int oldVal, int newVal) https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface */ -static int mbCreate(void) +static int mbCreate(char *dev) { /* <0 error */ - unlink(MB_DEV); + unlink(dev); - return mknod(MB_DEV, S_IFCHR|0600, makedev(MB_DEV_MAJOR, 0)); + return mknod(dev, S_IFCHR|0600, makedev(MB_DEV_MAJOR, 0)); } static int mbOpen(void) { /* <0 error */ - return open(MB_DEV, 0); + int fd; + + fd = open(MB_DEV1, 0); + + if (fd < 0) + { + mbCreate(MB_DEV2); + fd = open(MB_DEV2, 0); + } + return fd; } static void mbClose(int fd) @@ -6471,9 +6481,6 @@ static int initAllocDMAMem(void) if (dmaMboxBlk == MAP_FAILED) SOFT_ERROR(PI_INIT_FAILED, "mmap mbox block failed (%m)"); - if (mbCreate() < 0) - SOFT_ERROR(PI_INIT_FAILED, "mbox create failed(%m)"); - fdMbox = mbOpen(); if (fdMbox < 0) diff --git a/pigpio.h b/pigpio.h index a13d3be..99948e7 100644 --- a/pigpio.h +++ b/pigpio.h @@ -31,7 +31,7 @@ For more information, please refer to #include #include -#define PIGPIO_VERSION 35 +#define PIGPIO_VERSION 36 /*TEXT