]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/tvp5150.c
V4L/DVB (5144): Restore VIDIOC_INT_[SG]_REGISTER calls
[linux-2.6-omap-h63xx.git] / drivers / media / video / tvp5150.c
index 1055423aa2b91c47ca3dab80cee20e7670f60473..bc0a4fc27b24452a828e971d906e1918aeff2a27 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/delay.h>
 #include <linux/video_decoder.h>
 #include <media/v4l2-common.h>
+#include <media/tvp5150.h>
 
 #include "tvp5150_reg.h"
 
@@ -89,7 +90,7 @@ struct tvp5150 {
        struct i2c_client *client;
 
        v4l2_std_id norm;       /* Current set standard */
-       int input;
+       struct v4l2_routing route;
        int enable;
        int bright;
        int contrast;
@@ -283,33 +284,35 @@ static void dump_reg(struct i2c_client *c)
 /****************************************************************************
                        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,
-                                 enum tvp5150_input input)
+static inline void tvp5150_selmux(struct i2c_client *c)
 {
        int opmode=0;
-
        struct tvp5150 *decoder = i2c_get_clientdata(c);
+       int input = 0;
 
-       if (!decoder->enable)
-               input |= TVP5150_BLACK_SCREEN;
+       if ((decoder->route.output & TVP5150_BLACK_SCREEN) || !decoder->enable)
+               input = 8;
 
-       switch (input) {
-       case TVP5150_ANALOG_CH0:
-       case TVP5150_ANALOG_CH1:
+       switch (decoder->route.input) {
+       case TVP5150_COMPOSITE1:
+               input |= 2;
+               /* fall through */
+       case TVP5150_COMPOSITE0:
                opmode=0x30;            /* TV Mode */
                break;
+       case TVP5150_SVIDEO:
        default:
+               input |= 1;
                opmode=0;               /* Auto Mode */
                break;
        }
 
+       tvp5150_dbg( 1, "Selecting video route: route input=%i, output=%i "
+                       "=> tvp5150 input=%i, opmode=%i\n",
+                       decoder->route.input,decoder->route.output,
+                       input, opmode );
+
        tvp5150_write(c, TVP5150_OP_MODE_CTL, opmode);
        tvp5150_write(c, TVP5150_VD_IN_SRC_SEL_1, input);
 };
@@ -790,7 +793,7 @@ static inline void tvp5150_reset(struct i2c_client *c)
        tvp5150_vdp_init(c, vbi_ram_default);
 
        /* Selects decoder input */
-       tvp5150_selmux(c, decoder->input);
+       tvp5150_selmux(c);
 
        /* Initializes TVP5150 to stream enabled values */
        tvp5150_write_inittab(c, tvp5150_init_enable);
