drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vicodec/codec-v4l2-fwht.c- Extension
.c- Size
- 11095 bytes
- Lines
- 368
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/string.hlinux/videodev2.hcodec-v4l2-fwht.h
Detected Declarations
function v4l2_fwht_validate_fmtfunction prepare_raw_framefunction v4l2_fwht_encodefunction v4l2_fwht_decode
Annotated Snippet
if (is_valid) {
if (start_idx == 0)
return v4l2_fwht_pixfmts + i;
start_idx--;
}
}
return NULL;
}
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_find_pixfmt(u32 pixelformat)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(v4l2_fwht_pixfmts); i++)
if (v4l2_fwht_pixfmts[i].id == pixelformat)
return v4l2_fwht_pixfmts + i;
return NULL;
}
const struct v4l2_fwht_pixfmt_info *v4l2_fwht_get_pixfmt(u32 idx)
{
if (idx >= ARRAY_SIZE(v4l2_fwht_pixfmts))
return NULL;
return v4l2_fwht_pixfmts + idx;
}
static int prepare_raw_frame(struct fwht_raw_frame *rf,
const struct v4l2_fwht_pixfmt_info *info, u8 *buf,
unsigned int size)
{
rf->luma = buf;
rf->width_div = info->width_div;
rf->height_div = info->height_div;
rf->luma_alpha_step = info->luma_alpha_step;
rf->chroma_step = info->chroma_step;
rf->alpha = NULL;
rf->components_num = info->components_num;
/*
* The buffer is NULL if it is the reference
* frame of an I-frame in the stateless decoder
*/
if (!buf) {
rf->luma = NULL;
rf->cb = NULL;
rf->cr = NULL;
rf->alpha = NULL;
return 0;
}
switch (info->id) {
case V4L2_PIX_FMT_GREY:
rf->cb = NULL;
rf->cr = NULL;
break;
case V4L2_PIX_FMT_YUV420:
rf->cb = rf->luma + size;
rf->cr = rf->cb + size / 4;
break;
case V4L2_PIX_FMT_YVU420:
rf->cr = rf->luma + size;
rf->cb = rf->cr + size / 4;
break;
case V4L2_PIX_FMT_YUV422P:
rf->cb = rf->luma + size;
rf->cr = rf->cb + size / 2;
break;
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV24:
rf->cb = rf->luma + size;
rf->cr = rf->cb + 1;
break;
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV61:
case V4L2_PIX_FMT_NV42:
rf->cr = rf->luma + size;
rf->cb = rf->cr + 1;
break;
case V4L2_PIX_FMT_YUYV:
rf->cb = rf->luma + 1;
rf->cr = rf->cb + 2;
break;
case V4L2_PIX_FMT_YVYU:
rf->cr = rf->luma + 1;
rf->cb = rf->cr + 2;
break;
case V4L2_PIX_FMT_UYVY:
rf->cb = rf->luma;
rf->cr = rf->cb + 2;
rf->luma++;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/string.h`, `linux/videodev2.h`, `codec-v4l2-fwht.h`.
- Detected declarations: `function v4l2_fwht_validate_fmt`, `function prepare_raw_frame`, `function v4l2_fwht_encode`, `function v4l2_fwht_decode`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
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.