Camera options
This commit is contained in:
parent
7dd1ec9c0c
commit
9cf4cc359a
29
cmd/camera.c
29
cmd/camera.c
@ -1,6 +1,7 @@
|
||||
#include "camera.h"
|
||||
|
||||
#include "hw/device.h"
|
||||
#include "hw/buffer_list.h"
|
||||
#include "hw/links.h"
|
||||
#include "hw/v4l2.h"
|
||||
|
||||
@ -8,13 +9,13 @@ void camera_init(camera_t *camera)
|
||||
{
|
||||
memset(camera, 0, sizeof(*camera));
|
||||
camera->name = "CAMERA";
|
||||
strcpy(camera->path, "/dev/video0");
|
||||
camera->width = 1280;
|
||||
camera->height = 720;
|
||||
camera->nbufs = 4;
|
||||
camera->format = V4L2_PIX_FMT_SRGGB10P;
|
||||
camera->allow_dma = true;
|
||||
camera->fps = 30;
|
||||
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)
|
||||
@ -31,14 +32,18 @@ void camera_close(camera_t *camera)
|
||||
|
||||
int camera_open(camera_t *camera)
|
||||
{
|
||||
camera->camera = device_open("CAMERA", camera->path);
|
||||
camera->camera = device_open("CAMERA", camera->options.path);
|
||||
if (!camera->camera) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
camera->camera->allow_dma = camera->allow_dma;
|
||||
camera->camera->allow_dma = camera->options.allow_dma;
|
||||
|
||||
switch (camera->format) {
|
||||
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;
|
||||
}
|
||||
|
||||
switch (camera->camera->capture_list->fmt_format) {
|
||||
case V4L2_PIX_FMT_YUYV:
|
||||
if (camera_configure_direct(camera) < 0) {
|
||||
goto error;
|
||||
@ -65,7 +70,7 @@ int camera_open(camera_t *camera)
|
||||
break;
|
||||
|
||||
default:
|
||||
E_LOG_ERROR(camera, "Unsupported camera format=%s", fourcc_to_string(camera->format).buf);
|
||||
E_LOG_ERROR(camera, "Unsupported camera format=%s", fourcc_to_string(camera->options.format).buf);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -77,7 +82,7 @@ error:
|
||||
|
||||
int camera_set_params(camera_t *camera)
|
||||
{
|
||||
device_set_fps(camera->camera, camera->fps);
|
||||
device_set_fps(camera->camera, camera->options.fps);
|
||||
|
||||
DEVICE_SET_OPTION(camera->camera, EXPOSURE, 2684);
|
||||
DEVICE_SET_OPTION(camera->camera, ANALOGUE_GAIN, 938);
|
||||
|
14
cmd/camera.h
14
cmd/camera.h
@ -8,9 +8,18 @@
|
||||
|
||||
#define CAMERA_DEVICE_CAMERA 0
|
||||
|
||||
typedef struct camera_options_s {
|
||||
char path[256];
|
||||
unsigned width, height, format;
|
||||
unsigned nbufs, fps;
|
||||
bool allow_dma;
|
||||
} camera_options_t;
|
||||
|
||||
typedef struct camera_s {
|
||||
const char *name;
|
||||
|
||||
camera_options_t options;
|
||||
|
||||
union {
|
||||
device_t *devices[MAX_DEVICES];
|
||||
struct {
|
||||
@ -25,11 +34,6 @@ typedef struct camera_s {
|
||||
};
|
||||
};
|
||||
link_t links[MAX_DEVICES];
|
||||
|
||||
char path[256];
|
||||
unsigned width, height, format;
|
||||
unsigned nbufs, fps;
|
||||
bool allow_dma;
|
||||
} camera_t;
|
||||
|
||||
#define CAMERA(DEVICE) camera->devices[DEVICE]
|
||||
|
@ -10,10 +10,6 @@
|
||||
|
||||
int camera_configure_decoder(camera_t *camera)
|
||||
{
|
||||
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, camera->format, 0, camera->nbufs, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
buffer_list_t *src = camera->camera->capture_list;
|
||||
|
||||
camera->decoder = device_open("DECODER", "/dev/video10");
|
||||
@ -26,7 +22,7 @@ int camera_configure_decoder(camera_t *camera)
|
||||
|
||||
src = camera->decoder->capture_list;
|
||||
|
||||
if (camera->format != V4L2_PIX_FMT_MJPEG && camera->format != V4L2_PIX_FMT_JPEG) {
|
||||
if (camera->options.format != V4L2_PIX_FMT_MJPEG && camera->options.format != V4L2_PIX_FMT_JPEG) {
|
||||
camera->codec_jpeg = device_open("JPEG", "/dev/video31");
|
||||
|
||||
if (device_open_buffer_list_output(camera->codec_jpeg, src) < 0 ||
|
||||
@ -42,7 +38,7 @@ int camera_configure_decoder(camera_t *camera)
|
||||
|
||||
link_t *links = camera->links;
|
||||
|
||||
if (camera->format == V4L2_PIX_FMT_MJPEG || camera->format == V4L2_PIX_FMT_JPEG) {
|
||||
if (camera->options.format == V4L2_PIX_FMT_MJPEG || camera->options.format == V4L2_PIX_FMT_JPEG) {
|
||||
*links++ = (link_t){ camera->camera, { camera->decoder }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
*links++ = (link_t){ camera->decoder, { camera->codec_h264 } };
|
||||
*links++ = (link_t){ camera->codec_h264, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||
|
@ -10,10 +10,6 @@
|
||||
|
||||
int camera_configure_direct(camera_t *camera)
|
||||
{
|
||||
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, camera->format, 0, camera->nbufs, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
buffer_list_t *src = camera->camera->capture_list;
|
||||
|
||||
camera->codec_jpeg = device_open("JPEG", "/dev/video31");
|
||||
|
@ -12,10 +12,6 @@ void write_yuvu(buffer_t *buffer);
|
||||
|
||||
int camera_configure_isp(camera_t *camera, float high_div, float low_div)
|
||||
{
|
||||
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, camera->format, 0, camera->nbufs, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
buffer_list_t *src = camera->camera->capture_list;
|
||||
|
||||
camera->isp_srgb = device_open("ISP", "/dev/video13");
|
||||
|
@ -22,10 +22,6 @@ void write_yuvu(buffer_t *buffer)
|
||||
|
||||
int camera_configure_legacy_isp(camera_t *camera, float div)
|
||||
{
|
||||
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, camera->format, 0, camera->nbufs, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
buffer_list_t *src = camera->camera->capture_list;
|
||||
|
||||
camera->legacy_isp = device_open("ISP", "/dev/video12");
|
||||
|
@ -34,12 +34,12 @@ int main(int argc, char *argv[])
|
||||
camera_init(&camera);
|
||||
|
||||
//camera.width = 1920; camera.height = 1080;
|
||||
strcpy(camera.path, "/dev/video2"); camera.width = 2328; camera.height = 1748; camera.format = V4L2_PIX_FMT_SRGGB10P; // 1164x874
|
||||
strcpy(camera.options.path, "/dev/video2"); camera.options.width = 2328; camera.options.height = 1748; camera.options.format = V4L2_PIX_FMT_SRGGB10P; // 1164x874
|
||||
//camera.width = 4656; camera.height = 3496;
|
||||
//camera.width = 3840; camera.height = 2160;
|
||||
//camera.width = 1280; camera.height = 720;
|
||||
strcpy(camera.path, "/dev/video0"); camera.width = 1920; camera.height = 1080; camera.format = V4L2_PIX_FMT_YUYV; camera.format = V4L2_PIX_FMT_MJPEG; camera.allow_dma = false;
|
||||
camera.nbufs = 1;
|
||||
strcpy(camera.options.path, "/dev/video0"); camera.options.width = 1920; camera.options.height = 1080; camera.options.format = V4L2_PIX_FMT_YUYV; camera.options.format = V4L2_PIX_FMT_MJPEG; camera.options.allow_dma = false;
|
||||
camera.options.nbufs = 1;
|
||||
|
||||
if (camera_open(&camera) < 0) {
|
||||
goto error;
|
||||
|
Loading…
x
Reference in New Issue
Block a user