From patchwork Fri Oct 20 21:50:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo F. Padovan" X-Patchwork-Id: 45064 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e5fCS-0001X0-Gq; Fri, 20 Oct 2017 21:51:28 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753222AbdJTVvW (ORCPT + 1 other); Fri, 20 Oct 2017 17:51:22 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:51538 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753462AbdJTVvS (ORCPT ); Fri, 20 Oct 2017 17:51:18 -0400 Received: by mail-qk0-f195.google.com with SMTP id 17so15982123qkq.8; Fri, 20 Oct 2017 14:51:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZOOoJvSfP3l7qqv5p70yESD0KUP7idM7W5jIpvsLedY=; b=bM7K0o0609yZfuM8WhjDpTwIupaVnN6II51ecUVYwU94bG6qdGJndsdfjIB2lta5Uw sXfEOnO5X909AONK/g7Xxup/a/CfzMaeKY77Y+9YCmlJ3i0b5ljtCRdO6WqtyV+jsl5w XP84xF3x+FQgW52YW0hXGc/VHX6EoOg+8YZOo2ObPYD27gxgsbyHCZsY/OhwhlwHgBnD 48n6xlJNiEJjzv+6E5ahYop9eKfd69mqa7mwDt+EQfI2JWruaBf5EebzRMzO67p0L9Ah iYy7ylj5PKO2NbX2jOilsYNmURtXNPkrzl1EX9kpURBTo3eOwUxwO50NNMcb7uwr4cT7 j6rw== X-Gm-Message-State: AMCzsaX7a8Om4uUE6bkYRTSqFq4q8FFTzrfJf91WDK+l3GipRqogwIYP NMa/5M3JQ6AsDf288h6+ir7dUFl9 X-Google-Smtp-Source: ABhQp+Sl1Ygduj2nbq16izuPOpgB4ouYulK6ld2czb9P37jSgs3dY3sBzz8Eg/rHh7eRMgfzDNjDFw== X-Received: by 10.55.16.87 with SMTP id a84mr9725025qkh.170.1508536277121; Fri, 20 Oct 2017 14:51:17 -0700 (PDT) Received: from localhost.localdomain (189-19-125-192.dsl.telesp.net.br. [189.19.125.192]) by smtp.gmail.com with ESMTPSA id j4sm1167039qkf.75.2017.10.20.14.51.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 14:51:16 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Shuah Khan , Pawel Osciak , Alexandre Courbot , Sakari Ailus , Brian Starkey , linux-kernel@vger.kernel.org, Gustavo Padovan Subject: [RFC v4 17/17] [media] v4l: Document explicit synchronization behaviour Date: Fri, 20 Oct 2017 19:50:12 -0200 Message-Id: <20171020215012.20646-18-gustavo@padovan.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171020215012.20646-1-gustavo@padovan.org> References: <20171020215012.20646-1-gustavo@padovan.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Gustavo Padovan Add section to VIDIOC_QBUF about it v3: - make the out_fence refer to the current buffer (Hans) - Note what happens when the IN_FENCE is not set (Hans) v2: - mention that fences are files (Hans) - rework for the new API Signed-off-by: Gustavo Padovan --- Documentation/media/uapi/v4l/vidioc-qbuf.rst | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Documentation/media/uapi/v4l/vidioc-qbuf.rst b/Documentation/media/uapi/v4l/vidioc-qbuf.rst index 9e448a4aa3aa..a65a50578bad 100644 --- a/Documentation/media/uapi/v4l/vidioc-qbuf.rst +++ b/Documentation/media/uapi/v4l/vidioc-qbuf.rst @@ -118,6 +118,37 @@ immediately with an ``EAGAIN`` error code when no buffer is available. The struct :c:type:`v4l2_buffer` structure is specified in :ref:`buffer`. +Explicit Synchronization +------------------------ + +Explicit Synchronization allows us to control the synchronization of +shared buffers from userspace by passing fences to the kernel and/or +receiving them from it. Fences passed to the kernel are named in-fences and +the kernel should wait on them to signal before using the buffer, i.e., queueing +it to the driver. On the other side, the kernel can create out-fences for the +buffers it queues to the drivers. Out-fences signal when the driver is +finished with buffer, i.e., the buffer is ready. The fences are represented +as a file and passed as a file descriptor to userspace. + +The in-fences are communicated to the kernel at the ``VIDIOC_QBUF`` ioctl +using the ``V4L2_BUF_FLAG_IN_FENCE`` buffer +flags and the `fence_fd` field. If an in-fence needs to be passed to the kernel, +`fence_fd` should be set to the fence file descriptor number and the +``V4L2_BUF_FLAG_IN_FENCE`` should be set as well Setting one but not the other +will cause ``VIDIOC_QBUF`` to return with error. + +The fence_fd field (formely the reserved2 field) will be ignored if the +``V4L2_BUF_FLAG_IN_FENCE`` is not set. + +To get an out-fence back from V4L2 the ``V4L2_BUF_FLAG_OUT_FENCE`` flag should +be set to ask for a fence to be attached to the buffer. To become aware of +the out-fence created one should listen for the ``V4L2_EVENT_OUT_FENCE`` event. +An event will be triggered for every buffer queued to the V4L2 driver with the +``V4L2_BUF_FLAG_OUT_FENCE``. + +At streamoff the out-fences will either signal normally if the drivers waits +for the operations on the buffers to finish or signal with error if the +driver cancels the pending operations. Return Value ============