From patchwork Fri Sep 22 06:24:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Lin X-Patchwork-Id: 143576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5785591vqi; Fri, 22 Sep 2023 11:26:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7ShHX2fP7jP4leitzwhxKqs2Pm76zzRNdSD07l/90G6oVyPtmPJQ2gnyR+EPFBReTR3rg X-Received: by 2002:a17:902:8e89:b0:1b9:e8a5:3699 with SMTP id bg9-20020a1709028e8900b001b9e8a53699mr242366plb.21.1695407193378; Fri, 22 Sep 2023 11:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695407193; cv=none; d=google.com; s=arc-20160816; b=OS17AKGJ5/2NfAI8V0D59UeERGFeqtazdiIa/Pi23engGpansFX6cTTcOkzzKqo+Oq BUa08PM+qhid9fWZNYhcWIza2oAmUrt7lWE3CrCbj7Jn/t3hvuQMAsthJTRB/8gRTg2J E5rALKIxxmgZo6rCQYs7Z2JfRfsUXVohEg1uo5qVzIPY1og7TkD8HvI0dkLsJOKzE6xD yk8xqX1NkI/SyFiWgE4XsdiL0lbHDh5y/f8mIhH2Y9VSFqcueKmHTfKToCHPgOcOX45t 4iItbn1hQcN/B0ns0H5ETayQw6buhlHCCt+hTWCvwCOIOdcyFVQ/gbTyyzNgnG8jRGdb ++cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tctOiThLj6Q9+Dvszb1ohC6zJEOPoGelrBq8oKS8xvw=; fh=RfSP4T/SRZN1UnzrZA8MryqWeGpAu/0o11HYNSBkyrI=; b=vVDtm2YZpKpIV/0THk5aLPPVdmBoTae9KfibzxnSJahilUbBMqWVw1z8WEEng1rZ0M nHDTj1Lxzdyw5CGUunJF/WGByPKRjDthLmeg9ZV67LW+s1XazXXGku5d/rp9VbnxY0tQ yz8YoI9pFTBDhLLCUDVlxW80tGF/PZOlhVq4zijRYt+LX7GCvSPZmRvmrsefoY//Wb+h 1CzxIrmyz6+8aGnAahFGQf9VJ+8iOqwsMy7JF0vp415EZzBgJEoxZj0n6S1bUmc05eXa qv2//TGb2UfIYVZmVA7Gr7d52eAeZd13XBu+BtMoFGpJBCga8Jku4MTEcF8pKwimEoqs GycQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TiAc4EWh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id t3-20020a170902e84300b001b8c824e826si4629776plg.533.2023.09.22.11.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 11:26:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TiAc4EWh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 7A08980622A0; Thu, 21 Sep 2023 23:25:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbjIVGZT (ORCPT + 30 others); Fri, 22 Sep 2023 02:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231542AbjIVGYq (ORCPT ); Fri, 22 Sep 2023 02:24:46 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31EB719D; Thu, 21 Sep 2023 23:24:37 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2746ab05409so1262264a91.0; Thu, 21 Sep 2023 23:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695363876; x=1695968676; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tctOiThLj6Q9+Dvszb1ohC6zJEOPoGelrBq8oKS8xvw=; b=TiAc4EWhF/lfQ5EMtevE42GUFBzil+bhtw6eBCCu+LT++MaAiRZ+XKCpyjdCgPNGmR 1EQcOhY80ayaFRFcRquIVeq7mgfvH7khegiaASkhqcofuCb0TshYe8bxm0sjeRzt0rx6 hSAjb5mdVHHKW1NwLIkN8/h1m9O7ZvhxvQg8jtk6bqNz65J1c4edE9U9lzedvRNpt5QC 2vMEn+RxXdUGLv1z/kSXzVvd0Jeiw62CGlFS950mzaCrx4PXKM3X0dgWkUNoJ1haai1u PnF4HsvSD6IkDB2tPOLe9v14SvC3fZzoX7nNtkpQGAWwwurPQNnQ6OMDSE0PaOZtIwga TJ7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695363876; x=1695968676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tctOiThLj6Q9+Dvszb1ohC6zJEOPoGelrBq8oKS8xvw=; b=iQVsxg+ChuSq1zgxBdqAGgsoLxM4BKs7Kw0NmhEmCyQTN7VaEc4USoaB33CTY0zF8l w3Qe7TM250dbrIt6l0laDzMkZP0+L74dc5tNwmQiB0M0jOrrJFjArW6b08xDNVJFSjLW Akb8R2CxgYpKfKufVPxZ75phc3HVhsSZbRARkIPuPPW/LGbkJc3JV+qvJgcPhAhpf5ly jjAKeWOUvqBCPAz89EiV1ZY4FTSNxlmJvAsKlpBmmp0eAfLbYJ8BniZ8gz0ahJ1nzRzj j+rKQz5sjC9zZUBix2Py3QWBPSsnFq8GGj8RW7kpfs0/+PeM5yiPzLaxi9QHHPv9STBQ MDnA== X-Gm-Message-State: AOJu0YyugVi97AtZDZxwZwMjNgUYxXekEUtC1qHQEbBhFkkVIEI8tB8N leFJ2N6Kmt6GBLAvegWOUMU= X-Received: by 2002:a17:90a:b901:b0:274:8be8:f767 with SMTP id p1-20020a17090ab90100b002748be8f767mr7220563pjr.15.1695363876543; Thu, 21 Sep 2023 23:24:36 -0700 (PDT) Received: from hcdev-d520mt2.. (60-250-192-107.hinet-ip.hinet.net. [60.250.192.107]) by smtp.gmail.com with ESMTPSA id m11-20020a17090ade0b00b00274de7c8aacsm4157417pjv.45.2023.09.21.23.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 23:24:36 -0700 (PDT) From: Marvin Lin To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andrzej.p@collabora.com Cc: devicetree@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, kwliu@nuvoton.com, kflin@nuvoton.com, Marvin Lin Subject: [PATCH v16 6/7] media: uapi: Add controls for NPCM video driver Date: Fri, 22 Sep 2023 14:24:04 +0800 Message-Id: <20230922062405.2571850-7-milkfafa@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922062405.2571850-1-milkfafa@gmail.com> References: <20230922062405.2571850-1-milkfafa@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 21 Sep 2023 23:25:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777763293261631983 X-GMAIL-MSGID: 1777763293261631983 Create controls for Nuvoton NPCM video driver to support setting capture mode of Video Capture/Differentiation (VCD) engine and getting the count of HEXTILE rectangles that is compressed by Encoding Compression Engine (ECE). Signed-off-by: Marvin Lin --- .../userspace-api/media/drivers/index.rst | 1 + .../media/drivers/npcm-video.rst | 66 +++++++++++++++++++ include/uapi/linux/npcm-video.h | 41 ++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 Documentation/userspace-api/media/drivers/npcm-video.rst create mode 100644 include/uapi/linux/npcm-video.h diff --git a/Documentation/userspace-api/media/drivers/index.rst b/Documentation/userspace-api/media/drivers/index.rst index 6708d649afd7..783f92f01a4c 100644 --- a/Documentation/userspace-api/media/drivers/index.rst +++ b/Documentation/userspace-api/media/drivers/index.rst @@ -37,6 +37,7 @@ For more details see the file COPYING in the source distribution of Linux. dw100 imx-uapi max2175 + npcm-video omap3isp-uapi st-vgxy61 uvcvideo diff --git a/Documentation/userspace-api/media/drivers/npcm-video.rst b/Documentation/userspace-api/media/drivers/npcm-video.rst new file mode 100644 index 000000000000..b47771dd8b27 --- /dev/null +++ b/Documentation/userspace-api/media/drivers/npcm-video.rst @@ -0,0 +1,66 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. include:: + +NPCM video driver +================= + +This driver is used to control the Video Capture/Differentiation (VCD) engine +and Encoding Compression Engine (ECE) present on Nuvoton NPCM SoCs. The VCD can +capture a frame from digital video input and compare two frames in memory, and +the ECE can compress the frame data into HEXTILE format. + +Driver-specific Controls +------------------------ + +V4L2_CID_NPCM_CAPTURE_MODE +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The VCD engine supports two modes: + +- COMPLETE mode: + + Capture the next complete frame into memory. + +- DIFF mode: + + Compare the incoming frame with the frame stored in memory, and updates the + differentiated frame in memory. + +Application can use ``V4L2_CID_NPCM_CAPTURE_MODE`` control to set the VCD mode +with different control values (enum v4l2_npcm_capture_mode): + +- ``V4L2_NPCM_CAPTURE_MODE_COMPLETE``: will set VCD to COMPLETE mode. +- ``V4L2_NPCM_CAPTURE_MODE_DIFF``: will set VCD to DIFF mode. + +V4L2_CID_NPCM_RECT_COUNT +~~~~~~~~~~~~~~~~~~~~~~~~ + +If using V4L2_PIX_FMT_HEXTILE format, VCD will capture frame data and then ECE +will compress the data into HEXTILE rectangles and store them in V4L2 video +buffer with the layout defined in Remote Framebuffer Protocol: +:: + + (RFC 6143, https://www.rfc-editor.org/rfc/rfc6143.html#section-7.6.1) + + +--------------+--------------+-------------------+ + | No. of bytes | Type [Value] | Description | + +--------------+--------------+-------------------+ + | 2 | U16 | x-position | + | 2 | U16 | y-position | + | 2 | U16 | width | + | 2 | U16 | height | + | 4 | S32 | encoding-type (5) | + +--------------+--------------+-------------------+ + | HEXTILE rectangle data | + +-------------------------------------------------+ + +Application can get the video buffer through VIDIOC_DQBUF, and followed by +calling ``V4L2_CID_NPCM_RECT_COUNT`` control to get the number of HEXTILE +rectangles in this buffer. + +References +---------- +include/uapi/linux/npcm-video.h + +**Copyright** |copy| 2022 Nuvoton Technologies diff --git a/include/uapi/linux/npcm-video.h b/include/uapi/linux/npcm-video.h new file mode 100644 index 000000000000..1d39f6f38c96 --- /dev/null +++ b/include/uapi/linux/npcm-video.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Controls header for NPCM video driver + * + * Copyright (C) 2022 Nuvoton Technologies + */ + +#ifndef _UAPI_LINUX_NPCM_VIDEO_H +#define _UAPI_LINUX_NPCM_VIDEO_H + +#include + +/* + * Check Documentation/userspace-api/media/drivers/npcm-video.rst for control + * details. + */ + +/* + * This control is meant to set the mode of NPCM Video Capture/Differentiation + * (VCD) engine. + * + * The VCD engine supports two modes: + * COMPLETE - Capture the next complete frame into memory. + * DIFF - Compare the incoming frame with the frame stored in memory, and + * updates the differentiated frame in memory. + */ +#define V4L2_CID_NPCM_CAPTURE_MODE (V4L2_CID_USER_NPCM_BASE + 0) + +enum v4l2_npcm_capture_mode { + V4L2_NPCM_CAPTURE_MODE_COMPLETE = 0, /* COMPLETE mode */ + V4L2_NPCM_CAPTURE_MODE_DIFF = 1, /* DIFF mode */ +}; + +/* + * This control is meant to get the count of compressed HEXTILE rectangles which + * is relevant to the number of differentiated frames if VCD is in DIFF mode. + * And the count will always be 1 if VCD is in COMPLETE mode. + */ +#define V4L2_CID_NPCM_RECT_COUNT (V4L2_CID_USER_NPCM_BASE + 1) + +#endif /* _UAPI_LINUX_NPCM_VIDEO_H */