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>,
Javier Martinez Canillas <javierm@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org,
Marcus Folkesson <marcus.folkesson@gmail.com>
Subject: [PATCH v3 3/7] drm/sitronix/st7571-i2c: move common structures to st7571.h
Date: Mon, 15 Dec 2025 10:46:45 +0100 [thread overview]
Message-ID: <20251215-st7571-split-v3-3-d5f3205c3138@gmail.com> (raw)
In-Reply-To: <20251215-st7571-split-v3-0-d5f3205c3138@gmail.com>
Move all structures that will be common for all interfaces (SPI/I2C) to
a separate header file.
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
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 c830fd648572..ac4293d5089c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8106,6 +8106,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 2b52919d7dd4..af27658a5e15 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 000000000000..c6fd6f1d3aa3
--- /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.51.2
next prev parent reply other threads:[~2025-12-15 9:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 9:46 [PATCH v3 0/7] drm/sitronix/st7571: split up driver to support both I2C and SPI Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 1/7] drm/sitronix/st7571-i2c: rename 'struct drm_device' in st7571_device Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 2/7] drm/sitronix/st7571-i2c: add 'struct device' to st7571_device Marcus Folkesson
2025-12-15 9:46 ` Marcus Folkesson [this message]
2025-12-15 9:46 ` [PATCH v3 4/7] drm/sitronix/st7571-i2c: make probe independent of hw interface Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 5/7] drm/sitronix/st7571: split up the driver into a common and an i2c part Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 6/7] drm/sitronix/st7571-spi: add support for SPI interface Marcus Folkesson
2025-12-15 9:46 ` [PATCH v3 7/7] dt-bindings: display: sitronix,st7571: add example for SPI Marcus Folkesson
2025-12-15 12:57 ` [PATCH v3 0/7] drm/sitronix/st7571: split up driver to support both I2C and SPI Javier Martinez Canillas
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=20251215-st7571-split-v3-3-d5f3205c3138@gmail.com \
--to=marcus.folkesson@gmail.com \
--cc=airlied@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=robh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).