Received: by 10.223.176.5 with SMTP id f5csp3916043wra; Mon, 29 Jan 2018 22:33:06 -0800 (PST) X-Google-Smtp-Source: AH8x2275GLgCzYJEIBydPXkWPhwfIKzeMOkIeECuXdQ7IOCILCtawC5Cxk/a01qdNDnZhMLtyQfO X-Received: by 2002:a17:902:6908:: with SMTP id j8-v6mr24047112plk.211.1517293986084; Mon, 29 Jan 2018 22:33:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517293986; cv=none; d=google.com; s=arc-20160816; b=zVQFW5ggecpN4nDLpldT+QWLL9aEafZIaIYZBX8yHJHq0a46+U45vyYxo/6xxMfF4k TV9FkjBRGWxNU4xUaJn3JoGtdvBzLhkzDErD/5tvUCs7BeFkfT+MIekYkiAWsgpJRidt U8IOIRrtifmmMrEwsznrRcDSHbJ+oOcHSHmqX+n99yzYBoF1qNHuGEKD3x4mUCgYkC09 QNxT/3fSW/wwVIR8PXHuc7ZTm0TJ6Pwcw/sh7U/xaAIcQRVr9Ul8dlKg33ovhm8P9afx XQKMPfXh0dbFK0ftOVk+Bw2A8iZurSEo0EGS9nuplL+HCOGUtJO+pj+8dUkyQDtoCSvL Gpkg== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=8zY0Rg2bk+YtusKm/68yt4/hYsgN5fL0QJQ1WkzQEuE=; b=LAj5CB2OXdIA4stJ9oPnqL4OASNH8PGu043R4lyBcZFytD/A9eb+ZLxzZE9LoD5N2o rE3Trib+lXtGqHbZDoeqlh4yv3nQUShTl5dEx2fc2SjPWPk0upLAcT6Dv2e7NMmu9Ikv SvOvdRenZpFmDj0Apyqv3b/w+OfYzD0hyPJeNM/jzkPV3bIlJzvguniOC+j+BvwYOtMS njoh2TJMzsPTj6e+uw68fc7GaBHVzkp0CZYwf0EaHTdL+hFgtFYJZ9o6CvDFWxFzAnFU Q1sKxreCfe+Snw9X1cbJDbx+y0FUkJDkKVEJV0anNt67DyhzTL+5+JRdEkh7/xGulv+Z w6ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=J0Phv3Lm; 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 m67si850748pfa.283.2018.01.29.22.32.51; Mon, 29 Jan 2018 22:33:06 -0800 (PST) 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=J0Phv3Lm; 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 S1752910AbeA3GcQ (ORCPT + 99 others); Tue, 30 Jan 2018 01:32:16 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:46307 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752845AbeA3Gb4 (ORCPT ); Tue, 30 Jan 2018 01:31:56 -0500 Received: by mail-io0-f193.google.com with SMTP id f34so10241296ioi.13 for ; Mon, 29 Jan 2018 22:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=8zY0Rg2bk+YtusKm/68yt4/hYsgN5fL0QJQ1WkzQEuE=; b=J0Phv3Lm6C6JRe/AMi7Mw2eAkSAweuUXlas1Z3Zd+zUpaQPukSHXmlUaSjt3rmbKlB l+whlC5N6dCRl9CeNmpRFBET+j7WjNpDWlenwDTUkleNx4ICxVdBTR2cVeQuZfZ6t2xX C3HV2we9GoG4qGLCu0MTNIsz7dhCiuuhRNAp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=8zY0Rg2bk+YtusKm/68yt4/hYsgN5fL0QJQ1WkzQEuE=; b=HTZT5dyKV2szzB59dc7+r69BWi/Fkt9z8iSwimRRrJ1Dr06GxoQFHsYqhEvscOKcVU UF6Y5cikESJitXB1RP/3VTJ94oEdhzpCEr1/l9AOtSGV8s9HpGva2Ff2Vr3by8Hzqx6g /PsmywhZeqKXiRlAGWt3gXcoLUwh21ropn4fBlXal4KnFy0vq+A7P2266HOPUo/xLHUe TGKdl511W2hOKZtsL+Uk9Dpv50Ef4jzJIHTlJzbPjKiaSwFPZWjiT9uB86VZ1OIooTO9 2VRDHn2ssRCXSw3ox97PAMJctUVoGczXeSGzElIdsT595xJzK8JdBjNhhGKS8VSyrbHd ZUtA== X-Gm-Message-State: AKwxytftJyVl85hq/kEIIaNDAHPUtZo8V7MdXKA8oFJEk5B8ovI4p0yf 0cNEXwCzub6IZF6Dxb7O0KhYGz4Zskw= X-Received: by 10.107.182.67 with SMTP id g64mr22657498iof.150.1517293914842; Mon, 29 Jan 2018 22:31:54 -0800 (PST) Received: from mail-io0-f169.google.com (mail-io0-f169.google.com. [209.85.223.169]) by smtp.gmail.com with ESMTPSA id i83sm5242633iod.82.2018.01.29.22.31.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jan 2018 22:31:54 -0800 (PST) Received: by mail-io0-f169.google.com with SMTP id m11so10252757iob.2 for ; Mon, 29 Jan 2018 22:31:53 -0800 (PST) X-Received: by 10.107.180.70 with SMTP id d67mr30393599iof.73.1517293913500; Mon, 29 Jan 2018 22:31:53 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.241.9 with HTTP; Mon, 29 Jan 2018 22:31:33 -0800 (PST) In-Reply-To: <1f5dba55-fee6-a368-0dcb-b32760cf693a@xs4all.nl> References: <20180126060216.147918-1-acourbot@chromium.org> <20180126060216.147918-6-acourbot@chromium.org> <1f5dba55-fee6-a368-0dcb-b32760cf693a@xs4all.nl> From: Alexandre Courbot Date: Tue, 30 Jan 2018 15:31:33 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 5/8] media: Document the media request API To: Hans Verkuil Cc: Mauro Carvalho Chehab , Laurent Pinchart , Pawel Osciak , Marek Szyprowski , Tomasz Figa , Sakari Ailus , Gustavo Padovan , Linux Media Mailing List , linux-kernel@vger.kernel.org, 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, Jan 30, 2018 at 1:04 AM, Hans Verkuil wrote: > On 01/26/2018 07:02 AM, Alexandre Courbot wrote: >> From: Laurent Pinchart >> >> The media request API is made of a new ioctl to implement request >> management. Document it. >> >> Signed-off-by: Laurent Pinchart >> [acourbot@chromium.org: adapt for newest API] >> Signed-off-by: Alexandre Courbot >> --- >> Documentation/media/uapi/mediactl/media-funcs.rst | 1 + >> .../media/uapi/mediactl/media-ioc-request-cmd.rst | 140 +++++++++++++++++++++ >> 2 files changed, 141 insertions(+) >> create mode 100644 Documentation/media/uapi/mediactl/media-ioc-request-cmd.rst >> >> diff --git a/Documentation/media/uapi/mediactl/media-funcs.rst b/Documentation/media/uapi/mediactl/media-funcs.rst >> index 076856501cdb..e3a45d82ffcb 100644 >> --- a/Documentation/media/uapi/mediactl/media-funcs.rst >> +++ b/Documentation/media/uapi/mediactl/media-funcs.rst >> @@ -15,4 +15,5 @@ Function Reference >> media-ioc-g-topology >> media-ioc-enum-entities >> media-ioc-enum-links >> + media-ioc-request-cmd >> media-ioc-setup-link >> diff --git a/Documentation/media/uapi/mediactl/media-ioc-request-cmd.rst b/Documentation/media/uapi/mediactl/media-ioc-request-cmd.rst >> new file mode 100644 >> index 000000000000..17223e8170e9 >> --- /dev/null >> +++ b/Documentation/media/uapi/mediactl/media-ioc-request-cmd.rst >> @@ -0,0 +1,140 @@ >> +.. -*- coding: utf-8; mode: rst -*- >> + >> +.. _media_ioc_request_cmd: >> + >> +*************************** >> +ioctl MEDIA_IOC_REQUEST_CMD >> +*************************** >> + >> +Name >> +==== >> + >> +MEDIA_IOC_REQUEST_CMD - Manage media device requests >> + >> + >> +Synopsis >> +======== >> + >> +.. c:function:: int ioctl( int fd, MEDIA_IOC_REQUEST_CMD, struct media_request_cmd *argp ) >> + :name: MEDIA_IOC_REQUEST_CMD >> + >> + >> +Arguments >> +========= >> + >> +``fd`` >> + File descriptor returned by :ref:`open() `. >> + >> +``argp`` >> + >> + >> +Description >> +=========== >> + >> +The MEDIA_IOC_REQUEST_CMD ioctl allow applications to manage media device >> +requests. A request is an object that can group media device configuration >> +parameters, including subsystem-specific parameters, in order to apply all the >> +parameters atomically. Applications are responsible for allocating and >> +deleting requests, filling them with configuration parameters submitting them. >> + >> +Request operations are performed by calling the MEDIA_IOC_REQUEST_CMD ioctl >> +with a pointer to a struct :c:type:`media_request_cmd` with the cmd field set >> +to the appropriate command. :ref:`media-request-command` lists the commands >> +supported by the ioctl. >> + >> +The struct :c:type:`media_request_cmd` request field contains the file >> +descriptorof the request on which the command operates. For the >> +``MEDIA_REQ_CMD_ALLOC`` command the field is set to zero by applications and >> +filled by the driver. For all other commands the field is set by applications >> +and left untouched by the driver. >> + >> +To allocate a new request applications use the ``MEDIA_REQ_CMD_ALLOC`` >> +command. The driver will allocate a new request and return its ID in the > > ID -> FD Indeed, this is a leftover from the original documentation. > >> +request field. >> + >> +Requests are reference-counted. A newly allocated request is referenced >> +by the returned file descriptor, and can be later referenced by >> +subsystem-specific operations. Requests will thus be automatically deleted >> +when they're not longer used after the returned file descriptor is closed. >> + >> +If a request isn't needed applications can delete it by calling ``close()`` >> +on it. The driver will drop the file handle reference. The request will not >> +be usable through the MEDIA_IOC_REQUEST_CMD ioctl anymore, but will only be >> +deleted when the last reference is released. If no other reference exists when >> +``close()`` is invoked the request will be deleted immediately. >> + >> +After creating a request applications should fill it with configuration >> +parameters. This is performed through subsystem-specific request APIs outside >> +the scope of the media controller API. See the appropriate subsystem APIs for >> +more information, including how they interact with the MEDIA_IOC_REQUEST_CMD >> +ioctl. >> + >> +Once a request contains all the desired configuration parameters it can be >> +submitted using the ``MEDIA_REQ_CMD_SUBMIT`` command. This will let the >> +buffers queued for the request be passed to their respective drivers, which >> +will then apply the request's parameters before processing them. >> + >> +Once a request has been queued applications are not allowed to modify its >> +configuration parameters until the request has been fully processed. Any >> +attempt to do so will result in the related subsystem API returning an error. >> +The application that submitted the request can wait for its completion by >> +polling on the request's file descriptor. >> + >> +Once a request has completed, it can be reused. The ``MEDIA_REQ_CMD_REINIT`` >> +command will bring it back to its initial state, so it can be prepared and >> +submitted again. >> + >> +.. c:type:: media_request_cmd >> + >> +.. flat-table:: struct media_request_cmd >> + :header-rows: 0 >> + :stub-columns: 0 >> + :widths: 1 2 8 >> + >> + * - __u32 >> + - ``cmd`` >> + - Command, set by the application. See below for the list of supported >> + commands. >> + * - __u32 >> + - ``fd`` >> + - Request FD, set by the driver for the MEDIA_REQ_CMD_ALLOC command and >> + by the application for all other commands. >> + >> + >> +.. _media-request-command: >> + >> +.. cssclass:: longtable >> + >> +.. flat-table:: Media request commands >> + :header-rows: 0 >> + :stub-columns: 0 >> + >> + * .. _MEDIA-REQ-CMD-ALLOC: >> + >> + - ``MEDIA_REQ_CMD_ALLOC`` >> + - Allocate a new request. >> + * .. _MEDIA-REQ-CMD-SUBMIT: >> + >> + - ``MEDIA_REQ_CMD_SUBMIT`` >> + - Submit a request to be processed. >> + * .. _MEDIA-REQ-CMD-QUEUE: >> + >> + - ``MEDIA_REQ_CMD_REINIT`` >> + - Reinitializes a completed request. >> + >> + >> +Return Value >> +============ >> + >> +On success 0 is returned, on error -1 and the ``errno`` variable is set >> +appropriately. The generic error codes are described at the >> +:ref:`Generic Error Codes ` chapter. >> + >> +EINVAL >> + The struct :c:type:`media_request_cmd` specifies an invalid command or >> + references a non-existing request. >> + >> +ENOSYS >> + The struct :c:type:`media_request_cmd` specifies the >> + ``MEDIA_REQ_CMD_QUEUE`` or ``MEDIA_REQ_CMD_APPLY`` command and that > > MEDIA_REQ_CMD_APPLY isn't defined in the table above. Same. :) > >> + command isn't implemented by the device. >> > > > So what is missing from this documentation is whether a newly created request > has a copy of the current state or if it is empty. And didn't we allow a > request to be based on an other existing request? Unfortunately I have no > time to dig up that information at the moment. Will specify the behavior better. > > More comments in my review for 6/8. Probably best to read that review > first before this one. > > Regards, > > Hans