Skip to contentSkip to conversation

drivers: ddcci: add drivers for DDCCI

PATCH In review Yusuf Khan 5 participants 10 messages Apr 3, 2022 – Apr 4, 2022

Subsystems (4)
lore
Share & tools
lore

Yusuf Khan

author
#0 lore raw

v10 cover drivers: ddcci: add drivers for DDCCI

This patch adds the DDCCI driver by Christoph Grenz into the kernel. The original gitlab page is loacted at https://gitlab.com/ddcci-driv
er-linux/ddcci-driver-linux/-/tree/master.

DDC/CI is a control protocol for monitor settings supported by most monitors since about 2005. A chardev and sysfs interface is provided. A backlight driver using DDCCI is also provided in the seccond patch.

---
v2: Fix typos.

v3: Add documentation, move files around, replace semaphores with mutexes, and replaced <asm-generic/fcntl.h> with <linux/fcntl.h>. "imirkin"(which due to his involvement in the dri-devel irc channel I cant help but assume to be a DRM developer) said that the DDC/CI bus does not intefere with the buses that DRM is involved with.

v4: Move some documentation, fix grammer mistakes, remove usages of likely(), and clarify some documentation.

v5: Fix grammer mistakes, remove usages of likely(), and clarify some documentation.

v6: Change contact information to reference Christoph Grenz.

v7: Remove all instances of the unlikely() macro.

v8: Modify documentation to provide updated date and kernel documentation, fix SPDX lines, use isalpha instead of redefining logic, change maximum amount of bytes that can be written to be conformant with DDC/CI specification, prevent userspace from holding locks with the open file descriptor, remove ddcci_cdev_seek, dont refine sysfs_emit() logic, use EXPORT_SYMBOL_GPL instead of EXPORT_SYMBOL, remove ddcci_device_remove_void, remove module paramaters and version, and split into 2 patches.

v9: Fix IS_ANY_ID matching for compilers and archs where char is unsigned char and use the cannonical patch format.

v10: Change patch title to "drivers: ddcci: add drivers for DDCCI and change" and change patch descriptions to add more detailed explanations of function.

Patch 1: Add the main DDCCI component.

Patch 2: Add the backlight driver that utilizes the DDCCI driver.

Patch 3: Add documentation for the DDCCI drivers.

Yusuf Khan (3):
drivers: ddcci: add drivers for DDCCI
drivers: ddcci: add drivers for DDCCI
drivers: ddcci: add drivers for DDCCI

 Documentation/ABI/testing/sysfs-driver-ddcci |   57 +
 Documentation/driver-api/ddcci.rst           |  122 ++
 drivers/char/Kconfig                         |   11 +
 drivers/char/Makefile                        |    1 +
 drivers/char/ddcci.c                         | 1805 ++++++++++++++++++
 drivers/video/backlight/Kconfig              |   11 +
 drivers/video/backlight/Makefile             |    1 +
 drivers/video/backlight/ddcci-backlight.c    |  411 ++++
 include/linux/ddcci.h                        |  163 ++
 9 files changed, 2582 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-ddcci
 create mode 100644 Documentation/driver-api/ddcci.rst
 create mode 100644 drivers/char/ddcci.c
 create mode 100644 drivers/video/backlight/ddcci-backlight.c
 create mode 100644 include/linux/ddcci.h
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v10 1/3 drivers: ddcci: add drivers for DDCCI

This patch adds the main DDCCI driver. This interfaces with I2C to allow the kernel to communicate with DDCCI supporting monitors, it exports a chardev and sysfs interface for userspace.

---
 drivers/char/Kconfig  |   11 +
 drivers/char/Makefile |    1 +
 drivers/char/ddcci.c  | 1805 +++++++++++++++++++++++++++++++++++++++++
 include/linux/ddcci.h |  163 ++++
 4 files changed, 1980 insertions(+)
 create mode 100644 drivers/char/ddcci.c
 create mode 100644 include/linux/ddcci.h
drivers/char/Kconfig +11 -0
index 740811893c57..2449c17e1080 100644
@@ -451,4 +451,15 @@ config RANDOM_TRUST_BOOTLOADER
 	pool. Otherwise, say N here so it will be regarded as device input that
 	only mixes the entropy pool.
 
+config DDCCI
+	tristate "DDCCI display protocol support"
+	depends on I2C
+	help
+	  Display Data Channel Command Interface is an
+	  interface that allows the kernel to "talk"
+	  to most displays made after 2005. Check your
+	  display's specification to see if it has
+	  support for this. This depends on I2C to
+	  compile.
+
 endmenu
