Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp493827imm; Fri, 15 Jun 2018 01:05:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5wLYbiEXsoKTYhtMgU9AH8A37zOLbY5oW2omCiD/9WOsGPq7mGiQlaQyEZPU5NgDNttgV X-Received: by 2002:a65:48c9:: with SMTP id o9-v6mr632614pgs.262.1529049906260; Fri, 15 Jun 2018 01:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529049906; cv=none; d=google.com; s=arc-20160816; b=u3rBLPzYCFSKj//X4quERIO29nvJ90eBRY58Jg937xK22cKmrWpbTRUeBOAFKqXPPS 43LSSnExiDBi8nMuFSvQoHNfhydNKHAqHcuMRLeRHHW7c4IIchLbmhvpUORmkNKXn/d+ 7rJ/AQUbr4OyxotKzfKvKvcNjEr/rynVaHCq8DimRNbdelPjKTeXFcLGcWZVN4FYXa9t F4aILGLAOKwvxiC9ad8bnYZ8Jx8odSQM6FAX0afgCGqDPctfPvHHw5wU7cONdZFXZ2H9 KSvgVfccSWI7mEq3npnt4BNhtwskYHun5pvWyhQWsCgXwi2D57x5799fnYquJ76qY7VS HGbw== 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:arc-authentication-results; bh=TUywPvvy+T+3/1XCUXGEFR/s9n7XvS1JZLvJf8YoPoA=; b=QKK4eAjVpdDr/YIvVenXlqdge85BwCCGd8hMItgUvdeEY296u+J4RwwtjE94EhRPce d1Ylvi98adpbqf7dD2cQ55QAHlAAWwK7ZhAg1aboxdb2fHZl7oWKMlXwd0S2uuqlBBFN FmUEZ3X92QKlK5Q0ZVK+QLQ4Iuionl3gCqaXpV5X6mmiiWrLLU8y8KvzWgfzL8gVcHkW goS8RzBJ8w6en5NdjeT4adO0zMap7QWeM1dDi4qOXku9MjmLw1PRnpYNJwColrDZZqeD FA7r/u/D6QTIx9LZLfkkJgpzFGSCM9OXPbzG3D+DezArE/rAPG3aQXHMjhGGirO7qWEA /l6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gPSStXvf; 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 n9-v6si6125910pgp.558.2018.06.15.01.04.50; Fri, 15 Jun 2018 01:05:06 -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; dkim=pass header.i=@chromium.org header.s=google header.b=gPSStXvf; 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 S1755994AbeFOIDG (ORCPT + 99 others); Fri, 15 Jun 2018 04:03:06 -0400 Received: from mail-yw0-f195.google.com ([209.85.161.195]:37377 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755792AbeFOIDE (ORCPT ); Fri, 15 Jun 2018 04:03:04 -0400 Received: by mail-yw0-f195.google.com with SMTP id j134-v6so3073606ywg.4 for ; Fri, 15 Jun 2018 01:03:04 -0700 (PDT) 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=TUywPvvy+T+3/1XCUXGEFR/s9n7XvS1JZLvJf8YoPoA=; b=gPSStXvfT3YUbH2ePjau5UM44Yi1hTTyKq1awZ1Jr3DGw7KT3HGNLgo7YmrYTEV/UP eOcNUOHwQPBdrUNOX+WiwM5XnsOc7j7Mn5ud8Uu2Q9hzRN2QEnN6ztmDi/IY8EFcXElU /Sa+cTpC9ak/Kdrz0+0r/L/4sGRylgKr1cmUk= 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=TUywPvvy+T+3/1XCUXGEFR/s9n7XvS1JZLvJf8YoPoA=; b=A5WMuXaU+K89k00i0yZ0WWXbegmCAC4vKL88U9+ALd7+r6xybSTNq0tYeZPbvnHpGj YNPE6QiC870XwWgVV58Jnc74yEsYFxv2qf2bYOF3ZkmwbwE1P1WKAHujnSsfUi1a5Nc8 CWVblbdZ5EPpreo2jjCiIKIsMTVE4/HuS10zUXeiI7yLB0NAjNRWtD2PDcmoOmX5WuxL w0UpiE7vFueTA2W9fo5cN30ZYIy7x+5mWxS41tGDjIT0vxCNJ8iJaUJqw6VoN7MLJGvW XrjHHjpIhbLUfktYanZtWmNltdLNg2pxlVP1sHCky+NR4nLor4mp5kqE4NsxtiPbfMID DqHA== X-Gm-Message-State: APt69E19w8IMhtZAOq9VhyqZLqcjIh72YEt+1KgsiwL95yDUdh+ZXOHz 8GfZwTc9+k4bzVJDKVVLFwVu5cjmeKs= X-Received: by 2002:a81:e30e:: with SMTP id q14-v6mr277625ywl.23.1529049783330; Fri, 15 Jun 2018 01:03:03 -0700 (PDT) Received: from mail-yw0-f177.google.com (mail-yw0-f177.google.com. [209.85.161.177]) by smtp.gmail.com with ESMTPSA id y21-v6sm3239882ywd.0.2018.06.15.01.03.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 01:03:02 -0700 (PDT) Received: by mail-yw0-f177.google.com with SMTP id s201-v6so3066809ywg.8 for ; Fri, 15 Jun 2018 01:03:02 -0700 (PDT) X-Received: by 2002:a0d:dc81:: with SMTP id f123-v6mr267212ywe.66.1529049781634; Fri, 15 Jun 2018 01:03:01 -0700 (PDT) MIME-Version: 1.0 References: <20180605103328.176255-1-tfiga@chromium.org> <20180605103328.176255-2-tfiga@chromium.org> <89dca3ae-cbbc-4b5b-1c8a-207951997839@linaro.org> In-Reply-To: <89dca3ae-cbbc-4b5b-1c8a-207951997839@linaro.org> From: Tomasz Figa Date: Fri, 15 Jun 2018 17:02:50 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/2] media: docs-rst: Add decoder UAPI specification to Codec Interfaces To: Stanimir Varbanov Cc: Linux Media Mailing List , Linux Kernel Mailing List , Mauro Carvalho Chehab , Hans Verkuil , Pawel Osciak , Alexandre Courbot , kamil@wypas.org, a.hajda@samsung.com, Kyungmin Park , jtp.park@samsung.com, Philipp Zabel , =?UTF-8?B?VGlmZmFueSBMaW4gKOael+aFp+ePiik=?= , =?UTF-8?B?QW5kcmV3LUNUIENoZW4gKOmZs+aZuui/qik=?= , todor.tomov@linaro.org, nicolas@ndufresne.ca, Paul Kocialkowski , Laurent Pinchart 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 Hi Stanimir, On Thu, Jun 14, 2018 at 9:34 PM Stanimir Varbanov wrote: > > Hi Tomasz, > > > On 06/05/2018 01:33 PM, Tomasz Figa wrote: > > Due to complexity of the video decoding process, the V4L2 drivers of > > stateful decoder hardware require specific sequencies of V4L2 API calls > > to be followed. These include capability enumeration, initialization, > > decoding, seek, pause, dynamic resolution change, flush 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 that > > originated at those events was later implemented by the drivers we alre= ady > > have merged in mainline, such as s5p-mfc or mtk-vcodec. > > > > 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-codec.rst | 771 +++++++++++++++++++++ > > Documentation/media/uapi/v4l/v4l2.rst | 14 +- > > 2 files changed, 784 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/media/uapi/v4l/dev-codec.rst b/Documentation= /media/uapi/v4l/dev-codec.rst > > index c61e938bd8dc..0483b10c205e 100644 > > --- a/Documentation/media/uapi/v4l/dev-codec.rst > > +++ b/Documentation/media/uapi/v4l/dev-codec.rst > > > > > +Initialization sequence > > +----------------------- > > + > > +1. (optional) Enumerate supported OUTPUT formats and resolutions. See > > + capability enumeration. > > + > > +2. Set a coded format on the source queue via :c:func:`VIDIOC_S_FMT` > > + > > + a. Required fields: > > + > > + i. type =3D OUTPUT > > + > > + ii. fmt.pix_mp.pixelformat set to a coded format > > + > > + iii. fmt.pix_mp.width, fmt.pix_mp.height only if cannot be > > + parsed from the stream for the given coded format; > > + ignored otherwise; > > Can we say that if width !=3D 0 and height !=3D 0 then the user knows the > real coded resolution? And vise versa if width/height are both zero the > driver should parse the stream metadata? > > Also what about fmt.pix_mp.plane_fmt.sizeimage, as per spec (S_FMT) this > field should be filled with correct image size? If the coded > width/height is zero sizeimage will be unknown. I think we have two > options, the user fill sizeimage with bigger enough size or the driver > has to have some default size. First of all, thanks for review! It's a bit more tricky, because not all hardware may permit the resolution of CAPTURE buffers, based on what userspace set on OUTPUT queue. I'd say that the hardware should always parse these data from the stream, if it has such ability. If it parses, it should update the OUTPUT format and, if CAPTURE format as set by userspace is not compatible with HW requirements, it should adjust CAPTURE format appropriately. It would then send a source change event, mandating the userspace to read the new format. That would be still compatible with old userspace (GStreamer), since on hardware it used to work, the resulting CAPTURE format would be compatible with hardware. As for sizeimage on OUTPUT, it doesn't really make much sense, because OUTPUT queue is fed with compressed bitstream. Existing drivers accept this coming from userspace. If there is a specific HW requirement (e.g. constant buffer size or at least N bytes), the driver should adjust it appropriately on S_FMT then. > > > + > > + b. Return values: > > + > > + i. EINVAL: unsupported format. > > + > > + ii. Others: per spec > > + > > + .. note:: > > + > > + The driver must not adjust pixelformat, so if > > + ``V4L2_PIX_FMT_H264`` is passed but only > > + ``V4L2_PIX_FMT_H264_SLICE`` is supported, S_FMT will return > > + -EINVAL. If both are acceptable by client, calling S_FMT for > > + the other after one gets rejected may be required (or use > > + :c:func:`VIDIOC_ENUM_FMT` to discover beforehand, see Capability > > + enumeration). > > + > > +3. (optional) Get minimum number of buffers required for OUTPUT queue > > + via :c:func:`VIDIOC_G_CTRL`. This is useful if client intends to u= se > > + more buffers than minimum required by hardware/format (see > > + allocation). > > + > > + a. Required fields: > > + > > + i. id =3D ``V4L2_CID_MIN_BUFFERS_FOR_OUTPUT`` > > + > > + b. Return values: per spec. > > + > > + c. Return fields: > > + > > + i. value: required number of OUTPUT buffers for the currently s= et > > + format; > > + > > +4. Allocate source (bitstream) buffers via :c:func:`VIDIOC_REQBUFS` o= n OUTPUT > > + queue. > > + > > + a. Required fields: > > + > > + i. count =3D n, where n > 0. > > + > > + ii. type =3D OUTPUT > > + > > + iii. memory =3D as per spec > > + > > + b. Return values: Per spec. > > + > > + c. Return fields: > > + > > + i. count: adjusted to allocated number of buffers > > + > > + d. The driver must adjust count to minimum of required number of > > + source buffers for given format and count passed. The client > > + must check this value after the ioctl returns to get the > > + number of buffers allocated. > > + > > + .. note:: > > + > > + Passing count =3D 1 is useful for letting the driver choose > > + the minimum according to the selected format/hardware > > + requirements. > > + > > + .. note:: > > + > > + To allocate more than minimum number of buffers (for pipeline > > + depth), use G_CTRL(``V4L2_CID_MIN_BUFFERS_FOR_OUTPUT)`` to > > + get minimum number of buffers required by the driver/format, > > + and pass the obtained value plus the number of additional > > + buffers needed in count to :c:func:`VIDIOC_REQBUFS`. > > + > > +5. Begin parsing the stream for stream metadata via :c:func:`VIDIOC_S= TREAMON` on > > + OUTPUT queue. This step allows the driver to parse/decode > > + initial stream metadata until enough information to allocate > > + CAPTURE buffers is found. This is indicated by the driver by > > + sending a ``V4L2_EVENT_SOURCE_CHANGE`` event, which the client > > + must handle. > > + > > + a. Required fields: as per spec. > > + > > + b. Return values: as per spec. > > + > > + .. note:: > > + > > + Calling :c:func:`VIDIOC_REQBUFS`, :c:func:`VIDIOC_STREAMON` > > + or :c:func:`VIDIOC_G_FMT` on the CAPTURE queue at this time is = not > > + allowed and must return EINVAL. > > + > > +6. This step only applies for coded formats that contain resolution > > + information in the stream. > > maybe an example of such coded formats will be good to have. I think we should make it more like "for coded formats that the hardware is able to parse resolution information from the stream". Obviously we can still list formats, which include such information, but we should add a note saying that such capability is hardware-specific. Best regards, Tomasz