drivers/media/pci/ivtv/ivtv-fileops.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/ivtv/ivtv-fileops.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/ivtv/ivtv-fileops.c- Extension
.c- Size
- 31761 bytes
- Lines
- 1072
- 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.
- 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.
- 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
ivtv-driver.hivtv-fileops.hivtv-i2c.hivtv-queue.hivtv-udma.hivtv-irq.hivtv-vbi.hivtv-mailbox.hivtv-routing.hivtv-streams.hivtv-yuv.hivtv-ioctl.hivtv-cards.hivtv-firmware.hlinux/lockdep.hmedia/v4l2-event.hmedia/i2c/saa7115.h
Detected Declarations
function Copyrightfunction IVTV_ENC_STREAM_TYPE_VBIfunction ivtv_release_streamfunction test_bitfunction ivtv_dualwatchfunction ivtv_update_pgm_infofunction ivtv_schedulefunction ivtv_setup_sliced_vbi_buffunction ivtv_copy_buf_to_userfunction ivtv_readfunction ivtv_read_posfunction ivtv_start_capturefunction test_bitfunction test_bitfunction ivtv_v4l2_readfunction ivtv_start_decodingfunction ivtv_schedule_dmafunction ivtv_writefunction ivtv_v4l2_writefunction ivtv_v4l2_dec_pollfunction ivtv_v4l2_enc_pollfunction ivtv_stop_capturefunction ivtv_stop_decodingfunction ivtv_v4l2_closefunction v4l2_fh_is_singular_filefunction ivtv_openfunction ivtv_v4l2_openfunction ivtv_mutefunction ivtv_unmuteexport ivtv_claim_streamexport ivtv_release_stream
Annotated Snippet
if (s->id == id) {
/* yes, this file descriptor did. So that's OK. */
return 0;
}
if (s->id == NULL && (type == IVTV_DEC_STREAM_TYPE_VBI ||
type == IVTV_ENC_STREAM_TYPE_VBI)) {
/* VBI is handled already internally, now also assign
the file descriptor to this stream for external
reading of the stream. */
s->id = id;
IVTV_DEBUG_INFO("Start Read VBI\n");
return 0;
}
/* someone else is using this stream already */
IVTV_DEBUG_INFO("Stream %d is busy\n", type);
return -EBUSY;
}
s->id = id;
if (type == IVTV_DEC_STREAM_TYPE_VBI) {
/* Enable reinsertion interrupt */
ivtv_clear_irq_mask(itv, IVTV_IRQ_DEC_VBI_RE_INSERT);
}
/* IVTV_DEC_STREAM_TYPE_MPG needs to claim IVTV_DEC_STREAM_TYPE_VBI,
IVTV_ENC_STREAM_TYPE_MPG needs to claim IVTV_ENC_STREAM_TYPE_VBI
(provided VBI insertion is on and sliced VBI is selected), for all
other streams we're done */
if (type == IVTV_DEC_STREAM_TYPE_MPG) {
vbi_type = IVTV_DEC_STREAM_TYPE_VBI;
} else if (type == IVTV_ENC_STREAM_TYPE_MPG &&
itv->vbi.insert_mpeg && !ivtv_raw_vbi(itv)) {
vbi_type = IVTV_ENC_STREAM_TYPE_VBI;
} else {
return 0;
}
s_vbi = &itv->streams[vbi_type];
if (!test_and_set_bit(IVTV_F_S_CLAIMED, &s_vbi->s_flags)) {
/* Enable reinsertion interrupt */
if (vbi_type == IVTV_DEC_STREAM_TYPE_VBI)
ivtv_clear_irq_mask(itv, IVTV_IRQ_DEC_VBI_RE_INSERT);
}
/* mark that it is used internally */
set_bit(IVTV_F_S_INTERNAL_USE, &s_vbi->s_flags);
return 0;
}
EXPORT_SYMBOL(ivtv_claim_stream);
/* This function releases a previously claimed stream. It will take into
account associated VBI streams. */
void ivtv_release_stream(struct ivtv_stream *s)
{
struct ivtv *itv = s->itv;
struct ivtv_stream *s_vbi;
s->id = NULL;
if ((s->type == IVTV_DEC_STREAM_TYPE_VBI || s->type == IVTV_ENC_STREAM_TYPE_VBI) &&
test_bit(IVTV_F_S_INTERNAL_USE, &s->s_flags)) {
/* this stream is still in use internally */
return;
}
if (!test_and_clear_bit(IVTV_F_S_CLAIMED, &s->s_flags)) {
IVTV_DEBUG_WARN("Release stream %s not in use!\n", s->name);
return;
}
ivtv_flush_queues(s);
/* disable reinsertion interrupt */
if (s->type == IVTV_DEC_STREAM_TYPE_VBI)
ivtv_set_irq_mask(itv, IVTV_IRQ_DEC_VBI_RE_INSERT);
/* IVTV_DEC_STREAM_TYPE_MPG needs to release IVTV_DEC_STREAM_TYPE_VBI,
IVTV_ENC_STREAM_TYPE_MPG needs to release IVTV_ENC_STREAM_TYPE_VBI,
for all other streams we're done */
if (s->type == IVTV_DEC_STREAM_TYPE_MPG)
s_vbi = &itv->streams[IVTV_DEC_STREAM_TYPE_VBI];
else if (s->type == IVTV_ENC_STREAM_TYPE_MPG)
s_vbi = &itv->streams[IVTV_ENC_STREAM_TYPE_VBI];
else
return;
/* clear internal use flag */
if (!test_and_clear_bit(IVTV_F_S_INTERNAL_USE, &s_vbi->s_flags)) {
/* was already cleared */
return;
}
if (s_vbi->id) {
/* VBI stream still claimed by a file descriptor */
return;
Annotation
- Immediate include surface: `ivtv-driver.h`, `ivtv-fileops.h`, `ivtv-i2c.h`, `ivtv-queue.h`, `ivtv-udma.h`, `ivtv-irq.h`, `ivtv-vbi.h`, `ivtv-mailbox.h`.
- Detected declarations: `function Copyright`, `function IVTV_ENC_STREAM_TYPE_VBI`, `function ivtv_release_stream`, `function test_bit`, `function ivtv_dualwatch`, `function ivtv_update_pgm_info`, `function ivtv_schedule`, `function ivtv_setup_sliced_vbi_buf`, `function ivtv_copy_buf_to_user`, `function ivtv_read`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.
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.