drivers/media/pci/ivtv/ivtv-ioctl.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/ivtv/ivtv-ioctl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/ivtv/ivtv-ioctl.c- Extension
.c- Size
- 48606 bytes
- Lines
- 1752
- 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
ivtv-driver.hivtv-version.hivtv-mailbox.hivtv-i2c.hivtv-queue.hivtv-fileops.hivtv-vbi.hivtv-routing.hivtv-streams.hivtv-yuv.hivtv-ioctl.hivtv-gpio.hivtv-controls.hivtv-cards.hmedia/i2c/saa7127.hmedia/tveeprom.hmedia/v4l2-event.h
Detected Declarations
function Copyrightfunction valid_service_linefunction select_service_from_setfunction ivtv_expand_service_setfunction check_service_setfunction ivtv_get_service_setfunction ivtv_set_osd_alphafunction ivtv_set_speedfunction ivtv_validate_speedfunction ivtv_video_commandfunction ivtv_g_fmt_sliced_vbi_outfunction ivtv_g_fmt_vid_capfunction ivtv_g_fmt_vbi_capfunction ivtv_g_fmt_sliced_vbi_capfunction ivtv_g_fmt_vid_outfunction ivtv_g_fmt_vid_out_overlayfunction ivtv_try_fmt_sliced_vbi_outfunction ivtv_try_fmt_vid_capfunction ivtv_try_fmt_vbi_capfunction ivtv_try_fmt_sliced_vbi_capfunction ivtv_try_fmt_vid_outfunction ivtv_try_fmt_vid_out_overlayfunction ivtv_s_fmt_sliced_vbi_outfunction ivtv_s_fmt_vid_capfunction ivtv_s_fmt_vbi_capfunction ivtv_s_fmt_sliced_vbi_capfunction ivtv_s_fmt_vid_outfunction ivtv_s_fmt_vid_out_overlayfunction ivtv_itvcfunction ivtv_g_registerfunction ivtv_s_registerfunction ivtv_querycapfunction ivtv_enumaudiofunction ivtv_g_audiofunction ivtv_s_audiofunction ivtv_enumaudoutfunction ivtv_g_audoutfunction ivtv_s_audoutfunction ivtv_enum_inputfunction ivtv_enum_outputfunction ivtv_g_pixelaspectfunction ivtv_s_selectionfunction ivtv_g_selectionfunction ivtv_enum_fmt_vid_capfunction ivtv_enum_fmt_vid_outfunction ivtv_g_inputfunction ivtv_do_s_inputfunction ivtv_s_input
Annotated Snippet
while (test_bit(IVTV_F_I_DMA, &itv->i_flags)) {
got_sig = signal_pending(current);
if (got_sig)
break;
got_sig = 0;
schedule();
}
finish_wait(&itv->dma_waitq, &wait);
mutex_lock(&itv->serialize_lock);
if (got_sig)
return -EINTR;
/* Change Speed safely */
ivtv_api(itv, CX2341X_DEC_SET_PLAYBACK_SPEED, 7, data);
IVTV_DEBUG_INFO("Setting Speed to 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
data[0], data[1], data[2], data[3], data[4], data[5], data[6]);
}
if (single_step) {
speed = (speed < 0) ? -1 : 1;
ivtv_vapi(itv, CX2341X_DEC_STEP_VIDEO, 1, 0);
}
itv->speed = speed;
return 0;
}
static int ivtv_validate_speed(int cur_speed, int new_speed)
{
int fact = new_speed < 0 ? -1 : 1;
int s;
if (cur_speed == 0)
cur_speed = 1000;
if (new_speed < 0)
new_speed = -new_speed;
if (cur_speed < 0)
cur_speed = -cur_speed;
if (cur_speed <= new_speed) {
if (new_speed > 1500)
return fact * 2000;
if (new_speed > 1000)
return fact * 1500;
}
else {
if (new_speed >= 2000)
return fact * 2000;
if (new_speed >= 1500)
return fact * 1500;
if (new_speed >= 1000)
return fact * 1000;
}
if (new_speed == 0)
return 1000;
if (new_speed == 1 || new_speed == 1000)
return fact * new_speed;
s = new_speed;
new_speed = 1000 / new_speed;
if (1000 / cur_speed == new_speed)
new_speed += (cur_speed < s) ? -1 : 1;
if (new_speed > 60) return 1000 / (fact * 60);
return 1000 / (fact * new_speed);
}
static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
struct v4l2_decoder_cmd *dc, int try)
{
struct ivtv_stream *s = &itv->streams[IVTV_DEC_STREAM_TYPE_MPG];
if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
return -EINVAL;
switch (dc->cmd) {
case V4L2_DEC_CMD_START: {
dc->flags &= V4L2_DEC_CMD_START_MUTE_AUDIO;
dc->start.speed = ivtv_validate_speed(itv->speed, dc->start.speed);
if (dc->start.speed < 0)
dc->start.format = V4L2_DEC_START_FMT_GOP;
else
dc->start.format = V4L2_DEC_START_FMT_NONE;
if (dc->start.speed != 500 && dc->start.speed != 1500)
dc->flags = dc->start.speed == 1000 ? 0 :
V4L2_DEC_CMD_START_MUTE_AUDIO;
if (try) break;
itv->speed_mute_audio = dc->flags & V4L2_DEC_CMD_START_MUTE_AUDIO;
if (ivtv_set_output_mode(itv, OUT_MPG) != OUT_MPG)
return -EBUSY;
if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags)) {
/* forces ivtv_set_speed to be called */
Annotation
- Immediate include surface: `ivtv-driver.h`, `ivtv-version.h`, `ivtv-mailbox.h`, `ivtv-i2c.h`, `ivtv-queue.h`, `ivtv-fileops.h`, `ivtv-vbi.h`, `ivtv-routing.h`.
- Detected declarations: `function Copyright`, `function valid_service_line`, `function select_service_from_set`, `function ivtv_expand_service_set`, `function check_service_set`, `function ivtv_get_service_set`, `function ivtv_set_osd_alpha`, `function ivtv_set_speed`, `function ivtv_validate_speed`, `function ivtv_video_command`.
- 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.