1 // SPDX-License-Identifier: GPL-2.0-or-later
3 tea6415c - i2c-driver for the tea6415c by SGS Thomson
5 Copyright (C) 1998-2003 Michael Hunold <michael@mihu.de>
6 Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl>
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>
26 MODULE_AUTHOR("Michael Hunold <michael@mihu.de>");
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
,
120 const struct i2c_device_id
*id
)
122 struct v4l2_subdev
*sd
;
124 /* let's see whether this adapter can support what we need */
125 if (!i2c_check_functionality(client
->adapter
, I2C_FUNC_SMBUS_WRITE_BYTE
))
128 v4l_info(client
, "chip found @ 0x%x (%s)\n",
129 client
->addr
<< 1, client
->adapter
->name
);
130 sd
= devm_kzalloc(&client
->dev
, sizeof(*sd
), GFP_KERNEL
);
133 v4l2_i2c_subdev_init(sd
, client
, &tea6415c_ops
);
137 static int tea6415c_remove(struct i2c_client
*client
)
139 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
141 v4l2_device_unregister_subdev(sd
);
145 static const struct i2c_device_id tea6415c_id
[] = {
149 MODULE_DEVICE_TABLE(i2c
, tea6415c_id
);
151 static struct i2c_driver tea6415c_driver
= {
155 .probe
= tea6415c_probe
,
156 .remove
= tea6415c_remove
,
157 .id_table
= tea6415c_id
,
160 module_i2c_driver(tea6415c_driver
);