drivers/media/pci/cx18/cx18-streams.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cx18/cx18-streams.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cx18/cx18-streams.c- Extension
.c- Size
- 29396 bytes
- Lines
- 1052
- 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
cx18-driver.hcx18-io.hcx18-fileops.hcx18-mailbox.hcx18-i2c.hcx18-queue.hcx18-ioctl.hcx18-streams.hcx18-cards.hcx18-scb.hcx18-dvb.h
Detected Declarations
function cx18_queue_setupfunction cx18_buf_queuefunction cx18_buf_preparefunction cx18_clear_queuefunction cx18_start_streamingfunction cx18_stop_streamingfunction cx18_stream_initfunction cx18_prep_devfunction cx18_streams_setupfunction cx18_reg_devfunction cx18_streams_registerfunction cx18_streams_cleanupfunction cx18_vbi_setupfunction cx18_stream_rotate_idx_mdlsfunction _cx18_stream_load_fw_queuefunction cx18_out_work_handlerfunction cx18_stream_configure_mdlsfunction cx18_start_v4l2_encode_streamfunction cx18_vapifunction cx18_stop_all_capturesfunction cx18_stop_v4l2_encode_streamfunction cx18_find_handleexport cx18_start_v4l2_encode_streamexport cx18_stop_v4l2_encode_stream
Annotated Snippet
if (cx->card->hw_all & CX18_HW_DVB) {
s->dvb = kzalloc_obj(struct cx18_dvb);
if (s->dvb == NULL) {
CX18_ERR("Couldn't allocate cx18_dvb structure for %s\n",
s->name);
return -ENOMEM;
}
} else {
/* Don't need buffers for the TS, if there is no DVB */
s->buffers = 0;
}
}
if (num_offset == -1)
return 0;
/* initialize the v4l2 video device structure */
snprintf(s->video_dev.name, sizeof(s->video_dev.name), "%s %s",
cx->v4l2_dev.name, s->name);
s->video_dev.num = num;
s->video_dev.v4l2_dev = &cx->v4l2_dev;
if (type == CX18_ENC_STREAM_TYPE_YUV)
s->video_dev.fops = &cx18_v4l2_enc_yuv_fops;
else
s->video_dev.fops = &cx18_v4l2_enc_fops;
s->video_dev.release = video_device_release_empty;
if (cx->card->video_inputs->video_type == CX18_CARD_INPUT_VID_TUNER)
s->video_dev.tvnorms = cx->tuner_std;
else
s->video_dev.tvnorms = V4L2_STD_ALL;
s->video_dev.lock = &cx->serialize_lock;
cx18_set_funcs(&s->video_dev);
return 0;
}
/* Initialize v4l2 variables and register v4l2 devices */
int cx18_streams_setup(struct cx18 *cx)
{
int type, ret;
/* Setup V4L2 Devices */
for (type = 0; type < CX18_MAX_STREAMS; type++) {
/* Prepare device */
ret = cx18_prep_dev(cx, type);
if (ret < 0)
break;
/* Allocate Stream */
ret = cx18_stream_alloc(&cx->streams[type]);
if (ret < 0)
break;
}
if (type == CX18_MAX_STREAMS)
return 0;
/* One or more streams could not be initialized. Clean 'em all up. */
cx18_streams_cleanup(cx, 0);
return ret;
}
static int cx18_reg_dev(struct cx18 *cx, int type)
{
struct cx18_stream *s = &cx->streams[type];
int vfl_type = cx18_stream_info[type].vfl_type;
const char *name;
int num, ret;
if (type == CX18_ENC_STREAM_TYPE_TS && s->dvb != NULL) {
ret = cx18_dvb_register(s);
if (ret < 0) {
CX18_ERR("DVB failed to register\n");
return ret;
}
}
if (s->video_dev.v4l2_dev == NULL)
return 0;
num = s->video_dev.num;
s->video_dev.device_caps = s->v4l2_dev_caps; /* device capabilities */
/* card number + user defined offset + device offset */
if (type != CX18_ENC_STREAM_TYPE_MPG) {
struct cx18_stream *s_mpg = &cx->streams[CX18_ENC_STREAM_TYPE_MPG];
if (s_mpg->video_dev.v4l2_dev)
num = s_mpg->video_dev.num
+ cx18_stream_info[type].num_offset;
}
video_set_drvdata(&s->video_dev, s);
Annotation
- Immediate include surface: `cx18-driver.h`, `cx18-io.h`, `cx18-fileops.h`, `cx18-mailbox.h`, `cx18-i2c.h`, `cx18-queue.h`, `cx18-ioctl.h`, `cx18-streams.h`.
- Detected declarations: `function cx18_queue_setup`, `function cx18_buf_queue`, `function cx18_buf_prepare`, `function cx18_clear_queue`, `function cx18_start_streaming`, `function cx18_stop_streaming`, `function cx18_stream_init`, `function cx18_prep_dev`, `function cx18_streams_setup`, `function cx18_reg_dev`.
- 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.