drivers/media/platform/ti/omap3isp/ispstat.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/ti/omap3isp/ispstat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/ti/omap3isp/ispstat.c- Extension
.c- Size
- 30075 bytes
- Lines
- 1076
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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.
- 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/dma-mapping.hlinux/slab.hlinux/timekeeping.hlinux/uaccess.hisp.h
Detected Declarations
function Copyrightfunction isp_stat_buf_sync_magic_for_devicefunction isp_stat_buf_sync_magic_for_cpufunction isp_stat_buf_check_magicfunction isp_stat_buf_insert_magicfunction isp_stat_buf_sync_for_devicefunction isp_stat_buf_sync_for_cpufunction isp_stat_buf_clearfunction __isp_stat_buf_findfunction isp_stat_buf_find_oldestfunction isp_stat_buf_find_oldest_or_emptyfunction isp_stat_buf_queuefunction isp_stat_buf_nextfunction isp_stat_buf_releasefunction isp_stat_bufs_freefunction isp_stat_bufs_alloc_onefunction isp_stat_queue_eventfunction omap3isp_stat_request_statisticsfunction omap3isp_stat_request_statistics_time32function omap3isp_stat_configfunction isp_stat_buf_processfunction omap3isp_stat_pcr_busyfunction omap3isp_stat_busyfunction isp_stat_pcr_enablefunction omap3isp_stat_suspendfunction omap3isp_stat_resumefunction isp_stat_try_enablefunction omap3isp_stat_isr_frame_syncfunction omap3isp_stat_sbl_overflowfunction omap3isp_stat_enablefunction omap3isp_stat_s_streamfunction __stat_isrfunction omap3isp_stat_isrfunction omap3isp_stat_dma_isrfunction omap3isp_stat_subscribe_eventfunction omap3isp_stat_unregister_entitiesfunction omap3isp_stat_register_entitiesfunction isp_stat_init_entitiesfunction omap3isp_stat_initfunction omap3isp_stat_cleanup
Annotated Snippet
if (unlikely(*w != MAGIC_NUM)) {
dev_dbg(stat->isp->dev,
"%s: ending magic check does not match.\n",
stat->subdev.name);
return -EINVAL;
}
}
isp_stat_buf_sync_magic_for_device(stat, buf, buf_size,
DMA_FROM_DEVICE);
return 0;
}
static void isp_stat_buf_insert_magic(struct ispstat *stat,
struct ispstat_buffer *buf)
{
const u32 buf_size = IS_H3A_AF(stat) ?
stat->buf_size + AF_EXTRA_DATA : stat->buf_size;
isp_stat_buf_sync_magic_for_cpu(stat, buf, buf_size, DMA_FROM_DEVICE);
/*
* Inserting MAGIC_NUM at the beginning and end of the buffer.
* buf->buf_size is set only after the buffer is queued. For now the
* right buf_size for the current configuration is pointed by
* stat->buf_size.
*/
memset(buf->virt_addr, MAGIC_NUM, MAGIC_SIZE);
memset(buf->virt_addr + buf_size, MAGIC_NUM, MAGIC_SIZE);
isp_stat_buf_sync_magic_for_device(stat, buf, buf_size,
DMA_BIDIRECTIONAL);
}
static void isp_stat_buf_sync_for_device(struct ispstat *stat,
struct ispstat_buffer *buf)
{
if (ISP_STAT_USES_DMAENGINE(stat))
return;
dma_sync_sgtable_for_device(stat->isp->dev, &buf->sgt, DMA_FROM_DEVICE);
}
static void isp_stat_buf_sync_for_cpu(struct ispstat *stat,
struct ispstat_buffer *buf)
{
if (ISP_STAT_USES_DMAENGINE(stat))
return;
dma_sync_sgtable_for_cpu(stat->isp->dev, &buf->sgt, DMA_FROM_DEVICE);
}
static void isp_stat_buf_clear(struct ispstat *stat)
{
int i;
for (i = 0; i < STAT_MAX_BUFS; i++)
stat->buf[i].empty = 1;
}
static struct ispstat_buffer *
__isp_stat_buf_find(struct ispstat *stat, int look_empty)
{
struct ispstat_buffer *found = NULL;
int i;
for (i = 0; i < STAT_MAX_BUFS; i++) {
struct ispstat_buffer *curr = &stat->buf[i];
/*
* Don't select the buffer which is being copied to
* userspace or used by the module.
*/
if (curr == stat->locked_buf || curr == stat->active_buf)
continue;
/* Don't select uninitialised buffers if it's not required */
if (!look_empty && curr->empty)
continue;
/* Pick uninitialised buffer over anything else if look_empty */
if (curr->empty) {
found = curr;
break;
}
/* Choose the oldest buffer */
if (!found ||
(s32)curr->frame_number - (s32)found->frame_number < 0)
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/slab.h`, `linux/timekeeping.h`, `linux/uaccess.h`, `isp.h`.
- Detected declarations: `function Copyright`, `function isp_stat_buf_sync_magic_for_device`, `function isp_stat_buf_sync_magic_for_cpu`, `function isp_stat_buf_check_magic`, `function isp_stat_buf_insert_magic`, `function isp_stat_buf_sync_for_device`, `function isp_stat_buf_sync_for_cpu`, `function isp_stat_buf_clear`, `function __isp_stat_buf_find`, `function isp_stat_buf_find_oldest`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.