[media] cx88: embed video_device
Embed the video_device struct to simplify the error handling and in order to (eventually) get rid of video_device_alloc/release. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
55cda4ab53
commit
34080bc25f
|
@ -1102,32 +1102,26 @@ static int cx8802_blackbird_advise_release(struct cx8802_driver *drv)
|
||||||
|
|
||||||
static void blackbird_unregister_video(struct cx8802_dev *dev)
|
static void blackbird_unregister_video(struct cx8802_dev *dev)
|
||||||
{
|
{
|
||||||
if (dev->mpeg_dev) {
|
video_unregister_device(&dev->mpeg_dev);
|
||||||
if (video_is_registered(dev->mpeg_dev))
|
|
||||||
video_unregister_device(dev->mpeg_dev);
|
|
||||||
else
|
|
||||||
video_device_release(dev->mpeg_dev);
|
|
||||||
dev->mpeg_dev = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blackbird_register_video(struct cx8802_dev *dev)
|
static int blackbird_register_video(struct cx8802_dev *dev)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
dev->mpeg_dev = cx88_vdev_init(dev->core, dev->pci,
|
cx88_vdev_init(dev->core, dev->pci, &dev->mpeg_dev,
|
||||||
&cx8802_mpeg_template, "mpeg");
|
&cx8802_mpeg_template, "mpeg");
|
||||||
dev->mpeg_dev->ctrl_handler = &dev->cxhdl.hdl;
|
dev->mpeg_dev.ctrl_handler = &dev->cxhdl.hdl;
|
||||||
video_set_drvdata(dev->mpeg_dev, dev);
|
video_set_drvdata(&dev->mpeg_dev, dev);
|
||||||
dev->mpeg_dev->queue = &dev->vb2_mpegq;
|
dev->mpeg_dev.queue = &dev->vb2_mpegq;
|
||||||
err = video_register_device(dev->mpeg_dev, VFL_TYPE_GRABBER, -1);
|
err = video_register_device(&dev->mpeg_dev, VFL_TYPE_GRABBER, -1);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk(KERN_INFO "%s/2: can't register mpeg device\n",
|
printk(KERN_INFO "%s/2: can't register mpeg device\n",
|
||||||
dev->core->name);
|
dev->core->name);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
printk(KERN_INFO "%s/2: registered device %s [mpeg]\n",
|
printk(KERN_INFO "%s/2: registered device %s [mpeg]\n",
|
||||||
dev->core->name, video_device_node_name(dev->mpeg_dev));
|
dev->core->name, video_device_node_name(&dev->mpeg_dev));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -985,17 +985,14 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
|
||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
struct video_device *cx88_vdev_init(struct cx88_core *core,
|
void cx88_vdev_init(struct cx88_core *core,
|
||||||
struct pci_dev *pci,
|
struct pci_dev *pci,
|
||||||
const struct video_device *template_,
|
struct video_device *vfd,
|
||||||
const char *type)
|
const struct video_device *template_,
|
||||||
|
const char *type)
|
||||||
{
|
{
|
||||||
struct video_device *vfd;
|
|
||||||
|
|
||||||
vfd = video_device_alloc();
|
|
||||||
if (NULL == vfd)
|
|
||||||
return NULL;
|
|
||||||
*vfd = *template_;
|
*vfd = *template_;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The dev pointer of v4l2_device is NULL, instead we set the
|
* The dev pointer of v4l2_device is NULL, instead we set the
|
||||||
* video_device dev_parent pointer to the correct PCI bus device.
|
* video_device dev_parent pointer to the correct PCI bus device.
|
||||||
|
@ -1004,11 +1001,10 @@ struct video_device *cx88_vdev_init(struct cx88_core *core,
|
||||||
*/
|
*/
|
||||||
vfd->v4l2_dev = &core->v4l2_dev;
|
vfd->v4l2_dev = &core->v4l2_dev;
|
||||||
vfd->dev_parent = &pci->dev;
|
vfd->dev_parent = &pci->dev;
|
||||||
vfd->release = video_device_release;
|
vfd->release = video_device_release_empty;
|
||||||
vfd->lock = &core->lock;
|
vfd->lock = &core->lock;
|
||||||
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
|
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
|
||||||
core->name, type, core->board.name);
|
core->name, type, core->board.name);
|
||||||
return vfd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cx88_core* cx88_core_get(struct pci_dev *pci)
|
struct cx88_core* cx88_core_get(struct pci_dev *pci)
|
||||||
|
|
|
@ -1274,27 +1274,9 @@ static const struct v4l2_ctrl_ops cx8800_ctrl_aud_ops = {
|
||||||
|
|
||||||
static void cx8800_unregister_video(struct cx8800_dev *dev)
|
static void cx8800_unregister_video(struct cx8800_dev *dev)
|
||||||
{
|
{
|
||||||
if (dev->radio_dev) {
|
video_unregister_device(&dev->radio_dev);
|
||||||
if (video_is_registered(dev->radio_dev))
|
video_unregister_device(&dev->vbi_dev);
|
||||||
video_unregister_device(dev->radio_dev);
|
video_unregister_device(&dev->video_dev);
|
||||||
else
|
|
||||||
video_device_release(dev->radio_dev);
|
|
||||||
dev->radio_dev = NULL;
|
|
||||||
}
|
|
||||||
if (dev->vbi_dev) {
|
|
||||||
if (video_is_registered(dev->vbi_dev))
|
|
||||||
video_unregister_device(dev->vbi_dev);
|
|
||||||
else
|
|
||||||
video_device_release(dev->vbi_dev);
|
|
||||||
dev->vbi_dev = NULL;
|
|
||||||
}
|
|
||||||
if (dev->video_dev) {
|
|
||||||
if (video_is_registered(dev->video_dev))
|
|
||||||
video_unregister_device(dev->video_dev);
|
|
||||||
else
|
|
||||||
video_device_release(dev->video_dev);
|
|
||||||
dev->video_dev = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cx8800_initdev(struct pci_dev *pci_dev,
|
static int cx8800_initdev(struct pci_dev *pci_dev,
|
||||||
|
@ -1485,12 +1467,12 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
|
||||||
goto fail_unreg;
|
goto fail_unreg;
|
||||||
|
|
||||||
/* register v4l devices */
|
/* register v4l devices */
|
||||||
dev->video_dev = cx88_vdev_init(core,dev->pci,
|
cx88_vdev_init(core, dev->pci, &dev->video_dev,
|
||||||
&cx8800_video_template,"video");
|
&cx8800_video_template, "video");
|
||||||
video_set_drvdata(dev->video_dev, dev);
|
video_set_drvdata(&dev->video_dev, dev);
|
||||||
dev->video_dev->ctrl_handler = &core->video_hdl;
|
dev->video_dev.ctrl_handler = &core->video_hdl;
|
||||||
dev->video_dev->queue = &dev->vb2_vidq;
|
dev->video_dev.queue = &dev->vb2_vidq;
|
||||||
err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
|
err = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER,
|
||||||
video_nr[core->nr]);
|
video_nr[core->nr]);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk(KERN_ERR "%s/0: can't register video device\n",
|
printk(KERN_ERR "%s/0: can't register video device\n",
|
||||||
|
@ -1498,12 +1480,13 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
|
||||||
goto fail_unreg;
|
goto fail_unreg;
|
||||||
}
|
}
|
||||||
printk(KERN_INFO "%s/0: registered device %s [v4l2]\n",
|
printk(KERN_INFO "%s/0: registered device %s [v4l2]\n",
|
||||||
core->name, video_device_node_name(dev->video_dev));
|
core->name, video_device_node_name(&dev->video_dev));
|
||||||
|
|
||||||
dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi");
|
cx88_vdev_init(core, dev->pci, &dev->vbi_dev,
|
||||||
video_set_drvdata(dev->vbi_dev, dev);
|
&cx8800_vbi_template, "vbi");
|
||||||
dev->vbi_dev->queue = &dev->vb2_vbiq;
|
video_set_drvdata(&dev->vbi_dev, dev);
|
||||||
err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
|
dev->vbi_dev.queue = &dev->vb2_vbiq;
|
||||||
|
err = video_register_device(&dev->vbi_dev, VFL_TYPE_VBI,
|
||||||
vbi_nr[core->nr]);
|
vbi_nr[core->nr]);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk(KERN_ERR "%s/0: can't register vbi device\n",
|
printk(KERN_ERR "%s/0: can't register vbi device\n",
|
||||||
|
@ -1511,14 +1494,14 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
|
||||||
goto fail_unreg;
|
goto fail_unreg;
|
||||||
}
|
}
|
||||||
printk(KERN_INFO "%s/0: registered device %s\n",
|
printk(KERN_INFO "%s/0: registered device %s\n",
|
||||||
core->name, video_device_node_name(dev->vbi_dev));
|
core->name, video_device_node_name(&dev->vbi_dev));
|
||||||
|
|
||||||
if (core->board.radio.type == CX88_RADIO) {
|
if (core->board.radio.type == CX88_RADIO) {
|
||||||
dev->radio_dev = cx88_vdev_init(core,dev->pci,
|
cx88_vdev_init(core, dev->pci, &dev->radio_dev,
|
||||||
&cx8800_radio_template,"radio");
|
&cx8800_radio_template, "radio");
|
||||||
video_set_drvdata(dev->radio_dev, dev);
|
video_set_drvdata(&dev->radio_dev, dev);
|
||||||
dev->radio_dev->ctrl_handler = &core->audio_hdl;
|
dev->radio_dev.ctrl_handler = &core->audio_hdl;
|
||||||
err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
|
err = video_register_device(&dev->radio_dev, VFL_TYPE_RADIO,
|
||||||
radio_nr[core->nr]);
|
radio_nr[core->nr]);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk(KERN_ERR "%s/0: can't register radio device\n",
|
printk(KERN_ERR "%s/0: can't register radio device\n",
|
||||||
|
@ -1526,7 +1509,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
|
||||||
goto fail_unreg;
|
goto fail_unreg;
|
||||||
}
|
}
|
||||||
printk(KERN_INFO "%s/0: registered device %s\n",
|
printk(KERN_INFO "%s/0: registered device %s\n",
|
||||||
core->name, video_device_node_name(dev->radio_dev));
|
core->name, video_device_node_name(&dev->radio_dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start tvaudio thread */
|
/* start tvaudio thread */
|
||||||
|
|
|
@ -478,9 +478,9 @@ struct cx8800_dev {
|
||||||
|
|
||||||
/* various device info */
|
/* various device info */
|
||||||
unsigned int resources;
|
unsigned int resources;
|
||||||
struct video_device *video_dev;
|
struct video_device video_dev;
|
||||||
struct video_device *vbi_dev;
|
struct video_device vbi_dev;
|
||||||
struct video_device *radio_dev;
|
struct video_device radio_dev;
|
||||||
|
|
||||||
/* pci i/o */
|
/* pci i/o */
|
||||||
struct pci_dev *pci;
|
struct pci_dev *pci;
|
||||||
|
@ -563,7 +563,7 @@ struct cx8802_dev {
|
||||||
/* for blackbird only */
|
/* for blackbird only */
|
||||||
struct list_head devlist;
|
struct list_head devlist;
|
||||||
#if IS_ENABLED(CONFIG_VIDEO_CX88_BLACKBIRD)
|
#if IS_ENABLED(CONFIG_VIDEO_CX88_BLACKBIRD)
|
||||||
struct video_device *mpeg_dev;
|
struct video_device mpeg_dev;
|
||||||
u32 mailbox;
|
u32 mailbox;
|
||||||
|
|
||||||
/* mpeg params */
|
/* mpeg params */
|
||||||
|
@ -647,10 +647,11 @@ extern int cx88_set_scale(struct cx88_core *core, unsigned int width,
|
||||||
unsigned int height, enum v4l2_field field);
|
unsigned int height, enum v4l2_field field);
|
||||||
extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm);
|
extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm);
|
||||||
|
|
||||||
extern struct video_device *cx88_vdev_init(struct cx88_core *core,
|
extern void cx88_vdev_init(struct cx88_core *core,
|
||||||
struct pci_dev *pci,
|
struct pci_dev *pci,
|
||||||
const struct video_device *template_,
|
struct video_device *vfd,
|
||||||
const char *type);
|
const struct video_device *template_,
|
||||||
|
const char *type);
|
||||||
extern struct cx88_core *cx88_core_get(struct pci_dev *pci);
|
extern struct cx88_core *cx88_core_get(struct pci_dev *pci);
|
||||||
extern void cx88_core_put(struct cx88_core *core,
|
extern void cx88_core_put(struct cx88_core *core,
|
||||||
struct pci_dev *pci);
|
struct pci_dev *pci);
|
||||||
|
|
Loading…
Reference in a new issue