@@ -858,9 +861,23 @@ static int tvp5150_command(struct i2c_client *c,
 
        case 0:
        case VIDIOC_INT_RESET:
-       case DECODER_INIT:
                tvp5150_reset(c);
                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:
                if (decoder->norm == *(v4l2_std_id *)arg)
                        break;
@@ -957,99 +974,15 @@ static int tvp5150_command(struct i2c_client *c,
 #endif
 
        case VIDIOC_LOG_STATUS:
-       case DECODER_DUMP:
                dump_reg(c);
                break;
 
-       case DECODER_GET_CAPABILITIES:
-               {
-                       struct video_decoder_capability *cap = arg;
-
-                       cap->flags = VIDEO_DECODER_PAL |
-                           VIDEO_DECODER_NTSC |
-                           VIDEO_DECODER_SECAM |
-                           VIDEO_DECODER_AUTO | VIDEO_DECODER_CCIR;
-                       cap->inputs = 3;
-                       cap->outputs = 1;
-                       break;
-               }
-       case DECODER_GET_STATUS:
-               {
-                       int *iarg = arg;
-                       int status;
-                       int res=0;
-                       status = tvp5150_read(c, 0x88);
-                       if(status&0x08){
-                               res |= DECODER_STATUS_COLOR;
-                       }
-                       if(status&0x04 && status&0x02){
-                               res |= DECODER_STATUS_GOOD;
-                       }
-                       *iarg=res;
-                       break;
-               }
-
-       case DECODER_SET_GPIO:
-               break;
-
-       case DECODER_SET_VBI_BYPASS:
-               break;
-
-       case DECODER_SET_NORM:
+       case VIDIOC_G_TUNER:
                {
-                       int *iarg = arg;
-
-                       switch (*iarg) {
-
-                       case VIDEO_MODE_NTSC:
-                               break;
-
-                       case VIDEO_MODE_PAL:
-                               break;
-
-                       case VIDEO_MODE_SECAM:
-                               break;
-
-                       case VIDEO_MODE_AUTO:
-                               break;
-
-                       default:
-                               return -EINVAL;
-
-                       }
-                       decoder->norm = *iarg;
-                       break;
-               }
-       case DECODER_SET_INPUT:
-               {
-                       int *iarg = arg;
-                       if (*iarg < 0 || *iarg > 3) {
-                               return -EINVAL;
-                       }
-
-                       decoder->input = *iarg;
-                       tvp5150_selmux(c, decoder->input);
-
-                       break;
-               }
-       case DECODER_SET_OUTPUT:
-               {
-                       int *iarg = arg;
-
-                       /* not much choice of outputs */
-                       if (*iarg != 0) {
-                               return -EINVAL;
-                       }
-                       break;
-               }
-       case DECODER_ENABLE_OUTPUT:
-               {
-                       int *iarg = arg;
-
-                       decoder->enable = (*iarg != 0);
-
-                       tvp5150_selmux(c, decoder->input);
+                       struct v4l2_tuner *vt = arg;
+                       int status = tvp5150_read(c, 0x88);
 
+                       vt->signal = ((status & 0x04) && (status & 0x02)) ? 0xffff : 0x0;
                        break;
                }
        case VIDIOC_QUERYCTRL:
@@ -1095,35 +1028,6 @@ static int tvp5150_command(struct i2c_client *c,
                        return -EINVAL;
                }
 
-       case DECODER_SET_PICTURE:
-               {
-                       struct video_picture *pic = arg;
-                       if (decoder->bright != pic->brightness) {
-                               /* We want 0 to 255 we get 0-65535 */
-                               decoder->bright = pic->brightness;
-                               tvp5150_write(c, TVP5150_BRIGHT_CTL,
-                                             decoder->bright >> 8);
-                       }
-                       if (decoder->contrast != pic->contrast) {
-                               /* We want 0 to 255 we get 0-65535 */
-                               decoder->contrast = pic->contrast;
-                               tvp5150_write(c, TVP5150_CONTRAST_CTL,
-                                             decoder->contrast >> 8);
-                       }
-                       if (decoder->sat != pic->colour) {
-                               /* We want 0 to 255 we get 0-65535 */
-                               decoder->sat = pic->colour;
-                               tvp5150_write(c, TVP5150_SATURATION_CTL,
-                                             decoder->contrast >> 8);
-                       }
-                       if (decoder->hue != pic->hue) {
-                               /* We want -128 to 127 we get 0-65535 */
-                               decoder->hue = pic->hue;
-                               tvp5150_write(c, TVP5150_HUE_CTL,
-                                             (decoder->hue - 32768) >> 8);
-                       }
-                       break;
-               }
        default:
                return -EINVAL;
        }
@@ -1177,7 +1081,7 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
        rv = i2c_attach_client(c);
 
        core->norm = V4L2_STD_ALL;      /* Default is autodetect */
-       core->input = 2;
+       core->route.input = TVP5150_COMPOSITE1;
        core->enable = 1;
        core->bright = 32768;
        core->contrast = 32768;