drivers/soc/amlogic/meson-canvas.c
Source file repositories/reference/linux-study-clean/drivers/soc/amlogic/meson-canvas.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/amlogic/meson-canvas.c- Extension
.c- Size
- 5459 bytes
- Lines
- 209
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/platform_device.hlinux/regmap.hlinux/soc/amlogic/meson-canvas.hlinux/of_address.hlinux/of_platform.hlinux/io.h
Detected Declarations
struct meson_canvasfunction canvas_writefunction canvas_readfunction meson_canvas_configfunction meson_canvas_allocfunction meson_canvas_freefunction meson_canvas_probeexport meson_canvas_getexport meson_canvas_configexport meson_canvas_allocexport meson_canvas_free
Annotated Snippet
struct meson_canvas {
struct device *dev;
void __iomem *reg_base;
spinlock_t lock; /* canvas device lock */
u8 used[NUM_CANVAS];
bool supports_endianness;
};
static void canvas_write(struct meson_canvas *canvas, u32 reg, u32 val)
{
writel_relaxed(val, canvas->reg_base + reg);
}
static u32 canvas_read(struct meson_canvas *canvas, u32 reg)
{
return readl_relaxed(canvas->reg_base + reg);
}
struct meson_canvas *meson_canvas_get(struct device *dev)
{
struct device_node *canvas_node;
struct platform_device *canvas_pdev;
struct meson_canvas *canvas;
canvas_node = of_parse_phandle(dev->of_node, "amlogic,canvas", 0);
if (!canvas_node)
return ERR_PTR(-ENODEV);
canvas_pdev = of_find_device_by_node(canvas_node);
of_node_put(canvas_node);
if (!canvas_pdev)
return ERR_PTR(-EPROBE_DEFER);
/*
* If priv is NULL, it's probably because the canvas hasn't
* properly initialized. Bail out with -EINVAL because, in the
* current state, this driver probe cannot return -EPROBE_DEFER
*/
canvas = dev_get_drvdata(&canvas_pdev->dev);
put_device(&canvas_pdev->dev);
if (!canvas)
return ERR_PTR(-EINVAL);
return canvas;
}
EXPORT_SYMBOL_GPL(meson_canvas_get);
int meson_canvas_config(struct meson_canvas *canvas, u8 canvas_index,
u32 addr, u32 stride, u32 height,
unsigned int wrap,
unsigned int blkmode,
unsigned int endian)
{
unsigned long flags;
if (endian && !canvas->supports_endianness) {
dev_err(canvas->dev,
"Endianness is not supported on this SoC\n");
return -EINVAL;
}
spin_lock_irqsave(&canvas->lock, flags);
if (!canvas->used[canvas_index]) {
dev_err(canvas->dev,
"Trying to setup non allocated canvas %u\n",
canvas_index);
spin_unlock_irqrestore(&canvas->lock, flags);
return -EINVAL;
}
canvas_write(canvas, DMC_CAV_LUT_DATAL,
((addr + 7) >> 3) |
(((stride + 7) >> 3) << CANVAS_WIDTH_LBIT));
canvas_write(canvas, DMC_CAV_LUT_DATAH,
((((stride + 7) >> 3) >> CANVAS_WIDTH_LWID) <<
CANVAS_WIDTH_HBIT) |
(height << CANVAS_HEIGHT_BIT) |
(wrap << CANVAS_WRAP_BIT) |
(blkmode << CANVAS_BLKMODE_BIT) |
(endian << CANVAS_ENDIAN_BIT));
canvas_write(canvas, DMC_CAV_LUT_ADDR,
CANVAS_LUT_WR_EN | canvas_index);
/* Force a read-back to make sure everything is flushed. */
canvas_read(canvas, DMC_CAV_LUT_DATAH);
spin_unlock_irqrestore(&canvas->lock, flags);
return 0;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/soc/amlogic/meson-canvas.h`, `linux/of_address.h`, `linux/of_platform.h`.
- Detected declarations: `struct meson_canvas`, `function canvas_write`, `function canvas_read`, `function meson_canvas_config`, `function meson_canvas_alloc`, `function meson_canvas_free`, `function meson_canvas_probe`, `export meson_canvas_get`, `export meson_canvas_config`, `export meson_canvas_alloc`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: integration 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.