Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp94408imj; Thu, 7 Feb 2019 00:52:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IYajMVEH7+chCnnKIngL3J6jgaVKhSijCTuyfeqISr2b/08V11alQi80Uxbg5y8tQD4ofVW X-Received: by 2002:a17:902:ec06:: with SMTP id cy6mr15011402plb.11.1549529565084; Thu, 07 Feb 2019 00:52:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549529565; cv=none; d=google.com; s=arc-20160816; b=oRyQ6TZlqumqOQRK8MHZ/M8gJzsuXrlQWmrt6nWf3X9TSrzWq0iUtfmy11Yagz7Cis br5iuBGU00ldvY7d7Q10gRL9QzyVKKS61qzdXRQGwdrkb1deEGdRkeh6RPCOvIVUq0BS FVVUT/LrnthdbYgPpCM4m//SmVxR9LLxPupw8oGBsWbo/t9bNaK8myuelpGlMfLBxOTW b5FuQCnyOChuAqXF/DgaMffMYPC1UndPDq5ae9W5918V4islArRWxhC3azcAcl+RUowv H0JLIG5WUFD9LFQM8bSDTnwytDDfDw9NR1mw37fha3MZhJtWkc485762dzVIdL8Y/PLa QXZg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=67TqqQt2cMAQmgp7V/k3Hdqs/WwIh1qTEk8gB70lbIc=; b=N+xUe6zzQKOSBlbCthzg2P0bBa6rFE4xQb8twjfEz6WVDZz/b6OeszDbCWELCqmBim k9pTNpWSLpB8oR4/uAPp0Dw/Z/iP3+V5er6H7VYi9V6FWMB31JYIISfYzDbtSrXGXi5X sGG3A2+QjvBw3GHjHHsH++QvJ172ixSwjeYj8ZG2W3oQeAUdyuLII77FMLykWzDJ1+6k WKQnL6IIBHrBkdwImh97N6ldXCBgO2/aIGUs1+V5UXUIhNPGCrLGwoOT6WI7s8MWeQPu uVuwoweZlyEq30R3/iCy88qSYRGRux1le+MuIHvnQVfjM7iblz1EX5k/8Wm6Tk/TU2nE S4fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PQq0BYlJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si8901917pli.418.2019.02.07.00.52.29; Thu, 07 Feb 2019 00:52:45 -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 header.i=@chromium.org header.s=google header.b=PQq0BYlJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbfBGIvs (ORCPT + 99 others); Thu, 7 Feb 2019 03:51:48 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:34564 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbfBGIvs (ORCPT ); Thu, 7 Feb 2019 03:51:48 -0500 Received: by mail-ot1-f67.google.com with SMTP id t5so17028389otk.1 for ; Thu, 07 Feb 2019 00:51:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=67TqqQt2cMAQmgp7V/k3Hdqs/WwIh1qTEk8gB70lbIc=; b=PQq0BYlJLY3tKUKboY4AsqTP74D06T1ebfDhMRI6scT73OZEYw5dxxNsVAioNYkONS vf6OCiQxorR5o0UeAlerno/P1IY2Zf5l6m+VdN7iae9ToBUfpnr5A2pTQvDCJRS66tO3 PzEl2vMr5HEbIY2w9YWrwVRHaKkTa9obJr1nA= 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:content-transfer-encoding; bh=67TqqQt2cMAQmgp7V/k3Hdqs/WwIh1qTEk8gB70lbIc=; b=onIy4ZUeGo6TzOvDF9aAXGpSLJZ0yFxVumjcMOxfsZBDyrDtrQpaDPjMYOC4uz3awj /NWqsXtOEcJdjAFzcTpt3gjl5jan6o/Q0NeFFCcdEbo2eVimjz8v/EsZuTgQVSmZF++2 34pe4mx5b88YQaASFGKD8/eBk7PEQCsgkMeSKwEuw/fI53s7vk27StDsK085flkDKEBm 0dtSr2BCd/EaS5pHqL57sGnjKLfnXldeskbAv1d5QTfNHGCniB4kAvuZUa4IlEo3tjB9 +ngPiajEFj9nsHNSSYX/uBHjJtLjWsBQAsfVwcHDK+tIXg4Hp5Uk8m9B8lDZDZsv8PAM 6OPQ== X-Gm-Message-State: AHQUAub34X6liLBn2lkxhRLqXxyA89EynWRYW5dvkqakw+iLrDweITgw gpt92fKtrFgF1AoGNc18nwghCDlAUjJXkA== X-Received: by 2002:a9d:7685:: with SMTP id j5mr8252391otl.150.1549529507218; Thu, 07 Feb 2019 00:51:47 -0800 (PST) Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com. [209.85.210.52]) by smtp.gmail.com with ESMTPSA id m133sm11511789oib.52.2019.02.07.00.51.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 00:51:45 -0800 (PST) Received: by mail-ot1-f52.google.com with SMTP id u16so16936392otk.8 for ; Thu, 07 Feb 2019 00:51:44 -0800 (PST) X-Received: by 2002:a9d:1b67:: with SMTP id l94mr430687otl.147.1549529504330; Thu, 07 Feb 2019 00:51:44 -0800 (PST) MIME-Version: 1.0 References: <20190124100419.26492-1-tfiga@chromium.org> <20190124100419.26492-2-tfiga@chromium.org> <54430438-33a3-2c52-b6c8-4000a4088906@xs4all.nl> <1548938648.4585.3.camel@pengutronix.de> <6aa88094-068a-089d-2d52-3f9ade5a396c@xs4all.nl> In-Reply-To: <6aa88094-068a-089d-2d52-3f9ade5a396c@xs4all.nl> From: Tomasz Figa Date: Thu, 7 Feb 2019 17:51:33 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/2] media: docs-rst: Document memory-to-memory video decoder interface To: Hans Verkuil Cc: Philipp Zabel , Linux Media Mailing List , Linux Kernel Mailing List , Mauro Carvalho Chehab , Pawel Osciak , Alexandre Courbot , Kamil Debski , Andrzej Hajda , Kyungmin Park , Jeongtae Park , =?UTF-8?B?VGlmZmFueSBMaW4gKOael+aFp+ePiik=?= , =?UTF-8?B?QW5kcmV3LUNUIENoZW4gKOmZs+aZuui/qik=?= , Stanimir Varbanov , Todor Tomov , Nicolas Dufresne , Paul Kocialkowski , Laurent Pinchart , dave.stevenson@raspberrypi.org, Ezequiel Garcia , Maxime Jourdan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 31, 2019 at 10:19 PM Hans Verkuil wrote: > > On 1/31/19 1:44 PM, Philipp Zabel wrote: > > On Thu, 2019-01-31 at 13:30 +0100, Hans Verkuil wrote: > >> On 1/31/19 11:45 AM, Hans Verkuil wrote: > >>> On 1/24/19 11:04 AM, Tomasz Figa wrote: > >>>> Due to complexity of the video decoding process, the V4L2 drivers of > >>>> stateful decoder hardware require specific sequences of V4L2 API cal= ls > >>>> to be followed. These include capability enumeration, initialization= , > >>>> decoding, seek, pause, dynamic resolution change, drain and end of > >>>> stream. > >>>> > >>>> Specifics of the above have been discussed during Media Workshops at > >>>> LinuxCon Europe 2012 in Barcelona and then later Embedded Linux > >>>> Conference Europe 2014 in D=C3=BCsseldorf. The de facto Codec API th= at > >>>> originated at those events was later implemented by the drivers we a= lready > >>>> have merged in mainline, such as s5p-mfc or coda. > >>>> > >>>> The only thing missing was the real specification included as a part= of > >>>> Linux Media documentation. Fix it now and document the decoder part = of > >>>> the Codec API. > >>>> > >>>> Signed-off-by: Tomasz Figa > >>>> --- > >>>> Documentation/media/uapi/v4l/dev-decoder.rst | 1076 ++++++++++++++= +++ > >>>> Documentation/media/uapi/v4l/dev-mem2mem.rst | 5 + > >>>> Documentation/media/uapi/v4l/pixfmt-v4l2.rst | 5 + > >>>> Documentation/media/uapi/v4l/v4l2.rst | 10 +- > >>>> .../media/uapi/v4l/vidioc-decoder-cmd.rst | 40 +- > >>>> Documentation/media/uapi/v4l/vidioc-g-fmt.rst | 14 + > >>>> 6 files changed, 1135 insertions(+), 15 deletions(-) > >>>> create mode 100644 Documentation/media/uapi/v4l/dev-decoder.rst > >>>> > >>> > >>> > >>> > >>>> +4. **This step only applies to coded formats that contain resoluti= on information > >>>> + in the stream.** Continue queuing/dequeuing bitstream buffers t= o/from the > >>>> + ``OUTPUT`` queue via :c:func:`VIDIOC_QBUF` and :c:func:`VIDIOC_= DQBUF`. The > >>>> + buffers will be processed and returned to the client in order, = until > >>>> + required metadata to configure the ``CAPTURE`` queue are found.= This is > >>>> + indicated by the decoder sending a ``V4L2_EVENT_SOURCE_CHANGE``= event with > >>>> + ``V4L2_EVENT_SRC_CH_RESOLUTION`` source change type. > >>>> + > >>>> + * It is not an error if the first buffer does not contain enoug= h data for > >>>> + this to occur. Processing of the buffers will continue as lon= g as more > >>>> + data is needed. > >>>> + > >>>> + * If data in a buffer that triggers the event is required to de= code the > >>>> + first frame, it will not be returned to the client, until the > >>>> + initialization sequence completes and the frame is decoded. > >>>> + > >>>> + * If the client sets width and height of the ``OUTPUT`` format = to 0, > >>>> + calling :c:func:`VIDIOC_G_FMT`, :c:func:`VIDIOC_S_FMT`, > >>>> + :c:func:`VIDIOC_TRY_FMT` or :c:func:`VIDIOC_REQBUFS` on the `= `CAPTURE`` > >>>> + queue will return the ``-EACCES`` error code, until the decod= er > >>>> + configures ``CAPTURE`` format according to stream metadata. > >>> > >>> I think this should also include the G/S_SELECTION ioctls, right? > >> > >> I've started work on adding compliance tests for codecs to v4l2-compli= ance and > >> I quickly discovered that this 'EACCES' error code is not nice at all. > >> > >> The problem is that it is really inconsistent with V4L2 behavior: the = basic > >> rule is that there always is a format defined, i.e. G_FMT will always = return > >> a format. > >> > >> Suddenly returning an error is actually quite painful to handle becaus= e it is > >> a weird exception just for the capture queue of a stateful decoder if = no > >> output resolution is known. > >> > >> Just writing that sentence is painful. > >> > >> Why not just return some default driver defined format? It will automa= tically > >> be updated once the decoder parsed the bitstream and knows the new res= olution. > >> > >> It really is just the same behavior as with a resolution change. > >> > >> It is also perfectly fine to request buffers for the capture queue for= that > >> default format. It's pointless, but not a bug. > >> > >> Unless I am missing something I strongly recommend changing this behav= ior. > > > > I just wrote the same in my reply to Nicolas, the CODA driver currently > > sets the capture queue width/height to the output queue's crop rectangl= e > > (rounded to macroblock size) without ever having seen the SPS. > > And thinking about the initial 0x0 width/height for the output queue: > > that too is an exception, although less of a problem than the EACCES beha= vior. > > It should be fine for an application to set width/height to 0 when callin= g > S_FMT for the output queue of the decoder, but I would also prefer that i= t is > just replaced by the driver with some default resolution. It really doesn= 't > matter in practice, since you will wait for the SOURCE_CHANGE event regar= dless. > > Only then do you start to configure the CAPTURE queue. > > Using 0x0 and EACCES looks good on paper, but in the code it is a hassle = and > I'm not convinced there is any benefit. > > I like generic APIs and no where else do we ever return a 0 value for wid= th > or height, except in this corner case. It's just awkward. Agreed, although with some caveats I mentioned in my reply to the venus pat= ch. Best regards, Tomasz