From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Marcus Folkesson <marcus.folkesson@gmail.com>
Subject: [PATCH v2 3/6] drm/sitronix/st7571-i2c: move common structures to st7571.h
Date: Mon, 27 Oct 2025 09:05:43 +0100 [thread overview]
Message-ID: <20251027-st7571-split-v2-3-8352fb278d21@gmail.com> (raw)
In-Reply-To: <20251027-st7571-split-v2-0-8352fb278d21@gmail.com>
Move all structures that will be common for all interfaces (SPI/I2C) to
a separate header file.
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
MAINTAINERS | 1 +
drivers/gpu/drm/sitronix/st7571-i2c.c | 91 +---------------------------
drivers/gpu/drm/sitronix/st7571.h | 108 ++++++++++++++++++++++++++++++++++
3 files changed, 111 insertions(+), 89 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index cc8a7f3f1dabaf402b21f767ecb093a31ade248f..2814faae61eceecae1bccaaf92010e22dca81376 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8083,6 +8083,7 @@ S: Maintained
F: Documentation/devicetree/bindings/display/sitronix,st7567.yaml
F: Documentation/devicetree/bindings/display/sitronix,st7571.yaml
F: drivers/gpu/drm/sitronix/st7571-i2c.c
+F: drivers/gpu/drm/sitronix/st7571.h
DRM DRIVER FOR SITRONIX ST7701 PANELS
M: Jagan Teki <jagan@amarulasolutions.com>
diff --git a/drivers/gpu/drm/sitronix/st7571-i2c.c b/drivers/gpu/drm/sitronix/st7571-i2c.c
index 2b52919d7dd434bb16aa66274eae8730649f62f1..af27658a5e152534d445bc623893eee6b3ca00d5 100644
--- a/drivers/gpu/drm/sitronix/st7571-i2c.c
+++ b/drivers/gpu/drm/sitronix/st7571-i2c.c
@@ -35,6 +35,8 @@
#include <video/display_timing.h>
#include <video/of_display_timing.h>
+#include "st7571.h"
+
#define ST7571_COMMAND_MODE (0x00)
#define ST7571_DATA_MODE (0x40)
@@ -78,95 +80,6 @@
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 0
-enum st7571_color_mode {
- ST7571_COLOR_MODE_GRAY = 0,
- ST7571_COLOR_MODE_BLACKWHITE = 1,
-};
-
-struct st7571_device;
-
-struct st7571_panel_constraints {
- u32 min_nlines;
- u32 max_nlines;
- u32 min_ncols;
- u32 max_ncols;
- bool support_grayscale;
-};
-
-struct st7571_panel_data {
- int (*init)(struct st7571_device *st7571);
- int (*parse_dt)(struct st7571_device *st7571);
- struct st7571_panel_constraints constraints;
-};
-
-struct st7571_panel_format {
- void (*prepare_buffer)(struct st7571_device *st7571,
- const struct iosys_map *vmap,
- struct drm_framebuffer *fb,
- struct drm_rect *rect,
- struct drm_format_conv_state *fmtcnv_state);
- int (*update_rect)(struct drm_framebuffer *fb, struct drm_rect *rect);
- enum st7571_color_mode mode;
- const u8 nformats;
- const u32 formats[];
-};
-
-struct st7571_device {
- struct drm_device drm;
- struct device *dev;
-
- struct drm_plane primary_plane;
- struct drm_crtc crtc;
- struct drm_encoder encoder;
- struct drm_connector connector;
-
- struct drm_display_mode mode;
-
- const struct st7571_panel_format *pformat;
- const struct st7571_panel_data *pdata;
- struct i2c_client *client;
- struct gpio_desc *reset;
- struct regmap *regmap;
-
- /*
- * Depending on the hardware design, the acknowledge signal may be hard to
- * recognize as a valid logic "0" level.
- * Therefor, ignore NAK if possible to stay compatible with most hardware designs
- * and off-the-shelf panels out there.
- *
- * From section 6.4 MICROPOCESSOR INTERFACE section in the datasheet:
- *
- * "By connecting SDA_OUT to SDA_IN externally, the SDA line becomes fully
- * I2C interface compatible.
- * Separating acknowledge-output from serial data
- * input is advantageous for chip-on-glass (COG) applications. In COG
- * applications, the ITO resistance and the pull-up resistor will form a
- * voltage divider, which affects acknowledge-signal level. Larger ITO
- * resistance will raise the acknowledged-signal level and system cannot
- * recognize this level as a valid logic “0” level. By separating SDA_IN from
- * SDA_OUT, the IC can be used in a mode that ignores the acknowledge-bit.
- * For applications which check acknowledge-bit, it is necessary to minimize
- * the ITO resistance of the SDA_OUT trace to guarantee a valid low level."
- *
- */
- bool ignore_nak;
-
- bool grayscale;
- bool inverted;
- u32 height_mm;
- u32 width_mm;
- u32 startline;
- u32 nlines;
- u32 ncols;
- u32 bpp;
-
- /* Intermediate buffer in LCD friendly format */
- u8 *hwbuf;
-
- /* Row of (transformed) pixels ready to be written to the display */
- u8 *row;
-};
-
static inline struct st7571_device *drm_to_st7571(struct drm_device *drm)
{
return container_of(drm, struct st7571_device, drm);
diff --git a/drivers/gpu/drm/sitronix/st7571.h b/drivers/gpu/drm/sitronix/st7571.h
new file mode 100644
index 0000000000000000000000000000000000000000..c6fd6f1d3aa33d6b43330ce8f2cb2d3f2321b29b
--- /dev/null
+++ b/drivers/gpu/drm/sitronix/st7571.h
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Header file for:
+ * Driver for Sitronix ST7571, a 4 level gray scale dot matrix LCD controller
+ *
+ * Copyright (C) 2025 Marcus Folkesson <marcus.folkesson@gmail.com>
+ */
+
+#ifndef __ST7571_H__
+#define __ST7571_H__
+
+#include <drm/drm_connector.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_encoder.h>
+
+#include <linux/regmap.h>
+
+enum st7571_color_mode {
+ ST7571_COLOR_MODE_GRAY = 0,
+ ST7571_COLOR_MODE_BLACKWHITE = 1,
+};
+
+struct st7571_device;
+
+struct st7571_panel_constraints {
+ u32 min_nlines;
+ u32 max_nlines;
+ u32 min_ncols;
+ u32 max_ncols;
+ bool support_grayscale;
+};
+
+struct st7571_panel_data {
+ int (*init)(struct st7571_device *st7571);
+ int (*parse_dt)(struct st7571_device *st7571);
+ struct st7571_panel_constraints constraints;
+};
+
+struct st7571_panel_format {
+ void (*prepare_buffer)(struct st7571_device *st7571,
+ const struct iosys_map *vmap,
+ struct drm_framebuffer *fb,
+ struct drm_rect *rect,
+ struct drm_format_conv_state *fmtcnv_state);
+ int (*update_rect)(struct drm_framebuffer *fb, struct drm_rect *rect);
+ enum st7571_color_mode mode;
+ const u8 nformats;
+ const u32 formats[];
+};
+
+struct st7571_device {
+ struct drm_device drm;
+ struct device *dev;
+
+ struct drm_plane primary_plane;
+ struct drm_crtc crtc;
+ struct drm_encoder encoder;
+ struct drm_connector connector;
+
+ struct drm_display_mode mode;
+
+ const struct st7571_panel_format *pformat;
+ const struct st7571_panel_data *pdata;
+ struct i2c_client *client;
+ struct gpio_desc *reset;
+ struct regmap *regmap;
+
+ /*
+ * Depending on the hardware design, the acknowledge signal may be hard to
+ * recognize as a valid logic "0" level.
+ * Therefor, ignore NAK if possible to stay compatible with most hardware designs
+ * and off-the-shelf panels out there.
+ *
+ * From section 6.4 MICROPOCESSOR INTERFACE section in the datasheet:
+ *
+ * "By connecting SDA_OUT to SDA_IN externally, the SDA line becomes fully
+ * I2C interface compatible.
+ * Separating acknowledge-output from serial data
+ * input is advantageous for chip-on-glass (COG) applications. In COG
+ * applications, the ITO resistance and the pull-up resistor will form a
+ * voltage divider, which affects acknowledge-signal level. Larger ITO
+ * resistance will raise the acknowledged-signal level and system cannot
+ * recognize this level as a valid logic “0” level. By separating SDA_IN from
+ * SDA_OUT, the IC can be used in a mode that ignores the acknowledge-bit.
+ * For applications which check acknowledge-bit, it is necessary to minimize
+ * the ITO resistance of the SDA_OUT trace to guarantee a valid low level."
+ *
+ */
+ bool ignore_nak;
+
+ bool grayscale;
+ bool inverted;
+ u32 height_mm;
+ u32 width_mm;
+ u32 startline;
+ u32 nlines;
+ u32 ncols;
+ u32 bpp;
+
+ /* Intermediate buffer in LCD friendly format */
+ u8 *hwbuf;
+
+ /* Row of (transformed) pixels ready to be written to the display */
+ u8 *row;
+};
+
+#endif /* __ST7571_H__ */
--
2.50.1
next prev parent reply other threads:[~2025-10-27 8:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 8:05 [PATCH v2 0/6] drm/sitronix/st7571: split up driver to support both I2C and SPI Marcus Folkesson
2025-10-27 8:05 ` [PATCH v2 1/6] drm/sitronix/st7571-i2c: rename 'struct drm_device' in st7571_device Marcus Folkesson
2025-10-27 8:05 ` [PATCH v2 2/6] drm/sitronix/st7571-i2c: add 'struct device' to st7571_device Marcus Folkesson
2025-10-27 8:05 ` Marcus Folkesson [this message]
2025-10-27 8:05 ` [PATCH v2 4/6] drm/sitronix/st7571-i2c: make probe independent of hw interface Marcus Folkesson
2025-10-27 8:05 ` [PATCH v2 5/6] drm/sitronix/st7571: split up the driver into a common and an i2c part Marcus Folkesson
2025-10-27 8:05 ` [PATCH v2 6/6] drm/sitronix/st7571-spi: add support for SPI interface Marcus Folkesson
2025-11-10 9:05 ` [PATCH v2 0/6] drm/sitronix/st7571: split up driver to support both I2C and SPI Marcus Folkesson
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=20251027-st7571-split-v2-3-8352fb278d21@gmail.com \
--to=marcus.folkesson@gmail.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.