return 0;
}
-/* Should beallocated dynamically too, but we have only one. */
+static struct soc_camera_host_ops pxa_soc_camera_host_ops = {
+ .owner = THIS_MODULE,
+ .add = pxa_camera_add_device,
+ .remove = pxa_camera_remove_device,
+ .set_fmt_cap = pxa_camera_set_fmt_cap,
+ .try_fmt_cap = pxa_camera_try_fmt_cap,
+ .reqbufs = pxa_camera_reqbufs,
+ .poll = pxa_camera_poll,
+ .querycap = pxa_camera_querycap,
+ .try_bus_param = pxa_camera_try_bus_param,
+ .set_bus_param = pxa_camera_set_bus_param,
+};
+
+/* Should be allocated dynamically too, but we have only one. */
static struct soc_camera_host pxa_soc_camera_host = {
.drv_name = PXA_CAM_DRV_NAME,
.vbq_ops = &pxa_videobuf_ops,
- .add = pxa_camera_add_device,
- .remove = pxa_camera_remove_device,
.msize = sizeof(struct pxa_buffer),
- .set_fmt_cap = pxa_camera_set_fmt_cap,
- .try_fmt_cap = pxa_camera_try_fmt_cap,
- .reqbufs = pxa_camera_reqbufs,
- .poll = pxa_camera_poll,
- .querycap = pxa_camera_querycap,
- .try_bus_param = pxa_camera_try_bus_param,
- .set_bus_param = pxa_camera_set_bus_param,
+ .ops = &pxa_soc_camera_host_ops,
};
static int pxa_camera_probe(struct platform_device *pdev)
pxa_soc_camera_host.priv = pcdev;
pxa_soc_camera_host.dev.parent = &pdev->dev;
pxa_soc_camera_host.nr = pdev->id;
- err = soc_camera_host_register(&pxa_soc_camera_host, THIS_MODULE);
+ err = soc_camera_host_register(&pxa_soc_camera_host);
if (err)
goto exit_free_irq;
}
/* test physical bus parameters */
- ret = ici->try_bus_param(icd, f->fmt.pix.pixelformat);
+ ret = ici->ops->try_bus_param(icd, f->fmt.pix.pixelformat);
if (ret)
return ret;
/* limit format to hardware capabilities */
- ret = ici->try_fmt_cap(icd, f);
+ ret = ici->ops->try_fmt_cap(icd, f);
/* calculate missing fields */
f->fmt.pix.field = field;
if (ret < 0)
return ret;
- return ici->reqbufs(icf, p);
+ return ici->ops->reqbufs(icf, p);
return ret;
}
goto emgd;
}
- if (!try_module_get(ici->owner)) {
+ if (!try_module_get(ici->ops->owner)) {
dev_err(&icd->dev, "Couldn't lock capture bus driver.\n");
ret = -EINVAL;
goto emgi;
/* Now we really have to activate the camera */
if (icd->use_count == 1) {
- ret = ici->add(icd);
+ ret = ici->ops->add(icd);
if (ret < 0) {
dev_err(&icd->dev, "Couldn't activate the camera: %d\n", ret);
icd->use_count--;
/* All errors are entered with the video_lock held */
eiciadd:
- module_put(ici->owner);
+ module_put(ici->ops->owner);
emgi:
module_put(icd->ops->owner);
emgd:
mutex_lock(&video_lock);
icd->use_count--;
if (!icd->use_count)
- ici->remove(icd);
+ ici->ops->remove(icd);
module_put(icd->ops->owner);
- module_put(ici->owner);
+ module_put(ici->ops->owner);
mutex_unlock(&video_lock);
vfree(file->private_data);
return POLLERR;
}
- return ici->poll(file, pt);
+ return ici->ops->poll(file, pt);
}
rect.top = icd->y_current;
rect.width = f->fmt.pix.width;
rect.height = f->fmt.pix.height;
- ret = ici->set_fmt_cap(icd, f->fmt.pix.pixelformat, &rect);
+ ret = ici->ops->set_fmt_cap(icd, f->fmt.pix.pixelformat, &rect);
if (ret < 0)
return ret;
icd->width, icd->height);
/* set physical bus parameters */
- return ici->set_bus_param(icd, f->fmt.pix.pixelformat);
+ return ici->ops->set_bus_param(icd, f->fmt.pix.pixelformat);
}
static int soc_camera_enum_fmt_cap(struct file *file, void *priv,
WARN_ON(priv != file->private_data);
strlcpy(cap->driver, ici->drv_name, sizeof(cap->driver));
- return ici->querycap(ici, cap);
+ return ici->ops->querycap(ici, cap);
}
static int soc_camera_streamon(struct file *file, void *priv,
if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
- ret = ici->set_fmt_cap(icd, 0, &a->c);
+ ret = ici->ops->set_fmt_cap(icd, 0, &a->c);
if (!ret) {
icd->width = a->c.width;
icd->height = a->c.height;
/* We only call ->add() here to activate and probe the camera.
* We shall ->remove() and deactivate it immediately afterwards. */
- ret = ici->add(icd);
+ ret = ici->ops->add(icd);
if (ret < 0)
return ret;
icd->exposure = qctrl ? qctrl->default_value :
(unsigned short)~0;
}
- ici->remove(icd);
+ ici->ops->remove(icd);
return ret;
}
{
}
-int soc_camera_host_register(struct soc_camera_host *ici, struct module *owner)
+int soc_camera_host_register(struct soc_camera_host *ici)
{
int ret;
struct soc_camera_host *ix;
- if (!ici->vbq_ops || !ici->add || !ici->remove || !owner)
+ if (!ici->vbq_ops || !ici->ops->add || !ici->ops->remove)
return -EINVAL;
/* Number might be equal to the platform device ID */
list_add_tail(&ici->list, &hosts);
mutex_unlock(&list_lock);
- ici->owner = owner;
ici->dev.release = dummy_release;
ret = device_register(&ici->dev);
if (icd->dev.parent == &ici->dev) {
device_unregister(&icd->dev);
/* Not before device_unregister(), .remove
- * needs parent to call ici->remove() */
+ * needs parent to call ici->ops->remove() */
icd->dev.parent = NULL;
memset(&icd->dev.kobj, 0, sizeof(icd->dev.kobj));
}
unsigned char nr; /* Host number */
size_t msize;
struct videobuf_queue_ops *vbq_ops;
- struct module *owner;
void *priv;
char *drv_name;
+ struct soc_camera_host_ops *ops;
+};
+
+struct soc_camera_host_ops {
+ struct module *owner;
int (*add)(struct soc_camera_device *);
void (*remove)(struct soc_camera_device *);
int (*set_fmt_cap)(struct soc_camera_device *, __u32,
return container_of(dev, struct soc_camera_host, dev);
}
-extern int soc_camera_host_register(struct soc_camera_host *ici,
- struct module *owner);
+extern int soc_camera_host_register(struct soc_camera_host *ici);
extern void soc_camera_host_unregister(struct soc_camera_host *ici);
extern int soc_camera_device_register(struct soc_camera_device *icd);
extern void soc_camera_device_unregister(struct soc_camera_device *icd);