aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-04-02 10:26:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-04-06 20:44:27 -0400
commit5325b4272a53b43f55b82cc369c310c2fcacdca1 (patch)
treef2a1491de3d05901152e0e271c0cb5ce381884c2 /drivers/media/video
parentc0ff29150d37615ac703802ab3edc775fd402491 (diff)
V4L/DVB (11380): v4l2-subdev: change s_routing prototype
It is no longer needed to use a struct pointer as argument, since v4l2_subdev doesn't require that ioctl-like approach anymore. Instead just pass the input, output and config (new!) arguments directly. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/adv7170.c19
-rw-r--r--drivers/media/video/adv7175.c17
-rw-r--r--drivers/media/video/au0828/au0828-video.c10
-rw-r--r--drivers/media/video/bt819.c11
-rw-r--r--drivers/media/video/bt856.c11
-rw-r--r--drivers/media/video/bt866.c11
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c23
-rw-r--r--drivers/media/video/cs5345.c11
-rw-r--r--drivers/media/video/cs53l32a.c9
-rw-r--r--drivers/media/video/cx18/cx18-audio.c9
-rw-r--r--drivers/media/video/cx18/cx18-av-core.c8
-rw-r--r--drivers/media/video/cx18/cx18-gpio.c4
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c2
-rw-r--r--drivers/media/video/cx18/cx18-video.c16
-rw-r--r--drivers/media/video/cx231xx/cx231xx-cards.c5
-rw-r--r--drivers/media/video/cx231xx/cx231xx-video.c7
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c8
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c10
-rw-r--r--drivers/media/video/cx88/cx88-video.c12
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c11
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c19
-rw-r--r--drivers/media/video/ivtv/ivtv-gpio.c16
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c10
-rw-r--r--drivers/media/video/ivtv/ivtv-routing.c66
-rw-r--r--drivers/media/video/ks0127.c17
-rw-r--r--drivers/media/video/m52790.c7
-rw-r--r--drivers/media/video/msp3400-driver.c25
-rw-r--r--drivers/media/video/msp3400-driver.h3
-rw-r--r--drivers/media/video/msp3400-kthreads.c6
-rw-r--r--drivers/media/video/mxb.c115
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-audio.c8
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c7
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c9
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-video-v4l.c8
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-wm8775.c12
-rw-r--r--drivers/media/video/saa7110.c13
-rw-r--r--drivers/media/video/saa7115.c30
-rw-r--r--drivers/media/video/saa7127.c11
-rw-r--r--drivers/media/video/saa717x.c23
-rw-r--r--drivers/media/video/saa7185.c9
-rw-r--r--drivers/media/video/saa7191.c6
-rw-r--r--drivers/media/video/tea6415c.c5
-rw-r--r--drivers/media/video/tea6420.c17
-rw-r--r--drivers/media/video/tvaudio.c7
-rw-r--r--drivers/media/video/tvp5150.c21
-rw-r--r--drivers/media/video/upd64031a.c11
-rw-r--r--drivers/media/video/upd64083.c9
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c5
-rw-r--r--drivers/media/video/vino.c10
-rw-r--r--drivers/media/video/vpx3220.c19
-rw-r--r--drivers/media/video/wm8775.c9
-rw-r--r--drivers/media/video/zoran/zoran_card.c4
-rw-r--r--drivers/media/video/zoran/zoran_device.c20
-rw-r--r--drivers/media/video/zoran/zoran_driver.c20
54 files changed, 358 insertions, 433 deletions
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 873c30a41bd7..97b003449c91 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -219,18 +219,19 @@ static int adv7170_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
219 return 0; 219 return 0;
220} 220}
221 221
222static int adv7170_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 222static int adv7170_s_routing(struct v4l2_subdev *sd,
223 u32 input, u32 output, u32 config)
223{ 224{
224 struct adv7170 *encoder = to_adv7170(sd); 225 struct adv7170 *encoder = to_adv7170(sd);
225 226
226 /* RJ: route->input = 0: input is from decoder 227 /* RJ: input = 0: input is from decoder
227 route->input = 1: input is from ZR36060 228 input = 1: input is from ZR36060
228 route->input = 2: color bar */ 229 input = 2: color bar */
229 230
230 v4l2_dbg(1, debug, sd, "set input from %s\n", 231 v4l2_dbg(1, debug, sd, "set input from %s\n",
231 route->input == 0 ? "decoder" : "ZR36060"); 232 input == 0 ? "decoder" : "ZR36060");
232 233
233 switch (route->input) { 234 switch (input) {
234 case 0: 235 case 0:
235 adv7170_write(sd, 0x01, 0x20); 236 adv7170_write(sd, 0x01, 0x20);
236 adv7170_write(sd, 0x08, TR1CAPT); /* TR1 */ 237 adv7170_write(sd, 0x08, TR1CAPT); /* TR1 */
@@ -250,11 +251,11 @@ static int adv7170_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *
250 break; 251 break;
251 252
252 default: 253 default:
253 v4l2_dbg(1, debug, sd, "illegal input: %d\n", route->input); 254 v4l2_dbg(1, debug, sd, "illegal input: %d\n", input);
254 return -EINVAL; 255 return -EINVAL;
255 } 256 }
256 v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[route->input]); 257 v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[input]);
257 encoder->input = route->input; 258 encoder->input = input;
258 return 0; 259 return 0;
259} 260}
260 261
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index ff1210303295..cf8c06c85ded 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -237,15 +237,16 @@ static int adv7175_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
237 return 0; 237 return 0;
238} 238}
239 239
240static int adv7175_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 240static int adv7175_s_routing(struct v4l2_subdev *sd,
241 u32 input, u32 output, u32 config)
241{ 242{
242 struct adv7175 *encoder = to_adv7175(sd); 243 struct adv7175 *encoder = to_adv7175(sd);
243 244
244 /* RJ: route->input = 0: input is from decoder 245 /* RJ: input = 0: input is from decoder
245 route->input = 1: input is from ZR36060 246 input = 1: input is from ZR36060
246 route->input = 2: color bar */ 247 input = 2: color bar */
247 248
248 switch (route->input) { 249 switch (input) {
249 case 0: 250 case 0:
250 adv7175_write(sd, 0x01, 0x00); 251 adv7175_write(sd, 0x01, 0x00);
251 252
@@ -288,11 +289,11 @@ static int adv7175_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *
288 break; 289 break;
289 290
290 default: 291 default:
291 v4l2_dbg(1, debug, sd, "illegal input: %d\n", route->input); 292 v4l2_dbg(1, debug, sd, "illegal input: %d\n", input);
292 return -EINVAL; 293 return -EINVAL;
293 } 294 }
294 v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[route->input]); 295 v4l2_dbg(1, debug, sd, "switched to %s\n", inputs[input]);
295 encoder->input = route->input; 296 encoder->input = input;
296 return 0; 297 return 0;
297} 298}
298 299
diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c
index 19b23f21f968..27bedc6c7791 100644
--- a/drivers/media/video/au0828/au0828-video.c
+++ b/drivers/media/video/au0828/au0828-video.c
@@ -1154,7 +1154,6 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index)
1154 struct au0828_fh *fh = priv; 1154 struct au0828_fh *fh = priv;
1155 struct au0828_dev *dev = fh->dev; 1155 struct au0828_dev *dev = fh->dev;
1156 int i; 1156 int i;
1157 struct v4l2_routing route;
1158 1157
1159 dprintk(1, "VIDIOC_S_INPUT in function %s, input=%d\n", __func__, 1158 dprintk(1, "VIDIOC_S_INPUT in function %s, input=%d\n", __func__,
1160 index); 1159 index);
@@ -1180,9 +1179,8 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index)
1180 break; 1179 break;
1181 } 1180 }
1182 1181
1183 route.input = AUVI_INPUT(index).vmux; 1182 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing,
1184 route.output = 0; 1183 AUVI_INPUT(index).vmux, 0, 0);
1185 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, &route);
1186 1184
1187 for (i = 0; i < AU0828_MAX_INPUT; i++) { 1185 for (i = 0; i < AU0828_MAX_INPUT; i++) {
1188 int enable = 0; 1186 int enable = 0;
@@ -1205,8 +1203,8 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index)
1205 } 1203 }
1206 } 1204 }
1207 1205
1208 route.input = AUVI_INPUT(index).amux; 1206 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing,
1209 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, &route); 1207 AUVI_INPUT(index).amux, 0, 0);
1210 return 0; 1208 return 0;
1211} 1209}
1212 1210
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 9f84032ce38c..f9330e3529c3 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -292,21 +292,22 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
292 return 0; 292 return 0;
293} 293}
294 294
295static int bt819_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 295static int bt819_s_routing(struct v4l2_subdev *sd,
296 u32 input, u32 output, u32 config)
296{ 297{
297 struct bt819 *decoder = to_bt819(sd); 298 struct bt819 *decoder = to_bt819(sd);
298 299
299 v4l2_dbg(1, debug, sd, "set input %x\n", route->input); 300 v4l2_dbg(1, debug, sd, "set input %x\n", input);
300 301
301 if (route->input < 0 || route->input > 7) 302 if (input < 0 || input > 7)
302 return -EINVAL; 303 return -EINVAL;
303 304
304 if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL) 305 if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL)
305 v4l2_err(sd, "no notify found!\n"); 306 v4l2_err(sd, "no notify found!\n");
306 307
307 if (decoder->input != route->input) { 308 if (decoder->input != input) {
308 v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0); 309 v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0);
309 decoder->input = route->input; 310 decoder->input = input;
310 /* select mode */ 311 /* select mode */
311 if (decoder->input == 0) { 312 if (decoder->input == 0) {
312 bt819_setbit(decoder, 0x0b, 6, 0); 313 bt819_setbit(decoder, 0x0b, 6, 0);
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 78db39503947..d0b4d4925ff8 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -142,16 +142,17 @@ static int bt856_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
142 return 0; 142 return 0;
143} 143}
144 144
145static int bt856_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 145static int bt856_s_routing(struct v4l2_subdev *sd,
146 u32 input, u32 output, u32 config)
146{ 147{
147 struct bt856 *encoder = to_bt856(sd); 148 struct bt856 *encoder = to_bt856(sd);
148 149
149 v4l2_dbg(1, debug, sd, "set input %d\n", route->input); 150 v4l2_dbg(1, debug, sd, "set input %d\n", input);
150 151
151 /* We only have video bus. 152 /* We only have video bus.
152 * route->input= 0: input is from bt819 153 * input= 0: input is from bt819
153 * route->input= 1: input is from ZR36060 */ 154 * input= 1: input is from ZR36060 */
154 switch (route->input) { 155 switch (input) {
155 case 0: 156 case 0:
156 bt856_setbit(encoder, 0xde, 4, 0); 157 bt856_setbit(encoder, 0xde, 4, 0);
157 bt856_setbit(encoder, 0xde, 3, 1); 158 bt856_setbit(encoder, 0xde, 3, 1);
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c
index 350cae4b02c3..af7e3a5bac9f 100644
--- a/drivers/media/video/bt866.c
+++ b/drivers/media/video/bt866.c
@@ -99,7 +99,8 @@ static int bt866_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
99 return 0; 99 return 0;
100} 100}
101 101
102static int bt866_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 102static int bt866_s_routing(struct v4l2_subdev *sd,
103 u32 input, u32 output, u32 config)
103{ 104{
104 static const __u8 init[] = { 105 static const __u8 init[] = {
105 0xc8, 0xcc, /* CRSCALE */ 106 0xc8, 0xcc, /* CRSCALE */
@@ -137,7 +138,7 @@ static int bt866_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *ro
137 138
138 val = encoder->reg[0xdc]; 139 val = encoder->reg[0xdc];
139 140
140 if (route->input == 0) 141 if (input == 0)
141 val |= 0x40; /* CBSWAP */ 142 val |= 0x40; /* CBSWAP */
142 else 143 else
143 val &= ~0x40; /* !CBSWAP */ 144 val &= ~0x40; /* !CBSWAP */
@@ -145,15 +146,15 @@ static int bt866_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *ro
145 bt866_write(encoder, 0xdc, val); 146 bt866_write(encoder, 0xdc, val);
146 147
147 val = encoder->reg[0xcc]; 148 val = encoder->reg[0xcc];
148 if (route->input == 2) 149 if (input == 2)
149 val |= 0x01; /* OSDBAR */ 150 val |= 0x01; /* OSDBAR */
150 else 151 else
151 val &= ~0x01; /* !OSDBAR */ 152 val &= ~0x01; /* !OSDBAR */
152 bt866_write(encoder, 0xcc, val); 153 bt866_write(encoder, 0xcc, val);
153 154
154 v4l2_dbg(1, debug, sd, "set input %d\n", route->input); 155 v4l2_dbg(1, debug, sd, "set input %d\n", input);
155 156
156 switch (route->input) { 157 switch (input) {
157 case 0: 158 case 0:
158 case 1: 159 case 1:
159 case 2: 160 case 2:
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 41c31eabe261..74f619d6cc93 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -1198,7 +1198,7 @@ audio_mux(struct bttv *btv, int input, int mute)
1198 ctrl.value = btv->mute; 1198 ctrl.value = btv->mute;
1199 bttv_call_all(btv, core, s_ctrl, &ctrl); 1199 bttv_call_all(btv, core, s_ctrl, &ctrl);
1200 if (btv->sd_msp34xx) { 1200 if (btv->sd_msp34xx) {
1201 struct v4l2_routing route; 1201 u32 in;
1202 1202
1203 /* Note: the inputs tuner/radio/extern/intern are translated 1203 /* Note: the inputs tuner/radio/extern/intern are translated
1204 to msp routings. This assumes common behavior for all msp3400 1204 to msp routings. This assumes common behavior for all msp3400
@@ -1207,11 +1207,11 @@ audio_mux(struct bttv *btv, int input, int mute)
1207 For now this is sufficient. */ 1207 For now this is sufficient. */
1208 switch (input) { 1208 switch (input) {
1209 case TVAUDIO_INPUT_RADIO: 1209 case TVAUDIO_INPUT_RADIO:
1210 route.input = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, 1210 in = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1,
1211 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); 1211 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
1212 break; 1212 break;
1213 case TVAUDIO_INPUT_EXTERN: 1213 case TVAUDIO_INPUT_EXTERN:
1214 route.input = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, 1214 in = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
1215 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); 1215 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
1216 break; 1216 break;
1217 case TVAUDIO_INPUT_INTERN: 1217 case TVAUDIO_INPUT_INTERN:
@@ -1220,7 +1220,7 @@ audio_mux(struct bttv *btv, int input, int mute)
1220 input is the BTTV_BOARD_AVERMEDIA98. I wonder how 1220 input is the BTTV_BOARD_AVERMEDIA98. I wonder how
1221 that was tested. My guess is that the whole INTERN 1221 that was tested. My guess is that the whole INTERN
1222 input does not work. */ 1222 input does not work. */
1223 route.input = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, 1223 in = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1,
1224 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); 1224 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART);
1225 break; 1225 break;
1226 case TVAUDIO_INPUT_TUNER: 1226 case TVAUDIO_INPUT_TUNER:
@@ -1229,21 +1229,18 @@ audio_mux(struct bttv *btv, int input, int mute)
1229 is the only difference between the VOODOOTV_FM 1229 is the only difference between the VOODOOTV_FM
1230 and VOODOOTV_200 */ 1230 and VOODOOTV_200 */
1231 if (btv->c.type == BTTV_BOARD_VOODOOTV_200) 1231 if (btv->c.type == BTTV_BOARD_VOODOOTV_200)
1232 route.input = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER2, \ 1232 in = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER2, \
1233 MSP_DSP_IN_TUNER, MSP_DSP_IN_TUNER); 1233 MSP_DSP_IN_TUNER, MSP_DSP_IN_TUNER);
1234 else 1234 else
1235 route.input = MSP_INPUT_DEFAULT; 1235 in = MSP_INPUT_DEFAULT;
1236 break; 1236 break;
1237 } 1237 }
1238 route.output = MSP_OUTPUT_DEFAULT; 1238 v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing,
1239 v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, &route); 1239 in, MSP_OUTPUT_DEFAULT, 0);
1240 } 1240 }
1241 if (btv->sd_tvaudio) { 1241 if (btv->sd_tvaudio) {
1242 struct v4l2_routing route; 1242 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing,
1243 1243 input, 0, 0);
1244 route.input = input;
1245 route.output = 0;
1246 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, &route);
1247 } 1244 }
1248 return 0; 1245 return 0;
1249} 1246}
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c
index 9714059ee949..57dc1704b6c0 100644
--- a/drivers/media/video/cs5345.c
+++ b/drivers/media/video/cs5345.c
@@ -53,14 +53,15 @@ static inline int cs5345_read(struct v4l2_subdev *sd, u8 reg)
53 return i2c_smbus_read_byte_data(client, reg); 53 return i2c_smbus_read_byte_data(client, reg);
54} 54}
55 55
56static int cs5345_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 56static int cs5345_s_routing(struct v4l2_subdev *sd,
57 u32 input, u32 output, u32 config)
57{ 58{
58 if ((route->input & 0xf) > 6) { 59 if ((input & 0xf) > 6) {
59 v4l2_err(sd, "Invalid input %d.\n", route->input); 60 v4l2_err(sd, "Invalid input %d.\n", input);
60 return -EINVAL; 61 return -EINVAL;
61 } 62 }
62 cs5345_write(sd, 0x09, route->input & 0xf); 63 cs5345_write(sd, 0x09, input & 0xf);
63 cs5345_write(sd, 0x05, route->input & 0xf0); 64 cs5345_write(sd, 0x05, input & 0xf0);
64 return 0; 65 return 0;
65} 66}
66 67
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 5aeb066857a7..80bca8df9fbf 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -58,17 +58,18 @@ static int cs53l32a_read(struct v4l2_subdev *sd, u8 reg)
58 return i2c_smbus_read_byte_data(client, reg); 58 return i2c_smbus_read_byte_data(client, reg);
59} 59}
60 60
61static int cs53l32a_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 61static int cs53l32a_s_routing(struct v4l2_subdev *sd,
62 u32 input, u32 output, u32 config)
62{ 63{
63 /* There are 2 physical inputs, but the second input can be 64 /* There are 2 physical inputs, but the second input can be
64 placed in two modes, the first mode bypasses the PGA (gain), 65 placed in two modes, the first mode bypasses the PGA (gain),
65 the second goes through the PGA. Hence there are three 66 the second goes through the PGA. Hence there are three
66 possible inputs to choose from. */ 67 possible inputs to choose from. */
67 if (route->input > 2) { 68 if (input > 2) {
68 v4l2_err(sd, "Invalid input %d.\n", route->input); 69 v4l2_err(sd, "Invalid input %d.\n", input);
69 return -EINVAL; 70 return -EINVAL;
70 } 71 }
71 cs53l32a_write(sd, 0x01, 0x01 + (route->input << 4)); 72 cs53l32a_write(sd, 0x01, 0x01 + (input << 4));
72 return 0; 73 return 0;
73} 74}
74 75
diff --git a/drivers/media/video/cx18/cx18-audio.c b/drivers/media/video/cx18/cx18-audio.c
index bb5c5165dd5f..1519e91c677a 100644
--- a/drivers/media/video/cx18/cx18-audio.c
+++ b/drivers/media/video/cx18/cx18-audio.c
@@ -33,7 +33,6 @@
33int cx18_audio_set_io(struct cx18 *cx) 33int cx18_audio_set_io(struct cx18 *cx)
34{ 34{
35 const struct cx18_card_audio_input *in; 35 const struct cx18_card_audio_input *in;
36 struct v4l2_routing route;
37 u32 val; 36 u32 val;
38 int err; 37 int err;
39 38
@@ -44,13 +43,11 @@ int cx18_audio_set_io(struct cx18 *cx)
44 in = &cx->card->audio_inputs[cx->audio_input]; 43 in = &cx->card->audio_inputs[cx->audio_input];
45 44
46 /* handle muxer chips */ 45 /* handle muxer chips */
47 route.input = in->muxer_input; 46 v4l2_subdev_call(cx->sd_extmux, audio, s_routing,
48 route.output = 0; 47 in->audio_input, 0, 0);
49 v4l2_subdev_call(cx->sd_extmux, audio, s_routing, &route);
50 48
51 route.input = in->audio_input;
52 err = cx18_call_hw_err(cx, cx->card->hw_audio_ctrl, 49 err = cx18_call_hw_err(cx, cx->card->hw_audio_ctrl,
53 audio, s_routing, &route); 50 audio, s_routing, in->audio_input, 0, 0);
54 if (err) 51 if (err)
55 return err; 52 return err;
56 53
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c
index 9b3e574dd829..cf2bd888a429 100644
--- a/drivers/media/video/cx18/cx18-av-core.c
+++ b/drivers/media/video/cx18/cx18-av-core.c
@@ -547,19 +547,19 @@ static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input,
547} 547}
548 548
549static int cx18_av_s_video_routing(struct v4l2_subdev *sd, 549static int cx18_av_s_video_routing(struct v4l2_subdev *sd,
550 const struct v4l2_routing *route) 550 u32 input, u32 output, u32 config)
551{ 551{
552 struct cx18_av_state *state = to_cx18_av_state(sd); 552 struct cx18_av_state *state = to_cx18_av_state(sd);
553 struct cx18 *cx = v4l2_get_subdevdata(sd); 553 struct cx18 *cx = v4l2_get_subdevdata(sd);
554 return set_input(cx, route->input, state->aud_input); 554 return set_input(cx, input, state->aud_input);
555} 555}
556 556
557static int cx18_av_s_audio_routing(struct v4l2_subdev *sd, 557static int cx18_av_s_audio_routing(struct v4l2_subdev *sd,
558 const struct v4l2_routing *route) 558 u32 input, u32 output, u32 config)
559{ 559{
560 struct cx18_av_state *state = to_cx18_av_state(sd); 560 struct cx18_av_state *state = to_cx18_av_state(sd);
561 struct cx18 *cx = v4l2_get_subdevdata(sd); 561 struct cx18 *cx = v4l2_get_subdevdata(sd);
562 return set_input(cx, state->vid_input, route->input); 562 return set_input(cx, state->vid_input, input);
563} 563}
564 564
565static int cx18_av_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) 565static int cx18_av_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c
index ae2460e6860a..86a204b5448e 100644
--- a/drivers/media/video/cx18/cx18-gpio.c
+++ b/drivers/media/video/cx18/cx18-gpio.c
@@ -156,12 +156,12 @@ static int gpiomux_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
156} 156}
157 157
158static int gpiomux_s_audio_routing(struct v4l2_subdev *sd, 158static int gpiomux_s_audio_routing(struct v4l2_subdev *sd,
159 const struct v4l2_routing *route) 159 u32 input, u32 output, u32 config)
160{ 160{
161 struct cx18 *cx = v4l2_get_subdevdata(sd); 161 struct cx18 *cx = v4l2_get_subdevdata(sd);
162 u32 data; 162 u32 data;
163 163
164 switch (route->input) { 164 switch (input) {
165 case 0: 165 case 0:
166 data = cx->card->gpio_audio_input.tuner; 166 data = cx->card->gpio_audio_input.tuner;
167 break; 167 break;
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index f572080590fb..cdefd90d5eca 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -932,7 +932,7 @@ static long cx18_default(struct file *file, void *fh, int cmd, void *arg)
932 CX18_DEBUG_IOCTL("VIDIOC_INT_S_AUDIO_ROUTING(%d, %d)\n", 932 CX18_DEBUG_IOCTL("VIDIOC_INT_S_AUDIO_ROUTING(%d, %d)\n",
933 route->input, route->output); 933 route->input, route->output);
934 cx18_call_hw(cx, cx->card->hw_audio_ctrl, audio, s_routing, 934 cx18_call_hw(cx, cx->card->hw_audio_ctrl, audio, s_routing,
935 route); 935 route->input, route->output, 0);
936 break; 936 break;
937 } 937 }
938 938
diff --git a/drivers/media/video/cx18/cx18-video.c b/drivers/media/video/cx18/cx18-video.c
index 6fdadedf17a8..6dc84aac8f44 100644
--- a/drivers/media/video/cx18/cx18-video.c
+++ b/drivers/media/video/cx18/cx18-video.c
@@ -25,20 +25,8 @@
25 25
26void cx18_video_set_io(struct cx18 *cx) 26void cx18_video_set_io(struct cx18 *cx)
27{ 27{
28 struct v4l2_routing route;
29 int inp = cx->active_input; 28 int inp = cx->active_input;
30 u32 type;
31 29
32 route.input = cx->card->video_inputs[inp].video_input; 30 v4l2_subdev_call(cx->sd_av, video, s_routing,
33 route.output = 0; 31 cx->card->video_inputs[inp].video_input, 0, 0);
34 v4l2_subdev_call(cx->sd_av, video, s_routing, &route);
35
36 type = cx->card->video_inputs[inp].video_type;
37
38 if (type == CX18_CARD_INPUT_VID_TUNER)
39 route.input = 0; /* Tuner */
40 else if (type < CX18_CARD_INPUT_COMPOSITE1)
41 route.input = 2; /* S-Video */
42 else
43 route.input = 1; /* Composite */
44} 32}
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c
index f209fe14f829..c8a32b1b5381 100644
--- a/drivers/media/video/cx231xx/cx231xx-cards.c
+++ b/drivers/media/video/cx231xx/cx231xx-cards.c
@@ -357,10 +357,7 @@ int cx231xx_config(struct cx231xx *dev)
357 */ 357 */
358void cx231xx_config_i2c(struct cx231xx *dev) 358void cx231xx_config_i2c(struct cx231xx *dev)
359{ 359{
360 struct v4l2_routing route; 360 /* u32 input = INPUT(dev->video_input)->vmux; */
361
362 route.input = INPUT(dev->video_input)->vmux;
363 route.output = 0;
364 361
365 call_all(dev, video, s_stream, 1); 362 call_all(dev, video, s_stream, 1);
366} 363}
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c
index 0645703e6f9c..a23ae73fe634 100644
--- a/drivers/media/video/cx231xx/cx231xx-video.c
+++ b/drivers/media/video/cx231xx/cx231xx-video.c
@@ -820,17 +820,12 @@ static struct videobuf_queue_ops cx231xx_video_qops = {
820 820
821void video_mux(struct cx231xx *dev, int index) 821void video_mux(struct cx231xx *dev, int index)
822{ 822{
823
824 struct v4l2_routing route;
825
826 route.input = INPUT(index)->vmux;
827 route.output = 0;
828 dev->video_input = index; 823 dev->video_input = index;
829 dev->ctl_ainput = INPUT(index)->amux; 824 dev->ctl_ainput = INPUT(index)->amux;
830 825
831 cx231xx_set_video_input_mux(dev, index); 826 cx231xx_set_video_input_mux(dev, index);
832 827
833 cx25840_call(dev, video, s_routing, &route); 828 cx25840_call(dev, video, s_routing, INPUT(index)->vmux, 0, 0);
834 829
835 cx231xx_set_audio_input(dev, dev->ctl_ainput); 830 cx231xx_set_audio_input(dev, dev->ctl_ainput);
836 831
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index ce7b3f8cdc65..68068c6d0987 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -393,9 +393,6 @@ static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh,
393 393
394static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input) 394static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
395{ 395{
396 struct v4l2_routing route;
397 memset(&route, 0, sizeof(route));
398
399 dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", 396 dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n",
400 __func__, 397 __func__,
401 input, INPUT(input)->vmux, 398 input, INPUT(input)->vmux,
@@ -403,10 +400,9 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
403 INPUT(input)->gpio2, INPUT(input)->gpio3); 400 INPUT(input)->gpio2, INPUT(input)->gpio3);
404 dev->input = input; 401 dev->input = input;
405 402
406 route.input = INPUT(input)->vmux;
407
408 /* Tell the internal A/V decoder */ 403 /* Tell the internal A/V decoder */
409 v4l2_subdev_call(dev->sd_cx25840, video, s_routing, &route); 404 v4l2_subdev_call(dev->sd_cx25840, video, s_routing,
405 INPUT(input)->vmux, 0, 0);
410 406
411 return 0; 407 return 0;
412} 408}
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 62090279f46f..0be51b65f098 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -1322,22 +1322,24 @@ static int cx25840_s_radio(struct v4l2_subdev *sd)
1322 return 0; 1322 return 0;
1323} 1323}
1324 1324
1325static int cx25840_s_video_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 1325static int cx25840_s_video_routing(struct v4l2_subdev *sd,
1326 u32 input, u32 output, u32 config)
1326{ 1327{
1327 struct cx25840_state *state = to_state(sd); 1328 struct cx25840_state *state = to_state(sd);
1328 struct i2c_client *client = v4l2_get_subdevdata(sd); 1329 struct i2c_client *client = v4l2_get_subdevdata(sd);
1329 1330
1330 return set_input(client, route->input, state->aud_input); 1331 return set_input(client, input, state->aud_input);
1331} 1332}
1332 1333
1333static int cx25840_s_audio_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 1334static int cx25840_s_audio_routing(struct v4l2_subdev *sd,
1335 u32 input, u32 output, u32 config)
1334{ 1336{
1335 struct cx25840_state *state = to_state(sd); 1337 struct cx25840_state *state = to_state(sd);
1336 struct i2c_client *client = v4l2_get_subdevdata(sd); 1338 struct i2c_client *client = v4l2_get_subdevdata(sd);
1337 1339
1338 if (state->is_cx25836) 1340 if (state->is_cx25836)
1339 return -EINVAL; 1341 return -EINVAL;
1340 return set_input(client, state->vid_input, route->input); 1342 return set_input(client, state->vid_input, input);
1341} 1343}
1342 1344
1343static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq) 1345static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *freq)
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 61afa89f7b11..ec0425d9043a 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -428,10 +428,8 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
428 routes for different inputs. HVR-1300 surely does */ 428 routes for different inputs. HVR-1300 surely does */
429 if (core->board.audio_chip && 429 if (core->board.audio_chip &&
430 core->board.audio_chip == V4L2_IDENT_WM8775) { 430 core->board.audio_chip == V4L2_IDENT_WM8775) {
431 struct v4l2_routing route; 431 call_all(core, audio, s_routing,
432 432 INPUT(input).audioroute, 0, 0);
433 route.input = INPUT(input).audioroute;
434 call_all(core, audio, s_routing, &route);
435 } 433 }
436 /* cx2388's C-ADC is connected to the tuner only. 434 /* cx2388's C-ADC is connected to the tuner only.
437 When used with S-Video, that ADC is busy dealing with 435 When used with S-Video, that ADC is busy dealing with
@@ -823,10 +821,8 @@ static int video_open(struct file *file)
823 if (core->board.radio.audioroute) { 821 if (core->board.radio.audioroute) {
824 if(core->board.audio_chip && 822 if(core->board.audio_chip &&
825 core->board.audio_chip == V4L2_IDENT_WM8775) { 823 core->board.audio_chip == V4L2_IDENT_WM8775) {
826 struct v4l2_routing route; 824 call_all(core, audio, s_routing,
827 825 core->board.radio.audioroute, 0, 0);
828 route.input = core->board.radio.audioroute;
829 call_all(core, audio, s_routing, &route);
830 } 826 }
831 /* "I2S ADC mode" */ 827 /* "I2S ADC mode" */
832 core->tvaudio = WW_I2SADC; 828 core->tvaudio = WW_I2SADC;
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 8f8f20e14713..192b76cdd5d7 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -1018,14 +1018,9 @@ EXPORT_SYMBOL_GPL(em28xx_init_isoc);
1018 */ 1018 */
1019void em28xx_wake_i2c(struct em28xx *dev) 1019void em28xx_wake_i2c(struct em28xx *dev)
1020{ 1020{
1021 struct v4l2_routing route; 1021 v4l2_device_call_all(&dev->v4l2_dev, 0, core, reset, 0);
1022 int zero = 0; 1022 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing,
1023 1023 INPUT(dev->ctl_input)->vmux, 0, 0);
1024 route.input = INPUT(dev->ctl_input)->vmux;
1025 route.output = 0;
1026
1027 v4l2_device_call_all(&dev->v4l2_dev, 0, core, reset, zero);
1028 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, &route);
1029 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0); 1024 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
1030} 1025}
1031 1026
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 96487843a473..882796e84dbc 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -515,10 +515,6 @@ static struct videobuf_queue_ops em28xx_video_qops = {
515 515
516static void video_mux(struct em28xx *dev, int index) 516static void video_mux(struct em28xx *dev, int index)
517{ 517{
518 struct v4l2_routing route;
519
520 route.input = INPUT(index)->vmux;
521 route.output = 0;
522 dev->ctl_input = index; 518 dev->ctl_input = index;
523 dev->ctl_ainput = INPUT(index)->amux; 519 dev->ctl_ainput = INPUT(index)->amux;
524 dev->ctl_aoutput = INPUT(index)->aout; 520 dev->ctl_aoutput = INPUT(index)->aout;
@@ -526,25 +522,22 @@ static void video_mux(struct em28xx *dev, int index)
526 if (!dev->ctl_aoutput) 522 if (!dev->ctl_aoutput)
527 dev->ctl_aoutput = EM28XX_AOUT_MASTER; 523 dev->ctl_aoutput = EM28XX_AOUT_MASTER;
528 524
529 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, &route); 525 v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing,
526 INPUT(index)->vmux, 0, 0);
530 527
531 if (dev->board.has_msp34xx) { 528 if (dev->board.has_msp34xx) {
532 if (dev->i2s_speed) { 529 if (dev->i2s_speed) {
533 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, 530 v4l2_device_call_all(&dev->v4l2_dev, 0, audio,
534 s_i2s_clock_freq, dev->i2s_speed); 531 s_i2s_clock_freq, dev->i2s_speed);
535 } 532 }
536 route.input = dev->ctl_ainput;
537 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
538
539 /* Note: this is msp3400 specific */ 533 /* Note: this is msp3400 specific */
540 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, &route); 534 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing,
535 dev->ctl_ainput, MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0);
541 } 536 }
542 537
543 if (dev->board.adecoder != EM28XX_NOADECODER) { 538 if (dev->board.adecoder != EM28XX_NOADECODER) {
544 route.input = dev->ctl_ainput; 539 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing,
545 route.output = dev->ctl_aoutput; 540 dev->ctl_ainput, dev->ctl_aoutput, 0);
546
547 v4l2_device_call_all(&dev->v4l2_dev, 0, audio, s_routing, &route);
548 } 541 }
549 542
550 em28xx_audio_analog_set(dev); 543 em28xx_audio_analog_set(dev);
diff --git a/drivers/media/video/ivtv/ivtv-gpio.c b/drivers/media/video/ivtv/ivtv-gpio.c
index 0dd5f53b7319..ceb05bdcaf62 100644
--- a/drivers/media/video/ivtv/ivtv-gpio.c
+++ b/drivers/media/video/ivtv/ivtv-gpio.c
@@ -248,15 +248,16 @@ static int subdev_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
248 return 0; 248 return 0;
249} 249}
250 250
251static int subdev_s_audio_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 251static int subdev_s_audio_routing(struct v4l2_subdev *sd,
252 u32 input, u32 output, u32 config)
252{ 253{
253 struct ivtv *itv = sd_to_ivtv(sd); 254 struct ivtv *itv = sd_to_ivtv(sd);
254 u16 mask, data; 255 u16 mask, data;
255 256
256 if (route->input > 2) 257 if (input > 2)
257 return -EINVAL; 258 return -EINVAL;
258 mask = itv->card->gpio_audio_input.mask; 259 mask = itv->card->gpio_audio_input.mask;
259 switch (route->input) { 260 switch (input) {
260 case 0: 261 case 0:
261 data = itv->card->gpio_audio_input.tuner; 262 data = itv->card->gpio_audio_input.tuner;
262 break; 263 break;
@@ -318,17 +319,18 @@ static int subdev_log_status(struct v4l2_subdev *sd)
318 return 0; 319 return 0;
319} 320}
320 321
321static int subdev_s_video_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 322static int subdev_s_video_routing(struct v4l2_subdev *sd,
323 u32 input, u32 output, u32 config)
322{ 324{
323 struct ivtv *itv = sd_to_ivtv(sd); 325 struct ivtv *itv = sd_to_ivtv(sd);
324 u16 mask, data; 326 u16 mask, data;
325 327
326 if (route->input > 2) /* 0:Tuner 1:Composite 2:S-Video */ 328 if (input > 2) /* 0:Tuner 1:Composite 2:S-Video */
327 return -EINVAL; 329 return -EINVAL;
328 mask = itv->card->gpio_video_input.mask; 330 mask = itv->card->gpio_video_input.mask;
329 if (route->input == 0) 331 if (input == 0)
330 data = itv->card->gpio_video_input.tuner; 332 data = itv->card->gpio_video_input.tuner;
331 else if (route->input == 1) 333 else if (input == 1)
332 data = itv->card->gpio_video_input.composite; 334 data = itv->card->gpio_video_input.composite;
333 else 335 else
334 data = itv->card->gpio_video_input.svideo; 336 data = itv->card->gpio_video_input.svideo;
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 052fbe9cde86..cf48b6ab97cb 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1033,7 +1033,6 @@ static int ivtv_g_output(struct file *file, void *fh, unsigned int *i)
1033static int ivtv_s_output(struct file *file, void *fh, unsigned int outp) 1033static int ivtv_s_output(struct file *file, void *fh, unsigned int outp)
1034{ 1034{
1035 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv; 1035 struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
1036 struct v4l2_routing route;
1037 1036
1038 if (outp >= itv->card->nof_outputs) 1037 if (outp >= itv->card->nof_outputs)
1039 return -EINVAL; 1038 return -EINVAL;
@@ -1046,9 +1045,9 @@ static int ivtv_s_output(struct file *file, void *fh, unsigned int outp)
1046 itv->active_output, outp); 1045 itv->active_output, outp);
1047 1046
1048 itv->active_output = outp; 1047 itv->active_output = outp;
1049 route.input = SAA7127_INPUT_TYPE_NORMAL; 1048 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_routing,
1050 route.output = itv->card->video_outputs[outp].video_output; 1049 SAA7127_INPUT_TYPE_NORMAL,
1051 ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_routing, &route); 1050 itv->card->video_outputs[outp].video_output, 0);
1052 1051
1053 return 0; 1052 return 0;
1054} 1053}
@@ -1738,7 +1737,8 @@ static long ivtv_default(struct file *file, void *fh, int cmd, void *arg)
1738 case VIDIOC_INT_S_AUDIO_ROUTING: { 1737 case VIDIOC_INT_S_AUDIO_ROUTING: {
1739 struct v4l2_routing *route = arg; 1738 struct v4l2_routing *route = arg;
1740 1739
1741 ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing, route); 1740 ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing,
1741 route->input, route->output, 0);
1742 break; 1742 break;
1743 } 1743 }
1744 1744
diff --git a/drivers/media/video/ivtv/ivtv-routing.c b/drivers/media/video/ivtv/ivtv-routing.c
index 3fd302294497..8898c569a1c9 100644
--- a/drivers/media/video/ivtv/ivtv-routing.c
+++ b/drivers/media/video/ivtv/ivtv-routing.c
@@ -34,7 +34,7 @@
34void ivtv_audio_set_io(struct ivtv *itv) 34void ivtv_audio_set_io(struct ivtv *itv)
35{ 35{
36 const struct ivtv_card_audio_input *in; 36 const struct ivtv_card_audio_input *in;
37 struct v4l2_routing route; 37 u32 input, output = 0;
38 38
39 /* Determine which input to use */ 39 /* Determine which input to use */
40 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) 40 if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))
@@ -43,73 +43,77 @@ void ivtv_audio_set_io(struct ivtv *itv)
43 in = &itv->card->audio_inputs[itv->audio_input]; 43 in = &itv->card->audio_inputs[itv->audio_input];
44 44
45 /* handle muxer chips */ 45 /* handle muxer chips */
46 route.input = in->muxer_input; 46 input = in->muxer_input;
47 route.output = 0;
48 if (itv->card->hw_muxer & IVTV_HW_M52790) 47 if (itv->card->hw_muxer & IVTV_HW_M52790)
49 route.output = M52790_OUT_STEREO; 48 output = M52790_OUT_STEREO;
50 v4l2_subdev_call(itv->sd_muxer, audio, s_routing, &route); 49 v4l2_subdev_call(itv->sd_muxer, audio, s_routing,
50 input, output, 0);
51 51
52 route.input = in->audio_input; 52 input = in->audio_input;
53 route.output = 0; 53 output = 0;
54 if (itv->card->hw_audio & IVTV_HW_MSP34XX) 54 if (itv->card->hw_audio & IVTV_HW_MSP34XX)
55 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); 55 output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
56 ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing, &route); 56 ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing,
57 input, output, 0);
57} 58}
58 59
59/* Selects the video input and output according to the current 60/* Selects the video input and output according to the current
60 settings. */ 61 settings. */
61void ivtv_video_set_io(struct ivtv *itv) 62void ivtv_video_set_io(struct ivtv *itv)
62{ 63{
63 struct v4l2_routing route;
64 int inp = itv->active_input; 64 int inp = itv->active_input;
65 u32 input;
65 u32 type; 66 u32 type;
66 67
67 route.input = itv->card->video_inputs[inp].video_input; 68 v4l2_subdev_call(itv->sd_video, video, s_routing,
68 route.output = 0; 69 itv->card->video_inputs[inp].video_input, 0, 0);
69 v4l2_subdev_call(itv->sd_video, video, s_routing, &route);
70 70
71 type = itv->card->video_inputs[inp].video_type; 71 type = itv->card->video_inputs[inp].video_type;
72 72
73 if (type == IVTV_CARD_INPUT_VID_TUNER) { 73 if (type == IVTV_CARD_INPUT_VID_TUNER) {
74 route.input = 0; /* Tuner */ 74 input = 0; /* Tuner */
75 } else if (type < IVTV_CARD_INPUT_COMPOSITE1) { 75 } else if (type < IVTV_CARD_INPUT_COMPOSITE1) {
76 route.input = 2; /* S-Video */ 76 input = 2; /* S-Video */
77 } else { 77 } else {
78 route.input = 1; /* Composite */ 78 input = 1; /* Composite */
79 } 79 }
80 80
81 if (itv->card->hw_video & IVTV_HW_GPIO) 81 if (itv->card->hw_video & IVTV_HW_GPIO)
82 ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing, &route); 82 ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing,
83 input, 0, 0);
83 84
84 if (itv->card->hw_video & IVTV_HW_UPD64031A) { 85 if (itv->card->hw_video & IVTV_HW_UPD64031A) {
85 if (type == IVTV_CARD_INPUT_VID_TUNER || 86 if (type == IVTV_CARD_INPUT_VID_TUNER ||
86 type >= IVTV_CARD_INPUT_COMPOSITE1) { 87 type >= IVTV_CARD_INPUT_COMPOSITE1) {
87 /* Composite: GR on, connect to 3DYCS */ 88 /* Composite: GR on, connect to 3DYCS */
88 route.input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE; 89 input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE;
89 } else { 90 } else {
90 /* S-Video: GR bypassed, turn it off */ 91 /* S-Video: GR bypassed, turn it off */
91 route.input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE; 92 input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE;
92 } 93 }
93 route.input |= itv->card->gr_config; 94 input |= itv->card->gr_config;
94 95
95 ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing, &route); 96 ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing,
97 input, 0, 0);
96 } 98 }
97 99
98 if (itv->card->hw_video & IVTV_HW_UPD6408X) { 100 if (itv->card->hw_video & IVTV_HW_UPD6408X) {
99 route.input = UPD64083_YCS_MODE; 101 input = UPD64083_YCS_MODE;
100 if (type > IVTV_CARD_INPUT_VID_TUNER && 102 if (type > IVTV_CARD_INPUT_VID_TUNER &&
101 type < IVTV_CARD_INPUT_COMPOSITE1) { 103 type < IVTV_CARD_INPUT_COMPOSITE1) {
102 /* S-Video uses YCNR mode and internal Y-ADC, the upd64031a 104 /* S-Video uses YCNR mode and internal Y-ADC, the
103 is not used. */ 105 upd64031a is not used. */
104 route.input |= UPD64083_YCNR_MODE; 106 input |= UPD64083_YCNR_MODE;
105 } 107 }
106 else if (itv->card->hw_video & IVTV_HW_UPD64031A) { 108 else if (itv->card->hw_video & IVTV_HW_UPD64031A) {
107 /* Use upd64031a output for tuner and composite(CX23416GYC only) inputs */ 109 /* Use upd64031a output for tuner and
108 if ((type == IVTV_CARD_INPUT_VID_TUNER)|| 110 composite(CX23416GYC only) inputs */
109 (itv->card->type == IVTV_CARD_CX23416GYC)) { 111 if (type == IVTV_CARD_INPUT_VID_TUNER ||
110 route.input |= UPD64083_EXT_Y_ADC; 112 itv->card->type == IVTV_CARD_CX23416GYC) {
111 } 113 input |= UPD64083_EXT_Y_ADC;
114 }
112 } 115 }
113 ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing, &route); 116 ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing,
117 input, 0, 0);
114 } 118 }
115} 119}
diff --git a/drivers/media/video/ks0127.c b/drivers/media/video/ks0127.c
index 4e5f0e7dc591..fab8e0254bbc 100644
--- a/drivers/media/video/ks0127.c
+++ b/drivers/media/video/ks0127.c
@@ -409,11 +409,12 @@ static void ks0127_init(struct v4l2_subdev *sd)
409 } 409 }
410} 410}
411 411
412static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 412static int ks0127_s_routing(struct v4l2_subdev *sd,
413 u32 input, u32 output, u32 config)
413{ 414{
414 struct ks0127 *ks = to_ks0127(sd); 415 struct ks0127 *ks = to_ks0127(sd);
415 416
416 switch (route->input) { 417 switch (input) {
417 case KS_INPUT_COMPOSITE_1: 418 case KS_INPUT_COMPOSITE_1:
418 case KS_INPUT_COMPOSITE_2: 419 case KS_INPUT_COMPOSITE_2:
419 case KS_INPUT_COMPOSITE_3: 420 case KS_INPUT_COMPOSITE_3:
@@ -421,13 +422,13 @@ static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r
421 case KS_INPUT_COMPOSITE_5: 422 case KS_INPUT_COMPOSITE_5:
422 case KS_INPUT_COMPOSITE_6: 423 case KS_INPUT_COMPOSITE_6:
423 v4l2_dbg(1, debug, sd, 424 v4l2_dbg(1, debug, sd,
424 "s_routing %d: Composite\n", route->input); 425 "s_routing %d: Composite\n", input);
425 /* autodetect 50/60 Hz */ 426 /* autodetect 50/60 Hz */
426 ks0127_and_or(sd, KS_CMDA, 0xfc, 0x00); 427 ks0127_and_or(sd, KS_CMDA, 0xfc, 0x00);
427 /* VSE=0 */ 428 /* VSE=0 */
428 ks0127_and_or(sd, KS_CMDA, ~0x40, 0x00); 429 ks0127_and_or(sd, KS_CMDA, ~0x40, 0x00);
429 /* set input line */ 430 /* set input line */
430 ks0127_and_or(sd, KS_CMDB, 0xb0, route->input); 431 ks0127_and_or(sd, KS_CMDB, 0xb0, input);
431 /* non-freerunning mode */ 432 /* non-freerunning mode */
432 ks0127_and_or(sd, KS_CMDC, 0x70, 0x0a); 433 ks0127_and_or(sd, KS_CMDC, 0x70, 0x0a);
433 /* analog input */ 434 /* analog input */
@@ -455,13 +456,13 @@ static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r
455 case KS_INPUT_SVIDEO_2: 456 case KS_INPUT_SVIDEO_2:
456 case KS_INPUT_SVIDEO_3: 457 case KS_INPUT_SVIDEO_3:
457 v4l2_dbg(1, debug, sd, 458 v4l2_dbg(1, debug, sd,
458 "s_routing %d: S-Video\n", route->input); 459 "s_routing %d: S-Video\n", input);
459 /* autodetect 50/60 Hz */ 460 /* autodetect 50/60 Hz */
460 ks0127_and_or(sd, KS_CMDA, 0xfc, 0x00); 461 ks0127_and_or(sd, KS_CMDA, 0xfc, 0x00);
461 /* VSE=0 */ 462 /* VSE=0 */
462 ks0127_and_or(sd, KS_CMDA, ~0x40, 0x00); 463 ks0127_and_or(sd, KS_CMDA, ~0x40, 0x00);
463 /* set input line */ 464 /* set input line */
464 ks0127_and_or(sd, KS_CMDB, 0xb0, route->input); 465 ks0127_and_or(sd, KS_CMDB, 0xb0, input);
465 /* non-freerunning mode */ 466 /* non-freerunning mode */
466 ks0127_and_or(sd, KS_CMDC, 0x70, 0x0a); 467 ks0127_and_or(sd, KS_CMDC, 0x70, 0x0a);
467 /* analog input */ 468 /* analog input */
@@ -496,7 +497,7 @@ static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r
496 497
497 ks0127_and_or(sd, KS_CMDA, 0xff, 0x40); /* VSE=1 */ 498 ks0127_and_or(sd, KS_CMDA, 0xff, 0x40); /* VSE=1 */
498 /* set input line and VALIGN */ 499 /* set input line and VALIGN */
499 ks0127_and_or(sd, KS_CMDB, 0xb0, (route->input | 0x40)); 500 ks0127_and_or(sd, KS_CMDB, 0xb0, (input | 0x40));
500 /* freerunning mode, */ 501 /* freerunning mode, */
501 /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/ 502 /* TSTGEN = 1 TSTGFR=11 TSTGPH=0 TSTGPK=0 VMEM=1*/
502 ks0127_and_or(sd, KS_CMDC, 0x70, 0x87); 503 ks0127_and_or(sd, KS_CMDC, 0x70, 0x87);
@@ -531,7 +532,7 @@ static int ks0127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r
531 532
532 default: 533 default:
533 v4l2_dbg(1, debug, sd, 534 v4l2_dbg(1, debug, sd,
534 "s_routing: Unknown input %d\n", route->input); 535 "s_routing: Unknown input %d\n", input);
535 break; 536 break;
536 } 537 }
537 538
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c
index 1f340fefc49d..d7317e798cc4 100644
--- a/drivers/media/video/m52790.c
+++ b/drivers/media/video/m52790.c
@@ -69,12 +69,13 @@ static int m52790_write(struct v4l2_subdev *sd)
69 part of the audio output routing. The normal case is that another 69 part of the audio output routing. The normal case is that another
70 chip takes care of the actual muting so making it part of the 70 chip takes care of the actual muting so making it part of the
71 output routing seems to be the right thing to do for now. */ 71 output routing seems to be the right thing to do for now. */
72static int m52790_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 72static int m52790_s_routing(struct v4l2_subdev *sd,
73 u32 input, u32 output, u32 config)
73{ 74{
74 struct m52790_state *state = to_state(sd); 75 struct m52790_state *state = to_state(sd);
75 76
76 state->input = route->input; 77 state->input = input;
77 state->output = route->output; 78 state->output = output;
78 m52790_write(sd); 79 m52790_write(sd);
79 return 0; 80 return 0;
80} 81}
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 38e639750a48..e9df3cb02cc1 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -505,25 +505,26 @@ static int msp_s_std(struct v4l2_subdev *sd, v4l2_std_id id)
505 return 0; 505 return 0;
506} 506}
507 507
508static int msp_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *rt) 508static int msp_s_routing(struct v4l2_subdev *sd,
509 u32 input, u32 output, u32 config)
509{ 510{
510 struct msp_state *state = to_state(sd); 511 struct msp_state *state = to_state(sd);
511 struct i2c_client *client = v4l2_get_subdevdata(sd); 512 struct i2c_client *client = v4l2_get_subdevdata(sd);
512 int tuner = (rt->input >> 3) & 1; 513 int tuner = (input >> 3) & 1;
513 int sc_in = rt->input & 0x7; 514 int sc_in = input & 0x7;
514 int sc1_out = rt->output & 0xf; 515 int sc1_out = output & 0xf;
515 int sc2_out = (rt->output >> 4) & 0xf; 516 int sc2_out = (output >> 4) & 0xf;
516 u16 val, reg; 517 u16 val, reg;
517 int i; 518 int i;
518 int extern_input = 1; 519 int extern_input = 1;
519 520
520 if (state->routing.input == rt->input && 521 if (state->route_in == input && state->route_out == output)
521 state->routing.output == rt->output)
522 return 0; 522 return 0;
523 state->routing = *rt; 523 state->route_in = input;
524 state->route_out = output;
524 /* check if the tuner input is used */ 525 /* check if the tuner input is used */
525 for (i = 0; i < 5; i++) { 526 for (i = 0; i < 5; i++) {
526 if (((rt->input >> (4 + i * 4)) & 0xf) == 0) 527 if (((input >> (4 + i * 4)) & 0xf) == 0)
527 extern_input = 0; 528 extern_input = 0;
528 } 529 }
529 state->mode = extern_input ? MSP_MODE_EXTERN : MSP_MODE_AM_DETECT; 530 state->mode = extern_input ? MSP_MODE_EXTERN : MSP_MODE_AM_DETECT;
@@ -673,7 +674,7 @@ static int msp_log_status(struct v4l2_subdev *sd)
673 } 674 }
674 v4l_info(client, "Audmode: 0x%04x\n", state->audmode); 675 v4l_info(client, "Audmode: 0x%04x\n", state->audmode);
675 v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n", 676 v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n",
676 state->routing.input, state->routing.output); 677 state->route_in, state->route_out);
677 v4l_info(client, "ACB: 0x%04x\n", state->acb); 678 v4l_info(client, "ACB: 0x%04x\n", state->acb);
678 return 0; 679 return 0;
679} 680}
@@ -761,8 +762,8 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
761 state->i2s_mode = 0; 762 state->i2s_mode = 0;
762 init_waitqueue_head(&state->wq); 763 init_waitqueue_head(&state->wq);
763 /* These are the reset input/output positions */ 764 /* These are the reset input/output positions */
764 state->routing.input = MSP_INPUT_DEFAULT; 765 state->route_in = MSP_INPUT_DEFAULT;
765 state->routing.output = MSP_OUTPUT_DEFAULT; 766 state->route_out = MSP_OUTPUT_DEFAULT;
766 767
767 state->rev1 = msp_read_dsp(client, 0x1e); 768 state->rev1 = msp_read_dsp(client, 0x1e);
768 if (state->rev1 != -1) 769 if (state->rev1 != -1)
diff --git a/drivers/media/video/msp3400-driver.h b/drivers/media/video/msp3400-driver.h
index 3fe1c1b10f53..d6b3e6d0eef7 100644
--- a/drivers/media/video/msp3400-driver.h
+++ b/drivers/media/video/msp3400-driver.h
@@ -80,7 +80,8 @@ struct msp_state {
80 int i2s_mode; 80 int i2s_mode;
81 int main, second; /* sound carrier */ 81 int main, second; /* sound carrier */
82 int input; 82 int input;
83 struct v4l2_routing routing; 83 u32 route_in;
84 u32 route_out;
84 85
85 /* v4l2 */ 86 /* v4l2 */
86 int audmode; 87 int audmode;
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index a655e9c30146..168bca703614 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -188,7 +188,7 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
188{ 188{
189 struct msp_state *state = to_state(i2c_get_clientdata(client)); 189 struct msp_state *state = to_state(i2c_get_clientdata(client));
190 struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode]; 190 struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode];
191 int tuner = (state->routing.input >> 3) & 1; 191 int tuner = (state->route_in >> 3) & 1;
192 int i; 192 int i;
193 193
194 v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode); 194 v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode);
@@ -896,7 +896,7 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
896static void msp34xxg_set_sources(struct i2c_client *client) 896static void msp34xxg_set_sources(struct i2c_client *client)
897{ 897{
898 struct msp_state *state = to_state(i2c_get_clientdata(client)); 898 struct msp_state *state = to_state(i2c_get_clientdata(client));
899 u32 in = state->routing.input; 899 u32 in = state->route_in;
900 900
901 msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf); 901 msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf);
902 /* quasi-peak detector is set to same input as the loudspeaker (MAIN) */ 902 /* quasi-peak detector is set to same input as the loudspeaker (MAIN) */
@@ -912,7 +912,7 @@ static void msp34xxg_set_sources(struct i2c_client *client)
912static void msp34xxg_reset(struct i2c_client *client) 912static void msp34xxg_reset(struct i2c_client *client)
913{ 913{
914 struct msp_state *state = to_state(i2c_get_clientdata(client)); 914 struct msp_state *state = to_state(i2c_get_clientdata(client));
915 int tuner = (state->routing.input >> 3) & 1; 915 int tuner = (state->route_in >> 3) & 1;
916 int modus; 916 int modus;
917 917
918 /* initialize std to 1 (autodetect) to signal that no standard is 918 /* initialize std to 1 (autodetect) to signal that no standard is
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index a547c85b4ca7..3be5a71bdac2 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -83,9 +83,14 @@ static struct {
83static int video_audio_connect[MXB_INPUTS] = 83static int video_audio_connect[MXB_INPUTS] =
84 { 0, 1, 3, 3 }; 84 { 0, 1, 3, 3 };
85 85
86struct mxb_routing {
87 u32 input;
88 u32 output;
89};
90
86/* These are the necessary input-output-pins for bringing one audio source 91/* These are the necessary input-output-pins for bringing one audio source
87 (see above) to the CD-output. Note that gain is set to 0 in this table. */ 92 (see above) to the CD-output. Note that gain is set to 0 in this table. */
88static struct v4l2_routing TEA6420_cd[MXB_AUDIOS + 1][2] = { 93static struct mxb_routing TEA6420_cd[MXB_AUDIOS + 1][2] = {
89 { { 1, 1 }, { 1, 1 } }, /* Tuner */ 94 { { 1, 1 }, { 1, 1 } }, /* Tuner */
90 { { 5, 1 }, { 6, 1 } }, /* AUX 1 */ 95 { { 5, 1 }, { 6, 1 } }, /* AUX 1 */
91 { { 4, 1 }, { 6, 1 } }, /* AUX 2 */ 96 { { 4, 1 }, { 6, 1 } }, /* AUX 2 */
@@ -97,7 +102,7 @@ static struct v4l2_routing TEA6420_cd[MXB_AUDIOS + 1][2] = {
97 102
98/* These are the necessary input-output-pins for bringing one audio source 103/* These are the necessary input-output-pins for bringing one audio source
99 (see above) to the line-output. Note that gain is set to 0 in this table. */ 104 (see above) to the line-output. Note that gain is set to 0 in this table. */
100static struct v4l2_routing TEA6420_line[MXB_AUDIOS + 1][2] = { 105static struct mxb_routing TEA6420_line[MXB_AUDIOS + 1][2] = {
101 { { 2, 3 }, { 1, 2 } }, 106 { { 2, 3 }, { 1, 2 } },
102 { { 5, 3 }, { 6, 2 } }, 107 { { 5, 3 }, { 6, 2 } },
103 { { 4, 3 }, { 6, 2 } }, 108 { { 4, 3 }, { 6, 2 } },
@@ -134,10 +139,6 @@ struct mxb
134 139
135#define saa7111a_call(mxb, o, f, args...) \ 140#define saa7111a_call(mxb, o, f, args...) \
136 v4l2_subdev_call(mxb->saa7111a, o, f, ##args) 141 v4l2_subdev_call(mxb->saa7111a, o, f, ##args)
137#define tea6420_1_call(mxb, o, f, args...) \
138 v4l2_subdev_call(mxb->tea6420_1, o, f, ##args)
139#define tea6420_2_call(mxb, o, f, args...) \
140 v4l2_subdev_call(mxb->tea6420_2, o, f, ##args)
141#define tda9840_call(mxb, o, f, args...) \ 142#define tda9840_call(mxb, o, f, args...) \
142 v4l2_subdev_call(mxb->tda9840, o, f, ##args) 143 v4l2_subdev_call(mxb->tda9840, o, f, ##args)
143#define tea6415c_call(mxb, o, f, args...) \ 144#define tea6415c_call(mxb, o, f, args...) \
@@ -147,6 +148,22 @@ struct mxb
147#define call_all(dev, o, f, args...) \ 148#define call_all(dev, o, f, args...) \
148 v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args) 149 v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args)
149 150
151static inline void tea6420_route_cd(struct mxb *mxb, int idx)
152{
153 v4l2_subdev_call(mxb->tea6420_1, audio, s_routing,
154 TEA6420_cd[idx][0].input, TEA6420_cd[idx][0].output, 0);
155 v4l2_subdev_call(mxb->tea6420_2, audio, s_routing,
156 TEA6420_cd[idx][1].input, TEA6420_cd[idx][1].output, 0);
157}
158
159static inline void tea6420_route_line(struct mxb *mxb, int idx)
160{
161 v4l2_subdev_call(mxb->tea6420_1, audio, s_routing,
162 TEA6420_line[idx][0].input, TEA6420_line[idx][0].output, 0);
163 v4l2_subdev_call(mxb->tea6420_2, audio, s_routing,
164 TEA6420_line[idx][1].input, TEA6420_line[idx][1].output, 0);
165}
166
150static struct saa7146_extension extension; 167static struct saa7146_extension extension;
151 168
152static int mxb_probe(struct saa7146_dev *dev) 169static int mxb_probe(struct saa7146_dev *dev)
@@ -268,7 +285,6 @@ static int mxb_init_done(struct saa7146_dev* dev)
268 struct i2c_msg msg; 285 struct i2c_msg msg;
269 struct tuner_setup tun_setup; 286 struct tuner_setup tun_setup;
270 v4l2_std_id std = V4L2_STD_PAL_BG; 287 v4l2_std_id std = V4L2_STD_PAL_BG;
271 struct v4l2_routing route;
272 288
273 int i = 0, err = 0; 289 int i = 0, err = 0;
274 290
@@ -277,9 +293,8 @@ static int mxb_init_done(struct saa7146_dev* dev)
277 293
278 /* select tuner-output on saa7111a */ 294 /* select tuner-output on saa7111a */
279 i = 0; 295 i = 0;
280 route.input = SAA7115_COMPOSITE0; 296 saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0,
281 route.output = SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS; 297 SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS, 0);
282 saa7111a_call(mxb, video, s_routing, &route);
283 298
284 /* select a tuner type */ 299 /* select a tuner type */
285 tun_setup.mode_mask = T_ANALOG_TV; 300 tun_setup.mode_mask = T_ANALOG_TV;
@@ -296,20 +311,14 @@ static int mxb_init_done(struct saa7146_dev* dev)
296 tuner_call(mxb, core, s_std, std); 311 tuner_call(mxb, core, s_std, std);
297 312
298 /* mute audio on tea6420s */ 313 /* mute audio on tea6420s */
299 tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[6][0]); 314 tea6420_route_line(mxb, 6);
300 tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[6][1]); 315 tea6420_route_cd(mxb, 6);
301 tea6420_1_call(mxb, audio, s_routing, &TEA6420_cd[6][0]);
302 tea6420_2_call(mxb, audio, s_routing, &TEA6420_cd[6][1]);
303 316
304 /* switch to tuner-channel on tea6415c */ 317 /* switch to tuner-channel on tea6415c */
305 route.input = 3; 318 tea6415c_call(mxb, video, s_routing, 3, 17, 0);
306 route.output = 17;
307 tea6415c_call(mxb, video, s_routing, &route);
308 319
309 /* select tuner-output on multicable on tea6415c */ 320 /* select tuner-output on multicable on tea6415c */
310 route.input = 3; 321 tea6415c_call(mxb, video, s_routing, 3, 13, 0);
311 route.output = 13;
312 tea6415c_call(mxb, video, s_routing, &route);
313 322
314 /* the rest for mxb */ 323 /* the rest for mxb */
315 mxb->cur_input = 0; 324 mxb->cur_input = 0;
@@ -433,18 +442,9 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
433 442
434 if (vc->id == V4L2_CID_AUDIO_MUTE) { 443 if (vc->id == V4L2_CID_AUDIO_MUTE) {
435 mxb->cur_mute = vc->value; 444 mxb->cur_mute = vc->value;
436 if (!vc->value) { 445 /* switch the audio-source */
437 /* switch the audio-source */ 446 tea6420_route_line(mxb, vc->value ? 6 :
438 tea6420_1_call(mxb, audio, s_routing, 447 video_audio_connect[mxb->cur_input]);
439 &TEA6420_line[video_audio_connect[mxb->cur_input]][0]);
440 tea6420_2_call(mxb, audio, s_routing,
441 &TEA6420_line[video_audio_connect[mxb->cur_input]][1]);
442 } else {
443 tea6420_1_call(mxb, audio, s_routing,
444 &TEA6420_line[6][0]);
445 tea6420_2_call(mxb, audio, s_routing,
446 &TEA6420_line[6][1]);
447 }
448 DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value)); 448 DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value));
449 } 449 }
450 return 0; 450 return 0;
@@ -473,7 +473,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
473{ 473{
474 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; 474 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
475 struct mxb *mxb = (struct mxb *)dev->ext_priv; 475 struct mxb *mxb = (struct mxb *)dev->ext_priv;
476 struct v4l2_routing route; 476 int err = 0;
477 int i = 0; 477 int i = 0;
478 478
479 DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); 479 DEB_EE(("VIDIOC_S_INPUT %d.\n", input));
@@ -491,16 +491,12 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
491 switch (input) { 491 switch (input) {
492 case TUNER: 492 case TUNER:
493 i = SAA7115_COMPOSITE0; 493 i = SAA7115_COMPOSITE0;
494 route.input = 3;
495 route.output = 17;
496 494
497 if (tea6415c_call(mxb, video, s_routing, &route)) { 495 err = tea6415c_call(mxb, video, s_routing, 3, 17, 0);
498 printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #1\n"); 496
499 return -EFAULT;
500 }
501 /* connect tuner-output always to multicable */ 497 /* connect tuner-output always to multicable */
502 route.input = 3; 498 if (!err)
503 route.output = 13; 499 err = tea6415c_call(mxb, video, s_routing, 3, 13, 0);
504 break; 500 break;
505 case AUX3_YC: 501 case AUX3_YC:
506 /* nothing to be done here. aux3_yc is 502 /* nothing to be done here. aux3_yc is
@@ -514,37 +510,20 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
514 break; 510 break;
515 case AUX1: 511 case AUX1:
516 i = SAA7115_COMPOSITE0; 512 i = SAA7115_COMPOSITE0;
517 route.input = 1; 513 err = tea6415c_call(mxb, video, s_routing, 1, 17, 0);
518 route.output = 17;
519 break; 514 break;
520 } 515 }
521 516
522 /* switch video in tea6415c only if necessary */ 517 if (err)
523 switch (input) { 518 return err;
524 case TUNER:
525 case AUX1:
526 if (tea6415c_call(mxb, video, s_routing, &route)) {
527 printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #3\n");
528 return -EFAULT;
529 }
530 break;
531 default:
532 break;
533 }
534 519
535 /* switch video in saa7111a */ 520 /* switch video in saa7111a */
536 route.input = i; 521 if (saa7111a_call(mxb, video, s_routing, i, 0, 0))
537 route.output = 0;
538 if (saa7111a_call(mxb, video, s_routing, &route))
539 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n"); 522 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n");
540 523
541 /* switch the audio-source only if necessary */ 524 /* switch the audio-source only if necessary */
542 if (0 == mxb->cur_mute) { 525 if (0 == mxb->cur_mute)
543 tea6420_1_call(mxb, audio, s_routing, 526 tea6420_route_line(mxb, video_audio_connect[input]);
544 &TEA6420_line[video_audio_connect[input]][0]);
545 tea6420_2_call(mxb, audio, s_routing,
546 &TEA6420_line[video_audio_connect[input]][1]);
547 }
548 527
549 return 0; 528 return 0;
550} 529}
@@ -686,9 +665,7 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg)
686 665
687 DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); 666 DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i));
688 667
689 tea6420_1_call(mxb, audio, s_routing, &TEA6420_cd[i][0]); 668 tea6420_route_cd(mxb, i);
690 tea6420_2_call(mxb, audio, s_routing, &TEA6420_cd[i][1]);
691
692 return 0; 669 return 0;
693 } 670 }
694 case MXB_S_AUDIO_LINE: 671 case MXB_S_AUDIO_LINE:
@@ -701,9 +678,7 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg)
701 } 678 }
702 679
703 DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); 680 DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i));
704 tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[i][0]); 681 tea6420_route_line(mxb, i);
705 tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[i][1]);
706
707 return 0; 682 return 0;
708 } 683 }
709 default: 684 default:
diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.c b/drivers/media/video/pvrusb2/pvrusb2-audio.c
index ccf2a3c7ad06..10ef1a2c13ea 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-audio.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-audio.c
@@ -58,9 +58,9 @@ static const struct routing_scheme routing_schemes[] = {
58void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) 58void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
59{ 59{
60 if (hdw->input_dirty || hdw->force_dirty) { 60 if (hdw->input_dirty || hdw->force_dirty) {
61 struct v4l2_routing route;
62 const struct routing_scheme *sp; 61 const struct routing_scheme *sp;
63 unsigned int sid = hdw->hdw_desc->signal_routing_scheme; 62 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
63 u32 input;
64 64
65 pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo"); 65 pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo");
66 66
@@ -68,7 +68,7 @@ void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
68 ((sp = routing_schemes + sid) != NULL) && 68 ((sp = routing_schemes + sid) != NULL) &&
69 (hdw->input_val >= 0) && 69 (hdw->input_val >= 0) &&
70 (hdw->input_val < sp->cnt)) { 70 (hdw->input_val < sp->cnt)) {
71 route.input = sp->def[hdw->input_val]; 71 input = sp->def[hdw->input_val];
72 } else { 72 } else {
73 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 73 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
74 "*** WARNING *** subdev msp3400 set_input:" 74 "*** WARNING *** subdev msp3400 set_input:"
@@ -77,8 +77,8 @@ void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
77 sid, hdw->input_val); 77 sid, hdw->input_val);
78 return; 78 return;
79 } 79 }
80 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); 80 sd->ops->audio->s_routing(sd, input,
81 sd->ops->audio->s_routing(sd, &route); 81 MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0);
82 } 82 }
83} 83}
84 84
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c b/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c
index b5c3428ebb9f..9023adf3fdcc 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c
@@ -60,16 +60,16 @@ static const struct routing_scheme routing_schemes[] = {
60void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) 60void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
61{ 61{
62 if (hdw->input_dirty || hdw->force_dirty) { 62 if (hdw->input_dirty || hdw->force_dirty) {
63 struct v4l2_routing route;
64 const struct routing_scheme *sp; 63 const struct routing_scheme *sp;
65 unsigned int sid = hdw->hdw_desc->signal_routing_scheme; 64 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
65 u32 input;
66 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", 66 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
67 hdw->input_val); 67 hdw->input_val);
68 if ((sid < ARRAY_SIZE(routing_schemes)) && 68 if ((sid < ARRAY_SIZE(routing_schemes)) &&
69 ((sp = routing_schemes + sid) != NULL) && 69 ((sp = routing_schemes + sid) != NULL) &&
70 (hdw->input_val >= 0) && 70 (hdw->input_val >= 0) &&
71 (hdw->input_val < sp->cnt)) { 71 (hdw->input_val < sp->cnt)) {
72 route.input = sp->def[hdw->input_val]; 72 input = sp->def[hdw->input_val];
73 } else { 73 } else {
74 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 74 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
75 "*** WARNING *** subdev v4l2 set_input:" 75 "*** WARNING *** subdev v4l2 set_input:"
@@ -78,8 +78,7 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
78 sid, hdw->input_val); 78 sid, hdw->input_val);
79 return; 79 return;
80 } 80 }
81 route.output = 0; 81 sd->ops->audio->s_routing(sd, input, 0, 0);
82 sd->ops->audio->s_routing(sd, &route);
83 } 82 }
84} 83}
85 84
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
index 4e017ff26c36..05e52358ae49 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -105,14 +105,11 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
105{ 105{
106 pvr2_trace(PVR2_TRACE_CHIPS, "subdev cx2584x update..."); 106 pvr2_trace(PVR2_TRACE_CHIPS, "subdev cx2584x update...");
107 if (hdw->input_dirty || hdw->force_dirty) { 107 if (hdw->input_dirty || hdw->force_dirty) {
108 struct v4l2_routing route;
109 enum cx25840_video_input vid_input; 108 enum cx25840_video_input vid_input;
110 enum cx25840_audio_input aud_input; 109 enum cx25840_audio_input aud_input;
111 const struct routing_scheme *sp; 110 const struct routing_scheme *sp;
112 unsigned int sid = hdw->hdw_desc->signal_routing_scheme; 111 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
113 112
114 memset(&route, 0, sizeof(route));
115
116 if ((sid < ARRAY_SIZE(routing_schemes)) && 113 if ((sid < ARRAY_SIZE(routing_schemes)) &&
117 ((sp = routing_schemes + sid) != NULL) && 114 ((sp = routing_schemes + sid) != NULL) &&
118 (hdw->input_val >= 0) && 115 (hdw->input_val >= 0) &&
@@ -131,10 +128,8 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
131 pvr2_trace(PVR2_TRACE_CHIPS, 128 pvr2_trace(PVR2_TRACE_CHIPS,
132 "subdev cx2584x set_input vid=0x%x aud=0x%x", 129 "subdev cx2584x set_input vid=0x%x aud=0x%x",
133 vid_input, aud_input); 130 vid_input, aud_input);
134 route.input = (u32)vid_input; 131 sd->ops->video->s_routing(sd, (u32)vid_input, 0, 0);
135 sd->ops->video->s_routing(sd, &route); 132 sd->ops->audio->s_routing(sd, (u32)aud_input, 0, 0);
136 route.input = (u32)aud_input;
137 sd->ops->audio->s_routing(sd, &route);
138 } 133 }
139} 134}
140 135
diff --git a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
index b3862f5554bd..d2fe7c8f2c3a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
@@ -75,16 +75,17 @@ static const struct routing_scheme routing_schemes[] = {
75void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) 75void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
76{ 76{
77 if (hdw->input_dirty || hdw->force_dirty) { 77 if (hdw->input_dirty || hdw->force_dirty) {
78 struct v4l2_routing route;
79 const struct routing_scheme *sp; 78 const struct routing_scheme *sp;
80 unsigned int sid = hdw->hdw_desc->signal_routing_scheme; 79 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
80 u32 input;
81
81 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", 82 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
82 hdw->input_val); 83 hdw->input_val);
83 if ((sid < ARRAY_SIZE(routing_schemes)) && 84 if ((sid < ARRAY_SIZE(routing_schemes)) &&
84 ((sp = routing_schemes + sid) != NULL) && 85 ((sp = routing_schemes + sid) != NULL) &&
85 (hdw->input_val >= 0) && 86 (hdw->input_val >= 0) &&
86 (hdw->input_val < sp->cnt)) { 87 (hdw->input_val < sp->cnt)) {
87 route.input = sp->def[hdw->input_val]; 88 input = sp->def[hdw->input_val];
88 } else { 89 } else {
89 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 90 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
90 "*** WARNING *** subdev v4l2 set_input:" 91 "*** WARNING *** subdev v4l2 set_input:"
@@ -93,8 +94,7 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
93 sid, hdw->input_val); 94 sid, hdw->input_val);
94 return; 95 return;
95 } 96 }
96 route.output = 0; 97 sd->ops->video->s_routing(sd, input, 0, 0);
97 sd->ops->video->s_routing(sd, &route);
98 } 98 }
99} 99}
100 100
diff --git a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
index 1670aa4051ce..8c1eae05aa08 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
@@ -39,24 +39,22 @@
39void pvr2_wm8775_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) 39void pvr2_wm8775_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
40{ 40{
41 if (hdw->input_dirty || hdw->force_dirty) { 41 if (hdw->input_dirty || hdw->force_dirty) {
42 struct v4l2_routing route; 42 u32 input;
43
44 memset(&route, 0, sizeof(route));
45 43
46 switch (hdw->input_val) { 44 switch (hdw->input_val) {
47 case PVR2_CVAL_INPUT_RADIO: 45 case PVR2_CVAL_INPUT_RADIO:
48 route.input = 1; 46 input = 1;
49 break; 47 break;
50 default: 48 default:
51 /* All other cases just use the second input */ 49 /* All other cases just use the second input */
52 route.input = 2; 50 input = 2;
53 break; 51 break;
54 } 52 }
55 pvr2_trace(PVR2_TRACE_CHIPS, "subdev wm8775" 53 pvr2_trace(PVR2_TRACE_CHIPS, "subdev wm8775"
56 " set_input(val=%d route=0x%x)", 54 " set_input(val=%d route=0x%x)",
57 hdw->input_val, route.input); 55 hdw->input_val, input);
58 56
59 sd->ops->audio->s_routing(sd, &route); 57 sd->ops->audio->s_routing(sd, input, 0, 0);
60 } 58 }
61} 59}
62 60
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 8bb1fc17d195..5c24c993ac16 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -299,17 +299,18 @@ static int saa7110_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
299 return 0; 299 return 0;
300} 300}
301 301
302static int saa7110_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 302static int saa7110_s_routing(struct v4l2_subdev *sd,
303 u32 input, u32 output, u32 config)
303{ 304{
304 struct saa7110 *decoder = to_saa7110(sd); 305 struct saa7110 *decoder = to_saa7110(sd);
305 306
306 if (route->input < 0 || route->input >= SAA7110_MAX_INPUT) { 307 if (input < 0 || input >= SAA7110_MAX_INPUT) {
307 v4l2_dbg(1, debug, sd, "input=%d not available\n", route->input); 308 v4l2_dbg(1, debug, sd, "input=%d not available\n", input);
308 return -EINVAL; 309 return -EINVAL;
309 } 310 }
310 if (decoder->input != route->input) { 311 if (decoder->input != input) {
311 saa7110_selmux(sd, route->input); 312 saa7110_selmux(sd, input);
312 v4l2_dbg(1, debug, sd, "switched to input=%d\n", route->input); 313 v4l2_dbg(1, debug, sd, "switched to input=%d\n", input);
313 } 314 }
314 return 0; 315 return 0;
315} 316}
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index c0e66a88be4f..44873a016c2c 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1228,30 +1228,32 @@ static int saa711x_s_radio(struct v4l2_subdev *sd)
1228 return 0; 1228 return 0;
1229} 1229}
1230 1230
1231static int saa711x_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 1231static int saa711x_s_routing(struct v4l2_subdev *sd,
1232 u32 input, u32 output, u32 config)
1232{ 1233{
1233 struct saa711x_state *state = to_state(sd); 1234 struct saa711x_state *state = to_state(sd);
1234 u32 input = route->input;
1235 u8 mask = (state->ident == V4L2_IDENT_SAA7111) ? 0xf8 : 0xf0; 1235 u8 mask = (state->ident == V4L2_IDENT_SAA7111) ? 0xf8 : 0xf0;
1236 1236
1237 v4l2_dbg(1, debug, sd, "decoder set input %d output %d\n", route->input, route->output); 1237 v4l2_dbg(1, debug, sd, "decoder set input %d output %d\n",
1238 input, output);
1239
1238 /* saa7111/3 does not have these inputs */ 1240 /* saa7111/3 does not have these inputs */
1239 if ((state->ident == V4L2_IDENT_SAA7113 || 1241 if ((state->ident == V4L2_IDENT_SAA7113 ||
1240 state->ident == V4L2_IDENT_SAA7111) && 1242 state->ident == V4L2_IDENT_SAA7111) &&
1241 (route->input == SAA7115_COMPOSITE4 || 1243 (input == SAA7115_COMPOSITE4 ||
1242 route->input == SAA7115_COMPOSITE5)) { 1244 input == SAA7115_COMPOSITE5)) {
1243 return -EINVAL; 1245 return -EINVAL;
1244 } 1246 }
1245 if (route->input > SAA7115_SVIDEO3) 1247 if (input > SAA7115_SVIDEO3)
1246 return -EINVAL; 1248 return -EINVAL;
1247 if (route->output > SAA7115_IPORT_ON) 1249 if (output > SAA7115_IPORT_ON)
1248 return -EINVAL; 1250 return -EINVAL;
1249 if (state->input == route->input && state->output == route->output) 1251 if (state->input == input && state->output == output)
1250 return 0; 1252 return 0;
1251 v4l2_dbg(1, debug, sd, "now setting %s input %s output\n", 1253 v4l2_dbg(1, debug, sd, "now setting %s input %s output\n",
1252 (route->input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite", 1254 (input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite",
1253 (route->output == SAA7115_IPORT_ON) ? "iport on" : "iport off"); 1255 (output == SAA7115_IPORT_ON) ? "iport on" : "iport off");
1254 state->input = route->input; 1256 state->input = input;
1255 1257
1256 /* saa7111 has slightly different input numbering */ 1258 /* saa7111 has slightly different input numbering */
1257 if (state->ident == V4L2_IDENT_SAA7111) { 1259 if (state->ident == V4L2_IDENT_SAA7111) {
@@ -1260,10 +1262,10 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *
1260 /* saa7111 specific */ 1262 /* saa7111 specific */
1261 saa711x_write(sd, R_10_CHROMA_CNTL_2, 1263 saa711x_write(sd, R_10_CHROMA_CNTL_2,
1262 (saa711x_read(sd, R_10_CHROMA_CNTL_2) & 0x3f) | 1264 (saa711x_read(sd, R_10_CHROMA_CNTL_2) & 0x3f) |
1263 ((route->output & 0xc0) ^ 0x40)); 1265 ((output & 0xc0) ^ 0x40));
1264 saa711x_write(sd, R_13_RT_X_PORT_OUT_CNTL, 1266 saa711x_write(sd, R_13_RT_X_PORT_OUT_CNTL,
1265 (saa711x_read(sd, R_13_RT_X_PORT_OUT_CNTL) & 0xf0) | 1267 (saa711x_read(sd, R_13_RT_X_PORT_OUT_CNTL) & 0xf0) |
1266 ((route->output & 2) ? 0x0a : 0)); 1268 ((output & 2) ? 0x0a : 0));
1267 } 1269 }
1268 1270
1269 /* select mode */ 1271 /* select mode */
@@ -1276,7 +1278,7 @@ static int saa711x_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *
1276 (saa711x_read(sd, R_09_LUMA_CNTL) & 0x7f) | 1278 (saa711x_read(sd, R_09_LUMA_CNTL) & 0x7f) |
1277 (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0)); 1279 (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0));
1278 1280
1279 state->output = route->output; 1281 state->output = output;
1280 if (state->ident == V4L2_IDENT_SAA7114 || 1282 if (state->ident == V4L2_IDENT_SAA7114 ||
1281 state->ident == V4L2_IDENT_SAA7115) { 1283 state->ident == V4L2_IDENT_SAA7115) {
1282 saa711x_write(sd, R_83_X_PORT_I_O_ENA_AND_OUT_CLK, 1284 saa711x_write(sd, R_83_X_PORT_I_O_ENA_AND_OUT_CLK,
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index 128bb8b8dbbf..2fe7a701b954 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -570,15 +570,16 @@ static int saa7127_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
570 return saa7127_set_std(sd, std); 570 return saa7127_set_std(sd, std);
571} 571}
572 572
573static int saa7127_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 573static int saa7127_s_routing(struct v4l2_subdev *sd,
574 u32 input, u32 output, u32 config)
574{ 575{
575 struct saa7127_state *state = to_state(sd); 576 struct saa7127_state *state = to_state(sd);
576 int rc = 0; 577 int rc = 0;
577 578
578 if (state->input_type != route->input) 579 if (state->input_type != input)
579 rc = saa7127_set_input_type(sd, route->input); 580 rc = saa7127_set_input_type(sd, input);
580 if (rc == 0 && state->output_type != route->output) 581 if (rc == 0 && state->output_type != output)
581 rc = saa7127_set_output_type(sd, route->output); 582 rc = saa7127_set_output_type(sd, output);
582 return rc; 583 return rc;
583} 584}
584 585
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c
index b73801caaa9d..b15c40908e84 100644
--- a/drivers/media/video/saa717x.c
+++ b/drivers/media/video/saa717x.c
@@ -1104,22 +1104,22 @@ static struct v4l2_queryctrl saa717x_qctrl[] = {
1104 }, 1104 },
1105}; 1105};
1106 1106
1107static int saa717x_s_video_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 1107static int saa717x_s_video_routing(struct v4l2_subdev *sd,
1108 u32 input, u32 output, u32 config)
1108{ 1109{
1109 struct saa717x_state *decoder = to_state(sd); 1110 struct saa717x_state *decoder = to_state(sd);
1110 int inp = route->input; 1111 int is_tuner = input & 0x80; /* tuner input flag */
1111 int is_tuner = inp & 0x80; /* tuner input flag */
1112 1112
1113 inp &= 0x7f; 1113 input &= 0x7f;
1114 1114
1115 v4l2_dbg(1, debug, sd, "decoder set input (%d)\n", inp); 1115 v4l2_dbg(1, debug, sd, "decoder set input (%d)\n", input);
1116 /* inputs from 0-9 are available*/ 1116 /* inputs from 0-9 are available*/
1117 /* saa717x have mode0-mode9 but mode5 is reserved. */ 1117 /* saa717x have mode0-mode9 but mode5 is reserved. */
1118 if (inp < 0 || inp > 9 || inp == 5) 1118 if (input < 0 || input > 9 || input == 5)
1119 return -EINVAL; 1119 return -EINVAL;
1120 1120
1121 if (decoder->input != inp) { 1121 if (decoder->input != input) {
1122 int input_line = inp; 1122 int input_line = input;
1123 1123
1124 decoder->input = input_line; 1124 decoder->input = input_line;
1125 v4l2_dbg(1, debug, sd, "now setting %s input %d\n", 1125 v4l2_dbg(1, debug, sd, "now setting %s input %d\n",
@@ -1276,12 +1276,13 @@ static int saa717x_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
1276 return 0; 1276 return 0;
1277} 1277}
1278 1278
1279static int saa717x_s_audio_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 1279static int saa717x_s_audio_routing(struct v4l2_subdev *sd,
1280 u32 input, u32 output, u32 config)
1280{ 1281{
1281 struct saa717x_state *decoder = to_state(sd); 1282 struct saa717x_state *decoder = to_state(sd);
1282 1283
1283 if (route->input < 3) { /* FIXME! --tadachi */ 1284 if (input < 3) { /* FIXME! --tadachi */
1284 decoder->audio_input = route->input; 1285 decoder->audio_input = input;
1285 v4l2_dbg(1, debug, sd, 1286 v4l2_dbg(1, debug, sd,
1286 "set decoder audio input to %d\n", 1287 "set decoder audio input to %d\n",
1287 decoder->audio_input); 1288 decoder->audio_input);
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 75747b104d07..212baa10829b 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -245,14 +245,15 @@ static int saa7185_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std)
245 return 0; 245 return 0;
246} 246}
247 247
248static int saa7185_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 248static int saa7185_s_routing(struct v4l2_subdev *sd,
249 u32 input, u32 output, u32 config)
249{ 250{
250 struct saa7185 *encoder = to_saa7185(sd); 251 struct saa7185 *encoder = to_saa7185(sd);
251 252
252 /* RJ: route->input = 0: input is from SA7111 253 /* RJ: input = 0: input is from SA7111
253 route->input = 1: input is from ZR36060 */ 254 input = 1: input is from ZR36060 */
254 255
255 switch (route->input) { 256 switch (input) {
256 case 0: 257 case 0:
257 /* turn off colorbar */ 258 /* turn off colorbar */
258 saa7185_write(sd, 0x3a, 0x0f); 259 saa7185_write(sd, 0x3a, 0x0f);
diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c
index 13ab4f2ddcc5..a2513772196b 100644
--- a/drivers/media/video/saa7191.c
+++ b/drivers/media/video/saa7191.c
@@ -160,14 +160,14 @@ static int saa7191_write_block(struct v4l2_subdev *sd,
160/* Helper functions */ 160/* Helper functions */
161 161
162static int saa7191_s_routing(struct v4l2_subdev *sd, 162static int saa7191_s_routing(struct v4l2_subdev *sd,
163 const struct v4l2_routing *route) 163 u32 input, u32 output, u32 config)
164{ 164{
165 struct saa7191 *decoder = to_saa7191(sd); 165 struct saa7191 *decoder = to_saa7191(sd);
166 u8 luma = saa7191_read_reg(sd, SAA7191_REG_LUMA); 166 u8 luma = saa7191_read_reg(sd, SAA7191_REG_LUMA);
167 u8 iock = saa7191_read_reg(sd, SAA7191_REG_IOCK); 167 u8 iock = saa7191_read_reg(sd, SAA7191_REG_IOCK);
168 int err; 168 int err;
169 169
170 switch (route->input) { 170 switch (input) {
171 case SAA7191_INPUT_COMPOSITE: /* Set Composite input */ 171 case SAA7191_INPUT_COMPOSITE: /* Set Composite input */
172 iock &= ~(SAA7191_IOCK_CHRS | SAA7191_IOCK_GPSW1 172 iock &= ~(SAA7191_IOCK_CHRS | SAA7191_IOCK_GPSW1
173 | SAA7191_IOCK_GPSW2); 173 | SAA7191_IOCK_GPSW2);
@@ -190,7 +190,7 @@ static int saa7191_s_routing(struct v4l2_subdev *sd,
190 if (err) 190 if (err)
191 return -EIO; 191 return -EIO;
192 192
193 decoder->input = route->input; 193 decoder->input = input;
194 194
195 return 0; 195 return 0;
196} 196}
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index ff696d14a5dd..d4a9ed45764b 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -47,12 +47,11 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
47 47
48 48
49/* makes a connection between the input-pin 'i' and the output-pin 'o' */ 49/* makes a connection between the input-pin 'i' and the output-pin 'o' */
50static int tea6415c_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 50static int tea6415c_s_routing(struct v4l2_subdev *sd,
51 u32 i, u32 o, u32 config)
51{ 52{
52 struct i2c_client *client = v4l2_get_subdevdata(sd); 53 struct i2c_client *client = v4l2_get_subdevdata(sd);
53 u8 byte = 0; 54 u8 byte = 0;
54 u32 i = route->input;
55 u32 o = route->output;
56 int ret; 55 int ret;
57 56
58 v4l2_dbg(1, debug, sd, "i=%d, o=%d\n", i, o); 57 v4l2_dbg(1, debug, sd, "i=%d, o=%d\n", i, o);
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index 8a55b46ea9b7..ced6eadf347a 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -48,15 +48,15 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
48 48
49/* make a connection between the input 'i' and the output 'o' 49/* make a connection between the input 'i' and the output 'o'
50 with gain 'g' (note: i = 6 means 'mute') */ 50 with gain 'g' (note: i = 6 means 'mute') */
51static int tea6420_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 51static int tea6420_s_routing(struct v4l2_subdev *sd,
52 u32 i, u32 o, u32 config)
52{ 53{
53 struct i2c_client *client = v4l2_get_subdevdata(sd); 54 struct i2c_client *client = v4l2_get_subdevdata(sd);
54 int i = route->input; 55 int g = (o >> 4) & 0xf;
55 int o = route->output & 0xf;
56 int g = (route->output >> 4) & 0xf;
57 u8 byte; 56 u8 byte;
58 int ret; 57 int ret;
59 58
59 o &= 0xf;
60 v4l2_dbg(1, debug, sd, "i=%d, o=%d, g=%d\n", i, o, g); 60 v4l2_dbg(1, debug, sd, "i=%d, o=%d, g=%d\n", i, o, g);
61 61
62 /* check if the parameters are valid */ 62 /* check if the parameters are valid */
@@ -133,13 +133,8 @@ static int tea6420_probe(struct i2c_client *client,
133 133
134 /* set initial values: set "mute"-input to all outputs at gain 0 */ 134 /* set initial values: set "mute"-input to all outputs at gain 0 */
135 err = 0; 135 err = 0;
136 for (i = 1; i < 5; i++) { 136 for (i = 1; i < 5; i++)
137 struct v4l2_routing route; 137 err += tea6420_s_routing(sd, 6, i, 0);
138
139 route.input = 6;
140 route.output = i;
141 err += tea6420_s_routing(sd, &route);
142 }
143 if (err) { 138 if (err) {
144 v4l_dbg(1, debug, client, "could not initialize tea6420\n"); 139 v4l_dbg(1, debug, client, "could not initialize tea6420\n");
145 return -ENODEV; 140 return -ENODEV;
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 17d50e3cd518..0869bafc2b56 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1781,17 +1781,18 @@ static int tvaudio_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
1781 return -EINVAL; 1781 return -EINVAL;
1782} 1782}
1783 1783
1784static int tvaudio_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *rt) 1784static int tvaudio_s_routing(struct v4l2_subdev *sd,
1785 u32 input, u32 output, u32 config)
1785{ 1786{
1786 struct CHIPSTATE *chip = to_state(sd); 1787 struct CHIPSTATE *chip = to_state(sd);
1787 struct CHIPDESC *desc = chip->desc; 1788 struct CHIPDESC *desc = chip->desc;
1788 1789
1789 if (!(desc->flags & CHIP_HAS_INPUTSEL)) 1790 if (!(desc->flags & CHIP_HAS_INPUTSEL))
1790 return 0; 1791 return 0;
1791 if (rt->input >= 4) 1792 if (input >= 4)
1792 return -EINVAL; 1793 return -EINVAL;
1793 /* There are four inputs: tuner, radio, extern and intern. */ 1794 /* There are four inputs: tuner, radio, extern and intern. */
1794 chip->input = rt->input; 1795 chip->input = input;
1795 if (chip->muted) 1796 if (chip->muted)
1796 return 0; 1797 return 0;
1797 chip_write_masked(chip, desc->inputreg, 1798 chip_write_masked(chip, desc->inputreg,
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 4aea84a392e8..2d38e253f14e 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -69,7 +69,8 @@ struct tvp5150 {
69 struct v4l2_subdev sd; 69 struct v4l2_subdev sd;
70 70
71 v4l2_std_id norm; /* Current set standard */ 71 v4l2_std_id norm; /* Current set standard */
72 struct v4l2_routing route; 72 u32 input;
73 u32 output;
73 int enable; 74 int enable;
74 int bright; 75 int bright;
75 int contrast; 76 int contrast;
@@ -280,10 +281,10 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd)
280 int input = 0; 281 int input = 0;
281 unsigned char val; 282 unsigned char val;
282 283
283 if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable) 284 if ((decoder->output & TVP5150_BLACK_SCREEN) || !decoder->enable)
284 input = 8; 285 input = 8;
285 286
286 switch (decoder->route.input) { 287 switch (decoder->input) {
287 case TVP5150_COMPOSITE1: 288 case TVP5150_COMPOSITE1:
288 input |= 2; 289 input |= 2;
289 /* fall through */ 290 /* fall through */
@@ -299,8 +300,8 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd)
299 300
300 v4l2_dbg(1, debug, sd, "Selecting video route: route input=%i, output=%i " 301 v4l2_dbg(1, debug, sd, "Selecting video route: route input=%i, output=%i "
301 "=> tvp5150 input=%i, opmode=%i\n", 302 "=> tvp5150 input=%i, opmode=%i\n",
302 decoder->route.input,decoder->route.output, 303 decoder->input, decoder->output,
303 input, opmode ); 304 input, opmode);
304 305
305 tvp5150_write(sd, TVP5150_OP_MODE_CTL, opmode); 306 tvp5150_write(sd, TVP5150_OP_MODE_CTL, opmode);
306 tvp5150_write(sd, TVP5150_VD_IN_SRC_SEL_1, input); 307 tvp5150_write(sd, TVP5150_VD_IN_SRC_SEL_1, input);
@@ -309,7 +310,7 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd)
309 * For Composite and TV, it should be the reverse 310 * For Composite and TV, it should be the reverse
310 */ 311 */
311 val = tvp5150_read(sd, TVP5150_MISC_CTL); 312 val = tvp5150_read(sd, TVP5150_MISC_CTL);
312 if (decoder->route.input == TVP5150_SVIDEO) 313 if (decoder->input == TVP5150_SVIDEO)
313 val = (val & ~0x40) | 0x10; 314 val = (val & ~0x40) | 0x10;
314 else 315 else
315 val = (val & ~0x10) | 0x40; 316 val = (val & ~0x10) | 0x40;
@@ -878,11 +879,13 @@ static int tvp5150_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
878 I2C Command 879 I2C Command
879 ****************************************************************************/ 880 ****************************************************************************/
880 881
881static int tvp5150_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 882static int tvp5150_s_routing(struct v4l2_subdev *sd,
883 u32 input, u32 output, u32 config)
882{ 884{
883 struct tvp5150 *decoder = to_tvp5150(sd); 885 struct tvp5150 *decoder = to_tvp5150(sd);
884 886
885 decoder->route = *route; 887 decoder->input = input;
888 decoder->output = output;
886 tvp5150_selmux(sd); 889 tvp5150_selmux(sd);
887 return 0; 890 return 0;
888} 891}
@@ -1077,7 +1080,7 @@ static int tvp5150_probe(struct i2c_client *c,
1077 c->addr << 1, c->adapter->name); 1080 c->addr << 1, c->adapter->name);
1078 1081
1079 core->norm = V4L2_STD_ALL; /* Default is autodetect */ 1082 core->norm = V4L2_STD_ALL; /* Default is autodetect */
1080 core->route.input = TVP5150_COMPOSITE1; 1083 core->input = TVP5150_COMPOSITE1;
1081 core->enable = 1; 1084 core->enable = 1;
1082 core->bright = 128; 1085 core->bright = 128;
1083 core->contrast = 128; 1086 core->contrast = 128;
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c
index c0ac651bb358..a07a3fbb51eb 100644
--- a/drivers/media/video/upd64031a.c
+++ b/drivers/media/video/upd64031a.c
@@ -124,17 +124,18 @@ static int upd64031a_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *
124 124
125/* ------------------------------------------------------------------------ */ 125/* ------------------------------------------------------------------------ */
126 126
127static int upd64031a_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 127static int upd64031a_s_routing(struct v4l2_subdev *sd,
128 u32 input, u32 output, u32 config)
128{ 129{
129 struct upd64031a_state *state = to_state(sd); 130 struct upd64031a_state *state = to_state(sd);
130 u8 r00, r05, r08; 131 u8 r00, r05, r08;
131 132
132 state->gr_mode = (route->input & 3) << 6; 133 state->gr_mode = (input & 3) << 6;
133 state->direct_3dycs_connect = (route->input & 0xc) << 4; 134 state->direct_3dycs_connect = (input & 0xc) << 4;
134 state->ext_comp_sync = 135 state->ext_comp_sync =
135 (route->input & UPD64031A_COMPOSITE_EXTERNAL) << 1; 136 (input & UPD64031A_COMPOSITE_EXTERNAL) << 1;
136 state->ext_vert_sync = 137 state->ext_vert_sync =
137 (route->input & UPD64031A_VERTICAL_EXTERNAL) << 2; 138 (input & UPD64031A_VERTICAL_EXTERNAL) << 2;
138 r00 = (state->regs[R00] & ~GR_MODE_MASK) | state->gr_mode; 139 r00 = (state->regs[R00] & ~GR_MODE_MASK) | state->gr_mode;
139 r05 = (state->regs[R00] & ~SYNC_CIRCUIT_MASK) | 140 r05 = (state->regs[R00] & ~SYNC_CIRCUIT_MASK) |
140 state->ext_comp_sync | state->ext_vert_sync; 141 state->ext_comp_sync | state->ext_vert_sync;
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index 410c915d51fa..6eb0e5b00c32 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -102,15 +102,16 @@ static u8 upd64083_read(struct v4l2_subdev *sd, u8 reg)
102 102
103/* ------------------------------------------------------------------------ */ 103/* ------------------------------------------------------------------------ */
104 104
105static int upd64083_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 105static int upd64083_s_routing(struct v4l2_subdev *sd,
106 u32 input, u32 output, u32 config)
106{ 107{
107 struct upd64083_state *state = to_state(sd); 108 struct upd64083_state *state = to_state(sd);
108 u8 r00, r02; 109 u8 r00, r02;
109 110
110 if (route->input > 7 || (route->input & 6) == 6) 111 if (input > 7 || (input & 6) == 6)
111 return -EINVAL; 112 return -EINVAL;
112 state->mode = (route->input & 3) << 6; 113 state->mode = (input & 3) << 6;
113 state->ext_y_adc = (route->input & UPD64083_EXT_Y_ADC) << 3; 114 state->ext_y_adc = (input & UPD64083_EXT_Y_ADC) << 3;
114 r00 = (state->regs[R00] & ~(3 << 6)) | state->mode; 115 r00 = (state->regs[R00] & ~(3 << 6)) | state->mode;
115 r02 = (state->regs[R02] & ~(1 << 5)) | state->ext_y_adc; 116 r02 = (state->regs[R02] & ~(1 << 5)) | state->ext_y_adc;
116 upd64083_write(sd, R00, r00); 117 upd64083_write(sd, R00, r00);
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index a0feb1c97736..8bc03b9e1315 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -2597,7 +2597,6 @@ int usbvision_muxsel(struct usb_usbvision *usbvision, int channel)
2597 /* inputs #1 and #2 are variable for SAA7111 and SAA7113 */ 2597 /* inputs #1 and #2 are variable for SAA7111 and SAA7113 */
2598 int mode[4]= {SAA7115_COMPOSITE0, 0, 0, SAA7115_COMPOSITE3}; 2598 int mode[4]= {SAA7115_COMPOSITE0, 0, 0, SAA7115_COMPOSITE3};
2599 int audio[]= {1, 0, 0, 0}; 2599 int audio[]= {1, 0, 0, 0};
2600 struct v4l2_routing route;
2601 //channel 0 is TV with audiochannel 1 (tuner mono) 2600 //channel 0 is TV with audiochannel 1 (tuner mono)
2602 //channel 1 is Composite with audio channel 0 (line in) 2601 //channel 1 is Composite with audio channel 0 (line in)
2603 //channel 2 is S-Video with audio channel 0 (line in) 2602 //channel 2 is S-Video with audio channel 0 (line in)
@@ -2630,9 +2629,7 @@ int usbvision_muxsel(struct usb_usbvision *usbvision, int channel)
2630 mode[2] = SAA7115_SVIDEO1; 2629 mode[2] = SAA7115_SVIDEO1;
2631 break; 2630 break;
2632 } 2631 }
2633 route.input = mode[channel]; 2632 call_all(usbvision, video, s_routing, mode[channel], 0, 0);
2634 route.output = 0;
2635 call_all(usbvision, video, s_routing, &route);
2636 usbvision_set_audio(usbvision, audio[channel]); 2633 usbvision_set_audio(usbvision, audio[channel]);
2637 return 0; 2634 return 0;
2638} 2635}
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 2fb745464311..43e0998adb53 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -2565,12 +2565,11 @@ static int vino_acquire_input(struct vino_channel_settings *vcs)
2565 int input; 2565 int input;
2566 int data_norm; 2566 int data_norm;
2567 v4l2_std_id norm; 2567 v4l2_std_id norm;
2568 struct v4l2_routing route = { 0, 0 };
2569 2568
2570 input = VINO_INPUT_COMPOSITE; 2569 input = VINO_INPUT_COMPOSITE;
2571 2570
2572 route.input = vino_get_saa7191_input(input); 2571 ret = decoder_call(video, s_routing,
2573 ret = decoder_call(video, s_routing, &route); 2572 vino_get_saa7191_input(input), 0, 0);
2574 if (ret) { 2573 if (ret) {
2575 ret = -EINVAL; 2574 ret = -EINVAL;
2576 goto out; 2575 goto out;
@@ -2656,10 +2655,9 @@ static int vino_set_input(struct vino_channel_settings *vcs, int input)
2656 if (vino_drvdata->decoder_owner == vcs->channel) { 2655 if (vino_drvdata->decoder_owner == vcs->channel) {
2657 int data_norm; 2656 int data_norm;
2658 v4l2_std_id norm; 2657 v4l2_std_id norm;
2659 struct v4l2_routing route = { 0, 0 };
2660 2658
2661 route.input = vino_get_saa7191_input(input); 2659 ret = decoder_call(video, s_routing,
2662 ret = decoder_call(video, s_routing, &route); 2660 vino_get_saa7191_input(input), 0, 0);
2663 if (ret) { 2661 if (ret) {
2664 vino_drvdata->decoder_owner = VINO_NO_CHANNEL; 2662 vino_drvdata->decoder_owner = VINO_NO_CHANNEL;
2665 ret = -EINVAL; 2663 ret = -EINVAL;
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 59a8bb046c35..97e0ce28ff18 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -376,33 +376,34 @@ static int vpx3220_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
376 return 0; 376 return 0;
377} 377}
378 378
379static int vpx3220_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 379static int vpx3220_s_routing(struct v4l2_subdev *sd,
380 u32 input, u32 output, u32 config)
380{ 381{
381 int data; 382 int data;
382 383
383 /* RJ: route->input = 0: ST8 (PCTV) input 384 /* RJ: input = 0: ST8 (PCTV) input
384 route->input = 1: COMPOSITE input 385 input = 1: COMPOSITE input
385 route->input = 2: SVHS input */ 386 input = 2: SVHS input */
386 387
387 const int input[3][2] = { 388 const int input_vals[3][2] = {
388 {0x0c, 0}, 389 {0x0c, 0},
389 {0x0d, 0}, 390 {0x0d, 0},
390 {0x0e, 1} 391 {0x0e, 1}
391 }; 392 };
392 393
393 if (route->input < 0 || route->input > 2) 394 if (input < 0 || input > 2)
394 return -EINVAL; 395 return -EINVAL;
395 396
396 v4l2_dbg(1, debug, sd, "input switched to %s\n", inputs[route->input]); 397 v4l2_dbg(1, debug, sd, "input switched to %s\n", inputs[input]);
397 398
398 vpx3220_write(sd, 0x33, input[route->input][0]); 399 vpx3220_write(sd, 0x33, input_vals[input][0]);
399 400
400 data = vpx3220_fp_read(sd, 0xf2) & ~(0x0020); 401 data = vpx3220_fp_read(sd, 0xf2) & ~(0x0020);
401 if (data < 0) 402 if (data < 0)
402 return data; 403 return data;
403 /* 0x0010 is required to latch the setting */ 404 /* 0x0010 is required to latch the setting */
404 vpx3220_fp_write(sd, 0xf2, 405 vpx3220_fp_write(sd, 0xf2,
405 data | (input[route->input][1] << 5) | 0x0010); 406 data | (input_vals[input][1] << 5) | 0x0010);
406 407
407 udelay(10); 408 udelay(10);
408 return 0; 409 return 0;
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index eddf11abe1d9..f1f261a35245 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -79,7 +79,8 @@ static int wm8775_write(struct v4l2_subdev *sd, int reg, u16 val)
79 return -1; 79 return -1;
80} 80}
81 81
82static int wm8775_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route) 82static int wm8775_s_routing(struct v4l2_subdev *sd,
83 u32 input, u32 output, u32 config)
83{ 84{
84 struct wm8775_state *state = to_state(sd); 85 struct wm8775_state *state = to_state(sd);
85 86
@@ -88,11 +89,11 @@ static int wm8775_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *r
88 16 combinations. 89 16 combinations.
89 If only one input is active (the normal case) then the 90 If only one input is active (the normal case) then the
90 input values 1, 2, 4 or 8 should be used. */ 91 input values 1, 2, 4 or 8 should be used. */
91 if (route->input > 15) { 92 if (input > 15) {
92 v4l2_err(sd, "Invalid input %d.\n", route->input); 93 v4l2_err(sd, "Invalid input %d.\n", input);
93 return -EINVAL; 94 return -EINVAL;
94 } 95 }
95 state->input = route->input; 96 state->input = input;
96 if (state->muted) 97 if (state->muted)
97 return 0; 98 return 0;
98 wm8775_write(sd, R21, 0x0c0); 99 wm8775_write(sd, R21, 0x0c0);
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c
index 1ef70b090c4c..ea6c577b0eb3 100644
--- a/drivers/media/video/zoran/zoran_card.c
+++ b/drivers/media/video/zoran/zoran_card.c
@@ -1087,10 +1087,8 @@ zr36057_init (struct zoran *zr)
1087 detect_guest_activity(zr); 1087 detect_guest_activity(zr);
1088 test_interrupts(zr); 1088 test_interrupts(zr);
1089 if (!pass_through) { 1089 if (!pass_through) {
1090 struct v4l2_routing route = { 2, 0 };
1091
1092 decoder_call(zr, video, s_stream, 0); 1090 decoder_call(zr, video, s_stream, 0);
1093 encoder_call(zr, video, s_routing, &route); 1091 encoder_call(zr, video, s_routing, 2, 0, 0);
1094 } 1092 }
1095 1093
1096 zr->zoran_proc = NULL; 1094 zr->zoran_proc = NULL;
diff --git a/drivers/media/video/zoran/zoran_device.c b/drivers/media/video/zoran/zoran_device.c
index 25e565f0502a..f6c2fb4fc3b4 100644
--- a/drivers/media/video/zoran/zoran_device.c
+++ b/drivers/media/video/zoran/zoran_device.c
@@ -971,7 +971,6 @@ zr36057_enable_jpg (struct zoran *zr,
971 struct vfe_settings cap; 971 struct vfe_settings cap;
972 int field_size = 972 int field_size =
973 zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff; 973 zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff;
974 struct v4l2_routing route = { 0, 0 };
975 974
976 zr->codec_mode = mode; 975 zr->codec_mode = mode;
977 976
@@ -994,8 +993,7 @@ zr36057_enable_jpg (struct zoran *zr,
994 */ 993 */
995 set_videobus_dir(zr, 0); 994 set_videobus_dir(zr, 0);
996 decoder_call(zr, video, s_stream, 1); 995 decoder_call(zr, video, s_stream, 1);
997 route.input = 0; 996 encoder_call(zr, video, s_routing, 0, 0, 0);
998 encoder_call(zr, video, s_routing, &route);
999 997
1000 /* Take the JPEG codec and the VFE out of sleep */ 998 /* Take the JPEG codec and the VFE out of sleep */
1001 jpeg_codec_sleep(zr, 0); 999 jpeg_codec_sleep(zr, 0);
@@ -1043,8 +1041,7 @@ zr36057_enable_jpg (struct zoran *zr,
1043 */ 1041 */
1044 decoder_call(zr, video, s_stream, 0); 1042 decoder_call(zr, video, s_stream, 0);
1045 set_videobus_dir(zr, 1); 1043 set_videobus_dir(zr, 1);
1046 route.input = 1; 1044 encoder_call(zr, video, s_routing, 1, 0, 0);
1047 encoder_call(zr, video, s_routing, &route);
1048 1045
1049 /* Take the JPEG codec and the VFE out of sleep */ 1046 /* Take the JPEG codec and the VFE out of sleep */
1050 jpeg_codec_sleep(zr, 0); 1047 jpeg_codec_sleep(zr, 0);
@@ -1089,8 +1086,7 @@ zr36057_enable_jpg (struct zoran *zr,
1089 zr36057_adjust_vfe(zr, mode); 1086 zr36057_adjust_vfe(zr, mode);
1090 1087
1091 decoder_call(zr, video, s_stream, 1); 1088 decoder_call(zr, video, s_stream, 1);
1092 route.input = 0; 1089 encoder_call(zr, video, s_routing, 0, 0, 0);
1093 encoder_call(zr, video, s_routing, &route);
1094 1090
1095 dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); 1091 dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr));
1096 break; 1092 break;
@@ -1571,8 +1567,6 @@ zoran_set_pci_master (struct zoran *zr,
1571void 1567void
1572zoran_init_hardware (struct zoran *zr) 1568zoran_init_hardware (struct zoran *zr)
1573{ 1569{
1574 struct v4l2_routing route = { 0, 0 };
1575
1576 /* Enable bus-mastering */ 1570 /* Enable bus-mastering */
1577 zoran_set_pci_master(zr, 1); 1571 zoran_set_pci_master(zr, 1);
1578 1572
@@ -1581,16 +1575,14 @@ zoran_init_hardware (struct zoran *zr)
1581 zr->card.init(zr); 1575 zr->card.init(zr);
1582 } 1576 }
1583 1577
1584 route.input = zr->card.input[zr->input].muxsel;
1585
1586 decoder_call(zr, core, init, 0); 1578 decoder_call(zr, core, init, 0);
1587 decoder_call(zr, core, s_std, zr->norm); 1579 decoder_call(zr, core, s_std, zr->norm);
1588 decoder_call(zr, video, s_routing, &route); 1580 decoder_call(zr, video, s_routing,
1581 zr->card.input[zr->input].muxsel, 0, 0);
1589 1582
1590 encoder_call(zr, core, init, 0); 1583 encoder_call(zr, core, init, 0);
1591 encoder_call(zr, video, s_std_output, zr->norm); 1584 encoder_call(zr, video, s_std_output, zr->norm);
1592 route.input = 0; 1585 encoder_call(zr, video, s_routing, 0, 0, 0);
1593 encoder_call(zr, video, s_routing, &route);
1594 1586
1595 /* toggle JPEG codec sleep to sync PLL */ 1587 /* toggle JPEG codec sleep to sync PLL */
1596 jpeg_codec_sleep(zr, 1); 1588 jpeg_codec_sleep(zr, 1);
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c
index 979e8d0e80f5..092333b1c34f 100644
--- a/drivers/media/video/zoran/zoran_driver.c
+++ b/drivers/media/video/zoran/zoran_driver.c
@@ -1018,10 +1018,8 @@ zoran_close(struct file *file)
1018 zoran_set_pci_master(zr, 0); 1018 zoran_set_pci_master(zr, 0);
1019 1019
1020 if (!pass_through) { /* Switch to color bar */ 1020 if (!pass_through) { /* Switch to color bar */
1021 struct v4l2_routing route = { 2, 0 };
1022
1023 decoder_call(zr, video, s_stream, 0); 1021 decoder_call(zr, video, s_stream, 0);
1024 encoder_call(zr, video, s_routing, &route); 1022 encoder_call(zr, video, s_routing, 2, 0, 0);
1025 } 1023 }
1026 } 1024 }
1027 1025
@@ -1496,8 +1494,6 @@ static int
1496zoran_set_input (struct zoran *zr, 1494zoran_set_input (struct zoran *zr,
1497 int input) 1495 int input)
1498{ 1496{
1499 struct v4l2_routing route = { 0, 0 };
1500
1501 if (input == zr->input) { 1497 if (input == zr->input) {
1502 return 0; 1498 return 0;
1503 } 1499 }
@@ -1519,10 +1515,10 @@ zoran_set_input (struct zoran *zr,
1519 return -EINVAL; 1515 return -EINVAL;
1520 } 1516 }
1521 1517
1522 route.input = zr->card.input[input].muxsel;
1523 zr->input = input; 1518 zr->input = input;
1524 1519
1525 decoder_call(zr, video, s_routing, &route); 1520 decoder_call(zr, video, s_routing,
1521 zr->card.input[input].muxsel, 0, 0);
1526 1522
1527 return 0; 1523 return 0;
1528} 1524}
@@ -1748,7 +1744,6 @@ jpgreqbuf_unlock_and_return:
1748 case BUZIOC_G_STATUS: 1744 case BUZIOC_G_STATUS:
1749 { 1745 {
1750 struct zoran_status *bstat = arg; 1746 struct zoran_status *bstat = arg;
1751 struct v4l2_routing route = { 0, 0 };
1752 int status = 0, res = 0; 1747 int status = 0, res = 0;
1753 v4l2_std_id norm; 1748 v4l2_std_id norm;
1754 1749
@@ -1762,8 +1757,6 @@ jpgreqbuf_unlock_and_return:
1762 return -EINVAL; 1757 return -EINVAL;
1763 } 1758 }
1764 1759
1765 route.input = zr->card.input[bstat->input].muxsel;
1766
1767 mutex_lock(&zr->resource_lock); 1760 mutex_lock(&zr->resource_lock);
1768 1761
1769 if (zr->codec_mode != BUZ_MODE_IDLE) { 1762 if (zr->codec_mode != BUZ_MODE_IDLE) {
@@ -1775,7 +1768,8 @@ jpgreqbuf_unlock_and_return:
1775 goto gstat_unlock_and_return; 1768 goto gstat_unlock_and_return;
1776 } 1769 }
1777 1770
1778 decoder_call(zr, video, s_routing, &route); 1771 decoder_call(zr, video, s_routing,
1772 zr->card.input[bstat->input].muxsel, 0, 0);
1779 1773
1780 /* sleep 1 second */ 1774 /* sleep 1 second */
1781 ssleep(1); 1775 ssleep(1);
@@ -1785,8 +1779,8 @@ jpgreqbuf_unlock_and_return:
1785 decoder_call(zr, video, g_input_status, &status); 1779 decoder_call(zr, video, g_input_status, &status);
1786 1780
1787 /* restore previous input and norm */ 1781 /* restore previous input and norm */
1788 route.input = zr->card.input[zr->input].muxsel; 1782 decoder_call(zr, video, s_routing,
1789 decoder_call(zr, video, s_routing, &route); 1783 zr->card.input[zr->input].muxsel, 0, 0);
1790gstat_unlock_and_return: 1784gstat_unlock_and_return:
1791 mutex_unlock(&zr->resource_lock); 1785 mutex_unlock(&zr->resource_lock);
1792 1786