Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp559669imm; Wed, 19 Sep 2018 03:23:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbDh8YPEmzP4iEYAzMGqFeU1prEOJi9Aqqx2+pH9Z6cB6rh4JTdhyUAf17zy6GZMGyIEqvB X-Received: by 2002:a62:c60e:: with SMTP id m14-v6mr35735847pfg.40.1537352634167; Wed, 19 Sep 2018 03:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537352634; cv=none; d=google.com; s=arc-20160816; b=bfT3NlZjr0jXbp7TRkE0bS9+D1r8aDIhr735s9KoFQwyp8Wl+9nlB1YCwN4d+wCH/4 lsl6CP0eJACeRszivgDi4PmIFaP69wMfq4OpJJ2GnRkUkSFe+imtuSvOh92tn3tmToZC kM99u2dcOAxFkXuRknMIsQTD7K9BiGSVsgbQcDviH/sU9en6vPzy91CYeGq1gzyeJLfc lunLsHD3zMz1+1Q/VH14c9C7iCBqyciu6+84rDkC1QH/cEvx1AF+ZE+v0SeXkNcPf/Wp K0c5hDVSfXR0Kl5hy5fZJZjhbafjnnAhAfaH3oxdd8G68cPgZj9hu9iW8u/pqoRhx9Pa AB2g== 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=6/ur6QXM/TIs3seyCG1eY+nt8+kQPTfObR2NvcT8GX0=; b=JfCO9CkZ+cdpBJ+UeVV5dowEm2GrrtESXsBxeygcgG39p5G1RM7Fqa+ZYIAwUlnPlc YCR3wKhYNz3j3XqAWxCxrzJ4K5pqqo6b1Tcs//fOR5IyaqbleCZZ60WuUjN/zr2GleM3 1e3oiIQAJ5buXJf13j/spwwYL0XnbPFrJKzmhtoZkcdBTfValKwVjEQcD9MCPjgNtfqD tI5yG0eHpSHeEzMSmgoH+4kJE2Am1ZMCIy6RAK3Qd4itmXKdejvJ1CylLXu0QrX5sEN6 cwjTJcbZA5/UujF6l2MsB1PbyWSsC+aoN7A3/ohyDX+xbKaLEb0yg5Ua4SQ2KWosma7Q k2HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JQc7gNu1; 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 l4-v6si2201381pgo.350.2018.09.19.03.23.37; Wed, 19 Sep 2018 03:23:54 -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=JQc7gNu1; 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 S1730984AbeISQAq (ORCPT + 99 others); Wed, 19 Sep 2018 12:00:46 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:37202 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727605AbeISQAq (ORCPT ); Wed, 19 Sep 2018 12:00:46 -0400 Received: by mail-yb1-f196.google.com with SMTP id b3-v6so1086992yba.4 for ; Wed, 19 Sep 2018 03:23:31 -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=6/ur6QXM/TIs3seyCG1eY+nt8+kQPTfObR2NvcT8GX0=; b=JQc7gNu1a/0ENCDufP+WwJ/BGc3TyL9x9Pzvruuy1fhOHKZ7ZhsNNlaz4iIPlCIRJh OH0pQ+ESh2Z8GEDv+HMm93Zn3WwrEjibv3nHZ5BpH3j+Wqj/vhc8q2nMElCo0VXltOdI bjFklaBfMDi63I0q5ZVeSSyiVKHgt2paSg1EU= 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=6/ur6QXM/TIs3seyCG1eY+nt8+kQPTfObR2NvcT8GX0=; b=s7lRhCFamRfKcnolQCp15nRby6VDeEbiZ45HcKzjVbrLtj+JuBbrAsMv9Ut3heAW+t qpGIHKuAQbsUS25r/DBW9YBYlTPNBUk3Dp17A0icgkjhruUbqU56i3uOPnbk0VTRKNfb 9jv91SfQX1u7hGqGpXCMkBVK0b9JfXGyWjvJJenPTIHIjSr0tBPGa1k8XarmrPjJaMiT 7bb8PzULNukNDPJB49RGXmRQCAamhUECBNVdEMI02DsQ2sd7Mk5V6AL4etjYdPxqvM9u 17zPoQyB6BO7ULK4STrWnfGwEb/++KLWpQOMEixZLclPYJN2QfnW9XSUSvDmOnWunHmc JIXw== X-Gm-Message-State: APzg51DhJRt/Vn3goWR9P4Ped1+dz5mC/kAAzk1AvN014kcJOuh9HL3r NTL5sJ8ZE6Wz5zWDJFyzvxd1CqWE5Rq48g== X-Received: by 2002:a5b:701:: with SMTP id g1-v6mr6879249ybq.317.1537352610622; Wed, 19 Sep 2018 03:23:30 -0700 (PDT) Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com. [209.85.219.174]) by smtp.gmail.com with ESMTPSA id o193-v6sm2054609ywd.84.2018.09.19.03.23.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 03:23:30 -0700 (PDT) Received: by mail-yb1-f174.google.com with SMTP id y20-v6so2120397ybi.13 for ; Wed, 19 Sep 2018 03:23:30 -0700 (PDT) X-Received: by 2002:a25:bb0d:: with SMTP id z13-v6mr15144321ybg.114.1537352277090; Wed, 19 Sep 2018 03:17:57 -0700 (PDT) MIME-Version: 1.0 References: <20180724140621.59624-1-tfiga@chromium.org> <20180724140621.59624-2-tfiga@chromium.org> <37a8faea-a226-2d52-36d4-f9df194623cc@xs4all.nl> In-Reply-To: From: Tomasz Figa Date: Wed, 19 Sep 2018 19:17:44 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] media: docs-rst: Document memory-to-memory video decoder interface To: Hans Verkuil Cc: Linux Media Mailing List , Linux Kernel Mailing List , Stanimir Varbanov , Mauro Carvalho Chehab , 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 , 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 Hi Hans, On Thu, Jul 26, 2018 at 7:20 PM Tomasz Figa wrote: > > Hi Hans, > > On Wed, Jul 25, 2018 at 8:59 PM Hans Verkuil wrote: > > > > Hi Tomasz, > > > > Many, many thanks for working on this! It's a great document and when d= one > > it will be very useful indeed. > > > > Review comments follow... > > Thanks for review! > > > > > On 24/07/18 16:06, Tomasz Figa wrote: [snip] > > > +13. Allocate destination (raw format) buffers via :c:func:`VIDIOC_RE= QBUFS` > > > + on the ``CAPTURE`` queue. > > > + > > > + * **Required fields:** > > > + > > > + ``count`` > > > + requested number of buffers to allocate; greater than zero > > > + > > > + ``type`` > > > + a ``V4L2_BUF_TYPE_*`` enum appropriate for ``CAPTURE`` > > > + > > > + ``memory`` > > > + follows standard semantics > > > + > > > + * **Return fields:** > > > + > > > + ``count`` > > > + adjusted to allocated number of buffers > > > + > > > + * The driver must adjust count to minimum of required number of > > > + destination buffers for given format and stream configuration = and the > > > + count passed. The client must check this value after the ioctl > > > + returns to get the number of buffers allocated. > > > + > > > + .. note:: > > > + > > > + To allocate more than minimum number of buffers (for pipeline > > > + depth), use G_CTRL(``V4L2_CID_MIN_BUFFERS_FOR_CAPTURE``) to > > > + get minimum number of buffers required, and pass the obtained= value > > > + plus the number of additional buffers needed in count to > > > + :c:func:`VIDIOC_REQBUFS`. > > > > > > I think we should mention here the option of using VIDIOC_CREATE_BUFS i= n order > > to allocate buffers larger than the current CAPTURE format in order to = accommodate > > future resolution changes. > > Ack. > I'm about to add a paragraph to describe this, but there is one detail to iron out. The VIDIOC_CREATE_BUFS ioctl accepts a v4l2_format struct. Userspace needs to fill in this struct and the specs says that "Usually this will be done using the VIDIOC_TRY_FMT or VIDIOC_G_FMT ioctls to ensure that the requested format is supported by the driver." However, in case of a decoder, those calls would fixup the format to match the currently parsed stream, which would likely resolve to the current coded resolution (~hardware alignment). How do we get a format for the desired maximum resolution? [snip]. > > > + > > > + * The driver is also allowed to and may not return all decoded = frames [snip] > > > + queued but not decode before the seek sequence was initiated.= For > > > > Very confusing sentence. I think you mean this: > > > > The driver may not return all decoded frames that where ready= for > > dequeueing from before the seek sequence was initiated. > > > > Is this really true? Once decoded frames are marked as buffer_done by t= he > > driver there is no reason for them to be removed. Or you mean something= else > > here, e.g. the frames are decoded, but the buffers not yet given back t= o vb2. > > > > Exactly "the frames are decoded, but the buffers not yet given back to > vb2", for example, if reordering takes place. However, if one stops > streaming before dequeuing all buffers, they are implicitly returned > (reset to the state after REQBUFS) and can't be dequeued anymore, so > the frames are lost, even if the driver returned them. I guess the > sentence was really unfortunate indeed. > Actually, that's not the only case. The documentation is written from userspace point of view. Queuing an OUTPUT buffer is not equivalent to having it decoded (and a CAPTURE buffer given back to vb2). If the userspace queues a buffer and then stops streaming, the buffer might have been still waiting in the queue, for decoding of previous buffers to finish. So basically by "queued frames" I meant "OUTPUT buffers queued by userspace and not sent to the hardware yet" and by "decoded frames" I meant "CAPTURE buffers containing matching frames given back to vb2". How about rewording like this: * The ``VIDIOC_STREAMOFF`` operation discards any remaining queued ``OUTPUT`` buffers, which means that not all of the ``OUTPUT`` buffe= rs queued before the seek may have matching ``CAPTURE`` buffers produce= d. For example, [...] > > > + example, given an ``OUTPUT`` queue sequence: QBUF(A), QBUF(B)= , > > > + STREAMOFF(OUT), STREAMON(OUT), QBUF(G), QBUF(H), any of the > > > + following results on the ``CAPTURE`` queue is allowed: {A=E2= =80=99, B=E2=80=99, G=E2=80=99, > > > + H=E2=80=99}, {A=E2=80=99, G=E2=80=99, H=E2=80=99}, {G=E2=80= =99, H=E2=80=99}. > > > + > > > + .. note:: > > > + > > > + To achieve instantaneous seek, the client may restart streamin= g on > > > + ``CAPTURE`` queue to discard decoded, but not yet dequeued buf= fers. Best regards, Tomasz