From: Hefei <3066883572@qq.com>
To: dri-devel@lists.freedesktop.org
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 6/6] backlight: add VIEWE I2C backlight driver
Date: Thu, 19 Nov 2026 10:48:12 +0800 [thread overview]
Message-ID: <tencent_87F1AA0F0CABDAEF48428FA7BB5F24D48D07@qq.com> (raw)
Add a simple I2C backlight class driver for the VIEWE panel MCU at
address 0x45, register 0x86.
Signed-off-by: Hefei <3066883572@qq.com>
---
drivers/video/backlight/Kconfig | 7 ++
drivers/video/backlight/Makefile | 1 +
drivers/video/backlight/viewe_bl_i2c.c | 91 ++++++++++++++++++++++++++
3 files changed, 99 insertions(+)
create mode 100644 drivers/video/backlight/viewe_bl_i2c.c
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 7b836f9..8ea7332 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -501,6 +501,13 @@ config BACKLIGHT_LED
If you have a LCD backlight adjustable by LED class driver, say Y
to enable this driver.
+config BACKLIGHT_VIEWE_I2C
+ tristate "VIEWE I2C backlight"
+ depends on I2C
+ help
+ Backlight driver for VIEWE DSI panels. Brightness is written to
+ the panel MCU at I2C address 0x45, register 0x86.
+
endif # BACKLIGHT_CLASS_DEVICE
endmenu
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index bcb568a..b82d959 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -61,3 +61,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_VIEWE_I2C) += viewe_bl_i2c.o
diff --git a/drivers/video/backlight/viewe_bl_i2c.c b/drivers/video/backlight/viewe_bl_i2c.c
new file mode 100644
index 0000000..3be1759
--- /dev/null
+++ b/drivers/video/backlight/viewe_bl_i2c.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2026 VIEWE
+ *
+ * I2C backlight for VIEWE DSI panels (MCU @0x45, register 0x86, 0..255).
+ */
+
+#include <linux/backlight.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+#define VIEWE_BL_REG 0x86
+#define VIEWE_BL_MAX 255
+#define VIEWE_BL_DEFAULT 200
+
+struct viewe_bl {
+ struct i2c_client *client;
+ struct backlight_device *bd;
+};
+
+static int viewe_bl_update_status(struct backlight_device *bd)
+{
+ struct viewe_bl *bl = bl_get_data(bd);
+ u8 buf[2] = { VIEWE_BL_REG, (u8)backlight_get_brightness(bd) };
+ struct i2c_msg msg = {
+ .addr = bl->client->addr,
+ .flags = 0,
+ .len = sizeof(buf),
+ .buf = buf,
+ };
+ int ret;
+
+ ret = i2c_transfer(bl->client->adapter, &msg, 1);
+ return ret == 1 ? 0 : (ret < 0 ? ret : -EIO);
+}
+
+static const struct backlight_ops viewe_bl_ops = {
+ .update_status = viewe_bl_update_status,
+};
+
+static int viewe_bl_probe(struct i2c_client *client)
+{
+ struct backlight_properties props = {
+ .type = BACKLIGHT_RAW,
+ .brightness = VIEWE_BL_DEFAULT,
+ .max_brightness = VIEWE_BL_MAX,
+ };
+ struct viewe_bl *bl;
+
+ bl = devm_kzalloc(&client->dev, sizeof(*bl), GFP_KERNEL);
+ if (!bl)
+ return -ENOMEM;
+
+ bl->client = client;
+ i2c_set_clientdata(client, bl);
+
+ bl->bd = devm_backlight_device_register(&client->dev, "viewe_bl",
+ &client->dev, bl, &viewe_bl_ops,
+ &props);
+ if (IS_ERR(bl->bd))
+ return PTR_ERR(bl->bd);
+
+ return 0;
+}
+
+static const struct of_device_id viewe_bl_of_match[] = {
+ { .compatible = "viewe,i2c-backlight" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, viewe_bl_of_match);
+
+static const struct i2c_device_id viewe_bl_id[] = {
+ { "viewe_bl", 0 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, viewe_bl_id);
+
+static struct i2c_driver viewe_bl_driver = {
+ .driver = {
+ .name = "viewe_bl_i2c",
+ .of_match_table = viewe_bl_of_match,
+ },
+ .probe = viewe_bl_probe,
+ .id_table = viewe_bl_id,
+};
+module_i2c_driver(viewe_bl_driver);
+
+MODULE_AUTHOR("Hefei <3066883572@qq.com>");
+MODULE_DESCRIPTION("VIEWE I2C backlight");
+MODULE_LICENSE("GPL");
--
2.55.0.windows.5
reply other threads:[~2026-11-19 2:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_87F1AA0F0CABDAEF48428FA7BB5F24D48D07@qq.com \
--to=3066883572@qq.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®