drivers/char/Makefile +1 -0
index 264eb398fdd4..eaa2d58d50df 100644
@@ -3,6 +3,7 @@
 # Makefile for the kernel character device drivers.
 #
 
+obj-$(CONFIG_DDCCI)				+= ddcci.o
 obj-y				+= mem.o random.o
 obj-$(CONFIG_TTY_PRINTK)	+= ttyprintk.o
 obj-y				+= misc.o
drivers/char/ddcci.c new file +1805 -0

1,805 lines not on this page · raw message

include/linux/ddcci.h new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#2 lore raw
Quoted 3 lines · Yusuf Khan

This patch adds the main DDCCI driver. This interfaces with I2C to allow the kernel to communicate with DDCCI supporting monitors, it exports a chardev and sysfs interface for userspace.

Where is the Documentation/ABI/ entries for the sysfs code, and where is the userspace code that uses the chardev interface? And why chardev?

This text says _what_ you are doing, but not _why_ you are doing it.

thanks,

greg k-h

#3 lore raw

[PATCH] drivers: ddcci: fix platform_no_drv_owner.cocci warnings

In reply to Yusuf Khan
drivers/char/ddcci.c:1721:3-8: No need to set .owner here. The core will do it.

From: kernel test robot <[email protected]>

drivers/char/ddcci.c:1721:3-8: No need to set .owner here. The core will do it.

Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

---

url:    https://github.com/intel-lab-lkp/linux/commits/Yusuf-Khan/drivers-ddcci-add-drivers-for-DDCCI/20220404-080905
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 37fd83916da2e4cae03d350015c82a67b1b334c4

:::::: branch date: 13 hours ago
:::::: commit date: 13 hours ago

 drivers/char/ddcci.c |    1 -
 1 file changed, 1 deletion(-)
