media: imx-pxp: Add media controller support
Register a media device for the PXP, using the v4l2-mem2mem MC infrastructure to populate the media graph. No media device operation is implemented, the main use of the MC API is to allow consistent discovery of media devices for userspace. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
parent
15acb0824e
commit
ff89b9b425
@ -24,6 +24,7 @@
|
||||
#include <linux/sched.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <media/media-device.h>
|
||||
#include <media/v4l2-ctrls.h>
|
||||
#include <media/v4l2-device.h>
|
||||
#include <media/v4l2-event.h>
|
||||
@ -201,6 +202,9 @@ struct pxp_pdata {
|
||||
struct pxp_dev {
|
||||
struct v4l2_device v4l2_dev;
|
||||
struct video_device vfd;
|
||||
#ifdef CONFIG_MEDIA_CONTROLLER
|
||||
struct media_device mdev;
|
||||
#endif
|
||||
|
||||
struct clk *clk;
|
||||
void __iomem *mmio;
|
||||
@ -1815,8 +1819,34 @@ static int pxp_probe(struct platform_device *pdev)
|
||||
goto err_m2m;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MEDIA_CONTROLLER
|
||||
dev->mdev.dev = &pdev->dev;
|
||||
strscpy(dev->mdev.model, MEM2MEM_NAME, sizeof(dev->mdev.model));
|
||||
media_device_init(&dev->mdev);
|
||||
dev->v4l2_dev.mdev = &dev->mdev;
|
||||
|
||||
ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
|
||||
MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Failed to initialize media device\n");
|
||||
goto err_vfd;
|
||||
}
|
||||
|
||||
ret = media_device_register(&dev->mdev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Failed to register media device\n");
|
||||
goto err_m2m_mc;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
#ifdef CONFIG_MEDIA_CONTROLLER
|
||||
err_m2m_mc:
|
||||
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
|
||||
err_vfd:
|
||||
video_unregister_device(vfd);
|
||||
#endif
|
||||
err_m2m:
|
||||
v4l2_m2m_release(dev->m2m_dev);
|
||||
err_v4l2:
|
||||
@ -1837,6 +1867,11 @@ static int pxp_remove(struct platform_device *pdev)
|
||||
clk_disable_unprepare(dev->clk);
|
||||
|
||||
v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME);
|
||||
|
||||
#ifdef CONFIG_MEDIA_CONTROLLER
|
||||
media_device_unregister(&dev->mdev);
|
||||
v4l2_m2m_unregister_media_controller(dev->m2m_dev);
|
||||
#endif
|
||||
video_unregister_device(&dev->vfd);
|
||||
v4l2_m2m_release(dev->m2m_dev);
|
||||
v4l2_device_unregister(&dev->v4l2_dev);
|
||||
|
Loading…
Reference in New Issue
Block a user