diff options
Diffstat (limited to 'drivers/media/video/tea6415c.c')
-rw-r--r-- | drivers/media/video/tea6415c.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index cde092adbb5a..31dde86f2df4 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | #include <linux/ioctl.h> | 32 | #include <linux/ioctl.h> |
33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
34 | #include <media/v4l2-common.h> | 34 | #include <media/v4l2-device.h> |
35 | #include <media/v4l2-i2c-drv-legacy.h> | 35 | #include <media/v4l2-i2c-drv-legacy.h> |
36 | #include "tea6415c.h" | 36 | #include "tea6415c.h" |
37 | 37 | ||
@@ -122,31 +122,57 @@ static int switch_matrix(struct i2c_client *client, int i, int o) | |||
122 | return ret; | 122 | return ret; |
123 | } | 123 | } |
124 | 124 | ||
125 | static int tea6415c_command(struct i2c_client *client, unsigned cmd, void *arg) | 125 | static int tea6415c_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) |
126 | { | 126 | { |
127 | struct tea6415c_multiplex *v = (struct tea6415c_multiplex *)arg; | 127 | if (cmd == TEA6415C_SWITCH) { |
128 | int result = 0; | 128 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
129 | struct tea6415c_multiplex *v = (struct tea6415c_multiplex *)arg; | ||
129 | 130 | ||
130 | switch (cmd) { | 131 | return switch_matrix(client, v->in, v->out); |
131 | case TEA6415C_SWITCH: | ||
132 | result = switch_matrix(client, v->in, v->out); | ||
133 | break; | ||
134 | default: | ||
135 | return -ENOIOCTLCMD; | ||
136 | } | 132 | } |
137 | return result; | 133 | return -ENOIOCTLCMD; |
138 | } | 134 | } |
139 | 135 | ||
136 | static int tea6415c_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
137 | { | ||
138 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
139 | } | ||
140 | |||
141 | /* ----------------------------------------------------------------------- */ | ||
142 | |||
143 | static const struct v4l2_subdev_core_ops tea6415c_core_ops = { | ||
144 | .ioctl = tea6415c_ioctl, | ||
145 | }; | ||
146 | |||
147 | static const struct v4l2_subdev_ops tea6415c_ops = { | ||
148 | .core = &tea6415c_core_ops, | ||
149 | }; | ||
150 | |||
140 | /* this function is called by i2c_probe */ | 151 | /* this function is called by i2c_probe */ |
141 | static int tea6415c_probe(struct i2c_client *client, | 152 | static int tea6415c_probe(struct i2c_client *client, |
142 | const struct i2c_device_id *id) | 153 | const struct i2c_device_id *id) |
143 | { | 154 | { |
155 | struct v4l2_subdev *sd; | ||
156 | |||
144 | /* let's see whether this adapter can support what we need */ | 157 | /* let's see whether this adapter can support what we need */ |
145 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE)) | 158 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE)) |
146 | return 0; | 159 | return 0; |
147 | 160 | ||
148 | v4l_info(client, "chip found @ 0x%x (%s)\n", | 161 | v4l_info(client, "chip found @ 0x%x (%s)\n", |
149 | client->addr << 1, client->adapter->name); | 162 | client->addr << 1, client->adapter->name); |
163 | sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | ||
164 | if (sd == NULL) | ||
165 | return -ENOMEM; | ||
166 | v4l2_i2c_subdev_init(sd, client, &tea6415c_ops); | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static int tea6415c_remove(struct i2c_client *client) | ||
171 | { | ||
172 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | ||
173 | |||
174 | v4l2_device_unregister_subdev(sd); | ||
175 | kfree(sd); | ||
150 | return 0; | 176 | return 0; |
151 | } | 177 | } |
152 | 178 | ||
@@ -168,6 +194,7 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = { | |||
168 | .driverid = I2C_DRIVERID_TEA6415C, | 194 | .driverid = I2C_DRIVERID_TEA6415C, |
169 | .command = tea6415c_command, | 195 | .command = tea6415c_command, |
170 | .probe = tea6415c_probe, | 196 | .probe = tea6415c_probe, |
197 | .remove = tea6415c_remove, | ||
171 | .legacy_probe = tea6415c_legacy_probe, | 198 | .legacy_probe = tea6415c_legacy_probe, |
172 | .id_table = tea6415c_id, | 199 | .id_table = tea6415c_id, |
173 | }; | 200 | }; |