V4L/DVB (3608): Implement new routing commands in saa7127.c
authorHans Verkuil <hverkuil@xs4all.nl>
Sat, 25 Mar 2006 12:50:20 +0000 (09:50 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 2 Apr 2006 07:54:56 +0000 (04:54 -0300)
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/saa7127.c
include/media/saa7127.h [new file with mode: 0644]

index 992c71774f303f40fea02013481c16ef2f30edfe..133f9e5252fec0f0646c3d1d34e2f92d85385199 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
 #include <media/v4l2-common.h>
+#include <media/saa7127.h>
 
 static int debug = 0;
 static int test_image = 0;
@@ -222,22 +223,6 @@ static struct i2c_reg_value saa7127_init_config_50hz[] = {
        { 0, 0 }
 };
 
-/* Enumeration for the Supported input types */
-enum saa7127_input_type {
-       SAA7127_INPUT_TYPE_NORMAL,
-       SAA7127_INPUT_TYPE_TEST_IMAGE
-};
-
-/* Enumeration for the Supported Output signal types */
-enum saa7127_output_type {
-       SAA7127_OUTPUT_TYPE_BOTH,
-       SAA7127_OUTPUT_TYPE_COMPOSITE,
-       SAA7127_OUTPUT_TYPE_SVIDEO,
-       SAA7127_OUTPUT_TYPE_RGB,
-       SAA7127_OUTPUT_TYPE_YUV_C,
-       SAA7127_OUTPUT_TYPE_YUV_V
-};
-
 /*
  **********************************************************************
  *
@@ -561,7 +546,7 @@ static int saa7127_command(struct i2c_client *client,
 {
        struct saa7127_state *state = i2c_get_clientdata(client);
        struct v4l2_format *fmt = arg;
-       int *iarg = arg;
+       struct v4l2_routing *route = arg;
 
        switch (cmd) {
        case VIDIOC_S_STD:
@@ -573,15 +558,23 @@ static int saa7127_command(struct i2c_client *client,
                *(v4l2_std_id *)arg = state->std;
                break;
 
-       case VIDIOC_S_INPUT:
-               if (state->input_type == *iarg)
-                       break;
-               return saa7127_set_input_type(client, *iarg);
+       case VIDIOC_INT_G_VIDEO_ROUTING:
+               route->input = state->input_type;
+               route->output = state->output_type;
+               break;
 
-       case VIDIOC_S_OUTPUT:
-               if (state->output_type == *iarg)
-                       break;
-               return saa7127_set_output_type(client, *iarg);
+       case VIDIOC_INT_S_VIDEO_ROUTING:
+       {
+               int rc = 0;
+
+               if (state->input_type != route->input) {
+                       rc = saa7127_set_input_type(client, route->input);
+               }
+               if (rc == 0 && state->output_type != route->output) {
+                       rc = saa7127_set_output_type(client, route->output);
+               }
+               return rc;
+       }
 
        case VIDIOC_STREAMON:
        case VIDIOC_STREAMOFF:
diff --git a/include/media/saa7127.h b/include/media/saa7127.h
new file mode 100644 (file)
index 0000000..bbcf862
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+    saa7127.h - definition for saa7126/7/8/9 inputs/outputs
+
+    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 _SAA7127_H_
+#define _SAA7127_H_
+
+/* Enumeration for the supported input types */
+enum saa7127_input_type {
+       SAA7127_INPUT_TYPE_NORMAL,
+       SAA7127_INPUT_TYPE_TEST_IMAGE
+};
+
+/* Enumeration for the supported output signal types */
+enum saa7127_output_type {
+       SAA7127_OUTPUT_TYPE_BOTH,
+       SAA7127_OUTPUT_TYPE_COMPOSITE,
+       SAA7127_OUTPUT_TYPE_SVIDEO,
+       SAA7127_OUTPUT_TYPE_RGB,
+       SAA7127_OUTPUT_TYPE_YUV_C,
+       SAA7127_OUTPUT_TYPE_YUV_V
+};
+
+#endif
+