drivers/gpu/drm/tiny/sharp-memory.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tiny/sharp-memory.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tiny/sharp-memory.c- Extension
.c- Size
- 19703 bytes
- Lines
- 670
- 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
drm/clients/drm_client_setup.hdrm/drm_atomic.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_probe_helper.hdrm/drm_rect.hlinux/bitrev.hlinux/delay.hlinux/gpio/consumer.hlinux/kthread.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/pwm.hlinux/spi/spi.h
Detected Declarations
struct sharp_memory_deviceenum sharp_memory_modelenum sharp_memory_vcom_modefunction sharp_memory_spi_writefunction sharp_memory_set_tx_buffer_modefunction sharp_memory_set_tx_buffer_addressesfunction sharp_memory_set_tx_buffer_datafunction sharp_memory_update_displayfunction sharp_memory_maintain_displayfunction sharp_memory_clear_displayfunction sharp_memory_fb_dirtyfunction sharp_memory_plane_atomic_checkfunction sharp_memory_plane_atomic_updatefunction sharp_memory_format_mod_supportedfunction sharp_memory_crtc_mode_validfunction sharp_memory_crtc_checkfunction sharp_memory_sw_vcom_signal_threadfunction sharp_memory_crtc_enablefunction sharp_memory_crtc_disablefunction sharp_memory_connector_get_modesfunction sharp_memory_pipe_initfunction sharp_memory_init_pwm_vcom_signalfunction sharp_memory_probefunction sharp_memory_remove
Annotated Snippet
struct sharp_memory_device {
struct drm_device drm;
struct spi_device *spi;
const struct drm_display_mode *mode;
struct drm_crtc crtc;
struct drm_plane plane;
struct drm_encoder encoder;
struct drm_connector connector;
struct gpio_desc *enable_gpio;
struct task_struct *sw_vcom_signal;
struct pwm_device *pwm_vcom_signal;
enum sharp_memory_vcom_mode vcom_mode;
u8 vcom;
u32 pitch;
u32 tx_buffer_size;
u8 *tx_buffer;
/* When vcom_mode == "software" a kthread is used to periodically send a
* 'maintain display' message over spi. This mutex ensures tx_buffer access
* and spi bus usage is synchronized in this case.
*/
struct mutex tx_mutex;
};
static inline int sharp_memory_spi_write(struct spi_device *spi, void *buf, size_t len)
{
/* Reverse the bit order */
for (u8 *b = buf; b < ((u8 *)buf) + len; ++b)
*b = bitrev8(*b);
return spi_write(spi, buf, len);
}
static inline struct sharp_memory_device *drm_to_sharp_memory_device(struct drm_device *drm)
{
return container_of(drm, struct sharp_memory_device, drm);
}
DEFINE_DRM_GEM_DMA_FOPS(sharp_memory_fops);
static const struct drm_driver sharp_memory_drm_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
.fops = &sharp_memory_fops,
DRM_GEM_DMA_DRIVER_OPS_VMAP,
DRM_FBDEV_DMA_DRIVER_OPS,
.name = "sharp_memory_display",
.desc = "Sharp Display Memory LCD",
.major = 1,
.minor = 0,
};
static inline void sharp_memory_set_tx_buffer_mode(u8 *buffer, u8 mode, u8 vcom)
{
*buffer = mode | (vcom << 1);
}
static inline void sharp_memory_set_tx_buffer_addresses(u8 *buffer,
struct drm_rect clip,
u32 pitch)
{
for (u32 line = 0; line < clip.y2; ++line)
buffer[line * pitch] = line + 1;
}
static void sharp_memory_set_tx_buffer_data(u8 *buffer,
struct drm_framebuffer *fb,
const struct iosys_map *vmap,
struct drm_rect clip,
u32 pitch,
struct drm_format_conv_state *fmtcnv_state)
{
int ret;
struct iosys_map dst;
ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE);
if (ret)
return;
iosys_map_set_vaddr(&dst, buffer);
drm_fb_xrgb8888_to_mono(&dst, &pitch, vmap, fb, &clip, fmtcnv_state);
drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
}
Annotation
- Immediate include surface: `drm/clients/drm_client_setup.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_connector.h`, `drm/drm_damage_helper.h`, `drm/drm_drv.h`, `drm/drm_fb_dma_helper.h`, `drm/drm_fbdev_dma.h`.
- Detected declarations: `struct sharp_memory_device`, `enum sharp_memory_model`, `enum sharp_memory_vcom_mode`, `function sharp_memory_spi_write`, `function sharp_memory_set_tx_buffer_mode`, `function sharp_memory_set_tx_buffer_addresses`, `function sharp_memory_set_tx_buffer_data`, `function sharp_memory_update_display`, `function sharp_memory_maintain_display`, `function sharp_memory_clear_display`.
- 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.