drivers/gpu/drm/sitronix/st7735r.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sitronix/st7735r.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sitronix/st7735r.c- Extension
.c- Size
- 10187 bytes
- Lines
- 379
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/backlight.hlinux/delay.hlinux/dma-buf.hlinux/gpio/consumer.hlinux/module.hlinux/property.hlinux/spi/spi.hvideo/mipi_display.hdrm/clients/drm_client_setup.hdrm/drm_atomic_helper.hdrm/drm_drv.hdrm/drm_fbdev_dma.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_dma_helper.hdrm/drm_managed.hdrm/drm_mipi_dbi.hdrm/drm_print.h
Detected Declarations
struct st7735r_cfgstruct st7735r_devicefunction st7735r_crtc_helper_atomic_enablefunction st7735r_probefunction st7735r_removefunction st7735r_shutdown
Annotated Snippet
struct st7735r_cfg {
const struct drm_display_mode mode;
unsigned int left_offset;
unsigned int top_offset;
unsigned int write_only:1;
unsigned int rgb:1; /* RGB (vs. BGR) */
};
struct st7735r_device {
struct mipi_dbi_dev dbidev; /* Must be first for .release() */
const struct st7735r_cfg *cfg;
struct drm_plane plane;
struct drm_crtc crtc;
struct drm_encoder encoder;
struct drm_connector connector;
};
static struct st7735r_device *to_st7735r_device(struct drm_device *drm)
{
return container_of(drm_to_mipi_dbi_dev(drm), struct st7735r_device, dbidev);
}
static const u32 st7735r_plane_formats[] = {
DRM_MIPI_DBI_PLANE_FORMATS,
};
static const u64 st7735r_plane_format_modifiers[] = {
DRM_MIPI_DBI_PLANE_FORMAT_MODIFIERS,
};
static const struct drm_plane_helper_funcs st7735r_plane_helper_funcs = {
DRM_MIPI_DBI_PLANE_HELPER_FUNCS,
};
static const struct drm_plane_funcs st7735r_plane_funcs = {
DRM_MIPI_DBI_PLANE_FUNCS,
.destroy = drm_plane_cleanup,
};
static void st7735r_crtc_helper_atomic_enable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
struct drm_device *drm = crtc->dev;
struct st7735r_device *st7735r = to_st7735r_device(drm);
struct mipi_dbi_dev *dbidev = &st7735r->dbidev;
struct mipi_dbi *dbi = &dbidev->dbi;
int ret, idx;
u8 addr_mode;
if (!drm_dev_enter(drm, &idx))
return;
DRM_DEBUG_KMS("\n");
ret = mipi_dbi_poweron_reset(dbidev);
if (ret)
goto out_exit;
msleep(150);
mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE);
msleep(500);
mipi_dbi_command(dbi, ST7735R_FRMCTR1, 0x01, 0x2c, 0x2d);
mipi_dbi_command(dbi, ST7735R_FRMCTR2, 0x01, 0x2c, 0x2d);
mipi_dbi_command(dbi, ST7735R_FRMCTR3, 0x01, 0x2c, 0x2d, 0x01, 0x2c,
0x2d);
mipi_dbi_command(dbi, ST7735R_INVCTR, 0x07);
mipi_dbi_command(dbi, ST7735R_PWCTR1, 0xa2, 0x02, 0x84);
mipi_dbi_command(dbi, ST7735R_PWCTR2, 0xc5);
mipi_dbi_command(dbi, ST7735R_PWCTR3, 0x0a, 0x00);
mipi_dbi_command(dbi, ST7735R_PWCTR4, 0x8a, 0x2a);
mipi_dbi_command(dbi, ST7735R_PWCTR5, 0x8a, 0xee);
mipi_dbi_command(dbi, ST7735R_VMCTR1, 0x0e);
mipi_dbi_command(dbi, MIPI_DCS_EXIT_INVERT_MODE);
switch (dbidev->rotation) {
default:
addr_mode = ST7735R_MX | ST7735R_MY;
break;
case 90:
addr_mode = ST7735R_MX | ST7735R_MV;
break;
case 180:
addr_mode = 0;
break;
case 270:
addr_mode = ST7735R_MY | ST7735R_MV;
break;
}
Annotation
- Immediate include surface: `linux/backlight.h`, `linux/delay.h`, `linux/dma-buf.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/property.h`, `linux/spi/spi.h`, `video/mipi_display.h`.
- Detected declarations: `struct st7735r_cfg`, `struct st7735r_device`, `function st7735r_crtc_helper_atomic_enable`, `function st7735r_probe`, `function st7735r_remove`, `function st7735r_shutdown`.
- 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.