drivers/staging/media/imx/imx-media-dev-common.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/imx/imx-media-dev-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/imx/imx-media-dev-common.c- Extension
.c- Size
- 10039 bytes
- Lines
- 402
- 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.
- 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
media/v4l2-ctrls.hmedia/v4l2-event.hmedia/v4l2-ioctl.hmedia/v4l2-mc.himx-media.h
Detected Declarations
function Copyrightfunction imx_media_create_csi2_linksfunction list_for_each_entryfunction list_for_each_entryfunction imx_media_add_vdev_to_padfunction list_for_each_entryfunction imx_media_alloc_pad_vdev_listsfunction list_for_each_entryfunction imx_media_create_pad_vdev_listsfunction list_for_each_entryfunction imx_media_probe_completefunction imx_media_inherit_controlsfunction imx_media_link_notifyfunction list_for_each_entryfunction list_for_each_entryfunction imx_media_notifyfunction imx_media_dev_notifier_registerexport imx_media_probe_completeexport imx_media_dev_initexport imx_media_dev_notifier_register
Annotated Snippet
if (sd->grp_id == IMX_MEDIA_GRP_ID_CSI2) {
csi2 = sd;
break;
}
}
if (!csi2)
return;
list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
/* skip if not a CSI or a CSI mux */
if (!(sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) &&
!(sd->grp_id & IMX_MEDIA_GRP_ID_CSI_MUX))
continue;
v4l2_create_fwnode_links(csi2, sd);
}
}
/*
* adds given video device to given imx-media source pad vdev list.
* Continues upstream from the pad entity's sink pads.
*/
static int imx_media_add_vdev_to_pad(struct imx_media_dev *imxmd,
struct imx_media_video_dev *vdev,
struct media_pad *srcpad)
{
struct media_entity *entity = srcpad->entity;
struct imx_media_pad_vdev *pad_vdev;
struct list_head *pad_vdev_list;
struct media_link *link;
struct v4l2_subdev *sd;
int i, ret;
/* skip this entity if not a v4l2_subdev */
if (!is_media_entity_v4l2_subdev(entity))
return 0;
sd = media_entity_to_v4l2_subdev(entity);
pad_vdev_list = to_pad_vdev_list(sd, srcpad->index);
if (!pad_vdev_list) {
v4l2_warn(&imxmd->v4l2_dev, "%s:%u has no vdev list!\n",
entity->name, srcpad->index);
/*
* shouldn't happen, but no reason to fail driver load,
* just skip this entity.
*/
return 0;
}
/* just return if we've been here before */
list_for_each_entry(pad_vdev, pad_vdev_list, list) {
if (pad_vdev->vdev == vdev)
return 0;
}
dev_dbg(imxmd->md.dev, "adding %s to pad %s:%u\n",
vdev->vfd->entity.name, entity->name, srcpad->index);
pad_vdev = devm_kzalloc(imxmd->md.dev, sizeof(*pad_vdev), GFP_KERNEL);
if (!pad_vdev)
return -ENOMEM;
/* attach this vdev to this pad */
pad_vdev->vdev = vdev;
list_add_tail(&pad_vdev->list, pad_vdev_list);
/* move upstream from this entity's sink pads */
for (i = 0; i < entity->num_pads; i++) {
struct media_pad *pad = &entity->pads[i];
if (!(pad->flags & MEDIA_PAD_FL_SINK))
continue;
list_for_each_entry(link, &entity->links, list) {
if (link->sink != pad)
continue;
ret = imx_media_add_vdev_to_pad(imxmd, vdev,
link->source);
if (ret)
return ret;
}
}
return 0;
}
/*
* For every subdevice, allocate an array of list_head's, one list_head
* for each pad, to hold the list of video devices reachable from that
Annotation
- Immediate include surface: `media/v4l2-ctrls.h`, `media/v4l2-event.h`, `media/v4l2-ioctl.h`, `media/v4l2-mc.h`, `imx-media.h`.
- Detected declarations: `function Copyright`, `function imx_media_create_csi2_links`, `function list_for_each_entry`, `function list_for_each_entry`, `function imx_media_add_vdev_to_pad`, `function list_for_each_entry`, `function imx_media_alloc_pad_vdev_lists`, `function list_for_each_entry`, `function imx_media_create_pad_vdev_lists`, `function list_for_each_entry`.
- 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.
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.