[RFCv3 PATCH 22/33] vb2-core: refactor reqbufs/create_bufs.
From: Hans Verkuil Split off the memory and type validation. This is done both from reqbufs and create_bufs, and will also be done by vb2 helpers in a later patch. Signed-off-by: Hans Verkuil --- drivers/media/video/videobuf2-core.c | 145 ++ 1 file changed, 77 insertions(+), 68 deletions(-) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 9d4e9ed..7d7f86f 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -454,7 +454,50 @@ static int __verify_mmap_ops(struct vb2_queue *q) } /** - * vb2_reqbufs() - Initiate streaming + * __verify_memory_type() - Check whether the memory type and buffer type + * passed to a buffer operation are compatible with the queue. + */ +static int __verify_memory_type(struct vb2_queue *q, + enum v4l2_memory memory, enum v4l2_buf_type type) +{ + if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR) { + dprintk(1, "reqbufs: unsupported memory type\n"); + return -EINVAL; + } + + if (type != q->type) { + dprintk(1, "reqbufs: requested type is incorrect\n"); + return -EINVAL; + } + + /* +* Make sure all the required memory ops for given memory type +* are available. +*/ + if (memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { + dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); + return -EINVAL; + } + + if (memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { + dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); + return -EINVAL; + } + + /* +* Place the busy tests at the end: -EBUSY can be ignored when +* create_bufs is called with count == 0, but count == 0 should still +* do the memory and type validation. +*/ + if (q->fileio) { + dprintk(1, "reqbufs: file io in progress\n"); + return -EBUSY; + } + return 0; +} + +/** + * __reqbufs() - Initiate streaming * @q: videobuf2 queue * @req: struct passed from userspace to vidioc_reqbufs handler in driver * @@ -476,46 +519,16 @@ static int __verify_mmap_ops(struct vb2_queue *q) * The return values from this function are intended to be directly returned * from vidioc_reqbufs handler in driver. */ -int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) +static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) { unsigned int num_buffers, allocated_buffers, num_planes = 0; - int ret = 0; - - if (q->fileio) { - dprintk(1, "reqbufs: file io in progress\n"); - return -EBUSY; - } - - if (req->memory != V4L2_MEMORY_MMAP - && req->memory != V4L2_MEMORY_USERPTR) { - dprintk(1, "reqbufs: unsupported memory type\n"); - return -EINVAL; - } - - if (req->type != q->type) { - dprintk(1, "reqbufs: requested type is incorrect\n"); - return -EINVAL; - } + int ret; if (q->streaming) { dprintk(1, "reqbufs: streaming active\n"); return -EBUSY; } - /* -* Make sure all the required memory ops for given memory type -* are available. -*/ - if (req->memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { - dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); - return -EINVAL; - } - - if (req->memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { - dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); - return -EINVAL; - } - if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) { /* * We already have buffers allocated, so first check if they @@ -595,10 +608,23 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) return 0; } + +/** + * vb2_reqbufs() - Wrapper for __reqbufs() that also verifies the memory and + * type values. + * @q: videobuf2 queue + * @req: struct passed from userspace to vidioc_reqbufs handler in driver + */ +int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) +{ + int ret = __verify_memory_type(q, req->memory, req->type); + + return ret ? ret : __reqbufs(q, req); +} EXPORT_SYMBOL_GPL(vb2_reqbufs); /** - * vb2_create_bufs() - Allocate buffers and any required auxiliary structs + * __create_bufs() - Allocate buffers and any required auxiliary structs * @q: videobuf2 queue * @create:creation parameters, passed from userspace to vidioc_create_bufs * handler in driver @@ -612,40 +638,10 @@ EXPORT_SYMBOL_GPL(vb2_reqbufs); * The return v
[RFCv3 PATCH 31/33] v4l2-dev.c: also add debug support for the fops.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-dev.c | 25 - 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index b827781..d13c47f 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c @@ -305,6 +305,9 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf, ret = vdev->fops->read(filp, buf, sz, off); if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) mutex_unlock(vdev->lock); + if (vdev->debug) + printk(KERN_DEBUG "%s: read: %zd (%d)\n", + video_device_node_name(vdev), sz, ret); return ret; } @@ -323,6 +326,9 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf, ret = vdev->fops->write(filp, buf, sz, off); if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) mutex_unlock(vdev->lock); + if (vdev->debug) + printk(KERN_DEBUG "%s: write: %zd (%d)\n", + video_device_node_name(vdev), sz, ret); return ret; } @@ -339,6 +345,9 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll) ret = vdev->fops->poll(filp, poll); if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) mutex_unlock(vdev->lock); + if (vdev->debug) + printk(KERN_DEBUG "%s: poll: %08x\n", + video_device_node_name(vdev), ret); return ret; } @@ -403,12 +412,17 @@ static unsigned long v4l2_get_unmapped_area(struct file *filp, unsigned long flags) { struct video_device *vdev = video_devdata(filp); + int ret; if (!vdev->fops->get_unmapped_area) return -ENOSYS; if (!video_is_registered(vdev)) return -ENODEV; - return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); + ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); + if (vdev->debug) + printk(KERN_DEBUG "%s: get_unmapped_area (%d)\n", + video_device_node_name(vdev), ret); + return ret; } #endif @@ -426,6 +440,9 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm) ret = vdev->fops->mmap(filp, vm); if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) mutex_unlock(vdev->lock); + if (vdev->debug) + printk(KERN_DEBUG "%s: mmap (%d)\n", + video_device_node_name(vdev), ret); return ret; } @@ -464,6 +481,9 @@ err: /* decrease the refcount in case of an error */ if (ret) video_put(vdev); + if (vdev->debug) + printk(KERN_DEBUG "%s: open (%d)\n", + video_device_node_name(vdev), ret); return ret; } @@ -483,6 +503,9 @@ static int v4l2_release(struct inode *inode, struct file *filp) /* decrease the refcount unconditionally since the release() return value is ignored. */ video_put(vdev); + if (vdev->debug) + printk(KERN_DEBUG "%s: release\n", + video_device_node_name(vdev)); return ret; } -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 04/33] v4l2-ioctl.c: remove an unnecessary #ifdef.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c |2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 7a15f35..be89dad 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -506,10 +506,8 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_TRY_ENCODER_CMD, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), IOCTL_INFO(VIDIOC_DECODER_CMD, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_TRY_DECODER_CMD, 0), -#ifdef CONFIG_VIDEO_ADV_DEBUG IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0), IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0), -#endif IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0), IOCTL_INFO(VIDIOC_S_HW_FREQ_SEEK, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0), -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 11/33] v4l2-ioctl.c: use the new table for control ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 395 +++--- 1 file changed, 198 insertions(+), 197 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 1f75a6c..798ee42 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -512,6 +512,49 @@ static void v4l_print_streamparm(const void *arg, bool write_only) } } +static void v4l_print_queryctrl(const void *arg, bool write_only) +{ + const struct v4l2_queryctrl *p = arg; + + pr_cont("id=0x%x, type=%d, name=%s, min/max=%d/%d, " + "step=%d, default=%d, flags=0x%08x\n", + p->id, p->type, p->name, + p->minimum, p->maximum, + p->step, p->default_value, p->flags); +} + +static void v4l_print_querymenu(const void *arg, bool write_only) +{ + const struct v4l2_querymenu *p = arg; + + pr_cont("id=0x%x, index=%d\n", p->id, p->index); +} + +static void v4l_print_control(const void *arg, bool write_only) +{ + const struct v4l2_control *p = arg; + + pr_cont("id=0x%x, value=%d\n", p->id, p->value); +} + +static void v4l_print_ext_controls(const void *arg, bool write_only) +{ + const struct v4l2_ext_controls *p = arg; + int i; + + pr_cont("class=0x%x, count=%d, error_idx=%d", + p->ctrl_class, p->count, p->error_idx); + for (i = 0; i < p->count; i++) { + if (p->controls[i].size) + pr_cont(", id/val=0x%x/0x%x", + p->controls[i].id, p->controls[i].value); + else + pr_cont(", id/size=0x%x/%u", + p->controls[i].id, p->controls[i].size); + } + pr_cont("\n"); +} + static void v4l_print_u32(const void *arg, bool write_only) { pr_cont("value=%u\n", *(const u32 *)arg); @@ -552,27 +595,7 @@ static void dbgtimings(struct video_device *vfd, } } -static inline void v4l_print_ext_ctrls(unsigned int cmd, - struct video_device *vfd, struct v4l2_ext_controls *c, int show_vals) -{ - __u32 i; - - if (!(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) - return; - dbgarg(cmd, ""); - printk(KERN_CONT "class=0x%x", c->ctrl_class); - for (i = 0; i < c->count; i++) { - if (show_vals && !c->controls[i].size) - printk(KERN_CONT " id/val=0x%x/0x%x", - c->controls[i].id, c->controls[i].value); - else - printk(KERN_CONT " id=0x%x,size=%u", - c->controls[i].id, c->controls[i].size); - } - printk(KERN_CONT "\n"); -}; - -static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) +static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) { __u32 i; @@ -1213,6 +1236,153 @@ static int v4l_s_parm(const struct v4l2_ioctl_ops *ops, return ret ? ret : ops->vidioc_s_parm(file, fh, p); } +static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_queryctrl *p = arg; + struct v4l2_fh *vfh = fh; + + if (vfh && vfh->ctrl_handler) + return v4l2_queryctrl(vfh->ctrl_handler, p); + if (vfd->ctrl_handler) + return v4l2_queryctrl(vfd->ctrl_handler, p); + if (ops->vidioc_queryctrl) + return ops->vidioc_queryctrl(file, fh, p); + return -ENOTTY; +} + +static int v4l_querymenu(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_querymenu *p = arg; + struct v4l2_fh *vfh = fh; + + if (vfh && vfh->ctrl_handler) + return v4l2_querymenu(vfh->ctrl_handler, p); + if (vfd->ctrl_handler) + return v4l2_querymenu(vfd->ctrl_handler, p); + if (ops->vidioc_querymenu) + return ops->vidioc_querymenu(file, fh, p); + return -ENOTTY; +} + +static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_control *p = arg; + struct v4l2_fh *vfh = fh; + struct v4l2_ext_controls ctrls; + struct v4l2_ext_control ctrl; + + if (vfh && vfh->ctrl_handler) + return v4l2_g_ctrl(vfh->ctrl_handler, p); + if (vfd->ctrl_handler) + return v4l2_g_ctrl(vfd->ctrl_handler, p); + if (ops->vidioc_g_ctrl) + return ops->vidioc_g_ctrl(file, fh, p); + if (ops->vidioc_g_ext_ctrls == NULL) + return -EN
[RFCv3 PATCH 10/33] v4l2-ioctl.c: use the new table for queuing/parm ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 317 -- 1 file changed, 166 insertions(+), 151 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 4d2d0d6..1f75a6c 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -426,48 +426,97 @@ static void v4l_print_hw_freq_seek(const void *arg, bool write_only) p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing); } -static void v4l_print_u32(const void *arg, bool write_only) +static void v4l_print_requestbuffers(const void *arg, bool write_only) { - pr_cont("value=%u\n", *(const u32 *)arg); + const struct v4l2_requestbuffers *p = arg; + + pr_cont("count=%d, type=%s, memory=%s\n", + p->count, + prt_names(p->type, v4l2_type_names), + prt_names(p->memory, v4l2_memory_names)); } -static void dbgbuf(unsigned int cmd, struct video_device *vfd, - struct v4l2_buffer *p) +static void v4l_print_buffer(const void *arg, bool write_only) { - struct v4l2_timecode *tc = &p->timecode; - struct v4l2_plane *plane; + const struct v4l2_buffer *p = arg; + const struct v4l2_timecode *tc = &p->timecode; + const struct v4l2_plane *plane; int i; - dbgarg(cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, " - "flags=0x%08d, field=%0d, sequence=%d, memory=%s\n", + pr_cont("%02ld:%02d:%02d.%08ld index=%d, type=%s, " + "flags=0x%08x, field=%s, sequence=%d, memory=%s", p->timestamp.tv_sec / 3600, (int)(p->timestamp.tv_sec / 60) % 60, (int)(p->timestamp.tv_sec % 60), (long)p->timestamp.tv_usec, p->index, prt_names(p->type, v4l2_type_names), - p->flags, p->field, p->sequence, - prt_names(p->memory, v4l2_memory_names)); + p->flags, prt_names(p->field, v4l2_field_names), + p->sequence, prt_names(p->memory, v4l2_memory_names)); if (V4L2_TYPE_IS_MULTIPLANAR(p->type) && p->m.planes) { + pr_cont("\n"); for (i = 0; i < p->length; ++i) { plane = &p->m.planes[i]; - dbgarg2("plane %d: bytesused=%d, data_offset=0x%08x " - "offset/userptr=0x%08lx, length=%d\n", + printk(KERN_DEBUG + "plane %d: bytesused=%d, data_offset=0x%08x " + "offset/userptr=0x%lx, length=%d\n", i, plane->bytesused, plane->data_offset, plane->m.userptr, plane->length); } } else { - dbgarg2("bytesused=%d, offset/userptr=0x%08lx, length=%d\n", + pr_cont("bytesused=%d, offset/userptr=0x%lx, length=%d\n", p->bytesused, p->m.userptr, p->length); } - dbgarg2("timecode=%02d:%02d:%02d type=%d, " - "flags=0x%08d, frames=%d, userbits=0x%08x\n", + printk(KERN_DEBUG "timecode=%02d:%02d:%02d type=%d, " + "flags=0x%08x, frames=%d, userbits=0x%08x\n", tc->hours, tc->minutes, tc->seconds, tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); } +static void v4l_print_create_buffers(const void *arg, bool write_only) +{ + const struct v4l2_create_buffers *p = arg; + + pr_cont("index=%d, count=%d, memory=%s, ", + p->index, p->count, + prt_names(p->memory, v4l2_memory_names)); + v4l_print_format(&p->format, write_only); +} + +static void v4l_print_streamparm(const void *arg, bool write_only) +{ + const struct v4l2_streamparm *p = arg; + + pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); + + if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE || + p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + const struct v4l2_captureparm *c = &p->parm.capture; + + pr_cont(", capability=0x%x, capturemode=0x%x, timeperframe=%d/%d, " + "extendedmode=%d, readbuffers=%d\n", + c->capability, c->capturemode, + c->timeperframe.numerator, c->timeperframe.denominator, + c->extendedmode, c->readbuffers); + } else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT || + p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + const struct v4l2_outputparm *c = &p->parm.output; + + pr_cont(", capability=0x%x, outputmode=0x%x, timeperframe=%d/%d, " + "extendedmode=%d, writebuffers=%d\n", +
[RFCv3 PATCH 15/33] v4l2-ioctl.c: use the new table for preset/timings ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 207 -- 1 file changed, 67 insertions(+), 140 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index ee11e08..fdceac8 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -655,29 +655,35 @@ static void v4l_print_dbg_register(const void *arg, bool write_only) p->reg, p->val); } -static void v4l_print_u32(const void *arg, bool write_only) +static void v4l_print_dv_enum_presets(const void *arg, bool write_only) { - pr_cont("value=%u\n", *(const u32 *)arg); + const struct v4l2_dv_enum_preset *p = arg; + + pr_cont("index=%u, preset=%u, name=%s, width=%u, height=%u\n", + p->index, p->preset, p->name, p->width, p->height); } -static void v4l_print_newline(const void *arg, bool write_only) +static void v4l_print_dv_preset(const void *arg, bool write_only) { - pr_cont("\n"); + const struct v4l2_dv_preset *p = arg; + + pr_cont("preset=%u\n", p->preset); } -static void dbgtimings(struct video_device *vfd, - const struct v4l2_dv_timings *p) +static void v4l_print_dv_timings(const void *arg, bool write_only) { + const struct v4l2_dv_timings *p = arg; + switch (p->type) { case V4L2_DV_BT_656_1120: - dbgarg2("bt-656/1120:interlaced=%d," - " pixelclock=%lld," - " width=%d, height=%d, polarities=%x," - " hfrontporch=%d, hsync=%d," - " hbackporch=%d, vfrontporch=%d," - " vsync=%d, vbackporch=%d," - " il_vfrontporch=%d, il_vsync=%d," - " il_vbackporch=%d, standards=%x, flags=%x\n", + pr_cont("type=bt-656/1120, interlaced=%u, " + "pixelclock=%llu, " + "width=%u, height=%u, polarities=0x%x, " + "hfrontporch=%u, hsync=%u, " + "hbackporch=%u, vfrontporch=%u, " + "vsync=%u, vbackporch=%u, " + "il_vfrontporch=%u, il_vsync=%u, " + "il_vbackporch=%u, standards=0x%x, flags=0x%x\n", p->bt.interlaced, p->bt.pixelclock, p->bt.width, p->bt.height, p->bt.polarities, p->bt.hfrontporch, @@ -688,11 +694,48 @@ static void dbgtimings(struct video_device *vfd, p->bt.standards, p->bt.flags); break; default: - dbgarg2("Unknown type %d!\n", p->type); + pr_cont("type=%d\n", p->type); break; } } +static void v4l_print_enum_dv_timings(const void *arg, bool write_only) +{ + const struct v4l2_enum_dv_timings *p = arg; + + pr_cont("index=%u, ", p->index); + v4l_print_dv_timings(&p->timings, write_only); +} + +static void v4l_print_dv_timings_cap(const void *arg, bool write_only) +{ + const struct v4l2_dv_timings_cap *p = arg; + + switch (p->type) { + case V4L2_DV_BT_656_1120: + pr_cont("type=bt-656/1120, width=%u-%u, height=%u-%u, " + "pixelclock=%llu-%llu, standards=0x%x, capabilities=0x%x\n", + p->bt.min_width, p->bt.max_width, + p->bt.min_height, p->bt.max_height, + p->bt.min_pixelclock, p->bt.max_pixelclock, + p->bt.standards, p->bt.capabilities); + break; + default: + pr_cont("type=%u\n", p->type); + break; + } +} + +static void v4l_print_u32(const void *arg, bool write_only) +{ + pr_cont("value=%u\n", *(const u32 *)arg); +} + +static void v4l_print_newline(const void *arg, bool write_only) +{ + pr_cont("\n"); +} + static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) { __u32 i; @@ -1740,20 +1783,20 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO_FNC(VIDIOC_DBG_G_REGISTER, v4l_dbg_g_register, v4l_print_dbg_register, 0), IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_IDENT, v4l_dbg_g_chip_ident, v4l_print_dbg_chip_ident, 0), IOCTL_INFO_FNC(VIDIOC_S_HW_FREQ_SEEK, v4l_s_hw_freq_seek, v4l_print_hw_freq_seek, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0), - IOCTL_INFO(VIDIOC_S_DV_PRESET, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_DV_PRESET, 0), - IOCTL_INFO(VIDIOC_QUERY_DV_PRESET, 0), - IOCTL_INFO(VIDIOC_S_DV_TIMINGS, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_DV_TIMINGS, 0), + IOCTL_INFO_STD(VIDIOC_ENUM_DV_PRESETS, vidioc_enum_dv_presets, v4l_print_dv_enum_presets, 0), + IOCTL_INFO_STD(VIDIOC_S_DV_PRESE
[RFCv3 PATCH 23/33] vb2-core: add support for count == 0 in create_bufs.
From: Hans Verkuil This also fixes incorrect error handling in create_bufs: the return code of __vb2_queue_alloc is the number of allocated buffers, and not a traditional error code. Signed-off-by: Hans Verkuil --- drivers/media/video/videobuf2-core.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 7d7f86f..4461106 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -669,9 +669,9 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create /* Finally, allocate buffers and video memory */ ret = __vb2_queue_alloc(q, create->memory, num_buffers, num_planes); - if (ret < 0) { - dprintk(1, "Memory allocation failed with error: %d\n", ret); - return ret; + if (ret == 0) { + dprintk(1, "Memory allocation failed\n"); + return -ENOMEM; } allocated_buffers = ret; @@ -702,7 +702,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create if (ret < 0) { __vb2_queue_free(q, allocated_buffers); - return ret; + return -ENOMEM; } /* @@ -726,6 +726,8 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) int ret = __verify_memory_type(q, create->memory, create->format.type); create->index = q->num_buffers; + if (create->count == 0) + return ret != -EBUSY ? ret : 0; return ret ? ret : __create_bufs(q, create); } EXPORT_SYMBOL_GPL(vb2_create_bufs); -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 33/33] pwc: v4l2-compliance fixes.
From: Hans Verkuil - add device_caps - set colorspace - s_parm should support a fps of 0 (== reset to nominal fps) Signed-off-by: Hans Verkuil --- drivers/media/video/pwc/pwc-v4l.c | 25 - 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index 114ae41..545e9bb 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c @@ -405,6 +405,7 @@ static void pwc_vidioc_fill_fmt(struct v4l2_format *f, f->fmt.pix.pixelformat = pixfmt; f->fmt.pix.bytesperline = f->fmt.pix.width; f->fmt.pix.sizeimage= f->fmt.pix.height * f->fmt.pix.width * 3 / 2; + f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; PWC_DEBUG_IOCTL("pwc_vidioc_fill_fmt() " "width=%d, height=%d, bytesperline=%d, sizeimage=%d, pixelformat=%c%c%c%c\n", f->fmt.pix.width, @@ -497,10 +498,9 @@ static int pwc_querycap(struct file *file, void *fh, struct v4l2_capability *cap strcpy(cap->driver, PWC_NAME); strlcpy(cap->card, pdev->vdev.name, sizeof(cap->card)); usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info)); - cap->capabilities = - V4L2_CAP_VIDEO_CAPTURE | - V4L2_CAP_STREAMING | - V4L2_CAP_READWRITE; + cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | + V4L2_CAP_READWRITE; + cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; } @@ -509,7 +509,8 @@ static int pwc_enum_input(struct file *file, void *fh, struct v4l2_input *i) if (i->index) /* Only one INPUT is supported */ return -EINVAL; - strcpy(i->name, "usb"); + strlcpy(i->name, "Camera", sizeof(i->name)); + i->type = V4L2_INPUT_TYPE_CAMERA; return 0; } @@ -1003,12 +1004,18 @@ static int pwc_s_parm(struct file *file, void *fh, int compression = 0; int ret, fps; - if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || - parm->parm.capture.timeperframe.numerator == 0) + if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; - fps = parm->parm.capture.timeperframe.denominator / - parm->parm.capture.timeperframe.numerator; + /* If timeperframe == 0, then reset the framerate to the nominal value. + We pick a high framerate here, and let pwc_set_video_mode() figure + out the best match. */ + if (parm->parm.capture.timeperframe.numerator == 0 || + parm->parm.capture.timeperframe.denominator == 0) + fps = 30; + else + fps = parm->parm.capture.timeperframe.denominator / + parm->parm.capture.timeperframe.numerator; if (vb2_is_busy(&pdev->vb_queue)) return -EBUSY; -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 32/33] pwc: use the new vb2 helpers.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/pwc/pwc-if.c | 155 - drivers/media/video/pwc/pwc-v4l.c | 140 +++-- drivers/media/video/pwc/pwc.h |3 - 3 files changed, 24 insertions(+), 274 deletions(-) diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index ec4e2ef..b310c14 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c @@ -136,19 +136,13 @@ static int leds[2] = { 100, 0 }; /***/ -static int pwc_video_close(struct file *file); -static ssize_t pwc_video_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos); -static unsigned int pwc_video_poll(struct file *file, poll_table *wait); -static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); - static const struct v4l2_file_operations pwc_fops = { .owner =THIS_MODULE, .open = v4l2_fh_open, - .release = pwc_video_close, - .read = pwc_video_read, - .poll = pwc_video_poll, - .mmap = pwc_video_mmap, + .release = vb2_fop_release, + .read = vb2_fop_read, + .poll = vb2_fop_poll, + .mmap = vb2_fop_mmap, .unlocked_ioctl = video_ioctl2, }; static struct video_device pwc_template = { @@ -562,17 +556,6 @@ static const char *pwc_sensor_type_to_string(unsigned int sensor_type) /***/ /* Video4Linux functions */ -int pwc_test_n_set_capt_file(struct pwc_device *pdev, struct file *file) -{ - if (pdev->capt_file != NULL && - pdev->capt_file != file) - return -EBUSY; - - pdev->capt_file = file; - - return 0; -} - static void pwc_video_release(struct v4l2_device *v) { struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); @@ -583,113 +566,6 @@ static void pwc_video_release(struct v4l2_device *v) kfree(pdev); } -static int pwc_video_close(struct file *file) -{ - struct pwc_device *pdev = video_drvdata(file); - - /* -* If we're still streaming vb2_queue_release will call stream_stop -* so we must take both the v4l2_lock and the vb_queue_lock. -*/ - if (mutex_lock_interruptible(&pdev->v4l2_lock)) - return -ERESTARTSYS; - if (mutex_lock_interruptible(&pdev->vb_queue_lock)) { - mutex_unlock(&pdev->v4l2_lock); - return -ERESTARTSYS; - } - - if (pdev->capt_file == file) { - vb2_queue_release(&pdev->vb_queue); - pdev->capt_file = NULL; - } - - mutex_unlock(&pdev->vb_queue_lock); - mutex_unlock(&pdev->v4l2_lock); - - return v4l2_fh_release(file); -} - -static ssize_t pwc_video_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) -{ - struct pwc_device *pdev = video_drvdata(file); - int lock_v4l2 = 0; - ssize_t ret; - - if (mutex_lock_interruptible(&pdev->vb_queue_lock)) - return -ERESTARTSYS; - - ret = pwc_test_n_set_capt_file(pdev, file); - if (ret) - goto out; - - /* stream_start will get called so we must take the v4l2_lock */ - if (pdev->vb_queue.fileio == NULL) - lock_v4l2 = 1; - - /* Use try_lock, since we're taking the locks in the *wrong* order! */ - if (lock_v4l2 && !mutex_trylock(&pdev->v4l2_lock)) { - ret = -ERESTARTSYS; - goto out; - } - ret = vb2_read(&pdev->vb_queue, buf, count, ppos, - file->f_flags & O_NONBLOCK); - if (lock_v4l2) - mutex_unlock(&pdev->v4l2_lock); -out: - mutex_unlock(&pdev->vb_queue_lock); - return ret; -} - -static unsigned int pwc_video_poll(struct file *file, poll_table *wait) -{ - struct pwc_device *pdev = video_drvdata(file); - struct vb2_queue *q = &pdev->vb_queue; - unsigned long req_events = poll_requested_events(wait); - unsigned int ret = POLL_ERR; - int lock_v4l2 = 0; - - if (mutex_lock_interruptible(&pdev->vb_queue_lock)) - return POLL_ERR; - - /* Will this start fileio and thus call start_stream? */ - if ((req_events & (POLLIN | POLLRDNORM)) && - q->num_buffers == 0 && !q->streaming && q->fileio == NULL) { - if (pwc_test_n_set_capt_file(pdev, file)) - goto out; - lock_v4l2 = 1; - } - - /* Use try_lock, since we're taking the locks in the *wrong* order! */ - if (lock_v4l2 && !mutex_trylock(&pdev->v4l2_lock)) - goto out; - ret = vb2_poll(&pdev->vb_queue, file, wait); - if (lock_v4l2) - mutex_unlock(&pdev->v4l2_lock); - -out: - if (!pdev->udev)
[RFCv3 PATCH 21/33] cx18: don't mess with vfd->debug.
From: Hans Verkuil This is now controlled by sysfs. Signed-off-by: Hans Verkuil --- drivers/media/video/cx18/cx18-ioctl.c | 18 -- drivers/media/video/cx18/cx18-ioctl.h |2 -- drivers/media/video/cx18/cx18-streams.c |4 ++-- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c index 35fde4e..e9912db 100644 --- a/drivers/media/video/cx18/cx18-ioctl.c +++ b/drivers/media/video/cx18/cx18-ioctl.c @@ -1142,24 +1142,6 @@ static long cx18_default(struct file *file, void *fh, bool valid_prio, return 0; } -long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - struct video_device *vfd = video_devdata(filp); - struct cx18_open_id *id = file2id(filp); - struct cx18 *cx = id->cx; - long res; - - mutex_lock(&cx->serialize_lock); - - if (cx18_debug & CX18_DBGFLG_IOCTL) - vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; - res = video_ioctl2(filp, cmd, arg); - vfd->debug = 0; - mutex_unlock(&cx->serialize_lock); - return res; -} - static const struct v4l2_ioctl_ops cx18_ioctl_ops = { .vidioc_querycap= cx18_querycap, .vidioc_s_audio = cx18_s_audio, diff --git a/drivers/media/video/cx18/cx18-ioctl.h b/drivers/media/video/cx18/cx18-ioctl.h index dcb2559..2f9dd59 100644 --- a/drivers/media/video/cx18/cx18-ioctl.h +++ b/drivers/media/video/cx18/cx18-ioctl.h @@ -29,5 +29,3 @@ void cx18_set_funcs(struct video_device *vdev); int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std); int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); int cx18_s_input(struct file *file, void *fh, unsigned int inp); -long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg); diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index 4185bcb..9d598ab 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c @@ -40,8 +40,7 @@ static struct v4l2_file_operations cx18_v4l2_enc_fops = { .owner = THIS_MODULE, .read = cx18_v4l2_read, .open = cx18_v4l2_open, - /* FIXME change to video_ioctl2 if serialization lock can be removed */ - .unlocked_ioctl = cx18_v4l2_ioctl, + .unlocked_ioctl = video_ioctl2, .release = cx18_v4l2_close, .poll = cx18_v4l2_enc_poll, .mmap = cx18_v4l2_mmap, @@ -376,6 +375,7 @@ static int cx18_prep_dev(struct cx18 *cx, int type) s->video_dev->fops = &cx18_v4l2_enc_fops; s->video_dev->release = video_device_release; s->video_dev->tvnorms = V4L2_STD_ALL; + s->video_dev->lock = &cx->serialize_lock; set_bit(V4L2_FL_USE_FH_PRIO, &s->video_dev->flags); cx18_set_funcs(s->video_dev); return 0; -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 18/33] v4l2-dev.c: add debug sysfs entry.
From: Hans Verkuil Since this could theoretically change the debug value while in the middle of v4l2-ioctl.c, we make a copy of vfd->debug to ensure consistent debug behavior. Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-dev.c | 24 drivers/media/video/v4l2-ioctl.c |9 + 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 83dbb2d..c2122e5 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c @@ -46,6 +46,29 @@ static ssize_t show_index(struct device *cd, return sprintf(buf, "%i\n", vdev->index); } +static ssize_t show_debug(struct device *cd, +struct device_attribute *attr, char *buf) +{ + struct video_device *vdev = to_video_device(cd); + + return sprintf(buf, "%i\n", vdev->debug); +} + +static ssize_t set_debug(struct device *cd, struct device_attribute *attr, + const char *buf, size_t len) +{ + struct video_device *vdev = to_video_device(cd); + int res = 0; + u16 value; + + res = kstrtou16(buf, 0, &value); + if (res) + return res; + + vdev->debug = value; + return len; +} + static ssize_t show_name(struct device *cd, struct device_attribute *attr, char *buf) { @@ -56,6 +79,7 @@ static ssize_t show_name(struct device *cd, static struct device_attribute video_device_attrs[] = { __ATTR(name, S_IRUGO, show_name, NULL), + __ATTR(debug, 0644, show_debug, set_debug), __ATTR(index, S_IRUGO, show_index, NULL), __ATTR_NULL }; diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 9ded54b..273c6d7 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -1999,6 +1999,7 @@ static long __video_do_ioctl(struct file *file, void *fh = file->private_data; struct v4l2_fh *vfh = NULL; int use_fh_prio = 0; + int debug = vfd->debug; long ret = -ENOTTY; if (ops == NULL) { @@ -2032,7 +2033,7 @@ static long __video_do_ioctl(struct file *file, } write_only = _IOC_DIR(cmd) == _IOC_WRITE; - if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) { + if (write_only && debug > V4L2_DEBUG_IOCTL) { v4l_print_ioctl(vfd->name, cmd); pr_cont(": "); info->debug(arg, write_only); @@ -2054,8 +2055,8 @@ static long __video_do_ioctl(struct file *file, } done: - if (vfd->debug) { - if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) { + if (debug) { + if (write_only && debug > V4L2_DEBUG_IOCTL) { if (ret < 0) printk(KERN_DEBUG "%s: error %ld\n", video_device_node_name(vfd), ret); @@ -2064,7 +2065,7 @@ done: v4l_print_ioctl(vfd->name, cmd); if (ret < 0) pr_cont(": error %ld\n", ret); - else if (vfd->debug == V4L2_DEBUG_IOCTL) + else if (debug == V4L2_DEBUG_IOCTL) pr_cont("\n"); else if (_IOC_DIR(cmd) == _IOC_NONE) info->debug(arg, write_only); -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 09/33] v4l2-ioctl.c: use the new table for std/tuner/modulator ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 430 +++--- 1 file changed, 220 insertions(+), 210 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 78ff09f..4d2d0d6 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -364,6 +364,68 @@ static void v4l_print_buftype(const void *arg, bool write_only) pr_cont("type=%s\n", prt_names(*(u32 *)arg, v4l2_type_names)); } +static void v4l_print_modulator(const void *arg, bool write_only) +{ + const struct v4l2_modulator *p = arg; + + if (write_only) + pr_cont("index=%u, txsubchans=0x%x", p->index, p->txsubchans); + else + pr_cont("index=%u, name=%s, capability=0x%x, " + "rangelow=%u, rangehigh=%u, txsubchans=0x%x\n", + p->index, p->name, p->capability, + p->rangelow, p->rangehigh, p->txsubchans); +} + +static void v4l_print_tuner(const void *arg, bool write_only) +{ + const struct v4l2_tuner *p = arg; + + if (write_only) + pr_cont("index=%u, audmode=%u\n", p->index, p->audmode); + else + pr_cont("index=%u, name=%s, type=%u, capability=0x%x, " + "rangelow=%u, rangehigh=%u, signal=%u, afc=%d, " + "rxsubchans=0x%x, audmode=%u\n", + p->index, p->name, p->type, + p->capability, p->rangelow, + p->rangehigh, p->signal, p->afc, + p->rxsubchans, p->audmode); +} + +static void v4l_print_frequency(const void *arg, bool write_only) +{ + const struct v4l2_frequency *p = arg; + + pr_cont("tuner=%u, type=%u, frequency=%u\n", + p->tuner, p->type, p->frequency); +} + +static void v4l_print_standard(const void *arg, bool write_only) +{ + const struct v4l2_standard *p = arg; + + pr_cont("index=%u, id=0x%Lx, name=%s, fps=%u/%u, " + "framelines=%u\n", p->index, + (unsigned long long)p->id, p->name, + p->frameperiod.numerator, + p->frameperiod.denominator, + p->framelines); +} + +static void v4l_print_std(const void *arg, bool write_only) +{ + pr_cont("std=0x%08Lx\n", *(const long long unsigned *)arg); +} + +static void v4l_print_hw_freq_seek(const void *arg, bool write_only) +{ + const struct v4l2_hw_freq_seek *p = arg; + + pr_cont("tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u\n", + p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing); +} + static void v4l_print_u32(const void *arg, bool write_only) { pr_cont("value=%u\n", *(const u32 *)arg); @@ -861,6 +923,153 @@ static int v4l_streamoff(const struct v4l2_ioctl_ops *ops, return ops->vidioc_streamoff(file, fh, *(unsigned int *)arg); } +static int v4l_g_tuner(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_tuner *p = arg; + + p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + return ops->vidioc_g_tuner(file, fh, p); +} + +static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_tuner *p = arg; + + p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + return ops->vidioc_s_tuner(file, fh, p); +} + +static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_frequency *p = arg; + + p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + return ops->vidioc_g_frequency(file, fh, p); +} + +static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_frequency *p = arg; + enum v4l2_tuner_type type; + + type = (vfd->vfl_type == VFL_TYPE_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + if (p->type != type) + return -EINVAL; + return ops->vidioc_s_frequency(file, fh, p); +} + +static int v4l_enumstd(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + struct v4l2_standard *p = arg; + v4l2_std_id id = vfd->tvnorms,
[RFCv3 PATCH 00/33] Core and vb2 enhancements
Hi all, This is the third version of this patch series. The first version is here: http://www.mail-archive.com/linux-media@vger.kernel.org/msg47558.html Changes since RFCv2: - Rebased to staging/for_v3.6. - Incorporated Laurent's review comments in patch 22: vb2-core: refactor reqbufs/create_bufs. Changes since RFCv1: - Incorporated all review comments from Hans de Goede and Laurent Pinchart (Thanks!) except for splitting off the vb2 helper functions into a separate source. I decided to keep it together with the vb2-core code. - Improved commit messages, added more comments to the code. - The owner filehandle and the queue lock are both moved to struct vb2_queue since these are a property of the queue. - The debug function has a new 'write_only' boolean: some debug functions can only print a subset of the arguments if it is called by an _IOW ioctl. The previous patch series split this up into two functions. Handling the debug function for a write-only ioctl is annoying at the moment: you have to print the arguments before calling the ioctl since the ioctl can overwrite arguments. I am considering changing the op argument to const for such ioctls and see if any driver is actually messing around with the contents of such structs. If we can guarantee that drivers do not change the argument struct, then we can simplify the debug code. - All debugging is now KERN_DEBUG instead of KERN_INFO. I still have one outstanding question: should anyone be able to call mmap() or only the owner of the vb2 queue? Right now anyone can call mmap(). Comments are welcome, but if I don't see any in the next 2-3 days, then I'll make a pull request for this on Sunday. Regards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 25/33] v4l2-dev/ioctl.c: add vb2_queue support to video_device.
From: Hans Verkuil This prepares struct video_device for easier integration with vb2. It also introduces a new lock that protects the vb2_queue. It is up to the driver to use it or not. And the driver can associate an owner filehandle with the queue to check whether queuing requests are permitted for the calling filehandle. Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-dev.c | 16 +--- drivers/media/video/v4l2-ioctl.c | 31 +++ include/media/v4l2-dev.h |3 +++ include/media/v4l2-ioctl.h |5 + include/media/videobuf2-core.h | 13 + 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index c2122e5..b827781 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c @@ -348,20 +348,14 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) int ret = -ENODEV; if (vdev->fops->unlocked_ioctl) { - bool locked = false; + struct mutex *lock = v4l2_ioctl_get_lock(vdev, cmd); - if (vdev->lock) { - /* always lock unless the cmd is marked as "don't use lock" */ - locked = !v4l2_is_known_ioctl(cmd) || -!test_bit(_IOC_NR(cmd), vdev->disable_locking); - - if (locked && mutex_lock_interruptible(vdev->lock)) - return -ERESTARTSYS; - } + if (lock && mutex_lock_interruptible(lock)) + return -ERESTARTSYS; if (video_is_registered(vdev)) ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); - if (locked) - mutex_unlock(vdev->lock); + if (lock) + mutex_unlock(lock); } else if (vdev->fops->ioctl) { /* This code path is a replacement for the BKL. It is a major * hack but it will have to do for those drivers that are not diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index fd6436e..70e0efb 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -27,6 +27,7 @@ #include #include #include +#include /* Zero out the end of the struct pointed to by p. Everything after, but * not including, the specified field is cleared. */ @@ -1817,6 +1818,8 @@ struct v4l2_ioctl_info { #define INFO_FL_STD(1 << 2) /* This is ioctl has its own function */ #define INFO_FL_FUNC (1 << 3) +/* Queuing ioctl */ +#define INFO_FL_QUEUE (1 << 4) /* Zero struct from after the field to the end */ #define INFO_FL_CLEAR(v4l2_struct, field) \ ((offsetof(struct v4l2_struct, field) + \ @@ -1846,15 +1849,15 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO_FNC(VIDIOC_ENUM_FMT, v4l_enum_fmt, v4l_print_fmtdesc, INFO_FL_CLEAR(v4l2_fmtdesc, type)), IOCTL_INFO_FNC(VIDIOC_G_FMT, v4l_g_fmt, v4l_print_format, INFO_FL_CLEAR(v4l2_format, type)), IOCTL_INFO_FNC(VIDIOC_S_FMT, v4l_s_fmt, v4l_print_format, INFO_FL_PRIO), - IOCTL_INFO_FNC(VIDIOC_REQBUFS, v4l_reqbufs, v4l_print_requestbuffers, INFO_FL_PRIO), - IOCTL_INFO_FNC(VIDIOC_QUERYBUF, v4l_querybuf, v4l_print_buffer, INFO_FL_CLEAR(v4l2_buffer, length)), + IOCTL_INFO_FNC(VIDIOC_REQBUFS, v4l_reqbufs, v4l_print_requestbuffers, INFO_FL_PRIO | INFO_FL_QUEUE), + IOCTL_INFO_FNC(VIDIOC_QUERYBUF, v4l_querybuf, v4l_print_buffer, INFO_FL_QUEUE | INFO_FL_CLEAR(v4l2_buffer, length)), IOCTL_INFO_STD(VIDIOC_G_FBUF, vidioc_g_fbuf, v4l_print_framebuffer, 0), IOCTL_INFO_STD(VIDIOC_S_FBUF, vidioc_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO), IOCTL_INFO_STD(VIDIOC_OVERLAY, vidioc_overlay, v4l_print_u32, INFO_FL_PRIO), - IOCTL_INFO_FNC(VIDIOC_QBUF, v4l_qbuf, v4l_print_buffer, 0), - IOCTL_INFO_FNC(VIDIOC_DQBUF, v4l_dqbuf, v4l_print_buffer, 0), - IOCTL_INFO_FNC(VIDIOC_STREAMON, v4l_streamon, v4l_print_buftype, INFO_FL_PRIO), - IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO), + IOCTL_INFO_FNC(VIDIOC_QBUF, v4l_qbuf, v4l_print_buffer, INFO_FL_QUEUE), + IOCTL_INFO_FNC(VIDIOC_DQBUF, v4l_dqbuf, v4l_print_buffer, INFO_FL_QUEUE), + IOCTL_INFO_FNC(VIDIOC_STREAMON, v4l_streamon, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), + IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), IOCTL_INFO_FNC(VIDIOC_G_PARM, v4l_g_parm, v4l_print_streamparm, INFO_FL_CLEAR(v4l2_streamparm, type)), IOCTL_INFO_FNC(VIDIOC_S_PARM, v4l_s_parm, v4l_print_streamparm, INFO_FL_PRIO), IOCTL_INFO_FNC(VIDIOC_G_STD, v4l_g_std, v4l_print_std, 0), @@ -1918,8 +1921,8 @@ static struct v4l2_ioctl_info v4l2_ioctl
[RFCv3 PATCH 24/33] Spec: document CREATE_BUFS behavior if count == 0.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- Documentation/DocBook/media/v4l/vidioc-create-bufs.xml |8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml index a2474ec..5e73b1c 100644 --- a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml +++ b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml @@ -97,7 +97,13 @@ information. __u32 count - The number of buffers requested or granted. + The number of buffers requested or granted. If count == 0, then + VIDIOC_CREATE_BUFS will set index + to the current number of created buffers, and it will check the validity of + memory and format.type. + If those are invalid -1 is returned and errno is set to &EINVAL;, + otherwise VIDIOC_CREATE_BUFS returns 0. It will + never set errno to &EBUSY; in this particular case. __u32 -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 17/33] v4l2-ioctl.c: finalize table conversion.
From: Hans Verkuil Implement the default case which finalizes the table conversion and allows us to remove the last part of the switch. Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 35 +-- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 74fe6a2..9ded54b 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -855,6 +855,11 @@ static void v4l_print_newline(const void *arg, bool write_only) pr_cont("\n"); } +static void v4l_print_default(const void *arg, bool write_only) +{ + pr_cont("driver-specific ioctl\n"); +} + static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) { __u32 i; @@ -1839,12 +1844,6 @@ struct v4l2_ioctl_info { sizeof(((struct v4l2_struct *)0)->field)) << 16) #define INFO_FL_CLEAR_MASK (_IOC_SIZEMASK << 16) -#define IOCTL_INFO(_ioctl, _flags) [_IOC_NR(_ioctl)] = { \ - .ioctl = _ioctl,\ - .flags = _flags,\ - .name = #_ioctl,\ -} - #define IOCTL_INFO_STD(_ioctl, _vidioc, _debug, _flags) \ [_IOC_NR(_ioctl)] = { \ .ioctl = _ioctl,\ @@ -2028,12 +2027,12 @@ static long __video_do_ioctl(struct file *file, } else { default_info.ioctl = cmd; default_info.flags = 0; - default_info.debug = NULL; + default_info.debug = v4l_print_default; info = &default_info; } write_only = _IOC_DIR(cmd) == _IOC_WRITE; - if (info->debug && write_only && vfd->debug > V4L2_DEBUG_IOCTL) { + if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) { v4l_print_ioctl(vfd->name, cmd); pr_cont(": "); info->debug(arg, write_only); @@ -2044,22 +2043,16 @@ static long __video_do_ioctl(struct file *file, const vidioc_op *vidioc = p + info->offset; ret = (*vidioc)(file, fh, arg); - goto done; } else if (info->flags & INFO_FL_FUNC) { ret = info->func(ops, file, fh, arg); - goto done; + } else if (!ops->vidioc_default) { + ret = -ENOTTY; + } else { + ret = ops->vidioc_default(file, fh, + use_fh_prio ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0, + cmd, arg); } - switch (cmd) { - default: - if (!ops->vidioc_default) - break; - ret = ops->vidioc_default(file, fh, use_fh_prio ? - v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0, - cmd, arg); - break; - } /* switch */ - done: if (vfd->debug) { if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) { @@ -2073,8 +2066,6 @@ done: pr_cont(": error %ld\n", ret); else if (vfd->debug == V4L2_DEBUG_IOCTL) pr_cont("\n"); - else if (!info->debug) - return ret; else if (_IOC_DIR(cmd) == _IOC_NONE) info->debug(arg, write_only); else { -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 03/33] v4l2-ioctl.c: v4l2-ioctl: add debug and callback/offset functionality.
From: Hans Verkuil Add the necessary plumbing to make it possible to replace the switch by a table driven implementation. The ioctls ops can either be called directly, or by calling a small function that does some additional work if needed. Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 91 -- 1 file changed, 78 insertions(+), 13 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index e2f77bc..7a15f35 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -396,12 +396,22 @@ struct v4l2_ioctl_info { unsigned int ioctl; u32 flags; const char * const name; + union { + u32 offset; + int (*func)(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *p); + }; + void (*debug)(const void *arg, bool write_only); }; /* This control needs a priority check */ #define INFO_FL_PRIO (1 << 0) /* This control can be valid if the filehandle passes a control handler. */ #define INFO_FL_CTRL (1 << 1) +/* This is a standard ioctl, no need for special code */ +#define INFO_FL_STD(1 << 2) +/* This is ioctl has its own function */ +#define INFO_FL_FUNC (1 << 3) /* Zero struct from after the field to the end */ #define INFO_FL_CLEAR(v4l2_struct, field) \ ((offsetof(struct v4l2_struct, field) + \ @@ -414,6 +424,24 @@ struct v4l2_ioctl_info { .name = #_ioctl,\ } +#define IOCTL_INFO_STD(_ioctl, _vidioc, _debug, _flags) \ + [_IOC_NR(_ioctl)] = { \ + .ioctl = _ioctl,\ + .flags = _flags | INFO_FL_STD, \ + .name = #_ioctl,\ + .offset = offsetof(struct v4l2_ioctl_ops, _vidioc), \ + .debug = _debug,\ + } + +#define IOCTL_INFO_FNC(_ioctl, _func, _debug, _flags) \ + [_IOC_NR(_ioctl)] = { \ + .ioctl = _ioctl,\ + .flags = _flags | INFO_FL_FUNC, \ + .name = #_ioctl,\ + .func = _func, \ + .debug = _debug,\ + } + static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_QUERYCAP, 0), IOCTL_INFO(VIDIOC_ENUM_FMT, INFO_FL_CLEAR(v4l2_fmtdesc, type)), @@ -512,7 +540,7 @@ bool v4l2_is_known_ioctl(unsigned int cmd) external ioctl messages as well as internal V4L ioctl */ void v4l_printk_ioctl(unsigned int cmd) { - char *dir, *type; + const char *dir, *type; switch (_IOC_TYPE(cmd)) { case 'd': @@ -523,10 +551,11 @@ void v4l_printk_ioctl(unsigned int cmd) type = "v4l2"; break; } - printk("%s", v4l2_ioctls[_IOC_NR(cmd)].name); + pr_cont("%s", v4l2_ioctls[_IOC_NR(cmd)].name); return; default: type = "unknown"; + break; } switch (_IOC_DIR(cmd)) { @@ -536,7 +565,7 @@ void v4l_printk_ioctl(unsigned int cmd) case _IOC_READ | _IOC_WRITE: dir = "rw"; break; default: dir = "*ERR*"; break; } - printk("%s ioctl '%c', dir=%s, #%d (0x%08x)", + pr_cont("%s ioctl '%c', dir=%s, #%d (0x%08x)", type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); } EXPORT_SYMBOL(v4l_printk_ioctl); @@ -546,6 +575,9 @@ static long __video_do_ioctl(struct file *file, { struct video_device *vfd = video_devdata(file); const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; + bool write_only = false; + struct v4l2_ioctl_info default_info; + const struct v4l2_ioctl_info *info; void *fh = file->private_data; struct v4l2_fh *vfh = NULL; int use_fh_prio = 0; @@ -563,23 +595,40 @@ static long __video_do_ioctl(struct file *file, } if (v4l2_is_known_ioctl(cmd)) { - struct v4l2_ioctl_info *info = &v4l2_ioctls[_IOC_NR(cmd)]; + info = &v4l2_ioctls[_IOC_NR(cmd)]; if (!test_bit(_IOC_NR(cmd), vfd->valid_ioctls) && !((info->flags & INFO_FL_CTRL) && vfh && vfh->ctrl_handler)) - return -ENOTTY; + goto done; if (use_fh_prio && (info->flags & INFO_FL_PRIO)) { ret = v4l2_prio_check(vfd->prio, vfh->prio); if
[RFCv3 PATCH 14/33] v4l2-ioctl.c: use the new table for debug ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 139 -- 1 file changed, 89 insertions(+), 50 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 935fcbc..ee11e08 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -629,11 +629,42 @@ static void v4l_print_decoder_cmd(const void *arg, bool write_only) pr_info("pts=%llu\n", p->stop.pts); } +static void v4l_print_dbg_chip_ident(const void *arg, bool write_only) +{ + const struct v4l2_dbg_chip_ident *p = arg; + + pr_cont("type=%u, ", p->match.type); + if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) + pr_cont("name=%s, ", p->match.name); + else + pr_cont("addr=%u, ", p->match.addr); + pr_cont("chip_ident=%u, revision=0x%x\n", + p->ident, p->revision); +} + +static void v4l_print_dbg_register(const void *arg, bool write_only) +{ + const struct v4l2_dbg_register *p = arg; + + pr_cont("type=%u, ", p->match.type); + if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) + pr_cont("name=%s, ", p->match.name); + else + pr_cont("addr=%u, ", p->match.addr); + pr_cont("reg=0x%llx, val=0x%llx\n", + p->reg, p->val); +} + static void v4l_print_u32(const void *arg, bool write_only) { pr_cont("value=%u\n", *(const u32 *)arg); } +static void v4l_print_newline(const void *arg, bool write_only) +{ + pr_cont("\n"); +} + static void dbgtimings(struct video_device *vfd, const struct v4l2_dv_timings *p) { @@ -1537,6 +1568,60 @@ static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, return 0; } +static int v4l_log_status(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd = video_devdata(file); + int ret; + + if (vfd->v4l2_dev) + pr_info("%s: = START STATUS =\n", + vfd->v4l2_dev->name); + ret = ops->vidioc_log_status(file, fh); + if (vfd->v4l2_dev) + pr_info("%s: == END STATUS ==\n", + vfd->v4l2_dev->name); + return ret; +} + +static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ +#ifdef CONFIG_VIDEO_ADV_DEBUG + struct v4l2_dbg_register *p = arg; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + return ops->vidioc_g_register(file, fh, p); +#else + return -ENOTTY; +#endif +} + +static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ +#ifdef CONFIG_VIDEO_ADV_DEBUG + struct v4l2_dbg_register *p = arg; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + return ops->vidioc_s_register(file, fh, p); +#else + return -ENOTTY; +#endif +} + +static int v4l_dbg_g_chip_ident(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_dbg_chip_ident *p = arg; + + p->ident = V4L2_IDENT_NONE; + p->revision = 0; + return ops->vidioc_g_chip_ident(file, fh, p); +} + struct v4l2_ioctl_info { unsigned int ioctl; u32 flags; @@ -1640,7 +1725,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO_FNC(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0), IOCTL_INFO_FNC(VIDIOC_S_PRIORITY, v4l_s_priority, v4l_print_u32, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)), - IOCTL_INFO(VIDIOC_LOG_STATUS, 0), + IOCTL_INFO_FNC(VIDIOC_LOG_STATUS, v4l_log_status, v4l_print_newline, 0), IOCTL_INFO_FNC(VIDIOC_G_EXT_CTRLS, v4l_g_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL), IOCTL_INFO_FNC(VIDIOC_S_EXT_CTRLS, v4l_s_ext_ctrls, v4l_print_ext_controls, INFO_FL_PRIO | INFO_FL_CTRL), IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, 0), @@ -1651,9 +1736,9 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO_STD(VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), IOCTL_INFO_STD(VIDIOC_DECODER_CMD, vidioc_decoder_cmd, v4l_print_decoder_cmd, INFO_FL_PRIO), IOCTL_INFO_STD(VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd, v4l_print_decoder_cmd, 0), - IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0), - IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0), - IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0), + IOCTL_INFO_FNC(VIDIOC_DBG_S_REGISTER, v4l_dbg_s_register, v4l_print_dbg_register, 0), + IOCTL_INFO_FNC
[RFCv3 PATCH 20/33] ivtv: don't mess with vfd->debug.
From: Hans Verkuil This is now controlled by sysfs. Signed-off-by: Hans Verkuil --- drivers/media/video/ivtv/ivtv-ioctl.c | 12 drivers/media/video/ivtv/ivtv-ioctl.h |1 - drivers/media/video/ivtv/ivtv-streams.c |4 ++-- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index f7d57b3..32a5910 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c @@ -1830,18 +1830,6 @@ static long ivtv_default(struct file *file, void *fh, bool valid_prio, return 0; } -long ivtv_v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - struct video_device *vfd = video_devdata(filp); - long ret; - - if (ivtv_debug & IVTV_DBGFLG_IOCTL) - vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; - ret = video_ioctl2(filp, cmd, arg); - vfd->debug = 0; - return ret; -} - static const struct v4l2_ioctl_ops ivtv_ioctl_ops = { .vidioc_querycap= ivtv_querycap, .vidioc_s_audio = ivtv_s_audio, diff --git a/drivers/media/video/ivtv/ivtv-ioctl.h b/drivers/media/video/ivtv/ivtv-ioctl.h index 89185ca..7c553d1 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.h +++ b/drivers/media/video/ivtv/ivtv-ioctl.h @@ -31,6 +31,5 @@ void ivtv_s_std_enc(struct ivtv *itv, v4l2_std_id *std); void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id *std); int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); int ivtv_s_input(struct file *file, void *fh, unsigned int inp); -long ivtv_v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); #endif diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index 6738592..87990c5 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c @@ -50,7 +50,7 @@ static const struct v4l2_file_operations ivtv_v4l2_enc_fops = { .read = ivtv_v4l2_read, .write = ivtv_v4l2_write, .open = ivtv_v4l2_open, - .unlocked_ioctl = ivtv_v4l2_ioctl, + .unlocked_ioctl = video_ioctl2, .release = ivtv_v4l2_close, .poll = ivtv_v4l2_enc_poll, }; @@ -60,7 +60,7 @@ static const struct v4l2_file_operations ivtv_v4l2_dec_fops = { .read = ivtv_v4l2_read, .write = ivtv_v4l2_write, .open = ivtv_v4l2_open, - .unlocked_ioctl = ivtv_v4l2_ioctl, + .unlocked_ioctl = video_ioctl2, .release = ivtv_v4l2_close, .poll = ivtv_v4l2_dec_poll, }; -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 26/33] videobuf2-core: add helper functions.
From: Hans Verkuil Add helper functions to make it easier to adapt drivers to vb2. These helpers take care of core locking and check if the filehandle is the owner of the queue. Signed-off-by: Hans Verkuil --- drivers/media/video/videobuf2-core.c | 227 ++ include/media/videobuf2-core.h | 32 + 2 files changed, 259 insertions(+) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 4461106..04c19e6 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -2126,6 +2126,233 @@ size_t vb2_write(struct vb2_queue *q, char __user *data, size_t count, } EXPORT_SYMBOL_GPL(vb2_write); + +/* + * The following functions are not part of the vb2 core API, but are helper + * functions that plug into struct v4l2_ioctl_ops and struct v4l2_file_operations. + * They contain boilerplate code that most if not all drivers have to do + * and so they simplify the driver code. + */ + +/* The queue is busy if there is a owner and you are not that owner. */ +static inline bool vb2_queue_is_busy(struct video_device *vdev, struct file *file) +{ + return vdev->queue->owner && vdev->queue->owner != file->private_data; +} + +int vb2_ioctl_reqbufs(struct file *file, void *priv, + struct v4l2_requestbuffers *p) +{ + struct video_device *vdev = video_devdata(file); + int res = __verify_memory_type(vdev->queue, p->memory, p->type); + + if (res) + return res; + if (vb2_queue_is_busy(vdev, file)) + return -EBUSY; + res = __reqbufs(vdev->queue, p); + /* If count == 0, then the owner has released all buffers and he + is no longer owner of the queue. Otherwise we have a new owner. */ + if (res == 0) + vdev->queue->owner = p->count ? file->private_data : NULL; + return res; +} +EXPORT_SYMBOL_GPL(vb2_ioctl_reqbufs); + +int vb2_ioctl_create_bufs(struct file *file, void *priv, + struct v4l2_create_buffers *p) +{ + struct video_device *vdev = video_devdata(file); + int res = __verify_memory_type(vdev->queue, p->memory, p->format.type); + + p->index = vdev->queue->num_buffers; + /* If count == 0, then just check if memory and type are valid. + Any -EBUSY result from __verify_memory_type can be mapped to 0. */ + if (p->count == 0) + return res != -EBUSY ? res : 0; + if (res) + return res; + if (vb2_queue_is_busy(vdev, file)) + return -EBUSY; + res = __create_bufs(vdev->queue, p); + if (res == 0) + vdev->queue->owner = file->private_data; + return res; +} +EXPORT_SYMBOL_GPL(vb2_ioctl_create_bufs); + +int vb2_ioctl_prepare_buf(struct file *file, void *priv, + struct v4l2_buffer *p) +{ + struct video_device *vdev = video_devdata(file); + + if (vb2_queue_is_busy(vdev, file)) + return -EBUSY; + return vb2_prepare_buf(vdev->queue, p); +} +EXPORT_SYMBOL_GPL(vb2_ioctl_prepare_buf); + +int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) +{ + struct video_device *vdev = video_devdata(file); + + /* No need to call vb2_queue_is_busy(), anyone can query buffers. */ + return vb2_querybuf(vdev->queue, p); +} +EXPORT_SYMBOL_GPL(vb2_ioctl_querybuf); + +int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) +{ + struct video_device *vdev = video_devdata(file); + + if (vb2_queue_is_busy(vdev, file)) + return -EBUSY; + return vb2_qbuf(vdev->queue, p); +} +EXPORT_SYMBOL_GPL(vb2_ioctl_qbuf); + +int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) +{ + struct video_device *vdev = video_devdata(file); + + if (vb2_queue_is_busy(vdev, file)) + return -EBUSY; + return vb2_dqbuf(vdev->queue, p, file->f_flags & O_NONBLOCK); +} +EXPORT_SYMBOL_GPL(vb2_ioctl_dqbuf); + +int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i) +{ + struct video_device *vdev = video_devdata(file); + + if (vb2_queue_is_busy(vdev, file)) + return -EBUSY; + return vb2_streamon(vdev->queue, i); +} +EXPORT_SYMBOL_GPL(vb2_ioctl_streamon); + +int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) +{ + struct video_device *vdev = video_devdata(file); + + if (vb2_queue_is_busy(vdev, file)) + return -EBUSY; + return vb2_streamoff(vdev->queue, i); +} +EXPORT_SYMBOL_GPL(vb2_ioctl_streamoff); + +int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma) +{ + struct video_device *vdev = video_devdata(file); + + return vb2_mmap(vdev->queue, vma); +} +EXPORT_SYMBOL_GPL(vb2_fop_mmap); + +int vb2_fop_release(struct file *file) +{ + struct video_device *vdev = video_devdata(file); + +
[RFCv3 PATCH 30/33] vivi: add create_bufs/preparebuf support.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/vivi.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index f6d7c6e..1e8c4f3 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c @@ -767,7 +767,13 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, struct vivi_dev *dev = vb2_get_drv_priv(vq); unsigned long size; - size = dev->width * dev->height * dev->pixelsize; + if (fmt) + size = fmt->fmt.pix.sizeimage; + else + size = dev->width * dev->height * dev->pixelsize; + + if (size == 0) + return -EINVAL; if (0 == *nbuffers) *nbuffers = 32; @@ -1180,6 +1186,8 @@ static const struct v4l2_ioctl_ops vivi_ioctl_ops = { .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_prepare_buf = vb2_ioctl_prepare_buf, .vidioc_querybuf = vb2_ioctl_querybuf, .vidioc_qbuf = vb2_ioctl_qbuf, .vidioc_dqbuf = vb2_ioctl_dqbuf, -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 19/33] v4l2-ioctl: remove v4l_(i2c_)print_ioctl
From: Hans Verkuil v4l_i2c_print_ioctl wasn't used and v4l_print_ioctl could be replaced by v4l_printk_ioctl. Signed-off-by: Hans Verkuil --- drivers/media/video/pvrusb2/pvrusb2-v4l2.c |4 ++-- drivers/media/video/sn9c102/sn9c102.h |2 +- drivers/media/video/uvc/uvc_v4l2.c |2 +- drivers/media/video/v4l2-ioctl.c | 34 +++- include/media/v4l2-ioctl.h | 20 +++- 5 files changed, 15 insertions(+), 47 deletions(-) diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index cbe4080..f344aed 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c @@ -957,7 +957,7 @@ static long pvr2_v4l2_ioctl(struct file *file, long ret = -EINVAL; if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) - v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw), cmd); + v4l_printk_ioctl(pvr2_hdw_get_driver_name(hdw), cmd); if (!pvr2_hdw_dev_ok(hdw)) { pvr2_trace(PVR2_TRACE_ERROR_LEGS, @@ -990,7 +990,7 @@ static long pvr2_v4l2_ioctl(struct file *file, pvr2_trace(PVR2_TRACE_V4LIOCTL, "pvr2_v4l2_do_ioctl failure, ret=%ld" " command was:", ret); - v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw), + v4l_printk_ioctl(pvr2_hdw_get_driver_name(hdw), cmd); } } diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h index 22ea211..2bc153e 100644 --- a/drivers/media/video/sn9c102/sn9c102.h +++ b/drivers/media/video/sn9c102/sn9c102.h @@ -182,7 +182,7 @@ do { \ # define V4LDBG(level, name, cmd) \ do { \ if (debug >= (level)) \ - v4l_print_ioctl(name, cmd); \ + v4l_printk_ioctl(name, cmd); \ } while (0) # define KDBG(level, fmt, args...) \ do { \ diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c index 759bef8..f00db30 100644 --- a/drivers/media/video/uvc/uvc_v4l2.c +++ b/drivers/media/video/uvc/uvc_v4l2.c @@ -1051,7 +1051,7 @@ static long uvc_v4l2_ioctl(struct file *file, { if (uvc_trace_param & UVC_TRACE_IOCTL) { uvc_printk(KERN_DEBUG, "uvc_v4l2_ioctl("); - v4l_printk_ioctl(cmd); + v4l_printk_ioctl(NULL, cmd); printk(")\n"); } diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 273c6d7..fd6436e 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -28,27 +28,6 @@ #include #include -#define dbgarg(cmd, fmt, arg...) \ - do {\ - if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {\ - printk(KERN_DEBUG "%s: ", vfd->name); \ - v4l_printk_ioctl(cmd); \ - printk(" " fmt, ## arg); \ - } \ - } while (0) - -#define dbgarg2(fmt, arg...) \ - do {\ - if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ - printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\ - } while (0) - -#define dbgarg3(fmt, arg...) \ - do {\ - if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ - printk(KERN_CONT "%s: " fmt, vfd->name, ## arg);\ - } while (0) - /* Zero out the end of the struct pointed to by p. Everything after, but * not including, the specified field is cleared. */ #define CLEAR_AFTER_FIELD(p, field) \ @@ -1956,10 +1935,13 @@ bool v4l2_is_known_ioctl(unsigned int cmd) /* Common ioctl debug function. This function can be used by external ioctl messages as well as internal V4L ioctl */ -void v4l_printk_ioctl(unsigned int cmd) +void v4l_printk_ioctl(const char *prefix, unsigned int cmd) { const char *dir, *type; + if (prefix) + printk(KERN_DEBUG "%s: ", prefix); + switch (_IOC_TYPE(cmd)) { case 'd': type = "
[RFCv3 PATCH 28/33] vivi: embed struct video_device instead of allocating it.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/vivi.c | 24 +++- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index e00efcf..1e4da5e 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c @@ -188,6 +188,7 @@ struct vivi_dev { struct list_head vivi_devlist; struct v4l2_device v4l2_dev; struct v4l2_ctrl_handler ctrl_handler; + struct video_devicevdev; /* controls */ struct v4l2_ctrl *brightness; @@ -213,9 +214,6 @@ struct vivi_dev { spinlock_t slock; struct mutex mutex; - /* various device info */ - struct video_device*vfd; - struct vivi_dmaqueue vidq; /* Several counters */ @@ -1326,7 +1324,7 @@ static struct video_device vivi_template = { .name = "vivi", .fops = &vivi_fops, .ioctl_ops = &vivi_ioctl_ops, - .release= video_device_release, + .release= video_device_release_empty, }; /* - @@ -1344,8 +1342,8 @@ static int vivi_release(void) dev = list_entry(list, struct vivi_dev, vivi_devlist); v4l2_info(&dev->v4l2_dev, "unregistering %s\n", - video_device_node_name(dev->vfd)); - video_unregister_device(dev->vfd); + video_device_node_name(&dev->vdev)); + video_unregister_device(&dev->vdev); v4l2_device_unregister(&dev->v4l2_dev); v4l2_ctrl_handler_free(&dev->ctrl_handler); kfree(dev); @@ -1430,11 +1428,7 @@ static int __init vivi_create_instance(int inst) INIT_LIST_HEAD(&dev->vidq.active); init_waitqueue_head(&dev->vidq.wq); - ret = -ENOMEM; - vfd = video_device_alloc(); - if (!vfd) - goto unreg_dev; - + vfd = &dev->vdev; *vfd = vivi_template; vfd->debug = debug; vfd->v4l2_dev = &dev->v4l2_dev; @@ -1445,12 +1439,11 @@ static int __init vivi_create_instance(int inst) * all fops and v4l2 ioctls. */ vfd->lock = &dev->mutex; + video_set_drvdata(vfd, dev); ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr); if (ret < 0) - goto rel_vdev; - - video_set_drvdata(vfd, dev); + goto unreg_dev; /* Now that everything is fine, let's add it to device list */ list_add_tail(&dev->vivi_devlist, &vivi_devlist); @@ -1458,13 +1451,10 @@ static int __init vivi_create_instance(int inst) if (video_nr != -1) video_nr++; - dev->vfd = vfd; v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", video_device_node_name(vfd)); return 0; -rel_vdev: - video_device_release(vfd); unreg_dev: v4l2_ctrl_handler_free(hdl); v4l2_device_unregister(&dev->v4l2_dev); -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 12/33] v4l2-ioctl.c: use the new table for selection ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 262 ++ 1 file changed, 127 insertions(+), 135 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 798ee42..179b22c 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -555,17 +555,45 @@ static void v4l_print_ext_controls(const void *arg, bool write_only) pr_cont("\n"); } -static void v4l_print_u32(const void *arg, bool write_only) +static void v4l_print_cropcap(const void *arg, bool write_only) { - pr_cont("value=%u\n", *(const u32 *)arg); + const struct v4l2_cropcap *p = arg; + + pr_cont("type=%s, bounds wxh=%dx%d, x,y=%d,%d, " + "defrect wxh=%dx%d, x,y=%d,%d\n, " + "pixelaspect %d/%d\n", + prt_names(p->type, v4l2_type_names), + p->bounds.width, p->bounds.height, + p->bounds.left, p->bounds.top, + p->defrect.width, p->defrect.height, + p->defrect.left, p->defrect.top, + p->pixelaspect.numerator, p->pixelaspect.denominator); } -static inline void dbgrect(struct video_device *vfd, char *s, - struct v4l2_rect *r) +static void v4l_print_crop(const void *arg, bool write_only) { - dbgarg2("%sRect start at %dx%d, size=%dx%d\n", s, r->left, r->top, - r->width, r->height); -}; + const struct v4l2_crop *p = arg; + + pr_cont("type=%s, wxh=%dx%d, x,y=%d,%d\n", + prt_names(p->type, v4l2_type_names), + p->c.width, p->c.height, + p->c.left, p->c.top); +} + +static void v4l_print_selection(const void *arg, bool write_only) +{ + const struct v4l2_selection *p = arg; + + pr_cont("type=%s, target=%d, flags=0x%x, wxh=%dx%d, x,y=%d,%d\n", + prt_names(p->type, v4l2_type_names), + p->target, p->flags, + p->r.width, p->r.height, p->r.left, p->r.top); +} + +static void v4l_print_u32(const void *arg, bool write_only) +{ + pr_cont("value=%u\n", *(const u32 *)arg); +} static void dbgtimings(struct video_device *vfd, const struct v4l2_dv_timings *p) @@ -1383,6 +1411,93 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops, -EINVAL; } +static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_crop *p = arg; + struct v4l2_selection s = { + .type = p->type, + }; + int ret; + + if (ops->vidioc_g_crop) + return ops->vidioc_g_crop(file, fh, p); + /* simulate capture crop using selection api */ + + /* crop means compose for output devices */ + if (V4L2_TYPE_IS_OUTPUT(p->type)) + s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; + else + s.target = V4L2_SEL_TGT_CROP_ACTIVE; + + ret = ops->vidioc_g_selection(file, fh, &s); + + /* copying results to old structure on success */ + if (!ret) + p->c = s.r; + return ret; +} + +static int v4l_s_crop(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_crop *p = arg; + struct v4l2_selection s = { + .type = p->type, + .r = p->c, + }; + + if (ops->vidioc_s_crop) + return ops->vidioc_s_crop(file, fh, p); + /* simulate capture crop using selection api */ + + /* crop means compose for output devices */ + if (V4L2_TYPE_IS_OUTPUT(p->type)) + s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; + else + s.target = V4L2_SEL_TGT_CROP_ACTIVE; + + return ops->vidioc_s_selection(file, fh, &s); +} + +static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_cropcap *p = arg; + struct v4l2_selection s = { .type = p->type }; + int ret; + + if (ops->vidioc_cropcap) + return ops->vidioc_cropcap(file, fh, p); + + /* obtaining bounds */ + if (V4L2_TYPE_IS_OUTPUT(p->type)) + s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; + else + s.target = V4L2_SEL_TGT_CROP_BOUNDS; + + ret = ops->vidioc_g_selection(file, fh, &s); + if (ret) + return ret; + p->bounds = s.r; + + /* obtaining defrect */ + if (V4L2_TYPE_IS_OUTPUT(p->type)) + s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; + else + s.target = V4L2_SEL_TGT_CROP_DEFAULT; + + ret = ops->vidioc_g_selection(file, fh, &s); + if (ret) + return ret; + p->defrect = s.r; + +
[RFCv3 PATCH 27/33] vivi: remove pointless g/s_std support
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/vivi.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 08c1024..e00efcf 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c @@ -1072,11 +1072,6 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) return vb2_streamoff(&dev->vb_vidq, i); } -static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i) -{ - return 0; -} - /* only one input in this sample driver */ static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *inp) @@ -1085,7 +1080,6 @@ static int vidioc_enum_input(struct file *file, void *priv, return -EINVAL; inp->type = V4L2_INPUT_TYPE_CAMERA; - inp->std = V4L2_STD_525_60; sprintf(inp->name, "Camera %u", inp->index); return 0; } @@ -1318,7 +1312,6 @@ static const struct v4l2_ioctl_ops vivi_ioctl_ops = { .vidioc_querybuf = vidioc_querybuf, .vidioc_qbuf = vidioc_qbuf, .vidioc_dqbuf = vidioc_dqbuf, - .vidioc_s_std = vidioc_s_std, .vidioc_enum_input= vidioc_enum_input, .vidioc_g_input = vidioc_g_input, .vidioc_s_input = vidioc_s_input, @@ -1334,9 +1327,6 @@ static struct video_device vivi_template = { .fops = &vivi_fops, .ioctl_ops = &vivi_ioctl_ops, .release= video_device_release, - - .tvnorms = V4L2_STD_525_60, - .current_norm = V4L2_STD_NTSC_M, }; /* - -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 29/33] vivi: use vb2 helper functions.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/vivi.c | 150 1 file changed, 12 insertions(+), 138 deletions(-) diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 1e4da5e..f6d7c6e 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c @@ -790,27 +790,6 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, return 0; } -static int buffer_init(struct vb2_buffer *vb) -{ - struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); - - BUG_ON(NULL == dev->fmt); - - /* -* This callback is called once per buffer, after its allocation. -* -* Vivi does not allow changing format during streaming, but it is -* possible to do so when streaming is paused (i.e. in streamoff state). -* Buffers however are not freed when going into streamoff and so -* buffer size verification has to be done in buffer_prepare, on each -* qbuf. -* It would be best to move verification code here to buf_init and -* s_fmt though. -*/ - - return 0; -} - static int buffer_prepare(struct vb2_buffer *vb) { struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); @@ -848,20 +827,6 @@ static int buffer_prepare(struct vb2_buffer *vb) return 0; } -static int buffer_finish(struct vb2_buffer *vb) -{ - struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); - dprintk(dev, 1, "%s\n", __func__); - return 0; -} - -static void buffer_cleanup(struct vb2_buffer *vb) -{ - struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); - dprintk(dev, 1, "%s\n", __func__); - -} - static void buffer_queue(struct vb2_buffer *vb) { struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); @@ -907,10 +872,7 @@ static void vivi_unlock(struct vb2_queue *vq) static struct vb2_ops vivi_video_qops = { .queue_setup= queue_setup, - .buf_init = buffer_init, .buf_prepare= buffer_prepare, - .buf_finish = buffer_finish, - .buf_cleanup= buffer_cleanup, .buf_queue = buffer_queue, .start_streaming= start_streaming, .stop_streaming = stop_streaming, @@ -1019,7 +981,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, if (ret < 0) return ret; - if (vb2_is_streaming(q)) { + if (vb2_is_busy(q)) { dprintk(dev, 1, "%s device busy\n", __func__); return -EBUSY; } @@ -1033,43 +995,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, return 0; } -static int vidioc_reqbufs(struct file *file, void *priv, - struct v4l2_requestbuffers *p) -{ - struct vivi_dev *dev = video_drvdata(file); - return vb2_reqbufs(&dev->vb_vidq, p); -} - -static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) -{ - struct vivi_dev *dev = video_drvdata(file); - return vb2_querybuf(&dev->vb_vidq, p); -} - -static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) -{ - struct vivi_dev *dev = video_drvdata(file); - return vb2_qbuf(&dev->vb_vidq, p); -} - -static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) -{ - struct vivi_dev *dev = video_drvdata(file); - return vb2_dqbuf(&dev->vb_vidq, p, file->f_flags & O_NONBLOCK); -} - -static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) -{ - struct vivi_dev *dev = video_drvdata(file); - return vb2_streamon(&dev->vb_vidq, i); -} - -static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) -{ - struct vivi_dev *dev = video_drvdata(file); - return vb2_streamoff(&dev->vb_vidq, i); -} - /* only one input in this sample driver */ static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *inp) @@ -1137,58 +1062,6 @@ static int vivi_s_ctrl(struct v4l2_ctrl *ctrl) File operations for the device --*/ -static ssize_t -vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos) -{ - struct vivi_dev *dev = video_drvdata(file); - int err; - - dprintk(dev, 1, "read called\n"); - mutex_lock(&dev->mutex); - err = vb2_read(&dev->vb_vidq, data, count, ppos, - file->f_flags & O_NONBLOCK); - mutex_unlock(&dev->mutex); - return err; -} - -static unsigned int -vivi_poll(struct file *file, struct poll_table_struct *wait) -{ - struct vivi_dev *dev = video_drvdata(file); - struct vb2_queue *q = &dev->vb_vidq; - - dprintk(dev, 1, "%s\n", __func__); - return vb2_poll(q, file, wait); -} - -static int
[RFCv3 PATCH 07/33] v4l2-ioctl.c: use the new table for format/framebuffer ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 692 +++--- 1 file changed, 346 insertions(+), 346 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 4029d12..25c0a8a 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -235,6 +235,130 @@ static void v4l_print_audioout(const void *arg, bool write_only) p->index, p->name, p->capability, p->mode); } +static void v4l_print_fmtdesc(const void *arg, bool write_only) +{ + const struct v4l2_fmtdesc *p = arg; + + pr_cont("index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, description='%s'\n", + p->index, prt_names(p->type, v4l2_type_names), + p->flags, (p->pixelformat & 0xff), + (p->pixelformat >> 8) & 0xff, + (p->pixelformat >> 16) & 0xff, + (p->pixelformat >> 24) & 0xff, + p->description); +} + +static void v4l_print_format(const void *arg, bool write_only) +{ + const struct v4l2_format *p = arg; + const struct v4l2_pix_format *pix; + const struct v4l2_pix_format_mplane *mp; + const struct v4l2_vbi_format *vbi; + const struct v4l2_sliced_vbi_format *sliced; + const struct v4l2_window *win; + const struct v4l2_clip *clip; + unsigned i; + + pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); + switch (p->type) { + case V4L2_BUF_TYPE_VIDEO_CAPTURE: + case V4L2_BUF_TYPE_VIDEO_OUTPUT: + pix = &p->fmt.pix; + pr_cont(", width=%u, height=%u, " + "pixelformat=%c%c%c%c, field=%s, " + "bytesperline=%u sizeimage=%u, colorspace=%d\n", + pix->width, pix->height, + (pix->pixelformat & 0xff), + (pix->pixelformat >> 8) & 0xff, + (pix->pixelformat >> 16) & 0xff, + (pix->pixelformat >> 24) & 0xff, + prt_names(pix->field, v4l2_field_names), + pix->bytesperline, pix->sizeimage, + pix->colorspace); + break; + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + mp = &p->fmt.pix_mp; + pr_cont(", width=%u, height=%u, " + "format=%c%c%c%c, field=%s, " + "colorspace=%d, num_planes=%u\n", + mp->width, mp->height, + (mp->pixelformat & 0xff), + (mp->pixelformat >> 8) & 0xff, + (mp->pixelformat >> 16) & 0xff, + (mp->pixelformat >> 24) & 0xff, + prt_names(mp->field, v4l2_field_names), + mp->colorspace, mp->num_planes); + for (i = 0; i < mp->num_planes; i++) + printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i, + mp->plane_fmt[i].bytesperline, + mp->plane_fmt[i].sizeimage); + break; + case V4L2_BUF_TYPE_VIDEO_OVERLAY: + case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: + win = &p->fmt.win; + pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, " + "chromakey=0x%08x, bitmap=%p, " + "global_alpha=0x%02x\n", + win->w.width, win->w.height, + win->w.left, win->w.top, + prt_names(win->field, v4l2_field_names), + win->chromakey, win->bitmap, win->global_alpha); + clip = win->clips; + for (i = 0; i < win->clipcount; i++) { + printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n", + i, clip->c.width, clip->c.height, + clip->c.left, clip->c.top); + clip = clip->next; + } + break; + case V4L2_BUF_TYPE_VBI_CAPTURE: + case V4L2_BUF_TYPE_VBI_OUTPUT: + vbi = &p->fmt.vbi; + pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, " + "sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n", + vbi->sampling_rate, vbi->offset, + vbi->samples_per_line, + (vbi->sample_format & 0xff), + (vbi->sample_format >> 8) & 0xff, + (vbi->sample_format >> 16) & 0xff, + (vbi->sample_format >> 24) & 0xff, + vbi->start[0], vbi->start[1], + vbi->count[0], vbi->count[1]); + break; + case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: + case V4L
[RFCv3 PATCH 13/33] v4l2-ioctl.c: use the new table for compression ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 123 ++ 1 file changed, 46 insertions(+), 77 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 179b22c..935fcbc 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -590,6 +590,45 @@ static void v4l_print_selection(const void *arg, bool write_only) p->r.width, p->r.height, p->r.left, p->r.top); } +static void v4l_print_jpegcompression(const void *arg, bool write_only) +{ + const struct v4l2_jpegcompression *p = arg; + + pr_cont("quality=%d, APPn=%d, APP_len=%d, " + "COM_len=%d, jpeg_markers=0x%x\n", + p->quality, p->APPn, p->APP_len, + p->COM_len, p->jpeg_markers); +} + +static void v4l_print_enc_idx(const void *arg, bool write_only) +{ + const struct v4l2_enc_idx *p = arg; + + pr_cont("entries=%d, entries_cap=%d\n", + p->entries, p->entries_cap); +} + +static void v4l_print_encoder_cmd(const void *arg, bool write_only) +{ + const struct v4l2_encoder_cmd *p = arg; + + pr_cont("cmd=%d, flags=0x%x\n", + p->cmd, p->flags); +} + +static void v4l_print_decoder_cmd(const void *arg, bool write_only) +{ + const struct v4l2_decoder_cmd *p = arg; + + pr_cont("cmd=%d, flags=0x%x\n", p->cmd, p->flags); + + if (p->cmd == V4L2_DEC_CMD_START) + pr_info("speed=%d, format=%u\n", + p->start.speed, p->start.format); + else if (p->cmd == V4L2_DEC_CMD_STOP) + pr_info("pts=%llu\n", p->stop.pts); +} + static void v4l_print_u32(const void *arg, bool write_only) { pr_cont("value=%u\n", *(const u32 *)arg); @@ -1592,8 +1631,8 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO_FNC(VIDIOC_S_CROP, v4l_s_crop, v4l_print_crop, INFO_FL_PRIO), IOCTL_INFO_STD(VIDIOC_G_SELECTION, vidioc_g_selection, v4l_print_selection, 0), IOCTL_INFO_STD(VIDIOC_S_SELECTION, vidioc_s_selection, v4l_print_selection, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_JPEGCOMP, 0), - IOCTL_INFO(VIDIOC_S_JPEGCOMP, INFO_FL_PRIO), + IOCTL_INFO_STD(VIDIOC_G_JPEGCOMP, vidioc_g_jpegcomp, v4l_print_jpegcompression, 0), + IOCTL_INFO_STD(VIDIOC_S_JPEGCOMP, vidioc_s_jpegcomp, v4l_print_jpegcompression, INFO_FL_PRIO), IOCTL_INFO_FNC(VIDIOC_QUERYSTD, v4l_querystd, v4l_print_std, 0), IOCTL_INFO_FNC(VIDIOC_TRY_FMT, v4l_try_fmt, v4l_print_format, 0), IOCTL_INFO_STD(VIDIOC_ENUMAUDIO, vidioc_enumaudio, v4l_print_audio, INFO_FL_CLEAR(v4l2_audio, index)), @@ -1607,11 +1646,11 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, 0), IOCTL_INFO(VIDIOC_ENUM_FRAMESIZES, INFO_FL_CLEAR(v4l2_frmsizeenum, pixel_format)), IOCTL_INFO(VIDIOC_ENUM_FRAMEINTERVALS, INFO_FL_CLEAR(v4l2_frmivalenum, height)), - IOCTL_INFO(VIDIOC_G_ENC_INDEX, 0), - IOCTL_INFO(VIDIOC_ENCODER_CMD, INFO_FL_PRIO | INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), - IOCTL_INFO(VIDIOC_TRY_ENCODER_CMD, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), - IOCTL_INFO(VIDIOC_DECODER_CMD, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_TRY_DECODER_CMD, 0), + IOCTL_INFO_STD(VIDIOC_G_ENC_INDEX, vidioc_g_enc_index, v4l_print_enc_idx, 0), + IOCTL_INFO_STD(VIDIOC_ENCODER_CMD, vidioc_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_PRIO | INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), + IOCTL_INFO_STD(VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), + IOCTL_INFO_STD(VIDIOC_DECODER_CMD, vidioc_decoder_cmd, v4l_print_decoder_cmd, INFO_FL_PRIO), + IOCTL_INFO_STD(VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd, v4l_print_decoder_cmd, 0), IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0), IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0), IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0), @@ -1736,76 +1775,6 @@ static long __video_do_ioctl(struct file *file, } switch (cmd) { - case VIDIOC_G_JPEGCOMP: - { - struct v4l2_jpegcompression *p = arg; - - ret = ops->vidioc_g_jpegcomp(file, fh, p); - if (!ret) - dbgarg(cmd, "quality=%d, APPn=%d, " - "APP_len=%d, COM_len=%d, " - "jpeg_markers=%d\n", - p->quality, p->APPn, p->APP_len, - p->COM_len, p->jpeg_markers); - break; - } - case VIDIOC_S_JPEGCOMP: - { - struct v4l2_jpegcompression *p = arg; - - dbgarg(cmd, "quality=%d, APPn=%d, APP_len=%d, " - "COM_len=%d, jpeg_marke
[RFCv3 PATCH 16/33] v4l2-ioctl.c: use the new table for the remaining ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 278 +- 1 file changed, 154 insertions(+), 124 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index fdceac8..74fe6a2 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -726,6 +726,125 @@ static void v4l_print_dv_timings_cap(const void *arg, bool write_only) } } +static void v4l_print_frmsizeenum(const void *arg, bool write_only) +{ + const struct v4l2_frmsizeenum *p = arg; + + pr_cont("index=%u, pixelformat=%c%c%c%c, type=%u", + p->index, + (p->pixel_format & 0xff), + (p->pixel_format >> 8) & 0xff, + (p->pixel_format >> 16) & 0xff, + (p->pixel_format >> 24) & 0xff, + p->type); + switch (p->type) { + case V4L2_FRMSIZE_TYPE_DISCRETE: + pr_cont(" wxh=%ux%u\n", + p->discrete.width, p->discrete.height); + break; + case V4L2_FRMSIZE_TYPE_STEPWISE: + pr_cont(" min=%ux%u, max=%ux%u, step=%ux%u\n", + p->stepwise.min_width, p->stepwise.min_height, + p->stepwise.step_width, p->stepwise.step_height, + p->stepwise.max_width, p->stepwise.max_height); + break; + case V4L2_FRMSIZE_TYPE_CONTINUOUS: + /* fall through */ + default: + pr_cont("\n"); + break; + } +} + +static void v4l_print_frmivalenum(const void *arg, bool write_only) +{ + const struct v4l2_frmivalenum *p = arg; + + pr_cont("index=%u, pixelformat=%c%c%c%c, wxh=%ux%u, type=%u", + p->index, + (p->pixel_format & 0xff), + (p->pixel_format >> 8) & 0xff, + (p->pixel_format >> 16) & 0xff, + (p->pixel_format >> 24) & 0xff, + p->width, p->height, p->type); + switch (p->type) { + case V4L2_FRMIVAL_TYPE_DISCRETE: + pr_cont(" fps=%d/%d\n", + p->discrete.numerator, + p->discrete.denominator); + break; + case V4L2_FRMIVAL_TYPE_STEPWISE: + pr_cont(" min=%d/%d, max=%d/%d, step=%d/%d\n", + p->stepwise.min.numerator, + p->stepwise.min.denominator, + p->stepwise.max.numerator, + p->stepwise.max.denominator, + p->stepwise.step.numerator, + p->stepwise.step.denominator); + break; + case V4L2_FRMIVAL_TYPE_CONTINUOUS: + /* fall through */ + default: + pr_cont("\n"); + break; + } +} + +static void v4l_print_event(const void *arg, bool write_only) +{ + const struct v4l2_event *p = arg; + const struct v4l2_event_ctrl *c; + + pr_cont("type=0x%x, pending=%u, sequence=%u, id=%u, " + "timestamp=%lu.%9.9lu\n", + p->type, p->pending, p->sequence, p->id, + p->timestamp.tv_sec, p->timestamp.tv_nsec); + switch (p->type) { + case V4L2_EVENT_VSYNC: + printk(KERN_DEBUG "field=%s\n", + prt_names(p->u.vsync.field, v4l2_field_names)); + break; + case V4L2_EVENT_CTRL: + c = &p->u.ctrl; + printk(KERN_DEBUG "changes=0x%x, type=%u, ", + c->changes, c->type); + if (c->type == V4L2_CTRL_TYPE_INTEGER64) + pr_cont("value64=%lld, ", c->value64); + else + pr_cont("value=%d, ", c->value); + pr_cont("flags=0x%x, minimum=%d, maximum=%d, step=%d," + " default_value=%d\n", + c->flags, c->minimum, c->maximum, + c->step, c->default_value); + break; + case V4L2_EVENT_FRAME_SYNC: + pr_cont("frame_sequence=%u\n", + p->u.frame_sync.frame_sequence); + break; + } +} + +static void v4l_print_event_subscription(const void *arg, bool write_only) +{ + const struct v4l2_event_subscription *p = arg; + + pr_cont("type=0x%x, id=0x%x, flags=0x%x\n", + p->type, p->id, p->flags); +} + +static void v4l_print_sliced_vbi_cap(const void *arg, bool write_only) +{ + const struct v4l2_sliced_vbi_cap *p = arg; + int i; + + pr_cont("type=%s, service_set=0x%08x\n", + prt_names(p->type, v4l2_type_names), p->service_set); + for (i
[RFCv3 PATCH 05/33] v4l2-ioctl.c: use the new table for querycap and i/o ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 328 -- 1 file changed, 133 insertions(+), 195 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index be89dad..7556678 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -183,6 +183,63 @@ static const char *v4l2_memory_names[] = { /* -- */ /* debug help functions */ +static void v4l_print_querycap(const void *arg, bool write_only) +{ + const struct v4l2_capability *p = arg; + + pr_cont("driver=%s, card=%s, bus=%s, version=0x%08x, " + "capabilities=0x%08x, device_caps=0x%08x\n", + p->driver, p->card, p->bus_info, + p->version, p->capabilities, p->device_caps); +} + +static void v4l_print_enuminput(const void *arg, bool write_only) +{ + const struct v4l2_input *p = arg; + + pr_cont("index=%u, name=%s, type=%u, audioset=0x%x, tuner=%u, " + "std=0x%08Lx, status=0x%x, capabilities=0x%x\n", + p->index, p->name, p->type, p->audioset, p->tuner, + (unsigned long long)p->std, p->status, p->capabilities); +} + +static void v4l_print_enumoutput(const void *arg, bool write_only) +{ + const struct v4l2_output *p = arg; + + pr_cont("index=%u, name=%s, type=%u, audioset=0x%x, " + "modulator=%u, std=0x%08Lx, capabilities=0x%x\n", + p->index, p->name, p->type, p->audioset, p->modulator, + (unsigned long long)p->std, p->capabilities); +} + +static void v4l_print_audio(const void *arg, bool write_only) +{ + const struct v4l2_audio *p = arg; + + if (write_only) + pr_cont("index=%u, mode=0x%x\n", p->index, p->mode); + else + pr_cont("index=%u, name=%s, capability=0x%x, mode=0x%x\n", + p->index, p->name, p->capability, p->mode); +} + +static void v4l_print_audioout(const void *arg, bool write_only) +{ + const struct v4l2_audioout *p = arg; + + if (write_only) + pr_cont("index=%u\n", p->index); + else + pr_cont("index=%u, name=%s, capability=0x%x, mode=0x%x\n", + p->index, p->name, p->capability, p->mode); +} + +static void v4l_print_u32(const void *arg, bool write_only) +{ + pr_cont("value=%u\n", *(const u32 *)arg); +} + static void dbgbuf(unsigned int cmd, struct video_device *vfd, struct v4l2_buffer *p) { @@ -392,6 +449,69 @@ static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type) return -EINVAL; } +static int v4l_querycap(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_capability *cap = (struct v4l2_capability *)arg; + + cap->version = LINUX_VERSION_CODE; + return ops->vidioc_querycap(file, fh, cap); +} + +static int v4l_s_input(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + return ops->vidioc_s_input(file, fh, *(unsigned int *)arg); +} + +static int v4l_s_output(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + return ops->vidioc_s_output(file, fh, *(unsigned int *)arg); +} + +static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_input *p = arg; + + /* +* We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & +* CAP_STD here based on ioctl handler provided by the +* driver. If the driver doesn't support these +* for a specific input, it must override these flags. +*/ + if (ops->vidioc_s_std) + p->capabilities |= V4L2_IN_CAP_STD; + if (ops->vidioc_s_dv_preset) + p->capabilities |= V4L2_IN_CAP_PRESETS; + if (ops->vidioc_s_dv_timings) + p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS; + + return ops->vidioc_enum_input(file, fh, p); +} + +static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct v4l2_output *p = arg; + + /* +* We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & +* CAP_STD here based on ioctl handler provided by the +* driver. If the driver doesn't support these +* for a specific output, it must override these flags. +*/ + if (ops->vidioc_s_std) + p->capabilities |= V4L2_OUT_CAP_STD; + if (ops->vidioc_s_dv_preset) + p->capabilities |= V4L2_OUT_CAP_PRESETS; + if (ops->vidioc_s_dv_timings) + p-
[RFCv3 PATCH 06/33] v4l2-ioctl.c: use the new table for priority ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 60 ++ 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 7556678..4029d12 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -470,6 +470,33 @@ static int v4l_s_output(const struct v4l2_ioctl_ops *ops, return ops->vidioc_s_output(file, fh, *(unsigned int *)arg); } +static int v4l_g_priority(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd; + u32 *p = arg; + + if (ops->vidioc_g_priority) + return ops->vidioc_g_priority(file, fh, arg); + vfd = video_devdata(file); + *p = v4l2_prio_max(&vfd->v4l2_dev->prio); + return 0; +} + +static int v4l_s_priority(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + struct video_device *vfd; + struct v4l2_fh *vfh; + u32 *p = arg; + + if (ops->vidioc_s_priority) + return ops->vidioc_s_priority(file, fh, *p); + vfd = video_devdata(file); + vfh = file->private_data; + return v4l2_prio_change(&vfd->v4l2_dev->prio, &vfh->prio, *p); +} + static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { @@ -612,8 +639,8 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_TRY_FMT, 0), IOCTL_INFO_STD(VIDIOC_ENUMAUDIO, vidioc_enumaudio, v4l_print_audio, INFO_FL_CLEAR(v4l2_audio, index)), IOCTL_INFO_STD(VIDIOC_ENUMAUDOUT, vidioc_enumaudout, v4l_print_audioout, INFO_FL_CLEAR(v4l2_audioout, index)), - IOCTL_INFO(VIDIOC_G_PRIORITY, 0), - IOCTL_INFO(VIDIOC_S_PRIORITY, INFO_FL_PRIO), + IOCTL_INFO_FNC(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0), + IOCTL_INFO_FNC(VIDIOC_S_PRIORITY, v4l_s_priority, v4l_print_u32, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)), IOCTL_INFO(VIDIOC_LOG_STATUS, 0), IOCTL_INFO(VIDIOC_G_EXT_CTRLS, INFO_FL_CTRL), @@ -750,35 +777,6 @@ static long __video_do_ioctl(struct file *file, } switch (cmd) { - - /* --- priority -- */ - case VIDIOC_G_PRIORITY: - { - enum v4l2_priority *p = arg; - - if (ops->vidioc_g_priority) { - ret = ops->vidioc_g_priority(file, fh, p); - } else if (use_fh_prio) { - *p = v4l2_prio_max(&vfd->v4l2_dev->prio); - ret = 0; - } - if (!ret) - dbgarg(cmd, "priority is %d\n", *p); - break; - } - case VIDIOC_S_PRIORITY: - { - enum v4l2_priority *p = arg; - - dbgarg(cmd, "setting priority to %d\n", *p); - if (ops->vidioc_s_priority) - ret = ops->vidioc_s_priority(file, fh, *p); - else - ret = v4l2_prio_change(&vfd->v4l2_dev->prio, - &vfh->prio, *p); - break; - } - /* --- capture ioctls */ case VIDIOC_ENUM_FMT: { -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 08/33] v4l2-ioctl.c: use the new table for overlay/streamon/off ioctls.
From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 47 -- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 25c0a8a..78ff09f 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -359,6 +359,11 @@ static void v4l_print_framebuffer(const void *arg, bool write_only) p->fmt.colorspace); } +static void v4l_print_buftype(const void *arg, bool write_only) +{ + pr_cont("type=%s\n", prt_names(*(u32 *)arg, v4l2_type_names)); +} + static void v4l_print_u32(const void *arg, bool write_only) { pr_cont("value=%u\n", *(const u32 *)arg); @@ -844,6 +849,18 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, return -EINVAL; } +static int v4l_streamon(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + return ops->vidioc_streamon(file, fh, *(unsigned int *)arg); +} + +static int v4l_streamoff(const struct v4l2_ioctl_ops *ops, + struct file *file, void *fh, void *arg) +{ + return ops->vidioc_streamoff(file, fh, *(unsigned int *)arg); +} + struct v4l2_ioctl_info { unsigned int ioctl; u32 flags; @@ -903,11 +920,11 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_QUERYBUF, INFO_FL_CLEAR(v4l2_buffer, length)), IOCTL_INFO_STD(VIDIOC_G_FBUF, vidioc_g_fbuf, v4l_print_framebuffer, 0), IOCTL_INFO_STD(VIDIOC_S_FBUF, vidioc_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_OVERLAY, INFO_FL_PRIO), + IOCTL_INFO_STD(VIDIOC_OVERLAY, vidioc_overlay, v4l_print_u32, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_QBUF, 0), IOCTL_INFO(VIDIOC_DQBUF, 0), - IOCTL_INFO(VIDIOC_STREAMON, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_STREAMOFF, INFO_FL_PRIO), + IOCTL_INFO_FNC(VIDIOC_STREAMON, v4l_streamon, v4l_print_buftype, INFO_FL_PRIO), + IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_G_PARM, INFO_FL_CLEAR(v4l2_streamparm, type)), IOCTL_INFO(VIDIOC_S_PARM, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_G_STD, 0), @@ -1143,30 +1160,6 @@ static long __video_do_ioctl(struct file *file, dbgbuf(cmd, vfd, p); break; } - case VIDIOC_OVERLAY: - { - int *i = arg; - - dbgarg(cmd, "value=%d\n", *i); - ret = ops->vidioc_overlay(file, fh, *i); - break; - } - case VIDIOC_STREAMON: - { - enum v4l2_buf_type i = *(int *)arg; - - dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); - ret = ops->vidioc_streamon(file, fh, i); - break; - } - case VIDIOC_STREAMOFF: - { - enum v4l2_buf_type i = *(int *)arg; - - dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); - ret = ops->vidioc_streamoff(file, fh, i); - break; - } /* -- tv norms -- */ case VIDIOC_ENUMSTD: { -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFCv3 PATCH 01/33] v4l2-ioctl.c: move a block of code down, no other changes.
From: Hans Verkuil A block of code is moved down in the code to make later changes easier. Do just the move without other changes to keep the diff readable for the upcoming patch. Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 288 +++--- 1 file changed, 144 insertions(+), 144 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index d7fa896..46fd953 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -183,150 +183,6 @@ static const char *v4l2_memory_names[] = { /* -- */ /* debug help functions */ -struct v4l2_ioctl_info { - unsigned int ioctl; - u16 flags; - const char * const name; -}; - -/* This control needs a priority check */ -#define INFO_FL_PRIO (1 << 0) -/* This control can be valid if the filehandle passes a control handler. */ -#define INFO_FL_CTRL (1 << 1) - -#define IOCTL_INFO(_ioctl, _flags) [_IOC_NR(_ioctl)] = { \ - .ioctl = _ioctl,\ - .flags = _flags,\ - .name = #_ioctl,\ -} - -static struct v4l2_ioctl_info v4l2_ioctls[] = { - IOCTL_INFO(VIDIOC_QUERYCAP, 0), - IOCTL_INFO(VIDIOC_ENUM_FMT, 0), - IOCTL_INFO(VIDIOC_G_FMT, 0), - IOCTL_INFO(VIDIOC_S_FMT, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_REQBUFS, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_QUERYBUF, 0), - IOCTL_INFO(VIDIOC_G_FBUF, 0), - IOCTL_INFO(VIDIOC_S_FBUF, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_OVERLAY, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_QBUF, 0), - IOCTL_INFO(VIDIOC_DQBUF, 0), - IOCTL_INFO(VIDIOC_STREAMON, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_STREAMOFF, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_PARM, 0), - IOCTL_INFO(VIDIOC_S_PARM, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_STD, 0), - IOCTL_INFO(VIDIOC_S_STD, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_ENUMSTD, 0), - IOCTL_INFO(VIDIOC_ENUMINPUT, 0), - IOCTL_INFO(VIDIOC_G_CTRL, INFO_FL_CTRL), - IOCTL_INFO(VIDIOC_S_CTRL, INFO_FL_PRIO | INFO_FL_CTRL), - IOCTL_INFO(VIDIOC_G_TUNER, 0), - IOCTL_INFO(VIDIOC_S_TUNER, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_AUDIO, 0), - IOCTL_INFO(VIDIOC_S_AUDIO, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_QUERYCTRL, INFO_FL_CTRL), - IOCTL_INFO(VIDIOC_QUERYMENU, INFO_FL_CTRL), - IOCTL_INFO(VIDIOC_G_INPUT, 0), - IOCTL_INFO(VIDIOC_S_INPUT, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_OUTPUT, 0), - IOCTL_INFO(VIDIOC_S_OUTPUT, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_ENUMOUTPUT, 0), - IOCTL_INFO(VIDIOC_G_AUDOUT, 0), - IOCTL_INFO(VIDIOC_S_AUDOUT, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_MODULATOR, 0), - IOCTL_INFO(VIDIOC_S_MODULATOR, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_FREQUENCY, 0), - IOCTL_INFO(VIDIOC_S_FREQUENCY, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_CROPCAP, 0), - IOCTL_INFO(VIDIOC_G_CROP, 0), - IOCTL_INFO(VIDIOC_S_CROP, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_SELECTION, 0), - IOCTL_INFO(VIDIOC_S_SELECTION, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_JPEGCOMP, 0), - IOCTL_INFO(VIDIOC_S_JPEGCOMP, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_QUERYSTD, 0), - IOCTL_INFO(VIDIOC_TRY_FMT, 0), - IOCTL_INFO(VIDIOC_ENUMAUDIO, 0), - IOCTL_INFO(VIDIOC_ENUMAUDOUT, 0), - IOCTL_INFO(VIDIOC_G_PRIORITY, 0), - IOCTL_INFO(VIDIOC_S_PRIORITY, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, 0), - IOCTL_INFO(VIDIOC_LOG_STATUS, 0), - IOCTL_INFO(VIDIOC_G_EXT_CTRLS, INFO_FL_CTRL), - IOCTL_INFO(VIDIOC_S_EXT_CTRLS, INFO_FL_PRIO | INFO_FL_CTRL), - IOCTL_INFO(VIDIOC_TRY_EXT_CTRLS, 0), - IOCTL_INFO(VIDIOC_ENUM_FRAMESIZES, 0), - IOCTL_INFO(VIDIOC_ENUM_FRAMEINTERVALS, 0), - IOCTL_INFO(VIDIOC_G_ENC_INDEX, 0), - IOCTL_INFO(VIDIOC_ENCODER_CMD, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_TRY_ENCODER_CMD, 0), - IOCTL_INFO(VIDIOC_DECODER_CMD, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_TRY_DECODER_CMD, 0), -#ifdef CONFIG_VIDEO_ADV_DEBUG - IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0), - IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0), -#endif - IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0), - IOCTL_INFO(VIDIOC_S_HW_FREQ_SEEK, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0), - IOCTL_INFO(VIDIOC_S_DV_PRESET, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_DV_PRESET, 0), - IOCTL_INFO(VIDIOC_QUERY_DV_PRESET, 0), - IOCTL_INFO(VIDIOC_S_DV_TIMINGS, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_DV_TIMINGS, 0), - IOCTL_INFO(VIDIOC_DQEVENT, 0), - IOCTL_INFO(VIDIOC_SUBSCRIBE_EVENT, 0), - IOCTL_INFO(VIDIOC_UNSUBSCRIBE_EVENT, 0), - IOCTL_INFO(VIDIOC_CREATE_BUFS, INFO_FL_PRIO), - IOCTL_
[RFCv3 PATCH 02/33] v4l2-ioctl.c: introduce INFO_FL_CLEAR to replace switch.
From: Hans Verkuil The switch statement that determines how much data should be copied from userspace is replaced by a table lookup. Signed-off-by: Hans Verkuil --- drivers/media/video/v4l2-ioctl.c | 103 +++--- 1 file changed, 41 insertions(+), 62 deletions(-) diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 46fd953..e2f77bc 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c @@ -394,7 +394,7 @@ static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type) struct v4l2_ioctl_info { unsigned int ioctl; - u16 flags; + u32 flags; const char * const name; }; @@ -402,6 +402,11 @@ struct v4l2_ioctl_info { #define INFO_FL_PRIO (1 << 0) /* This control can be valid if the filehandle passes a control handler. */ #define INFO_FL_CTRL (1 << 1) +/* Zero struct from after the field to the end */ +#define INFO_FL_CLEAR(v4l2_struct, field) \ + ((offsetof(struct v4l2_struct, field) + \ + sizeof(((struct v4l2_struct *)0)->field)) << 16) +#define INFO_FL_CLEAR_MASK (_IOC_SIZEMASK << 16) #define IOCTL_INFO(_ioctl, _flags) [_IOC_NR(_ioctl)] = { \ .ioctl = _ioctl,\ @@ -411,11 +416,11 @@ struct v4l2_ioctl_info { static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_QUERYCAP, 0), - IOCTL_INFO(VIDIOC_ENUM_FMT, 0), - IOCTL_INFO(VIDIOC_G_FMT, 0), + IOCTL_INFO(VIDIOC_ENUM_FMT, INFO_FL_CLEAR(v4l2_fmtdesc, type)), + IOCTL_INFO(VIDIOC_G_FMT, INFO_FL_CLEAR(v4l2_format, type)), IOCTL_INFO(VIDIOC_S_FMT, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_REQBUFS, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_QUERYBUF, 0), + IOCTL_INFO(VIDIOC_QUERYBUF, INFO_FL_CLEAR(v4l2_buffer, length)), IOCTL_INFO(VIDIOC_G_FBUF, 0), IOCTL_INFO(VIDIOC_S_FBUF, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_OVERLAY, INFO_FL_PRIO), @@ -423,33 +428,33 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_DQBUF, 0), IOCTL_INFO(VIDIOC_STREAMON, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_STREAMOFF, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_PARM, 0), + IOCTL_INFO(VIDIOC_G_PARM, INFO_FL_CLEAR(v4l2_streamparm, type)), IOCTL_INFO(VIDIOC_S_PARM, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_G_STD, 0), IOCTL_INFO(VIDIOC_S_STD, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_ENUMSTD, 0), - IOCTL_INFO(VIDIOC_ENUMINPUT, 0), + IOCTL_INFO(VIDIOC_ENUMSTD, INFO_FL_CLEAR(v4l2_standard, index)), + IOCTL_INFO(VIDIOC_ENUMINPUT, INFO_FL_CLEAR(v4l2_input, index)), IOCTL_INFO(VIDIOC_G_CTRL, INFO_FL_CTRL), IOCTL_INFO(VIDIOC_S_CTRL, INFO_FL_PRIO | INFO_FL_CTRL), - IOCTL_INFO(VIDIOC_G_TUNER, 0), + IOCTL_INFO(VIDIOC_G_TUNER, INFO_FL_CLEAR(v4l2_tuner, index)), IOCTL_INFO(VIDIOC_S_TUNER, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_G_AUDIO, 0), IOCTL_INFO(VIDIOC_S_AUDIO, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_QUERYCTRL, INFO_FL_CTRL), - IOCTL_INFO(VIDIOC_QUERYMENU, INFO_FL_CTRL), + IOCTL_INFO(VIDIOC_QUERYCTRL, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_queryctrl, id)), + IOCTL_INFO(VIDIOC_QUERYMENU, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_querymenu, index)), IOCTL_INFO(VIDIOC_G_INPUT, 0), IOCTL_INFO(VIDIOC_S_INPUT, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_OUTPUT, 0), + IOCTL_INFO(VIDIOC_G_OUTPUT, INFO_FL_CLEAR(v4l2_output, index)), IOCTL_INFO(VIDIOC_S_OUTPUT, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_ENUMOUTPUT, 0), IOCTL_INFO(VIDIOC_G_AUDOUT, 0), IOCTL_INFO(VIDIOC_S_AUDOUT, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_MODULATOR, 0), + IOCTL_INFO(VIDIOC_G_MODULATOR, INFO_FL_CLEAR(v4l2_modulator, index)), IOCTL_INFO(VIDIOC_S_MODULATOR, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_G_FREQUENCY, 0), + IOCTL_INFO(VIDIOC_G_FREQUENCY, INFO_FL_CLEAR(v4l2_frequency, tuner)), IOCTL_INFO(VIDIOC_S_FREQUENCY, INFO_FL_PRIO), - IOCTL_INFO(VIDIOC_CROPCAP, 0), - IOCTL_INFO(VIDIOC_G_CROP, 0), + IOCTL_INFO(VIDIOC_CROPCAP, INFO_FL_CLEAR(v4l2_cropcap, type)), + IOCTL_INFO(VIDIOC_G_CROP, INFO_FL_CLEAR(v4l2_crop, type)), IOCTL_INFO(VIDIOC_S_CROP, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_G_SELECTION, 0), IOCTL_INFO(VIDIOC_S_SELECTION, INFO_FL_PRIO), @@ -457,20 +462,20 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = { IOCTL_INFO(VIDIOC_S_JPEGCOMP, INFO_FL_PRIO), IOCTL_INFO(VIDIOC_QUERYSTD, 0), IOCTL_INFO(VIDIOC_TRY_FMT, 0), - IOCTL_INFO(VIDIOC_ENUMAUDIO, 0), - IOCTL_INFO(VIDIOC_ENUMAUDOUT, 0), + IOCTL_INFO(VIDIOC_ENUMAUDIO, INFO_FL_CLEAR(v4l2_audio, index)), + IOCTL_INFO(VIDIOC_ENUMAUDOUT, INFO_FL_CLEAR(v4l2_audioout, index)), IOCTL_INFO(VIDIOC_G_PRIORITY, 0), IOCTL_INFO(VIDIOC_S_PRIORITY, INFO_FL_PRIO), -
Re: [PATCH] omap_vout: Set DSS overlay_info only if paddr is non zero
On Mon, Mar 19, 2012 at 5:16 PM, Archit Taneja wrote: > On Monday 19 March 2012 02:15 PM, Hiremath, Vaibhav wrote: >> >> On Fri, Mar 16, 2012 at 16:41:27, Taneja, Archit wrote: >>> >>> Hi, >>> >>> On Friday 16 March 2012 03:46 PM, Archit Taneja wrote: On Monday 12 March 2012 03:34 PM, Hiremath, Vaibhav wrote: > > On Wed, Mar 07, 2012 at 14:31:16, Taneja, Archit wrote: >> >> The omap_vout driver tries to set the DSS overlay_info using >> set_overlay_info() >> when the physical address for the overlay is still not configured. >> This happens >> in omap_vout_probe() and vidioc_s_fmt_vid_out(). >> >> The calls to omapvid_init(which internally calls set_overlay_info()) >> are removed >> from these functions. They don't need to be called as the >> omap_vout_device >> struct anyway maintains the overlay related changes made. Also, >> remove the >> explicit call to set_overlay_info() in vidioc_streamon(), this was >> used to set >> the paddr, this isn't needed as omapvid_init() does the same thing >> later. >> >> These changes are required as the DSS2 driver since 3.3 kernel >> doesn't let you >> set the overlay info with paddr as 0. >> >> Signed-off-by: Archit Taneja >> --- >> drivers/media/video/omap/omap_vout.c | 36 >> - >> 1 files changed, 5 insertions(+), 31 deletions(-) >> >> diff --git a/drivers/media/video/omap/omap_vout.c >> b/drivers/media/video/omap/omap_vout.c >> index 1fb7d5b..dffcf66 100644 >> --- a/drivers/media/video/omap/omap_vout.c >> +++ b/drivers/media/video/omap/omap_vout.c >> @@ -1157,13 +1157,6 @@ static int vidioc_s_fmt_vid_out(struct file >> *file, void *fh, >> /* set default crop and win */ >> omap_vout_new_format(&vout->pix,&vout->fbuf,&vout->crop,&vout->win); >> >> - /* Save the changes in the overlay strcuture */ >> - ret = omapvid_init(vout, 0); >> - if (ret) { >> - v4l2_err(&vout->vid_dev->v4l2_dev, "failed to change mode\n"); >> - goto s_fmt_vid_out_exit; >> - } >> - >> ret = 0; >> >> s_fmt_vid_out_exit: >> @@ -1664,20 +1657,6 @@ static int vidioc_streamon(struct file *file, >> void *fh, enum v4l2_buf_type i) >> >> omap_dispc_register_isr(omap_vout_isr, vout, mask); >> >> - for (j = 0; j< Â ovid->num_overlays; j++) { >> - struct omap_overlay *ovl = ovid->overlays[j]; >> - >> - if (ovl->manager&& Â ovl->manager->device) { >> - struct omap_overlay_info info; >> - ovl->get_overlay_info(ovl,&info); >> - info.paddr = addr; >> - if (ovl->set_overlay_info(ovl,&info)) { >> - ret = -EINVAL; >> - goto streamon_err1; >> - } >> - } >> - } >> - > > > Have you checked for build warnings? I am getting build warnings > > CC drivers/media/video/omap/omap_vout.o > CC drivers/media/video/omap/omap_voutlib.o > CC drivers/media/video/omap/omap_vout_vrfb.o > drivers/media/video/omap/omap_vout.c: In function 'vidioc_streamon': > drivers/media/video/omap/omap_vout.c:1619:25: warning: unused variable > 'ovid' > drivers/media/video/omap/omap_vout.c:1615:15: warning: unused variable > 'j' > LD drivers/media/video/omap/omap-vout.o > LD drivers/media/video/omap/built-in.o > > Can you fix this and submit the next version? >>> >>> >>> I applied the patch on the current mainline kernel, it doesn't give any >>> build warnings. Even after applying the patch, 'j and ovid' are still >>> used in vidioc_streamon(). >>> >>> Can you check if it was applied correctly? >>> >> >> Archit, >> >> I could able to trace what's going on here, >> >> I am using "v4l_for_linus" branch, which has one missing patch, >> >> commit aaa874a985158383c4b394c687c716ef26288741 >> Author: Tomi Valkeinen >> Date: Â Tue Nov 15 16:37:53 2011 +0200 >> >> Â Â OMAPDSS: APPLY: rewrite overlay enable/disable >> >> >> So, I do not have below changes, >> >> @@ -1686,6 +1681,16 @@ static int vidioc_streamon(struct file *file, void >> *fh, enum v4l2_buf_type i) >> Â Â Â Â if (ret) >> Â Â Â Â Â Â Â Â v4l2_err(&vout->vid_dev->v4l2_dev, "failed to change >> mode\n"); >> >> + Â Â Â for (j = 0; j< Â ovid->num_overlays; j++) { >> + Â Â Â Â Â Â Â struct omap_overlay *ovl = ovid->overlays[j]; >> + >> + Â Â Â Â Â Â Â if (ovl->manager&& Â ovl->manager->device) { >> >> + Â Â Â Â Â Â Â Â Â Â Â ret = ovl->enable(ovl); >> + Â Â Â Â Â Â Â Â Â Â Â if (ret) >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto streamon_err1; >> + Â Â Â Â Â Â Â } >> + Â Â Â } >> + >> >> This explains why I am seeing these warnings. Let me give pull request >> based on master branch. > > > Okay. Thanks for looking into this. > > Archit Hi Vaibhav, This patch has been outstanding since March, and we have received reports from various users. Could you please push it ASAP to Mauro for the upcoming -rc? Or Did I miss a pull request fr
dib0700 can't enable debug messages
Hi all, I would like to see some debug messages from the dib0700 driver. I have tried to enable debug messages like this, following the instructions found here: http://www.linuxtv.org/wiki/index.php/Template:Making-it-work:dvb-usb-dib0700 # rmmod dvb_usb_dib0700 # insmod /lib/modules/3.3.7-1-ARCH/kernel/drivers/media/dvb/dvb-usb/dvb-usb-dib0700.ko.gz debug=1 # rmmod dvb_usb_dib0700 # insmod /lib/modules/3.3.7-1-ARCH/kernel/drivers/media/dvb/dvb-usb/dvb-usb-dib0700.ko.gz debug=2 # rmmod dvb_usb_dib0700 # insmod /lib/modules/3.3.7-1-ARCH/kernel/drivers/media/dvb/dvb-usb/dvb-usb-dib0700.ko.gz debug=4 # rmmod dvb_usb_dib0700 # insmod /lib/modules/3.3.7-1-ARCH/kernel/drivers/media/dvb/dvb-usb/dvb-usb-dib0700.ko.gz debug=8 # rmmod dvb_usb_dib0700 # insmod /lib/modules/3.3.7-1-ARCH/kernel/drivers/media/dvb/dvb-usb/dvb-usb-dib0700.ko.gz debug 8 Error: could not insert module /lib/modules/3.3.7-1-ARCH/kernel/drivers/media/dvb/dvb-usb/dvb-usb-dib0700.ko.gz: Invalid parameters # insmod /lib/modules/3.3.7-1-ARCH/kernel/drivers/media/dvb/dvb-usb/dvb-usb-dib0700.ko.gz debug=15 # rmmod dvb_usb_dib0700 # modprobe dvb_usb_dib0700 debug=15 The messaegs in /var/log/messages are the same in all the above cases: Jun 28 00:46:27 localhost kernel: [29669.758363] dvb-usb: found a 'Pinnacle PCTV 73e SE' in warm state. Jun 28 00:46:27 localhost kernel: [29669.758428] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer. Jun 28 00:46:27 localhost kernel: [29669.758619] DVB: registering new adapter (Pinnacle PCTV 73e SE) Jun 28 00:46:27 localhost kernel: [29669.970031] DVB: registering adapter 0 frontend 0 (DiBcom 7000PC)... Jun 28 00:46:28 localhost kernel: [29670.177652] DiB0070: successfully identified Jun 28 00:46:28 localhost kernel: [29670.177669] Registered IR keymap rc-dib0700-rc5 Jun 28 00:46:28 localhost kernel: [29670.177887] input: IR-receiver inside an USB DVB receiver as /devices/pci:00/:00:1d.7/usb2/2-4/rc/rc6/input31 Jun 28 00:46:28 localhost kernel: [29670.178061] rc6: IR-receiver inside an USB DVB receiver as /devices/pci:00/:00:1d.7/usb2/2-4/rc/rc6 Jun 28 00:46:28 localhost kernel: [29670.178274] dvb-usb: schedule remote query interval to 50 msecs. Jun 28 00:46:28 localhost kernel: [29670.178278] dvb-usb: Pinnacle PCTV 73e SE successfully initialized and connected. Jun 28 00:46:28 localhost kernel: [29670.178426] usbcore: registered new interface driver dvb_usb_dib0700 Jun 28 00:47:25 localhost kernel: [29727.435215] usbcore: deregistering interface driver dvb_usb_dib0700 Jun 28 00:47:25 localhost acpid: input device has been disconnected, fd 20 Jun 28 00:47:25 localhost kernel: [29727.444744] dvb-usb: Pinnacle PCTV 73e SE successfully deinitialized and disconnected. Jun 28 00:47:27 localhost kernel: [29729.807075] dvb-usb: found a 'Pinnacle PCTV 73e SE' in warm state. Jun 28 00:47:27 localhost kernel: [29729.807151] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer. Jun 28 00:47:27 localhost kernel: [29729.807828] DVB: registering new adapter (Pinnacle PCTV 73e SE) Jun 28 00:47:27 localhost kernel: [29730.023174] DVB: registering adapter 0 frontend 0 (DiBcom 7000PC)... Jun 28 00:47:28 localhost kernel: [29730.230923] DiB0070: successfully identified Jun 28 00:47:28 localhost kernel: [29730.230940] Registered IR keymap rc-dib0700-rc5 Jun 28 00:47:28 localhost kernel: [29730.231159] input: IR-receiver inside an USB DVB receiver as /devices/pci:00/:00:1d.7/usb2/2-4/rc/rc7/input32 Jun 28 00:47:28 localhost kernel: [29730.231336] rc7: IR-receiver inside an USB DVB receiver as /devices/pci:00/:00:1d.7/usb2/2-4/rc/rc7 Jun 28 00:47:28 localhost kernel: [29730.231543] dvb-usb: schedule remote query interval to 50 msecs. Jun 28 00:47:28 localhost kernel: [29730.231547] dvb-usb: Pinnacle PCTV 73e SE successfully initialized and connected. Jun 28 00:47:28 localhost kernel: [29730.231692] usbcore: registered new interface driver dvb_usb_dib0700 Jun 28 00:48:08 localhost kernel: [29770.891230] usbcore: deregistering interface driver dvb_usb_dib0700 Jun 28 00:48:08 localhost acpid: input device has been disconnected, fd 20 Jun 28 00:48:08 localhost kernel: [29770.902035] dvb-usb: Pinnacle PCTV 73e SE successfully deinitialized and disconnected. Jun 28 00:48:11 localhost kernel: [29773.181745] dvb-usb: found a 'Pinnacle PCTV 73e SE' in warm state. Jun 28 00:48:11 localhost kernel: [29773.181812] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer. Jun 28 00:48:11 localhost kernel: [29773.182044] DVB: registering new adapter (Pinnacle PCTV 73e SE) Jun 28 00:48:11 localhost kernel: [29773.390057] DVB: registering adapter 0 frontend 0 (DiBcom 7000PC)... Jun 28 00:48:11 localhost kernel: [29773.594311] DiB0070: successfully identified Jun 28 00:48:11 localhost kernel: [29773.594328] Registered IR keymap rc-dib0700-rc5 Jun 28 00:48:11 localhost kernel: [29773.594544] input: IR-receiver inside an USB DVB
Re: [PATCH] [V2] stv090x: variable 'no_signal' set but not used
Hey Peter, On Wed, Jun 27, 2012 at 7:18 PM, Peter Senna Tschudin wrote: > - Â Â Â Â Â Â Â Â Â Â Â no_signal = stv090x_chk_signal(state); > + Â Â Â Â Â Â Â Â Â Â Â (void) stv090x_chk_signal(state); Why are you casting return to void? I can't see there is a reason to it. Regards, Ezequiel. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
DVB core enhancements - comments please?
Here is my list of needed DVB core related changes. Feel free to comment - what are not needed or what you would like to see instead. I will try to implement what I can (and what I like most interesting :). general validly checking for demodulator callback input values -- * currently each driver needs to validate those * values are highly hooked up to used television standard * we can do almost all validly checking inside core * we can also check if call is possible to perform in given condition * for example BER is not valid when demod is unlocked suspend / resume support -- * support is currently quite missing, all what is done is on interface drivers * needs power management * streaming makes it hard * quite a lot work to get it working in case of straming is ongoing use Kernel power management instead of own -- * there seems to be Kernel services for power-management * study if it is wise to use Kernel services instead of own * own PM is still working very well, at least I dont know any problems SDR - Softaware Defined Radio support DVB API -- * http://comments.gmane.org/gmane.linux.drivers.video-input-infrastructure/44461 * there is existing devices that are SDR (RTL2832U "rtl-sdr") * SDR is quite near what is digital TV streaming * study what is needed * new delivery system for frontend API called SDR? * some core changes needed, like status (is locked etc) * how about demuxer? * stream conversion, inside Kernel? * what are new parameters needed for DVB API? DTMB standard support for DVB API -- * it is Chinese DTV standard * I already ran RFC but have been too busy for implementing it :] LNA (low-noise amplifier) support for DVB API -- * there is quite a lot of devices having LNA * currently not supported => LNA is configured off typically offer polling method for statistics -- * many static counters could not be read as a "one go" * typical cycle is : start measurement => wait => read counters * some drivers starts own internal work-queue for polling (complexity) * some drivers blocks IOCTL when taking measurement (bad) fix frontend properties -- * those has been broken since MFE => SFE change * currently implemented as a properties per driver * need to be properties per delivery system * are broken because driver/chip could support multiple DTV standards regards Antti -- http://palosaari.fi/ -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 7/8] soc-camera: Add and use soc_camera_power_[on|off]() helper functions
Hi Guennadi, Thanks for the review. On Thursday 21 June 2012 23:15:14 Guennadi Liakhovetski wrote: > On Wed, 23 May 2012, Laurent Pinchart wrote: > > Instead of forcing all soc-camera drivers to go through the mid-layer to > > handle power management, create soc_camera_power_[on|off]() functions > > that can be called from the subdev .s_power() operation to manage > > regulators and platform-specific power handling. This allows non > > soc-camera hosts to use soc-camera-aware clients. > > > > Signed-off-by: Laurent Pinchart [snip] > > diff --git a/drivers/media/video/imx074.c b/drivers/media/video/imx074.c > > index 351e9ba..1166c89 100644 > > --- a/drivers/media/video/imx074.c > > +++ b/drivers/media/video/imx074.c > > @@ -268,6 +268,17 @@ static int imx074_g_chip_ident(struct v4l2_subdev [snip] > > +static int imx074_s_power(struct v4l2_subdev *sd, int on) > > +{ > > + struct i2c_client *client = v4l2_get_subdevdata(sd); > > + struct soc_camera_link *icl = soc_camera_i2c_to_link(client); > > + > > + if (on) > > + return soc_camera_power_on(&client->dev, icl); > > + else > > + return soc_camera_power_off(&client->dev, icl); > > I think an inline function would be nice for these to just write in most > of your converted drivers > > return soc_camera_s_power(&client->dev, icl, on); OK. > > +} [snip] > > diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c > > index b0c5299..b9bfb4f 100644 > > --- a/drivers/media/video/mt9m111.c > > +++ b/drivers/media/video/mt9m111.c > > @@ -832,10 +832,35 @@ static int mt9m111_video_probe(struct i2c_client > > *client)> > > return v4l2_ctrl_handler_setup(&mt9m111->hdl); > > > > } > > > > +static int mt9m111_power_on(struct mt9m111 *mt9m111) > > +{ > > + struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); > > + struct soc_camera_link *icl = soc_camera_i2c_to_link(client); > > + int ret; > > + > > + ret = soc_camera_power_on(&client->dev, icl); > > + if (ret < 0) > > + return ret; > > + > > + ret = mt9m111_resume(mt9m111); > > + if (ret < 0) > > + dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret); > > What do you think, don't we have to soc_camera_power_off() if the above > resume fails? At least I was doing that in the original > soc_camera_power_on() and you also preserve it that way. I agree. I'll fix that. > > + > > + return ret; > > +} [snip] > > diff --git a/drivers/media/video/ov5642.c b/drivers/media/video/ov5642.c > > index 0bc9331..98de102 100644 > > --- a/drivers/media/video/ov5642.c > > +++ b/drivers/media/video/ov5642.c > > @@ -933,13 +933,20 @@ static int ov5642_g_mbus_config(struct v4l2_subdev > > *sd,> > > static int ov5642_s_power(struct v4l2_subdev *sd, int on) > > { > > - struct i2c_client *client; > > + struct i2c_client *client = v4l2_get_subdevdata(sd); > > + struct soc_camera_link *icl = soc_camera_i2c_to_link(client); > > int ret; > > > > + if (on) > > + ret = soc_camera_power_on(&client->dev, icl); > > + else > > + ret = soc_camera_power_off(&client->dev, icl); > > + if (ret < 0) > > + return ret; > > + > > if (!on) > > return 0; > > How about > > if (!on) > return soc_camera_power_off(&client->dev, icl); > > ret = soc_camera_power_on(&client->dev, icl); > if (ret < 0) > ... That looks good to me. > > - client = v4l2_get_subdevdata(sd); > > > > ret = ov5642_write_array(client, ov5642_default_regs_init); > > if (!ret) > > ret = ov5642_set_resolution(sd); > > [snip] > > diff --git a/drivers/media/video/sh_mobile_csi2.c > > b/drivers/media/video/sh_mobile_csi2.c index 0528650..88c6911 100644 > > --- a/drivers/media/video/sh_mobile_csi2.c > > +++ b/drivers/media/video/sh_mobile_csi2.c > > @@ -276,12 +276,20 @@ static void sh_csi2_client_disconnect(struct sh_csi2 > > *priv)> > > static int sh_csi2_s_power(struct v4l2_subdev *sd, int on) > > { > > + struct i2c_client *client = v4l2_get_subdevdata(sd); > > + struct soc_camera_link *icl = soc_camera_i2c_to_link(client); > > struct sh_csi2 *priv = container_of(sd, struct sh_csi2, subdev); > > + int ret; > > > > - if (on) > > + if (on) { > > + ret = soc_camera_power_on(&client->dev, icl); > > + if (ret < 0) > > + return ret; > > > > return sh_csi2_client_connect(priv); > > + } > > > > sh_csi2_client_disconnect(priv); > > > > + soc_camera_power_off(&client->dev, icl); > > > > return 0; > > Actually, I might have confused you on this one, sorry. This is not an > external device, and as such it cannot have platform .s_power() callbacks > or regulators to switch its power. So, maybe we don't have to patch this > one at all? Good, I'll skip it :-) > > } > > > > diff --git a/drivers/media/video/soc_camera.c > > b/drivers/media/video/soc_camer
[PATCH] [V2] stv090x: variable 'no_signal' set but not used
Remove variable and ignore return value of stv090x_chk_signal(). Tested by compilation only. Signed-off-by: Peter Senna Tschudin --- drivers/media/dvb/frontends/stv090x.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index d79e69f..a4d5954 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c @@ -3172,7 +3172,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) enum stv090x_signal_state signal_state = STV090x_NOCARRIER; u32 reg; s32 agc1_power, power_iq = 0, i; - int lock = 0, low_sr = 0, no_signal = 0; + int lock = 0, low_sr = 0; reg = STV090x_READ_DEMOD(state, TSCFGH); STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* Stop path 1 stream merger */ @@ -3413,7 +3413,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) goto err; } else { signal_state = STV090x_NODATA; - no_signal = stv090x_chk_signal(state); + (void) stv090x_chk_signal(state); } } return signal_state; -- 1.7.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/8] ov2640: Don't access the device in the g_mbus_fmt operation
Hi Guennadi, Thanks for the review. On Thursday 21 June 2012 14:28:04 Guennadi Liakhovetski wrote: > On Wed, 23 May 2012, Laurent Pinchart wrote: > > The g_mbus_fmt operation only needs to return the current mbus frame > > format and doesn't need to configure the hardware to do so. Fix it to > > avoid requiring the chip to be powered on when calling the operation. > > > > Signed-off-by: Laurent Pinchart > > --- > > > > drivers/media/video/ov2640.c |5 + > > 1 files changed, 1 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/media/video/ov2640.c b/drivers/media/video/ov2640.c > > index 3c2c5d3..d9a427c 100644 > > --- a/drivers/media/video/ov2640.c > > +++ b/drivers/media/video/ov2640.c > > @@ -837,10 +837,7 @@ static int ov2640_g_fmt(struct v4l2_subdev *sd, > > > > if (!priv->win) { > > > > u32 width = W_SVGA, height = H_SVGA; > > > > - int ret = ov2640_set_params(client, &width, &height, > > - V4L2_MBUS_FMT_UYVY8_2X8); > > - if (ret < 0) > > - return ret; > > + priv->win = ov2640_select_win(&width, &height); > > I think you also have to set > > priv->cfmt_code = V4L2_MBUS_FMT_UYVY8_2X8; You're right. I'll fix that. -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: dheitmueller/cx23885_fixes.git and mygica x8507
Hi El 27/06/12 01:52, Devin Heitmueller escribió: On Tue, Jun 26, 2012 at 11:40 PM, Alfredo Jesús Delaiti wrote: The problem was that tvtime was set to 768, by passing a resolution to 720 was solved. Sorry for not having tried before. With a resolution of 720 pixels the image looks good. My sincere apologies and thanks. I'll have to check if that's a driver bug or not. The way the logic is supposed to work is the application is supposed to propose a size, and if the driver concludes the size is unacceptable it should return the size that it intends to actually operate at. The application is expected to read the resulting size from the driver and adjust accordingly. Hence, either: 1. the driver is saying "ok" to 768 and then tvtime receives green video from the driver. 2. the driver properly returns 720 when asked for 768, but tvtime doesn't check for the adjusted size. Scenario #1 is a driver bug, and scenario #2 is a tvtime bug. Devin What I can I do to know what is the problem? I tried the following: I have two cards, one FlyVideo 3000 that has no problems with TVTime to change the resolution (no green line on the right side) and over the X8507 has the problem. With the X8507 card with the resolution set at 768 pixels, if I change the TV standards NTSC, PAL-M, PAL-N, NTSC-JP no green line(Of course the image is distorted). If change to Pal, Pal-Nc and Pal-60 shows the green line. Always using TVTime. Output of TVTime at 768 first and 720 below alfredo@dhcppc1:/usr/share/man/es> tvtime -v --device=/dev/video1 Ejecutando tvtime 1.0.2. Leyendo la configuración de /etc/tvtime/tvtime.xml Leyendo la configuración de /home/alfredo/.tvtime/tvtime.xml cpuinfo: CPU AMD Phenom(tm) 8450 Triple-Core Processor, family 15, model 2, stepping 3. cpuinfo: CPU measured at 2104,519MHz. tvtime: Cannot set priority to -10: Permiso denegado. xcommon: Display :0, vendor The X.Org Foundation, vendor release 10903000 xfullscreen: Using XINERAMA for dual-head information. xfullscreen: Pixels are square. xfullscreen: Number of displays is 1. xfullscreen: Head 0 at 0,0 with size 1920x1080. xcommon: Have XTest, will use it to ping the screensaver. xcommon: Pixel aspect ratio 1:1. xcommon: Pixel aspect ratio 1:1. xcommon: Window manager is KWin and is EWMH compliant. xcommon: Using EWMH state fullscreen property. xcommon: Using EWMH state above property. xcommon: Using EWMH state below property. xcommon: Pixel aspect ratio 1:1. xcommon: Displaying in a 768x576 window inside 768x576 space. xvoutput: Using XVIDEO adaptor 63: Radeon Textured Video. speedycode: Using MMXEXT optimized functions. station: Reading stationlist from /home/alfredo/.tvtime/stationlist.xml videoinput: Using video4linux2 driver 'cx23885', card 'Mygica X8507' (bus PCIe::02:00.0). videoinput: Version is 197635, capabilities 5010011. videoinput: Maximum input width: 768 pixels. tvtime: Sampling input at 768 pixels per scanline. xcommon: Pixel aspect ratio 1:1. xcommon: Displaying in a 768x576 window inside 768x576 space. xcommon: Received a map, marking window as visible (58). tvtime: Cleaning up. Gracias por usar tvtime. alfredo@dhcppc1:/usr/share/man/es> tvtime -v --device=/dev/video1 Ejecutando tvtime 1.0.2. Leyendo la configuración de /etc/tvtime/tvtime.xml Leyendo la configuración de /home/alfredo/.tvtime/tvtime.xml cpuinfo: CPU AMD Phenom(tm) 8450 Triple-Core Processor, family 15, model 2, stepping 3. cpuinfo: CPU measured at 2104,500MHz. tvtime: Cannot set priority to -10: Permiso denegado. xcommon: Display :0, vendor The X.Org Foundation, vendor release 10903000 xfullscreen: Using XINERAMA for dual-head information. xfullscreen: Pixels are square. xfullscreen: Number of displays is 1. xfullscreen: Head 0 at 0,0 with size 1920x1080. xcommon: Have XTest, will use it to ping the screensaver. xcommon: Pixel aspect ratio 1:1. xcommon: Pixel aspect ratio 1:1. xcommon: Window manager is KWin and is EWMH compliant. xcommon: Using EWMH state fullscreen property. xcommon: Using EWMH state above property. xcommon: Using EWMH state below property. xcommon: Pixel aspect ratio 1:1. xcommon: Displaying in a 768x576 window inside 768x576 space. xvoutput: Using XVIDEO adaptor 63: Radeon Textured Video. speedycode: Using MMXEXT optimized functions. station: Reading stationlist from /home/alfredo/.tvtime/stationlist.xml videoinput: Using video4linux2 driver 'cx23885', card 'Mygica X8507' (bus PCIe::02:00.0). videoinput: Version is 197635, capabilities 5010011. videoinput: Maximum input width: 768 pixels. tvtime: Sampling input at 720 pixels per scanline. xcommon: Pixel aspect ratio 1:1. xcommon: Displaying in a 768x576 window inside 768x576 space. xcommon: Received a map, marking window as visible (60). tvtime: Cleaning up. Gracias por usar tvtime. Thank you very much for your help and time. Alfredo -- Dona tu voz http://www.voxforge.org/es -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of
Re: [ 3960.758784] 1 lock held by motion/7776: [ 3960.758788] #0: (&queue->mutex){......}, at: [] uvc_queue_enable+0x32/0xc0
Monday, May 7, 2012, 3:28:36 PM, you wrote: > Hi, > On 05/07/2012 01:44 PM, Hans Verkuil wrote: >> On Monday 07 May 2012 13:06:01 Laurent Pinchart wrote: >>> Hi Sanser, >>> >>> On Sunday 06 May 2012 16:54:40 Sander Eikelenboom wrote: Hello Laurent / Mauro, I have updated to latest 3.4-rc5-tip, running multiple video grabbers. I don't see anything specific to uvcvideo anymore, but i do get the possible circular locking dependency below. >>> >>> Thanks for the report. >>> >>> We indeed have a serious issue there (CC'ing Hans Verkuil). >>> >>> Hans, serializing both ioctl handling an mmap with a single device lock as >>> we >>> currently do in V4L2 is prone to AB-BA deadlocks (uvcvideo shouldn't be >>> affected as it has no device-wide lock). >>> >>> If we want to keep a device-wide lock we need to take it after the mm- mmap_sem lock in all code paths, as there's no way we can change the lock >>> ordering for mmap(). The copy_from_user/copy_to_user issue could be solved >>> by >>> moving locking from v4l2_ioctl to __video_do_ioctl (device-wide locks would >>> then require using video_ioctl2), but I'm not sure whether that will play >>> nicely with the QBUF implementation in videobuf2 (which already includes a >>> workaround for this particular AB-BA deadlock issue). >> >> I've seen the same thing. It was on my TODO list of things to look into. I >> think >> mmap shouldn't take the device wide lock at all. But it will mean reviewing >> affected drivers before I can remove it. >> >> To be honest, I wasn't sure whether or not to take the device lock for mmap >> when >> I first wrote that code. >> >> If you look at irc I had a discussion today with HdG about adding flags to >> selectively disable locks for fops. It may be an idea to implement this soon >> so >> we can start updating drivers one-by-one. > I've a patch almost ready for this, when I'm happy with it I'll send of a new > version of the (ever growing) gspca use control framework patchset both me and > the other Hans have been working on, which will include this patch. Hi Hans, Is there any progress on this ? It still happens when booting with a 3.5-rc4 kernel. Probably with either the PWC or the em28xx driver. -- Sander > Regards, > Hans -- Best regards, Sandermailto:li...@eikelenboom.it -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv7 03/15] v4l: vb2: add support for shared buffer (dma_buf)
Hi Dima, On Tuesday 26 June 2012 13:53:34 Dima Zavin wrote: > On Tue, Jun 26, 2012 at 2:40 AM, Hans Verkuil wrote: > > On Tue 26 June 2012 11:11:06 Laurent Pinchart wrote: > >> On Tuesday 26 June 2012 10:40:44 Tomasz Stanislawski wrote: > >> > Hi Dima Zavin, > >> > Thank you for the patch and for a ping remainder :). > >> > > >> > You are right. The unmap is missing in __vb2_queue_cancel. > >> > I will apply your fix into next version of V4L2 support for dmabuf. > >> > > >> > Please refer to some comments below. > >> > > >> > On 06/20/2012 08:12 AM, Dima Zavin wrote: > >> > > Tomasz, > >> > > > >> > > I've encountered an issue with this patch when userspace does several > >> > > stream_on/stream_off cycles. When the user tries to qbuf a buffer > >> > > after doing stream_off, we trigger the "dmabuf already pinned" > >> > > warning since we didn't unmap the buffer as dqbuf was never called. > >> > > > >> > > The below patch adds calls to unmap in queue_cancel, but my feeling > >> > > is that we probably should be calling detach too (i.e. put_dmabuf). > >> > >> According to the V4L2 specification, the "VIDIOC_STREAMOFF ioctl, apart > >> of aborting or finishing any DMA in progress, unlocks any user pointer > >> buffers locked in physical memory, and it removes all buffers from the > >> incoming and outgoing queues". > > > > Correct. And what that means in practice is that after a streamoff all > > buffers are returned to the state they had just before STREAMON was > > called. > > That can't be right. The buffers had to have been returned to the > state just *after REQBUFS*, not just *before STREAMON*. You need to > re-enqueue buffers before calling STREAMON. I assume that's what you > meant? Your interpretation is correct. > > So after STREAMOFF you can immediately queue all buffers again with QBUF > > and call STREAMON to restart streaming. No mmap or other operations > > should be required. This behavior must be kept. > > > > VIDIOC_REQBUFS() or a close() are the only two operations that will > > actually free the buffers completely. > > > > In practice, a STREAMOFF is either followed by a STREAMON at a later time, > > or almost immediately followed by REQBUFS or close() to tear down the > > buffers. So I don't think the buffers should be detached at streamoff. > > I agree. I was leaning this way which is why I left it out of my patch > and wanted to hear your guys' opinion as you are much more familiar > with the intended behavior than I am. > > Thanks! You're welcome. Thank you for reporting the problem and providing a patch. -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
cron job: media_tree daily build: ERRORS
This message is generated daily by a cron job that builds media_tree for the kernels and architectures in the list below. Results of the daily build of media_tree: date:Wed Jun 27 19:00:22 CEST 2012 git hash:5472d3f17845c4398c6a510b46855820920c2181 gcc version: i686-linux-gcc (GCC) 4.7.1 host hardware:x86_64 host os: 3.4.07-marune linux-git-arm-eabi-davinci: WARNINGS linux-git-arm-eabi-exynos: WARNINGS linux-git-arm-eabi-omap: WARNINGS linux-git-i686: WARNINGS linux-git-m32r: WARNINGS linux-git-mips: WARNINGS linux-git-powerpc64: WARNINGS linux-git-x86_64: WARNINGS linux-2.6.31.12-x86_64: WARNINGS linux-2.6.32.6-x86_64: WARNINGS linux-2.6.33-x86_64: WARNINGS linux-2.6.34-x86_64: WARNINGS linux-2.6.35.3-x86_64: WARNINGS linux-2.6.36-x86_64: WARNINGS linux-2.6.37-x86_64: WARNINGS linux-2.6.38.2-x86_64: WARNINGS linux-2.6.39.1-x86_64: WARNINGS linux-3.0-x86_64: WARNINGS linux-3.1-x86_64: WARNINGS linux-3.2.1-x86_64: WARNINGS linux-3.3-x86_64: WARNINGS linux-3.4-x86_64: WARNINGS linux-2.6.31.12-i686: WARNINGS linux-2.6.32.6-i686: WARNINGS linux-2.6.33-i686: WARNINGS linux-2.6.34-i686: WARNINGS linux-2.6.35.3-i686: WARNINGS linux-2.6.36-i686: WARNINGS linux-2.6.37-i686: WARNINGS linux-2.6.38.2-i686: WARNINGS linux-2.6.39.1-i686: WARNINGS linux-3.0-i686: WARNINGS linux-3.1-i686: WARNINGS linux-3.2.1-i686: WARNINGS linux-3.3-i686: WARNINGS linux-3.4-i686: WARNINGS apps: ERRORS spec-git: WARNINGS sparse: ERRORS Detailed results are available here: http://www.xs4all.nl/~hverkuil/logs/Wednesday.log Full logs are available here: http://www.xs4all.nl/~hverkuil/logs/Wednesday.tar.bz2 The V4L-DVB specification from this daily build is here: http://www.xs4all.nl/~hverkuil/spec/media.html -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/9] cx23885: Remove useless struct i2c_algo_bit_data
The field 'struct i2c_algo_bit_data i2c_algo' is wrongly confused with struct i2c_algorithm. Moreover, i2c_algo field is not used since i2c is registered using i2c_add_adpater() and not i2c_bit_add_bus(). Therefore, it's safe to remove it. Tested by compilation only. Signed-off-by: Ezequiel Garcia --- drivers/media/video/cx23885/cx23885-i2c.c |3 --- drivers/media/video/cx23885/cx23885.h |2 -- drivers/media/video/saa7164/saa7164.h |1 - 3 files changed, 0 insertions(+), 6 deletions(-) diff --git a/drivers/media/video/cx23885/cx23885-i2c.c b/drivers/media/video/cx23885/cx23885-i2c.c index be1e21d..615c71f 100644 --- a/drivers/media/video/cx23885/cx23885-i2c.c +++ b/drivers/media/video/cx23885/cx23885-i2c.c @@ -318,8 +318,6 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) memcpy(&bus->i2c_adap, &cx23885_i2c_adap_template, sizeof(bus->i2c_adap)); - memcpy(&bus->i2c_algo, &cx23885_i2c_algo_template, - sizeof(bus->i2c_algo)); memcpy(&bus->i2c_client, &cx23885_i2c_client_template, sizeof(bus->i2c_client)); @@ -328,7 +326,6 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); - bus->i2c_algo.data = bus; bus->i2c_adap.algo_data = bus; i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); i2c_add_adapter(&bus->i2c_adap); diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h index d884784..3cf397f 100644 --- a/drivers/media/video/cx23885/cx23885.h +++ b/drivers/media/video/cx23885/cx23885.h @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -246,7 +245,6 @@ struct cx23885_i2c { /* i2c i/o */ struct i2c_adapter i2c_adap; - struct i2c_algo_bit_data i2c_algo; struct i2c_client i2c_client; u32i2c_rc; diff --git a/drivers/media/video/saa7164/saa7164.h b/drivers/media/video/saa7164/saa7164.h index fc1f854..35219b9 100644 --- a/drivers/media/video/saa7164/saa7164.h +++ b/drivers/media/video/saa7164/saa7164.h @@ -46,7 +46,6 @@ #include #include -#include #include #include #include -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/9] saa7164: Remove useless struct i2c_algo_bit_data
The field 'struct i2c_algo_bit_data i2c_algo' is wrongly confused with struct i2c_algorithm. Moreover, i2c_algo field is not used since i2c is registered using i2c_add_adpater() and not i2c_bit_add_bus(). Therefore, it's safe to remove it. Tested by compilation only. Signed-off-by: Ezequiel Garcia --- drivers/media/video/saa7164/saa7164-i2c.c |4 drivers/media/video/saa7164/saa7164.h |1 - 2 files changed, 0 insertions(+), 5 deletions(-) diff --git a/drivers/media/video/saa7164/saa7164-i2c.c b/drivers/media/video/saa7164/saa7164-i2c.c index 26148f7..1c54ab4 100644 --- a/drivers/media/video/saa7164/saa7164-i2c.c +++ b/drivers/media/video/saa7164/saa7164-i2c.c @@ -109,9 +109,6 @@ int saa7164_i2c_register(struct saa7164_i2c *bus) memcpy(&bus->i2c_adap, &saa7164_i2c_adap_template, sizeof(bus->i2c_adap)); - memcpy(&bus->i2c_algo, &saa7164_i2c_algo_template, - sizeof(bus->i2c_algo)); - memcpy(&bus->i2c_client, &saa7164_i2c_client_template, sizeof(bus->i2c_client)); @@ -120,7 +117,6 @@ int saa7164_i2c_register(struct saa7164_i2c *bus) strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); - bus->i2c_algo.data = bus; bus->i2c_adap.algo_data = bus; i2c_set_adapdata(&bus->i2c_adap, bus); i2c_add_adapter(&bus->i2c_adap); diff --git a/drivers/media/video/saa7164/saa7164.h b/drivers/media/video/saa7164/saa7164.h index 8d120e3..fc1f854 100644 --- a/drivers/media/video/saa7164/saa7164.h +++ b/drivers/media/video/saa7164/saa7164.h @@ -251,7 +251,6 @@ struct saa7164_i2c { /* I2C I/O */ struct i2c_adapter i2c_adap; - struct i2c_algo_bit_datai2c_algo; struct i2c_client i2c_client; u32 i2c_rc; }; -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 9/9] cx25821: Replace struct memcpy with struct assignment
Copying structs by assignment is type safe. Plus, is shorter and easier to read. Signed-off-by: Ezequiel Garcia --- drivers/media/video/cx25821/cx25821-i2c.c |7 ++- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/video/cx25821/cx25821-i2c.c b/drivers/media/video/cx25821/cx25821-i2c.c index 0a44b4e..9844549 100644 --- a/drivers/media/video/cx25821/cx25821-i2c.c +++ b/drivers/media/video/cx25821/cx25821-i2c.c @@ -305,11 +305,8 @@ int cx25821_i2c_register(struct cx25821_i2c *bus) dprintk(1, "%s(bus = %d)\n", __func__, bus->nr); - memcpy(&bus->i2c_adap, &cx25821_i2c_adap_template, - sizeof(bus->i2c_adap)); - memcpy(&bus->i2c_client, &cx25821_i2c_client_template, - sizeof(bus->i2c_client)); - + bus->i2c_adap = cx25821_i2c_adap_template; + bus->i2c_client = cx25821_i2c_client_template; bus->i2c_adap.dev.parent = &dev->pci->dev; strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/9] saa7164: Replace struct memcpy with struct assignment
Copying structs by assignment is type safe. Plus, is shorter and easier to read. Signed-off-by: Ezequiel Garcia --- drivers/media/video/saa7164/saa7164-i2c.c |7 ++- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/video/saa7164/saa7164-i2c.c b/drivers/media/video/saa7164/saa7164-i2c.c index d8d7baa..4f7e3b4 100644 --- a/drivers/media/video/saa7164/saa7164-i2c.c +++ b/drivers/media/video/saa7164/saa7164-i2c.c @@ -97,11 +97,8 @@ int saa7164_i2c_register(struct saa7164_i2c *bus) dprintk(DBGLVL_I2C, "%s(bus = %d)\n", __func__, bus->nr); - memcpy(&bus->i2c_adap, &saa7164_i2c_adap_template, - sizeof(bus->i2c_adap)); - - memcpy(&bus->i2c_client, &saa7164_i2c_client_template, - sizeof(bus->i2c_client)); + bus->i2c_adap = saa7164_i2c_adap_template; + bus->i2c_client = saa7164_i2c_client_template; bus->i2c_adap.dev.parent = &dev->pci->dev; -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 8/9] cx231xx: Replace struct memcpy with struct assignment
Copying structs by assignment is type safe. Plus, is shorter and easier to read. Signed-off-by: Ezequiel Garcia --- drivers/media/video/cx231xx/cx231xx-i2c.c |6 ++ 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/cx231xx/cx231xx-i2c.c b/drivers/media/video/cx231xx/cx231xx-i2c.c index 7c0ed1b..781feed 100644 --- a/drivers/media/video/cx231xx/cx231xx-i2c.c +++ b/drivers/media/video/cx231xx/cx231xx-i2c.c @@ -499,10 +499,8 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus) BUG_ON(!dev->cx231xx_send_usb_command); - memcpy(&bus->i2c_adap, &cx231xx_adap_template, sizeof(bus->i2c_adap)); - memcpy(&bus->i2c_client, &cx231xx_client_template, - sizeof(bus->i2c_client)); - + bus->i2c_adap = cx231xx_adap_template; + bus->i2c_client = cx231xx_client_template; bus->i2c_adap.dev.parent = &dev->udev->dev; strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 7/9] cx23885: Replace struct memcpy with struct assignment
Copying structs by assignment is type safe. Plus, is shorter and easier to read. Signed-off-by: Ezequiel Garcia --- drivers/media/video/cx23885/cx23885-i2c.c |7 ++- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/video/cx23885/cx23885-i2c.c b/drivers/media/video/cx23885/cx23885-i2c.c index 615c71f..4887314 100644 --- a/drivers/media/video/cx23885/cx23885-i2c.c +++ b/drivers/media/video/cx23885/cx23885-i2c.c @@ -316,11 +316,8 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) dprintk(1, "%s(bus = %d)\n", __func__, bus->nr); - memcpy(&bus->i2c_adap, &cx23885_i2c_adap_template, - sizeof(bus->i2c_adap)); - memcpy(&bus->i2c_client, &cx23885_i2c_client_template, - sizeof(bus->i2c_client)); - + bus->i2c_adap = cx23885_i2c_adap_template; + bus->i2c_client = cx23885_i2c_client_template; bus->i2c_adap.dev.parent = &dev->pci->dev; strlcpy(bus->i2c_adap.name, bus->dev->name, -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/9] saa7164: Remove unused saa7164_call_i2c_clients()
This function has no users, so it's safe to remove it. Tested by compilation only. Signed-off-by: Ezequiel Garcia --- drivers/media/video/saa7164/saa7164-i2c.c |9 - 1 files changed, 0 insertions(+), 9 deletions(-) diff --git a/drivers/media/video/saa7164/saa7164-i2c.c b/drivers/media/video/saa7164/saa7164-i2c.c index 1c54ab4..d8d7baa 100644 --- a/drivers/media/video/saa7164/saa7164-i2c.c +++ b/drivers/media/video/saa7164/saa7164-i2c.c @@ -69,15 +69,6 @@ err: return retval; } -void saa7164_call_i2c_clients(struct saa7164_i2c *bus, unsigned int cmd, - void *arg) -{ - if (bus->i2c_rc != 0) - return; - - i2c_clients_command(&bus->i2c_adap, cmd, arg); -} - static u32 saa7164_functionality(struct i2c_adapter *adap) { return I2C_FUNC_I2C; -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/9] cx25821: Remove useless struct i2c_algo_bit_data
The field 'struct i2c_algo_bit_data i2c_algo' is wrongly confused with struct i2c_algorithm. Moreover, i2c_algo field is not used since i2c is registered using i2c_add_adpater() and not i2c_bit_add_bus(). Therefore, it's safe to remove it. Tested by compilation only. Signed-off-by: Ezequiel Garcia --- drivers/media/video/cx25821/cx25821-i2c.c |3 --- drivers/media/video/cx25821/cx25821.h |2 -- 2 files changed, 0 insertions(+), 5 deletions(-) diff --git a/drivers/media/video/cx25821/cx25821-i2c.c b/drivers/media/video/cx25821/cx25821-i2c.c index 6311180..0a44b4e 100644 --- a/drivers/media/video/cx25821/cx25821-i2c.c +++ b/drivers/media/video/cx25821/cx25821-i2c.c @@ -307,8 +307,6 @@ int cx25821_i2c_register(struct cx25821_i2c *bus) memcpy(&bus->i2c_adap, &cx25821_i2c_adap_template, sizeof(bus->i2c_adap)); - memcpy(&bus->i2c_algo, &cx25821_i2c_algo_template, - sizeof(bus->i2c_algo)); memcpy(&bus->i2c_client, &cx25821_i2c_client_template, sizeof(bus->i2c_client)); @@ -316,7 +314,6 @@ int cx25821_i2c_register(struct cx25821_i2c *bus) strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); - bus->i2c_algo.data = bus; bus->i2c_adap.algo_data = bus; i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); i2c_add_adapter(&bus->i2c_adap); diff --git a/drivers/media/video/cx25821/cx25821.h b/drivers/media/video/cx25821/cx25821.h index b9aa801..ed52501 100644 --- a/drivers/media/video/cx25821/cx25821.h +++ b/drivers/media/video/cx25821/cx25821.h @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -213,7 +212,6 @@ struct cx25821_i2c { /* i2c i/o */ struct i2c_adapter i2c_adap; - struct i2c_algo_bit_data i2c_algo; struct i2c_client i2c_client; u32 i2c_rc; -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/9] cx231xx: Remove useless struct i2c_algo_bit_data
The field 'struct i2c_algo_bit_data i2c_algo' is wrongly confused with struct i2c_algorithm. Moreover, i2c_algo field is not used since i2c is registered using i2c_add_adpater() and not i2c_bit_add_bus(). Therefore, it's safe to remove it. Tested by compilation only. Signed-off-by: Ezequiel Garcia --- drivers/media/video/cx231xx/cx231xx-i2c.c |2 -- drivers/media/video/cx231xx/cx231xx.h |2 -- 2 files changed, 0 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/cx231xx/cx231xx-i2c.c b/drivers/media/video/cx231xx/cx231xx-i2c.c index 925f3a0..7c0ed1b 100644 --- a/drivers/media/video/cx231xx/cx231xx-i2c.c +++ b/drivers/media/video/cx231xx/cx231xx-i2c.c @@ -500,7 +500,6 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus) BUG_ON(!dev->cx231xx_send_usb_command); memcpy(&bus->i2c_adap, &cx231xx_adap_template, sizeof(bus->i2c_adap)); - memcpy(&bus->i2c_algo, &cx231xx_algo, sizeof(bus->i2c_algo)); memcpy(&bus->i2c_client, &cx231xx_client_template, sizeof(bus->i2c_client)); @@ -508,7 +507,6 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus) strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); - bus->i2c_algo.data = bus; bus->i2c_adap.algo_data = bus; i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); i2c_add_adapter(&bus->i2c_adap); diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h index e174475..a89d020 100644 --- a/drivers/media/video/cx231xx/cx231xx.h +++ b/drivers/media/video/cx231xx/cx231xx.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -481,7 +480,6 @@ struct cx231xx_i2c { /* i2c i/o */ struct i2c_adapter i2c_adap; - struct i2c_algo_bit_data i2c_algo; struct i2c_client i2c_client; u32 i2c_rc; -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/9] struct i2c_algo_bit_data cleanup on several drivers
Hi Mauro, This patchset cleans the i2c part of some drivers. This issue was recently reported by Dan Carpenter [1], and revealed wrong (and harmless) usage of struct i2c_algo_bit_data. This series consist in two kinds of patches: - remove one unused function - remove unused field i2c_algo - replace struct memcpy with struct assignment This last change is, in my opinion, a much safer way for struct filling and (in this case) I'm not aware of any change in functionality. Also I've dropped i2c_rc cleaning entirely. I'm still working on these and they are not related to this patchset. As I don't own any of these devices, I can't test the changes beyond compilation. Changes from v1: - Drop i2c_rc clean patches - Verbose commit messages Ezequiel Garcia (9): cx25821: Replace struct memcpy with struct assignment cx231xx: Replace struct memcpy with struct assignment cx23885: Replace struct memcpy with struct assignment saa7164: Replace struct memcpy with struct assignment saa7164: Remove unused saa7164_call_i2c_clients() cx25821: Remove useless struct i2c_algo_bit_data cx231xx: Remove useless struct i2c_algo_bit_data cx23885: Remove useless struct i2c_algo_bit_data saa7164: Remove useless struct i2c_algo_bit_data drivers/media/video/cx231xx/cx231xx-i2c.c |8 ++-- drivers/media/video/cx231xx/cx231xx.h |2 -- drivers/media/video/cx23885/cx23885-i2c.c | 10 ++ drivers/media/video/cx23885/cx23885.h |2 -- drivers/media/video/cx25821/cx25821-i2c.c | 10 ++ drivers/media/video/cx25821/cx25821.h |2 -- drivers/media/video/saa7164/saa7164-i2c.c | 20 ++-- drivers/media/video/saa7164/saa7164.h |2 -- 8 files changed, 8 insertions(+), 48 deletions(-) Thanks, Ezequiel. [1] http://comments.gmane.org/gmane.linux.drivers.video-input-infrastructure/49553 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [git:v4l-dvb/for_v3.6] [media] stv090x: variable 'no_signal' set but not used
Manu, On Wed, Jun 27, 2012 at 9:59 AM, Manu Abraham wrote: > Wonderful, instead of ignoring the return value, you ignored the whole > function > itself. Most of the demodulator registers are R-M-x registers. The patch > brings > in unwanted side-effects of R-M-x. Sorry for that. I'll send V2 of this patch just ignoring the return value. Can you please send me some reference about R-M-x registers? > > Please revert this patch. > > Thanks, > Manu Thanks, Peter > > > On Fri, Jun 22, 2012 at 2:28 AM, Mauro Carvalho Chehab > wrote: >> >> This is an automatic generated email to let you know that the following >> patch were queued at the >> http://git.linuxtv.org/media_tree.git tree: >> >> Subject: [media] stv090x: variable 'no_signal' set but not used >> Author: Â Peter Senna Tschudin >> Date: Â Â Thu Jun 14 13:58:15 2012 -0300 >> >> Tested by compilation only. >> >> Signed-off-by: Peter Senna Tschudin >> Signed-off-by: Mauro Carvalho Chehab >> >> Â drivers/media/dvb/frontends/stv090x.c | Â Â 7 +++ >> Â 1 files changed, 3 insertions(+), 4 deletions(-) >> >> --- >> >> >> http://git.linuxtv.org/media_tree.git?a=commitdiff;h=59f6a93fae656409042c8a55e8b9088893c40378 >> >> diff --git a/drivers/media/dvb/frontends/stv090x.c >> b/drivers/media/dvb/frontends/stv090x.c >> index d79e69f..d229dba 100644 >> --- a/drivers/media/dvb/frontends/stv090x.c >> +++ b/drivers/media/dvb/frontends/stv090x.c >> @@ -3172,7 +3172,7 @@ static enum stv090x_signal_state stv090x_algo(struct >> stv090x_state *state) >> Â Â Â Â enum stv090x_signal_state signal_state = STV090x_NOCARRIER; >> Â Â Â Â u32 reg; >> Â Â Â Â s32 agc1_power, power_iq = 0, i; >> - Â Â Â int lock = 0, low_sr = 0, no_signal = 0; >> + Â Â Â int lock = 0, low_sr = 0; >> >> Â Â Â Â reg = STV090x_READ_DEMOD(state, TSCFGH); >> Â Â Â Â STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* Stop path 1 stream >> merger */ >> @@ -3411,10 +3411,9 @@ static enum stv090x_signal_state >> stv090x_algo(struct stv090x_state *state) >> Â Â Â Â Â Â Â Â Â Â Â Â /* Reset the packet Error counter2 */ >> Â Â Â Â Â Â Â Â Â Â Â Â if (STV090x_WRITE_DEMOD(state, ERRCTRL2, 0xc1) < 0) >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â goto err; >> - Â Â Â Â Â Â Â } else { >> + Â Â Â Â Â Â Â } else >> Â Â Â Â Â Â Â Â Â Â Â Â signal_state = STV090x_NODATA; >> - Â Â Â Â Â Â Â Â Â Â Â no_signal = stv090x_chk_signal(state); >> - Â Â Â Â Â Â Â } >> + >> Â Â Â Â } >> Â Â Â Â return signal_state; >> >> >> ___ >> linuxtv-commits mailing list >> linuxtv-comm...@linuxtv.org >> http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits > > -- Peter Senna Tschudin peter.se...@gmail.com gpg id: 48274C36 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [media] omap3isp: fix dqbuf description comment
Signed-off-by: Michael Jones --- drivers/media/video/omap3isp/ispqueue.c |9 ++--- 1 files changed, 2 insertions(+), 7 deletions(-) This comment looks like it was a copy-paste from the description of qbuf. diff --git a/drivers/media/video/omap3isp/ispqueue.c b/drivers/media/video/omap3isp/ispqueue.c index 5fda5d0..23915ce 100644 --- a/drivers/media/video/omap3isp/ispqueue.c +++ b/drivers/media/video/omap3isp/ispqueue.c @@ -908,13 +908,8 @@ done: * * This function is intended to be used as a VIDIOC_DQBUF ioctl handler. * - * The v4l2_buffer structure passed from userspace is first sanity tested. If - * sane, the buffer is then processed and added to the main queue and, if the - * queue is streaming, to the IRQ queue. - * - * Before being enqueued, USERPTR buffers are checked for address changes. If - * the buffer has a different userspace address, the old memory area is unlocked - * and the new memory area is locked. + * if nonblocking=1, returns -EAGAIN if no buffer is available. + * if nonblocking=0, waits on IRQ queue until a buffer becomes available. */ int omap3isp_video_queue_dqbuf(struct isp_video_queue *queue, struct v4l2_buffer *vbuf, int nonblocking) -- 1.7.4.1 MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler Registergericht: Amtsgericht Stuttgart, HRB 271090 Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner, Erhard Meier -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC/PATCH v3] media: Add stk1160 new driver
On 06/27/2012 04:40 PM, Ezequiel Garcia wrote: > Hi Sylwester, > > I'm OK with every comment you made. > > Except for the -ETIMEDOUT. > I'm still not 100% convinced, but I'll take your word for it. It looked most appropriate to me, however I didn't really analyse very deeply the whole driver to see how it would have been propagated. That's just a humble suggestion. Good luck with those works! :) --- Regards, Sylwester -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] omap3isp: preview: Add support for non-GRBG Bayer patterns
Hi Laurent, On Wed, 2012-06-27 at 16:42 +0200, Laurent Pinchart wrote: > Hi Ivan, > > On Wednesday 27 June 2012 17:30:32 Ivan T. Ivanov wrote: > > On Wed, 2012-06-27 at 15:54 +0200, Laurent Pinchart wrote: > > > On Wednesday 27 June 2012 16:42:01 Ivan T. Ivanov wrote: > > > > On Tue, 2012-06-26 at 03:30 +0200, Laurent Pinchart wrote: > > > > > On Saturday 23 June 2012 11:22:37 Sakari Ailus wrote: > > > > > > On Mon, Jun 18, 2012 at 04:30:53PM +0200, Laurent Pinchart wrote: > > > > > > > Rearrange the CFA interpolation coefficients table based on the > > > > > > > Bayer pattern. Modifying the table during streaming isn't > > > > > > > supported anymore, but didn't make sense in the first place > > > > > > > anyway. > > > > > > > > > > > > Why not? I could imagine someone might want to change the table > > > > > > while streaming to change the white balance, for example. Gamma > > > > > > tables or the SRGB matrix can be used to do mostly the same but we > > > > > > should leave the decision which one to use to the user space. > > > > > > > > > > Because making the CFA table runtime-configurable brings an additional > > > > > complexity without a use case I'm aware of. The preview engine has > > > > > separate gamma tables, white balance matrices, and RGB-to-RGB and RGB- > > > > > to-YUV matrices that can be modified during streaming. If a user > > > > > really needs to modify the CFA tables during streaming I'll be happy > > > > > to implement that (and even happier to receive a patch :-)), but I'm a > > > > > bit reluctant to add complexity to an already complex code without a > > > > > real use case. > > > > > > > > Sorry for not following this thread very closely. One use case for > > > > changing CFA table is to adjust sharpness of the frames coming out > > > > of the ISP. And we are doing exactly this in N9. > > > > > > Thank you for the valuable feedback. Now we have a use case :-) I'll make > > > sure the CFA table can be updated during streaming then. Are you fine > > > with always specifying the table in SGRBG order, and letting the driver > > > rearrange the 4 blocks based on the input bayer pattern ? > > > > I am afraid that I am not :-). Primary and secondary cameras of the above > > device have different order of the color channels. We are selecting desired > > CFA table pattern based on sensor used. Probably we can add yet another > > IOCTL to previewer sub-device, which will explicitly overwrite "order" of > > the user supplied table? > > The idea is that applications should supply a CFA table in the SGRBG order, > regardless of the real sensor pattern. The ISP driver will then rearrange the > table based on the pattern of the select sensor. I like this idea. > > This will break compatibility with libomap3camd, but the N9 isn't supported > by > Nokia anymore anyway :-/ Same feelings :-/. In this case, I suppose you are free to change it as you like it. > BTW, are the CFA tables hardcoded in the libomap3camd > binary, or are they loaded from an external file ? No comments :-) Regards, Ivan -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] omap3isp: preview: Add support for non-GRBG Bayer patterns
Hi Ivan, On Wednesday 27 June 2012 17:30:32 Ivan T. Ivanov wrote: > On Wed, 2012-06-27 at 15:54 +0200, Laurent Pinchart wrote: > > On Wednesday 27 June 2012 16:42:01 Ivan T. Ivanov wrote: > > > On Tue, 2012-06-26 at 03:30 +0200, Laurent Pinchart wrote: > > > > On Saturday 23 June 2012 11:22:37 Sakari Ailus wrote: > > > > > On Mon, Jun 18, 2012 at 04:30:53PM +0200, Laurent Pinchart wrote: > > > > > > Rearrange the CFA interpolation coefficients table based on the > > > > > > Bayer pattern. Modifying the table during streaming isn't > > > > > > supported anymore, but didn't make sense in the first place > > > > > > anyway. > > > > > > > > > > Why not? I could imagine someone might want to change the table > > > > > while streaming to change the white balance, for example. Gamma > > > > > tables or the SRGB matrix can be used to do mostly the same but we > > > > > should leave the decision which one to use to the user space. > > > > > > > > Because making the CFA table runtime-configurable brings an additional > > > > complexity without a use case I'm aware of. The preview engine has > > > > separate gamma tables, white balance matrices, and RGB-to-RGB and RGB- > > > > to-YUV matrices that can be modified during streaming. If a user > > > > really needs to modify the CFA tables during streaming I'll be happy > > > > to implement that (and even happier to receive a patch :-)), but I'm a > > > > bit reluctant to add complexity to an already complex code without a > > > > real use case. > > > > > > Sorry for not following this thread very closely. One use case for > > > changing CFA table is to adjust sharpness of the frames coming out > > > of the ISP. And we are doing exactly this in N9. > > > > Thank you for the valuable feedback. Now we have a use case :-) I'll make > > sure the CFA table can be updated during streaming then. Are you fine > > with always specifying the table in SGRBG order, and letting the driver > > rearrange the 4 blocks based on the input bayer pattern ? > > I am afraid that I am not :-). Primary and secondary cameras of the above > device have different order of the color channels. We are selecting desired > CFA table pattern based on sensor used. Probably we can add yet another > IOCTL to previewer sub-device, which will explicitly overwrite "order" of > the user supplied table? The idea is that applications should supply a CFA table in the SGRBG order, regardless of the real sensor pattern. The ISP driver will then rearrange the table based on the pattern of the select sensor. This will break compatibility with libomap3camd, but the N9 isn't supported by Nokia anymore anyway :-/ BTW, are the CFA tables hardcoded in the libomap3camd binary, or are they loaded from an external file ? -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC/PATCH v3] media: Add stk1160 new driver
On Mon, Jun 25, 2012 at 6:09 PM, Sylwester Nawrocki wrote: > Hi Ezequiel, > > a few minor comments below... Hi Sylwester, I'm OK with every comment you made. Except for the -ETIMEDOUT. I'm still not 100% convinced, but I'll take your word for it. Also, is there any other serious issue preventing us from replacing staging/easycap with stk1160? Thank a lot for your review, Ezequiel. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] omap3isp: preview: Add support for non-GRBG Bayer patterns
Hi, On Wed, 2012-06-27 at 15:54 +0200, Laurent Pinchart wrote: > Hi Ivan, > > On Wednesday 27 June 2012 16:42:01 Ivan T. Ivanov wrote: > > On Tue, 2012-06-26 at 03:30 +0200, Laurent Pinchart wrote: > > > On Saturday 23 June 2012 11:22:37 Sakari Ailus wrote: > > > > On Mon, Jun 18, 2012 at 04:30:53PM +0200, Laurent Pinchart wrote: > > > > > Rearrange the CFA interpolation coefficients table based on the Bayer > > > > > pattern. Modifying the table during streaming isn't supported anymore, > > > > > but didn't make sense in the first place anyway. > > > > > > > > Why not? I could imagine someone might want to change the table while > > > > streaming to change the white balance, for example. Gamma tables or the > > > > SRGB matrix can be used to do mostly the same but we should leave the > > > > decision which one to use to the user space. > > > > > > Because making the CFA table runtime-configurable brings an additional > > > complexity without a use case I'm aware of. The preview engine has > > > separate > > > gamma tables, white balance matrices, and RGB-to-RGB and RGB-to-YUV > > > matrices that can be modified during streaming. If a user really needs to > > > modify the CFA tables during streaming I'll be happy to implement that > > > (and even happier to receive a patch :-)), but I'm a bit reluctant to add > > > complexity to an already complex code without a real use case. > > > > Sorry for not following this thread very closely. One use case for > > changing CFA table is to adjust sharpness of the frames coming out > > of the ISP. And we are doing exactly this in N9. > > Thank you for the valuable feedback. Now we have a use case :-) I'll make > sure > the CFA table can be updated during streaming then. Are you fine with always > specifying the table in SGRBG order, and letting the driver rearrange the 4 > blocks based on the input bayer pattern ? I am afraid that I am not :-). Primary and secondary cameras of the above device have different order of the color channels. We are selecting desired CFA table pattern based on sensor used. Probably we can add yet another IOCTL to previewer sub-device, which will explicitly overwrite "order" of the user supplied table? Regards, Ivan -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] s5p-fimc: Remove V4L2_FL_LOCK_ALL_FOPS flag
This patch adds locking for open(), close(), poll() and mmap() file operations in the driver as a follow up to the changes done in commit 5126f2590bee412e3053de851cb07f531 "v4l2-dev: add flag to have the core lock all file operations". Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/video/s5p-fimc/fimc-capture.c | 78 ++- drivers/media/video/s5p-fimc/fimc-m2m.c | 45 2 files changed, 87 insertions(+), 36 deletions(-) diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index 500b588..69708dc 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c @@ -480,48 +480,59 @@ static int fimc_capture_set_default_format(struct fimc_dev *fimc); static int fimc_capture_open(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); - int ret; + int ret = -EBUSY; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); + if (mutex_lock_interruptible(&fimc->lock)) + return -ERESTARTSYS; + if (fimc_m2m_active(fimc)) - return -EBUSY; + goto unlock; set_bit(ST_CAPT_BUSY, &fimc->state); ret = pm_runtime_get_sync(&fimc->pdev->dev); if (ret < 0) - return ret; + goto unlock; ret = v4l2_fh_open(file); - if (ret) - return ret; - - if (++fimc->vid_cap.refcnt != 1) - return 0; + if (ret) { + pm_runtime_put(&fimc->pdev->dev); + goto unlock; + } - ret = fimc_pipeline_initialize(&fimc->pipeline, + if (++fimc->vid_cap.refcnt == 1) { + ret = fimc_pipeline_initialize(&fimc->pipeline, &fimc->vid_cap.vfd->entity, true); - if (ret < 0) { - clear_bit(ST_CAPT_BUSY, &fimc->state); - pm_runtime_put_sync(&fimc->pdev->dev); - fimc->vid_cap.refcnt--; - v4l2_fh_release(file); - return ret; - } - ret = fimc_capture_ctrls_create(fimc); - if (!ret && !fimc->vid_cap.user_subdev_api) - ret = fimc_capture_set_default_format(fimc); + if (!ret && !fimc->vid_cap.user_subdev_api) + ret = fimc_capture_set_default_format(fimc); + + if (!ret) + ret = fimc_capture_ctrls_create(fimc); + if (ret < 0) { + clear_bit(ST_CAPT_BUSY, &fimc->state); + pm_runtime_put_sync(&fimc->pdev->dev); + fimc->vid_cap.refcnt--; + v4l2_fh_release(file); + } + } +unlock: + mutex_unlock(&fimc->lock); return ret; } static int fimc_capture_close(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); + int ret; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); + if (mutex_lock_interruptible(&fimc->lock)) + return -ERESTARTSYS; + if (--fimc->vid_cap.refcnt == 0) { clear_bit(ST_CAPT_BUSY, &fimc->state); fimc_stop_capture(fimc, false); @@ -535,22 +546,40 @@ static int fimc_capture_close(struct file *file) vb2_queue_release(&fimc->vid_cap.vbq); fimc_ctrls_delete(fimc->vid_cap.ctx); } - return v4l2_fh_release(file); + + ret = v4l2_fh_release(file); + + mutex_unlock(&fimc->lock); + return ret; } static unsigned int fimc_capture_poll(struct file *file, struct poll_table_struct *wait) { struct fimc_dev *fimc = video_drvdata(file); + int ret; - return vb2_poll(&fimc->vid_cap.vbq, file, wait); + if (mutex_lock_interruptible(&fimc->lock)) + return POLL_ERR; + + ret = vb2_poll(&fimc->vid_cap.vbq, file, wait); + mutex_unlock(&fimc->lock); + + return ret; } static int fimc_capture_mmap(struct file *file, struct vm_area_struct *vma) { struct fimc_dev *fimc = video_drvdata(file); + int ret; + + if (mutex_lock_interruptible(&fimc->lock)) + return -ERESTARTSYS; - return vb2_mmap(&fimc->vid_cap.vbq, vma); + ret = vb2_mmap(&fimc->vid_cap.vbq, vma); + mutex_unlock(&fimc->lock); + + return ret; } static const struct v4l2_file_operations fimc_capture_fops = { @@ -1598,10 +1627,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, vfd->minor = -1; vfd->release= video_device_release; vfd->lock = &fimc->lock; - /* Locking in file operations other than ioctl should be done - by the driver, not the V4L2 core. - This driver needs auditing so that this flag can be removed. */ - s
[PATCH] s5p-fimc: Add missing FIMC-LITE file operations locking
commit 5126f2590bee412e3053de851cb07f531e4be36a "v4l2-dev: add flag to have the core lock all file operations" introduced an additional bit flag (V4L2_FL_LOCK_ALL_FOPS) that should be set by drivers that use the v4l2 core lock for all file operations. Since this driver has been merged at the same time as the core changes it doesn't set this flags and thus its all file operations except IOCTL are not properly serialized. Fix this by adding file ops locking in the driver. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/video/s5p-fimc/fimc-lite.c | 61 +- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/drivers/media/video/s5p-fimc/fimc-lite.c b/drivers/media/video/s5p-fimc/fimc-lite.c index 4d269b8..74ff310 100644 --- a/drivers/media/video/s5p-fimc/fimc-lite.c +++ b/drivers/media/video/s5p-fimc/fimc-lite.c @@ -453,34 +453,42 @@ static int fimc_lite_open(struct file *file) struct fimc_lite *fimc = video_drvdata(file); int ret; + if (mutex_lock_interruptible(&fimc->lock)) + return -ERESTARTSYS; + set_bit(ST_FLITE_IN_USE, &fimc->state); ret = pm_runtime_get_sync(&fimc->pdev->dev); if (ret < 0) - return ret; - - if (++fimc->ref_count != 1 || fimc->out_path != FIMC_IO_DMA) - return 0; + goto done; ret = v4l2_fh_open(file); if (ret < 0) - return ret; + goto done; - ret = fimc_pipeline_initialize(&fimc->pipeline, &fimc->vfd->entity, - true); - if (ret < 0) { - pm_runtime_put_sync(&fimc->pdev->dev); - fimc->ref_count--; - v4l2_fh_release(file); - clear_bit(ST_FLITE_IN_USE, &fimc->state); - } + if (++fimc->ref_count == 1 && fimc->out_path == FIMC_IO_DMA) { + ret = fimc_pipeline_initialize(&fimc->pipeline, + &fimc->vfd->entity, true); + if (ret < 0) { + pm_runtime_put_sync(&fimc->pdev->dev); + fimc->ref_count--; + v4l2_fh_release(file); + clear_bit(ST_FLITE_IN_USE, &fimc->state); + } - fimc_lite_clear_event_counters(fimc); + fimc_lite_clear_event_counters(fimc); + } +done: + mutex_unlock(&fimc->lock); return ret; } static int fimc_lite_close(struct file *file) { struct fimc_lite *fimc = video_drvdata(file); + int ret; + + if (mutex_lock_interruptible(&fimc->lock)) + return -ERESTARTSYS; if (--fimc->ref_count == 0 && fimc->out_path == FIMC_IO_DMA) { clear_bit(ST_FLITE_IN_USE, &fimc->state); @@ -494,20 +502,39 @@ static int fimc_lite_close(struct file *file) if (fimc->ref_count == 0) vb2_queue_release(&fimc->vb_queue); - return v4l2_fh_release(file); + ret = v4l2_fh_release(file); + + mutex_unlock(&fimc->lock); + return ret; } static unsigned int fimc_lite_poll(struct file *file, struct poll_table_struct *wait) { struct fimc_lite *fimc = video_drvdata(file); - return vb2_poll(&fimc->vb_queue, file, wait); + int ret; + + if (mutex_lock_interruptible(&fimc->lock)) + return POLL_ERR; + + ret = vb2_poll(&fimc->vb_queue, file, wait); + mutex_unlock(&fimc->lock); + + return ret; } static int fimc_lite_mmap(struct file *file, struct vm_area_struct *vma) { struct fimc_lite *fimc = video_drvdata(file); - return vb2_mmap(&fimc->vb_queue, vma); + int ret; + + if (mutex_lock_interruptible(&fimc->lock)) + return -ERESTARTSYS; + + ret = vb2_mmap(&fimc->vb_queue, vma); + mutex_unlock(&fimc->lock); + + return ret; } static const struct v4l2_file_operations fimc_lite_fops = { -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Revert "[media] V4L: JPEG class documentation corrections"
This reverts commit feed0258e11e04b7e0, as the same issues are already covered in another version of that patch that was also applied (579e92ffac65c717c9c8a50feb755a). Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- Documentation/DocBook/media/v4l/controls.xml |2 +- Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml |7 --- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml index 676bc46..cda0dfb 100644 --- a/Documentation/DocBook/media/v4l/controls.xml +++ b/Documentation/DocBook/media/v4l/controls.xml @@ -3988,7 +3988,7 @@ interface and may change in the future. from RGB to Y'CbCr color space. - + diff --git a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml index e3d5afcd..0a4b90f 100644 --- a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml +++ b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml @@ -284,14 +284,6 @@ These controls are described in . - - V4L2_CTRL_CLASS_JPEG - 0x9d - The class containing JPEG compression controls. -These controls are described in . - -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] omap3isp: preview: Add support for non-GRBG Bayer patterns
Hi Sakari, On Tuesday 26 June 2012 22:01:14 Sakari Ailus wrote: > On Tue, Jun 26, 2012 at 03:30:09AM +0200, Laurent Pinchart wrote: > > On Saturday 23 June 2012 11:22:37 Sakari Ailus wrote: > > > On Mon, Jun 18, 2012 at 04:30:53PM +0200, Laurent Pinchart wrote: > > > > Rearrange the CFA interpolation coefficients table based on the Bayer > > > > pattern. Modifying the table during streaming isn't supported anymore, > > > > but didn't make sense in the first place anyway. > > > > > > Why not? I could imagine someone might want to change the table while > > > streaming to change the white balance, for example. Gamma tables or the > > > SRGB matrix can be used to do mostly the same but we should leave the > > > decision which one to use to the user space. > > > > Because making the CFA table runtime-configurable brings an additional > > complexity without a use case I'm aware of. The preview engine has > > separate > > gamma tables, white balance matrices, and RGB-to-RGB and RGB-to-YUV > > matrices that can be modified during streaming. If a user really needs to > > modify the CFA tables during streaming I'll be happy to implement that > > (and even happier to receive a patch :-)), but I'm a bit reluctant to add > > complexity to an already complex code without a real use case. > > I'm fine with that. Let's get back to the topic once this is really needed. It seems to be really needed now, so I'll fix this. > ... > > > > > + return; > > > > + } > > > > + > > > > + params = (prev->params.active & OMAP3ISP_PREV_CFA) > > > > + ? &prev->params.params[0] : &prev->params.params[1]; > > > > + > > > > + isp_reg_set(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR, > > > > ISPPRV_PCR_CFAEN); > > > > + isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_PREV, ISPPRV_PCR, > > > > + ISPPRV_PCR_CFAFMT_MASK, > > > > ISPPRV_PCR_CFAFMT_BAYER); > > > > + > > > > + isp_reg_writel(isp, > > > > + (params->cfa.gradthrs_vert << > > > > ISPPRV_CFA_GRADTH_VER_SHIFT) | > > > > + (params->cfa.gradthrs_horz << > > > > ISPPRV_CFA_GRADTH_HOR_SHIFT), > > > > + OMAP3_ISP_IOMEM_PREV, ISPPRV_CFA); > > > > + > > > > + switch (prev->formats[PREV_PAD_SINK].code) { > > > > + case V4L2_MBUS_FMT_SGRBG10_1X10: > > > > > > > + default: > > > Is the "default" case expected to ever happen? > > How about this one? It's not expected to happen, no. I expected the compiler to produce a warning, but it doesn't. I'm not sure if that's good or bad though. I'll reorder the code to avoid crashes if we get an unexpected format. > > > > + order = cfa_coef_order[0]; > > > > + break; > > > > + case V4L2_MBUS_FMT_SRGGB10_1X10: > > > > + order = cfa_coef_order[1]; > > > > + break; > > > > + case V4L2_MBUS_FMT_SBGGR10_1X10: > > > > + order = cfa_coef_order[2]; > > > > + break; > > > > + case V4L2_MBUS_FMT_SGBRG10_1X10: > > > > + order = cfa_coef_order[3]; > > > > + break; > > > > + } > > > > + > > > > + isp_reg_writel(isp, ISPPRV_CFA_TABLE_ADDR, > > > > + OMAP3_ISP_IOMEM_PREV, ISPPRV_SET_TBL_ADDR); > > > > + > > > > + for (i = 0; i < 4; ++i) { > > > > + __u32 *block = params->cfa.table > > > > ++ order[i] * OMAP3ISP_PREV_CFA_BLK_SIZE; > > > > + > > > > + for (j = 0; j < OMAP3ISP_PREV_CFA_BLK_SIZE; ++j) > > > > + isp_reg_writel(isp, block[j], > > > > OMAP3_ISP_IOMEM_PREV, > > > > + ISPPRV_SET_TBL_DATA); > > > > + } > > > > > > > > } > > > > > > > > /* -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] omap3isp: preview: Add support for non-GRBG Bayer patterns
Hi, On Tue, 2012-06-26 at 03:30 +0200, Laurent Pinchart wrote: > Hi Sakari, > > On Saturday 23 June 2012 11:22:37 Sakari Ailus wrote: > > On Mon, Jun 18, 2012 at 04:30:53PM +0200, Laurent Pinchart wrote: > > > Rearrange the CFA interpolation coefficients table based on the Bayer > > > pattern. Modifying the table during streaming isn't supported anymore, > > > but didn't make sense in the first place anyway. > > > > Why not? I could imagine someone might want to change the table while > > streaming to change the white balance, for example. Gamma tables or the SRGB > > matrix can be used to do mostly the same but we should leave the decision > > which one to use to the user space. > > Because making the CFA table runtime-configurable brings an additional > complexity without a use case I'm aware of. The preview engine has separate > gamma tables, white balance matrices, and RGB-to-RGB and RGB-to-YUV matrices > that can be modified during streaming. If a user really needs to modify the > CFA tables during streaming I'll be happy to implement that (and even happier > to receive a patch :-)), but I'm a bit reluctant to add complexity to an > already complex code without a real use case. > Sorry for not following this thread very closely. One use case for changing CFA table is to adjust sharpness of the frames coming out of the ISP. And we are doing exactly this in N9. Regards, Ivan. -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] omap3isp: preview: Add support for non-GRBG Bayer patterns
Hi Ivan, On Wednesday 27 June 2012 16:42:01 Ivan T. Ivanov wrote: > On Tue, 2012-06-26 at 03:30 +0200, Laurent Pinchart wrote: > > On Saturday 23 June 2012 11:22:37 Sakari Ailus wrote: > > > On Mon, Jun 18, 2012 at 04:30:53PM +0200, Laurent Pinchart wrote: > > > > Rearrange the CFA interpolation coefficients table based on the Bayer > > > > pattern. Modifying the table during streaming isn't supported anymore, > > > > but didn't make sense in the first place anyway. > > > > > > Why not? I could imagine someone might want to change the table while > > > streaming to change the white balance, for example. Gamma tables or the > > > SRGB matrix can be used to do mostly the same but we should leave the > > > decision which one to use to the user space. > > > > Because making the CFA table runtime-configurable brings an additional > > complexity without a use case I'm aware of. The preview engine has > > separate > > gamma tables, white balance matrices, and RGB-to-RGB and RGB-to-YUV > > matrices that can be modified during streaming. If a user really needs to > > modify the CFA tables during streaming I'll be happy to implement that > > (and even happier to receive a patch :-)), but I'm a bit reluctant to add > > complexity to an already complex code without a real use case. > > Sorry for not following this thread very closely. One use case for > changing CFA table is to adjust sharpness of the frames coming out > of the ISP. And we are doing exactly this in N9. Thank you for the valuable feedback. Now we have a use case :-) I'll make sure the CFA table can be updated during streaming then. Are you fine with always specifying the table in SGRBG order, and letting the driver rearrange the 4 blocks based on the input bayer pattern ? -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch -resend] [media] az6007: precedence bug in az6007_i2c_xfer()
Em 27-06-2012 06:06, Dan Carpenter escreveu: > The intent here was to test that the flag was clear but the '!' has > higher precedence than the '&'. I2C_M_RD is 0x1 so the current code is > equivalent to "&& (!sgs[i].flags) ..." > > Signed-off-by: Dan Carpenter > --- > I sent this originally on Wed, 25 Jan 2012 and Emil Goode sent the same > fix on Thu, May 3, 2012. > > diff --git a/drivers/media/dvb/dvb-usb/az6007.c > b/drivers/media/dvb/dvb-usb/az6007.c > index 4008b9c..f6f0cf9 100644 > --- a/drivers/media/dvb/dvb-usb/az6007.c > +++ b/drivers/media/dvb/dvb-usb/az6007.c > @@ -711,7 +711,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, > struct i2c_msg msgs[], > addr = msgs[i].addr << 1; > if (((i + 1) < num) > && (msgs[i].len == 1) > - && (!msgs[i].flags & I2C_M_RD) > + && (!(msgs[i].flags & I2C_M_RD)) > && (msgs[i + 1].flags & I2C_M_RD) > && (msgs[i].addr == msgs[i + 1].addr)) { > /* > Dan, Your logic is correct, however, I didn't apply this patch because it broke the driver. I'll need to re-visit the driver when I have some time, in order to be able to apply this one, without breaking the driver. I'll likely need to change some other things on this routine. (this has a low priority, as the driver is working properly the way it is). So, I'm keeping your patch at patchwork, while I don't find some time for it. Regards, Mauro -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [GIT PULL FOR v3.5] Move sta2x11_vip to staging
> Hi Federico, > > Any news on this? Not at the moment. I'll ask for detail :) -- Federico Vaga -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: rtl28xxu - rtl2832 frontend attach
On 06/27/2012 07:21 AM, Thomas Mair wrote: > On 26.06.2012 19:17, poma wrote: >> On 05/28/2012 04:48 PM, Thomas Mair wrote: >>> On 28.05.2012 08:58, Thomas Mair wrote: On 26.05.2012 04:47, poma wrote: > On 05/20/2012 11:12 PM, Thomas Mair wrote: >> On 20.05.2012 22:08, Antti Palosaari wrote: >>> On 20.05.2012 20:04, poma wrote: After hard/cold boot: >>> DVB: register adapter0/net0 @ minor: 2 (0x02) rtl2832u_frontend_attach: rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 rtl28xxu_ctrl_msg: failed=-32 No compatible tuner found >>> >>> These errors are coming from tuner probe. As it still goes to probing >>> and did not jump out earlier when gate is opened it means that demod is >>> answering commands but tuner are not. >>> >>> My guess is that tuner is still on the reset or not powered at all. It >>> is almost 100% sure error is wrong tuner GPIO. >> >> There is an issue with GPIO, as FC0012 tuner callback will set >> the value of one of the GPIO outputs. However fixing that, will >> not resolve the issue. So I need to debug the problem further. >> > True. Whatever a value is changed - 'rtl2832u_power_ctrl', it brakes > even more. > Precisely, what breaks a tuner on next soft [re]boot are apps/utils > which engage tzap/scan[dvb]. > To reproduce the bug it is not necessary to reboot the machine. Simply unload and load of the dvb_usb_rtl28xxu module will lead to the same situation. I suspect, that when power is turned off, the tuner power is not switched on correctly. The mistake is not related to the OUTPUT_VAL registers but probably to the OUTPUT_DIR or OUTPUT_EN registers. What makes me wonder is if no tuning operation is performed before reboot, the driver does work correctly after that, as poma already noticed. I have some spare time today and will investigate the problem further. >>> >>> I tried a few things regarding the problem today and could find out a >>> few more details, but could not resolve the issue. >>> >>> The GPIO pin configuration for the devices with the fc0012 (and probably >>> also with the fc0013) tuner is the following: >>> >>> GPIO0: demod power >>> GPIO3: tuner power? (the realtek driver puts this to 1 and never touches it >>> again) >>> GPIO4: tuner power? (maybe antenna power?) >>> GPIO5: tuner reset >>> GPIO6: UHF/VHF band selection >>> >>> All of these GPIOs are configured as output. When the device is plugged in >>> the tuner is powered up correctly, but I am not able to power it up when >>> a reboot is performed. What I tried was the following: >>> >>> - on rtl28xxu_power_ctrl off: >>> - GPIO4 = 1 (off) >>> - GPIO5 = 0 >>> - GPIO6 = 0 (default state) >>> >>> - on rtl28xxu_power_ctrl on: >>> - GPIO3 = 1 >>> - GPIO4 = 0 (on) >>> - GPIO5 = 0 >>> - GPIO6 = 0 (default state) >>> >>> - on rtl2832_frontend_attach: >>> - GPIO5 = 1 >>> - GPIO5 = 0 >>> >>> This sequence should ensure that the tuner is powered on when the frontend >>> is attached, and a tuner reset is being performed before the tuner is >>> probed. >>> However this sequence fails the same way as it did before. I tried to add >>> timeouts to be sure that the tuner is not probed while it is reset but that >>> did not help either. >>> >>> Right now I really don't know where I should look for the solution of >>> the problem. It seems that the tuner reset does not have any effect on the >>> tuner whatsoever. >>> >>> Is there anybody who could look at the code, or maybe knows what could be >>> the cause of the problem? I suspect I am just too blind to see my own >>> mistakes. >>> >>> Regards >>> Thomas >>> >> >> Cheers Thomas, Hans-Frieder, Antti, Mauro! >> Hans-Frieder, are you having the same issue with fc0011&af9035? >> Antti, no tricks up your sleeve? >> Senhor Mauro, is rtl2832 demod going to be merged? >> >> regards, >> poma >> > Hi all, > > I will try to solve the issue as soon as I have some spare time. In the > meantime I > asked Realtek if they knew of any problems with the hardware, and I got a GPIO > list which might help me to solve the problem. > > Regrads > Thomas > Nice to know ;) Cheers, poma -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] omap3isp: video: Split format info bpp field into width and bpp
Laurent Pinchart wrote: > Hi Sakari, > > Thanks for the review. > > On Wednesday 27 June 2012 14:07:51 Sakari Ailus wrote: >> Laurent Pinchart wrote: >>> The bpp field currently stores the sample width and is aligned to the >>> next multiple of 8 bits when computing data size in memory. This won't >>> work anymore for YUYV8_2X8 formats. Split the bpp field into a sample >>> width and a bits per pixel value. >>> >>> Signed-off-by: Laurent Pinchart >> >> ... >> >>> diff --git a/drivers/media/video/omap3isp/ispvideo.h >>> b/drivers/media/video/omap3isp/ispvideo.h index 5acc909..f8092cc 100644 >>> --- a/drivers/media/video/omap3isp/ispvideo.h >>> +++ b/drivers/media/video/omap3isp/ispvideo.h >>> @@ -51,7 +51,8 @@ struct v4l2_pix_format; >>> >>> * @flavor: V4L2 media bus format code for the same pixel layout but >>> * shifted to be 8 bits per pixel. =0 if format is not shiftable. >>> * @pixelformat: V4L2 pixel format FCC identifier >>> >>> - * @bpp: Bits per pixel >>> + * @width: Data bus width >>> + * @bpp: Bits per pixel (when stored in memory) >> >> Would it make sense to use bytes rather than bits? > > I'll change that. > >> Also width isn't really the width of the data bus on serial busses, is it? >> How about busses that transfer pixels 8 bits at the time? > > I could change the comment to "bits per pixel (when transferred on a bus)", > would that be better ? Pixels (or samples, as you suggested later) sounds good to me. >> You can also stop using ALIGN() in isp_video_mbus_to_pix() (in ispvideo.c) >> as the ISP will always write complete bytes. > > Indeed. With these changes, Acked-by: Sakari Ailus -- Sakari Ailus sakari.ai...@iki.fi -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] omap3isp: video: Split format info bpp field into width and bpp
On Wednesday 27 June 2012 13:54:30 Laurent Pinchart wrote: > Hi Sakari, > > Thanks for the review. > > On Wednesday 27 June 2012 14:07:51 Sakari Ailus wrote: > > Laurent Pinchart wrote: > > > The bpp field currently stores the sample width and is aligned to the > > > next multiple of 8 bits when computing data size in memory. This won't > > > work anymore for YUYV8_2X8 formats. Split the bpp field into a sample > > > width and a bits per pixel value. > > > > > > Signed-off-by: Laurent Pinchart > > > > ... > > > > > diff --git a/drivers/media/video/omap3isp/ispvideo.h > > > b/drivers/media/video/omap3isp/ispvideo.h index 5acc909..f8092cc 100644 > > > --- a/drivers/media/video/omap3isp/ispvideo.h > > > +++ b/drivers/media/video/omap3isp/ispvideo.h > > > @@ -51,7 +51,8 @@ struct v4l2_pix_format; > > > > > > * @flavor: V4L2 media bus format code for the same pixel layout but > > > * shifted to be 8 bits per pixel. =0 if format is not shiftable. > > > * @pixelformat: V4L2 pixel format FCC identifier > > > > > > - * @bpp: Bits per pixel > > > + * @width: Data bus width > > > + * @bpp: Bits per pixel (when stored in memory) > > > > Would it make sense to use bytes rather than bits? > > I'll change that. > > > Also width isn't really the width of the data bus on serial busses, is it? > > How about busses that transfer pixels 8 bits at the time? > > I could change the comment to "bits per pixel (when transferred on a bus)", > would that be better ? s/pixel/sample/ > > You can also stop using ALIGN() in isp_video_mbus_to_pix() (in ispvideo.c) > > as the ISP will always write complete bytes. > > Indeed. > > > I might even switch the meaning between width and bpp but this is up to > > you. > I got used to width/bpp as defined by this patch, so that would be confusing > :-) > : > > > */ > > > > > > struct isp_format_info { > > > > > > enum v4l2_mbus_pixelcode code; > > > > > > @@ -59,6 +60,7 @@ struct isp_format_info { > > > > > > enum v4l2_mbus_pixelcode uncompressed; > > > enum v4l2_mbus_pixelcode flavor; > > > u32 pixelformat; > > > > > > + unsigned int width; > > > > > > unsigned int bpp; > > > > > > }; > > > > > > @@ -106,7 +108,7 @@ struct isp_pipeline { > > > > > > struct v4l2_fract max_timeperframe; > > > struct v4l2_subdev *external; > > > unsigned int external_rate; > > > > > > - unsigned int external_bpp; > > > + unsigned int external_width; > > > > > > }; > > > > > > #define to_isp_pipeline(__e) \ -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/6] omap3isp: ccdc: Add YUV input formats support
Laurent Pinchart wrote: > Enable the bridge automatically when the input format is YUYV8 or UYVY8. > > Signed-off-by: Laurent Pinchart Thanks for the patch, Laurent! Acked-by: Sakari Ailus -- Sakari Ailus sakari.ai...@iki.fi -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] omap3isp: video: Split format info bpp field into width and bpp
Hi Sakari, Thanks for the review. On Wednesday 27 June 2012 14:07:51 Sakari Ailus wrote: > Laurent Pinchart wrote: > > The bpp field currently stores the sample width and is aligned to the > > next multiple of 8 bits when computing data size in memory. This won't > > work anymore for YUYV8_2X8 formats. Split the bpp field into a sample > > width and a bits per pixel value. > > > > Signed-off-by: Laurent Pinchart > > ... > > > diff --git a/drivers/media/video/omap3isp/ispvideo.h > > b/drivers/media/video/omap3isp/ispvideo.h index 5acc909..f8092cc 100644 > > --- a/drivers/media/video/omap3isp/ispvideo.h > > +++ b/drivers/media/video/omap3isp/ispvideo.h > > @@ -51,7 +51,8 @@ struct v4l2_pix_format; > > > > * @flavor: V4L2 media bus format code for the same pixel layout but > > * shifted to be 8 bits per pixel. =0 if format is not shiftable. > > * @pixelformat: V4L2 pixel format FCC identifier > > > > - * @bpp: Bits per pixel > > + * @width: Data bus width > > + * @bpp: Bits per pixel (when stored in memory) > > Would it make sense to use bytes rather than bits? I'll change that. > Also width isn't really the width of the data bus on serial busses, is it? > How about busses that transfer pixels 8 bits at the time? I could change the comment to "bits per pixel (when transferred on a bus)", would that be better ? > You can also stop using ALIGN() in isp_video_mbus_to_pix() (in ispvideo.c) > as the ISP will always write complete bytes. Indeed. > I might even switch the meaning between width and bpp but this is up to you. I got used to width/bpp as defined by this patch, so that would be confusing :-) > > */ > > > > struct isp_format_info { > > > > enum v4l2_mbus_pixelcode code; > > > > @@ -59,6 +60,7 @@ struct isp_format_info { > > > > enum v4l2_mbus_pixelcode uncompressed; > > enum v4l2_mbus_pixelcode flavor; > > u32 pixelformat; > > > > + unsigned int width; > > > > unsigned int bpp; > > > > }; > > > > @@ -106,7 +108,7 @@ struct isp_pipeline { > > > > struct v4l2_fract max_timeperframe; > > struct v4l2_subdev *external; > > unsigned int external_rate; > > > > - unsigned int external_bpp; > > + unsigned int external_width; > > > > }; > > > > #define to_isp_pipeline(__e) \ -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/6] omap3isp: ccdc: Remove ispccdc_syncif structure
Laurent Pinchart wrote: > The structure is only used to store configuration data and pass it to > CCDC configuration functions. Access the data directly from the > locations that need it. > > Signed-off-by: Laurent Pinchart Thanks!! Acked-by: Sakari Ailus -- Sakari Ailus sakari.ai...@iki.fi -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] omap3isp: ccdc: Remove support for interlaced data and master HS/VS mode
Laurent Pinchart wrote: > Those features are half-implemented and not used. Remove them. > > Signed-off-by: Laurent Pinchart Thanks! Acked-by: Sakari Ailus -- Sakari Ailus sakari.ai...@iki.fi -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/6] omap3isp: video: Split format info bpp field into width and bpp
Hi Laurent, Thanks for the patch. Laurent Pinchart wrote: > The bpp field currently stores the sample width and is aligned to the > next multiple of 8 bits when computing data size in memory. This won't > work anymore for YUYV8_2X8 formats. Split the bpp field into a sample > width and a bits per pixel value. > > Signed-off-by: Laurent Pinchart ... > diff --git a/drivers/media/video/omap3isp/ispvideo.h > b/drivers/media/video/omap3isp/ispvideo.h > index 5acc909..f8092cc 100644 > --- a/drivers/media/video/omap3isp/ispvideo.h > +++ b/drivers/media/video/omap3isp/ispvideo.h > @@ -51,7 +51,8 @@ struct v4l2_pix_format; > * @flavor: V4L2 media bus format code for the same pixel layout but > * shifted to be 8 bits per pixel. =0 if format is not shiftable. > * @pixelformat: V4L2 pixel format FCC identifier > - * @bpp: Bits per pixel > + * @width: Data bus width > + * @bpp: Bits per pixel (when stored in memory) Would it make sense to use bytes rather than bits? Also width isn't really the width of the data bus on serial busses, is it? How about busses that transfer pixels 8 bits at the time? You can also stop using ALIGN() in isp_video_mbus_to_pix() (in ispvideo.c) as the ISP will always write complete bytes. I might even switch the meaning between width and bpp but this is up to you. > */ > struct isp_format_info { > enum v4l2_mbus_pixelcode code; > @@ -59,6 +60,7 @@ struct isp_format_info { > enum v4l2_mbus_pixelcode uncompressed; > enum v4l2_mbus_pixelcode flavor; > u32 pixelformat; > + unsigned int width; > unsigned int bpp; > }; > > @@ -106,7 +108,7 @@ struct isp_pipeline { > struct v4l2_fract max_timeperframe; > struct v4l2_subdev *external; > unsigned int external_rate; > - unsigned int external_bpp; > + unsigned int external_width; > }; > > #define to_isp_pipeline(__e) \ > Cheers, -- Sakari Ailus sakari.ai...@iki.fi -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: About s_std_output
On Wed 27 June 2012 12:14:34 Scott Jiang wrote: > 2012/6/27 Hans Verkuil : > > On Wed 27 June 2012 11:37:24 Scott Jiang wrote: > >> Hi Hans, > >> > >> I noticed there are two s_std ops in core and video for output. And > >> some drivers call video->s_std_out and then core->s_std in their S_STD > >> iotcl. Could anyone share me the story why we have > >> s_std_output/g_std_output/g_tvnorms_output ops in video instead of > >> making use of s_std/g_std in core? > > > > The core class is for common, often used ops. Setting the standard for > > capture devices is very common, so it is in core. Setting the standard > > for output devices is much less common (there aren't that many output > > devices in the kernel), so that stayed in the video class. > > > My question is why we can't reuse s_std/g_std for output device. We > use same VIDIOC_S_STD/VIDIOC_G_STD ioctl for both input and output. Ah, no. There some drivers that can do both capture and display (ivtv in particular). The capture and output part are independent and each have their own video node. So there is no confusion about whether the VIDIOC_S_STD is for capture or for output. But internally the S_STD ioctl is converted to a s_std or s_std_output broadcast to all i2c devices using v4l2_device_call_all(). You don't want the s_std for the output to interfere with the s_std for input i2c devices or vice versa, hence the separate s_std_output. Note that this issue is specific to s_std. Many drivers need to broadcast an s_std to all their i2c devices (the TV receiver, the tuner, the demodulator, possibly audio demodulator devices as well). Depending on the PCI board these can exists in various configurations. So you need the broadcast functionality, and in that case you need to have separate s_std and s_std_output ops. > > > It is a bit arbitrary and I am not sure whether I would make the same > > choice now. > > > So I should ignore s_std/g_std and use s_std_output/g_std_output in > encoder driver, right? Correct. > > > There is no g_tvnorms_output, BTW. > > > It really exists. > struct v4l2_subdev_video_ops { > int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 > output, u32 config); > int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags); > int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std); > int (*g_std_output)(struct v4l2_subdev *sd, v4l2_std_id *std); > int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std); > int (*g_tvnorms_output)(struct v4l2_subdev *sd, v4l2_std_id *std); > Oops, you are correct. Hmm, odd that nobody needed a g_tvnorms for input. Regards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 19/34] v4l2-dev.c: add debug sysfs entry.
Hi Hans, On Wednesday 27 June 2012 12:38:54 Hans Verkuil wrote: > On Wed 27 June 2012 11:54:40 Laurent Pinchart wrote: > > On Friday 22 June 2012 14:21:13 Hans Verkuil wrote: > > > From: Hans Verkuil > > > > > > Since this could theoretically change the debug value while in the > > > middle of v4l2-ioctl.c, we make a copy of vfd->debug to ensure > > > consistent debug behavior. > > > > In my review of RFCv1, I wrote that this could introduce a race condition: > > > > "You test the debug value several times in the __video_do_ioctl() > > function. I haven't checked in details whether changing the value between > > the two tests could for instance lead to a KERN_CONT print without a > > previous non-KERN_CONT message. That won't crash the machine but it > > should still be avoided." > > > > Have you verified whether that problem can occur ? > > Yes, this problem can occur. Which is why I've changed the code accordingly. I've missed that. My bad, sorry. -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 23/34] vb2-core: refactor reqbufs/create_bufs.
On Wednesday 27 June 2012 12:37:21 Hans Verkuil wrote: > On Wed 27 June 2012 11:52:10 Laurent Pinchart wrote: > > On Friday 22 June 2012 14:21:17 Hans Verkuil wrote: > > > From: Hans Verkuil > > > > > > Split off the memory and type validation. This is done both from reqbufs > > > and create_bufs, and will also be done by vb2 helpers in a later patch. > > > > > > Signed-off-by: Hans Verkuil [snip] > > > + > > > +/** > > > + * vb2_reqbufs() - Wrapper for __reqbufs() that also verifies the > > > memory and > > > + * type values. > > > + * @q: videobuf2 queue > > > + * @create: creation parameters, passed from userspace to > > > vidioc_create_bufs > > > + * handler in driver > > > + */ > > > +int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers > > > *create) > > > +{ > > > + int ret = __verify_memory_type(q, create->memory, > > > create->format.type); > > > + > > > + create->index = q->num_buffers; > > > > I think this changes the behaviour of create_bufs, it should thus belong > > to the next patch. > > No, I don't think this changes the behavior as far as I can tell. Without your patch create->index isn't modified if the checks fail. On the other hand, I've just remembered that video_usercopy won't copy the structure back to userspace if ret < 0, so you should be right. > > > + return ret ? ret : __create_bufs(q, create); > > > +} > > > > > > EXPORT_SYMBOL_GPL(vb2_create_bufs); > > > > > > /** -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 32/34] v4l2-dev.c: also add debug support for the fops.
On Wed 27 June 2012 11:59:06 Laurent Pinchart wrote: > Hi Hans, > > Thanks for the patch. > > On Friday 22 June 2012 14:21:26 Hans Verkuil wrote: > > From: Hans Verkuil > > > > Signed-off-by: Hans Verkuil > > --- > > drivers/media/video/v4l2-dev.c | 25 - > > 1 file changed, 24 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c > > index 1b34360..b51bee9 100644 > > --- a/drivers/media/video/v4l2-dev.c > > +++ b/drivers/media/video/v4l2-dev.c > > @@ -305,6 +305,9 @@ static ssize_t v4l2_read(struct file *filp, char __user > > *buf, ret = vdev->fops->read(filp, buf, sz, off); > > if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) > > mutex_unlock(vdev->lock); > > + if (vdev->debug) > > + printk(KERN_DEBUG "%s: read: %zd (%d)\n", > > + video_device_node_name(vdev), sz, ret); > > Would it make sense to introduce a v4l_dbg macro ? BTW, what was the outcome > of the pr_ vs. dev_ tests ? When using e.g. dev_info you would get 'video4linux video0' as prefix, which is a mouthful. So I decided against using it. I've thought about adding a v4l_dbg macro, but I decided against it. This use of KERN_DEBUG is quite unusual: usually any _dbg macro is either compiled away if DEBUG isn't defined, uses dynamic printk, or uses a debug variable somewhere. In this case you don't want any of those, you really want to print a message unconditionally to the log at log level KERN_DEBUG. Regards, Hans > > > return ret; > > } > > > > @@ -323,6 +326,9 @@ static ssize_t v4l2_write(struct file *filp, const char > > __user *buf, ret = vdev->fops->write(filp, buf, sz, off); > > if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) > > mutex_unlock(vdev->lock); > > + if (vdev->debug) > > + printk(KERN_DEBUG "%s: write: %zd (%d)\n", > > + video_device_node_name(vdev), sz, ret); > > return ret; > > } > > > > @@ -339,6 +345,9 @@ static unsigned int v4l2_poll(struct file *filp, struct > > poll_table_struct *poll) ret = vdev->fops->poll(filp, poll); > > if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) > > mutex_unlock(vdev->lock); > > + if (vdev->debug) > > + printk(KERN_DEBUG "%s: poll: %08x\n", > > + video_device_node_name(vdev), ret); > > return ret; > > } > > > > @@ -403,12 +412,17 @@ static unsigned long v4l2_get_unmapped_area(struct > > file *filp, unsigned long flags) > > { > > struct video_device *vdev = video_devdata(filp); > > + int ret; > > > > if (!vdev->fops->get_unmapped_area) > > return -ENOSYS; > > if (!video_is_registered(vdev)) > > return -ENODEV; > > - return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); > > + ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); > > + if (vdev->debug) > > + printk(KERN_DEBUG "%s: get_unmapped_area (%d)\n", > > + video_device_node_name(vdev), ret); > > + return ret; > > } > > #endif > > > > @@ -426,6 +440,9 @@ static int v4l2_mmap(struct file *filp, struct > > vm_area_struct *vm) ret = vdev->fops->mmap(filp, vm); > > if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) > > mutex_unlock(vdev->lock); > > + if (vdev->debug) > > + printk(KERN_DEBUG "%s: mmap (%d)\n", > > + video_device_node_name(vdev), ret); > > return ret; > > } > > > > @@ -464,6 +481,9 @@ err: > > /* decrease the refcount in case of an error */ > > if (ret) > > video_put(vdev); > > + if (vdev->debug) > > + printk(KERN_DEBUG "%s: open (%d)\n", > > + video_device_node_name(vdev), ret); > > return ret; > > } > > > > @@ -483,6 +503,9 @@ static int v4l2_release(struct inode *inode, struct file > > *filp) /* decrease the refcount unconditionally since the release() > >return value is ignored. */ > > video_put(vdev); > > + if (vdev->debug) > > + printk(KERN_DEBUG "%s: release\n", > > + video_device_node_name(vdev)); > > return ret; > > } > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] Miscellaneous OMAP3 ISP fixes
Laurent Pinchart wrote: > Hi everybody, > > Not much to be said here. The first patch is needed by the second, which is > described in its commit message. I'd like to get this into v3.6. > > Laurent Pinchart (2): > omap3isp: Don't access ISP_CTRL directly in the statistics modules > omap3isp: Configure HS/VS interrupt source before enabling interrupts > > drivers/media/video/omap3isp/isp.c | 47 +-- > drivers/media/video/omap3isp/isp.h |9 +++-- > drivers/media/video/omap3isp/isph3a_aewb.c | 10 +- > drivers/media/video/omap3isp/isph3a_af.c | 10 +- > drivers/media/video/omap3isp/isphist.c |6 +-- > 5 files changed, 40 insertions(+), 42 deletions(-) Thanks! Acked-by: Sakari Ailus -- Sakari Ailus sakari.ai...@iki.fi -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 19/34] v4l2-dev.c: add debug sysfs entry.
On Wed 27 June 2012 11:54:40 Laurent Pinchart wrote: > Hi Hans, > > Thanks for the patch. > > On Friday 22 June 2012 14:21:13 Hans Verkuil wrote: > > From: Hans Verkuil > > > > Since this could theoretically change the debug value while in the middle > > of v4l2-ioctl.c, we make a copy of vfd->debug to ensure consistent debug > > behavior. > > In my review of RFCv1, I wrote that this could introduce a race condition: > > "You test the debug value several times in the __video_do_ioctl() function. I > haven't checked in details whether changing the value between the two tests > could for instance lead to a KERN_CONT print without a previous non-KERN_CONT > message. That won't crash the machine but it should still be avoided." > > Have you verified whether that problem can occur ? Yes, this problem can occur. Which is why I've changed the code accordingly. Regards, Hans > > > Signed-off-by: Hans Verkuil > > --- > > drivers/media/video/v4l2-dev.c | 24 > > drivers/media/video/v4l2-ioctl.c |9 + > > 2 files changed, 29 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c > > index 1500208..5c0bb18 100644 > > --- a/drivers/media/video/v4l2-dev.c > > +++ b/drivers/media/video/v4l2-dev.c > > @@ -46,6 +46,29 @@ static ssize_t show_index(struct device *cd, > > return sprintf(buf, "%i\n", vdev->index); > > } > > > > +static ssize_t show_debug(struct device *cd, > > +struct device_attribute *attr, char *buf) > > +{ > > + struct video_device *vdev = to_video_device(cd); > > + > > + return sprintf(buf, "%i\n", vdev->debug); > > +} > > + > > +static ssize_t set_debug(struct device *cd, struct device_attribute *attr, > > + const char *buf, size_t len) > > +{ > > + struct video_device *vdev = to_video_device(cd); > > + int res = 0; > > + u16 value; > > + > > + res = kstrtou16(buf, 0, &value); > > + if (res) > > + return res; > > + > > + vdev->debug = value; > > + return len; > > +} > > + > > static ssize_t show_name(struct device *cd, > > struct device_attribute *attr, char *buf) > > { > > @@ -56,6 +79,7 @@ static ssize_t show_name(struct device *cd, > > > > static struct device_attribute video_device_attrs[] = { > > __ATTR(name, S_IRUGO, show_name, NULL), > > + __ATTR(debug, 0644, show_debug, set_debug), > > __ATTR(index, S_IRUGO, show_index, NULL), > > __ATTR_NULL > > }; > > diff --git a/drivers/media/video/v4l2-ioctl.c > > b/drivers/media/video/v4l2-ioctl.c index 0531d9a..2e1421b 100644 > > --- a/drivers/media/video/v4l2-ioctl.c > > +++ b/drivers/media/video/v4l2-ioctl.c > > @@ -1998,6 +1998,7 @@ static long __video_do_ioctl(struct file *file, > > void *fh = file->private_data; > > struct v4l2_fh *vfh = NULL; > > int use_fh_prio = 0; > > + int debug = vfd->debug; > > long ret = -ENOTTY; > > > > if (ops == NULL) { > > @@ -2031,7 +2032,7 @@ static long __video_do_ioctl(struct file *file, > > } > > > > write_only = _IOC_DIR(cmd) == _IOC_WRITE; > > - if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) { > > + if (write_only && debug > V4L2_DEBUG_IOCTL) { > > v4l_print_ioctl(vfd->name, cmd); > > pr_cont(": "); > > info->debug(arg, write_only); > > @@ -2053,8 +2054,8 @@ static long __video_do_ioctl(struct file *file, > > } > > > > done: > > - if (vfd->debug) { > > - if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) { > > + if (debug) { > > + if (write_only && debug > V4L2_DEBUG_IOCTL) { > > if (ret < 0) > > printk(KERN_DEBUG "%s: error %ld\n", > > video_device_node_name(vfd), ret); > > @@ -2063,7 +2064,7 @@ done: > > v4l_print_ioctl(vfd->name, cmd); > > if (ret < 0) > > pr_cont(": error %ld\n", ret); > > - else if (vfd->debug == V4L2_DEBUG_IOCTL) > > + else if (debug == V4L2_DEBUG_IOCTL) > > pr_cont("\n"); > > else if (_IOC_DIR(cmd) == _IOC_NONE) > > info->debug(arg, write_only); > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 23/34] vb2-core: refactor reqbufs/create_bufs.
On Wed 27 June 2012 11:52:10 Laurent Pinchart wrote: > Hi Hans, > > Thanks for the patch. > > On Friday 22 June 2012 14:21:17 Hans Verkuil wrote: > > From: Hans Verkuil > > > > Split off the memory and type validation. This is done both from reqbufs and > > create_bufs, and will also be done by vb2 helpers in a later patch. > > > > Signed-off-by: Hans Verkuil > > --- > > drivers/media/video/videobuf2-core.c | 153 +-- > > 1 file changed, 80 insertions(+), 73 deletions(-) > > > > diff --git a/drivers/media/video/videobuf2-core.c > > b/drivers/media/video/videobuf2-core.c index 9d4e9ed..8486e33 100644 > > --- a/drivers/media/video/videobuf2-core.c > > +++ b/drivers/media/video/videobuf2-core.c > > @@ -454,7 +454,53 @@ static int __verify_mmap_ops(struct vb2_queue *q) > > } > > > > /** > > - * vb2_reqbufs() - Initiate streaming > > + * __verify_memory_type() - do basic checks for memory and type > > I'd expand this comment a bit, as "basic checks" doesn't really tell much > about the purpose of the checks. Maybe something like > > "Check whether the memory type and buffer type passed to a buffer operation > are compatible with the queue." In my opinion the code is clear about what is being tested, but I'll change the comment. > > + */ > > +static int __verify_memory_type(struct vb2_queue *q, __u32 memory, __u32 > > type) > > What about using enum v4l2_memory and enum v4l2_buf_type instead of __u32 ? Will do. > > > +{ > > + if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR) { > > + dprintk(1, "reqbufs: unsupported memory type\n"); > > + return -EINVAL; > > + } > > + > > + if (type != q->type) { > > + dprintk(1, "reqbufs: requested type is incorrect\n"); > > + return -EINVAL; > > + } > > + > > + /* > > +* Make sure all the required memory ops for given memory type > > +* are available. > > +*/ > > + if (memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { > > + dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); > > + return -EINVAL; > > + } > > + > > + if (memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { > > + dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); > > + return -EINVAL; > > + } > > + > > + /* > > +* Place the busy tests at the end: -EBUSY can be ignored when > > +* create_bufs is called with count == 0, but count == 0 should still > > +* do the memory and type validation. > > +*/ > > + if (q->fileio) { > > + dprintk(1, "reqbufs: file io in progress\n"); > > + return -EBUSY; > > + } > > + > > + if (q->streaming) { > > + dprintk(1, "reqbufs: streaming active\n"); > > + return -EBUSY; > > + } > > create_bufs didn't check for q->streaming. Isn't it legal to add a buffer > during streaming ? Yes it is legal. Good catch! > > + return 0; > > +} > > + > > +/** > > + * __reqbufs() - Initiate streaming > > * @q: videobuf2 queue > > * @req: struct passed from userspace to vidioc_reqbufs handler in driver > > * > > @@ -476,45 +522,10 @@ static int __verify_mmap_ops(struct vb2_queue *q) > > * The return values from this function are intended to be directly > > returned * from vidioc_reqbufs handler in driver. > > */ > > -int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) > > +static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) > > { > > unsigned int num_buffers, allocated_buffers, num_planes = 0; > > - int ret = 0; > > - > > - if (q->fileio) { > > - dprintk(1, "reqbufs: file io in progress\n"); > > - return -EBUSY; > > - } > > - > > - if (req->memory != V4L2_MEMORY_MMAP > > - && req->memory != V4L2_MEMORY_USERPTR) { > > - dprintk(1, "reqbufs: unsupported memory type\n"); > > - return -EINVAL; > > - } > > - > > - if (req->type != q->type) { > > - dprintk(1, "reqbufs: requested type is incorrect\n"); > > - return -EINVAL; > > - } > > - > > - if (q->streaming) { > > - dprintk(1, "reqbufs: streaming active\n"); > > - return -EBUSY; > > - } > > - > > - /* > > -* Make sure all the required memory ops for given memory type > > -* are available. > > -*/ > > - if (req->memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { > > - dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); > > - return -EINVAL; > > - } > > - > > - if (req->memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { > > - dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); > > - return -EINVAL; > > - } > > + int ret; > > > > if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) > > { > > /* > > @@ -595,10 +606,23 @@ int vb2_reqbufs(struct vb2_queue *q, struct > > v4l2_req
Re: [RFCv2 PATCH 27/34] videobuf2-core: add helper functions.
On Wed 27 June 2012 11:42:31 Laurent Pinchart wrote: > Hi Hans, > > Thanks for the patch. > > On Friday 22 June 2012 14:21:21 Hans Verkuil wrote: > > From: Hans Verkuil > > > > Add helper functions to make it easier to adapt drivers to vb2. > > > > These helpers take care of core locking and check if the filehandle is the > > owner of the queue. > > > > Signed-off-by: Hans Verkuil > > --- > > drivers/media/video/videobuf2-core.c | 227 +++ > > Was it not possible to move the functions to videobuf2-ioctl.c ? Yes, it was possible, but it would require making some functions extern instead of static. In my opinion there is not enough advantage in moving these functions to a separate file. I've added additional comments that should prevent any confusion. Regards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: About s_std_output
2012/6/27 Hans Verkuil : > On Wed 27 June 2012 11:37:24 Scott Jiang wrote: >> Hi Hans, >> >> I noticed there are two s_std ops in core and video for output. And >> some drivers call video->s_std_out and then core->s_std in their S_STD >> iotcl. Could anyone share me the story why we have >> s_std_output/g_std_output/g_tvnorms_output ops in video instead of >> making use of s_std/g_std in core? > > The core class is for common, often used ops. Setting the standard for > capture devices is very common, so it is in core. Setting the standard > for output devices is much less common (there aren't that many output > devices in the kernel), so that stayed in the video class. > My question is why we can't reuse s_std/g_std for output device. We use same VIDIOC_S_STD/VIDIOC_G_STD ioctl for both input and output. > It is a bit arbitrary and I am not sure whether I would make the same > choice now. > So I should ignore s_std/g_std and use s_std_output/g_std_output in encoder driver, right? > There is no g_tvnorms_output, BTW. > It really exists. struct v4l2_subdev_video_ops { int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config); int (*s_crystal_freq)(struct v4l2_subdev *sd, u32 freq, u32 flags); int (*s_std_output)(struct v4l2_subdev *sd, v4l2_std_id std); int (*g_std_output)(struct v4l2_subdev *sd, v4l2_std_id *std); int (*querystd)(struct v4l2_subdev *sd, v4l2_std_id *std); int (*g_tvnorms_output)(struct v4l2_subdev *sd, v4l2_std_id *std); -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 32/34] v4l2-dev.c: also add debug support for the fops.
Hi Hans, Thanks for the patch. On Friday 22 June 2012 14:21:26 Hans Verkuil wrote: > From: Hans Verkuil > > Signed-off-by: Hans Verkuil > --- > drivers/media/video/v4l2-dev.c | 25 - > 1 file changed, 24 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c > index 1b34360..b51bee9 100644 > --- a/drivers/media/video/v4l2-dev.c > +++ b/drivers/media/video/v4l2-dev.c > @@ -305,6 +305,9 @@ static ssize_t v4l2_read(struct file *filp, char __user > *buf, ret = vdev->fops->read(filp, buf, sz, off); > if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) > mutex_unlock(vdev->lock); > + if (vdev->debug) > + printk(KERN_DEBUG "%s: read: %zd (%d)\n", > + video_device_node_name(vdev), sz, ret); Would it make sense to introduce a v4l_dbg macro ? BTW, what was the outcome of the pr_ vs. dev_ tests ? > return ret; > } > > @@ -323,6 +326,9 @@ static ssize_t v4l2_write(struct file *filp, const char > __user *buf, ret = vdev->fops->write(filp, buf, sz, off); > if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) > mutex_unlock(vdev->lock); > + if (vdev->debug) > + printk(KERN_DEBUG "%s: write: %zd (%d)\n", > + video_device_node_name(vdev), sz, ret); > return ret; > } > > @@ -339,6 +345,9 @@ static unsigned int v4l2_poll(struct file *filp, struct > poll_table_struct *poll) ret = vdev->fops->poll(filp, poll); > if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) > mutex_unlock(vdev->lock); > + if (vdev->debug) > + printk(KERN_DEBUG "%s: poll: %08x\n", > + video_device_node_name(vdev), ret); > return ret; > } > > @@ -403,12 +412,17 @@ static unsigned long v4l2_get_unmapped_area(struct > file *filp, unsigned long flags) > { > struct video_device *vdev = video_devdata(filp); > + int ret; > > if (!vdev->fops->get_unmapped_area) > return -ENOSYS; > if (!video_is_registered(vdev)) > return -ENODEV; > - return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); > + ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); > + if (vdev->debug) > + printk(KERN_DEBUG "%s: get_unmapped_area (%d)\n", > + video_device_node_name(vdev), ret); > + return ret; > } > #endif > > @@ -426,6 +440,9 @@ static int v4l2_mmap(struct file *filp, struct > vm_area_struct *vm) ret = vdev->fops->mmap(filp, vm); > if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) > mutex_unlock(vdev->lock); > + if (vdev->debug) > + printk(KERN_DEBUG "%s: mmap (%d)\n", > + video_device_node_name(vdev), ret); > return ret; > } > > @@ -464,6 +481,9 @@ err: > /* decrease the refcount in case of an error */ > if (ret) > video_put(vdev); > + if (vdev->debug) > + printk(KERN_DEBUG "%s: open (%d)\n", > + video_device_node_name(vdev), ret); > return ret; > } > > @@ -483,6 +503,9 @@ static int v4l2_release(struct inode *inode, struct file > *filp) /* decrease the refcount unconditionally since the release() > return value is ignored. */ > video_put(vdev); > + if (vdev->debug) > + printk(KERN_DEBUG "%s: release\n", > + video_device_node_name(vdev)); > return ret; > } -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: About s_std_output
On Wed 27 June 2012 11:37:24 Scott Jiang wrote: > Hi Hans, > > I noticed there are two s_std ops in core and video for output. And > some drivers call video->s_std_out and then core->s_std in their S_STD > iotcl. Could anyone share me the story why we have > s_std_output/g_std_output/g_tvnorms_output ops in video instead of > making use of s_std/g_std in core? The core class is for common, often used ops. Setting the standard for capture devices is very common, so it is in core. Setting the standard for output devices is much less common (there aren't that many output devices in the kernel), so that stayed in the video class. It is a bit arbitrary and I am not sure whether I would make the same choice now. There is no g_tvnorms_output, BTW. Regards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 19/34] v4l2-dev.c: add debug sysfs entry.
Hi Hans, Thanks for the patch. On Friday 22 June 2012 14:21:13 Hans Verkuil wrote: > From: Hans Verkuil > > Since this could theoretically change the debug value while in the middle > of v4l2-ioctl.c, we make a copy of vfd->debug to ensure consistent debug > behavior. In my review of RFCv1, I wrote that this could introduce a race condition: "You test the debug value several times in the __video_do_ioctl() function. I haven't checked in details whether changing the value between the two tests could for instance lead to a KERN_CONT print without a previous non-KERN_CONT message. That won't crash the machine but it should still be avoided." Have you verified whether that problem can occur ? > Signed-off-by: Hans Verkuil > --- > drivers/media/video/v4l2-dev.c | 24 > drivers/media/video/v4l2-ioctl.c |9 + > 2 files changed, 29 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c > index 1500208..5c0bb18 100644 > --- a/drivers/media/video/v4l2-dev.c > +++ b/drivers/media/video/v4l2-dev.c > @@ -46,6 +46,29 @@ static ssize_t show_index(struct device *cd, > return sprintf(buf, "%i\n", vdev->index); > } > > +static ssize_t show_debug(struct device *cd, > + struct device_attribute *attr, char *buf) > +{ > + struct video_device *vdev = to_video_device(cd); > + > + return sprintf(buf, "%i\n", vdev->debug); > +} > + > +static ssize_t set_debug(struct device *cd, struct device_attribute *attr, > +const char *buf, size_t len) > +{ > + struct video_device *vdev = to_video_device(cd); > + int res = 0; > + u16 value; > + > + res = kstrtou16(buf, 0, &value); > + if (res) > + return res; > + > + vdev->debug = value; > + return len; > +} > + > static ssize_t show_name(struct device *cd, >struct device_attribute *attr, char *buf) > { > @@ -56,6 +79,7 @@ static ssize_t show_name(struct device *cd, > > static struct device_attribute video_device_attrs[] = { > __ATTR(name, S_IRUGO, show_name, NULL), > + __ATTR(debug, 0644, show_debug, set_debug), > __ATTR(index, S_IRUGO, show_index, NULL), > __ATTR_NULL > }; > diff --git a/drivers/media/video/v4l2-ioctl.c > b/drivers/media/video/v4l2-ioctl.c index 0531d9a..2e1421b 100644 > --- a/drivers/media/video/v4l2-ioctl.c > +++ b/drivers/media/video/v4l2-ioctl.c > @@ -1998,6 +1998,7 @@ static long __video_do_ioctl(struct file *file, > void *fh = file->private_data; > struct v4l2_fh *vfh = NULL; > int use_fh_prio = 0; > + int debug = vfd->debug; > long ret = -ENOTTY; > > if (ops == NULL) { > @@ -2031,7 +2032,7 @@ static long __video_do_ioctl(struct file *file, > } > > write_only = _IOC_DIR(cmd) == _IOC_WRITE; > - if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) { > + if (write_only && debug > V4L2_DEBUG_IOCTL) { > v4l_print_ioctl(vfd->name, cmd); > pr_cont(": "); > info->debug(arg, write_only); > @@ -2053,8 +2054,8 @@ static long __video_do_ioctl(struct file *file, > } > > done: > - if (vfd->debug) { > - if (write_only && vfd->debug > V4L2_DEBUG_IOCTL) { > + if (debug) { > + if (write_only && debug > V4L2_DEBUG_IOCTL) { > if (ret < 0) > printk(KERN_DEBUG "%s: error %ld\n", > video_device_node_name(vfd), ret); > @@ -2063,7 +2064,7 @@ done: > v4l_print_ioctl(vfd->name, cmd); > if (ret < 0) > pr_cont(": error %ld\n", ret); > - else if (vfd->debug == V4L2_DEBUG_IOCTL) > + else if (debug == V4L2_DEBUG_IOCTL) > pr_cont("\n"); > else if (_IOC_DIR(cmd) == _IOC_NONE) > info->debug(arg, write_only); -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFCv2 PATCH 23/34] vb2-core: refactor reqbufs/create_bufs.
Hi Hans, Thanks for the patch. On Friday 22 June 2012 14:21:17 Hans Verkuil wrote: > From: Hans Verkuil > > Split off the memory and type validation. This is done both from reqbufs and > create_bufs, and will also be done by vb2 helpers in a later patch. > > Signed-off-by: Hans Verkuil > --- > drivers/media/video/videobuf2-core.c | 153 +-- > 1 file changed, 80 insertions(+), 73 deletions(-) > > diff --git a/drivers/media/video/videobuf2-core.c > b/drivers/media/video/videobuf2-core.c index 9d4e9ed..8486e33 100644 > --- a/drivers/media/video/videobuf2-core.c > +++ b/drivers/media/video/videobuf2-core.c > @@ -454,7 +454,53 @@ static int __verify_mmap_ops(struct vb2_queue *q) > } > > /** > - * vb2_reqbufs() - Initiate streaming > + * __verify_memory_type() - do basic checks for memory and type I'd expand this comment a bit, as "basic checks" doesn't really tell much about the purpose of the checks. Maybe something like "Check whether the memory type and buffer type passed to a buffer operation are compatible with the queue." > + */ > +static int __verify_memory_type(struct vb2_queue *q, __u32 memory, __u32 > type) What about using enum v4l2_memory and enum v4l2_buf_type instead of __u32 ? > +{ > + if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR) { > + dprintk(1, "reqbufs: unsupported memory type\n"); > + return -EINVAL; > + } > + > + if (type != q->type) { > + dprintk(1, "reqbufs: requested type is incorrect\n"); > + return -EINVAL; > + } > + > + /* > + * Make sure all the required memory ops for given memory type > + * are available. > + */ > + if (memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { > + dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); > + return -EINVAL; > + } > + > + if (memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { > + dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); > + return -EINVAL; > + } > + > + /* > + * Place the busy tests at the end: -EBUSY can be ignored when > + * create_bufs is called with count == 0, but count == 0 should still > + * do the memory and type validation. > + */ > + if (q->fileio) { > + dprintk(1, "reqbufs: file io in progress\n"); > + return -EBUSY; > + } > + > + if (q->streaming) { > + dprintk(1, "reqbufs: streaming active\n"); > + return -EBUSY; > + } create_bufs didn't check for q->streaming. Isn't it legal to add a buffer during streaming ? > + return 0; > +} > + > +/** > + * __reqbufs() - Initiate streaming > * @q: videobuf2 queue > * @req: struct passed from userspace to vidioc_reqbufs handler in driver > * > @@ -476,45 +522,10 @@ static int __verify_mmap_ops(struct vb2_queue *q) > * The return values from this function are intended to be directly > returned * from vidioc_reqbufs handler in driver. > */ > -int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) > +static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) > { > unsigned int num_buffers, allocated_buffers, num_planes = 0; > - int ret = 0; > - > - if (q->fileio) { > - dprintk(1, "reqbufs: file io in progress\n"); > - return -EBUSY; > - } > - > - if (req->memory != V4L2_MEMORY_MMAP > - && req->memory != V4L2_MEMORY_USERPTR) { > - dprintk(1, "reqbufs: unsupported memory type\n"); > - return -EINVAL; > - } > - > - if (req->type != q->type) { > - dprintk(1, "reqbufs: requested type is incorrect\n"); > - return -EINVAL; > - } > - > - if (q->streaming) { > - dprintk(1, "reqbufs: streaming active\n"); > - return -EBUSY; > - } > - > - /* > - * Make sure all the required memory ops for given memory type > - * are available. > - */ > - if (req->memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { > - dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); > - return -EINVAL; > - } > - > - if (req->memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { > - dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); > - return -EINVAL; > - } > + int ret; > > if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) > { > /* > @@ -595,10 +606,23 @@ int vb2_reqbufs(struct vb2_queue *q, struct > v4l2_requestbuffers *req) > > return 0; > } > + > +/** > + * vb2_reqbufs() - Wrapper for __reqbufs() that also verifies the memory > and + * type values. > + * @q: videobuf2 queue > + * @req: struct passed from userspace to vidioc_reqbufs handler in driver > + */ > +int vb2_reqbufs(struct vb2_queue *q
Re: [RFCv2 PATCH 27/34] videobuf2-core: add helper functions.
Hi Hans, Thanks for the patch. On Friday 22 June 2012 14:21:21 Hans Verkuil wrote: > From: Hans Verkuil > > Add helper functions to make it easier to adapt drivers to vb2. > > These helpers take care of core locking and check if the filehandle is the > owner of the queue. > > Signed-off-by: Hans Verkuil > --- > drivers/media/video/videobuf2-core.c | 227 +++ Was it not possible to move the functions to videobuf2-ioctl.c ? > include/media/videobuf2-core.h | 32 + > 2 files changed, 259 insertions(+) -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
About s_std_output
Hi Hans, I noticed there are two s_std ops in core and video for output. And some drivers call video->s_std_out and then core->s_std in their S_STD iotcl. Could anyone share me the story why we have s_std_output/g_std_output/g_tvnorms_output ops in video instead of making use of s_std/g_std in core? Thanks, Scott -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: hacking MT9P031 (LI-5M03) driver in Ubuntu 12.04 on BeagleBoard xM?
Hi Chris, On Thursday 21 June 2012 09:38:11 Chris MacGregor wrote: > Hi. I was redirected to this list by a response to my post (below) on > the BeagleBoard group. I'm happy to help/cooperate/etc. in whatever way > I reasonably can. > > Original Message > > Hello, all. > > I managed to get the MT9P031 driver (for the Leopard Imaging LI-5M03 camera > board) working using a slightly modified Ubuntu 12.04 kernel, including the > mainline kernel version of the MT9P031 driver. Once everything is clean and > happy I will post info for those still trying to get there. Meanwhile, > though, there are some odd issues, and a few driver bugs I need to fix and > features I need to add. I wanted to reach out to others who are working with > this hardware in current (not Angstrom 2.6.x) kernels so we can compare > notes, and so we don't go off in the wrong (or a different) direction on > solving some of the problems. > > For our application, we are capturing video in raw format (raw Bayer), with > MT9P031 -> CCDC -> CCDC output (no resizer etc.), reading from /dev/video2. > The new media controller framework is pretty cool once you get the hang of > it - it addresses some significant deficiencies. Thank you :-) > I just wish the new subdev selection was available, but it's not in 3.2.x... > hopefully we can move to 3.5 soon and then I just need to implement it in > the MT9P031 driver (if someone else doesn't do that before I get there). > > Some of the issues: > > 1. To get it working, I had to patch in the Aptina driver mods for board- > omap3beagle.c etc. I'm not at all sure this is kosher since I'm using the > mainline kernel driver, not the Aptina driver (nor the RidgeRun one, in > which I had to fix a lot of bugs when we were doing this on a Leopardboard). > But without these changes, the camera was not recognized (likely because it > wasn't being powered up). I would think that someone out there must be using > the driver in the mainline kernel, since it's in there, but how are they > getting the camera to be recognized? Unlike on PC hardware, operating systems on embedded hardware usually can't discover devices at runtime. The Linux kernel thus needs a list of the devices present on the system (both inside the SoC and on the board) to handle them properly. That list is usually hardcoded in board code, and the Linux kernel on ARM recently started a migration to the Device Tree that provides such a hardware description from outside the kernel. Devices present inside the SoC or directly on the board are not removable and can be hardcoded in board code or in the device tree. However, devices that come on add-on boards are problematic as they're not always present and can be replaced. Several sensor modules exist for the Beagleboard-xM, we can't hardcode support for one of them in the mainline kernel. There's currently no way to properly support the different sensor modules with a single kernel, mostly because nobody developed a solution so far (although proposals have been posted to mailing lists). For that reason I currently maintain board code with sensor support for several OMAP3 platforms in the omap3isp-sensors-board branch of my git tree at http://git.linuxtv.org/pinchartl/media.git. I'd be happy to push that to mainline if we had a good technical solution. Where did you get the Aptina board code patch from ? > 2. Max frame rate at full resolution seems to be 6.86 fps. I think we're > running at half clock speed. We'd like to fix that. I can track it down, but > I don't want to duplicate work already done by someone else, and of course > this likely relates to issue # 1, above. The clock speed is configurable, but the device is limited to 48 MHz when using 1.8V I/O. To reach 96 MHz we would have to power the I/O supply with 2.8V and add a level shifter on the board, as the OMAP3 use 1/8V I/O. > 3. When I start streaming, then stop streaming, then start streaming again > without closing and reopening the device in between (and sometimes even if I > do but reopen right after closing), the second time we start streaming, it > appears that the green and non-green (red or blue as the case may be) pixels > are swapped - as if it was offset by one column. But if I change the > cropping (using VIDIOC_SUBDEV_S_FMT on /ev/v4l-subdev8, which is the MT9P031 > directly) to include the black (inactive) pixels on the top and left, it is > still true - but the black pixels don't change, only the active ones, even > though they still start at the same offset (+10,+50 IIRC). I don't even see > how that should be possible. Just to make sure I understand that properly, do you mean that the boundary between the black and non-black pixels doesn't move, when you expected it to be shifted by one column or one line if the color swap had been caused by an image shift ? Did you include both black lines and black columns in your test ? > The MT9P031 registers (all of them) are
Re: [GIT PULL FOR v3.5] Move sta2x11_vip to staging
On Mon 28 May 2012 13:47:43 Federico Vaga wrote: > > I didn't get any reply from Federico when I posted my concerns last > > week, so that makes me unhappy as well. > > > > I hope the author will fix these issues, but in the meantime this will > > move it to staging waiting for further developments. > > The last time I worked on this device was 2 month and half ago (RFC > time) and before answer "Ok, I'll fix it" I'm trying to understand if me > or someone else will do that work. I'll provide a better answer than > this when I have more information. > > Sorry for not sending an ack immediately, but be reassured that I'm > still on the hardware and following the developments. Hi Federico, Any news on this? Regards, Hans -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch -resend] [media] az6007: precedence bug in az6007_i2c_xfer()
The intent here was to test that the flag was clear but the '!' has higher precedence than the '&'. I2C_M_RD is 0x1 so the current code is equivalent to "&& (!sgs[i].flags) ..." Signed-off-by: Dan Carpenter --- I sent this originally on Wed, 25 Jan 2012 and Emil Goode sent the same fix on Thu, May 3, 2012. diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c index 4008b9c..f6f0cf9 100644 --- a/drivers/media/dvb/dvb-usb/az6007.c +++ b/drivers/media/dvb/dvb-usb/az6007.c @@ -711,7 +711,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], addr = msgs[i].addr << 1; if (((i + 1) < num) && (msgs[i].len == 1) - && (!msgs[i].flags & I2C_M_RD) + && (!(msgs[i].flags & I2C_M_RD)) && (msgs[i + 1].flags & I2C_M_RD) && (msgs[i].addr == msgs[i + 1].addr)) { /* -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html