drivers/media/platform/rockchip/rga/rga.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/rockchip/rga/rga.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/rockchip/rga/rga.c- Extension
.c- Size
- 23353 bytes
- Lines
- 940
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/clk.hlinux/debugfs.hlinux/delay.hlinux/fs.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/pm_runtime.hlinux/reset.hlinux/sched.hlinux/slab.hlinux/timer.hlinux/platform_device.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-ioctl.hmedia/v4l2-mem2mem.hmedia/videobuf2-dma-sg.hmedia/videobuf2-dma-contig.hmedia/videobuf2-v4l2.hrga.h
Detected Declarations
function device_runfunction rga_isrfunction queue_initfunction rga_s_ctrlfunction rga_setup_ctrlsfunction check_scaling_factorfunction rga_check_scalingfunction rga_openfunction rga_releasefunction vidioc_querycapfunction vidioc_enum_fmtfunction vidioc_g_fmtfunction vidioc_try_fmtfunction vidioc_s_fmtfunction vidioc_g_selectionfunction vidioc_s_selectionfunction rga_parse_dtfunction properlyfunction rga_probefunction rga_removefunction rga_runtime_suspendfunction rga_runtime_resume
Annotated Snippet
vb2_is_streaming(v4l2_m2m_get_src_vq(ctx->fh.m2m_ctx))) {
ret = rga_check_scaling(hw, &ctx->in.crop,
&ctx->out.crop, ctrl->val);
if (ret < 0)
goto s_ctrl_done;
}
ctx->rotate = ctrl->val;
break;
case V4L2_CID_BG_COLOR:
ctx->fill_color = ctrl->val;
break;
}
ctx->cmdbuf_dirty = true;
s_ctrl_done:
spin_unlock_irqrestore(&ctx->rga->ctrl_lock, flags);
return ret;
}
static const struct v4l2_ctrl_ops rga_ctrl_ops = {
.s_ctrl = rga_s_ctrl,
};
static int rga_setup_ctrls(struct rga_ctx *ctx)
{
struct rockchip_rga *rga = ctx->rga;
v4l2_ctrl_handler_init(&ctx->ctrl_handler, 4);
if (rga->hw->features & RGA_FEATURE_FLIP) {
v4l2_ctrl_new_std(&ctx->ctrl_handler, &rga_ctrl_ops,
V4L2_CID_HFLIP, 0, 1, 1, 0);
v4l2_ctrl_new_std(&ctx->ctrl_handler, &rga_ctrl_ops,
V4L2_CID_VFLIP, 0, 1, 1, 0);
}
if (rga->hw->features & RGA_FEATURE_ROTATE)
v4l2_ctrl_new_std(&ctx->ctrl_handler, &rga_ctrl_ops,
V4L2_CID_ROTATE, 0, 270, 90, 0);
if (rga->hw->features & RGA_FEATURE_BG_COLOR)
v4l2_ctrl_new_std(&ctx->ctrl_handler, &rga_ctrl_ops,
V4L2_CID_BG_COLOR, 0, 0xffffffff, 1, 0);
if (ctx->ctrl_handler.error) {
int err = ctx->ctrl_handler.error;
v4l2_err(&rga->v4l2_dev, "%s failed\n", __func__);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
return err;
}
return 0;
}
static bool check_scaling_factor(const struct rga_hw *hw, u32 src_size,
u32 dst_size)
{
if (src_size < dst_size)
return src_size * hw->max_scaling_factor >= dst_size;
else
return dst_size * hw->max_scaling_factor >= src_size;
}
int rga_check_scaling(const struct rga_hw *hw, const struct v4l2_rect *crop_in,
const struct v4l2_rect *crop_out, u32 rotate)
{
u32 scaled_width;
u32 scaled_height;
if (rotate == 90 || rotate == 270) {
scaled_width = crop_out->height;
scaled_height = crop_out->width;
} else {
scaled_width = crop_out->width;
scaled_height = crop_out->height;
}
if (!check_scaling_factor(hw, crop_in->width, scaled_width))
return -EINVAL;
if (!check_scaling_factor(hw, crop_in->height, scaled_height))
return -EINVAL;
return 0;
}
struct rga_frame *rga_get_frame(struct rga_ctx *ctx, enum v4l2_buf_type type)
{
Annotation
- Immediate include surface: `linux/clk.h`, `linux/debugfs.h`, `linux/delay.h`, `linux/fs.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`, `linux/pm_runtime.h`.
- Detected declarations: `function device_run`, `function rga_isr`, `function queue_init`, `function rga_s_ctrl`, `function rga_setup_ctrls`, `function check_scaling_factor`, `function rga_check_scaling`, `function rga_open`, `function rga_release`, `function vidioc_querycap`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.