From patchwork Thu Mar 2 13:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D9EAC7EE33 for ; Thu, 2 Mar 2023 13:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbjCBNDk (ORCPT ); Thu, 2 Mar 2023 08:03:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbjCBNDi (ORCPT ); Thu, 2 Mar 2023 08:03:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F446136DA for ; Thu, 2 Mar 2023 05:03:35 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F18F1615B3 for ; Thu, 2 Mar 2023 13:03:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E349C433EF; Thu, 2 Mar 2023 13:03:33 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 01/17] media: saa7146: drop 'dev' and 'resources' from struct saa7146_fh Date: Thu, 2 Mar 2023 14:03:14 +0100 Message-Id: <20230302130330.1125172-2-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Instead use vv->resources and video_drvdata(file) to obtain this information. This prepares for the vb2 conversion later when saa7146_fh is dropped completely. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_fops.c | 31 +++++----- drivers/media/common/saa7146/saa7146_vbi.c | 21 +++---- drivers/media/common/saa7146/saa7146_video.c | 60 +++++++++----------- drivers/media/pci/saa7146/hexium_gemini.c | 4 +- drivers/media/pci/saa7146/hexium_orion.c | 4 +- drivers/media/pci/saa7146/mxb.c | 22 +++---- drivers/media/pci/ttpci/budget-av.c | 4 +- drivers/staging/media/av7110/av7110_v4l.c | 35 ++++++------ include/media/drv-intf/saa7146_vv.h | 7 +-- 9 files changed, 86 insertions(+), 102 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c index 08c8e73cef2c..3cb3ee7855ee 100644 --- a/drivers/media/common/saa7146/saa7146_fops.c +++ b/drivers/media/common/saa7146/saa7146_fops.c @@ -7,12 +7,11 @@ /****************************************************************************/ /* resource management functions, shamelessly stolen from saa7134 driver */ -int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit) +int saa7146_res_get(struct saa7146_dev *dev, unsigned int bit) { - struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; - if (fh->resources & bit) { + if (vv->resources & bit) { DEB_D("already allocated! want: 0x%02x, cur:0x%02x\n", bit, vv->resources); /* have it already allocated */ @@ -27,20 +26,17 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit) return 0; } /* it's free, grab it */ - fh->resources |= bit; vv->resources |= bit; DEB_D("res: get 0x%02x, cur:0x%02x\n", bit, vv->resources); return 1; } -void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits) +void saa7146_res_free(struct saa7146_dev *dev, unsigned int bits) { - struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; - BUG_ON((fh->resources & bits) != bits); + WARN_ON((vv->resources & bits) != bits); - fh->resources &= ~bits; vv->resources &= ~bits; DEB_D("res: put 0x%02x, cur:0x%02x\n", bits, vv->resources); } @@ -221,7 +217,6 @@ static int fops_open(struct file *file) v4l2_fh_init(&fh->fh, vdev); file->private_data = &fh->fh; - fh->dev = dev; if (vdev->vfl_type == VFL_TYPE_VBI) { DEB_S("initializing vbi...\n"); @@ -257,8 +252,8 @@ static int fops_open(struct file *file) static int fops_release(struct file *file) { struct video_device *vdev = video_devdata(file); + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; DEB_EE("file:%p\n", file); @@ -287,6 +282,7 @@ static int fops_release(struct file *file) static int fops_mmap(struct file *file, struct vm_area_struct * vma) { struct video_device *vdev = video_devdata(file); + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_fh *fh = file->private_data; struct videobuf_queue *q; int res; @@ -301,7 +297,7 @@ static int fops_mmap(struct file *file, struct vm_area_struct * vma) case VFL_TYPE_VBI: { DEB_EE("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, vma:%p\n", file, vma); - if (fh->dev->ext_vv_data->capabilities & V4L2_CAP_SLICED_VBI_OUTPUT) + if (dev->ext_vv_data->capabilities & V4L2_CAP_SLICED_VBI_OUTPUT) return -ENODEV; q = &fh->vbi_q; break; @@ -320,6 +316,7 @@ static int fops_mmap(struct file *file, struct vm_area_struct * vma) static __poll_t __fops_poll(struct file *file, struct poll_table_struct *wait) { struct video_device *vdev = video_devdata(file); + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_fh *fh = file->private_data; struct videobuf_buffer *buf = NULL; struct videobuf_queue *q; @@ -328,7 +325,7 @@ static __poll_t __fops_poll(struct file *file, struct poll_table_struct *wait) DEB_EE("file:%p, poll:%p\n", file, wait); if (vdev->vfl_type == VFL_TYPE_VBI) { - if (fh->dev->ext_vv_data->capabilities & V4L2_CAP_SLICED_VBI_OUTPUT) + if (dev->ext_vv_data->capabilities & V4L2_CAP_SLICED_VBI_OUTPUT) return res | EPOLLOUT | EPOLLWRNORM; if( 0 == fh->vbi_q.streaming ) return res | videobuf_poll_stream(file, &fh->vbi_q, wait); @@ -370,7 +367,7 @@ static __poll_t fops_poll(struct file *file, struct poll_table_struct *wait) static ssize_t fops_read(struct file *file, char __user *data, size_t count, loff_t *ppos) { struct video_device *vdev = video_devdata(file); - struct saa7146_fh *fh = file->private_data; + struct saa7146_dev *dev = video_drvdata(file); int ret; switch (vdev->vfl_type) { @@ -385,7 +382,7 @@ static ssize_t fops_read(struct file *file, char __user *data, size_t count, lof DEB_EE("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", file, data, (unsigned long)count); */ - if (fh->dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) { + if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) { if (mutex_lock_interruptible(vdev->lock)) return -ERESTARTSYS; ret = saa7146_vbi_uops.read(file, data, count, ppos); @@ -401,17 +398,17 @@ static ssize_t fops_read(struct file *file, char __user *data, size_t count, lof static ssize_t fops_write(struct file *file, const char __user *data, size_t count, loff_t *ppos) { struct video_device *vdev = video_devdata(file); - struct saa7146_fh *fh = file->private_data; + struct saa7146_dev *dev = video_drvdata(file); int ret; switch (vdev->vfl_type) { case VFL_TYPE_VIDEO: return -EINVAL; case VFL_TYPE_VBI: - if (fh->dev->ext_vv_data->vbi_fops.write) { + if (dev->ext_vv_data->vbi_fops.write) { if (mutex_lock_interruptible(vdev->lock)) return -ERESTARTSYS; - ret = fh->dev->ext_vv_data->vbi_fops.write(file, data, count, ppos); + ret = dev->ext_vv_data->vbi_fops.write(file, data, count, ppos); mutex_unlock(vdev->lock); return ret; } diff --git a/drivers/media/common/saa7146/saa7146_vbi.c b/drivers/media/common/saa7146/saa7146_vbi.c index bd442b984423..1a6fb0f381b7 100644 --- a/drivers/media/common/saa7146/saa7146_vbi.c +++ b/drivers/media/common/saa7146/saa7146_vbi.c @@ -219,8 +219,7 @@ static int buffer_activate(struct saa7146_dev *dev, static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,enum v4l2_field field) { struct file *file = q->priv_data; - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_buf *buf = (struct saa7146_buf *)vb; int err = 0; @@ -289,8 +288,7 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) { struct file *file = q->priv_data; - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; struct saa7146_buf *buf = (struct saa7146_buf *)vb; @@ -301,8 +299,7 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) { struct file *file = q->priv_data; - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_buf *buf = (struct saa7146_buf *)vb; DEB_VBI("vb:%p\n", vb); @@ -320,7 +317,7 @@ static const struct videobuf_queue_ops vbi_qops = { static void vbi_stop(struct saa7146_fh *fh, struct file *file) { - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; unsigned long flags; DEB_VBI("dev:%p, fh:%p\n", dev, fh); @@ -353,8 +350,8 @@ static void vbi_read_timeout(struct timer_list *t) { struct saa7146_vv *vv = from_timer(vv, t, vbi_read_timeout); struct file *file = vv->vbi_read_timeout_file; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; DEB_VBI("dev:%p, fh:%p\n", dev, fh); @@ -376,14 +373,14 @@ static void vbi_init(struct saa7146_dev *dev, struct saa7146_vv *vv) static int vbi_open(struct saa7146_dev *dev, struct file *file) { struct saa7146_fh *fh = file->private_data; - struct saa7146_vv *vv = fh->dev->vv_data; + struct saa7146_vv *vv = dev->vv_data; u32 arbtr_ctrl = saa7146_read(dev, PCI_BT_V1); int ret = 0; DEB_VBI("dev:%p, fh:%p\n", dev, fh); - ret = saa7146_res_get(fh, RESOURCE_DMA3_BRS); + ret = saa7146_res_get(dev, RESOURCE_DMA3_BRS); if (0 == ret) { DEB_S("cannot get vbi RESOURCE_DMA3_BRS resource\n"); return -EBUSY; @@ -431,7 +428,7 @@ static void vbi_close(struct saa7146_dev *dev, struct file *file) if( fh == vv->vbi_streaming ) { vbi_stop(fh, file); } - saa7146_res_free(fh, RESOURCE_DMA3_BRS); + saa7146_res_free(dev, RESOURCE_DMA3_BRS); } static void vbi_irq_done(struct saa7146_dev *dev, unsigned long status) @@ -456,7 +453,7 @@ static void vbi_irq_done(struct saa7146_dev *dev, unsigned long status) static ssize_t vbi_read(struct file *file, char __user *data, size_t count, loff_t *ppos) { struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; ssize_t ret = 0; diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 27c97218ee53..58f39cf64a1c 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -211,9 +211,8 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu /********************************************************************************/ /* file operations */ -static int video_begin(struct saa7146_fh *fh) +static int video_begin(struct saa7146_dev *dev, struct saa7146_fh *fh) { - struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; struct saa7146_format *fmt = NULL; unsigned int resource; @@ -241,7 +240,7 @@ static int video_begin(struct saa7146_fh *fh) resource = RESOURCE_DMA1_HPS; } - ret = saa7146_res_get(fh, resource); + ret = saa7146_res_get(dev, resource); if (0 == ret) { DEB_S("cannot get capture resource %d\n", resource); return -EBUSY; @@ -259,9 +258,8 @@ static int video_begin(struct saa7146_fh *fh) return 0; } -static int video_end(struct saa7146_fh *fh, struct file *file) +static int video_end(struct saa7146_dev *dev, struct saa7146_fh *fh) { - struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; struct saa7146_dmaqueue *q = &vv->video_dmaq; struct saa7146_format *fmt = NULL; @@ -311,14 +309,14 @@ static int video_end(struct saa7146_fh *fh, struct file *file) vv->video_fh = NULL; vv->video_status = 0; - saa7146_res_free(fh, resource); + saa7146_res_free(dev, resource); return 0; } static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *cap) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); strscpy((char *)cap->driver, "saa7146 v4l2", sizeof(cap->driver)); strscpy((char *)cap->card, dev->ext->name, sizeof(cap->card)); @@ -391,7 +389,7 @@ int saa7146_s_ctrl(struct v4l2_ctrl *ctrl) static int vidioc_g_parm(struct file *file, void *fh, struct v4l2_streamparm *parm) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -404,7 +402,7 @@ static int vidioc_g_parm(struct file *file, void *fh, static int vidioc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; f->fmt.pix = vv->video_fmt; @@ -413,7 +411,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format static int vidioc_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; f->fmt.vbi = vv->vbi_fmt; @@ -422,7 +420,7 @@ static int vidioc_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; struct saa7146_format *fmt; enum v4l2_field field; @@ -487,8 +485,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma static int vidioc_s_fmt_vid_cap(struct file *file, void *__fh, struct v4l2_format *f) { + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_fh *fh = __fh; - struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; int err; @@ -508,7 +506,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *__fh, struct v4l2_forma static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; *norm = vv->standard->id; @@ -535,7 +533,7 @@ static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm) static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id id) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; int found = 0; int i; @@ -612,12 +610,13 @@ static int vidioc_dqbuf(struct file *file, void *__fh, struct v4l2_buffer *buf) static int vidioc_streamon(struct file *file, void *__fh, enum v4l2_buf_type type) { + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_fh *fh = __fh; int err; DEB_D("VIDIOC_STREAMON, type:%d\n", type); - err = video_begin(fh); + err = video_begin(dev, fh); if (err) return err; if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) @@ -629,8 +628,8 @@ static int vidioc_streamon(struct file *file, void *__fh, enum v4l2_buf_type typ static int vidioc_streamoff(struct file *file, void *__fh, enum v4l2_buf_type type) { + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_fh *fh = __fh; - struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; int err; @@ -656,9 +655,9 @@ static int vidioc_streamoff(struct file *file, void *__fh, enum v4l2_buf_type ty err = videobuf_streamoff(&fh->vbi_q); if (0 != err) { DEB_D("warning: videobuf_streamoff() failed\n"); - video_end(fh, file); + video_end(dev, fh); } else { - err = video_end(fh, file); + err = video_end(dev, fh); } return err; } @@ -727,8 +726,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, enum v4l2_field field) { struct file *file = q->priv_data; - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; struct saa7146_buf *buf = (struct saa7146_buf *)vb; int size,err = 0; @@ -808,8 +806,8 @@ static int buffer_prepare(struct videobuf_queue *q, static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) { struct file *file = q->priv_data; - struct saa7146_fh *fh = file->private_data; - struct saa7146_vv *vv = fh->dev->vv_data; + struct saa7146_dev *dev = video_drvdata(file); + struct saa7146_vv *vv = dev->vv_data; if (0 == *count || *count > MAX_SAA7146_CAPTURE_BUFFERS) *count = MAX_SAA7146_CAPTURE_BUFFERS; @@ -829,20 +827,18 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) { struct file *file = q->priv_data; - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; struct saa7146_buf *buf = (struct saa7146_buf *)vb; DEB_CAP("vbuf:%p\n", vb); - saa7146_buffer_queue(fh->dev, &vv->video_dmaq, buf); + saa7146_buffer_queue(dev, &vv->video_dmaq, buf); } static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) { struct file *file = q->priv_data; - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_buf *buf = (struct saa7146_buf *)vb; DEB_CAP("vbuf:%p\n", vb); @@ -900,7 +896,7 @@ static void video_close(struct saa7146_dev *dev, struct file *file) struct videobuf_queue *q = &fh->video_q; if (IS_CAPTURE_ACTIVE(fh) != 0) - video_end(fh, file); + video_end(dev, fh); videobuf_stop(q); /* hmm, why is this function declared void? */ @@ -926,8 +922,8 @@ static void video_irq_done(struct saa7146_dev *dev, unsigned long st) static ssize_t video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) { + struct saa7146_dev *dev = video_drvdata(file); struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; struct saa7146_vv *vv = dev->vv_data; ssize_t ret = 0; @@ -943,7 +939,7 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo return -EBUSY; } - ret = video_begin(fh); + ret = video_begin(dev, fh); if( 0 != ret) { goto out; } @@ -951,9 +947,9 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo ret = videobuf_read_one(&fh->video_q , data, count, ppos, file->f_flags & O_NONBLOCK); if (ret != 0) { - video_end(fh, file); + video_end(dev, fh); } else { - ret = video_end(fh, file); + ret = video_end(dev, fh); } out: return ret; diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c index 3947701cd6c7..7dead0dfcc9f 100644 --- a/drivers/media/pci/saa7146/hexium_gemini.c +++ b/drivers/media/pci/saa7146/hexium_gemini.c @@ -215,7 +215,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct hexium *hexium = (struct hexium *) dev->ext_priv; *input = hexium->cur_input; @@ -226,7 +226,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) static int vidioc_s_input(struct file *file, void *fh, unsigned int input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct hexium *hexium = (struct hexium *) dev->ext_priv; DEB_EE("VIDIOC_S_INPUT %d\n", input); diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c index 2eb4bee16b71..a83fd5d19add 100644 --- a/drivers/media/pci/saa7146/hexium_orion.c +++ b/drivers/media/pci/saa7146/hexium_orion.c @@ -326,7 +326,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct hexium *hexium = (struct hexium *) dev->ext_priv; *input = hexium->cur_input; @@ -337,7 +337,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) static int vidioc_s_input(struct file *file, void *fh, unsigned int input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct hexium *hexium = (struct hexium *) dev->ext_priv; if (input >= HEXIUM_INPUTS) diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 7ded8f5b05cb..f518ad8c92ed 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -456,7 +456,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_g_input(struct file *file, void *fh, unsigned int *i) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; *i = mxb->cur_input; @@ -466,7 +466,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i) static int vidioc_s_input(struct file *file, void *fh, unsigned int input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; int err = 0; int i = 0; @@ -528,7 +528,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; if (t->index) { @@ -550,7 +550,7 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) static int vidioc_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *t) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; if (t->index) { @@ -565,14 +565,14 @@ static int vidioc_s_tuner(struct file *file, void *fh, const struct v4l2_tuner * static int vidioc_querystd(struct file *file, void *fh, v4l2_std_id *norm) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); return call_all(dev, video, querystd, norm); } static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; if (f->tuner) @@ -585,7 +585,7 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; struct saa7146_vv *vv = dev->vv_data; @@ -626,7 +626,7 @@ static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a) static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; DEB_EE("VIDIOC_G_AUDIO\n"); @@ -636,7 +636,7 @@ static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a) static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio *a) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; DEB_D("VIDIOC_S_AUDIO %d\n", a->index); @@ -656,7 +656,7 @@ static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio * #ifdef CONFIG_VIDEO_ADV_DEBUG static int vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); if (reg->reg > pci_resource_len(dev->pci, 0) - 4) return -EINVAL; @@ -667,7 +667,7 @@ static int vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_regist static int vidioc_s_register(struct file *file, void *fh, const struct v4l2_dbg_register *reg) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); if (reg->reg > pci_resource_len(dev->pci, 0) - 4) return -EINVAL; diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c index 3cb83005cf09..f33d1e2602d1 100644 --- a/drivers/media/pci/ttpci/budget-av.c +++ b/drivers/media/pci/ttpci/budget-av.c @@ -1410,7 +1410,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_g_input(struct file *file, void *fh, unsigned int *i) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct budget_av *budget_av = (struct budget_av *)dev->ext_priv; *i = budget_av->cur_input; @@ -1421,7 +1421,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i) static int vidioc_s_input(struct file *file, void *fh, unsigned int input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct budget_av *budget_av = (struct budget_av *)dev->ext_priv; dprintk(1, "VIDIOC_S_INPUT %d\n", input); diff --git a/drivers/staging/media/av7110/av7110_v4l.c b/drivers/staging/media/av7110/av7110_v4l.c index 374f78b84c04..3ab930cd8a27 100644 --- a/drivers/staging/media/av7110/av7110_v4l.c +++ b/drivers/staging/media/av7110/av7110_v4l.c @@ -213,9 +213,8 @@ static const struct v4l2_audio msp3400_v4l2_audio = { .capability = V4L2_AUDCAP_STEREO }; -static int av7110_dvb_c_switch(struct saa7146_fh *fh) +static int av7110_dvb_c_switch(struct saa7146_dev *dev) { - struct saa7146_dev *dev = fh->dev; struct av7110 *av7110 = (struct av7110*)dev->ext_priv; u16 adswitch; int source, sync; @@ -295,7 +294,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; u16 stereo_det; s8 stereo; @@ -339,7 +338,7 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) static int vidioc_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *t) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; u16 fm_matrix, src; dprintk(2, "VIDIOC_S_TUNER: %d\n", t->index); @@ -383,7 +382,7 @@ static int vidioc_s_tuner(struct file *file, void *fh, const struct v4l2_tuner * static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_G_FREQ: freq:0x%08x\n", f->frequency); @@ -399,7 +398,7 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_S_FREQUENCY: freq:0x%08x\n", f->frequency); @@ -429,7 +428,7 @@ static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_fre static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index); @@ -449,7 +448,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; *input = av7110->current_input; @@ -459,7 +458,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) static int vidioc_s_input(struct file *file, void *fh, unsigned int input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_S_INPUT: %d\n", input); @@ -471,7 +470,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) return -EINVAL; av7110->current_input = input; - return av7110_dvb_c_switch(fh); + return av7110_dvb_c_switch(dev); } static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a) @@ -485,7 +484,7 @@ static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a) static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_G_AUDIO: %d\n", a->index); @@ -499,7 +498,7 @@ static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a) static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio *a) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_S_AUDIO: %d\n", a->index); @@ -511,7 +510,7 @@ static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio * static int vidioc_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced_vbi_cap *cap) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_G_SLICED_VBI_CAP\n"); @@ -527,7 +526,7 @@ static int vidioc_g_sliced_vbi_cap(struct file *file, void *fh, static int vidioc_g_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_format *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_G_FMT:\n"); @@ -545,7 +544,7 @@ static int vidioc_g_fmt_sliced_vbi_out(struct file *file, void *fh, static int vidioc_s_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_format *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_S_FMT\n"); @@ -573,8 +572,7 @@ static int vidioc_s_fmt_sliced_vbi_out(struct file *file, void *fh, static int av7110_vbi_reset(struct file *file) { - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110*) dev->ext_priv; dprintk(2, "%s\n", __func__); @@ -588,8 +586,7 @@ static int av7110_vbi_reset(struct file *file) static ssize_t av7110_vbi_write(struct file *file, const char __user *data, size_t count, loff_t *ppos) { - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110*) dev->ext_priv; struct v4l2_sliced_vbi_data d; int rc; diff --git a/include/media/drv-intf/saa7146_vv.h b/include/media/drv-intf/saa7146_vv.h index 932961e8f5ab..fee861670ddb 100644 --- a/include/media/drv-intf/saa7146_vv.h +++ b/include/media/drv-intf/saa7146_vv.h @@ -80,15 +80,12 @@ struct saa7146_dmaqueue { struct saa7146_fh { /* Must be the first field! */ struct v4l2_fh fh; - struct saa7146_dev *dev; /* video capture */ struct videobuf_queue video_q; /* vbi capture */ struct videobuf_queue vbi_q; - - unsigned int resources; /* resource management for device open */ }; #define STATUS_CAPTURE 0x02 @@ -192,8 +189,8 @@ int saa7146_s_ctrl(struct v4l2_ctrl *ctrl); extern const struct saa7146_use_ops saa7146_vbi_uops; /* resource management functions */ -int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit); -void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits); +int saa7146_res_get(struct saa7146_dev *dev, unsigned int bit); +void saa7146_res_free(struct saa7146_dev *dev, unsigned int bits); #define RESOURCE_DMA1_HPS 0x1 #define RESOURCE_DMA2_CLP 0x2 From patchwork Thu Mar 2 13:03:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B64CC6FA8E for ; Thu, 2 Mar 2023 13:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjCBNDi (ORCPT ); Thu, 2 Mar 2023 08:03:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjCBNDh (ORCPT ); Thu, 2 Mar 2023 08:03:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F14918A8B for ; Thu, 2 Mar 2023 05:03:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E57FE6157F for ; Thu, 2 Mar 2023 13:03:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83E0DC4339C; Thu, 2 Mar 2023 13:03:34 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 02/17] media: common: saa7146: drop 'fmt' from struct saa7146_buf Date: Thu, 2 Mar 2023 14:03:15 +0100 Message-Id: <20230302130330.1125172-3-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the video_fmt in saa7146_vv instead of having a pointer to it in struct saa7146_buf. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_hlp.c | 37 +++++++++++--------- drivers/media/common/saa7146/saa7146_video.c | 12 +++---- include/media/drv-intf/saa7146_vv.h | 1 - 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_hlp.c b/drivers/media/common/saa7146/saa7146_hlp.c index 6792a96d0ba3..69101f93a12e 100644 --- a/drivers/media/common/saa7146/saa7146_hlp.c +++ b/drivers/media/common/saa7146/saa7146_hlp.c @@ -407,14 +407,14 @@ void saa7146_write_out_dma(struct saa7146_dev* dev, int which, struct saa7146_vi static int calculate_video_dma_grab_packed(struct saa7146_dev* dev, struct saa7146_buf *buf) { struct saa7146_vv *vv = dev->vv_data; + struct v4l2_pix_format *pix = &vv->video_fmt; struct saa7146_video_dma vdma1; + struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev, pix->pixelformat); - struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat); - - int width = buf->fmt->width; - int height = buf->fmt->height; - int bytesperline = buf->fmt->bytesperline; - enum v4l2_field field = buf->fmt->field; + int width = pix->width; + int height = pix->height; + int bytesperline = pix->bytesperline; + enum v4l2_field field = pix->field; int depth = sfmt->depth; @@ -469,8 +469,9 @@ static int calculate_video_dma_grab_packed(struct saa7146_dev* dev, struct saa71 static int calc_planar_422(struct saa7146_vv *vv, struct saa7146_buf *buf, struct saa7146_video_dma *vdma2, struct saa7146_video_dma *vdma3) { - int height = buf->fmt->height; - int width = buf->fmt->width; + struct v4l2_pix_format *pix = &vv->video_fmt; + int height = pix->height; + int width = pix->width; vdma2->pitch = width; vdma3->pitch = width; @@ -500,8 +501,9 @@ static int calc_planar_422(struct saa7146_vv *vv, struct saa7146_buf *buf, struc static int calc_planar_420(struct saa7146_vv *vv, struct saa7146_buf *buf, struct saa7146_video_dma *vdma2, struct saa7146_video_dma *vdma3) { - int height = buf->fmt->height; - int width = buf->fmt->width; + struct v4l2_pix_format *pix = &vv->video_fmt; + int height = pix->height; + int width = pix->width; vdma2->pitch = width/2; vdma3->pitch = width/2; @@ -530,15 +532,15 @@ static int calc_planar_420(struct saa7146_vv *vv, struct saa7146_buf *buf, struc static int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa7146_buf *buf) { struct saa7146_vv *vv = dev->vv_data; + struct v4l2_pix_format *pix = &vv->video_fmt; struct saa7146_video_dma vdma1; struct saa7146_video_dma vdma2; struct saa7146_video_dma vdma3; + struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev, pix->pixelformat); - struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat); - - int width = buf->fmt->width; - int height = buf->fmt->height; - enum v4l2_field field = buf->fmt->field; + int width = pix->width; + int height = pix->height; + enum v4l2_field field = pix->field; BUG_ON(0 == buf->pt[0].dma); BUG_ON(0 == buf->pt[1].dma); @@ -701,8 +703,9 @@ static void program_capture_engine(struct saa7146_dev *dev, int planar) void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next) { - struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat); struct saa7146_vv *vv = dev->vv_data; + struct v4l2_pix_format *pix = &vv->video_fmt; + struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev, pix->pixelformat); u32 vdma1_prot_addr; DEB_CAP("buf:%p, next:%p\n", buf, next); @@ -714,7 +717,7 @@ void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struc saa7146_write(dev, MC2, MASK_27 ); } - saa7146_set_window(dev, buf->fmt->width, buf->fmt->height, buf->fmt->field); + saa7146_set_window(dev, pix->width, pix->height, pix->field); saa7146_set_output_format(dev, sfmt->trans); if ( vv->last_field == V4L2_FIELD_INTERLACED ) { diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 58f39cf64a1c..dd0d803c38cd 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -93,11 +93,13 @@ struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fou static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *buf) { + struct saa7146_vv *vv = dev->vv_data; struct pci_dev *pci = dev->pci; struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); struct scatterlist *list = dma->sglist; int length = dma->sglen; - struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat); + struct v4l2_pix_format *pix = &vv->video_fmt; + struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev, pix->pixelformat); DEB_EE("dev:%p, buf:%p, sg_len:%d\n", dev, buf, length); @@ -108,7 +110,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu __le32 *ptr1, *ptr2, *ptr3; __le32 fill; - int size = buf->fmt->width*buf->fmt->height; + int size = pix->width * pix->height; int i,p,m1,m2,m3,o1,o2; switch( sfmt->depth ) { @@ -757,8 +759,7 @@ static int buffer_prepare(struct videobuf_queue *q, buf->vb.height != vv->video_fmt.height || buf->vb.size != size || buf->vb.field != field || - buf->vb.field != vv->video_fmt.field || - buf->fmt != &vv->video_fmt) { + buf->vb.field != vv->video_fmt.field) { saa7146_dma_free(dev,q,buf); } @@ -770,10 +771,9 @@ static int buffer_prepare(struct videobuf_queue *q, buf->vb.height = vv->video_fmt.height; buf->vb.size = size; buf->vb.field = field; - buf->fmt = &vv->video_fmt; buf->vb.field = vv->video_fmt.field; - sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat); + sfmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); release_all_pagetables(dev, buf); if( 0 != IS_PLANAR(sfmt->trans)) { diff --git a/include/media/drv-intf/saa7146_vv.h b/include/media/drv-intf/saa7146_vv.h index fee861670ddb..80463fdd30eb 100644 --- a/include/media/drv-intf/saa7146_vv.h +++ b/include/media/drv-intf/saa7146_vv.h @@ -60,7 +60,6 @@ struct saa7146_buf { struct videobuf_buffer vb; /* saa7146 specific */ - struct v4l2_pix_format *fmt; int (*activate)(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next); From patchwork Thu Mar 2 13:03:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2629C7EE30 for ; Thu, 2 Mar 2023 13:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229890AbjCBNDj (ORCPT ); Thu, 2 Mar 2023 08:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229854AbjCBNDi (ORCPT ); Thu, 2 Mar 2023 08:03:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E40A18B31 for ; Thu, 2 Mar 2023 05:03:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BA1EA615C6 for ; Thu, 2 Mar 2023 13:03:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F2EFC433D2; Thu, 2 Mar 2023 13:03:35 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 03/17] media: common: saa7146: replace BUG_ON by WARN_ON Date: Thu, 2 Mar 2023 14:03:16 +0100 Message-Id: <20230302130330.1125172-4-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org No need for BUG_ON, WARN_ON is a lot friendlier. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_core.c | 11 +++++++---- drivers/media/common/saa7146/saa7146_fops.c | 6 ++++-- drivers/media/common/saa7146/saa7146_hlp.c | 7 ++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_core.c b/drivers/media/common/saa7146/saa7146_core.c index e50fa0ff7c5d..f15caf54771b 100644 --- a/drivers/media/common/saa7146/saa7146_core.c +++ b/drivers/media/common/saa7146/saa7146_core.c @@ -37,7 +37,8 @@ void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data) { u32 value = 0; - BUG_ON(port > 3); + if (WARN_ON(port > 3)) + return; value = saa7146_read(dev, GPIO_CTRL); value &= ~(0xff << (8*port)); @@ -148,7 +149,8 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages) pg = vmalloc_to_page(virt); if (NULL == pg) goto err; - BUG_ON(PageHighMem(pg)); + if (WARN_ON(PageHighMem(pg))) + return NULL; sg_set_page(&sglist[i], pg, PAGE_SIZE, 0); } return sglist; @@ -239,8 +241,9 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt int nr_pages = 0; int i,p; - BUG_ON(0 == sglen); - BUG_ON(list->offset > PAGE_SIZE); + if (WARN_ON(!sglen) || + WARN_ON(list->offset > PAGE_SIZE)) + return -EIO; /* if we have a user buffer, the first page may not be aligned to a page boundary. */ diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c index 3cb3ee7855ee..4645545c3719 100644 --- a/drivers/media/common/saa7146/saa7146_fops.c +++ b/drivers/media/common/saa7146/saa7146_fops.c @@ -68,7 +68,8 @@ int saa7146_buffer_queue(struct saa7146_dev *dev, assert_spin_locked(&dev->slock); DEB_EE("dev:%p, dmaq:%p, buf:%p\n", dev, q, buf); - BUG_ON(!q); + if (WARN_ON(!q)) + return -EIO; if (NULL == q->curr) { q->curr = buf; @@ -109,7 +110,8 @@ void saa7146_buffer_next(struct saa7146_dev *dev, { struct saa7146_buf *buf,*next = NULL; - BUG_ON(!q); + if (WARN_ON(!q)) + return; DEB_INT("dev:%p, dmaq:%p, vbi:%d\n", dev, q, vbi); diff --git a/drivers/media/common/saa7146/saa7146_hlp.c b/drivers/media/common/saa7146/saa7146_hlp.c index 69101f93a12e..b99c0d6fddd1 100644 --- a/drivers/media/common/saa7146/saa7146_hlp.c +++ b/drivers/media/common/saa7146/saa7146_hlp.c @@ -542,9 +542,10 @@ static int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa71 int height = pix->height; enum v4l2_field field = pix->field; - BUG_ON(0 == buf->pt[0].dma); - BUG_ON(0 == buf->pt[1].dma); - BUG_ON(0 == buf->pt[2].dma); + if (WARN_ON(!buf->pt[0].dma) || + WARN_ON(!buf->pt[1].dma) || + WARN_ON(!buf->pt[2].dma)) + return -1; DEB_CAP("[size=%dx%d,fields=%s]\n", width, height, v4l2_field_names[field]); From patchwork Thu Mar 2 13:03:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D55EC7EE36 for ; Thu, 2 Mar 2023 13:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbjCBNDl (ORCPT ); Thu, 2 Mar 2023 08:03:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjCBNDk (ORCPT ); Thu, 2 Mar 2023 08:03:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A235919F2B for ; Thu, 2 Mar 2023 05:03:39 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5AE4FB811F3 for ; Thu, 2 Mar 2023 13:03:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A53BC4339B; Thu, 2 Mar 2023 13:03:36 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 04/17] staging: media: av7110: replace BUG_ON by WARN_ON Date: Thu, 2 Mar 2023 14:03:17 +0100 Message-Id: <20230302130330.1125172-5-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org No need for BUG_ON, WARN_ON is a lot friendlier. Signed-off-by: Hans Verkuil --- drivers/staging/media/av7110/av7110.c | 6 ++++-- drivers/staging/media/av7110/av7110_hw.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/av7110/av7110.c b/drivers/staging/media/av7110/av7110.c index df81a9b744c2..a5a431c14ea7 100644 --- a/drivers/staging/media/av7110/av7110.c +++ b/drivers/staging/media/av7110/av7110.c @@ -1106,9 +1106,11 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num, struct av7110 *av7110; /* pointer casting paranoia... */ - BUG_ON(!demux); + if (WARN_ON(!demux)) + return -EIO; dvbdemux = demux->priv; - BUG_ON(!dvbdemux); + if (WARN_ON(!dvbdemux)) + return -EIO; av7110 = dvbdemux->priv; dprintk(4, "%p\n", av7110); diff --git a/drivers/staging/media/av7110/av7110_hw.c b/drivers/staging/media/av7110/av7110_hw.c index 93ca31e38ddd..a0be37717259 100644 --- a/drivers/staging/media/av7110/av7110_hw.c +++ b/drivers/staging/media/av7110/av7110_hw.c @@ -1007,7 +1007,8 @@ static int OSDSetBlock(struct av7110 *av7110, int x0, int y0, if (av7110->bmp_state == BMP_LOADING) { /* possible if syscall is repeated by -ERESTARTSYS and if firmware cannot abort */ - BUG_ON (FW_VERSION(av7110->arm_app) >= 0x261e); + if (WARN_ON(FW_VERSION(av7110->arm_app) >= 0x261e)) + return -EIO; rc = WaitUntilBmpLoaded(av7110); if (rc) return rc; From patchwork Thu Mar 2 13:03:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B3BDC6FA8E for ; Thu, 2 Mar 2023 13:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229913AbjCBNDm (ORCPT ); Thu, 2 Mar 2023 08:03:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbjCBNDl (ORCPT ); Thu, 2 Mar 2023 08:03:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A41DB1F5FF for ; Thu, 2 Mar 2023 05:03:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 46FA4B81219 for ; Thu, 2 Mar 2023 13:03:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75481C4339C; Thu, 2 Mar 2023 13:03:37 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 05/17] media: common: saa7146: fix broken V4L2_PIX_FMT_YUV422P support Date: Thu, 2 Mar 2023 14:03:18 +0100 Message-Id: <20230302130330.1125172-6-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The U and V components were swapped. Drop the FORMAT_BYTE_SWAP to fix this. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index dd0d803c38cd..bc4e8d12873b 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -51,7 +51,7 @@ static struct saa7146_format formats[] = { .pixelformat = V4L2_PIX_FMT_YUV422P, .trans = YUV422_DECOMPOSED, .depth = 16, - .flags = FORMAT_BYTE_SWAP|FORMAT_IS_PLANAR, + .flags = FORMAT_IS_PLANAR, }, { .pixelformat = V4L2_PIX_FMT_YVU420, .trans = YUV420_DECOMPOSED, From patchwork Thu Mar 2 13:03:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157305 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEAE9C678D4 for ; Thu, 2 Mar 2023 13:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbjCBNDp (ORCPT ); Thu, 2 Mar 2023 08:03:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbjCBNDn (ORCPT ); Thu, 2 Mar 2023 08:03:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 919B5136DA for ; Thu, 2 Mar 2023 05:03:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3F6E0B81205 for ; Thu, 2 Mar 2023 13:03:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71079C433D2; Thu, 2 Mar 2023 13:03:38 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 06/17] media: common: saa7146: use for_each_sg_dma_page Date: Thu, 2 Mar 2023 14:03:19 +0100 Message-Id: <20230302130330.1125172-7-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When building the pgtables, use for_each_sg_dma_page. Also clean up the code a bit. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_core.c | 29 ++------ drivers/media/common/saa7146/saa7146_video.c | 76 +++++++------------- 2 files changed, 32 insertions(+), 73 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_core.c b/drivers/media/common/saa7146/saa7146_core.c index f15caf54771b..bcb957883044 100644 --- a/drivers/media/common/saa7146/saa7146_core.c +++ b/drivers/media/common/saa7146/saa7146_core.c @@ -235,11 +235,12 @@ int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) } int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, - struct scatterlist *list, int sglen ) + struct scatterlist *list, int sglen) { + struct sg_dma_page_iter dma_iter; __le32 *ptr, fill; int nr_pages = 0; - int i,p; + int i; if (WARN_ON(!sglen) || WARN_ON(list->offset > PAGE_SIZE)) @@ -250,32 +251,16 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt pt->offset = list->offset; ptr = pt->cpu; - for (i = 0; i < sglen; i++, list++) { -/* - pr_debug("i:%d, adr:0x%08x, len:%d, offset:%d\n", - i, sg_dma_address(list), sg_dma_len(list), - list->offset); -*/ - for (p = 0; p * 4096 < sg_dma_len(list); p++, ptr++) { - *ptr = cpu_to_le32(sg_dma_address(list) + p * 4096); - nr_pages++; - } + for_each_sg_dma_page(list, &dma_iter, sglen, 0) { + *ptr++ = cpu_to_le32(sg_page_iter_dma_address(&dma_iter)); + nr_pages++; } /* safety; fill the page table up with the last valid page */ fill = *(ptr-1); - for(i=nr_pages;i<1024;i++) { + for (i = nr_pages; i < 1024; i++) *ptr++ = fill; - } - -/* - ptr = pt->cpu; - pr_debug("offset: %d\n", pt->offset); - for(i=0;i<5;i++) { - pr_debug("ptr1 %d: 0x%08x\n", i, ptr[i]); - } -*/ return 0; } diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index bc4e8d12873b..6af30fece176 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -107,31 +107,32 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu struct saa7146_pgtable *pt1 = &buf->pt[0]; struct saa7146_pgtable *pt2 = &buf->pt[1]; struct saa7146_pgtable *pt3 = &buf->pt[2]; + struct sg_dma_page_iter dma_iter; __le32 *ptr1, *ptr2, *ptr3; __le32 fill; int size = pix->width * pix->height; - int i,p,m1,m2,m3,o1,o2; + int i, m1, m2, m3, o1, o2; switch( sfmt->depth ) { case 12: { /* create some offsets inside the page table */ - m1 = ((size+PAGE_SIZE)/PAGE_SIZE)-1; - m2 = ((size+(size/4)+PAGE_SIZE)/PAGE_SIZE)-1; - m3 = ((size+(size/2)+PAGE_SIZE)/PAGE_SIZE)-1; - o1 = size%PAGE_SIZE; - o2 = (size+(size/4))%PAGE_SIZE; + m1 = ((size + PAGE_SIZE) / PAGE_SIZE) - 1; + m2 = ((size + (size / 4) + PAGE_SIZE) / PAGE_SIZE) - 1; + m3 = ((size + (size / 2) + PAGE_SIZE) / PAGE_SIZE) - 1; + o1 = size % PAGE_SIZE; + o2 = (size + (size / 4)) % PAGE_SIZE; DEB_CAP("size:%d, m1:%d, m2:%d, m3:%d, o1:%d, o2:%d\n", size, m1, m2, m3, o1, o2); break; } case 16: { /* create some offsets inside the page table */ - m1 = ((size+PAGE_SIZE)/PAGE_SIZE)-1; - m2 = ((size+(size/2)+PAGE_SIZE)/PAGE_SIZE)-1; - m3 = ((2*size+PAGE_SIZE)/PAGE_SIZE)-1; - o1 = size%PAGE_SIZE; - o2 = (size+(size/2))%PAGE_SIZE; + m1 = ((size + PAGE_SIZE) / PAGE_SIZE) - 1; + m2 = ((size + (size / 2) + PAGE_SIZE) / PAGE_SIZE) - 1; + m3 = ((2 * size + PAGE_SIZE) / PAGE_SIZE) - 1; + o1 = size % PAGE_SIZE; + o2 = (size + (size / 2)) % PAGE_SIZE; DEB_CAP("size:%d, m1:%d, m2:%d, m3:%d, o1:%d, o2:%d\n", size, m1, m2, m3, o1, o2); break; @@ -145,64 +146,37 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu ptr2 = pt2->cpu; ptr3 = pt3->cpu; - /* walk all pages, copy all page addresses to ptr1 */ - for (i = 0; i < length; i++, list++) { - for (p = 0; p * 4096 < sg_dma_len(list); p++, ptr1++) - *ptr1 = cpu_to_le32(sg_dma_address(list) - list->offset); - } -/* - ptr1 = pt1->cpu; - for(j=0;j<40;j++) { - printk("ptr1 %d: 0x%08x\n",j,ptr1[j]); - } -*/ + for_each_sg_dma_page(list, &dma_iter, length, 0) + *ptr1++ = cpu_to_le32(sg_page_iter_dma_address(&dma_iter) - list->offset); /* if we have a user buffer, the first page may not be aligned to a page boundary. */ pt1->offset = dma->sglist->offset; - pt2->offset = pt1->offset+o1; - pt3->offset = pt1->offset+o2; + pt2->offset = pt1->offset + o1; + pt3->offset = pt1->offset + o2; /* create video-dma2 page table */ ptr1 = pt1->cpu; - for(i = m1; i <= m2 ; i++, ptr2++) { + for (i = m1; i <= m2; i++, ptr2++) *ptr2 = ptr1[i]; - } - fill = *(ptr2-1); - for(;i<1024;i++,ptr2++) { + fill = *(ptr2 - 1); + for (; i < 1024; i++, ptr2++) *ptr2 = fill; - } /* create video-dma3 page table */ ptr1 = pt1->cpu; - for(i = m2; i <= m3; i++,ptr3++) { + for (i = m2; i <= m3; i++, ptr3++) *ptr3 = ptr1[i]; - } - fill = *(ptr3-1); - for(;i<1024;i++,ptr3++) { + fill = *(ptr3 - 1); + for (; i < 1024; i++, ptr3++) *ptr3 = fill; - } /* finally: finish up video-dma1 page table */ - ptr1 = pt1->cpu+m1; + ptr1 = pt1->cpu + m1; fill = pt1->cpu[m1]; - for(i=m1;i<1024;i++,ptr1++) { + for (i = m1; i < 1024; i++, ptr1++) *ptr1 = fill; - } -/* - ptr1 = pt1->cpu; - ptr2 = pt2->cpu; - ptr3 = pt3->cpu; - for(j=0;j<40;j++) { - printk("ptr1 %d: 0x%08x\n",j,ptr1[j]); - } - for(j=0;j<40;j++) { - printk("ptr2 %d: 0x%08x\n",j,ptr2[j]); - } - for(j=0;j<40;j++) { - printk("ptr3 %d: 0x%08x\n",j,ptr3[j]); - } -*/ } else { struct saa7146_pgtable *pt = &buf->pt[0]; + return saa7146_pgtable_build_single(pci, pt, list, length); } From patchwork Thu Mar 2 13:03:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157308 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A159C7EE30 for ; Thu, 2 Mar 2023 13:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbjCBNDr (ORCPT ); Thu, 2 Mar 2023 08:03:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjCBNDq (ORCPT ); Thu, 2 Mar 2023 08:03:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91A6518B31 for ; Thu, 2 Mar 2023 05:03:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E4550615C6 for ; Thu, 2 Mar 2023 13:03:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D5C2C4339E; Thu, 2 Mar 2023 13:03:39 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 07/17] media: saa7146: convert to vb2 Date: Thu, 2 Mar 2023 14:03:20 +0100 Message-Id: <20230302130330.1125172-8-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Convert this driver from the old videobuf framework to the vb2 frame. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/Kconfig | 2 +- drivers/media/common/saa7146/saa7146_fops.c | 323 ++----------- drivers/media/common/saa7146/saa7146_vbi.c | 277 +++++------ drivers/media/common/saa7146/saa7146_video.c | 484 +++++-------------- drivers/media/pci/saa7146/mxb.c | 10 - include/media/drv-intf/saa7146_vv.h | 30 +- 6 files changed, 308 insertions(+), 818 deletions(-) diff --git a/drivers/media/common/saa7146/Kconfig b/drivers/media/common/saa7146/Kconfig index a0aa155e5d85..dfec86e50dff 100644 --- a/drivers/media/common/saa7146/Kconfig +++ b/drivers/media/common/saa7146/Kconfig @@ -6,5 +6,5 @@ config VIDEO_SAA7146 config VIDEO_SAA7146_VV tristate depends on VIDEO_DEV - select VIDEOBUF_DMA_SG + select VIDEOBUF2_DMA_SG select VIDEO_SAA7146 diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c index 4645545c3719..a3b4fe303d03 100644 --- a/drivers/media/common/saa7146/saa7146_fops.c +++ b/drivers/media/common/saa7146/saa7146_fops.c @@ -42,22 +42,6 @@ void saa7146_res_free(struct saa7146_dev *dev, unsigned int bits) } -/********************************************************************************/ -/* common dma functions */ - -void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q, - struct saa7146_buf *buf) -{ - struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); - DEB_EE("dev:%p, buf:%p\n", dev, buf); - - videobuf_waiton(q, &buf->vb, 0, 0); - videobuf_dma_unmap(q->dev, dma); - videobuf_dma_free(dma); - buf->vb.state = VIDEOBUF_NEEDS_INIT; -} - - /********************************************************************************/ /* common buffer functions */ @@ -76,8 +60,7 @@ int saa7146_buffer_queue(struct saa7146_dev *dev, DEB_D("immediately activating buffer %p\n", buf); buf->activate(dev,buf,NULL); } else { - list_add_tail(&buf->vb.queue,&q->queue); - buf->vb.state = VIDEOBUF_QUEUED; + list_add_tail(&buf->list, &q->queue); DEB_D("adding buffer %p to queue. (active buffer present)\n", buf); } @@ -88,21 +71,31 @@ void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, int state) { + struct saa7146_vv *vv = dev->vv_data; + struct saa7146_buf *buf = q->curr; + assert_spin_locked(&dev->slock); DEB_EE("dev:%p, dmaq:%p, state:%d\n", dev, q, state); DEB_EE("q->curr:%p\n", q->curr); /* finish current buffer */ - if (NULL == q->curr) { + if (!buf) { DEB_D("aiii. no current buffer\n"); return; } - q->curr->vb.state = state; - q->curr->vb.ts = ktime_get_ns(); - wake_up(&q->curr->vb.done); - q->curr = NULL; + buf->vb.vb2_buf.timestamp = ktime_get_ns(); + if (vv->video_fmt.field == V4L2_FIELD_ALTERNATE) + buf->vb.field = vv->last_field; + else if (vv->video_fmt.field == V4L2_FIELD_ANY) + buf->vb.field = (vv->video_fmt.height > vv->standard->v_max_out / 2) + ? V4L2_FIELD_INTERLACED + : V4L2_FIELD_BOTTOM; + else + buf->vb.field = vv->video_fmt.field; + buf->vb.sequence = vv->seqnr++; + vb2_buffer_done(&buf->vb.vb2_buf, state); } void saa7146_buffer_next(struct saa7146_dev *dev, @@ -118,10 +111,10 @@ void saa7146_buffer_next(struct saa7146_dev *dev, assert_spin_locked(&dev->slock); if (!list_empty(&q->queue)) { /* activate next one from queue */ - buf = list_entry(q->queue.next,struct saa7146_buf,vb.queue); - list_del(&buf->vb.queue); + buf = list_entry(q->queue.next, struct saa7146_buf, list); + list_del(&buf->list); if (!list_empty(&q->queue)) - next = list_entry(q->queue.next,struct saa7146_buf, vb.queue); + next = list_entry(q->queue.next,struct saa7146_buf, list); q->curr = buf; DEB_INT("next buffer: buf:%p, prev:%p, next:%p\n", buf, q->queue.prev, q->queue.next); @@ -169,7 +162,7 @@ void saa7146_buffer_timeout(struct timer_list *t) spin_lock_irqsave(&dev->slock,flags); if (q->curr) { DEB_D("timeout on %p\n", q->curr); - saa7146_buffer_finish(dev,q,VIDEOBUF_ERROR); + saa7146_buffer_finish(dev, q, VB2_BUF_STATE_ERROR); } /* we don't restart the transfer here like other drivers do. when @@ -178,257 +171,23 @@ void saa7146_buffer_timeout(struct timer_list *t) we mess up our capture logic. if a timeout occurs on another buffer, then something is seriously broken before, so no need to buffer the next capture IMHO... */ -/* - saa7146_buffer_next(dev,q); -*/ + + saa7146_buffer_next(dev, q, 0); + spin_unlock_irqrestore(&dev->slock,flags); } /********************************************************************************/ /* file operations */ -static int fops_open(struct file *file) -{ - struct video_device *vdev = video_devdata(file); - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = NULL; - int result = 0; - - DEB_EE("file:%p, dev:%s\n", file, video_device_node_name(vdev)); - - if (mutex_lock_interruptible(vdev->lock)) - return -ERESTARTSYS; - - DEB_D("using: %p\n", dev); - - /* check if an extension is registered */ - if( NULL == dev->ext ) { - DEB_S("no extension registered for this device\n"); - result = -ENODEV; - goto out; - } - - /* allocate per open data */ - fh = kzalloc(sizeof(*fh),GFP_KERNEL); - if (NULL == fh) { - DEB_S("cannot allocate memory for per open data\n"); - result = -ENOMEM; - goto out; - } - - v4l2_fh_init(&fh->fh, vdev); - - file->private_data = &fh->fh; - - if (vdev->vfl_type == VFL_TYPE_VBI) { - DEB_S("initializing vbi...\n"); - if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) - result = saa7146_vbi_uops.open(dev,file); - if (dev->ext_vv_data->vbi_fops.open) - dev->ext_vv_data->vbi_fops.open(file); - } else { - DEB_S("initializing video...\n"); - result = saa7146_video_uops.open(dev,file); - } - - if (0 != result) { - goto out; - } - - if( 0 == try_module_get(dev->ext->module)) { - result = -EINVAL; - goto out; - } - - result = 0; - v4l2_fh_add(&fh->fh); -out: - if (fh && result != 0) { - kfree(fh); - file->private_data = NULL; - } - mutex_unlock(vdev->lock); - return result; -} - -static int fops_release(struct file *file) -{ - struct video_device *vdev = video_devdata(file); - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = file->private_data; - - DEB_EE("file:%p\n", file); - - mutex_lock(vdev->lock); - - if (vdev->vfl_type == VFL_TYPE_VBI) { - if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) - saa7146_vbi_uops.release(dev,file); - if (dev->ext_vv_data->vbi_fops.release) - dev->ext_vv_data->vbi_fops.release(file); - } else { - saa7146_video_uops.release(dev,file); - } - - v4l2_fh_del(&fh->fh); - v4l2_fh_exit(&fh->fh); - module_put(dev->ext->module); - file->private_data = NULL; - kfree(fh); - - mutex_unlock(vdev->lock); - - return 0; -} - -static int fops_mmap(struct file *file, struct vm_area_struct * vma) -{ - struct video_device *vdev = video_devdata(file); - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = file->private_data; - struct videobuf_queue *q; - int res; - - switch (vdev->vfl_type) { - case VFL_TYPE_VIDEO: { - DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, vma:%p\n", - file, vma); - q = &fh->video_q; - break; - } - case VFL_TYPE_VBI: { - DEB_EE("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, vma:%p\n", - file, vma); - if (dev->ext_vv_data->capabilities & V4L2_CAP_SLICED_VBI_OUTPUT) - return -ENODEV; - q = &fh->vbi_q; - break; - } - default: - BUG(); - } - - if (mutex_lock_interruptible(vdev->lock)) - return -ERESTARTSYS; - res = videobuf_mmap_mapper(q, vma); - mutex_unlock(vdev->lock); - return res; -} - -static __poll_t __fops_poll(struct file *file, struct poll_table_struct *wait) -{ - struct video_device *vdev = video_devdata(file); - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = file->private_data; - struct videobuf_buffer *buf = NULL; - struct videobuf_queue *q; - __poll_t res = v4l2_ctrl_poll(file, wait); - - DEB_EE("file:%p, poll:%p\n", file, wait); - - if (vdev->vfl_type == VFL_TYPE_VBI) { - if (dev->ext_vv_data->capabilities & V4L2_CAP_SLICED_VBI_OUTPUT) - return res | EPOLLOUT | EPOLLWRNORM; - if( 0 == fh->vbi_q.streaming ) - return res | videobuf_poll_stream(file, &fh->vbi_q, wait); - q = &fh->vbi_q; - } else { - DEB_D("using video queue\n"); - q = &fh->video_q; - } - - if (!list_empty(&q->stream)) - buf = list_entry(q->stream.next, struct videobuf_buffer, stream); - - if (!buf) { - DEB_D("buf == NULL!\n"); - return res | EPOLLERR; - } - - poll_wait(file, &buf->done, wait); - if (buf->state == VIDEOBUF_DONE || buf->state == VIDEOBUF_ERROR) { - DEB_D("poll succeeded!\n"); - return res | EPOLLIN | EPOLLRDNORM; - } - - DEB_D("nothing to poll for, buf->state:%d\n", buf->state); - return res; -} - -static __poll_t fops_poll(struct file *file, struct poll_table_struct *wait) -{ - struct video_device *vdev = video_devdata(file); - __poll_t res; - - mutex_lock(vdev->lock); - res = __fops_poll(file, wait); - mutex_unlock(vdev->lock); - return res; -} - -static ssize_t fops_read(struct file *file, char __user *data, size_t count, loff_t *ppos) -{ - struct video_device *vdev = video_devdata(file); - struct saa7146_dev *dev = video_drvdata(file); - int ret; - - switch (vdev->vfl_type) { - case VFL_TYPE_VIDEO: -/* - DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, data:%p, count:%lun", - file, data, (unsigned long)count); -*/ - return saa7146_video_uops.read(file,data,count,ppos); - case VFL_TYPE_VBI: -/* - DEB_EE("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", - file, data, (unsigned long)count); -*/ - if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) { - if (mutex_lock_interruptible(vdev->lock)) - return -ERESTARTSYS; - ret = saa7146_vbi_uops.read(file, data, count, ppos); - mutex_unlock(vdev->lock); - return ret; - } - return -EINVAL; - default: - BUG(); - } -} - -static ssize_t fops_write(struct file *file, const char __user *data, size_t count, loff_t *ppos) -{ - struct video_device *vdev = video_devdata(file); - struct saa7146_dev *dev = video_drvdata(file); - int ret; - - switch (vdev->vfl_type) { - case VFL_TYPE_VIDEO: - return -EINVAL; - case VFL_TYPE_VBI: - if (dev->ext_vv_data->vbi_fops.write) { - if (mutex_lock_interruptible(vdev->lock)) - return -ERESTARTSYS; - ret = dev->ext_vv_data->vbi_fops.write(file, data, count, ppos); - mutex_unlock(vdev->lock); - return ret; - } - return -EINVAL; - default: - BUG(); - } -} - static const struct v4l2_file_operations video_fops = { .owner = THIS_MODULE, - .open = fops_open, - .release = fops_release, - .read = fops_read, - .write = fops_write, - .poll = fops_poll, - .mmap = fops_mmap, + .open = v4l2_fh_open, + .release = vb2_fop_release, + .read = vb2_fop_read, + .poll = vb2_fop_poll, + .mmap = vb2_fop_mmap, .unlocked_ioctl = video_ioctl2, }; @@ -568,16 +327,20 @@ EXPORT_SYMBOL_GPL(saa7146_vv_release); int saa7146_register_device(struct video_device *vfd, struct saa7146_dev *dev, char *name, int type) { + struct vb2_queue *q; int err; int i; DEB_EE("dev:%p, name:'%s', type:%d\n", dev, name, type); vfd->fops = &video_fops; - if (type == VFL_TYPE_VIDEO) + if (type == VFL_TYPE_VIDEO) { vfd->ioctl_ops = &dev->ext_vv_data->vid_ops; - else + q = &dev->vv_data->video_dmaq.q; + } else { vfd->ioctl_ops = &dev->ext_vv_data->vbi_ops; + q = &dev->vv_data->vbi_dmaq.q; + } vfd->release = video_device_release_empty; vfd->lock = &dev->v4l2_lock; vfd->v4l2_dev = &dev->v4l2_dev; @@ -592,8 +355,22 @@ int saa7146_register_device(struct video_device *vfd, struct saa7146_dev *dev, vfd->device_caps &= ~(V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_OUTPUT); else - vfd->device_caps &= - ~(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO); + vfd->device_caps &= ~(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO); + q->type = type == VFL_TYPE_VIDEO ? V4L2_BUF_TYPE_VIDEO_CAPTURE : V4L2_BUF_TYPE_VBI_CAPTURE; + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ | VB2_DMABUF; + q->ops = type == VFL_TYPE_VIDEO ? &video_qops : &vbi_qops; + q->mem_ops = &vb2_dma_sg_memops; + q->drv_priv = dev; + q->gfp_flags = __GFP_DMA32; + q->buf_struct_size = sizeof(struct saa7146_buf); + q->lock = &dev->v4l2_lock; + q->min_buffers_needed = 2; + q->dev = &dev->pci->dev; + err = vb2_queue_init(q); + if (err) + return err; + vfd->queue = q; video_set_drvdata(vfd, dev); err = video_register_device(vfd, type, -1); diff --git a/drivers/media/common/saa7146/saa7146_vbi.c b/drivers/media/common/saa7146/saa7146_vbi.c index 1a6fb0f381b7..c1d8d8008b6f 100644 --- a/drivers/media/common/saa7146/saa7146_vbi.c +++ b/drivers/media/common/saa7146/saa7146_vbi.c @@ -207,7 +207,6 @@ static int buffer_activate(struct saa7146_dev *dev, struct saa7146_buf *next) { struct saa7146_vv *vv = dev->vv_data; - buf->vb.state = VIDEOBUF_ACTIVE; DEB_VBI("dev:%p, buf:%p, next:%p\n", dev, buf, next); saa7146_set_vbi_capture(dev,buf,next); @@ -216,111 +215,101 @@ static int buffer_activate(struct saa7146_dev *dev, return 0; } -static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,enum v4l2_field field) -{ - struct file *file = q->priv_data; - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_buf *buf = (struct saa7146_buf *)vb; +/* ------------------------------------------------------------------ */ - int err = 0; - int lines, llength, size; +static int queue_setup(struct vb2_queue *q, + unsigned int *num_buffers, unsigned int *num_planes, + unsigned int sizes[], struct device *alloc_devs[]) +{ + unsigned int size = 16 * 2 * vbi_pixel_to_capture; - lines = 16 * 2 ; /* 2 fields */ - llength = vbi_pixel_to_capture; - size = lines * llength; + if (*num_planes) + return sizes[0] < size ? -EINVAL : 0; + *num_planes = 1; + sizes[0] = size; - DEB_VBI("vb:%p\n", vb); + return 0; +} - if (0 != buf->vb.baddr && buf->vb.bsize < size) { - DEB_VBI("size mismatch\n"); - return -EINVAL; - } +static void buf_queue(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct vb2_queue *vq = vb->vb2_queue; + struct saa7146_dev *dev = vb2_get_drv_priv(vq); + struct saa7146_buf *buf = container_of(vbuf, struct saa7146_buf, vb); + unsigned long flags; - if (buf->vb.size != size) - saa7146_dma_free(dev,q,buf); + spin_lock_irqsave(&dev->slock, flags); - if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { - struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); + saa7146_buffer_queue(dev, &dev->vv_data->vbi_dmaq, buf); + spin_unlock_irqrestore(&dev->slock, flags); +} - buf->vb.width = llength; - buf->vb.height = lines; - buf->vb.size = size; - buf->vb.field = field; // FIXME: check this +static int buf_init(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct saa7146_buf *buf = container_of(vbuf, struct saa7146_buf, vb); + struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb.vb2_buf, 0); + struct scatterlist *list = sgt->sgl; + int length = sgt->nents; + struct vb2_queue *vq = vb->vb2_queue; + struct saa7146_dev *dev = vb2_get_drv_priv(vq); + int ret; - saa7146_pgtable_free(dev->pci, &buf->pt[2]); - saa7146_pgtable_alloc(dev->pci, &buf->pt[2]); - - err = videobuf_iolock(q,&buf->vb, NULL); - if (err) - goto oops; - err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], - dma->sglist, dma->sglen); - if (0 != err) - return err; - } - buf->vb.state = VIDEOBUF_PREPARED; buf->activate = buffer_activate; - return 0; - - oops: - DEB_VBI("error out\n"); - saa7146_dma_free(dev,q,buf); + saa7146_pgtable_alloc(dev->pci, &buf->pt[2]); - return err; + ret = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], + list, length); + if (ret) + saa7146_pgtable_free(dev->pci, &buf->pt[2]); + return ret; } -static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) +static int buf_prepare(struct vb2_buffer *vb) { - int llength,lines; - - lines = 16 * 2 ; /* 2 fields */ - llength = vbi_pixel_to_capture; - - *size = lines * llength; - *count = 2; - - DEB_VBI("count:%d, size:%d\n", *count, *size); + unsigned int size = 16 * 2 * vbi_pixel_to_capture; + if (vb2_plane_size(vb, 0) < size) + return -EINVAL; + vb2_set_plane_payload(vb, 0, size); return 0; } -static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) +static void buf_cleanup(struct vb2_buffer *vb) { - struct file *file = q->priv_data; - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_vv *vv = dev->vv_data; - struct saa7146_buf *buf = (struct saa7146_buf *)vb; + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct saa7146_buf *buf = container_of(vbuf, struct saa7146_buf, vb); + struct vb2_queue *vq = vb->vb2_queue; + struct saa7146_dev *dev = vb2_get_drv_priv(vq); - DEB_VBI("vb:%p\n", vb); - saa7146_buffer_queue(dev, &vv->vbi_dmaq, buf); + saa7146_pgtable_free(dev->pci, &buf->pt[2]); } -static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) +static void return_buffers(struct vb2_queue *q, int state) { - struct file *file = q->priv_data; - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_buf *buf = (struct saa7146_buf *)vb; - - DEB_VBI("vb:%p\n", vb); - saa7146_dma_free(dev,q,buf); + struct saa7146_dev *dev = vb2_get_drv_priv(q); + struct saa7146_dmaqueue *dq = &dev->vv_data->vbi_dmaq; + struct saa7146_buf *buf; + + if (dq->curr) { + buf = dq->curr; + dq->curr = NULL; + vb2_buffer_done(&buf->vb.vb2_buf, state); + } + while (!list_empty(&dq->queue)) { + buf = list_entry(dq->queue.next, struct saa7146_buf, list); + list_del(&buf->list); + vb2_buffer_done(&buf->vb.vb2_buf, state); + } } -static const struct videobuf_queue_ops vbi_qops = { - .buf_setup = buffer_setup, - .buf_prepare = buffer_prepare, - .buf_queue = buffer_queue, - .buf_release = buffer_release, -}; - -/* ------------------------------------------------------------------ */ - -static void vbi_stop(struct saa7146_fh *fh, struct file *file) +static void vbi_stop(struct saa7146_dev *dev) { - struct saa7146_dev *dev = video_drvdata(file); struct saa7146_vv *vv = dev->vv_data; unsigned long flags; - DEB_VBI("dev:%p, fh:%p\n", dev, fh); + DEB_VBI("dev:%p\n", dev); spin_lock_irqsave(&dev->slock,flags); @@ -334,11 +323,7 @@ static void vbi_stop(struct saa7146_fh *fh, struct file *file) saa7146_write(dev, MC1, MASK_20); if (vv->vbi_dmaq.curr) - saa7146_buffer_finish(dev, &vv->vbi_dmaq, VIDEOBUF_DONE); - - videobuf_queue_cancel(&fh->vbi_q); - - vv->vbi_streaming = NULL; + saa7146_buffer_finish(dev, &vv->vbi_dmaq, VB2_BUF_STATE_DONE); del_timer(&vv->vbi_dmaq.timeout); del_timer(&vv->vbi_read_timeout); @@ -349,36 +334,20 @@ static void vbi_stop(struct saa7146_fh *fh, struct file *file) static void vbi_read_timeout(struct timer_list *t) { struct saa7146_vv *vv = from_timer(vv, t, vbi_read_timeout); - struct file *file = vv->vbi_read_timeout_file; - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = file->private_data; - - DEB_VBI("dev:%p, fh:%p\n", dev, fh); + struct saa7146_dev *dev = vv->vbi_dmaq.dev; - vbi_stop(fh, file); -} - -static void vbi_init(struct saa7146_dev *dev, struct saa7146_vv *vv) -{ DEB_VBI("dev:%p\n", dev); - INIT_LIST_HEAD(&vv->vbi_dmaq.queue); - - timer_setup(&vv->vbi_dmaq.timeout, saa7146_buffer_timeout, 0); - vv->vbi_dmaq.dev = dev; - - init_waitqueue_head(&vv->vbi_wq); + vbi_stop(dev); } -static int vbi_open(struct saa7146_dev *dev, struct file *file) +static int vbi_begin(struct saa7146_dev *dev) { - struct saa7146_fh *fh = file->private_data; struct saa7146_vv *vv = dev->vv_data; - u32 arbtr_ctrl = saa7146_read(dev, PCI_BT_V1); int ret = 0; - DEB_VBI("dev:%p, fh:%p\n", dev, fh); + DEB_VBI("dev:%p\n", dev); ret = saa7146_res_get(dev, RESOURCE_DMA3_BRS); if (0 == ret) { @@ -392,15 +361,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file) saa7146_write(dev, PCI_BT_V1, arbtr_ctrl); saa7146_write(dev, MC2, (MASK_04|MASK_20)); - videobuf_queue_sg_init(&fh->vbi_q, &vbi_qops, - &dev->pci->dev, &dev->slock, - V4L2_BUF_TYPE_VBI_CAPTURE, - V4L2_FIELD_SEQ_TB, // FIXME: does this really work? - sizeof(struct saa7146_buf), - file, &dev->v4l2_lock); - vv->vbi_read_timeout.function = vbi_read_timeout; - vv->vbi_read_timeout_file = file; /* initialize the brs */ if ( 0 != (SAA7146_USE_PORT_B_FOR_VBI & dev->ext_vv_data->flags)) { @@ -419,18 +380,54 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file) return 0; } -static void vbi_close(struct saa7146_dev *dev, struct file *file) +static int start_streaming(struct vb2_queue *q, unsigned int count) { - struct saa7146_fh *fh = file->private_data; - struct saa7146_vv *vv = dev->vv_data; - DEB_VBI("dev:%p, fh:%p\n", dev, fh); + struct saa7146_dev *dev = vb2_get_drv_priv(q); + int ret; + + if (!vb2_is_streaming(&dev->vv_data->vbi_dmaq.q)) + dev->vv_data->seqnr = 0; + ret = vbi_begin(dev); + if (ret) + return_buffers(q, VB2_BUF_STATE_QUEUED); + return ret; +} - if( fh == vv->vbi_streaming ) { - vbi_stop(fh, file); - } +static void stop_streaming(struct vb2_queue *q) +{ + struct saa7146_dev *dev = vb2_get_drv_priv(q); + + vbi_stop(dev); + return_buffers(q, VB2_BUF_STATE_ERROR); saa7146_res_free(dev, RESOURCE_DMA3_BRS); } +const struct vb2_ops vbi_qops = { + .queue_setup = queue_setup, + .buf_queue = buf_queue, + .buf_init = buf_init, + .buf_prepare = buf_prepare, + .buf_cleanup = buf_cleanup, + .start_streaming = start_streaming, + .stop_streaming = stop_streaming, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, +}; + +/* ------------------------------------------------------------------ */ + +static void vbi_init(struct saa7146_dev *dev, struct saa7146_vv *vv) +{ + DEB_VBI("dev:%p\n", dev); + + INIT_LIST_HEAD(&vv->vbi_dmaq.queue); + + timer_setup(&vv->vbi_dmaq.timeout, saa7146_buffer_timeout, 0); + vv->vbi_dmaq.dev = dev; + + init_waitqueue_head(&vv->vbi_wq); +} + static void vbi_irq_done(struct saa7146_dev *dev, unsigned long status) { struct saa7146_vv *vv = dev->vv_data; @@ -438,10 +435,7 @@ static void vbi_irq_done(struct saa7146_dev *dev, unsigned long status) if (vv->vbi_dmaq.curr) { DEB_VBI("dev:%p, curr:%p\n", dev, vv->vbi_dmaq.curr); - /* this must be += 2, one count for each field */ - vv->vbi_fieldcount+=2; - vv->vbi_dmaq.curr->vb.field_count = vv->vbi_fieldcount; - saa7146_buffer_finish(dev, &vv->vbi_dmaq, VIDEOBUF_DONE); + saa7146_buffer_finish(dev, &vv->vbi_dmaq, VB2_BUF_STATE_DONE); } else { DEB_VBI("dev:%p\n", dev); } @@ -450,46 +444,7 @@ static void vbi_irq_done(struct saa7146_dev *dev, unsigned long status) spin_unlock(&dev->slock); } -static ssize_t vbi_read(struct file *file, char __user *data, size_t count, loff_t *ppos) -{ - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_vv *vv = dev->vv_data; - ssize_t ret = 0; - - DEB_VBI("dev:%p, fh:%p\n", dev, fh); - - if( NULL == vv->vbi_streaming ) { - // fixme: check if dma3 is available - // fixme: activate vbi engine here if necessary. (really?) - vv->vbi_streaming = fh; - } - - if( fh != vv->vbi_streaming ) { - DEB_VBI("open %p is already using vbi capture\n", - vv->vbi_streaming); - return -EBUSY; - } - - mod_timer(&vv->vbi_read_timeout, jiffies+BUFFER_TIMEOUT); - ret = videobuf_read_stream(&fh->vbi_q, data, count, ppos, 1, - file->f_flags & O_NONBLOCK); -/* - printk("BASE_ODD3: 0x%08x\n", saa7146_read(dev, BASE_ODD3)); - printk("BASE_EVEN3: 0x%08x\n", saa7146_read(dev, BASE_EVEN3)); - printk("PROT_ADDR3: 0x%08x\n", saa7146_read(dev, PROT_ADDR3)); - printk("PITCH3: 0x%08x\n", saa7146_read(dev, PITCH3)); - printk("BASE_PAGE3: 0x%08x\n", saa7146_read(dev, BASE_PAGE3)); - printk("NUM_LINE_BYTE3: 0x%08x\n", saa7146_read(dev, NUM_LINE_BYTE3)); - printk("BRS_CTRL: 0x%08x\n", saa7146_read(dev, BRS_CTRL)); -*/ - return ret; -} - const struct saa7146_use_ops saa7146_vbi_uops = { .init = vbi_init, - .open = vbi_open, - .release = vbi_close, .irq_done = vbi_irq_done, - .read = vbi_read, }; diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 6af30fece176..290f388c2f28 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -11,9 +11,6 @@ static int max_memory = 32; module_param(max_memory, int, 0644); MODULE_PARM_DESC(max_memory, "maximum memory usage for capture buffers (default: 32Mb)"); -#define IS_CAPTURE_ACTIVE(fh) \ - (((vv->video_status & STATUS_CAPTURE) != 0) && (vv->video_fh == fh)) - /* format descriptions for capture and preview */ static struct saa7146_format formats[] = { { @@ -95,9 +92,9 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu { struct saa7146_vv *vv = dev->vv_data; struct pci_dev *pci = dev->pci; - struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); - struct scatterlist *list = dma->sglist; - int length = dma->sglen; + struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb.vb2_buf, 0); + struct scatterlist *list = sgt->sgl; + int length = sgt->nents; struct v4l2_pix_format *pix = &vv->video_fmt; struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev, pix->pixelformat); @@ -151,7 +148,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu /* if we have a user buffer, the first page may not be aligned to a page boundary. */ - pt1->offset = dma->sglist->offset; + pt1->offset = sgt->sgl->offset; pt2->offset = pt1->offset + o1; pt3->offset = pt1->offset + o2; @@ -187,23 +184,14 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu /********************************************************************************/ /* file operations */ -static int video_begin(struct saa7146_dev *dev, struct saa7146_fh *fh) +static int video_begin(struct saa7146_dev *dev) { struct saa7146_vv *vv = dev->vv_data; struct saa7146_format *fmt = NULL; unsigned int resource; int ret = 0; - DEB_EE("dev:%p, fh:%p\n", dev, fh); - - if ((vv->video_status & STATUS_CAPTURE) != 0) { - if (vv->video_fh == fh) { - DEB_S("already capturing\n"); - return 0; - } - DEB_S("already capturing in another open\n"); - return -EBUSY; - } + DEB_EE("dev:%p\n", dev); fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); /* we need to have a valid format set here */ @@ -228,36 +216,22 @@ static int video_begin(struct saa7146_dev *dev, struct saa7146_fh *fh) /* enable rps0 irqs */ SAA7146_IER_ENABLE(dev, MASK_27); - vv->video_fh = fh; - vv->video_status = STATUS_CAPTURE; - return 0; } -static int video_end(struct saa7146_dev *dev, struct saa7146_fh *fh) +static void video_end(struct saa7146_dev *dev) { struct saa7146_vv *vv = dev->vv_data; - struct saa7146_dmaqueue *q = &vv->video_dmaq; struct saa7146_format *fmt = NULL; unsigned long flags; unsigned int resource; u32 dmas = 0; - DEB_EE("dev:%p, fh:%p\n", dev, fh); - - if ((vv->video_status & STATUS_CAPTURE) != STATUS_CAPTURE) { - DEB_S("not capturing\n"); - return 0; - } - - if (vv->video_fh != fh) { - DEB_S("capturing, but in another open\n"); - return -EBUSY; - } + DEB_EE("dev:%p\n", dev); fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); /* we need to have a valid format set here */ if (!fmt) - return -EINVAL; + return; if (0 != (fmt->flags & FORMAT_IS_PLANAR)) { resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS; @@ -277,17 +251,9 @@ static int video_end(struct saa7146_dev *dev, struct saa7146_fh *fh) /* shut down all used video dma transfers */ saa7146_write(dev, MC1, dmas); - if (q->curr) - saa7146_buffer_finish(dev, q, VIDEOBUF_DONE); - spin_unlock_irqrestore(&dev->slock, flags); - vv->video_fh = NULL; - vv->video_status = 0; - saa7146_res_free(dev, resource); - - return 0; } static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *cap) @@ -345,13 +311,13 @@ int saa7146_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_HFLIP: /* fixme: we can support changing VFLIP and HFLIP here... */ - if ((vv->video_status & STATUS_CAPTURE)) + if (vb2_is_busy(&vv->video_dmaq.q)) return -EBUSY; vv->hflip = ctrl->val; break; case V4L2_CID_VFLIP: - if ((vv->video_status & STATUS_CAPTURE)) + if (vb2_is_busy(&vv->video_dmaq.q)) return -EBUSY; vv->vflip = ctrl->val; break; @@ -459,15 +425,14 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma return 0; } -static int vidioc_s_fmt_vid_cap(struct file *file, void *__fh, struct v4l2_format *f) +static int vidioc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = __fh; struct saa7146_vv *vv = dev->vv_data; int err; - DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh); - if (IS_CAPTURE_ACTIVE(fh) != 0) { + DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p\n", dev); + if (vb2_is_busy(&vv->video_dmaq.q)) { DEB_EE("streaming capture is active\n"); return -EBUSY; } @@ -489,24 +454,6 @@ static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm) return 0; } - /* the saa7146 supfhrts (used in conjunction with the saa7111a for example) - PAL / NTSC / SECAM. if your hardware does not (or does more) - -- override this function in your extension */ -/* - case VIDIOC_ENUMSTD: - { - struct v4l2_standard *e = arg; - if (e->index < 0 ) - return -EINVAL; - if( e->index < dev->ext_vv_data->num_stds ) { - DEB_EE("VIDIOC_ENUMSTD: index:%d\n", e->index); - v4l2_video_std_construct(e, dev->ext_vv_data->stds[e->index].id, dev->ext_vv_data->stds[e->index].name); - return 0; - } - return -EINVAL; - } - */ - static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id id) { struct saa7146_dev *dev = video_drvdata(file); @@ -516,7 +463,7 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id id) DEB_EE("VIDIOC_S_STD\n"); - if ((vv->video_status & STATUS_CAPTURE) == STATUS_CAPTURE) { + if (vb2_is_busy(&vv->video_dmaq.q) || vb2_is_busy(&vv->vbi_dmaq.q)) { DEB_D("cannot change video standard while streaming capture is active\n"); return -EBUSY; } @@ -540,120 +487,22 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id id) return 0; } -static int vidioc_reqbufs(struct file *file, void *__fh, struct v4l2_requestbuffers *b) -{ - struct saa7146_fh *fh = __fh; - - if (b->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - return videobuf_reqbufs(&fh->video_q, b); - if (b->type == V4L2_BUF_TYPE_VBI_CAPTURE) - return videobuf_reqbufs(&fh->vbi_q, b); - return -EINVAL; -} - -static int vidioc_querybuf(struct file *file, void *__fh, struct v4l2_buffer *buf) -{ - struct saa7146_fh *fh = __fh; - - if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - return videobuf_querybuf(&fh->video_q, buf); - if (buf->type == V4L2_BUF_TYPE_VBI_CAPTURE) - return videobuf_querybuf(&fh->vbi_q, buf); - return -EINVAL; -} - -static int vidioc_qbuf(struct file *file, void *__fh, struct v4l2_buffer *buf) -{ - struct saa7146_fh *fh = __fh; - - if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - return videobuf_qbuf(&fh->video_q, buf); - if (buf->type == V4L2_BUF_TYPE_VBI_CAPTURE) - return videobuf_qbuf(&fh->vbi_q, buf); - return -EINVAL; -} - -static int vidioc_dqbuf(struct file *file, void *__fh, struct v4l2_buffer *buf) -{ - struct saa7146_fh *fh = __fh; - - if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - return videobuf_dqbuf(&fh->video_q, buf, file->f_flags & O_NONBLOCK); - if (buf->type == V4L2_BUF_TYPE_VBI_CAPTURE) - return videobuf_dqbuf(&fh->vbi_q, buf, file->f_flags & O_NONBLOCK); - return -EINVAL; -} - -static int vidioc_streamon(struct file *file, void *__fh, enum v4l2_buf_type type) -{ - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = __fh; - int err; - - DEB_D("VIDIOC_STREAMON, type:%d\n", type); - - err = video_begin(dev, fh); - if (err) - return err; - if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - return videobuf_streamon(&fh->video_q); - if (type == V4L2_BUF_TYPE_VBI_CAPTURE) - return videobuf_streamon(&fh->vbi_q); - return -EINVAL; -} - -static int vidioc_streamoff(struct file *file, void *__fh, enum v4l2_buf_type type) -{ - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = __fh; - struct saa7146_vv *vv = dev->vv_data; - int err; - - DEB_D("VIDIOC_STREAMOFF, type:%d\n", type); - - /* ugly: we need to copy some checks from video_end(), - because videobuf_streamoff() relies on the capture running. - check and fix this */ - if ((vv->video_status & STATUS_CAPTURE) != STATUS_CAPTURE) { - DEB_S("not capturing\n"); - return 0; - } - - if (vv->video_fh != fh) { - DEB_S("capturing, but in another open\n"); - return -EBUSY; - } - - err = -EINVAL; - if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE) - err = videobuf_streamoff(&fh->video_q); - else if (type == V4L2_BUF_TYPE_VBI_CAPTURE) - err = videobuf_streamoff(&fh->vbi_q); - if (0 != err) { - DEB_D("warning: videobuf_streamoff() failed\n"); - video_end(dev, fh); - } else { - err = video_end(dev, fh); - } - return err; -} - const struct v4l2_ioctl_ops saa7146_video_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, - - .vidioc_reqbufs = vidioc_reqbufs, - .vidioc_querybuf = vidioc_querybuf, - .vidioc_qbuf = vidioc_qbuf, - .vidioc_dqbuf = vidioc_dqbuf, .vidioc_g_std = vidioc_g_std, .vidioc_s_std = vidioc_s_std, - .vidioc_streamon = vidioc_streamon, - .vidioc_streamoff = vidioc_streamoff, .vidioc_g_parm = vidioc_g_parm, + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; @@ -661,16 +510,17 @@ const struct v4l2_ioctl_ops saa7146_video_ioctl_ops = { const struct v4l2_ioctl_ops saa7146_vbi_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, - - .vidioc_reqbufs = vidioc_reqbufs, - .vidioc_querybuf = vidioc_querybuf, - .vidioc_qbuf = vidioc_qbuf, - .vidioc_dqbuf = vidioc_dqbuf, + .vidioc_s_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, .vidioc_g_std = vidioc_g_std, .vidioc_s_std = vidioc_s_std, - .vidioc_streamon = vidioc_streamon, - .vidioc_streamoff = vidioc_streamoff, .vidioc_g_parm = vidioc_g_parm, + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; @@ -684,7 +534,6 @@ static int buffer_activate (struct saa7146_dev *dev, { struct saa7146_vv *vv = dev->vv_data; - buf->vb.state = VIDEOBUF_ACTIVE; saa7146_set_capture(dev,buf,next); mod_timer(&vv->video_dmaq.timeout, jiffies+BUFFER_TIMEOUT); @@ -698,135 +547,136 @@ static void release_all_pagetables(struct saa7146_dev *dev, struct saa7146_buf * saa7146_pgtable_free(dev->pci, &buf->pt[2]); } -static int buffer_prepare(struct videobuf_queue *q, - struct videobuf_buffer *vb, enum v4l2_field field) +static int queue_setup(struct vb2_queue *q, + unsigned int *num_buffers, unsigned int *num_planes, + unsigned int sizes[], struct device *alloc_devs[]) { - struct file *file = q->priv_data; - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_vv *vv = dev->vv_data; - struct saa7146_buf *buf = (struct saa7146_buf *)vb; - int size,err = 0; - - DEB_CAP("vbuf:%p\n", vb); - - /* sanity checks */ - if (vv->video_fmt.width < 48 || - vv->video_fmt.height < 32 || - vv->video_fmt.width > vv->standard->h_max_out || - vv->video_fmt.height > vv->standard->v_max_out) { - DEB_D("w (%d) / h (%d) out of bounds\n", - vv->video_fmt.width, vv->video_fmt.height); - return -EINVAL; - } + struct saa7146_dev *dev = vb2_get_drv_priv(q); + unsigned size = dev->vv_data->video_fmt.sizeimage; - size = vv->video_fmt.sizeimage; - if (0 != buf->vb.baddr && buf->vb.bsize < size) { - DEB_D("size mismatch\n"); - return -EINVAL; - } + if (*num_planes) + return sizes[0] < size ? -EINVAL : 0; + *num_planes = 1; + sizes[0] = size; - DEB_CAP("buffer_prepare [size=%dx%d,bytes=%d,fields=%s]\n", - vv->video_fmt.width, vv->video_fmt.height, - size, v4l2_field_names[vv->video_fmt.field]); - if (buf->vb.width != vv->video_fmt.width || - buf->vb.bytesperline != vv->video_fmt.bytesperline || - buf->vb.height != vv->video_fmt.height || - buf->vb.size != size || - buf->vb.field != field || - buf->vb.field != vv->video_fmt.field) { - saa7146_dma_free(dev,q,buf); - } + return 0; +} - if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { - struct saa7146_format *sfmt; +static void buf_queue(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct vb2_queue *vq = vb->vb2_queue; + struct saa7146_dev *dev = vb2_get_drv_priv(vq); + struct saa7146_buf *buf = container_of(vbuf, struct saa7146_buf, vb); + unsigned long flags; - buf->vb.bytesperline = vv->video_fmt.bytesperline; - buf->vb.width = vv->video_fmt.width; - buf->vb.height = vv->video_fmt.height; - buf->vb.size = size; - buf->vb.field = field; - buf->vb.field = vv->video_fmt.field; + spin_lock_irqsave(&dev->slock, flags); - sfmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); + saa7146_buffer_queue(dev, &dev->vv_data->video_dmaq, buf); + spin_unlock_irqrestore(&dev->slock, flags); +} - release_all_pagetables(dev, buf); - if( 0 != IS_PLANAR(sfmt->trans)) { - saa7146_pgtable_alloc(dev->pci, &buf->pt[0]); - saa7146_pgtable_alloc(dev->pci, &buf->pt[1]); - saa7146_pgtable_alloc(dev->pci, &buf->pt[2]); - } else { - saa7146_pgtable_alloc(dev->pci, &buf->pt[0]); - } +static int buf_init(struct vb2_buffer *vb) +{ + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct saa7146_buf *buf = container_of(vbuf, struct saa7146_buf, vb); + struct vb2_queue *vq = vb->vb2_queue; + struct saa7146_dev *dev = vb2_get_drv_priv(vq); + struct saa7146_vv *vv = dev->vv_data; + struct saa7146_format *sfmt; + int ret; - err = videobuf_iolock(q, &buf->vb, NULL); - if (err) - goto oops; - err = saa7146_pgtable_build(dev,buf); - if (err) - goto oops; - } - buf->vb.state = VIDEOBUF_PREPARED; buf->activate = buffer_activate; + sfmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); - return 0; - - oops: - DEB_D("error out\n"); - saa7146_dma_free(dev,q,buf); + if (IS_PLANAR(sfmt->trans)) { + saa7146_pgtable_alloc(dev->pci, &buf->pt[0]); + saa7146_pgtable_alloc(dev->pci, &buf->pt[1]); + saa7146_pgtable_alloc(dev->pci, &buf->pt[2]); + } else { + saa7146_pgtable_alloc(dev->pci, &buf->pt[0]); + } - return err; + ret = saa7146_pgtable_build(dev,buf); + if (ret) + release_all_pagetables(dev, buf); + return ret; } -static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) +static int buf_prepare(struct vb2_buffer *vb) { - struct file *file = q->priv_data; - struct saa7146_dev *dev = video_drvdata(file); + struct vb2_queue *vq = vb->vb2_queue; + struct saa7146_dev *dev = vb2_get_drv_priv(vq); struct saa7146_vv *vv = dev->vv_data; + unsigned int size = vv->video_fmt.sizeimage; - if (0 == *count || *count > MAX_SAA7146_CAPTURE_BUFFERS) - *count = MAX_SAA7146_CAPTURE_BUFFERS; - - *size = vv->video_fmt.sizeimage; - - /* check if we exceed the "max_memory" parameter */ - if( (*count * *size) > (max_memory*1048576) ) { - *count = (max_memory*1048576) / *size; - } - - DEB_CAP("%d buffers, %d bytes each\n", *count, *size); - + if (vb2_plane_size(vb, 0) < size) + return -EINVAL; + vb2_set_plane_payload(vb, 0, size); return 0; } -static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) +static void buf_cleanup(struct vb2_buffer *vb) { - struct file *file = q->priv_data; - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_vv *vv = dev->vv_data; - struct saa7146_buf *buf = (struct saa7146_buf *)vb; + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct saa7146_buf *buf = container_of(vbuf, struct saa7146_buf, vb); + struct vb2_queue *vq = vb->vb2_queue; + struct saa7146_dev *dev = vb2_get_drv_priv(vq); - DEB_CAP("vbuf:%p\n", vb); - saa7146_buffer_queue(dev, &vv->video_dmaq, buf); + release_all_pagetables(dev, buf); } -static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) +static void return_buffers(struct vb2_queue *q, int state) { - struct file *file = q->priv_data; - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_buf *buf = (struct saa7146_buf *)vb; + struct saa7146_dev *dev = vb2_get_drv_priv(q); + struct saa7146_dmaqueue *dq = &dev->vv_data->video_dmaq; + struct saa7146_buf *buf; + + if (dq->curr) { + buf = dq->curr; + dq->curr = NULL; + vb2_buffer_done(&buf->vb.vb2_buf, state); + } + while (!list_empty(&dq->queue)) { + buf = list_entry(dq->queue.next, struct saa7146_buf, list); + list_del(&buf->list); + vb2_buffer_done(&buf->vb.vb2_buf, state); + } +} - DEB_CAP("vbuf:%p\n", vb); +static int start_streaming(struct vb2_queue *q, unsigned int count) +{ + struct saa7146_dev *dev = vb2_get_drv_priv(q); + int ret; + + if (!vb2_is_streaming(&dev->vv_data->video_dmaq.q)) + dev->vv_data->seqnr = 0; + ret = video_begin(dev); + if (ret) + return_buffers(q, VB2_BUF_STATE_QUEUED); + return ret; +} - saa7146_dma_free(dev,q,buf); +static void stop_streaming(struct vb2_queue *q) +{ + struct saa7146_dev *dev = vb2_get_drv_priv(q); + struct saa7146_dmaqueue *dq = &dev->vv_data->video_dmaq; - release_all_pagetables(dev, buf); + del_timer(&dq->timeout); + video_end(dev); + return_buffers(q, VB2_BUF_STATE_ERROR); } -static const struct videobuf_queue_ops video_qops = { - .buf_setup = buffer_setup, - .buf_prepare = buffer_prepare, - .buf_queue = buffer_queue, - .buf_release = buffer_release, +const struct vb2_ops video_qops = { + .queue_setup = queue_setup, + .buf_queue = buf_queue, + .buf_init = buf_init, + .buf_prepare = buf_prepare, + .buf_cleanup = buf_cleanup, + .start_streaming = start_streaming, + .stop_streaming = stop_streaming, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, }; /********************************************************************************/ @@ -847,36 +697,6 @@ static void video_init(struct saa7146_dev *dev, struct saa7146_vv *vv) vv->current_hps_sync = SAA7146_HPS_SYNC_PORT_A; } - -static int video_open(struct saa7146_dev *dev, struct file *file) -{ - struct saa7146_fh *fh = file->private_data; - - videobuf_queue_sg_init(&fh->video_q, &video_qops, - &dev->pci->dev, &dev->slock, - V4L2_BUF_TYPE_VIDEO_CAPTURE, - V4L2_FIELD_INTERLACED, - sizeof(struct saa7146_buf), - file, &dev->v4l2_lock); - - return 0; -} - - -static void video_close(struct saa7146_dev *dev, struct file *file) -{ - struct saa7146_fh *fh = file->private_data; - struct saa7146_vv *vv = dev->vv_data; - struct videobuf_queue *q = &fh->video_q; - - if (IS_CAPTURE_ACTIVE(fh) != 0) - video_end(dev, fh); - - videobuf_stop(q); - /* hmm, why is this function declared void? */ -} - - static void video_irq_done(struct saa7146_dev *dev, unsigned long st) { struct saa7146_vv *vv = dev->vv_data; @@ -886,53 +706,15 @@ static void video_irq_done(struct saa7146_dev *dev, unsigned long st) DEB_CAP("called\n"); /* only finish the buffer if we have one... */ - if( NULL != q->curr ) { - saa7146_buffer_finish(dev,q,VIDEOBUF_DONE); + if (q->curr) { + saa7146_buffer_finish(dev, q, VB2_BUF_STATE_DONE); } saa7146_buffer_next(dev,q,0); spin_unlock(&dev->slock); } -static ssize_t video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) -{ - struct saa7146_dev *dev = video_drvdata(file); - struct saa7146_fh *fh = file->private_data; - struct saa7146_vv *vv = dev->vv_data; - ssize_t ret = 0; - - DEB_EE("called\n"); - - if ((vv->video_status & STATUS_CAPTURE) != 0) { - /* fixme: should we allow read() captures while streaming capture? */ - if (vv->video_fh == fh) { - DEB_S("already capturing\n"); - return -EBUSY; - } - DEB_S("already capturing in another open\n"); - return -EBUSY; - } - - ret = video_begin(dev, fh); - if( 0 != ret) { - goto out; - } - - ret = videobuf_read_one(&fh->video_q , data, count, ppos, - file->f_flags & O_NONBLOCK); - if (ret != 0) { - video_end(dev, fh); - } else { - ret = video_end(dev, fh); - } -out: - return ret; -} - const struct saa7146_use_ops saa7146_video_uops = { .init = video_init, - .open = video_open, - .release = video_close, .irq_done = video_irq_done, - .read = video_read, }; diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index f518ad8c92ed..557ba89cd12d 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -587,7 +587,6 @@ static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_fre { struct saa7146_dev *dev = video_drvdata(file); struct mxb *mxb = (struct mxb *)dev->ext_priv; - struct saa7146_vv *vv = dev->vv_data; if (f->tuner) return -EINVAL; @@ -604,15 +603,6 @@ static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_fre tuner_call(mxb, tuner, g_frequency, &mxb->cur_freq); if (mxb->cur_audinput == 0) mxb_update_audmode(mxb); - - if (mxb->cur_input) - return 0; - - /* hack: changing the frequency should invalidate the vbi-counter (=> alevt) */ - spin_lock(&dev->slock); - vv->vbi_fieldcount = 0; - spin_unlock(&dev->slock); - return 0; } diff --git a/include/media/drv-intf/saa7146_vv.h b/include/media/drv-intf/saa7146_vv.h index 80463fdd30eb..f31aaf156be3 100644 --- a/include/media/drv-intf/saa7146_vv.h +++ b/include/media/drv-intf/saa7146_vv.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #define MAX_SAA7146_CAPTURE_BUFFERS 32 /* arbitrary */ #define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */ @@ -57,7 +57,8 @@ struct saa7146_standard /* buffer for one video/vbi frame */ struct saa7146_buf { /* common v4l buffer stuff -- must be first */ - struct videobuf_buffer vb; + struct vb2_v4l2_buffer vb; + struct list_head list; /* saa7146 specific */ int (*activate)(struct saa7146_dev *dev, @@ -73,41 +74,29 @@ struct saa7146_dmaqueue { struct saa7146_buf *curr; struct list_head queue; struct timer_list timeout; + struct vb2_queue q; }; /* per open data */ struct saa7146_fh { /* Must be the first field! */ struct v4l2_fh fh; - - /* video capture */ - struct videobuf_queue video_q; - - /* vbi capture */ - struct videobuf_queue vbi_q; }; -#define STATUS_CAPTURE 0x02 - struct saa7146_vv { /* vbi capture */ struct saa7146_dmaqueue vbi_dmaq; struct v4l2_vbi_format vbi_fmt; struct timer_list vbi_read_timeout; - struct file *vbi_read_timeout_file; /* vbi workaround interrupt queue */ wait_queue_head_t vbi_wq; - int vbi_fieldcount; - struct saa7146_fh *vbi_streaming; - - int video_status; - struct saa7146_fh *video_fh; /* video capture */ struct saa7146_dmaqueue video_dmaq; struct v4l2_pix_format video_fmt; enum v4l2_field last_field; + u32 seqnr; /* common: fixme? shouldn't this be in saa7146_fh? (this leads to a more complicated question: shall the driver @@ -122,7 +111,7 @@ struct saa7146_vv int current_hps_source; int current_hps_sync; - unsigned int resources; /* resource management for device */ + unsigned int resources; /* resource management for device */ }; /* flags */ @@ -152,10 +141,7 @@ struct saa7146_ext_vv struct saa7146_use_ops { void (*init)(struct saa7146_dev *, struct saa7146_vv *); - int(*open)(struct saa7146_dev *, struct file *); - void (*release)(struct saa7146_dev *, struct file *); void (*irq_done)(struct saa7146_dev *, unsigned long status); - ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); }; /* from saa7146_fops.c */ @@ -165,8 +151,6 @@ void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi); int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf); void saa7146_buffer_timeout(struct timer_list *t); -void saa7146_dma_free(struct saa7146_dev* dev,struct videobuf_queue *q, - struct saa7146_buf *buf); int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv); int saa7146_vv_release(struct saa7146_dev* dev); @@ -181,11 +165,13 @@ void saa7146_set_gpio(struct saa7146_dev *saa, u8 pin, u8 data); extern const struct v4l2_ioctl_ops saa7146_video_ioctl_ops; extern const struct v4l2_ioctl_ops saa7146_vbi_ioctl_ops; extern const struct saa7146_use_ops saa7146_video_uops; +extern const struct vb2_ops video_qops; long saa7146_video_do_ioctl(struct file *file, unsigned int cmd, void *arg); int saa7146_s_ctrl(struct v4l2_ctrl *ctrl); /* from saa7146_vbi.c */ extern const struct saa7146_use_ops saa7146_vbi_uops; +extern const struct vb2_ops vbi_qops; /* resource management functions */ int saa7146_res_get(struct saa7146_dev *dev, unsigned int bit); From patchwork Thu Mar 2 13:03:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157304 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02EB6C7EE30 for ; Thu, 2 Mar 2023 13:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbjCBNDo (ORCPT ); Thu, 2 Mar 2023 08:03:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbjCBNDn (ORCPT ); Thu, 2 Mar 2023 08:03:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A1AC18175 for ; Thu, 2 Mar 2023 05:03:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F14F6615B3 for ; Thu, 2 Mar 2023 13:03:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90237C433EF; Thu, 2 Mar 2023 13:03:40 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 08/17] media: common: saa7146: fix compliance problems with field handling Date: Thu, 2 Mar 2023 14:03:21 +0100 Message-Id: <20230302130330.1125172-9-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The initial field value of the format is ANY, which isn't allowed. Change to INTERLACED. VIDIOC_TRY_FMT will overwrite vv->last_field, which is an unwanted side-effect, so drop this. And finally vidioc_s_fmt_vid_cap didn't initialize vv->last_field correctly. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_fops.c | 2 +- drivers/media/common/saa7146/saa7146_video.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c index a3b4fe303d03..89cba6b36372 100644 --- a/drivers/media/common/saa7146/saa7146_fops.c +++ b/drivers/media/common/saa7146/saa7146_fops.c @@ -282,7 +282,7 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) fmt->width = 384; fmt->height = 288; fmt->pixelformat = V4L2_PIX_FMT_BGR24; - fmt->field = V4L2_FIELD_ANY; + fmt->field = V4L2_FIELD_INTERLACED; fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; fmt->bytesperline = 3 * fmt->width; fmt->sizeimage = fmt->bytesperline * fmt->height; diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 290f388c2f28..592a4c6da103 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -386,20 +386,13 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma } switch (field) { case V4L2_FIELD_ALTERNATE: - vv->last_field = V4L2_FIELD_TOP; - maxh = maxh / 2; - break; case V4L2_FIELD_TOP: case V4L2_FIELD_BOTTOM: - vv->last_field = V4L2_FIELD_INTERLACED; maxh = maxh / 2; break; - case V4L2_FIELD_INTERLACED: - vv->last_field = V4L2_FIELD_INTERLACED; - break; default: - DEB_D("no known field mode '%d'\n", field); - return -EINVAL; + field = V4L2_FIELD_INTERLACED; + break; } f->fmt.pix.field = field; @@ -439,6 +432,14 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format err = vidioc_try_fmt_vid_cap(file, fh, f); if (0 != err) return err; + switch (f->fmt.pix.field) { + case V4L2_FIELD_ALTERNATE: + vv->last_field = V4L2_FIELD_TOP; + break; + default: + vv->last_field = V4L2_FIELD_INTERLACED; + break; + } vv->video_fmt = f->fmt.pix; DEB_EE("set to pixelformat '%4.4s'\n", (char *)&vv->video_fmt.pixelformat); From patchwork Thu Mar 2 13:03:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ED63C6FA8E for ; Thu, 2 Mar 2023 13:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbjCBNDp (ORCPT ); Thu, 2 Mar 2023 08:03:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjCBNDo (ORCPT ); Thu, 2 Mar 2023 08:03:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A4F81DBAB for ; Thu, 2 Mar 2023 05:03:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C6E32615D1 for ; Thu, 2 Mar 2023 13:03:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BE9FC433D2; Thu, 2 Mar 2023 13:03:41 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 09/17] media: common: saa7146: check minimum video format size Date: Thu, 2 Mar 2023 14:03:22 +0100 Message-Id: <20230302130330.1125172-10-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There was no check for the minimum width and height, so 0 values were just passed on. Fix this. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_video.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 592a4c6da103..6d8da22dd321 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -397,6 +397,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma f->fmt.pix.field = field; f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; + if (f->fmt.pix.width < 48) + f->fmt.pix.width = 48; + if (f->fmt.pix.height < 32) + f->fmt.pix.height = 32; if (f->fmt.pix.width > maxw) f->fmt.pix.width = maxw; if (f->fmt.pix.height > maxh) From patchwork Thu Mar 2 13:03:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1EB5C6FA8E for ; Thu, 2 Mar 2023 13:03:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbjCBNDw (ORCPT ); Thu, 2 Mar 2023 08:03:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbjCBNDt (ORCPT ); Thu, 2 Mar 2023 08:03:49 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7E118AB7 for ; Thu, 2 Mar 2023 05:03:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id C2BCACE1ED1 for ; Thu, 2 Mar 2023 13:03:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 880B1C433EF; Thu, 2 Mar 2023 13:03:42 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 10/17] media: common: saa7146: fall back to V4L2_PIX_FMT_BGR24 Date: Thu, 2 Mar 2023 14:03:23 +0100 Message-Id: <20230302130330.1125172-11-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If the requested pixelformat is not supported, then fall back to V4L2_PIX_FMT_BGR24 for improved V4L2 compliance. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_video.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 6d8da22dd321..bf42de07625e 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -372,8 +372,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh); fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat); - if (NULL == fmt) - return -EINVAL; + if (!fmt) { + f->fmt.pix.pixelformat = V4L2_PIX_FMT_BGR24; + fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat); + } field = f->fmt.pix.field; maxw = vv->standard->h_max_out; From patchwork Thu Mar 2 13:03:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE49CC6FA8E for ; Thu, 2 Mar 2023 13:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229960AbjCBNDt (ORCPT ); Thu, 2 Mar 2023 08:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbjCBNDr (ORCPT ); Thu, 2 Mar 2023 08:03:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9F97211E1 for ; Thu, 2 Mar 2023 05:03:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 71F8DB81205 for ; Thu, 2 Mar 2023 13:03:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8373CC4339B; Thu, 2 Mar 2023 13:03:43 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 11/17] media: common: saa7146: allow S_STD(G_STD) Date: Thu, 2 Mar 2023 14:03:24 +0100 Message-Id: <20230302130330.1125172-12-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If the requested TV standard is identical to the current TV standard, then return 0, even when the vb2 queues are busy. This fixes a V4L2 compliance issue. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_video.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index bf42de07625e..305af9ade9c4 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -470,14 +470,19 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id id) DEB_EE("VIDIOC_S_STD\n"); + for (i = 0; i < dev->ext_vv_data->num_stds; i++) + if (id & dev->ext_vv_data->stds[i].id) + break; + + if (i != dev->ext_vv_data->num_stds && + vv->standard == &dev->ext_vv_data->stds[i]) + return 0; + if (vb2_is_busy(&vv->video_dmaq.q) || vb2_is_busy(&vv->vbi_dmaq.q)) { DEB_D("cannot change video standard while streaming capture is active\n"); return -EBUSY; } - for (i = 0; i < dev->ext_vv_data->num_stds; i++) - if (id & dev->ext_vv_data->stds[i].id) - break; if (i != dev->ext_vv_data->num_stds) { vv->standard = &dev->ext_vv_data->stds[i]; if (NULL != dev->ext_vv_data->std_callback) From patchwork Thu Mar 2 13:03:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDC80C678D4 for ; Thu, 2 Mar 2023 13:03:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjCBNDt (ORCPT ); Thu, 2 Mar 2023 08:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbjCBNDs (ORCPT ); Thu, 2 Mar 2023 08:03:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC51518A8B for ; Thu, 2 Mar 2023 05:03:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 65279B811F3 for ; Thu, 2 Mar 2023 13:03:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E627C433D2; Thu, 2 Mar 2023 13:03:44 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 12/17] media: mxb: update the tvnorms when changing input Date: Thu, 2 Mar 2023 14:03:25 +0100 Message-Id: <20230302130330.1125172-13-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The tuner input uses different tvnorms compared to the S-Video/Composite inputs. So update the tvnorms field in struct video_device when switching inputs. This fixes a V4L2 compliance issue. Signed-off-by: Hans Verkuil --- drivers/media/pci/saa7146/mxb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 557ba89cd12d..3b0c475c7ab4 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -512,6 +512,9 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) if (err) return err; + mxb->video_dev.tvnorms = mxb_inputs[input].std; + mxb->vbi_dev.tvnorms = mxb_inputs[input].std; + /* switch video in saa7111a */ if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0)) pr_err("VIDIOC_S_INPUT: could not address saa7111a\n"); From patchwork Thu Mar 2 13:03:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4A55C7EE30 for ; Thu, 2 Mar 2023 13:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229969AbjCBNDv (ORCPT ); Thu, 2 Mar 2023 08:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbjCBNDt (ORCPT ); Thu, 2 Mar 2023 08:03:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8951C18B31 for ; Thu, 2 Mar 2023 05:03:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 46E18B8121A for ; Thu, 2 Mar 2023 13:03:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79660C433EF; Thu, 2 Mar 2023 13:03:45 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 13/17] media: common: saa7146: add support for missing .vidioc_try_fmt_vbi_cap Date: Thu, 2 Mar 2023 14:03:26 +0100 Message-Id: <20230302130330.1125172-14-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Support for VIDIOC_TRY_FMT for the vbi device was missing. Add it. This fixes a V4L2 compliance issue. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_video.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c index 305af9ade9c4..bd125ffdb8b1 100644 --- a/drivers/media/common/saa7146/saa7146_video.c +++ b/drivers/media/common/saa7146/saa7146_video.c @@ -522,6 +522,7 @@ const struct v4l2_ioctl_ops saa7146_video_ioctl_ops = { const struct v4l2_ioctl_ops saa7146_vbi_ioctl_ops = { .vidioc_querycap = vidioc_querycap, .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, + .vidioc_try_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, .vidioc_s_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, .vidioc_g_std = vidioc_g_std, .vidioc_s_std = vidioc_s_std, From patchwork Thu Mar 2 13:03:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157310 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6E1BC7EE33 for ; Thu, 2 Mar 2023 13:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbjCBNDv (ORCPT ); Thu, 2 Mar 2023 08:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbjCBNDu (ORCPT ); Thu, 2 Mar 2023 08:03:50 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A19BC19F2B for ; Thu, 2 Mar 2023 05:03:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5A894B81227 for ; Thu, 2 Mar 2023 13:03:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7490CC4339C; Thu, 2 Mar 2023 13:03:46 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 14/17] media: mxb: allow tuner/input/audio ioctls for vbi Date: Thu, 2 Mar 2023 14:03:27 +0100 Message-Id: <20230302130330.1125172-15-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The vbi stream comes from the same video input as the video stream. So all the related ioctls to that are just as valid for the vbi stream. Add these. This fixes a V4L2 compliance issue. Signed-off-by: Hans Verkuil --- drivers/media/pci/saa7146/mxb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 3b0c475c7ab4..8f1843baa732 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -706,6 +706,17 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data vv_data.vid_ops.vidioc_g_register = vidioc_g_register; vv_data.vid_ops.vidioc_s_register = vidioc_s_register; #endif + vv_data.vbi_ops.vidioc_enum_input = vidioc_enum_input; + vv_data.vbi_ops.vidioc_g_input = vidioc_g_input; + vv_data.vbi_ops.vidioc_s_input = vidioc_s_input; + vv_data.vbi_ops.vidioc_querystd = vidioc_querystd; + vv_data.vbi_ops.vidioc_g_tuner = vidioc_g_tuner; + vv_data.vbi_ops.vidioc_s_tuner = vidioc_s_tuner; + vv_data.vbi_ops.vidioc_g_frequency = vidioc_g_frequency; + vv_data.vbi_ops.vidioc_s_frequency = vidioc_s_frequency; + vv_data.vbi_ops.vidioc_enumaudio = vidioc_enumaudio; + vv_data.vbi_ops.vidioc_g_audio = vidioc_g_audio; + vv_data.vbi_ops.vidioc_s_audio = vidioc_s_audio; if (saa7146_register_device(&mxb->video_dev, dev, "mxb", VFL_TYPE_VIDEO)) { ERR("cannot register capture v4l2 device. skipping.\n"); saa7146_vv_release(dev); From patchwork Thu Mar 2 13:03:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1778C678D4 for ; Thu, 2 Mar 2023 13:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229982AbjCBNDx (ORCPT ); Thu, 2 Mar 2023 08:03:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbjCBNDv (ORCPT ); Thu, 2 Mar 2023 08:03:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDC49199CB for ; Thu, 2 Mar 2023 05:03:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5FFE3B811F3 for ; Thu, 2 Mar 2023 13:03:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FABFC4339B; Thu, 2 Mar 2023 13:03:47 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 15/17] media: common: saa7146: allow AUDIO ioctls for the vbi stream Date: Thu, 2 Mar 2023 14:03:28 +0100 Message-Id: <20230302130330.1125172-16-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The audio ioctls are just as valid for the vbi stream as for the video stream. The saa7146 driver removed the AUDIO capability, but that's wrong. Keep it. This fixes a V4L2 compliance issue. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_fops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c index 89cba6b36372..8771b31e1166 100644 --- a/drivers/media/common/saa7146/saa7146_fops.c +++ b/drivers/media/common/saa7146/saa7146_fops.c @@ -355,7 +355,7 @@ int saa7146_register_device(struct video_device *vfd, struct saa7146_dev *dev, vfd->device_caps &= ~(V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_OUTPUT); else - vfd->device_caps &= ~(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO); + vfd->device_caps &= ~V4L2_CAP_VIDEO_CAPTURE; q->type = type == VFL_TYPE_VIDEO ? V4L2_BUF_TYPE_VIDEO_CAPTURE : V4L2_BUF_TYPE_VBI_CAPTURE; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ | VB2_DMABUF; From patchwork Thu Mar 2 13:03:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FDD7C7EE33 for ; Thu, 2 Mar 2023 13:03:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbjCBNDy (ORCPT ); Thu, 2 Mar 2023 08:03:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbjCBNDx (ORCPT ); Thu, 2 Mar 2023 08:03:53 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 788B619F00 for ; Thu, 2 Mar 2023 05:03:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 31310B81219 for ; Thu, 2 Mar 2023 13:03:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B307C4339C; Thu, 2 Mar 2023 13:03:48 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 16/17] media: common: saa7146: drop USERPTR support Date: Thu, 2 Mar 2023 14:03:29 +0100 Message-Id: <20230302130330.1125172-17-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org With USERPTR enabled the following kernel warning appears: [ 113.123640] ------------[ cut here ]------------ [ 113.123689] get_vaddr_frames() cannot follow VM_IO mapping [ 113.123731] WARNING: CPU: 2 PID: 1389 at drivers/media/common/videobuf2/frame_vector.c:63 get_vaddr_frames+0x83/0x90 [videobuf2_common] [ 113.123750] Modules linked in: rc_hauppauge ir_kbd_i2c rc_core ivtv_alsa pulse8_cec serport tda9887 tda8290 msp3400 saa7127 hexium_orion tuner_simple tuner_types tea5767 tuner tda9840 tea6415c tea6420 saa7115 ivtv mxb saa7146_vv saa7146 videobuf2_dma_sg cx2341x wmi_bmof videobuf2_memops videobuf2_v4l2 tveeprom videobuf2_common mxm_wmi videodev mc x86_pkg_temp_thermal nouveau drm_ttm_helper thermal [ 113.123838] CPU: 2 PID: 1389 Comm: v4l2-compliance Tainted: G U 6.2.0-rc7-iszm #39 [ 113.123847] Hardware name: System manufacturer System Product Name/H170-PRO, BIOS 3805 05/16/2018 [ 113.123854] RIP: 0010:get_vaddr_frames+0x83/0x90 [videobuf2_common] [ 113.123868] Code: 00 00 85 c0 75 dd b8 f2 ff ff ff eb d6 0f 0b 89 c6 eb ac 48 c7 c7 00 e9 32 a0 89 44 24 04 c6 05 06 8b 00 00 01 e8 98 24 d8 e1 <0f> 0b 8b 44 24 04 eb c9 0f 1f 44 00 00 90 90 90 90 90 90 90 90 90 [ 113.123876] RSP: 0018:ffffc90001f73a80 EFLAGS: 00010282 [ 113.123886] RAX: 0000000000000000 RBX: ffff88813deff800 RCX: 0000000000000000 [ 113.123893] RDX: 0000000000000001 RSI: ffffffff829fc76d RDI: 00000000ffffffff [ 113.123900] RBP: 0000000000000000 R08: 00000000ffff7fff R09: 00000000ffff7fff [ 113.123907] R10: ffffffff82e656a0 R11: ffffffff82e656a0 R12: ffff88813deff800 [ 113.123914] R13: 0000000000000001 R14: ffff88810545b800 R15: 0000000000000000 [ 113.123921] FS: 00007f3ec4809b80(0000) GS:ffff888425c80000(0000) knlGS:0000000000000000 [ 113.123929] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 113.123936] CR2: 00007f3ec37ae000 CR3: 00000001516a0004 CR4: 00000000003706e0 [ 113.123943] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 113.123949] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 113.123956] Call Trace: [ 113.123962] [ 113.123971] vb2_create_framevec+0x57/0xb0 [videobuf2_memops] [ 113.123984] vb2_dma_sg_get_userptr+0x8b/0x150 [videobuf2_dma_sg] [ 113.123999] __prepare_userptr.constprop.0+0xe4/0x3e0 [videobuf2_common] [ 113.124017] ? unmap_page_range+0x2ca/0x430 [ 113.124027] ? unmap_vmas+0xf4/0x1d0 [ 113.124044] ? __lock_acquire+0x4b7/0xa00 [ 113.124060] ? lock_acquire+0xd2/0x2d0 [ 113.124072] ? lock_is_held_type+0xdc/0x130 [ 113.124089] __buf_prepare+0x1b6/0x1f0 [videobuf2_common] [ 113.124105] vb2_core_qbuf+0x242/0x530 [videobuf2_common] [ 113.124124] vb2_qbuf+0x78/0xb0 [videobuf2_v4l2] [ 113.124140] __video_do_ioctl+0x19a/0x3e0 [videodev] [ 113.124169] ? __might_fault+0x31/0x80 [ 113.124178] ? lock_release+0x85/0x170 [ 113.124191] video_usercopy+0x336/0x6b0 [videodev] [ 113.124213] ? __pfx___video_do_ioctl+0x10/0x10 [videodev] [ 113.124254] v4l2_ioctl+0x45/0x50 [videodev] [ 113.124275] __x64_sys_ioctl+0x8c/0xc0 [ 113.124286] do_syscall_64+0x43/0x90 [ 113.124296] entry_SYSCALL_64_after_hwframe+0x72/0xdc [ 113.124305] RIP: 0033:0x7f3ec4af6bab [ 113.124313] Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00 [ 113.124320] RSP: 002b:00007ffc41f63a80 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 113.124330] RAX: ffffffffffffffda RBX: 00007ffc41f63cf0 RCX: 00007f3ec4af6bab [ 113.124337] RDX: 00007ffc41f63ef8 RSI: 00000000c058560f RDI: 0000000000000003 [ 113.124343] RBP: 00007ffc41f67ef0 R08: 00000000fffffff8 R09: 0000000000000019 [ 113.124350] R10: 0000000000051000 R11: 0000000000000246 R12: 00007ffc41f67ef0 [ 113.124357] R13: 00007ffc41f63cf0 R14: 0000000000000000 R15: 00007ffc41f63f50 [ 113.124378] [ 113.124385] irq event stamp: 69479 [ 113.124391] hardirqs last enabled at (69489): [] __up_console_sem+0x4d/0x60 [ 113.124401] hardirqs last disabled at (69498): [] __up_console_sem+0x32/0x60 [ 113.124409] softirqs last enabled at (68754): [] __do_softirq+0x2bf/0x4dd [ 113.124417] softirqs last disabled at (68749): [] __irq_exit_rcu+0xb9/0x120 [ 113.124425] ---[ end trace 0000000000000000 ]--- Since USERPTR support is problematic anyway, just drop support for this. DMABUF is the right way to go. Signed-off-by: Hans Verkuil --- drivers/media/common/saa7146/saa7146_fops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c index 8771b31e1166..3cb8a944d3a0 100644 --- a/drivers/media/common/saa7146/saa7146_fops.c +++ b/drivers/media/common/saa7146/saa7146_fops.c @@ -358,7 +358,7 @@ int saa7146_register_device(struct video_device *vfd, struct saa7146_dev *dev, vfd->device_caps &= ~V4L2_CAP_VIDEO_CAPTURE; q->type = type == VFL_TYPE_VIDEO ? V4L2_BUF_TYPE_VIDEO_CAPTURE : V4L2_BUF_TYPE_VBI_CAPTURE; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ | VB2_DMABUF; + q->io_modes = VB2_MMAP | VB2_READ | VB2_DMABUF; q->ops = type == VFL_TYPE_VIDEO ? &video_qops : &vbi_qops; q->mem_ops = &vb2_dma_sg_memops; q->drv_priv = dev; From patchwork Thu Mar 2 13:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13157315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A211C6FA8E for ; Thu, 2 Mar 2023 13:03:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbjCBNDz (ORCPT ); Thu, 2 Mar 2023 08:03:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbjCBNDy (ORCPT ); Thu, 2 Mar 2023 08:03:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ECA2136DA for ; Thu, 2 Mar 2023 05:03:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 56A89B8121D for ; Thu, 2 Mar 2023 13:03:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6706BC433A0; Thu, 2 Mar 2023 13:03:49 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 17/17] media: pci: saa7146: advertise only those TV standard that are supported Date: Thu, 2 Mar 2023 14:03:30 +0100 Message-Id: <20230302130330.1125172-18-hverkuil-cisco@xs4all.nl> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> References: <20230302130330.1125172-1-hverkuil-cisco@xs4all.nl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org V4L2_STD_ALL advertises more standards than these boards actually support. This causes a V4L2 compliance issue. Limit the supported standards to those that are actually implemented. Signed-off-by: Hans Verkuil --- drivers/media/pci/saa7146/hexium_gemini.c | 19 ++++++++++--------- drivers/media/pci/saa7146/hexium_orion.c | 19 ++++++++++--------- drivers/media/pci/saa7146/mxb.c | 7 ++++--- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c index 7dead0dfcc9f..40b35098f3ea 100644 --- a/drivers/media/pci/saa7146/hexium_gemini.c +++ b/drivers/media/pci/saa7146/hexium_gemini.c @@ -27,17 +27,18 @@ static int hexium_num; #define HEXIUM_GEMINI 4 #define HEXIUM_GEMINI_DUAL 5 +#define HEXIUM_STD (V4L2_STD_PAL | V4L2_STD_SECAM | V4L2_STD_NTSC) #define HEXIUM_INPUTS 9 static struct v4l2_input hexium_inputs[HEXIUM_INPUTS] = { - { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, + { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, }; #define HEXIUM_AUDIOS 0 diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c index a83fd5d19add..8c26fe554986 100644 --- a/drivers/media/pci/saa7146/hexium_orion.c +++ b/drivers/media/pci/saa7146/hexium_orion.c @@ -28,17 +28,18 @@ static int hexium_num; #define HEXIUM_ORION_1SVHS_3BNC 2 #define HEXIUM_ORION_4BNC 3 +#define HEXIUM_STD (V4L2_STD_PAL | V4L2_STD_SECAM | V4L2_STD_NTSC) #define HEXIUM_INPUTS 9 static struct v4l2_input hexium_inputs[HEXIUM_INPUTS] = { - { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, - { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 0, 0, V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, + { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, + { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 0, 0, HEXIUM_STD, 0, V4L2_IN_CAP_STD }, }; #define HEXIUM_AUDIOS 0 diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 8f1843baa732..a14b839098b8 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -48,6 +48,7 @@ static int debug; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); +#define MXB_STD (V4L2_STD_PAL_BG | V4L2_STD_PAL_I | V4L2_STD_SECAM | V4L2_STD_NTSC) #define MXB_INPUTS 4 enum { TUNER, AUX1, AUX3, AUX3_YC }; @@ -55,11 +56,11 @@ static struct v4l2_input mxb_inputs[MXB_INPUTS] = { { TUNER, "Tuner", V4L2_INPUT_TYPE_TUNER, 0x3f, 0, V4L2_STD_PAL_BG | V4L2_STD_PAL_I, 0, V4L2_IN_CAP_STD }, { AUX1, "AUX1", V4L2_INPUT_TYPE_CAMERA, 0x3f, 0, - V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, + MXB_STD, 0, V4L2_IN_CAP_STD }, { AUX3, "AUX3 Composite", V4L2_INPUT_TYPE_CAMERA, 0x3f, 0, - V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, + MXB_STD, 0, V4L2_IN_CAP_STD }, { AUX3_YC, "AUX3 S-Video", V4L2_INPUT_TYPE_CAMERA, 0x3f, 0, - V4L2_STD_ALL, 0, V4L2_IN_CAP_STD }, + MXB_STD, 0, V4L2_IN_CAP_STD }, }; /* this array holds the information, which port of the saa7146 each