From patchwork Tue May 2 08:44:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Lin X-Patchwork-Id: 89288 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp453348vqo; Tue, 2 May 2023 01:53:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lI+4LowY50LVw0GR9TlBO2EVX7Fk+A+GIB1YHXMdyOB7E7NdkaLZhcPeJlWkPNyWZLfV0 X-Received: by 2002:a17:90a:4417:b0:24d:e923:e9f9 with SMTP id s23-20020a17090a441700b0024de923e9f9mr8311497pjg.11.1683017587814; Tue, 02 May 2023 01:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683017587; cv=none; d=google.com; s=arc-20160816; b=ymn81Y1ppdCRbftNQO3LLEpHvMjqEg7PBK44yp1WWiUq6T2Ygox0kH/UpJs4r3BPvC Q16y9DvD3o2COf96LmWk54oeOiQGooMDGqq6tfngPzBiEjoQ57ytVfiJ+Si3anHJrVHp wr3zNq9yzzCikDcARDynS7J3yHfLwfr/kbpwETCtY3cMmkvJ8Vxwz/CxXhlTD5kJI9+Q J9o1veZOtreCVYaWsS0Ld+JkczEbd18G+dhlDqrU75OASF0OS57dp9autrc/N1zV8tKY b8RGO7zgK12ceBZS6oB0HP2JvJY2l+N+xM8Fba+U0BPBmBd0PB3d/WEUtuuW69YEpMlJ S29Q== 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=n9/IAi2WKAiTTNgYoMQrx/m0c+NwYKV1J+3q3HTRy94=; b=sNWJC2J1FEwuVZpKmBTzCN3oB6GN79m2IkP9z8h3UC5JnfDVnBT4CJpS8s4sK3DfRO t2E6yu8EXIB++/HUwRBzzhL1z1FvosxC1sGdZrEBO8OE+nSzge53iaFTYIsYM5hQ92B7 pnKO6kyc6qF5v99zfYwucS3j8FOQtg1jXETZWZyl3iMeoyK/ijus90jap6hA+qsjKxL/ fnBWt2/SHdcPU7tOrp00GQxnpCB6zW0BJF/o4onnXWUX4oyUqJI3OooiOGpYJohQav8h wtADBxAyBR92GXbf9NX+Ax1jNI2lIBMoSx4RUU47ZqG+BIUGofsAU3JsE/UkaADxPQgC GfHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=p85+gzgM; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lp6-20020a17090b4a8600b002470e893981si11653610pjb.79.2023.05.02.01.52.54; Tue, 02 May 2023 01:53:07 -0700 (PDT) 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=20221208 header.b=p85+gzgM; 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 S233979AbjEBIpr (ORCPT + 99 others); Tue, 2 May 2023 04:45:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233904AbjEBIpV (ORCPT ); Tue, 2 May 2023 04:45:21 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5D175247; Tue, 2 May 2023 01:45:07 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-51fdc1a1270so2329705a12.1; Tue, 02 May 2023 01:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683017107; x=1685609107; 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=n9/IAi2WKAiTTNgYoMQrx/m0c+NwYKV1J+3q3HTRy94=; b=p85+gzgMGercUZXK5ZuVpfFOxBwxN4zPXtjWZklumaWBQN+qGjmO7jVSDwp3Qas/oh TNhnF7kKEbsaFiXwq3Q2su7mbjhQ4BqJzp87OxjW0sBUVpnWzdoRyOJAAWQiznNVF+bO ioqQaWxaw9SNW5d5qgxmSVpROTt0dnVA3A3ZEJBneOHzCufVC4FyqKidQG0S98C/bfAE i1TRXRpFB4RxVDNJO/CjU8BFzKhSssY+5TOraBkkWXM2SR8W8sI5KPm3/EdLaSA3COca CO+SspnkemgNKQzsixAg4J+cYPxSOsGiUgeQo78hxz6FJNRElgYe9z8euse/4WLe5WnH 34ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683017107; x=1685609107; 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=n9/IAi2WKAiTTNgYoMQrx/m0c+NwYKV1J+3q3HTRy94=; b=Une1ShzSCve4FqH8nF3b8uJ9lGL1mKEfp68kgQczp9uDeCeomK1pI+k/kzUWfAdE/D PqEXq+2VurZMSp6FzYxGxAXpj4AEg4zkewaIIxRkHat/0ftjPOIecw/sTke8oHAwv1BI AMJ8aJHqTnfY/od0OWk9UzEEQmpTZdIrd9/i3o+26WJfbRSxASMzwQaHgf0DKSQ+9HYW YmE07NqnSQwNqmT3QcK/GWvnpHjinJ94mCQYqb7pkU7/nMpLVd+h2I25PbcK2diNQn+W VdZ92hq1HTvITMqwJ0on5oGormGyYXTBG60fFvGaFA02eWd1NyPOeFp+Q8EyiLYO+rnw i1mg== X-Gm-Message-State: AC+VfDz2E2eT8dYouvGkhPvhCJ+rMDazyKQffEB7zeSgQskOtrwtuJ6K NPCTwyptNSHiPuYTTAdWMwM= X-Received: by 2002:a17:902:ea0f:b0:1a5:22a6:4e6a with SMTP id s15-20020a170902ea0f00b001a522a64e6amr19490224plg.51.1683017107291; Tue, 02 May 2023 01:45:07 -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 v10-20020a17090a520a00b0023fcece8067sm7059039pjh.2.2023.05.02.01.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 01:45:07 -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 v12 6/7] media: uapi: Add controls for NPCM video driver Date: Tue, 2 May 2023 16:44:29 +0800 Message-Id: <20230502084430.234182-7-milkfafa@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230502084430.234182-1-milkfafa@gmail.com> References: <20230502084430.234182-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,T_SCC_BODY_TEXT_LINE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764771850384577155?= X-GMAIL-MSGID: =?utf-8?q?1764771850384577155?= 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 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..d0d596d1fb82 --- /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, 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 +~~~~~~~~~~~~~~~~~~~~~~~~ + +After frame data is captured, if using V4L2_PIX_FMT_HEXTILE format, 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 */