drivers/char/ddcci.c +0 -1
@@ -1718,7 +1718,6 @@ MODULE_DEVICE_TABLE(i2c, ddcci_idtable);
 static struct i2c_driver ddcci_driver = {
 	.driver = {
 		.name	= "ddcci",
-		.owner	= THIS_MODULE,
 	},
 
 	.id_table	= ddcci_idtable,
#4 lore raw
In reply to Yusuf Khan
Thank you for the patch! Perhaps something to improve:

Hi Yusuf,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on linus/master lee-backlight/for-backlight-next linux/master v5.18-rc1 next-20220404] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Yusuf-Khan/drivers-ddcci-add-drivers-for-DDCCI/20220404-080905
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 37fd83916da2e4cae03d350015c82a67b1b334c4
config: i386-randconfig-c003-20220404 (https://download.01.org/0day-ci/archive/20220404/[email protected]/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0

If you fix the issue, kindly add following tag as appropriate

cocci warnings: (new ones prefixed by >>)

>> drivers/char/ddcci.c:1721:3-8: No need to set .owner here. The core will do it.

Please review and possibly fold the followup patch.

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
author
#5 lore raw

PATCH v10 2/3 drivers: ddcci: add drivers for DDCCI

In reply to Yusuf Khan

This patch adds the backlight driver that utilizes the DDCCI driver from patch one to add a backlight driver.

---
 drivers/video/backlight/Kconfig           |  11 +
 drivers/video/backlight/Makefile          |   1 +
 drivers/video/backlight/ddcci-backlight.c | 411 ++++++++++++++++++++++
 3 files changed, 423 insertions(+)
 create mode 100644 drivers/video/backlight/ddcci-backlight.c
drivers/video/backlight/Kconfig +11 -0
index e32694c13da5..7a26088c3c3f 100644
@@ -289,6 +289,17 @@ config BACKLIGHT_QCOM_WLED
 	  If you have the Qualcomm PMIC, say Y to enable a driver for the
 	  WLED block. Currently it supports PM8941 and PMI8998.
 
+config BACKLIGHT_DDCCI
+	tristate "DDCCI Backlight Driver"
+	depends on DDCCI
+	help
+	  If you have a DDC/CI supporing monitor, say Y to enable a driver
+	  to control its backlight using DDC/CI. This could be useful if
+	  your monitor does not include a backlight driver. For this to be
+	  useful you need to enable DDCCI support which can be found in
+	  Device Drivers -> Character devices and that further depends on
+	  I2C.
+
 config BACKLIGHT_RT4831
 	tristate "Richtek RT4831 Backlight Driver"
 	depends on MFD_RT4831
drivers/video/backlight/Makefile +1 -0
index cae2c83422ae..7bfb6e506b35 100644
@@ -58,3 +58,4 @@ obj-$(CONFIG_BACKLIGHT_WM831X)		+= wm831x_bl.o
 obj-$(CONFIG_BACKLIGHT_ARCXCNN) 	+= arcxcnn_bl.o
 obj-$(CONFIG_BACKLIGHT_RAVE_SP)		+= rave-sp-backlight.o
 obj-$(CONFIG_BACKLIGHT_LED)		+= led_bl.o
+obj-$(CONFIG_BACKLIGHT_DDCCI)		+= ddcci-backlight.o
drivers/video/backlight/ddcci-backlight.c new file +411 -0

411 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#6 lore raw

PATCH v10 3/3 drivers: ddcci: add drivers for DDCCI

In reply to Yusuf Khan

This patch adds Documentation for the DDCCI drivers.

---
 Documentation/ABI/testing/sysfs-driver-ddcci |  57 +++++++++
 Documentation/driver-api/ddcci.rst           | 122 +++++++++++++++++++
 2 files changed, 179 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-ddcci
 create mode 100644 Documentation/driver-api/ddcci.rst
Documentation/ABI/testing/sysfs-driver-ddcci new file +57 -0
new file mode 100644
index 000000000000..19f77ccf3ed0
@@ -0,0 +1,57 @@
+What:		/sys/bus/ddcci/ddcci<I²C bus number>i<hex address>
+Date:		March 2022
+KernelVersion:	5.18
+Contact:	Christoph Grenz <[email protected]>
+Description:	This file is a user interface for an internal
+		dependent device on the I2C bus, it exports the same
+		information as the master device(/sys/bus/ddcci/
+		ddcci<I²C bus number>) that is referenced in this
+		document.
+
+What:		/sys/bus/ddcci/ddcci<I²C bus number>e<hex address>
+Date:		March 2022
+KernelVersion:	5.18
+Contact:	Christoph Grenz <[email protected]>
+Description:	This file is a user interface for an external
+		dependent device on the I2C bus, it exports the same
+		information as the master device(/sys/bus/ddcci/
+		ddcci<I²C bus number>) that is referenced in this
+		document.
+
+What:		/sys/bus/ddcci/ddcci<I²C bus number>
+Date:		March 2022
+KernelVersion:	5.18
+Contact:	Christoph Grenz <[email protected]>
+Description:	This file provides the user interface for the
+		master device on the I2C bus. It exports the following
+		peices of information:
+		- idProt
+		ACCESS.bus protocol supported by the device. Usually
+		"monitor".
+
+		- idType
+		ACCESS.bus device subtype. Usually "LCD" or "CRT".
+
+		- idModel
+		ACCESS.bus device model identifier. Usually a
+		shortened form of the device model name.
+
+		- idVendor
+		ACCESS.bus device vendor identifier. Empty if the
+		Identification command is not supported.
+
+		- idModule
+		ACCESS.bus device module identifier. Empty if the
+		Identification command is not supported.
+
+		- idSerial
+		32 bit device number. A fixed serial number if it's
+		positive, a temporary serial number if negative and zero
+		if the Identification command is not supported.
+
+		- modalias
+		A combined identifier for driver selection. It has the form:
+		ddcci:<idProt>-<idType>-<idModel>-<idVendor>-<idModule>.
+		All non-alphanumeric characters (including whitespace)
+		in the model, vendor or module parts are replaced by
+		underscores to prevent issues with software like systemd-udevd.
Documentation/driver-api/ddcci.rst new file +122 -0

122 lines not on this page · raw message

Signature · 1 line
2.25.1
reviewer
#7 lore raw
In reply to Yusuf Khan

Hi--

Quoted 4 lines · Yusuf Khan

This patch adds the DDCCI driver by Christoph Grenz into the kernel. The original gitlab page is loacted at https://gitlab.com/ddcci-driv
er-linux/ddcci-driver-linux/-/tree/master.

...

Quoted 4 lines

v10: Change patch title to "drivers: ddcci: add drivers for DDCCI and change" and change patch descriptions to add more detailed explanations of function.

Greg KH recently said [1] that the Subject: for each patch should not be the same, yet they still are the same. This is not good.

[1] https://lore.kernel.org/lkml/[email protected]/

Signature · 1 line
~Randy
maintainer
#8 lore raw
In reply to Yusuf Khan
Quoted 3 lines · Yusuf Khan

v10: Change patch title to "drivers: ddcci: add drivers for DDCCI and change" and change patch descriptions to add more detailed explanations of function.

As Randy points out, the subjects can not all be the same as obviously the patches are not doing all the same thing. Please read the kernel documentation for how to write good subject lines and good changelog texts.

thanks,

greg k-h

#9 lore raw
In reply to Yusuf Khan

Hi Yusuf,

Quoted 10 lines · Yusuf Khan

This patch adds the DDCCI driver by Christoph Grenz into the kernel. The original gitlab page is loacted at https://gitlab.com/ddcci-driv
er-linux/ddcci-driver-linux/-/tree/master.

DDC/CI is a control protocol for monitor settings supported by most monitors since about 2005. A chardev and sysfs interface is provided. A backlight driver using DDCCI is also provided in the seccond patch.

Thank you for your submission of this patch series.

I must say that I'm a bit surprised that this series was NOT also send to the drm/kms subsystem maintainers and mailinglists since this deals with monitors and thus is highly relevant for those folks. Luckily I saw an article about this at Phoronix (you write in the changelog that you believe that there is no interaction with the DRM/KMS subsystems but that is wrong).

One very important thing which I'm missing in this cover-letter is why you want to have this in the kernel at all? There are already various tools which do DDCCI from userspace just fine.

I guess you may be interested in offering /sys/class/backlight functionality for external monitors. That is actually something which I'm interested in too, but it is not that simple.

The current /sys/class/backlight interface does not offer a way for userspace to map a /sys/class/backlight device to a specific display-output / monitor. So userspace currently assumes that there is only 1 (1 valid) /sys/class/backlight device and that that *always* belongs to the internal LCD panel of a laptop.

So just adding /sys/class/backlight device(s) for internal monitors without addressing the short-comings of the existing userspace interface is simply not possible because it would break existing userspace which is something which is not allowed.

So NACK from me for the backlight part at least and without that, I really see no reason to do this in the kernel rather then userspace.

I've recently been discussing this with a colleague of mine, Sebastian Wick and as a result of that I'm giving a talk with a proposal for a better userspace API for this at kernel-recipes:
https://kernel-recipes.org/en/2022/talks/new-userspace-api-for-display-panel-brightness-control/

I hope to start working on a RFC patch series for this soon.

IMHO merging this series should be put on hold until we have a better idea of how we want to solve the userspace API challenges, esp. the monitor <-> /sys/class/backlight mapping problem.

Regards,

Hans

p.s.

This is not the first time this has come up:

https://lore.kernel.org/all/[email protected]/
https://www.x.org/wiki/Events/XDC2014/XDC2014GoedeBacklight/

Quoted 63 lines

---
v2: Fix typos.

v3: Add documentation, move files around, replace semaphores with mutexes, and replaced <asm-generic/fcntl.h> with <linux/fcntl.h>. "imirkin"(which due to his involvement in the dri-devel irc channel I cant help but assume to be a DRM developer) said that the DDC/CI bus does not intefere with the buses that DRM is involved with.

v4: Move some documentation, fix grammer mistakes, remove usages of likely(), and clarify some documentation.

v5: Fix grammer mistakes, remove usages of likely(), and clarify some documentation.

v6: Change contact information to reference Christoph Grenz.

v7: Remove all instances of the unlikely() macro.

v8: Modify documentation to provide updated date and kernel documentation, fix SPDX lines, use isalpha instead of redefining logic, change maximum amount of bytes that can be written to be conformant with DDC/CI specification, prevent userspace from holding locks with the open file descriptor, remove ddcci_cdev_seek, dont refine sysfs_emit() logic, use EXPORT_SYMBOL_GPL instead of EXPORT_SYMBOL, remove ddcci_device_remove_void, remove module paramaters and version, and split into 2 patches.

v9: Fix IS_ANY_ID matching for compilers and archs where char is unsigned char and use the cannonical patch format.

v10: Change patch title to "drivers: ddcci: add drivers for DDCCI and change" and change patch descriptions to add more detailed explanations of function.

Patch 1: Add the main DDCCI component.

Patch 2: Add the backlight driver that utilizes the DDCCI driver.

Patch 3: Add documentation for the DDCCI drivers.

Yusuf Khan (3):
drivers: ddcci: add drivers for DDCCI
drivers: ddcci: add drivers for DDCCI
drivers: ddcci: add drivers for DDCCI

 Documentation/ABI/testing/sysfs-driver-ddcci |   57 +
 Documentation/driver-api/ddcci.rst           |  122 ++
 drivers/char/Kconfig                         |   11 +
 drivers/char/Makefile                        |    1 +
 drivers/char/ddcci.c                         | 1805 ++++++++++++++++++
 drivers/video/backlight/Kconfig              |   11 +
 drivers/video/backlight/Makefile             |    1 +
 drivers/video/backlight/ddcci-backlight.c    |  411 ++++
 include/linux/ddcci.h                        |  163 ++
 9 files changed, 2582 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-ddcci
 create mode 100644 Documentation/driver-api/ddcci.rst
 create mode 100644 drivers/char/ddcci.c
 create mode 100644 drivers/video/backlight/ddcci-backlight.c
 create mode 100644 include/linux/ddcci.h