drivers/gpu/drm/sitronix/st7920.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sitronix/st7920.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sitronix/st7920.c- Extension
.c- Size
- 23407 bytes
- Lines
- 868
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/bitrev.hlinux/delay.hlinux/gpio/consumer.hlinux/module.hlinux/regmap.hlinux/spi/spi.hdrm/clients/drm_client_setup.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_crtc_helper.hdrm/drm_damage_helper.hdrm/drm_drv.hdrm/drm_fbdev_shmem.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_gem_shmem_helper.hdrm/drm_plane.hdrm/drm_print.hdrm/drm_probe_helper.h
Detected Declarations
struct spi7920_errorstruct st7920_devicestruct st7920_plane_statestruct st7920_crtc_statefunction st7920_store_gdram_addressfunction st7920_store_gdram_datafunction st7920_store_othersfunction st7920_spi_writefunction st7920_power_onfunction st7920_power_offfunction st7920_hw_resetfunction st7920_initfunction st7920_update_rectfunction st7920_clear_screenfunction st7920_fb_blit_rectfunction st7920_primary_plane_atomic_checkfunction st7920_primary_plane_atomic_updatefunction drm_atomic_for_each_plane_damagefunction st7920_primary_plane_atomic_disablefunction st7920_primary_plane_resetfunction st7920_primary_plane_destroy_statefunction st7920_crtc_mode_validfunction st7920_crtc_atomic_checkfunction st7920_crtc_atomic_enablefunction st7920_crtc_atomic_disablefunction st7920_crtc_resetfunction st7920_crtc_destroy_statefunction st7920_connector_get_modesfunction st7920_init_modesetfunction st7920_probefunction st7920_removefunction st7920_shutdown
Annotated Snippet
struct spi7920_error {
int errno;
};
struct st7920_device {
struct drm_device drm;
struct drm_display_mode mode;
struct drm_plane primary_plane;
struct drm_crtc crtc;
struct drm_encoder encoder;
struct drm_connector connector;
struct spi_device *spi;
struct regmap *regmap;
struct gpio_desc *reset_gpio;
u32 height;
u32 width;
};
struct st7920_plane_state {
struct drm_shadow_plane_state base;
/* Intermediate buffer to convert pixels from XRGB8888 to HW format */
u8 *buffer;
};
struct st7920_crtc_state {
struct drm_crtc_state base;
/* Buffer to store pixels in HW format and written to the panel */
u8 *data_array;
};
static inline struct st7920_plane_state *to_st7920_plane_state(struct drm_plane_state *state)
{
return container_of(state, struct st7920_plane_state, base.base);
}
static inline struct st7920_crtc_state *to_st7920_crtc_state(struct drm_crtc_state *state)
{
return container_of(state, struct st7920_crtc_state, base);
}
static inline struct st7920_device *drm_to_st7920(struct drm_device *drm)
{
return container_of(drm, struct st7920_device, drm);
}
static int st7920_store_gdram_address(const void *data, u8 *reg)
{
const u8 y_addr = *(const u8 *)data;
bool bottom_screen = (y_addr >= 32);
int i = 0;
reg[i++] = SYNC_BITS;
/* Set vertical address */
if (!bottom_screen)
reg[i++] = TOP_VERTICAL_ADDRESS + (*(uint8_t *)data & HIGH_DATA_MASK);
else
reg[i++] = BOTTOM_VERTICAL_ADDRESS + (*(uint8_t *)data & HIGH_DATA_MASK);
reg[i++] = *(uint8_t *)data << 4;
/* Set horizontal address */
reg[i++] = SET_GDRAM_ADDRESS;
if (!bottom_screen)
reg[i++] = TOP_HORIZONTAL_ADDRESS;
else
reg[i++] = BOTTOM_HORIZONTAL_ADDRESS;
return i;
}
static int st7920_store_gdram_data(const void *data, u8 *reg)
{
const u8 *line_data = data;
int i = 0, j = 0;
reg[i++] = SYNC_BITS | RS_HIGH;
for (j = 0; j < 16; j++) {
reg[i++] = line_data[j] & 0xF0;
reg[i++] = (line_data[j] << 4) & 0xF0;
}
return i;
}
static int st7920_store_others(int cmd, const void *data, u8 *reg)
{
int i = 0;
Annotation
- Immediate include surface: `linux/bitrev.h`, `linux/delay.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/regmap.h`, `linux/spi/spi.h`, `drm/clients/drm_client_setup.h`, `drm/drm_atomic.h`.
- Detected declarations: `struct spi7920_error`, `struct st7920_device`, `struct st7920_plane_state`, `struct st7920_crtc_state`, `function st7920_store_gdram_address`, `function st7920_store_gdram_data`, `function st7920_store_others`, `function st7920_spi_write`, `function st7920_power_on`, `function st7920_power_off`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source 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.