Pass options to ISP

This commit is contained in:
Kamil Trzcinski 2022-04-08 19:57:22 +02:00
parent 42ab32b1a6
commit 08c179e22a
5 changed files with 20 additions and 18 deletions

View File

@ -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),

View File

@ -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);

View File

@ -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 {

View File

@ -1,4 +1,5 @@
#include "device/hw/device.h"
#include "opts/opts.h"
#include <ctype.h>
@ -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);
}

View File

@ -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"