Commit c7c0b34c authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

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: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent b7f8292c
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <linux/usb.h> #include <linux/usb.h>
#include <media/tuner.h> #include <media/tuner.h>
#include <media/msp3400.h> #include <media/msp3400.h>
#include <media/saa7115.h>
#include <media/tvp5150.h>
#include <media/tveeprom.h> #include <media/tveeprom.h>
#include <media/audiochip.h> #include <media/audiochip.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
...@@ -46,11 +48,11 @@ struct em28xx_board em28xx_boards[] = { ...@@ -46,11 +48,11 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -64,11 +66,11 @@ struct em28xx_board em28xx_boards[] = { ...@@ -64,11 +66,11 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -82,11 +84,11 @@ struct em28xx_board em28xx_boards[] = { ...@@ -82,11 +84,11 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -100,15 +102,15 @@ struct em28xx_board em28xx_boards[] = { ...@@ -100,15 +102,15 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_TELEVISION, .type = EM28XX_VMUX_TELEVISION,
.vmux = 2, .vmux = SAA7115_COMPOSITE2,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -122,15 +124,15 @@ struct em28xx_board em28xx_boards[] = { ...@@ -122,15 +124,15 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_TELEVISION, .type = EM28XX_VMUX_TELEVISION,
.vmux = 2, .vmux = SAA7115_COMPOSITE2,
.amux = 0, .amux = 0,
},{ },{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -146,11 +148,11 @@ struct em28xx_board em28xx_boards[] = { ...@@ -146,11 +148,11 @@ struct em28xx_board em28xx_boards[] = {
/*FIXME: S-Video not tested */ /*FIXME: S-Video not tested */
.input = {{ .input = {{
.type = EM28XX_VMUX_TELEVISION, .type = EM28XX_VMUX_TELEVISION,
.vmux = 0, .vmux = TVP5150_COMPOSITE0,
.amux = MSP_INPUT_DEFAULT, .amux = MSP_INPUT_DEFAULT,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 2, .vmux = TVP5150_SVIDEO,
.amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
MSP_DSP_IN_SCART, MSP_DSP_IN_SCART), MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
}}, }},
...@@ -165,15 +167,15 @@ struct em28xx_board em28xx_boards[] = { ...@@ -165,15 +167,15 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7114, .decoder = EM28XX_SAA7114,
.input = {{ .input = {{
.type = EM28XX_VMUX_TELEVISION, .type = EM28XX_VMUX_TELEVISION,
.vmux = 4, .vmux = SAA7115_COMPOSITE4,
.amux = 0, .amux = 0,
},{ },{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -188,15 +190,15 @@ struct em28xx_board em28xx_boards[] = { ...@@ -188,15 +190,15 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_TELEVISION, .type = EM28XX_VMUX_TELEVISION,
.vmux = 2, .vmux = SAA7115_COMPOSITE2,
.amux = 0, .amux = 0,
},{ },{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -211,15 +213,15 @@ struct em28xx_board em28xx_boards[] = { ...@@ -211,15 +213,15 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_TELEVISION, .type = EM28XX_VMUX_TELEVISION,
.vmux = 2, .vmux = SAA7115_COMPOSITE2,
.amux = 0, .amux = 0,
},{ },{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -234,15 +236,15 @@ struct em28xx_board em28xx_boards[] = { ...@@ -234,15 +236,15 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_TELEVISION, .type = EM28XX_VMUX_TELEVISION,
.vmux = 2, .vmux = SAA7115_COMPOSITE2,
.amux = 0, .amux = 0,
},{ },{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
...@@ -254,11 +256,11 @@ struct em28xx_board em28xx_boards[] = { ...@@ -254,11 +256,11 @@ struct em28xx_board em28xx_boards[] = {
.decoder = EM28XX_SAA7113, .decoder = EM28XX_SAA7113,
.input = {{ .input = {{
.type = EM28XX_VMUX_COMPOSITE1, .type = EM28XX_VMUX_COMPOSITE1,
.vmux = 0, .vmux = SAA7115_COMPOSITE0,
.amux = 1, .amux = 1,
},{ },{
.type = EM28XX_VMUX_SVIDEO, .type = EM28XX_VMUX_SVIDEO,
.vmux = 9, .vmux = SAA7115_SVIDEO3,
.amux = 1, .amux = 1,
}}, }},
}, },
......
...@@ -170,8 +170,12 @@ static int em28xx_config(struct em28xx *dev) ...@@ -170,8 +170,12 @@ static int em28xx_config(struct em28xx *dev)
static void em28xx_config_i2c(struct em28xx *dev) static void em28xx_config_i2c(struct em28xx *dev)
{ {
struct v4l2_frequency f; struct v4l2_frequency f;
struct v4l2_routing route;
route.input = INPUT(dev->ctl_input)->vmux;
route.output = 0;
em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, NULL); em28xx_i2c_call_clients(dev, VIDIOC_INT_RESET, NULL);
em28xx_i2c_call_clients(dev, VIDIOC_S_INPUT, &dev->ctl_input); em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL); em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL);
/* configure tuner */ /* configure tuner */
...@@ -206,19 +210,19 @@ static void em28xx_empty_framequeues(struct em28xx *dev) ...@@ -206,19 +210,19 @@ static void em28xx_empty_framequeues(struct em28xx *dev)
static void video_mux(struct em28xx *dev, int index) static void video_mux(struct em28xx *dev, int index)
{ {
int input, ainput; int ainput;
struct v4l2_routing route;
input = INPUT(index)->vmux; route.input = INPUT(index)->vmux;
route.output = 0;
dev->ctl_input = index; dev->ctl_input = index;
dev->ctl_ainput = INPUT(index)->amux; dev->ctl_ainput = INPUT(index)->amux;
em28xx_i2c_call_clients(dev, VIDIOC_S_INPUT, &input); em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput); em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,route.input,dev->ctl_ainput);
if (dev->has_msp34xx) { if (dev->has_msp34xx) {
struct v4l2_routing route;
if (dev->i2s_speed) if (dev->i2s_speed)
em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed); em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed);
route.input = dev->ctl_ainput; route.input = dev->ctl_ainput;
......
...@@ -1238,34 +1238,6 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar ...@@ -1238,34 +1238,6 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
break; break;
} }
case VIDIOC_G_INPUT:
*(int *)arg = state->input;
break;
case VIDIOC_S_INPUT:
v4l_dbg(1, debug, client, "decoder set input %d\n", *iarg);
/* inputs from 0-9 are available */
if (*iarg < 0 || *iarg > 9) {
return -EINVAL;
}
if (state->input == *iarg)
break;
v4l_dbg(1, debug, client, "now setting %s input\n",
*iarg >= 6 ? "S-Video" : "Composite");
state->input = *iarg;
/* select mode */
saa7115_write(client, 0x02,
(saa7115_read(client, 0x02) & 0xf0) |
state->input);
/* bypass chrominance trap for modes 6..9 */
saa7115_write(client, 0x09,
(saa7115_read(client, 0x09) & 0x7f) |
(state->input < 6 ? 0x0 : 0x80));
break;
case VIDIOC_STREAMON: case VIDIOC_STREAMON:
case VIDIOC_STREAMOFF: case VIDIOC_STREAMOFF:
v4l_dbg(1, debug, client, "%s output\n", v4l_dbg(1, debug, client, "%s output\n",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/video_decoder.h> #include <linux/video_decoder.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/tvp5150.h>
#include "tvp5150_reg.h" #include "tvp5150_reg.h"
...@@ -89,7 +90,7 @@ struct tvp5150 { ...@@ -89,7 +90,7 @@ struct tvp5150 {
struct i2c_client *client; struct i2c_client *client;
v4l2_std_id norm; /* Current set standard */ v4l2_std_id norm; /* Current set standard */
int input; struct v4l2_routing route;
int enable; int enable;
int bright; int bright;
int contrast; int contrast;
...@@ -283,29 +284,26 @@ static void dump_reg(struct i2c_client *c) ...@@ -283,29 +284,26 @@ static void dump_reg(struct i2c_client *c)
/**************************************************************************** /****************************************************************************
Basic functions Basic functions
****************************************************************************/ ****************************************************************************/
enum tvp5150_input {
TVP5150_ANALOG_CH0 = 0,
TVP5150_SVIDEO = 1,
TVP5150_ANALOG_CH1 = 2,
TVP5150_BLACK_SCREEN = 8
};
static inline void tvp5150_selmux(struct i2c_client *c, static inline void tvp5150_selmux(struct i2c_client *c)
enum tvp5150_input input)
{ {
int opmode=0; int opmode=0;
struct tvp5150 *decoder = i2c_get_clientdata(c); struct tvp5150 *decoder = i2c_get_clientdata(c);
int input = 0;
if (!decoder->enable) if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable)
input |= TVP5150_BLACK_SCREEN; input = 8;
switch (input) { switch (input) {
case TVP5150_ANALOG_CH0: case TVP5150_COMPOSITE1:
case TVP5150_ANALOG_CH1: input |= 2;
/* fall through */
case TVP5150_COMPOSITE0:
opmode=0x30; /* TV Mode */ opmode=0x30; /* TV Mode */
break; break;
case TVP5150_SVIDEO:
default: default:
input |= 1;
opmode=0; /* Auto Mode */ opmode=0; /* Auto Mode */
break; break;
} }
...@@ -790,7 +788,7 @@ static inline void tvp5150_reset(struct i2c_client *c) ...@@ -790,7 +788,7 @@ static inline void tvp5150_reset(struct i2c_client *c)
tvp5150_vdp_init(c, vbi_ram_default); tvp5150_vdp_init(c, vbi_ram_default);
/* Selects decoder input */ /* Selects decoder input */
tvp5150_selmux(c, decoder->input); tvp5150_selmux(c);
/* Initializes TVP5150 to stream enabled values */ /* Initializes TVP5150 to stream enabled values */
tvp5150_write_inittab(c, tvp5150_init_enable); tvp5150_write_inittab(c, tvp5150_init_enable);
...@@ -860,6 +858,21 @@ static int tvp5150_command(struct i2c_client *c, ...@@ -860,6 +858,21 @@ static int tvp5150_command(struct i2c_client *c,
case VIDIOC_INT_RESET: case VIDIOC_INT_RESET:
tvp5150_reset(c); tvp5150_reset(c);
break; break;
case VIDIOC_INT_G_VIDEO_ROUTING:
{
struct v4l2_routing *route = arg;
*route = decoder->route;
break;
}
case VIDIOC_INT_S_VIDEO_ROUTING:
{
struct v4l2_routing *route = arg;
decoder->route = *route;
tvp5150_selmux(c);
break;
}
case VIDIOC_S_STD: case VIDIOC_S_STD:
if (decoder->norm == *(v4l2_std_id *)arg) if (decoder->norm == *(v4l2_std_id *)arg)
break; break;
...@@ -1063,7 +1076,7 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter, ...@@ -1063,7 +1076,7 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
rv = i2c_attach_client(c); rv = i2c_attach_client(c);
core->norm = V4L2_STD_ALL; /* Default is autodetect */ core->norm = V4L2_STD_ALL; /* Default is autodetect */
core->input = 2; core->route.input = TVP5150_COMPOSITE1;
core->enable = 1; core->enable = 1;
core->bright = 32768; core->bright = 32768;
core->contrast = 32768; core->contrast = 32768;
......
/*
tvp5150.h - definition for tvp5150 inputs
Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _TVP5150_H_
#define _TVP5150_H_
/* TVP5150 HW inputs */
#define TVP5150_COMPOSITE0 0
#define TVP5150_COMPOSITE1 1
#define TVP5150_SVIDEO 2
/* TVP5150 HW outputs */
#define TVP5150_NORMAL 0
#define TVP5150_BLACK_SCREEN 1
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment