Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp173910imm; Thu, 6 Sep 2018 00:02:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYymXdgpE/5mv6jnGivQMjd7xU6rUD7xYsOYvYZCdB7j8hfqFMr8rjVR/2gDa6GhhxdxPLW X-Received: by 2002:a63:10c:: with SMTP id 12-v6mr1374148pgb.62.1536217357499; Thu, 06 Sep 2018 00:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536217357; cv=none; d=google.com; s=arc-20160816; b=gu295xbNL7PXr002N1TqjTAdm6SAdgRgkbTIjurMQhBMAPjja41vR8+ClCnoZ4YW3G 8EkDFkwlRktNK8FIxycf/wByywTs4kWWlfiV4y90eKQXW7vEAfB+KZSuKb+zlJ/m+mqy JdN6MzMgK5GMq3f4V2Xt0jRd+homq2bmCw+KPsEiMeGGj00O2f+2cwC46FEoe9eGc8H+ hpXjSzkFw/9b3UWhZzHL6aczgr+sybKksFytfMkoKbeJV794FrrgBF5ZTN7VfaH/Ky4z Tnr+mBpNGgEwVPYTQPbR396wFMVkE/xwYurUrLoQ9plhAmaONpk8IdBpm54oWsSjALN/ tZfg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=R+g/PRGLw9EFNj0O4EgnHCItWJOQui6p/8WOsFXrtv4=; b=tClTrmkz10y0/xSa6eeVV7lmz/tRlpCT7uM/TOFMQC3LVY61syQAylQwqilldWSi0s sV+Lrt7fy0ZWFPLOXFl/6kyk3nLodN8TmoqQtTrdMI8oAV/RepSPVk9esGAqnnQ6n5rr XGFvaCfdixDjv4ZjVqjx08kXCHeCLkXRv0eIb6pL53/zMK/AK0B6T0EXHzpaREVjGJ/Z m2KTOHh2ChBZNsAjFEkZ1Fwvz7nd4rtjWZL4eGXDDjcIqKFuwMEHxYjuNjBNC4yiaMlx 3JGTPEbjfpH8v5VN9GH8bSCW85qJfLIRXOXGuPqjQKjDgSJpnh1k1iKtV+/RqDTkNODv f3Bg== ARC-Authentication-Results: i=1; mx.google.com; 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 s36-v6si4294545pld.8.2018.09.06.00.02.21; Thu, 06 Sep 2018 00:02:37 -0700 (PDT) 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; 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 S1727713AbeIFLfK (ORCPT + 99 others); Thu, 6 Sep 2018 07:35:10 -0400 Received: from lb3-smtp-cloud8.xs4all.net ([194.109.24.29]:49088 "EHLO lb3-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbeIFLfJ (ORCPT ); Thu, 6 Sep 2018 07:35:09 -0400 Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud8.xs4all.net with ESMTPA id xoHlfLObCxO9BxoHpf3tHZ; Thu, 06 Sep 2018 09:01:08 +0200 Subject: Re: [PATCH v8 4/8] media: platform: Add Cedrus VPU decoder driver To: Paul Kocialkowski , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org Cc: Mauro Carvalho Chehab , Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , Greg Kroah-Hartman , Thomas Petazzoni , Randy Li , Ezequiel Garcia , Tomasz Figa , Alexandre Courbot , Philipp Zabel , Laurent Pinchart , Sakari Ailus , linux-sunxi@googlegroups.com References: <20180828073424.30247-1-paul.kocialkowski@bootlin.com> <20180828073424.30247-5-paul.kocialkowski@bootlin.com> <5faf5eed-eb2c-f804-93e3-5a42f6204d99@xs4all.nl> From: Hans Verkuil Message-ID: <461c6a0d-a346-b9da-b75e-4aab907054df@xs4all.nl> Date: Thu, 6 Sep 2018 09:01:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfN1+h3UOvqZbrarh9UhH8Bfv69s5kMqmDcqkLJ1ycrLl1/38jMEi6GdRVCGa/hiIzqnltppzSEH1zZxcf8U+wDJ0AVG0qXh088G+2jB+lP1graTZrYo9 4LyA1vMz6tJpDuU+ElTbLkVbw7LTQ8x6iRA44Utb2cKIooluYBR3hyNmg3vWPGB/sB0xLnhi23CVg6wDrXsruoFhTbtrC3hxAKaLefcrzKXDYYwqels1C64s SsCml7CY5MeDNv5Nvv879q8d9NPOHUkSLILJuox+Tot7i4p60NCu2v3eAF9nh/+6yWptgFRmG4b0vOVokBWKHitgoUjqZqCZ7JMLXM2rWcM8I7kpKoaG4SLn knhLDsy6pypTzdvX1RsuoyPlGRTBdGvm1b2R5G07DZue6c/YZaCKr8IWJxnjXWiYn7qe9rtSUmhivJuwaFLQe3HSE7yZXHuw7Q+jpWOYkDnkNWENn1sZ9u1Y 3+KZOALSbHOiR81wiat+DqFksCcTZN8EEYB+yTTuG4sw/QPyBfiMBGFNj37ZoYe12M58AFHsw5aZUFlzxvScEIzzgWeJlW4I95lwiKO228wM8pDV/V1CSSAq uf4Ezr18AstDqKliXhPs8MihmP9El5/dHGXTAtKayvp6ucnFMCVWJzAzeAUBFIuIsumIVpUJFCdxUxlvbXhz9ZHyba+oBBKTqI+QwG94DbR+slD6Xl2nwghF ebQP87t+z1uhvxKdmeaQyTgsJAUu54YJgKtvIDJ4mlH3mDF4zR5fW+sKZYYYdZGT/6LYehI9rCofY5c+rJ/TR8g7c2UUx5iLQFAQ7W7sPTeku7fH3IB8XyZM 5gdJxEuIvNjFblb7roB2YVFBQQpbeBc0vcAlErM9/1pt/G3IsbL8L1/9P/IGvoUAwTMOGxMkl03B9+XKV7k= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/05/2018 06:29 PM, Paul Kocialkowski wrote: > Hi and thanks for the review! > > Le lundi 03 septembre 2018 à 11:11 +0200, Hans Verkuil a écrit : >> On 08/28/2018 09:34 AM, Paul Kocialkowski wrote: >>> +static int cedrus_request_validate(struct media_request *req) >>> +{ >>> + struct media_request_object *obj, *obj_safe; >>> + struct v4l2_ctrl_handler *parent_hdl, *hdl; >>> + struct cedrus_ctx *ctx = NULL; >>> + struct v4l2_ctrl *ctrl_test; >>> + unsigned int i; >>> + >>> + list_for_each_entry_safe(obj, obj_safe, &req->objects, list) { >> >> You don't need to use the _safe variant during validation. > > Okay, I'll use the regular one then. > >>> + struct vb2_buffer *vb; >>> + >>> + if (vb2_request_object_is_buffer(obj)) { >>> + vb = container_of(obj, struct vb2_buffer, req_obj); >>> + ctx = vb2_get_drv_priv(vb->vb2_queue); >>> + >>> + break; >>> + } >>> + } >> >> Interesting question: what happens if more than one buffer is queued in the >> request? This is allowed by the request API and in that case the associated >> controls in the request apply to all queued buffers. >> >> Would this make sense at all for this driver? If not, then you need to >> check here if there is more than one buffer in the request and document in >> the spec that this is not allowed. > > Well, our driver was written with the (unformal) assumption that we > only deal with a pair of one output and one capture buffer. So I will > add a check for this at request validation time and document it in the > spec. Should that be part of the MPEG-2 PIXFMT documentation (and > duplicated for future formats we add support for)? Can you make a patch for vb2_request_has_buffers() in videobuf2-core.c renaming it to vb2_request_buffer_cnt() and returning the number of buffers in the request? Then you can call it here to check that you have only one buffer. And this has to be documented with the PIXFMT. Multiple buffers are certainly possible in non-codec scenarios (vim2m and vivid happily accept that), so this is an exception that should be documented and checked in the codec driver. > >> If it does make sense, then you need to test this. >> >> Again, this can be corrected in a follow-up patch, unless there will be a >> v9 anyway. > > [...] >>> +static int cedrus_queue_setup(struct vb2_queue *vq, unsigned int *nbufs, >>> + unsigned int *nplanes, unsigned int sizes[], >>> + struct device *alloc_devs[]) >>> +{ >>> + struct cedrus_ctx *ctx = vb2_get_drv_priv(vq); >>> + struct cedrus_dev *dev = ctx->dev; >>> + struct v4l2_pix_format_mplane *mplane_fmt; >>> + struct cedrus_format *fmt; >>> + unsigned int i; >>> + >>> + switch (vq->type) { >>> + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: >>> + mplane_fmt = &ctx->src_fmt; >>> + fmt = cedrus_find_format(mplane_fmt->pixelformat, >>> + CEDRUS_DECODE_SRC, >>> + dev->capabilities); >>> + break; >>> + >>> + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: >>> + mplane_fmt = &ctx->dst_fmt; >>> + fmt = cedrus_find_format(mplane_fmt->pixelformat, >>> + CEDRUS_DECODE_DST, >>> + dev->capabilities); >>> + break; >>> + >>> + default: >>> + return -EINVAL; >>> + } >>> + >>> + if (!fmt) >>> + return -EINVAL; >>> + >>> + if (fmt->num_buffers == 1) { >>> + sizes[0] = 0; >>> + >>> + for (i = 0; i < fmt->num_planes; i++) >>> + sizes[0] += mplane_fmt->plane_fmt[i].sizeimage; >>> + } else if (fmt->num_buffers == fmt->num_planes) { >>> + for (i = 0; i < fmt->num_planes; i++) >>> + sizes[i] = mplane_fmt->plane_fmt[i].sizeimage; >>> + } else { >>> + return -EINVAL; >>> + } >>> + >>> + *nplanes = fmt->num_buffers; >> >> This code does not take VIDIOC_CREATE_BUFFERS into account. >> >> If it is called from that ioctl, then *nplanes is non-zero and you need >> to check if *nplanes equals fmt->num_buffers and that sizes[n] is >= >> the required size of the format. If so, then return 0, otherwise return >> -EINVAL. > > Thanks for spotting this, I'll fix it as you suggested in the next > revision. > >> Doesn't v4l2-compliance fail on that? Or is that test skipped because this >> is a decoder for which streaming is not supported (yet)? > > Apparently, v4l2-compliance doesn't fail since I'm getting: > test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK It is tested, but only with the -s option. I'll see if I can improve the tests. Regards, Hans