diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-02-03 07:51:06 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-06-17 08:32:58 -0400 |
commit | 268d06bb765da0bdd17344a6877f5898713a7cbb (patch) | |
tree | b82f525fe5826f23154c97250ba186e15dffa686 /drivers/media/radio/radio-sf16fmi.c | |
parent | 96bb42b8ab3d4f15b5e98a65c6d8decf36f3f930 (diff) |
[media] radio-sf16fmi: convert to the control framework
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio/radio-sf16fmi.c')
-rw-r--r-- | drivers/media/radio/radio-sf16fmi.c | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 9cd0338a3d2b..b058f36669ee 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/io.h> /* outb, outb_p */ | 27 | #include <linux/io.h> /* outb, outb_p */ |
28 | #include <media/v4l2-device.h> | 28 | #include <media/v4l2-device.h> |
29 | #include <media/v4l2-ioctl.h> | 29 | #include <media/v4l2-ioctl.h> |
30 | #include <media/v4l2-ctrls.h> | ||
30 | #include "lm7000.h" | 31 | #include "lm7000.h" |
31 | 32 | ||
32 | MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); | 33 | MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); |
@@ -44,6 +45,7 @@ module_param(radio_nr, int, 0); | |||
44 | struct fmi | 45 | struct fmi |
45 | { | 46 | { |
46 | struct v4l2_device v4l2_dev; | 47 | struct v4l2_device v4l2_dev; |
48 | struct v4l2_ctrl_handler hdl; | ||
47 | struct video_device vdev; | 49 | struct video_device vdev; |
48 | int io; | 50 | int io; |
49 | bool mute; | 51 | bool mute; |
@@ -178,46 +180,26 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
178 | return 0; | 180 | return 0; |
179 | } | 181 | } |
180 | 182 | ||
181 | static int vidioc_queryctrl(struct file *file, void *priv, | 183 | static int fmi_s_ctrl(struct v4l2_ctrl *ctrl) |
182 | struct v4l2_queryctrl *qc) | ||
183 | { | 184 | { |
184 | switch (qc->id) { | 185 | struct fmi *fmi = container_of(ctrl->handler, struct fmi, hdl); |
185 | case V4L2_CID_AUDIO_MUTE: | ||
186 | return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1); | ||
187 | } | ||
188 | return -EINVAL; | ||
189 | } | ||
190 | |||
191 | static int vidioc_g_ctrl(struct file *file, void *priv, | ||
192 | struct v4l2_control *ctrl) | ||
193 | { | ||
194 | struct fmi *fmi = video_drvdata(file); | ||
195 | 186 | ||
196 | switch (ctrl->id) { | 187 | switch (ctrl->id) { |
197 | case V4L2_CID_AUDIO_MUTE: | 188 | case V4L2_CID_AUDIO_MUTE: |
198 | ctrl->value = fmi->mute; | 189 | if (ctrl->val) |
199 | return 0; | ||
200 | } | ||
201 | return -EINVAL; | ||
202 | } | ||
203 | |||
204 | static int vidioc_s_ctrl(struct file *file, void *priv, | ||
205 | struct v4l2_control *ctrl) | ||
206 | { | ||
207 | struct fmi *fmi = video_drvdata(file); | ||
208 | |||
209 | switch (ctrl->id) { | ||
210 | case V4L2_CID_AUDIO_MUTE: | ||
211 | if (ctrl->value) | ||
212 | fmi_mute(fmi); | 190 | fmi_mute(fmi); |
213 | else | 191 | else |
214 | fmi_unmute(fmi); | 192 | fmi_unmute(fmi); |
215 | fmi->mute = ctrl->value; | 193 | fmi->mute = ctrl->val; |
216 | return 0; | 194 | return 0; |
217 | } | 195 | } |
218 | return -EINVAL; | 196 | return -EINVAL; |
219 | } | 197 | } |
220 | 198 | ||
199 | static const struct v4l2_ctrl_ops fmi_ctrl_ops = { | ||
200 | .s_ctrl = fmi_s_ctrl, | ||
201 | }; | ||
202 | |||
221 | static const struct v4l2_file_operations fmi_fops = { | 203 | static const struct v4l2_file_operations fmi_fops = { |
222 | .owner = THIS_MODULE, | 204 | .owner = THIS_MODULE, |
223 | .unlocked_ioctl = video_ioctl2, | 205 | .unlocked_ioctl = video_ioctl2, |
@@ -229,9 +211,6 @@ static const struct v4l2_ioctl_ops fmi_ioctl_ops = { | |||
229 | .vidioc_s_tuner = vidioc_s_tuner, | 211 | .vidioc_s_tuner = vidioc_s_tuner, |
230 | .vidioc_g_frequency = vidioc_g_frequency, | 212 | .vidioc_g_frequency = vidioc_g_frequency, |
231 | .vidioc_s_frequency = vidioc_s_frequency, | 213 | .vidioc_s_frequency = vidioc_s_frequency, |
232 | .vidioc_queryctrl = vidioc_queryctrl, | ||
233 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
234 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
235 | }; | 214 | }; |
236 | 215 | ||
237 | /* ladis: this is my card. does any other types exist? */ | 216 | /* ladis: this is my card. does any other types exist? */ |
@@ -281,6 +260,7 @@ static int __init fmi_init(void) | |||
281 | { | 260 | { |
282 | struct fmi *fmi = &fmi_card; | 261 | struct fmi *fmi = &fmi_card; |
283 | struct v4l2_device *v4l2_dev = &fmi->v4l2_dev; | 262 | struct v4l2_device *v4l2_dev = &fmi->v4l2_dev; |
263 | struct v4l2_ctrl_handler *hdl = &fmi->hdl; | ||
284 | int res, i; | 264 | int res, i; |
285 | int probe_ports[] = { 0, 0x284, 0x384 }; | 265 | int probe_ports[] = { 0, 0x284, 0x384 }; |
286 | 266 | ||
@@ -333,6 +313,18 @@ static int __init fmi_init(void) | |||
333 | return res; | 313 | return res; |
334 | } | 314 | } |
335 | 315 | ||
316 | v4l2_ctrl_handler_init(hdl, 1); | ||
317 | v4l2_ctrl_new_std(hdl, &fmi_ctrl_ops, | ||
318 | V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); | ||
319 | v4l2_dev->ctrl_handler = hdl; | ||
320 | if (hdl->error) { | ||
321 | res = hdl->error; | ||
322 | v4l2_err(v4l2_dev, "Could not register controls\n"); | ||
323 | v4l2_ctrl_handler_free(hdl); | ||
324 | v4l2_device_unregister(v4l2_dev); | ||
325 | return res; | ||
326 | } | ||
327 | |||
336 | strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name)); | 328 | strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name)); |
337 | fmi->vdev.v4l2_dev = v4l2_dev; | 329 | fmi->vdev.v4l2_dev = v4l2_dev; |
338 | fmi->vdev.fops = &fmi_fops; | 330 | fmi->vdev.fops = &fmi_fops; |
@@ -346,6 +338,7 @@ static int __init fmi_init(void) | |||
346 | fmi_mute(fmi); | 338 | fmi_mute(fmi); |
347 | 339 | ||
348 | if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { | 340 | if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { |
341 | v4l2_ctrl_handler_free(hdl); | ||
349 | v4l2_device_unregister(v4l2_dev); | 342 | v4l2_device_unregister(v4l2_dev); |
350 | release_region(fmi->io, 2); | 343 | release_region(fmi->io, 2); |
351 | if (pnp_attached) | 344 | if (pnp_attached) |
@@ -361,6 +354,7 @@ static void __exit fmi_exit(void) | |||
361 | { | 354 | { |
362 | struct fmi *fmi = &fmi_card; | 355 | struct fmi *fmi = &fmi_card; |
363 | 356 | ||
357 | v4l2_ctrl_handler_free(&fmi->hdl); | ||
364 | video_unregister_device(&fmi->vdev); | 358 | video_unregister_device(&fmi->vdev); |
365 | v4l2_device_unregister(&fmi->v4l2_dev); | 359 | v4l2_device_unregister(&fmi->v4l2_dev); |
366 | release_region(fmi->io, 2); | 360 | release_region(fmi->io, 2); |