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>
79 u16 set = fmt->service_set; in ivtv_expand_service_set()
82 fmt->service_set = 0; in ivtv_expand_service_set()
85 fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal); in ivtv_expand_service_set()
96 fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal); in check_service_set()
108 set |= fmt->service_lines[f][l]; in ivtv_get_service_set()
117 itv->osd_global_alpha_state, itv->osd_global_alpha, !itv->osd_local_alpha_state); in ivtv_set_osd_alpha()
118 ivtv_vapi(itv, CX2341X_OSD_SET_CHROMA_KEY, 2, itv->osd_chroma_key_state, itv->osd_chroma_key); in ivtv_set_osd_alpha()
124 int single_step = (speed == 1 || speed == -1); in ivtv_set_speed()
130 if (speed == itv->speed && !single_step) in ivtv_set_speed()
133 if (single_step && (speed < 0) == (itv->speed < 0)) { in ivtv_set_speed()
136 itv->speed = speed; in ivtv_set_speed()
141 speed = speed < 0 ? -1000 : 1000; in ivtv_set_speed()
143 data[0] = (speed > 1000 || speed < -1000) ? 0x80000000 : 0; in ivtv_set_speed()
144 data[0] |= (speed > 1000 || speed < -1500) ? 0x40000000 : 0; in ivtv_set_speed()
147 data[3] = v4l2_ctrl_g_ctrl(itv->cxhdl.video_b_frames); in ivtv_set_speed()
148 data[4] = (speed == 1500 || speed == 500) ? itv->speed_mute_audio : 0; in ivtv_set_speed()
152 if (speed == 1500 || speed == -1500) data[0] |= 1; in ivtv_set_speed()
153 else if (speed == 2000 || speed == -2000) data[0] |= 2; in ivtv_set_speed()
154 else if (speed > -1000 && speed < 0) data[0] |= (-1000 / speed); in ivtv_set_speed()
158 if (atomic_read(&itv->decoding) > 0) { in ivtv_set_speed()
165 mutex_unlock(&itv->serialize_lock); in ivtv_set_speed()
166 prepare_to_wait(&itv->dma_waitq, &wait, TASK_INTERRUPTIBLE); in ivtv_set_speed()
167 while (test_bit(IVTV_F_I_DMA, &itv->i_flags)) { in ivtv_set_speed()
174 finish_wait(&itv->dma_waitq, &wait); in ivtv_set_speed()
175 mutex_lock(&itv->serialize_lock); in ivtv_set_speed()
177 return -EINTR; in ivtv_set_speed()
185 speed = (speed < 0) ? -1 : 1; in ivtv_set_speed()
188 itv->speed = speed; in ivtv_set_speed()
194 int fact = new_speed < 0 ? -1 : 1; in ivtv_validate_speed()
200 new_speed = -new_speed; in ivtv_validate_speed()
202 cur_speed = -cur_speed; in ivtv_validate_speed()
226 new_speed += (cur_speed < s) ? -1 : 1; in ivtv_validate_speed()
234 struct ivtv_stream *s = &itv->streams[IVTV_DEC_STREAM_TYPE_MPG]; in ivtv_video_command()
236 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_video_command()
237 return -EINVAL; in ivtv_video_command()
239 switch (dc->cmd) { in ivtv_video_command()
241 dc->flags &= V4L2_DEC_CMD_START_MUTE_AUDIO; in ivtv_video_command()
242 dc->start.speed = ivtv_validate_speed(itv->speed, dc->start.speed); in ivtv_video_command()
243 if (dc->start.speed < 0) in ivtv_video_command()
244 dc->start.format = V4L2_DEC_START_FMT_GOP; in ivtv_video_command()
246 dc->start.format = V4L2_DEC_START_FMT_NONE; in ivtv_video_command()
247 if (dc->start.speed != 500 && dc->start.speed != 1500) in ivtv_video_command()
248 dc->flags = dc->start.speed == 1000 ? 0 : in ivtv_video_command()
252 itv->speed_mute_audio = dc->flags & V4L2_DEC_CMD_START_MUTE_AUDIO; in ivtv_video_command()
254 return -EBUSY; in ivtv_video_command()
255 if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags)) { in ivtv_video_command()
257 itv->speed = 0; in ivtv_video_command()
259 return ivtv_start_decoding(id, dc->start.speed); in ivtv_video_command()
263 dc->flags &= V4L2_DEC_CMD_STOP_IMMEDIATELY | V4L2_DEC_CMD_STOP_TO_BLACK; in ivtv_video_command()
264 if (dc->flags & V4L2_DEC_CMD_STOP_IMMEDIATELY) in ivtv_video_command()
265 dc->stop.pts = 0; in ivtv_video_command()
267 if (atomic_read(&itv->decoding) == 0) in ivtv_video_command()
269 if (itv->output_mode != OUT_MPG) in ivtv_video_command()
270 return -EBUSY; in ivtv_video_command()
272 itv->output_mode = OUT_NONE; in ivtv_video_command()
273 return ivtv_stop_v4l2_decode_stream(s, dc->flags, dc->stop.pts); in ivtv_video_command()
276 dc->flags &= V4L2_DEC_CMD_PAUSE_TO_BLACK; in ivtv_video_command()
278 if (!atomic_read(&itv->decoding)) in ivtv_video_command()
279 return -EPERM; in ivtv_video_command()
280 if (itv->output_mode != OUT_MPG) in ivtv_video_command()
281 return -EBUSY; in ivtv_video_command()
282 if (atomic_read(&itv->decoding) > 0) { in ivtv_video_command()
284 (dc->flags & V4L2_DEC_CMD_PAUSE_TO_BLACK) ? 1 : 0); in ivtv_video_command()
285 set_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags); in ivtv_video_command()
290 dc->flags = 0; in ivtv_video_command()
292 if (!atomic_read(&itv->decoding)) in ivtv_video_command()
293 return -EPERM; in ivtv_video_command()
294 if (itv->output_mode != OUT_MPG) in ivtv_video_command()
295 return -EBUSY; in ivtv_video_command()
296 if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags)) { in ivtv_video_command()
297 int speed = itv->speed; in ivtv_video_command()
298 itv->speed = 0; in ivtv_video_command()
304 return -EINVAL; in ivtv_video_command()
311 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_fmt_sliced_vbi_out()
312 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in ivtv_g_fmt_sliced_vbi_out()
314 vbifmt->reserved[0] = 0; in ivtv_g_fmt_sliced_vbi_out()
315 vbifmt->reserved[1] = 0; in ivtv_g_fmt_sliced_vbi_out()
316 if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_OUTPUT)) in ivtv_g_fmt_sliced_vbi_out()
317 return -EINVAL; in ivtv_g_fmt_sliced_vbi_out()
318 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_g_fmt_sliced_vbi_out()
319 memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines)); in ivtv_g_fmt_sliced_vbi_out()
320 if (itv->is_60hz) { in ivtv_g_fmt_sliced_vbi_out()
321 vbifmt->service_lines[0][21] = V4L2_SLICED_CAPTION_525; in ivtv_g_fmt_sliced_vbi_out()
322 vbifmt->service_lines[1][21] = V4L2_SLICED_CAPTION_525; in ivtv_g_fmt_sliced_vbi_out()
324 vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625; in ivtv_g_fmt_sliced_vbi_out()
325 vbifmt->service_lines[0][16] = V4L2_SLICED_VPS; in ivtv_g_fmt_sliced_vbi_out()
327 vbifmt->service_set = ivtv_get_service_set(vbifmt); in ivtv_g_fmt_sliced_vbi_out()
334 struct ivtv *itv = id->itv; in ivtv_g_fmt_vid_cap()
335 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; in ivtv_g_fmt_vid_cap()
337 pixfmt->width = itv->cxhdl.width; in ivtv_g_fmt_vid_cap()
338 pixfmt->height = itv->cxhdl.height; in ivtv_g_fmt_vid_cap()
339 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in ivtv_g_fmt_vid_cap()
340 pixfmt->field = V4L2_FIELD_INTERLACED; in ivtv_g_fmt_vid_cap()
341 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { in ivtv_g_fmt_vid_cap()
342 pixfmt->pixelformat = V4L2_PIX_FMT_NV12_16L16; in ivtv_g_fmt_vid_cap()
344 pixfmt->sizeimage = pixfmt->height * 720 * 3 / 2; in ivtv_g_fmt_vid_cap()
345 pixfmt->bytesperline = 720; in ivtv_g_fmt_vid_cap()
347 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; in ivtv_g_fmt_vid_cap()
348 pixfmt->sizeimage = 128 * 1024; in ivtv_g_fmt_vid_cap()
349 pixfmt->bytesperline = 0; in ivtv_g_fmt_vid_cap()
356 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_fmt_vbi_cap()
357 struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi; in ivtv_g_fmt_vbi_cap()
359 vbifmt->sampling_rate = 27000000; in ivtv_g_fmt_vbi_cap()
360 vbifmt->offset = 248; in ivtv_g_fmt_vbi_cap()
361 vbifmt->samples_per_line = itv->vbi.raw_decoder_line_size - 4; in ivtv_g_fmt_vbi_cap()
362 vbifmt->sample_format = V4L2_PIX_FMT_GREY; in ivtv_g_fmt_vbi_cap()
363 vbifmt->start[0] = itv->vbi.start[0]; in ivtv_g_fmt_vbi_cap()
364 vbifmt->start[1] = itv->vbi.start[1]; in ivtv_g_fmt_vbi_cap()
365 vbifmt->count[0] = vbifmt->count[1] = itv->vbi.count; in ivtv_g_fmt_vbi_cap()
366 vbifmt->flags = 0; in ivtv_g_fmt_vbi_cap()
367 vbifmt->reserved[0] = 0; in ivtv_g_fmt_vbi_cap()
368 vbifmt->reserved[1] = 0; in ivtv_g_fmt_vbi_cap()
374 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in ivtv_g_fmt_sliced_vbi_cap()
376 struct ivtv *itv = id->itv; in ivtv_g_fmt_sliced_vbi_cap()
378 vbifmt->reserved[0] = 0; in ivtv_g_fmt_sliced_vbi_cap()
379 vbifmt->reserved[1] = 0; in ivtv_g_fmt_sliced_vbi_cap()
380 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_g_fmt_sliced_vbi_cap()
382 if (id->type == IVTV_DEC_STREAM_TYPE_VBI) { in ivtv_g_fmt_sliced_vbi_cap()
383 vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 : in ivtv_g_fmt_sliced_vbi_cap()
385 ivtv_expand_service_set(vbifmt, itv->is_50hz); in ivtv_g_fmt_sliced_vbi_cap()
386 vbifmt->service_set = ivtv_get_service_set(vbifmt); in ivtv_g_fmt_sliced_vbi_cap()
390 v4l2_subdev_call(itv->sd_video, vbi, g_sliced_fmt, vbifmt); in ivtv_g_fmt_sliced_vbi_cap()
391 vbifmt->service_set = ivtv_get_service_set(vbifmt); in ivtv_g_fmt_sliced_vbi_cap()
398 struct ivtv *itv = id->itv; in ivtv_g_fmt_vid_out()
399 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; in ivtv_g_fmt_vid_out()
401 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_g_fmt_vid_out()
402 return -EINVAL; in ivtv_g_fmt_vid_out()
403 pixfmt->width = itv->main_rect.width; in ivtv_g_fmt_vid_out()
404 pixfmt->height = itv->main_rect.height; in ivtv_g_fmt_vid_out()
405 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; in ivtv_g_fmt_vid_out()
406 pixfmt->field = V4L2_FIELD_INTERLACED; in ivtv_g_fmt_vid_out()
407 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) { in ivtv_g_fmt_vid_out()
408 switch (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) { in ivtv_g_fmt_vid_out()
410 pixfmt->field = (itv->yuv_info.lace_mode & IVTV_YUV_SYNC_MASK) ? in ivtv_g_fmt_vid_out()
414 pixfmt->field = V4L2_FIELD_NONE; in ivtv_g_fmt_vid_out()
417 pixfmt->field = V4L2_FIELD_ANY; in ivtv_g_fmt_vid_out()
420 pixfmt->pixelformat = V4L2_PIX_FMT_NV12_16L16; in ivtv_g_fmt_vid_out()
421 pixfmt->bytesperline = 720; in ivtv_g_fmt_vid_out()
422 pixfmt->width = itv->yuv_info.v4l2_src_w; in ivtv_g_fmt_vid_out()
423 pixfmt->height = itv->yuv_info.v4l2_src_h; in ivtv_g_fmt_vid_out()
425 pixfmt->sizeimage = in ivtv_g_fmt_vid_out()
426 1080 * ((pixfmt->height + 31) & ~31); in ivtv_g_fmt_vid_out()
428 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG; in ivtv_g_fmt_vid_out()
429 pixfmt->sizeimage = 128 * 1024; in ivtv_g_fmt_vid_out()
430 pixfmt->bytesperline = 0; in ivtv_g_fmt_vid_out()
437 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_fmt_vid_out_overlay()
438 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_g_fmt_vid_out_overlay()
439 struct v4l2_window *winfmt = &fmt->fmt.win; in ivtv_g_fmt_vid_out_overlay()
441 if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_g_fmt_vid_out_overlay()
442 return -EINVAL; in ivtv_g_fmt_vid_out_overlay()
443 if (!itv->osd_video_pbase) in ivtv_g_fmt_vid_out_overlay()
444 return -EINVAL; in ivtv_g_fmt_vid_out_overlay()
445 winfmt->chromakey = itv->osd_chroma_key; in ivtv_g_fmt_vid_out_overlay()
446 winfmt->global_alpha = itv->osd_global_alpha; in ivtv_g_fmt_vid_out_overlay()
447 winfmt->field = V4L2_FIELD_INTERLACED; in ivtv_g_fmt_vid_out_overlay()
448 winfmt->clips = NULL; in ivtv_g_fmt_vid_out_overlay()
449 winfmt->clipcount = 0; in ivtv_g_fmt_vid_out_overlay()
450 winfmt->bitmap = NULL; in ivtv_g_fmt_vid_out_overlay()
451 winfmt->w.top = winfmt->w.left = 0; in ivtv_g_fmt_vid_out_overlay()
452 winfmt->w.width = itv->osd_rect.width; in ivtv_g_fmt_vid_out_overlay()
453 winfmt->w.height = itv->osd_rect.height; in ivtv_g_fmt_vid_out_overlay()
465 struct ivtv *itv = id->itv; in ivtv_try_fmt_vid_cap()
466 int w = fmt->fmt.pix.width; in ivtv_try_fmt_vid_cap()
467 int h = fmt->fmt.pix.height; in ivtv_try_fmt_vid_cap()
472 if (id->type == IVTV_ENC_STREAM_TYPE_YUV) { in ivtv_try_fmt_vid_cap()
477 h = min(h, itv->is_50hz ? 576 : 480); in ivtv_try_fmt_vid_cap()
480 fmt->fmt.pix.width = w; in ivtv_try_fmt_vid_cap()
481 fmt->fmt.pix.height = h; in ivtv_try_fmt_vid_cap()
492 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in ivtv_try_fmt_sliced_vbi_cap()
494 struct ivtv *itv = id->itv; in ivtv_try_fmt_sliced_vbi_cap()
496 if (id->type == IVTV_DEC_STREAM_TYPE_VBI) in ivtv_try_fmt_sliced_vbi_cap()
500 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; in ivtv_try_fmt_sliced_vbi_cap()
501 vbifmt->reserved[0] = 0; in ivtv_try_fmt_sliced_vbi_cap()
502 vbifmt->reserved[1] = 0; in ivtv_try_fmt_sliced_vbi_cap()
504 if (vbifmt->service_set) in ivtv_try_fmt_sliced_vbi_cap()
505 ivtv_expand_service_set(vbifmt, itv->is_50hz); in ivtv_try_fmt_sliced_vbi_cap()
506 check_service_set(vbifmt, itv->is_50hz); in ivtv_try_fmt_sliced_vbi_cap()
507 vbifmt->service_set = ivtv_get_service_set(vbifmt); in ivtv_try_fmt_sliced_vbi_cap()
514 s32 w = fmt->fmt.pix.width; in ivtv_try_fmt_vid_out()
515 s32 h = fmt->fmt.pix.height; in ivtv_try_fmt_vid_out()
516 int field = fmt->fmt.pix.field; in ivtv_try_fmt_vid_out()
529 can be displayed full-screen on PAL and a 720x576 video can be in ivtv_try_fmt_vid_out()
533 resolution is locked to the broadcast standard and not scaled. in ivtv_try_fmt_vid_out()
538 if (id->type == IVTV_DEC_STREAM_TYPE_YUV) in ivtv_try_fmt_vid_out()
539 fmt->fmt.pix.field = field; in ivtv_try_fmt_vid_out()
540 fmt->fmt.pix.width = w; in ivtv_try_fmt_vid_out()
541 fmt->fmt.pix.height = h; in ivtv_try_fmt_vid_out()
547 struct ivtv *itv = fh2id(fh)->itv; in ivtv_try_fmt_vid_out_overlay()
548 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_try_fmt_vid_out_overlay()
549 u32 chromakey = fmt->fmt.win.chromakey; in ivtv_try_fmt_vid_out_overlay()
550 u8 global_alpha = fmt->fmt.win.global_alpha; in ivtv_try_fmt_vid_out_overlay()
552 if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_try_fmt_vid_out_overlay()
553 return -EINVAL; in ivtv_try_fmt_vid_out_overlay()
554 if (!itv->osd_video_pbase) in ivtv_try_fmt_vid_out_overlay()
555 return -EINVAL; in ivtv_try_fmt_vid_out_overlay()
557 fmt->fmt.win.chromakey = chromakey; in ivtv_try_fmt_vid_out_overlay()
558 fmt->fmt.win.global_alpha = global_alpha; in ivtv_try_fmt_vid_out_overlay()
570 struct ivtv *itv = id->itv; in ivtv_s_fmt_vid_cap()
575 int w = fmt->fmt.pix.width; in ivtv_s_fmt_vid_cap()
576 int h = fmt->fmt.pix.height; in ivtv_s_fmt_vid_cap()
581 if (itv->cxhdl.width == w && itv->cxhdl.height == h) in ivtv_s_fmt_vid_cap()
584 if (atomic_read(&itv->capturing) > 0) in ivtv_s_fmt_vid_cap()
585 return -EBUSY; in ivtv_s_fmt_vid_cap()
587 itv->cxhdl.width = w; in ivtv_s_fmt_vid_cap()
588 itv->cxhdl.height = h; in ivtv_s_fmt_vid_cap()
589 if (v4l2_ctrl_g_ctrl(itv->cxhdl.video_encoding) == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) in ivtv_s_fmt_vid_cap()
590 fmt->fmt.pix.width /= 2; in ivtv_s_fmt_vid_cap()
591 format.format.width = fmt->fmt.pix.width; in ivtv_s_fmt_vid_cap()
594 v4l2_subdev_call(itv->sd_video, pad, set_fmt, NULL, &format); in ivtv_s_fmt_vid_cap()
600 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_fmt_vbi_cap()
602 if (!ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0) in ivtv_s_fmt_vbi_cap()
603 return -EBUSY; in ivtv_s_fmt_vbi_cap()
604 itv->vbi.sliced_in->service_set = 0; in ivtv_s_fmt_vbi_cap()
605 itv->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE; in ivtv_s_fmt_vbi_cap()
606 v4l2_subdev_call(itv->sd_video, vbi, s_raw_fmt, &fmt->fmt.vbi); in ivtv_s_fmt_vbi_cap()
612 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; in ivtv_s_fmt_sliced_vbi_cap()
614 struct ivtv *itv = id->itv; in ivtv_s_fmt_sliced_vbi_cap()
617 if (ret || id->type == IVTV_DEC_STREAM_TYPE_VBI) in ivtv_s_fmt_sliced_vbi_cap()
620 check_service_set(vbifmt, itv->is_50hz); in ivtv_s_fmt_sliced_vbi_cap()
621 if (ivtv_raw_vbi(itv) && atomic_read(&itv->capturing) > 0) in ivtv_s_fmt_sliced_vbi_cap()
622 return -EBUSY; in ivtv_s_fmt_sliced_vbi_cap()
623 itv->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; in ivtv_s_fmt_sliced_vbi_cap()
624 v4l2_subdev_call(itv->sd_video, vbi, s_sliced_fmt, vbifmt); in ivtv_s_fmt_sliced_vbi_cap()
625 memcpy(itv->vbi.sliced_in, vbifmt, sizeof(*itv->vbi.sliced_in)); in ivtv_s_fmt_sliced_vbi_cap()
632 struct ivtv *itv = id->itv; in ivtv_s_fmt_vid_out()
633 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_s_fmt_vid_out()
639 if (id->type != IVTV_DEC_STREAM_TYPE_YUV) in ivtv_s_fmt_vid_out()
643 if (yi->stream_size) in ivtv_s_fmt_vid_out()
644 return -EBUSY; in ivtv_s_fmt_vid_out()
646 yi->v4l2_src_w = fmt->fmt.pix.width; in ivtv_s_fmt_vid_out()
647 yi->v4l2_src_h = fmt->fmt.pix.height; in ivtv_s_fmt_vid_out()
649 switch (fmt->fmt.pix.field) { in ivtv_s_fmt_vid_out()
651 yi->lace_mode = IVTV_YUV_MODE_PROGRESSIVE; in ivtv_s_fmt_vid_out()
654 yi->lace_mode = IVTV_YUV_MODE_AUTO; in ivtv_s_fmt_vid_out()
657 yi->lace_mode = in ivtv_s_fmt_vid_out()
662 yi->lace_mode = IVTV_YUV_MODE_INTERLACED; in ivtv_s_fmt_vid_out()
665 yi->lace_sync_field = (yi->lace_mode & IVTV_YUV_SYNC_MASK) == IVTV_YUV_SYNC_EVEN ? 0 : 1; in ivtv_s_fmt_vid_out()
667 if (test_bit(IVTV_F_I_DEC_YUV, &itv->i_flags)) in ivtv_s_fmt_vid_out()
668 itv->dma_data_req_size = in ivtv_s_fmt_vid_out()
669 1080 * ((yi->v4l2_src_h + 31) & ~31); in ivtv_s_fmt_vid_out()
676 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_fmt_vid_out_overlay()
680 itv->osd_chroma_key = fmt->fmt.win.chromakey; in ivtv_s_fmt_vid_out_overlay()
681 itv->osd_global_alpha = fmt->fmt.win.global_alpha; in ivtv_s_fmt_vid_out_overlay()
693 return -EINVAL; in ivtv_itvc()
695 reg_start = itv->reg_mem - IVTV_REG_OFFSET; in ivtv_itvc()
696 else if (itv->has_cx23415 && reg >= IVTV_DECODER_OFFSET && in ivtv_itvc()
698 reg_start = itv->dec_mem - IVTV_DECODER_OFFSET; in ivtv_itvc()
700 reg_start = itv->enc_mem; in ivtv_itvc()
702 return -EINVAL; in ivtv_itvc()
713 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_register()
715 reg->size = 4; in ivtv_g_register()
716 return ivtv_itvc(itv, true, reg->reg, ®->val); in ivtv_g_register()
721 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_register()
722 u64 val = reg->val; in ivtv_s_register()
724 return ivtv_itvc(itv, false, reg->reg, &val); in ivtv_s_register()
730 struct ivtv_open_id *id = fh2id(file->private_data); in ivtv_querycap()
731 struct ivtv *itv = id->itv; in ivtv_querycap()
733 strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver)); in ivtv_querycap()
734 strscpy(vcap->card, itv->card_name, sizeof(vcap->card)); in ivtv_querycap()
735 vcap->capabilities = itv->v4l2_cap | V4L2_CAP_DEVICE_CAPS; in ivtv_querycap()
741 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enumaudio()
743 return ivtv_get_audio_input(itv, vin->index, vin); in ivtv_enumaudio()
748 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_audio()
750 vin->index = itv->audio_input; in ivtv_g_audio()
751 return ivtv_get_audio_input(itv, vin->index, vin); in ivtv_g_audio()
756 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_audio()
758 if (vout->index >= itv->nof_audio_inputs) in ivtv_s_audio()
759 return -EINVAL; in ivtv_s_audio()
761 itv->audio_input = vout->index; in ivtv_s_audio()
769 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enumaudout()
772 return ivtv_get_audio_output(itv, vin->index, vin); in ivtv_enumaudout()
777 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_audout()
779 vin->index = 0; in ivtv_g_audout()
780 return ivtv_get_audio_output(itv, vin->index, vin); in ivtv_g_audout()
785 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_audout()
787 if (itv->card->video_outputs == NULL || vout->index != 0) in ivtv_s_audout()
788 return -EINVAL; in ivtv_s_audout()
794 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enum_input()
797 return ivtv_get_input(itv, vin->index, vin); in ivtv_enum_input()
802 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enum_output()
804 return ivtv_get_output(itv, vout->index, vout); in ivtv_enum_output()
811 struct ivtv *itv = id->itv; in ivtv_g_pixelaspect()
814 f->numerator = itv->is_50hz ? 54 : 11; in ivtv_g_pixelaspect()
815 f->denominator = itv->is_50hz ? 59 : 10; in ivtv_g_pixelaspect()
817 f->numerator = itv->is_out_50hz ? 54 : 11; in ivtv_g_pixelaspect()
818 f->denominator = itv->is_out_50hz ? 59 : 10; in ivtv_g_pixelaspect()
820 return -EINVAL; in ivtv_g_pixelaspect()
829 struct ivtv *itv = id->itv; in ivtv_s_selection()
830 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_s_selection()
832 int streamtype = id->type; in ivtv_s_selection()
834 if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in ivtv_s_selection()
835 !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_s_selection()
836 return -EINVAL; in ivtv_s_selection()
838 if (sel->target != V4L2_SEL_TGT_COMPOSE) in ivtv_s_selection()
839 return -EINVAL; in ivtv_s_selection()
842 if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in ivtv_s_selection()
843 !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_s_selection()
844 return -EINVAL; in ivtv_s_selection()
846 r.height = itv->is_out_50hz ? 576 : 480; in ivtv_s_selection()
847 if (streamtype == IVTV_DEC_STREAM_TYPE_YUV && yi->track_osd) { in ivtv_s_selection()
848 r.width = yi->osd_full_w; in ivtv_s_selection()
849 r.height = yi->osd_full_h; in ivtv_s_selection()
851 sel->r.width = clamp(sel->r.width, 16U, r.width); in ivtv_s_selection()
852 sel->r.height = clamp(sel->r.height, 16U, r.height); in ivtv_s_selection()
853 sel->r.left = clamp_t(unsigned, sel->r.left, 0, r.width - sel->r.width); in ivtv_s_selection()
854 sel->r.top = clamp_t(unsigned, sel->r.top, 0, r.height - sel->r.height); in ivtv_s_selection()
857 yi->main_rect = sel->r; in ivtv_s_selection()
861 sel->r.width, sel->r.height, sel->r.left, sel->r.top)) { in ivtv_s_selection()
862 itv->main_rect = sel->r; in ivtv_s_selection()
865 return -EINVAL; in ivtv_s_selection()
872 struct ivtv *itv = id->itv; in ivtv_g_selection()
873 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_g_selection()
875 int streamtype = id->type; in ivtv_g_selection()
877 if (sel->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { in ivtv_g_selection()
878 switch (sel->target) { in ivtv_g_selection()
881 sel->r.top = sel->r.left = 0; in ivtv_g_selection()
882 sel->r.width = 720; in ivtv_g_selection()
883 sel->r.height = itv->is_50hz ? 576 : 480; in ivtv_g_selection()
886 return -EINVAL; in ivtv_g_selection()
890 if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in ivtv_g_selection()
891 !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_g_selection()
892 return -EINVAL; in ivtv_g_selection()
894 switch (sel->target) { in ivtv_g_selection()
897 sel->r = yi->main_rect; in ivtv_g_selection()
899 sel->r = itv->main_rect; in ivtv_g_selection()
903 r.height = itv->is_out_50hz ? 576 : 480; in ivtv_g_selection()
904 if (streamtype == IVTV_DEC_STREAM_TYPE_YUV && yi->track_osd) { in ivtv_g_selection()
905 r.width = yi->osd_full_w; in ivtv_g_selection()
906 r.height = yi->osd_full_h; in ivtv_g_selection()
908 sel->r = r; in ivtv_g_selection()
911 return -EINVAL; in ivtv_g_selection()
927 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enum_fmt_vid_cap()
928 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_enum_fmt_vid_cap()
930 if (fmt->index) in ivtv_enum_fmt_vid_cap()
931 return -EINVAL; in ivtv_enum_fmt_vid_cap()
932 if (s->type == IVTV_ENC_STREAM_TYPE_MPG) in ivtv_enum_fmt_vid_cap()
934 else if (s->type == IVTV_ENC_STREAM_TYPE_YUV) in ivtv_enum_fmt_vid_cap()
937 return -EINVAL; in ivtv_enum_fmt_vid_cap()
954 struct ivtv *itv = fh2id(fh)->itv; in ivtv_enum_fmt_vid_out()
955 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_enum_fmt_vid_out()
957 if (fmt->index) in ivtv_enum_fmt_vid_out()
958 return -EINVAL; in ivtv_enum_fmt_vid_out()
959 if (s->type == IVTV_DEC_STREAM_TYPE_MPG) in ivtv_enum_fmt_vid_out()
961 else if (s->type == IVTV_DEC_STREAM_TYPE_YUV) in ivtv_enum_fmt_vid_out()
964 return -EINVAL; in ivtv_enum_fmt_vid_out()
970 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_input()
972 *i = itv->active_input; in ivtv_g_input()
979 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_input()
983 if (inp >= itv->nof_inputs) in ivtv_s_input()
984 return -EINVAL; in ivtv_s_input()
986 if (inp == itv->active_input) { in ivtv_s_input()
991 if (atomic_read(&itv->capturing) > 0) { in ivtv_s_input()
992 return -EBUSY; in ivtv_s_input()
996 itv->active_input, inp); in ivtv_s_input()
998 itv->active_input = inp; in ivtv_s_input()
1001 itv->audio_input = itv->card->video_inputs[inp].audio_index; in ivtv_s_input()
1003 if (itv->card->video_inputs[inp].video_type == IVTV_CARD_INPUT_VID_TUNER) in ivtv_s_input()
1004 std = itv->tuner_std; in ivtv_s_input()
1008 itv->streams[i].vdev.tvnorms = std; in ivtv_s_input()
1022 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_output()
1024 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_g_output()
1025 return -EINVAL; in ivtv_g_output()
1027 *i = itv->active_output; in ivtv_g_output()
1034 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_output()
1036 if (outp >= itv->card->nof_outputs) in ivtv_s_output()
1037 return -EINVAL; in ivtv_s_output()
1039 if (outp == itv->active_output) { in ivtv_s_output()
1044 itv->active_output, outp); in ivtv_s_output()
1046 itv->active_output = outp; in ivtv_s_output()
1049 itv->card->video_outputs[outp].video_output, 0); in ivtv_s_output()
1056 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_frequency()
1057 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_g_frequency()
1059 if (s->vdev.vfl_dir) in ivtv_g_frequency()
1060 return -ENOTTY; in ivtv_g_frequency()
1061 if (vf->tuner != 0) in ivtv_g_frequency()
1062 return -EINVAL; in ivtv_g_frequency()
1070 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_frequency()
1071 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_s_frequency()
1073 if (s->vdev.vfl_dir) in ivtv_s_frequency()
1074 return -ENOTTY; in ivtv_s_frequency()
1075 if (vf->tuner != 0) in ivtv_s_frequency()
1076 return -EINVAL; in ivtv_s_frequency()
1079 IVTV_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency); in ivtv_s_frequency()
1087 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_std()
1089 *std = itv->std; in ivtv_g_std()
1095 itv->std = std; in ivtv_s_std_enc()
1096 itv->is_60hz = (std & V4L2_STD_525_60) ? 1 : 0; in ivtv_s_std_enc()
1097 itv->is_50hz = !itv->is_60hz; in ivtv_s_std_enc()
1098 cx2341x_handler_set_50hz(&itv->cxhdl, itv->is_50hz); in ivtv_s_std_enc()
1099 itv->cxhdl.width = 720; in ivtv_s_std_enc()
1100 itv->cxhdl.height = itv->is_50hz ? 576 : 480; in ivtv_s_std_enc()
1101 itv->vbi.count = itv->is_50hz ? 18 : 12; in ivtv_s_std_enc()
1102 itv->vbi.start[0] = itv->is_50hz ? 6 : 10; in ivtv_s_std_enc()
1103 itv->vbi.start[1] = itv->is_50hz ? 318 : 273; in ivtv_s_std_enc()
1105 if (itv->hw_flags & IVTV_HW_CX25840) in ivtv_s_std_enc()
1106 itv->vbi.sliced_decoder_line_size = itv->is_60hz ? 272 : 284; in ivtv_s_std_enc()
1109 ivtv_call_all(itv, video, s_std, itv->std); in ivtv_s_std_enc()
1114 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_s_std_dec()
1118 /* set display standard */ in ivtv_s_std_dec()
1119 itv->std_out = std; in ivtv_s_std_dec()
1120 itv->is_out_60hz = (std & V4L2_STD_525_60) ? 1 : 0; in ivtv_s_std_dec()
1121 itv->is_out_50hz = !itv->is_out_60hz; in ivtv_s_std_dec()
1122 ivtv_call_all(itv, video, s_std_output, itv->std_out); in ivtv_s_std_dec()
1130 mutex_unlock(&itv->serialize_lock); in ivtv_s_std_dec()
1132 prepare_to_wait(&itv->vsync_waitq, &wait, in ivtv_s_std_dec()
1138 finish_wait(&itv->vsync_waitq, &wait); in ivtv_s_std_dec()
1139 mutex_lock(&itv->serialize_lock); in ivtv_s_std_dec()
1144 ivtv_vapi(itv, CX2341X_DEC_SET_STANDARD, 1, itv->is_out_50hz); in ivtv_s_std_dec()
1145 itv->main_rect.left = 0; in ivtv_s_std_dec()
1146 itv->main_rect.top = 0; in ivtv_s_std_dec()
1147 itv->main_rect.width = 720; in ivtv_s_std_dec()
1148 itv->main_rect.height = itv->is_out_50hz ? 576 : 480; in ivtv_s_std_dec()
1150 720, itv->main_rect.height, 0, 0); in ivtv_s_std_dec()
1151 yi->main_rect = itv->main_rect; in ivtv_s_std_dec()
1152 if (!itv->osd_info) { in ivtv_s_std_dec()
1153 yi->osd_full_w = 720; in ivtv_s_std_dec()
1154 yi->osd_full_h = itv->is_out_50hz ? 576 : 480; in ivtv_s_std_dec()
1160 struct ivtv *itv = fh2id(fh)->itv; in ivtv_s_std()
1163 return -EINVAL; in ivtv_s_std()
1165 if (std == itv->std) in ivtv_s_std()
1168 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) || in ivtv_s_std()
1169 atomic_read(&itv->capturing) > 0 || in ivtv_s_std()
1170 atomic_read(&itv->decoding) > 0) { in ivtv_s_std()
1171 /* Switching standard would mess with already running in ivtv_s_std()
1173 return -EBUSY; in ivtv_s_std()
1176 IVTV_DEBUG_INFO("Switching standard to %llx.\n", in ivtv_s_std()
1177 (unsigned long long)itv->std); in ivtv_s_std()
1180 if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) in ivtv_s_std()
1186 static int ivtv_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt) in ivtv_s_tuner() argument
1189 struct ivtv *itv = id->itv; in ivtv_s_tuner()
1191 if (vt->index != 0) in ivtv_s_tuner()
1192 return -EINVAL; in ivtv_s_tuner()
1194 ivtv_call_all(itv, tuner, s_tuner, vt); in ivtv_s_tuner()
1199 static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) in ivtv_g_tuner() argument
1201 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_tuner()
1203 if (vt->index != 0) in ivtv_g_tuner()
1204 return -EINVAL; in ivtv_g_tuner()
1206 ivtv_call_all(itv, tuner, g_tuner, vt); in ivtv_g_tuner()
1208 if (vt->type == V4L2_TUNER_RADIO) in ivtv_g_tuner()
1209 strscpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); in ivtv_g_tuner()
1211 strscpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); in ivtv_g_tuner()
1217 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_sliced_vbi_cap()
1218 int set = itv->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; in ivtv_g_sliced_vbi_cap()
1221 if (cap->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) { in ivtv_g_sliced_vbi_cap()
1224 if (valid_service_line(f, l, itv->is_50hz)) in ivtv_g_sliced_vbi_cap()
1225 cap->service_lines[f][l] = set; in ivtv_g_sliced_vbi_cap()
1228 } else if (cap->type == V4L2_BUF_TYPE_SLICED_VBI_OUTPUT) { in ivtv_g_sliced_vbi_cap()
1229 if (!(itv->v4l2_cap & V4L2_CAP_SLICED_VBI_OUTPUT)) in ivtv_g_sliced_vbi_cap()
1230 return -EINVAL; in ivtv_g_sliced_vbi_cap()
1231 if (itv->is_60hz) { in ivtv_g_sliced_vbi_cap()
1232 cap->service_lines[0][21] = V4L2_SLICED_CAPTION_525; in ivtv_g_sliced_vbi_cap()
1233 cap->service_lines[1][21] = V4L2_SLICED_CAPTION_525; in ivtv_g_sliced_vbi_cap()
1235 cap->service_lines[0][23] = V4L2_SLICED_WSS_625; in ivtv_g_sliced_vbi_cap()
1236 cap->service_lines[0][16] = V4L2_SLICED_VPS; in ivtv_g_sliced_vbi_cap()
1239 return -EINVAL; in ivtv_g_sliced_vbi_cap()
1245 set |= cap->service_lines[f][l]; in ivtv_g_sliced_vbi_cap()
1246 cap->service_set = set; in ivtv_g_sliced_vbi_cap()
1252 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_enc_index()
1253 struct v4l2_enc_idx_entry *e = idx->entry; in ivtv_g_enc_index()
1257 entries = (itv->pgm_info_write_idx + IVTV_MAX_PGM_INDEX - itv->pgm_info_read_idx) % in ivtv_g_enc_index()
1261 idx->entries = 0; in ivtv_g_enc_index()
1262 idx->entries_cap = IVTV_MAX_PGM_INDEX; in ivtv_g_enc_index()
1263 if (!atomic_read(&itv->capturing)) in ivtv_g_enc_index()
1266 *e = itv->pgm_info[(itv->pgm_info_read_idx + i) % IVTV_MAX_PGM_INDEX]; in ivtv_g_enc_index()
1267 if ((e->flags & V4L2_ENC_IDX_FRAME_MASK) <= V4L2_ENC_IDX_FRAME_B) { in ivtv_g_enc_index()
1268 idx->entries++; in ivtv_g_enc_index()
1272 itv->pgm_info_read_idx = (itv->pgm_info_read_idx + idx->entries) % IVTV_MAX_PGM_INDEX; in ivtv_g_enc_index()
1279 struct ivtv *itv = id->itv; in ivtv_encoder_cmd()
1282 switch (enc->cmd) { in ivtv_encoder_cmd()
1285 enc->flags = 0; in ivtv_encoder_cmd()
1290 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; in ivtv_encoder_cmd()
1291 ivtv_stop_capture(id, enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END); in ivtv_encoder_cmd()
1296 enc->flags = 0; in ivtv_encoder_cmd()
1298 if (!atomic_read(&itv->capturing)) in ivtv_encoder_cmd()
1299 return -EPERM; in ivtv_encoder_cmd()
1300 if (test_and_set_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags)) in ivtv_encoder_cmd()
1309 enc->flags = 0; in ivtv_encoder_cmd()
1311 if (!atomic_read(&itv->capturing)) in ivtv_encoder_cmd()
1312 return -EPERM; in ivtv_encoder_cmd()
1314 if (!test_and_clear_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags)) in ivtv_encoder_cmd()
1321 IVTV_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd); in ivtv_encoder_cmd()
1322 return -EINVAL; in ivtv_encoder_cmd()
1330 struct ivtv *itv = fh2id(fh)->itv; in ivtv_try_encoder_cmd()
1332 switch (enc->cmd) { in ivtv_try_encoder_cmd()
1335 enc->flags = 0; in ivtv_try_encoder_cmd()
1340 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; in ivtv_try_encoder_cmd()
1345 enc->flags = 0; in ivtv_try_encoder_cmd()
1350 enc->flags = 0; in ivtv_try_encoder_cmd()
1353 IVTV_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd); in ivtv_try_encoder_cmd()
1354 return -EINVAL; in ivtv_try_encoder_cmd()
1360 struct ivtv *itv = fh2id(fh)->itv; in ivtv_g_fbuf()
1361 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_g_fbuf()
1363 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_g_fbuf()
1367 V4L2_PIX_FMT_PAL8, /* Uses a 256-entry RGB colormap */ in ivtv_g_fbuf()
1375 V4L2_PIX_FMT_PAL8, /* Uses a 256-entry YUV colormap */ in ivtv_g_fbuf()
1385 if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_g_fbuf()
1386 return -ENOTTY; in ivtv_g_fbuf()
1387 if (!itv->osd_video_pbase) in ivtv_g_fbuf()
1388 return -ENOTTY; in ivtv_g_fbuf()
1390 fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY | in ivtv_g_fbuf()
1397 fb->fmt.pixelformat = pixel_format[pixfmt]; in ivtv_g_fbuf()
1398 fb->fmt.width = itv->osd_rect.width; in ivtv_g_fbuf()
1399 fb->fmt.height = itv->osd_rect.height; in ivtv_g_fbuf()
1400 fb->fmt.field = V4L2_FIELD_INTERLACED; in ivtv_g_fbuf()
1401 fb->fmt.bytesperline = fb->fmt.width; in ivtv_g_fbuf()
1402 fb->fmt.colorspace = V4L2_COLORSPACE_SMPTE170M; in ivtv_g_fbuf()
1403 fb->fmt.field = V4L2_FIELD_INTERLACED; in ivtv_g_fbuf()
1404 if (fb->fmt.pixelformat != V4L2_PIX_FMT_PAL8) in ivtv_g_fbuf()
1405 fb->fmt.bytesperline *= 2; in ivtv_g_fbuf()
1406 if (fb->fmt.pixelformat == V4L2_PIX_FMT_RGB32 || in ivtv_g_fbuf()
1407 fb->fmt.pixelformat == V4L2_PIX_FMT_YUV32) in ivtv_g_fbuf()
1408 fb->fmt.bytesperline *= 2; in ivtv_g_fbuf()
1409 fb->fmt.sizeimage = fb->fmt.bytesperline * fb->fmt.height; in ivtv_g_fbuf()
1410 fb->base = (void *)itv->osd_video_pbase; in ivtv_g_fbuf()
1411 fb->flags = 0; in ivtv_g_fbuf()
1413 if (itv->osd_chroma_key_state) in ivtv_g_fbuf()
1414 fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY; in ivtv_g_fbuf()
1416 if (itv->osd_global_alpha_state) in ivtv_g_fbuf()
1417 fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; in ivtv_g_fbuf()
1419 if (yi->track_osd) in ivtv_g_fbuf()
1420 fb->flags |= V4L2_FBUF_FLAG_OVERLAY; in ivtv_g_fbuf()
1428 /* 16-bit formats have inverted local alpha */ in ivtv_g_fbuf()
1430 fb->capability |= V4L2_FBUF_CAP_LOCAL_INV_ALPHA; in ivtv_g_fbuf()
1432 fb->capability |= V4L2_FBUF_CAP_LOCAL_ALPHA; in ivtv_g_fbuf()
1434 if (itv->osd_local_alpha_state) { in ivtv_g_fbuf()
1435 /* 16-bit formats have inverted local alpha */ in ivtv_g_fbuf()
1437 fb->flags |= V4L2_FBUF_FLAG_LOCAL_INV_ALPHA; in ivtv_g_fbuf()
1439 fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; in ivtv_g_fbuf()
1448 struct ivtv *itv = id->itv; in ivtv_s_fbuf()
1449 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_s_fbuf()
1450 struct yuv_playback_info *yi = &itv->yuv_info; in ivtv_s_fbuf()
1452 if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_s_fbuf()
1453 return -ENOTTY; in ivtv_s_fbuf()
1454 if (!itv->osd_video_pbase) in ivtv_s_fbuf()
1455 return -ENOTTY; in ivtv_s_fbuf()
1457 itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; in ivtv_s_fbuf()
1458 itv->osd_local_alpha_state = in ivtv_s_fbuf()
1459 (fb->flags & (V4L2_FBUF_FLAG_LOCAL_ALPHA|V4L2_FBUF_FLAG_LOCAL_INV_ALPHA)) != 0; in ivtv_s_fbuf()
1460 itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; in ivtv_s_fbuf()
1462 yi->track_osd = (fb->flags & V4L2_FBUF_FLAG_OVERLAY) != 0; in ivtv_s_fbuf()
1469 struct ivtv *itv = id->itv; in ivtv_overlay()
1470 struct ivtv_stream *s = &itv->streams[fh2id(fh)->type]; in ivtv_overlay()
1472 if (!(s->vdev.device_caps & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) in ivtv_overlay()
1473 return -ENOTTY; in ivtv_overlay()
1474 if (!itv->osd_video_pbase) in ivtv_overlay()
1475 return -ENOTTY; in ivtv_overlay()
1484 switch (sub->type) { in ivtv_subscribe_event()
1495 struct ivtv *itv = fh2id(fh)->itv; in ivtv_log_status()
1498 int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT; in ivtv_log_status()
1503 IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION, itv->card_name); in ivtv_log_status()
1504 if (itv->hw_flags & IVTV_HW_TVEEPROM) { in ivtv_log_status()
1510 ivtv_get_input(itv, itv->active_input, &vidin); in ivtv_log_status()
1511 ivtv_get_audio_input(itv, itv->audio_input, &audin); in ivtv_log_status()
1514 itv->dualwatch_stereo_mode == V4L2_MPEG_AUDIO_MODE_DUAL ? in ivtv_log_status()
1519 int mode = itv->output_mode; in ivtv_log_status()
1552 ivtv_get_output(itv, itv->active_output, &vidout); in ivtv_log_status()
1566 test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? "Radio" : "TV"); in ivtv_log_status()
1567 v4l2_ctrl_handler_log_status(&itv->cxhdl.hdl, itv->v4l2_dev.name); in ivtv_log_status()
1568 IVTV_INFO("Status flags: 0x%08lx\n", itv->i_flags); in ivtv_log_status()
1570 struct ivtv_stream *s = &itv->streams[i]; in ivtv_log_status()
1572 if (s->vdev.v4l2_dev == NULL || s->buffers == 0) in ivtv_log_status()
1574 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()
1575 (s->buffers - s->q_free.buffers) * 100 / s->buffers, in ivtv_log_status()
1576 (s->buffers * s->buf_size) / 1024, s->buffers); in ivtv_log_status()
1580 (long long)itv->mpg_data_received, in ivtv_log_status()
1581 (long long)itv->vbi_data_inserted); in ivtv_log_status()
1587 struct ivtv_open_id *id = fh2id(file->private_data); in ivtv_decoder_cmd()
1588 struct ivtv *itv = id->itv; in ivtv_decoder_cmd()
1590 IVTV_DEBUG_IOCTL("VIDIOC_DECODER_CMD %d\n", dec->cmd); in ivtv_decoder_cmd()
1596 struct ivtv_open_id *id = fh2id(file->private_data); in ivtv_try_decoder_cmd()
1597 struct ivtv *itv = id->itv; in ivtv_try_decoder_cmd()
1599 IVTV_DEBUG_IOCTL("VIDIOC_TRY_DECODER_CMD %d\n", dec->cmd); in ivtv_try_decoder_cmd()
1605 struct ivtv_open_id *id = fh2id(filp->private_data); in ivtv_decoder_ioctls()
1606 struct ivtv *itv = id->itv; in ivtv_decoder_ioctls()
1607 struct ivtv_stream *s = &itv->streams[id->type]; in ivtv_decoder_ioctls()
1614 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_decoder_ioctls()
1615 return -EINVAL; in ivtv_decoder_ioctls()
1616 if (args->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) in ivtv_decoder_ioctls()
1617 return -EINVAL; in ivtv_decoder_ioctls()
1618 if (itv->output_mode == OUT_UDMA_YUV && args->y_source == NULL) in ivtv_decoder_ioctls()
1620 if (ivtv_start_decoding(id, id->type)) { in ivtv_decoder_ioctls()
1621 return -EBUSY; in ivtv_decoder_ioctls()
1625 return -EBUSY; in ivtv_decoder_ioctls()
1628 id->yuv_frames = 1; in ivtv_decoder_ioctls()
1629 if (args->y_source == NULL) in ivtv_decoder_ioctls()
1636 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) in ivtv_decoder_ioctls()
1637 return -EINVAL; in ivtv_decoder_ioctls()
1640 return -EINVAL; in ivtv_decoder_ioctls()
1648 struct ivtv *itv = fh2id(fh)->itv; in ivtv_default()
1653 return -EBUSY; in ivtv_default()
1661 if ((val == 0 && itv->options.newi2c) || (val & 0x01)) in ivtv_default()
1664 v4l2_subdev_call(itv->sd_video, core, reset, 0); in ivtv_default()
1673 return -ENOTTY; in ivtv_default()
1742 vdev->ioctl_ops = &ivtv_ioctl_ops; in ivtv_set_funcs()