diff --git a/src/detection/brightness/brightness_bsd.c b/src/detection/brightness/brightness_bsd.c index 3212f7278..42a13eb6f 100644 --- a/src/detection/brightness/brightness_bsd.c +++ b/src/detection/brightness/brightness_bsd.c @@ -9,7 +9,8 @@ #include #include -#include +#if __has_include() + #include const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { // FIXME: doesn't work for me @@ -34,15 +35,7 @@ const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* re uint8_t i2cIn[] = { FF_DDC_CI_VCP_COMMAND, FF_DDC_CI_MAKE_HEADER(2), FF_DDC_CI_GET_VCP, FF_DDC_CI_LUMINANCE_OPCODE, 0 }; i2cIn[4] = FF_DDC_CI_WRITE_ADDR ^ i2cIn[0] ^ i2cIn[1] ^ i2cIn[2] ^ i2cIn[3]; - int ret = ioctl(fd, I2CRDWR, &(struct iic_rdwr_data) { - .msgs = &(struct iic_msg) { - .slave = FF_DDC_CI_WRITE_ADDR, - .flags = IIC_M_WR, - .len = ARRAY_SIZE(i2cIn), - .buf = i2cIn - }, - .nmsgs = 1 - }); + int ret = ioctl(fd, I2CRDWR, &(struct iic_rdwr_data){ .msgs = &(struct iic_msg){ .slave = FF_DDC_CI_WRITE_ADDR, .flags = IIC_M_WR, .len = ARRAY_SIZE(i2cIn), .buf = i2cIn }, .nmsgs = 1 }); if (ret < 0) { FF_DEBUG("First ioctl(/dev/iic%c, I2CRDWR) failed: %s", i, strerror(errno)); continue; @@ -51,15 +44,11 @@ const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* re ffTimeSleep(options->ddcciSleep); uint8_t i2cOut[12] = {}; - ret = ioctl(fd, I2CRDWR, &(struct iic_rdwr_data) { - .msgs = &(struct iic_msg) { - .slave = FF_DDC_CI_READ_ADDR, // LSB will be overridden by kernel to set read bit - .flags = IIC_M_RD, - .len = ARRAY_SIZE(i2cOut), - .buf = i2cOut - }, - .nmsgs = 1 - }); + ret = ioctl(fd, I2CRDWR, &(struct iic_rdwr_data){ .msgs = &(struct iic_msg){ .slave = FF_DDC_CI_READ_ADDR, // LSB will be overridden by kernel to set read bit + .flags = IIC_M_RD, + .len = ARRAY_SIZE(i2cOut), + .buf = i2cOut }, + .nmsgs = 1 }); if (ret < 0) { FF_DEBUG("Second ioctl(/dev/iic%c, I2CRDWR) failed: %s", i, strerror(errno)); continue; @@ -83,11 +72,18 @@ const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FFlist* re return NULL; } +#else + +const char* detectWithDdcci(FF_A_UNUSED FFBrightnessOptions* options, FF_A_UNUSED FFlist* result) { + FF_DEBUG("DDC/CI support is not available on this system"); + return "DDC/CI is supported only on FreeBSD"; +} + +#endif + #if __has_include() - #include - const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { // https://man.freebsd.org/cgi/man.cgi?query=backlight&sektion=9 char path[] = "/dev/backlight/backlight0"; @@ -141,7 +137,6 @@ const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FF_A_U #endif - const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { detectWithBacklight(options, result); if (result->length == 0) {