drivers/staging/media/imx/imx-media-dev.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/imx/imx-media-dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/imx/imx-media-dev.c- Extension
.c- Size
- 3586 bytes
- Lines
- 144
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/module.hlinux/platform_device.hmedia/v4l2-async.hmedia/v4l2-event.hmedia/imx.himx-media.h
Detected Declarations
function Copyrightfunction imx_media_subdev_boundfunction imx6_media_probe_completefunction imx_media_probefunction imx_media_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* V4L2 Media Controller Driver for Freescale i.MX5/6 SOC
*
* Copyright (c) 2016-2019 Mentor Graphics Inc.
*/
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <media/v4l2-async.h>
#include <media/v4l2-event.h>
#include <media/imx.h>
#include "imx-media.h"
static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n)
{
return container_of(n, struct imx_media_dev, notifier);
}
/* async subdev bound notifier */
static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *sd,
struct v4l2_async_connection *asd)
{
struct imx_media_dev *imxmd = notifier2dev(notifier);
int ret;
if (sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) {
/* register the IPU internal subdevs */
ret = imx_media_register_ipu_internal_subdevs(imxmd, sd);
if (ret)
return ret;
}
dev_dbg(imxmd->md.dev, "subdev %s bound\n", sd->name);
return 0;
}
/* async subdev complete notifier */
static int imx6_media_probe_complete(struct v4l2_async_notifier *notifier)
{
struct imx_media_dev *imxmd = notifier2dev(notifier);
int ret;
/* call the imx5/6/7 common probe completion handler */
ret = imx_media_probe_complete(notifier);
if (ret)
return ret;
mutex_lock(&imxmd->mutex);
imxmd->m2m_vdev = imx_media_csc_scaler_device_init(imxmd);
if (IS_ERR(imxmd->m2m_vdev)) {
ret = PTR_ERR(imxmd->m2m_vdev);
imxmd->m2m_vdev = NULL;
goto unlock;
}
ret = imx_media_csc_scaler_device_register(imxmd->m2m_vdev);
unlock:
mutex_unlock(&imxmd->mutex);
return ret;
}
/* async subdev complete notifier */
static const struct v4l2_async_notifier_operations imx_media_notifier_ops = {
.bound = imx_media_subdev_bound,
.complete = imx6_media_probe_complete,
};
static int imx_media_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct imx_media_dev *imxmd;
int ret;
imxmd = imx_media_dev_init(dev, NULL);
if (IS_ERR(imxmd))
return PTR_ERR(imxmd);
ret = imx_media_add_of_subdevs(imxmd, node);
if (ret) {
v4l2_err(&imxmd->v4l2_dev,
"add_of_subdevs failed with %d\n", ret);
goto cleanup;
}
ret = imx_media_dev_notifier_register(imxmd, &imx_media_notifier_ops);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/module.h`, `linux/platform_device.h`, `media/v4l2-async.h`, `media/v4l2-event.h`, `media/imx.h`, `imx-media.h`.
- Detected declarations: `function Copyright`, `function imx_media_subdev_bound`, `function imx6_media_probe_complete`, `function imx_media_probe`, `function imx_media_remove`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.