diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-08-21 00:24:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-10-09 21:07:34 -0400 |
commit | db8a695658cda21eacfa2a5e3b15e8964bfb93ef (patch) | |
tree | ac69f32af5b52f78ad65ad1125d330aa19c7bdda /drivers/media/video/tea5761.c | |
parent | 293197cd0f34eb6bfb5492a63a878575b69e9df4 (diff) |
V4L/DVB (6127): tuner: kill i2c_client interface to tuner sub-drivers
To ease the conversion of the analog tuner sub-drivers into dvb_frontend
style tuner modules, we must remove the i2c_client interface.
dvb_frontend style tuner modules use i2c_transfer directly on the i2c_adapter.
This change only alters the interface between tuner.ko and the tuner
sub-drivers. The v4l2 / i2c_client interface to tuner.ko remains intact.
This patch adds inline functions tuner_i2c_xfer_send, and tuner_i2c_xfer_recv,
to replace i2c_master_send and i2c_master_recv inside the tuner sub-drivers.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: Mike Isely <isely@pobox.com>
Acked-by: Steven Toth <stoth@hauppauge.com>
Acked-by: Patrick Boettcher <pb@linuxtv.org>
Acked-by: Jarod Wilson <jwilson@redhat.com>
Acked-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tea5761.c')
-rw-r--r-- | drivers/media/video/tea5761.c | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/drivers/media/video/tea5761.c b/drivers/media/video/tea5761.c index 43bdc374927e..9965ba48cffa 100644 --- a/drivers/media/video/tea5761.c +++ b/drivers/media/video/tea5761.c | |||
@@ -18,6 +18,10 @@ | |||
18 | /* from tuner-core.c */ | 18 | /* from tuner-core.c */ |
19 | extern int tuner_debug; | 19 | extern int tuner_debug; |
20 | 20 | ||
21 | struct tea5761_priv { | ||
22 | struct tuner_i2c_props i2c_props; | ||
23 | }; | ||
24 | |||
21 | /*****************************************************************************/ | 25 | /*****************************************************************************/ |
22 | 26 | ||
23 | /*************************** | 27 | /*************************** |
@@ -114,10 +118,8 @@ extern int tuner_debug; | |||
114 | 118 | ||
115 | /*****************************************************************************/ | 119 | /*****************************************************************************/ |
116 | 120 | ||
117 | static void set_tv_freq(struct i2c_client *c, unsigned int freq) | 121 | static void set_tv_freq(struct tuner *t, unsigned int freq) |
118 | { | 122 | { |
119 | struct tuner *t = i2c_get_clientdata(c); | ||
120 | |||
121 | tuner_warn("This tuner doesn't support TV freq.\n"); | 123 | tuner_warn("This tuner doesn't support TV freq.\n"); |
122 | } | 124 | } |
123 | 125 | ||
@@ -135,9 +137,9 @@ static void tea5761_status_dump(unsigned char *buffer) | |||
135 | } | 137 | } |
136 | 138 | ||
137 | /* Freq should be specifyed at 62.5 Hz */ | 139 | /* Freq should be specifyed at 62.5 Hz */ |
138 | static void set_radio_freq(struct i2c_client *c, unsigned int frq) | 140 | static void set_radio_freq(struct tuner *t, unsigned int frq) |
139 | { | 141 | { |
140 | struct tuner *t = i2c_get_clientdata(c); | 142 | struct tea5761_priv *priv = t->priv; |
141 | unsigned char buffer[7] = {0, 0, 0, 0, 0, 0, 0 }; | 143 | unsigned char buffer[7] = {0, 0, 0, 0, 0, 0, 0 }; |
142 | unsigned div; | 144 | unsigned div; |
143 | int rc; | 145 | int rc; |
@@ -167,31 +169,31 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) | |||
167 | if (tuner_debug) | 169 | if (tuner_debug) |
168 | tea5761_status_dump(buffer); | 170 | tea5761_status_dump(buffer); |
169 | 171 | ||
170 | if (7 != (rc = i2c_master_send(c, buffer, 7))) | 172 | if (7 != (rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 7))) |
171 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); | 173 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); |
172 | } | 174 | } |
173 | 175 | ||
174 | static int tea5761_signal(struct i2c_client *c) | 176 | static int tea5761_signal(struct tuner *t) |
175 | { | 177 | { |
176 | unsigned char buffer[16]; | 178 | unsigned char buffer[16]; |
177 | int rc; | 179 | int rc; |
178 | struct tuner *t = i2c_get_clientdata(c); | 180 | struct tea5761_priv *priv = t->priv; |
179 | 181 | ||
180 | memset(buffer, 0, sizeof(buffer)); | 182 | memset(buffer, 0, sizeof(buffer)); |
181 | if (16 != (rc = i2c_master_recv(c, buffer, 16))) | 183 | if (16 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 16))) |
182 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); | 184 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); |
183 | 185 | ||
184 | return ((buffer[9] & TEA5761_TUNCHECK_LEV_MASK) << (13 - 4)); | 186 | return ((buffer[9] & TEA5761_TUNCHECK_LEV_MASK) << (13 - 4)); |
185 | } | 187 | } |
186 | 188 | ||
187 | static int tea5761_stereo(struct i2c_client *c) | 189 | static int tea5761_stereo(struct tuner *t) |
188 | { | 190 | { |
189 | unsigned char buffer[16]; | 191 | unsigned char buffer[16]; |
190 | int rc; | 192 | int rc; |
191 | struct tuner *t = i2c_get_clientdata(c); | 193 | struct tea5761_priv *priv = t->priv; |
192 | 194 | ||
193 | memset(buffer, 0, sizeof(buffer)); | 195 | memset(buffer, 0, sizeof(buffer)); |
194 | if (16 != (rc = i2c_master_recv(c, buffer, 16))) | 196 | if (16 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buffer, 16))) |
195 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); | 197 | tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); |
196 | 198 | ||
197 | rc = buffer[9] & TEA5761_TUNCHECK_STEREO; | 199 | rc = buffer[9] & TEA5761_TUNCHECK_STEREO; |
@@ -201,13 +203,13 @@ static int tea5761_stereo(struct i2c_client *c) | |||
201 | return (rc ? V4L2_TUNER_SUB_STEREO : 0); | 203 | return (rc ? V4L2_TUNER_SUB_STEREO : 0); |
202 | } | 204 | } |
203 | 205 | ||
204 | int tea5761_autodetection(struct i2c_client *c) | 206 | int tea5761_autodetection(struct tuner *t) |
205 | { | 207 | { |
206 | unsigned char buffer[16]; | 208 | unsigned char buffer[16]; |
207 | int rc; | 209 | int rc; |
208 | struct tuner *t = i2c_get_clientdata(c); | 210 | struct tuner_i2c_props i2c = { .adap = t->i2c.adapter, .addr = t->i2c.addr }; |
209 | 211 | ||
210 | if (16 != (rc = i2c_master_recv(c, buffer, 16))) { | 212 | if (16 != (rc = tuner_i2c_xfer_recv(&i2c, buffer, 16))) { |
211 | tuner_warn("it is not a TEA5761. Received %i chars.\n", rc); | 213 | tuner_warn("it is not a TEA5761. Received %i chars.\n", rc); |
212 | return EINVAL; | 214 | return EINVAL; |
213 | } | 215 | } |
@@ -220,22 +222,37 @@ int tea5761_autodetection(struct i2c_client *c) | |||
220 | return 0; | 222 | return 0; |
221 | } | 223 | } |
222 | 224 | ||
225 | static void tea5761_release(struct tuner *t) | ||
226 | { | ||
227 | kfree(t->priv); | ||
228 | t->priv = NULL; | ||
229 | } | ||
230 | |||
223 | static struct tuner_operations tea5761_tuner_ops = { | 231 | static struct tuner_operations tea5761_tuner_ops = { |
224 | .set_tv_freq = set_tv_freq, | 232 | .set_tv_freq = set_tv_freq, |
225 | .set_radio_freq = set_radio_freq, | 233 | .set_radio_freq = set_radio_freq, |
226 | .has_signal = tea5761_signal, | 234 | .has_signal = tea5761_signal, |
227 | .is_stereo = tea5761_stereo, | 235 | .is_stereo = tea5761_stereo, |
236 | .release = tea5761_release, | ||
228 | }; | 237 | }; |
229 | 238 | ||
230 | int tea5761_tuner_init(struct i2c_client *c) | 239 | int tea5761_tuner_init(struct tuner *t) |
231 | { | 240 | { |
232 | struct tuner *t = i2c_get_clientdata(c); | 241 | struct tea5761_priv *priv = NULL; |
233 | 242 | ||
234 | if (tea5761_autodetection(c) == EINVAL) | 243 | if (tea5761_autodetection(t) == EINVAL) |
235 | return EINVAL; | 244 | return EINVAL; |
236 | 245 | ||
246 | priv = kzalloc(sizeof(struct tea5761_priv), GFP_KERNEL); | ||
247 | if (priv == NULL) | ||
248 | return -ENOMEM; | ||
249 | t->priv = priv; | ||
250 | |||
251 | priv->i2c_props.addr = t->i2c.addr; | ||
252 | priv->i2c_props.adap = t->i2c.adapter; | ||
253 | |||
237 | tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5761HN FM Radio"); | 254 | tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5761HN FM Radio"); |
238 | strlcpy(c->name, "tea5761", sizeof(c->name)); | 255 | strlcpy(t->i2c.name, "tea5761", sizeof(t->i2c.name)); |
239 | 256 | ||
240 | memcpy(&t->ops, &tea5761_tuner_ops, sizeof(struct tuner_operations)); | 257 | memcpy(&t->ops, &tea5761_tuner_ops, sizeof(struct tuner_operations)); |
241 | 258 | ||