Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions vcgencmd/vcgencmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <unistd.h>
#include <sys/ioctl.h> /* ioctl */

#define DEVICE_FILE_NAME "/dev/vcio"
#define countof(x) (sizeof x/sizeof *x)

#define MAJOR_NUM 100
#define IOCTL_MBOX_PROPERTY _IOWR(MAJOR_NUM, 0, char *)

Expand All @@ -61,15 +62,19 @@ static int mbox_property(int file_desc, void *buf)
static int mbox_open()
{
int file_desc;

const char *devices[] = {"/dev/vcio_gencmd", "/dev/vcio"};
int i;
// open a char device file used for communicating with kernel mbox driver
file_desc = open(DEVICE_FILE_NAME, 0);
if (file_desc < 0) {
printf("Can't open device file: %s\n", DEVICE_FILE_NAME);
printf("Try creating a device file with: sudo mknod %s c %d 0\n", DEVICE_FILE_NAME, MAJOR_NUM);
exit(-1);
// first try the more restrictive interface but fall back to full if unavailable
for (i=0; i<countof(devices); i++)
{
file_desc = open(devices[i], 0);
if (file_desc >= 0)
return file_desc;
}
return file_desc;
printf("Can't open device file: %s\n", devices[0]);
printf("Try creating a device file with: sudo mknod %s c %d 0\n", devices[0], MAJOR_NUM);
exit(-1);
}

static void mbox_close(int file_desc) {
Expand Down