drivers/gpu/drm/sitronix/st7571.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sitronix/st7571.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sitronix/st7571.c- Extension
.c- Size
- 25347 bytes
- Lines
- 919
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/module.hlinux/regmap.hdrm/clients/drm_client_setup.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_connector.hdrm/drm_crtc_helper.hdrm/drm_damage_helper.hdrm/drm_drv.hdrm/drm_encoder.hdrm/drm_fb_helper.hdrm/drm_fbdev_shmem.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_gem_shmem_helper.hdrm/drm_modeset_helper_vtables.hdrm/drm_module.hdrm/drm_plane.hdrm/drm_probe_helper.hvideo/display_timing.hvideo/of_display_timing.hst7571.h
Detected Declarations
function Copyrightfunction st7571_send_command_listfunction st7571_transform_xyfunction st7571_set_positionfunction st7571_fb_clear_screenfunction st7571_prepare_buffer_monochromefunction st7571_prepare_buffer_grayscalefunction st7571_fb_update_rect_monochromefunction st7571_fb_update_rect_grayscalefunction st7571_connector_get_modesfunction st7571_primary_plane_helper_atomic_checkfunction st7571_primary_plane_helper_atomic_updatefunction st7571_primary_plane_helper_atomic_disablefunction st7571_crtc_mode_validfunction st7571_encoder_atomic_enablefunction st7571_encoder_atomic_disablefunction st7571_modefunction st7571_mode_config_initfunction st7571_plane_initfunction st7571_crtc_initfunction st7571_encoder_initfunction st7571_connector_initfunction st7571_validate_parametersfunction st7567_parse_dtfunction st7571_parse_dtfunction st7571_resetfunction st7567_lcd_initfunction st7571_lcd_initfunction st7571_removeexport st7571_probeexport st7571_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Driver for Sitronix ST7571, a 4 level gray scale dot matrix LCD controller
*
* Copyright (C) 2025 Marcus Folkesson <marcus.folkesson@gmail.com>
*/
#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <drm/clients/drm_client_setup.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_connector.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_encoder.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_fbdev_shmem.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_module.h>
#include <drm/drm_plane.h>
#include <drm/drm_probe_helper.h>
#include <video/display_timing.h>
#include <video/of_display_timing.h>
#include "st7571.h"
#define ST7571_COMMAND_MODE (0x00)
#define ST7571_DATA_MODE (0x40)
/* Normal mode command set */
#define ST7571_DISPLAY_OFF (0xae)
#define ST7571_DISPLAY_ON (0xaf)
#define ST7571_OSC_ON (0xab)
#define ST7571_SET_COLUMN_LSB(c) (0x00 | FIELD_PREP(GENMASK(3, 0), (c)))
#define ST7571_SET_COLUMN_MSB(c) (0x10 | FIELD_PREP(GENMASK(2, 0), (c) >> 4))
#define ST7571_SET_COM0_LSB(x) (FIELD_PREP(GENMASK(6, 0), (x)))
#define ST7571_SET_COM0_MSB (0x44)
#define ST7571_SET_COM_SCAN_DIR(d) (0xc0 | FIELD_PREP(GENMASK(3, 3), (d)))
#define ST7571_SET_CONTRAST_LSB(c) (FIELD_PREP(GENMASK(5, 0), (c)))
#define ST7571_SET_CONTRAST_MSB (0x81)
#define ST7571_SET_DISPLAY_DUTY_LSB(d) (FIELD_PREP(GENMASK(7, 0), (d)))
#define ST7571_SET_DISPLAY_DUTY_MSB (0x48)
#define ST7571_SET_ENTIRE_DISPLAY_ON(p) (0xa4 | FIELD_PREP(GENMASK(0, 0), (p)))
#define ST7571_SET_LCD_BIAS(b) (0x50 | FIELD_PREP(GENMASK(2, 0), (b)))
#define ST7571_SET_MODE_LSB(m) (FIELD_PREP(GENMASK(7, 2), (m)))
#define ST7571_SET_MODE_MSB (0x38)
#define ST7571_SET_PAGE(p) (0xb0 | FIELD_PREP(GENMASK(3, 0), (p)))
#define ST7571_SET_POWER(p) (0x28 | FIELD_PREP(GENMASK(2, 0), (p)))
#define ST7571_SET_REGULATOR_REG(r) (0x20 | FIELD_PREP(GENMASK(2, 0), (r)))
#define ST7571_SET_REVERSE(r) (0xa6 | FIELD_PREP(GENMASK(0, 0), (r)))
#define ST7571_SET_SEG_SCAN_DIR(d) (0xa0 | FIELD_PREP(GENMASK(0, 0), (d)))
#define ST7571_SET_START_LINE_LSB(l) (FIELD_PREP(GENMASK(6, 0), (l)))
#define ST7571_SET_START_LINE_MSB (0x40)
/* Extension command set 3 */
#define ST7571_COMMAND_SET_3 (0x7b)
#define ST7571_SET_COLOR_MODE(c) (0x10 | FIELD_PREP(GENMASK(0, 0), (c)))
#define ST7571_COMMAND_SET_NORMAL (0x00)
/* ST7567 commands */
#define ST7567_SET_LCD_BIAS(m) (0xa2 | FIELD_PREP(GENMASK(0, 0), (m)))
#define ST7571_PAGE_HEIGHT 8
#define DRIVER_NAME "st7571"
#define DRIVER_DESC "ST7571 DRM driver"
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 0
static inline struct st7571_device *drm_to_st7571(struct drm_device *drm)
{
return container_of(drm, struct st7571_device, drm);
}
static int st7571_send_command_list(struct st7571_device *st7571,
const u8 *cmd_list, size_t len)
{
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `drm/clients/drm_client_setup.h`, `drm/drm_atomic.h`.
- Detected declarations: `function Copyright`, `function st7571_send_command_list`, `function st7571_transform_xy`, `function st7571_set_position`, `function st7571_fb_clear_screen`, `function st7571_prepare_buffer_monochrome`, `function st7571_prepare_buffer_grayscale`, `function st7571_fb_update_rect_monochrome`, `function st7571_fb_update_rect_grayscale`, `function st7571_connector_get_modes`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.