drivers: ddcci: upstream DDCCI driver
PATCH v9 1/1 drivers: ddcci: upstream DDCCI driver
This patch upstreams(adds) the DDCCI driver by Christoph Grenz into the kernel. The original gitlab page is loacted at https://gitlab
.com/ddcci-driver-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. The seccond patch in this series provides a backlight driver using DDC/CI.
---
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.
Patch 1: Add the main DDCCI component.
Patch 2: Add the backlight driver that utilizes DDCCI.
Patch 3: Add documentation for the DDCCI drivers.
Yusuf Khan (3):
drivers: ddcci: upstream DDCCI driver
drivers: ddcci: upstream DDCCI driver
drivers: ddcci: upstream DDCCI driver
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
PATCH v9 1/1 drivers: ddcci: upstream DDCCI driver
This patch adds the main DDCCI driver.
--- 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
@@ -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
@@ -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
PATCH v9 1/1 drivers: ddcci: upstream DDCCI driver
In reply to Yusuf KhanThis patch adds the backlight driver that utilizes the DDCCI protocol to add backlight support.
--- 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
@@ -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
@@ -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
PATCH v9 1/1 drivers: ddcci: upstream DDCCI driver
In reply to Yusuf KhanThis patch adds Documentation for the DDCCI driver.
--- 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
@@ -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
Sorry for the incorrect titles, ill send another patch series shortly with everything
sorted.
Quoted 206 lines · Yusuf Khan
This patch adds Documentation for the DDCCI driver.
Signed-off-by Yusuf Khan <[email protected]>Signed-off-by Christoph Grenz <[email protected]>--- 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.rstDocumentation/ABI/testing/sysfs-driver-ddcci new file +57
-0@@ -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
-1@@ -0,0 +1,122 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +============== +DDC/CI +============== + +1. Introduction +=============== +DDC/CI is a control protocol for monitor settings supported by most +monitors since about 2005. It is based on ACCESS.bus (an early USB predecessor). +This could be used to create drivers that communicate with the DDCCI component, +see ddcci-backlight for an example. + +2. sysfs interface +================== +Each detected DDC/CI device gets a directory in /sys/bus/ddcci/devices. +The main device on a bus is named ddcci[I²C bus number]. +Internal dependent devices are named ddcci[I²C bus number]i[hex address] +External dependent devices are named ddcci[I²C bus number]e[hex address] +There the following files export information about the device: + +capabilities +The full ACCESS.bus capabilities string. It contains the protocol, +type and model of the device, a list of all supported command +codes, etc. See the ACCESS.bus spec for more 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. + +3. Character device interface +============================= +For each DDC/CI device a character device in +/dev/bus/ddcci/[I²C bus number]/ is created, +127 devices are assigned in total. + +The main device on the bus is named display. + +Internal dependent devices are named i[hex address] + +External dependent devices are named e[hex address] + +These character devices can be used to issue commands to a DDC/CI device +more easily than over i2c-dev devices. They should be opened unbuffered. +To send a command just write the command byte and the arguments with a +single write() operation. The length byte and checksum are automatically +calculated. + +To read a response use read() with a buffer big enough for the expected answer. + +NOTE: The maximum length of a DDC/CI message is 32 bytes. + +4. ddcci-backlight (monitor backlight driver) +============================================= +[This is not specific to the DDC/CI backlight driver, if you already dealt with +backlight drivers, skip over this.] + +For each monitor that supports accessing the Backlight Level White +or the Luminance property, a backlight device of type "raw" named like the +corresponding ddcci device is created. You can find them in /sys/class/backlight/. +For convenience a symlink "ddcci_backlight" on the device associated with the +display connector in /sys/class/drm/ to the backlight device is created, as +long as the graphics driver allows to make this association. + +5. Limitations +============== + +-Dependent devices (sub devices using DDC/CI directly wired to the monitor, +like Calibration devices, IR remotes, etc.) aren't automatically detected. +You can force detection of external dependent devices by writing +"ddcci-dependent [address]" into /sys/bus/i2c/i2c-?/new_device. + +There is no direct synchronization if you manually change the luminance +with the buttons on your monitor, as this can only be realized through polling +and some monitors close their OSD every time a DDC/CI command is received. + +Monitor hotplugging is not detected. You need to detach/reattach the I²C driver +or reload the module. + +6. Debugging +============ +Both drivers use the dynamic debugging feature of the Linux kernel. +To get detailed debugging messages, set the dyndbg module parameter. +If you want to enable debugging permanently across reboots, create a file +/etc/modprobe.d/ddcci.conf containing lines like the following before loading the modules: + +options ddcci dyndbg +options ddcci-backlight dyndbg + +7. Origin +============ +This driver originally came from Christoph Grenz in DKMS form here: +https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux +with multiple backups available on the wayback machine. It also +inlcudes a example program for the usage of this driver in +userland. --2.25.1