From ae48e07f84fdab9e615f9acbe3cd42b6113eb89b Mon Sep 17 00:00:00 2001 From: Egor Shestakov Date: Wed, 12 Mar 2025 12:06:38 +0000 Subject: [PATCH] use libmegapixels_get_model in find_calibration --- src/dcp.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/dcp.c b/src/dcp.c index 839a6f9..61a11d7 100644 --- a/src/dcp.c +++ b/src/dcp.c @@ -1,6 +1,7 @@ #include "dcp.h" #include +#include #include #include #include @@ -42,30 +43,12 @@ bool find_calibration(char *conffile, const char *sensor) { char model[512]; - FILE *fp; - - if (access("/proc/device-tree/compatible", F_OK) == -1) { - return false; - } - fp = fopen("/proc/device-tree/compatible", "r"); - char *modelptr = model; - while (1) { - int c = fgetc(fp); - if (c == EOF) { - *(modelptr) = '\0'; - return find_calibration_by_model(conffile, model, sensor); - } - *(modelptr++) = (char)c; - if (c == 0) { - bool res = - find_calibration_by_model(conffile, model, sensor); - if (res) { - return true; - } - modelptr = model; - } - } + int model_found = libmegapixels_get_model(sizeof(model), model); + if (!model_found) + return false; + return find_calibration_by_model(conffile, model, sensor); } + struct MPCameraCalibration parse_calibration_file(const char *path) {