Update logs
This commit is contained in:
@ -6,7 +6,7 @@ int libcamera_buffer_open(buffer_t *buf)
|
||||
buf->libcamera = new buffer_libcamera_t{};
|
||||
buf->libcamera->request = buf->buf_list->dev->libcamera->camera->createRequest(buf->index);
|
||||
if (!buf->libcamera->request) {
|
||||
E_LOG_ERROR(buf, "Can't create request");
|
||||
LOG_ERROR(buf, "Can't create request");
|
||||
}
|
||||
|
||||
for (libcamera::StreamConfiguration &stream_cfg : *buf->buf_list->libcamera->configuration) {
|
||||
@ -16,12 +16,12 @@ int libcamera_buffer_open(buffer_t *buf)
|
||||
auto const &buffer = buffers[buf->index];
|
||||
|
||||
if (buf->libcamera->request->addBuffer(stream, buffer.get()) < 0) {
|
||||
E_LOG_ERROR(buf, "Can't set buffer for request");
|
||||
LOG_ERROR(buf, "Can't set buffer for request");
|
||||
}
|
||||
|
||||
for (auto const &plane : buffer->planes()) {
|
||||
if (buf->start) {
|
||||
E_LOG_ERROR(buf, "Too many planes open.");
|
||||
LOG_ERROR(buf, "Too many planes open.");
|
||||
}
|
||||
|
||||
buf->start = mmap(NULL, plane.length, PROT_READ | PROT_WRITE, MAP_SHARED, plane.fd.get(), 0);
|
||||
@ -30,10 +30,10 @@ int libcamera_buffer_open(buffer_t *buf)
|
||||
buf->dma_fd = plane.fd.get();
|
||||
|
||||
if (!buf->start) {
|
||||
E_LOG_ERROR(buf, "Failed to mmap DMA buffer");
|
||||
LOG_ERROR(buf, "Failed to mmap DMA buffer");
|
||||
}
|
||||
|
||||
E_LOG_DEBUG(buf, "Mapped buffer: start=%p, length=%d, fd=%d",
|
||||
LOG_DEBUG(buf, "Mapped buffer: start=%p, length=%d, fd=%d",
|
||||
buf->start, buf->length, buf->dma_fd);
|
||||
}
|
||||
}
|
||||
@ -66,7 +66,7 @@ int libcamera_buffer_enqueue(buffer_t *buf, const char *who)
|
||||
// }
|
||||
|
||||
if (buf->buf_list->dev->libcamera->camera->queueRequest(buf->libcamera->request.get()) < 0) {
|
||||
E_LOG_ERROR(buf, "Can't queue buffer.");
|
||||
LOG_ERROR(buf, "Can't queue buffer.");
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -92,12 +92,12 @@ int libcamera_buffer_list_dequeue(buffer_list_t *buf_list, buffer_t **bufp)
|
||||
unsigned index = 0;
|
||||
int n = read(buf_list->libcamera->fds[0], &index, sizeof(index));
|
||||
if (n != sizeof(index)) {
|
||||
E_LOG_INFO(buf_list, "Received invalid result from `read`: %d", n);
|
||||
LOG_INFO(buf_list, "Received invalid result from `read`: %d", n);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (index >= buf_list->nbufs) {
|
||||
E_LOG_INFO(buf_list, "Received invalid index from `read`: %d >= %d", index, buf_list->nbufs);
|
||||
LOG_INFO(buf_list, "Received invalid index from `read`: %d >= %d", index, buf_list->nbufs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,12 @@ int libcamera_buffer_list_open(buffer_list_t *buf_list, unsigned width, unsigned
|
||||
int got_bufs = 0;
|
||||
|
||||
if (!buf_list->do_capture) {
|
||||
E_LOG_INFO(buf_list, "Only capture mode is supported.");
|
||||
LOG_INFO(buf_list, "Only capture mode is supported.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!buf_list->do_mmap) {
|
||||
E_LOG_INFO(buf_list, "Only mmap buffers are supported.");
|
||||
LOG_INFO(buf_list, "Only mmap buffers are supported.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ int libcamera_buffer_list_open(buffer_list_t *buf_list, unsigned width, unsigned
|
||||
buf_list->libcamera->fds[1] = -1;
|
||||
|
||||
if (pipe2(buf_list->libcamera->fds, O_DIRECT|O_CLOEXEC) < 0) {
|
||||
E_LOG_INFO(buf_list, "Cannot open `pipe2`.");
|
||||
LOG_INFO(buf_list, "Cannot open `pipe2`.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -38,11 +38,11 @@ int libcamera_buffer_list_open(buffer_list_t *buf_list, unsigned width, unsigned
|
||||
configuration.bufferCount = nbufs;
|
||||
}
|
||||
if (buf_list->libcamera->configuration->validate() == libcamera::CameraConfiguration::Invalid) {
|
||||
E_LOG_ERROR(buf_list, "Camera configuration invalid");
|
||||
LOG_ERROR(buf_list, "Camera configuration invalid");
|
||||
}
|
||||
|
||||
if (buf_list->dev->libcamera->camera->configure(buf_list->libcamera->configuration.get()) < 0) {
|
||||
E_LOG_ERROR(buf_list, "Failed to configure camera");
|
||||
LOG_ERROR(buf_list, "Failed to configure camera");
|
||||
}
|
||||
|
||||
buf_list->fmt_width = configuration.size.width;
|
||||
@ -57,7 +57,7 @@ int libcamera_buffer_list_open(buffer_list_t *buf_list, unsigned width, unsigned
|
||||
|
||||
for (libcamera::StreamConfiguration &stream_config : *buf_list->libcamera->configuration) {
|
||||
if (buf_list->libcamera->allocator->allocate(stream_config.stream()) < 0) {
|
||||
E_LOG_ERROR(buf_list, "Can't allocate buffers");
|
||||
LOG_ERROR(buf_list, "Can't allocate buffers");
|
||||
}
|
||||
|
||||
int allocated = buf_list->libcamera->allocator->buffers(
|
||||
@ -89,14 +89,14 @@ int libcamera_buffer_list_set_stream(buffer_list_t *buf_list, bool do_on)
|
||||
buf_list->libcamera, &buffer_list_libcamera_t::libcamera_buffer_list_dequeued);
|
||||
|
||||
if (buf_list->dev->libcamera->camera->start() < 0) {
|
||||
E_LOG_ERROR(buf_list, "Failed to start camera.");
|
||||
LOG_ERROR(buf_list, "Failed to start camera.");
|
||||
}
|
||||
} else {
|
||||
buf_list->dev->libcamera->camera->requestCompleted.disconnect(
|
||||
buf_list->libcamera, &buffer_list_libcamera_t::libcamera_buffer_list_dequeued);
|
||||
|
||||
if (buf_list->dev->libcamera->camera->stop() < 0) {
|
||||
E_LOG_ERROR(buf_list, "Failed to stop camera.");
|
||||
LOG_ERROR(buf_list, "Failed to stop camera.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,26 +14,26 @@ int libcamera_device_open(device_t *dev)
|
||||
dev->libcamera->camera_manager = std::make_shared<libcamera::CameraManager>();
|
||||
int ret = dev->libcamera->camera_manager->start();
|
||||
if (ret < 0) {
|
||||
E_LOG_ERROR(dev, "Cannot start camera_manager.");
|
||||
LOG_ERROR(dev, "Cannot start camera_manager.");
|
||||
}
|
||||
|
||||
dev->libcamera->camera = dev->libcamera->camera_manager->get(dev->path);
|
||||
if (!dev->libcamera->camera) {
|
||||
if (dev->libcamera->camera_manager->cameras().size()) {
|
||||
for(auto const &camera : dev->libcamera->camera_manager->cameras()) {
|
||||
E_LOG_INFO(dev, "Available Camera: %s", camera->id().c_str());
|
||||
LOG_INFO(dev, "Available Camera: %s", camera->id().c_str());
|
||||
}
|
||||
} else {
|
||||
E_LOG_INFO(dev, "No available cameras");
|
||||
LOG_INFO(dev, "No available cameras");
|
||||
}
|
||||
E_LOG_ERROR(dev, "Camera `%s` was not found.", dev->path);
|
||||
LOG_ERROR(dev, "Camera `%s` was not found.", dev->path);
|
||||
}
|
||||
|
||||
if (dev->libcamera->camera->acquire()) {
|
||||
E_LOG_ERROR(dev, "Failed to acquire `%s` camera.", dev->path);
|
||||
LOG_ERROR(dev, "Failed to acquire `%s` camera.", dev->path);
|
||||
}
|
||||
|
||||
E_LOG_INFO(dev, "Device path=%s opened", dev->path);
|
||||
LOG_INFO(dev, "Device path=%s opened", dev->path);
|
||||
|
||||
for (auto const &control : dev->libcamera->camera->controls()) {
|
||||
if (!control.first)
|
||||
@ -42,7 +42,7 @@ int libcamera_device_open(device_t *dev)
|
||||
auto control_id = control.first;
|
||||
auto control_key = libcamera_device_option_normalize(control_id->name());
|
||||
|
||||
E_LOG_VERBOSE(dev, "Available control: %s (%08x, type=%d)",
|
||||
LOG_VERBOSE(dev, "Available control: %s (%08x, type=%d)",
|
||||
control_key.c_str(), control_id->id(), control_id->type());
|
||||
}
|
||||
return 0;
|
||||
@ -113,10 +113,10 @@ int libcamera_device_set_option(device_t *dev, const char *keyp, const char *val
|
||||
}
|
||||
|
||||
if (control_value.isNone()) {
|
||||
E_LOG_ERROR(dev, "The `%s` type `%d` is not supported.", control_key.c_str(), control_id->type());
|
||||
LOG_ERROR(dev, "The `%s` type `%d` is not supported.", control_key.c_str(), control_id->type());
|
||||
}
|
||||
|
||||
E_LOG_INFO(dev, "Configuring option %s (%08x, type=%d) = %s",
|
||||
LOG_INFO(dev, "Configuring option %s (%08x, type=%d) = %s",
|
||||
control_key.c_str(), control_id->id(), control_id->type(),
|
||||
control_value.toString().c_str());
|
||||
dev->libcamera->controls.set(control_id->id(), control_value);
|
||||
|
@ -25,7 +25,7 @@ extern "C" device_t *device_libcamera_open(const char *name, const char *path)
|
||||
#else // USE_LIBCAMERA
|
||||
extern "C" device_t *device_libcamera_open(const char *name, const char *path)
|
||||
{
|
||||
E_LOG_INFO(NULL, "libcamera is not supported");
|
||||
LOG_INFO(NULL, "libcamera is not supported");
|
||||
return NULL;
|
||||
}
|
||||
#endif // USE_LIBCAMERA
|
||||
|
Reference in New Issue
Block a user