1 // SPDX-License-Identifier: GPL-2.0-or-later
3 tea6415c - i2c-driver for the tea6415c by SGS Thomson
8 The tea6415c is a bus controlled video-matrix-switch
9 with 8 inputs and 6 outputs.
10 It is cascadable, i.e. it can be found at the addresses
11 0x86 and 0x06 on the i2c-bus.
13 For detailed information download the specifications directly
14 from SGS Thomson at http://www.st.com
19 #include <linux/module.h>
20 #include <linux/ioctl.h>
21 #include <linux/slab.h>
22 #include <linux/i2c.h>
23 #include <media/v4l2-device.h>
27 MODULE_DESCRIPTION("tea6415c driver");
28 MODULE_LICENSE("GPL");
31 module_param(debug, int, 0644);
33 MODULE_PARM_DESC(debug, "Debug level (0-1)");
36 /* makes a connection between the input-pin 'i' and the output-pin 'o' */
37 static int tea6415c_s_routing(struct v4l2_subdev *sd,
38 u32 i, u32 o, u32 config)
40 struct i2c_client *client = v4l2_get_subdevdata(sd);
44 v4l2_dbg(1, debug, sd, "i=%d, o=%d\n", i, o);
46 /* check if the pins are valid */
47 if (0 == ((1 == i || 3 == i || 5 == i || 6 == i || 8 == i || 10 == i || 20 == i || 11 == i)
48 && (18 == o || 17 == o || 16 == o || 15 == o || 14 == o || 13 == o)))
51 /* to understand this, have a look at the tea6415c-specs (p.5) */
100 ret = i2c_smbus_write_byte(client, byte);
102 v4l2_dbg(1, debug, sd,
103 "i2c_smbus_write_byte() failed, ret:%d\n", ret);
109 /* ----------------------------------------------------------------------- */
111 static const struct v4l2_subdev_video_ops tea6415c_video_ops = {
112 .s_routing = tea6415c_s_routing,
115 static const struct v4l2_subdev_ops tea6415c_ops = {
116 .video = &tea6415c_video_ops,
119 static int tea6415c_probe(struct i2c_client *client)
121 struct v4l2_subdev *sd;
123 /* let's see whether this adapter can support what we need */
124 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE))
127 v4l_info(client, "chip found @ 0x%x (%s)\n",
128 client->addr << 1, client->adapter->name);
129 sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL);
132 v4l2_i2c_subdev_init(sd, client, &tea6415c_ops);
136 static void tea6415c_remove(struct i2c_client *client)
138 struct v4l2_subdev *sd = i2c_get_clientdata(client);
140 v4l2_device_unregister_subdev(sd);
143 static const struct i2c_device_id tea6415c_id[] = {
147 MODULE_DEVICE_TABLE(i2c, tea6415c_id);
149 static struct i2c_driver tea6415c_driver = {
153 .probe = tea6415c_probe,
154 .remove = tea6415c_remove,
155 .id_table = tea6415c_id,
158 module_i2c_driver(tea6415c_driver);