drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c- Extension
.c- Size
- 21999 bytes
- Lines
- 916
- 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/interrupt.hlinux/io.hlinux/iopoll.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hmedia/v4l2-device.hmedia/v4l2-event.hmedia/v4l2-ioctl.hmedia/v4l2-mem2mem.hsun8i-formats.hsun8i-rotate.h
Detected Declarations
function Copyrightfunction rotate_writefunction rotate_set_bitsfunction rotate_calc_addr_pitchfunction rotate_device_runfunction rotate_irqfunction rotate_prepare_formatfunction rotate_querycapfunction rotate_enum_fmt_vid_capfunction rotate_enum_fmt_vid_outfunction rotate_enum_framesizesfunction rotate_set_cap_formatfunction rotate_g_fmt_vid_capfunction rotate_g_fmt_vid_outfunction rotate_try_fmt_vid_capfunction rotate_try_fmt_vid_outfunction rotate_s_fmt_vid_capfunction rotate_s_fmt_vid_outfunction rotate_queue_setupfunction rotate_buf_preparefunction rotate_buf_queuefunction rotate_queue_cleanupfunction rotate_start_streamingfunction rotate_stop_streamingfunction rotate_queue_initfunction rotate_s_ctrlfunction rotate_setup_ctrlsfunction rotate_openfunction rotate_releasefunction rotate_probefunction rotate_removefunction rotate_runtime_resumefunction rotate_runtime_suspend
Annotated Snippet
if (i > 0) {
size *= fmt->bpp[i];
size /= fmt->hsub;
size /= fmt->vsub;
}
sizeimage += size;
}
pix_fmt->width = width;
pix_fmt->height = height;
pix_fmt->bytesperline = bpl;
pix_fmt->sizeimage = sizeimage;
}
static int rotate_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
strscpy(cap->driver, ROTATE_NAME, sizeof(cap->driver));
strscpy(cap->card, ROTATE_NAME, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
"platform:%s", ROTATE_NAME);
return 0;
}
static int rotate_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
return rotate_enum_fmt(f, true);
}
static int rotate_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
return rotate_enum_fmt(f, false);
}
static int rotate_enum_framesizes(struct file *file, void *priv,
struct v4l2_frmsizeenum *fsize)
{
const struct rotate_format *fmt;
if (fsize->index != 0)
return -EINVAL;
fmt = rotate_find_format(fsize->pixel_format);
if (!fmt)
return -EINVAL;
fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
fsize->stepwise.min_width = ROTATE_MIN_WIDTH;
fsize->stepwise.min_height = ROTATE_MIN_HEIGHT;
fsize->stepwise.max_width = ROTATE_MAX_WIDTH;
fsize->stepwise.max_height = ROTATE_MAX_HEIGHT;
fsize->stepwise.step_width = fmt->hsub;
fsize->stepwise.step_height = fmt->vsub;
return 0;
}
static int rotate_set_cap_format(struct rotate_ctx *ctx,
struct v4l2_pix_format *f,
u32 rotate)
{
const struct rotate_format *fmt;
fmt = rotate_find_format(ctx->src_fmt.pixelformat);
if (!fmt)
return -EINVAL;
if (fmt->flags & ROTATE_FLAG_YUV)
f->pixelformat = V4L2_PIX_FMT_YUV420;
else
f->pixelformat = ctx->src_fmt.pixelformat;
f->field = V4L2_FIELD_NONE;
if (rotate == 90 || rotate == 270) {
f->width = ctx->src_fmt.height;
f->height = ctx->src_fmt.width;
} else {
f->width = ctx->src_fmt.width;
f->height = ctx->src_fmt.height;
}
rotate_prepare_format(f);
return 0;
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `function Copyright`, `function rotate_write`, `function rotate_set_bits`, `function rotate_calc_addr_pitch`, `function rotate_device_run`, `function rotate_irq`, `function rotate_prepare_format`, `function rotate_querycap`, `function rotate_enum_fmt_vid_cap`, `function rotate_enum_fmt_vid_out`.
- 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.