Simplify devices
This commit is contained in:
parent
a861c25a09
commit
e75cf3abeb
28
cmd/camera.h
28
cmd/camera.h
@ -15,27 +15,13 @@ typedef struct camera_s {
|
||||
device_t *devices[MAX_DEVICES];
|
||||
struct {
|
||||
device_t *camera;
|
||||
|
||||
struct {
|
||||
device_t *codec_jpeg;
|
||||
device_t *codec_h264;
|
||||
};
|
||||
|
||||
union {
|
||||
struct {
|
||||
device_t *isp_srgb;
|
||||
device_t *isp_yuuv;
|
||||
device_t *isp_yuuv_low;
|
||||
} isp;
|
||||
|
||||
struct {
|
||||
device_t *isp;
|
||||
} legacy_isp;
|
||||
|
||||
struct {
|
||||
device_t *decoder;
|
||||
} decoder;
|
||||
};
|
||||
device_t *codec_jpeg;
|
||||
device_t *codec_h264;
|
||||
device_t *legacy_isp;
|
||||
device_t *isp_srgb;
|
||||
device_t *isp_yuuv;
|
||||
device_t *isp_yuuv_low;
|
||||
device_t *decoder;
|
||||
};
|
||||
};
|
||||
link_t links[MAX_DEVICES];
|
||||
|
@ -16,15 +16,15 @@ int camera_configure_decoder(camera_t *camera)
|
||||
|
||||
buffer_list_t *src = camera->camera->capture_list;
|
||||
|
||||
camera->decoder.decoder = device_open("DECODER", "/dev/video10");
|
||||
camera->decoder = device_open("DECODER", "/dev/video10");
|
||||
camera->codec_h264 = device_open("H264", "/dev/video11");
|
||||
|
||||
if (device_open_buffer_list_output(camera->decoder.decoder, src) < 0 ||
|
||||
device_open_buffer_list_capture(camera->decoder.decoder, src, 1.0, V4L2_PIX_FMT_YUV420, true) < 0) {
|
||||
if (device_open_buffer_list_output(camera->decoder, src) < 0 ||
|
||||
device_open_buffer_list_capture(camera->decoder, src, 1.0, V4L2_PIX_FMT_YUV420, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
src = camera->decoder.decoder->capture_list;
|
||||
src = camera->decoder->capture_list;
|
||||
|
||||
if (camera->format != V4L2_PIX_FMT_MJPEG && camera->format != V4L2_PIX_FMT_JPEG) {
|
||||
camera->codec_jpeg = device_open("JPEG", "/dev/video31");
|
||||
@ -43,12 +43,12 @@ 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) {
|
||||
*links++ = (link_t){ camera->camera, { camera->decoder.decoder }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
*links++ = (link_t){ camera->decoder.decoder, { camera->codec_h264 } };
|
||||
*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 } };
|
||||
} else {
|
||||
*links++ = (link_t){ camera->camera, { camera->decoder.decoder } };
|
||||
*links++ = (link_t){ camera->decoder.decoder, { camera->codec_jpeg, camera->codec_h264 } };
|
||||
*links++ = (link_t){ camera->camera, { camera->decoder } };
|
||||
*links++ = (link_t){ camera->decoder, { 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 } };
|
||||
}
|
||||
|
@ -18,28 +18,28 @@ int camera_configure_isp(camera_t *camera, float high_div, float low_div)
|
||||
|
||||
buffer_list_t *src = camera->camera->capture_list;
|
||||
|
||||
camera->isp.isp_srgb = device_open("ISP", "/dev/video13");
|
||||
camera->isp.isp_yuuv = device_open("ISP-YUUV", "/dev/video14");
|
||||
camera->isp.isp_yuuv->output_device = camera->isp.isp_srgb;
|
||||
camera->isp_srgb = device_open("ISP", "/dev/video13");
|
||||
camera->isp_yuuv = device_open("ISP-YUUV", "/dev/video14");
|
||||
camera->isp_yuuv->output_device = camera->isp_srgb;
|
||||
camera->codec_jpeg = device_open("JPEG", "/dev/video31");
|
||||
camera->codec_h264 = device_open("H264", "/dev/video11");
|
||||
|
||||
if (device_open_buffer_list_output(camera->isp.isp_srgb, src) < 0 ||
|
||||
device_open_buffer_list_capture(camera->isp.isp_yuuv, src, high_div, V4L2_PIX_FMT_YUYV, true) < 0) {
|
||||
if (device_open_buffer_list_output(camera->isp_srgb, src) < 0 ||
|
||||
device_open_buffer_list_capture(camera->isp_yuuv, src, high_div, V4L2_PIX_FMT_YUYV, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (low_div >= 1) {
|
||||
camera->isp.isp_yuuv_low = device_open("ISP-YUUV-LOW", "/dev/video15");
|
||||
camera->isp.isp_yuuv_low->output_device = camera->isp.isp_srgb;
|
||||
camera->isp_yuuv_low = device_open("ISP-YUUV-LOW", "/dev/video15");
|
||||
camera->isp_yuuv_low->output_device = camera->isp_srgb;
|
||||
|
||||
if (device_open_buffer_list_capture(camera->isp.isp_yuuv_low, src, low_div, V4L2_PIX_FMT_YUYV, true) < 0) {
|
||||
if (device_open_buffer_list_capture(camera->isp_yuuv_low, src, low_div, V4L2_PIX_FMT_YUYV, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
src = camera->isp.isp_yuuv_low->capture_list;
|
||||
src = camera->isp_yuuv_low->capture_list;
|
||||
} else {
|
||||
src = camera->isp.isp_yuuv->capture_list;
|
||||
src = camera->isp_yuuv->capture_list;
|
||||
}
|
||||
|
||||
if (device_open_buffer_list_output(camera->codec_jpeg, src) < 0 ||
|
||||
@ -52,19 +52,19 @@ int camera_configure_isp(camera_t *camera, float high_div, float low_div)
|
||||
return -1;
|
||||
}
|
||||
|
||||
DEVICE_SET_OPTION(camera->isp.isp_srgb, RED_BALANCE, 2120);
|
||||
DEVICE_SET_OPTION(camera->isp.isp_srgb, BLUE_BALANCE, 1472);
|
||||
DEVICE_SET_OPTION(camera->isp.isp_srgb, DIGITAL_GAIN, 1007);
|
||||
DEVICE_SET_OPTION(camera->isp_srgb, RED_BALANCE, 2120);
|
||||
DEVICE_SET_OPTION(camera->isp_srgb, BLUE_BALANCE, 1472);
|
||||
DEVICE_SET_OPTION(camera->isp_srgb, DIGITAL_GAIN, 1007);
|
||||
|
||||
link_t *links = camera->links;
|
||||
|
||||
*links++ = (link_t){ camera->camera, { camera->isp.isp_srgb } };
|
||||
*links++ = (link_t){ camera->camera, { camera->isp_srgb } };
|
||||
|
||||
if (camera->isp.isp_yuuv_low) {
|
||||
*links++ = (link_t){ camera->isp.isp_yuuv, { } };
|
||||
*links++ = (link_t){ camera->isp.isp_yuuv_low, { camera->codec_jpeg, camera->codec_h264 }, { write_yuvu } };
|
||||
if (camera->isp_yuuv_low) {
|
||||
*links++ = (link_t){ camera->isp_yuuv, { } };
|
||||
*links++ = (link_t){ camera->isp_yuuv_low, { camera->codec_jpeg, camera->codec_h264 }, { write_yuvu } };
|
||||
} else {
|
||||
*links++ = (link_t){ camera->isp.isp_yuuv, { camera->codec_jpeg, camera->codec_h264 }, { write_yuvu } };
|
||||
*links++ = (link_t){ camera->isp_yuuv, { camera->codec_jpeg, camera->codec_h264 }, { write_yuvu } };
|
||||
}
|
||||
|
||||
*links++ = (link_t){ camera->codec_jpeg, { }, { http_jpeg_capture, http_jpeg_needs_buffer } };
|
||||
|
@ -28,16 +28,16 @@ int camera_configure_legacy_isp(camera_t *camera, float div)
|
||||
|
||||
buffer_list_t *src = camera->camera->capture_list;
|
||||
|
||||
camera->legacy_isp.isp = device_open("ISP", "/dev/video12");
|
||||
camera->legacy_isp = device_open("ISP", "/dev/video12");
|
||||
camera->codec_jpeg = device_open("JPEG", "/dev/video31");
|
||||
camera->codec_h264 = device_open("H264", "/dev/video11");
|
||||
|
||||
if (device_open_buffer_list_output(camera->legacy_isp.isp, src) < 0 ||
|
||||
device_open_buffer_list_capture(camera->legacy_isp.isp, src, div, V4L2_PIX_FMT_YUYV, true) < 0) {
|
||||
if (device_open_buffer_list_output(camera->legacy_isp, src) < 0 ||
|
||||
device_open_buffer_list_capture(camera->legacy_isp, src, div, V4L2_PIX_FMT_YUYV, true) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
src = camera->legacy_isp.isp->capture_list;
|
||||
src = camera->legacy_isp->capture_list;
|
||||
|
||||
if (device_open_buffer_list_output(camera->codec_jpeg, src) < 0 ||
|
||||
device_open_buffer_list_capture(camera->codec_jpeg, src, 1.0, V4L2_PIX_FMT_JPEG, true) < 0) {
|
||||
@ -51,8 +51,8 @@ int camera_configure_legacy_isp(camera_t *camera, float div)
|
||||
|
||||
link_t *links = camera->links;
|
||||
|
||||
*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->camera, { camera->legacy_isp } };
|
||||
*links++ = (link_t){ camera->legacy_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 } };
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user