aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tea6415c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/tea6415c.c')
-rw-r--r--drivers/media/video/tea6415c.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index bb9b7780c49f..d61c56f42bcd 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -32,7 +32,8 @@
32#include <linux/ioctl.h> 32#include <linux/ioctl.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <media/v4l2-device.h> 34#include <media/v4l2-device.h>
35#include <media/v4l2-i2c-drv-legacy.h> 35#include <media/v4l2-chip-ident.h>
36#include <media/v4l2-i2c-drv.h>
36#include "tea6415c.h" 37#include "tea6415c.h"
37 38
38MODULE_AUTHOR("Michael Hunold <michael@mihu.de>"); 39MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
@@ -44,25 +45,22 @@ module_param(debug, int, 0644);
44 45
45MODULE_PARM_DESC(debug, "Debug level (0-1)"); 46MODULE_PARM_DESC(debug, "Debug level (0-1)");
46 47
47/* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */
48static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END };
49 48
50/* magic definition of all other variables and things */ 49/* makes a connection between the input-pin 'i' and the output-pin 'o' */
51I2C_CLIENT_INSMOD; 50static int tea6415c_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *route)
52
53/* makes a connection between the input-pin 'i' and the output-pin 'o'
54 for the tea6415c-client 'client' */
55static int switch_matrix(struct i2c_client *client, int i, int o)
56{ 51{
52 struct i2c_client *client = v4l2_get_subdevdata(sd);
57 u8 byte = 0; 53 u8 byte = 0;
54 u32 i = route->input;
55 u32 o = route->output;
58 int ret; 56 int ret;
59 57
60 v4l_dbg(1, debug, client, "i=%d, o=%d\n", i, o); 58 v4l2_dbg(1, debug, sd, "i=%d, o=%d\n", i, o);
61 59
62 /* check if the pins are valid */ 60 /* check if the pins are valid */
63 if (0 == ((1 == i || 3 == i || 5 == i || 6 == i || 8 == i || 10 == i || 20 == i || 11 == i) 61 if (0 == ((1 == i || 3 == i || 5 == i || 6 == i || 8 == i || 10 == i || 20 == i || 11 == i)
64 && (18 == o || 17 == o || 16 == o || 15 == o || 14 == o || 13 == o))) 62 && (18 == o || 17 == o || 16 == o || 15 == o || 14 == o || 13 == o)))
65 return -1; 63 return -EINVAL;
66 64
67 /* to understand this, have a look at the tea6415c-specs (p.5) */ 65 /* to understand this, have a look at the tea6415c-specs (p.5) */
68 switch (o) { 66 switch (o) {
@@ -115,37 +113,33 @@ static int switch_matrix(struct i2c_client *client, int i, int o)
115 113
116 ret = i2c_smbus_write_byte(client, byte); 114 ret = i2c_smbus_write_byte(client, byte);
117 if (ret) { 115 if (ret) {
118 v4l_dbg(1, debug, client, 116 v4l2_dbg(1, debug, sd,
119 "i2c_smbus_write_byte() failed, ret:%d\n", ret); 117 "i2c_smbus_write_byte() failed, ret:%d\n", ret);
120 return -EIO; 118 return -EIO;
121 } 119 }
122 return ret; 120 return ret;
123} 121}
124 122
125static long tea6415c_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) 123static int tea6415c_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
126{ 124{
127 if (cmd == TEA6415C_SWITCH) { 125 struct i2c_client *client = v4l2_get_subdevdata(sd);
128 struct i2c_client *client = v4l2_get_subdevdata(sd);
129 struct tea6415c_multiplex *v = (struct tea6415c_multiplex *)arg;
130 126
131 return switch_matrix(client, v->in, v->out); 127 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TEA6415C, 0);
132 }
133 return -ENOIOCTLCMD;
134}
135
136static int tea6415c_command(struct i2c_client *client, unsigned cmd, void *arg)
137{
138 return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg);
139} 128}
140 129
141/* ----------------------------------------------------------------------- */ 130/* ----------------------------------------------------------------------- */
142 131
143static const struct v4l2_subdev_core_ops tea6415c_core_ops = { 132static const struct v4l2_subdev_core_ops tea6415c_core_ops = {
144 .ioctl = tea6415c_ioctl, 133 .g_chip_ident = tea6415c_g_chip_ident,
134};
135
136static const struct v4l2_subdev_video_ops tea6415c_video_ops = {
137 .s_routing = tea6415c_s_routing,
145}; 138};
146 139
147static const struct v4l2_subdev_ops tea6415c_ops = { 140static const struct v4l2_subdev_ops tea6415c_ops = {
148 .core = &tea6415c_core_ops, 141 .core = &tea6415c_core_ops,
142 .video = &tea6415c_video_ops,
149}; 143};
150 144
151/* this function is called by i2c_probe */ 145/* this function is called by i2c_probe */
@@ -176,12 +170,6 @@ static int tea6415c_remove(struct i2c_client *client)
176 return 0; 170 return 0;
177} 171}
178 172
179static int tea6415c_legacy_probe(struct i2c_adapter *adapter)
180{
181 /* Let's see whether this is a known adapter we can attach to.
182 Prevents conflicts with tvaudio.c. */
183 return adapter->id == I2C_HW_SAA7146;
184}
185 173
186static const struct i2c_device_id tea6415c_id[] = { 174static const struct i2c_device_id tea6415c_id[] = {
187 { "tea6415c", 0 }, 175 { "tea6415c", 0 },
@@ -191,9 +179,7 @@ MODULE_DEVICE_TABLE(i2c, tea6415c_id);
191 179
192static struct v4l2_i2c_driver_data v4l2_i2c_data = { 180static struct v4l2_i2c_driver_data v4l2_i2c_data = {
193 .name = "tea6415c", 181 .name = "tea6415c",
194 .command = tea6415c_command,
195 .probe = tea6415c_probe, 182 .probe = tea6415c_probe,
196 .remove = tea6415c_remove, 183 .remove = tea6415c_remove,
197 .legacy_probe = tea6415c_legacy_probe,
198 .id_table = tea6415c_id, 184 .id_table = tea6415c_id,
199}; 185};