allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / drivers / media / video / ivtv / ivtv-video.c
blob5858b197d51050181fedc4eca72087e210ad79d9
1 /*
2 saa7127 interface functions
3 Copyright (C) 2004-2007 Hans Verkuil <hverkuil@xs4all.nl>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "ivtv-driver.h"
21 #include "ivtv-video.h"
22 #include "ivtv-i2c.h"
23 #include "ivtv-gpio.h"
24 #include "ivtv-cards.h"
25 #include <media/upd64031a.h>
26 #include <media/upd64083.h>
28 void ivtv_set_vps(struct ivtv *itv, int enabled, u8 vps1, u8 vps2, u8 vps3,
29 u8 vps4, u8 vps5)
31 struct v4l2_sliced_vbi_data data;
33 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
34 return;
35 data.id = V4L2_SLICED_VPS;
36 data.field = 0;
37 data.line = enabled ? 16 : 0;
38 data.data[4] = vps1;
39 data.data[10] = vps2;
40 data.data[11] = vps3;
41 data.data[12] = vps4;
42 data.data[13] = vps5;
43 ivtv_saa7127(itv, VIDIOC_INT_S_VBI_DATA, &data);
46 void ivtv_set_cc(struct ivtv *itv, int mode, u8 cc1, u8 cc2, u8 cc3, u8 cc4)
48 struct v4l2_sliced_vbi_data data;
50 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
51 return;
52 data.id = V4L2_SLICED_CAPTION_525;
53 data.field = 0;
54 data.line = (mode & 1) ? 21 : 0;
55 data.data[0] = cc1;
56 data.data[1] = cc2;
57 ivtv_saa7127(itv, VIDIOC_INT_S_VBI_DATA, &data);
58 data.field = 1;
59 data.line = (mode & 2) ? 21 : 0;
60 data.data[0] = cc3;
61 data.data[1] = cc4;
62 ivtv_saa7127(itv, VIDIOC_INT_S_VBI_DATA, &data);
65 void ivtv_set_wss(struct ivtv *itv, int enabled, int mode)
67 struct v4l2_sliced_vbi_data data;
69 if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT))
70 return;
71 /* When using a 50 Hz system, always turn on the
72 wide screen signal with 4x3 ratio as the default.
73 Turning this signal on and off can confuse certain
74 TVs. As far as I can tell there is no reason not to
75 transmit this signal. */
76 if ((itv->std & V4L2_STD_625_50) && !enabled) {
77 enabled = 1;
78 mode = 0x08; /* 4x3 full format */
80 data.id = V4L2_SLICED_WSS_625;
81 data.field = 0;
82 data.line = enabled ? 23 : 0;
83 data.data[0] = mode & 0xff;
84 data.data[1] = (mode >> 8) & 0xff;
85 ivtv_saa7127(itv, VIDIOC_INT_S_VBI_DATA, &data);
88 void ivtv_video_set_io(struct ivtv *itv)
90 struct v4l2_routing route;
91 int inp = itv->active_input;
92 u32 type;
94 route.input = itv->card->video_inputs[inp].video_input;
95 route.output = 0;
96 itv->video_dec_func(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
98 type = itv->card->video_inputs[inp].video_type;
100 if (type == IVTV_CARD_INPUT_VID_TUNER) {
101 route.input = 0; /* Tuner */
102 } else if (type < IVTV_CARD_INPUT_COMPOSITE1) {
103 route.input = 2; /* S-Video */
104 } else {
105 route.input = 1; /* Composite */
108 if (itv->card->hw_video & IVTV_HW_GPIO)
109 ivtv_gpio(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
111 if (itv->card->hw_video & IVTV_HW_UPD64031A) {
112 if (type == IVTV_CARD_INPUT_VID_TUNER ||
113 type >= IVTV_CARD_INPUT_COMPOSITE1) {
114 /* Composite: GR on, connect to 3DYCS */
115 route.input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE;
116 } else {
117 /* S-Video: GR bypassed, turn it off */
118 route.input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE;
120 route.input |= itv->card->gr_config;
122 ivtv_upd64031a(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
125 if (itv->card->hw_video & IVTV_HW_UPD6408X) {
126 route.input = UPD64083_YCS_MODE;
127 if (type > IVTV_CARD_INPUT_VID_TUNER &&
128 type < IVTV_CARD_INPUT_COMPOSITE1) {
129 /* S-Video uses YCNR mode and internal Y-ADC, the upd64031a
130 is not used. */
131 route.input |= UPD64083_YCNR_MODE;
133 else if (itv->card->hw_video & IVTV_HW_UPD64031A) {
134 /* Use upd64031a output for tuner and composite(CX23416GYC only) inputs */
135 if ((type == IVTV_CARD_INPUT_VID_TUNER)||
136 (itv->card->type == IVTV_CARD_CX23416GYC)) {
137 route.input |= UPD64083_EXT_Y_ADC;
140 ivtv_upd64083(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);