FRV: Use generic show_interrupts()
[cris-mirror.git] / drivers / media / video / ivtv / ivtv-controls.c
blobb31ee1bceef82c71bf3b13845bc55a5f481945ba
1 /*
2 ioctl control functions
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-ioctl.h"
23 #include "ivtv-controls.h"
25 static int ivtv_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)
27 struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
29 /* First try to allocate sliced VBI buffers if needed. */
30 if (fmt && itv->vbi.sliced_mpeg_data[0] == NULL) {
31 int i;
33 for (i = 0; i < IVTV_VBI_FRAMES; i++) {
34 /* Yuck, hardcoded. Needs to be a define */
35 itv->vbi.sliced_mpeg_data[i] = kmalloc(2049, GFP_KERNEL);
36 if (itv->vbi.sliced_mpeg_data[i] == NULL) {
37 while (--i >= 0) {
38 kfree(itv->vbi.sliced_mpeg_data[i]);
39 itv->vbi.sliced_mpeg_data[i] = NULL;
41 return -ENOMEM;
46 itv->vbi.insert_mpeg = fmt;
48 if (itv->vbi.insert_mpeg == 0) {
49 return 0;
51 /* Need sliced data for mpeg insertion */
52 if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) {
53 if (itv->is_60hz)
54 itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525;
55 else
56 itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625;
57 ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz);
59 return 0;
62 static int ivtv_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val)
64 struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
65 int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
66 struct v4l2_mbus_framefmt fmt;
68 /* fix videodecoder resolution */
69 fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1);
70 fmt.height = cxhdl->height;
71 fmt.code = V4L2_MBUS_FMT_FIXED;
72 v4l2_subdev_call(itv->sd_video, video, s_mbus_fmt, &fmt);
73 return 0;
76 static int ivtv_s_audio_sampling_freq(struct cx2341x_handler *cxhdl, u32 idx)
78 static const u32 freqs[3] = { 44100, 48000, 32000 };
79 struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
81 /* The audio clock of the digitizer must match the codec sample
82 rate otherwise you get some very strange effects. */
83 if (idx < ARRAY_SIZE(freqs))
84 ivtv_call_all(itv, audio, s_clock_freq, freqs[idx]);
85 return 0;
88 static int ivtv_s_audio_mode(struct cx2341x_handler *cxhdl, u32 val)
90 struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
92 itv->dualwatch_stereo_mode = val;
93 return 0;
96 struct cx2341x_handler_ops ivtv_cxhdl_ops = {
97 .s_audio_mode = ivtv_s_audio_mode,
98 .s_audio_sampling_freq = ivtv_s_audio_sampling_freq,
99 .s_video_encoding = ivtv_s_video_encoding,
100 .s_stream_vbi_fmt = ivtv_s_stream_vbi_fmt,