3 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
4 Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "ivtv-driver.h"
22 #include "ivtv-version.h"
23 #include "ivtv-mailbox.h"
25 #include "ivtv-queue.h"
26 #include "ivtv-fileops.h"
28 #include "ivtv-routing.h"
29 #include "ivtv-streams.h"
31 #include "ivtv-ioctl.h"
32 #include "ivtv-gpio.h"
33 #include "ivtv-controls.h"
34 #include "ivtv-cards.h"
35 #include <media/saa7127.h>
36 #include <media/tveeprom.h>
37 #include <media/v4l2-chip-ident.h>
38 #include <linux/dvb/audio.h>
39 #include <linux/i2c-id.h>
41 u16
ivtv_service2vbi(int type
)
44 case V4L2_SLICED_TELETEXT_B
:
45 return IVTV_SLICED_TYPE_TELETEXT_B
;
46 case V4L2_SLICED_CAPTION_525
:
47 return IVTV_SLICED_TYPE_CAPTION_525
;
48 case V4L2_SLICED_WSS_625
:
49 return IVTV_SLICED_TYPE_WSS_625
;
51 return IVTV_SLICED_TYPE_VPS
;
57 static int valid_service_line(int field
, int line
, int is_pal
)
59 return (is_pal
&& line
>= 6 && (line
!= 23 || field
== 0)) ||
60 (!is_pal
&& line
>= 10 && line
< 22);
63 static u16
select_service_from_set(int field
, int line
, u16 set
, int is_pal
)
65 u16 valid_set
= (is_pal
? V4L2_SLICED_VBI_625
: V4L2_SLICED_VBI_525
);
68 set
= set
& valid_set
;
69 if (set
== 0 || !valid_service_line(field
, line
, is_pal
)) {
73 if (line
== 21 && (set
& V4L2_SLICED_CAPTION_525
))
74 return V4L2_SLICED_CAPTION_525
;
77 if (line
== 16 && field
== 0 && (set
& V4L2_SLICED_VPS
))
78 return V4L2_SLICED_VPS
;
79 if (line
== 23 && field
== 0 && (set
& V4L2_SLICED_WSS_625
))
80 return V4L2_SLICED_WSS_625
;
84 for (i
= 0; i
< 32; i
++) {
91 void ivtv_expand_service_set(struct v4l2_sliced_vbi_format
*fmt
, int is_pal
)
93 u16 set
= fmt
->service_set
;
97 for (f
= 0; f
< 2; f
++) {
98 for (l
= 0; l
< 24; l
++) {
99 fmt
->service_lines
[f
][l
] = select_service_from_set(f
, l
, set
, is_pal
);
104 static int check_service_set(struct v4l2_sliced_vbi_format
*fmt
, int is_pal
)
109 for (f
= 0; f
< 2; f
++) {
110 for (l
= 0; l
< 24; l
++) {
111 fmt
->service_lines
[f
][l
] = select_service_from_set(f
, l
, fmt
->service_lines
[f
][l
], is_pal
);
112 set
|= fmt
->service_lines
[f
][l
];
118 u16
ivtv_get_service_set(struct v4l2_sliced_vbi_format
*fmt
)
123 for (f
= 0; f
< 2; f
++) {
124 for (l
= 0; l
< 24; l
++) {
125 set
|= fmt
->service_lines
[f
][l
];
131 static const struct {
135 { V4L2_STD_PAL_BG
| V4L2_STD_PAL_H
, "PAL-BGH" },
136 { V4L2_STD_PAL_DK
, "PAL-DK" },
137 { V4L2_STD_PAL_I
, "PAL-I" },
138 { V4L2_STD_PAL_M
, "PAL-M" },
139 { V4L2_STD_PAL_N
, "PAL-N" },
140 { V4L2_STD_PAL_Nc
, "PAL-Nc" },
141 { V4L2_STD_SECAM_B
| V4L2_STD_SECAM_G
| V4L2_STD_SECAM_H
, "SECAM-BGH" },
142 { V4L2_STD_SECAM_DK
, "SECAM-DK" },
143 { V4L2_STD_SECAM_L
, "SECAM-L" },
144 { V4L2_STD_SECAM_LC
, "SECAM-L'" },
145 { V4L2_STD_NTSC_M
, "NTSC-M" },
146 { V4L2_STD_NTSC_M_JP
, "NTSC-J" },
147 { V4L2_STD_NTSC_M_KR
, "NTSC-K" },
150 static const struct v4l2_standard ivtv_std_60hz
=
152 .frameperiod
= {.numerator
= 1001, .denominator
= 30000},
156 static const struct v4l2_standard ivtv_std_50hz
=
158 .frameperiod
= {.numerator
= 1, .denominator
= 25},
162 void ivtv_set_osd_alpha(struct ivtv
*itv
)
164 ivtv_vapi(itv
, CX2341X_OSD_SET_GLOBAL_ALPHA
, 3,
165 itv
->osd_global_alpha_state
, itv
->osd_global_alpha
, !itv
->osd_local_alpha_state
);
166 ivtv_vapi(itv
, CX2341X_OSD_SET_CHROMA_KEY
, 2, itv
->osd_chroma_key_state
, itv
->osd_chroma_key
);
169 int ivtv_set_speed(struct ivtv
*itv
, int speed
)
171 u32 data
[CX2341X_MBOX_MAX_DATA
];
172 struct ivtv_stream
*s
;
173 int single_step
= (speed
== 1 || speed
== -1);
176 if (speed
== 0) speed
= 1000;
179 if (speed
== itv
->speed
&& !single_step
)
182 s
= &itv
->streams
[IVTV_DEC_STREAM_TYPE_MPG
];
184 if (single_step
&& (speed
< 0) == (itv
->speed
< 0)) {
185 /* Single step video and no need to change direction */
186 ivtv_vapi(itv
, CX2341X_DEC_STEP_VIDEO
, 1, 0);
191 /* Need to change direction */
192 speed
= speed
< 0 ? -1000 : 1000;
194 data
[0] = (speed
> 1000 || speed
< -1000) ? 0x80000000 : 0;
195 data
[0] |= (speed
> 1000 || speed
< -1500) ? 0x40000000 : 0;
196 data
[1] = (speed
< 0);
197 data
[2] = speed
< 0 ? 3 : 7;
198 data
[3] = itv
->params
.video_b_frames
;
199 data
[4] = (speed
== 1500 || speed
== 500) ? itv
->speed_mute_audio
: 0;
203 if (speed
== 1500 || speed
== -1500) data
[0] |= 1;
204 else if (speed
== 2000 || speed
== -2000) data
[0] |= 2;
205 else if (speed
> -1000 && speed
< 0) data
[0] |= (-1000 / speed
);
206 else if (speed
< 1000 && speed
> 0) data
[0] |= (1000 / speed
);
208 /* If not decoding, just change speed setting */
209 if (atomic_read(&itv
->decoding
) > 0) {
212 /* Stop all DMA and decoding activity */
213 ivtv_vapi(itv
, CX2341X_DEC_PAUSE_PLAYBACK
, 1, 0);
215 /* Wait for any DMA to finish */
216 prepare_to_wait(&itv
->dma_waitq
, &wait
, TASK_INTERRUPTIBLE
);
217 while (itv
->i_flags
& IVTV_F_I_DMA
) {
218 got_sig
= signal_pending(current
);
224 finish_wait(&itv
->dma_waitq
, &wait
);
228 /* Change Speed safely */
229 ivtv_api(itv
, CX2341X_DEC_SET_PLAYBACK_SPEED
, 7, data
);
230 IVTV_DEBUG_INFO("Setting Speed to 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
231 data
[0], data
[1], data
[2], data
[3], data
[4], data
[5], data
[6]);
234 speed
= (speed
< 0) ? -1 : 1;
235 ivtv_vapi(itv
, CX2341X_DEC_STEP_VIDEO
, 1, 0);
241 static int ivtv_validate_speed(int cur_speed
, int new_speed
)
243 int fact
= new_speed
< 0 ? -1 : 1;
249 new_speed
= -new_speed
;
251 cur_speed
= -cur_speed
;
253 if (cur_speed
<= new_speed
) {
254 if (new_speed
> 1500)
256 if (new_speed
> 1000)
260 if (new_speed
>= 2000)
262 if (new_speed
>= 1500)
264 if (new_speed
>= 1000)
269 if (new_speed
== 1 || new_speed
== 1000)
270 return fact
* new_speed
;
273 new_speed
= 1000 / new_speed
;
274 if (1000 / cur_speed
== new_speed
)
275 new_speed
+= (cur_speed
< s
) ? -1 : 1;
276 if (new_speed
> 60) return 1000 / (fact
* 60);
277 return 1000 / (fact
* new_speed
);
280 static int ivtv_video_command(struct ivtv
*itv
, struct ivtv_open_id
*id
,
281 struct video_command
*vc
, int try)
283 struct ivtv_stream
*s
= &itv
->streams
[IVTV_DEC_STREAM_TYPE_MPG
];
285 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
289 case VIDEO_CMD_PLAY
: {
291 vc
->play
.speed
= ivtv_validate_speed(itv
->speed
, vc
->play
.speed
);
292 if (vc
->play
.speed
< 0)
293 vc
->play
.format
= VIDEO_PLAY_FMT_GOP
;
296 if (ivtv_set_output_mode(itv
, OUT_MPG
) != OUT_MPG
)
298 if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED
, &itv
->i_flags
)) {
299 /* forces ivtv_set_speed to be called */
302 return ivtv_start_decoding(id
, vc
->play
.speed
);
306 vc
->flags
&= VIDEO_CMD_STOP_IMMEDIATELY
|VIDEO_CMD_STOP_TO_BLACK
;
307 if (vc
->flags
& VIDEO_CMD_STOP_IMMEDIATELY
)
310 if (atomic_read(&itv
->decoding
) == 0)
312 if (itv
->output_mode
!= OUT_MPG
)
315 itv
->output_mode
= OUT_NONE
;
316 return ivtv_stop_v4l2_decode_stream(s
, vc
->flags
, vc
->stop
.pts
);
318 case VIDEO_CMD_FREEZE
:
319 vc
->flags
&= VIDEO_CMD_FREEZE_TO_BLACK
;
321 if (itv
->output_mode
!= OUT_MPG
)
323 if (atomic_read(&itv
->decoding
) > 0) {
324 ivtv_vapi(itv
, CX2341X_DEC_PAUSE_PLAYBACK
, 1,
325 (vc
->flags
& VIDEO_CMD_FREEZE_TO_BLACK
) ? 1 : 0);
326 set_bit(IVTV_F_I_DEC_PAUSED
, &itv
->i_flags
);
330 case VIDEO_CMD_CONTINUE
:
333 if (itv
->output_mode
!= OUT_MPG
)
335 if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED
, &itv
->i_flags
)) {
336 int speed
= itv
->speed
;
338 return ivtv_start_decoding(id
, speed
);
348 static int ivtv_itvc(struct ivtv
*itv
, unsigned int cmd
, void *arg
)
350 struct v4l2_register
*regs
= arg
;
352 volatile u8 __iomem
*reg_start
;
354 if (!capable(CAP_SYS_ADMIN
))
356 if (regs
->reg
>= IVTV_REG_OFFSET
&& regs
->reg
< IVTV_REG_OFFSET
+ IVTV_REG_SIZE
)
357 reg_start
= itv
->reg_mem
- IVTV_REG_OFFSET
;
358 else if (itv
->has_cx23415
&& regs
->reg
>= IVTV_DECODER_OFFSET
&&
359 regs
->reg
< IVTV_DECODER_OFFSET
+ IVTV_DECODER_SIZE
)
360 reg_start
= itv
->dec_mem
- IVTV_DECODER_OFFSET
;
361 else if (regs
->reg
>= 0 && regs
->reg
< IVTV_ENCODER_SIZE
)
362 reg_start
= itv
->enc_mem
;
366 spin_lock_irqsave(&ivtv_cards_lock
, flags
);
367 if (cmd
== VIDIOC_DBG_G_REGISTER
) {
368 regs
->val
= readl(regs
->reg
+ reg_start
);
370 writel(regs
->val
, regs
->reg
+ reg_start
);
372 spin_unlock_irqrestore(&ivtv_cards_lock
, flags
);
376 static int ivtv_g_fmt_sliced_vbi_out(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
378 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
379 struct v4l2_sliced_vbi_format
*vbifmt
= &fmt
->fmt
.sliced
;
381 if (!(itv
->v4l2_cap
& V4L2_CAP_SLICED_VBI_OUTPUT
))
383 vbifmt
->io_size
= sizeof(struct v4l2_sliced_vbi_data
) * 36;
385 vbifmt
->service_lines
[0][21] = V4L2_SLICED_CAPTION_525
;
386 vbifmt
->service_lines
[1][21] = V4L2_SLICED_CAPTION_525
;
388 vbifmt
->service_lines
[0][23] = V4L2_SLICED_WSS_625
;
389 vbifmt
->service_lines
[0][16] = V4L2_SLICED_VPS
;
391 vbifmt
->service_set
= ivtv_get_service_set(vbifmt
);
395 static int ivtv_g_fmt_vid_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
397 struct ivtv_open_id
*id
= fh
;
398 struct ivtv
*itv
= id
->itv
;
400 fmt
->fmt
.pix
.width
= itv
->params
.width
;
401 fmt
->fmt
.pix
.height
= itv
->params
.height
;
402 fmt
->fmt
.pix
.colorspace
= V4L2_COLORSPACE_SMPTE170M
;
403 fmt
->fmt
.pix
.field
= V4L2_FIELD_INTERLACED
;
404 if (id
->type
== IVTV_ENC_STREAM_TYPE_YUV
||
405 id
->type
== IVTV_DEC_STREAM_TYPE_YUV
) {
406 fmt
->fmt
.pix
.pixelformat
= V4L2_PIX_FMT_HM12
;
407 /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */
408 fmt
->fmt
.pix
.sizeimage
=
409 fmt
->fmt
.pix
.height
* fmt
->fmt
.pix
.width
+
410 fmt
->fmt
.pix
.height
* (fmt
->fmt
.pix
.width
/ 2);
412 fmt
->fmt
.pix
.pixelformat
= V4L2_PIX_FMT_MPEG
;
413 fmt
->fmt
.pix
.sizeimage
= 128 * 1024;
418 static int ivtv_g_fmt_vbi_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
420 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
422 fmt
->fmt
.vbi
.sampling_rate
= 27000000;
423 fmt
->fmt
.vbi
.offset
= 248;
424 fmt
->fmt
.vbi
.samples_per_line
= itv
->vbi
.raw_decoder_line_size
- 4;
425 fmt
->fmt
.vbi
.sample_format
= V4L2_PIX_FMT_GREY
;
426 fmt
->fmt
.vbi
.start
[0] = itv
->vbi
.start
[0];
427 fmt
->fmt
.vbi
.start
[1] = itv
->vbi
.start
[1];
428 fmt
->fmt
.vbi
.count
[0] = fmt
->fmt
.vbi
.count
[1] = itv
->vbi
.count
;
432 static int ivtv_g_fmt_sliced_vbi_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
434 struct v4l2_sliced_vbi_format
*vbifmt
= &fmt
->fmt
.sliced
;
435 struct ivtv_open_id
*id
= fh
;
436 struct ivtv
*itv
= id
->itv
;
438 vbifmt
->io_size
= sizeof(struct v4l2_sliced_vbi_data
) * 36;
440 if (id
->type
== IVTV_DEC_STREAM_TYPE_VBI
) {
441 vbifmt
->service_set
= itv
->is_50hz
? V4L2_SLICED_VBI_625
:
443 ivtv_expand_service_set(vbifmt
, itv
->is_50hz
);
447 itv
->video_dec_func(itv
, VIDIOC_G_FMT
, fmt
);
448 vbifmt
->service_set
= ivtv_get_service_set(vbifmt
);
452 static int ivtv_g_fmt_vid_out(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
454 struct ivtv_open_id
*id
= fh
;
455 struct ivtv
*itv
= id
->itv
;
457 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
459 fmt
->fmt
.pix
.width
= itv
->main_rect
.width
;
460 fmt
->fmt
.pix
.height
= itv
->main_rect
.height
;
461 fmt
->fmt
.pix
.colorspace
= V4L2_COLORSPACE_SMPTE170M
;
462 fmt
->fmt
.pix
.field
= V4L2_FIELD_INTERLACED
;
463 if (id
->type
== IVTV_DEC_STREAM_TYPE_YUV
) {
464 switch (itv
->yuv_info
.lace_mode
& IVTV_YUV_MODE_MASK
) {
465 case IVTV_YUV_MODE_INTERLACED
:
466 fmt
->fmt
.pix
.field
= (itv
->yuv_info
.lace_mode
& IVTV_YUV_SYNC_MASK
) ?
467 V4L2_FIELD_INTERLACED_BT
: V4L2_FIELD_INTERLACED_TB
;
469 case IVTV_YUV_MODE_PROGRESSIVE
:
470 fmt
->fmt
.pix
.field
= V4L2_FIELD_NONE
;
473 fmt
->fmt
.pix
.field
= V4L2_FIELD_ANY
;
476 fmt
->fmt
.pix
.pixelformat
= V4L2_PIX_FMT_HM12
;
477 fmt
->fmt
.pix
.bytesperline
= 720;
478 fmt
->fmt
.pix
.width
= itv
->yuv_info
.v4l2_src_w
;
479 fmt
->fmt
.pix
.height
= itv
->yuv_info
.v4l2_src_h
;
480 /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */
481 fmt
->fmt
.pix
.sizeimage
=
482 1080 * ((fmt
->fmt
.pix
.height
+ 31) & ~31);
483 } else if (id
->type
== IVTV_ENC_STREAM_TYPE_YUV
) {
484 fmt
->fmt
.pix
.pixelformat
= V4L2_PIX_FMT_HM12
;
485 /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */
486 fmt
->fmt
.pix
.sizeimage
=
487 fmt
->fmt
.pix
.height
* fmt
->fmt
.pix
.width
+
488 fmt
->fmt
.pix
.height
* (fmt
->fmt
.pix
.width
/ 2);
490 fmt
->fmt
.pix
.pixelformat
= V4L2_PIX_FMT_MPEG
;
491 fmt
->fmt
.pix
.sizeimage
= 128 * 1024;
496 static int ivtv_g_fmt_vid_out_overlay(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
498 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
500 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
502 fmt
->fmt
.win
.chromakey
= itv
->osd_chroma_key
;
503 fmt
->fmt
.win
.global_alpha
= itv
->osd_global_alpha
;
507 static int ivtv_try_fmt_sliced_vbi_out(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
509 return ivtv_g_fmt_sliced_vbi_out(file
, fh
, fmt
);
512 static int ivtv_try_fmt_vid_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
514 struct ivtv_open_id
*id
= fh
;
515 struct ivtv
*itv
= id
->itv
;
516 int w
= fmt
->fmt
.pix
.width
;
517 int h
= fmt
->fmt
.pix
.height
;
521 h
= min(h
, itv
->is_50hz
? 576 : 480);
523 ivtv_g_fmt_vid_cap(file
, fh
, fmt
);
524 fmt
->fmt
.pix
.width
= w
;
525 fmt
->fmt
.pix
.height
= h
;
529 static int ivtv_try_fmt_vbi_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
531 return ivtv_g_fmt_vbi_cap(file
, fh
, fmt
);
534 static int ivtv_try_fmt_sliced_vbi_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
536 struct v4l2_sliced_vbi_format
*vbifmt
= &fmt
->fmt
.sliced
;
537 struct ivtv_open_id
*id
= fh
;
538 struct ivtv
*itv
= id
->itv
;
540 if (id
->type
== IVTV_DEC_STREAM_TYPE_VBI
)
541 return ivtv_g_fmt_sliced_vbi_cap(file
, fh
, fmt
);
543 /* set sliced VBI capture format */
544 vbifmt
->io_size
= sizeof(struct v4l2_sliced_vbi_data
) * 36;
545 memset(vbifmt
->reserved
, 0, sizeof(vbifmt
->reserved
));
547 if (vbifmt
->service_set
)
548 ivtv_expand_service_set(vbifmt
, itv
->is_50hz
);
549 check_service_set(vbifmt
, itv
->is_50hz
);
550 vbifmt
->service_set
= ivtv_get_service_set(vbifmt
);
554 static int ivtv_try_fmt_vid_out(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
556 struct ivtv_open_id
*id
= fh
;
561 w
= fmt
->fmt
.pix
.width
;
562 h
= fmt
->fmt
.pix
.height
;
563 field
= fmt
->fmt
.pix
.field
;
564 ret
= ivtv_g_fmt_vid_out(file
, fh
, fmt
);
565 fmt
->fmt
.pix
.width
= w
;
566 fmt
->fmt
.pix
.height
= h
;
567 if (!ret
&& id
->type
== IVTV_DEC_STREAM_TYPE_YUV
) {
568 fmt
->fmt
.pix
.field
= field
;
569 if (fmt
->fmt
.pix
.width
< 2)
570 fmt
->fmt
.pix
.width
= 2;
571 if (fmt
->fmt
.pix
.width
> 720)
572 fmt
->fmt
.pix
.width
= 720;
573 if (fmt
->fmt
.pix
.height
< 2)
574 fmt
->fmt
.pix
.height
= 2;
575 if (fmt
->fmt
.pix
.height
> 576)
576 fmt
->fmt
.pix
.height
= 576;
581 static int ivtv_try_fmt_vid_out_overlay(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
583 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
585 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
590 static int ivtv_s_fmt_sliced_vbi_out(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
592 return ivtv_g_fmt_sliced_vbi_out(file
, fh
, fmt
);
595 static int ivtv_s_fmt_vid_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
597 struct ivtv_open_id
*id
= fh
;
598 struct ivtv
*itv
= id
->itv
;
599 struct cx2341x_mpeg_params
*p
= &itv
->params
;
600 int w
= fmt
->fmt
.pix
.width
;
601 int h
= fmt
->fmt
.pix
.height
;
602 int ret
= ivtv_try_fmt_vid_cap(file
, fh
, fmt
);
607 if (p
->width
== w
&& p
->height
== h
)
610 if (atomic_read(&itv
->capturing
) > 0)
615 if (w
!= 720 || h
!= (itv
->is_50hz
? 576 : 480))
616 p
->video_temporal_filter
= 0;
618 p
->video_temporal_filter
= 8;
619 if (p
->video_encoding
== V4L2_MPEG_VIDEO_ENCODING_MPEG_1
)
620 fmt
->fmt
.pix
.width
/= 2;
621 itv
->video_dec_func(itv
, VIDIOC_S_FMT
, fmt
);
622 return ivtv_g_fmt_vid_cap(file
, fh
, fmt
);
625 static int ivtv_s_fmt_vbi_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
627 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
629 itv
->vbi
.sliced_in
->service_set
= 0;
630 itv
->video_dec_func(itv
, VIDIOC_S_FMT
, &itv
->vbi
.in
);
631 return ivtv_g_fmt_vbi_cap(file
, fh
, fmt
);
634 static int ivtv_s_fmt_sliced_vbi_cap(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
636 struct v4l2_sliced_vbi_format
*vbifmt
= &fmt
->fmt
.sliced
;
637 struct ivtv_open_id
*id
= fh
;
638 struct ivtv
*itv
= id
->itv
;
639 int ret
= ivtv_try_fmt_sliced_vbi_cap(file
, fh
, fmt
);
641 if (ret
|| id
->type
== IVTV_DEC_STREAM_TYPE_VBI
)
644 if (check_service_set(vbifmt
, itv
->is_50hz
) == 0)
646 if (atomic_read(&itv
->capturing
) > 0)
648 itv
->video_dec_func(itv
, VIDIOC_S_FMT
, fmt
);
649 memcpy(itv
->vbi
.sliced_in
, vbifmt
, sizeof(*itv
->vbi
.sliced_in
));
653 static int ivtv_s_fmt_vid_out(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
655 struct ivtv_open_id
*id
= fh
;
656 struct ivtv
*itv
= id
->itv
;
657 struct yuv_playback_info
*yi
= &itv
->yuv_info
;
658 int ret
= ivtv_try_fmt_vid_out(file
, fh
, fmt
);
663 if (id
->type
!= IVTV_DEC_STREAM_TYPE_YUV
)
666 /* Return now if we already have some frame data */
670 yi
->v4l2_src_w
= fmt
->fmt
.pix
.width
;
671 yi
->v4l2_src_h
= fmt
->fmt
.pix
.height
;
673 switch (fmt
->fmt
.pix
.field
) {
674 case V4L2_FIELD_NONE
:
675 yi
->lace_mode
= IVTV_YUV_MODE_PROGRESSIVE
;
678 yi
->lace_mode
= IVTV_YUV_MODE_AUTO
;
680 case V4L2_FIELD_INTERLACED_BT
:
682 IVTV_YUV_MODE_INTERLACED
|IVTV_YUV_SYNC_ODD
;
684 case V4L2_FIELD_INTERLACED_TB
:
686 yi
->lace_mode
= IVTV_YUV_MODE_INTERLACED
;
689 yi
->lace_sync_field
= (yi
->lace_mode
& IVTV_YUV_SYNC_MASK
) == IVTV_YUV_SYNC_EVEN
? 0 : 1;
691 if (test_bit(IVTV_F_I_DEC_YUV
, &itv
->i_flags
))
692 itv
->dma_data_req_size
=
693 1080 * ((yi
->v4l2_src_h
+ 31) & ~31);
695 /* Force update of yuv registers */
696 yi
->yuv_forced_update
= 1;
700 static int ivtv_s_fmt_vid_out_overlay(struct file
*file
, void *fh
, struct v4l2_format
*fmt
)
702 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
703 int ret
= ivtv_try_fmt_vid_out_overlay(file
, fh
, fmt
);
706 itv
->osd_chroma_key
= fmt
->fmt
.win
.chromakey
;
707 itv
->osd_global_alpha
= fmt
->fmt
.win
.global_alpha
;
708 ivtv_set_osd_alpha(itv
);
713 static int ivtv_g_chip_ident(struct file
*file
, void *fh
, struct v4l2_chip_ident
*chip
)
715 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
717 chip
->ident
= V4L2_IDENT_NONE
;
719 if (chip
->match_type
== V4L2_CHIP_MATCH_HOST
) {
720 if (v4l2_chip_match_host(chip
->match_type
, chip
->match_chip
))
721 chip
->ident
= itv
->has_cx23415
? V4L2_IDENT_CX23415
: V4L2_IDENT_CX23416
;
724 if (chip
->match_type
== V4L2_CHIP_MATCH_I2C_DRIVER
)
725 return ivtv_i2c_id(itv
, chip
->match_chip
, VIDIOC_G_CHIP_IDENT
, chip
);
726 if (chip
->match_type
== V4L2_CHIP_MATCH_I2C_ADDR
)
727 return ivtv_call_i2c_client(itv
, chip
->match_chip
, VIDIOC_G_CHIP_IDENT
, chip
);
731 static int ivtv_g_register(struct file
*file
, void *fh
, struct v4l2_register
*reg
)
733 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
735 if (v4l2_chip_match_host(reg
->match_type
, reg
->match_chip
))
736 return ivtv_itvc(itv
, VIDIOC_DBG_G_REGISTER
, reg
);
737 if (reg
->match_type
== V4L2_CHIP_MATCH_I2C_DRIVER
)
738 return ivtv_i2c_id(itv
, reg
->match_chip
, VIDIOC_DBG_G_REGISTER
, reg
);
739 return ivtv_call_i2c_client(itv
, reg
->match_chip
, VIDIOC_DBG_G_REGISTER
, reg
);
742 static int ivtv_s_register(struct file
*file
, void *fh
, struct v4l2_register
*reg
)
744 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
746 if (v4l2_chip_match_host(reg
->match_type
, reg
->match_chip
))
747 return ivtv_itvc(itv
, VIDIOC_DBG_S_REGISTER
, reg
);
748 if (reg
->match_type
== V4L2_CHIP_MATCH_I2C_DRIVER
)
749 return ivtv_i2c_id(itv
, reg
->match_chip
, VIDIOC_DBG_S_REGISTER
, reg
);
750 return ivtv_call_i2c_client(itv
, reg
->match_chip
, VIDIOC_DBG_S_REGISTER
, reg
);
753 static int ivtv_g_priority(struct file
*file
, void *fh
, enum v4l2_priority
*p
)
755 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
757 *p
= v4l2_prio_max(&itv
->prio
);
762 static int ivtv_s_priority(struct file
*file
, void *fh
, enum v4l2_priority prio
)
764 struct ivtv_open_id
*id
= fh
;
765 struct ivtv
*itv
= id
->itv
;
767 return v4l2_prio_change(&itv
->prio
, &id
->prio
, prio
);
770 static int ivtv_querycap(struct file
*file
, void *fh
, struct v4l2_capability
*vcap
)
772 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
774 memset(vcap
, 0, sizeof(*vcap
));
775 strlcpy(vcap
->driver
, IVTV_DRIVER_NAME
, sizeof(vcap
->driver
));
776 strlcpy(vcap
->card
, itv
->card_name
, sizeof(vcap
->card
));
777 strlcpy(vcap
->bus_info
, pci_name(itv
->dev
), sizeof(vcap
->bus_info
));
778 vcap
->version
= IVTV_DRIVER_VERSION
; /* version */
779 vcap
->capabilities
= itv
->v4l2_cap
; /* capabilities */
780 /* reserved.. must set to 0! */
781 vcap
->reserved
[0] = vcap
->reserved
[1] =
782 vcap
->reserved
[2] = vcap
->reserved
[3] = 0;
786 static int ivtv_enumaudio(struct file
*file
, void *fh
, struct v4l2_audio
*vin
)
788 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
790 return ivtv_get_audio_input(itv
, vin
->index
, vin
);
793 static int ivtv_g_audio(struct file
*file
, void *fh
, struct v4l2_audio
*vin
)
795 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
797 vin
->index
= itv
->audio_input
;
798 return ivtv_get_audio_input(itv
, vin
->index
, vin
);
801 static int ivtv_s_audio(struct file
*file
, void *fh
, struct v4l2_audio
*vout
)
803 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
805 if (vout
->index
>= itv
->nof_audio_inputs
)
808 itv
->audio_input
= vout
->index
;
809 ivtv_audio_set_io(itv
);
814 static int ivtv_enumaudout(struct file
*file
, void *fh
, struct v4l2_audioout
*vin
)
816 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
818 /* set it to defaults from our table */
819 return ivtv_get_audio_output(itv
, vin
->index
, vin
);
822 static int ivtv_g_audout(struct file
*file
, void *fh
, struct v4l2_audioout
*vin
)
824 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
827 return ivtv_get_audio_output(itv
, vin
->index
, vin
);
830 static int ivtv_s_audout(struct file
*file
, void *fh
, struct v4l2_audioout
*vout
)
832 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
834 return ivtv_get_audio_output(itv
, vout
->index
, vout
);
837 static int ivtv_enum_input(struct file
*file
, void *fh
, struct v4l2_input
*vin
)
839 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
841 /* set it to defaults from our table */
842 return ivtv_get_input(itv
, vin
->index
, vin
);
845 static int ivtv_enum_output(struct file
*file
, void *fh
, struct v4l2_output
*vout
)
847 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
849 return ivtv_get_output(itv
, vout
->index
, vout
);
852 static int ivtv_cropcap(struct file
*file
, void *fh
, struct v4l2_cropcap
*cropcap
)
854 struct ivtv_open_id
*id
= fh
;
855 struct ivtv
*itv
= id
->itv
;
856 struct yuv_playback_info
*yi
= &itv
->yuv_info
;
859 streamtype
= id
->type
;
861 if (cropcap
->type
!= V4L2_BUF_TYPE_VIDEO_OUTPUT
)
863 cropcap
->bounds
.top
= cropcap
->bounds
.left
= 0;
864 cropcap
->bounds
.width
= 720;
865 if (cropcap
->type
== V4L2_BUF_TYPE_VIDEO_CAPTURE
) {
866 cropcap
->bounds
.height
= itv
->is_50hz
? 576 : 480;
867 cropcap
->pixelaspect
.numerator
= itv
->is_50hz
? 59 : 10;
868 cropcap
->pixelaspect
.denominator
= itv
->is_50hz
? 54 : 11;
869 } else if (streamtype
== IVTV_DEC_STREAM_TYPE_YUV
) {
871 cropcap
->bounds
.width
= yi
->osd_full_w
;
872 cropcap
->bounds
.height
= yi
->osd_full_h
;
874 cropcap
->bounds
.width
= 720;
875 cropcap
->bounds
.height
=
876 itv
->is_out_50hz
? 576 : 480;
878 cropcap
->pixelaspect
.numerator
= itv
->is_out_50hz
? 59 : 10;
879 cropcap
->pixelaspect
.denominator
= itv
->is_out_50hz
? 54 : 11;
881 cropcap
->bounds
.height
= itv
->is_out_50hz
? 576 : 480;
882 cropcap
->pixelaspect
.numerator
= itv
->is_out_50hz
? 59 : 10;
883 cropcap
->pixelaspect
.denominator
= itv
->is_out_50hz
? 54 : 11;
885 cropcap
->defrect
= cropcap
->bounds
;
889 static int ivtv_s_crop(struct file
*file
, void *fh
, struct v4l2_crop
*crop
)
891 struct ivtv_open_id
*id
= fh
;
892 struct ivtv
*itv
= id
->itv
;
893 struct yuv_playback_info
*yi
= &itv
->yuv_info
;
896 streamtype
= id
->type
;
898 if (ivtv_debug
& IVTV_DBGFLG_IOCTL
) {
899 printk(KERN_INFO
"ivtv%d ioctl: ", itv
->num
);
900 /* Should be replaced */
901 /* v4l_printk_ioctl(VIDIOC_S_CROP); */
904 if (crop
->type
== V4L2_BUF_TYPE_VIDEO_OUTPUT
&&
905 (itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
)) {
906 if (streamtype
== IVTV_DEC_STREAM_TYPE_YUV
) {
907 yi
->main_rect
= crop
->c
;
910 if (!ivtv_vapi(itv
, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW
, 4,
911 crop
->c
.width
, crop
->c
.height
, crop
->c
.left
, crop
->c
.top
)) {
912 itv
->main_rect
= crop
->c
;
921 static int ivtv_g_crop(struct file
*file
, void *fh
, struct v4l2_crop
*crop
)
923 struct ivtv_open_id
*id
= fh
;
924 struct ivtv
*itv
= id
->itv
;
925 struct yuv_playback_info
*yi
= &itv
->yuv_info
;
928 streamtype
= id
->type
;
930 if (crop
->type
== V4L2_BUF_TYPE_VIDEO_OUTPUT
&&
931 (itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
)) {
932 if (streamtype
== IVTV_DEC_STREAM_TYPE_YUV
)
933 crop
->c
= yi
->main_rect
;
935 crop
->c
= itv
->main_rect
;
941 static int ivtv_enum_fmt_vid_cap(struct file
*file
, void *fh
, struct v4l2_fmtdesc
*fmt
)
943 static struct v4l2_fmtdesc formats
[] = {
945 "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12
,
948 { 1, 0, V4L2_FMT_FLAG_COMPRESSED
,
949 "MPEG", V4L2_PIX_FMT_MPEG
,
953 enum v4l2_buf_type type
= fmt
->type
;
958 *fmt
= formats
[fmt
->index
];
963 static int ivtv_enum_fmt_vid_out(struct file
*file
, void *fh
, struct v4l2_fmtdesc
*fmt
)
965 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
967 static struct v4l2_fmtdesc formats
[] = {
969 "HM12 (YUV 4:2:0)", V4L2_PIX_FMT_HM12
,
972 { 1, 0, V4L2_FMT_FLAG_COMPRESSED
,
973 "MPEG", V4L2_PIX_FMT_MPEG
,
977 enum v4l2_buf_type type
= fmt
->type
;
979 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
985 *fmt
= formats
[fmt
->index
];
991 static int ivtv_g_input(struct file
*file
, void *fh
, unsigned int *i
)
993 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
995 *i
= itv
->active_input
;
1000 int ivtv_s_input(struct file
*file
, void *fh
, unsigned int inp
)
1002 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1004 if (inp
< 0 || inp
>= itv
->nof_inputs
)
1007 if (inp
== itv
->active_input
) {
1008 IVTV_DEBUG_INFO("Input unchanged\n");
1012 if (atomic_read(&itv
->capturing
) > 0) {
1016 IVTV_DEBUG_INFO("Changing input from %d to %d\n",
1017 itv
->active_input
, inp
);
1019 itv
->active_input
= inp
;
1020 /* Set the audio input to whatever is appropriate for the
1022 itv
->audio_input
= itv
->card
->video_inputs
[inp
].audio_index
;
1024 /* prevent others from messing with the streams until
1025 we're finished changing inputs. */
1027 ivtv_video_set_io(itv
);
1028 ivtv_audio_set_io(itv
);
1034 static int ivtv_g_output(struct file
*file
, void *fh
, unsigned int *i
)
1036 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1038 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
1041 *i
= itv
->active_output
;
1046 static int ivtv_s_output(struct file
*file
, void *fh
, unsigned int outp
)
1048 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1049 struct v4l2_routing route
;
1051 if (outp
>= itv
->card
->nof_outputs
)
1054 if (outp
== itv
->active_output
) {
1055 IVTV_DEBUG_INFO("Output unchanged\n");
1058 IVTV_DEBUG_INFO("Changing output from %d to %d\n",
1059 itv
->active_output
, outp
);
1061 itv
->active_output
= outp
;
1062 route
.input
= SAA7127_INPUT_TYPE_NORMAL
;
1063 route
.output
= itv
->card
->video_outputs
[outp
].video_output
;
1064 ivtv_saa7127(itv
, VIDIOC_INT_S_VIDEO_ROUTING
, &route
);
1069 static int ivtv_g_frequency(struct file
*file
, void *fh
, struct v4l2_frequency
*vf
)
1071 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1076 ivtv_call_i2c_clients(itv
, VIDIOC_G_FREQUENCY
, vf
);
1080 int ivtv_s_frequency(struct file
*file
, void *fh
, struct v4l2_frequency
*vf
)
1082 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1088 IVTV_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf
->frequency
);
1089 ivtv_call_i2c_clients(itv
, VIDIOC_S_FREQUENCY
, vf
);
1094 static int ivtv_g_std(struct file
*file
, void *fh
, v4l2_std_id
*std
)
1096 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1102 int ivtv_s_std(struct file
*file
, void *fh
, v4l2_std_id
*std
)
1104 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1105 struct yuv_playback_info
*yi
= &itv
->yuv_info
;
1107 if ((*std
& V4L2_STD_ALL
) == 0)
1110 if (*std
== itv
->std
)
1113 if (test_bit(IVTV_F_I_RADIO_USER
, &itv
->i_flags
) ||
1114 atomic_read(&itv
->capturing
) > 0 ||
1115 atomic_read(&itv
->decoding
) > 0) {
1116 /* Switching standard would turn off the radio or mess
1117 with already running streams, prevent that by
1123 itv
->is_60hz
= (*std
& V4L2_STD_525_60
) ? 1 : 0;
1124 itv
->params
.is_50hz
= itv
->is_50hz
= !itv
->is_60hz
;
1125 itv
->params
.width
= 720;
1126 itv
->params
.height
= itv
->is_50hz
? 576 : 480;
1127 itv
->vbi
.count
= itv
->is_50hz
? 18 : 12;
1128 itv
->vbi
.start
[0] = itv
->is_50hz
? 6 : 10;
1129 itv
->vbi
.start
[1] = itv
->is_50hz
? 318 : 273;
1131 if (itv
->hw_flags
& IVTV_HW_CX25840
)
1132 itv
->vbi
.sliced_decoder_line_size
= itv
->is_60hz
? 272 : 284;
1134 IVTV_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)itv
->std
);
1137 ivtv_call_i2c_clients(itv
, VIDIOC_S_STD
, &itv
->std
);
1139 if (itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
) {
1140 /* set display standard */
1141 itv
->std_out
= *std
;
1142 itv
->is_out_60hz
= itv
->is_60hz
;
1143 itv
->is_out_50hz
= itv
->is_50hz
;
1144 ivtv_call_i2c_clients(itv
, VIDIOC_INT_S_STD_OUTPUT
, &itv
->std_out
);
1145 ivtv_vapi(itv
, CX2341X_DEC_SET_STANDARD
, 1, itv
->is_out_50hz
);
1146 itv
->main_rect
.left
= itv
->main_rect
.top
= 0;
1147 itv
->main_rect
.width
= 720;
1148 itv
->main_rect
.height
= itv
->params
.height
;
1149 ivtv_vapi(itv
, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW
, 4,
1150 720, itv
->main_rect
.height
, 0, 0);
1151 yi
->main_rect
= itv
->main_rect
;
1152 if (!itv
->osd_info
) {
1153 yi
->osd_full_w
= 720;
1154 yi
->osd_full_h
= itv
->is_out_50hz
? 576 : 480;
1160 static int ivtv_s_tuner(struct file
*file
, void *fh
, struct v4l2_tuner
*vt
)
1162 struct ivtv_open_id
*id
= fh
;
1163 struct ivtv
*itv
= id
->itv
;
1168 ivtv_call_i2c_clients(itv
, VIDIOC_S_TUNER
, vt
);
1173 static int ivtv_g_tuner(struct file
*file
, void *fh
, struct v4l2_tuner
*vt
)
1175 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1180 memset(vt
, 0, sizeof(*vt
));
1181 ivtv_call_i2c_clients(itv
, VIDIOC_G_TUNER
, vt
);
1183 if (test_bit(IVTV_F_I_RADIO_USER
, &itv
->i_flags
)) {
1184 strlcpy(vt
->name
, "ivtv Radio Tuner", sizeof(vt
->name
));
1185 vt
->type
= V4L2_TUNER_RADIO
;
1187 strlcpy(vt
->name
, "ivtv TV Tuner", sizeof(vt
->name
));
1188 vt
->type
= V4L2_TUNER_ANALOG_TV
;
1194 static int ivtv_g_sliced_vbi_cap(struct file
*file
, void *fh
, struct v4l2_sliced_vbi_cap
*cap
)
1196 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1197 int set
= itv
->is_50hz
? V4L2_SLICED_VBI_625
: V4L2_SLICED_VBI_525
;
1199 enum v4l2_buf_type type
= cap
->type
;
1201 memset(cap
, 0, sizeof(*cap
));
1203 if (type
== V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
) {
1204 for (f
= 0; f
< 2; f
++) {
1205 for (l
= 0; l
< 24; l
++) {
1206 if (valid_service_line(f
, l
, itv
->is_50hz
))
1207 cap
->service_lines
[f
][l
] = set
;
1212 if (type
== V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
) {
1213 if (!(itv
->v4l2_cap
& V4L2_CAP_SLICED_VBI_OUTPUT
))
1216 cap
->service_lines
[0][21] = V4L2_SLICED_CAPTION_525
;
1217 cap
->service_lines
[1][21] = V4L2_SLICED_CAPTION_525
;
1219 cap
->service_lines
[0][23] = V4L2_SLICED_WSS_625
;
1220 cap
->service_lines
[0][16] = V4L2_SLICED_VPS
;
1227 static int ivtv_g_enc_index(struct file
*file
, void *fh
, struct v4l2_enc_idx
*idx
)
1229 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1230 struct v4l2_enc_idx_entry
*e
= idx
->entry
;
1234 entries
= (itv
->pgm_info_write_idx
+ IVTV_MAX_PGM_INDEX
- itv
->pgm_info_read_idx
) %
1236 if (entries
> V4L2_ENC_IDX_ENTRIES
)
1237 entries
= V4L2_ENC_IDX_ENTRIES
;
1239 for (i
= 0; i
< entries
; i
++) {
1240 *e
= itv
->pgm_info
[(itv
->pgm_info_read_idx
+ i
) % IVTV_MAX_PGM_INDEX
];
1241 if ((e
->flags
& V4L2_ENC_IDX_FRAME_MASK
) <= V4L2_ENC_IDX_FRAME_B
) {
1246 itv
->pgm_info_read_idx
= (itv
->pgm_info_read_idx
+ idx
->entries
) % IVTV_MAX_PGM_INDEX
;
1250 static int ivtv_encoder_cmd(struct file
*file
, void *fh
, struct v4l2_encoder_cmd
*enc
)
1252 struct ivtv_open_id
*id
= fh
;
1253 struct ivtv
*itv
= id
->itv
;
1255 memset(&enc
->raw
, 0, sizeof(enc
->raw
));
1258 case V4L2_ENC_CMD_START
:
1259 IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
1261 return ivtv_start_capture(id
);
1263 case V4L2_ENC_CMD_STOP
:
1264 IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
1265 enc
->flags
&= V4L2_ENC_CMD_STOP_AT_GOP_END
;
1266 ivtv_stop_capture(id
, enc
->flags
& V4L2_ENC_CMD_STOP_AT_GOP_END
);
1269 case V4L2_ENC_CMD_PAUSE
:
1270 IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
1273 if (!atomic_read(&itv
->capturing
))
1275 if (test_and_set_bit(IVTV_F_I_ENC_PAUSED
, &itv
->i_flags
))
1279 ivtv_vapi(itv
, CX2341X_ENC_PAUSE_ENCODER
, 1, 0);
1282 case V4L2_ENC_CMD_RESUME
:
1283 IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
1286 if (!atomic_read(&itv
->capturing
))
1289 if (!test_and_clear_bit(IVTV_F_I_ENC_PAUSED
, &itv
->i_flags
))
1292 ivtv_vapi(itv
, CX2341X_ENC_PAUSE_ENCODER
, 1, 1);
1296 IVTV_DEBUG_IOCTL("Unknown cmd %d\n", enc
->cmd
);
1303 static int ivtv_try_encoder_cmd(struct file
*file
, void *fh
, struct v4l2_encoder_cmd
*enc
)
1305 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1307 memset(&enc
->raw
, 0, sizeof(enc
->raw
));
1310 case V4L2_ENC_CMD_START
:
1311 IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
1315 case V4L2_ENC_CMD_STOP
:
1316 IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
1317 enc
->flags
&= V4L2_ENC_CMD_STOP_AT_GOP_END
;
1320 case V4L2_ENC_CMD_PAUSE
:
1321 IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
1325 case V4L2_ENC_CMD_RESUME
:
1326 IVTV_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
1330 IVTV_DEBUG_IOCTL("Unknown cmd %d\n", enc
->cmd
);
1335 static int ivtv_g_fbuf(struct file
*file
, void *fh
, struct v4l2_framebuffer
*fb
)
1337 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1338 u32 data
[CX2341X_MBOX_MAX_DATA
];
1339 struct yuv_playback_info
*yi
= &itv
->yuv_info
;
1342 static u32 pixel_format
[16] = {
1343 V4L2_PIX_FMT_PAL8
, /* Uses a 256-entry RGB colormap */
1344 V4L2_PIX_FMT_RGB565
,
1345 V4L2_PIX_FMT_RGB555
,
1346 V4L2_PIX_FMT_RGB444
,
1351 V4L2_PIX_FMT_PAL8
, /* Uses a 256-entry YUV colormap */
1352 V4L2_PIX_FMT_YUV565
,
1353 V4L2_PIX_FMT_YUV555
,
1354 V4L2_PIX_FMT_YUV444
,
1361 memset(fb
, 0, sizeof(*fb
));
1363 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT_OVERLAY
))
1366 fb
->capability
= V4L2_FBUF_CAP_EXTERNOVERLAY
| V4L2_FBUF_CAP_CHROMAKEY
|
1367 V4L2_FBUF_CAP_GLOBAL_ALPHA
;
1369 ivtv_vapi_result(itv
, data
, CX2341X_OSD_GET_STATE
, 0);
1370 data
[0] |= (read_reg(0x2a00) >> 7) & 0x40;
1371 pixfmt
= (data
[0] >> 3) & 0xf;
1373 fb
->fmt
.pixelformat
= pixel_format
[pixfmt
];
1374 fb
->fmt
.width
= itv
->osd_rect
.width
;
1375 fb
->fmt
.height
= itv
->osd_rect
.height
;
1376 fb
->base
= (void *)itv
->osd_video_pbase
;
1378 if (itv
->osd_chroma_key_state
)
1379 fb
->flags
|= V4L2_FBUF_FLAG_CHROMAKEY
;
1381 if (itv
->osd_global_alpha_state
)
1382 fb
->flags
|= V4L2_FBUF_FLAG_GLOBAL_ALPHA
;
1386 /* no local alpha for RGB565 or unknown formats */
1387 if (pixfmt
== 1 || pixfmt
> 4)
1390 /* 16-bit formats have inverted local alpha */
1391 if (pixfmt
== 2 || pixfmt
== 3)
1392 fb
->capability
|= V4L2_FBUF_CAP_LOCAL_INV_ALPHA
;
1394 fb
->capability
|= V4L2_FBUF_CAP_LOCAL_ALPHA
;
1396 if (itv
->osd_local_alpha_state
) {
1397 /* 16-bit formats have inverted local alpha */
1398 if (pixfmt
== 2 || pixfmt
== 3)
1399 fb
->flags
|= V4L2_FBUF_FLAG_LOCAL_INV_ALPHA
;
1401 fb
->flags
|= V4L2_FBUF_FLAG_LOCAL_ALPHA
;
1404 fb
->flags
|= V4L2_FBUF_FLAG_OVERLAY
;
1409 static int ivtv_s_fbuf(struct file
*file
, void *fh
, struct v4l2_framebuffer
*fb
)
1411 struct ivtv_open_id
*id
= fh
;
1412 struct ivtv
*itv
= id
->itv
;
1413 struct yuv_playback_info
*yi
= &itv
->yuv_info
;
1415 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT_OVERLAY
))
1418 itv
->osd_global_alpha_state
= (fb
->flags
& V4L2_FBUF_FLAG_GLOBAL_ALPHA
) != 0;
1419 itv
->osd_local_alpha_state
=
1420 (fb
->flags
& (V4L2_FBUF_FLAG_LOCAL_ALPHA
|V4L2_FBUF_FLAG_LOCAL_INV_ALPHA
)) != 0;
1421 itv
->osd_chroma_key_state
= (fb
->flags
& V4L2_FBUF_FLAG_CHROMAKEY
) != 0;
1422 ivtv_set_osd_alpha(itv
);
1423 yi
->track_osd
= (fb
->flags
& V4L2_FBUF_FLAG_OVERLAY
) != 0;
1428 static int ivtv_overlay(struct file
*file
, void *fh
, unsigned int on
)
1430 struct ivtv_open_id
*id
= fh
;
1431 struct ivtv
*itv
= id
->itv
;
1433 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT_OVERLAY
))
1436 ivtv_vapi(itv
, CX2341X_OSD_SET_STATE
, 1, on
!= 0);
1441 static int ivtv_log_status(struct file
*file
, void *fh
)
1443 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1444 u32 data
[CX2341X_MBOX_MAX_DATA
];
1446 int has_output
= itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
;
1447 struct v4l2_input vidin
;
1448 struct v4l2_audio audin
;
1451 IVTV_INFO("================= START STATUS CARD #%d =================\n", itv
->num
);
1452 IVTV_INFO("Version: %s Card: %s\n", IVTV_VERSION
, itv
->card_name
);
1453 if (itv
->hw_flags
& IVTV_HW_TVEEPROM
) {
1456 ivtv_read_eeprom(itv
, &tv
);
1458 ivtv_call_i2c_clients(itv
, VIDIOC_LOG_STATUS
, NULL
);
1459 ivtv_get_input(itv
, itv
->active_input
, &vidin
);
1460 ivtv_get_audio_input(itv
, itv
->audio_input
, &audin
);
1461 IVTV_INFO("Video Input: %s\n", vidin
.name
);
1462 IVTV_INFO("Audio Input: %s%s\n", audin
.name
,
1463 (itv
->dualwatch_stereo_mode
& ~0x300) == 0x200 ? " (Bilingual)" : "");
1465 struct v4l2_output vidout
;
1466 struct v4l2_audioout audout
;
1467 int mode
= itv
->output_mode
;
1468 static const char * const output_modes
[5] = {
1475 static const char * const audio_modes
[5] = {
1482 static const char * const alpha_mode
[4] = {
1488 static const char * const pixel_format
[16] = {
1507 ivtv_get_output(itv
, itv
->active_output
, &vidout
);
1508 ivtv_get_audio_output(itv
, 0, &audout
);
1509 IVTV_INFO("Video Output: %s\n", vidout
.name
);
1510 IVTV_INFO("Audio Output: %s (Stereo/Bilingual: %s/%s)\n", audout
.name
,
1511 audio_modes
[itv
->audio_stereo_mode
],
1512 audio_modes
[itv
->audio_bilingual_mode
]);
1513 if (mode
< 0 || mode
> OUT_PASSTHROUGH
)
1515 IVTV_INFO("Output Mode: %s\n", output_modes
[mode
]);
1516 ivtv_vapi_result(itv
, data
, CX2341X_OSD_GET_STATE
, 0);
1517 data
[0] |= (read_reg(0x2a00) >> 7) & 0x40;
1518 IVTV_INFO("Overlay: %s, Alpha: %s, Pixel Format: %s\n",
1519 data
[0] & 1 ? "On" : "Off",
1520 alpha_mode
[(data
[0] >> 1) & 0x3],
1521 pixel_format
[(data
[0] >> 3) & 0xf]);
1523 IVTV_INFO("Tuner: %s\n",
1524 test_bit(IVTV_F_I_RADIO_USER
, &itv
->i_flags
) ? "Radio" : "TV");
1525 cx2341x_log_status(&itv
->params
, itv
->name
);
1526 IVTV_INFO("Status flags: 0x%08lx\n", itv
->i_flags
);
1527 for (i
= 0; i
< IVTV_MAX_STREAMS
; i
++) {
1528 struct ivtv_stream
*s
= &itv
->streams
[i
];
1530 if (s
->v4l2dev
== NULL
|| s
->buffers
== 0)
1532 IVTV_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n", s
->name
, s
->s_flags
,
1533 (s
->buffers
- s
->q_free
.buffers
) * 100 / s
->buffers
,
1534 (s
->buffers
* s
->buf_size
) / 1024, s
->buffers
);
1537 IVTV_INFO("Read MPG/VBI: %lld/%lld bytes\n", (long long)itv
->mpg_data_received
, (long long)itv
->vbi_data_inserted
);
1538 IVTV_INFO("================== END STATUS CARD #%d ==================\n", itv
->num
);
1543 static int ivtv_decoder_ioctls(struct file
*filp
, unsigned int cmd
, void *arg
)
1545 struct ivtv_open_id
*id
= (struct ivtv_open_id
*)filp
->private_data
;
1546 struct ivtv
*itv
= id
->itv
;
1547 int nonblocking
= filp
->f_flags
& O_NONBLOCK
;
1548 struct ivtv_stream
*s
= &itv
->streams
[id
->type
];
1551 case IVTV_IOC_DMA_FRAME
: {
1552 struct ivtv_dma_frame
*args
= arg
;
1554 IVTV_DEBUG_IOCTL("IVTV_IOC_DMA_FRAME\n");
1555 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
1557 if (args
->type
!= V4L2_BUF_TYPE_VIDEO_OUTPUT
)
1559 if (itv
->output_mode
== OUT_UDMA_YUV
&& args
->y_source
== NULL
)
1561 if (ivtv_claim_stream(id
, id
->type
)) {
1564 if (ivtv_set_output_mode(itv
, OUT_UDMA_YUV
) != OUT_UDMA_YUV
) {
1565 ivtv_release_stream(s
);
1568 /* Mark that this file handle started the UDMA_YUV mode */
1570 if (args
->y_source
== NULL
)
1572 return ivtv_yuv_prep_frame(itv
, args
);
1575 case VIDEO_GET_PTS
: {
1576 u32 data
[CX2341X_MBOX_MAX_DATA
];
1579 IVTV_DEBUG_IOCTL("VIDEO_GET_PTS\n");
1580 if (s
->type
< IVTV_DEC_STREAM_TYPE_MPG
) {
1584 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
1587 if (test_bit(IVTV_F_I_VALID_DEC_TIMINGS
, &itv
->i_flags
)) {
1588 *pts
= (u64
) ((u64
)itv
->last_dec_timing
[2] << 32) |
1589 (u64
)itv
->last_dec_timing
[1];
1593 if (atomic_read(&itv
->decoding
)) {
1594 if (ivtv_api(itv
, CX2341X_DEC_GET_TIMING_INFO
, 5, data
)) {
1595 IVTV_DEBUG_WARN("GET_TIMING: couldn't read clock\n");
1598 memcpy(itv
->last_dec_timing
, data
, sizeof(itv
->last_dec_timing
));
1599 set_bit(IVTV_F_I_VALID_DEC_TIMINGS
, &itv
->i_flags
);
1600 *pts
= (u64
) ((u64
) data
[2] << 32) | (u64
) data
[1];
1601 /*timing->scr = (u64) (((u64) data[4] << 32) | (u64) (data[3]));*/
1606 case VIDEO_GET_FRAME_COUNT
: {
1607 u32 data
[CX2341X_MBOX_MAX_DATA
];
1610 IVTV_DEBUG_IOCTL("VIDEO_GET_FRAME_COUNT\n");
1611 if (s
->type
< IVTV_DEC_STREAM_TYPE_MPG
) {
1615 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
1618 if (test_bit(IVTV_F_I_VALID_DEC_TIMINGS
, &itv
->i_flags
)) {
1619 *frame
= itv
->last_dec_timing
[0];
1623 if (atomic_read(&itv
->decoding
)) {
1624 if (ivtv_api(itv
, CX2341X_DEC_GET_TIMING_INFO
, 5, data
)) {
1625 IVTV_DEBUG_WARN("GET_TIMING: couldn't read clock\n");
1628 memcpy(itv
->last_dec_timing
, data
, sizeof(itv
->last_dec_timing
));
1629 set_bit(IVTV_F_I_VALID_DEC_TIMINGS
, &itv
->i_flags
);
1636 struct video_command vc
;
1638 IVTV_DEBUG_IOCTL("VIDEO_PLAY\n");
1639 memset(&vc
, 0, sizeof(vc
));
1640 vc
.cmd
= VIDEO_CMD_PLAY
;
1641 return ivtv_video_command(itv
, id
, &vc
, 0);
1645 struct video_command vc
;
1647 IVTV_DEBUG_IOCTL("VIDEO_STOP\n");
1648 memset(&vc
, 0, sizeof(vc
));
1649 vc
.cmd
= VIDEO_CMD_STOP
;
1650 vc
.flags
= VIDEO_CMD_STOP_TO_BLACK
| VIDEO_CMD_STOP_IMMEDIATELY
;
1651 return ivtv_video_command(itv
, id
, &vc
, 0);
1654 case VIDEO_FREEZE
: {
1655 struct video_command vc
;
1657 IVTV_DEBUG_IOCTL("VIDEO_FREEZE\n");
1658 memset(&vc
, 0, sizeof(vc
));
1659 vc
.cmd
= VIDEO_CMD_FREEZE
;
1660 return ivtv_video_command(itv
, id
, &vc
, 0);
1663 case VIDEO_CONTINUE
: {
1664 struct video_command vc
;
1666 IVTV_DEBUG_IOCTL("VIDEO_CONTINUE\n");
1667 memset(&vc
, 0, sizeof(vc
));
1668 vc
.cmd
= VIDEO_CMD_CONTINUE
;
1669 return ivtv_video_command(itv
, id
, &vc
, 0);
1673 case VIDEO_TRY_COMMAND
: {
1674 struct video_command
*vc
= arg
;
1675 int try = (cmd
== VIDEO_TRY_COMMAND
);
1678 IVTV_DEBUG_IOCTL("VIDEO_TRY_COMMAND %d\n", vc
->cmd
);
1680 IVTV_DEBUG_IOCTL("VIDEO_COMMAND %d\n", vc
->cmd
);
1681 return ivtv_video_command(itv
, id
, vc
, try);
1684 case VIDEO_GET_EVENT
: {
1685 struct video_event
*ev
= arg
;
1688 IVTV_DEBUG_IOCTL("VIDEO_GET_EVENT\n");
1689 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
1691 memset(ev
, 0, sizeof(*ev
));
1692 set_bit(IVTV_F_I_EV_VSYNC_ENABLED
, &itv
->i_flags
);
1695 if (test_and_clear_bit(IVTV_F_I_EV_DEC_STOPPED
, &itv
->i_flags
))
1696 ev
->type
= VIDEO_EVENT_DECODER_STOPPED
;
1697 else if (test_and_clear_bit(IVTV_F_I_EV_VSYNC
, &itv
->i_flags
)) {
1698 ev
->type
= VIDEO_EVENT_VSYNC
;
1699 ev
->u
.vsync_field
= test_bit(IVTV_F_I_EV_VSYNC_FIELD
, &itv
->i_flags
) ?
1700 VIDEO_VSYNC_FIELD_ODD
: VIDEO_VSYNC_FIELD_EVEN
;
1701 if (itv
->output_mode
== OUT_UDMA_YUV
&&
1702 (itv
->yuv_info
.lace_mode
& IVTV_YUV_MODE_MASK
) ==
1703 IVTV_YUV_MODE_PROGRESSIVE
) {
1704 ev
->u
.vsync_field
= VIDEO_VSYNC_FIELD_PROGRESSIVE
;
1711 /* Wait for event. Note that serialize_lock is locked,
1712 so to allow other processes to access the driver while
1713 we are waiting unlock first and later lock again. */
1714 mutex_unlock(&itv
->serialize_lock
);
1715 prepare_to_wait(&itv
->event_waitq
, &wait
, TASK_INTERRUPTIBLE
);
1716 if ((itv
->i_flags
& (IVTV_F_I_EV_DEC_STOPPED
|IVTV_F_I_EV_VSYNC
)) == 0)
1718 finish_wait(&itv
->event_waitq
, &wait
);
1719 mutex_lock(&itv
->serialize_lock
);
1720 if (signal_pending(current
)) {
1721 /* return if a signal was received */
1722 IVTV_DEBUG_INFO("User stopped wait for event\n");
1735 static int ivtv_default(struct file
*file
, void *fh
, int cmd
, void *arg
)
1737 struct ivtv
*itv
= ((struct ivtv_open_id
*)fh
)->itv
;
1740 case VIDIOC_INT_S_AUDIO_ROUTING
: {
1741 struct v4l2_routing
*route
= arg
;
1743 ivtv_i2c_hw(itv
, itv
->card
->hw_audio
, VIDIOC_INT_S_AUDIO_ROUTING
, route
);
1747 case VIDIOC_INT_RESET
: {
1748 u32 val
= *(u32
*)arg
;
1750 if ((val
== 0 && itv
->options
.newi2c
) || (val
& 0x01))
1751 ivtv_reset_ir_gpio(itv
);
1753 itv
->video_dec_func(itv
, cmd
, NULL
);
1763 static int ivtv_serialized_ioctl(struct ivtv
*itv
, struct inode
*inode
, struct file
*filp
,
1764 unsigned int cmd
, unsigned long arg
)
1766 struct ivtv_open_id
*id
= (struct ivtv_open_id
*)filp
->private_data
;
1769 /* Filter dvb ioctls that cannot be handled by the v4l ioctl framework */
1771 case VIDEO_SELECT_SOURCE
:
1772 IVTV_DEBUG_IOCTL("VIDEO_SELECT_SOURCE\n");
1773 if (!(itv
->v4l2_cap
& V4L2_CAP_VIDEO_OUTPUT
))
1775 return ivtv_passthrough_mode(itv
, arg
== VIDEO_SOURCE_DEMUX
);
1777 case AUDIO_SET_MUTE
:
1778 IVTV_DEBUG_IOCTL("AUDIO_SET_MUTE\n");
1779 itv
->speed_mute_audio
= arg
;
1782 case AUDIO_CHANNEL_SELECT
:
1783 IVTV_DEBUG_IOCTL("AUDIO_CHANNEL_SELECT\n");
1784 if (arg
> AUDIO_STEREO_SWAPPED
)
1786 itv
->audio_stereo_mode
= arg
;
1787 ivtv_vapi(itv
, CX2341X_DEC_SET_AUDIO_MODE
, 2, itv
->audio_bilingual_mode
, itv
->audio_stereo_mode
);
1790 case AUDIO_BILINGUAL_CHANNEL_SELECT
:
1791 IVTV_DEBUG_IOCTL("AUDIO_BILINGUAL_CHANNEL_SELECT\n");
1792 if (arg
> AUDIO_STEREO_SWAPPED
)
1794 itv
->audio_bilingual_mode
= arg
;
1795 ivtv_vapi(itv
, CX2341X_DEC_SET_AUDIO_MODE
, 2, itv
->audio_bilingual_mode
, itv
->audio_stereo_mode
);
1798 case IVTV_IOC_DMA_FRAME
:
1800 case VIDEO_GET_FRAME_COUNT
:
1801 case VIDEO_GET_EVENT
:
1805 case VIDEO_CONTINUE
:
1807 case VIDEO_TRY_COMMAND
:
1808 return ivtv_decoder_ioctls(filp
, cmd
, (void *)arg
);
1814 /* check priority */
1818 case VIDIOC_S_INPUT
:
1819 case VIDIOC_S_OUTPUT
:
1820 case VIDIOC_S_TUNER
:
1821 case VIDIOC_S_FREQUENCY
:
1824 case VIDIOC_S_AUDIO
:
1825 case VIDIOC_S_AUDOUT
:
1826 case VIDIOC_S_EXT_CTRLS
:
1828 case VIDIOC_OVERLAY
:
1829 ret
= v4l2_prio_check(&itv
->prio
, &id
->prio
);
1834 if (ivtv_debug
& IVTV_DBGFLG_IOCTL
) {
1835 printk(KERN_INFO
"ivtv%d ioctl: ", itv
->num
);
1836 v4l_printk_ioctl(cmd
);
1840 return video_ioctl2(inode
, filp
, cmd
, arg
);
1843 int ivtv_v4l2_ioctl(struct inode
*inode
, struct file
*filp
, unsigned int cmd
,
1846 struct ivtv_open_id
*id
= (struct ivtv_open_id
*)filp
->private_data
;
1847 struct ivtv
*itv
= id
->itv
;
1850 mutex_lock(&itv
->serialize_lock
);
1851 res
= ivtv_serialized_ioctl(itv
, inode
, filp
, cmd
, arg
);
1852 mutex_unlock(&itv
->serialize_lock
);
1856 void ivtv_set_funcs(struct video_device
*vdev
)
1858 vdev
->vidioc_querycap
= ivtv_querycap
;
1859 vdev
->vidioc_g_priority
= ivtv_g_priority
;
1860 vdev
->vidioc_s_priority
= ivtv_s_priority
;
1861 vdev
->vidioc_s_audio
= ivtv_s_audio
;
1862 vdev
->vidioc_g_audio
= ivtv_g_audio
;
1863 vdev
->vidioc_enumaudio
= ivtv_enumaudio
;
1864 vdev
->vidioc_s_audout
= ivtv_s_audout
;
1865 vdev
->vidioc_g_audout
= ivtv_g_audout
;
1866 vdev
->vidioc_enum_input
= ivtv_enum_input
;
1867 vdev
->vidioc_enum_output
= ivtv_enum_output
;
1868 vdev
->vidioc_enumaudout
= ivtv_enumaudout
;
1869 vdev
->vidioc_cropcap
= ivtv_cropcap
;
1870 vdev
->vidioc_s_crop
= ivtv_s_crop
;
1871 vdev
->vidioc_g_crop
= ivtv_g_crop
;
1872 vdev
->vidioc_g_input
= ivtv_g_input
;
1873 vdev
->vidioc_s_input
= ivtv_s_input
;
1874 vdev
->vidioc_g_output
= ivtv_g_output
;
1875 vdev
->vidioc_s_output
= ivtv_s_output
;
1876 vdev
->vidioc_g_frequency
= ivtv_g_frequency
;
1877 vdev
->vidioc_s_frequency
= ivtv_s_frequency
;
1878 vdev
->vidioc_s_tuner
= ivtv_s_tuner
;
1879 vdev
->vidioc_g_tuner
= ivtv_g_tuner
;
1880 vdev
->vidioc_g_enc_index
= ivtv_g_enc_index
;
1881 vdev
->vidioc_g_fbuf
= ivtv_g_fbuf
;
1882 vdev
->vidioc_s_fbuf
= ivtv_s_fbuf
;
1883 vdev
->vidioc_g_std
= ivtv_g_std
;
1884 vdev
->vidioc_s_std
= ivtv_s_std
;
1885 vdev
->vidioc_overlay
= ivtv_overlay
;
1886 vdev
->vidioc_log_status
= ivtv_log_status
;
1887 vdev
->vidioc_enum_fmt_vid_cap
= ivtv_enum_fmt_vid_cap
;
1888 vdev
->vidioc_encoder_cmd
= ivtv_encoder_cmd
;
1889 vdev
->vidioc_try_encoder_cmd
= ivtv_try_encoder_cmd
;
1890 vdev
->vidioc_enum_fmt_vid_out
= ivtv_enum_fmt_vid_out
;
1891 vdev
->vidioc_g_fmt_vid_cap
= ivtv_g_fmt_vid_cap
;
1892 vdev
->vidioc_g_fmt_vbi_cap
= ivtv_g_fmt_vbi_cap
;
1893 vdev
->vidioc_g_fmt_sliced_vbi_cap
= ivtv_g_fmt_sliced_vbi_cap
;
1894 vdev
->vidioc_g_fmt_vid_out
= ivtv_g_fmt_vid_out
;
1895 vdev
->vidioc_g_fmt_vid_out_overlay
= ivtv_g_fmt_vid_out_overlay
;
1896 vdev
->vidioc_g_fmt_sliced_vbi_out
= ivtv_g_fmt_sliced_vbi_out
;
1897 vdev
->vidioc_s_fmt_vid_cap
= ivtv_s_fmt_vid_cap
;
1898 vdev
->vidioc_s_fmt_vbi_cap
= ivtv_s_fmt_vbi_cap
;
1899 vdev
->vidioc_s_fmt_sliced_vbi_cap
= ivtv_s_fmt_sliced_vbi_cap
;
1900 vdev
->vidioc_s_fmt_vid_out
= ivtv_s_fmt_vid_out
;
1901 vdev
->vidioc_s_fmt_vid_out_overlay
= ivtv_s_fmt_vid_out_overlay
;
1902 vdev
->vidioc_s_fmt_sliced_vbi_out
= ivtv_s_fmt_sliced_vbi_out
;
1903 vdev
->vidioc_try_fmt_vid_cap
= ivtv_try_fmt_vid_cap
;
1904 vdev
->vidioc_try_fmt_vbi_cap
= ivtv_try_fmt_vbi_cap
;
1905 vdev
->vidioc_try_fmt_sliced_vbi_cap
= ivtv_try_fmt_sliced_vbi_cap
;
1906 vdev
->vidioc_try_fmt_vid_out
= ivtv_try_fmt_vid_out
;
1907 vdev
->vidioc_try_fmt_vid_out_overlay
= ivtv_try_fmt_vid_out_overlay
;
1908 vdev
->vidioc_try_fmt_sliced_vbi_out
= ivtv_try_fmt_sliced_vbi_out
;
1909 vdev
->vidioc_g_sliced_vbi_cap
= ivtv_g_sliced_vbi_cap
;
1910 vdev
->vidioc_g_chip_ident
= ivtv_g_chip_ident
;
1911 vdev
->vidioc_g_register
= ivtv_g_register
;
1912 vdev
->vidioc_s_register
= ivtv_s_register
;
1913 vdev
->vidioc_default
= ivtv_default
;
1914 vdev
->vidioc_queryctrl
= ivtv_queryctrl
;
1915 vdev
->vidioc_querymenu
= ivtv_querymenu
;
1916 vdev
->vidioc_g_ctrl
= ivtv_g_ctrl
;
1917 vdev
->vidioc_s_ctrl
= ivtv_s_ctrl
;
1918 vdev
->vidioc_g_ext_ctrls
= ivtv_g_ext_ctrls
;
1919 vdev
->vidioc_s_ext_ctrls
= ivtv_s_ext_ctrls
;
1920 vdev
->vidioc_try_ext_ctrls
= ivtv_try_ext_ctrls
;