Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1313525pxu; Mon, 23 Nov 2020 18:07:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJ1+UQIsHkTz9LTLnl5Gp3s37kOrOTISfJNKmaxogUUAqygS+5DgAdgvJFHxIin9nJGOhA X-Received: by 2002:aa7:ce8d:: with SMTP id y13mr2040681edv.65.1606183625289; Mon, 23 Nov 2020 18:07:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606183625; cv=none; d=google.com; s=arc-20160816; b=n9AuwCCWKaVDaSqDMHwwMU0Bx3TsKnPDrXhA2xpAKpbKBGMAoV8tfy77nTomHrfp56 gOj2PxnG0j7dTc9017M0NXeAwuGNzpueeW9+ow4G6Sd4fyya2lhEZxIlgKkpdoP3AR9e LcAyh7oKWWYqgDBaQQ0w/l/Km18R9bynJR99eTbK1nOokjACUeVdSy9V/lME2GDIqtKa UzNtdQBBjR8e+kL2VHS6/OBcRuzcqR7nAmi7HCtL/nKc3Vj9W5b56MFz9d7qhAV5oypP M7DFwGZjo8vsBpXt9dvVj4lzhsfbrQSGWh1Yj/bdbQ7asI2UQFsdrLyi6bHPLqHdVXW0 HokQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GyUtXV4I7oufOCmRehbSbZihfE2dNAsjJjjjrmEuICw=; b=mT56qhIyDAe5RPTqVZIk9TeGu0SHZttDwkkiUMxJQhEjPq/U1mz9k6nO+rJwbLg1YO 845xdGbXO+UIz2KxrgTnwLo4C8ltGmb//CWmipOzcKKMjYAZSNOm80LjQCeHi3FuD6Hz MeGw32yFFaQVSi+VAg/izt90i8XgLN1e6sppgEjb17l90eWe4jOgpIBu2hbSfw0Mhbg+ d/qphg/6Ie+nOScWJUFz07GwANTbawz5KZD19E7RLgRKk05fRElj3RbB7EhE92Dof8bP 0DxkojkG7vPKqZbgXhoOmnGX1EWO9+3F3SZ/wfyRGi5mCIP8DTVbJQTC02ZK6jWikFEu 6vDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=xzdEz6kB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a13si8023498edb.92.2020.11.23.18.06.42; Mon, 23 Nov 2020 18:07:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=xzdEz6kB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388254AbgKWNHv (ORCPT + 99 others); Mon, 23 Nov 2020 08:07:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732870AbgKWMtI (ORCPT ); Mon, 23 Nov 2020 07:49:08 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7045AC061A4F for ; Mon, 23 Nov 2020 04:49:05 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id cf17so13376246edb.2 for ; Mon, 23 Nov 2020 04:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GyUtXV4I7oufOCmRehbSbZihfE2dNAsjJjjjrmEuICw=; b=xzdEz6kB4zBik1uOatoshaBm6LaSKmUojijYt8h9dh2QGrUS76eruUvLIzkSH0eGEe DOl+Li0VGvprWuzJGUffQBqShHCUBvn0FG05F8PWA7Ix6v7nmuwvqau9BuAUXtBuzc9P biFtftXYWUdPL666mAAt48VYycPt4mDE/nFamResc8Jm6tepnfAiJpTSHUAnPk79ypk0 LDR50k++wjeWldDm+gC03roaoqPBQQqL0fsaZikOBH87K99u1MRrLTd13dwLHowdkXpQ ztf6f/03UDNnrWdRmhDlhaGsgjm9AQ0a+uIiw96KobpddpBrzU5tcbP8H1dC1S7gVEf2 xPfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GyUtXV4I7oufOCmRehbSbZihfE2dNAsjJjjjrmEuICw=; b=kh0xf3D3GEgRT4YdValvVNSuPAGv9i/wSAac3AXNhgmld3atmgt2/lZkyTS5HdgXbn SBsa+A9zSk6SqmOPbjCBQ+cFJYN+KEvD17gMsOQRxC6v6gwW+KgAfLy9leFRVq3mH2CI qJhrKHPYr5OTdLVOTaYq1WHb6ELGKr1PePLXbfjlYBnQLgOesSV2PDmpc+rPsCRb5JoN vc/oL9S5oINUm19gaY52LTbz6iixiGmdrMO0UD8wptOWbefG3eBxGk34g0o2FpOKrZ4O BxZCWwp2OttywS90akHQPZKmUosVISOJ4s3y6ODamQzkDF9D64KvUfiDn3IfPjbBLMHP +6Vw== X-Gm-Message-State: AOAM5333yxOAndo5PwMl52V5qjsYgtjaXsqjDhnw3KMF1OpnQ7YnfAqb wJ9KnNzaI9Yka+6D09j9xJJvRZ5zoBBsRX6RFcba7g== X-Received: by 2002:aa7:cb52:: with SMTP id w18mr38774344edt.362.1606135744041; Mon, 23 Nov 2020 04:49:04 -0800 (PST) MIME-Version: 1.0 References: <20200922165535.1356622-1-maxime.chevallier@bootlin.com> <20200922165535.1356622-3-maxime.chevallier@bootlin.com> <20201123082122.49a08ebb@bootlin.com> In-Reply-To: <20201123082122.49a08ebb@bootlin.com> From: Ezequiel Garcia Date: Mon, 23 Nov 2020 09:48:51 -0300 Message-ID: Subject: Re: [PATCH v3 2/3] media: rockchip: Introduce driver for Rockhip's camera interface To: Maxime Chevallier Cc: Mauro Carvalho Chehab , Rob Herring , Robin Murphy , Mark Rutland , Heiko Stuebner , Hans Verkuil , Helen Koike , Dafna Hirschfeld , linux-media , devicetree , linux-arm-kernel , "open list:ARM/Rockchip SoC..." , Linux Kernel Mailing List , Thomas Petazzoni , Miquel Raynal , Paul Kocialkowski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime, On Mon, 23 Nov 2020 at 04:21, Maxime Chevallier wrote: > > Hi Ezequiel, and thanks a lot for the review ! > > On Fri, 2 Oct 2020 14:35:28 -0300 > Ezequiel Garcia wrote: > > > Hi Maxime, > > > >Thanks to Dafna, I found the patch ^_^ > > > >The driver looks real good. Just a few comments below. > > > >Is the driver passing latest v4l2-compliance tests? > > I'll post them along with the next iteration of the series. > > >> +config VIDEO_ROCKCHIP_VIP > >> + tristate "Rockchip VIP (Video InPut) Camera Interface" > >> + depends on VIDEO_DEV && VIDEO_V4L2 > >> + depends on ARCH_ROCKCHIP || COMPILE_TEST > >> + select VIDEOBUF2_DMA_SG > >> + select VIDEOBUF2_DMA_CONTIG > >> + select V4L2_FWNODE > >> + select V4L2_MEM2MEM_DEV > >> + help > >> + This is a v4l2 driver for Rockchip SOC Camera interface. > >> + > >> + To compile this driver as a module choose m here. > >> + > > > >Please add ... "the module will be called {the name}". > > Sure, I will do ! > > [...] > > >> +#define VIP_REQ_BUFS_MIN 1 > > > >I think you might want to have more than 1 buffer > >as minimum. How about 3? Two for the ping and pong, > >and one more in the queue. > > Yes you're correct, 3 should be the strict minimum required buffers > here, I didn't update that after adding the dual-buffering mode. > > >> +#define VIP_MIN_WIDTH 64 > >> +#define VIP_MIN_HEIGHT 64 > >> +#define VIP_MAX_WIDTH 8192 > >> +#define VIP_MAX_HEIGHT 8192 > >> + > >> +#define RK_VIP_PLANE_Y 0 > >> +#define RK_VIP_PLANE_CBCR 1 > >> + > >> +#define VIP_FETCH_Y_LAST_LINE(VAL) ((VAL) & 0x1fff) > >> +/* Check if swap y and c in bt1120 mode */ > >> +#define VIP_FETCH_IS_Y_FIRST(VAL) ((VAL) & 0xf) > >> + > >> +/* Get xsubs and ysubs for fourcc formats > >> + * > >> + * @xsubs: horizontal color samples in a 4*4 matrix, for yuv > >> + * @ysubs: vertical color samples in a 4*4 matrix, for yuv > >> + */ > >> +static int fcc_xysubs(u32 fcc, u32 *xsubs, u32 *ysubs) > > > >See below, you should be using v4l2_fill_pixfmt_mp. > > > >> +{ > >> + switch (fcc) { > >> + case V4L2_PIX_FMT_NV16: > >> + case V4L2_PIX_FMT_NV61: > >> + *xsubs = 2; > >> + *ysubs = 1; > >> + break; > >> + case V4L2_PIX_FMT_NV21: > >> + case V4L2_PIX_FMT_NV12: > >> + *xsubs = 2; > >> + *ysubs = 2; > >> + break; > >> + default: > >> + return -EINVAL; > >> + } > >> + > >> + return 0; > >> +} > >> + > >> +static const struct vip_output_fmt out_fmts[] = { > >> + { > >> + .fourcc = V4L2_PIX_FMT_NV16, > >> + .cplanes = 2, > > > >From what I can see, you are only using this > >information to calculate bytesperline and sizeimage, > >so you should be using the v4l2_fill_pixfmt_mp() helper. > > You're correct, it indeed makes things much easier and allowed to > removed a lot of redundant info here ! > > > >> +static void rk_vip_set_fmt(struct rk_vip_stream *stream, > >> + struct v4l2_pix_format_mplane *pixm, > >> + bool try) > >> +{ > >> + struct rk_vip_device *dev = stream->vipdev; > >> + struct v4l2_subdev_format sd_fmt; > >> + const struct vip_output_fmt *fmt; > >> + struct v4l2_rect input_rect; > >> + unsigned int planes, imagesize = 0; > >> + u32 xsubs = 1, ysubs = 1; > >> + int i; > >> + > > > >I was expecting to see some is_busy or is_streaming check > >here, have you tested what happens if you change the format > >while streaming, or after buffers are queued? > > Yes correct. I used the stream->state private flag here, but I it was > also brought to my attention that there also exists a vb2_is_busy() > helper, but I'm unsure if it would be correct to use it here. > Long story, short: when the application creates buffers, with e.g. REQBUF (see vb2_core_reqbufs), it will call the driver (vb2_ops.queue_setup), to get the planes' sizes. In the current model, for a given vb2 queue, all the buffers are the same size. In practice, the simpler way to express this is not allowing S_FMT if there are buffers allocated in the queue (vb2_is_busy). You could relax the vb2_is_busy requirement in your driver, but I usually find it's not worth the trouble. > > >> + > >> +static int rk_vip_g_input(struct file *file, void *fh, unsigned int *i) > >> +{ > >> + *i = 0; > >> + return 0; > >> +} > >> + > >> +static int rk_vip_s_input(struct file *file, void *fh, unsigned int i) > >> +{ > > > >Only one input, why do you need to support this ioctl at all? > > I actually saw a fair amount of existing drivers implementing these > callbacks even for only one input, so I don't really know if I should > remove it or not ? > S_INPUT is used e.g. on capture devices that have multiple inputs and can capture from one input at a time. If the ioctl is empty like this, the driver can simply not support the ioctl. Best regards, Ezequiel