Lines Matching +full:standard +full:- +full:vt
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
5 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
9 #include "ivtv-driver.h"
10 #include "ivtv-version.h"
11 #include "ivtv-mailbox.h"
12 #include "ivtv-i2c.h"
13 #include "ivtv-queue.h"
14 #include "ivtv-fileops.h"
15 #include "ivtv-vbi.h"
16 #include "ivtv-routing.h"
17 #include "ivtv-streams.h"
18 #include "ivtv-yuv.h"
19 #include "ivtv-ioctl.h"
20 #include "ivtv-gpio.h"
21 #include "ivtv-controls.h"
22 #include "ivtv-cards.h"
25 #include <media/v4l2-event.h>
84 u16 set = fmt->service_set; in ivtv_expand_service_set()
87 fmt->service_set = 0; in ivtv_expand_service_set()
90 fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal); in ivtv_expand_service_set()
101 fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal); in check_service_set()
113 set |= fmt->service_lines[f][l]; in ivtv_get_service_set()
122 itv->osd_global_alpha_state, itv->osd_global_alpha, !itv->osd_local_alpha_state); in ivtv_set_osd_alpha()
123 ivtv_vapi(itv, CX2341X_OSD_SET_CHROMA_KEY, 2, itv->osd_chroma_key_state, itv->osd_chroma_key); in ivtv_set_osd_alpha()
129 int single_step = (speed == 1 || speed == -1); in ivtv_set_speed()
135 if (speed == itv->speed && !single_step) in ivtv_set_speed()
138 if (single_step && (speed < 0) == (itv->speed < 0)) { in ivtv_set_speed()
141 itv->speed = speed; in ivtv_set_speed()
146 speed = speed < 0 ? -1000 : 1000; in ivtv_set_speed()
148 data[0] = (speed > 1000 || speed < -1000) ? 0x80000000 : 0; in ivtv_set_speed()
149 data[0] |= (speed > 1000 || speed < -1500) ? 0x40000000 : 0; in ivtv_set_speed()
152 data[3] = v4l2_ctrl_g_ctrl(itv->cxhdl.video_b_frames); in ivtv_set_speed()
153 data[4] = (speed == 1500 || speed == 500) ? itv->speed_mute_audio : 0; in ivtv_set_speed()
157 if (speed == 1500 || speed == -1500) data[0] |= 1; in ivtv_set_speed()
158 else if (speed == 2000 || speed == -2000) data[0] |= 2; in ivtv_set_speed()
159 else if (speed > -1000 && speed < 0) data[0] |= (-1000 / speed); in ivtv_set_speed()
163 if (atomic_read(&itv->decoding) > 0) { in ivtv_set_speed()
170 mutex_unlock(&itv->serialize_lock); in ivtv_set_speed()
171 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE); in ivtv_set_speed()
172 while (test_bit(IVTV_F_I_DMA, &itv->i_flags)) { in ivtv_set_speed()
179 finish_wait(&itv->dma_waitq, &wait); in ivtv_set_speed()
180 mutex_lock(&itv->serialize_lock); in ivtv_set_speed()
182 return -EINTR; in ivtv_set_speed()
190 speed = (speed < 0) ? -1 : 1; in ivtv_set_speed()
193 itv->speed = speed; in ivtv_set_speed()
199 int fact = new_speed < 0 ? -1 : 1; in ivtv_validate_speed()
205 new_speed = -new_speed; in ivtv_validate_speed()
207 cur_speed = -cur_speed; in ivtv_validate_speed()
231 new_speed += (cur_speed < s) ? -1 : 1; in ivtv_validate_speed()
239 struct ivtv_stream *s = &itv->streams[IVTV_DEC_STREAM_TYPE_MPG]; in ivtv_video_command()
241 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_video_command()
242 return -EINVAL; in ivtv_video_command()
244 switch (dc->cmd) { in ivtv_video_command()
246 dc->flags &= V4L2_DEC_CMD_START_MUTE_AUDIO; in ivtv_video_command()
247 dc->start.speed = ivtv_validate_speed(itv->speed, dc->start.speed); in ivtv_video_command()
248 if (dc->start.speed < 0) in ivtv_video_command()
249 dc->start.format = V4L2_DEC_START_FMT_GOP; in ivtv_video_command()
251 dc->start.format = V4L2_DEC_START_FMT_NONE; in ivtv_video_command()
252 if (dc->start.speed != 500 && dc->start.speed != 1500) in ivtv_video_command()
253 dc->flags = dc->start.speed == 1000 ? 0 : in ivtv_video_command()
257 itv->speed_mute_audio = dc->flags & V4L2_DEC_CMD_START_MUTE_AUDIO; in ivtv_video_command()
259 return -EBUSY; in ivtv_video_command()
260 if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags)) { in ivtv_video_command()
262 itv->speed = 0; in ivtv_video_command()
264 return ivtv_start_decoding(id, dc->start.speed); in ivtv_video_command()
268 dc->flags &= V4L2_DEC_CMD_STOP_IMMEDIATELY | V4L2_DEC_CMD_STOP_TO_BLACK; in ivtv_video_command()
269 if (dc->flags & V4L2_DEC_CMD_STOP_IMMEDIATELY) in ivtv_video_command()
270 dc->stop.pts = 0; in ivtv_video_command()
272 if (atomic_read(&itv->decoding) == 0) in ivtv_video_command()
274 if (itv->output_mode != OUT_MPG) in ivtv_video_command()
275 return -EBUSY; in ivtv_video_command()
277 itv->output_mode = OUT_NONE; in ivtv_video_command()
278 return ivtv_stop_v4l2_decode_stream(s, dc->flags, dc->stop.pts); in ivtv_video_command()
281 dc->flags &= V4L2_DEC_CMD_PAUSE_TO_BLACK; in ivtv_video_command()
283 if (!atomic_read(&itv->decoding)) in ivtv_video_command()
284 return -EPERM; in ivtv_video_command()
285 if (itv->output_mode != OUT_MPG) in ivtv_video_command()
286 return -EBUSY; in ivtv_video_command()
287 if (atomic_read(&itv->decoding) > 0) { in ivtv_video_command()
289 (dc->flags & V4L2_DEC_CMD_PAUSE_TO_BLACK) ? 1 : 0); in ivtv_video_command()
290 set_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags); in ivtv_video_command()
295 dc->flags = 0; in ivtv_video_command()
297 if (!atomic_read(&itv->decoding)) in ivtv_video_command()
298 return -EPERM; in ivtv_video_command()
299 if (itv->output_mode != OUT_MPG) in ivtv_video_command()
300 return -EBUSY; in ivtv_video_command()
301 if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags)) { in ivtv_video_command()
302 int speed = itv->speed; in ivtv_video_command()
303 itv->speed = 0; in ivtv_video_command()
309 return -EINVAL; in ivtv_video_command()
316 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_fmt_sliced_vbi_out()
317 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in ivtv_g_fmt_sliced_vbi_out()
319 vbifmt->reserved[0] = 0; in ivtv_g_fmt_sliced_vbi_out()
320 vbifmt->reserved[1] = 0; in ivtv_g_fmt_sliced_vbi_out()
321 if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_OUTPUT)) in ivtv_g_fmt_sliced_vbi_out()
322 return -EINVAL; in ivtv_g_fmt_sliced_vbi_out()
323 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_g_fmt_sliced_vbi_out()
324 memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines)); in ivtv_g_fmt_sliced_vbi_out()
325 if (itv->is_60hz) { in ivtv_g_fmt_sliced_vbi_out()
326 vbifmt->service_lines[0][21] = V4L2_SLICED_CAPTION_525; in ivtv_g_fmt_sliced_vbi_out()
327 vbifmt->service_lines[1][21] = V4L2_SLICED_CAPTION_525; in ivtv_g_fmt_sliced_vbi_out()
329 vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625; in ivtv_g_fmt_sliced_vbi_out()
330 vbifmt->service_lines[0][16] = V4L2_SLICED_VPS; in ivtv_g_fmt_sliced_vbi_out()
332 vbifmt->service_set = ivtv_get_service_set(vbifmt); in ivtv_g_fmt_sliced_vbi_out()
339 struct ivtv *itv = id->itv; in ivtv_g_fmt_vid_cap()
340 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; in ivtv_g_fmt_vid_cap()
342 pixfmt->width = itv->cxhdl.width; in ivtv_g_fmt_vid_cap()
343 pixfmt->height = itv->cxhdl.height; in ivtv_g_fmt_vid_cap()
344 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in ivtv_g_fmt_vid_cap()
345 pixfmt->field = V4L2_FIELD_INTERLACED; in ivtv_g_fmt_vid_cap()
346 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { in ivtv_g_fmt_vid_cap()
347 pixfmt->pixelformat = V4L2_PIX_FMT_HM12; in ivtv_g_fmt_vid_cap()
349 pixfmt->sizeimage = pixfmt->height * 720 * 3 / 2; in ivtv_g_fmt_vid_cap()
350 pixfmt->bytesperline = 720; in ivtv_g_fmt_vid_cap()
352 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; in ivtv_g_fmt_vid_cap()
353 pixfmt->sizeimage = 128 * 1024; in ivtv_g_fmt_vid_cap()
354 pixfmt->bytesperline = 0; in ivtv_g_fmt_vid_cap()
361 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_fmt_vbi_cap()
362 struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi; in ivtv_g_fmt_vbi_cap()
364 vbifmt->sampling_rate = 27000000; in ivtv_g_fmt_vbi_cap()
365 vbifmt->offset = 248; in ivtv_g_fmt_vbi_cap()
366 vbifmt->samples_per_line = itv->vbi.raw_decoder_line_size - 4; in ivtv_g_fmt_vbi_cap()
367 vbifmt->sample_format = V4L2_PIX_FMT_GREY; in ivtv_g_fmt_vbi_cap()
368 vbifmt->start[0] = itv->vbi.start[0]; in ivtv_g_fmt_vbi_cap()
369 vbifmt->start[1] = itv->vbi.start[1]; in ivtv_g_fmt_vbi_cap()
370 vbifmt->count[0] = vbifmt->count[1] = itv->vbi.count; in ivtv_g_fmt_vbi_cap()
371 vbifmt->flags = 0; in ivtv_g_fmt_vbi_cap()
372 vbifmt->reserved[0] = 0; in ivtv_g_fmt_vbi_cap()
373 vbifmt->reserved[1] = 0; in ivtv_g_fmt_vbi_cap()
379 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in ivtv_g_fmt_sliced_vbi_cap()
381 struct ivtv *itv = id->itv; in ivtv_g_fmt_sliced_vbi_cap()
383 vbifmt->reserved[0] = 0; in ivtv_g_fmt_sliced_vbi_cap()
384 vbifmt->reserved[1] = 0; in ivtv_g_fmt_sliced_vbi_cap()
385 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_g_fmt_sliced_vbi_cap()
387 if (id->type == IVTV_DEC_STREAM_TYPE_VBI) { in ivtv_g_fmt_sliced_vbi_cap()
388 vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 : in ivtv_g_fmt_sliced_vbi_cap()
390 ivtv_expand_service_set(vbifmt, itv->is_50hz); in ivtv_g_fmt_sliced_vbi_cap()
391 vbifmt->service_set = ivtv_get_service_set(vbifmt); in ivtv_g_fmt_sliced_vbi_cap()
395 v4l2_subdev_call(itv->sd_video, vbi, g_sliced_fmt, vbifmt); in ivtv_g_fmt_sliced_vbi_cap()
396 vbifmt->service_set = ivtv_get_service_set(vbifmt); in ivtv_g_fmt_sliced_vbi_cap()
403 struct ivtv *itv = id->itv; in ivtv_g_fmt_vid_out()
404 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; in ivtv_g_fmt_vid_out()
406 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_g_fmt_vid_out()
407 return -EINVAL; in ivtv_g_fmt_vid_out()
408 pixfmt->width = itv->main_rect.width; in ivtv_g_fmt_vid_out()
409 pixfmt->height = itv->main_rect.height; in ivtv_g_fmt_vid_out()
410 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in ivtv_g_fmt_vid_out()
411 pixfmt->field = V4L2_FIELD_INTERLACED; in ivtv_g_fmt_vid_out()
412 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) { in ivtv_g_fmt_vid_out()
413 switch (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) { in ivtv_g_fmt_vid_out()
415 pixfmt->field = (itv->yuv_info.lace_mode & IVTV_YUV_SYNC_MASK) ? in ivtv_g_fmt_vid_out()
419 pixfmt->field = V4L2_FIELD_NONE; in ivtv_g_fmt_vid_out()
422 pixfmt->field = V4L2_FIELD_ANY; in ivtv_g_fmt_vid_out()
425 pixfmt->pixelformat = V4L2_PIX_FMT_HM12; in ivtv_g_fmt_vid_out()
426 pixfmt->bytesperline = 720; in ivtv_g_fmt_vid_out()
427 pixfmt->width = itv->yuv_info.v4l2_src_w; in ivtv_g_fmt_vid_out()
428 pixfmt->height = itv->yuv_info.v4l2_src_h; in ivtv_g_fmt_vid_out()
430 pixfmt->sizeimage = in ivtv_g_fmt_vid_out()
431 1080 * ((pixfmt->height + 31) & ~31); in ivtv_g_fmt_vid_out()
433 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; in ivtv_g_fmt_vid_out()
434 pixfmt->sizeimage = 128 * 1024; in ivtv_g_fmt_vid_out()
435 pixfmt->bytesperline = 0; in ivtv_g_fmt_vid_out()
442 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_fmt_vid_out_overlay()
443 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_g_fmt_vid_out_overlay()
444 struct v4l2_window *winfmt = &fmt->fmt.win; in ivtv_g_fmt_vid_out_overlay()
446 if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_g_fmt_vid_out_overlay()
447 return -EINVAL; in ivtv_g_fmt_vid_out_overlay()
448 if (!itv->osd_video_pbase) in ivtv_g_fmt_vid_out_overlay()
449 return -EINVAL; in ivtv_g_fmt_vid_out_overlay()
450 winfmt->chromakey = itv->osd_chroma_key; in ivtv_g_fmt_vid_out_overlay()
451 winfmt->global_alpha = itv->osd_global_alpha; in ivtv_g_fmt_vid_out_overlay()
452 winfmt->field = V4L2_FIELD_INTERLACED; in ivtv_g_fmt_vid_out_overlay()
453 winfmt->clips = NULL; in ivtv_g_fmt_vid_out_overlay()
454 winfmt->clipcount = 0; in ivtv_g_fmt_vid_out_overlay()
455 winfmt->bitmap = NULL; in ivtv_g_fmt_vid_out_overlay()
456 winfmt->w.top = winfmt->w.left = 0; in ivtv_g_fmt_vid_out_overlay()
457 winfmt->w.width = itv->osd_rect.width; in ivtv_g_fmt_vid_out_overlay()
458 winfmt->w.height = itv->osd_rect.height; in ivtv_g_fmt_vid_out_overlay()
470 struct ivtv *itv = id->itv; in ivtv_try_fmt_vid_cap()
471 int w = fmt->fmt.pix.width; in ivtv_try_fmt_vid_cap()
472 int h = fmt->fmt.pix.height; in ivtv_try_fmt_vid_cap()
477 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { in ivtv_try_fmt_vid_cap()
482 h = min(h, itv->is_50hz ? 576 : 480); in ivtv_try_fmt_vid_cap()
485 fmt->fmt.pix.width = w; in ivtv_try_fmt_vid_cap()
486 fmt->fmt.pix.height = h; in ivtv_try_fmt_vid_cap()
497 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in ivtv_try_fmt_sliced_vbi_cap()
499 struct ivtv *itv = id->itv; in ivtv_try_fmt_sliced_vbi_cap()
501 if (id->type == IVTV_DEC_STREAM_TYPE_VBI) in ivtv_try_fmt_sliced_vbi_cap()
505 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_try_fmt_sliced_vbi_cap()
506 vbifmt->reserved[0] = 0; in ivtv_try_fmt_sliced_vbi_cap()
507 vbifmt->reserved[1] = 0; in ivtv_try_fmt_sliced_vbi_cap()
509 if (vbifmt->service_set) in ivtv_try_fmt_sliced_vbi_cap()
510 ivtv_expand_service_set(vbifmt, itv->is_50hz); in ivtv_try_fmt_sliced_vbi_cap()
511 check_service_set(vbifmt, itv->is_50hz); in ivtv_try_fmt_sliced_vbi_cap()
512 vbifmt->service_set = ivtv_get_service_set(vbifmt); in ivtv_try_fmt_sliced_vbi_cap()
519 s32 w = fmt->fmt.pix.width; in ivtv_try_fmt_vid_out()
520 s32 h = fmt->fmt.pix.height; in ivtv_try_fmt_vid_out()
521 int field = fmt->fmt.pix.field; in ivtv_try_fmt_vid_out()
534 can be displayed full-screen on PAL and a 720x576 video can be in ivtv_try_fmt_vid_out()
538 resolution is locked to the broadcast standard and not scaled. in ivtv_try_fmt_vid_out()
543 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) in ivtv_try_fmt_vid_out()
544 fmt->fmt.pix.field = field; in ivtv_try_fmt_vid_out()
545 fmt->fmt.pix.width = w; in ivtv_try_fmt_vid_out()
546 fmt->fmt.pix.height = h; in ivtv_try_fmt_vid_out()
552 struct ivtv *itv = fh2id(fh)->itv; in ivtv_try_fmt_vid_out_overlay()
553 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_try_fmt_vid_out_overlay()
554 u32 chromakey = fmt->fmt.win.chromakey; in ivtv_try_fmt_vid_out_overlay()
555 u8 global_alpha = fmt->fmt.win.global_alpha; in ivtv_try_fmt_vid_out_overlay()
557 if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_try_fmt_vid_out_overlay()
558 return -EINVAL; in ivtv_try_fmt_vid_out_overlay()
559 if (!itv->osd_video_pbase) in ivtv_try_fmt_vid_out_overlay()
560 return -EINVAL; in ivtv_try_fmt_vid_out_overlay()
562 fmt->fmt.win.chromakey = chromakey; in ivtv_try_fmt_vid_out_overlay()
563 fmt->fmt.win.global_alpha = global_alpha; in ivtv_try_fmt_vid_out_overlay()
575 struct ivtv *itv = id->itv; in ivtv_s_fmt_vid_cap()
580 int w = fmt->fmt.pix.width; in ivtv_s_fmt_vid_cap()
581 int h = fmt->fmt.pix.height; in ivtv_s_fmt_vid_cap()
586 if (itv->cxhdl.width == w && itv->cxhdl.height == h) in ivtv_s_fmt_vid_cap()
589 if (atomic_read(&itv->capturing) > 0) in ivtv_s_fmt_vid_cap()
590 return -EBUSY; in ivtv_s_fmt_vid_cap()
592 itv->cxhdl.width = w; in ivtv_s_fmt_vid_cap()
593 itv->cxhdl.height = h; in ivtv_s_fmt_vid_cap()
594 if (v4l2_ctrl_g_ctrl(itv->cxhdl.video_encoding) == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) in ivtv_s_fmt_vid_cap()
595 fmt->fmt.pix.width /= 2; in ivtv_s_fmt_vid_cap()
596 format.format.width = fmt->fmt.pix.width; in ivtv_s_fmt_vid_cap()
599 v4l2_subdev_call(itv->sd_video, pad, set_fmt, NULL, &format); in ivtv_s_fmt_vid_cap()
605 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_fmt_vbi_cap()
607 if (!ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0) in ivtv_s_fmt_vbi_cap()
608 return -EBUSY; in ivtv_s_fmt_vbi_cap()
609 itv->vbi.sliced_in->service_set = 0; in ivtv_s_fmt_vbi_cap()
610 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in ivtv_s_fmt_vbi_cap()
611 v4l2_subdev_call(itv->sd_video, vbi, s_raw_fmt, &fmt->fmt.vbi); in ivtv_s_fmt_vbi_cap()
617 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in ivtv_s_fmt_sliced_vbi_cap()
619 struct ivtv *itv = id->itv; in ivtv_s_fmt_sliced_vbi_cap()
622 if (ret || id->type == IVTV_DEC_STREAM_TYPE_VBI) in ivtv_s_fmt_sliced_vbi_cap()
625 check_service_set(vbifmt, itv->is_50hz); in ivtv_s_fmt_sliced_vbi_cap()
626 if (ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0) in ivtv_s_fmt_sliced_vbi_cap()
627 return -EBUSY; in ivtv_s_fmt_sliced_vbi_cap()
628 itv->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; in ivtv_s_fmt_sliced_vbi_cap()
629 v4l2_subdev_call(itv->sd_video, vbi, s_sliced_fmt, vbifmt); in ivtv_s_fmt_sliced_vbi_cap()
630 memcpy(itv->vbi.sliced_in, vbifmt, sizeof(*itv->vbi.sliced_in)); in ivtv_s_fmt_sliced_vbi_cap()
637 struct ivtv *itv = id->itv; in ivtv_s_fmt_vid_out()
638 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_s_fmt_vid_out()
644 if (id->type != IVTV_DEC_STREAM_TYPE_YUV) in ivtv_s_fmt_vid_out()
648 if (yi->stream_size) in ivtv_s_fmt_vid_out()
649 return -EBUSY; in ivtv_s_fmt_vid_out()
651 yi->v4l2_src_w = fmt->fmt.pix.width; in ivtv_s_fmt_vid_out()
652 yi->v4l2_src_h = fmt->fmt.pix.height; in ivtv_s_fmt_vid_out()
654 switch (fmt->fmt.pix.field) { in ivtv_s_fmt_vid_out()
656 yi->lace_mode = IVTV_YUV_MODE_PROGRESSIVE; in ivtv_s_fmt_vid_out()
659 yi->lace_mode = IVTV_YUV_MODE_AUTO; in ivtv_s_fmt_vid_out()
662 yi->lace_mode = in ivtv_s_fmt_vid_out()
667 yi->lace_mode = IVTV_YUV_MODE_INTERLACED; in ivtv_s_fmt_vid_out()
670 yi->lace_sync_field = (yi->lace_mode & IVTV_YUV_SYNC_MASK) == IVTV_YUV_SYNC_EVEN ? 0 : 1; in ivtv_s_fmt_vid_out()
672 if (test_bit(IVTV_F_I_DEC_YUV, &itv->i_flags)) in ivtv_s_fmt_vid_out()
673 itv->dma_data_req_size = in ivtv_s_fmt_vid_out()
674 1080 * ((yi->v4l2_src_h + 31) & ~31); in ivtv_s_fmt_vid_out()
681 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_fmt_vid_out_overlay()
685 itv->osd_chroma_key = fmt->fmt.win.chromakey; in ivtv_s_fmt_vid_out_overlay()
686 itv->osd_global_alpha = fmt->fmt.win.global_alpha; in ivtv_s_fmt_vid_out_overlay()
698 return -EINVAL; in ivtv_itvc()
700 reg_start = itv->reg_mem - IVTV_REG_OFFSET; in ivtv_itvc()
701 else if (itv->has_cx23415 && reg >= IVTV_DECODER_OFFSET && in ivtv_itvc()
703 reg_start = itv->dec_mem - IVTV_DECODER_OFFSET; in ivtv_itvc()
705 reg_start = itv->enc_mem; in ivtv_itvc()
707 return -EINVAL; in ivtv_itvc()
718 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_register()
720 reg->size = 4; in ivtv_g_register()
721 return ivtv_itvc(itv, true, reg->reg, ®->val); in ivtv_g_register()
726 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_register()
727 u64 val = reg->val; in ivtv_s_register()
729 return ivtv_itvc(itv, false, reg->reg, &val); in ivtv_s_register()
735 struct ivtv_open_id *id = fh2id(file->private_data); in ivtv_querycap()
736 struct ivtv *itv = id->itv; in ivtv_querycap()
738 strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver)); in ivtv_querycap()
739 strscpy(vcap->card, itv->card_name, sizeof(vcap->card)); in ivtv_querycap()
740 snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(itv->pdev)); in ivtv_querycap()
741 vcap->capabilities = itv->v4l2_cap | V4L2_CAP_DEVICE_CAPS; in ivtv_querycap()
747 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enumaudio()
749 return ivtv_get_audio_input(itv, vin->index, vin); in ivtv_enumaudio()
754 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_audio()
756 vin->index = itv->audio_input; in ivtv_g_audio()
757 return ivtv_get_audio_input(itv, vin->index, vin); in ivtv_g_audio()
762 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_audio()
764 if (vout->index >= itv->nof_audio_inputs) in ivtv_s_audio()
765 return -EINVAL; in ivtv_s_audio()
767 itv->audio_input = vout->index; in ivtv_s_audio()
775 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enumaudout()
778 return ivtv_get_audio_output(itv, vin->index, vin); in ivtv_enumaudout()
783 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_audout()
785 vin->index = 0; in ivtv_g_audout()
786 return ivtv_get_audio_output(itv, vin->index, vin); in ivtv_g_audout()
791 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_audout()
793 if (itv->card->video_outputs == NULL || vout->index != 0) in ivtv_s_audout()
794 return -EINVAL; in ivtv_s_audout()
800 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enum_input()
803 return ivtv_get_input(itv, vin->index, vin); in ivtv_enum_input()
808 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enum_output()
810 return ivtv_get_output(itv, vout->index, vout); in ivtv_enum_output()
817 struct ivtv *itv = id->itv; in ivtv_g_pixelaspect()
820 f->numerator = itv->is_50hz ? 54 : 11; in ivtv_g_pixelaspect()
821 f->denominator = itv->is_50hz ? 59 : 10; in ivtv_g_pixelaspect()
823 f->numerator = itv->is_out_50hz ? 54 : 11; in ivtv_g_pixelaspect()
824 f->denominator = itv->is_out_50hz ? 59 : 10; in ivtv_g_pixelaspect()
826 return -EINVAL; in ivtv_g_pixelaspect()
835 struct ivtv *itv = id->itv; in ivtv_s_selection()
836 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_s_selection()
838 int streamtype = id->type; in ivtv_s_selection()
840 if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in ivtv_s_selection()
841 !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_s_selection()
842 return -EINVAL; in ivtv_s_selection()
844 if (sel->target != V4L2_SEL_TGT_COMPOSE) in ivtv_s_selection()
845 return -EINVAL; in ivtv_s_selection()
848 if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in ivtv_s_selection()
849 !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_s_selection()
850 return -EINVAL; in ivtv_s_selection()
852 r.height = itv->is_out_50hz ? 576 : 480; in ivtv_s_selection()
853 if (streamtype == IVTV_DEC_STREAM_TYPE_YUV && yi->track_osd) { in ivtv_s_selection()
854 r.width = yi->osd_full_w; in ivtv_s_selection()
855 r.height = yi->osd_full_h; in ivtv_s_selection()
857 sel->r.width = clamp(sel->r.width, 16U, r.width); in ivtv_s_selection()
858 sel->r.height = clamp(sel->r.height, 16U, r.height); in ivtv_s_selection()
859 sel->r.left = clamp_t(unsigned, sel->r.left, 0, r.width - sel->r.width); in ivtv_s_selection()
860 sel->r.top = clamp_t(unsigned, sel->r.top, 0, r.height - sel->r.height); in ivtv_s_selection()
863 yi->main_rect = sel->r; in ivtv_s_selection()
867 sel->r.width, sel->r.height, sel->r.left, sel->r.top)) { in ivtv_s_selection()
868 itv->main_rect = sel->r; in ivtv_s_selection()
871 return -EINVAL; in ivtv_s_selection()
878 struct ivtv *itv = id->itv; in ivtv_g_selection()
879 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_g_selection()
881 int streamtype = id->type; in ivtv_g_selection()
883 if (sel->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { in ivtv_g_selection()
884 switch (sel->target) { in ivtv_g_selection()
887 sel->r.top = sel->r.left = 0; in ivtv_g_selection()
888 sel->r.width = 720; in ivtv_g_selection()
889 sel->r.height = itv->is_50hz ? 576 : 480; in ivtv_g_selection()
892 return -EINVAL; in ivtv_g_selection()
896 if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in ivtv_g_selection()
897 !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_g_selection()
898 return -EINVAL; in ivtv_g_selection()
900 switch (sel->target) { in ivtv_g_selection()
903 sel->r = yi->main_rect; in ivtv_g_selection()
905 sel->r = itv->main_rect; in ivtv_g_selection()
909 r.height = itv->is_out_50hz ? 576 : 480; in ivtv_g_selection()
910 if (streamtype == IVTV_DEC_STREAM_TYPE_YUV && yi->track_osd) { in ivtv_g_selection()
911 r.width = yi->osd_full_w; in ivtv_g_selection()
912 r.height = yi->osd_full_h; in ivtv_g_selection()
914 sel->r = r; in ivtv_g_selection()
917 return -EINVAL; in ivtv_g_selection()
933 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enum_fmt_vid_cap()
934 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_enum_fmt_vid_cap()
936 if (fmt->index) in ivtv_enum_fmt_vid_cap()
937 return -EINVAL; in ivtv_enum_fmt_vid_cap()
938 if (s->type == IVTV_ENC_STREAM_TYPE_MPG) in ivtv_enum_fmt_vid_cap()
940 else if (s->type == IVTV_ENC_STREAM_TYPE_YUV) in ivtv_enum_fmt_vid_cap()
943 return -EINVAL; in ivtv_enum_fmt_vid_cap()
960 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enum_fmt_vid_out()
961 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_enum_fmt_vid_out()
963 if (fmt->index) in ivtv_enum_fmt_vid_out()
964 return -EINVAL; in ivtv_enum_fmt_vid_out()
965 if (s->type == IVTV_DEC_STREAM_TYPE_MPG) in ivtv_enum_fmt_vid_out()
967 else if (s->type == IVTV_DEC_STREAM_TYPE_YUV) in ivtv_enum_fmt_vid_out()
970 return -EINVAL; in ivtv_enum_fmt_vid_out()
976 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_input()
978 *i = itv->active_input; in ivtv_g_input()
985 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_input()
989 if (inp >= itv->nof_inputs) in ivtv_s_input()
990 return -EINVAL; in ivtv_s_input()
992 if (inp == itv->active_input) { in ivtv_s_input()
997 if (atomic_read(&itv->capturing) > 0) { in ivtv_s_input()
998 return -EBUSY; in ivtv_s_input()
1002 itv->active_input, inp); in ivtv_s_input()
1004 itv->active_input = inp; in ivtv_s_input()
1007 itv->audio_input = itv->card->video_inputs[inp].audio_index; in ivtv_s_input()
1009 if (itv->card->video_inputs[inp].video_type == IVTV_CARD_INPUT_VID_TUNER) in ivtv_s_input()
1010 std = itv->tuner_std; in ivtv_s_input()
1014 itv->streams[i].vdev.tvnorms = std; in ivtv_s_input()
1028 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_output()
1030 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_g_output()
1031 return -EINVAL; in ivtv_g_output()
1033 *i = itv->active_output; in ivtv_g_output()
1040 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_output()
1042 if (outp >= itv->card->nof_outputs) in ivtv_s_output()
1043 return -EINVAL; in ivtv_s_output()
1045 if (outp == itv->active_output) { in ivtv_s_output()
1050 itv->active_output, outp); in ivtv_s_output()
1052 itv->active_output = outp; in ivtv_s_output()
1055 itv->card->video_outputs[outp].video_output, 0); in ivtv_s_output()
1062 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_frequency()
1063 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_g_frequency()
1065 if (s->vdev.vfl_dir) in ivtv_g_frequency()
1066 return -ENOTTY; in ivtv_g_frequency()
1067 if (vf->tuner != 0) in ivtv_g_frequency()
1068 return -EINVAL; in ivtv_g_frequency()
1076 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_frequency()
1077 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_s_frequency()
1079 if (s->vdev.vfl_dir) in ivtv_s_frequency()
1080 return -ENOTTY; in ivtv_s_frequency()
1081 if (vf->tuner != 0) in ivtv_s_frequency()
1082 return -EINVAL; in ivtv_s_frequency()
1085 IVTV_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency); in ivtv_s_frequency()
1093 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_std()
1095 *std = itv->std; in ivtv_g_std()
1101 itv->std = std; in ivtv_s_std_enc()
1102 itv->is_60hz = (std & V4L2_STD_525_60) ? 1 : 0; in ivtv_s_std_enc()
1103 itv->is_50hz = !itv->is_60hz; in ivtv_s_std_enc()
1104 cx2341x_handler_set_50hz(&itv->cxhdl, itv->is_50hz); in ivtv_s_std_enc()
1105 itv->cxhdl.width = 720; in ivtv_s_std_enc()
1106 itv->cxhdl.height = itv->is_50hz ? 576 : 480; in ivtv_s_std_enc()
1107 itv->vbi.count = itv->is_50hz ? 18 : 12; in ivtv_s_std_enc()
1108 itv->vbi.start[0] = itv->is_50hz ? 6 : 10; in ivtv_s_std_enc()
1109 itv->vbi.start[1] = itv->is_50hz ? 318 : 273; in ivtv_s_std_enc()
1111 if (itv->hw_flags & IVTV_HW_CX25840) in ivtv_s_std_enc()
1112 itv->vbi.sliced_decoder_line_size = itv->is_60hz ? 272 : 284; in ivtv_s_std_enc()
1115 ivtv_call_all(itv, video, s_std, itv->std); in ivtv_s_std_enc()
1120 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_s_std_dec()
1124 /* set display standard */ in ivtv_s_std_dec()
1125 itv->std_out = std; in ivtv_s_std_dec()
1126 itv->is_out_60hz = (std & V4L2_STD_525_60) ? 1 : 0; in ivtv_s_std_dec()
1127 itv->is_out_50hz = !itv->is_out_60hz; in ivtv_s_std_dec()
1128 ivtv_call_all(itv, video, s_std_output, itv->std_out); in ivtv_s_std_dec()
1136 mutex_unlock(&itv->serialize_lock); in ivtv_s_std_dec()
1138 prepare_to_wait(&itv->vsync_waitq, &wait, in ivtv_s_std_dec()
1144 finish_wait(&itv->vsync_waitq, &wait); in ivtv_s_std_dec()
1145 mutex_lock(&itv->serialize_lock); in ivtv_s_std_dec()
1150 ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz); in ivtv_s_std_dec()
1151 itv->main_rect.left = 0; in ivtv_s_std_dec()
1152 itv->main_rect.top = 0; in ivtv_s_std_dec()
1153 itv->main_rect.width = 720; in ivtv_s_std_dec()
1154 itv->main_rect.height = itv->is_out_50hz ? 576 : 480; in ivtv_s_std_dec()
1156 720, itv->main_rect.height, 0, 0); in ivtv_s_std_dec()
1157 yi->main_rect = itv->main_rect; in ivtv_s_std_dec()
1158 if (!itv->osd_info) { in ivtv_s_std_dec()
1159 yi->osd_full_w = 720; in ivtv_s_std_dec()
1160 yi->osd_full_h = itv->is_out_50hz ? 576 : 480; in ivtv_s_std_dec()
1166 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_std()
1169 return -EINVAL; in ivtv_s_std()
1171 if (std == itv->std) in ivtv_s_std()
1174 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) || in ivtv_s_std()
1175 atomic_read(&itv->capturing) > 0 || in ivtv_s_std()
1176 atomic_read(&itv->decoding) > 0) { in ivtv_s_std()
1177 /* Switching standard would mess with already running in ivtv_s_std()
1179 return -EBUSY; in ivtv_s_std()
1182 IVTV_DEBUG_INFO("Switching standard to %llx.\n", in ivtv_s_std()
1183 (unsigned long long)itv->std); in ivtv_s_std()
1186 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) in ivtv_s_std()
1192 static int ivtv_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt) in ivtv_s_tuner() argument
1195 struct ivtv *itv = id->itv; in ivtv_s_tuner()
1197 if (vt->index != 0) in ivtv_s_tuner()
1198 return -EINVAL; in ivtv_s_tuner()
1200 ivtv_call_all(itv, tuner, s_tuner, vt); in ivtv_s_tuner()
1205 static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) in ivtv_g_tuner() argument
1207 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_tuner()
1209 if (vt->index != 0) in ivtv_g_tuner()
1210 return -EINVAL; in ivtv_g_tuner()
1212 ivtv_call_all(itv, tuner, g_tuner, vt); in ivtv_g_tuner()
1214 if (vt->type == V4L2_TUNER_RADIO) in ivtv_g_tuner()
1215 strscpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); in ivtv_g_tuner()
1217 strscpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); in ivtv_g_tuner()
1223 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_sliced_vbi_cap()
1224 int set = itv->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; in ivtv_g_sliced_vbi_cap()
1227 if (cap->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) { in ivtv_g_sliced_vbi_cap()
1230 if (valid_service_line(f, l, itv->is_50hz)) in ivtv_g_sliced_vbi_cap()
1231 cap->service_lines[f][l] = set; in ivtv_g_sliced_vbi_cap()
1234 } else if (cap->type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT) { in ivtv_g_sliced_vbi_cap()
1235 if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_OUTPUT)) in ivtv_g_sliced_vbi_cap()
1236 return -EINVAL; in ivtv_g_sliced_vbi_cap()
1237 if (itv->is_60hz) { in ivtv_g_sliced_vbi_cap()
1238 cap->service_lines[0][21] = V4L2_SLICED_CAPTION_525; in ivtv_g_sliced_vbi_cap()
1239 cap->service_lines[1][21] = V4L2_SLICED_CAPTION_525; in ivtv_g_sliced_vbi_cap()
1241 cap->service_lines[0][23] = V4L2_SLICED_WSS_625; in ivtv_g_sliced_vbi_cap()
1242 cap->service_lines[0][16] = V4L2_SLICED_VPS; in ivtv_g_sliced_vbi_cap()
1245 return -EINVAL; in ivtv_g_sliced_vbi_cap()
1251 set |= cap->service_lines[f][l]; in ivtv_g_sliced_vbi_cap()
1252 cap->service_set = set; in ivtv_g_sliced_vbi_cap()
1258 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_enc_index()
1259 struct v4l2_enc_idx_entry *e = idx->entry; in ivtv_g_enc_index()
1263 entries = (itv->pgm_info_write_idx + IVTV_MAX_PGM_INDEX - itv->pgm_info_read_idx) % in ivtv_g_enc_index()
1267 idx->entries = 0; in ivtv_g_enc_index()
1268 idx->entries_cap = IVTV_MAX_PGM_INDEX; in ivtv_g_enc_index()
1269 if (!atomic_read(&itv->capturing)) in ivtv_g_enc_index()
1272 *e = itv->pgm_info[(itv->pgm_info_read_idx + i) % IVTV_MAX_PGM_INDEX]; in ivtv_g_enc_index()
1273 if ((e->flags & V4L2_ENC_IDX_FRAME_MASK) <= V4L2_ENC_IDX_FRAME_B) { in ivtv_g_enc_index()
1274 idx->entries++; in ivtv_g_enc_index()
1278 itv->pgm_info_read_idx = (itv->pgm_info_read_idx + idx->entries) % IVTV_MAX_PGM_INDEX; in ivtv_g_enc_index()
1285 struct ivtv *itv = id->itv; in ivtv_encoder_cmd()
1288 switch (enc->cmd) { in ivtv_encoder_cmd()
1291 enc->flags = 0; in ivtv_encoder_cmd()
1296 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; in ivtv_encoder_cmd()
1297 ivtv_stop_capture(id, enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END); in ivtv_encoder_cmd()
1302 enc->flags = 0; in ivtv_encoder_cmd()
1304 if (!atomic_read(&itv->capturing)) in ivtv_encoder_cmd()
1305 return -EPERM; in ivtv_encoder_cmd()
1306 if (test_and_set_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags)) in ivtv_encoder_cmd()
1315 enc->flags = 0; in ivtv_encoder_cmd()
1317 if (!atomic_read(&itv->capturing)) in ivtv_encoder_cmd()
1318 return -EPERM; in ivtv_encoder_cmd()
1320 if (!test_and_clear_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags)) in ivtv_encoder_cmd()
1327 IVTV_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd); in ivtv_encoder_cmd()
1328 return -EINVAL; in ivtv_encoder_cmd()
1336 struct ivtv *itv = fh2id(fh)->itv; in ivtv_try_encoder_cmd()
1338 switch (enc->cmd) { in ivtv_try_encoder_cmd()
1341 enc->flags = 0; in ivtv_try_encoder_cmd()
1346 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; in ivtv_try_encoder_cmd()
1351 enc->flags = 0; in ivtv_try_encoder_cmd()
1356 enc->flags = 0; in ivtv_try_encoder_cmd()
1359 IVTV_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd); in ivtv_try_encoder_cmd()
1360 return -EINVAL; in ivtv_try_encoder_cmd()
1366 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_fbuf()
1367 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_g_fbuf()
1369 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_g_fbuf()
1373 V4L2_PIX_FMT_PAL8, /* Uses a 256-entry RGB colormap */ in ivtv_g_fbuf()
1381 V4L2_PIX_FMT_PAL8, /* Uses a 256-entry YUV colormap */ in ivtv_g_fbuf()
1391 if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_g_fbuf()
1392 return -ENOTTY; in ivtv_g_fbuf()
1393 if (!itv->osd_video_pbase) in ivtv_g_fbuf()
1394 return -ENOTTY; in ivtv_g_fbuf()
1396 fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY | in ivtv_g_fbuf()
1403 fb->fmt.pixelformat = pixel_format[pixfmt]; in ivtv_g_fbuf()
1404 fb->fmt.width = itv->osd_rect.width; in ivtv_g_fbuf()
1405 fb->fmt.height = itv->osd_rect.height; in ivtv_g_fbuf()
1406 fb->fmt.field = V4L2_FIELD_INTERLACED; in ivtv_g_fbuf()
1407 fb->fmt.bytesperline = fb->fmt.width; in ivtv_g_fbuf()
1408 fb->fmt.colorspace = V4L2_COLORSPACE_SMPTE170M; in ivtv_g_fbuf()
1409 fb->fmt.field = V4L2_FIELD_INTERLACED; in ivtv_g_fbuf()
1410 if (fb->fmt.pixelformat != V4L2_PIX_FMT_PAL8) in ivtv_g_fbuf()
1411 fb->fmt.bytesperline *= 2; in ivtv_g_fbuf()
1412 if (fb->fmt.pixelformat == V4L2_PIX_FMT_RGB32 || in ivtv_g_fbuf()
1413 fb->fmt.pixelformat == V4L2_PIX_FMT_YUV32) in ivtv_g_fbuf()
1414 fb->fmt.bytesperline *= 2; in ivtv_g_fbuf()
1415 fb->fmt.sizeimage = fb->fmt.bytesperline * fb->fmt.height; in ivtv_g_fbuf()
1416 fb->base = (void *)itv->osd_video_pbase; in ivtv_g_fbuf()
1417 fb->flags = 0; in ivtv_g_fbuf()
1419 if (itv->osd_chroma_key_state) in ivtv_g_fbuf()
1420 fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY; in ivtv_g_fbuf()
1422 if (itv->osd_global_alpha_state) in ivtv_g_fbuf()
1423 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; in ivtv_g_fbuf()
1425 if (yi->track_osd) in ivtv_g_fbuf()
1426 fb->flags |= V4L2_FBUF_FLAG_OVERLAY; in ivtv_g_fbuf()
1434 /* 16-bit formats have inverted local alpha */ in ivtv_g_fbuf()
1436 fb->capability |= V4L2_FBUF_CAP_LOCAL_INV_ALPHA; in ivtv_g_fbuf()
1438 fb->capability |= V4L2_FBUF_CAP_LOCAL_ALPHA; in ivtv_g_fbuf()
1440 if (itv->osd_local_alpha_state) { in ivtv_g_fbuf()
1441 /* 16-bit formats have inverted local alpha */ in ivtv_g_fbuf()
1443 fb->flags |= V4L2_FBUF_FLAG_LOCAL_INV_ALPHA; in ivtv_g_fbuf()
1445 fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; in ivtv_g_fbuf()
1454 struct ivtv *itv = id->itv; in ivtv_s_fbuf()
1455 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_s_fbuf()
1456 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_s_fbuf()
1458 if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_s_fbuf()
1459 return -ENOTTY; in ivtv_s_fbuf()
1460 if (!itv->osd_video_pbase) in ivtv_s_fbuf()
1461 return -ENOTTY; in ivtv_s_fbuf()
1463 itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; in ivtv_s_fbuf()
1464 itv->osd_local_alpha_state = in ivtv_s_fbuf()
1465 (fb->flags & (V4L2_FBUF_FLAG_LOCAL_ALPHA|V4L2_FBUF_FLAG_LOCAL_INV_ALPHA)) != 0; in ivtv_s_fbuf()
1466 itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; in ivtv_s_fbuf()
1468 yi->track_osd = (fb->flags & V4L2_FBUF_FLAG_OVERLAY) != 0; in ivtv_s_fbuf()
1475 struct ivtv *itv = id->itv; in ivtv_overlay()
1476 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_overlay()
1478 if (!(s->caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_overlay()
1479 return -ENOTTY; in ivtv_overlay()
1480 if (!itv->osd_video_pbase) in ivtv_overlay()
1481 return -ENOTTY; in ivtv_overlay()
1490 switch (sub->type) { in ivtv_subscribe_event()
1501 struct ivtv *itv = fh2id(fh)->itv; in ivtv_log_status()
1504 int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT; in ivtv_log_status()
1509 IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name); in ivtv_log_status()
1510 if (itv->hw_flags & IVTV_HW_TVEEPROM) { in ivtv_log_status()
1516 ivtv_get_input(itv, itv->active_input, &vidin); in ivtv_log_status()
1517 ivtv_get_audio_input(itv, itv->audio_input, &audin); in ivtv_log_status()
1520 itv->dualwatch_stereo_mode == V4L2_MPEG_AUDIO_MODE_DUAL ? in ivtv_log_status()
1525 int mode = itv->output_mode; in ivtv_log_status()
1558 ivtv_get_output(itv, itv->active_output, &vidout); in ivtv_log_status()
1572 test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? "Radio" : "TV"); in ivtv_log_status()
1573 v4l2_ctrl_handler_log_status(&itv->cxhdl.hdl, itv->v4l2_dev.name); in ivtv_log_status()
1574 IVTV_INFO("Status flags: 0x%08lx\n", itv->i_flags); in ivtv_log_status()
1576 struct ivtv_stream *s = &itv->streams[i]; in ivtv_log_status()
1578 if (s->vdev.v4l2_dev == NULL || s->buffers == 0) in ivtv_log_status()
1580 IVTV_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n", s->name, s->s_flags, in ivtv_log_status()
1581 (s->buffers - s->q_free.buffers) * 100 / s->buffers, in ivtv_log_status()
1582 (s->buffers * s->buf_size) / 1024, s->buffers); in ivtv_log_status()
1586 (long long)itv->mpg_data_received, in ivtv_log_status()
1587 (long long)itv->vbi_data_inserted); in ivtv_log_status()
1593 struct ivtv_open_id *id = fh2id(file->private_data); in ivtv_decoder_cmd()
1594 struct ivtv *itv = id->itv; in ivtv_decoder_cmd()
1596 IVTV_DEBUG_IOCTL("VIDIOC_DECODER_CMD %d\n", dec->cmd); in ivtv_decoder_cmd()
1602 struct ivtv_open_id *id = fh2id(file->private_data); in ivtv_try_decoder_cmd()
1603 struct ivtv *itv = id->itv; in ivtv_try_decoder_cmd()
1605 IVTV_DEBUG_IOCTL("VIDIOC_TRY_DECODER_CMD %d\n", dec->cmd); in ivtv_try_decoder_cmd()
1634 struct ivtv_open_id *id = fh2id(filp->private_data); in ivtv_decoder_ioctls()
1635 struct ivtv *itv = id->itv; in ivtv_decoder_ioctls()
1636 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_decoder_ioctls()
1638 int nonblocking = filp->f_flags & O_NONBLOCK; in ivtv_decoder_ioctls()
1647 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_decoder_ioctls()
1648 return -EINVAL; in ivtv_decoder_ioctls()
1649 if (args->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) in ivtv_decoder_ioctls()
1650 return -EINVAL; in ivtv_decoder_ioctls()
1651 if (itv->output_mode == OUT_UDMA_YUV && args->y_source == NULL) in ivtv_decoder_ioctls()
1653 if (ivtv_start_decoding(id, id->type)) { in ivtv_decoder_ioctls()
1654 return -EBUSY; in ivtv_decoder_ioctls()
1658 return -EBUSY; in ivtv_decoder_ioctls()
1661 id->yuv_frames = 1; in ivtv_decoder_ioctls()
1662 if (args->y_source == NULL) in ivtv_decoder_ioctls()
1669 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_decoder_ioctls()
1670 return -EINVAL; in ivtv_decoder_ioctls()
1678 if (s->type < IVTV_DEC_STREAM_TYPE_MPG) { in ivtv_decoder_ioctls()
1679 *pts = s->dma_pts; in ivtv_decoder_ioctls()
1682 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_decoder_ioctls()
1683 return -EINVAL; in ivtv_decoder_ioctls()
1692 if (s->type < IVTV_DEC_STREAM_TYPE_MPG) { in ivtv_decoder_ioctls()
1696 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_decoder_ioctls()
1697 return -EINVAL; in ivtv_decoder_ioctls()
1763 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_decoder_ioctls()
1764 return -EINVAL; in ivtv_decoder_ioctls()
1766 set_bit(IVTV_F_I_EV_VSYNC_ENABLED, &itv->i_flags); in ivtv_decoder_ioctls()
1769 if (test_and_clear_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags)) in ivtv_decoder_ioctls()
1770 ev->type = VIDEO_EVENT_DECODER_STOPPED; in ivtv_decoder_ioctls()
1771 else if (test_and_clear_bit(IVTV_F_I_EV_VSYNC, &itv->i_flags)) { in ivtv_decoder_ioctls()
1774 ev->type = VIDEO_EVENT_VSYNC; in ivtv_decoder_ioctls()
1775 vsync_field = test_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags) ? in ivtv_decoder_ioctls()
1777 if (itv->output_mode == OUT_UDMA_YUV && in ivtv_decoder_ioctls()
1778 (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) == in ivtv_decoder_ioctls()
1784 ev32->u.vsync_field = vsync_field; in ivtv_decoder_ioctls()
1787 ev->u.vsync_field = vsync_field; in ivtv_decoder_ioctls()
1789 if (ev->type) in ivtv_decoder_ioctls()
1792 return -EAGAIN; in ivtv_decoder_ioctls()
1796 mutex_unlock(&itv->serialize_lock); in ivtv_decoder_ioctls()
1797 prepare_to_wait(&itv->event_waitq, &wait, TASK_INTERRUPTIBLE); in ivtv_decoder_ioctls()
1798 if (!test_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags) && in ivtv_decoder_ioctls()
1799 !test_bit(IVTV_F_I_EV_VSYNC, &itv->i_flags)) in ivtv_decoder_ioctls()
1801 finish_wait(&itv->event_waitq, &wait); in ivtv_decoder_ioctls()
1802 mutex_lock(&itv->serialize_lock); in ivtv_decoder_ioctls()
1806 return -EINTR; in ivtv_decoder_ioctls()
1814 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_decoder_ioctls()
1815 return -EINVAL; in ivtv_decoder_ioctls()
1820 itv->speed_mute_audio = iarg; in ivtv_decoder_ioctls()
1826 return -EINVAL; in ivtv_decoder_ioctls()
1827 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_playback, iarg + 1); in ivtv_decoder_ioctls()
1832 return -EINVAL; in ivtv_decoder_ioctls()
1833 return v4l2_ctrl_s_ctrl(itv->ctrl_audio_multilingual_playback, iarg + 1); in ivtv_decoder_ioctls()
1836 return -EINVAL; in ivtv_decoder_ioctls()
1844 struct ivtv *itv = fh2id(fh)->itv; in ivtv_default()
1860 return -EBUSY; in ivtv_default()
1868 if ((val == 0 && itv->options.newi2c) || (val & 0x01)) in ivtv_default()
1871 v4l2_subdev_call(itv->sd_video, core, reset, 0); in ivtv_default()
1895 return -ENOTTY; in ivtv_default()
1964 vdev->ioctl_ops = &ivtv_ioctl_ops; in ivtv_set_funcs()