drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c- Extension
.c- Size
- 9776 bytes
- Lines
- 329
- 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/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_crtc.hdrm/drm_fb_dma_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_dma_helper.hshmob_drm_drv.hshmob_drm_kms.hshmob_drm_plane.hshmob_drm_regs.h
Detected Declarations
struct shmob_drm_planestruct shmob_drm_plane_statefunction shmob_drm_plane_compute_basefunction shmob_drm_primary_plane_setupfunction shmob_drm_overlay_plane_setupfunction shmob_drm_plane_atomic_checkfunction shmob_drm_plane_atomic_updatefunction shmob_drm_plane_atomic_disablefunction shmob_drm_plane_atomic_duplicate_statefunction shmob_drm_plane_atomic_destroy_statefunction shmob_drm_plane_reset
Annotated Snippet
struct shmob_drm_plane {
struct drm_plane base;
unsigned int index;
};
struct shmob_drm_plane_state {
struct drm_plane_state base;
const struct shmob_drm_format_info *format;
u32 dma[2];
};
static inline struct shmob_drm_plane *to_shmob_plane(struct drm_plane *plane)
{
return container_of(plane, struct shmob_drm_plane, base);
}
static inline struct shmob_drm_plane_state *to_shmob_plane_state(struct drm_plane_state *state)
{
return container_of(state, struct shmob_drm_plane_state, base);
}
static void shmob_drm_plane_compute_base(struct shmob_drm_plane_state *sstate)
{
struct drm_framebuffer *fb = sstate->base.fb;
unsigned int x = sstate->base.src_x >> 16;
unsigned int y = sstate->base.src_y >> 16;
struct drm_gem_dma_object *gem;
unsigned int bpp;
bpp = shmob_drm_format_is_yuv(sstate->format) ? 8 : sstate->format->bpp;
gem = drm_fb_dma_get_gem_obj(fb, 0);
sstate->dma[0] = gem->dma_addr + fb->offsets[0]
+ y * fb->pitches[0] + x * bpp / 8;
if (shmob_drm_format_is_yuv(sstate->format)) {
bpp = sstate->format->bpp - 8;
gem = drm_fb_dma_get_gem_obj(fb, 1);
sstate->dma[1] = gem->dma_addr + fb->offsets[1]
+ y / (bpp == 4 ? 2 : 1) * fb->pitches[1]
+ x * (bpp == 16 ? 2 : 1);
}
}
static void shmob_drm_primary_plane_setup(struct shmob_drm_plane *splane,
struct drm_plane_state *state)
{
struct shmob_drm_plane_state *sstate = to_shmob_plane_state(state);
struct shmob_drm_device *sdev = to_shmob_device(splane->base.dev);
struct drm_framebuffer *fb = state->fb;
/* TODO: Handle YUV colorspaces. Hardcode REC709 for now. */
lcdc_write(sdev, LDDFR, sstate->format->lddfr | LDDFR_CF1);
lcdc_write(sdev, LDMLSR, fb->pitches[0]);
/* Word and long word swap. */
lcdc_write(sdev, LDDDSR, sstate->format->ldddsr);
lcdc_write_mirror(sdev, LDSA1R, sstate->dma[0]);
if (shmob_drm_format_is_yuv(sstate->format))
lcdc_write_mirror(sdev, LDSA2R, sstate->dma[1]);
lcdc_write(sdev, LDRCNTR, lcdc_read(sdev, LDRCNTR) ^ LDRCNTR_MRS);
}
static void shmob_drm_overlay_plane_setup(struct shmob_drm_plane *splane,
struct drm_plane_state *state)
{
struct shmob_drm_plane_state *sstate = to_shmob_plane_state(state);
struct shmob_drm_device *sdev = to_shmob_device(splane->base.dev);
struct drm_framebuffer *fb = state->fb;
u32 format;
/* TODO: Support ROP3 mode */
format = LDBBSIFR_EN | ((state->alpha >> 8) << LDBBSIFR_LAY_SHIFT) |
sstate->format->ldbbsifr;
#define plane_reg_dump(sdev, splane, reg) \
dev_dbg(sdev->ddev.dev, "%s(%u): %s 0x%08x 0x%08x\n", __func__, \
splane->index, #reg, \
lcdc_read(sdev, reg(splane->index)), \
lcdc_read(sdev, reg(splane->index) + LCDC_SIDE_B_OFFSET))
plane_reg_dump(sdev, splane, LDBnBSIFR);
plane_reg_dump(sdev, splane, LDBnBSSZR);
plane_reg_dump(sdev, splane, LDBnBLOCR);
plane_reg_dump(sdev, splane, LDBnBSMWR);
plane_reg_dump(sdev, splane, LDBnBSAYR);
plane_reg_dump(sdev, splane, LDBnBSACR);
Annotation
- Immediate include surface: `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_crtc.h`, `drm/drm_fb_dma_helper.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`, `drm/drm_gem_dma_helper.h`, `shmob_drm_drv.h`.
- Detected declarations: `struct shmob_drm_plane`, `struct shmob_drm_plane_state`, `function shmob_drm_plane_compute_base`, `function shmob_drm_primary_plane_setup`, `function shmob_drm_overlay_plane_setup`, `function shmob_drm_plane_atomic_check`, `function shmob_drm_plane_atomic_update`, `function shmob_drm_plane_atomic_disable`, `function shmob_drm_plane_atomic_duplicate_state`, `function shmob_drm_plane_atomic_destroy_state`.
- 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.