Add more camera modes
This commit is contained in:
parent
5a81b75684
commit
f4e133b191
@ -10,6 +10,9 @@ void camera_init(camera_t *camera)
|
||||
camera->width = 1280;
|
||||
camera->height = 720;
|
||||
camera->nbufs = 4;
|
||||
camera->format = V4L2_PIX_FMT_SRGGB10P;
|
||||
camera->allow_dma = true;
|
||||
camera->fps = 30;
|
||||
}
|
||||
|
||||
void camera_close(camera_t *camera)
|
||||
@ -36,6 +39,8 @@ int camera_open(camera_t *camera, const char *path)
|
||||
|
||||
int camera_set_params(camera_t *camera)
|
||||
{
|
||||
device_set_fps(camera->camera, camera->fps);
|
||||
|
||||
DEVICE_SET_OPTION(camera->camera, EXPOSURE, 2684);
|
||||
DEVICE_SET_OPTION(camera->camera, ANALOGUE_GAIN, 938);
|
||||
DEVICE_SET_OPTION(camera->camera, DIGITAL_GAIN, 512);
|
||||
|
11
cmd/camera.h
11
cmd/camera.h
@ -34,8 +34,9 @@ typedef struct camera_s {
|
||||
};
|
||||
link_t links[MAX_DEVICES];
|
||||
|
||||
unsigned width, height;
|
||||
unsigned nbufs;
|
||||
unsigned width, height, format;
|
||||
unsigned nbufs, fps;
|
||||
bool allow_dma;
|
||||
} camera_t;
|
||||
|
||||
#define CAMERA(DEVICE) camera->devices[DEVICE]
|
||||
@ -43,7 +44,9 @@ typedef struct camera_s {
|
||||
void camera_init(camera_t *camera);
|
||||
void camera_close(camera_t *camera);
|
||||
int camera_open(camera_t *camera, const char *path);
|
||||
int camera_configure_srgb_isp(camera_t *camera, float high_div, float low_div);
|
||||
int camera_configure_srgb_legacy_isp(camera_t *camera, float div);
|
||||
int camera_set_params(camera_t *camera);
|
||||
int camera_run(camera_t *camera);
|
||||
|
||||
int camera_configure_isp(camera_t *camera, float high_div, float low_div);
|
||||
int camera_configure_legacy_isp(camera_t *camera, float div);
|
||||
int camera_configure_direct(camera_t *camera);
|
||||
|
40
cmd/camera_direct.c
Normal file
40
cmd/camera_direct.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include "camera.h"
|
||||
|
||||
#include "hw/buffer.h"
|
||||
#include "hw/buffer_list.h"
|
||||
#include "hw/device.h"
|
||||
#include "hw/links.h"
|
||||
#include "hw/v4l2.h"
|
||||
#include "hw/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
int camera_configure_direct(camera_t *camera)
|
||||
{
|
||||
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, camera->format, 0, camera->nbufs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
buffer_list_t *src = camera->camera->capture_list;
|
||||
|
||||
camera->codec_jpeg = device_open("JPEG", "/dev/video31");
|
||||
camera->codec_jpeg->allow_dma = false;
|
||||
camera->codec_h264 = device_open("H264", "/dev/video11");
|
||||
camera->codec_h264->allow_dma = false;
|
||||
|
||||
if (device_open_buffer_list(camera->codec_jpeg, false, src->fmt_width, src->fmt_height, src->fmt_format, src->fmt_bytesperline, camera->nbufs) < 0 ||
|
||||
device_open_buffer_list(camera->codec_jpeg, true, src->fmt_width, src->fmt_height, V4L2_PIX_FMT_JPEG, 0, camera->nbufs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (device_open_buffer_list(camera->codec_h264, false, src->fmt_width, src->fmt_height, src->fmt_format, src->fmt_bytesperline, camera->nbufs) < 0 ||
|
||||
device_open_buffer_list(camera->codec_h264, true, src->fmt_width, src->fmt_height, V4L2_PIX_FMT_H264, 0, camera->nbufs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
link_t *links = camera->links;
|
||||
|
||||
*links++ = (link_t){ camera->camera, { camera->codec_jpeg, camera->codec_h264 } };
|
||||
*links++ = (link_t){ camera->codec_jpeg, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
*links++ = (link_t){ camera->codec_h264, { }, { http_h264_capture, http_h264_needs_buffer } };
|
||||
return 0;
|
||||
}
|
@ -8,13 +8,11 @@
|
||||
#include "hw/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
extern bool check_streaming();
|
||||
|
||||
void write_yuvu(buffer_t *buffer);
|
||||
|
||||
int camera_configure_srgb_isp(camera_t *camera, float high_div, float low_div)
|
||||
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, V4L2_PIX_FMT_SRGGB10P, 0, camera->nbufs) < 0) {
|
||||
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, camera->format, 0, camera->nbufs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -60,7 +58,7 @@ int camera_configure_srgb_isp(camera_t *camera, float high_div, float low_div)
|
||||
|
||||
link_t *links = camera->links;
|
||||
|
||||
*links++ = (link_t){ camera->camera, { camera->isp.isp_srgb }, { NULL, check_streaming } };
|
||||
*links++ = (link_t){ camera->camera, { camera->isp.isp_srgb } };
|
||||
|
||||
if (camera->isp.isp_yuuv_low) {
|
||||
*links++ = (link_t){ camera->isp.isp_yuuv, { } };
|
@ -8,8 +8,6 @@
|
||||
#include "hw/buffer_list.h"
|
||||
#include "http/http.h"
|
||||
|
||||
extern bool check_streaming();
|
||||
|
||||
void write_yuvu(buffer_t *buffer)
|
||||
{
|
||||
#if 0
|
||||
@ -22,9 +20,9 @@ void write_yuvu(buffer_t *buffer)
|
||||
#endif
|
||||
}
|
||||
|
||||
int camera_configure_srgb_legacy_isp(camera_t *camera, float div)
|
||||
int camera_configure_legacy_isp(camera_t *camera, float div)
|
||||
{
|
||||
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, V4L2_PIX_FMT_SRGGB10P, 0, camera->nbufs) < 0) {
|
||||
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, camera->format, 0, camera->nbufs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -53,7 +51,7 @@ int camera_configure_srgb_legacy_isp(camera_t *camera, float div)
|
||||
|
||||
link_t *links = camera->links;
|
||||
|
||||
*links++ = (link_t){ camera->camera, { camera->legacy_isp.isp }, { NULL, check_streaming } };
|
||||
*links++ = (link_t){ camera->camera, { camera->legacy_isp.isp } };
|
||||
*links++ = (link_t){ camera->legacy_isp.isp, { camera->codec_jpeg, camera->codec_h264 }, { write_yuvu, NULL } };
|
||||
*links++ = (link_t){ camera->codec_jpeg, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
*links++ = (link_t){ camera->codec_h264, { }, { http_h264_capture, http_h264_needs_buffer } };
|
15
cmd/main.c
15
cmd/main.c
@ -32,18 +32,25 @@ int main(int argc, char *argv[])
|
||||
camera.width = 2328; camera.height = 1748; // 1164x874
|
||||
//camera.width = 4656; camera.height = 3496;
|
||||
//camera.width = 3840; camera.height = 2160;
|
||||
//camera.width = 1280; camera.height = 720;
|
||||
camera.nbufs = 4;
|
||||
camera.format = V4L2_PIX_FMT_SRGGB10P;
|
||||
//camera.format = V4L2_PIX_FMT_YUYV; camera.allow_dma = false;
|
||||
|
||||
if (camera_open(&camera, "/dev/video0") < 0) {
|
||||
if (camera_open(&camera, "/dev/video2") < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if 1
|
||||
if (camera_configure_srgb_isp(&camera, 1.5, 0) < 0) {
|
||||
#if 0
|
||||
if (camera_configure_direct(&camera) < 0) {
|
||||
goto error;
|
||||
}
|
||||
#elif 1
|
||||
if (camera_configure_isp(&camera, 3, 0) < 0) {
|
||||
goto error;
|
||||
}
|
||||
#else
|
||||
if (camera_configure_srgb_legacy_isp(&camera, 1.3) < 0) {
|
||||
if (camera_configure_legacy_isp(&camera, 1.3) < 0) {
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user