aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 17:39:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 17:39:09 -0400
commite317234975cb7463b8ca21a93bb6862d9dcf113f (patch)
tree4446fa3a21364f3cba23a22aa2a94027f169d8df /sound
parentf37ab0fba271e43edab0e3ae9fe644fcda455402 (diff)
parent7483d45f0aee3afc0646d185cabd4af9f6cab58c (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - V4L2 API additions to better support JPEG compression control - media API additions to properly support MPEG decoders - V4L2 API additions for image crop/scaling - a few other V4L2 API DocBook fixes/improvements - two new DVB frontend drivers: m88rs2000 and rtl2830 - two new DVB drivers: az6007 and rtl28xxu - a framework for ISA drivers, that removed lots of common code found at the ISA radio drivers - a new FM transmitter driver (radio-keene) - a GPIO-based IR receiver driver - a new sensor driver: mt9m032 - some new video drivers: adv7183, blackfin, mx2_emmaprp, sii9234_drv, vs6624 - several new board additions, driver fixes, improvements and cleanups. * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (295 commits) [media] update CARDLIST.em28xx [media] partially reverts changeset fa5527c [media] stb0899: fix the limits for signal strength values [media] em28xx: support for 2304:0242 PCTV QuatroStick (510e) [media] em28xx: support for 2013:0251 PCTV QuatroStick nano (520e) [media] -EINVAL -> -ENOTTY [media] gspca - sn9c20x: Cleanup source [media] gspca - sn9c20x: Simplify register write for capture start/stop [media] gspca - sn9c20x: Add automatic JPEG compression mechanism [media] gspca - sn9c20x: Greater delay in case of sensor no response [media] gspca - sn9c20x: Optimize the code of write sequences [media] gspca - sn9c20x: Add the JPEG compression quality control [media] gspca - sn9c20x: Add a delay after Omnivision sensor reset [media] gspca - sn9c20x: Propagate USB errors to higher level [media] gspca - sn9c20x: Use the new video control mechanism [media] gspca - sn9c20x: Fix loss of frame start [media] gspca - zc3xx: Lack of register 08 value for sensor cs2102k [media] gspca - ov534_9: Add brightness to OmniVision 5621 sensor [media] gspca - zc3xx: Add V4L2_CID_JPEG_COMPRESSION_QUALITY control support [media] pvrusb2: fix 7MHz & 8MHz DVB-T tuner support for HVR1900 rev D1F5 ...
Diffstat (limited to 'sound')
-rw-r--r--sound/i2c/other/tea575x-tuner.c169
-rw-r--r--sound/pci/es1968.c15
-rw-r--r--sound/pci/fm801.c20
3 files changed, 146 insertions, 58 deletions
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c
index 6b68c8206805..a63faec5e7fd 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
33MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 36MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
34MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips"); 37MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips");
35MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
36 39
37static int radio_nr = -1; 40#define FREQ_LO (76U * 16000)
38module_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
@@ -90,7 +89,7 @@ static void snd_tea575x_write(struct snd_tea575x *tea, unsigned int val)
90 tea->ops->set_pins(tea, 0); 89 tea->ops->set_pins(tea, 0);
91} 90}
92 91
93static unsigned int snd_tea575x_read(struct snd_tea575x *tea) 92static u32 snd_tea575x_read(struct snd_tea575x *tea)
94{ 93{
95 u16 l, rdata; 94 u16 l, rdata;
96 u32 data = 0; 95 u32 data = 0;
@@ -121,11 +120,13 @@ static unsigned int snd_tea575x_read(struct snd_tea575x *tea)
121 return data; 120 return data;
122} 121}
123 122
124static void snd_tea575x_get_freq(struct snd_tea575x *tea) 123static u32 snd_tea575x_get_freq(struct snd_tea575x *tea)
125{ 124{
126 unsigned long freq; 125 u32 freq = snd_tea575x_read(tea) & TEA575X_BIT_FREQ_MASK;
126
127 if (freq == 0)
128 return freq;
127 129
128 freq = snd_tea575x_read(tea) & TEA575X_BIT_FREQ_MASK;
129 /* freq *= 12.5 */ 130 /* freq *= 12.5 */
130 freq *= 125; 131 freq *= 125;
131 freq /= 10; 132 freq /= 10;
@@ -135,14 +136,13 @@ static void snd_tea575x_get_freq(struct snd_tea575x *tea)
135 else 136 else
136 freq -= TEA575X_FMIF; 137 freq -= TEA575X_FMIF;
137 138
138 tea->freq = freq * 16; /* from kHz */ 139 return clamp(freq * 16, FREQ_LO, FREQ_HI); /* from kHz */
139} 140}
140 141
141static void snd_tea575x_set_freq(struct snd_tea575x *tea) 142static void snd_tea575x_set_freq(struct snd_tea575x *tea)
142{ 143{
143 unsigned long freq; 144 u32 freq = tea->freq;
144 145
145 freq = clamp(tea->freq, FREQ_LO, FREQ_HI);
146 freq /= 16; /* to kHz */ 146 freq /= 16; /* to kHz */
147 /* crystal fixup */ 147 /* crystal fixup */
148 if (tea->tea5759) 148 if (tea->tea5759)
@@ -167,12 +167,14 @@ static int vidioc_querycap(struct file *file, void *priv,
167{ 167{
168 struct snd_tea575x *tea = video_drvdata(file); 168 struct snd_tea575x *tea = video_drvdata(file);
169 169
170 strlcpy(v->driver, "tea575x-tuner", sizeof(v->driver)); 170 strlcpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver));
171 strlcpy(v->card, tea->card, sizeof(v->card)); 171 strlcpy(v->card, tea->card, sizeof(v->card));
172 strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card)); 172 strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card));
173 strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info)); 173 strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info));
174 v->version = RADIO_VERSION; 174 v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
175 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; 175 if (!tea->cannot_read_data)
176 v->device_caps |= V4L2_CAP_HW_FREQ_SEEK;
177 v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS;
176 return 0; 178 return 0;
177} 179}
178 180
@@ -191,18 +193,24 @@ static int vidioc_g_tuner(struct file *file, void *priv,
191 v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; 193 v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
192 v->rangelow = FREQ_LO; 194 v->rangelow = FREQ_LO;
193 v->rangehigh = FREQ_HI; 195 v->rangehigh = FREQ_HI;
194 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 196 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; 197 v->audmode = (tea->val & TEA575X_BIT_MONO) ?
198 V4L2_TUNER_MODE_MONO : V4L2_TUNER_MODE_STEREO;
196 v->signal = tea->tuned ? 0xffff : 0; 199 v->signal = tea->tuned ? 0xffff : 0;
197
198 return 0; 200 return 0;
199} 201}
200 202
201static int vidioc_s_tuner(struct file *file, void *priv, 203static int vidioc_s_tuner(struct file *file, void *priv,
202 struct v4l2_tuner *v) 204 struct v4l2_tuner *v)
203{ 205{
204 if (v->index > 0) 206 struct snd_tea575x *tea = video_drvdata(file);
207
208 if (v->index)
205 return -EINVAL; 209 return -EINVAL;
210 tea->val &= ~TEA575X_BIT_MONO;
211 if (v->audmode == V4L2_TUNER_MODE_MONO)
212 tea->val |= TEA575X_BIT_MONO;
213 snd_tea575x_write(tea, tea->val);
206 return 0; 214 return 0;
207} 215}
208 216
@@ -214,7 +222,6 @@ static int vidioc_g_frequency(struct file *file, void *priv,
214 if (f->tuner != 0) 222 if (f->tuner != 0)
215 return -EINVAL; 223 return -EINVAL;
216 f->type = V4L2_TUNER_RADIO; 224 f->type = V4L2_TUNER_RADIO;
217 snd_tea575x_get_freq(tea);
218 f->frequency = tea->freq; 225 f->frequency = tea->freq;
219 return 0; 226 return 0;
220} 227}
@@ -227,33 +234,72 @@ static int vidioc_s_frequency(struct file *file, void *priv,
227 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) 234 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
228 return -EINVAL; 235 return -EINVAL;
229 236
230 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) 237 tea->val &= ~TEA575X_BIT_SEARCH;
231 return -EINVAL; 238 tea->freq = clamp(f->frequency, FREQ_LO, FREQ_HI);
232
233 tea->freq = f->frequency;
234
235 snd_tea575x_set_freq(tea); 239 snd_tea575x_set_freq(tea);
236
237 return 0; 240 return 0;
238} 241}
239 242
240static int vidioc_g_audio(struct file *file, void *priv, 243static int vidioc_s_hw_freq_seek(struct file *file, void *fh,
241 struct v4l2_audio *a) 244 struct v4l2_hw_freq_seek *a)
242{ 245{
243 if (a->index > 1) 246 struct snd_tea575x *tea = video_drvdata(file);
244 return -EINVAL; 247 unsigned long timeout;
245 248 int i;
246 strcpy(a->name, "Radio");
247 a->capability = V4L2_AUDCAP_STEREO;
248 return 0;
249}
250 249
251static int vidioc_s_audio(struct file *file, void *priv, 250 if (tea->cannot_read_data)
252 struct v4l2_audio *a) 251 return -ENOTTY;
253{ 252 if (a->tuner || a->wrap_around)
254 if (a->index != 0)
255 return -EINVAL; 253 return -EINVAL;
256 return 0; 254
255 /* clear the frequency, HW will fill it in */
256 tea->val &= ~TEA575X_BIT_FREQ_MASK;
257 tea->val |= TEA575X_BIT_SEARCH;
258 if (a->seek_upward)
259 tea->val |= TEA575X_BIT_UPDOWN;
260 else
261 tea->val &= ~TEA575X_BIT_UPDOWN;
262 snd_tea575x_write(tea, tea->val);
263 timeout = jiffies + msecs_to_jiffies(10000);
264 for (;;) {
265 if (time_after(jiffies, timeout))
266 break;
267 if (schedule_timeout_interruptible(msecs_to_jiffies(10))) {
268 /* some signal arrived, stop search */
269 tea->val &= ~TEA575X_BIT_SEARCH;
270 snd_tea575x_set_freq(tea);
271 return -ERESTARTSYS;
272 }
273 if (!(snd_tea575x_read(tea) & TEA575X_BIT_SEARCH)) {
274 u32 freq;
275
276 /* Found a frequency, wait until it can be read */
277 for (i = 0; i < 100; i++) {
278 msleep(10);
279 freq = snd_tea575x_get_freq(tea);
280 if (freq) /* available */
281 break;
282 }
283 if (freq == 0) /* shouldn't happen */
284 break;
285 /*
286 * if we moved by less than 50 kHz, or in the wrong
287 * direction, continue seeking
288 */
289 if (abs(tea->freq - freq) < 16 * 50 ||
290 (a->seek_upward && freq < tea->freq) ||
291 (!a->seek_upward && freq > tea->freq)) {
292 snd_tea575x_write(tea, tea->val);
293 continue;
294 }
295 tea->freq = freq;
296 tea->val &= ~TEA575X_BIT_SEARCH;
297 return 0;
298 }
299 }
300 tea->val &= ~TEA575X_BIT_SEARCH;
301 snd_tea575x_set_freq(tea);
302 return -EAGAIN;
257} 303}
258 304
259static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl) 305static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl)
@@ -273,23 +319,27 @@ static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl)
273static const struct v4l2_file_operations tea575x_fops = { 319static const struct v4l2_file_operations tea575x_fops = {
274 .owner = THIS_MODULE, 320 .owner = THIS_MODULE,
275 .unlocked_ioctl = video_ioctl2, 321 .unlocked_ioctl = video_ioctl2,
322 .open = v4l2_fh_open,
323 .release = v4l2_fh_release,
324 .poll = v4l2_ctrl_poll,
276}; 325};
277 326
278static const struct v4l2_ioctl_ops tea575x_ioctl_ops = { 327static const struct v4l2_ioctl_ops tea575x_ioctl_ops = {
279 .vidioc_querycap = vidioc_querycap, 328 .vidioc_querycap = vidioc_querycap,
280 .vidioc_g_tuner = vidioc_g_tuner, 329 .vidioc_g_tuner = vidioc_g_tuner,
281 .vidioc_s_tuner = vidioc_s_tuner, 330 .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, 331 .vidioc_g_frequency = vidioc_g_frequency,
285 .vidioc_s_frequency = vidioc_s_frequency, 332 .vidioc_s_frequency = vidioc_s_frequency,
333 .vidioc_s_hw_freq_seek = vidioc_s_hw_freq_seek,
334 .vidioc_log_status = v4l2_ctrl_log_status,
335 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
336 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
286}; 337};
287 338
288static struct video_device tea575x_radio = { 339static const struct video_device tea575x_radio = {
289 .name = "tea575x-tuner",
290 .fops = &tea575x_fops, 340 .fops = &tea575x_fops,
291 .ioctl_ops = &tea575x_ioctl_ops, 341 .ioctl_ops = &tea575x_ioctl_ops,
292 .release = video_device_release_empty, 342 .release = video_device_release_empty,
293}; 343};
294 344
295static const struct v4l2_ctrl_ops tea575x_ctrl_ops = { 345static const struct v4l2_ctrl_ops tea575x_ctrl_ops = {
@@ -303,27 +353,34 @@ int snd_tea575x_init(struct snd_tea575x *tea)
303{ 353{
304 int retval; 354 int retval;
305 355
306 tea->mute = 1; 356 tea->mute = true;
307 357
308 snd_tea575x_write(tea, 0x55AA); 358 /* Not all devices can or know how to read the data back.
309 if (snd_tea575x_read(tea) != 0x55AA) 359 Such devices can set cannot_read_data to true. */
310 return -ENODEV; 360 if (!tea->cannot_read_data) {
361 snd_tea575x_write(tea, 0x55AA);
362 if (snd_tea575x_read(tea) != 0x55AA)
363 return -ENODEV;
364 }
311 365
312 tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40; 366 tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_5_28;
313 tea->freq = 90500 * 16; /* 90.5Mhz default */ 367 tea->freq = 90500 * 16; /* 90.5Mhz default */
314 snd_tea575x_set_freq(tea); 368 snd_tea575x_set_freq(tea);
315 369
316 tea->vd = tea575x_radio; 370 tea->vd = tea575x_radio;
317 video_set_drvdata(&tea->vd, tea); 371 video_set_drvdata(&tea->vd, tea);
318 mutex_init(&tea->mutex); 372 mutex_init(&tea->mutex);
373 strlcpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name));
319 tea->vd.lock = &tea->mutex; 374 tea->vd.lock = &tea->mutex;
375 tea->vd.v4l2_dev = tea->v4l2_dev;
376 tea->vd.ctrl_handler = &tea->ctrl_handler;
377 set_bit(V4L2_FL_USE_FH_PRIO, &tea->vd.flags);
320 378
321 v4l2_ctrl_handler_init(&tea->ctrl_handler, 1); 379 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); 380 v4l2_ctrl_new_std(&tea->ctrl_handler, &tea575x_ctrl_ops, V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
324 retval = tea->ctrl_handler.error; 381 retval = tea->ctrl_handler.error;
325 if (retval) { 382 if (retval) {
326 printk(KERN_ERR "tea575x-tuner: can't initialize controls\n"); 383 v4l2_err(tea->v4l2_dev, "can't initialize controls\n");
327 v4l2_ctrl_handler_free(&tea->ctrl_handler); 384 v4l2_ctrl_handler_free(&tea->ctrl_handler);
328 return retval; 385 return retval;
329 } 386 }
@@ -338,9 +395,9 @@ int snd_tea575x_init(struct snd_tea575x *tea)
338 395
339 v4l2_ctrl_handler_setup(&tea->ctrl_handler); 396 v4l2_ctrl_handler_setup(&tea->ctrl_handler);
340 397
341 retval = video_register_device(&tea->vd, VFL_TYPE_RADIO, radio_nr); 398 retval = video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->radio_nr);
342 if (retval) { 399 if (retval) {
343 printk(KERN_ERR "tea575x-tuner: can't register video device!\n"); 400 v4l2_err(tea->v4l2_dev, "can't register video device!\n");
344 v4l2_ctrl_handler_free(&tea->ctrl_handler); 401 v4l2_ctrl_handler_free(&tea->ctrl_handler);
345 return retval; 402 return retval;
346 } 403 }
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
143static bool joystick[SNDRV_CARDS]; 143static bool joystick[SNDRV_CARDS];
144#endif 144#endif
145static int radio_nr[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
145 146
146module_param_array(index, int, NULL, 0444); 147module_param_array(index, int, NULL, 0444);
147MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); 148MODULE_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)");
165module_param_array(joystick, bool, NULL, 0444); 166module_param_array(joystick, bool, NULL, 0444);
166MODULE_PARM_DESC(joystick, "Enable joystick."); 167MODULE_PARM_DESC(joystick, "Enable joystick.");
167#endif 168#endif
169module_param_array(radio_nr, int, NULL, 0444);
170MODULE_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 */
60static int tea575x_tuner[SNDRV_CARDS]; 60static int tea575x_tuner[SNDRV_CARDS];
61static int radio_nr[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
61 62
62module_param_array(index, int, NULL, 0444); 63module_param_array(index, int, NULL, 0444);
63MODULE_PARM_DESC(index, "Index value for the FM801 soundcard."); 64MODULE_PARM_DESC(index, "Index value for the FM801 soundcard.");
@@ -67,6 +68,9 @@ module_param_array(enable, bool, NULL, 0444);
67MODULE_PARM_DESC(enable, "Enable FM801 soundcard."); 68MODULE_PARM_DESC(enable, "Enable FM801 soundcard.");
68module_param_array(tea575x_tuner, int, NULL, 0444); 69module_param_array(tea575x_tuner, int, NULL, 0444);
69MODULE_PARM_DESC(tea575x_tuner, "TEA575x tuner access method (0 = auto, 1 = SF256-PCS, 2=SF256-PCP, 3=SF64-PCR, 8=disable, +16=tuner-only)."); 70MODULE_PARM_DESC(tea575x_tuner, "TEA575x tuner access method (0 = auto, 1 = SF256-PCS, 2=SF256-PCP, 3=SF64-PCR, 8=disable, +16=tuner-only).");
71module_param_array(radio_nr, int, NULL, 0444);
72MODULE_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)
1175static int __devinit snd_fm801_create(struct snd_card *card, 1182static 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 }