drivers/media/mc/mc-entity.c
Source file repositories/reference/linux-study-clean/drivers/media/mc/mc-entity.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/mc/mc-entity.c- Extension
.c- Size
- 41304 bytes
- Lines
- 1676
- Domain
- Driver Families
- Bucket
- drivers/media
- 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
linux/bitmap.hlinux/list.hlinux/property.hlinux/slab.hmedia/media-entity.hmedia/media-device.h
Detected Declarations
struct media_pipeline_walk_entrystruct media_pipeline_walkfunction Copyrightfunction media_entity_enum_initfunction media_entity_enum_cleanupfunction dev_dbg_objfunction media_gobj_createfunction media_gobj_destroyfunction media_entity_pads_initfunction media_entity_for_each_padfunction media_entity_has_pad_interdepfunction media_entity_otherfunction stack_pushfunction media_graph_walk_cleanupfunction media_graph_walk_cleanupfunction media_graph_walk_startfunction media_graph_walk_iterfunction media_pipeline_walk_topfunction media_pipeline_walk_emptyfunction media_pipeline_walk_resizefunction media_pipeline_walk_pushfunction media_pipeline_walk_popfunction media_pipeline_walk_destroyfunction media_pipeline_add_padfunction list_for_each_entryfunction media_pipeline_explore_next_linkfunction media_entity_for_each_padfunction media_pipeline_cleanupfunction media_pipeline_populatefunction media_pipeline_explore_next_linkfunction __media_pipeline_startfunction list_for_each_entryfunction for_each_media_entity_data_linkfunction list_for_each_entryfunction media_pipeline_startfunction __media_pipeline_stopfunction media_pipeline_stopfunction media_pipeline_alloc_startfunction __media_pipeline_pad_iter_nextfunction media_pipeline_entity_iter_initfunction media_pipeline_entity_iter_cleanupfunction __media_pipeline_entity_iter_nextfunction __media_entity_remove_linkfunction list_for_each_entry_safefunction media_get_pad_indexfunction media_create_pad_linkfunction media_create_pad_linksfunction media_device_for_each_entity
Annotated Snippet
struct media_pipeline_walk_entry {
struct media_pad *pad;
struct list_head *links;
};
/**
* struct media_pipeline_walk - State used by the media pipeline traversal
* algorithm
*
* @mdev: The media device
* @stack: Depth-first search stack
* @stack.size: Number of allocated entries in @stack.entries
* @stack.top: Index of the top stack entry (-1 if the stack is empty)
* @stack.entries: Stack entries
*/
struct media_pipeline_walk {
struct media_device *mdev;
struct {
unsigned int size;
int top;
struct media_pipeline_walk_entry *entries;
} stack;
};
#define MEDIA_PIPELINE_STACK_GROW_STEP 16
static struct media_pipeline_walk_entry *
media_pipeline_walk_top(struct media_pipeline_walk *walk)
{
return &walk->stack.entries[walk->stack.top];
}
static bool media_pipeline_walk_empty(struct media_pipeline_walk *walk)
{
return walk->stack.top == -1;
}
/* Increase the stack size by MEDIA_PIPELINE_STACK_GROW_STEP elements. */
static int media_pipeline_walk_resize(struct media_pipeline_walk *walk)
{
struct media_pipeline_walk_entry *entries;
unsigned int new_size;
/* Safety check, to avoid stack overflows in case of bugs. */
if (walk->stack.size >= 256)
return -E2BIG;
new_size = walk->stack.size + MEDIA_PIPELINE_STACK_GROW_STEP;
entries = krealloc(walk->stack.entries,
new_size * sizeof(*walk->stack.entries),
GFP_KERNEL);
if (!entries)
return -ENOMEM;
walk->stack.entries = entries;
walk->stack.size = new_size;
return 0;
}
/* Push a new entry on the stack. */
static int media_pipeline_walk_push(struct media_pipeline_walk *walk,
struct media_pad *pad)
{
struct media_pipeline_walk_entry *entry;
int ret;
if (walk->stack.top + 1 >= walk->stack.size) {
ret = media_pipeline_walk_resize(walk);
if (ret)
return ret;
}
walk->stack.top++;
entry = media_pipeline_walk_top(walk);
entry->pad = pad;
entry->links = pad->entity->links.next;
dev_dbg(walk->mdev->dev,
"media pipeline: pushed entry %u: '%s':%u\n",
walk->stack.top, pad->entity->name, pad->index);
return 0;
}
/*
* Move the top entry link cursor to the next link. If all links of the entry
* have been visited, pop the entry itself. Return true if the entry has been
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/list.h`, `linux/property.h`, `linux/slab.h`, `media/media-entity.h`, `media/media-device.h`.
- Detected declarations: `struct media_pipeline_walk_entry`, `struct media_pipeline_walk`, `function Copyright`, `function media_entity_enum_init`, `function media_entity_enum_cleanup`, `function dev_dbg_obj`, `function media_gobj_create`, `function media_gobj_destroy`, `function media_entity_pads_init`, `function media_entity_for_each_pad`.
- Atlas domain: Driver Families / drivers/media.
- 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.