Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5600081rwb; Tue, 22 Nov 2022 02:12:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf4gCuU/19VyYPwZRQfhyBK1mwWS5gQTzIWp7HIu9iXfbMdI/923ivk/LAkZsvf+avoRdI0w X-Received: by 2002:a05:6402:3203:b0:467:b8c9:a7fa with SMTP id g3-20020a056402320300b00467b8c9a7famr4637816eda.25.1669111956653; Tue, 22 Nov 2022 02:12:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669111956; cv=none; d=google.com; s=arc-20160816; b=vCA3WSQPaj2RL2X83CgK5LD9vohAC950UMVlE2aWEfzv9/IWV1iJ/Bn1D1CjAc6bwk T2dlAK+EYv7Hv5KBzVUnQzKR5SIGLRQndMflmOmTOal0ilo8s+rHZSVO4Al45Mwb8lsC 5Xg5lGIFmVqZszsgpB58qLRYcOX01DCSboQuw9WwpW/LQxNeZxyAYmqkOzQmNe7ayUK7 dshnbiRLiuDb4MUgnh+XhpUH7jxJDobOwrR6cZzQ5cy/+/cEbcp6fA1m5bYDVIINcHph L+xXy2uVPaJJtR9bdS++CAcr1UDPs9QXr2u0f9wSPlJsV5UGQqwsF6+8ocug8RYV9WWz kLww== 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=TCuoC3ZK+f0MYOxr5GQA/jhwn1vyzgSzmA1l7LzDqeI=; b=O0farVkqiBzsPDijgkDEpnRrNSedjHOBlY4+utkq7rzSzL+txB/l/canSc0c8/RyKz VdnrEJ+h6usIkInxJSSlceJ4LqjPisXCUPra0UL2aL3bJ4fNruO04j4JNIgao2bPU/qu 6lW706FsDs2AcQ7V2eQt1hxrI8xGocypi6zZ/YzHtF/oLmpgjI8M0jl9XQ0SiBcz7R04 FhCOwXgtZSMdBEWXG2/2o1PIjaokpJgNOF5+NLxbJuCFfqdigjJqW23eb1Vw1hvDB+Ik H+TYpxIFJFXxhSXKu2sckv+yFcvPL6PQUZglFcmTXludE3dtALHcWnlGtaON4Mv5Y/fk YOWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i1Hlnyrk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du5-20020a17090772c500b007ae6aa9e875si13284663ejc.370.2022.11.22.02.12.13; Tue, 22 Nov 2022 02:12:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i1Hlnyrk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233081AbiKVI6v (ORCPT + 91 others); Tue, 22 Nov 2022 03:58:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233040AbiKVI6S (ORCPT ); Tue, 22 Nov 2022 03:58:18 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D80D927B0E; Tue, 22 Nov 2022 00:58:00 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id s196so13538942pgs.3; Tue, 22 Nov 2022 00:58:00 -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=TCuoC3ZK+f0MYOxr5GQA/jhwn1vyzgSzmA1l7LzDqeI=; b=i1HlnyrkOViZAulaPPBGMoLRp+7Dw0lgicmqiuFhVVnNhqFgP4XeRa9OWEIh+SuCYV PoDOCmEbUzivp8E1PhyJxP9YtFZheI/MXk6UeZ1mkP77Za9MeEd+9BkLkLEezUCwnJ0J yEYgUOOKr/KzHOWgzvk8I+0w76IQP11j8aoVtnd57OPipXgEtzSYybZKXvoqJ7ZBWrTq DHEJUL1kin2bV0OhiyjROxBfQdUZCo1hiyJlQJDTGkET0h/zwA9KNOaEJXkHB4NcHiWI yGPJhLWNFTT+8IYnyXLr7jHzkzby5HnMIYUnAIm7AjF0NcCG5AxxEnpp/nUfl4PDMoA1 gk3g== 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=TCuoC3ZK+f0MYOxr5GQA/jhwn1vyzgSzmA1l7LzDqeI=; b=SmfCcn2+JK22rkjMu0SL8WEf4hQeAzrfd6R9A15jyryx1D864Dlsum0r64E/W607yi Zp8m3bxmsUOvyi1fOsdyDqsuAlGl+xIVofJ0b4OHn8vHZCGovsIfduZG4krCUk5UFDsZ pmV208n2rmT9KG7w4/KnEM/BqDpNtJtjFJbOJx/rF7cw9XuwtdvpwgIVhOFXxgXcWQ1C UgffILUodG7U4s95tzfLLdwz1kpAZbip/2xitrkFVXILhg6UaumO8+kGdBH2FpKo+RuB 0WVxRaq/DT4kaP9Ole+xjfKfb9GzeihRAeUNyaIjo4eBBGd78hb4G6zPZV+jtYSRsTiT DmIg== X-Gm-Message-State: ANoB5pmD86fhad33TKYH0J53aH4C+bLhxWj9cYs14NgSnNKyblE3NiV3 QgpEZDio9DWYSA5RF+edgcw= X-Received: by 2002:a62:1812:0:b0:56c:afe:e8bf with SMTP id 18-20020a621812000000b0056c0afee8bfmr3069036pfy.51.1669107480130; Tue, 22 Nov 2022 00:58:00 -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 u9-20020a17090341c900b0017a0668befasm11400246ple.124.2022.11.22.00.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 00:57:59 -0800 (PST) From: Marvin Lin To: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: openbmc@lists.ozlabs.org, avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, kwliu@nuvoton.com, kflin@nuvoton.com, Marvin Lin Subject: [PATCH v7 6/7] media: uapi: Add controls for NPCM video driver Date: Tue, 22 Nov 2022 16:57:23 +0800 Message-Id: <20221122085724.3245078-7-milkfafa@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122085724.3245078-1-milkfafa@gmail.com> References: <20221122085724.3245078-1-milkfafa@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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 | 68 +++++++++++++++++++ include/uapi/linux/npcm-video.h | 41 +++++++++++ 3 files changed, 110 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 32f82aed47d9..27ce108b15e1 100644 --- a/Documentation/userspace-api/media/drivers/index.rst +++ b/Documentation/userspace-api/media/drivers/index.rst @@ -37,5 +37,6 @@ For more details see the file COPYING in the source distribution of Linux. imx-uapi max2175 meye-uapi + npcm-video omap3isp-uapi 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..3041122fe299 --- /dev/null +++ b/Documentation/userspace-api/media/drivers/npcm-video.rst @@ -0,0 +1,68 @@ +.. 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 and differentiate video data from digital or analog sources, then the +ECE will compress the 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..6d9c77068e45 --- /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