drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c- Extension
.c- Size
- 8911 bytes
- Lines
- 355
- 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.
- 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/dma-mapping.hlinux/interrupt.hlinux/module.hlinux/mutex.hlinux/of.hlinux/of_graph.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hlinux/videodev2.hmedia/v4l2-dev.hmedia/v4l2-device.hmedia/v4l2-fwnode.hmedia/v4l2-ioctl.hmedia/v4l2-mediabus.hmedia/videobuf2-core.hmedia/videobuf2-dma-contig.hsun4i_csi.h
Detected Declarations
struct sun4i_csi_traitsfunction sun4i_csi_video_link_validatefunction sun4i_csi_notify_boundfunction sun4i_csi_notify_completefunction sun4i_csi_notifier_initfunction sun4i_csi_probefunction sun4i_csi_removefunction sun4i_csi_runtime_resumefunction sun4i_csi_runtime_suspend
Annotated Snippet
struct sun4i_csi_traits {
unsigned int channels;
unsigned int max_width;
bool has_isp;
};
static int sun4i_csi_video_link_validate(struct media_link *link)
{
dev_warn_once(link->graph_obj.mdev->dev,
"Driver bug: link validation not implemented\n");
return 0;
}
static const struct media_entity_operations sun4i_csi_video_entity_ops = {
.link_validate = sun4i_csi_video_link_validate,
};
static const struct media_entity_operations sun4i_csi_subdev_entity_ops = {
.link_validate = v4l2_subdev_link_validate,
};
static int sun4i_csi_notify_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *subdev,
struct v4l2_async_connection *asd)
{
struct sun4i_csi *csi = container_of(notifier, struct sun4i_csi,
notifier);
csi->src_subdev = subdev;
csi->src_pad = media_entity_get_fwnode_pad(&subdev->entity,
subdev->fwnode,
MEDIA_PAD_FL_SOURCE);
if (csi->src_pad < 0) {
dev_err(csi->dev, "Couldn't find output pad for subdev %s\n",
subdev->name);
return csi->src_pad;
}
dev_dbg(csi->dev, "Bound %s pad: %d\n", subdev->name, csi->src_pad);
return 0;
}
static int sun4i_csi_notify_complete(struct v4l2_async_notifier *notifier)
{
struct sun4i_csi *csi = container_of(notifier, struct sun4i_csi,
notifier);
struct v4l2_subdev *subdev = &csi->subdev;
struct video_device *vdev = &csi->vdev;
int ret;
ret = v4l2_device_register_subdev(&csi->v4l, subdev);
if (ret < 0)
return ret;
ret = sun4i_csi_v4l2_register(csi);
if (ret < 0)
return ret;
ret = media_device_register(&csi->mdev);
if (ret)
return ret;
/* Create link from subdev to main device */
ret = media_create_pad_link(&subdev->entity, CSI_SUBDEV_SOURCE,
&vdev->entity, 0,
MEDIA_LNK_FL_ENABLED |
MEDIA_LNK_FL_IMMUTABLE);
if (ret)
goto err_clean_media;
ret = media_create_pad_link(&csi->src_subdev->entity, csi->src_pad,
&subdev->entity, CSI_SUBDEV_SINK,
MEDIA_LNK_FL_ENABLED |
MEDIA_LNK_FL_IMMUTABLE);
if (ret)
goto err_clean_media;
ret = v4l2_device_register_subdev_nodes(&csi->v4l);
if (ret < 0)
goto err_clean_media;
return 0;
err_clean_media:
media_device_unregister(&csi->mdev);
return ret;
}
static const struct v4l2_async_notifier_operations sun4i_csi_notify_ops = {
Annotation
- Immediate include surface: `linux/clk.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/module.h`, `linux/mutex.h`, `linux/of.h`, `linux/of_graph.h`, `linux/platform_device.h`.
- Detected declarations: `struct sun4i_csi_traits`, `function sun4i_csi_video_link_validate`, `function sun4i_csi_notify_bound`, `function sun4i_csi_notify_complete`, `function sun4i_csi_notifier_init`, `function sun4i_csi_probe`, `function sun4i_csi_remove`, `function sun4i_csi_runtime_resume`, `function sun4i_csi_runtime_suspend`.
- 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.