diff options
author | Alexey Klimov <klimov.linux@gmail.com> | 2009-04-03 17:45:17 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 20:44:50 -0400 |
commit | 406827cccca472b2b2d9dd69020a93504bf29561 (patch) | |
tree | 30b8a8e874f87cccb9caf55961656135e1b0f0c2 /drivers/media | |
parent | ec624803b47a5cc08fc270005890b3bead5df262 (diff) |
V4L/DVB (11435): dsbr100 radio: convert to to v4l2_device
dsbr100: convert to v4l2_device.
Signed-off-by: Alexey Klimov <klimov.linux@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/radio/dsbr100.c | 88 |
1 files changed, 36 insertions, 52 deletions
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index cc54ed4efc48..613576202294 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -33,6 +33,9 @@ | |||
33 | 33 | ||
34 | History: | 34 | History: |
35 | 35 | ||
36 | Version 0.45: | ||
37 | Converted to v4l2_device. | ||
38 | |||
36 | Version 0.44: | 39 | Version 0.44: |
37 | Add suspend/resume functions, fix unplug of device, | 40 | Add suspend/resume functions, fix unplug of device, |
38 | a lot of cleanups and fixes by Alexey Klimov <klimov.linux@gmail.com> | 41 | a lot of cleanups and fixes by Alexey Klimov <klimov.linux@gmail.com> |
@@ -88,7 +91,7 @@ | |||
88 | #include <linux/slab.h> | 91 | #include <linux/slab.h> |
89 | #include <linux/input.h> | 92 | #include <linux/input.h> |
90 | #include <linux/videodev2.h> | 93 | #include <linux/videodev2.h> |
91 | #include <media/v4l2-common.h> | 94 | #include <media/v4l2-device.h> |
92 | #include <media/v4l2-ioctl.h> | 95 | #include <media/v4l2-ioctl.h> |
93 | #include <linux/usb.h> | 96 | #include <linux/usb.h> |
94 | 97 | ||
@@ -97,39 +100,8 @@ | |||
97 | */ | 100 | */ |
98 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | 101 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ |
99 | 102 | ||
100 | #define DRIVER_VERSION "v0.44" | 103 | #define DRIVER_VERSION "v0.45" |
101 | #define RADIO_VERSION KERNEL_VERSION(0, 4, 4) | 104 | #define RADIO_VERSION KERNEL_VERSION(0, 4, 5) |
102 | |||
103 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
104 | { | ||
105 | .id = V4L2_CID_AUDIO_MUTE, | ||
106 | .name = "Mute", | ||
107 | .minimum = 0, | ||
108 | .maximum = 1, | ||
109 | .default_value = 1, | ||
110 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
111 | }, | ||
112 | /* HINT: the disabled controls are only here to satify kradio and such apps */ | ||
113 | { .id = V4L2_CID_AUDIO_VOLUME, | ||
114 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
115 | }, | ||
116 | { | ||
117 | .id = V4L2_CID_AUDIO_BALANCE, | ||
118 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
119 | }, | ||
120 | { | ||
121 | .id = V4L2_CID_AUDIO_BASS, | ||
122 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
123 | }, | ||
124 | { | ||
125 | .id = V4L2_CID_AUDIO_TREBLE, | ||
126 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
127 | }, | ||
128 | { | ||
129 | .id = V4L2_CID_AUDIO_LOUDNESS, | ||
130 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
131 | }, | ||
132 | }; | ||
133 | 105 | ||
134 | #define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" | 106 | #define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" |
135 | #define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" | 107 | #define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" |
@@ -167,6 +139,8 @@ module_param(radio_nr, int, 0); | |||
167 | struct dsbr100_device { | 139 | struct dsbr100_device { |
168 | struct usb_device *usbdev; | 140 | struct usb_device *usbdev; |
169 | struct video_device videodev; | 141 | struct video_device videodev; |
142 | struct v4l2_device v4l2_dev; | ||
143 | |||
170 | u8 *transfer_buffer; | 144 | u8 *transfer_buffer; |
171 | struct mutex lock; /* buffer locking */ | 145 | struct mutex lock; /* buffer locking */ |
172 | int curfreq; | 146 | int curfreq; |
@@ -384,6 +358,7 @@ static void usb_dsbr100_disconnect(struct usb_interface *intf) | |||
384 | mutex_unlock(&radio->lock); | 358 | mutex_unlock(&radio->lock); |
385 | 359 | ||
386 | video_unregister_device(&radio->videodev); | 360 | video_unregister_device(&radio->videodev); |
361 | v4l2_device_disconnect(&radio->v4l2_dev); | ||
387 | } | 362 | } |
388 | 363 | ||
389 | 364 | ||
@@ -479,14 +454,11 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
479 | static int vidioc_queryctrl(struct file *file, void *priv, | 454 | static int vidioc_queryctrl(struct file *file, void *priv, |
480 | struct v4l2_queryctrl *qc) | 455 | struct v4l2_queryctrl *qc) |
481 | { | 456 | { |
482 | int i; | 457 | switch (qc->id) { |
483 | 458 | case V4L2_CID_AUDIO_MUTE: | |
484 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | 459 | return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1); |
485 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
486 | memcpy(qc, &(radio_qctrl[i]), sizeof(*qc)); | ||
487 | return 0; | ||
488 | } | ||
489 | } | 460 | } |
461 | |||
490 | return -EINVAL; | 462 | return -EINVAL; |
491 | } | 463 | } |
492 | 464 | ||
@@ -656,6 +628,7 @@ static void usb_dsbr100_video_device_release(struct video_device *videodev) | |||
656 | { | 628 | { |
657 | struct dsbr100_device *radio = videodev_to_radio(videodev); | 629 | struct dsbr100_device *radio = videodev_to_radio(videodev); |
658 | 630 | ||
631 | v4l2_device_unregister(&radio->v4l2_dev); | ||
659 | kfree(radio->transfer_buffer); | 632 | kfree(radio->transfer_buffer); |
660 | kfree(radio); | 633 | kfree(radio); |
661 | } | 634 | } |
@@ -683,22 +656,15 @@ static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = { | |||
683 | .vidioc_s_input = vidioc_s_input, | 656 | .vidioc_s_input = vidioc_s_input, |
684 | }; | 657 | }; |
685 | 658 | ||
686 | /* V4L2 interface */ | ||
687 | static struct video_device dsbr100_videodev_data = { | ||
688 | .name = "D-Link DSB-R 100", | ||
689 | .fops = &usb_dsbr100_fops, | ||
690 | .ioctl_ops = &usb_dsbr100_ioctl_ops, | ||
691 | .release = usb_dsbr100_video_device_release, | ||
692 | }; | ||
693 | |||
694 | /* check if the device is present and register with v4l and usb if it is */ | 659 | /* check if the device is present and register with v4l and usb if it is */ |
695 | static int usb_dsbr100_probe(struct usb_interface *intf, | 660 | static int usb_dsbr100_probe(struct usb_interface *intf, |
696 | const struct usb_device_id *id) | 661 | const struct usb_device_id *id) |
697 | { | 662 | { |
698 | struct dsbr100_device *radio; | 663 | struct dsbr100_device *radio; |
664 | struct v4l2_device *v4l2_dev; | ||
699 | int retval; | 665 | int retval; |
700 | 666 | ||
701 | radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL); | 667 | radio = kzalloc(sizeof(struct dsbr100_device), GFP_KERNEL); |
702 | 668 | ||
703 | if (!radio) | 669 | if (!radio) |
704 | return -ENOMEM; | 670 | return -ENOMEM; |
@@ -710,17 +676,35 @@ static int usb_dsbr100_probe(struct usb_interface *intf, | |||
710 | return -ENOMEM; | 676 | return -ENOMEM; |
711 | } | 677 | } |
712 | 678 | ||
679 | v4l2_dev = &radio->v4l2_dev; | ||
680 | |||
681 | retval = v4l2_device_register(&intf->dev, v4l2_dev); | ||
682 | if (retval < 0) { | ||
683 | v4l2_err(v4l2_dev, "couldn't register v4l2_device\n"); | ||
684 | kfree(radio->transfer_buffer); | ||
685 | kfree(radio); | ||
686 | return retval; | ||
687 | } | ||
688 | |||
689 | strlcpy(radio->videodev.name, v4l2_dev->name, sizeof(radio->videodev.name)); | ||
690 | radio->videodev.v4l2_dev = v4l2_dev; | ||
691 | radio->videodev.fops = &usb_dsbr100_fops; | ||
692 | radio->videodev.ioctl_ops = &usb_dsbr100_ioctl_ops; | ||
693 | radio->videodev.release = usb_dsbr100_video_device_release; | ||
694 | |||
713 | mutex_init(&radio->lock); | 695 | mutex_init(&radio->lock); |
714 | radio->videodev = dsbr100_videodev_data; | ||
715 | 696 | ||
716 | radio->removed = 0; | 697 | radio->removed = 0; |
717 | radio->users = 0; | 698 | radio->users = 0; |
718 | radio->usbdev = interface_to_usbdev(intf); | 699 | radio->usbdev = interface_to_usbdev(intf); |
719 | radio->curfreq = FREQ_MIN * FREQ_MUL; | 700 | radio->curfreq = FREQ_MIN * FREQ_MUL; |
701 | |||
720 | video_set_drvdata(&radio->videodev, radio); | 702 | video_set_drvdata(&radio->videodev, radio); |
703 | |||
721 | retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, radio_nr); | 704 | retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, radio_nr); |
722 | if (retval < 0) { | 705 | if (retval < 0) { |
723 | dev_err(&intf->dev, "couldn't register video device\n"); | 706 | v4l2_err(v4l2_dev, "couldn't register video device\n"); |
707 | v4l2_device_unregister(v4l2_dev); | ||
724 | kfree(radio->transfer_buffer); | 708 | kfree(radio->transfer_buffer); |
725 | kfree(radio); | 709 | kfree(radio); |
726 | return -EIO; | 710 | return -EIO; |