18 #include <linux/module.h>
20 #include <linux/i2c.h>
21 #include <linux/videodev2.h>
23 #include <linux/slab.h>
36 static u8 global_registers[] = {
47 static u8 channel_registers[] = {
115 for (i = 0; regs[
i] != 0xff; i += 2)
117 regs[i] | (channel << 6), regs[i + 1]) < 0)
122 static int wis_tw2804_command(
struct i2c_client *client,
123 unsigned int cmd,
void *
arg)
125 struct wis_tw2804 *dec = i2c_get_clientdata(client);
130 if (*input < 0 || *input > 3) {
132 "between 0 and 3!\n", *input);
139 write_regs(client, global_registers, 0) < 0) {
141 "TW2804 global registers\n");
144 if (write_regs(client, channel_registers, dec->
channel) < 0) {
146 "TW2804 channel %d\n", dec->
channel);
154 "channel number is set\n", cmd);
175 write_regs(client, regs, dec->
channel);
229 if (ctrl->
value > 255)
231 else if (ctrl->
value < 0)
238 if (ctrl->
value > 255)
240 else if (ctrl->
value < 0)
247 if (ctrl->
value > 255)
249 else if (ctrl->
value < 0)
256 if (ctrl->
value > 255)
258 else if (ctrl->
value < 0)
293 static int wis_tw2804_probe(
struct i2c_client *client,
312 i2c_set_clientdata(client, dec);
320 static int wis_tw2804_remove(
struct i2c_client *client)
322 struct wis_tw2804 *dec = i2c_get_clientdata(client);
334 static struct i2c_driver wis_tw2804_driver = {
336 .name =
"WIS TW2804 I2C driver",
338 .probe = wis_tw2804_probe,
339 .remove = wis_tw2804_remove,
340 .command = wis_tw2804_command,
341 .id_table = wis_tw2804_id,
344 static int __init wis_tw2804_init(
void)
346 return i2c_add_driver(&wis_tw2804_driver);
349 static void __exit wis_tw2804_cleanup(
void)