Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1060507rdb; Tue, 19 Sep 2023 20:29:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpj65zb2NqyznvWR1ds/RTMOYqteRoCqVztOf/FIoWPwWWfD8WOLiVQBW91LUTlQrmpKKB X-Received: by 2002:a05:620a:404e:b0:767:9d40:a3b7 with SMTP id i14-20020a05620a404e00b007679d40a3b7mr1318120qko.21.1695180572341; Tue, 19 Sep 2023 20:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695180572; cv=none; d=google.com; s=arc-20160816; b=nbN6aRJ5sY5UrAcD4YDVzr/ijyuCTbYPo0AQock97tRg86v7sp7x21leg0Syx12hss hVTUT9FFmsE39V13agVJPokqoeGIeBNGvFWftQNBiuqIBFUvv1bgg6/A+57kA1a2OrFB Y19BUgm/4IApbxwJ/fzPXjX+JDV0k1XFINjbMFUkzxp8iusXtEoEJdTtqKFWKRJAOKQ4 alX1E3yy7hp5EGi5eApgPdkpNe8orCOxt5sidh/B44CT25+qL+fSHF96G5kdxUjgnmKa QrADPjqUxWGMXRCfzjI2slqZKe8t9156ZOcZ95E2d0PXHNdho9zq9y2iOgaKdXOJU3bW qvcg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=VfzrZwHFhCid05Dh4cuoZwqnMh3jue5FZMC0tshYFgs=; fh=RfSP4T/SRZN1UnzrZA8MryqWeGpAu/0o11HYNSBkyrI=; b=Q4s+OL2dGrZY4AiI1+PQOakJ24AjNHiyTCVaGiuS0jIfZ10v7nZX/myuGst/r1RE4w sVhTM9J00139g+SAD7jrgktYxoxgwpmMKrGn8xSuWWhlVLvEER9lCC6edYqxreJ+ISga q30n1D/BbmZ7KNgyoIPhLILUYy5T/wcb+BXYe2qO+xKzzR+SYVvHWFQ9zXbh1KoNxSvd kkKI1vvWE63WKJgj14wZNcgE6AW7MREyxqln1OV/Ganbw9TXrmzdpt+HE/jnKxXXJcaV T/NcBU0hGQY73Khixg3wGnlBgIxPphKC2hZqwm9Z4BDJiClDnCTQ85XpKhf/IuqOtOsS PZhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ShytoypH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id fc40-20020a056a002e2800b006906fce83aesi5880080pfb.40.2023.09.19.20.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 20:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ShytoypH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 5364E8297C67; Tue, 19 Sep 2023 19:28:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232073AbjITC2t (ORCPT + 99 others); Tue, 19 Sep 2023 22:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjITC2s (ORCPT ); Tue, 19 Sep 2023 22:28:48 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3B6BC6; Tue, 19 Sep 2023 19:28:41 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-565e395e7a6so3734352a12.0; Tue, 19 Sep 2023 19:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695176921; x=1695781721; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VfzrZwHFhCid05Dh4cuoZwqnMh3jue5FZMC0tshYFgs=; b=ShytoypHx5w1yO+FAoQvCV9S2YQ8S669J5momARMpnUFn4TyPi6Y9G73k9vuBcegP1 lyagB04QVDl3mWPqDGdRZwINYfndYZLmgURmwOywlhIDItOQiHhZtlVyCruZRlzRAwL+ FTrawzETBnTWjMJvABYXPw7xGO7hQMbLUS12t5HMASShjRgocaCxCpoIEnNQLk71418N mSsKNPFCSyT9huTDFIc63geSxXBvJPGt73achD+piNiEOgjkMieAwzJBUN9qR/71E0MA oBcbgJx/kVozx0FdCHk2lB3thm0SfrJCvLQ9J2GoHIa28/T/qY+WTXpXuu+r5awL4jb+ SHqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695176921; x=1695781721; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VfzrZwHFhCid05Dh4cuoZwqnMh3jue5FZMC0tshYFgs=; b=Npe+xe6T30rYI6XN++ny+X0ky6N5n/TBKz8vr6naMATQhUvwlHzFyy6Hr0CDOI9BXn 5UYnzQUoCona/li9o/vZhwCPgXM+sasSyz8xUcf/z5od9aFtUpKwWNsDTiEp+kzlre7/ K+5ADIYHMkAFJ7ZJSpROC2NmKJP6W8eoK5TYRJYF/CT8R7XdPBnvRTGqqqPF0lGt9n75 wQtdzoyigiWvz8kbAwaOtGNxcIPSeBE5bc/S5SRRGwN2MxwgUDMG1LL2gg2YDRCbAK3X qtRKwgVcBQdNkEr5r+PcUgga847XyjCuNZPhjmPVHzw1yDSgMPDTWMOrAhP8H3JiPZxn DBNw== X-Gm-Message-State: AOJu0YzCC3BlPBxvxn7pV0ojVKHi8Ex6mEnJ9ThNIIC84sgdpsJJnJ/W ten+dty78tTAYMDTqs0hWS4= X-Received: by 2002:a05:6a20:552a:b0:14d:6309:fc92 with SMTP id ko42-20020a056a20552a00b0014d6309fc92mr1120474pzb.46.1695176920911; Tue, 19 Sep 2023 19:28:40 -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 n9-20020a170903110900b001bc930d4517sm10610009plh.42.2023.09.19.19.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 19:28:40 -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 v15 0/7] Support Nuvoton NPCM Video Capture/Encode Engine Date: Wed, 20 Sep 2023 10:28:05 +0800 Message-Id: <20230920022812.601800-1-milkfafa@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 19:28:53 -0700 (PDT) This patch series add DTS node, dt-bindings document and drivers for Video Capture/Differentiation Engine (VCD) and Encoding Compression Engine (ECE) present on Nuvoton NPCM SoCs. As described in the datasheet NPCM750D_DS_Rev_1.0, the VCD can capture a frame from digital video input and compare two frames in memory, and then the ECE can compress the frame data into HEXTILE format which is defined in Remote Framebuffer Protocol (RFC 6143, chapter 7.7.4. Hextile Encoding). The output of v4l2-compliance: v4l2-compliance 1.23.0-4996, 64 bits, 64-bit time_t v4l2-compliance SHA: 9431e4b26b48 2023-02-13 14:51:47 Compliance test for npcm-video device /dev/video0: Driver Info: Driver name : npcm-video Card type : NPCM Video Engine Bus info : platform:npcm-video Driver version : 6.1.12 Capabilities : 0x84200001 Video Capture Streaming Extended Pix Format Device Capabilities Device Caps : 0x04200001 Video Capture Streaming Extended Pix Format Required ioctls: test VIDIOC_QUERYCAP: OK test invalid ioctls: OK Allow for multiple opens: test second /dev/video0 open: OK test VIDIOC_QUERYCAP: OK test VIDIOC_G/S_PRIORITY: OK test for unlimited opens: OK Debug ioctls: test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported) Input ioctls: test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported) test VIDIOC_G/S/ENUMINPUT: OK test VIDIOC_G/S_AUDIO: OK (Not Supported) Inputs: 1 Audio Inputs: 0 Tuners: 0 Output ioctls: test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported) Outputs: 0 Audio Outputs: 0 Modulators: 0 Input/Output configuration ioctls: test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK test VIDIOC_DV_TIMINGS_CAP: OK test VIDIOC_G/S_EDID: OK (Not Supported) Control ioctls (Input 0): test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK test VIDIOC_G/S_CTRL: OK test VIDIOC_G/S/TRY_EXT_CTRLS: OK warn: v4l2-test-controls.cpp(1139): V4L2_CID_DV_RX_POWER_PRESENT not found for input 0 test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 1 Private Controls: 2 Format ioctls (Input 0): test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK test VIDIOC_TRY_FMT: OK test VIDIOC_S_FMT: OK test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported) test Composing: OK (Not Supported) test Scaling: OK (Not Supported) Codec ioctls (Input 0): test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported) Buffer ioctls (Input 0): test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK test Requests: OK (Not Supported) Total for npcm-video device /dev/video0: 45, Succeeded: 45, Failed: 0, Warnings: 1 Changes in v15: - Drop VOLATILE flag from V4L2_CID_NPCM_RECT_COUNT control and update value by v4l2_ctrl_s_ctrl. - Add more explanations in comment/document for V4L2_CID_NPCM_RECT_COUNT. Changes in v14: - Modify the flow of setting resolution and queue setup - Correct the control type (TYPE_MENU) of selecting between two modes. - Let ECE could be optional (only supports PIX_FMT_RGB565 if ECE is not enabled in DT). Changes in v13: - Modify the flow for capturing next frame - Modify the behavior of resolution change interrupt - Move GFXI dt-bindings document to Documentation/devicetree/bindings/soc/nuvoton/nuvoton,gfxi.yaml Changes in v12: - Modify the flow for detecting resolution change and raise V4L2_EVENT_SOURCE_CHANGE event. - Add V4L2_PIX_FMT_RGB565 format support. Changes in v11: - Replace "u8/u16/u32" with "unsigned int" for generic local variables. - Correct subsystem prefixes, drop redundant words in commit subject, and add more information in commit message. Changes in v10: - drivers/media/platform/nuvoton/npcm-video.c * Let short functions to be inline function. * Correct return type of some functions, and properly handle return value by callers. * Correct the timing of removing rect_list and the flow of FIFO overrun case in irq. * Adjust line breaks, indentations, and style of variable declarations. Changes in v9: - Change ECE node name to "video-codec". - Drop redundant "bindings for" in commit subject of patch 2/7. - Refine the format of VCD/ECE dt-binding document. Changes in v8: - Let VCD/ECE to be 2 separate nodes and update dt-binding documents. - Move register definitions out to a local header file. - Driver refinements (add error handling for memory allocation, remove unnecessary condition check and introduce "goto"s to handle similar error recovery paths). - Correct properties and typo in GFXI dt-binding document. Changes in v7: - Add uapi documents for driver-specific controls. - Implement driver-specific controls for switching capture mode and getting the count of compressed HEXTILE rectangles. - Drop unnecessary "enum_framesizes" and "enum_frameintervals" functions. - Include the output of v4l2-compliance in cover letter. Changes in v6: - Support NPCM845 and add compatible "nuvoton,npcm845-video". - Correct pixel format to V4L2_PIX_FMT_HEXTILE which is newly added in this patch series. Changes in v5: - Simplify function prefix "nuvoton_" to "npcm_". - Increase VCD_BUSY_TIMEOUT_US and ECE_POLL_TIMEOUT_US to 300ms to prevent polling timeout when ECC is enabled or system is busy. Changes in v4: - Fix compile warning reported by kernel test robot. Changes in v3: - Add video driver entry in MAINTAINERS. - Change config name to CONFIG_VIDEO_NPCM_VCD_ECE. - Reduce the waiting time after resetting the VCD/ECE module. - Correct data types of some variables. Changes in v2: - Add Hextile document and locate with vendor formats. Marvin Lin (7): ARM: dts: nuvoton: Add node for NPCM VCD and ECE engine media: dt-bindings: nuvoton: Add NPCM VCD and ECE engine dt-bindings: soc: nuvoton: Add NPCM GFXI media: v4l: Add HEXTILE compressed format media: v4l2-ctrls: Add user control base for Nuvoton NPCM controls media: uapi: Add controls for NPCM video driver media: nuvoton: Add driver for NPCM video capture and encoding engine .../bindings/media/nuvoton,npcm-ece.yaml | 43 + .../bindings/media/nuvoton,npcm-vcd.yaml | 72 + .../bindings/soc/nuvoton/nuvoton,gfxi.yaml | 39 + .../userspace-api/media/drivers/index.rst | 1 + .../media/drivers/npcm-video.rst | 66 + .../media/v4l/pixfmt-reserved.rst | 7 + MAINTAINERS | 12 + .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 23 + drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/nuvoton/Kconfig | 15 + drivers/media/platform/nuvoton/Makefile | 2 + drivers/media/platform/nuvoton/npcm-regs.h | 152 ++ drivers/media/platform/nuvoton/npcm-video.c | 1830 +++++++++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 1 + include/uapi/linux/npcm-video.h | 41 + include/uapi/linux/v4l2-controls.h | 6 + include/uapi/linux/videodev2.h | 1 + 18 files changed, 2313 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/nuvoton,npcm-ece.yaml create mode 100644 Documentation/devicetree/bindings/media/nuvoton,npcm-vcd.yaml create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,gfxi.yaml create mode 100644 Documentation/userspace-api/media/drivers/npcm-video.rst create mode 100644 drivers/media/platform/nuvoton/Kconfig create mode 100644 drivers/media/platform/nuvoton/Makefile create mode 100644 drivers/media/platform/nuvoton/npcm-regs.h create mode 100644 drivers/media/platform/nuvoton/npcm-video.c create mode 100644 include/uapi/linux/npcm-video.h -- 2.34.1