diff options
author | Daniel W. S. Almeida <dwlsalmeida@gmail.com> | 2021-01-06 06:04:46 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-01-27 14:28:18 +0300 |
commit | e259572d6ffc036d29d0829f505de2c0149ff0bc (patch) | |
tree | 5c3044d4280f20d3061c4e46234d6230603bbc24 /drivers/media/test-drivers/vidtv/vidtv_bridge.c | |
parent | 8d23ada8e72d460c24da50a008209ecd3d7f9c8b (diff) | |
download | linux-e259572d6ffc036d29d0829f505de2c0149ff0bc.tar.xz |
media: vidtv: Add media controller support
Add media controller support when CONFIG_MEDIA_CONTROLLER_DVB is set
so that, in the future, a test sequence in v4l-utils can be written
without having to know which /dev/fooX device should be used.
[mchehab: avoided usage of C99 comments]
Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/test-drivers/vidtv/vidtv_bridge.c')
-rw-r--r-- | drivers/media/test-drivers/vidtv/vidtv_bridge.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/media/test-drivers/vidtv/vidtv_bridge.c b/drivers/media/test-drivers/vidtv/vidtv_bridge.c index fc64d0c8492a..20c7345eb2b6 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_bridge.c +++ b/drivers/media/test-drivers/vidtv/vidtv_bridge.c @@ -17,6 +17,8 @@ #include <linux/time.h> #include <linux/types.h> #include <linux/workqueue.h> +#include <media/dvbdev.h> +#include <media/media-device.h> #include "vidtv_bridge.h" #include "vidtv_common.h" @@ -501,9 +503,30 @@ static int vidtv_bridge_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dvb); +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb->mdev.dev = &pdev->dev; + + strscpy(dvb->mdev.model, "vidtv", sizeof(dvb->mdev.model)); + strscpy(dvb->mdev.bus_info, "platform:vidtv", sizeof(dvb->mdev.bus_info)); + + media_device_init(&dvb->mdev); + ret = media_device_register(&dvb->mdev); + if (ret) { + dev_err(dvb->mdev.dev, + "media device register failed (err=%d)\n", ret); + goto err_media_device_register; + } + + dvb_register_media_controller(&dvb->adapter, &dvb->mdev); +#endif /* CONFIG_MEDIA_CONTROLLER_DVB */ + dev_info(&pdev->dev, "Successfully initialized vidtv!\n"); return ret; +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +err_media_device_register: + media_device_cleanup(&dvb->mdev); +#endif /* CONFIG_MEDIA_CONTROLLER_DVB */ err_dvb: kfree(dvb); return ret; @@ -516,6 +539,11 @@ static int vidtv_bridge_remove(struct platform_device *pdev) dvb = platform_get_drvdata(pdev); +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + media_device_unregister(&dvb->mdev); + media_device_cleanup(&dvb->mdev); +#endif /* CONFIG_MEDIA_CONTROLLER_DVB */ + mutex_destroy(&dvb->feed_lock); for (i = 0; i < NUM_FE; ++i) { |