diff --git a/doc/json_schema.json b/doc/json_schema.json index fd463b79e..469b233c6 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -1750,10 +1750,18 @@ "$ref": "#/$defs/percent" }, "ddcciSleep": { - "type": "integer", - "description": "Sleep time in milliseconds between DDC/CI requests\nSee for details", - "minimum": 0, - "maximum": 400, + "description": "Sleep time in milliseconds between DDC/CI requests\nSet to null to skip DDC/CI detection\nSee for details", + "oneOf": [ + { + "type": "null", + "description": "Skip DDC/CI detection" + }, + { + "type": "integer", + "minimum": 0, + "maximum": 400 + } + ], "default": 10 }, "compact": { diff --git a/src/detection/brightness/brightness.h b/src/detection/brightness/brightness.h index 9aa586292..abb94787e 100644 --- a/src/detection/brightness/brightness.h +++ b/src/detection/brightness/brightness.h @@ -20,6 +20,7 @@ enum { FF_DDC_CI_COMMAND_PACKET = 0x80u, FF_DDC_CI_LUMINANCE_OPCODE = 0x10u, }; +#define FF_BRIGHTNESS_DDCCI_SLEEP_SKIP ((uint32_t) -1) #define FF_DDC_CI_MAKE_HEADER(len) (FF_DDC_CI_COMMAND_PACKET | ((len) & 0x7F)) const char* ffDetectBrightness(FFBrightnessOptions* options, FFlist* result); // list of FFBrightnessResult diff --git a/src/detection/brightness/brightness_apple.c b/src/detection/brightness/brightness_apple.c index 8afa18f2e..5dd12b2a4 100644 --- a/src/detection/brightness/brightness_apple.c +++ b/src/detection/brightness/brightness_apple.c @@ -236,7 +236,7 @@ const char* ffDetectBrightness(FFBrightnessOptions* options, FFlist* result) { detectWithDisplayServices(displayServer, result); - if (displayServer->displays.length > result->length) { + if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && displayServer->displays.length > result->length) { detectWithDdcci(displayServer, options, result); } diff --git a/src/detection/brightness/brightness_bsd.c b/src/detection/brightness/brightness_bsd.c index 42a13eb6f..45fe5e46a 100644 --- a/src/detection/brightness/brightness_bsd.c +++ b/src/detection/brightness/brightness_bsd.c @@ -139,7 +139,8 @@ const char* detectWithBacklight(FF_A_UNUSED FFBrightnessOptions* options, FF_A_U const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { detectWithBacklight(options, result); - if (result->length == 0) { + + if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && result->length == 0) { detectWithDdcci(options, result); } return NULL; diff --git a/src/detection/brightness/brightness_linux.c b/src/detection/brightness/brightness_linux.c index 876d8fbda..95cde9fa9 100644 --- a/src/detection/brightness/brightness_linux.c +++ b/src/detection/brightness/brightness_linux.c @@ -164,9 +164,11 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* detectWithBacklight(result); #ifdef FF_HAVE_DDCUTIL - const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); - if (result->length < displayServer->displays.length) { - detectWithDdcci(options, result); + if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP) { + const FFDisplayServerResult* displayServer = ffConnectDisplayServer(); + if (result->length < displayServer->displays.length) { + detectWithDdcci(options, result); + } } #endif diff --git a/src/detection/brightness/brightness_windows.c b/src/detection/brightness/brightness_windows.c index 685882f2d..70b7f0197 100644 --- a/src/detection/brightness/brightness_windows.c +++ b/src/detection/brightness/brightness_windows.c @@ -213,7 +213,7 @@ const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* detectWithWmi(result); } - if (result->length < displayServer->displays.length) { + if (options->ddcciSleep != FF_BRIGHTNESS_DDCCI_SLEEP_SKIP && result->length < displayServer->displays.length) { FF_DEBUG("resultCount=%u < displayCount=%u, trying DDC/CI", result->length, displayServer->displays.length); detectWithDdcci(displayServer, result); } diff --git a/src/modules/brightness/brightness.c b/src/modules/brightness/brightness.c index 0da4c8d2b..9f440c476 100644 --- a/src/modules/brightness/brightness.c +++ b/src/modules/brightness/brightness.c @@ -113,7 +113,11 @@ void ffParseBrightnessJsonObject(FFBrightnessOptions* options, yyjson_val* modul } if (unsafe_yyjson_equals_str(key, "ddcciSleep")) { - options->ddcciSleep = (uint32_t) yyjson_get_uint(val); + if (yyjson_is_null(val)) { + options->ddcciSleep = FF_BRIGHTNESS_DDCCI_SLEEP_SKIP; + } else { + options->ddcciSleep = (uint32_t) yyjson_get_uint(val); + } continue; } @@ -133,7 +137,11 @@ void ffParseBrightnessJsonObject(FFBrightnessOptions* options, yyjson_val* modul void ffGenerateBrightnessJsonConfig(FFBrightnessOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) { ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs); - yyjson_mut_obj_add_uint(doc, module, "ddcciSleep", options->ddcciSleep); + if (options->ddcciSleep == FF_BRIGHTNESS_DDCCI_SLEEP_SKIP) { + yyjson_mut_obj_add_null(doc, module, "ddcciSleep"); + } else { + yyjson_mut_obj_add_uint(doc, module, "ddcciSleep", options->ddcciSleep); + } ffPercentGenerateJsonConfig(doc, module, options->percent);