diff --git a/cmd/camera_stream.c b/cmd/camera_stream.c index cf1af40..e771b6b 100644 --- a/cmd/camera_stream.c +++ b/cmd/camera_stream.c @@ -74,6 +74,8 @@ option_t all_options[] = { DEFINE_OPTION(camera, low_res_factor, float), DEFINE_OPTION_PTR(camera, options, list), + DEFINE_OPTION_PTR(camera, isp.options, list), + DEFINE_OPTION(http, port, uint), DEFINE_OPTION(http, maxcons, uint), diff --git a/device/camera.c b/device/camera.c index 6f52032..00dd9e0 100644 --- a/device/camera.c +++ b/device/camera.c @@ -108,6 +108,7 @@ int camera_set_params(camera_t *camera) { device_set_fps(camera->camera, camera->options.fps); device_set_option_list(camera->camera, camera->options.options); + device_set_option_list(camera->isp_srgb, camera->options.isp.options); // DEVICE_SET_OPTION(camera->camera, EXPOSURE, 2684); // DEVICE_SET_OPTION(camera->camera, ANALOGUE_GAIN, 938); diff --git a/device/camera.h b/device/camera.h index e184e67..7e89c6a 100644 --- a/device/camera.h +++ b/device/camera.h @@ -7,6 +7,7 @@ #define MAX_HTTP_METHODS 20 #define CAMERA_DEVICE_CAMERA 0 +#define CAMERA_OPTIONS_LENGTH 4096 typedef struct camera_options_s { char path[256]; @@ -16,7 +17,11 @@ typedef struct camera_options_s { float high_res_factor; float low_res_factor; - char options[4096]; + char options[CAMERA_OPTIONS_LENGTH]; + + struct { + char options[CAMERA_OPTIONS_LENGTH]; + } isp; } camera_options_t; typedef struct camera_s { diff --git a/device/hw/device_options.c b/device/hw/device_options.c index 7c160f3..49741a2 100644 --- a/device/hw/device_options.c +++ b/device/hw/device_options.c @@ -1,4 +1,5 @@ #include "device/hw/device.h" +#include "opts/opts.h" #include @@ -83,7 +84,8 @@ error: int device_set_option_string(device_t *dev, const char *option) { - char name[256]; + int ret = -1; + char *name = strdup(option); strcpy(name, option); char *value = strchr(name, '='); @@ -94,21 +96,19 @@ int device_set_option_string(device_t *dev, const char *option) device_option_normalize_name(name); - int ret = device_set_option_string_fd(dev, dev->subdev_fd, name, value); - if (ret > 0) - return 0; - - ret = device_set_option_string_fd(dev, dev->fd, name, value); - + ret = device_set_option_string_fd(dev, dev->subdev_fd, name, value); + if (ret <= 0) + ret = device_set_option_string_fd(dev, dev->fd, name, value); if (ret == 0) E_LOG_ERROR(dev, "The '%s' was failed to find.", option); else if (ret < 0) E_LOG_ERROR(dev, "The '%s' did fail to be set.", option); - return 0; + ret = 0; error: - return -1; + free(name); + return ret; } void device_set_option_list(device_t *dev, const char *option_list) @@ -121,7 +121,7 @@ void device_set_option_list(device_t *dev, const char *option_list) char *string = start; char *option; - while (option = strsep(&string, ",")) { + while (option = strsep(&string, OPTION_VALUE_LIST_SEP)) { device_set_option_string(dev, option); } diff --git a/opts/opts.h b/opts/opts.h index 5ecf801..abb34fc 100644 --- a/opts/opts.h +++ b/opts/opts.h @@ -25,13 +25,7 @@ typedef struct options_s { const char *default_value; } option_t; -#define lambda(return_type, function_body) \ -({ \ - return_type __fn__ function_body \ - __fn__; \ -}) - -#define OPTION_VALUE_LIST_SEP "," +#define OPTION_VALUE_LIST_SEP ";" #define OPTION_FORMAT_uint "%d" #define OPTION_FORMAT_hex "%08x"