diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-02-27 03:30:13 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-03-19 10:27:21 -0400 |
commit | d4ecc83b79cc290eadf1ffb33a589c3c72bbc295 (patch) | |
tree | 2f806d32d714a8481be13106649ad17ab1eb8c62 /sound | |
parent | 9f1dfccf6607822f556698f0940ead57e6e42d5f (diff) |
[media] tea575x-tuner: update to latest V4L2 framework requirements
The tea575x-tuner module has been updated to use the latest V4L2 framework
functionality. This also required changes in the drivers that rely on it.
The tea575x changes are:
- The drivers must provide a v4l2_device struct to the tea module.
- The radio_nr module parameter must be part of the actual radio driver,
and not of the tea module.
- Changed the frequency range to the normal 76-108 MHz range instead of
50-150.
- Add hardware frequency seek support.
- Fix broken rxsubchans/audmode handling.
- The application can now select between stereo and mono.
- Support polling for control events.
- Add V4L2 priority handling.
And radio-sf16fmr2.c now uses the isa bus kernel framework.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Thanks-to: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/i2c/other/tea575x-tuner.c | 146 | ||||
-rw-r--r-- | sound/pci/es1968.c | 15 | ||||
-rw-r--r-- | sound/pci/fm801.c | 20 |
3 files changed, 113 insertions, 68 deletions
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c index 6b68c8206805..b291bd86c4ca 100644 --- a/sound/i2c/other/tea575x-tuner.c +++ b/sound/i2c/other/tea575x-tuner.c | |||
@@ -25,21 +25,20 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/version.h> | 28 | #include <linux/sched.h> |
29 | #include <media/v4l2-device.h> | ||
29 | #include <media/v4l2-dev.h> | 30 | #include <media/v4l2-dev.h> |
31 | #include <media/v4l2-fh.h> | ||
30 | #include <media/v4l2-ioctl.h> | 32 | #include <media/v4l2-ioctl.h> |
33 | #include <media/v4l2-event.h> | ||
31 | #include <sound/tea575x-tuner.h> | 34 | #include <sound/tea575x-tuner.h> |
32 | 35 | ||
33 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); | 36 | MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); |
34 | MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips"); | 37 | MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips"); |
35 | MODULE_LICENSE("GPL"); | 38 | MODULE_LICENSE("GPL"); |
36 | 39 | ||
37 | static int radio_nr = -1; | 40 | #define FREQ_LO (76U * 16000) |
38 | module_param(radio_nr, int, 0); | 41 | #define FREQ_HI (108U * 16000) |
39 | |||
40 | #define RADIO_VERSION KERNEL_VERSION(0, 0, 2) | ||
41 | #define FREQ_LO (50UL * 16000) | ||
42 | #define FREQ_HI (150UL * 16000) | ||
43 | 42 | ||
44 | /* | 43 | /* |
45 | * definitions | 44 | * definitions |
@@ -121,28 +120,10 @@ static unsigned int snd_tea575x_read(struct snd_tea575x *tea) | |||
121 | return data; | 120 | return data; |
122 | } | 121 | } |
123 | 122 | ||
124 | static void snd_tea575x_get_freq(struct snd_tea575x *tea) | ||
125 | { | ||
126 | unsigned long freq; | ||
127 | |||
128 | freq = snd_tea575x_read(tea) & TEA575X_BIT_FREQ_MASK; | ||
129 | /* freq *= 12.5 */ | ||
130 | freq *= 125; | ||
131 | freq /= 10; | ||
132 | /* crystal fixup */ | ||
133 | if (tea->tea5759) | ||
134 | freq += TEA575X_FMIF; | ||
135 | else | ||
136 | freq -= TEA575X_FMIF; | ||
137 | |||
138 | tea->freq = freq * 16; /* from kHz */ | ||
139 | } | ||
140 | |||
141 | static void snd_tea575x_set_freq(struct snd_tea575x *tea) | 123 | static void snd_tea575x_set_freq(struct snd_tea575x *tea) |
142 | { | 124 | { |
143 | unsigned long freq; | 125 | u32 freq = tea->freq; |
144 | 126 | ||
145 | freq = clamp(tea->freq, FREQ_LO, FREQ_HI); | ||
146 | freq /= 16; /* to kHz */ | 127 | freq /= 16; /* to kHz */ |
147 | /* crystal fixup */ | 128 | /* crystal fixup */ |
148 | if (tea->tea5759) | 129 | if (tea->tea5759) |
@@ -167,12 +148,14 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
167 | { | 148 | { |
168 | struct snd_tea575x *tea = video_drvdata(file); | 149 | struct snd_tea575x *tea = video_drvdata(file); |
169 | 150 | ||
170 | strlcpy(v->driver, "tea575x-tuner", sizeof(v->driver)); | 151 | strlcpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver)); |
171 | strlcpy(v->card, tea->card, sizeof(v->card)); | 152 | strlcpy(v->card, tea->card, sizeof(v->card)); |
172 | strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card)); | 153 | strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card)); |
173 | strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); | 154 | strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); |
174 | v->version = RADIO_VERSION; | 155 | v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; |
175 | v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; | 156 | if (!tea->cannot_read_data) |
157 | v->device_caps |= V4L2_CAP_HW_FREQ_SEEK; | ||
158 | v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
176 | return 0; | 159 | return 0; |
177 | } | 160 | } |
178 | 161 | ||
@@ -191,18 +174,24 @@ static int vidioc_g_tuner(struct file *file, void *priv, | |||
191 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | 174 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; |
192 | v->rangelow = FREQ_LO; | 175 | v->rangelow = FREQ_LO; |
193 | v->rangehigh = FREQ_HI; | 176 | v->rangehigh = FREQ_HI; |
194 | v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; | 177 | v->rxsubchans = tea->stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; |
195 | v->audmode = tea->stereo ? V4L2_TUNER_MODE_STEREO : V4L2_TUNER_MODE_MONO; | 178 | v->audmode = (tea->val & TEA575X_BIT_MONO) ? |
179 | V4L2_TUNER_MODE_MONO : V4L2_TUNER_MODE_STEREO; | ||
196 | v->signal = tea->tuned ? 0xffff : 0; | 180 | v->signal = tea->tuned ? 0xffff : 0; |
197 | |||
198 | return 0; | 181 | return 0; |
199 | } | 182 | } |
200 | 183 | ||
201 | static int vidioc_s_tuner(struct file *file, void *priv, | 184 | static int vidioc_s_tuner(struct file *file, void *priv, |
202 | struct v4l2_tuner *v) | 185 | struct v4l2_tuner *v) |
203 | { | 186 | { |
204 | if (v->index > 0) | 187 | struct snd_tea575x *tea = video_drvdata(file); |
188 | |||
189 | if (v->index) | ||
205 | return -EINVAL; | 190 | return -EINVAL; |
191 | tea->val &= ~TEA575X_BIT_MONO; | ||
192 | if (v->audmode == V4L2_TUNER_MODE_MONO) | ||
193 | tea->val |= TEA575X_BIT_MONO; | ||
194 | snd_tea575x_write(tea, tea->val); | ||
206 | return 0; | 195 | return 0; |
207 | } | 196 | } |
208 | 197 | ||
@@ -214,7 +203,6 @@ static int vidioc_g_frequency(struct file *file, void *priv, | |||
214 | if (f->tuner != 0) | 203 | if (f->tuner != 0) |
215 | return -EINVAL; | 204 | return -EINVAL; |
216 | f->type = V4L2_TUNER_RADIO; | 205 | f->type = V4L2_TUNER_RADIO; |
217 | snd_tea575x_get_freq(tea); | ||
218 | f->frequency = tea->freq; | 206 | f->frequency = tea->freq; |
219 | return 0; | 207 | return 0; |
220 | } | 208 | } |
@@ -227,32 +215,47 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
227 | if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) | 215 | if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) |
228 | return -EINVAL; | 216 | return -EINVAL; |
229 | 217 | ||
230 | if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) | 218 | tea->val &= ~TEA575X_BIT_SEARCH; |
231 | return -EINVAL; | 219 | tea->freq = clamp(f->frequency, FREQ_LO, FREQ_HI); |
232 | |||
233 | tea->freq = f->frequency; | ||
234 | |||
235 | snd_tea575x_set_freq(tea); | 220 | snd_tea575x_set_freq(tea); |
236 | |||
237 | return 0; | 221 | return 0; |
238 | } | 222 | } |
239 | 223 | ||
240 | static int vidioc_g_audio(struct file *file, void *priv, | 224 | static int vidioc_s_hw_freq_seek(struct file *file, void *fh, |
241 | struct v4l2_audio *a) | 225 | struct v4l2_hw_freq_seek *a) |
242 | { | 226 | { |
243 | if (a->index > 1) | 227 | struct snd_tea575x *tea = video_drvdata(file); |
244 | return -EINVAL; | ||
245 | |||
246 | strcpy(a->name, "Radio"); | ||
247 | a->capability = V4L2_AUDCAP_STEREO; | ||
248 | return 0; | ||
249 | } | ||
250 | 228 | ||
251 | static int vidioc_s_audio(struct file *file, void *priv, | 229 | if (tea->cannot_read_data) |
252 | struct v4l2_audio *a) | 230 | return -ENOTTY; |
253 | { | 231 | if (a->tuner || a->wrap_around) |
254 | if (a->index != 0) | ||
255 | return -EINVAL; | 232 | return -EINVAL; |
233 | tea->val |= TEA575X_BIT_SEARCH; | ||
234 | tea->val &= ~TEA575X_BIT_UPDOWN; | ||
235 | if (a->seek_upward) | ||
236 | tea->val |= TEA575X_BIT_UPDOWN; | ||
237 | snd_tea575x_write(tea, tea->val); | ||
238 | for (;;) { | ||
239 | unsigned val = snd_tea575x_read(tea); | ||
240 | |||
241 | if (!(val & TEA575X_BIT_SEARCH)) { | ||
242 | /* Found a frequency */ | ||
243 | val &= TEA575X_BIT_FREQ_MASK; | ||
244 | val = (val * 10) / 125; | ||
245 | if (tea->tea5759) | ||
246 | val += TEA575X_FMIF; | ||
247 | else | ||
248 | val -= TEA575X_FMIF; | ||
249 | tea->freq = clamp(val * 16, FREQ_LO, FREQ_HI); | ||
250 | return 0; | ||
251 | } | ||
252 | if (schedule_timeout_interruptible(msecs_to_jiffies(10))) { | ||
253 | /* some signal arrived, stop search */ | ||
254 | tea->val &= ~TEA575X_BIT_SEARCH; | ||
255 | snd_tea575x_write(tea, tea->val); | ||
256 | return -ERESTARTSYS; | ||
257 | } | ||
258 | } | ||
256 | return 0; | 259 | return 0; |
257 | } | 260 | } |
258 | 261 | ||
@@ -273,23 +276,27 @@ static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl) | |||
273 | static const struct v4l2_file_operations tea575x_fops = { | 276 | static const struct v4l2_file_operations tea575x_fops = { |
274 | .owner = THIS_MODULE, | 277 | .owner = THIS_MODULE, |
275 | .unlocked_ioctl = video_ioctl2, | 278 | .unlocked_ioctl = video_ioctl2, |
279 | .open = v4l2_fh_open, | ||
280 | .release = v4l2_fh_release, | ||
281 | .poll = v4l2_ctrl_poll, | ||
276 | }; | 282 | }; |
277 | 283 | ||
278 | static const struct v4l2_ioctl_ops tea575x_ioctl_ops = { | 284 | static const struct v4l2_ioctl_ops tea575x_ioctl_ops = { |
279 | .vidioc_querycap = vidioc_querycap, | 285 | .vidioc_querycap = vidioc_querycap, |
280 | .vidioc_g_tuner = vidioc_g_tuner, | 286 | .vidioc_g_tuner = vidioc_g_tuner, |
281 | .vidioc_s_tuner = vidioc_s_tuner, | 287 | .vidioc_s_tuner = vidioc_s_tuner, |
282 | .vidioc_g_audio = vidioc_g_audio, | ||
283 | .vidioc_s_audio = vidioc_s_audio, | ||
284 | .vidioc_g_frequency = vidioc_g_frequency, | 288 | .vidioc_g_frequency = vidioc_g_frequency, |
285 | .vidioc_s_frequency = vidioc_s_frequency, | 289 | .vidioc_s_frequency = vidioc_s_frequency, |
290 | .vidioc_s_hw_freq_seek = vidioc_s_hw_freq_seek, | ||
291 | .vidioc_log_status = v4l2_ctrl_log_status, | ||
292 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
293 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
286 | }; | 294 | }; |
287 | 295 | ||
288 | static struct video_device tea575x_radio = { | 296 | static const struct video_device tea575x_radio = { |
289 | .name = "tea575x-tuner", | ||
290 | .fops = &tea575x_fops, | 297 | .fops = &tea575x_fops, |
291 | .ioctl_ops = &tea575x_ioctl_ops, | 298 | .ioctl_ops = &tea575x_ioctl_ops, |
292 | .release = video_device_release_empty, | 299 | .release = video_device_release_empty, |
293 | }; | 300 | }; |
294 | 301 | ||
295 | static const struct v4l2_ctrl_ops tea575x_ctrl_ops = { | 302 | static const struct v4l2_ctrl_ops tea575x_ctrl_ops = { |
@@ -303,11 +310,15 @@ int snd_tea575x_init(struct snd_tea575x *tea) | |||
303 | { | 310 | { |
304 | int retval; | 311 | int retval; |
305 | 312 | ||
306 | tea->mute = 1; | 313 | tea->mute = true; |
307 | 314 | ||
308 | snd_tea575x_write(tea, 0x55AA); | 315 | /* Not all devices can or know how to read the data back. |
309 | if (snd_tea575x_read(tea) != 0x55AA) | 316 | Such devices can set cannot_read_data to true. */ |
310 | return -ENODEV; | 317 | if (!tea->cannot_read_data) { |
318 | snd_tea575x_write(tea, 0x55AA); | ||
319 | if (snd_tea575x_read(tea) != 0x55AA) | ||
320 | return -ENODEV; | ||
321 | } | ||
311 | 322 | ||
312 | tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40; | 323 | tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40; |
313 | tea->freq = 90500 * 16; /* 90.5Mhz default */ | 324 | tea->freq = 90500 * 16; /* 90.5Mhz default */ |
@@ -316,14 +327,17 @@ int snd_tea575x_init(struct snd_tea575x *tea) | |||
316 | tea->vd = tea575x_radio; | 327 | tea->vd = tea575x_radio; |
317 | video_set_drvdata(&tea->vd, tea); | 328 | video_set_drvdata(&tea->vd, tea); |
318 | mutex_init(&tea->mutex); | 329 | mutex_init(&tea->mutex); |
330 | strlcpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name)); | ||
319 | tea->vd.lock = &tea->mutex; | 331 | tea->vd.lock = &tea->mutex; |
332 | tea->vd.v4l2_dev = tea->v4l2_dev; | ||
333 | tea->vd.ctrl_handler = &tea->ctrl_handler; | ||
334 | set_bit(V4L2_FL_USE_FH_PRIO, &tea->vd.flags); | ||
320 | 335 | ||
321 | v4l2_ctrl_handler_init(&tea->ctrl_handler, 1); | 336 | v4l2_ctrl_handler_init(&tea->ctrl_handler, 1); |
322 | tea->vd.ctrl_handler = &tea->ctrl_handler; | ||
323 | v4l2_ctrl_new_std(&tea->ctrl_handler, &tea575x_ctrl_ops, V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); | 337 | v4l2_ctrl_new_std(&tea->ctrl_handler, &tea575x_ctrl_ops, V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); |
324 | retval = tea->ctrl_handler.error; | 338 | retval = tea->ctrl_handler.error; |
325 | if (retval) { | 339 | if (retval) { |
326 | printk(KERN_ERR "tea575x-tuner: can't initialize controls\n"); | 340 | v4l2_err(tea->v4l2_dev, "can't initialize controls\n"); |
327 | v4l2_ctrl_handler_free(&tea->ctrl_handler); | 341 | v4l2_ctrl_handler_free(&tea->ctrl_handler); |
328 | return retval; | 342 | return retval; |
329 | } | 343 | } |
@@ -338,9 +352,9 @@ int snd_tea575x_init(struct snd_tea575x *tea) | |||
338 | 352 | ||
339 | v4l2_ctrl_handler_setup(&tea->ctrl_handler); | 353 | v4l2_ctrl_handler_setup(&tea->ctrl_handler); |
340 | 354 | ||
341 | retval = video_register_device(&tea->vd, VFL_TYPE_RADIO, radio_nr); | 355 | retval = video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->radio_nr); |
342 | if (retval) { | 356 | if (retval) { |
343 | printk(KERN_ERR "tea575x-tuner: can't register video device!\n"); | 357 | v4l2_err(tea->v4l2_dev, "can't register video device!\n"); |
344 | v4l2_ctrl_handler_free(&tea->ctrl_handler); | 358 | v4l2_ctrl_handler_free(&tea->ctrl_handler); |
345 | return retval; | 359 | return retval; |
346 | } | 360 | } |
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index cb557c603a80..a8faae1c85e4 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c | |||
@@ -142,6 +142,7 @@ static int enable_mpu[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; | |||
142 | #ifdef SUPPORT_JOYSTICK | 142 | #ifdef SUPPORT_JOYSTICK |
143 | static bool joystick[SNDRV_CARDS]; | 143 | static bool joystick[SNDRV_CARDS]; |
144 | #endif | 144 | #endif |
145 | static int radio_nr[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; | ||
145 | 146 | ||
146 | module_param_array(index, int, NULL, 0444); | 147 | module_param_array(index, int, NULL, 0444); |
147 | MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); | 148 | MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); |
@@ -165,6 +166,9 @@ MODULE_PARM_DESC(enable_mpu, "Enable MPU401. (0 = off, 1 = on, 2 = auto)"); | |||
165 | module_param_array(joystick, bool, NULL, 0444); | 166 | module_param_array(joystick, bool, NULL, 0444); |
166 | MODULE_PARM_DESC(joystick, "Enable joystick."); | 167 | MODULE_PARM_DESC(joystick, "Enable joystick."); |
167 | #endif | 168 | #endif |
169 | module_param_array(radio_nr, int, NULL, 0444); | ||
170 | MODULE_PARM_DESC(radio_nr, "Radio device numbers"); | ||
171 | |||
168 | 172 | ||
169 | 173 | ||
170 | #define NR_APUS 64 | 174 | #define NR_APUS 64 |
@@ -558,6 +562,7 @@ struct es1968 { | |||
558 | struct work_struct hwvol_work; | 562 | struct work_struct hwvol_work; |
559 | 563 | ||
560 | #ifdef CONFIG_SND_ES1968_RADIO | 564 | #ifdef CONFIG_SND_ES1968_RADIO |
565 | struct v4l2_device v4l2_dev; | ||
561 | struct snd_tea575x tea; | 566 | struct snd_tea575x tea; |
562 | #endif | 567 | #endif |
563 | }; | 568 | }; |
@@ -2613,6 +2618,7 @@ static int snd_es1968_free(struct es1968 *chip) | |||
2613 | 2618 | ||
2614 | #ifdef CONFIG_SND_ES1968_RADIO | 2619 | #ifdef CONFIG_SND_ES1968_RADIO |
2615 | snd_tea575x_exit(&chip->tea); | 2620 | snd_tea575x_exit(&chip->tea); |
2621 | v4l2_device_unregister(&chip->v4l2_dev); | ||
2616 | #endif | 2622 | #endif |
2617 | 2623 | ||
2618 | if (chip->irq >= 0) | 2624 | if (chip->irq >= 0) |
@@ -2655,6 +2661,7 @@ static int __devinit snd_es1968_create(struct snd_card *card, | |||
2655 | int capt_streams, | 2661 | int capt_streams, |
2656 | int chip_type, | 2662 | int chip_type, |
2657 | int do_pm, | 2663 | int do_pm, |
2664 | int radio_nr, | ||
2658 | struct es1968 **chip_ret) | 2665 | struct es1968 **chip_ret) |
2659 | { | 2666 | { |
2660 | static struct snd_device_ops ops = { | 2667 | static struct snd_device_ops ops = { |
@@ -2751,7 +2758,14 @@ static int __devinit snd_es1968_create(struct snd_card *card, | |||
2751 | snd_card_set_dev(card, &pci->dev); | 2758 | snd_card_set_dev(card, &pci->dev); |
2752 | 2759 | ||
2753 | #ifdef CONFIG_SND_ES1968_RADIO | 2760 | #ifdef CONFIG_SND_ES1968_RADIO |
2761 | err = v4l2_device_register(&pci->dev, &chip->v4l2_dev); | ||
2762 | if (err < 0) { | ||
2763 | snd_es1968_free(chip); | ||
2764 | return err; | ||
2765 | } | ||
2766 | chip->tea.v4l2_dev = &chip->v4l2_dev; | ||
2754 | chip->tea.private_data = chip; | 2767 | chip->tea.private_data = chip; |
2768 | chip->tea.radio_nr = radio_nr; | ||
2755 | chip->tea.ops = &snd_es1968_tea_ops; | 2769 | chip->tea.ops = &snd_es1968_tea_ops; |
2756 | strlcpy(chip->tea.card, "SF64-PCE2", sizeof(chip->tea.card)); | 2770 | strlcpy(chip->tea.card, "SF64-PCE2", sizeof(chip->tea.card)); |
2757 | sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci)); | 2771 | sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci)); |
@@ -2797,6 +2811,7 @@ static int __devinit snd_es1968_probe(struct pci_dev *pci, | |||
2797 | pcm_substreams_c[dev], | 2811 | pcm_substreams_c[dev], |
2798 | pci_id->driver_data, | 2812 | pci_id->driver_data, |
2799 | use_pm[dev], | 2813 | use_pm[dev], |
2814 | radio_nr[dev], | ||
2800 | &chip)) < 0) { | 2815 | &chip)) < 0) { |
2801 | snd_card_free(card); | 2816 | snd_card_free(card); |
2802 | return err; | 2817 | return err; |
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 9597ef1eccca..a416ea8af3e9 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c | |||
@@ -58,6 +58,7 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card | |||
58 | * High 16-bits are video (radio) device number + 1 | 58 | * High 16-bits are video (radio) device number + 1 |
59 | */ | 59 | */ |
60 | static int tea575x_tuner[SNDRV_CARDS]; | 60 | static int tea575x_tuner[SNDRV_CARDS]; |
61 | static int radio_nr[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; | ||
61 | 62 | ||
62 | module_param_array(index, int, NULL, 0444); | 63 | module_param_array(index, int, NULL, 0444); |
63 | MODULE_PARM_DESC(index, "Index value for the FM801 soundcard."); | 64 | MODULE_PARM_DESC(index, "Index value for the FM801 soundcard."); |
@@ -67,6 +68,9 @@ module_param_array(enable, bool, NULL, 0444); | |||
67 | MODULE_PARM_DESC(enable, "Enable FM801 soundcard."); | 68 | MODULE_PARM_DESC(enable, "Enable FM801 soundcard."); |
68 | module_param_array(tea575x_tuner, int, NULL, 0444); | 69 | module_param_array(tea575x_tuner, int, NULL, 0444); |
69 | MODULE_PARM_DESC(tea575x_tuner, "TEA575x tuner access method (0 = auto, 1 = SF256-PCS, 2=SF256-PCP, 3=SF64-PCR, 8=disable, +16=tuner-only)."); | 70 | MODULE_PARM_DESC(tea575x_tuner, "TEA575x tuner access method (0 = auto, 1 = SF256-PCS, 2=SF256-PCP, 3=SF64-PCR, 8=disable, +16=tuner-only)."); |
71 | module_param_array(radio_nr, int, NULL, 0444); | ||
72 | MODULE_PARM_DESC(radio_nr, "Radio device numbers"); | ||
73 | |||
70 | 74 | ||
71 | #define TUNER_DISABLED (1<<3) | 75 | #define TUNER_DISABLED (1<<3) |
72 | #define TUNER_ONLY (1<<4) | 76 | #define TUNER_ONLY (1<<4) |
@@ -197,6 +201,7 @@ struct fm801 { | |||
197 | struct snd_info_entry *proc_entry; | 201 | struct snd_info_entry *proc_entry; |
198 | 202 | ||
199 | #ifdef CONFIG_SND_FM801_TEA575X_BOOL | 203 | #ifdef CONFIG_SND_FM801_TEA575X_BOOL |
204 | struct v4l2_device v4l2_dev; | ||
200 | struct snd_tea575x tea; | 205 | struct snd_tea575x tea; |
201 | #endif | 206 | #endif |
202 | 207 | ||
@@ -1154,8 +1159,10 @@ static int snd_fm801_free(struct fm801 *chip) | |||
1154 | 1159 | ||
1155 | __end_hw: | 1160 | __end_hw: |
1156 | #ifdef CONFIG_SND_FM801_TEA575X_BOOL | 1161 | #ifdef CONFIG_SND_FM801_TEA575X_BOOL |
1157 | if (!(chip->tea575x_tuner & TUNER_DISABLED)) | 1162 | if (!(chip->tea575x_tuner & TUNER_DISABLED)) { |
1158 | snd_tea575x_exit(&chip->tea); | 1163 | snd_tea575x_exit(&chip->tea); |
1164 | v4l2_device_unregister(&chip->v4l2_dev); | ||
1165 | } | ||
1159 | #endif | 1166 | #endif |
1160 | if (chip->irq >= 0) | 1167 | if (chip->irq >= 0) |
1161 | free_irq(chip->irq, chip); | 1168 | free_irq(chip->irq, chip); |
@@ -1175,6 +1182,7 @@ static int snd_fm801_dev_free(struct snd_device *device) | |||
1175 | static int __devinit snd_fm801_create(struct snd_card *card, | 1182 | static int __devinit snd_fm801_create(struct snd_card *card, |
1176 | struct pci_dev * pci, | 1183 | struct pci_dev * pci, |
1177 | int tea575x_tuner, | 1184 | int tea575x_tuner, |
1185 | int radio_nr, | ||
1178 | struct fm801 ** rchip) | 1186 | struct fm801 ** rchip) |
1179 | { | 1187 | { |
1180 | struct fm801 *chip; | 1188 | struct fm801 *chip; |
@@ -1234,6 +1242,13 @@ static int __devinit snd_fm801_create(struct snd_card *card, | |||
1234 | snd_card_set_dev(card, &pci->dev); | 1242 | snd_card_set_dev(card, &pci->dev); |
1235 | 1243 | ||
1236 | #ifdef CONFIG_SND_FM801_TEA575X_BOOL | 1244 | #ifdef CONFIG_SND_FM801_TEA575X_BOOL |
1245 | err = v4l2_device_register(&pci->dev, &chip->v4l2_dev); | ||
1246 | if (err < 0) { | ||
1247 | snd_fm801_free(chip); | ||
1248 | return err; | ||
1249 | } | ||
1250 | chip->tea.v4l2_dev = &chip->v4l2_dev; | ||
1251 | chip->tea.radio_nr = radio_nr; | ||
1237 | chip->tea.private_data = chip; | 1252 | chip->tea.private_data = chip; |
1238 | chip->tea.ops = &snd_fm801_tea_ops; | 1253 | chip->tea.ops = &snd_fm801_tea_ops; |
1239 | sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci)); | 1254 | sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci)); |
@@ -1241,6 +1256,7 @@ static int __devinit snd_fm801_create(struct snd_card *card, | |||
1241 | (tea575x_tuner & TUNER_TYPE_MASK) < 4) { | 1256 | (tea575x_tuner & TUNER_TYPE_MASK) < 4) { |
1242 | if (snd_tea575x_init(&chip->tea)) { | 1257 | if (snd_tea575x_init(&chip->tea)) { |
1243 | snd_printk(KERN_ERR "TEA575x radio not found\n"); | 1258 | snd_printk(KERN_ERR "TEA575x radio not found\n"); |
1259 | snd_fm801_free(chip); | ||
1244 | return -ENODEV; | 1260 | return -ENODEV; |
1245 | } | 1261 | } |
1246 | } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) { | 1262 | } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) { |
@@ -1287,7 +1303,7 @@ static int __devinit snd_card_fm801_probe(struct pci_dev *pci, | |||
1287 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | 1303 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); |
1288 | if (err < 0) | 1304 | if (err < 0) |
1289 | return err; | 1305 | return err; |
1290 | if ((err = snd_fm801_create(card, pci, tea575x_tuner[dev], &chip)) < 0) { | 1306 | if ((err = snd_fm801_create(card, pci, tea575x_tuner[dev], radio_nr[dev], &chip)) < 0) { |
1291 | snd_card_free(card); | 1307 | snd_card_free(card); |
1292 | return err; | 1308 | return err; |
1293 | } | 1309 | } |