summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 14:39:09 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 14:39:09 -0700
commite317234975cb7463b8ca21a93bb6862d9dcf113f (patch)
tree4446fa3a21364f3cba23a22aa2a94027f169d8df /sound
parentf37ab0fba271e43edab0e3ae9fe644fcda455402 (diff)
parent7483d45f0aee3afc0646d185cabd4af9f6cab58c (diff)
downloadlinux-stable-e317234975cb7463b8ca21a93bb6862d9dcf113f.tar.gz
linux-stable-e317234975cb7463b8ca21a93bb6862d9dcf113f.tar.bz2
linux-stable-e317234975cb7463b8ca21a93bb6862d9dcf113f.zip
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 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
-#include <linux/version.h>
+#include <linux/sched.h>
+#include <media/v4l2-device.h>
#include <media/v4l2-dev.h>
+#include <media/v4l2-fh.h>
#include <media/v4l2-ioctl.h>
+#include <media/v4l2-event.h>
#include <sound/tea575x-tuner.h>
MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
MODULE_DESCRIPTION("Routines for control of TEA5757/5759 Philips AM/FM radio tuner chips");
MODULE_LICENSE("GPL");
-static int radio_nr = -1;
-module_param(radio_nr, int, 0);
-
-#define RADIO_VERSION KERNEL_VERSION(0, 0, 2)
-#define FREQ_LO (50UL * 16000)
-#define FREQ_HI (150UL * 16000)
+#define FREQ_LO (76U * 16000)
+#define FREQ_HI (108U * 16000)
/*
* definitions
@@ -90,7 +89,7 @@ static void snd_tea575x_write(struct snd_tea575x *tea, unsigned int val)
tea->ops->set_pins(tea, 0);
}
-static unsigned int snd_tea575x_read(struct snd_tea575x *tea)
+static u32 snd_tea575x_read(struct snd_tea575x *tea)
{
u16 l, rdata;
u32 data = 0;
@@ -121,11 +120,13 @@ static unsigned int snd_tea575x_read(struct snd_tea575x *tea)
return data;
}
-static void snd_tea575x_get_freq(struct snd_tea575x *tea)
+static u32 snd_tea575x_get_freq(struct snd_tea575x *tea)
{
- unsigned long freq;
+ u32 freq = snd_tea575x_read(tea) & TEA575X_BIT_FREQ_MASK;
+
+ if (freq == 0)
+ return freq;
- freq = snd_tea575x_read(tea) & TEA575X_BIT_FREQ_MASK;
/* freq *= 12.5 */
freq *= 125;
freq /= 10;
@@ -135,14 +136,13 @@ static void snd_tea575x_get_freq(struct snd_tea575x *tea)
else
freq -= TEA575X_FMIF;
- tea->freq = freq * 16; /* from kHz */
+ return clamp(freq * 16, FREQ_LO, FREQ_HI); /* from kHz */
}
static void snd_tea575x_set_freq(struct snd_tea575x *tea)
{
- unsigned long freq;
+ u32 freq = tea->freq;
- freq = clamp(tea->freq, FREQ_LO, FREQ_HI);
freq /= 16; /* to kHz */
/* crystal fixup */
if (tea->tea5759)
@@ -167,12 +167,14 @@ static int vidioc_querycap(struct file *file, void *priv,
{
struct snd_tea575x *tea = video_drvdata(file);
- strlcpy(v->driver, "tea575x-tuner", sizeof(v->driver));
+ strlcpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver));
strlcpy(v->card, tea->card, sizeof(v->card));
strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card));
strlcpy(v->bus_info, tea->bus_info, sizeof(v->bus_info));
- v->version = RADIO_VERSION;
- v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
+ v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
+ if (!tea->cannot_read_data)
+ v->device_caps |= V4L2_CAP_HW_FREQ_SEEK;
+ v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
}
@@ -191,18 +193,24 @@ static int vidioc_g_tuner(struct file *file, void *priv,
v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
v->rangelow = FREQ_LO;
v->rangehigh = FREQ_HI;
- v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
- v->audmode = tea->stereo ? V4L2_TUNER_MODE_STEREO : V4L2_TUNER_MODE_MONO;
+ v->rxsubchans = tea->stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
+ v->audmode = (tea->val & TEA575X_BIT_MONO) ?
+ V4L2_TUNER_MODE_MONO : V4L2_TUNER_MODE_STEREO;
v->signal = tea->tuned ? 0xffff : 0;
-
return 0;
}
static int vidioc_s_tuner(struct file *file, void *priv,
struct v4l2_tuner *v)
{
- if (v->index > 0)
+ struct snd_tea575x *tea = video_drvdata(file);
+
+ if (v->index)
return -EINVAL;
+ tea->val &= ~TEA575X_BIT_MONO;
+ if (v->audmode == V4L2_TUNER_MODE_MONO)
+ tea->val |= TEA575X_BIT_MONO;
+ snd_tea575x_write(tea, tea->val);
return 0;
}
@@ -214,7 +222,6 @@ static int vidioc_g_frequency(struct file *file, void *priv,
if (f->tuner != 0)
return -EINVAL;
f->type = V4L2_TUNER_RADIO;
- snd_tea575x_get_freq(tea);
f->frequency = tea->freq;
return 0;
}
@@ -227,33 +234,72 @@ static int vidioc_s_frequency(struct file *file, void *priv,
if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
return -EINVAL;
- if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
- return -EINVAL;
-
- tea->freq = f->frequency;
-
+ tea->val &= ~TEA575X_BIT_SEARCH;
+ tea->freq = clamp(f->frequency, FREQ_LO, FREQ_HI);
snd_tea575x_set_freq(tea);
-
return 0;
}
-static int vidioc_g_audio(struct file *file, void *priv,
- struct v4l2_audio *a)
+static int vidioc_s_hw_freq_seek(struct file *file, void *fh,
+ struct v4l2_hw_freq_seek *a)
{
- if (a->index > 1)
- return -EINVAL;
-
- strcpy(a->name, "Radio");
- a->capability = V4L2_AUDCAP_STEREO;
- return 0;
-}
+ struct snd_tea575x *tea = video_drvdata(file);
+ unsigned long timeout;
+ int i;
-static int vidioc_s_audio(struct file *file, void *priv,
- struct v4l2_audio *a)
-{
- if (a->index != 0)
+ if (tea->cannot_read_data)
+ return -ENOTTY;
+ if (a->tuner || a->wrap_around)
return -EINVAL;
- return 0;
+
+ /* clear the frequency, HW will fill it in */
+ tea->val &= ~TEA575X_BIT_FREQ_MASK;
+ tea->val |= TEA575X_BIT_SEARCH;
+ if (a->seek_upward)
+ tea->val |= TEA575X_BIT_UPDOWN;
+ else
+ tea->val &= ~TEA575X_BIT_UPDOWN;
+ snd_tea575x_write(tea, tea->val);
+ timeout = jiffies + msecs_to_jiffies(10000);
+ for (;;) {
+ if (time_after(jiffies, timeout))
+ break;
+ if (schedule_timeout_interruptible(msecs_to_jiffies(10))) {
+ /* some signal arrived, stop search */
+ tea->val &= ~TEA575X_BIT_SEARCH;
+ snd_tea575x_set_freq(tea);
+ return -ERESTARTSYS;
+ }
+ if (!(snd_tea575x_read(tea) & TEA575X_BIT_SEARCH)) {
+ u32 freq;
+
+ /* Found a frequency, wait until it can be read */
+ for (i = 0; i < 100; i++) {
+ msleep(10);
+ freq = snd_tea575x_get_freq(tea);
+ if (freq) /* available */
+ break;
+ }
+ if (freq == 0) /* shouldn't happen */
+ break;
+ /*
+ * if we moved by less than 50 kHz, or in the wrong
+ * direction, continue seeking
+ */
+ if (abs(tea->freq - freq) < 16 * 50 ||
+ (a->seek_upward && freq < tea->freq) ||
+ (!a->seek_upward && freq > tea->freq)) {
+ snd_tea575x_write(tea, tea->val);
+ continue;
+ }
+ tea->freq = freq;
+ tea->val &= ~TEA575X_BIT_SEARCH;
+ return 0;
+ }
+ }
+ tea->val &= ~TEA575X_BIT_SEARCH;
+ snd_tea575x_set_freq(tea);
+ return -EAGAIN;
}
static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl)
@@ -273,23 +319,27 @@ static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl)
static const struct v4l2_file_operations tea575x_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = video_ioctl2,
+ .open = v4l2_fh_open,
+ .release = v4l2_fh_release,
+ .poll = v4l2_ctrl_poll,
};
static const struct v4l2_ioctl_ops tea575x_ioctl_ops = {
.vidioc_querycap = vidioc_querycap,
.vidioc_g_tuner = vidioc_g_tuner,
.vidioc_s_tuner = vidioc_s_tuner,
- .vidioc_g_audio = vidioc_g_audio,
- .vidioc_s_audio = vidioc_s_audio,
.vidioc_g_frequency = vidioc_g_frequency,
.vidioc_s_frequency = vidioc_s_frequency,
+ .vidioc_s_hw_freq_seek = vidioc_s_hw_freq_seek,
+ .vidioc_log_status = v4l2_ctrl_log_status,
+ .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+ .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
};
-static struct video_device tea575x_radio = {
- .name = "tea575x-tuner",
+static const struct video_device tea575x_radio = {
.fops = &tea575x_fops,
.ioctl_ops = &tea575x_ioctl_ops,
- .release = video_device_release_empty,
+ .release = video_device_release_empty,
};
static const struct v4l2_ctrl_ops tea575x_ctrl_ops = {
@@ -303,27 +353,34 @@ int snd_tea575x_init(struct snd_tea575x *tea)
{
int retval;
- tea->mute = 1;
+ tea->mute = true;
- snd_tea575x_write(tea, 0x55AA);
- if (snd_tea575x_read(tea) != 0x55AA)
- return -ENODEV;
+ /* Not all devices can or know how to read the data back.
+ Such devices can set cannot_read_data to true. */
+ if (!tea->cannot_read_data) {
+ snd_tea575x_write(tea, 0x55AA);
+ if (snd_tea575x_read(tea) != 0x55AA)
+ return -ENODEV;
+ }
- tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40;
+ tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_5_28;
tea->freq = 90500 * 16; /* 90.5Mhz default */
snd_tea575x_set_freq(tea);
tea->vd = tea575x_radio;
video_set_drvdata(&tea->vd, tea);
mutex_init(&tea->mutex);
+ strlcpy(tea->vd.name, tea->v4l2_dev->name, sizeof(tea->vd.name));
tea->vd.lock = &tea->mutex;
+ tea->vd.v4l2_dev = tea->v4l2_dev;
+ tea->vd.ctrl_handler = &tea->ctrl_handler;
+ set_bit(V4L2_FL_USE_FH_PRIO, &tea->vd.flags);
v4l2_ctrl_handler_init(&tea->ctrl_handler, 1);
- tea->vd.ctrl_handler = &tea->ctrl_handler;
v4l2_ctrl_new_std(&tea->ctrl_handler, &tea575x_ctrl_ops, V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
retval = tea->ctrl_handler.error;
if (retval) {
- printk(KERN_ERR "tea575x-tuner: can't initialize controls\n");
+ v4l2_err(tea->v4l2_dev, "can't initialize controls\n");
v4l2_ctrl_handler_free(&tea->ctrl_handler);
return retval;
}
@@ -338,9 +395,9 @@ int snd_tea575x_init(struct snd_tea575x *tea)
v4l2_ctrl_handler_setup(&tea->ctrl_handler);
- retval = video_register_device(&tea->vd, VFL_TYPE_RADIO, radio_nr);
+ retval = video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->radio_nr);
if (retval) {
- printk(KERN_ERR "tea575x-tuner: can't register video device!\n");
+ v4l2_err(tea->v4l2_dev, "can't register video device!\n");
v4l2_ctrl_handler_free(&tea->ctrl_handler);
return retval;
}
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};
#ifdef SUPPORT_JOYSTICK
static bool joystick[SNDRV_CARDS];
#endif
+static int radio_nr[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
module_param_array(index, int, NULL, 0444);
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)");
module_param_array(joystick, bool, NULL, 0444);
MODULE_PARM_DESC(joystick, "Enable joystick.");
#endif
+module_param_array(radio_nr, int, NULL, 0444);
+MODULE_PARM_DESC(radio_nr, "Radio device numbers");
+
#define NR_APUS 64
@@ -558,6 +562,7 @@ struct es1968 {
struct work_struct hwvol_work;
#ifdef CONFIG_SND_ES1968_RADIO
+ struct v4l2_device v4l2_dev;
struct snd_tea575x tea;
#endif
};
@@ -2613,6 +2618,7 @@ static int snd_es1968_free(struct es1968 *chip)
#ifdef CONFIG_SND_ES1968_RADIO
snd_tea575x_exit(&chip->tea);
+ v4l2_device_unregister(&chip->v4l2_dev);
#endif
if (chip->irq >= 0)
@@ -2655,6 +2661,7 @@ static int __devinit snd_es1968_create(struct snd_card *card,
int capt_streams,
int chip_type,
int do_pm,
+ int radio_nr,
struct es1968 **chip_ret)
{
static struct snd_device_ops ops = {
@@ -2751,7 +2758,14 @@ static int __devinit snd_es1968_create(struct snd_card *card,
snd_card_set_dev(card, &pci->dev);
#ifdef CONFIG_SND_ES1968_RADIO
+ err = v4l2_device_register(&pci->dev, &chip->v4l2_dev);
+ if (err < 0) {
+ snd_es1968_free(chip);
+ return err;
+ }
+ chip->tea.v4l2_dev = &chip->v4l2_dev;
chip->tea.private_data = chip;
+ chip->tea.radio_nr = radio_nr;
chip->tea.ops = &snd_es1968_tea_ops;
strlcpy(chip->tea.card, "SF64-PCE2", sizeof(chip->tea.card));
sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
@@ -2797,6 +2811,7 @@ static int __devinit snd_es1968_probe(struct pci_dev *pci,
pcm_substreams_c[dev],
pci_id->driver_data,
use_pm[dev],
+ radio_nr[dev],
&chip)) < 0) {
snd_card_free(card);
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
* High 16-bits are video (radio) device number + 1
*/
static int tea575x_tuner[SNDRV_CARDS];
+static int radio_nr[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for the FM801 soundcard.");
@@ -67,6 +68,9 @@ module_param_array(enable, bool, NULL, 0444);
MODULE_PARM_DESC(enable, "Enable FM801 soundcard.");
module_param_array(tea575x_tuner, int, NULL, 0444);
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).");
+module_param_array(radio_nr, int, NULL, 0444);
+MODULE_PARM_DESC(radio_nr, "Radio device numbers");
+
#define TUNER_DISABLED (1<<3)
#define TUNER_ONLY (1<<4)
@@ -197,6 +201,7 @@ struct fm801 {
struct snd_info_entry *proc_entry;
#ifdef CONFIG_SND_FM801_TEA575X_BOOL
+ struct v4l2_device v4l2_dev;
struct snd_tea575x tea;
#endif
@@ -1154,8 +1159,10 @@ static int snd_fm801_free(struct fm801 *chip)
__end_hw:
#ifdef CONFIG_SND_FM801_TEA575X_BOOL
- if (!(chip->tea575x_tuner & TUNER_DISABLED))
+ if (!(chip->tea575x_tuner & TUNER_DISABLED)) {
snd_tea575x_exit(&chip->tea);
+ v4l2_device_unregister(&chip->v4l2_dev);
+ }
#endif
if (chip->irq >= 0)
free_irq(chip->irq, chip);
@@ -1175,6 +1182,7 @@ static int snd_fm801_dev_free(struct snd_device *device)
static int __devinit snd_fm801_create(struct snd_card *card,
struct pci_dev * pci,
int tea575x_tuner,
+ int radio_nr,
struct fm801 ** rchip)
{
struct fm801 *chip;
@@ -1234,6 +1242,13 @@ static int __devinit snd_fm801_create(struct snd_card *card,
snd_card_set_dev(card, &pci->dev);
#ifdef CONFIG_SND_FM801_TEA575X_BOOL
+ err = v4l2_device_register(&pci->dev, &chip->v4l2_dev);
+ if (err < 0) {
+ snd_fm801_free(chip);
+ return err;
+ }
+ chip->tea.v4l2_dev = &chip->v4l2_dev;
+ chip->tea.radio_nr = radio_nr;
chip->tea.private_data = chip;
chip->tea.ops = &snd_fm801_tea_ops;
sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
@@ -1241,6 +1256,7 @@ static int __devinit snd_fm801_create(struct snd_card *card,
(tea575x_tuner & TUNER_TYPE_MASK) < 4) {
if (snd_tea575x_init(&chip->tea)) {
snd_printk(KERN_ERR "TEA575x radio not found\n");
+ snd_fm801_free(chip);
return -ENODEV;
}
} else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) {
@@ -1287,7 +1303,7 @@ static int __devinit snd_card_fm801_probe(struct pci_dev *pci,
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
if (err < 0)
return err;
- if ((err = snd_fm801_create(card, pci, tea575x_tuner[dev], &chip)) < 0) {
+ if ((err = snd_fm801_create(card, pci, tea575x_tuner[dev], radio_nr[dev], &chip)) < 0) {
snd_card_free(card);
return err;
}