Received: by 10.223.185.116 with SMTP id b49csp683929wrg; Wed, 21 Feb 2018 05:21:19 -0800 (PST) X-Google-Smtp-Source: AH8x224UnMXxIagn7wmG1FDtCHySLUyULTMSvxTea+V/DCBMHiBuXKFPFABqI2OOouKq8XIOU3mQ X-Received: by 2002:a17:902:bb06:: with SMTP id l6-v6mr3146866pls.115.1519219279560; Wed, 21 Feb 2018 05:21:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519219279; cv=none; d=google.com; s=arc-20160816; b=NYnJYgOphCD/OrZ9+fO2jN2wXMc0oAJg1ELOM715V92cTfTkb03JkK714rFw+fO43Y IJEi+5e6rzU+BONl6mJbkjl0zAwtZbm+ml2leoRZWX3pfvePFDWPYm/yQ2Zt1SfLcNiW dulDPKpw10vXHu5YY/Z2D1IhjTKBH43XmI46tHl326Y3cAt5L+loMojnjJeAIStJf1jI /A3mmxlfLufsUwz/QKqt7G+TW+nifzJFrXu8xSr7133VboGw9ZhX22PWX3EDQdrfDugy zbRC2dwzGQomARVJ4Cg5zV1ubCEdB/oUD3Uh33JXPQ6tzeFWI2VI0SlMMWdqIcKQHCvz DysQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=/J1fPDTjkZUjDBGvPNdZMlKzWa2BX1+gDMOEbt/mzYQ=; b=sLdOpx8I8QKT0ZpZ5iL/zQHpleFwV1JKlqY7CelsRZMVLQTQymVJzql3wkgc/7MkN/ KaIvU4ZvwPgCHfVRBCv8qFRgpWaWrb7uN630oeboLY/bMjx1Z2FduqZ4HBG8zSP5uuxy Is7vEQQI8GEHaQbBMUrQiGXSJoA0ITBs8vKOrY7qN2j97dJm8btJ8jFMBBh/oh07jC/h JLksZSjW/XsiFrWMnKTIZ8US1iADroeEy4+Jq5EUsqfJK4H50NqR8ZkN+gc6xj0Hk8Lp epA5pQOIStnOadAQ5JKc1PuB2ERzYf7VUJ5qOhbs5r9rFHVsg2Jz8joRFO550p3wwsWX znPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=rxsRH7Ze; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22-v6si9268729plk.550.2018.02.21.05.21.05; Wed, 21 Feb 2018 05:21:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=rxsRH7Ze; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754251AbeBUM3I (ORCPT + 99 others); Wed, 21 Feb 2018 07:29:08 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:47319 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751929AbeBUM3G (ORCPT ); Wed, 21 Feb 2018 07:29:06 -0500 Received: from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 0D1AA200D4; Wed, 21 Feb 2018 13:27:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1519216043; bh=ZEIvY3NmIVZVUM6OpUO8AQSGTDAos5jnYmfSpA/LH18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rxsRH7Ze6MakFxTp+mcHIKUZZzBfbEHrRb9dgdQNxhQ1Kz8nfkt9tqafpD5yhmeVZ bV8hiwP70PYA3ksAsCds0R4+TW2JCayY0BjEItOyZpGEiFCMPObuItsmZttIJNfXGh D3SRgXjOPoYKqMlAWI+U3RbbIUDoBe8Y3aVzHzvg= From: Laurent Pinchart To: Hans Verkuil Cc: Jacopo Mondi , magnus.damm@gmail.com, geert@glider.be, mchehab@kernel.org, festevam@gmail.com, sakari.ailus@iki.fi, robh+dt@kernel.org, mark.rutland@arm.com, pombredanne@nexb.com, linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org, linux-sh@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 03/11] media: platform: Add Renesas CEU driver Date: Wed, 21 Feb 2018 14:29:47 +0200 Message-ID: <2908261.btsdL5a7UQ@avalon> Organization: Ideas on Board Oy In-Reply-To: <024c232f-bd43-42a9-25e7-0fbe71edbcb0@xs4all.nl> References: <1519059584-30844-1-git-send-email-jacopo+renesas@jmondi.org> <1519059584-30844-4-git-send-email-jacopo+renesas@jmondi.org> <024c232f-bd43-42a9-25e7-0fbe71edbcb0@xs4all.nl> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hans, On Wednesday, 21 February 2018 14:03:24 EET Hans Verkuil wrote: > On 02/19/18 17:59, Jacopo Mondi wrote: > > Add driver for Renesas Capture Engine Unit (CEU). > > > > The CEU interface supports capturing 'data' (YUV422) and 'images' > > (NV[12|21|16|61]). > > > > This driver aims to replace the soc_camera-based sh_mobile_ceu one. > > > > Tested with ov7670 camera sensor, providing YUYV_2X8 data on Renesas RZ > > platform GR-Peach. > > > > Tested with ov7725 camera sensor on SH4 platform Migo-R. > > > > Signed-off-by: Jacopo Mondi > > Reviewed-by: Laurent Pinchart > > --- > > > > drivers/media/platform/Kconfig | 9 + > > drivers/media/platform/Makefile | 1 + > > drivers/media/platform/renesas-ceu.c | 1661 +++++++++++++++++++++++++++++ > > 3 files changed, 1671 insertions(+) > > create mode 100644 drivers/media/platform/renesas-ceu.c > > > > > +static int ceu_s_input(struct file *file, void *priv, unsigned int i) > > +{ > > + struct ceu_device *ceudev = video_drvdata(file); > > + struct ceu_subdev *ceu_sd_old; > > + int ret; > > + > > + if (i >= ceudev->num_sd) > > + return -EINVAL; > > + > > + if (vb2_is_streaming(&ceudev->vb2_vq)) > > + return -EBUSY; > > + > > + if (i == ceudev->sd_index) > > + return 0; > > + > > + ceu_sd_old = ceudev->sd; > > + ceudev->sd = &ceudev->subdevs[i]; > > + > > + /* Make sure we can generate output image formats. */ > > + ret = ceu_init_formats(ceudev); > > Why is this done for every s_input? I would expect that this is done only > once for each subdev. > > I also expect to see a ceu_set_default_fmt() call here. Or that the v4l2_pix > is kept in ceu_subdev (i.e. per subdev) instead of a single fmt in cuedev. > I think I prefer that over configuring a new default format every time you > switch inputs. What does userspace expect today ? I don't think we document anywhere that formats are stored per-input in drivers. The VIDIOC_S_INPUT documentation is very vague: "To select a video input applications store the number of the desired input in an integer and call the VIDIOC_S_INPUT ioctl with a pointer to this integer. Side effects are possible. For example inputs may support different video standards, so the driver may implicitly switch the current standard. Because of these possible side effects applications must select an input before querying or negotiating any other parameters." I understand that as meaning "anything can happen when you switch inputs, so be prepared to reconfigure everything explicitly without assuming any particular parameter to have a sane value". > This code will work for two subdevs with exactly the same > formats/properties. But switching between e.g. a sensor and a video > receiver will leave things in an inconsistent state as far as I can see. > > E.g. if input 1 is the video receiver then switching to that input and > running 'v4l2-ctl -V' will show the sensor format, not the video receiver > format. I agree that the format should be consistent with the selected input, as calling VIDIOC_S_INPUT immediately followed by a stream start sequence without configuring formats should work (but produce a format that is not known to userspace). My question is whether we should reset to a default format for the newly select input, or switch back to the previously set format. I'd tend to go for the former to keep as little state as possible, but I'm open to counter-proposals. > > + if (ret) { > > + ceudev->sd = ceu_sd_old; > > + return -EINVAL; > > + } > > + > > + /* now that we're sure we can use the sensor, power off the old one. */ > > + v4l2_subdev_call(ceu_sd_old->v4l2_sd, core, s_power, 0); > > + v4l2_subdev_call(ceudev->sd->v4l2_sd, core, s_power, 1); > > + > > + ceudev->sd_index = i; > > + > > + return 0; > > +} > > The remainder of this driver looks good. -- Regards, Laurent Pinchart