drivers/staging/media/sunxi/cedrus/cedrus_hw.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/sunxi/cedrus/cedrus_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/sunxi/cedrus/cedrus_hw.c- Extension
.c- Size
- 7732 bytes
- Lines
- 359
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/platform_device.hlinux/of.hlinux/of_reserved_mem.hlinux/dma-mapping.hlinux/interrupt.hlinux/clk.hlinux/pm_runtime.hlinux/regmap.hlinux/reset.hlinux/soc/sunxi/sunxi_sram.hmedia/videobuf2-core.hmedia/v4l2-mem2mem.hcedrus.hcedrus_hw.hcedrus_regs.h
Detected Declarations
function Copyrightfunction cedrus_engine_disablefunction cedrus_dst_format_setfunction cedrus_irqfunction cedrus_watchdogfunction cedrus_hw_suspendfunction cedrus_hw_resumefunction cedrus_hw_probefunction cedrus_hw_remove
Annotated Snippet
switch (fmt->pixelformat) {
case V4L2_PIX_FMT_NV12:
reg = VE_PRIMARY_OUT_FMT_NV12;
break;
case V4L2_PIX_FMT_NV21:
reg = VE_PRIMARY_OUT_FMT_NV21;
break;
case V4L2_PIX_FMT_YUV420:
reg = VE_PRIMARY_OUT_FMT_YU12;
break;
case V4L2_PIX_FMT_YVU420:
default:
reg = VE_PRIMARY_OUT_FMT_YV12;
break;
}
cedrus_write(dev, VE_PRIMARY_OUT_FMT, reg);
reg = chroma_size / 2;
cedrus_write(dev, VE_PRIMARY_CHROMA_BUF_LEN, reg);
reg = VE_PRIMARY_FB_LINE_STRIDE_LUMA(ALIGN(width, 16)) |
VE_PRIMARY_FB_LINE_STRIDE_CHROMA(ALIGN(width, 16) / 2);
cedrus_write(dev, VE_PRIMARY_FB_LINE_STRIDE, reg);
break;
case V4L2_PIX_FMT_NV12_32L32:
default:
reg = VE_PRIMARY_OUT_FMT_TILED_32_NV12;
cedrus_write(dev, VE_PRIMARY_OUT_FMT, reg);
reg = VE_SECONDARY_OUT_FMT_TILED_32_NV12;
cedrus_write(dev, VE_CHROMA_BUF_LEN, reg);
break;
}
}
static irqreturn_t cedrus_irq(int irq, void *data)
{
struct cedrus_dev *dev = data;
struct cedrus_ctx *ctx;
enum vb2_buffer_state state;
enum cedrus_irq_status status;
/*
* If cancel_delayed_work returns false it means watchdog already
* executed and finished the job.
*/
if (!cancel_delayed_work(&dev->watchdog_work))
return IRQ_HANDLED;
ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev);
if (!ctx) {
v4l2_err(&dev->v4l2_dev,
"Instance released before the end of transaction\n");
return IRQ_NONE;
}
status = ctx->current_codec->irq_status(ctx);
if (status == CEDRUS_IRQ_NONE)
return IRQ_NONE;
ctx->current_codec->irq_disable(ctx);
ctx->current_codec->irq_clear(ctx);
if (status == CEDRUS_IRQ_ERROR)
state = VB2_BUF_STATE_ERROR;
else
state = VB2_BUF_STATE_DONE;
v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx,
state);
return IRQ_HANDLED;
}
void cedrus_watchdog(struct work_struct *work)
{
struct cedrus_dev *dev;
struct cedrus_ctx *ctx;
dev = container_of(to_delayed_work(work),
struct cedrus_dev, watchdog_work);
ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev);
if (!ctx)
return;
v4l2_err(&dev->v4l2_dev, "frame processing timed out!\n");
reset_control_reset(dev->rstc);
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/of.h`, `linux/of_reserved_mem.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/clk.h`, `linux/pm_runtime.h`, `linux/regmap.h`.
- Detected declarations: `function Copyright`, `function cedrus_engine_disable`, `function cedrus_dst_format_set`, `function cedrus_irq`, `function cedrus_watchdog`, `function cedrus_hw_suspend`, `function cedrus_hw_resume`, `function cedrus_hw_probe`, `function cedrus_hw_remove`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.