drivers/gpu/drm/panel/panel-sitronix-st7789v.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/panel/panel-sitronix-st7789v.c- Extension
.c- Size
- 21235 bytes
- Lines
- 698
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/gpio/consumer.hlinux/module.hlinux/regulator/consumer.hlinux/spi/spi.hvideo/mipi_display.hlinux/media-bus-format.hdrm/drm_device.hdrm/drm_modes.hdrm/drm_panel.h
Detected Declarations
struct st7789_panel_infostruct st7789venum st7789v_prefixfunction st7789v_spi_writefunction st7789v_write_commandfunction st7789v_write_datafunction st7789v_read_datafunction st7789v_check_idfunction st7789v_get_modesfunction st7789v_get_orientationfunction st7789v_preparefunction st7789v_enablefunction st7789v_disablefunction st7789v_unpreparefunction st7789v_probefunction st7789v_remove
Annotated Snippet
struct st7789_panel_info {
const struct drm_display_mode *mode;
u32 bus_format;
u32 bus_flags;
bool invert_mode;
bool partial_mode;
u16 partial_start;
u16 partial_end;
};
struct st7789v {
struct drm_panel panel;
const struct st7789_panel_info *info;
struct spi_device *spi;
struct gpio_desc *reset;
struct regulator *power;
enum drm_panel_orientation orientation;
};
enum st7789v_prefix {
ST7789V_COMMAND = 0,
ST7789V_DATA = 1,
};
static inline struct st7789v *panel_to_st7789v(struct drm_panel *panel)
{
return container_of(panel, struct st7789v, panel);
}
static int st7789v_spi_write(struct st7789v *ctx, enum st7789v_prefix prefix,
u8 data)
{
struct spi_transfer xfer = { };
u16 txbuf = ((prefix & 1) << 8) | data;
xfer.tx_buf = &txbuf;
xfer.len = sizeof(txbuf);
return spi_sync_transfer(ctx->spi, &xfer, 1);
}
static int st7789v_write_command(struct st7789v *ctx, u8 cmd)
{
return st7789v_spi_write(ctx, ST7789V_COMMAND, cmd);
}
static int st7789v_write_data(struct st7789v *ctx, u8 cmd)
{
return st7789v_spi_write(ctx, ST7789V_DATA, cmd);
}
static int st7789v_read_data(struct st7789v *ctx, u8 cmd, u8 *buf,
unsigned int len)
{
struct spi_transfer xfer[2] = { };
struct spi_message msg;
u16 txbuf = ((ST7789V_COMMAND & 1) << 8) | cmd;
u16 rxbuf[4] = {};
u8 bit9 = 0;
int ret, i;
switch (len) {
case 1:
case 3:
case 4:
break;
default:
return -EOPNOTSUPP;
}
spi_message_init(&msg);
xfer[0].tx_buf = &txbuf;
xfer[0].len = sizeof(txbuf);
spi_message_add_tail(&xfer[0], &msg);
xfer[1].rx_buf = rxbuf;
xfer[1].len = len * 2;
spi_message_add_tail(&xfer[1], &msg);
ret = spi_sync(ctx->spi, &msg);
if (ret)
return ret;
for (i = 0; i < len; i++) {
buf[i] = rxbuf[i] >> i | (bit9 << (9 - i));
if (i)
bit9 = rxbuf[i] & GENMASK(i - 1, 0);
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/regulator/consumer.h`, `linux/spi/spi.h`, `video/mipi_display.h`, `linux/media-bus-format.h`, `drm/drm_device.h`.
- Detected declarations: `struct st7789_panel_info`, `struct st7789v`, `enum st7789v_prefix`, `function st7789v_spi_write`, `function st7789v_write_command`, `function st7789v_write_data`, `function st7789v_read_data`, `function st7789v_check_id`, `function st7789v_get_modes`, `function st7789v_get_orientation`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.