From patchwork Wed Sep 28 11:21:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erling Ljunggren X-Patchwork-Id: 86371 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1odV91-00HBnM-48; Wed, 28 Sep 2022 11:22:27 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233186AbiI1LWY (ORCPT + 1 other); Wed, 28 Sep 2022 07:22:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232557AbiI1LWW (ORCPT ); Wed, 28 Sep 2022 07:22:22 -0400 Received: from aer-iport-3.cisco.com (aer-iport-3.cisco.com [173.38.203.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 466AADCEA2 for ; Wed, 28 Sep 2022 04:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=857; q=dns/txt; s=iport; t=1664364141; x=1665573741; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lrzpd5WOwWl7gM6g3AAVbvIN+JM6yWCsWR2pFThbQPA=; b=QxAIgtqVMlwHSS0LOm3e4WlRN7R8iM1sR5GphDfIWZAud7fIo4/Tuq47 uohqXtmJZ1dGaMN0kuUZ0lg4F5sgwUsVN9RLXdasqMxG0aGUZmW+OC5JM 8PjGQHyOiK0F08OlsBc+e/ERJEzgIn+94d1lJG/WdZ/mXKVI8AdV8QgmW w=; X-IronPort-AV: E=Sophos;i="5.93,352,1654560000"; d="scan'208";a="4146646" Received: from aer-iport-nat.cisco.com (HELO aer-core-1.cisco.com) ([173.38.203.22]) by aer-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 28 Sep 2022 11:21:15 +0000 Received: from office-260.rd.cisco.com ([10.47.77.162]) by aer-core-1.cisco.com (8.15.2/8.15.2) with ESMTP id 28SBLFel008487; Wed, 28 Sep 2022 11:21:15 GMT From: Erling Ljunggren To: linux-media@vger.kernel.org Cc: Erling Ljunggren Subject: [PATCH v3 1/5] media: videodev2.h: add V4L2_CAP_EDID Date: Wed, 28 Sep 2022 13:21:43 +0200 Message-Id: <20220928112147.358745-2-hljunggr@cisco.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928112147.358745-1-hljunggr@cisco.com> References: <20220928112147.358745-1-hljunggr@cisco.com> MIME-Version: 1.0 X-Outbound-SMTP-Client: 10.47.77.162, [10.47.77.162] X-Outbound-Node: aer-core-1.cisco.com X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, SPF_HELO_PASS,SPF_NONE,USER_IN_DEF_DKIM_WL 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-media@vger.kernel.org X-LSpam-Score: -10.0 (----------) X-LSpam-Report: No, score=-10.0 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_MED=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no Add capability flag to indicate that the device is an EDID-only device. Signed-off-by: Erling Ljunggren --- include/uapi/linux/videodev2.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 054fc8bbdb22..2ea95639f441 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -480,6 +480,7 @@ struct v4l2_capability { #define V4L2_CAP_META_CAPTURE 0x00800000 /* Is a metadata capture device */ #define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ +#define V4L2_CAP_EDID 0x02000000 /* Is an EDID-only device */ #define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ #define V4L2_CAP_META_OUTPUT 0x08000000 /* Is a metadata output device */ From patchwork Wed Sep 28 11:21:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erling Ljunggren X-Patchwork-Id: 86370 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1odV90-00HBnM-3S; Wed, 28 Sep 2022 11:22:26 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbiI1LWX (ORCPT + 1 other); Wed, 28 Sep 2022 07:22:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230228AbiI1LWW (ORCPT ); Wed, 28 Sep 2022 07:22:22 -0400 Received: from aer-iport-2.cisco.com (aer-iport-2.cisco.com [173.38.203.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4666CDCE9F for ; Wed, 28 Sep 2022 04:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2903; q=dns/txt; s=iport; t=1664364141; x=1665573741; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K0hB3FrAm9UEFFG+9U6bPquUkR74iYgbok3BKkLDx/g=; b=fbaBo1xiflR9GKPC2pYTwKZ45AMU185ZqKXOvJ3uu4aybLTWO0UtF/kk lYtYfkJ9ok+sUMQVkPt2W4voZs2TzhOHvjma2dSlOEVuMmLSYlfbftNu4 PmzsrLgA4Fb+4+2qY+Gr+PnDvzDLYuFt6SRGD0HSORQOLYjZraX2OXCLB A=; X-IronPort-AV: E=Sophos;i="5.93,352,1654560000"; d="scan'208";a="4178574" Received: from aer-iport-nat.cisco.com (HELO aer-core-1.cisco.com) ([173.38.203.22]) by aer-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 28 Sep 2022 11:21:16 +0000 Received: from office-260.rd.cisco.com ([10.47.77.162]) by aer-core-1.cisco.com (8.15.2/8.15.2) with ESMTP id 28SBLFem008487; Wed, 28 Sep 2022 11:21:15 GMT From: Erling Ljunggren To: linux-media@vger.kernel.org Cc: Erling Ljunggren Subject: [PATCH v3 2/5] media: docs: Add V4L2_CAP_EDID Date: Wed, 28 Sep 2022 13:21:44 +0200 Message-Id: <20220928112147.358745-3-hljunggr@cisco.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928112147.358745-1-hljunggr@cisco.com> References: <20220928112147.358745-1-hljunggr@cisco.com> MIME-Version: 1.0 X-Outbound-SMTP-Client: 10.47.77.162, [10.47.77.162] X-Outbound-Node: aer-core-1.cisco.com X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, SPF_HELO_PASS,SPF_NONE,USER_IN_DEF_DKIM_WL 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-media@vger.kernel.org X-LSpam-Score: -10.0 (----------) X-LSpam-Report: No, score=-10.0 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no Add documentation for the new edid capability. Signed-off-by: Erling Ljunggren --- Documentation/userspace-api/media/v4l/biblio.rst | 11 +++++++++++ .../userspace-api/media/v4l/vidioc-querycap.rst | 11 +++++++++++ .../userspace-api/media/videodev2.h.rst.exceptions | 1 + 3 files changed, 23 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/biblio.rst b/Documentation/userspace-api/media/v4l/biblio.rst index 9cd18c153d19..5cbe41877a63 100644 --- a/Documentation/userspace-api/media/v4l/biblio.rst +++ b/Documentation/userspace-api/media/v4l/biblio.rst @@ -334,6 +334,17 @@ VESA DMT :author: Video Electronics Standards Association (http://www.vesa.org) +.. _vesaeddc: + +E-DDC +==== + + +:title: VESA Enhanced Display Data Channel (E-DDC) Standard +:subtitle: Version 1.3 + +:author: Video Electronics Standards Association (http://www.vesa.org) + .. _vesaedid: EDID diff --git a/Documentation/userspace-api/media/v4l/vidioc-querycap.rst b/Documentation/userspace-api/media/v4l/vidioc-querycap.rst index 6c57b8428356..3d11d86d9cbf 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-querycap.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-querycap.rst @@ -244,6 +244,17 @@ specification the ioctl returns an ``EINVAL`` error code. - 0x01000000 - The device supports the :c:func:`read()` and/or :c:func:`write()` I/O methods. + * - ``V4L2_CAP_EDID`` + - 0x02000000 + - The device stores the EDID for a video input, or retrieves the EDID for a video + output. It is a standalone EDID device, so no video streaming etc. will take place. + + For a video input this is typically an eeprom that supports the + :ref:`VESA Enhanced Display Data Channel Standard `. It can be something + else as well, for example a micro controller. + + For a video output this is typically read from an external device such as an + HDMI splitter accessed by a serial port. * - ``V4L2_CAP_STREAMING`` - 0x04000000 - The device supports the :ref:`streaming ` I/O method. diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions index 9cbb7a0c354a..b1b1127d278c 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -185,6 +185,7 @@ replace define V4L2_CAP_META_OUTPUT device-capabilities replace define V4L2_CAP_DEVICE_CAPS device-capabilities replace define V4L2_CAP_TOUCH device-capabilities replace define V4L2_CAP_IO_MC device-capabilities +replace define V4L2_CAP_EDID device-capabilities # V4L2 pix flags replace define V4L2_PIX_FMT_PRIV_MAGIC :c:type:`v4l2_pix_format` From patchwork Wed Sep 28 11:21:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erling Ljunggren X-Patchwork-Id: 86374 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1odV97-00HBnM-3l; Wed, 28 Sep 2022 11:22:33 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233190AbiI1LW0 (ORCPT + 1 other); Wed, 28 Sep 2022 07:22:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232599AbiI1LWY (ORCPT ); Wed, 28 Sep 2022 07:22:24 -0400 Received: from aer-iport-7.cisco.com (aer-iport-7.cisco.com [173.38.203.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 519C9DCE99 for ; Wed, 28 Sep 2022 04:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1715; q=dns/txt; s=iport; t=1664364143; x=1665573743; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B0pImiRaODAXBVOex7WftZ32/MuyBAAbJcf0KrpTF4E=; b=hBoO0y+5mi0V9yZGs49y3JbL0KrNVyj8uTX132VspB0iSSJ6TSyiDbJ5 m3u0HMm062YE+Ts4kiyFqsXlQW0QsR1Hx36b0kb0achHn27V90I8+CULc G2oqUDDFfg2o2LctuoG2pZDD/tc0jCtrumitLgbksiGT5Xk6RV7QO02Rb M=; X-IronPort-AV: E=Sophos;i="5.93,352,1654560000"; d="scan'208";a="1510153" Received: from aer-iport-nat.cisco.com (HELO aer-core-1.cisco.com) ([173.38.203.22]) by aer-iport-7.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 28 Sep 2022 11:21:16 +0000 Received: from office-260.rd.cisco.com ([10.47.77.162]) by aer-core-1.cisco.com (8.15.2/8.15.2) with ESMTP id 28SBLFen008487; Wed, 28 Sep 2022 11:21:16 GMT From: Erling Ljunggren To: linux-media@vger.kernel.org Cc: Erling Ljunggren , devicetree@vger.kernel.org Subject: [PATCH v3 3/5] dt-bindings: media: add cat24c208 bindings Date: Wed, 28 Sep 2022 13:21:45 +0200 Message-Id: <20220928112147.358745-4-hljunggr@cisco.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928112147.358745-1-hljunggr@cisco.com> References: <20220928112147.358745-1-hljunggr@cisco.com> MIME-Version: 1.0 X-Outbound-SMTP-Client: 10.47.77.162, [10.47.77.162] X-Outbound-Node: aer-core-1.cisco.com X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, SPF_HELO_NONE,SPF_NONE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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-media@vger.kernel.org X-LSpam-Score: -10.0 (----------) X-LSpam-Report: No, score=-10.0 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no Add devicetree bindings for new cat24c208 EDID EEPROM driver. Signed-off-by: Erling Ljunggren --- .../bindings/media/i2c/onnn,cat24c208.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml b/Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file mode 100644 index 000000000000..fcfaccb5e39f --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/onnn,cat24c208.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ON Semiconductor CAT24C208 EDID EEPROM driver + +maintainers: + - Hans Verkuil + +description: | + CAT24C208 is a dual port i2c EEPROM designed for EDID storage. + + +properties: + compatible: + const: onnn,cat24c208 + + reg: + maxItems: 1 + + hpd-gpios: + maxItems: 1 + description: + References to the GPIO that controls the HDMI hot-plug detection pin. + The active flag indicates the GPIO level that enables hot-plug detection. + + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + cat24c208@31 { + compatible = "onnn,cat24c208"; + reg = <0x31>; + hpd-gpios = <&ioexp 0 GPIO_ACTIVE_HIGH>; + }; + }; +... From patchwork Wed Sep 28 11:21:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erling Ljunggren X-Patchwork-Id: 86373 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1odV92-00HBnM-RB; Wed, 28 Sep 2022 11:22:32 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233276AbiI1LWZ (ORCPT + 1 other); Wed, 28 Sep 2022 07:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233163AbiI1LWX (ORCPT ); Wed, 28 Sep 2022 07:22:23 -0400 Received: from aer-iport-1.cisco.com (aer-iport-1.cisco.com [173.38.203.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5664DCE85 for ; Wed, 28 Sep 2022 04:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=15812; q=dns/txt; s=iport; t=1664364142; x=1665573742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sQdcvxN5YHlCwnta0ArPmx3QaEqMv6Jy/G5jFqDq0y4=; b=YZkJf7FtJqCPCDNTpaBe8UijquRy8r4Wur6qKJ9BLQdErXot8yMv4djE cNpfB68SF/Ky5z53xZnWgUx3pPCCQV0CkAD0c8W22Mwlfni+rJRSMuFz1 GwrTJ+w3HMw5f14FZQ9PRRdebjDl8+co1uIrlayB5YEHrZWrzM4lTvqR7 E=; X-IronPort-AV: E=Sophos;i="5.93,352,1654560000"; d="scan'208";a="4176463" Received: from aer-iport-nat.cisco.com (HELO aer-core-1.cisco.com) ([173.38.203.22]) by aer-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 28 Sep 2022 11:21:16 +0000 Received: from office-260.rd.cisco.com ([10.47.77.162]) by aer-core-1.cisco.com (8.15.2/8.15.2) with ESMTP id 28SBLFeo008487; Wed, 28 Sep 2022 11:21:16 GMT From: Erling Ljunggren To: linux-media@vger.kernel.org Cc: Jonathan Selnes , Hans Verkuil , Erling Ljunggren Subject: [PATCH v3 4/5] media: i2c: cat24c208: driver for the cat24c208 EDID EEPROM Date: Wed, 28 Sep 2022 13:21:46 +0200 Message-Id: <20220928112147.358745-5-hljunggr@cisco.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928112147.358745-1-hljunggr@cisco.com> References: <20220928112147.358745-1-hljunggr@cisco.com> MIME-Version: 1.0 X-Outbound-SMTP-Client: 10.47.77.162, [10.47.77.162] X-Outbound-Node: aer-core-1.cisco.com X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, SPF_HELO_PASS,SPF_NONE,USER_IN_DEF_DKIM_WL 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-media@vger.kernel.org X-LSpam-Score: -10.0 (----------) X-LSpam-Report: No, score=-10.0 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_MED=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no From: Jonathan Selnes Support reading and writing the EDID EEPROM through the v4l2 API. Signed-off-by: Jonathan Selnes Co-developed-by: Hans Verkuil Signed-off-by: Hans Verkuil Co-developed-by: Erling Ljunggren Signed-off-by: Erling Ljunggren --- MAINTAINERS | 7 + drivers/media/i2c/Kconfig | 9 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/cat24c208.c | 480 ++++++++++++++++++++++++++++++++++ 4 files changed, 497 insertions(+) create mode 100644 drivers/media/i2c/cat24c208.c diff --git a/MAINTAINERS b/MAINTAINERS index 7d9490a5c15a..407d76c42bab 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14912,6 +14912,13 @@ S: Maintained T: git git://linuxtv.org/media_tree.git F: drivers/media/i2c/ov9734.c +ON SEMICONDUCTOR CAT24C208 EDID EEPROM DRIVER +M: Hans Verkuil +L: linux-media@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml +F: drivers/media/i2c/cat24c208* + ONENAND FLASH DRIVER M: Kyungmin Park L: linux-mtd@lists.infradead.org diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 2b20aa6c37b1..2f5f9f058b48 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -1530,6 +1530,15 @@ endmenu menu "Miscellaneous helper chips" visible if !MEDIA_HIDE_ANCILLARY_SUBDRV +config VIDEO_CAT24C208 + tristate "ON Semiconductor cat24c208 EDID EEPROM" + depends on VIDEO_DEV && I2C && OF + help + Support for the ON Semiconductor CAT24C208 Dual Port EDID EEPROM. + + To compile this driver as a module, choose M here: the + module will be called cat24c208. + config VIDEO_I2C tristate "I2C transport video support" depends on VIDEO_DEV && I2C diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index 3e1696963e7f..70e4360a21ba 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_VIDEO_APTINA_PLL) += aptina-pll.o obj-$(CONFIG_VIDEO_BT819) += bt819.o obj-$(CONFIG_VIDEO_BT856) += bt856.o obj-$(CONFIG_VIDEO_BT866) += bt866.o +obj-$(CONFIG_VIDEO_CAT24C208) += cat24c208.o obj-$(CONFIG_VIDEO_CCS) += ccs/ obj-$(CONFIG_VIDEO_CCS_PLL) += ccs-pll.o obj-$(CONFIG_VIDEO_CS3308) += cs3308.o diff --git a/drivers/media/i2c/cat24c208.c b/drivers/media/i2c/cat24c208.c new file mode 100644 index 000000000000..63b496f62c19 --- /dev/null +++ b/drivers/media/i2c/cat24c208.c @@ -0,0 +1,480 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * HDMI i2c controlled EEPROM from ON Semiconductor or Catalyst Semiconductor + * + * Support for i2c based DDC EEPROM + * + * Copyright (C) 2021-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + */ + +/* + * REF_01 - ON Semiconductor, cat24c208, Datasheet, URL : https://www.onsemi.com/pdf/datasheet/cat24c208-d.pdf + * Revision 7, May 2018 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +MODULE_DESCRIPTION("cat24c208 EDID EEPROM driver"); +MODULE_AUTHOR("Jonathan Selnes Bognaes "); +MODULE_LICENSE("GPL"); + +/* + * CAT24C208 setup + */ +#define BYTES_PER_BLOCK 128 +#define EDID_OFFSET_EXT_FLAG 126 +#define MAX_WRITE_BYTES 16 +#define NUM_BLOCKS 4 +#define NUM_CLIENTS 3 +#define CONFIG_NB_BIT BIT(0) +#define CONFIG_AB0_BIT BIT(1) +#define CONFIG_AB1_BIT BIT(2) +#define CONFIG_WE_BIT BIT(3) + +/* + * From the datasheet: REF_01 + * + * The write cycle time is the time from a valid stop condition of a write + * sequence to the end of the internal program/erase cycle. During the write + * cycle, the bus interface circuits are disabled, SDA is allowed to remain + * high, and the device does not respond to its slave address. + */ +#define WRITE_CYCLE_TIME_US 5000 + +/* + * CAT24C208 addresses + */ +#define CONFIG_I2C_ADDR 0x31 +#define EEPROM_I2C_ADDR 0x50 +#define SEGMENT_I2C_ADDR 0x30 + +struct cat24c208_state { + struct i2c_client *dev_client; + struct i2c_client *data_client; + struct i2c_client *seg_client; + // V4L2 ioctl serialization + struct mutex lock; + struct cec_notifier *notifier; + struct delayed_work dwork_enable_hpd; + + struct v4l2_device v4l2_dev; + struct video_device vdev; + struct gpio_desc *hpd_gpio; + + u8 edid_blocks; // edid length can vary, one block = 128 bytes + u8 edid[BYTES_PER_BLOCK * NUM_BLOCKS]; // actual active edid data +}; + +static const struct v4l2_file_operations cat24c208_fops = { + .owner = THIS_MODULE, + .open = v4l2_fh_open, + .release = v4l2_fh_release, + .unlocked_ioctl = video_ioctl2, +}; + +static int cat24c208_seg_write(struct cat24c208_state *state, u8 *data, u16 len, u8 seg) +{ + struct i2c_msg msg[] = { + { + .addr = state->seg_client->addr, // Segment + .buf = &seg, + .len = 1, + .flags = 0, + }, + { + .addr = state->data_client->addr, // write data + .buf = data, + .len = len, + .flags = 0, + }, + }; + int err; + + if (seg) + err = i2c_transfer(state->dev_client->adapter, msg, ARRAY_SIZE(msg)); + else + err = i2c_transfer(state->dev_client->adapter, &msg[1], 1); + + if (err < 0) + dev_err(&state->dev_client->dev, "Writing to 0x%x failed (segment %d)\n", + state->data_client->addr, seg); + + usleep_range(WRITE_CYCLE_TIME_US, 2 * WRITE_CYCLE_TIME_US); + return err < 0 ? err : 0; +} + +static int cat24c208_edid_read(struct cat24c208_state *state, u8 *data, u8 seg, u8 offset, u16 len) +{ + int err; + + len *= BYTES_PER_BLOCK; + if (seg) { + struct i2c_msg msg[] = { + { + .addr = state->seg_client->addr, // Segment + .buf = &seg, + .len = 1, + .flags = 0, + }, + { + .addr = state->data_client->addr, // read data + .buf = data, + .len = len, + .flags = I2C_M_RD, + }, + }; + err = i2c_transfer(state->dev_client->adapter, msg, ARRAY_SIZE(msg)); + } else { + struct i2c_msg msg[] = { + { + .addr = state->data_client->addr, // set offset + .buf = &offset, + .len = 1, + .flags = 0, + }, + { + .addr = state->data_client->addr, // read data + .buf = data, + .len = len, + .flags = I2C_M_RD, + }, + }; + err = i2c_transfer(state->dev_client->adapter, msg, ARRAY_SIZE(msg)); + } + + if (err < 0) + dev_err(&state->dev_client->dev, "Reading of EDID failed\n"); + return err < 0 ? err : 0; +} + +static int cat24c208_set_config(struct i2c_client *client) +{ + u8 buf[2] = { 0, CONFIG_NB_BIT }; + struct i2c_msg msg = { + .addr = client->addr, + .buf = buf, + .len = sizeof(buf), + .flags = 0, + }; + int err; + + err = i2c_transfer(client->adapter, &msg, 1); + if (err < 0) + dev_err(&client->dev, "Could not set config register\n"); + + usleep_range(WRITE_CYCLE_TIME_US, 2 * WRITE_CYCLE_TIME_US); + return err < 0 ? err : 0; +} + +static bool cat24c208_is_valid_edid(const u8 *block) +{ + static const u8 header_pattern[] = { + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 + }; + + return !memcmp(block, header_pattern, sizeof(header_pattern)); +} + +static void cat24c208_delayed_work_release_hpd(struct work_struct *work) +{ + struct delayed_work *dwork = to_delayed_work(work); + struct cat24c208_state *state = container_of(dwork, struct cat24c208_state, + dwork_enable_hpd); + + gpiod_set_value(state->hpd_gpio, 1); +} + +static int cat24c208_set_edid(struct file *file, void *fh, struct v4l2_edid *edid) +{ + struct cat24c208_state *state = video_drvdata(file); + u8 buf[MAX_WRITE_BYTES + 1]; + u16 pa; + int err; + int seg; + int i; + + memset(edid->reserved, 0, sizeof(edid->reserved)); + + if (edid->pad) + return -EINVAL; + + if (edid->blocks > NUM_BLOCKS) { + edid->blocks = NUM_BLOCKS; + return -E2BIG; + } + + if (edid->start_block) + return -EINVAL; + + pa = v4l2_get_edid_phys_addr(edid->edid, edid->blocks * BYTES_PER_BLOCK, NULL); + + err = v4l2_phys_addr_validate(pa, NULL, NULL); + if (err) + return err; + + if (state->hpd_gpio) { + cancel_delayed_work_sync(&state->dwork_enable_hpd); + gpiod_set_value(state->hpd_gpio, 0); + } + + if (edid->blocks == 0) { + cec_notifier_set_phys_addr(state->notifier, pa); + return 0; + } + + state->edid_blocks = edid->blocks; + memcpy(state->edid, edid->edid, state->edid_blocks * BYTES_PER_BLOCK); + + /* Write EDID to EEPROM */ + for (i = 0; i < edid->blocks * BYTES_PER_BLOCK; i = i + MAX_WRITE_BYTES) { + if (i >= 2 * BYTES_PER_BLOCK) { + seg = 1; + buf[0] = i - BYTES_PER_BLOCK * 2; + } else { + seg = 0; + buf[0] = i; + } + + memcpy(buf + 1, &edid->edid[i], MAX_WRITE_BYTES); + err = cat24c208_seg_write(state, buf, MAX_WRITE_BYTES + 1, seg); + if (err) { + dev_err(&state->dev_client->dev, + "Could not write EDID to EEPROM, i: %d\n", i); + return err; + } + } + + cec_notifier_set_phys_addr(state->notifier, pa); + + if (state->hpd_gpio) + schedule_delayed_work(&state->dwork_enable_hpd, 110 * HZ / 1000); + + return 0; +} + +static int cat24c208_get_edid(struct file *file, void *fh, struct v4l2_edid *edid) +{ + struct cat24c208_state *state = video_drvdata(file); + + memset(edid->reserved, 0, sizeof(edid->reserved)); + + if (edid->pad != 0) + return -EINVAL; + + if (edid->start_block == 0 && edid->blocks == 0) { + edid->blocks = state->edid_blocks; + return 0; + } + + if (state->edid_blocks == 0) + return -ENODATA; + + if (edid->start_block >= state->edid_blocks) + return -EINVAL; + + if (edid->start_block + edid->blocks > state->edid_blocks) + edid->blocks = state->edid_blocks - edid->start_block; + + memcpy(edid->edid, state->edid + edid->start_block * BYTES_PER_BLOCK, + edid->blocks * BYTES_PER_BLOCK); + + return 0; +} + +static int cat24c208_get_input(struct file *file, void *priv, unsigned int *i) +{ + *i = 0; + return 0; +} + +static int cat24c208_set_input(struct file *file, void *priv, unsigned int i) +{ + return i > 0 ? -EINVAL : 0; +} + +static int cat24c208_enum_input(struct file *file, void *priv, + struct v4l2_input *inp) +{ + if (inp->index) + return -EINVAL; + strscpy(inp->name, "HDMI", sizeof(inp->name)); + inp->capabilities = 0; + inp->type = V4L2_INPUT_TYPE_CAMERA; + return 0; +} + +static int cat24c208_querycap(struct file *file, + void *priv, struct v4l2_capability *cap) +{ + struct cat24c208_state *state = video_drvdata(file); + struct i2c_client *client = state->dev_client; + + strscpy(cap->driver, "cat24c208", sizeof(cap->driver)); + strscpy(cap->card, "cat24c208 EDID EEPROM", sizeof(cap->card)); + snprintf(cap->bus_info, sizeof(cap->bus_info), + "I2C:%d-%04x", client->adapter->nr, client->addr); + return 0; +} + +static const struct v4l2_ioctl_ops cat24c208_ioctl_ops = { + .vidioc_querycap = cat24c208_querycap, + .vidioc_g_edid = cat24c208_get_edid, + .vidioc_s_edid = cat24c208_set_edid, + .vidioc_g_input = cat24c208_get_input, + .vidioc_s_input = cat24c208_set_input, + .vidioc_enum_input = cat24c208_enum_input, +}; + +static void cat24c208_release(struct video_device *vdev) +{ + struct cat24c208_state *state = video_get_drvdata(vdev); + + v4l2_device_unregister(&state->v4l2_dev); + mutex_destroy(&state->lock); + kfree(state); +} + +static int cat24c208_probe(struct i2c_client *client) +{ + struct cat24c208_state *state; + struct v4l2_device *v4l2_dev; + int blocks; + int ret; + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (!state) + return -ENOMEM; + + state->dev_client = client; + state->data_client = i2c_new_ancillary_device(client, "eeprom", EEPROM_I2C_ADDR); + if (IS_ERR(state->data_client)) { + ret = PTR_ERR(state->data_client); + goto free_state; + } + state->seg_client = i2c_new_ancillary_device(client, "segment", SEGMENT_I2C_ADDR); + if (IS_ERR(state->seg_client)) { + ret = PTR_ERR(state->seg_client); + goto unreg_i2c_first; + } + + ret = cat24c208_set_config(client); + if (ret) + goto unreg_i2c_all; + + if (cat24c208_edid_read(state, state->edid, 0, 0, 2) >= 0 && + cat24c208_is_valid_edid(state->edid)) { + unsigned int i; + + blocks = 1 + state->edid[EDID_OFFSET_EXT_FLAG]; + state->edid_blocks = blocks; + for (i = 2; i < blocks; i += 2) { + if (cat24c208_edid_read(state, state->edid + i * BYTES_PER_BLOCK, + i / 2, 0, (i + 1 >= blocks ? 1 : 2))) { + state->edid_blocks = i; + break; + } + } + } + + v4l2_dev = &state->v4l2_dev; + strscpy(v4l2_dev->name, "cat24c208", sizeof(v4l2_dev->name)); + ret = v4l2_device_register(&client->dev, v4l2_dev); + if (ret) { + dev_err(&client->dev, "v4l2_device_register failed: %d\n", ret); + goto unreg_i2c_all; + } + + mutex_init(&state->lock); + + state->notifier = cec_notifier_conn_register(&client->dev, NULL, NULL); + if (!state->notifier) { + dev_err(&client->dev, "Failed to get CEC notifier\n"); + ret = -ENOMEM; + goto unreg_i2c_all; + } + + state->hpd_gpio = devm_gpiod_get_optional(&client->dev, + "hpd", GPIOD_OUT_LOW); + if (IS_ERR(state->hpd_gpio)) { + ret = PTR_ERR(state->hpd_gpio); + dev_err(&client->dev, "Failed to get hpd-gpio err:%d\n", ret); + goto unreg_i2c_all; + } + + INIT_DELAYED_WORK(&state->dwork_enable_hpd, cat24c208_delayed_work_release_hpd); + + snprintf(state->vdev.name, sizeof(state->vdev.name), + "cat24c208 %d-%d", client->adapter->nr, client->addr); + + state->vdev.v4l2_dev = v4l2_dev; + state->vdev.fops = &cat24c208_fops; + state->vdev.ioctl_ops = &cat24c208_ioctl_ops; + state->vdev.lock = &state->lock; + state->vdev.release = cat24c208_release; + state->vdev.device_caps = V4L2_CAP_EDID; + + video_set_drvdata(&state->vdev, state); + i2c_set_clientdata(client, state); + ret = video_register_device(&state->vdev, VFL_TYPE_VIDEO, -1); + if (ret != 0) { + dev_err(&client->dev, "Video registering failed: %d\n", ret); + goto unreg_v4l2_dev; + } + return 0; + +unreg_v4l2_dev: + v4l2_device_unregister(&state->v4l2_dev); + cec_notifier_conn_unregister(state->notifier); + cancel_delayed_work_sync(&state->dwork_enable_hpd); +unreg_i2c_all: + i2c_unregister_device(state->seg_client); +unreg_i2c_first: + i2c_unregister_device(state->data_client); +free_state: + kfree(state); + return ret; +} + +static int cat24c208_remove(struct i2c_client *client) +{ + struct cat24c208_state *state = i2c_get_clientdata(client); + + cancel_delayed_work_sync(&state->dwork_enable_hpd); + cec_notifier_conn_unregister(state->notifier); + i2c_unregister_device(state->data_client); + i2c_unregister_device(state->seg_client); + video_unregister_device(&state->vdev); + + return 0; +} + +static const struct of_device_id cat24c208_of_match[] = { + { .compatible = "onnn,cat24c208"}, + {} +}; +MODULE_DEVICE_TABLE(of, cat24c208_of_match); + +static struct i2c_driver cat24c208_driver = { + .driver = { + .name = "cat24c208", + .of_match_table = cat24c208_of_match, + }, + .probe_new = cat24c208_probe, + .remove = cat24c208_remove, +}; +module_i2c_driver(cat24c208_driver); From patchwork Wed Sep 28 11:21:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erling Ljunggren X-Patchwork-Id: 86372 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1odV91-00HBnM-V3; Wed, 28 Sep 2022 11:22:28 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233252AbiI1LWZ (ORCPT + 1 other); Wed, 28 Sep 2022 07:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232959AbiI1LWX (ORCPT ); Wed, 28 Sep 2022 07:22:23 -0400 Received: from aer-iport-6.cisco.com (aer-iport-6.cisco.com [173.38.203.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16555DCEB1 for ; Wed, 28 Sep 2022 04:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1711; q=dns/txt; s=iport; t=1664364142; x=1665573742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lqL9lLmFaDtF9r4XcvzUHpGO4/UFYfKq+3g0/9ZdfMo=; b=ZdpDHK5hoDCu6u2jCovE9YfxJBTWJBOyuSw1R+p+xxYtp3QqFw3Ni44s FmdxmCMjdRs5cplCWW6I8C3J4UYb7g5A55MPoRAq3KQQ5H9o6N7M/mhD8 OP5iQdvF9EHa+cXh+rlVQ624aAYtL3psfvO2RMq/J2wUoX+KgaN1KwCd+ 8=; X-IronPort-AV: E=Sophos;i="5.93,352,1654560000"; d="scan'208";a="1511164" Received: from aer-iport-nat.cisco.com (HELO aer-core-1.cisco.com) ([173.38.203.22]) by aer-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 28 Sep 2022 11:21:16 +0000 Received: from office-260.rd.cisco.com ([10.47.77.162]) by aer-core-1.cisco.com (8.15.2/8.15.2) with ESMTP id 28SBLFep008487; Wed, 28 Sep 2022 11:21:16 GMT From: Erling Ljunggren To: linux-media@vger.kernel.org Cc: Erling Ljunggren Subject: [PATCH v3 5/5] media: v4l2-dev: handle V4L2_CAP_EDID Date: Wed, 28 Sep 2022 13:21:47 +0200 Message-Id: <20220928112147.358745-6-hljunggr@cisco.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928112147.358745-1-hljunggr@cisco.com> References: <20220928112147.358745-1-hljunggr@cisco.com> MIME-Version: 1.0 X-Outbound-SMTP-Client: 10.47.77.162, [10.47.77.162] X-Outbound-Node: aer-core-1.cisco.com X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, SPF_HELO_NONE,SPF_NONE,USER_IN_DEF_DKIM_WL 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-media@vger.kernel.org X-LSpam-Score: -10.0 (----------) X-LSpam-Report: No, score=-10.0 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no When the V4L2_CAP_EDID capability flag is set, ioctls for enum inputs/outputs and get/set edid are automatically set. Signed-off-by: Erling Ljunggren --- drivers/media/v4l2-core/v4l2-dev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index d00237ee4cae..e8222b9835e6 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -556,6 +556,7 @@ static void determine_valid_ioctls(struct video_device *vdev) bool is_rx = vdev->vfl_dir != VFL_DIR_TX; bool is_tx = vdev->vfl_dir != VFL_DIR_RX; bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC; + bool is_edid = vdev->device_caps & V4L2_CAP_EDID; bitmap_zero(valid_ioctls, BASE_VIDIOC_PRIVATE); @@ -778,6 +779,20 @@ static void determine_valid_ioctls(struct video_device *vdev) SET_VALID_IOCTL(ops, VIDIOC_S_TUNER, vidioc_s_tuner); SET_VALID_IOCTL(ops, VIDIOC_S_HW_FREQ_SEEK, vidioc_s_hw_freq_seek); } + if (is_edid) { + SET_VALID_IOCTL(ops, VIDIOC_G_EDID, vidioc_g_edid); + if (is_tx) { + SET_VALID_IOCTL(ops, VIDIOC_G_OUTPUT, vidioc_g_output); + SET_VALID_IOCTL(ops, VIDIOC_S_OUTPUT, vidioc_s_output); + SET_VALID_IOCTL(ops, VIDIOC_ENUMOUTPUT, vidioc_enum_output); + } + if (is_rx) { + SET_VALID_IOCTL(ops, VIDIOC_ENUMINPUT, vidioc_enum_input); + SET_VALID_IOCTL(ops, VIDIOC_G_INPUT, vidioc_g_input); + SET_VALID_IOCTL(ops, VIDIOC_S_INPUT, vidioc_s_input); + SET_VALID_IOCTL(ops, VIDIOC_S_EDID, vidioc_s_edid); + } + } bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls, BASE_VIDIOC_PRIVATE);