Better support configurations
This commit is contained in:
14
cmd/camera.c
14
cmd/camera.c
@ -9,13 +9,6 @@ void camera_init(camera_t *camera)
|
||||
{
|
||||
memset(camera, 0, sizeof(*camera));
|
||||
camera->name = "CAMERA";
|
||||
strcpy(camera->options.path, "/dev/video0");
|
||||
camera->options.width = 1280;
|
||||
camera->options.height = 720;
|
||||
camera->options.nbufs = 4;
|
||||
camera->options.format = V4L2_PIX_FMT_SRGGB10P;
|
||||
camera->options.allow_dma = true;
|
||||
camera->options.fps = 30;
|
||||
}
|
||||
|
||||
void camera_close(camera_t *camera)
|
||||
@ -32,13 +25,18 @@ void camera_close(camera_t *camera)
|
||||
|
||||
int camera_open(camera_t *camera)
|
||||
{
|
||||
camera->camera = device_open("CAMERA", camera->options.path);
|
||||
camera->camera = device_open(camera->name, camera->options.path);
|
||||
if (!camera->camera) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
camera->camera->allow_dma = camera->options.allow_dma;
|
||||
|
||||
if (strstr(camera->camera->v4l2_cap.bus_info, "usb")) {
|
||||
E_LOG_INFO(camera, "Disabling DMA since device uses USB (which is likely not working properly).");
|
||||
camera->camera->allow_dma = false;
|
||||
}
|
||||
|
||||
if (device_open_buffer_list(camera->camera, true, camera->options.width, camera->options.height, camera->options.format, 0, camera->options.nbufs, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ typedef struct camera_options_s {
|
||||
unsigned width, height, format;
|
||||
unsigned nbufs, fps;
|
||||
bool allow_dma;
|
||||
float high_res_factor;
|
||||
float low_res_factor;
|
||||
} camera_options_t;
|
||||
|
||||
typedef struct camera_s {
|
||||
@ -33,7 +35,9 @@ typedef struct camera_s {
|
||||
device_t *codec_h264; // encode YUVU into H264
|
||||
};
|
||||
};
|
||||
|
||||
link_t links[MAX_DEVICES];
|
||||
int nlinks;
|
||||
} camera_t;
|
||||
|
||||
#define CAMERA(DEVICE) camera->devices[DEVICE]
|
||||
|
19
cmd/main.c
19
cmd/main.c
@ -28,7 +28,9 @@ camera_options_t camera_options = {
|
||||
.format = 0,
|
||||
.nbufs = 4,
|
||||
.fps = 30,
|
||||
.allow_dma = true
|
||||
.allow_dma = true,
|
||||
.high_res_factor = 1.0,
|
||||
.low_res_factor = 0.0,
|
||||
};
|
||||
|
||||
http_server_options_t http_options = {
|
||||
@ -41,14 +43,25 @@ log_options_t log_options = {
|
||||
.verbose = false
|
||||
};
|
||||
|
||||
option_value_t camera_formats[] = {
|
||||
{ "DEFAULT", 0 },
|
||||
{ "YUYV", V4L2_PIX_FMT_YUYV },
|
||||
{ "MJPEG", V4L2_PIX_FMT_MJPEG },
|
||||
{ "H264", V4L2_PIX_FMT_H264 },
|
||||
{ "RG10", V4L2_PIX_FMT_SRGGB10P },
|
||||
{}
|
||||
};
|
||||
|
||||
option_t all_options[] = {
|
||||
DEFINE_OPTION_PTR(camera, path, "%s"),
|
||||
DEFINE_OPTION_PTR(camera, path, string),
|
||||
DEFINE_OPTION(camera, width, uint),
|
||||
DEFINE_OPTION(camera, height, uint),
|
||||
DEFINE_OPTION(camera, format, uint),
|
||||
DEFINE_OPTION_VALUES(camera, format, camera_formats),
|
||||
DEFINE_OPTION(camera, nbufs, uint),
|
||||
DEFINE_OPTION(camera, fps, uint),
|
||||
DEFINE_OPTION(camera, allow_dma, bool),
|
||||
DEFINE_OPTION(camera, high_res_factor, float),
|
||||
DEFINE_OPTION(camera, low_res_factor, float),
|
||||
DEFINE_OPTION(http, port, uint),
|
||||
DEFINE_OPTION(http, maxcons, uint),
|
||||
DEFINE_OPTION(log, debug, bool),
|
||||
|
Reference in New Issue
Block a user