drivers/gpu/drm/tiny/pixpaper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tiny/pixpaper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tiny/pixpaper.c- Extension
.c- Size
- 43568 bytes
- Lines
- 1167
- 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/delay.hlinux/module.hlinux/spi/spi.hdrm/clients/drm_client_setup.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_drv.hdrm/drm_fbdev_shmem.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_shmem_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_print.hdrm/drm_probe_helper.h
Detected Declarations
struct pixpaper_error_ctxstruct pixpaper_panelfunction pixpaper_wait_for_panelfunction pixpaper_spi_syncfunction pixpaper_send_cmdfunction pixpaper_send_datafunction pixpaper_panel_hw_initfunction pack_pixels_to_bytefunction pixpaper_plane_helper_atomic_checkfunction pixpaper_crtc_helper_atomic_checkfunction pixpaper_crtc_atomic_enablefunction pixpaper_crtc_atomic_disablefunction pixpaper_plane_atomic_updatefunction pixpaper_connector_get_modesfunction pixpaper_mode_validfunction pixpaper_probefunction pixpaper_remove
Annotated Snippet
struct pixpaper_error_ctx {
int errno_code;
};
struct pixpaper_panel {
struct drm_device drm;
struct drm_plane plane;
struct drm_crtc crtc;
struct drm_encoder encoder;
struct drm_connector connector;
struct spi_device *spi;
struct gpio_desc *reset;
struct gpio_desc *busy;
struct gpio_desc *dc;
};
static inline struct pixpaper_panel *to_pixpaper_panel(struct drm_device *drm)
{
return container_of(drm, struct pixpaper_panel, drm);
}
static void pixpaper_wait_for_panel(struct pixpaper_panel *panel)
{
unsigned int timeout_ms = 10000;
unsigned long timeout_jiffies = jiffies + msecs_to_jiffies(timeout_ms);
usleep_range(1000, 1500);
while (gpiod_get_value_cansleep(panel->busy) != 1) {
if (time_after(jiffies, timeout_jiffies)) {
drm_warn(&panel->drm, "Busy wait timed out\n");
return;
}
usleep_range(100, 200);
}
}
static void pixpaper_spi_sync(struct spi_device *spi, struct spi_message *msg,
struct pixpaper_error_ctx *err)
{
if (err->errno_code)
return;
int ret = spi_sync(spi, msg);
if (ret < 0)
err->errno_code = ret;
}
static void pixpaper_send_cmd(struct pixpaper_panel *panel, u8 cmd,
struct pixpaper_error_ctx *err)
{
if (err->errno_code)
return;
struct spi_transfer xfer = {
.tx_buf = &cmd,
.len = 1,
};
struct spi_message msg;
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
gpiod_set_value_cansleep(panel->dc, 0);
usleep_range(1, 5);
pixpaper_spi_sync(panel->spi, &msg, err);
}
static void pixpaper_send_data(struct pixpaper_panel *panel, u8 data,
struct pixpaper_error_ctx *err)
{
if (err->errno_code)
return;
struct spi_transfer xfer = {
.tx_buf = &data,
.len = 1,
};
struct spi_message msg;
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
gpiod_set_value_cansleep(panel->dc, 1);
usleep_range(1, 5);
pixpaper_spi_sync(panel->spi, &msg, err);
}
static int pixpaper_panel_hw_init(struct pixpaper_panel *panel)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/module.h`, `linux/spi/spi.h`, `drm/clients/drm_client_setup.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_drv.h`, `drm/drm_fbdev_shmem.h`.
- Detected declarations: `struct pixpaper_error_ctx`, `struct pixpaper_panel`, `function pixpaper_wait_for_panel`, `function pixpaper_spi_sync`, `function pixpaper_send_cmd`, `function pixpaper_send_data`, `function pixpaper_panel_hw_init`, `function pack_pixels_to_byte`, `function pixpaper_plane_helper_atomic_check`, `function pixpaper_crtc_helper_atomic_check`.
- 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.