libcamera: configure RAW to force correct resolution
This commit is contained in:
parent
e2e5762b2b
commit
529d72b105
@ -19,7 +19,7 @@ buffer_list_t *buffer_list_open(const char *name, int index, struct device_s *de
|
||||
buf_list->index = index;
|
||||
|
||||
int got_bufs = dev->hw->buffer_list_open(buf_list);
|
||||
if (got_bufs <= 0) {
|
||||
if (got_bufs < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -58,14 +58,38 @@ static int camera_configure_input_libcamera(camera_t *camera)
|
||||
|
||||
camera->camera->opts.allow_dma = camera->options.allow_dma;
|
||||
|
||||
buffer_format_t fmt = {
|
||||
buffer_format_t raw_fmt = {
|
||||
.width = camera->options.width,
|
||||
.height = camera->options.height,
|
||||
.nbufs = camera->options.nbufs
|
||||
};
|
||||
|
||||
buffer_list_t *raw_capture = device_open_buffer_list(camera->camera, true, raw_fmt, true);
|
||||
if (!raw_capture) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned target_height = camera->options.height;
|
||||
|
||||
if (!camera->options.snapshot.disabled)
|
||||
target_height = camera->options.snapshot.height;
|
||||
else if (!camera->options.stream.disabled)
|
||||
target_height = camera->options.stream.height;
|
||||
else if (!camera->options.video.disabled)
|
||||
target_height = camera->options.video.height;
|
||||
|
||||
target_height = camera_rescaller_align_size(target_height);
|
||||
unsigned target_width = target_height * camera->options.width / camera->options.height;
|
||||
target_width = camera_rescaller_align_size(target_width);
|
||||
|
||||
buffer_format_t capture_fmt = {
|
||||
.width = target_width,
|
||||
.height = target_height,
|
||||
.format = camera->options.format,
|
||||
.nbufs = camera->options.nbufs
|
||||
};
|
||||
|
||||
buffer_list_t *camera_capture = device_open_buffer_list(camera->camera, true, fmt, true);
|
||||
buffer_list_t *camera_capture = device_open_buffer_list(camera->camera, true, capture_fmt, true);
|
||||
if (!camera_capture) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -41,11 +41,6 @@ int libcamera_buffer_list_open(buffer_list_t *buf_list)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_list->index > 0) {
|
||||
LOG_INFO(buf_list, "Only single capture device is supported.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!buf_list->do_mmap) {
|
||||
LOG_INFO(buf_list, "Only mmap buffers are supported.");
|
||||
return -1;
|
||||
@ -69,7 +64,9 @@ int libcamera_buffer_list_open(buffer_list_t *buf_list)
|
||||
auto &configurations = buf_list->dev->libcamera->configuration;
|
||||
auto &configuration = configurations->at(buf_list->index);
|
||||
configuration.size = libcamera::Size(buf_list->fmt.width, buf_list->fmt.height);
|
||||
configuration.pixelFormat = libcamera_from_fourcc(buf_list->fmt.format);
|
||||
if (buf_list->fmt.format) {
|
||||
configuration.pixelFormat = libcamera_from_fourcc(buf_list->fmt.format);
|
||||
}
|
||||
if (buf_list->fmt.bytesperline > 0) {
|
||||
configuration.stride = buf_list->fmt.bytesperline;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ int libcamera_device_open(device_t *dev)
|
||||
}
|
||||
|
||||
dev->libcamera->configuration = dev->libcamera->camera->generateConfiguration(
|
||||
{ libcamera::StreamRole::Viewfinder });
|
||||
{ libcamera::StreamRole::Raw, libcamera::StreamRole::StillCapture });
|
||||
|
||||
dev->libcamera->allocator = std::make_shared<libcamera::FrameBufferAllocator>(
|
||||
dev->libcamera->camera);
|
||||
|
Loading…
x
Reference in New Issue
Block a user