aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2015-11-02 21:27:51 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-09 10:20:09 -0400
commit68429f50ab60074e58b98010103fcc5bac4afd54 (patch)
tree79238fd7fd84b0d20692ef653c735c0fe22dfc57
parentdc3cdbc9d4dc22948d7f934789ee71baba55bc82 (diff)
[media] media: Move media_device link_notify operation to an ops structure
This will allow adding new operations without increasing the media_device structure size for drivers that don't implement any media device operation. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/media-entity.c11
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c6
-rw-r--r--drivers/media/platform/omap3isp/isp.c6
-rw-r--r--drivers/staging/media/omap4iss/iss.c6
-rw-r--r--include/media/media-device.h16
5 files changed, 33 insertions, 12 deletions
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 9014362e904d..c68239e60487 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -808,17 +808,18 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
808 808
809 mdev = source->graph_obj.mdev; 809 mdev = source->graph_obj.mdev;
810 810
811 if (mdev->link_notify) { 811 if (mdev->ops && mdev->ops->link_notify) {
812 ret = mdev->link_notify(link, flags, 812 ret = mdev->ops->link_notify(link, flags,
813 MEDIA_DEV_NOTIFY_PRE_LINK_CH); 813 MEDIA_DEV_NOTIFY_PRE_LINK_CH);
814 if (ret < 0) 814 if (ret < 0)
815 return ret; 815 return ret;
816 } 816 }
817 817
818 ret = __media_entity_setup_link_notify(link, flags); 818 ret = __media_entity_setup_link_notify(link, flags);
819 819
820 if (mdev->link_notify) 820 if (mdev->ops && mdev->ops->link_notify)
821 mdev->link_notify(link, flags, MEDIA_DEV_NOTIFY_POST_LINK_CH); 821 mdev->ops->link_notify(link, flags,
822 MEDIA_DEV_NOTIFY_POST_LINK_CH);
822 823
823 return ret; 824 return ret;
824} 825}
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 891625e77ef5..1a1154a9dfa4 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -1190,6 +1190,10 @@ static int fimc_md_link_notify(struct media_link *link, unsigned int flags,
1190 return ret ? -EPIPE : 0; 1190 return ret ? -EPIPE : 0;
1191} 1191}
1192 1192
1193static const struct media_device_ops fimc_md_ops = {
1194 .link_notify = fimc_md_link_notify,
1195};
1196
1193static ssize_t fimc_md_sysfs_show(struct device *dev, 1197static ssize_t fimc_md_sysfs_show(struct device *dev,
1194 struct device_attribute *attr, char *buf) 1198 struct device_attribute *attr, char *buf)
1195{ 1199{
@@ -1416,7 +1420,7 @@ static int fimc_md_probe(struct platform_device *pdev)
1416 1420
1417 strlcpy(fmd->media_dev.model, "SAMSUNG S5P FIMC", 1421 strlcpy(fmd->media_dev.model, "SAMSUNG S5P FIMC",
1418 sizeof(fmd->media_dev.model)); 1422 sizeof(fmd->media_dev.model));
1419 fmd->media_dev.link_notify = fimc_md_link_notify; 1423 fmd->media_dev.ops = &fimc_md_ops;
1420 fmd->media_dev.dev = dev; 1424 fmd->media_dev.dev = dev;
1421 1425
1422 v4l2_dev = &fmd->v4l2_dev; 1426 v4l2_dev = &fmd->v4l2_dev;
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 5d54e2c6c16b..0321d84addc7 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -657,6 +657,10 @@ static irqreturn_t isp_isr(int irq, void *_isp)
657 return IRQ_HANDLED; 657 return IRQ_HANDLED;
658} 658}
659 659
660static const struct media_device_ops isp_media_ops = {
661 .link_notify = v4l2_pipeline_link_notify,
662};
663
660/* ----------------------------------------------------------------------------- 664/* -----------------------------------------------------------------------------
661 * Pipeline stream management 665 * Pipeline stream management
662 */ 666 */
@@ -1680,7 +1684,7 @@ static int isp_register_entities(struct isp_device *isp)
1680 strlcpy(isp->media_dev.model, "TI OMAP3 ISP", 1684 strlcpy(isp->media_dev.model, "TI OMAP3 ISP",
1681 sizeof(isp->media_dev.model)); 1685 sizeof(isp->media_dev.model));
1682 isp->media_dev.hw_revision = isp->revision; 1686 isp->media_dev.hw_revision = isp->revision;
1683 isp->media_dev.link_notify = v4l2_pipeline_link_notify; 1687 isp->media_dev.ops = &isp_media_ops;
1684 media_device_init(&isp->media_dev); 1688 media_device_init(&isp->media_dev);
1685 1689
1686 isp->v4l2_dev.mdev = &isp->media_dev; 1690 isp->v4l2_dev.mdev = &isp->media_dev;
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
index 6ceb4eb00493..ffc4900da961 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -362,6 +362,10 @@ static irqreturn_t iss_isr(int irq, void *_iss)
362 return IRQ_HANDLED; 362 return IRQ_HANDLED;
363} 363}
364 364
365static const struct media_device_ops iss_media_ops = {
366 .link_notify = v4l2_pipeline_link_notify,
367};
368
365/* ----------------------------------------------------------------------------- 369/* -----------------------------------------------------------------------------
366 * Pipeline stream management 370 * Pipeline stream management
367 */ 371 */
@@ -988,7 +992,7 @@ static int iss_register_entities(struct iss_device *iss)
988 strlcpy(iss->media_dev.model, "TI OMAP4 ISS", 992 strlcpy(iss->media_dev.model, "TI OMAP4 ISS",
989 sizeof(iss->media_dev.model)); 993 sizeof(iss->media_dev.model));
990 iss->media_dev.hw_revision = iss->revision; 994 iss->media_dev.hw_revision = iss->revision;
991 iss->media_dev.link_notify = v4l2_pipeline_link_notify; 995 iss->media_dev.ops = &iss_media_ops;
992 ret = media_device_register(&iss->media_dev); 996 ret = media_device_register(&iss->media_dev);
993 if (ret < 0) { 997 if (ret < 0) {
994 dev_err(iss->dev, "Media device registration failed (%d)\n", 998 dev_err(iss->dev, "Media device registration failed (%d)\n",
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 481dd6c672cb..ef93e21335df 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -49,6 +49,16 @@ struct media_entity_notify {
49}; 49};
50 50
51/** 51/**
52 * struct media_device_ops - Media device operations
53 * @link_notify: Link state change notification callback. This callback is
54 * called with the graph_mutex held.
55 */
56struct media_device_ops {
57 int (*link_notify)(struct media_link *link, u32 flags,
58 unsigned int notification);
59};
60
61/**
52 * struct media_device - Media device 62 * struct media_device - Media device
53 * @dev: Parent device 63 * @dev: Parent device
54 * @devnode: Media device node 64 * @devnode: Media device node
@@ -80,8 +90,7 @@ struct media_entity_notify {
80 * @enable_source: Enable Source Handler function pointer 90 * @enable_source: Enable Source Handler function pointer
81 * @disable_source: Disable Source Handler function pointer 91 * @disable_source: Disable Source Handler function pointer
82 * 92 *
83 * @link_notify: Link state change notification callback. This callback is 93 * @ops: Operation handler callbacks
84 * called with the graph_mutex held.
85 * 94 *
86 * This structure represents an abstract high-level media device. It allows easy 95 * This structure represents an abstract high-level media device. It allows easy
87 * access to entities and provides basic media device-level support. The 96 * access to entities and provides basic media device-level support. The
@@ -150,8 +159,7 @@ struct media_device {
150 struct media_pipeline *pipe); 159 struct media_pipeline *pipe);
151 void (*disable_source)(struct media_entity *entity); 160 void (*disable_source)(struct media_entity *entity);
152 161
153 int (*link_notify)(struct media_link *link, u32 flags, 162 const struct media_device_ops *ops;
154 unsigned int notification);
155}; 163};
156 164
157/* We don't need to include pci.h or usb.h here */ 165/* We don't need to include pci.h or usb.h here */