drivers/media/pci/cx18/cx18-ioctl.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cx18/cx18-ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cx18/cx18-ioctl.c- Extension
.c- Size
- 29065 bytes
- Lines
- 1058
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
cx18-driver.hcx18-io.hcx18-version.hcx18-mailbox.hcx18-i2c.hcx18-queue.hcx18-fileops.hcx18-vbi.hcx18-audio.hcx18-video.hcx18-streams.hcx18-ioctl.hcx18-gpio.hcx18-controls.hcx18-cards.hcx18-av-core.hmedia/tveeprom.hmedia/v4l2-event.h
Detected Declarations
function cx18_g_fmt_vid_capfunction cx18_try_fmt_vid_capfunction isfunction cx18_s_fmt_vid_capfunction cx18_service2vbifunction valid_service_linefunction afunction cx18_expand_service_setfunction check_service_setfunction cx18_get_service_setfunction cx18_g_fmt_vbi_capfunction cx18_g_fmt_sliced_vbi_capfunction cx18_try_fmt_vbi_capfunction cx18_try_fmt_sliced_vbi_capfunction cx18_s_fmt_vbi_capfunction cx18_s_fmt_sliced_vbi_capfunction cx18_g_registerfunction cx18_s_registerfunction cx18_querycapfunction cx18_enumaudiofunction cx18_g_audiofunction cx18_s_audiofunction cx18_enum_inputfunction cx18_g_pixelaspectfunction cx18_g_selectionfunction cx18_enum_fmt_vid_capfunction cx18_g_inputfunction cx18_do_s_inputfunction cx18_s_inputfunction cx18_g_frequencyfunction cx18_do_s_frequencyfunction cx18_s_frequencyfunction cx18_g_stdfunction cx18_do_s_stdfunction isfunction cx18_s_stdfunction cx18_s_tunerfunction cx18_g_tunerfunction cx18_g_sliced_vbi_capfunction _cx18_process_idx_datafunction cx18_process_idx_datafunction list_for_each_entry_fromfunction cx18_g_enc_indexfunction cx18_encoder_cmdfunction cx18_try_encoder_cmdfunction cx18_log_statusfunction cx18_defaultfunction cx18_set_funcs
Annotated Snippet
if (pixfmt->pixelformat == V4L2_PIX_FMT_NV12_16L16) {
pixfmt->sizeimage = h * 720 * 3 / 2;
pixfmt->bytesperline = 720; /* First plane */
} else {
pixfmt->sizeimage = h * 720 * 2;
pixfmt->bytesperline = 1440; /* Packed */
}
} else {
pixfmt->pixelformat = V4L2_PIX_FMT_MPEG;
pixfmt->sizeimage = 128 * 1024;
pixfmt->bytesperline = 0;
}
pixfmt->width = w;
pixfmt->height = h;
pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
pixfmt->field = V4L2_FIELD_INTERLACED;
return 0;
}
static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *fmt)
{
struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct cx18_stream *s = &cx->streams[id->type];
int ret;
int w, h;
ret = cx18_try_fmt_vid_cap(file, fh, fmt);
if (ret)
return ret;
w = fmt->fmt.pix.width;
h = fmt->fmt.pix.height;
if (cx->cxhdl.width == w && cx->cxhdl.height == h &&
s->pixelformat == fmt->fmt.pix.pixelformat)
return 0;
if (atomic_read(&cx->ana_capturing) > 0)
return -EBUSY;
s->pixelformat = fmt->fmt.pix.pixelformat;
s->vb_bytes_per_frame = fmt->fmt.pix.sizeimage;
s->vb_bytes_per_line = fmt->fmt.pix.bytesperline;
format.format.width = cx->cxhdl.width = w;
format.format.height = cx->cxhdl.height = h;
format.format.code = MEDIA_BUS_FMT_FIXED;
v4l2_subdev_call(cx->sd_av, pad, set_fmt, NULL, &format);
return cx18_g_fmt_vid_cap(file, fh, fmt);
}
u16 cx18_service2vbi(int type)
{
switch (type) {
case V4L2_SLICED_TELETEXT_B:
return CX18_SLICED_TYPE_TELETEXT_B;
case V4L2_SLICED_CAPTION_525:
return CX18_SLICED_TYPE_CAPTION_525;
case V4L2_SLICED_WSS_625:
return CX18_SLICED_TYPE_WSS_625;
case V4L2_SLICED_VPS:
return CX18_SLICED_TYPE_VPS;
default:
return 0;
}
}
/* Check if VBI services are allowed on the (field, line) for the video std */
static int valid_service_line(int field, int line, int is_pal)
{
return (is_pal && line >= 6 &&
((field == 0 && line <= 23) || (field == 1 && line <= 22))) ||
(!is_pal && line >= 10 && line < 22);
}
/*
* For a (field, line, std) and inbound potential set of services for that line,
* return the first valid service of those passed in the incoming set for that
* line in priority order:
* CC, VPS, or WSS over TELETEXT for well known lines
* TELETEXT, before VPS, before CC, before WSS, for other lines
*/
static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
{
u16 valid_set = (is_pal ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525);
Annotation
- Immediate include surface: `cx18-driver.h`, `cx18-io.h`, `cx18-version.h`, `cx18-mailbox.h`, `cx18-i2c.h`, `cx18-queue.h`, `cx18-fileops.h`, `cx18-vbi.h`.
- Detected declarations: `function cx18_g_fmt_vid_cap`, `function cx18_try_fmt_vid_cap`, `function is`, `function cx18_s_fmt_vid_cap`, `function cx18_service2vbi`, `function valid_service_line`, `function a`, `function cx18_expand_service_set`, `function check_service_set`, `function cx18_get_service_set`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.