Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (3712): Fix video input setting of em28xx, use _INT_S_VIDEO_ROUTING in tvp5150

- Use new routing input defines in em28xx-cards.c
- Fix S-Video settings for tvp5150-based cards (input was copied from saa7115
based cards and worked only because S-Video was selected in the default: case)
- Replace VIDIOC_S_INPUT by VIDIOC_INT_S_VIDEO_ROUTING in em28xx-video.c
- Remove the now obsolete VIDIOC_S_INPUT handler in saa7115.c
- Add VIDIOC_INT_G/S_VIDEO_ROUTING in tvp5150.c
- Add new media/tvp5150.h with the routing defines.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
c7c0b34c b7f8292c

+104 -79
+30 -28
drivers/media/video/em28xx/em28xx-cards.c
··· 29 29 #include <linux/usb.h> 30 30 #include <media/tuner.h> 31 31 #include <media/msp3400.h> 32 + #include <media/saa7115.h> 33 + #include <media/tvp5150.h> 32 34 #include <media/tveeprom.h> 33 35 #include <media/audiochip.h> 34 36 #include <media/v4l2-common.h> ··· 48 46 .decoder = EM28XX_SAA7113, 49 47 .input = {{ 50 48 .type = EM28XX_VMUX_COMPOSITE1, 51 - .vmux = 0, 49 + .vmux = SAA7115_COMPOSITE0, 52 50 .amux = 1, 53 51 },{ 54 52 .type = EM28XX_VMUX_SVIDEO, 55 - .vmux = 9, 53 + .vmux = SAA7115_SVIDEO3, 56 54 .amux = 1, 57 55 }}, 58 56 }, ··· 66 64 .decoder = EM28XX_SAA7113, 67 65 .input = {{ 68 66 .type = EM28XX_VMUX_COMPOSITE1, 69 - .vmux = 0, 67 + .vmux = SAA7115_COMPOSITE0, 70 68 .amux = 1, 71 69 },{ 72 70 .type = EM28XX_VMUX_SVIDEO, 73 - .vmux = 9, 71 + .vmux = SAA7115_SVIDEO3, 74 72 .amux = 1, 75 73 }}, 76 74 }, ··· 84 82 .decoder = EM28XX_SAA7113, 85 83 .input = {{ 86 84 .type = EM28XX_VMUX_COMPOSITE1, 87 - .vmux = 0, 85 + .vmux = SAA7115_COMPOSITE0, 88 86 .amux = 1, 89 87 },{ 90 88 .type = EM28XX_VMUX_SVIDEO, 91 - .vmux = 9, 89 + .vmux = SAA7115_SVIDEO3, 92 90 .amux = 1, 93 91 }}, 94 92 }, ··· 102 100 .decoder = EM28XX_SAA7113, 103 101 .input = {{ 104 102 .type = EM28XX_VMUX_TELEVISION, 105 - .vmux = 2, 103 + .vmux = SAA7115_COMPOSITE2, 106 104 .amux = 1, 107 105 },{ 108 106 .type = EM28XX_VMUX_COMPOSITE1, 109 - .vmux = 0, 107 + .vmux = SAA7115_COMPOSITE0, 110 108 .amux = 1, 111 109 },{ 112 110 .type = EM28XX_VMUX_SVIDEO, 113 - .vmux = 9, 111 + .vmux = SAA7115_SVIDEO3, 114 112 .amux = 1, 115 113 }}, 116 114 }, ··· 124 122 .decoder = EM28XX_SAA7113, 125 123 .input = {{ 126 124 .type = EM28XX_VMUX_TELEVISION, 127 - .vmux = 2, 125 + .vmux = SAA7115_COMPOSITE2, 128 126 .amux = 0, 129 127 },{ 130 128 .type = EM28XX_VMUX_COMPOSITE1, 131 - .vmux = 0, 129 + .vmux = SAA7115_COMPOSITE0, 132 130 .amux = 1, 133 131 },{ 134 132 .type = EM28XX_VMUX_SVIDEO, 135 - .vmux = 9, 133 + .vmux = SAA7115_SVIDEO3, 136 134 .amux = 1, 137 135 }}, 138 136 }, ··· 148 146 /*FIXME: S-Video not tested */ 149 147 .input = {{ 150 148 .type = EM28XX_VMUX_TELEVISION, 151 - .vmux = 0, 149 + .vmux = TVP5150_COMPOSITE0, 152 150 .amux = MSP_INPUT_DEFAULT, 153 151 },{ 154 152 .type = EM28XX_VMUX_SVIDEO, 155 - .vmux = 2, 153 + .vmux = TVP5150_SVIDEO, 156 154 .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, 157 155 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART), 158 156 }}, ··· 167 165 .decoder = EM28XX_SAA7114, 168 166 .input = {{ 169 167 .type = EM28XX_VMUX_TELEVISION, 170 - .vmux = 4, 168 + .vmux = SAA7115_COMPOSITE4, 171 169 .amux = 0, 172 170 },{ 173 171 .type = EM28XX_VMUX_COMPOSITE1, 174 - .vmux = 0, 172 + .vmux = SAA7115_COMPOSITE0, 175 173 .amux = 1, 176 174 },{ 177 175 .type = EM28XX_VMUX_SVIDEO, 178 - .vmux = 9, 176 + .vmux = SAA7115_SVIDEO3, 179 177 .amux = 1, 180 178 }}, 181 179 }, ··· 190 188 .decoder = EM28XX_SAA7113, 191 189 .input = {{ 192 190 .type = EM28XX_VMUX_TELEVISION, 193 - .vmux = 2, 191 + .vmux = SAA7115_COMPOSITE2, 194 192 .amux = 0, 195 193 },{ 196 194 .type = EM28XX_VMUX_COMPOSITE1, 197 - .vmux = 0, 195 + .vmux = SAA7115_COMPOSITE0, 198 196 .amux = 1, 199 197 },{ 200 198 .type = EM28XX_VMUX_SVIDEO, 201 - .vmux = 9, 199 + .vmux = SAA7115_SVIDEO3, 202 200 .amux = 1, 203 201 }}, 204 202 }, ··· 213 211 .decoder = EM28XX_SAA7113, 214 212 .input = {{ 215 213 .type = EM28XX_VMUX_TELEVISION, 216 - .vmux = 2, 214 + .vmux = SAA7115_COMPOSITE2, 217 215 .amux = 0, 218 216 },{ 219 217 .type = EM28XX_VMUX_COMPOSITE1, 220 - .vmux = 0, 218 + .vmux = SAA7115_COMPOSITE0, 221 219 .amux = 1, 222 220 },{ 223 221 .type = EM28XX_VMUX_SVIDEO, 224 - .vmux = 9, 222 + .vmux = SAA7115_SVIDEO3, 225 223 .amux = 1, 226 224 }}, 227 225 }, ··· 236 234 .decoder = EM28XX_SAA7113, 237 235 .input = {{ 238 236 .type = EM28XX_VMUX_TELEVISION, 239 - .vmux = 2, 237 + .vmux = SAA7115_COMPOSITE2, 240 238 .amux = 0, 241 239 },{ 242 240 .type = EM28XX_VMUX_COMPOSITE1, 243 - .vmux = 0, 241 + .vmux = SAA7115_COMPOSITE0, 244 242 .amux = 1, 245 243 },{ 246 244 .type = EM28XX_VMUX_SVIDEO, 247 - .vmux = 9, 245 + .vmux = SAA7115_SVIDEO3, 248 246 .amux = 1, 249 247 }}, 250 248 }, ··· 256 254 .decoder = EM28XX_SAA7113, 257 255 .input = {{ 258 256 .type = EM28XX_VMUX_COMPOSITE1, 259 - .vmux = 0, 257 + .vmux = SAA7115_COMPOSITE0, 260 258 .amux = 1, 261 259 },{ 262 260 .type = EM28XX_VMUX_SVIDEO, 263 - .vmux = 9, 261 + .vmux = SAA7115_SVIDEO3, 264 262 .amux = 1, 265 263 }}, 266 264 },
+11 -7
drivers/media/video/em28xx/em28xx-video.c
··· 170 170 static void em28xx_config_i2c(struct em28xx *dev) 171 171 { 172 172 struct v4l2_frequency f; 173 + struct v4l2_routing route; 174 + 175 + route.input = INPUT(dev->ctl_input)->vmux; 176 + route.output = 0; 173 177 em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, NULL); 174 - em28xx_i2c_call_clients(dev, VIDIOC_S_INPUT, &dev->ctl_input); 178 + em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); 175 179 em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL); 176 180 177 181 /* configure tuner */ ··· 210 206 211 207 static void video_mux(struct em28xx *dev, int index) 212 208 { 213 - int input, ainput; 209 + int ainput; 210 + struct v4l2_routing route; 214 211 215 - input = INPUT(index)->vmux; 212 + route.input = INPUT(index)->vmux; 213 + route.output = 0; 216 214 dev->ctl_input = index; 217 215 dev->ctl_ainput = INPUT(index)->amux; 218 216 219 - em28xx_i2c_call_clients(dev, VIDIOC_S_INPUT, &input); 217 + em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); 220 218 221 - em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput); 219 + em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,route.input,dev->ctl_ainput); 222 220 223 221 if (dev->has_msp34xx) { 224 - struct v4l2_routing route; 225 - 226 222 if (dev->i2s_speed) 227 223 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed); 228 224 route.input = dev->ctl_ainput;
-28
drivers/media/video/saa7115.c
··· 1238 1238 break; 1239 1239 } 1240 1240 1241 - case VIDIOC_G_INPUT: 1242 - *(int *)arg = state->input; 1243 - break; 1244 - 1245 - case VIDIOC_S_INPUT: 1246 - v4l_dbg(1, debug, client, "decoder set input %d\n", *iarg); 1247 - /* inputs from 0-9 are available */ 1248 - if (*iarg < 0 || *iarg > 9) { 1249 - return -EINVAL; 1250 - } 1251 - 1252 - if (state->input == *iarg) 1253 - break; 1254 - v4l_dbg(1, debug, client, "now setting %s input\n", 1255 - *iarg >= 6 ? "S-Video" : "Composite"); 1256 - state->input = *iarg; 1257 - 1258 - /* select mode */ 1259 - saa7115_write(client, 0x02, 1260 - (saa7115_read(client, 0x02) & 0xf0) | 1261 - state->input); 1262 - 1263 - /* bypass chrominance trap for modes 6..9 */ 1264 - saa7115_write(client, 0x09, 1265 - (saa7115_read(client, 0x09) & 0x7f) | 1266 - (state->input < 6 ? 0x0 : 0x80)); 1267 - break; 1268 - 1269 1241 case VIDIOC_STREAMON: 1270 1242 case VIDIOC_STREAMOFF: 1271 1243 v4l_dbg(1, debug, client, "%s output\n",
+29 -16
drivers/media/video/tvp5150.c
··· 10 10 #include <linux/delay.h> 11 11 #include <linux/video_decoder.h> 12 12 #include <media/v4l2-common.h> 13 + #include <media/tvp5150.h> 13 14 14 15 #include "tvp5150_reg.h" 15 16 ··· 90 89 struct i2c_client *client; 91 90 92 91 v4l2_std_id norm; /* Current set standard */ 93 - int input; 92 + struct v4l2_routing route; 94 93 int enable; 95 94 int bright; 96 95 int contrast; ··· 284 283 /**************************************************************************** 285 284 Basic functions 286 285 ****************************************************************************/ 287 - enum tvp5150_input { 288 - TVP5150_ANALOG_CH0 = 0, 289 - TVP5150_SVIDEO = 1, 290 - TVP5150_ANALOG_CH1 = 2, 291 - TVP5150_BLACK_SCREEN = 8 292 - }; 293 286 294 - static inline void tvp5150_selmux(struct i2c_client *c, 295 - enum tvp5150_input input) 287 + static inline void tvp5150_selmux(struct i2c_client *c) 296 288 { 297 289 int opmode=0; 298 - 299 290 struct tvp5150 *decoder = i2c_get_clientdata(c); 291 + int input = 0; 300 292 301 - if (!decoder->enable) 302 - input |= TVP5150_BLACK_SCREEN; 293 + if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable) 294 + input = 8; 303 295 304 296 switch (input) { 305 - case TVP5150_ANALOG_CH0: 306 - case TVP5150_ANALOG_CH1: 297 + case TVP5150_COMPOSITE1: 298 + input |= 2; 299 + /* fall through */ 300 + case TVP5150_COMPOSITE0: 307 301 opmode=0x30; /* TV Mode */ 308 302 break; 303 + case TVP5150_SVIDEO: 309 304 default: 305 + input |= 1; 310 306 opmode=0; /* Auto Mode */ 311 307 break; 312 308 } ··· 788 790 tvp5150_vdp_init(c, vbi_ram_default); 789 791 790 792 /* Selects decoder input */ 791 - tvp5150_selmux(c, decoder->input); 793 + tvp5150_selmux(c); 792 794 793 795 /* Initializes TVP5150 to stream enabled values */ 794 796 tvp5150_write_inittab(c, tvp5150_init_enable); ··· 858 860 case VIDIOC_INT_RESET: 859 861 tvp5150_reset(c); 860 862 break; 863 + case VIDIOC_INT_G_VIDEO_ROUTING: 864 + { 865 + struct v4l2_routing *route = arg; 866 + 867 + *route = decoder->route; 868 + break; 869 + } 870 + case VIDIOC_INT_S_VIDEO_ROUTING: 871 + { 872 + struct v4l2_routing *route = arg; 873 + 874 + decoder->route = *route; 875 + tvp5150_selmux(c); 876 + break; 877 + } 861 878 case VIDIOC_S_STD: 862 879 if (decoder->norm == *(v4l2_std_id *)arg) 863 880 break; ··· 1076 1063 rv = i2c_attach_client(c); 1077 1064 1078 1065 core->norm = V4L2_STD_ALL; /* Default is autodetect */ 1079 - core->input = 2; 1066 + core->route.input = TVP5150_COMPOSITE1; 1080 1067 core->enable = 1; 1081 1068 core->bright = 32768; 1082 1069 core->contrast = 32768;
+34
include/media/tvp5150.h
··· 1 + /* 2 + tvp5150.h - definition for tvp5150 inputs 3 + 4 + Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl) 5 + 6 + This program is free software; you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation; either version 2 of the License, or 9 + (at your option) any later version. 10 + 11 + This program is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with this program; if not, write to the Free Software 18 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 + */ 20 + 21 + #ifndef _TVP5150_H_ 22 + #define _TVP5150_H_ 23 + 24 + /* TVP5150 HW inputs */ 25 + #define TVP5150_COMPOSITE0 0 26 + #define TVP5150_COMPOSITE1 1 27 + #define TVP5150_SVIDEO 2 28 + 29 + /* TVP5150 HW outputs */ 30 + #define TVP5150_NORMAL 0 31 + #define TVP5150_BLACK_SCREEN 1 32 + 33 + #endif 34 +