Fix libcamera resolution handling
This commit is contained in:
@ -42,77 +42,21 @@ camera_t *camera_open(camera_options_t *options)
|
||||
|
||||
switch (camera->options.type) {
|
||||
case CAMERA_V4L2:
|
||||
camera->camera = device_v4l2_open(camera->name, camera->options.path);
|
||||
if (camera_configure_v4l2(camera) < 0) {
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
|
||||
case CAMERA_LIBCAMERA:
|
||||
camera->camera = device_libcamera_open(camera->name, camera->options.path);
|
||||
if (camera_configure_libcamera(camera) < 0) {
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR(camera, "Unsupported camera type");
|
||||
}
|
||||
|
||||
if (!camera->camera) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
camera->camera->opts.allow_dma = camera->options.allow_dma;
|
||||
camera->camera->opts.width = camera->options.width;
|
||||
camera->camera->opts.height = camera->options.height;
|
||||
|
||||
if (strstr(camera->camera->bus_info, "usb")) {
|
||||
LOG_INFO(camera, "Disabling DMA since device uses USB (which is likely not working properly).");
|
||||
camera->camera->opts.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) {
|
||||
goto error;
|
||||
}
|
||||
camera->camera->capture_list->do_timestamps = true;
|
||||
|
||||
if (camera->options.fps > 0) {
|
||||
camera->camera->capture_list->fmt_interval_us = 1000 * 1000 / camera->options.fps;
|
||||
}
|
||||
|
||||
switch (camera->camera->capture_list->fmt_format) {
|
||||
case V4L2_PIX_FMT_YUYV:
|
||||
case V4L2_PIX_FMT_YVYU:
|
||||
case V4L2_PIX_FMT_VYUY:
|
||||
case V4L2_PIX_FMT_UYVY:
|
||||
case V4L2_PIX_FMT_YUV420:
|
||||
case V4L2_PIX_FMT_RGB565:
|
||||
case V4L2_PIX_FMT_RGB24:
|
||||
if (camera_configure_direct(camera) < 0) {
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
|
||||
case V4L2_PIX_FMT_MJPEG:
|
||||
case V4L2_PIX_FMT_H264:
|
||||
if (camera_configure_decoder(camera) < 0) {
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
|
||||
case V4L2_PIX_FMT_SRGGB10P:
|
||||
#if 1
|
||||
if (camera_configure_isp(camera, camera->options.high_res_factor, camera->options.low_res_factor) < 0) {
|
||||
goto error;
|
||||
}
|
||||
#else
|
||||
if (camera_configure_legacy_isp(camera, camera->options.high_res_factor) < 0) {
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR(camera, "Unsupported camera format=%s",
|
||||
fourcc_to_string(camera->camera->capture_list->fmt_format).buf);
|
||||
break;
|
||||
}
|
||||
|
||||
if (camera_set_params(camera) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
Reference in New Issue
Block a user