Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 181559
b: refs/heads/master
c: d68b687
h: refs/heads/master
i:
  181557: 1d6204c
  181555: 56364fd
  181551: 95d7ea4
v: v3
  • Loading branch information
Devin Heitmueller authored and Mauro Carvalho Chehab committed Feb 26, 2010
1 parent c926c27 commit fc6cb7f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4a8cfe6a5c158133f57c2e8476f259366d4bdc4d
refs/heads/master: d68b687b1e322e7325b1458d799e8234997e4ccd
38 changes: 6 additions & 32 deletions trunk/drivers/media/video/cx18/cx18-alsa-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,9 @@ static int __init snd_cx18_init(struct v4l2_device *v4l2_dev)
return ret;
}

static int __init cx18_alsa_init_callback(struct device *dev, void *data)
int cx18_alsa_load(struct cx18 *cx)
{
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
int *count = data;
struct cx18 *cx;
struct v4l2_device *v4l2_dev = &cx->v4l2_dev;
struct cx18_stream *s;

if (v4l2_dev == NULL) {
Expand Down Expand Up @@ -227,41 +225,16 @@ static int __init cx18_alsa_init_callback(struct device *dev, void *data)
__func__);
} else {
CX18_DEBUG_ALSA_INFO("%s: created cx18 ALSA interface instance "
"%d\n", __func__, *count);
(*count)++;
"\n", __func__);
}
return 0;
}

static int __init cx18_alsa_init(void)
{
struct device_driver *drv;
int count = 0;
int ret;

printk(KERN_INFO "cx18-alsa: module loading...\n");

drv = driver_find("cx18", &pci_bus_type);
if (drv == NULL) {
printk("cx18-alsa: drv was null\n");
return -ENODEV;
}
ret = driver_for_each_device(drv, NULL, &count,
cx18_alsa_init_callback);
put_driver(drv);

if (count == 0) {
printk(KERN_ERR "cx18-alsa: no cx18 cards found with a PCM "
"capture stream allocated\n");
ret = -ENODEV;
} else {
printk(KERN_INFO "cx18-alsa: ALSA interface(s) created for %d "
"cx18 card(s)\n", count);
ret = 0;
}

printk(KERN_INFO "cx18-alsa: module load complete\n");
return ret;
cx18_ext_init = &cx18_alsa_load;
return 0;
}

static void snd_cx18_exit(struct snd_cx18_card *cxsc)
Expand Down Expand Up @@ -308,6 +281,7 @@ static void cx18_alsa_exit(void)
ret = driver_for_each_device(drv, NULL, NULL, cx18_alsa_exit_callback);
put_driver(drv);

cx18_ext_init = NULL;
printk(KERN_INFO "cx18-alsa: module unload complete\n");
}

Expand Down
34 changes: 34 additions & 0 deletions trunk/drivers/media/video/cx18/cx18-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
setting this to 1 you ensure that radio0 is now also radio1. */
int cx18_first_minor;

/* Callback for registering extensions */
int (*cx18_ext_init)(struct cx18 *);
EXPORT_SYMBOL(cx18_ext_init);

/* add your revision and whatnot here */
static struct pci_device_id cx18_pci_tbl[] __devinitdata = {
{PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418,
Expand Down Expand Up @@ -243,6 +247,9 @@ MODULE_LICENSE("GPL");

MODULE_VERSION(CX18_VERSION);

/* Forward Declaration */
static void request_modules(struct cx18 *dev);

/* Generic utility functions */
int cx18_msleep_timeout(unsigned int msecs, int intr)
{
Expand Down Expand Up @@ -1049,6 +1056,10 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev,
}

CX18_INFO("Initialized card: %s\n", cx->card_name);

/* Load cx18 submodules (cx18-alsa) */
request_modules(cx);

return 0;

free_streams:
Expand Down Expand Up @@ -1237,6 +1248,29 @@ static void cx18_remove(struct pci_dev *pci_dev)
kfree(cx);
}


#if defined(CONFIG_MODULES) && defined(MODULE)
static void request_module_async(struct work_struct *work)
{
struct cx18 *dev=container_of(work, struct cx18, request_module_wk);

/* Make sure cx18-alsa module is loaded */
request_module("cx18-alsa");

/* Initialize cx18-alsa for this instance of the cx18 device */
if (cx18_ext_init != NULL)
cx18_ext_init(dev);
}

static void request_modules(struct cx18 *dev)
{
INIT_WORK(&dev->request_module_wk, request_module_async);
schedule_work(&dev->request_module_wk);
}
#else
#define request_modules(dev)
#endif /* CONFIG_MODULES */

/* define a pci_driver for card detection */
static struct pci_driver cx18_pci_driver = {
.name = "cx18",
Expand Down
6 changes: 6 additions & 0 deletions trunk/drivers/media/video/cx18/cx18-driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,19 @@ struct cx18 {
u32 active_input;
v4l2_std_id std;
v4l2_std_id tuner_std; /* The norm of the tuner (fixed) */

/* Used for cx18-alsa module loading */
struct work_struct request_module_wk;
};

static inline struct cx18 *to_cx18(struct v4l2_device *v4l2_dev)
{
return container_of(v4l2_dev, struct cx18, v4l2_dev);
}

/* cx18 extensions to be loaded */
extern int (*cx18_ext_init)(struct cx18 *);

/* Globals */
extern int cx18_first_minor;

Expand Down

0 comments on commit fc6cb7f

Please sign in to comment.