drivers/gpu/drm/tiny/repaper.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tiny/repaper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tiny/repaper.c- Extension
.c- Size
- 29153 bytes
- Lines
- 1154
- 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/delay.hlinux/gpio/consumer.hlinux/module.hlinux/property.hlinux/sched/clock.hlinux/spi/spi.hlinux/thermal.hdrm/clients/drm_client_setup.hdrm/drm_atomic_helper.hdrm/drm_connector.hdrm/drm_damage_helper.hdrm/drm_drv.hdrm/drm_fb_dma_helper.hdrm/drm_fbdev_dma.hdrm/drm_format_helper.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_gem_dma_helper.hdrm/drm_gem_framebuffer_helper.hdrm/drm_managed.hdrm/drm_modes.hdrm/drm_rect.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_simple_kms_helper.h
Detected Declarations
struct repaper_epdenum repaper_modelenum repaper_stageenum repaper_epd_border_bytefunction repaper_spi_transferfunction repaper_write_buffunction repaper_write_valfunction repaper_read_valfunction repaper_read_idfunction repaper_spi_mosi_lowfunction repaper_even_pixelsfunction repaper_odd_pixelsfunction repaper_interleave_bitsfunction repaper_all_pixelsfunction repaper_one_linefunction repaper_frame_fixedfunction repaper_frame_datafunction repaper_frame_fixed_repeatfunction repaper_frame_data_repeatfunction repaper_get_temperaturefunction repaper_fb_dirtyfunction power_offfunction repaper_pipe_mode_validfunction repaper_pipe_enablefunction repaper_pipe_disablefunction repaper_pipe_updatefunction repaper_connector_get_modesfunction repaper_probefunction repaper_removefunction repaper_shutdown
Annotated Snippet
struct repaper_epd {
struct drm_device drm;
struct drm_simple_display_pipe pipe;
const struct drm_display_mode *mode;
struct drm_connector connector;
struct spi_device *spi;
struct gpio_desc *panel_on;
struct gpio_desc *border;
struct gpio_desc *discharge;
struct gpio_desc *reset;
struct gpio_desc *busy;
struct thermal_zone_device *thermal;
unsigned int height;
unsigned int width;
unsigned int bytes_per_scan;
const u8 *channel_select;
unsigned int stage_time;
unsigned int factored_stage_time;
bool middle_scan;
bool pre_border_byte;
enum repaper_epd_border_byte border_byte;
u8 *line_buffer;
void *current_frame;
bool cleared;
bool partial;
};
static inline struct repaper_epd *drm_to_epd(struct drm_device *drm)
{
return container_of(drm, struct repaper_epd, drm);
}
static int repaper_spi_transfer(struct spi_device *spi, u8 header,
const void *tx, void *rx, size_t len)
{
void *txbuf = NULL, *rxbuf = NULL;
struct spi_transfer tr[2] = {};
u8 *headerbuf;
int ret;
headerbuf = kmalloc(1, GFP_KERNEL);
if (!headerbuf)
return -ENOMEM;
headerbuf[0] = header;
tr[0].tx_buf = headerbuf;
tr[0].len = 1;
/* Stack allocated tx? */
if (tx && len <= 32) {
txbuf = kmemdup(tx, len, GFP_KERNEL);
if (!txbuf) {
ret = -ENOMEM;
goto out_free;
}
}
if (rx) {
rxbuf = kmalloc(len, GFP_KERNEL);
if (!rxbuf) {
ret = -ENOMEM;
goto out_free;
}
}
tr[1].tx_buf = txbuf ? txbuf : tx;
tr[1].rx_buf = rxbuf;
tr[1].len = len;
ndelay(80);
ret = spi_sync_transfer(spi, tr, 2);
if (rx && !ret)
memcpy(rx, rxbuf, len);
out_free:
kfree(headerbuf);
kfree(txbuf);
kfree(rxbuf);
return ret;
}
static int repaper_write_buf(struct spi_device *spi, u8 reg,
const u8 *buf, size_t len)
{
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/module.h`, `linux/property.h`, `linux/sched/clock.h`, `linux/spi/spi.h`, `linux/thermal.h`, `drm/clients/drm_client_setup.h`.
- Detected declarations: `struct repaper_epd`, `enum repaper_model`, `enum repaper_stage`, `enum repaper_epd_border_byte`, `function repaper_spi_transfer`, `function repaper_write_buf`, `function repaper_write_val`, `function repaper_read_val`, `function repaper_read_id`, `function repaper_spi_mosi_low`.
- 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.