mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
v4l2: use log topic
This commit is contained in:
parent
a95937dfdb
commit
865635ef10
4 changed files with 65 additions and 51 deletions
|
|
@ -49,8 +49,6 @@
|
||||||
|
|
||||||
#include "v4l2.h"
|
#include "v4l2.h"
|
||||||
|
|
||||||
#define NAME "v4l2-source"
|
|
||||||
|
|
||||||
static const char default_device[] = "/dev/video0";
|
static const char default_device[] = "/dev/video0";
|
||||||
|
|
||||||
struct props {
|
struct props {
|
||||||
|
|
@ -877,7 +875,7 @@ static int impl_node_process(void *object)
|
||||||
if (port->control)
|
if (port->control)
|
||||||
process_control(this, &port->control->sequence);
|
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)
|
if (io->status == SPA_STATUS_HAVE_DATA)
|
||||||
return SPA_STATUS_HAVE_DATA;
|
return SPA_STATUS_HAVE_DATA;
|
||||||
|
|
@ -896,7 +894,7 @@ static int impl_node_process(void *object)
|
||||||
spa_list_remove(&b->link);
|
spa_list_remove(&b->link);
|
||||||
SPA_FLAG_SET(b->flags, BUFFER_FLAG_OUTSTANDING);
|
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->buffer_id = b->id;
|
||||||
io->status = SPA_STATUS_HAVE_DATA;
|
io->status = SPA_STATUS_HAVE_DATA;
|
||||||
|
|
@ -973,8 +971,9 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
this = (struct impl *) handle;
|
this = (struct impl *) handle;
|
||||||
|
|
||||||
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
||||||
this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop);
|
v4l2_log_topic_init(this->log);
|
||||||
|
|
||||||
|
this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop);
|
||||||
if (this->data_loop == NULL) {
|
if (this->data_loop == NULL) {
|
||||||
spa_log_error(this->log, "a data_loop is needed");
|
spa_log_error(this->log, "a data_loop is needed");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
||||||
|
|
@ -53,36 +53,36 @@ int spa_v4l2_open(struct spa_v4l2_device *dev, const char *path)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
spa_log_error(dev->log, "v4l2: Device property not set");
|
spa_log_error(dev->log, "Device property not set");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_log_info(dev->log, "v4l2: Playback device is '%s'", path);
|
spa_log_info(dev->log, "Playback device is '%s'", path);
|
||||||
|
|
||||||
dev->fd = open(path, O_RDWR | O_NONBLOCK, 0);
|
dev->fd = open(path, O_RDWR | O_NONBLOCK, 0);
|
||||||
if (dev->fd == -1) {
|
if (dev->fd == -1) {
|
||||||
err = errno;
|
err = errno;
|
||||||
spa_log_error(dev->log, "v4l2: Cannot open '%s': %d, %s",
|
spa_log_error(dev->log, "Cannot open '%s': %d, %s",
|
||||||
path, err, strerror(err));
|
path, err, strerror(err));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstat(dev->fd, &st) < 0) {
|
if (fstat(dev->fd, &st) < 0) {
|
||||||
err = errno;
|
err = errno;
|
||||||
spa_log_error(dev->log, "v4l2: Cannot identify '%s': %d, %s",
|
spa_log_error(dev->log, "Cannot identify '%s': %d, %s",
|
||||||
path, err, strerror(err));
|
path, err, strerror(err));
|
||||||
goto error_close;
|
goto error_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!S_ISCHR(st.st_mode)) {
|
if (!S_ISCHR(st.st_mode)) {
|
||||||
spa_log_error(dev->log, "v4l2: %s is no device", path);
|
spa_log_error(dev->log, "%s is no device", path);
|
||||||
err = ENODEV;
|
err = ENODEV;
|
||||||
goto error_close;
|
goto error_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xioctl(dev->fd, VIDIOC_QUERYCAP, &dev->cap) < 0) {
|
if (xioctl(dev->fd, VIDIOC_QUERYCAP, &dev->cap) < 0) {
|
||||||
err = errno;
|
err = errno;
|
||||||
spa_log_error(dev->log, "v4l2: '%s' QUERYCAP: %m", path);
|
spa_log_error(dev->log, "'%s' QUERYCAP: %m", path);
|
||||||
goto error_close;
|
goto error_close;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -110,7 +110,7 @@ int spa_v4l2_close(struct spa_v4l2_device *dev)
|
||||||
if (dev->active || dev->have_format)
|
if (dev->active || dev->have_format)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
spa_log_info(dev->log, "v4l2: close");
|
spa_log_info(dev->log, "close");
|
||||||
|
|
||||||
if (close(dev->fd))
|
if (close(dev->fd))
|
||||||
spa_log_warn(dev->log, "close: %m");
|
spa_log_warn(dev->log, "close: %m");
|
||||||
|
|
@ -134,7 +134,7 @@ static int spa_v4l2_buffer_recycle(struct impl *this, uint32_t buffer_id)
|
||||||
|
|
||||||
if (xioctl(dev->fd, VIDIOC_QBUF, &b->v4l2_buffer) < 0) {
|
if (xioctl(dev->fd, VIDIOC_QBUF, &b->v4l2_buffer) < 0) {
|
||||||
err = errno;
|
err = errno;
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_QBUF: %m", this->props.device);
|
spa_log_error(this->log, "'%s' VIDIOC_QBUF: %m", this->props.device);
|
||||||
return -err;
|
return -err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,14 +158,14 @@ static int spa_v4l2_clear_buffers(struct impl *this)
|
||||||
d = b->outbuf->datas;
|
d = b->outbuf->datas;
|
||||||
|
|
||||||
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_OUTSTANDING)) {
|
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_OUTSTANDING)) {
|
||||||
spa_log_debug(this->log, "v4l2: queueing outstanding buffer %p", b);
|
spa_log_debug(this->log, "queueing outstanding buffer %p", b);
|
||||||
spa_v4l2_buffer_recycle(this, i);
|
spa_v4l2_buffer_recycle(this, i);
|
||||||
}
|
}
|
||||||
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_MAPPED)) {
|
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_MAPPED)) {
|
||||||
munmap(b->ptr, d[0].maxsize);
|
munmap(b->ptr, d[0].maxsize);
|
||||||
}
|
}
|
||||||
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_ALLOCATED)) {
|
if (SPA_FLAG_IS_SET(b->flags, BUFFER_FLAG_ALLOCATED)) {
|
||||||
spa_log_debug(this->log, "v4l2: close %d", (int) d[0].fd);
|
spa_log_debug(this->log, "close %d", (int) d[0].fd);
|
||||||
close(d[0].fd);
|
close(d[0].fd);
|
||||||
}
|
}
|
||||||
d[0].type = SPA_ID_INVALID;
|
d[0].type = SPA_ID_INVALID;
|
||||||
|
|
@ -590,12 +590,12 @@ spa_v4l2_enum_format(struct impl *this, int seq,
|
||||||
fmt.fmt.pix.height = 0;
|
fmt.fmt.pix.height = 0;
|
||||||
|
|
||||||
if ((res = xioctl(dev->fd, VIDIOC_TRY_FMT, &fmt)) < 0) {
|
if ((res = xioctl(dev->fd, VIDIOC_TRY_FMT, &fmt)) < 0) {
|
||||||
spa_log_debug(this->log, "v4l2: '%s' VIDIOC_TRY_FMT %08x: %m",
|
spa_log_debug(this->log, "'%s' VIDIOC_TRY_FMT %08x: %m",
|
||||||
this->props.device, info->fourcc);
|
this->props.device, info->fourcc);
|
||||||
goto next_fmtdesc;
|
goto next_fmtdesc;
|
||||||
}
|
}
|
||||||
if (fmt.fmt.pix.pixelformat != info->fourcc) {
|
if (fmt.fmt.pix.pixelformat != info->fourcc) {
|
||||||
spa_log_debug(this->log, "v4l2: '%s' VIDIOC_TRY_FMT wanted %.4s gave %.4s",
|
spa_log_debug(this->log, "'%s' VIDIOC_TRY_FMT wanted %.4s gave %.4s",
|
||||||
this->props.device, (char*)&info->fourcc,
|
this->props.device, (char*)&info->fourcc,
|
||||||
(char*)&fmt.fmt.pix.pixelformat);
|
(char*)&fmt.fmt.pix.pixelformat);
|
||||||
goto next_fmtdesc;
|
goto next_fmtdesc;
|
||||||
|
|
@ -607,7 +607,7 @@ spa_v4l2_enum_format(struct impl *this, int seq,
|
||||||
goto enum_end;
|
goto enum_end;
|
||||||
|
|
||||||
res = -errno;
|
res = -errno;
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_ENUM_FMT: %m",
|
spa_log_error(this->log, "'%s' VIDIOC_ENUM_FMT: %m",
|
||||||
this->props.device);
|
this->props.device);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
@ -653,7 +653,7 @@ spa_v4l2_enum_format(struct impl *this, int seq,
|
||||||
goto next_fmtdesc;
|
goto next_fmtdesc;
|
||||||
|
|
||||||
res = -errno;
|
res = -errno;
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_ENUM_FRAMESIZES: %m",
|
spa_log_error(this->log, "'%s' VIDIOC_ENUM_FRAMESIZES: %m",
|
||||||
this->props.device);
|
this->props.device);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
@ -746,7 +746,7 @@ spa_v4l2_enum_format(struct impl *this, int seq,
|
||||||
goto next_frmsize;
|
goto next_frmsize;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_ENUM_FRAMEINTERVALS: %m",
|
spa_log_error(this->log, "'%s' VIDIOC_ENUM_FRAMEINTERVALS: %m",
|
||||||
this->props.device);
|
this->props.device);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
@ -896,7 +896,7 @@ static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format,
|
||||||
info = find_format_info_by_media_type(format->media_type,
|
info = find_format_info_by_media_type(format->media_type,
|
||||||
format->media_subtype, video_format, 0);
|
format->media_subtype, video_format, 0);
|
||||||
if (info == NULL || size == NULL || framerate == NULL) {
|
if (info == NULL || size == NULL || framerate == NULL) {
|
||||||
spa_log_error(this->log, "v4l2: 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);
|
format->media_subtype, video_format);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -909,7 +909,7 @@ static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format,
|
||||||
streamparm.parm.capture.timeperframe.numerator = framerate->denom;
|
streamparm.parm.capture.timeperframe.numerator = framerate->denom;
|
||||||
streamparm.parm.capture.timeperframe.denominator = framerate->num;
|
streamparm.parm.capture.timeperframe.denominator = framerate->num;
|
||||||
|
|
||||||
spa_log_debug(this->log, "v4l2: set %.4s %dx%d %d/%d", (char *)&fmt.fmt.pix.pixelformat,
|
spa_log_debug(this->log, "set %.4s %dx%d %d/%d", (char *)&fmt.fmt.pix.pixelformat,
|
||||||
fmt.fmt.pix.width, fmt.fmt.pix.height,
|
fmt.fmt.pix.width, fmt.fmt.pix.height,
|
||||||
streamparm.parm.capture.timeperframe.denominator,
|
streamparm.parm.capture.timeperframe.denominator,
|
||||||
streamparm.parm.capture.timeperframe.numerator);
|
streamparm.parm.capture.timeperframe.numerator);
|
||||||
|
|
@ -922,7 +922,7 @@ static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format,
|
||||||
cmd = (flags & SPA_NODE_PARAM_FLAG_TEST_ONLY) ? VIDIOC_TRY_FMT : VIDIOC_S_FMT;
|
cmd = (flags & SPA_NODE_PARAM_FLAG_TEST_ONLY) ? VIDIOC_TRY_FMT : VIDIOC_S_FMT;
|
||||||
if (xioctl(dev->fd, cmd, &fmt) < 0) {
|
if (xioctl(dev->fd, cmd, &fmt) < 0) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_S_FMT: %m",
|
spa_log_error(this->log, "'%s' VIDIOC_S_FMT: %m",
|
||||||
this->props.device);
|
this->props.device);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -936,7 +936,7 @@ static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format,
|
||||||
reqfmt.fmt.pix.height == fmt.fmt.pix.height);
|
reqfmt.fmt.pix.height == fmt.fmt.pix.height);
|
||||||
|
|
||||||
if (!match && !SPA_FLAG_IS_SET(flags, SPA_NODE_PARAM_FLAG_NEAREST)) {
|
if (!match && !SPA_FLAG_IS_SET(flags, SPA_NODE_PARAM_FLAG_NEAREST)) {
|
||||||
spa_log_error(this->log, "v4l2: wanted %.4s %dx%d, got %.4s %dx%d",
|
spa_log_error(this->log, "wanted %.4s %dx%d, got %.4s %dx%d",
|
||||||
(char *)&reqfmt.fmt.pix.pixelformat,
|
(char *)&reqfmt.fmt.pix.pixelformat,
|
||||||
reqfmt.fmt.pix.width, reqfmt.fmt.pix.height,
|
reqfmt.fmt.pix.width, reqfmt.fmt.pix.height,
|
||||||
(char *)&fmt.fmt.pix.pixelformat,
|
(char *)&fmt.fmt.pix.pixelformat,
|
||||||
|
|
@ -947,7 +947,7 @@ static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format,
|
||||||
if (flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)
|
if (flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)
|
||||||
return match ? 0 : 1;
|
return match ? 0 : 1;
|
||||||
|
|
||||||
spa_log_info(this->log, "v4l2: '%s' got %.4s %dx%d %d/%d",
|
spa_log_info(this->log, "'%s' got %.4s %dx%d %d/%d",
|
||||||
this->props.device, (char *)&fmt.fmt.pix.pixelformat,
|
this->props.device, (char *)&fmt.fmt.pix.pixelformat,
|
||||||
fmt.fmt.pix.width, fmt.fmt.pix.height,
|
fmt.fmt.pix.width, fmt.fmt.pix.height,
|
||||||
streamparm.parm.capture.timeperframe.denominator,
|
streamparm.parm.capture.timeperframe.denominator,
|
||||||
|
|
@ -1094,7 +1094,7 @@ spa_v4l2_enum_controls(struct impl *this, int seq,
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
res = -errno;
|
res = -errno;
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_QUERYCTRL: %m", this->props.device);
|
spa_log_error(this->log, "'%s' VIDIOC_QUERYCTRL: %m", this->props.device);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
if (result.next & next_fl)
|
if (result.next & next_fl)
|
||||||
|
|
@ -1261,7 +1261,7 @@ static void v4l2_on_fd_events(struct spa_source *source)
|
||||||
|
|
||||||
if (source->rmask & SPA_IO_ERR) {
|
if (source->rmask & SPA_IO_ERR) {
|
||||||
struct port *port = &this->out_ports[0];
|
struct port *port = &this->out_ports[0];
|
||||||
spa_log_error(this->log, "v4l2: '%p' error %08x", this->props.device, source->rmask);
|
spa_log_error(this->log, "'%p' error %08x", this->props.device, source->rmask);
|
||||||
if (port->source.loop)
|
if (port->source.loop)
|
||||||
spa_loop_remove_source(this->data_loop, &port->source);
|
spa_loop_remove_source(this->data_loop, &port->source);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1311,7 +1311,7 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
|
||||||
} else if (d[0].type == SPA_DATA_DmaBuf) {
|
} else if (d[0].type == SPA_DATA_DmaBuf) {
|
||||||
port->memtype = V4L2_MEMORY_DMABUF;
|
port->memtype = V4L2_MEMORY_DMABUF;
|
||||||
} else {
|
} else {
|
||||||
spa_log_error(this->log, "v4l2: can't use buffers of type %d", d[0].type);
|
spa_log_error(this->log, "can't use buffers of type %d", d[0].type);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1322,12 +1322,12 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
|
||||||
reqbuf.count = n_buffers;
|
reqbuf.count = n_buffers;
|
||||||
|
|
||||||
if (xioctl(dev->fd, VIDIOC_REQBUFS, &reqbuf) < 0) {
|
if (xioctl(dev->fd, VIDIOC_REQBUFS, &reqbuf) < 0) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_REQBUFS %m", this->props.device);
|
spa_log_error(this->log, "'%s' VIDIOC_REQBUFS %m", this->props.device);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
spa_log_debug(this->log, "v4l2: got %d buffers", reqbuf.count);
|
spa_log_debug(this->log, "got %d buffers", reqbuf.count);
|
||||||
if (reqbuf.count < n_buffers) {
|
if (reqbuf.count < n_buffers) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' can't allocate enough buffers %d < %d",
|
spa_log_error(this->log, "'%s' can't allocate enough buffers %d < %d",
|
||||||
this->props.device, reqbuf.count, n_buffers);
|
this->props.device, reqbuf.count, n_buffers);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
@ -1341,10 +1341,10 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
|
||||||
b->flags = BUFFER_FLAG_OUTSTANDING;
|
b->flags = BUFFER_FLAG_OUTSTANDING;
|
||||||
b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h));
|
b->h = spa_buffer_find_meta_data(buffers[i], SPA_META_Header, sizeof(*b->h));
|
||||||
|
|
||||||
spa_log_debug(this->log, "v4l2: import buffer %p", buffers[i]);
|
spa_log_debug(this->log, "import buffer %p", buffers[i]);
|
||||||
|
|
||||||
if (buffers[i]->n_datas < 1) {
|
if (buffers[i]->n_datas < 1) {
|
||||||
spa_log_error(this->log, "v4l2: invalid memory on buffer %p", buffers[i]);
|
spa_log_error(this->log, "invalid memory on buffer %p", buffers[i]);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
d = buffers[i]->datas;
|
d = buffers[i]->datas;
|
||||||
|
|
@ -1379,7 +1379,7 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
|
||||||
b->v4l2_buffer.m.fd = d[0].fd;
|
b->v4l2_buffer.m.fd = d[0].fd;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
spa_log_error(this->log, "v4l2: invalid port memory %d",
|
spa_log_error(this->log, "invalid port memory %d",
|
||||||
port->memtype);
|
port->memtype);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
@ -1409,15 +1409,15 @@ mmap_init(struct impl *this,
|
||||||
reqbuf.count = n_buffers;
|
reqbuf.count = n_buffers;
|
||||||
|
|
||||||
if (xioctl(dev->fd, VIDIOC_REQBUFS, &reqbuf) < 0) {
|
if (xioctl(dev->fd, VIDIOC_REQBUFS, &reqbuf) < 0) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_REQBUFS: %m", this->props.device);
|
spa_log_error(this->log, "'%s' VIDIOC_REQBUFS: %m", this->props.device);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_log_debug(this->log, "v4l2: got %d buffers", reqbuf.count);
|
spa_log_debug(this->log, "got %d buffers", reqbuf.count);
|
||||||
n_buffers = reqbuf.count;
|
n_buffers = reqbuf.count;
|
||||||
|
|
||||||
if (n_buffers < 2) {
|
if (n_buffers < 2) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' can't allocate enough buffers (%d)",
|
spa_log_error(this->log, "'%s' can't allocate enough buffers (%d)",
|
||||||
this->props.device, n_buffers);
|
this->props.device, n_buffers);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
@ -1427,7 +1427,7 @@ mmap_init(struct impl *this,
|
||||||
struct spa_data *d;
|
struct spa_data *d;
|
||||||
|
|
||||||
if (buffers[i]->n_datas < 1) {
|
if (buffers[i]->n_datas < 1) {
|
||||||
spa_log_error(this->log, "v4l2: invalid buffer data");
|
spa_log_error(this->log, "invalid buffer data");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1443,13 +1443,13 @@ mmap_init(struct impl *this,
|
||||||
b->v4l2_buffer.index = i;
|
b->v4l2_buffer.index = i;
|
||||||
|
|
||||||
if (xioctl(dev->fd, VIDIOC_QUERYBUF, &b->v4l2_buffer) < 0) {
|
if (xioctl(dev->fd, VIDIOC_QUERYBUF, &b->v4l2_buffer) < 0) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_QUERYBUF: %m", this->props.device);
|
spa_log_error(this->log, "'%s' VIDIOC_QUERYBUF: %m", this->props.device);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b->v4l2_buffer.flags & V4L2_BUF_FLAG_QUEUED) {
|
if (b->v4l2_buffer.flags & V4L2_BUF_FLAG_QUEUED) {
|
||||||
/* some drivers can give us an already queued buffer. */
|
/* some drivers can give us an already queued buffer. */
|
||||||
spa_log_warn(this->log, "v4l2: buffer %d was already queued", i);
|
spa_log_warn(this->log, "buffer %d was already queued", i);
|
||||||
n_buffers = i;
|
n_buffers = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1462,7 +1462,7 @@ mmap_init(struct impl *this,
|
||||||
d[0].chunk->stride = port->fmt.fmt.pix.bytesperline;
|
d[0].chunk->stride = port->fmt.fmt.pix.bytesperline;
|
||||||
d[0].chunk->flags = 0;
|
d[0].chunk->flags = 0;
|
||||||
|
|
||||||
spa_log_debug(this->log, "v4l2: data types %08x", d[0].type);
|
spa_log_debug(this->log, "data types %08x", d[0].type);
|
||||||
|
|
||||||
if (port->have_expbuf &&
|
if (port->have_expbuf &&
|
||||||
d[0].type != SPA_ID_INVALID &&
|
d[0].type != SPA_ID_INVALID &&
|
||||||
|
|
@ -1475,12 +1475,12 @@ mmap_init(struct impl *this,
|
||||||
expbuf.flags = O_CLOEXEC | O_RDONLY;
|
expbuf.flags = O_CLOEXEC | O_RDONLY;
|
||||||
if (xioctl(dev->fd, VIDIOC_EXPBUF, &expbuf) < 0) {
|
if (xioctl(dev->fd, VIDIOC_EXPBUF, &expbuf) < 0) {
|
||||||
if (errno == ENOTTY || errno == EINVAL) {
|
if (errno == ENOTTY || errno == EINVAL) {
|
||||||
spa_log_debug(this->log, "v4l2: '%s' VIDIOC_EXPBUF not supported: %m",
|
spa_log_debug(this->log, "'%s' VIDIOC_EXPBUF not supported: %m",
|
||||||
this->props.device);
|
this->props.device);
|
||||||
port->have_expbuf = false;
|
port->have_expbuf = false;
|
||||||
goto fallback;
|
goto fallback;
|
||||||
}
|
}
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_EXPBUF: %m", this->props.device);
|
spa_log_error(this->log, "'%s' VIDIOC_EXPBUF: %m", this->props.device);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
if (d[0].type & (1u<<SPA_DATA_DmaBuf))
|
if (d[0].type & (1u<<SPA_DATA_DmaBuf))
|
||||||
|
|
@ -1491,7 +1491,7 @@ mmap_init(struct impl *this,
|
||||||
d[0].fd = expbuf.fd;
|
d[0].fd = expbuf.fd;
|
||||||
d[0].data = NULL;
|
d[0].data = NULL;
|
||||||
SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED);
|
SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED);
|
||||||
spa_log_debug(this->log, "v4l2: EXPBUF fd:%d", expbuf.fd);
|
spa_log_debug(this->log, "EXPBUF fd:%d", expbuf.fd);
|
||||||
use_expbuf = true;
|
use_expbuf = true;
|
||||||
} else if (d[0].type & (1u << SPA_DATA_MemPtr)) {
|
} else if (d[0].type & (1u << SPA_DATA_MemPtr)) {
|
||||||
fallback:
|
fallback:
|
||||||
|
|
@ -1505,20 +1505,20 @@ fallback:
|
||||||
dev->fd,
|
dev->fd,
|
||||||
b->v4l2_buffer.m.offset);
|
b->v4l2_buffer.m.offset);
|
||||||
if (d[0].data == MAP_FAILED) {
|
if (d[0].data == MAP_FAILED) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' mmap: %m", this->props.device);
|
spa_log_error(this->log, "'%s' mmap: %m", this->props.device);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
b->ptr = d[0].data;
|
b->ptr = d[0].data;
|
||||||
SPA_FLAG_SET(b->flags, BUFFER_FLAG_MAPPED);
|
SPA_FLAG_SET(b->flags, BUFFER_FLAG_MAPPED);
|
||||||
spa_log_debug(this->log, "v4l2: mmap offset:%u data:%p", d[0].mapoffset, b->ptr);
|
spa_log_debug(this->log, "mmap offset:%u data:%p", d[0].mapoffset, b->ptr);
|
||||||
use_expbuf = false;
|
use_expbuf = false;
|
||||||
} else {
|
} else {
|
||||||
spa_log_error(this->log, "v4l2: unsupported data type:%08x", d[0].type);
|
spa_log_error(this->log, "unsupported data type:%08x", d[0].type);
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
spa_v4l2_buffer_recycle(this, i);
|
spa_v4l2_buffer_recycle(this, i);
|
||||||
}
|
}
|
||||||
spa_log_info(this->log, "v4l2: have %u buffers using %s", n_buffers,
|
spa_log_info(this->log, "have %u buffers using %s", n_buffers,
|
||||||
use_expbuf ? "EXPBUF" : "MMAP");
|
use_expbuf ? "EXPBUF" : "MMAP");
|
||||||
|
|
||||||
port->n_buffers = n_buffers;
|
port->n_buffers = n_buffers;
|
||||||
|
|
@ -1556,7 +1556,7 @@ spa_v4l2_alloc_buffers(struct impl *this,
|
||||||
if ((res = read_init(this)) < 0)
|
if ((res = read_init(this)) < 0)
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
spa_log_error(this->log, "v4l2: invalid capabilities %08x",
|
spa_log_error(this->log, "invalid capabilities %08x",
|
||||||
dev->cap.capabilities);
|
dev->cap.capabilities);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
@ -1583,7 +1583,7 @@ static int spa_v4l2_stream_on(struct impl *this)
|
||||||
|
|
||||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
if (xioctl(dev->fd, VIDIOC_STREAMON, &type) < 0) {
|
if (xioctl(dev->fd, VIDIOC_STREAMON, &type) < 0) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_STREAMON: %m", this->props.device);
|
spa_log_error(this->log, "'%s' VIDIOC_STREAMON: %m", this->props.device);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1631,7 +1631,7 @@ static int spa_v4l2_stream_off(struct impl *this)
|
||||||
|
|
||||||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
if (xioctl(dev->fd, VIDIOC_STREAMOFF, &type) < 0) {
|
if (xioctl(dev->fd, VIDIOC_STREAMOFF, &type) < 0) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_STREAMOFF: %m", this->props.device);
|
spa_log_error(this->log, "'%s' VIDIOC_STREAMOFF: %m", this->props.device);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
for (i = 0; i < port->n_buffers; i++) {
|
for (i = 0; i < port->n_buffers; i++) {
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,15 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <spa/support/plugin.h>
|
#include <spa/support/plugin.h>
|
||||||
|
#include <spa/support/log.h>
|
||||||
|
|
||||||
extern const struct spa_handle_factory spa_v4l2_source_factory;
|
extern const struct spa_handle_factory spa_v4l2_source_factory;
|
||||||
extern const struct spa_handle_factory spa_v4l2_udev_factory;
|
extern const struct spa_handle_factory spa_v4l2_udev_factory;
|
||||||
extern const struct spa_handle_factory spa_v4l2_device_factory;
|
extern const struct spa_handle_factory spa_v4l2_device_factory;
|
||||||
|
|
||||||
|
struct spa_log_topic log_topic = SPA_LOG_TOPIC(0, "spa.v4l2");
|
||||||
|
struct spa_log_topic *v4l2_log_topic = &log_topic;
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
int spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
||||||
uint32_t *index)
|
uint32_t *index)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,17 @@
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <spa/support/log.h>
|
||||||
|
|
||||||
|
#undef SPA_LOG_TOPIC_DEFAULT
|
||||||
|
#define SPA_LOG_TOPIC_DEFAULT v4l2_log_topic
|
||||||
|
extern struct spa_log_topic *v4l2_log_topic;
|
||||||
|
|
||||||
|
static inline void v4l2_log_topic_init(struct spa_log *log)
|
||||||
|
{
|
||||||
|
spa_log_topic_init(log, v4l2_log_topic);
|
||||||
|
}
|
||||||
|
|
||||||
struct spa_v4l2_device {
|
struct spa_v4l2_device {
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue