* [PATCH 1/3] tm6000: rewrite init and fini
@ 2010-05-30 12:19 stefan.ringel
2010-05-30 12:19 ` [PATCH 2/3] tm6000: move debug info print from header into c file stefan.ringel
2010-05-30 12:19 ` [PATCH 3/3] tm6000: move dvb into a separate kern module stefan.ringel
0 siblings, 2 replies; 4+ messages in thread
From: stefan.ringel @ 2010-05-30 12:19 UTC (permalink / raw)
To: linux-media; +Cc: mchehab, d.belimov, Stefan Ringel
From: Stefan Ringel <stefan.ringel@arcor.de>
rewrite tm6000_audio_init and tm6000_audio_fini
Signed-off-by: Stefan Ringel <stefan.ringel@arcor.de>
---
drivers/staging/tm6000/tm6000-alsa.c | 127 +++++++++++++---------------------
drivers/staging/tm6000/tm6000.h | 15 ++++
2 files changed, 63 insertions(+), 79 deletions(-)
diff --git a/drivers/staging/tm6000/tm6000-alsa.c b/drivers/staging/tm6000/tm6000-alsa.c
index ce081cd..477dd78 100644
--- a/drivers/staging/tm6000/tm6000-alsa.c
+++ b/drivers/staging/tm6000/tm6000-alsa.c
@@ -35,29 +35,6 @@
} while (0)
/****************************************************************************
- Data type declarations - Can be moded to a header file later
- ****************************************************************************/
-
-struct snd_tm6000_card {
- struct snd_card *card;
-
- spinlock_t reg_lock;
-
- atomic_t count;
-
- unsigned int period_size;
- unsigned int num_periods;
-
- struct tm6000_core *core;
- struct tm6000_buffer *buf;
-
- int bufsize;
-
- struct snd_pcm_substream *substream;
-};
-
-
-/****************************************************************************
Module global static vars
****************************************************************************/
@@ -311,21 +288,6 @@ static struct snd_pcm_ops snd_tm6000_pcm_ops = {
/*
* create a PCM device
*/
-static int __devinit snd_tm6000_pcm(struct snd_tm6000_card *chip,
- int device, char *name)
-{
- int err;
- struct snd_pcm *pcm;
-
- err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm);
- if (err < 0)
- return err;
- pcm->private_data = chip;
- strcpy(pcm->name, name);
- snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_tm6000_pcm_ops);
-
- return 0;
-}
/* FIXME: Control interface - How to control volume/mute? */
@@ -336,73 +298,64 @@ static int __devinit snd_tm6000_pcm(struct snd_tm6000_card *chip,
/*
* Alsa Constructor - Component probe
*/
-
-int tm6000_audio_init(struct tm6000_core *dev, int idx)
+int tm6000_audio_init(struct tm6000_core *dev)
{
- struct snd_card *card;
- struct snd_tm6000_card *chip;
- int rc, len;
- char component[14];
+ struct snd_card *card;
+ struct snd_tm6000_card *chip;
+ int rc;
+ static int devnr;
+ char component[14];
+ struct snd_pcm *pcm;
+
+ if (!dev)
+ return 0;
- if (idx >= SNDRV_CARDS)
+ if (devnr >= SNDRV_CARDS)
return -ENODEV;
- if (!enable[idx])
+ if (!enable[devnr])
return -ENOENT;
- rc = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card);
+ rc = snd_card_create(index[devnr], id[devnr], THIS_MODULE, 0, &card);
if (rc < 0) {
- snd_printk(KERN_ERR "cannot create card instance %d\n", idx);
+ snd_printk(KERN_ERR "cannot create card instance %d\n", devnr);
return rc;
}
- chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+ chip = kzalloc(sizeof(struct snd_tm6000_card), GFP_KERNEL);
if (!chip) {
rc = -ENOMEM;
goto error;
}
- chip->core = dev;
- chip->card = card;
-
- strcpy(card->driver, "tm6000-alsa");
sprintf(component, "USB%04x:%04x",
le16_to_cpu(dev->udev->descriptor.idVendor),
le16_to_cpu(dev->udev->descriptor.idProduct));
- snd_component_add(card, component);
-
- if (dev->udev->descriptor.iManufacturer)
- len = usb_string(dev->udev,
- dev->udev->descriptor.iManufacturer,
- card->longname, sizeof(card->longname));
- else
- len = 0;
-
- if (len > 0)
- strlcat(card->longname, " ", sizeof(card->longname));
+ snd_component_add(card, component);
- strlcat(card->longname, card->shortname, sizeof(card->longname));
-
- len = strlcat(card->longname, " at ", sizeof(card->longname));
-
- if (len < sizeof(card->longname))
- usb_make_path(dev->udev, card->longname + len,
- sizeof(card->longname) - len);
-
- strlcat(card->longname,
- dev->udev->speed == USB_SPEED_LOW ? ", low speed" :
- dev->udev->speed == USB_SPEED_FULL ? ", full speed" :
- ", high speed",
- sizeof(card->longname));
-
- rc = snd_tm6000_pcm(chip, 0, "tm6000 Digital");
+ spin_lock_init(&chip->reg_lock);
+ rc = snd_pcm_new(card, "TM6000 Audio", 0, 0, 1, &pcm);
if (rc < 0)
goto error;
+ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_tm6000_pcm_ops);
+ pcm->info_flags = 0;
+ pcm->private_data = dev;
+ strcpy(pcm->name, "Trident TM5600/60x0");
+ strcpy(card->driver, "tm6000-alsa");
+ strcpy(card->shortname, "TM5600/60x0");
+ sprintf(card->longname, "TM5600/60x0 Audio at bus %d device %d",
+ dev->udev->bus->busnum, dev->udev->devnum);
+
+ snd_card_set_dev(card, &dev->udev->dev);
+
rc = snd_card_register(card);
if (rc < 0)
goto error;
+ chip->core = dev;
+ chip->card = card;
+ dev->adev = chip;
return 0;
@@ -413,6 +366,22 @@ error:
static int tm6000_audio_fini(struct tm6000_core *dev)
{
+ struct snd_tm6000_card *chip = dev->adev;
+
+ if (!dev)
+ return 0;
+
+ if (!chip)
+ return 0;
+
+ if (!chip->card)
+ return 0;
+
+ snd_card_free(chip->card);
+ chip->card = NULL;
+ kfree(chip);
+ dev->adev = NULL;
+
return 0;
}
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 79ef72a..231e2be 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -132,6 +132,18 @@ struct tm6000_dvb {
struct mutex mutex;
};
+struct snd_tm6000_card {
+ struct snd_card *card;
+ spinlock_t reg_lock;
+ atomic_t count;
+ unsigned int period_size;
+ unsigned int num_periods;
+ struct tm6000_core *core;
+ struct tm6000_buffer *buf;
+ int bufsize;
+ struct snd_pcm_substream *substream;
+};
+
struct tm6000_endpoint {
struct usb_host_endpoint *endp;
__u8 bInterfaceNumber;
@@ -190,6 +202,9 @@ struct tm6000_core {
/* DVB-T support */
struct tm6000_dvb *dvb;
+ /* audio support */
+ struct snd_tm6000_card *adev;
+
/* locks */
struct mutex lock;
--
1.7.0.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] tm6000: move debug info print from header into c file
2010-05-30 12:19 [PATCH 1/3] tm6000: rewrite init and fini stefan.ringel
@ 2010-05-30 12:19 ` stefan.ringel
2010-06-02 17:53 ` Mauro Carvalho Chehab
2010-05-30 12:19 ` [PATCH 3/3] tm6000: move dvb into a separate kern module stefan.ringel
1 sibling, 1 reply; 4+ messages in thread
From: stefan.ringel @ 2010-05-30 12:19 UTC (permalink / raw)
To: linux-media; +Cc: mchehab, d.belimov, Stefan Ringel
From: Stefan Ringel <stefan.ringel@arcor.de>
move debug info print from header into c file
Signed-off-by: Stefan Ringel <stefan.ringel@arcor.de>
---
drivers/staging/tm6000/tm6000-core.c | 6 ++++++
drivers/staging/tm6000/tm6000-dvb.c | 8 ++++++++
drivers/staging/tm6000/tm6000-video.c | 6 ++++++
drivers/staging/tm6000/tm6000.h | 7 -------
4 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index 624c276..b5965a8 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -29,6 +29,12 @@
#include <media/v4l2-common.h>
#include <media/tuner.h>
+#define dprintk(dev, level, fmt, arg...) do { \
+ if (tm6000_debug & level) \
+ printk(KERN_INFO "(%lu) %s %s :"fmt, jiffies, \
+ dev->name, __FUNCTION__, ##arg); \
+ } while (0)
+
#define USB_TIMEOUT 5*HZ /* ms */
int tm6000_read_write_usb (struct tm6000_core *dev, u8 req_type, u8 req,
diff --git a/drivers/staging/tm6000/tm6000-dvb.c b/drivers/staging/tm6000/tm6000-dvb.c
index 714b384..b9e9ef1 100644
--- a/drivers/staging/tm6000/tm6000-dvb.c
+++ b/drivers/staging/tm6000/tm6000-dvb.c
@@ -30,6 +30,14 @@
#include "tuner-xc2028.h"
#include "xc5000.h"
+#undef dprintk
+
+#define dprintk(dev, level, fmt, arg...) do { \
+ if (debug >= level) \
+ printk(KERN_INFO "(%lu) %s %s :"fmt, jiffies, \
+ dev->name, __FUNCTION__, ##arg); \
+ } while (0)
+
static void inline print_err_status (struct tm6000_core *dev,
int packet, int status)
{
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index 9746fe7..98af4a5 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -42,6 +42,12 @@
#include "tm6000-regs.h"
#include "tm6000.h"
+#define dprintk(dev, level, fmt, arg...) do { \
+ if (tm6000_debug & level) \
+ printk(KERN_INFO "(%lu) %s %s :"fmt, jiffies, \
+ dev->name, __FUNCTION__, ##arg); \
+ } while (0)
+
#define BUFFER_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */
/* Limits minimum and default number of buffers */
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 231e2be..fd94ed6 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -316,13 +316,6 @@ int tm6000_queue_init(struct tm6000_core *dev);
/* Debug stuff */
-extern int tm6000_debug;
-
-#define dprintk(dev, level, fmt, arg...) do {\
- if (tm6000_debug & level) \
- printk(KERN_INFO "(%lu) %s %s :"fmt, jiffies, \
- dev->name, __FUNCTION__ , ##arg); } while (0)
-
#define V4L2_DEBUG_REG 0x0004
#define V4L2_DEBUG_I2C 0x0008
#define V4L2_DEBUG_QUEUE 0x0010
--
1.7.0.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] tm6000: move dvb into a separate kern module
2010-05-30 12:19 [PATCH 1/3] tm6000: rewrite init and fini stefan.ringel
2010-05-30 12:19 ` [PATCH 2/3] tm6000: move debug info print from header into c file stefan.ringel
@ 2010-05-30 12:19 ` stefan.ringel
1 sibling, 0 replies; 4+ messages in thread
From: stefan.ringel @ 2010-05-30 12:19 UTC (permalink / raw)
To: linux-media; +Cc: mchehab, d.belimov, Stefan Ringel
From: Stefan Ringel <stefan.ringel@arcor.de>
move dvb into a separate kern module
Signed-off-by: Stefan Ringel <stefan.ringel@arcor.de>
---
drivers/staging/tm6000/Kconfig | 4 +-
drivers/staging/tm6000/Makefile | 5 +--
drivers/staging/tm6000/tm6000-cards.c | 31 +-----------
drivers/staging/tm6000/tm6000-core.c | 1 +
drivers/staging/tm6000/tm6000-dvb.c | 83 ++++++++++++++++++++++++++++++++-
drivers/staging/tm6000/tm6000.h | 1 +
6 files changed, 89 insertions(+), 36 deletions(-)
diff --git a/drivers/staging/tm6000/Kconfig b/drivers/staging/tm6000/Kconfig
index 3657e33..c725356 100644
--- a/drivers/staging/tm6000/Kconfig
+++ b/drivers/staging/tm6000/Kconfig
@@ -26,8 +26,8 @@ config VIDEO_TM6000_ALSA
module will be called tm6000-alsa.
config VIDEO_TM6000_DVB
- bool "DVB Support for tm6000 based TV cards"
- depends on VIDEO_TM6000 && DVB_CORE && EXPERIMENTAL
+ tristate "DVB Support for tm6000 based TV cards"
+ depends on VIDEO_TM6000 && DVB_CORE && USB && EXPERIMENTAL
select DVB_ZL10353
---help---
This adds support for DVB cards based on the tm5600/tm6000 chip.
diff --git a/drivers/staging/tm6000/Makefile b/drivers/staging/tm6000/Makefile
index 93370fc..4129c18 100644
--- a/drivers/staging/tm6000/Makefile
+++ b/drivers/staging/tm6000/Makefile
@@ -4,12 +4,9 @@ tm6000-objs := tm6000-cards.o \
tm6000-video.o \
tm6000-stds.o
-ifeq ($(CONFIG_VIDEO_TM6000_DVB),y)
-tm6000-objs += tm6000-dvb.o
-endif
-
obj-$(CONFIG_VIDEO_TM6000) += tm6000.o
obj-$(CONFIG_VIDEO_TM6000_ALSA) += tm6000-alsa.o
+obj-$(CONFIG_VIDEO_TM6000_DVB) += tm6000-dvb.o
EXTRA_CFLAGS = -Idrivers/media/video
EXTRA_CFLAGS += -Idrivers/media/common/tuners
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 553ebe4..87b0bc4 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -346,7 +346,7 @@ int tm6000_xc5000_callback(void *ptr, int component, int command, int arg)
}
return (rc);
}
-
+EXPORT_SYMBOL_GPL(tm6000_xc5000_callback);
/* Tuner callback to provide the proper gpio changes needed for xc2028 */
@@ -436,6 +436,7 @@ int tm6000_tuner_callback(void *ptr, int component, int command, int arg)
}
return rc;
}
+EXPORT_SYMBOL_GPL(tm6000_tuner_callback);
int tm6000_cards_setup(struct tm6000_core *dev)
{
@@ -693,31 +694,12 @@ static int tm6000_init_dev(struct tm6000_core *dev)
goto err;
tm6000_add_into_devlist(dev);
-
tm6000_init_extension(dev);
- if (dev->caps.has_dvb) {
- dev->dvb = kzalloc(sizeof(*(dev->dvb)), GFP_KERNEL);
- if (!dev->dvb) {
- rc = -ENOMEM;
- goto err2;
- }
-
-#ifdef CONFIG_VIDEO_TM6000_DVB
- rc = tm6000_dvb_register(dev);
- if (rc < 0) {
- kfree(dev->dvb);
- dev->dvb = NULL;
- goto err2;
- }
-#endif
}
mutex_unlock(&dev->lock);
return 0;
-err2:
- v4l2_device_unregister(&dev->v4l2_dev);
-
err:
mutex_unlock(&dev->lock);
return rc;
@@ -918,13 +900,6 @@ static void tm6000_usb_disconnect(struct usb_interface *interface)
mutex_lock(&dev->lock);
-#ifdef CONFIG_VIDEO_TM6000_DVB
- if (dev->dvb) {
- tm6000_dvb_unregister(dev);
- kfree(dev->dvb);
- }
-#endif
-
if (dev->gpio.power_led) {
switch (dev->model) {
case TM6010_BOARD_HAUPPAUGE_900H:
@@ -954,8 +929,8 @@ static void tm6000_usb_disconnect(struct usb_interface *interface)
usb_put_dev(dev->udev);
- tm6000_remove_from_devlist(dev);
tm6000_close_extension(dev);
+ tm6000_remove_from_devlist(dev);
mutex_unlock(&dev->lock);
kfree(dev);
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index b5965a8..cd87b14 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -396,6 +396,7 @@ int tm6000_init_digital_mode (struct tm6000_core *dev)
return 0;
}
+EXPORT_SYMBOL(tm6000_init_digial_mode);
struct reg_init {
u8 req;
diff --git a/drivers/staging/tm6000/tm6000-dvb.c b/drivers/staging/tm6000/tm6000-dvb.c
index b9e9ef1..7830826 100644
--- a/drivers/staging/tm6000/tm6000-dvb.c
+++ b/drivers/staging/tm6000/tm6000-dvb.c
@@ -38,6 +38,19 @@
dev->name, __FUNCTION__, ##arg); \
} while (0)
+MODULE_DESCRIPTION("DVB driver extension module for tm5600/6000/6010 based TV cards");
+MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
+MODULE_LICENSE("GPL");
+
+MODULE_SUPPORTED_DEVICE("{{Trident, tm5600},"
+ "{{Trident, tm6000},"
+ "{{Trident, tm6010}");
+
+static int debug
+
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "enable debug message");
+
static void inline print_err_status (struct tm6000_core *dev,
int packet, int status)
{
@@ -245,7 +258,7 @@ int tm6000_dvb_attach_frontend(struct tm6000_core *dev)
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
-int tm6000_dvb_register(struct tm6000_core *dev)
+int register_dvb(struct tm6000_core *dev)
{
int ret = -1;
struct tm6000_dvb *dvb = dev->dvb;
@@ -356,7 +369,7 @@ err:
return ret;
}
-void tm6000_dvb_unregister(struct tm6000_core *dev)
+void unregister_dvb(struct tm6000_core *dev)
{
struct tm6000_dvb *dvb = dev->dvb;
@@ -382,3 +395,69 @@ void tm6000_dvb_unregister(struct tm6000_core *dev)
/* mutex_unlock(&tm6000_driver.open_close_mutex); */
}
+
+static int dvb_init(struct tm6000_core *dev)
+{
+ struct tm6000_dvb *dvb;
+ int rc;
+
+ if (!dev)
+ retrun 0;
+
+ if (!dev->caps.has_dvb)
+ return 0;
+
+ dvb = kzalloc(sizeof(struct tm6000_dvb), GFP_KERNEL);
+ if (!dvb) {
+ printk(KERN_INFO "Cannot allocate memory\n");
+ return -ENOMEM;
+ }
+
+ dev->dvb = dvb;
+
+ rc = register_dvb(dev);
+ if (rc < 0) {
+ kfree(dvb);
+ dev->dvb = NULL;
+ return 0;
+ }
+
+ return 0;
+}
+
+static int dvb_fini(struct tm6000_core *dev)
+{
+ if (!dev)
+ return 0;
+
+ if (!dev->caps.has_dvb)
+ return 0;
+
+ if (dev->dvb) {
+ unregister_dvb(dev);
+ kfree(dev->dvb);
+ dev->dvb = NULL;
+ }
+
+ retrun 0;
+}
+
+static struct tm6000_ops dvb_ops = {
+ .id = TM6000_DVB,
+ .name = "TM6000 dvb Extension",
+ .init = dvb_init,
+ .fini = dvb_fini,
+};
+
+static int __init tm6000_dvb_register(void)
+{
+ return tm6000_register_extension(&dvb_ops);
+}
+
+static void __exit tm6000_dvb_unregister(void)
+{
+ tm6000_unregister_extension(&dvb_ops);
+}
+
+module_init(tm6000_dvb_register);
+module_exit(tm6000_dvb_unregister);
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index fd94ed6..97bc14e 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -223,6 +223,7 @@ struct tm6000_core {
};
#define TM6000_AUDIO 0x10
+#define TM6000_DVB 0x20
struct tm6000_ops {
struct list_head next;
--
1.7.0.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/3] tm6000: move debug info print from header into c file
2010-05-30 12:19 ` [PATCH 2/3] tm6000: move debug info print from header into c file stefan.ringel
@ 2010-06-02 17:53 ` Mauro Carvalho Chehab
0 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2010-06-02 17:53 UTC (permalink / raw)
To: stefan.ringel; +Cc: linux-media, d.belimov
Em 30-05-2010 09:19, stefan.ringel@arcor.de escreveu:
> From: Stefan Ringel <stefan.ringel@arcor.de>
>
> move debug info print from header into c file
I don't see why to duplicate the printk's on every file. It seems better to me to
just keep them at the header file, and use tm6000_debug symbol for every tm6000
module.
Btw, I've applied a CodingStyle fix patch on my tree, together with the other patches.
As it touches on almost all drivers, it is better to merge from my tree ASAP.
I dunno why, but your rewrite copy_streams didn't apply fine, but this time I've fixed
the issues manually. I tested it here with two cards (Saphire Wonder TV - a 10moons clone,
based on tm5600 - and HVR900H), and the merge worked fine.
With your patch, image seems to be working fine (yet, I didn't re-add the memset(0) to
double check). However, running on a remote machine, via fast ethernet, the buffering
effect is seeing. Probably, there's still some trouble at the routine that fills the
buffers.
-
I suggest that you and Dmitri to use staging/tm6000 branch for development. this will
likely help to avoid conflict issues.
As usual, before submitting a patch, it would be wise to rebase it against upstream
with:
git remote update
git pull . staging/tm6000
git rebase staging/tm6000
After doing it, please compile and test, before submitting me the patches.
Cheers,
Mauro.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-06-02 17:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-30 12:19 [PATCH 1/3] tm6000: rewrite init and fini stefan.ringel
2010-05-30 12:19 ` [PATCH 2/3] tm6000: move debug info print from header into c file stefan.ringel
2010-06-02 17:53 ` Mauro Carvalho Chehab
2010-05-30 12:19 ` [PATCH 3/3] tm6000: move dvb into a separate kern module stefan.ringel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.