WIP
This commit is contained in:
79
main.c
79
main.c
@@ -12,6 +12,7 @@ device_t *camera = NULL;
|
||||
device_t *isp_srgb = NULL;
|
||||
device_t *isp_yuuv = NULL;
|
||||
device_t *isp_yuuv_low = NULL;
|
||||
device_t *codec_jpeg = NULL;
|
||||
|
||||
int open_camera(const char *path)
|
||||
{
|
||||
@@ -27,7 +28,7 @@ int open_camera(const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int open_isp(const char *srgb_path, const char *yuuv_path, const char *yuuv_low_path)
|
||||
int open_isp(buffer_list_t *src, const char *srgb_path, const char *yuuv_path, const char *yuuv_low_path)
|
||||
{
|
||||
isp_srgb = device_open("ISP-SRGB", srgb_path);
|
||||
isp_yuuv = device_open("ISP-YUUV", yuuv_path);
|
||||
@@ -37,9 +38,24 @@ int open_isp(const char *srgb_path, const char *yuuv_path, const char *yuuv_low_
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (device_open_buffer_list(isp_srgb, false, camera_width, camera_height, camera_format, camera_nbufs) < 0 ||
|
||||
device_open_buffer_list(isp_yuuv, true, camera_width, camera_height, V4L2_PIX_FMT_YUYV, camera_nbufs) < 0 ||
|
||||
device_open_buffer_list(isp_yuuv, true, camera_width / 2, camera_height / 2, V4L2_PIX_FMT_YUYV, camera_nbufs) < 0) {
|
||||
if (device_open_buffer_list(isp_srgb, false, src->fmt_width, src->fmt_height, src->fmt_format, camera_nbufs) < 0 ||
|
||||
device_open_buffer_list(isp_yuuv, true, src->fmt_width, src->fmt_height, V4L2_PIX_FMT_YUYV, camera_nbufs) < 0 ||
|
||||
device_open_buffer_list(isp_yuuv_low, true, src->fmt_width / 2, src->fmt_height / 2, V4L2_PIX_FMT_YUYV, camera_nbufs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int open_jpeg(buffer_list_t *src, const char *jpeg_codec)
|
||||
{
|
||||
codec_jpeg = device_open("JPEG", jpeg_codec);
|
||||
if (!codec_jpeg) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (device_open_buffer_list(codec_jpeg, false, src->fmt_width, src->fmt_height, src->fmt_format, camera_nbufs) < 0 ||
|
||||
device_open_buffer_list(codec_jpeg, true, src->fmt_width, src->fmt_height, V4L2_PIX_FMT_JPEG, camera_nbufs) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -51,26 +67,61 @@ int main(int argc, char *argv[])
|
||||
if (open_camera("/dev/video0") < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
// if (open_isp("/dev/video13", "/dev/video14", "/dev/video15") < 0) {
|
||||
// goto error;
|
||||
// }
|
||||
if (open_isp(camera->capture_list, "/dev/video13", "/dev/video14", "/dev/video15") < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (open_jpeg(isp_yuuv->capture_list, "/dev/video31") < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
// return;
|
||||
|
||||
if (device_stream(camera, true) < 0) {
|
||||
goto error;
|
||||
}
|
||||
//return;
|
||||
if (device_stream(isp_srgb, true) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (device_stream(isp_yuuv, true) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (device_stream(isp_yuuv_low, true) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (device_stream(codec_jpeg, true) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
while(true) {
|
||||
if (buffer_list_wait_pool(camera->capture_list, 1000000)) {
|
||||
buffer_t *buf;
|
||||
if (buf = buffer_list_capture_dequeue(camera->capture_list)) {
|
||||
E_LOG_INFO(camera, "Got camera buffer: %p", buf);
|
||||
buffer_capture_enqueue(buf);
|
||||
buffer_t *buf;
|
||||
|
||||
if (buffer_list_wait_pool(camera->capture_list, 100)) {
|
||||
if (buf = buffer_list_mmap_dequeue(camera->capture_list)) {
|
||||
buffer_list_mmap_enqueue(isp_srgb->output_list, buf);
|
||||
buffer_consumed(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer_list_wait_pool(isp_yuuv->capture_list, 100)) {
|
||||
if (buf = buffer_list_mmap_dequeue(isp_yuuv->capture_list)) {
|
||||
buffer_list_mmap_enqueue(codec_jpeg->output_list, buf);
|
||||
buffer_consumed(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer_list_wait_pool(isp_yuuv_low->capture_list, 100)) {
|
||||
if (buf = buffer_list_mmap_dequeue(isp_yuuv_low->capture_list)) {
|
||||
buffer_consumed(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer_list_wait_pool(codec_jpeg->capture_list, 100)) {
|
||||
if (buf = buffer_list_mmap_dequeue(codec_jpeg->capture_list)) {
|
||||
buffer_consumed(buf);
|
||||
}
|
||||
}
|
||||
|
||||
usleep(100*1000);
|
||||
}
|
||||
|
||||
error:
|
||||
|
||||
Reference in New Issue
Block a user