diff --git a/spa/plugins/libcamera/libcamera-client.c b/spa/plugins/libcamera/libcamera-client.c index 392fdd615..ae992c0d2 100644 --- a/spa/plugins/libcamera/libcamera-client.c +++ b/spa/plugins/libcamera/libcamera-client.c @@ -44,8 +44,6 @@ #include "libcamera.h" -#define NAME "libcamera-client" - struct impl { struct spa_handle handle; struct spa_device device; @@ -192,6 +190,8 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log); + libcamera_log_topic_init(this->log); + this->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop); if (this->main_loop == NULL) { diff --git a/spa/plugins/libcamera/libcamera-device.c b/spa/plugins/libcamera/libcamera-device.c index 4f2ff741a..1314d0846 100644 --- a/spa/plugins/libcamera/libcamera-device.c +++ b/spa/plugins/libcamera/libcamera-device.c @@ -46,8 +46,6 @@ #include "libcamera.h" -#define NAME "libcamera-device" - static const char default_device[] = "/dev/media0"; struct props { @@ -81,7 +79,7 @@ static int emit_info(struct impl *this, bool full) uint32_t n_items = 0; struct spa_device_info info; struct spa_param_info params[2]; - char path[128], version[16]; + char path[128], version[16]; if ((res = spa_libcamera_open(&this->dev)) < 0) return res; @@ -241,6 +239,7 @@ impl_init(const struct spa_handle_factory *factory, handle->clear = impl_clear, this = (struct impl *) handle; this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log); + libcamera_log_topic_init(this->log); spa_hook_list_init(&this->hooks); diff --git a/spa/plugins/libcamera/libcamera-source.c b/spa/plugins/libcamera/libcamera-source.c index 5bf361d5a..6d47a6148 100644 --- a/spa/plugins/libcamera/libcamera-source.c +++ b/spa/plugins/libcamera/libcamera-source.c @@ -49,8 +49,6 @@ #include "libcamera.h" -#define NAME "libcamera-source" - static const char default_device[] = "/dev/media0"; struct props { @@ -827,7 +825,7 @@ static int impl_node_process(void *object) if (port->control) process_control(this, &port->control->sequence); - spa_log_trace(this->log, NAME " %p; status %d", this, io->status); + spa_log_trace(this->log, "%p; status %d", this, io->status); if (io->status == SPA_STATUS_HAVE_DATA) { return SPA_STATUS_HAVE_DATA; @@ -849,7 +847,7 @@ static int impl_node_process(void *object) spa_list_remove(&b->link); SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUTSTANDING); - spa_log_trace(this->log, NAME " %p: dequeue buffer %d", this, b->id); + spa_log_trace(this->log, "%p: dequeue buffer %d", this, b->id); io->buffer_id = b->id; io->status = SPA_STATUS_HAVE_DATA; @@ -940,6 +938,8 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log); + libcamera_log_topic_init(this->log); + this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop); this->system = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_System); diff --git a/spa/plugins/libcamera/libcamera-utils.c b/spa/plugins/libcamera/libcamera-utils.c index 60f65bca9..7b49e2805 100644 --- a/spa/plugins/libcamera/libcamera-utils.c +++ b/spa/plugins/libcamera/libcamera-utils.c @@ -116,7 +116,7 @@ static int spa_libcamera_clear_buffers(struct impl *this) d = b->outbuf->datas; if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_OUTSTANDING)) { - spa_log_debug(this->log, "libcamera: queueing outstanding buffer %p", b); + spa_log_debug(this->log, "queueing outstanding buffer %p", b); spa_libcamera_buffer_recycle(this, i); } if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_MAPPED)) { @@ -454,7 +454,7 @@ static int spa_libcamera_set_format(struct impl *this, struct spa_video_info *fo info = find_format_info_by_media_type(format->media_type, format->media_subtype, video_format, 0); if (info == NULL || size == NULL || framerate == NULL) { - spa_log_error(this->log, "libcamera: unknown media type %d %d %d", format->media_type, + spa_log_error(this->log, "unknown media type %d %d %d", format->media_type, format->media_subtype, video_format); return -EINVAL; } @@ -470,7 +470,7 @@ static int spa_libcamera_set_format(struct impl *this, struct spa_video_info *fo if ((res = spa_libcamera_open(dev)) < 0) return res; - spa_log_info(dev->log, "libcamera: set %s %dx%d %d/%d", (char *)&info->fourcc, + spa_log_info(dev->log, "set %s %dx%d %d/%d", (char *)&info->fourcc, fmt.width, fmt.height, fmt.denominator, fmt.numerator); @@ -693,10 +693,10 @@ static int spa_libcamera_use_buffers(struct impl *this, struct spa_buffer **buff b->flags = BUFFER_FLAG_OUTSTANDING; b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h)); - spa_log_debug(this->log, "libcamera: import buffer %p", buffers[i]); + spa_log_debug(this->log, "import buffer %p", buffers[i]); if (buffers[i]->n_datas < 1) { - spa_log_error(this->log, "libcamera: invalid memory on buffer %p", buffers[i]); + spa_log_error(this->log, "invalid memory on buffer %p", buffers[i]); return -EINVAL; } @@ -718,23 +718,23 @@ static int spa_libcamera_use_buffers(struct impl *this, struct spa_buffer **buff } b->ptr = d[j].data; - spa_log_debug(this->log, "libcamera: In spa_libcamera_use_buffers(). mmap ptr:%p for fd = %ld buffer: #%d", + spa_log_debug(this->log, "In spa_libcamera_use_buffers(). mmap ptr:%p for fd = %ld buffer: #%d", d[j].data, d[j].fd, i); SPA_FLAG_SET(b->flags, BUFFER_FLAG_MAPPED); } else { b->ptr = d[j].data; - spa_log_debug(this->log, "libcamera: In spa_libcamera_use_buffers(). b->ptr = %p d[j].maxsize = %d for buffer: #%d", + spa_log_debug(this->log, "In spa_libcamera_use_buffers(). b->ptr = %p d[j].maxsize = %d for buffer: #%d", d[j].data, d[j].maxsize, i); } - spa_log_debug(this->log, "libcamera: In spa_libcamera_use_buffers(). setting b->ptr = %p for buffer: #%d on libcamera", + spa_log_debug(this->log, "In spa_libcamera_use_buffers(). setting b->ptr = %p for buffer: #%d on libcamera", b->ptr, i); } else if (port->memtype == SPA_DATA_DmaBuf) { d[j].fd = libcamera_get_fd(port->dev.camera, i, j); - spa_log_debug(this->log, "libcamera: Got fd = %ld for buffer: #%d", d[j].fd, i); + spa_log_debug(this->log, "Got fd = %ld for buffer: #%d", d[j].fd, i); } else { - spa_log_error(this->log, "libcamera: Exiting spa_libcamera_use_buffers() with -EIO"); + spa_log_error(this->log, "Exiting spa_libcamera_use_buffers() with -EIO"); return -EIO; } } @@ -754,7 +754,7 @@ mmap_init(struct impl *this, unsigned int i, j; struct spa_data *d; - spa_log_info(this->log, "libcamera: In mmap_init()"); + spa_log_info(this->log, "In mmap_init()"); if (n_buffers > 0) { d = buffers[0]->datas; @@ -780,7 +780,7 @@ mmap_init(struct impl *this, struct buffer *b; if (buffers[i]->n_datas < 1) { - spa_log_error(this->log, "libcamera: invalid buffer data"); + spa_log_error(this->log, "invalid buffer data"); return -EINVAL; } @@ -804,7 +804,7 @@ mmap_init(struct impl *this, if (port->memtype == SPA_DATA_DmaBuf || port->memtype == SPA_DATA_MemFd) { d[j].fd = libcamera_get_fd(port->dev.camera, i, j); - spa_log_info(this->log, "libcamera: Got fd = %ld for buffer: #%d", d[j].fd, i); + spa_log_info(this->log, "Got fd = %ld for buffer: #%d", d[j].fd, i); d[j].data = NULL; SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED); } @@ -821,9 +821,9 @@ mmap_init(struct impl *this, } b->ptr = d[j].data; SPA_FLAG_SET(b->flags, BUFFER_FLAG_MAPPED); - spa_log_info(this->log, "libcamera: mmap ptr:%p", d[j].data); + spa_log_info(this->log, "mmap ptr:%p", d[j].data); } else { - spa_log_error(this->log, "libcamera: invalid buffer type"); + spa_log_error(this->log, "invalid buffer type"); return -EIO; } } diff --git a/spa/plugins/libcamera/libcamera.c b/spa/plugins/libcamera/libcamera.c index 3be36fee3..89d25cad1 100644 --- a/spa/plugins/libcamera/libcamera.c +++ b/spa/plugins/libcamera/libcamera.c @@ -25,11 +25,15 @@ #include #include +#include extern const struct spa_handle_factory spa_libcamera_source_factory; extern const struct spa_handle_factory spa_libcamera_client_factory; extern const struct spa_handle_factory spa_libcamera_device_factory; +struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.libcamera"); +struct spa_log_topic *libcamera_log_topic = &log_topic; + SPA_EXPORT int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index) diff --git a/spa/plugins/libcamera/libcamera.h b/spa/plugins/libcamera/libcamera.h index ac6e3af33..a56b981bb 100644 --- a/spa/plugins/libcamera/libcamera.h +++ b/spa/plugins/libcamera/libcamera.h @@ -26,6 +26,17 @@ #include +#include + +#undef SPA_LOG_TOPIC_DEFAULT +#define SPA_LOG_TOPIC_DEFAULT libcamera_log_topic +extern struct spa_log_topic *libcamera_log_topic; + +static inline void libcamera_log_topic_init(struct spa_log *log) +{ + spa_log_topic_init(log, libcamera_log_topic); +} + #include "libcamera_wrapper.h" struct spa_libcamera_device {