drivers/staging/media/imx/imx-media-utils.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/imx/imx-media-utils.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/imx/imx-media-utils.c- Extension
.c- Size
- 19808 bytes
- Lines
- 788
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- 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/module.himx-media.h
Detected Declarations
function Copyrightfunction imx_media_find_pixel_formatfunction imx_media_find_mbus_formatfunction imx_media_enum_pixel_formatsfunction imx_media_enum_mbus_formatsfunction imx_media_init_mbus_fmtfunction imx_media_init_statefunction imx_media_try_colorimetryfunction imx_media_mbus_fmt_to_pix_fmtfunction imx_media_free_dma_buffunction imx_media_alloc_dma_buffunction imx_media_grp_id_to_sd_namefunction imx_media_add_video_devicefunction imx_media_pipeline_padfunction find_pipeline_entityfunction imx_media_pipeline_subdevfunction imx_media_pipeline_set_streamexport imx_media_find_pixel_formatexport imx_media_find_mbus_formatexport imx_media_enum_pixel_formatsexport imx_media_enum_mbus_formatsexport imx_media_init_mbus_fmtexport imx_media_init_stateexport imx_media_try_colorimetryexport imx_media_mbus_fmt_to_pix_fmtexport imx_media_free_dma_bufexport imx_media_alloc_dma_bufexport imx_media_grp_id_to_sd_nameexport imx_media_add_video_deviceexport imx_media_pipeline_padexport imx_media_pipeline_subdevexport imx_media_pipeline_set_stream
Annotated Snippet
if (code) {
unsigned int j;
if (!fmt->codes)
continue;
for (j = 0; fmt->codes[j]; j++) {
if (code == fmt->codes[j])
break;
}
if (!fmt->codes[j])
continue;
}
if (index == 0) {
*fourcc = fmt->fourcc;
return 0;
}
index--;
}
return -EINVAL;
}
EXPORT_SYMBOL_GPL(imx_media_enum_pixel_formats);
/*
* Enumerate entries in the pixel_formats[] array that match the
* requested search criteria. Return the media-bus code that matches
* the search criteria at the requested match index.
*
* @code: The returned media-bus code that matches the search criteria at
* the requested match index.
* @index: The requested match index.
* @fmt_sel: Include in the enumeration entries with the given selection
* criteria.
*/
int imx_media_enum_mbus_formats(u32 *code, u32 index,
enum imx_pixfmt_sel fmt_sel)
{
bool sel_ipu = fmt_sel & PIXFMT_SEL_IPU;
unsigned int i;
fmt_sel &= ~PIXFMT_SEL_IPU;
for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) {
const struct imx_media_pixfmt *fmt = &pixel_formats[i];
enum imx_pixfmt_sel sel;
unsigned int j;
if (sel_ipu != fmt->ipufmt)
continue;
sel = fmt->bayer ? PIXFMT_SEL_BAYER :
((fmt->cs == IPUV3_COLORSPACE_YUV) ?
PIXFMT_SEL_YUV : PIXFMT_SEL_RGB);
if (!(fmt_sel & sel) || !fmt->codes)
continue;
for (j = 0; fmt->codes[j]; j++) {
if (index == 0) {
*code = fmt->codes[j];
return 0;
}
index--;
}
}
return -EINVAL;
}
EXPORT_SYMBOL_GPL(imx_media_enum_mbus_formats);
int imx_media_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus,
u32 width, u32 height, u32 code, u32 field,
const struct imx_media_pixfmt **cc)
{
const struct imx_media_pixfmt *lcc;
mbus->width = width;
mbus->height = height;
mbus->field = field;
if (code == 0)
imx_media_enum_mbus_formats(&code, 0, PIXFMT_SEL_YUV);
lcc = imx_media_find_mbus_format(code, PIXFMT_SEL_ANY);
if (!lcc) {
Annotation
- Immediate include surface: `linux/module.h`, `imx-media.h`.
- Detected declarations: `function Copyright`, `function imx_media_find_pixel_format`, `function imx_media_find_mbus_format`, `function imx_media_enum_pixel_formats`, `function imx_media_enum_mbus_formats`, `function imx_media_init_mbus_fmt`, `function imx_media_init_state`, `function imx_media_try_colorimetry`, `function imx_media_mbus_fmt_to_pix_fmt`, `function imx_media_free_dma_buf`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: integration 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.