Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1886831imm; Thu, 14 Jun 2018 05:35:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKImE9cxkP3lPTWExTboif9ETCvl2wZ+bETmplH2TKIzLqtnLh9OHrakfuGVTJul6fb0L/qT X-Received: by 2002:a17:902:654c:: with SMTP id d12-v6mr2863983pln.8.1528979732802; Thu, 14 Jun 2018 05:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528979732; cv=none; d=google.com; s=arc-20160816; b=UZKybD4tDSTEyWKXKwsAzVO3vqkW1Qijt+oQeZhUO58XBh1AvIrJGSAazDxVXErcjg yL7lqIX6/sDP34lcp/yOwXRdq7dOq3aDecmI8haBgcZ/Qqori4ttdbu0C/cBNXUdP8K1 3uMVGBow70yQsleKExWS+qmbTWxUUpaq60seTihuBmCrG/aIhJnSIahg9GJ3apOblcKc oSBS/c7kpQVLlTIoxmK4RA4jstuwS5n4PHvco8H8Y0dhMvaPGUn5hOIvqsFwABHCVBL3 pr5dgjeiQEAwPCpOIcBa8OhAw5d1J0TU905m0lkRFEgjPeuauvvQZAkpV0/8w4V3K68i 3kvg== 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:dkim-signature :arc-authentication-results; bh=lRZKEBj/b3UzaHiW4SwtHDCZmimCS2t4/Iwzkuftkjs=; b=FR8iwzDt99/hCBduPKCGB9goL7nY9VxRgS70guJvc2xHEo3lN3TYUbpWxydrZm7OyM JkyrZ9WgHU47Fniz6qyNCtLYgjed1iWSn7KZ9kQsvqXljOTZES0pZ/OqbsZdG2OvfHdc v7dXThv2xI9DNrV/oext6TPYwIfqOnG8DKt5dWSzFJ8g2GO3jvT8eAgOFlZLJnChtQCX n7sCfYx98jHpTIG9erdJKECWENPH+mCR/JUtZoVBzDVJ1IEAe4weL3OXta2dmVXrng/e Engq+CdeMxkjUdztr1nzR12bnfKoZuo5D060BBv2Snl0uThATMAHkpoT470kXNliBWQe XyDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FZcC+Pil; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g67-v6si5712785plb.73.2018.06.14.05.35.18; Thu, 14 Jun 2018 05:35:32 -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=@linaro.org header.s=google header.b=FZcC+Pil; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755206AbeFNMef (ORCPT + 99 others); Thu, 14 Jun 2018 08:34:35 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:44688 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754927AbeFNMed (ORCPT ); Thu, 14 Jun 2018 08:34:33 -0400 Received: by mail-wr0-f193.google.com with SMTP id x4-v6so6246323wro.11 for ; Thu, 14 Jun 2018 05:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lRZKEBj/b3UzaHiW4SwtHDCZmimCS2t4/Iwzkuftkjs=; b=FZcC+PilopOnZlLh49TCoavyMqyQU6Ph28ZNO0GLF/xelct4CBwQSBG03/4F2BjbcA hkDUfp6/GyvhdLVhBSS9P3PctPaxxMmNZa/YqJJloRP5U9Avr0RlR9emh13eIs50jeX6 L9iZoUFEpdTU61cq5Ye/94rPPGZt6yxX3lxvI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lRZKEBj/b3UzaHiW4SwtHDCZmimCS2t4/Iwzkuftkjs=; b=cMQqkiUNufkyEU/6hrMZy23y4EQDwt2wJCAmt7hd8BK2CXmqTqd2eq11V00PAbXHtd Dux4U6jbvPa4xCXpv3nrd0BGFrgNKLFn+8Ite7kjFWNp9jOTz2aVXsJu95xNAQAteaIF cliCePVqYwOwGpsNslRgxDjomO+3ysAreaUC7iQm63RFomNHvf7QnzjUWK0/lG2FdwYO KiuHQUaWYYNj7IfqgWwoDBB6BAbFmgsSJwlQHKzp0Xhp0HM5Na44q096BO2n3X2htLTf 9gEWEHylWhNmFA+07t9BCk8QQjgLQijk9HoDy8relg4gTmvA26JzgwInDa185zhALQs1 Yiqw== X-Gm-Message-State: APt69E2Cw+a70eMbzhN2Cs3OU677OUUKk73+kxDraCpb0z5mRo3d5YRo zQHsL0uK1wazeY2qvYg+3wB0ag== X-Received: by 2002:adf:982d:: with SMTP id v42-v6mr2194736wrb.93.1528979671975; Thu, 14 Jun 2018 05:34:31 -0700 (PDT) Received: from [192.168.27.209] ([37.157.136.206]) by smtp.googlemail.com with ESMTPSA id k16-v6sm6317803wrh.25.2018.06.14.05.34.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 05:34:31 -0700 (PDT) Subject: Re: [RFC PATCH 1/2] media: docs-rst: Add decoder UAPI specification to Codec Interfaces To: Tomasz Figa , linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Hans Verkuil , =?UTF-8?B?UGF3ZcWCIE/Fm2NpYWs=?= , Alexandre Courbot , Kamil Debski , Andrzej Hajda , Kyungmin Park , Jeongtae Park , Philipp Zabel , Tiffany Lin , Andrew-CT Chen , Todor Tomov , Nicolas Dufresne , Paul Kocialkowski , Laurent Pinchart References: <20180605103328.176255-1-tfiga@chromium.org> <20180605103328.176255-2-tfiga@chromium.org> From: Stanimir Varbanov Message-ID: <89dca3ae-cbbc-4b5b-1c8a-207951997839@linaro.org> Date: Thu, 14 Jun 2018 15:34:27 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180605103328.176255-2-tfiga@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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üsseldorf. The de facto Codec API that > originated at those events was later implemented by the drivers we already > 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 = 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 != 0 and height != 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. > + > + 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 use > + more buffers than minimum required by hardware/format (see > + allocation). > + > + a. Required fields: > + > + i. id = ``V4L2_CID_MIN_BUFFERS_FOR_OUTPUT`` > + > + b. Return values: per spec. > + > + c. Return fields: > + > + i. value: required number of OUTPUT buffers for the currently set > + format; > + > +4. Allocate source (bitstream) buffers via :c:func:`VIDIOC_REQBUFS` on OUTPUT > + queue. > + > + a. Required fields: > + > + i. count = n, where n > 0. > + > + ii. type = OUTPUT > + > + iii. memory = 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 = 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_STREAMON` 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. > + Continue queuing/dequeuing bitstream buffers to/from the > + OUTPUT queue via :c:func:`VIDIOC_QBUF` and :c:func:`VIDIOC_DQBUF`. The driver > + must keep processing and returning each buffer to the client > + until required metadata to send a ``V4L2_EVENT_SOURCE_CHANGE`` > + for source change type ``V4L2_EVENT_SRC_CH_RESOLUTION`` is > + found. There is no requirement to pass enough data for this to > + occur in the first buffer and the driver must be able to > + process any number > + > + a. Required fields: as per spec. > + > + b. Return values: as per spec. > + > + c. If data in a buffer that triggers the event is required to decode > + the first frame, the driver must not return it to the client, > + but must retain it for further decoding. > + > + d. Until the resolution source event is sent to the client, calling > + :c:func:`VIDIOC_G_FMT` on the CAPTURE queue must return -EINVAL. > + > + .. note:: > + > + No decoded frames are produced during this phase. > + -- regards, Stan