Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 817CEC636CD for ; Tue, 7 Feb 2023 09:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231680AbjBGJVA (ORCPT ); Tue, 7 Feb 2023 04:21:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbjBGJUc (ORCPT ); Tue, 7 Feb 2023 04:20:32 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ECC338008; Tue, 7 Feb 2023 01:20:26 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id i2so1612146ple.13; Tue, 07 Feb 2023 01:20:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=kxcVf6sF5TMM3edA3aqu6HUdTIeyZS9p9GitxQ6INxk=; b=j+8QHMyXygNEk+dUkmBIrDzrv7GzWhHTpTFLi236LYzzpD+/xxVFyZCzX1tzIVMDOd MwLpCuXGz/kWLQTpgXi3GLdW8ukW8is6b3TPLLwjNfdjn8nzulEFv7x+Cx5yvebiXkHm sl2NpmZpKOroLdgDBtkJipPpf0xCcngLR/L8KfaEe3xDC7U1EOT+SIbWUDO652BuYFlO fcC0csTLVw790Zc5mhRpYqB5yLncsEIxc90X5lR9j/cJs4tgchpNjhze4WQAAcC3Rm0K KQgX5Nms+ey75OZNr34/4mTmT9fGsli5EzJJSeOgOwTcAhrDcKoh7baWBQRzVJDlfIvh qYMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=kxcVf6sF5TMM3edA3aqu6HUdTIeyZS9p9GitxQ6INxk=; b=OK5PNhnnXkbRf0Wrdfap/DbhbbFwji3beX6HEYUnZs1ZV7BWD5H3tBI0crkcMepQOd Zq1pbQXzmQMOOUjxZobqMxvQVFgrkAyTyhmDMtYrfhzvsuaxc/t/XaA2fAcw8D7vURH8 vyPW1bkLRjo54SjeDwk1Ajdl3/YBfZrUpFrzv5lkhrCwgFqgNVCD2NKFXdGyoNLsAkon dgGzxQ5VCNIkLUEmy5/Yp7LFIeRCwSQ7mR84jomSwlOmnRNx/w+qFV1jO/L2sRhH3DzS YfO58Et7MVeMeA+/KVrsVeJBaqsUkmctGbx4frlbV/VBp6wksFc2FvYG/L7GjLTo9mm8 7jGw== X-Gm-Message-State: AO0yUKUx1WTlwyTpcuWNpQ74sNG86XAB+BMAdergrBAhrGqxURP1Z48B 5XFCZVuQ5ik9pA5dmpm+tdw= X-Google-Smtp-Source: AK7set+jet0Ea5EedOCG+VvUsnC1yDffVh2hvzPbVeyKAEAVX9NmbqPVUZ+Bcn/8AEexY5SgDFZbBw== X-Received: by 2002:a17:903:11cf:b0:196:8d33:f083 with SMTP id q15-20020a17090311cf00b001968d33f083mr2689714plh.28.1675761625911; Tue, 07 Feb 2023 01:20:25 -0800 (PST) Received: from hcdev-d520mt2.. (60-250-192-107.hinet-ip.hinet.net. [60.250.192.107]) by smtp.gmail.com with ESMTPSA id io20-20020a17090312d400b0019934030f46sm545327plb.132.2023.02.07.01.20.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 01:20:25 -0800 (PST) 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 v11 6/7] media: uapi: Add controls for NPCM video driver Date: Tue, 7 Feb 2023 17:19:01 +0800 Message-Id: <20230207091902.2512905-7-milkfafa@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207091902.2512905-1-milkfafa@gmail.com> References: <20230207091902.2512905-1-milkfafa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 67 +++++++++++++++++++ include/uapi/linux/npcm-video.h | 41 ++++++++++++ 3 files changed, 109 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 915dbf0f4db5..97d2ce8da6b3 100644 --- a/Documentation/userspace-api/media/drivers/index.rst +++ b/Documentation/userspace-api/media/drivers/index.rst @@ -38,6 +38,7 @@ For more details see the file COPYING in the source distribution of Linux. imx-uapi max2175 meye-uapi + 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..eccbba0d7351 --- /dev/null +++ b/Documentation/userspace-api/media/drivers/npcm-video.rst @@ -0,0 +1,67 @@ +.. 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, then +the ECE will 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 +~~~~~~~~~~~~~~~~~~~~~~~~ + +After frame data is captured, the ECE will compress the data into HEXTILE format +and store these HEXTILE rectangles data 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 these video buffers through V4L2 interfaces and use +``V4L2_CID_NPCM_RECT_COUNT`` control to get the count of compressed HEXTILE +rectangles that can be put in the field number-of-rectangles of +FramebufferUpdate header. + +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 */ -- 2.34.1