Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp569975imm; Wed, 6 Jun 2018 02:18:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKItxibH7gOLqhg80+N9z3mLDAlG+qxjjeClGiSEzkpNbi6lYt4ac89qV+6cDQ+3sQXZJUuP X-Received: by 2002:a17:902:bd87:: with SMTP id q7-v6mr2408206pls.147.1528276725750; Wed, 06 Jun 2018 02:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528276725; cv=none; d=google.com; s=arc-20160816; b=NA2DP1QmJPQ12Yeix7MSJw9pRlsSVBmrjRjdTN8eouQB6I/0UIKh4VXa2WkQzDVfoN Xnas8d3DbtLTnzA4WPrsB/3VuTIbf25J97PzWbqAj4su8p0AlHIv/d6MG3j96Ol4Axo9 H4LTws4FFXoeeJl+Wf6OFzBCLzaGgoF1k1JEDCEpPYN74mXC8kkYOwnOIXJNQm6XDPyU o9+enbYZleUXywZBHX/a7VtUkHbfbYiHgxvvr6o6zEwlV/YbB89hEsAgH4WFDgNN9CPn f2DSZiWcCfa3uML3eTlU9HN5yGBGu9KPT/XtLxcNOiuqjYgf6Yc5BpkUvoXou9/DhFlr bVJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=fXPj9Uo9wXEroTf02l5KXoi1kpTtlrLxD0nw5yJl6rc=; b=yQxws3lcxKEX0nXL5PWnNtVZZ74IyncSJOiMFPe0i1EauM8F06yKK7wIGsmoNgiQNO 66gW9XzzYiYooTMD5BB9uvPcw9rX/qNMm310JJTZ+MZNchU70D+Lzmjsz52iix0h8kp8 GDhIjn6w0p4zolrqt/G585fbvHry/cIJzJX0SXLWIKyDRU0TIpKeyGgPafQqpYNVY/Hk VxkO1Ka6TZya64ZH0CF6vL8eqLDRkOiPE5eXDBbbkKQJ1w7o0LkXSOl4580+priIlG3c a8JgXWeWtRm63l+VaXcrTY62ACEfocCkVSJuFggpbGmx20Q1LL/V0P40kLeiEEAgYIj6 c5AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DVhVjHAB; 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 u17-v6si4177298pgv.455.2018.06.06.02.18.31; Wed, 06 Jun 2018 02:18:45 -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=DVhVjHAB; 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 S932428AbeFFJRy (ORCPT + 99 others); Wed, 6 Jun 2018 05:17:54 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:37787 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932315AbeFFJRx (ORCPT ); Wed, 6 Jun 2018 05:17:53 -0400 Received: by mail-vk0-f68.google.com with SMTP id w8-v6so3249778vkh.4 for ; Wed, 06 Jun 2018 02:17:52 -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; bh=fXPj9Uo9wXEroTf02l5KXoi1kpTtlrLxD0nw5yJl6rc=; b=DVhVjHABV12vh6G5Vu5UHq/LKeX6ZofENpl148+9J+Q2E5Pcvo+iF3fBlo1pq1Ue+F JFPdPJkGHDVUMNQMm53icLEl8P9PUpVXr4aMzryclWNAz5HEuxGWPACB11rYm7q6qGYm Ycgloq95qmQ9ud4y+BD+f8kH2HSUcsuhzf348= 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=fXPj9Uo9wXEroTf02l5KXoi1kpTtlrLxD0nw5yJl6rc=; b=T/sImEdIVyaL3tFX+9Odko1QUjxw4di2l52odJ33RTpcvXCx5tNbb3IK0fX4ISHT7Y XIHpWup3JAQyrM64jG7kcyGeeQOkcQN/JE0D4+gciQz/A3EInSehoPRZmn4TblihRx48 C0O+Qg5DLSGGDtgwipFNbBneDOYP3TfHD2U7DGxcjDeiLIsANWnHX30OxGZzUExzz9oK 0ZIEmAAlyYM5bZW9b70z7zEhoo43qNH+NDTyC+t1RoDVdyjrcNUOgz/55n7zcnJIb4jH /GrWevsBdhn+8XhzTYEGqLx0ce8MQ7v7sKLcAL4CWslEu7PiaNYnMG3z0OFtPmn0YNIZ bUkg== X-Gm-Message-State: APt69E37QK926D+c05Ym62JHeksVjWQ2jCMWHb/3l7vDyL19eqLM8Sld ad5s+Bh0wHoXhaAOhk/aJk4f9eWkGHE= X-Received: by 2002:a1f:5244:: with SMTP id g65-v6mr1371376vkb.28.1528276672221; Wed, 06 Jun 2018 02:17:52 -0700 (PDT) Received: from mail-ua0-f174.google.com (mail-ua0-f174.google.com. [209.85.217.174]) by smtp.gmail.com with ESMTPSA id e84-v6sm4944516vke.12.2018.06.06.02.17.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 02:17:52 -0700 (PDT) Received: by mail-ua0-f174.google.com with SMTP id e8-v6so3596309uam.13 for ; Wed, 06 Jun 2018 02:17:51 -0700 (PDT) X-Received: by 2002:a9f:3dcf:: with SMTP id e15-v6mr61702uaj.73.1528276671408; Wed, 06 Jun 2018 02:17:51 -0700 (PDT) MIME-Version: 1.0 References: <20180605103328.176255-1-tfiga@chromium.org> <20180605103328.176255-3-tfiga@chromium.org> <1528199628.4074.15.camel@pengutronix.de> <1528208578.4074.19.camel@pengutronix.de> In-Reply-To: <1528208578.4074.19.camel@pengutronix.de> From: Tomasz Figa Date: Wed, 6 Jun 2018 18:17:40 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 2/2] media: docs-rst: Add encoder UAPI specification to Codec Interfaces To: Philipp Zabel Cc: Pawel Osciak , Linux Media Mailing List , Linux Kernel Mailing List , Mauro Carvalho Chehab , Hans Verkuil , Alexandre Courbot , kamil@wypas.org, a.hajda@samsung.com, Kyungmin Park , jtp.park@samsung.com, =?UTF-8?B?VGlmZmFueSBMaW4gKOael+aFp+ePiik=?= , =?UTF-8?B?QW5kcmV3LUNUIENoZW4gKOmZs+aZuui/qik=?= , Stanimir Varbanov , todor.tomov@linaro.org, nicolas@ndufresne.ca, Paul Kocialkowski , Laurent Pinchart Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 5, 2018 at 11:23 PM Philipp Zabel wrote: > > On Tue, 2018-06-05 at 21:31 +0900, Tomasz Figa wrote: > [...] > > +Initialization > > > > +-------------- > > > > + > > > > +1. (optional) Enumerate supported formats and resolutions. See > > > > + capability enumeration. > > > > + > > > > +2. Set a coded format on the CAPTURE queue via :c:func:`VIDIOC_S_FMT` > > > > + > > > > + a. Required fields: > > > > + > > > > + i. type = CAPTURE > > > > + > > > > + ii. fmt.pix_mp.pixelformat set to a coded format to be produced > > > > + > > > > + b. Return values: > > > > + > > > > + i. EINVAL: unsupported format. > > > > + > > > > + ii. Others: per spec > > > > + > > > > + c. Return fields: > > > > + > > > > + i. fmt.pix_mp.width, fmt.pix_mp.height should be 0. > > > > + > > > > + .. note:: > > > > + > > > > + After a coded format is set, the set of raw formats > > > > + supported as source on the OUTPUT queue may change. > > > > > > So setting CAPTURE potentially also changes OUTPUT format? > > > > Yes, but at this point userspace hasn't yet set the desired format. > > > > > If the encoded stream supports colorimetry information, should that > > > information be taken from the CAPTURE queue? > > > > What's colorimetry? Is it something that is included in > > v4l2_pix_format(_mplane)? Is it something that can vary between raw > > input and encoded output? > > FTR, yes, I meant the colorspace, ycbcr_enc, quantization, and xfer_func > fields of the v4l2_pix_format(_mplane) structs. GStreamer uses the term > "colorimetry" to pull these fields together into a single parameter. > > The codecs usually don't care at all about this information, except some > streams (such as h.264 in the VUI parameters section of the SPS header) > may optionally contain a representation of these fields, so it may be > desirable to let encoders write the configured colorimetry or to let > decoders return the detected colorimetry via G_FMT(CAP) after a source > change event. > > I think it could be useful to enforce the same colorimetry on CAPTURE > and OUTPUT queue if the hardware doesn't do any colorspace conversion. After thinking a bit more on this, I guess it wouldn't overly complicate things if we require that the values from OUTPUT queue are copied to CAPTURE queue, if the stream doesn't include such information or the hardware just can't parse them. Also, userspace that can't parse them wouldn't have to do anything, as the colorspace default on OUTPUT would be V4L2_COLORSPACE_DEFAULT and if hardware can't parse it either, it would just be propagated to CAPTURE. > > > > > +3. (optional) Enumerate supported OUTPUT formats (raw formats for > > > > + source) for the selected coded format via :c:func:`VIDIOC_ENUM_FMT`. > > > > + > > > > + a. Required fields: > > > > + > > > > + i. type = OUTPUT > > > > + > > > > + ii. index = per spec > > > > + > > > > + b. Return values: per spec > > > > + > > > > + c. Return fields: > > > > + > > > > + i. pixelformat: raw format supported for the coded format > > > > + currently selected on the OUTPUT queue. > > > > + > > > > +4. Set a raw format on the OUTPUT queue and visible resolution for the > > > > + source raw frames via :c:func:`VIDIOC_S_FMT` on the OUTPUT queue. > > > > > > Isn't this optional? If S_FMT(CAP) already sets OUTPUT to a valid > > > format, just G_FMT(OUT) should be valid here as well. > > > > Technically it would be valid indeed, but that would be unlikely what > > the client needs, given that it probably already has some existing raw > > frames (at certain resolution) to encode. > > Maybe add a clarifying note that G_FMT is acceptable as an alternative? > We don't have to put this front and center if it is not the expected use > case, but it would still be nice to have it documented as valid use. > > This could be part of a still ongoing negotiation process if the source > is a scaler or some frame generator that can create frames of any size. > I guess it wouldn't hurt to say so, with a clear annotation that there is no expectation that the default values are practically usable. For example the input resolution could be set to minimum supported by default. > > > > + > > > > + a. Required fields: > > > > + > > > > + i. type = OUTPUT > > > > + > > > > + ii. fmt.pix_mp.pixelformat = raw format to be used as source of > > > > + encode > > > > + > > > > + iii. fmt.pix_mp.width, fmt.pix_mp.height = input resolution > > > > + for the source raw frames > > > > > > These are specific to multiplanar drivers. The same should apply to > > > singleplanar drivers. > > > > Right. In general I'd be interested in getting some suggestions in how > > to write this kind of descriptions nicely and consistent with other > > kernel documentation. > > Maybe just: > > a. Required fields: > > i. type = OUTPUT or OUTPUT_MPLANE > > ii. fmt.pix.pixelformat or fmt.pix_mp.pixelformat = ... > > iii. fmt.pix.width, fmt.pix_mp.height or fmt.pix_mp.width, > fmt.pix_mp.height = ... > Ack. > > [...] > > > > +7. Begin streaming on both OUTPUT and CAPTURE queues via > > > > + :c:func:`VIDIOC_STREAMON`. This may be performed in any order. > > > > > > Actual encoding starts once both queues are streaming > > > > I think that's the only thing possible with vb2, since it gives > > buffers to the driver when streaming starts on given queue. > > > > > and stops as soon > > > as the first queue receives STREAMOFF? > > > > Given that STREAMOFF is supposed to drop all the buffers from the > > queue, it should be so +/- finishing what's already queued to the > > hardware, if it cannot be cancelled. > > Oh, right. > > > I guess we should say this more explicitly. > > > [...] > > > > +Encoding parameter changes > > > > +-------------------------- > > > > + > > > > +The client is allowed to use :c:func:`VIDIOC_S_CTRL` to change encoder > > > > +parameters at any time. The driver must apply the new setting starting > > > > +at the next frame queued to it. > > > > + > > > > +This specifically means that if the driver maintains a queue of buffers > > > > +to be encoded and at the time of the call to :c:func:`VIDIOC_S_CTRL` not all the > > > > +buffers in the queue are processed yet, the driver must not apply the > > > > +change immediately, but schedule it for when the next buffer queued > > > > +after the :c:func:`VIDIOC_S_CTRL` starts being processed. > > > > > > Does this mean that hardware that doesn't support changing parameters at > > > runtime at all must stop streaming and restart streaming internally with > > > every parameter change? Or is it acceptable to not allow the controls to > > > be changed during streaming? > > > > That's a good question. I'd be leaning towards the latter (not allow), > > as to keep kernel code simple, but maybe we could have others > > (especially Pawel) comment on this. > > Same here. Same as where? :) > > [...] > > > > +2. Enumerating formats on OUTPUT queue must only return OUTPUT formats > > > > + supported for the CAPTURE format currently set. > > > > + > > > > +3. Setting/changing format on OUTPUT queue does not change formats > > > > + available on CAPTURE queue. An attempt to set OUTPUT format that > > > > + is not supported for the currently selected CAPTURE format must > > > > + result in an error (-EINVAL) from :c:func:`VIDIOC_S_FMT`. > > > > > > Same as for decoding, is this limited to pixel format? Why isn't the > > > pixel format corrected to a supported choice? What about > > > width/height/colorimetry? > > > > Width/height/colorimetry(Do you mean color space?) is a part of > > v4l2_pix_format(_mplane). I believe that's what this point was about. > > Yes. My question was more about whether this should return -EINVAL or > whether TRY_FMT/S_FMT should change the parameters to valid values. As per the standard semantics of TRY_/S_FMT, they should adjust the format on given queue. We only require that the state on other queue is left intact. Best regards, Tomasz