From patchwork Tue Dec 27 09:51:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Lin X-Patchwork-Id: 36804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1311843wrt; Tue, 27 Dec 2022 01:54:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9htVXIk5J4vV8DZRhYHc3iu4LDmAlSC923ujYP5ULXwxPhaCEPr3zwCjTXg2fvfl6JEen X-Received: by 2002:a17:903:3111:b0:192:5c3e:894e with SMTP id w17-20020a170903311100b001925c3e894emr13370252plc.16.1672134893517; Tue, 27 Dec 2022 01:54:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672134893; cv=none; d=google.com; s=arc-20160816; b=YoZhfnO3Tu20XKBqfapEvDrs/Neo4EDuzkVPZICiBsR1HxkIk3bDSnt0j92vv6mblX uv66xmR2sRwR3jIfJR84xRchC3os3oLExjMsOHpnmKciy2whR6LfUe3PWwJA2tgDc+rn cgElTIaOT96S0/Z/RNGFupzdGVEkcxbkXks/mapsrnSoJMPIybgm5jx8i9gObyk+xXSq GOySB9lsEmTfAHcu2GuZeY2FdyzzCHywUMwCQPw6nt+8NWD7pi0ghW3EmIvY19Z3BR0o lEe0L4zgHCfTjd0ZDbzWCd8/sRkj5OVPIfyflFGQM8SyM4gOPVvw5rsppHUeQd2pggYH SLCQ== 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=i3swy6qz7DvZvAluAP+tU7pAgPPOXXX+hPPdHMPIYTg=; b=mSgnIB/XSxyolP8Yk+Xby3SAkO+Vq9jkI4W/+UpZMm1JwUR/t5NjLt+ds79HRQUfH9 3uExvx3C5aSmH9N0lGLETyBrx9Xs2xSJxQh41fYC8142zdvqqcmAl4yHq4FOGfXFrbbZ rRH3aPP8P5voik44smLIu1Kd3v9DOzLacktQFUDXdAwxNOaJLG7pDosbBJMArIeIPZUt AtYcYXxxQ18CVd0coA2GYw8q5fVP6hAlEn+aawr6HXEtH4VAKV5DW2FRGLxJwO694cjw RoGODTEzcQM0XlFLJiFNoTifYAK+pPOk9GCVDWnWkQs4EKTa1Ru2e3mcqECHWUfOAivb lyxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aErG3oRj; 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 p9-20020a1709026b8900b001898ecbeef8si12942796plk.9.2022.12.27.01.54.41; Tue, 27 Dec 2022 01:54:53 -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=aErG3oRj; 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 S231394AbiL0Jwx (ORCPT + 99 others); Tue, 27 Dec 2022 04:52:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231379AbiL0JwV (ORCPT ); Tue, 27 Dec 2022 04:52:21 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F11009FE4; Tue, 27 Dec 2022 01:52:09 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so12750212pjj.4; Tue, 27 Dec 2022 01:52:09 -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=i3swy6qz7DvZvAluAP+tU7pAgPPOXXX+hPPdHMPIYTg=; b=aErG3oRj5SOjAyxRD7qJEBvDmQmn5AduZi0hquXRdjZUkBSY+3fQ3YIjpQ0KOZLVX4 nEDFnRuZfisOyvzMoiuzRECUUmBR3vp2i4R2S58ToC5Tke81T15KnatG8sK1EKYLqWQ4 MB057VrMRSgdBUvxLtYdTMWFDpGis9y2h79A8TyG/LX69GUNV8bbY0Tr0XSn0hHjdO8R oA5XNuRDiUQkgmPiKtrBhPGoxc0eqehD6tup+/zAbWYe1KeDjGoRbJLUp1XPhyFGxgiZ PHxxB/0A9QeFtmm5uHigetzcYtpij1XLju28ddkHXE8uUlIKbn/6NHOdJr+Is9Yti9hN oLJg== 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=i3swy6qz7DvZvAluAP+tU7pAgPPOXXX+hPPdHMPIYTg=; b=p6IDTqzi+ekPdiQz03UjpnxkuiyWRuguw9H6UPCyvvlUVvavwEzQZudV+IaXBrXcp1 pqIrou69VXfJrXQqnWeXRCDYIPi4httwOMQn5GHsvdb8tvYAa8CowJUt4w2r27cDjyny bYTQOCJLBhkcP75vw9VCNRtHPj7+D/u3lq+AInrVtCFl0/CZE+nSb9m9R82Y2BOvh2fF ZQzVLTrCVtdS3kqwYdVmIokqBOFxQ8pGuvMkmHvURRWgXLXttumQPfInlaZbXUXMxPI0 VVUxSJV2babOaICw3EEAJ2o1Ln4qAHprLE346ciAEHa4aT9ssbQYbQZuH0gOuxEBebRT uUYA== X-Gm-Message-State: AFqh2kq4KGma4QRwNdC9d02QbhbIdZ3KXRT7ClVKOu7L2ktO2noTO6AW /UPxkEYLxM09+VTlyrVbrCM= X-Received: by 2002:a05:6a20:e616:b0:a6:7529:7c99 with SMTP id my22-20020a056a20e61600b000a675297c99mr25819590pzb.5.1672134729168; Tue, 27 Dec 2022 01:52:09 -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 21-20020a621515000000b005813aec74bdsm2619052pfv.139.2022.12.27.01.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 01:52:08 -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 v10 6/7] media: uapi: Add controls for NPCM video driver Date: Tue, 27 Dec 2022 17:51:22 +0800 Message-Id: <20221227095123.2447948-7-milkfafa@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221227095123.2447948-1-milkfafa@gmail.com> References: <20221227095123.2447948-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 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?1753360517956010483?= X-GMAIL-MSGID: =?utf-8?q?1753360517956010483?= 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..abe9aac8fd34 --- /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 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..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 */