From 5458fd775d4c7e4e9ffe8bdbfd47e540ca712a31 Mon Sep 17 00:00:00 2001 From: Fneufneu Date: Mon, 27 Feb 2012 18:07:37 +0100 Subject: [PATCH] Initial FreeBSD support simply try to use ttyU* --- configure.ac | 3 +++ src/lib/adapter/USBCECAdapterDetection.cpp | 17 +++++++++++++++++ src/lib/platform/posix/os-types.h | 2 +- src/lib/platform/posix/serialport.cpp | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b7a4b60..209ecf6 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,9 @@ case "${host}" in has_libudev="no"; LIBS+="-framework CoreVideo -framework IOKit" ;; + *-freebsd*) + has_libudev="no" + ;; esac if test "x$has_libudev" != "xno"; then diff --git a/src/lib/adapter/USBCECAdapterDetection.cpp b/src/lib/adapter/USBCECAdapterDetection.cpp index 0d9f8b3..c2a0b5c 100644 --- a/src/lib/adapter/USBCECAdapterDetection.cpp +++ b/src/lib/adapter/USBCECAdapterDetection.cpp @@ -55,6 +55,9 @@ static GUID USB_RAW_GUID = { 0xA5DCBF10, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0x extern "C" { #include } +#elif defined(__FreeBSD__) +#include +#include #endif #define CEC_VID 0x2548 @@ -323,6 +326,20 @@ uint8_t CUSBCECAdapterDetection::FindAdapters(cec_adapter *deviceList, uint8_t i RegCloseKey(hDeviceKey); } +#elif defined(__FreeBSD__) + char devicePath[PATH_MAX + 1]; + int i; + + for (i = 0; i < 8; ++i) + { + (void)snprintf(devicePath, sizeof(devicePath), "/dev/ttyU%d", i); + if (!access(devicePath, 0)) + { + snprintf(deviceList[iFound].path, sizeof(deviceList[iFound].path), "%s", devicePath); + snprintf(deviceList[iFound].comm, sizeof(deviceList[iFound].path), "%s", devicePath); + ++iFound; + } + } #endif iBufSize = 0; /* silence "unused" warning on linux/osx */ diff --git a/src/lib/platform/posix/os-types.h b/src/lib/platform/posix/os-types.h index 631e965..b8783b1 100644 --- a/src/lib/platform/posix/os-types.h +++ b/src/lib/platform/posix/os-types.h @@ -35,7 +35,7 @@ #include #include #include -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__FreeBSD__) #include #endif #include diff --git a/src/lib/platform/posix/serialport.cpp b/src/lib/platform/posix/serialport.cpp index 5557064..31ae09b 100644 --- a/src/lib/platform/posix/serialport.cpp +++ b/src/lib/platform/posix/serialport.cpp @@ -37,7 +37,7 @@ #include "../util/baudrate.h" #include "../posix/os-socket.h" -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(__FreeBSD__) #ifndef XCASE #define XCASE 0 #endif -- 2.34.1