[PATCH] New driver for the radio FM module on Miro PCM20 sound card
From: Krzysztof Helt krzysztof...@wp.pl This is recreated driver for the FM module found on Miro PCM20 sound cards. This driver was removed around the 2.6.2x kernels because it relied on the removed OSS module. Now, it uses a current ALSA module (snd-miro) and is adapted to v4l2 layer. It provides only basic functionality: frequency changing and FM module muting. Signed-off-by: Krzysztof Helt krzysztof...@wp.pl Reviewed-by: Hans Verkuil hverk...@xs4all.nl --- This is the third version of the patch with fixed issues pointed by Takashi Iwai. drivers/media/radio/Kconfig | 18 +++ drivers/media/radio/Makefile |1 + drivers/media/radio/radio-miropcm20.c | 270 + 3 files changed, 289 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/radio-miropcm20.c diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index a87a477..b134553 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig @@ -195,6 +195,24 @@ config RADIO_MAESTRO To compile this driver as a module, choose M here: the module will be called radio-maestro. +config RADIO_MIROPCM20 + tristate miroSOUND PCM20 radio + depends on ISA VIDEO_V4L2 + select SND_MIRO + ---help--- + Choose Y here if you have this FM radio card. You also need to enable + the ALSA sound system. This choice automatically selects the ALSA + sound card driver Miro miroSOUND PCM1pro/PCM12/PCM20radio as this + is required for the radio-miropcm20. + + In order to control your radio card, you will need to use programs + that are compatible with the Video For Linux API. Information on + this API and pointers to v4l programs may be found at + file:Documentation/video4linux/API.html. + + To compile this driver as a module, choose M here: the + module will be called radio-miropcm20. + config RADIO_SF16FMI tristate SF16FMI Radio depends on ISA VIDEO_V4L2 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 2a1be3b..8a63d54 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_RADIO_TRUST) += radio-trust.o obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o +obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o obj-$(CONFIG_USB_DSBR) += dsbr100.o obj-$(CONFIG_RADIO_SI470X) += si470x/ obj-$(CONFIG_USB_MR800) += radio-mr800.o diff --git a/drivers/media/radio/radio-miropcm20.c b/drivers/media/radio/radio-miropcm20.c new file mode 100644 index 000..4ff8854 --- /dev/null +++ b/drivers/media/radio/radio-miropcm20.c @@ -0,0 +1,270 @@ +/* Miro PCM20 radio driver for Linux radio support + * (c) 1998 Ruurd Reitsma r.a.reit...@wbmt.tudelft.nl + * Thanks to Norberto Pellici for the ACI device interface specification + * The API part is based on the radiotrack driver by M. Kirkwood + * This driver relies on the aci mixer provided by the snd-miro + * ALSA driver. + * Look there for further info... + */ + +/* What ever you think about the ACI, version 0x07 is not very well! + * I can't get frequency, 'tuner status', 'tuner flags' or mute/mono + * conditions...Robert + */ + +#include linux/module.h +#include linux/init.h +#include linux/videodev2.h +#include media/v4l2-device.h +#include media/v4l2-ioctl.h +#include sound/aci.h + +static int radio_nr = -1; +module_param(radio_nr, int, 0); +MODULE_PARM_DESC(radio_nr, Set radio device number (/dev/radioX). Default: -1 (autodetect)); + +static int mono; +module_param(mono, bool, 0); +MODULE_PARM_DESC(mono, Force tuner into mono mode.); + +struct pcm20 { + struct v4l2_device v4l2_dev; + struct video_device vdev; + unsigned long freq; + int muted; + struct snd_miro_aci *aci; +}; + +static struct pcm20 pcm20_card = { + .freq = 87*16000, + .muted = 1, +}; + +static int pcm20_mute(struct pcm20 *dev, unsigned char mute) +{ + dev-muted = mute; + return snd_aci_cmd(dev-aci, ACI_SET_TUNERMUTE, mute, -1); +} + +static int pcm20_stereo(struct pcm20 *dev, unsigned char stereo) +{ + return snd_aci_cmd(dev-aci, ACI_SET_TUNERMONO, !stereo, -1); +} + +static int pcm20_setfreq(struct pcm20 *dev, unsigned long freq) +{ + unsigned char freql; + unsigned char freqh; + struct snd_miro_aci *aci = dev-aci; + + dev-freq = freq; + + freq /= 160; + if (!(aci-aci_version == 0x07 || aci-aci_version = 0xb0)) + freq /= 10; /* I don't know exactly which version + * needs this hack */ + freql = freq 0xff; + freqh = freq 8; + + pcm20_stereo(dev, !mono); + return snd_aci_cmd(aci, ACI_WRITE_TUNE, freql, freqh); +} + +static const struct v4l2_file_operations pcm20_fops = { + .owner
[PATCH] New driver for the radio FM module on Miro PCM20 sound card
From: Krzysztof Helt krzysztof...@wp.pl This is recreated driver for the FM module found on Miro PCM20 sound cards. This driver was removed around the 2.6.2x kernels because it relied on the removed OSS module. Now, it uses a current ALSA module (snd-miro) and is adapted to v4l2 layer. It provides only basic functionality: frequency changing and FM module muting. Signed-off-by: Krzysztof Helt krzysztof...@wp.pl Reviewed-by: Hans Verkuil hverk...@xs4all.nl --- This is the second version of the patch with changes suggested by Hans Verkuil. drivers/media/radio/Kconfig | 17 ++ drivers/media/radio/Makefile |1 + drivers/media/radio/radio-miropcm20.c | 269 + 3 files changed, 287 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/radio-miropcm20.c diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index a87a477..b1df9f2 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig @@ -195,6 +195,23 @@ config RADIO_MAESTRO To compile this driver as a module, choose M here: the module will be called radio-maestro. +config RADIO_MIROPCM20 + tristate miroSOUND PCM20 radio + depends on ISA VIDEO_V4L2 + select SND_MIRO + ---help--- + Choose Y here if you have this FM radio card. You also need to select + the Miro miroSOUND PCM1pro/PCM12/PCM20radio driver ALSA sound card + driver for this to work. + + In order to control your radio card, you will need to use programs + that are compatible with the Video For Linux API. Information on + this API and pointers to v4l programs may be found at + file:Documentation/video4linux/API.html. + + To compile this driver as a module, choose M here: the + module will be called radio-miropcm20. + config RADIO_SF16FMI tristate SF16FMI Radio depends on ISA VIDEO_V4L2 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 2a1be3b..8a63d54 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_RADIO_TRUST) += radio-trust.o obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o +obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o obj-$(CONFIG_USB_DSBR) += dsbr100.o obj-$(CONFIG_RADIO_SI470X) += si470x/ obj-$(CONFIG_USB_MR800) += radio-mr800.o diff --git a/drivers/media/radio/radio-miropcm20.c b/drivers/media/radio/radio-miropcm20.c new file mode 100644 index 000..6fd71f3 --- /dev/null +++ b/drivers/media/radio/radio-miropcm20.c @@ -0,0 +1,269 @@ +/* Miro PCM20 radio driver for Linux radio support + * (c) 1998 Ruurd Reitsma r.a.reit...@wbmt.tudelft.nl + * Thanks to Norberto Pellici for the ACI device interface specification + * The API part is based on the radiotrack driver by M. Kirkwood + * This driver relies on the aci mixer provided by the snd-miro + * ALSA driver. + * Look there for further info... + */ + +/* What ever you think about the ACI, version 0x07 is not very well! + * I can't get frequency, 'tuner status', 'tuner flags' or mute/mono + * conditions...Robert + */ + +#include linux/module.h +#include linux/init.h +#include linux/videodev2.h +#include media/v4l2-device.h +#include media/v4l2-ioctl.h +#include sound/aci.h + +static int radio_nr = -1; +module_param(radio_nr, int, 0); + +static int mono; +module_param(mono, bool, 0); +MODULE_PARM_DESC(mono, Force tuner into mono mode.); + +struct pcm20 { + struct v4l2_device v4l2_dev; + struct video_device vdev; + unsigned long freq; + int muted; + struct snd_miro_aci *aci; +}; + +static struct pcm20 pcm20_card = { + .freq = 87*16000, + .muted = 1, +}; + +static int pcm20_mute(struct pcm20 *dev, unsigned char mute) +{ + dev-muted = mute; + return snd_aci_cmd(dev-aci, ACI_SET_TUNERMUTE, mute, -1); +} + +static int pcm20_stereo(struct pcm20 *dev, unsigned char stereo) +{ + return snd_aci_cmd(dev-aci, ACI_SET_TUNERMONO, !stereo, -1); +} + +static int pcm20_setfreq(struct pcm20 *dev, unsigned long freq) +{ + unsigned char freql; + unsigned char freqh; + struct snd_miro_aci *aci = dev-aci; + + dev-freq = freq; + + freq /= 160; + if (!(aci-aci_version == 0x07 || aci-aci_version = 0xb0)) + freq /= 10; /* I don't know exactly which version + * needs this hack */ + freql = freq 0xff; + freqh = freq 8; + + pcm20_stereo(dev, !mono); + return snd_aci_cmd(aci, ACI_WRITE_TUNE, freql, freqh); +} + +static const struct v4l2_file_operations pcm20_fops = { + .owner = THIS_MODULE, + .ioctl = video_ioctl2, +}; + +static int vidioc_querycap(struct file *file, void *priv, + struct v4l2_capability *v
[PATCH] New driver for the radio FM module on Miro PCM20 sound card
From: Krzysztof Helt krzysztof...@wp.pl This is recreated driver for the FM module found on Miro PCM20 sound cards. This driver was removed around the 2.6.2x kernels because it relied on the removed OSS module. Now, it uses a current ALSA module (snd-miro) and is adapted to v4l2 layer. It provides only basic functionality: frequency changing and FM module muting. Signed-off-by: Krzysztof Helt krzysztof...@wp.pl --- This driver depends on changes to the snd-miro driver. These changes are already accepted to the ALSA tree, but these changes won't be pushed into the 2.6.33 kernel. drivers/media/radio/Kconfig | 17 ++ drivers/media/radio/Makefile |1 + drivers/media/radio/radio-miropcm20.c | 271 + 3 files changed, 289 insertions(+), 0 deletions(-) create mode 100644 drivers/media/radio/radio-miropcm20.c diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index a87a477..1c12f99 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig @@ -195,6 +195,23 @@ config RADIO_MAESTRO To compile this driver as a module, choose M here: the module will be called radio-maestro. +config RADIO_MIROPCM20 + tristate miroSOUND PCM20 radio + depends on ISA VIDEO_V4L2 + select SND_MIRO + ---help--- + Choose Y here if you have this FM radio card. You also need to select + the Miro miroSOUND PCM1pro/PCM12/PCM20radio driver ALSA sound card + driver for this to work. + + In order to control your radio card, you will need to use programs + that are compatible with the Video For Linux API. Information on + this API and pointers to v4l programs may be found at + file:Documentation/video4linux/API.html. + + To compile this driver as a module, choose M here: the + module will be called radio-miropcm20. + config RADIO_SF16FMI tristate SF16FMI Radio depends on ISA VIDEO_V4L2 diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index 2a1be3b..8a63d54 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_RADIO_TRUST) += radio-trust.o obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o +obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o obj-$(CONFIG_USB_DSBR) += dsbr100.o obj-$(CONFIG_RADIO_SI470X) += si470x/ obj-$(CONFIG_USB_MR800) += radio-mr800.o diff --git a/drivers/media/radio/radio-miropcm20.c b/drivers/media/radio/radio-miropcm20.c new file mode 100644 index 000..0b6940c --- /dev/null +++ b/drivers/media/radio/radio-miropcm20.c @@ -0,0 +1,271 @@ +/* Miro PCM20 radio driver for Linux radio support + * (c) 1998 Ruurd Reitsma r.a.reit...@wbmt.tudelft.nl + * Thanks to Norberto Pellici for the ACI device interface specification + * The API part is based on the radiotrack driver by M. Kirkwood + * This driver relies on the aci mixer provided by the snd-miro + * ALSA driver. + * Look there for further info... + */ + +/* Revision history: + * + * 1998Ruurd Reitsma r.a.reit...@wbmt.tudelft.nl + * 2000-09-05 Robert Siemer robert.sie...@gmx.de + *removed unfinished volume control (maybe adding it later again) + *use OSS-mixer; added stereo control + */ + +/* What ever you think about the ACI, version 0x07 is not very well! + * I can't get frequency, 'tuner status', 'tuner flags' or mute/mono + * conditions...Robert + */ + +#include linux/module.h +#include linux/init.h +#include linux/videodev2.h +#include media/v4l2-device.h +#include media/v4l2-ioctl.h +#include sound/aci.h + +static int radio_nr = -1; +module_param(radio_nr, int, 0); + +static int mono; +module_param(mono, bool, 0); +MODULE_PARM_DESC(mono, Force tuner into mono mode.); + +struct pcm20 { + struct v4l2_device v4l2_dev; + struct video_device vdev; + unsigned long freq; + int muted; + struct snd_miro_aci *aci; +}; + +static struct pcm20 pcm20_card = { + .freq = 87*16000, + .muted = 1, +}; + +static int pcm20_mute(struct pcm20 *dev, unsigned char mute) +{ + dev-muted = mute; + return snd_aci_cmd(dev-aci, ACI_SET_TUNERMUTE, mute, -1); +} + +static int pcm20_stereo(struct pcm20 *dev, unsigned char stereo) +{ + return snd_aci_cmd(dev-aci, ACI_SET_TUNERMONO, !stereo, -1); +} + +static int pcm20_setfreq(struct pcm20 *dev, unsigned long freq) +{ + unsigned char freql; + unsigned char freqh; + struct snd_miro_aci *aci = dev-aci; + + dev-freq = freq; + + freq /= 160; + if (!(aci-aci_version == 0x07 || aci-aci_version = 0xb0)) + freq /= 10; /* I don't know exactly which version + * needs this hack */ + freql = freq 0xff; + freqh = freq 8; + + pcm20_stereo(dev, !mono); + return
Re: [BUG] drivers/video/sis: deadlock introduced by fbdev: add mutex for fb_mmap locking
On Mon, 06 Jul 2009 09:13:11 +0800 Wu Zhangjin wuzhang...@gmail.com wrote: Hi, This patch also works for me, thanks! Regards, Wu Zhangjin Who should I send this patch to be included as a 2.6.31 regression fix? Regards, Krzysztof From: Krzysztof Helt krzysztof...@wp.pl Remove redundant call to the sisfb_get_fix() before sis frambuffer is registered. This fixes a problem with uninitialized the fb_info-mm_lock mutex. Signed-off-by: Krzysztof Helt krzysztof...@wp.pl --- diff -urp linux-ref/drivers/video/sis/sis_main.c linux-next/drivers/video/sis/sis_main.c --- linux-ref/drivers/video/sis/sis_main.c 2009-07-01 18:07:05.0 +0200 +++ linux-next/drivers/video/sis/sis_main.c 2009-07-05 17:20:33.0 +0200 @@ -6367,7 +6367,6 @@ error_3: vfree(ivideo-bios_abase); sis_fb_info-fix = ivideo-sisfb_fix; sis_fb_info-screen_base = ivideo-video_vbase + ivideo-video_offset; sis_fb_info-fbops = sisfb_ops; - sisfb_get_fix(sis_fb_info-fix, -1, sis_fb_info); sis_fb_info-pseudo_palette = ivideo-pseudo_palette; fb_alloc_cmap(sis_fb_info-cmap, 256 , 0); -- Najlepsze OC i AC tylko w Ergo Hestia http://link.interia.pl/f222 -- Najlepsze OC i AC tylko w Ergo Hestia http://link.interia.pl/f222 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [BUG] drivers/video/sis: deadlock introduced by fbdev: add mutex for fb_mmap locking
On Sun, 5 Jul 2009 07:19:33 -0700 (PDT) Linus Torvalds torva...@linux-foundation.org wrote: On Sun, 5 Jul 2009, Wu Zhangjin wrote: then it works! so, I guess there is a deadlock introduced by the above commit. Hmm. Perhaps more likely, the 'mm_lock' mutex hasn't even been initialized yet. We appear to have had that problem with matroxfb and sm501fb, and it may be more common than that. See commit f50bf2b2. That said, I do agree that the mm_lock seems to be causing more problems than it actually fixes, and maybe we should revert it. Krzysztof? I vote for fixing these drivers after my change. I will send a patch for the sis driver soon. I am building new kernel now. Regards, Krzysztof -- Rozwiaz krzyzowke i wygraj nagrody! Sprawdz http://link.interia.pl/f2232 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [BUG] drivers/video/sis: deadlock introduced by fbdev: add mutex for fb_mmap locking
On Mon, 6 Jul 2009 00:25:57 +0900 Paul Mundt let...@linux-sh.org wrote: On Sun, Jul 05, 2009 at 08:19:40AM -0700, Linus Torvalds wrote: On Mon, 6 Jul 2009, Paul Mundt wrote: Why not lock as well? I had that initially, but matroxfb will break if we do that, and presently nothing cares about trying to take -lock that early on. I really would rather have consistency than some odd rules like that. In particular - if matroxfb is different and needs its own lock initialization because it doesn't use the common allocation routine, then please make _that_ consistent too. Rather than have it special-case just one lock that it needs to initialize separately, make it clear that since it does its own allocations it needs to initialize _everything_ separately. Ok, here is an updated version with an updated matroxfb and the sm501fb change reverted. Signed-off-by: Paul Mundt let...@linux-sh.org --- This is incorrect way to fix this as some drivers do not use the framebuffer_alloc() at all. They use global (for a file) fb_info structure. I have done some cleanups to the fbdev layer before the 2.6.31 and there should no drivers which uses kmalloc or kzalloc to allocate the fb_info (your patch would break these drivers too). A root of the whole mm_lock issue is that the fb_mmap() BKL protected two fb_info fields which were never protected when set. I changed this by add the mm_lock around these fields but only in drivers which modified this fields AFTER call to the register_framebuffer(). Some drivers set these fields using the same function before and after the register_framebuffer(). I strongly believe that setting these fields before the register_framebuffer() is wrong or redundant for these drivers. See my fix for the sisfb driver below. I have tested the patch below. Wu Zhangjin, can you also confirm that this works for you (without your patch)? I will look into the matroxfb and sm501fb drivers now. The same problem is already fixed for the mx3fb driver and the patch is sent to Andrew Morton. Regards, Krzysztof From: Krzysztof Helt krzysztof...@wp.pl Remove redundant call to the sisfb_get_fix() before sis frambuffer is registered. This fixes a problem with uninitialized the fb_info-mm_lock mutex. Signed-off-by: Krzysztof Helt krzysztof...@wp.pl --- diff -urp linux-ref/drivers/video/sis/sis_main.c linux-next/drivers/video/sis/sis_main.c --- linux-ref/drivers/video/sis/sis_main.c 2009-07-01 18:07:05.0 +0200 +++ linux-next/drivers/video/sis/sis_main.c 2009-07-05 17:20:33.0 +0200 @@ -6367,7 +6367,6 @@ error_3: vfree(ivideo-bios_abase); sis_fb_info-fix = ivideo-sisfb_fix; sis_fb_info-screen_base = ivideo-video_vbase + ivideo-video_offset; sis_fb_info-fbops = sisfb_ops; - sisfb_get_fix(sis_fb_info-fix, -1, sis_fb_info); sis_fb_info-pseudo_palette = ivideo-pseudo_palette; fb_alloc_cmap(sis_fb_info-cmap, 256 , 0); -- Najlepsze OC i AC tylko w Ergo Hestia http://link.interia.pl/f222 -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [BUG] drivers/video/sis: deadlock introduced by fbdev: add mutex for fb_mmap locking
On Mon, 6 Jul 2009 00:25:57 +0900 Paul Mundt let...@linux-sh.org wrote: Ok, here is an updated version with an updated matroxfb and the sm501fb change reverted. Signed-off-by: Paul Mundt let...@linux-sh.org Here is a patch which should fix problem with sm501fb driver: diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c index 16d4f4c..924d794 100644 --- a/drivers/video/sm501fb.c +++ b/drivers/video/sm501fb.c @@ -1540,9 +1540,6 @@ static int sm501fb_init_fb(struct fb_info *fb, if (ret) dev_err(info-dev, check_var() failed on initial setup?\n); - /* ensure we've activated our new configuration */ - (fb-fbops-fb_set_par)(fb); - return 0; } Paul, please test it (without additional initialization of the mm_lock mutext). I will post the patch if it works for you. An issue here is that these drivers calls fb_set_par() function (or part of it as the sisfb driver) but the register_framebuffer() calls the fb_set_par() also after all structures are set up. There should be no need to call the fb_set_par() just before the register_framebuffer(). The matroxfb driver is quite far from standard driver framework by now. I vote for fixing it by adding this early initialization of the mm_mutex for now. Kind regards, Krzysztof -- Promocja ubezpieczen komunikacyjnych Ergo Hestia. Sprawdz! http://link.interia.pl/f222f -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html