]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/media/video/ivtv/ivtv-controls.c
x86: Resume trampoline must be executable
[mirror_ubuntu-artful-kernel.git] / drivers / media / video / ivtv / ivtv-controls.c
CommitLineData
1a0adaf3
HV
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>
5
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.
10
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.
15
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
19 */
20
21#include "ivtv-driver.h"
1a0adaf3 22#include "ivtv-ioctl.h"
1a0adaf3
HV
23#include "ivtv-controls.h"
24
f7b80e69 25static int ivtv_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)
1a0adaf3 26{
f7b80e69 27 struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
1a0adaf3
HV
28
29 /* First try to allocate sliced VBI buffers if needed. */
30 if (fmt && itv->vbi.sliced_mpeg_data[0] == NULL) {
31 int i;
32
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;
40 }
41 return -ENOMEM;
42 }
43 }
44 }
45
46 itv->vbi.insert_mpeg = fmt;
47
48 if (itv->vbi.insert_mpeg == 0) {
49 return 0;
50 }
51 /* Need sliced data for mpeg insertion */
feb5bce2 52 if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) {
1a0adaf3
HV
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;
feb5bce2 57 ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz);
1a0adaf3
HV
58 }
59 return 0;
60}
61
f7b80e69 62static int ivtv_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val)
1a0adaf3 63{
f7b80e69
HV
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;
67
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;
3f038d80 74}
1a0adaf3 75
f7b80e69 76static int ivtv_s_audio_sampling_freq(struct cx2341x_handler *cxhdl, u32 idx)
3f038d80 77{
f7b80e69
HV
78 static const u32 freqs[3] = { 44100, 48000, 32000 };
79 struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
1a0adaf3 80
f7b80e69
HV
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;
3f038d80 86}
1a0adaf3 87
f7b80e69 88static int ivtv_s_audio_mode(struct cx2341x_handler *cxhdl, u32 val)
3f038d80 89{
f7b80e69 90 struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
3f038d80 91
f7b80e69
HV
92 itv->dualwatch_stereo_mode = val;
93 return 0;
1a0adaf3 94}
f7b80e69
HV
95
96struct 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,
101};