diff options
Diffstat (limited to 'drivers/media/video/tda9840.c')
-rw-r--r-- | drivers/media/video/tda9840.c | 81 |
1 files changed, 9 insertions, 72 deletions
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index ae46a28dd052..fe1158094c24 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c | |||
@@ -30,8 +30,8 @@ | |||
30 | #include <linux/ioctl.h> | 30 | #include <linux/ioctl.h> |
31 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
32 | #include <media/v4l2-device.h> | 32 | #include <media/v4l2-device.h> |
33 | #include <media/v4l2-i2c-drv-legacy.h> | 33 | #include <media/v4l2-chip-ident.h> |
34 | #include "tda9840.h" | 34 | #include <media/v4l2-i2c-drv.h> |
35 | 35 | ||
36 | MODULE_AUTHOR("Michael Hunold <michael@mihu.de>"); | 36 | MODULE_AUTHOR("Michael Hunold <michael@mihu.de>"); |
37 | MODULE_DESCRIPTION("tda9840 driver"); | 37 | MODULE_DESCRIPTION("tda9840 driver"); |
@@ -56,11 +56,6 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
56 | #define TDA9840_SET_BOTH_R 0x16 | 56 | #define TDA9840_SET_BOTH_R 0x16 |
57 | #define TDA9840_SET_EXTERNAL 0x7a | 57 | #define TDA9840_SET_EXTERNAL 0x7a |
58 | 58 | ||
59 | /* addresses to scan, found only at 0x42 (7-Bit) */ | ||
60 | static unsigned short normal_i2c[] = { I2C_ADDR_TDA9840, I2C_CLIENT_END }; | ||
61 | |||
62 | /* magic definition of all other variables and things */ | ||
63 | I2C_CLIENT_INSMOD; | ||
64 | 59 | ||
65 | static void tda9840_write(struct v4l2_subdev *sd, u8 reg, u8 val) | 60 | static void tda9840_write(struct v4l2_subdev *sd, u8 reg, u8 val) |
66 | { | 61 | { |
@@ -137,60 +132,17 @@ static int tda9840_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *t) | |||
137 | return 0; | 132 | return 0; |
138 | } | 133 | } |
139 | 134 | ||
140 | static long tda9840_ioctl(struct v4l2_subdev *sd, unsigned cmd, void *arg) | 135 | static int tda9840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) |
141 | { | 136 | { |
142 | int byte; | 137 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
143 | |||
144 | switch (cmd) { | ||
145 | case TDA9840_LEVEL_ADJUST: | ||
146 | byte = *(int *)arg; | ||
147 | v4l2_dbg(1, debug, sd, "TDA9840_LEVEL_ADJUST: %d\n", byte); | ||
148 | |||
149 | /* check for correct range */ | ||
150 | if (byte > 25 || byte < -20) | ||
151 | return -EINVAL; | ||
152 | |||
153 | /* calculate actual value to set, see specs, page 18 */ | ||
154 | byte /= 5; | ||
155 | if (0 < byte) | ||
156 | byte += 0x8; | ||
157 | else | ||
158 | byte = -byte; | ||
159 | tda9840_write(sd, LEVEL_ADJUST, byte); | ||
160 | break; | ||
161 | |||
162 | case TDA9840_STEREO_ADJUST: | ||
163 | byte = *(int *)arg; | ||
164 | v4l2_dbg(1, debug, sd, "TDA9840_STEREO_ADJUST: %d\n", byte); | ||
165 | |||
166 | /* check for correct range */ | ||
167 | if (byte > 25 || byte < -24) | ||
168 | return -EINVAL; | ||
169 | |||
170 | /* calculate actual value to set */ | ||
171 | byte /= 5; | ||
172 | if (0 < byte) | ||
173 | byte += 0x20; | ||
174 | else | ||
175 | byte = -byte; | ||
176 | |||
177 | tda9840_write(sd, STEREO_ADJUST, byte); | ||
178 | break; | ||
179 | default: | ||
180 | return -ENOIOCTLCMD; | ||
181 | } | ||
182 | return 0; | ||
183 | } | ||
184 | 138 | ||
185 | static int tda9840_command(struct i2c_client *client, unsigned cmd, void *arg) | 139 | return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_TDA9840, 0); |
186 | { | ||
187 | return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg); | ||
188 | } | 140 | } |
189 | 141 | ||
190 | /* ----------------------------------------------------------------------- */ | 142 | /* ----------------------------------------------------------------------- */ |
191 | 143 | ||
192 | static const struct v4l2_subdev_core_ops tda9840_core_ops = { | 144 | static const struct v4l2_subdev_core_ops tda9840_core_ops = { |
193 | .ioctl = tda9840_ioctl, | 145 | .g_chip_ident = tda9840_g_chip_ident, |
194 | }; | 146 | }; |
195 | 147 | ||
196 | static const struct v4l2_subdev_tuner_ops tda9840_tuner_ops = { | 148 | static const struct v4l2_subdev_tuner_ops tda9840_tuner_ops = { |
@@ -209,8 +161,6 @@ static int tda9840_probe(struct i2c_client *client, | |||
209 | const struct i2c_device_id *id) | 161 | const struct i2c_device_id *id) |
210 | { | 162 | { |
211 | struct v4l2_subdev *sd; | 163 | struct v4l2_subdev *sd; |
212 | int result; | ||
213 | int byte; | ||
214 | 164 | ||
215 | /* let's see whether this adapter can support what we need */ | 165 | /* let's see whether this adapter can support what we need */ |
216 | if (!i2c_check_functionality(client->adapter, | 166 | if (!i2c_check_functionality(client->adapter, |
@@ -227,15 +177,9 @@ static int tda9840_probe(struct i2c_client *client, | |||
227 | v4l2_i2c_subdev_init(sd, client, &tda9840_ops); | 177 | v4l2_i2c_subdev_init(sd, client, &tda9840_ops); |
228 | 178 | ||
229 | /* set initial values for level & stereo - adjustment, mode */ | 179 | /* set initial values for level & stereo - adjustment, mode */ |
230 | byte = 0; | 180 | tda9840_write(sd, LEVEL_ADJUST, 0); |
231 | result = tda9840_ioctl(sd, TDA9840_LEVEL_ADJUST, &byte); | 181 | tda9840_write(sd, STEREO_ADJUST, 0); |
232 | result |= tda9840_ioctl(sd, TDA9840_STEREO_ADJUST, &byte); | ||
233 | tda9840_write(sd, SWITCH, TDA9840_SET_STEREO); | 182 | tda9840_write(sd, SWITCH, TDA9840_SET_STEREO); |
234 | if (result) { | ||
235 | v4l2_dbg(1, debug, sd, "could not initialize tda9840\n"); | ||
236 | kfree(sd); | ||
237 | return -ENODEV; | ||
238 | } | ||
239 | return 0; | 183 | return 0; |
240 | } | 184 | } |
241 | 185 | ||
@@ -248,12 +192,7 @@ static int tda9840_remove(struct i2c_client *client) | |||
248 | return 0; | 192 | return 0; |
249 | } | 193 | } |
250 | 194 | ||
251 | static int tda9840_legacy_probe(struct i2c_adapter *adapter) | 195 | |
252 | { | ||
253 | /* Let's see whether this is a known adapter we can attach to. | ||
254 | Prevents conflicts with tvaudio.c. */ | ||
255 | return adapter->id == I2C_HW_SAA7146; | ||
256 | } | ||
257 | static const struct i2c_device_id tda9840_id[] = { | 196 | static const struct i2c_device_id tda9840_id[] = { |
258 | { "tda9840", 0 }, | 197 | { "tda9840", 0 }, |
259 | { } | 198 | { } |
@@ -262,9 +201,7 @@ MODULE_DEVICE_TABLE(i2c, tda9840_id); | |||
262 | 201 | ||
263 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | 202 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { |
264 | .name = "tda9840", | 203 | .name = "tda9840", |
265 | .command = tda9840_command, | ||
266 | .probe = tda9840_probe, | 204 | .probe = tda9840_probe, |
267 | .remove = tda9840_remove, | 205 | .remove = tda9840_remove, |
268 | .legacy_probe = tda9840_legacy_probe, | ||
269 | .id_table = tda9840_id, | 206 | .id_table = tda9840_id, |
270 | }; | 207 | }; |