From d062f91193dbd5a0c1d8469c8517ec8dd552c3f2 Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Wed, 3 Jun 2015 12:12:53 -0300 Subject: [media] media: new media controller API for device resource support Add new media controller API to allocate media device as a device resource. When a media device is created on the main struct device which is the parent device for the interface device, it will be available to all drivers associated with that interface. For example, if a usb media device driver creates the media device on the main struct device which is common for all the drivers that control the media device, including the non-media ALSA driver, media controller API can be used to share access to the resources on the media device. This new interface provides the above described feature. A second interface that finds and returns the media device is added to allow drivers to find the media device created by any of the drivers associated with the device. Signed-off-by: Shuah Khan Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 7b39440192d6..a4d5b2488c05 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -462,3 +462,36 @@ void media_device_unregister_entity(struct media_entity *entity) entity->parent = NULL; } EXPORT_SYMBOL_GPL(media_device_unregister_entity); + +static void media_device_release_devres(struct device *dev, void *res) +{ +} + +/* + * media_device_get_devres() - get media device as device resource + * creates if one doesn't exist +*/ +struct media_device *media_device_get_devres(struct device *dev) +{ + struct media_device *mdev; + + mdev = devres_find(dev, media_device_release_devres, NULL, NULL); + if (mdev) + return mdev; + + mdev = devres_alloc(media_device_release_devres, + sizeof(struct media_device), GFP_KERNEL); + if (!mdev) + return NULL; + return devres_get(dev, mdev, NULL, NULL); +} +EXPORT_SYMBOL_GPL(media_device_get_devres); + +/* + * media_device_find_devres() - find media device as device resource +*/ +struct media_device *media_device_find_devres(struct device *dev) +{ + return devres_find(dev, media_device_release_devres, NULL, NULL); +} +EXPORT_SYMBOL_GPL(media_device_find_devres); -- cgit v1.2.3 From e576d60bb21e7add884f052ff0e5c28ebf7b7461 Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Fri, 5 Jun 2015 17:11:54 -0300 Subject: [media] media: define Media Controller API when CONFIG_MEDIA_CONTROLLER enabled Change to define Media Controller API when CONFIG_MEDIA_CONTROLLER is enabled. Define stubs for CONFIG_MEDIA_CONTROLLER disabled case. This will help avoid drivers needing to enclose Media Controller code within ifdef CONFIG_MEDIA_CONTROLLER block. Signed-off-by: Shuah Khan Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 4 ++++ include/media/media-device.h | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index a4d5b2488c05..c55ab5029323 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -30,6 +30,8 @@ #include #include +#ifdef CONFIG_MEDIA_CONTROLLER + /* ----------------------------------------------------------------------------- * Userspace API */ @@ -495,3 +497,5 @@ struct media_device *media_device_find_devres(struct device *dev) return devres_find(dev, media_device_release_devres, NULL, NULL); } EXPORT_SYMBOL_GPL(media_device_find_devres); + +#endif /* CONFIG_MEDIA_CONTROLLER */ diff --git a/include/media/media-device.h b/include/media/media-device.h index 22792cd5b1d1..a44f18fdf321 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -80,6 +80,8 @@ struct media_device { unsigned int notification); }; +#ifdef CONFIG_MEDIA_CONTROLLER + /* Supported link_notify @notification values. */ #define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0 #define MEDIA_DEV_NOTIFY_POST_LINK_CH 1 @@ -102,4 +104,29 @@ struct media_device *media_device_find_devres(struct device *dev); #define media_device_for_each_entity(entity, mdev) \ list_for_each_entry(entity, &(mdev)->entities, list) +#else +static inline int media_device_register(struct media_device *mdev) +{ + return 0; +} +static inline void media_device_unregister(struct media_device *mdev) +{ +} +static inline int media_device_register_entity(struct media_device *mdev, + struct media_entity *entity) +{ + return 0; +} +static inline void media_device_unregister_entity(struct media_entity *entity) +{ +} +static inline struct media_device *media_device_get_devres(struct device *dev) +{ + return NULL; +} +static inline struct media_device *media_device_find_devres(struct device *dev) +{ + return NULL; +} +#endif /* CONFIG_MEDIA_CONTROLLER */ #endif -- cgit v1.2.3 From bed6919665072b1e5bad31a013d53798394e097c Mon Sep 17 00:00:00 2001 From: Rafael Lourenço de Lima Chehab Date: Mon, 8 Jun 2015 22:20:46 -0300 Subject: [media] au0828: Add support for media controller Add support for analog and dvb tv using media controller. Signed-off-by: Rafael Lourenço de Lima Chehab Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/au8522_decoder.c | 17 +++++ drivers/media/dvb-frontends/au8522_priv.h | 12 ++++ drivers/media/usb/au0828/au0828-core.c | 98 ++++++++++++++++++++++++++++ drivers/media/usb/au0828/au0828-dvb.c | 10 +++ drivers/media/usb/au0828/au0828-video.c | 83 +++++++++++++++++++++++ drivers/media/usb/au0828/au0828.h | 6 ++ 6 files changed, 226 insertions(+) (limited to 'drivers') diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c index c8f13d8370e5..0a8882cb23c3 100644 --- a/drivers/media/dvb-frontends/au8522_decoder.c +++ b/drivers/media/dvb-frontends/au8522_decoder.c @@ -730,6 +730,9 @@ static int au8522_probe(struct i2c_client *client, struct v4l2_ctrl_handler *hdl; struct v4l2_subdev *sd; int instance; +#ifdef CONFIG_MEDIA_CONTROLLER + int ret; +#endif /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, @@ -758,6 +761,20 @@ static int au8522_probe(struct i2c_client *client, sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &au8522_ops); +#if defined(CONFIG_MEDIA_CONTROLLER) + + state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK; + state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; + state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; + sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + + ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), + state->pads, 0); + if (ret < 0) { + v4l_info(client, "failed to initialize media entity!\n"); + return ret; + } +#endif hdl = &state->hdl; v4l2_ctrl_handler_init(hdl, 4); diff --git a/drivers/media/dvb-frontends/au8522_priv.h b/drivers/media/dvb-frontends/au8522_priv.h index ee330c61aa61..404a0cb0ed8d 100644 --- a/drivers/media/dvb-frontends/au8522_priv.h +++ b/drivers/media/dvb-frontends/au8522_priv.h @@ -39,6 +39,14 @@ #define AU8522_DIGITAL_MODE 1 #define AU8522_SUSPEND_MODE 2 +enum au8522_media_pads { + AU8522_PAD_INPUT, + AU8522_PAD_VID_OUT, + AU8522_PAD_VBI_OUT, + + AU8522_NUM_PADS +}; + struct au8522_state { struct i2c_client *c; struct i2c_adapter *i2c; @@ -68,6 +76,10 @@ struct au8522_state { u32 id; u32 rev; struct v4l2_ctrl_handler hdl; + +#ifdef CONFIG_MEDIA_CONTROLLER + struct media_pad pads[AU8522_NUM_PADS]; +#endif }; /* These are routines shared by both the VSB/QAM demodulator and the analog diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 0934024fb89d..0378a2c99ebb 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -127,8 +127,22 @@ static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value, return status; } +static void au0828_unregister_media_device(struct au0828_dev *dev) +{ + +#ifdef CONFIG_MEDIA_CONTROLLER + if (dev->media_dev) { + media_device_unregister(dev->media_dev); + kfree(dev->media_dev); + dev->media_dev = NULL; + } +#endif +} + static void au0828_usb_release(struct au0828_dev *dev) { + au0828_unregister_media_device(dev); + /* I2C */ au0828_i2c_unregister(dev); @@ -161,6 +175,8 @@ static void au0828_usb_disconnect(struct usb_interface *interface) */ dev->dev_state = DEV_DISCONNECTED; + au0828_unregister_media_device(dev); + au0828_rc_unregister(dev); /* Digital TV */ au0828_dvb_unregister(dev); @@ -180,6 +196,81 @@ static void au0828_usb_disconnect(struct usb_interface *interface) au0828_usb_release(dev); } +static void au0828_media_device_register(struct au0828_dev *dev, + struct usb_device *udev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER + struct media_device *mdev; + int ret; + + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); + if (!mdev) + return; + + mdev->dev = &udev->dev; + + if (!dev->board.name) + strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model)); + else + strlcpy(mdev->model, dev->board.name, sizeof(mdev->model)); + if (udev->serial) + strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial)); + strcpy(mdev->bus_info, udev->devpath); + mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); + mdev->driver_version = LINUX_VERSION_CODE; + + ret = media_device_register(mdev); + if (ret) { + pr_err( + "Couldn't create a media device. Error: %d\n", + ret); + kfree(mdev); + return; + } + + dev->media_dev = mdev; +#endif +} + + +static void au0828_create_media_graph(struct au0828_dev *dev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER + struct media_device *mdev = dev->media_dev; + struct media_entity *entity; + struct media_entity *tuner = NULL, *decoder = NULL; + + if (!mdev) + return; + + media_device_for_each_entity(entity, mdev) { + switch (entity->type) { + case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: + tuner = entity; + break; + case MEDIA_ENT_T_V4L2_SUBDEV_DECODER: + decoder = entity; + break; + } + } + + /* Analog setup, using tuner as a link */ + + if (!decoder) + return; + + if (tuner) + media_entity_create_link(tuner, 0, decoder, 0, + MEDIA_LNK_FL_ENABLED); + if (dev->vdev.entity.links) + media_entity_create_link(decoder, 1, &dev->vdev.entity, 0, + MEDIA_LNK_FL_ENABLED); + if (dev->vbi_dev.entity.links) + media_entity_create_link(decoder, 2, &dev->vbi_dev.entity, 0, + MEDIA_LNK_FL_ENABLED); +#endif +} + static int au0828_usb_probe(struct usb_interface *interface, const struct usb_device_id *id) { @@ -224,11 +315,16 @@ static int au0828_usb_probe(struct usb_interface *interface, dev->boardnr = id->driver_info; dev->board = au0828_boards[dev->boardnr]; + /* Register the media controller */ + au0828_media_device_register(dev, usbdev); #ifdef CONFIG_VIDEO_AU0828_V4L2 dev->v4l2_dev.release = au0828_usb_v4l2_release; /* Create the v4l2_device */ +#ifdef CONFIG_MEDIA_CONTROLLER + dev->v4l2_dev.mdev = dev->media_dev; +#endif retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); if (retval) { pr_err("%s() v4l2_device_register failed\n", @@ -287,6 +383,8 @@ static int au0828_usb_probe(struct usb_interface *interface, mutex_unlock(&dev->lock); + au0828_create_media_graph(dev); + return retval; } diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c index c267d76f5b3c..c01772c4f9f0 100644 --- a/drivers/media/usb/au0828/au0828-dvb.c +++ b/drivers/media/usb/au0828/au0828-dvb.c @@ -415,6 +415,11 @@ static int dvb_register(struct au0828_dev *dev) result); goto fail_adapter; } + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb->adapter.mdev = dev->media_dev; +#endif + dvb->adapter.priv = dev; /* register frontend */ @@ -480,6 +485,11 @@ static int dvb_register(struct au0828_dev *dev) dvb->start_count = 0; dvb->stop_count = 0; + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + dvb_create_media_graph(&dvb->adapter); +#endif + return 0; fail_fe_conn: diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 0a725a161dd6..7aa7d509885b 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -638,6 +638,75 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb) return rc; } +static int au0828_enable_analog_tuner(struct au0828_dev *dev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER + struct media_device *mdev = dev->media_dev; + struct media_entity *entity, *decoder = NULL, *source; + struct media_link *link, *found_link = NULL; + int i, ret, active_links = 0; + + if (!mdev) + return 0; + + /* + * This will find the tuner that is connected into the decoder. + * Technically, this is not 100% correct, as the device may be + * using an analog input instead of the tuner. However, as we can't + * do DVB streaming while the DMA engine is being used for V4L2, + * this should be enough for the actual needs. + */ + media_device_for_each_entity(entity, mdev) { + if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) { + decoder = entity; + break; + } + } + if (!decoder) + return 0; + + for (i = 0; i < decoder->num_links; i++) { + link = &decoder->links[i]; + if (link->sink->entity == decoder) { + found_link = link; + if (link->flags & MEDIA_LNK_FL_ENABLED) + active_links++; + break; + } + } + + if (active_links == 1 || !found_link) + return 0; + + source = found_link->source->entity; + for (i = 0; i < source->num_links; i++) { + struct media_entity *sink; + int flags = 0; + + link = &source->links[i]; + sink = link->sink->entity; + + if (sink == entity) + flags = MEDIA_LNK_FL_ENABLED; + + ret = media_entity_setup_link(link, flags); + if (ret) { + pr_err( + "Couldn't change link %s->%s to %s. Error %d\n", + source->name, sink->name, + flags ? "enabled" : "disabled", + ret); + return ret; + } else + au0828_isocdbg( + "link %s->%s was %s\n", + source->name, sink->name, + flags ? "ENABLED" : "disabled"); + } +#endif + return 0; +} + static int queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) @@ -650,6 +719,8 @@ static int queue_setup(struct vb2_queue *vq, *nplanes = 1; sizes[0] = size; + au0828_enable_analog_tuner(dev); + return 0; } @@ -1823,6 +1894,18 @@ int au0828_analog_register(struct au0828_dev *dev, dev->vbi_dev.queue->lock = &dev->vb_vbi_queue_lock; strcpy(dev->vbi_dev.name, "au0828a vbi"); +#if defined(CONFIG_MEDIA_CONTROLLER) + dev->video_pad.flags = MEDIA_PAD_FL_SINK; + ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad, 0); + if (ret < 0) + pr_err("failed to initialize video media entity!\n"); + + dev->vbi_pad.flags = MEDIA_PAD_FL_SINK; + ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad, 0); + if (ret < 0) + pr_err("failed to initialize vbi media entity!\n"); +#endif + /* initialize videobuf2 stuff */ retval = au0828_vb2_setup(dev); if (retval != 0) { diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h index 60b59391ea2a..7d175d8b8a7a 100644 --- a/drivers/media/usb/au0828/au0828.h +++ b/drivers/media/usb/au0828/au0828.h @@ -33,6 +33,7 @@ #include #include #include +#include /* DVB */ #include "demux.h" @@ -276,6 +277,11 @@ struct au0828_dev { /* Preallocated transfer digital transfer buffers */ char *dig_transfer_buffer[URB_COUNT]; + +#ifdef CONFIG_MEDIA_CONTROLLER + struct media_device *media_dev; + struct media_pad video_pad, vbi_pad; +#endif }; -- cgit v1.2.3 From 0158e7b6a29f33a2c91cf045468958fbe8cb0b4c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 18 Jun 2015 13:06:38 -0300 Subject: [media] au0828: Cache the decoder info at au0828 dev structure Instead of seeking for the decoder every time analog stream is started, cache it. This simplifies the code a little bit. Requested-by: Hans Verkuil Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-cards.c | 4 ++++ drivers/media/usb/au0828/au0828-video.c | 19 +++++-------------- drivers/media/usb/au0828/au0828.h | 1 + 3 files changed, 10 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/au0828/au0828-cards.c b/drivers/media/usb/au0828/au0828-cards.c index 6b469e8c4c6e..ca861aea68a5 100644 --- a/drivers/media/usb/au0828/au0828-cards.c +++ b/drivers/media/usb/au0828/au0828-cards.c @@ -228,6 +228,10 @@ void au0828_card_analog_fe_setup(struct au0828_dev *dev) "au8522", 0x8e >> 1, NULL); if (sd == NULL) pr_err("analog subdev registration failed\n"); +#ifdef CONFIG_MEDIA_CONTROLLER + if (sd) + dev->decoder = &sd->entity; +#endif } /* Setup tuners */ diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 7aa7d509885b..0b6e97d4fd94 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -642,11 +642,11 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev = dev->media_dev; - struct media_entity *entity, *decoder = NULL, *source; + struct media_entity *entity, *source; struct media_link *link, *found_link = NULL; int i, ret, active_links = 0; - if (!mdev) + if (!mdev || !dev->decoder) return 0; /* @@ -656,18 +656,9 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev) * do DVB streaming while the DMA engine is being used for V4L2, * this should be enough for the actual needs. */ - media_device_for_each_entity(entity, mdev) { - if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) { - decoder = entity; - break; - } - } - if (!decoder) - return 0; - - for (i = 0; i < decoder->num_links; i++) { - link = &decoder->links[i]; - if (link->sink->entity == decoder) { + for (i = 0; i < dev->decoder->num_links; i++) { + link = &dev->decoder->links[i]; + if (link->sink->entity == dev->decoder) { found_link = link; if (link->flags & MEDIA_LNK_FL_ENABLED) active_links++; diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h index 7d175d8b8a7a..3577b931157b 100644 --- a/drivers/media/usb/au0828/au0828.h +++ b/drivers/media/usb/au0828/au0828.h @@ -281,6 +281,7 @@ struct au0828_dev { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *media_dev; struct media_pad video_pad, vbi_pad; + struct media_entity *decoder; #endif }; -- cgit v1.2.3 From 1809510715c4187fa7338204cac53e30326d5d04 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 6 Aug 2015 09:25:57 -0300 Subject: [media] media: get rid of unused "extra_links" param on media_entity_init() Currently, media_entity_init() creates an array with the links, allocated at init time. It provides a parameter (extra_links) that would allocate more links than the current needs, but this is not used by any driver. As we want to be able to do dynamic link allocation/removal, we'll need to change the implementation of the links. So, before doing that, let's first remove that extra unused parameter, in order to cleanup the interface first. Signed-off-by: Mauro Carvalho Chehab Acked-by: Sakari Ailus Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- Documentation/media-framework.txt | 7 +++---- Documentation/video4linux/v4l2-framework.txt | 4 ++-- Documentation/zh_CN/video4linux/v4l2-framework.txt | 4 ++-- drivers/media/dvb-core/dvbdev.c | 2 +- drivers/media/dvb-frontends/au8522_decoder.c | 2 +- drivers/media/i2c/ad9389b.c | 2 +- drivers/media/i2c/adp1653.c | 2 +- drivers/media/i2c/adv7180.c | 2 +- drivers/media/i2c/adv7511.c | 2 +- drivers/media/i2c/adv7604.c | 2 +- drivers/media/i2c/adv7842.c | 2 +- drivers/media/i2c/as3645a.c | 2 +- drivers/media/i2c/cx25840/cx25840-core.c | 2 +- drivers/media/i2c/lm3560.c | 2 +- drivers/media/i2c/lm3646.c | 2 +- drivers/media/i2c/m5mols/m5mols_core.c | 2 +- drivers/media/i2c/mt9m032.c | 2 +- drivers/media/i2c/mt9p031.c | 2 +- drivers/media/i2c/mt9t001.c | 2 +- drivers/media/i2c/mt9v032.c | 2 +- drivers/media/i2c/noon010pc30.c | 2 +- drivers/media/i2c/ov2659.c | 2 +- drivers/media/i2c/ov9650.c | 2 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 ++-- drivers/media/i2c/s5k4ecgx.c | 2 +- drivers/media/i2c/s5k5baf.c | 4 ++-- drivers/media/i2c/s5k6a3.c | 2 +- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 4 ++-- drivers/media/i2c/tc358743.c | 2 +- drivers/media/i2c/tvp514x.c | 2 +- drivers/media/i2c/tvp7002.c | 2 +- drivers/media/media-entity.c | 18 ++++++++---------- drivers/media/platform/exynos4-is/fimc-capture.c | 4 ++-- drivers/media/platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-isp.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 4 ++-- drivers/media/platform/exynos4-is/fimc-m2m.c | 2 +- drivers/media/platform/exynos4-is/mipi-csis.c | 2 +- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/isppreview.c | 2 +- drivers/media/platform/omap3isp/ispresizer.c | 2 +- drivers/media/platform/omap3isp/ispstat.c | 2 +- drivers/media/platform/omap3isp/ispvideo.c | 2 +- drivers/media/platform/s3c-camif/camif-capture.c | 4 ++-- drivers/media/platform/vsp1/vsp1_entity.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 2 +- drivers/media/platform/xilinx/xilinx-dma.c | 2 +- drivers/media/platform/xilinx/xilinx-tpg.c | 2 +- drivers/media/usb/au0828/au0828-video.c | 4 ++-- drivers/media/usb/cx231xx/cx231xx-video.c | 4 ++-- drivers/media/usb/uvc/uvc_entity.c | 4 ++-- drivers/media/v4l2-core/tuner-core.c | 2 +- drivers/media/v4l2-core/v4l2-flash-led-class.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 6 +++--- drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 +- drivers/staging/media/omap4iss/iss_csi2.c | 2 +- drivers/staging/media/omap4iss/iss_ipipe.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 2 +- drivers/staging/media/omap4iss/iss_resizer.c | 2 +- drivers/staging/media/omap4iss/iss_video.c | 2 +- include/media/media-entity.h | 2 +- 67 files changed, 89 insertions(+), 92 deletions(-) (limited to 'drivers') diff --git a/Documentation/media-framework.txt b/Documentation/media-framework.txt index f552a75c0e70..6903b2503577 100644 --- a/Documentation/media-framework.txt +++ b/Documentation/media-framework.txt @@ -104,7 +104,7 @@ although drivers can allocate entities directly. Drivers initialize entities by calling media_entity_init(struct media_entity *entity, u16 num_pads, - struct media_pad *pads, u16 extra_links); + struct media_pad *pads); The media_entity name, type, flags, revision and group_id fields can be initialized before or after calling media_entity_init. Entities embedded in @@ -120,9 +120,8 @@ media_entity_init. The function will initialize the other pads fields. Unlike the number of pads, the total number of links isn't always known in advance by the entity driver. As an initial estimate, media_entity_init -pre-allocates a number of links equal to the number of pads plus an optional -number of extra links. The links array will be reallocated if it grows beyond -the initial estimate. +pre-allocates a number of links equal to the number of pads. The links array +will be reallocated if it grows beyond the initial estimate. Drivers register entities with a media device by calling diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 75d5c18d689a..109cc3792534 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt @@ -300,7 +300,7 @@ calling media_entity_init(): struct media_pad *pads = &my_sd->pads; int err; - err = media_entity_init(&sd->entity, npads, pads, 0); + err = media_entity_init(&sd->entity, npads, pads); The pads array must have been previously initialized. There is no need to manually set the struct media_entity type and name fields, but the revision @@ -700,7 +700,7 @@ calling media_entity_init(): struct media_pad *pad = &my_vdev->pad; int err; - err = media_entity_init(&vdev->entity, 1, pad, 0); + err = media_entity_init(&vdev->entity, 1, pad); The pads array must have been previously initialized. There is no need to manually set the struct media_entity type and name fields. diff --git a/Documentation/zh_CN/video4linux/v4l2-framework.txt b/Documentation/zh_CN/video4linux/v4l2-framework.txt index 2b828e631e31..ff815cb92031 100644 --- a/Documentation/zh_CN/video4linux/v4l2-framework.txt +++ b/Documentation/zh_CN/video4linux/v4l2-framework.txt @@ -295,7 +295,7 @@ owner 域。若使用 i2c 辅助函数,这些都会帮你处理好。 struct media_pad *pads = &my_sd->pads; int err; - err = media_entity_init(&sd->entity, npads, pads, 0); + err = media_entity_init(&sd->entity, npads, pads); pads 数组必须预先初始化。无须手动设置 media_entity 的 type 和 name 域,但如有必要,revision 域必须初始化。 @@ -602,7 +602,7 @@ v4l2_file_operations 结构体是 file_operations 的一个子集。其主要 struct media_pad *pad = &my_vdev->pad; int err; - err = media_entity_init(&vdev->entity, 1, pad, 0); + err = media_entity_init(&vdev->entity, 1, pad); pads 数组必须预先初始化。没有必要手动设置 media_entity 的 type 和 name 域。 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 13bb57f0457f..2fdcbb5f000a 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -249,7 +249,7 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, } if (npads) - ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads, 0); + ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads); if (!ret) ret = media_device_register_entity(dvbdev->adapter->mdev, dvbdev->entity); diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c index 0a8882cb23c3..580859c89da1 100644 --- a/drivers/media/dvb-frontends/au8522_decoder.c +++ b/drivers/media/dvb-frontends/au8522_decoder.c @@ -769,7 +769,7 @@ static int au8522_probe(struct i2c_client *client, sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), - state->pads, 0); + state->pads); if (ret < 0) { v4l_info(client, "failed to initialize media entity!\n"); return ret; diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index 0494a7896aa2..a02dc4925707 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c @@ -1158,7 +1158,7 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id * state->rgb_quantization_range_ctrl->is_private = true; state->pad.flags = MEDIA_PAD_FL_SINK; - err = media_entity_init(&sd->entity, 1, &state->pad, 0); + err = media_entity_init(&sd->entity, 1, &state->pad); if (err) goto err_hdl; diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index f00745bbe471..07e46b5b849c 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -512,7 +512,7 @@ static int adp1653_probe(struct i2c_client *client, if (ret) goto free_and_quit; - ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0); + ret = media_entity_init(&flash->subdev.entity, 0, NULL); if (ret < 0) goto free_and_quit; diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 3c3c4bfe3866..0fca8677014c 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -1214,7 +1214,7 @@ static int adv7180_probe(struct i2c_client *client, state->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; - ret = media_entity_init(&sd->entity, 1, &state->pad, 0); + ret = media_entity_init(&sd->entity, 1, &state->pad); if (ret) goto err_free_ctrl; diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c index eeb2cd823c4d..cbcf81b1d29e 100644 --- a/drivers/media/i2c/adv7511.c +++ b/drivers/media/i2c/adv7511.c @@ -1482,7 +1482,7 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id * state->rgb_quantization_range_ctrl->is_private = true; state->pad.flags = MEDIA_PAD_FL_SINK; - err = media_entity_init(&sd->entity, 1, &state->pad, 0); + err = media_entity_init(&sd->entity, 1, &state->pad); if (err) goto err_hdl; diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 745286225655..c2df7e8053f3 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -3209,7 +3209,7 @@ static int adv76xx_probe(struct i2c_client *client, state->pads[state->source_pad].flags = MEDIA_PAD_FL_SOURCE; err = media_entity_init(&sd->entity, state->source_pad + 1, - state->pads, 0); + state->pads); if (err) goto err_work_queues; diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 69378e4914b6..b5013a937254 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -3309,7 +3309,7 @@ static int adv7842_probe(struct i2c_client *client, adv7842_delayed_work_enable_hotplug); state->pad.flags = MEDIA_PAD_FL_SOURCE; - err = media_entity_init(&sd->entity, 1, &state->pad, 0); + err = media_entity_init(&sd->entity, 1, &state->pad); if (err) goto err_work_queues; diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c index 29a2e7034aa6..b83c7fc988ae 100644 --- a/drivers/media/i2c/as3645a.c +++ b/drivers/media/i2c/as3645a.c @@ -827,7 +827,7 @@ static int as3645a_probe(struct i2c_client *client, if (ret < 0) goto done; - ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0); + ret = media_entity_init(&flash->subdev.entity, 0, NULL); if (ret < 0) goto done; diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index f2e2c34ddbbd..022ad5ae8869 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -5214,7 +5214,7 @@ static int cx25840_probe(struct i2c_client *client, sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), - state->pads, 0); + state->pads); if (ret < 0) { v4l_info(client, "failed to initialize media entity!\n"); return ret; diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index 19ecb8801064..91c1ed27a458 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -365,7 +365,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash, rval = lm3560_init_controls(flash, led_no); if (rval) goto err_out; - rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL, 0); + rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL); if (rval < 0) goto err_out; flash->subdev_led[led_no].entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c index 7fbe6ff1c4f4..a037616bbab0 100644 --- a/drivers/media/i2c/lm3646.c +++ b/drivers/media/i2c/lm3646.c @@ -282,7 +282,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash) rval = lm3646_init_controls(flash); if (rval) goto err_out; - rval = media_entity_init(&flash->subdev_led.entity, 0, NULL, 0); + rval = media_entity_init(&flash->subdev_led.entity, 0, NULL); if (rval < 0) goto err_out; flash->subdev_led.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index f8993933416e..0788c1908f9c 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -975,7 +975,7 @@ static int m5mols_probe(struct i2c_client *client, sd->internal_ops = &m5mols_subdev_internal_ops; info->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sd->entity, 1, &info->pad, 0); + ret = media_entity_init(&sd->entity, 1, &info->pad); if (ret < 0) return ret; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c index 101cb26f9330..a2a450839ca1 100644 --- a/drivers/media/i2c/mt9m032.c +++ b/drivers/media/i2c/mt9m032.c @@ -799,7 +799,7 @@ static int mt9m032_probe(struct i2c_client *client, sensor->subdev.ctrl_handler = &sensor->ctrls; sensor->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sensor->subdev.entity, 1, &sensor->pad, 0); + ret = media_entity_init(&sensor->subdev.entity, 1, &sensor->pad); if (ret < 0) goto error_ctrl; diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index a3da0e977d0b..165f29cddca6 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -1112,7 +1112,7 @@ static int mt9p031_probe(struct i2c_client *client, mt9p031->subdev.internal_ops = &mt9p031_subdev_internal_ops; mt9p031->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&mt9p031->subdev.entity, 1, &mt9p031->pad, 0); + ret = media_entity_init(&mt9p031->subdev.entity, 1, &mt9p031->pad); if (ret < 0) goto done; diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c index b28fdff1d310..7d3df84651d8 100644 --- a/drivers/media/i2c/mt9t001.c +++ b/drivers/media/i2c/mt9t001.c @@ -933,7 +933,7 @@ static int mt9t001_probe(struct i2c_client *client, mt9t001->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; mt9t001->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&mt9t001->subdev.entity, 1, &mt9t001->pad, 0); + ret = media_entity_init(&mt9t001->subdev.entity, 1, &mt9t001->pad); done: if (ret < 0) { diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index 1dbbd23fdfb0..b4f0f042c6c3 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c @@ -1046,7 +1046,7 @@ static int mt9v032_probe(struct i2c_client *client, mt9v032->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0); + ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad); if (ret < 0) goto err; diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 69e4f3031d8b..2e614ad473f1 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -780,7 +780,7 @@ static int noon010_probe(struct i2c_client *client, info->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; - ret = media_entity_init(&sd->entity, 1, &info->pad, 0); + ret = media_entity_init(&sd->entity, 1, &info->pad); if (ret < 0) goto np_err; diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c index 82c7ac1cc88e..ea95f854a519 100644 --- a/drivers/media/i2c/ov2659.c +++ b/drivers/media/i2c/ov2659.c @@ -1446,7 +1446,7 @@ static int ov2659_probe(struct i2c_client *client, #if defined(CONFIG_MEDIA_CONTROLLER) ov2659->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; - ret = media_entity_init(&sd->entity, 1, &ov2659->pad, 0); + ret = media_entity_init(&sd->entity, 1, &ov2659->pad); if (ret < 0) { v4l2_ctrl_handler_free(&ov2659->ctrls); return ret; diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index 9fe9006474b2..b4c408f2a2b0 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c @@ -1501,7 +1501,7 @@ static int ov965x_probe(struct i2c_client *client, ov965x->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; - ret = media_entity_init(&sd->entity, 1, &ov965x->pad, 0); + ret = media_entity_init(&sd->entity, 1, &ov965x->pad); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index 25f5e79dc9bc..381f903831f4 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1691,7 +1691,7 @@ static int s5c73m3_probe(struct i2c_client *client, sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS, - state->sensor_pads, 0); + state->sensor_pads); if (ret < 0) return ret; @@ -1707,7 +1707,7 @@ static int s5c73m3_probe(struct i2c_client *client, oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS, - state->oif_pads, 0); + state->oif_pads); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c index 6757aca2cdab..445a89e30949 100644 --- a/drivers/media/i2c/s5k4ecgx.c +++ b/drivers/media/i2c/s5k4ecgx.c @@ -962,7 +962,7 @@ static int s5k4ecgx_probe(struct i2c_client *client, priv->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; - ret = media_entity_init(&sd->entity, 1, &priv->pad, 0); + ret = media_entity_init(&sd->entity, 1, &priv->pad); if (ret) return ret; diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 774e0d0c94cb..30a9ca62e034 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -1905,7 +1905,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->cis_pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; - ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad, 0); + ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad); if (ret < 0) goto err; @@ -1920,7 +1920,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK; state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; - ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads, 0); + ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads); if (!ret) return 0; diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c index b1b1574dfb95..2434a7944781 100644 --- a/drivers/media/i2c/s5k6a3.c +++ b/drivers/media/i2c/s5k6a3.c @@ -333,7 +333,7 @@ static int s5k6a3_probe(struct i2c_client *client, sensor->format.height = S5K6A3_DEFAULT_HEIGHT; sensor->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sd->entity, 1, &sensor->pad, 0); + ret = media_entity_init(&sd->entity, 1, &sensor->pad); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c index 60aaff7190d2..31be29d25093 100644 --- a/drivers/media/i2c/s5k6aa.c +++ b/drivers/media/i2c/s5k6aa.c @@ -1578,7 +1578,7 @@ static int s5k6aa_probe(struct i2c_client *client, s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; - ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad, 0); + ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad); if (ret) return ret; diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index fb39dfd55e75..7ed0538ea8db 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2488,7 +2488,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) continue; rval = media_entity_init(&this->sd.entity, - this->npads, this->pads, 0); + this->npads, this->pads); if (rval) { dev_err(&client->dev, "media_entity_init failed\n"); @@ -3078,7 +3078,7 @@ static int smiapp_probe(struct i2c_client *client, sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE; rval = media_entity_init(&sensor->src->sd.entity, 2, - sensor->src->pads, 0); + sensor->src->pads); if (rval < 0) return rval; diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index 77b801152ea5..78e5b644d400 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -1889,7 +1889,7 @@ static int tc358743_probe(struct i2c_client *client, } state->pad.flags = MEDIA_PAD_FL_SOURCE; - err = media_entity_init(&sd->entity, 1, &state->pad, 0); + err = media_entity_init(&sd->entity, 1, &state->pad); if (err < 0) goto err_hdl; diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index b5dba5b7ce3a..11e426dbe891 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -1097,7 +1097,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) decoder->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; decoder->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; - ret = media_entity_init(&decoder->sd.entity, 1, &decoder->pad, 0); + ret = media_entity_init(&decoder->sd.entity, 1, &decoder->pad); if (ret < 0) { v4l2_err(sd, "%s decoder driver failed to register !!\n", sd->name); diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index 772a3043ae3b..a5ee2b8df429 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -1014,7 +1014,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) device->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; device->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; - error = media_entity_init(&device->sd.entity, 1, &device->pad, 0); + error = media_entity_init(&device->sd.entity, 1, &device->pad); if (error < 0) return error; #endif diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 767fe55ba08e..eabcbacfe387 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -30,32 +30,30 @@ * media_entity_init - Initialize a media entity * * @num_pads: Total number of sink and source pads. - * @extra_links: Initial estimate of the number of extra links. * @pads: Array of 'num_pads' pads. * * The total number of pads is an intrinsic property of entities known by the * entity driver, while the total number of links depends on hardware design * and is an extrinsic property unknown to the entity driver. However, in most - * use cases the entity driver can guess the number of links which can safely - * be assumed to be equal to or larger than the number of pads. + * use cases the number of links can safely be assumed to be equal to or + * larger than the number of pads. * - * For those reasons the links array can be preallocated based on the entity - * driver guess and will be reallocated later if extra links need to be - * created. + * For those reasons the links array can be preallocated based on the number + * of pads and will be reallocated later if extra links need to be created. * * This function allocates a links array with enough space to hold at least - * 'num_pads' + 'extra_links' elements. The media_entity::max_links field will - * be set to the number of allocated elements. + * 'num_pads' elements. The media_entity::max_links field will be set to the + * number of allocated elements. * * The pads array is managed by the entity driver and passed to * media_entity_init() where its pointer will be stored in the entity structure. */ int media_entity_init(struct media_entity *entity, u16 num_pads, - struct media_pad *pads, u16 extra_links) + struct media_pad *pads) { struct media_link *links; - unsigned int max_links = num_pads + extra_links; + unsigned int max_links = num_pads; unsigned int i; links = kzalloc(max_links * sizeof(links[0]), GFP_KERNEL); diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 0d549a6c8a13..8f5bee42783f 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -1800,7 +1800,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, vid_cap->wb_fmt.code = fmt->mbus_code; vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad, 0); + ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad); if (ret) goto err_free_ctx; @@ -1893,7 +1893,7 @@ int fimc_initialize_capture_subdev(struct fimc_dev *fimc) fimc->vid_cap.sd_pads[FIMC_SD_PAD_SINK_FIFO].flags = MEDIA_PAD_FL_SINK; fimc->vid_cap.sd_pads[FIMC_SD_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&sd->entity, FIMC_SD_PADS_NUM, - fimc->vid_cap.sd_pads, 0); + fimc->vid_cap.sd_pads); if (ret) return ret; diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c index 0dd22ec66694..817226d52b74 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c @@ -617,7 +617,7 @@ int fimc_isp_video_device_register(struct fimc_isp *isp, vdev->lock = &isp->video_lock; iv->pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&vdev->entity, 1, &iv->pad, 0); + ret = media_entity_init(&vdev->entity, 1, &iv->pad); if (ret < 0) return ret; diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index 5d78f5716f3b..f52eebf765c1 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c @@ -709,7 +709,7 @@ int fimc_isp_subdev_create(struct fimc_isp *isp) isp->subdev_pads[FIMC_ISP_SD_PAD_SRC_FIFO].flags = MEDIA_PAD_FL_SOURCE; isp->subdev_pads[FIMC_ISP_SD_PAD_SRC_DMA].flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&sd->entity, FIMC_ISP_SD_PADS_NUM, - isp->subdev_pads, 0); + isp->subdev_pads); if (ret) return ret; diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 639ee710499e..2ce670425cd9 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1316,7 +1316,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd) return ret; fimc->vd_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad, 0); + ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad); if (ret < 0) return ret; @@ -1431,7 +1431,7 @@ static int fimc_lite_create_capture_subdev(struct fimc_lite *fimc) fimc->subdev_pads[FLITE_SD_PAD_SOURCE_DMA].flags = MEDIA_PAD_FL_SOURCE; fimc->subdev_pads[FLITE_SD_PAD_SOURCE_ISP].flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&sd->entity, FLITE_SD_PADS_NUM, - fimc->subdev_pads, 0); + fimc->subdev_pads); if (ret) return ret; diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c index 5aa857c7b631..8ff4e6f76b84 100644 --- a/drivers/media/platform/exynos4-is/fimc-m2m.c +++ b/drivers/media/platform/exynos4-is/fimc-m2m.c @@ -739,7 +739,7 @@ int fimc_register_m2m_device(struct fimc_dev *fimc, return PTR_ERR(fimc->m2m.m2m_dev); } - ret = media_entity_init(&vfd->entity, 0, NULL, 0); + ret = media_entity_init(&vfd->entity, 0, NULL); if (ret) goto err_me; diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c index ff5dabf24694..8847797b0d0b 100644 --- a/drivers/media/platform/exynos4-is/mipi-csis.c +++ b/drivers/media/platform/exynos4-is/mipi-csis.c @@ -867,7 +867,7 @@ static int s5pcsis_probe(struct platform_device *pdev) state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK; state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&state->sd.entity, - CSIS_PADS_NUM, state->pads, 0); + CSIS_PADS_NUM, state->pads); if (ret < 0) goto e_clkdis; diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index a6a61cce43dd..3b10304b580b 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -2650,7 +2650,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) pads[CCDC_PAD_SOURCE_OF].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ccdc_media_ops; - ret = media_entity_init(me, CCDC_PADS_NUM, pads, 0); + ret = media_entity_init(me, CCDC_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index 38e6a974c5b1..e1b5f5bea541 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -1071,7 +1071,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) pads[CCP2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ccp2_media_ops; - ret = media_entity_init(me, CCP2_PADS_NUM, pads, 0); + ret = media_entity_init(me, CCP2_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index a78338d012b4..6fff92f0813a 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c @@ -1245,7 +1245,7 @@ static int csi2_init_entities(struct isp_csi2_device *csi2) | MEDIA_PAD_FL_MUST_CONNECT; me->ops = &csi2_media_ops; - ret = media_entity_init(me, CSI2_PADS_NUM, pads, 0); + ret = media_entity_init(me, CSI2_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c index 13803270d104..b440c6342ca4 100644 --- a/drivers/media/platform/omap3isp/isppreview.c +++ b/drivers/media/platform/omap3isp/isppreview.c @@ -2282,7 +2282,7 @@ static int preview_init_entities(struct isp_prev_device *prev) pads[PREV_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; me->ops = &preview_media_ops; - ret = media_entity_init(me, PREV_PADS_NUM, pads, 0); + ret = media_entity_init(me, PREV_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c index 7cfb43dc0ffd..3deb1ec4a973 100644 --- a/drivers/media/platform/omap3isp/ispresizer.c +++ b/drivers/media/platform/omap3isp/ispresizer.c @@ -1728,7 +1728,7 @@ static int resizer_init_entities(struct isp_res_device *res) pads[RESZ_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESZ_PADS_NUM, pads, 0); + ret = media_entity_init(me, RESZ_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c index 94d4c295d3d0..f7a5eee9f11d 100644 --- a/drivers/media/platform/omap3isp/ispstat.c +++ b/drivers/media/platform/omap3isp/ispstat.c @@ -1028,7 +1028,7 @@ static int isp_stat_init_entities(struct ispstat *stat, const char *name, stat->pad.flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; me->ops = NULL; - return media_entity_init(me, 1, &stat->pad, 0); + return media_entity_init(me, 1, &stat->pad); } int omap3isp_stat_init(struct ispstat *stat, const char *name, diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index ecadca3e945b..963cb9318873 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -1367,7 +1367,7 @@ int omap3isp_video_init(struct isp_video *video, const char *name) if (IS_ERR(video->alloc_ctx)) return PTR_ERR(video->alloc_ctx); - ret = media_entity_init(&video->video.entity, 1, &video->pad, 0); + ret = media_entity_init(&video->video.entity, 1, &video->pad); if (ret < 0) { vb2_dma_contig_cleanup_ctx(video->alloc_ctx); return ret; diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c index ec3abbed87d9..a87ac16273a0 100644 --- a/drivers/media/platform/s3c-camif/camif-capture.c +++ b/drivers/media/platform/s3c-camif/camif-capture.c @@ -1144,7 +1144,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx) goto err_vd_rel; vp->pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&vfd->entity, 1, &vp->pad, 0); + ret = media_entity_init(&vfd->entity, 1, &vp->pad); if (ret) goto err_vd_rel; @@ -1560,7 +1560,7 @@ int s3c_camif_create_subdev(struct camif_dev *camif) camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&sd->entity, CAMIF_SD_PADS_NUM, - camif->pads, 0); + camif->pads); if (ret) return ret; diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c index fd95a75b04f4..619942ff2058 100644 --- a/drivers/media/platform/vsp1/vsp1_entity.c +++ b/drivers/media/platform/vsp1/vsp1_entity.c @@ -220,7 +220,7 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, /* Initialize the media entity. */ return media_entity_init(&entity->subdev.entity, num_pads, - entity->pads, 0); + entity->pads); } void vsp1_entity_destroy(struct vsp1_entity *entity) diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 45eb65fa23db..fb52683b5c22 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -1193,7 +1193,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf) video->pipe.state = VSP1_PIPELINE_STOPPED; /* Initialize the media entity... */ - ret = media_entity_init(&video->video.entity, 1, &video->pad, 0); + ret = media_entity_init(&video->video.entity, 1, &video->pad); if (ret < 0) return ret; diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 722758f33924..ce2d34df12ed 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -677,7 +677,7 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, dma->pad.flags = type == V4L2_BUF_TYPE_VIDEO_CAPTURE ? MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&dma->video.entity, 1, &dma->pad, 0); + ret = media_entity_init(&dma->video.entity, 1, &dma->pad); if (ret < 0) goto error; diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c b/drivers/media/platform/xilinx/xilinx-tpg.c index 8bd7e3736019..c09ca513a9dc 100644 --- a/drivers/media/platform/xilinx/xilinx-tpg.c +++ b/drivers/media/platform/xilinx/xilinx-tpg.c @@ -838,7 +838,7 @@ static int xtpg_probe(struct platform_device *pdev) subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; subdev->entity.ops = &xtpg_media_ops; - ret = media_entity_init(&subdev->entity, xtpg->npads, xtpg->pads, 0); + ret = media_entity_init(&subdev->entity, xtpg->npads, xtpg->pads); if (ret < 0) goto error; diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 0b6e97d4fd94..57d7b9b45123 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -1887,12 +1887,12 @@ int au0828_analog_register(struct au0828_dev *dev, #if defined(CONFIG_MEDIA_CONTROLLER) dev->video_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad, 0); + ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad); if (ret < 0) pr_err("failed to initialize video media entity!\n"); dev->vbi_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad, 0); + ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); if (ret < 0) pr_err("failed to initialize vbi media entity!\n"); #endif diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index a70850fe6235..cbb28c912319 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -2177,7 +2177,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) cx231xx_vdev_init(dev, &dev->vdev, &cx231xx_video_template, "video"); #if defined(CONFIG_MEDIA_CONTROLLER) dev->video_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad, 0); + ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad); if (ret < 0) dev_err(dev->dev, "failed to initialize video media entity!\n"); #endif @@ -2204,7 +2204,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) #if defined(CONFIG_MEDIA_CONTROLLER) dev->vbi_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad, 0); + ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); if (ret < 0) dev_err(dev->dev, "failed to initialize vbi media entity!\n"); #endif diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index dc56a59ecadc..245445491516 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -89,10 +89,10 @@ static int uvc_mc_init_entity(struct uvc_entity *entity) sizeof(entity->subdev.name)); ret = media_entity_init(&entity->subdev.entity, - entity->num_pads, entity->pads, 0); + entity->num_pads, entity->pads); } else if (entity->vdev != NULL) { ret = media_entity_init(&entity->vdev->entity, - entity->num_pads, entity->pads, 0); + entity->num_pads, entity->pads); if (entity->flags & UVC_ENTITY_FLAG_DEFAULT) entity->vdev->entity.flags |= MEDIA_ENT_FL_DEFAULT; } else diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index 581e21ad6801..100b8f069640 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -699,7 +699,7 @@ register_client: t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER; t->sd.entity.name = t->name; - ret = media_entity_init(&t->sd.entity, 1, &t->pad, 0); + ret = media_entity_init(&t->sd.entity, 1, &t->pad); if (ret < 0) { tuner_err("failed to initialize media entity!\n"); kfree(t); diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c index 5bdfb8d5263a..34c489fed55e 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -651,7 +651,7 @@ struct v4l2_flash *v4l2_flash_init( sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; strlcpy(sd->name, config->dev_name, sizeof(sd->name)); - ret = media_entity_init(&sd->entity, 0, NULL, 0); + ret = media_entity_init(&sd->entity, 0, NULL); if (ret < 0) return ERR_PTR(ret); diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index c492914768ea..3badf169c419 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1840,7 +1840,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev) v4l2_ctrl_handler_setup(&ipipe->ctrls); sd->ctrl_handler = &ipipe->ctrls; - return media_entity_init(me, IPIPE_PADS_NUM, pads, 0); + return media_entity_init(me, IPIPE_PADS_NUM, pads); } /* diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index 8b230541b1d1..8fb676186898 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -1026,7 +1026,7 @@ int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif, ipipeif->output = IPIPEIF_OUTPUT_NONE; me->ops = &ipipeif_media_ops; - ret = media_entity_init(me, IPIPEIF_NUM_PADS, pads, 0); + ret = media_entity_init(me, IPIPEIF_NUM_PADS, pads); if (ret) goto fail; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index 80907b464412..b1f01adfa7c8 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -2052,7 +2052,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev) isif->input = ISIF_INPUT_NONE; isif->output = ISIF_OUTPUT_NONE; me->ops = &isif_media_ops; - status = media_entity_init(me, ISIF_PADS_NUM, pads, 0); + status = media_entity_init(me, ISIF_PADS_NUM, pads); if (status) goto isif_fail; isif->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index d892fee3f52f..7275cf3d6c20 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1910,7 +1910,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->crop_resizer.output2 = RESIZER_CROP_OUTPUT_NONE; vpfe_rsz->crop_resizer.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_CROP_PADS_NUM, pads, 0); + ret = media_entity_init(me, RESIZER_CROP_PADS_NUM, pads); if (ret) return ret; @@ -1932,7 +1932,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->resizer_a.output = RESIZER_OUTPUT_NONE; vpfe_rsz->resizer_a.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0); + ret = media_entity_init(me, RESIZER_PADS_NUM, pads); if (ret) return ret; @@ -1954,7 +1954,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->resizer_b.output = RESIZER_OUTPUT_NONE; vpfe_rsz->resizer_b.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0); + ret = media_entity_init(me, RESIZER_PADS_NUM, pads); if (ret) return ret; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index adb2bc8811ab..daae720eb82c 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -1601,7 +1601,7 @@ int vpfe_video_init(struct vpfe_video_device *video, const char *name) spin_lock_init(&video->dma_queue_lock); mutex_init(&video->lock); ret = media_entity_init(&video->video_dev.entity, - 1, &video->pad, 0); + 1, &video->pad); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index b941035139ae..86111e39a728 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -1271,7 +1271,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK; me->ops = &csi2_media_ops; - ret = media_entity_init(me, CSI2_PADS_NUM, pads, 0); + ret = media_entity_init(me, CSI2_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c index dd0abeffd893..44220765fb3a 100644 --- a/drivers/staging/media/omap4iss/iss_ipipe.c +++ b/drivers/staging/media/omap4iss/iss_ipipe.c @@ -513,7 +513,7 @@ static int ipipe_init_entities(struct iss_ipipe_device *ipipe) pads[IPIPE_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ipipe_media_ops; - ret = media_entity_init(me, IPIPE_PADS_NUM, pads, 0); + ret = media_entity_init(me, IPIPE_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index 5f9e449e7007..d031a5f22cdc 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -743,7 +743,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) pads[IPIPEIF_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ipipeif_media_ops; - ret = media_entity_init(me, IPIPEIF_PADS_NUM, pads, 0); + ret = media_entity_init(me, IPIPEIF_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index 108961e05f53..11031d9de3ab 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -785,7 +785,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer) pads[RESIZER_PAD_SOURCE_MEM].flags = MEDIA_PAD_FL_SOURCE; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0); + ret = media_entity_init(me, RESIZER_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index e9aeca08986f..194c41ef822c 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -1102,7 +1102,7 @@ int omap4iss_video_init(struct iss_video *video, const char *name) return -EINVAL; } - ret = media_entity_init(&video->video.entity, 1, &video->pad, 0); + ret = media_entity_init(&video->video.entity, 1, &video->pad); if (ret < 0) return ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 197f93799753..b92366317aee 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -134,7 +134,7 @@ struct media_entity_graph { }; int media_entity_init(struct media_entity *entity, u16 num_pads, - struct media_pad *pads, u16 extra_links); + struct media_pad *pads); void media_entity_cleanup(struct media_entity *entity); int media_entity_create_link(struct media_entity *source, u16 source_pad, -- cgit v1.2.3 From 21a0654200f24208aadd7bdc80fcdec65d2eb64b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 19 Aug 2015 06:57:59 -0300 Subject: [media] Kconfig: Re-enable Media controller support for DVB This was depending on broken because we're working at the Media Controller API, with has... issues. As this got fixed, we can re-enable it. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/Kconfig | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index 9264ea73b3be..a8518fb3bca7 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig @@ -97,7 +97,6 @@ config MEDIA_CONTROLLER config MEDIA_CONTROLLER_DVB bool "Enable Media controller for DVB (EXPERIMENTAL)" depends on MEDIA_CONTROLLER - depends on BROKEN ---help--- Enable the media controller API support for DVB. -- cgit v1.2.3 From 20fe0319de9aca71ba45e2f93c4a2a73dabde4da Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 20 Aug 2015 06:53:10 -0300 Subject: [media] au0828: Fix the logic that enables the analog demoder link This logic was broken on the original patch, likely due to a cut-and-paste mistake. Fix it. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 57d7b9b45123..a1df4eb93b14 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -642,7 +642,7 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev = dev->media_dev; - struct media_entity *entity, *source; + struct media_entity *source; struct media_link *link, *found_link = NULL; int i, ret, active_links = 0; @@ -677,7 +677,7 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev) link = &source->links[i]; sink = link->sink->entity; - if (sink == entity) + if (sink == dev->decoder) flags = MEDIA_LNK_FL_ENABLED; ret = media_entity_setup_link(link, flags); -- cgit v1.2.3 From fa762394fd85c838ade769990478bc4e01fd95e8 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 14 Aug 2015 10:42:05 -0300 Subject: [media] media: create a macro to get entity ID Instead of accessing directly entity.id, let's create a macro, as this field will be moved into a common struct later on. Acked-by: Hans Verkuil Reviewed-by: Javier Martinez Canillas Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 8 ++++---- drivers/media/media-entity.c | 8 ++++---- drivers/media/platform/vsp1/vsp1_video.c | 4 ++-- include/media/media-entity.h | 5 +++++ 4 files changed, 15 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index c55ab5029323..e429605ca2c3 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -77,8 +77,8 @@ static struct media_entity *find_entity(struct media_device *mdev, u32 id) spin_lock(&mdev->lock); media_device_for_each_entity(entity, mdev) { - if ((entity->id == id && !next) || - (entity->id > id && next)) { + if (((media_entity_id(entity) == id) && !next) || + ((media_entity_id(entity) > id) && next)) { spin_unlock(&mdev->lock); return entity; } @@ -104,7 +104,7 @@ static long media_device_enum_entities(struct media_device *mdev, if (ent == NULL) return -EINVAL; - u_ent.id = ent->id; + u_ent.id = media_entity_id(ent); if (ent->name) strlcpy(u_ent.name, ent->name, sizeof(u_ent.name)); u_ent.type = ent->type; @@ -122,7 +122,7 @@ static long media_device_enum_entities(struct media_device *mdev, static void media_device_kpad_to_upad(const struct media_pad *kpad, struct media_pad_desc *upad) { - upad->entity = kpad->entity->id; + upad->entity = media_entity_id(kpad->entity); upad->index = kpad->index; upad->flags = kpad->flags; } diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index eabcbacfe387..0342be39cae2 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -140,10 +140,10 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph, graph->stack[graph->top].entity = NULL; bitmap_zero(graph->entities, MEDIA_ENTITY_ENUM_MAX_ID); - if (WARN_ON(entity->id >= MEDIA_ENTITY_ENUM_MAX_ID)) + if (WARN_ON(media_entity_id(entity) >= MEDIA_ENTITY_ENUM_MAX_ID)) return; - __set_bit(entity->id, graph->entities); + __set_bit(media_entity_id(entity), graph->entities); stack_push(graph, entity); } EXPORT_SYMBOL_GPL(media_entity_graph_walk_start); @@ -184,11 +184,11 @@ media_entity_graph_walk_next(struct media_entity_graph *graph) /* Get the entity in the other end of the link . */ next = media_entity_other(entity, link); - if (WARN_ON(next->id >= MEDIA_ENTITY_ENUM_MAX_ID)) + if (WARN_ON(media_entity_id(next) >= MEDIA_ENTITY_ENUM_MAX_ID)) return NULL; /* Has the entity already been visited? */ - if (__test_and_set_bit(next->id, graph->entities)) { + if (__test_and_set_bit(media_entity_id(next), graph->entities)) { link_top(graph)++; continue; } diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index fb52683b5c22..516595cff408 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -323,10 +323,10 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe, break; /* Ensure the branch has no loop. */ - if (entities & (1 << entity->subdev.entity.id)) + if (entities & (1 << media_entity_id(&entity->subdev.entity))) return -EPIPE; - entities |= 1 << entity->subdev.entity.id; + entities |= 1 << media_entity_id(&entity->subdev.entity); /* UDS can't be chained. */ if (entity->type == VSP1_ENTITY_UDS) { diff --git a/include/media/media-entity.h b/include/media/media-entity.h index b92366317aee..57881758927e 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -113,6 +113,11 @@ static inline u32 media_entity_subtype(struct media_entity *entity) return entity->type & MEDIA_ENT_SUBTYPE_MASK; } +static inline u32 media_entity_id(struct media_entity *entity) +{ + return entity->id; +} + #define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 #define MEDIA_ENTITY_ENUM_MAX_ID 64 -- cgit v1.2.3 From 1302d39c4a7e31b9844638acb45c784633015cfd Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 19 Aug 2015 12:35:19 -0300 Subject: [media] staging: omap4iss: get entity ID using media_entity_id() Accessing media_entity ID should now use media_entity_id() macro to obtain the entity ID, as a next patch will remove the .id field from struct media_entity . So, get rid of it, otherwise the omap4iss driver will fail to build. Signed-off-by: Javier Martinez Canillas Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss.c | 2 +- drivers/staging/media/omap4iss/iss_video.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index e27a988540a6..5fc3675b190f 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -607,7 +607,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe, * crashed. Mark it as such, the ISS will be reset when * applications will release it. */ - iss->crashed |= 1U << subdev->entity.id; + iss->crashed |= 1U << media_entity_id(&subdev->entity); failure = -ETIMEDOUT; } } diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index 194c41ef822c..dd8ff03912a7 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -782,7 +782,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) entity = &video->video.entity; media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) - pipe->entities |= 1 << entity->id; + pipe->entities |= 1 << media_entity_id(entity); /* Verify that the currently configured format matches the output of * the connected subdev. -- cgit v1.2.3 From e0077cfdee9d249d3f85b9c7efd9e49d218093c8 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 19 Aug 2015 12:35:20 -0300 Subject: [media] omap3isp: get entity ID using media_entity_id() Accessing media_entity ID should now use media_entity_id() macro to obtain the entity ID, as a next patch will remove the .id field from struct media_entity . So, get rid of it, otherwise the omap3isp driver will fail to build. Signed-off-by: Javier Martinez Canillas Acked-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 7 +++++-- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispvideo.c | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 56e683b19a73..e08183f9d0f7 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -975,6 +975,7 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe) struct v4l2_subdev *subdev; int failure = 0; int ret; + u32 id; /* * We need to stop all the modules after CCDC first or they'll @@ -1027,8 +1028,10 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe) if (ret) { dev_info(isp->dev, "Unable to stop %s\n", subdev->name); isp->stop_failure = true; - if (subdev == &isp->isp_prev.subdev) - isp->crashed |= 1U << subdev->entity.id; + if (subdev == &isp->isp_prev.subdev) { + id = media_entity_id(&subdev->entity); + isp->crashed |= 1U << id; + } failure = -ETIMEDOUT; } } diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 3b10304b580b..d96e3be5e252 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -1608,7 +1608,7 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc) /* Wait for the CCDC to become idle. */ if (ccdc_sbl_wait_idle(ccdc, 1000)) { dev_info(isp->dev, "CCDC won't become idle!\n"); - isp->crashed |= 1U << ccdc->subdev.entity.id; + isp->crashed |= 1U << media_entity_id(&ccdc->subdev.entity); omap3isp_pipeline_cancel_stream(pipe); return 0; } diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index 963cb9318873..0e129075e99f 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -235,7 +235,7 @@ static int isp_video_get_graph_data(struct isp_video *video, while ((entity = media_entity_graph_walk_next(&graph))) { struct isp_video *__video; - pipe->entities |= 1 << entity->id; + pipe->entities |= 1 << media_entity_id(entity); if (far_end != NULL) continue; @@ -893,6 +893,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video, struct v4l2_ext_control ctrl; unsigned int i; int ret; + u32 id; /* Memory-to-memory pipelines have no external subdev. */ if (pipe->input != NULL) @@ -900,7 +901,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video, for (i = 0; i < ARRAY_SIZE(ents); i++) { /* Is the entity part of the pipeline? */ - if (!(pipe->entities & (1 << ents[i]->id))) + if (!(pipe->entities & (1 << media_entity_id(ents[i])))) continue; /* ISP entities have always sink pad == 0. Find source. */ @@ -952,7 +953,8 @@ static int isp_video_check_external_subdevs(struct isp_video *video, pipe->external_rate = ctrl.value64; - if (pipe->entities & (1 << isp->isp_ccdc.subdev.entity.id)) { + id = media_entity_id(&isp->isp_ccdc.subdev.entity); + if (pipe->entities & (1 << id)) { unsigned int rate = UINT_MAX; /* * Check that maximum allowed CCDC pixel rate isn't -- cgit v1.2.3 From ec6e4c950621a1d0db1e9b015ede4a3938fdfd18 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 25 Aug 2015 10:28:36 -0300 Subject: [media] media: add a common struct to be embed on media graph objects Due to the MC API proposed changes, we'll need to have an unique object ID for all graph objects, and have some shared fields that will be common on all media graph objects. Right now, the only common object is the object ID, but other fields will be added later on. Acked-by: Hans Verkuil Reviewed-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 32 +++++++++++++++++++++++ include/media/media-entity.h | 61 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 0342be39cae2..a76655c2ddef 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -26,6 +26,38 @@ #include #include +/** + * media_gobj_init - Initialize a graph object + * + * @mdev: Pointer to the media_device that contains the object + * @type: Type of the object + * @gobj: Pointer to the object + * + * This routine initializes the embedded struct media_gobj inside a + * media graph object. It is called automatically if media_*_create() + * calls are used. However, if the object (entity, link, pad, interface) + * is embedded on some other object, this function should be called before + * registering the object at the media controller. + */ +void media_gobj_init(struct media_device *mdev, + enum media_gobj_type type, + struct media_gobj *gobj) +{ + /* For now, nothing to do */ +} + +/** + * media_gobj_remove - Stop using a graph object on a media device + * + * @graph_obj: Pointer to the object + * + * This should be called at media_device_unregister_*() routines + */ +void media_gobj_remove(struct media_gobj *gobj) +{ + /* For now, nothing to do */ +} + /** * media_entity_init - Initialize a media entity * diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 57881758927e..96626356b8f3 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -28,6 +28,39 @@ #include #include +/* Enums used internally at the media controller to represent graphs */ + +/** + * enum media_gobj_type - type of a graph object + * + */ +enum media_gobj_type { + /* FIXME: add the types here, as we embed media_gobj */ + MEDIA_GRAPH_NONE +}; + +#define MEDIA_BITS_PER_TYPE 8 +#define MEDIA_BITS_PER_LOCAL_ID (32 - MEDIA_BITS_PER_TYPE) +#define MEDIA_LOCAL_ID_MASK GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 0) + +/* Structs to represent the objects that belong to a media graph */ + +/** + * struct media_gobj - Define a graph object. + * + * @id: Non-zero object ID identifier. The ID should be unique + * inside a media_device, as it is composed by + * MEDIA_BITS_PER_TYPE to store the type plus + * MEDIA_BITS_PER_LOCAL_ID to store a per-type ID + * (called as "local ID"). + * + * All objects on the media graph should have this struct embedded + */ +struct media_gobj { + u32 id; +}; + + struct media_pipeline { }; @@ -118,6 +151,26 @@ static inline u32 media_entity_id(struct media_entity *entity) return entity->id; } +static inline enum media_gobj_type media_type(struct media_gobj *gobj) +{ + return gobj->id >> MEDIA_BITS_PER_LOCAL_ID; +} + +static inline u32 media_localid(struct media_gobj *gobj) +{ + return gobj->id & MEDIA_LOCAL_ID_MASK; +} + +static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id) +{ + u32 id; + + id = type << MEDIA_BITS_PER_LOCAL_ID; + id |= local_id & MEDIA_LOCAL_ID_MASK; + + return id; +} + #define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 #define MEDIA_ENTITY_ENUM_MAX_ID 64 @@ -138,6 +191,14 @@ struct media_entity_graph { int top; }; +#define gobj_to_entity(gobj) \ + container_of(gobj, struct media_entity, graph_obj) + +void media_gobj_init(struct media_device *mdev, + enum media_gobj_type type, + struct media_gobj *gobj); +void media_gobj_remove(struct media_gobj *gobj); + int media_entity_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads); void media_entity_cleanup(struct media_entity *entity); -- cgit v1.2.3 From bfab2aacccfc144e2cceccb71ec89f1eff1b8c51 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 14 Aug 2015 12:47:48 -0300 Subject: [media] media: use media_gobj inside entities As entities are graph objects, let's embed media_gobj on it. That ensures an unique ID for entities that can be global along the entire media controller. For now, we'll keep the already existing entity ID. Such field need to be dropped at some point, but for now, let's not do this, to avoid needing to review all drivers and the userspace apps. Acked-by: Hans Verkuil Tested-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 8 +++----- drivers/media/media-entity.c | 7 ++++++- include/media/media-device.h | 3 ++- include/media/media-entity.h | 9 ++++----- 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index e429605ca2c3..81d6a130efef 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -379,7 +379,6 @@ int __must_check __media_device_register(struct media_device *mdev, if (WARN_ON(mdev->dev == NULL || mdev->model[0] == 0)) return -EINVAL; - mdev->entity_id = 1; INIT_LIST_HEAD(&mdev->entities); spin_lock_init(&mdev->lock); mutex_init(&mdev->graph_mutex); @@ -433,10 +432,8 @@ int __must_check media_device_register_entity(struct media_device *mdev, entity->parent = mdev; spin_lock(&mdev->lock); - if (entity->id == 0) - entity->id = mdev->entity_id++; - else - mdev->entity_id = max(entity->id + 1, mdev->entity_id); + /* Initialize media_gobj embedded at the entity */ + media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); list_add_tail(&entity->list, &mdev->entities); spin_unlock(&mdev->lock); @@ -459,6 +456,7 @@ void media_device_unregister_entity(struct media_entity *entity) return; spin_lock(&mdev->lock); + media_gobj_remove(&entity->graph_obj); list_del(&entity->list); spin_unlock(&mdev->lock); entity->parent = NULL; diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index a76655c2ddef..9f6f056eaeb0 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -43,7 +43,12 @@ void media_gobj_init(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj) { - /* For now, nothing to do */ + /* Create a per-type unique object ID */ + switch (type) { + case MEDIA_GRAPH_ENTITY: + gobj->id = media_gobj_gen_id(type, ++mdev->entity_id); + break; + } } /** diff --git a/include/media/media-device.h b/include/media/media-device.h index a44f18fdf321..f6deef6e5820 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -41,7 +41,7 @@ struct device; * @bus_info: Unique and stable device location identifier * @hw_revision: Hardware device revision * @driver_version: Device driver version - * @entity_id: ID of the next entity to be registered + * @entity_id: Unique ID used on the last entity registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -69,6 +69,7 @@ struct media_device { u32 driver_version; u32 entity_id; + struct list_head entities; /* Protects the entities list */ diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 96626356b8f3..4faa4d830da4 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -33,10 +33,10 @@ /** * enum media_gobj_type - type of a graph object * + * @MEDIA_GRAPH_ENTITY: Identify a media entity */ enum media_gobj_type { - /* FIXME: add the types here, as we embed media_gobj */ - MEDIA_GRAPH_NONE + MEDIA_GRAPH_ENTITY, }; #define MEDIA_BITS_PER_TYPE 8 @@ -94,10 +94,9 @@ struct media_entity_operations { }; struct media_entity { + struct media_gobj graph_obj; struct list_head list; struct media_device *parent; /* Media device this entity belongs to*/ - u32 id; /* Entity ID, unique in the parent media - * device context */ const char *name; /* Entity name */ u32 type; /* Entity type (MEDIA_ENT_T_*) */ u32 revision; /* Entity revision, driver specific */ @@ -148,7 +147,7 @@ static inline u32 media_entity_subtype(struct media_entity *entity) static inline u32 media_entity_id(struct media_entity *entity) { - return entity->id; + return entity->graph_obj.id; } static inline enum media_gobj_type media_type(struct media_gobj *gobj) -- cgit v1.2.3 From 18710dc67a433ed2c3ecaaffefd8e34502e53262 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 14 Aug 2015 12:50:08 -0300 Subject: [media] media: use media_gobj inside pads PADs also need unique object IDs that won't conflict with the entity object IDs. The pad objects are currently created via media_entity_init() and, once created, never change. While this will likely change in the future in order to support dynamic changes, for now we'll keep PADs as arrays and initialize the media_gobj embedded structs when registering the entity. Acked-by: Hans Verkuil Tested-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 11 +++++++++++ drivers/media/media-entity.c | 3 +++ include/media/media-device.h | 2 ++ include/media/media-entity.h | 3 +++ 4 files changed, 19 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 81d6a130efef..3bdda16584fe 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -427,6 +427,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister); int __must_check media_device_register_entity(struct media_device *mdev, struct media_entity *entity) { + int i; + /* Warn if we apparently re-register an entity */ WARN_ON(entity->parent != NULL); entity->parent = mdev; @@ -435,6 +437,12 @@ int __must_check media_device_register_entity(struct media_device *mdev, /* Initialize media_gobj embedded at the entity */ media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); list_add_tail(&entity->list, &mdev->entities); + + /* Initialize objects at the pads */ + for (i = 0; i < entity->num_pads; i++) + media_gobj_init(mdev, MEDIA_GRAPH_PAD, + &entity->pads[i].graph_obj); + spin_unlock(&mdev->lock); return 0; @@ -450,12 +458,15 @@ EXPORT_SYMBOL_GPL(media_device_register_entity); */ void media_device_unregister_entity(struct media_entity *entity) { + int i; struct media_device *mdev = entity->parent; if (mdev == NULL) return; spin_lock(&mdev->lock); + for (i = 0; i < entity->num_pads; i++) + media_gobj_remove(&entity->pads[i].graph_obj); media_gobj_remove(&entity->graph_obj); list_del(&entity->list); spin_unlock(&mdev->lock); diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 9f6f056eaeb0..2d94c859057b 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -48,6 +48,9 @@ void media_gobj_init(struct media_device *mdev, case MEDIA_GRAPH_ENTITY: gobj->id = media_gobj_gen_id(type, ++mdev->entity_id); break; + case MEDIA_GRAPH_PAD: + gobj->id = media_gobj_gen_id(type, ++mdev->pad_id); + break; } } diff --git a/include/media/media-device.h b/include/media/media-device.h index f6deef6e5820..9493721f630e 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -42,6 +42,7 @@ struct device; * @hw_revision: Hardware device revision * @driver_version: Device driver version * @entity_id: Unique ID used on the last entity registered + * @pad_id: Unique ID used on the last pad registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -69,6 +70,7 @@ struct media_device { u32 driver_version; u32 entity_id; + u32 pad_id; struct list_head entities; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 4faa4d830da4..b91c78d34f79 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -34,9 +34,11 @@ * enum media_gobj_type - type of a graph object * * @MEDIA_GRAPH_ENTITY: Identify a media entity + * @MEDIA_GRAPH_PAD: Identify a media pad */ enum media_gobj_type { MEDIA_GRAPH_ENTITY, + MEDIA_GRAPH_PAD, }; #define MEDIA_BITS_PER_TYPE 8 @@ -72,6 +74,7 @@ struct media_link { }; struct media_pad { + struct media_gobj graph_obj; struct media_entity *entity; /* Entity this pad belongs to */ u16 index; /* Pad index in the entity pads array */ unsigned long flags; /* Pad flags (MEDIA_PAD_FL_*) */ -- cgit v1.2.3 From 6b6a42780597028135f82c96e42c6d2bcd83fbae Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 14 Aug 2015 12:54:36 -0300 Subject: [media] media: use media_gobj inside links Just like entities and pads, links also need to have unique Object IDs along a given media controller. So, let's add a media_gobj inside it and initialize the object then a new link is created. Acked-by: Hans Verkuil Tested-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 9 +++++++++ drivers/media/media-entity.c | 9 +++++++++ include/media/media-device.h | 2 ++ include/media/media-entity.h | 3 +++ 4 files changed, 23 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 3bdda16584fe..065f6f08da37 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -438,6 +438,13 @@ int __must_check media_device_register_entity(struct media_device *mdev, media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); list_add_tail(&entity->list, &mdev->entities); + /* + * Initialize objects at the links + * in the case where links got created before entity register + */ + for (i = 0; i < entity->num_links; i++) + media_gobj_init(mdev, MEDIA_GRAPH_LINK, + &entity->links[i].graph_obj); /* Initialize objects at the pads */ for (i = 0; i < entity->num_pads; i++) media_gobj_init(mdev, MEDIA_GRAPH_PAD, @@ -465,6 +472,8 @@ void media_device_unregister_entity(struct media_entity *entity) return; spin_lock(&mdev->lock); + for (i = 0; i < entity->num_links; i++) + media_gobj_remove(&entity->links[i].graph_obj); for (i = 0; i < entity->num_pads; i++) media_gobj_remove(&entity->pads[i].graph_obj); media_gobj_remove(&entity->graph_obj); diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 2d94c859057b..63fd293a3fb8 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -51,6 +51,9 @@ void media_gobj_init(struct media_device *mdev, case MEDIA_GRAPH_PAD: gobj->id = media_gobj_gen_id(type, ++mdev->pad_id); break; + case MEDIA_GRAPH_LINK: + gobj->id = media_gobj_gen_id(type, ++mdev->link_id); + break; } } @@ -491,6 +494,9 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, link->sink = &sink->pads[sink_pad]; link->flags = flags; + /* Initialize graph object embedded at the new link */ + media_gobj_init(source->parent, MEDIA_GRAPH_LINK, &link->graph_obj); + /* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ @@ -504,6 +510,9 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; + /* Initialize graph object embedded at the new link */ + media_gobj_init(sink->parent, MEDIA_GRAPH_LINK, &backlink->graph_obj); + link->reverse = backlink; backlink->reverse = link; diff --git a/include/media/media-device.h b/include/media/media-device.h index 9493721f630e..05414e351f8e 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -43,6 +43,7 @@ struct device; * @driver_version: Device driver version * @entity_id: Unique ID used on the last entity registered * @pad_id: Unique ID used on the last pad registered + * @link_id: Unique ID used on the last link registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -71,6 +72,7 @@ struct media_device { u32 entity_id; u32 pad_id; + u32 link_id; struct list_head entities; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index b91c78d34f79..bf93c90e9218 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -35,10 +35,12 @@ * * @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad + * @MEDIA_GRAPH_LINK: Identify a media link */ enum media_gobj_type { MEDIA_GRAPH_ENTITY, MEDIA_GRAPH_PAD, + MEDIA_GRAPH_LINK, }; #define MEDIA_BITS_PER_TYPE 8 @@ -67,6 +69,7 @@ struct media_pipeline { }; struct media_link { + struct media_gobj graph_obj; struct media_pad *source; /* Source pad */ struct media_pad *sink; /* Sink pad */ struct media_link *reverse; /* Link in the reverse direction */ -- cgit v1.2.3 From 8f5a3188fbd13fdd5525fc6177cb19bf3996ee99 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 13 Aug 2015 15:22:24 -0300 Subject: [media] media: add messages when media device gets (un)registered We can only free the media device after being sure that no graph object is used. In order to help tracking it, let's add debug messages that will print when the media controller gets registered or unregistered. Acked-by: Hans Verkuil Reviewed-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 065f6f08da37..0f3844470147 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -359,6 +359,7 @@ static DEVICE_ATTR(model, S_IRUGO, show_model, NULL); static void media_device_release(struct media_devnode *mdev) { + dev_dbg(mdev->parent, "Media device released\n"); } /** @@ -397,6 +398,8 @@ int __must_check __media_device_register(struct media_device *mdev, return ret; } + dev_dbg(mdev->dev, "Media device registered\n"); + return 0; } EXPORT_SYMBOL_GPL(__media_device_register); @@ -416,6 +419,8 @@ void media_device_unregister(struct media_device *mdev) device_remove_file(&mdev->devnode.dev, &dev_attr_model); media_devnode_unregister(&mdev->devnode); + + dev_dbg(mdev->dev, "Media device unregistered\n"); } EXPORT_SYMBOL_GPL(media_device_unregister); -- cgit v1.2.3 From 39a956c4147e4f696f729916f677673e9a9dc7ab Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 13 Aug 2015 14:42:42 -0300 Subject: [media] media: add a debug message to warn about gobj creation/removal It helps to check if the media controller is doing the right thing with the object creation and removal. No extra code/data will be produced if DEBUG or CONFIG_DYNAMIC_DEBUG is not enabled. Acked-by: Hans Verkuil Reviewed-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 68 +++++++++++++++++++++++++++++++++++++++++++- include/media/media-entity.h | 7 +++++ 2 files changed, 74 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 63fd293a3fb8..f5b4822a324f 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -26,6 +26,69 @@ #include #include +/** + * dev_dbg_obj - Prints in debug mode a change on some object + * + * @event_name: Name of the event to report. Could be __func__ + * @gobj: Pointer to the object + * + * Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it + * won't produce any code. + */ +static inline const char *gobj_type(enum media_gobj_type type) +{ + switch (type) { + case MEDIA_GRAPH_ENTITY: + return "entity"; + case MEDIA_GRAPH_PAD: + return "pad"; + case MEDIA_GRAPH_LINK: + return "link"; + default: + return "unknown"; + } +} + +static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) +{ +#if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG) + switch (media_type(gobj)) { + case MEDIA_GRAPH_ENTITY: + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x entity#%d: '%s'\n", + event_name, gobj->id, media_localid(gobj), + gobj_to_entity(gobj)->name); + break; + case MEDIA_GRAPH_LINK: + { + struct media_link *link = gobj_to_link(gobj); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x link#%d: '%s' %s#%d ==> '%s' %s#%d\n", + event_name, gobj->id, media_localid(gobj), + + link->source->entity->name, + gobj_type(media_type(&link->source->graph_obj)), + media_localid(&link->source->graph_obj), + + link->sink->entity->name, + gobj_type(media_type(&link->sink->graph_obj)), + media_localid(&link->sink->graph_obj)); + break; + } + case MEDIA_GRAPH_PAD: + { + struct media_pad *pad = gobj_to_pad(gobj); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x pad#%d: '%s':%d\n", + event_name, gobj->id, media_localid(gobj), + pad->entity->name, pad->index); + } + } +#endif +} + /** * media_gobj_init - Initialize a graph object * @@ -43,6 +106,8 @@ void media_gobj_init(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj) { + gobj->mdev = mdev; + /* Create a per-type unique object ID */ switch (type) { case MEDIA_GRAPH_ENTITY: @@ -55,6 +120,7 @@ void media_gobj_init(struct media_device *mdev, gobj->id = media_gobj_gen_id(type, ++mdev->link_id); break; } + dev_dbg_obj(__func__, gobj); } /** @@ -66,7 +132,7 @@ void media_gobj_init(struct media_device *mdev, */ void media_gobj_remove(struct media_gobj *gobj) { - /* For now, nothing to do */ + dev_dbg_obj(__func__, gobj); } /** diff --git a/include/media/media-entity.h b/include/media/media-entity.h index bf93c90e9218..96a5d3e6f6f4 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -61,6 +61,7 @@ enum media_gobj_type { * All objects on the media graph should have this struct embedded */ struct media_gobj { + struct media_device *mdev; u32 id; }; @@ -199,6 +200,12 @@ struct media_entity_graph { #define gobj_to_entity(gobj) \ container_of(gobj, struct media_entity, graph_obj) +#define gobj_to_pad(gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_link(gobj) \ + container_of(gobj, struct media_link, graph_obj) + void media_gobj_init(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj); -- cgit v1.2.3 From 8df00a15817e3a252510ac914870214859325189 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 7 Aug 2015 08:14:38 -0300 Subject: [media] media: rename the function that create pad links With the new API, a link can be either between two PADs or between an interface and an entity. So, we need to use a better name for the function that create links between two pads. So, rename the such function to media_create_pad_link(). No functional changes. This patch was created via this shell script: for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,media_entity_create_link,media_create_pad_link,g <$i >a && mv a $i; done Acked-by: Hans Verkuil Tested-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- Documentation/media-framework.txt | 2 +- drivers/media/dvb-core/dvbdev.c | 8 ++++---- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 ++-- drivers/media/i2c/s5k5baf.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 4 ++-- drivers/media/media-entity.c | 4 ++-- drivers/media/platform/exynos4-is/media-dev.c | 16 ++++++++-------- drivers/media/platform/omap3isp/isp.c | 18 +++++++++--------- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/isppreview.c | 4 ++-- drivers/media/platform/omap3isp/ispresizer.c | 4 ++-- drivers/media/platform/s3c-camif/camif-core.c | 4 ++-- drivers/media/platform/vsp1/vsp1_drv.c | 4 ++-- drivers/media/platform/vsp1/vsp1_rpf.c | 2 +- drivers/media/platform/vsp1/vsp1_wpf.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 4 ++-- drivers/media/usb/au0828/au0828-core.c | 6 +++--- drivers/media/usb/cx231xx/cx231xx-cards.c | 6 +++--- drivers/media/usb/uvc/uvc_entity.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 8 ++++---- drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 10 +++++----- drivers/staging/media/omap4iss/iss.c | 12 ++++++------ drivers/staging/media/omap4iss/iss_csi2.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 2 +- drivers/staging/media/omap4iss/iss_resizer.c | 2 +- include/media/media-entity.h | 2 +- 30 files changed, 72 insertions(+), 72 deletions(-) (limited to 'drivers') diff --git a/Documentation/media-framework.txt b/Documentation/media-framework.txt index 6903b2503577..b424de6c3bb3 100644 --- a/Documentation/media-framework.txt +++ b/Documentation/media-framework.txt @@ -199,7 +199,7 @@ pre-allocated and grows dynamically as needed. Drivers create links by calling - media_entity_create_link(struct media_entity *source, u16 source_pad, + media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags); diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 2fdcbb5f000a..65f59f2124b4 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -412,16 +412,16 @@ void dvb_create_media_graph(struct dvb_adapter *adap) } if (tuner && fe) - media_entity_create_link(tuner, 0, fe, 0, 0); + media_create_pad_link(tuner, 0, fe, 0, 0); if (fe && demux) - media_entity_create_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED); + media_create_pad_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED); if (demux && dvr) - media_entity_create_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED); + media_create_pad_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED); if (demux && ca) - media_entity_create_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED); + media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED); } EXPORT_SYMBOL_GPL(dvb_create_media_graph); #endif diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index 381f903831f4..45c823b68f48 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1482,11 +1482,11 @@ static int s5c73m3_oif_registered(struct v4l2_subdev *sd) return ret; } - ret = media_entity_create_link(&state->sensor_sd.entity, + ret = media_create_pad_link(&state->sensor_sd.entity, S5C73M3_ISP_PAD, &state->oif_sd.entity, OIF_ISP_PAD, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); - ret = media_entity_create_link(&state->sensor_sd.entity, + ret = media_create_pad_link(&state->sensor_sd.entity, S5C73M3_JPEG_PAD, &state->oif_sd.entity, OIF_JPEG_PAD, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 30a9ca62e034..d3bff30bcb6f 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -1756,7 +1756,7 @@ static int s5k5baf_registered(struct v4l2_subdev *sd) v4l2_err(sd, "failed to register subdev %s\n", state->cis_sd.name); else - ret = media_entity_create_link(&state->cis_sd.entity, PAD_CIS, + ret = media_create_pad_link(&state->cis_sd.entity, PAD_CIS, &state->sd.entity, PAD_CIS, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 7ed0538ea8db..cf0cd507c2d0 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2495,7 +2495,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) return rval; } - rval = media_entity_create_link(&this->sd.entity, + rval = media_create_pad_link(&this->sd.entity, this->source_pad, &last->sd.entity, last->sink_pad, @@ -2503,7 +2503,7 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) MEDIA_LNK_FL_IMMUTABLE); if (rval) { dev_err(&client->dev, - "media_entity_create_link failed\n"); + "media_create_pad_link failed\n"); return rval; } diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index f5b4822a324f..e840da0325b7 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -542,7 +542,7 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) } int -media_entity_create_link(struct media_entity *source, u16 source_pad, +media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags) { struct media_link *link; @@ -586,7 +586,7 @@ media_entity_create_link(struct media_entity *source, u16 source_pad, return 0; } -EXPORT_SYMBOL_GPL(media_entity_create_link); +EXPORT_SYMBOL_GPL(media_create_pad_link); void __media_entity_remove_links(struct media_entity *entity) { diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 9481ce3201a2..4c524a02c59c 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -729,7 +729,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, flags = ((1 << i) & link_mask) ? MEDIA_LNK_FL_ENABLED : 0; sink = &fmd->fimc[i]->vid_cap.subdev.entity; - ret = media_entity_create_link(source, pad, sink, + ret = media_create_pad_link(source, pad, sink, FIMC_SD_PAD_SINK_CAM, flags); if (ret) return ret; @@ -749,7 +749,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, continue; sink = &fmd->fimc_lite[i]->subdev.entity; - ret = media_entity_create_link(source, pad, sink, + ret = media_create_pad_link(source, pad, sink, FLITE_SD_PAD_SINK, 0); if (ret) return ret; @@ -781,13 +781,13 @@ static int __fimc_md_create_flite_source_links(struct fimc_md *fmd) source = &fimc->subdev.entity; sink = &fimc->ve.vdev.entity; /* FIMC-LITE's subdev and video node */ - ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_DMA, + ret = media_create_pad_link(source, FLITE_SD_PAD_SOURCE_DMA, sink, 0, 0); if (ret) break; /* Link from FIMC-LITE to IS-ISP subdev */ sink = &fmd->fimc_is->isp.subdev.entity; - ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_ISP, + ret = media_create_pad_link(source, FLITE_SD_PAD_SOURCE_ISP, sink, 0, 0); if (ret) break; @@ -811,7 +811,7 @@ static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd) /* Link from FIMC-IS-ISP subdev to FIMC */ sink = &fmd->fimc[i]->vid_cap.subdev.entity; - ret = media_entity_create_link(source, FIMC_ISP_SD_PAD_SRC_FIFO, + ret = media_create_pad_link(source, FIMC_ISP_SD_PAD_SRC_FIFO, sink, FIMC_SD_PAD_SINK_FIFO, 0); if (ret) return ret; @@ -824,7 +824,7 @@ static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd) if (sink->num_pads == 0) return 0; - return media_entity_create_link(source, FIMC_ISP_SD_PAD_SRC_DMA, + return media_create_pad_link(source, FIMC_ISP_SD_PAD_SRC_DMA, sink, 0, 0); } @@ -873,7 +873,7 @@ static int fimc_md_create_links(struct fimc_md *fmd) return -EINVAL; pad = sensor->entity.num_pads - 1; - ret = media_entity_create_link(&sensor->entity, pad, + ret = media_create_pad_link(&sensor->entity, pad, &csis->entity, CSIS_PAD_SINK, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); @@ -927,7 +927,7 @@ static int fimc_md_create_links(struct fimc_md *fmd) source = &fmd->fimc[i]->vid_cap.subdev.entity; sink = &fmd->fimc[i]->vid_cap.ve.vdev.entity; - ret = media_entity_create_link(source, FIMC_SD_PAD_SOURCE, + ret = media_create_pad_link(source, FIMC_SD_PAD_SOURCE, sink, 0, flags); if (ret) break; diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index e08183f9d0f7..6351f35b0a65 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -1865,7 +1865,7 @@ static int isp_link_entity( return -EINVAL; } - return media_entity_create_link(entity, i, input, pad, flags); + return media_create_pad_link(entity, i, input, pad, flags); } static int isp_register_entities(struct isp_device *isp) @@ -2004,51 +2004,51 @@ static int isp_initialize_modules(struct isp_device *isp) } /* Connect the submodules. */ - ret = media_entity_create_link( + ret = media_create_pad_link( &isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE, &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &isp->isp_ccp2.subdev.entity, CCP2_PAD_SOURCE, &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, &isp->isp_prev.subdev.entity, PREV_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF, &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &isp->isp_prev.subdev.entity, PREV_PAD_SOURCE, &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, &isp->isp_aewb.subdev.entity, 0, MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, &isp->isp_af.subdev.entity, 0, MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, &isp->isp_hist.subdev.entity, 0, MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index d96e3be5e252..27555e4f4aa8 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -2667,7 +2667,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) goto error_video; /* Connect the CCDC subdev to the video node. */ - ret = media_entity_create_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF, + ret = media_create_pad_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF, &ccdc->video_out.video.entity, 0, 0); if (ret < 0) goto error_link; diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index e1b5f5bea541..b215eb5049d6 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -1100,7 +1100,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) goto error_video; /* Connect the video node to the ccp2 subdev. */ - ret = media_entity_create_link(&ccp2->video_in.video.entity, 0, + ret = media_create_pad_link(&ccp2->video_in.video.entity, 0, &ccp2->subdev.entity, CCP2_PAD_SINK, 0); if (ret < 0) goto error_link; diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index 6fff92f0813a..fcefc1e74881 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c @@ -1265,7 +1265,7 @@ static int csi2_init_entities(struct isp_csi2_device *csi2) goto error_video; /* Connect the CSI2 subdev to the video node. */ - ret = media_entity_create_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, + ret = media_create_pad_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, &csi2->video_out.video.entity, 0, 0); if (ret < 0) goto error_link; diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c index b440c6342ca4..ad38d20c7770 100644 --- a/drivers/media/platform/omap3isp/isppreview.c +++ b/drivers/media/platform/omap3isp/isppreview.c @@ -2312,12 +2312,12 @@ static int preview_init_entities(struct isp_prev_device *prev) goto error_video_out; /* Connect the video nodes to the previewer subdev. */ - ret = media_entity_create_link(&prev->video_in.video.entity, 0, + ret = media_create_pad_link(&prev->video_in.video.entity, 0, &prev->subdev.entity, PREV_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link(&prev->subdev.entity, PREV_PAD_SOURCE, + ret = media_create_pad_link(&prev->subdev.entity, PREV_PAD_SOURCE, &prev->video_out.video.entity, 0, 0); if (ret < 0) goto error_link; diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c index 3deb1ec4a973..b48ad4d4b834 100644 --- a/drivers/media/platform/omap3isp/ispresizer.c +++ b/drivers/media/platform/omap3isp/ispresizer.c @@ -1756,12 +1756,12 @@ static int resizer_init_entities(struct isp_res_device *res) res->video_out.video.entity.flags |= MEDIA_ENT_FL_DEFAULT; /* Connect the video nodes to the resizer subdev. */ - ret = media_entity_create_link(&res->video_in.video.entity, 0, + ret = media_create_pad_link(&res->video_in.video.entity, 0, &res->subdev.entity, RESZ_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link(&res->subdev.entity, RESZ_PAD_SOURCE, + ret = media_create_pad_link(&res->subdev.entity, RESZ_PAD_SOURCE, &res->video_out.video.entity, 0, 0); if (ret < 0) goto error_link; diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c index 1ba9bb08f5da..8649d4c0e90d 100644 --- a/drivers/media/platform/s3c-camif/camif-core.c +++ b/drivers/media/platform/s3c-camif/camif-core.c @@ -263,7 +263,7 @@ static int camif_create_media_links(struct camif_dev *camif) { int i, ret; - ret = media_entity_create_link(&camif->sensor.sd->entity, 0, + ret = media_create_pad_link(&camif->sensor.sd->entity, 0, &camif->subdev.entity, CAMIF_SD_PAD_SINK, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); @@ -271,7 +271,7 @@ static int camif_create_media_links(struct camif_dev *camif) return ret; for (i = 1; i < CAMIF_SD_PADS_NUM && !ret; i++) { - ret = media_entity_create_link(&camif->subdev.entity, i, + ret = media_create_pad_link(&camif->subdev.entity, i, &camif->vp[i - 1].vdev.entity, 0, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 4e61886384e3..9cd94a76a9ed 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -101,7 +101,7 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink) if (!(entity->pads[pad].flags & MEDIA_PAD_FL_SINK)) continue; - ret = media_entity_create_link(&source->subdev.entity, + ret = media_create_pad_link(&source->subdev.entity, source->source_pad, entity, pad, flags); if (ret < 0) @@ -262,7 +262,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) } if (vsp1->pdata.features & VSP1_HAS_LIF) { - ret = media_entity_create_link( + ret = media_create_pad_link( &vsp1->wpf[0]->entity.subdev.entity, RWPF_PAD_SOURCE, &vsp1->lif->entity.subdev.entity, LIF_PAD_SINK, 0); if (ret < 0) diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c index cd5248a9a271..1bd51d22ff04 100644 --- a/drivers/media/platform/vsp1/vsp1_rpf.c +++ b/drivers/media/platform/vsp1/vsp1_rpf.c @@ -278,7 +278,7 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) rpf->entity.video = video; /* Connect the video device to the RPF. */ - ret = media_entity_create_link(&rpf->video.video.entity, 0, + ret = media_create_pad_link(&rpf->video.video.entity, 0, &rpf->entity.subdev.entity, RWPF_PAD_SINK, MEDIA_LNK_FL_ENABLED | diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c index 95b62f4f77e7..ca19c534dac6 100644 --- a/drivers/media/platform/vsp1/vsp1_wpf.c +++ b/drivers/media/platform/vsp1/vsp1_wpf.c @@ -284,7 +284,7 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) if (!(vsp1->pdata.features & VSP1_HAS_LIF) || index != 0) flags |= MEDIA_LNK_FL_IMMUTABLE; - ret = media_entity_create_link(&wpf->entity.subdev.entity, + ret = media_create_pad_link(&wpf->entity.subdev.entity, RWPF_PAD_SOURCE, &wpf->video.video.entity, 0, flags); if (ret < 0) diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index b9bf24fefa5a..2352f7e5a6a3 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -156,7 +156,7 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, local->name, local_pad->index, remote->name, remote_pad->index); - ret = media_entity_create_link(local, local_pad->index, + ret = media_create_pad_link(local, local_pad->index, remote, remote_pad->index, link_flags); if (ret < 0) { @@ -270,7 +270,7 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) source->name, source_pad->index, sink->name, sink_pad->index); - ret = media_entity_create_link(source, source_pad->index, + ret = media_create_pad_link(source, source_pad->index, sink, sink_pad->index, link_flags); if (ret < 0) { diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 0378a2c99ebb..a55eb524ea21 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -260,13 +260,13 @@ static void au0828_create_media_graph(struct au0828_dev *dev) return; if (tuner) - media_entity_create_link(tuner, 0, decoder, 0, + media_create_pad_link(tuner, 0, decoder, 0, MEDIA_LNK_FL_ENABLED); if (dev->vdev.entity.links) - media_entity_create_link(decoder, 1, &dev->vdev.entity, 0, + media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, MEDIA_LNK_FL_ENABLED); if (dev->vbi_dev.entity.links) - media_entity_create_link(decoder, 2, &dev->vbi_dev.entity, 0, + media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, MEDIA_LNK_FL_ENABLED); #endif } diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 89dc695c696e..695f0c092c79 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1264,11 +1264,11 @@ static void cx231xx_create_media_graph(struct cx231xx *dev) return; if (tuner) - media_entity_create_link(tuner, 0, decoder, 0, + media_create_pad_link(tuner, 0, decoder, 0, MEDIA_LNK_FL_ENABLED); - media_entity_create_link(decoder, 1, &dev->vdev.entity, 0, + media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, MEDIA_LNK_FL_ENABLED); - media_entity_create_link(decoder, 2, &dev->vbi_dev.entity, 0, + media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, MEDIA_LNK_FL_ENABLED); #endif } diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 245445491516..429e428ccd93 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -56,7 +56,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain, continue; remote_pad = remote->num_pads - 1; - ret = media_entity_create_link(source, remote_pad, + ret = media_create_pad_link(source, remote_pad, sink, i, flags); if (ret < 0) return ret; diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index 8fb676186898..d96bdaaae50e 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -971,7 +971,7 @@ vpfe_ipipeif_register_entities(struct vpfe_ipipeif_device *ipipeif, ipipeif->video_in.vpfe_dev = vpfe_dev; flags = 0; - ret = media_entity_create_link(&ipipeif->video_in.video_dev.entity, 0, + ret = media_create_pad_link(&ipipeif->video_in.video_dev.entity, 0, &ipipeif->subdev.entity, 0, flags); if (ret < 0) goto fail; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index b1f01adfa7c8..df77288b0ec0 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -1817,7 +1817,7 @@ int vpfe_isif_register_entities(struct vpfe_isif_device *isif, isif->video_out.vpfe_dev = vpfe_dev; flags = 0; /* connect isif to video node */ - ret = media_entity_create_link(&isif->subdev.entity, 1, + ret = media_create_pad_link(&isif->subdev.entity, 1, &isif->video_out.video_dev.entity, 0, flags); if (ret < 0) diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 7275cf3d6c20..50c8725c5aa6 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1826,27 +1826,27 @@ int vpfe_resizer_register_entities(struct vpfe_resizer_device *resizer, resizer->resizer_b.video_out.vpfe_dev = vpfe_dev; /* create link between Resizer Crop----> Resizer A*/ - ret = media_entity_create_link(&resizer->crop_resizer.subdev.entity, 1, + ret = media_create_pad_link(&resizer->crop_resizer.subdev.entity, 1, &resizer->resizer_a.subdev.entity, 0, flags); if (ret < 0) goto out_create_link; /* create link between Resizer Crop----> Resizer B*/ - ret = media_entity_create_link(&resizer->crop_resizer.subdev.entity, 2, + ret = media_create_pad_link(&resizer->crop_resizer.subdev.entity, 2, &resizer->resizer_b.subdev.entity, 0, flags); if (ret < 0) goto out_create_link; /* create link between Resizer A ----> video out */ - ret = media_entity_create_link(&resizer->resizer_a.subdev.entity, 1, + ret = media_create_pad_link(&resizer->resizer_a.subdev.entity, 1, &resizer->resizer_a.video_out.video_dev.entity, 0, flags); if (ret < 0) goto out_create_link; /* create link between Resizer B ----> video out */ - ret = media_entity_create_link(&resizer->resizer_b.subdev.entity, 1, + ret = media_create_pad_link(&resizer->resizer_b.subdev.entity, 1, &resizer->resizer_b.video_out.video_dev.entity, 0, flags); if (ret < 0) goto out_create_link; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c index 69b678ca40c0..ec46f366dd17 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c @@ -445,32 +445,32 @@ static int vpfe_register_entities(struct vpfe_device *vpfe_dev) /* if entity has no pads (ex: amplifier), cant establish link */ if (vpfe_dev->sd[i]->entity.num_pads) { - ret = media_entity_create_link(&vpfe_dev->sd[i]->entity, + ret = media_create_pad_link(&vpfe_dev->sd[i]->entity, 0, &vpfe_dev->vpfe_isif.subdev.entity, 0, flags); if (ret < 0) goto out_resizer_register; } - ret = media_entity_create_link(&vpfe_dev->vpfe_isif.subdev.entity, 1, + ret = media_create_pad_link(&vpfe_dev->vpfe_isif.subdev.entity, 1, &vpfe_dev->vpfe_ipipeif.subdev.entity, 0, flags); if (ret < 0) goto out_resizer_register; - ret = media_entity_create_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1, + ret = media_create_pad_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1, &vpfe_dev->vpfe_ipipe.subdev.entity, 0, flags); if (ret < 0) goto out_resizer_register; - ret = media_entity_create_link(&vpfe_dev->vpfe_ipipe.subdev.entity, + ret = media_create_pad_link(&vpfe_dev->vpfe_ipipe.subdev.entity, 1, &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity, 0, flags); if (ret < 0) goto out_resizer_register; - ret = media_entity_create_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1, + ret = media_create_pad_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1, &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity, 0, flags); if (ret < 0) diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index 5fc3675b190f..60e67fadcac1 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -1259,7 +1259,7 @@ static int iss_register_entities(struct iss_device *iss) goto done; } - ret = media_entity_create_link(&sensor->entity, 0, input, pad, + ret = media_create_pad_link(&sensor->entity, 0, input, pad, flags); if (ret < 0) goto done; @@ -1317,31 +1317,31 @@ static int iss_initialize_modules(struct iss_device *iss) } /* Connect the submodules. */ - ret = media_entity_create_link( + ret = media_create_pad_link( &iss->csi2a.subdev.entity, CSI2_PAD_SOURCE, &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &iss->csi2b.subdev.entity, CSI2_PAD_SOURCE, &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, &iss->ipipe.subdev.entity, IPIPE_PAD_SINK, 0); if (ret < 0) goto error_link; - ret = media_entity_create_link( + ret = media_create_pad_link( &iss->ipipe.subdev.entity, IPIPE_PAD_SOURCE_VP, &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); if (ret < 0) diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index 86111e39a728..c6eb5a7a593f 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -1291,7 +1291,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) goto error_video; /* Connect the CSI2 subdev to the video node. */ - ret = media_entity_create_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, + ret = media_create_pad_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, &csi2->video_out.video.entity, 0, 0); if (ret < 0) goto error_link; diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index d031a5f22cdc..b0c5f2431b62 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -762,7 +762,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) return ret; /* Connect the IPIPEIF subdev to the video node. */ - ret = media_entity_create_link(&ipipeif->subdev.entity, + ret = media_create_pad_link(&ipipeif->subdev.entity, IPIPEIF_PAD_SOURCE_ISIF_SF, &ipipeif->video_out.video.entity, 0, 0); if (ret < 0) diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index 11031d9de3ab..a2cb57cb460d 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -804,7 +804,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer) return ret; /* Connect the RESIZER subdev to the video node. */ - ret = media_entity_create_link(&resizer->subdev.entity, + ret = media_create_pad_link(&resizer->subdev.entity, RESIZER_PAD_SOURCE_MEM, &resizer->video_out.video.entity, 0, 0); if (ret < 0) diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 96a5d3e6f6f4..ad9e16e5e44d 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -215,7 +215,7 @@ int media_entity_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads); void media_entity_cleanup(struct media_entity *entity); -int media_entity_create_link(struct media_entity *source, u16 source_pad, +int media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags); void __media_entity_remove_links(struct media_entity *entity); void media_entity_remove_links(struct media_entity *entity); -- cgit v1.2.3 From d10c98949d1a1fff14d750fe5162213bb5b39e11 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 19 Aug 2015 12:35:21 -0300 Subject: [media] media: use entity.graph_obj.mdev instead of .parent The struct media_entity has a .parent field that stores a pointer to the parent struct media_device. But recently a media_gobj was embedded into the entities and since struct media_gojb already has a pointer to a struct media_device in the .mdev field, the .parent field becomes redundant and can be removed. This patch replaces all the usage of .parent by .graph_obj.mdev so that field will become unused and can be removed on a later patch. No functional changes. The transformation was made using the following coccinelle spatch: @@ struct media_entity *me; @@ - me->parent + me->graph_obj.mdev @@ struct media_entity *link; @@ - link->source->entity->parent + link->source->entity->graph_obj.mdev @@ struct exynos_video_entity *ve; @@ - ve->vdev.entity.parent + ve->vdev.entity.graph_obj.mdev Suggested-by: Mauro Carvalho Chehab Signed-off-by: Javier Martinez Canillas Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 8 ++--- drivers/media/media-entity.c | 34 ++++++++++++---------- drivers/media/platform/exynos4-is/fimc-isp-video.c | 6 ++-- drivers/media/platform/exynos4-is/fimc-lite.c | 8 ++--- drivers/media/platform/exynos4-is/media-dev.c | 2 +- drivers/media/platform/exynos4-is/media-dev.h | 8 ++--- drivers/media/platform/omap3isp/isp.c | 4 +-- drivers/media/platform/omap3isp/ispvideo.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 2 +- drivers/media/platform/xilinx/xilinx-dma.c | 2 +- drivers/staging/media/davinci_vpfe/vpfe_video.c | 6 ++-- drivers/staging/media/omap4iss/iss.c | 4 +-- drivers/staging/media/omap4iss/iss_video.c | 2 +- 13 files changed, 45 insertions(+), 43 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 0f3844470147..138b18416460 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -435,8 +435,8 @@ int __must_check media_device_register_entity(struct media_device *mdev, int i; /* Warn if we apparently re-register an entity */ - WARN_ON(entity->parent != NULL); - entity->parent = mdev; + WARN_ON(entity->graph_obj.mdev != NULL); + entity->graph_obj.mdev = mdev; spin_lock(&mdev->lock); /* Initialize media_gobj embedded at the entity */ @@ -471,7 +471,7 @@ EXPORT_SYMBOL_GPL(media_device_register_entity); void media_device_unregister_entity(struct media_entity *entity) { int i; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; if (mdev == NULL) return; @@ -484,7 +484,7 @@ void media_device_unregister_entity(struct media_entity *entity) media_gobj_remove(&entity->graph_obj); list_del(&entity->list); spin_unlock(&mdev->lock); - entity->parent = NULL; + entity->graph_obj.mdev = NULL; } EXPORT_SYMBOL_GPL(media_device_unregister_entity); diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index e840da0325b7..6ed4a19b0be9 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -332,7 +332,7 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next); __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe) { - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; struct media_entity_graph graph; struct media_entity *entity_err = entity; int ret; @@ -387,7 +387,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, ret = entity->ops->link_validate(link); if (ret < 0 && ret != -ENOIOCTLCMD) { - dev_dbg(entity->parent->dev, + dev_dbg(entity->graph_obj.mdev->dev, "link validation failed for \"%s\":%u -> \"%s\":%u, error %d\n", link->source->entity->name, link->source->index, @@ -401,7 +401,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, if (!bitmap_full(active, entity->num_pads)) { ret = -EPIPE; - dev_dbg(entity->parent->dev, + dev_dbg(entity->graph_obj.mdev->dev, "\"%s\":%u must be connected by an enabled link\n", entity->name, (unsigned)find_first_zero_bit( @@ -454,7 +454,7 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start); */ void media_entity_pipeline_stop(struct media_entity *entity) { - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; struct media_entity_graph graph; mutex_lock(&mdev->graph_mutex); @@ -490,8 +490,8 @@ struct media_entity *media_entity_get(struct media_entity *entity) if (entity == NULL) return NULL; - if (entity->parent->dev && - !try_module_get(entity->parent->dev->driver->owner)) + if (entity->graph_obj.mdev->dev && + !try_module_get(entity->graph_obj.mdev->dev->driver->owner)) return NULL; return entity; @@ -511,8 +511,8 @@ void media_entity_put(struct media_entity *entity) if (entity == NULL) return; - if (entity->parent->dev) - module_put(entity->parent->dev->driver->owner); + if (entity->graph_obj.mdev->dev) + module_put(entity->graph_obj.mdev->dev->driver->owner); } EXPORT_SYMBOL_GPL(media_entity_put); @@ -561,7 +561,8 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, link->flags = flags; /* Initialize graph object embedded at the new link */ - media_gobj_init(source->parent, MEDIA_GRAPH_LINK, &link->graph_obj); + media_gobj_init(source->graph_obj.mdev, MEDIA_GRAPH_LINK, + &link->graph_obj); /* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. @@ -577,7 +578,8 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, backlink->flags = flags; /* Initialize graph object embedded at the new link */ - media_gobj_init(sink->parent, MEDIA_GRAPH_LINK, &backlink->graph_obj); + media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK, + &backlink->graph_obj); link->reverse = backlink; backlink->reverse = link; @@ -629,12 +631,12 @@ EXPORT_SYMBOL_GPL(__media_entity_remove_links); void media_entity_remove_links(struct media_entity *entity) { /* Do nothing if the entity is not registered. */ - if (entity->parent == NULL) + if (entity->graph_obj.mdev == NULL) return; - mutex_lock(&entity->parent->graph_mutex); + mutex_lock(&entity->graph_obj.mdev->graph_mutex); __media_entity_remove_links(entity); - mutex_unlock(&entity->parent->graph_mutex); + mutex_unlock(&entity->graph_obj.mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_entity_remove_links); @@ -703,7 +705,7 @@ int __media_entity_setup_link(struct media_link *link, u32 flags) (source->stream_count || sink->stream_count)) return -EBUSY; - mdev = source->parent; + mdev = source->graph_obj.mdev; if (mdev->link_notify) { ret = mdev->link_notify(link, flags, @@ -724,9 +726,9 @@ int media_entity_setup_link(struct media_link *link, u32 flags) { int ret; - mutex_lock(&link->source->entity->parent->graph_mutex); + mutex_lock(&link->source->entity->graph_obj.mdev->graph_mutex); ret = __media_entity_setup_link(link, flags); - mutex_unlock(&link->source->entity->parent->graph_mutex); + mutex_unlock(&link->source->entity->graph_obj.mdev->graph_mutex); return ret; } diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c index 817226d52b74..239df7d8bd30 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c @@ -287,7 +287,7 @@ static int isp_video_open(struct file *file) goto rel_fh; if (v4l2_fh_is_singular_file(file)) { - mutex_lock(&me->parent->graph_mutex); + mutex_lock(&me->graph_obj.mdev->graph_mutex); ret = fimc_pipeline_call(ve, open, me, true); @@ -295,7 +295,7 @@ static int isp_video_open(struct file *file) if (ret == 0) me->use_count++; - mutex_unlock(&me->parent->graph_mutex); + mutex_unlock(&me->graph_obj.mdev->graph_mutex); } if (!ret) goto unlock; @@ -311,7 +311,7 @@ static int isp_video_release(struct file *file) struct fimc_isp *isp = video_drvdata(file); struct fimc_is_video *ivc = &isp->video_capture; struct media_entity *entity = &ivc->ve.vdev.entity; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; mutex_lock(&isp->video_lock); diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 2ce670425cd9..11d25712153d 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -494,7 +494,7 @@ static int fimc_lite_open(struct file *file) atomic_read(&fimc->out_path) != FIMC_IO_DMA) goto unlock; - mutex_lock(&me->parent->graph_mutex); + mutex_lock(&me->graph_obj.mdev->graph_mutex); ret = fimc_pipeline_call(&fimc->ve, open, me, true); @@ -502,7 +502,7 @@ static int fimc_lite_open(struct file *file) if (ret == 0) me->use_count++; - mutex_unlock(&me->parent->graph_mutex); + mutex_unlock(&me->graph_obj.mdev->graph_mutex); if (!ret) { fimc_lite_clear_event_counters(fimc); @@ -535,9 +535,9 @@ static int fimc_lite_release(struct file *file) fimc_pipeline_call(&fimc->ve, close); clear_bit(ST_FLITE_IN_USE, &fimc->state); - mutex_lock(&entity->parent->graph_mutex); + mutex_lock(&entity->graph_obj.mdev->graph_mutex); entity->use_count--; - mutex_unlock(&entity->parent->graph_mutex); + mutex_unlock(&entity->graph_obj.mdev->graph_mutex); } _vb2_fop_release(file, NULL); diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 4c524a02c59c..a67b98676dd9 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1046,7 +1046,7 @@ static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable) return ret; } -/* Locking: called with entity->parent->graph_mutex mutex held. */ +/* Locking: called with entity->graph_obj.mdev->graph_mutex mutex held. */ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) { struct media_entity *entity_err = entity; diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h index 93a96126929b..e8845e1f5aab 100644 --- a/drivers/media/platform/exynos4-is/media-dev.h +++ b/drivers/media/platform/exynos4-is/media-dev.h @@ -164,8 +164,8 @@ struct fimc_sensor_info *source_to_sensor_info(struct fimc_source_info *si) static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me) { - return me->parent == NULL ? NULL : - container_of(me->parent, struct fimc_md, media_dev); + return me->graph_obj.mdev == NULL ? NULL : + container_of(me->graph_obj.mdev, struct fimc_md, media_dev); } static inline struct fimc_md *notifier_to_fimc_md(struct v4l2_async_notifier *n) @@ -175,12 +175,12 @@ static inline struct fimc_md *notifier_to_fimc_md(struct v4l2_async_notifier *n) static inline void fimc_md_graph_lock(struct exynos_video_entity *ve) { - mutex_lock(&ve->vdev.entity.parent->graph_mutex); + mutex_lock(&ve->vdev.entity.graph_obj.mdev->graph_mutex); } static inline void fimc_md_graph_unlock(struct exynos_video_entity *ve) { - mutex_unlock(&ve->vdev.entity.parent->graph_mutex); + mutex_unlock(&ve->vdev.entity.graph_obj.mdev->graph_mutex); } int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on); diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 6351f35b0a65..aa13b17d19a0 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -787,7 +787,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) int change = use ? 1 : -1; int ret; - mutex_lock(&entity->parent->graph_mutex); + mutex_lock(&entity->graph_obj.mdev->graph_mutex); /* Apply use count to node. */ entity->use_count += change; @@ -798,7 +798,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) if (ret < 0) entity->use_count -= change; - mutex_unlock(&entity->parent->graph_mutex); + mutex_unlock(&entity->graph_obj.mdev->graph_mutex); return ret; } diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index 0e129075e99f..a2e53b34d95f 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -226,7 +226,7 @@ static int isp_video_get_graph_data(struct isp_video *video, { struct media_entity_graph graph; struct media_entity *entity = &video->video.entity; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; struct isp_video *far_end = NULL; mutex_lock(&mdev->graph_mutex); diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 516595cff408..c2b2281bb530 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -380,7 +380,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe, { struct media_entity_graph graph; struct media_entity *entity = &video->video.entity; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; unsigned int i; int ret; diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index ce2d34df12ed..4b84a0e54a0c 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -181,7 +181,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe, { struct media_entity_graph graph; struct media_entity *entity = &start->video.entity; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; unsigned int num_inputs = 0; unsigned int num_outputs = 0; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index daae720eb82c..6e0d0375634d 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -130,7 +130,7 @@ __vpfe_video_get_format(struct vpfe_video_device *video, static void vpfe_prepare_pipeline(struct vpfe_video_device *video) { struct media_entity *entity = &video->video_dev.entity; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; struct vpfe_pipeline *pipe = &video->pipe; struct vpfe_video_device *far_end = NULL; struct media_entity_graph graph; @@ -288,7 +288,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) else entity = &pipe->inputs[0]->video_dev.entity; - mdev = entity->parent; + mdev = entity->graph_obj.mdev; mutex_lock(&mdev->graph_mutex); media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { @@ -328,7 +328,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) else entity = &pipe->inputs[0]->video_dev.entity; - mdev = entity->parent; + mdev = entity->graph_obj.mdev; mutex_lock(&mdev->graph_mutex); media_entity_graph_walk_start(&graph, entity); diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index 60e67fadcac1..b405dc93d90a 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -494,7 +494,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) int change = use ? 1 : -1; int ret; - mutex_lock(&entity->parent->graph_mutex); + mutex_lock(&entity->graph_obj.mdev->graph_mutex); /* Apply use count to node. */ entity->use_count += change; @@ -505,7 +505,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) if (ret < 0) entity->use_count -= change; - mutex_unlock(&entity->parent->graph_mutex); + mutex_unlock(&entity->graph_obj.mdev->graph_mutex); return ret; } diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index dd8ff03912a7..ea384630aab0 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -206,7 +206,7 @@ iss_video_far_end(struct iss_video *video) { struct media_entity_graph graph; struct media_entity *entity = &video->video.entity; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; struct iss_video *far_end = NULL; mutex_lock(&mdev->graph_mutex); -- cgit v1.2.3 From 27e543fa87deea308f0cc5224ab19e397b0a5ded Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 20 Aug 2015 09:07:34 -0300 Subject: [media] media: add functions to allow creating interfaces Interfaces are different than entities: they represent a Kernel<->userspace interaction, while entities represent a piece of hardware/firmware/software that executes a function. Let's distinguish them by creating a separate structure to store the interfaces. Later patches should change the existing drivers and logic to split the current interface embedded inside the entity structure (device nodes) into a separate object of the graph. Acked-by: Hans Verkuil Reviewed-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 83 ++++++++++++++++++++++++++++++++++++++++++++ include/media/media-device.h | 2 ++ include/media/media-entity.h | 48 +++++++++++++++++++++++++ 3 files changed, 133 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 6ed4a19b0be9..160ce2cc0865 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -44,11 +44,41 @@ static inline const char *gobj_type(enum media_gobj_type type) return "pad"; case MEDIA_GRAPH_LINK: return "link"; + case MEDIA_GRAPH_INTF_DEVNODE: + return "intf-devnode"; default: return "unknown"; } } +static inline const char *intf_type(struct media_interface *intf) +{ + switch (intf->type) { + case MEDIA_INTF_T_DVB_FE: + return "frontend"; + case MEDIA_INTF_T_DVB_DEMUX: + return "demux"; + case MEDIA_INTF_T_DVB_DVR: + return "DVR"; + case MEDIA_INTF_T_DVB_CA: + return "CA"; + case MEDIA_INTF_T_DVB_NET: + return "dvbnet"; + case MEDIA_INTF_T_V4L_VIDEO: + return "video"; + case MEDIA_INTF_T_V4L_VBI: + return "vbi"; + case MEDIA_INTF_T_V4L_RADIO: + return "radio"; + case MEDIA_INTF_T_V4L_SUBDEV: + return "v4l2-subdev"; + case MEDIA_INTF_T_V4L_SWRADIO: + return "swradio"; + default: + return "unknown-intf"; + } +}; + static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) { #if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG) @@ -84,6 +114,19 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) "%s: id 0x%08x pad#%d: '%s':%d\n", event_name, gobj->id, media_localid(gobj), pad->entity->name, pad->index); + break; + } + case MEDIA_GRAPH_INTF_DEVNODE: + { + struct media_interface *intf = gobj_to_intf(gobj); + struct media_intf_devnode *devnode = intf_to_devnode(intf); + + dev_dbg(gobj->mdev->dev, + "%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n", + event_name, gobj->id, media_localid(gobj), + intf_type(intf), + devnode->major, devnode->minor); + break; } } #endif @@ -119,6 +162,9 @@ void media_gobj_init(struct media_device *mdev, case MEDIA_GRAPH_LINK: gobj->id = media_gobj_gen_id(type, ++mdev->link_id); break; + case MEDIA_GRAPH_INTF_DEVNODE: + gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id); + break; } dev_dbg_obj(__func__, gobj); } @@ -793,3 +839,40 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) } EXPORT_SYMBOL_GPL(media_entity_remote_pad); + + +/* Functions related to the media interface via device nodes */ + +struct media_intf_devnode *media_devnode_create(struct media_device *mdev, + u32 type, u32 flags, + u32 major, u32 minor, + gfp_t gfp_flags) +{ + struct media_intf_devnode *devnode; + struct media_interface *intf; + + devnode = kzalloc(sizeof(*devnode), gfp_flags); + if (!devnode) + return NULL; + + intf = &devnode->intf; + + intf->type = type; + intf->flags = flags; + + devnode->major = major; + devnode->minor = minor; + + media_gobj_init(mdev, MEDIA_GRAPH_INTF_DEVNODE, + &devnode->intf.graph_obj); + + return devnode; +} +EXPORT_SYMBOL_GPL(media_devnode_create); + +void media_devnode_remove(struct media_intf_devnode *devnode) +{ + media_gobj_remove(&devnode->intf.graph_obj); + kfree(devnode); +} +EXPORT_SYMBOL_GPL(media_devnode_remove); diff --git a/include/media/media-device.h b/include/media/media-device.h index 05414e351f8e..3b14394d5701 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -44,6 +44,7 @@ struct device; * @entity_id: Unique ID used on the last entity registered * @pad_id: Unique ID used on the last pad registered * @link_id: Unique ID used on the last link registered + * @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @lock: Entities list lock * @graph_mutex: Entities graph operation lock @@ -73,6 +74,7 @@ struct media_device { u32 entity_id; u32 pad_id; u32 link_id; + u32 intf_devnode_id; struct list_head entities; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a493dd9910f4..4d5fc91c4134 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -36,11 +36,14 @@ * @MEDIA_GRAPH_ENTITY: Identify a media entity * @MEDIA_GRAPH_PAD: Identify a media pad * @MEDIA_GRAPH_LINK: Identify a media link + * @MEDIA_GRAPH_INTF_DEVNODE: Identify a media Kernel API interface via + * a device node */ enum media_gobj_type { MEDIA_GRAPH_ENTITY, MEDIA_GRAPH_PAD, MEDIA_GRAPH_LINK, + MEDIA_GRAPH_INTF_DEVNODE, }; #define MEDIA_BITS_PER_TYPE 8 @@ -141,6 +144,34 @@ struct media_entity { } info; }; +/** + * struct media_intf_devnode - Define a Kernel API interface + * + * @graph_obj: embedded graph object + * @type: Type of the interface as defined at the + * uapi/media/media.h header, e. g. + * MEDIA_INTF_T_* + * @flags: Interface flags as defined at uapi/media/media.h + */ +struct media_interface { + struct media_gobj graph_obj; + u32 type; + u32 flags; +}; + +/** + * struct media_intf_devnode - Define a Kernel API interface via a device node + * + * @intf: embedded interface object + * @major: Major number of a device node + * @minor: Minor number of a device node + */ +struct media_intf_devnode { + struct media_interface intf; + u32 major; + u32 minor; +}; + static inline u32 media_entity_type(struct media_entity *entity) { return entity->type & MEDIA_ENT_TYPE_MASK; @@ -205,6 +236,18 @@ struct media_entity_graph { #define gobj_to_link(gobj) \ container_of(gobj, struct media_link, graph_obj) +#define gobj_to_link(gobj) \ + container_of(gobj, struct media_link, graph_obj) + +#define gobj_to_pad(gobj) \ + container_of(gobj, struct media_pad, graph_obj) + +#define gobj_to_intf(gobj) \ + container_of(gobj, struct media_interface, graph_obj) + +#define intf_to_devnode(intf) \ + container_of(intf, struct media_intf_devnode, intf) + void media_gobj_init(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj); @@ -236,6 +279,11 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe); void media_entity_pipeline_stop(struct media_entity *entity); +struct media_intf_devnode *media_devnode_create(struct media_device *mdev, + u32 type, u32 flags, + u32 major, u32 minor, + gfp_t gfp_flags); +void media_devnode_remove(struct media_intf_devnode *devnode); #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) -- cgit v1.2.3 From f2f6da0d77027d05bf8a06eb8b80fe139f9cc853 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 26 Aug 2015 09:24:45 -0300 Subject: [media] omap3isp: separate links creation from entities init The omap3isp driver initializes the entities and creates the pads links before the entities are registered with the media device. This does not work now that object IDs are used to create links so the media_device has to be set. Split out the pads links creation from the entity initialization so the links are created after the entities have been registered with the media device. Suggested-by: Mauro Carvalho Chehab Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 152 +++++++++++++++++---------- drivers/media/platform/omap3isp/ispccdc.c | 22 ++-- drivers/media/platform/omap3isp/ispccdc.h | 1 + drivers/media/platform/omap3isp/ispccp2.c | 22 ++-- drivers/media/platform/omap3isp/ispccp2.h | 1 + drivers/media/platform/omap3isp/ispcsi2.c | 22 ++-- drivers/media/platform/omap3isp/ispcsi2.h | 1 + drivers/media/platform/omap3isp/isppreview.c | 33 +++--- drivers/media/platform/omap3isp/isppreview.h | 1 + drivers/media/platform/omap3isp/ispresizer.c | 33 +++--- drivers/media/platform/omap3isp/ispresizer.h | 1 + 11 files changed, 185 insertions(+), 104 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index aa13b17d19a0..b8f6f81d2db2 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -1933,6 +1933,100 @@ done: return ret; } +/* + * isp_create_pads_links - Pads links creation for the subdevices + * @isp : Pointer to ISP device + * return negative error code or zero on success + */ +static int isp_create_pads_links(struct isp_device *isp) +{ + int ret; + + ret = omap3isp_csi2_create_pads_links(isp); + if (ret < 0) { + dev_err(isp->dev, "CSI2 pads links creation failed\n"); + return ret; + } + + ret = omap3isp_ccp2_create_pads_links(isp); + if (ret < 0) { + dev_err(isp->dev, "CCP2 pads links creation failed\n"); + return ret; + } + + ret = omap3isp_ccdc_create_pads_links(isp); + if (ret < 0) { + dev_err(isp->dev, "CCDC pads links creation failed\n"); + return ret; + } + + ret = omap3isp_preview_create_pads_links(isp); + if (ret < 0) { + dev_err(isp->dev, "Preview pads links creation failed\n"); + return ret; + } + + ret = omap3isp_resizer_create_pads_links(isp); + if (ret < 0) { + dev_err(isp->dev, "Resizer pads links creation failed\n"); + return ret; + } + + /* Connect the submodules. */ + ret = media_create_pad_link( + &isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE, + &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_ccp2.subdev.entity, CCP2_PAD_SOURCE, + &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, + &isp->isp_prev.subdev.entity, PREV_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF, + &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_prev.subdev.entity, PREV_PAD_SOURCE, + &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, + &isp->isp_aewb.subdev.entity, 0, + MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, + &isp->isp_af.subdev.entity, 0, + MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, + &isp->isp_hist.subdev.entity, 0, + MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); + if (ret < 0) + return ret; + + return 0; +} + static void isp_cleanup_modules(struct isp_device *isp) { omap3isp_h3a_aewb_cleanup(isp); @@ -2003,62 +2097,8 @@ static int isp_initialize_modules(struct isp_device *isp) goto error_h3a_af; } - /* Connect the submodules. */ - ret = media_create_pad_link( - &isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE, - &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &isp->isp_ccp2.subdev.entity, CCP2_PAD_SOURCE, - &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, - &isp->isp_prev.subdev.entity, PREV_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF, - &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &isp->isp_prev.subdev.entity, PREV_PAD_SOURCE, - &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, - &isp->isp_aewb.subdev.entity, 0, - MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, - &isp->isp_af.subdev.entity, 0, - MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP, - &isp->isp_hist.subdev.entity, 0, - MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap3isp_h3a_af_cleanup(isp); error_h3a_af: omap3isp_h3a_aewb_cleanup(isp); error_h3a_aewb: @@ -2468,6 +2508,10 @@ static int isp_probe(struct platform_device *pdev) if (ret < 0) goto error_modules; + ret = isp_create_pads_links(isp); + if (ret < 0) + goto error_register_entities; + isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 27555e4f4aa8..9a811f5741fa 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -2666,16 +2666,8 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) if (ret < 0) goto error_video; - /* Connect the CCDC subdev to the video node. */ - ret = media_create_pad_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF, - &ccdc->video_out.video.entity, 0, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap3isp_video_cleanup(&ccdc->video_out); error_video: media_entity_cleanup(me); return ret; @@ -2720,6 +2712,20 @@ int omap3isp_ccdc_init(struct isp_device *isp) return 0; } +/* + * omap3isp_ccdc_create_pads_links - CCDC pads links creation + * @isp : Pointer to ISP device + * return negative error code or zero on success + */ +int omap3isp_ccdc_create_pads_links(struct isp_device *isp) +{ + struct isp_ccdc_device *ccdc = &isp->isp_ccdc; + + /* Connect the CCDC subdev to the video node. */ + return media_create_pad_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF, + &ccdc->video_out.video.entity, 0, 0); +} + /* * omap3isp_ccdc_cleanup - CCDC module cleanup. * @isp: Device pointer specific to the OMAP3 ISP. diff --git a/drivers/media/platform/omap3isp/ispccdc.h b/drivers/media/platform/omap3isp/ispccdc.h index 3440a7097940..2128203ef6fb 100644 --- a/drivers/media/platform/omap3isp/ispccdc.h +++ b/drivers/media/platform/omap3isp/ispccdc.h @@ -163,6 +163,7 @@ struct isp_ccdc_device { struct isp_device; int omap3isp_ccdc_init(struct isp_device *isp); +int omap3isp_ccdc_create_pads_links(struct isp_device *isp); void omap3isp_ccdc_cleanup(struct isp_device *isp); int omap3isp_ccdc_register_entities(struct isp_ccdc_device *ccdc, struct v4l2_device *vdev); diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index b215eb5049d6..6ec7d104ab75 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -1099,16 +1099,8 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) if (ret < 0) goto error_video; - /* Connect the video node to the ccp2 subdev. */ - ret = media_create_pad_link(&ccp2->video_in.video.entity, 0, - &ccp2->subdev.entity, CCP2_PAD_SINK, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap3isp_video_cleanup(&ccp2->video_in); error_video: media_entity_cleanup(&ccp2->subdev.entity); return ret; @@ -1156,6 +1148,20 @@ int omap3isp_ccp2_init(struct isp_device *isp) return 0; } +/* + * omap3isp_ccp2_create_pads_links - CCP2 pads links creation + * @isp : Pointer to ISP device + * return negative error code or zero on success + */ +int omap3isp_ccp2_create_pads_links(struct isp_device *isp) +{ + struct isp_ccp2_device *ccp2 = &isp->isp_ccp2; + + /* Connect the video node to the ccp2 subdev. */ + return media_create_pad_link(&ccp2->video_in.video.entity, 0, + &ccp2->subdev.entity, CCP2_PAD_SINK, 0); +} + /* * omap3isp_ccp2_cleanup - CCP2 un-initialization * @isp : Pointer to ISP device diff --git a/drivers/media/platform/omap3isp/ispccp2.h b/drivers/media/platform/omap3isp/ispccp2.h index 4662bffa79e3..fb74bc67878b 100644 --- a/drivers/media/platform/omap3isp/ispccp2.h +++ b/drivers/media/platform/omap3isp/ispccp2.h @@ -79,6 +79,7 @@ struct isp_ccp2_device { /* Function declarations */ int omap3isp_ccp2_init(struct isp_device *isp); +int omap3isp_ccp2_create_pads_links(struct isp_device *isp); void omap3isp_ccp2_cleanup(struct isp_device *isp); int omap3isp_ccp2_register_entities(struct isp_ccp2_device *ccp2, struct v4l2_device *vdev); diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index fcefc1e74881..0fb057a74f69 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c @@ -1264,16 +1264,8 @@ static int csi2_init_entities(struct isp_csi2_device *csi2) if (ret < 0) goto error_video; - /* Connect the CSI2 subdev to the video node. */ - ret = media_create_pad_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, - &csi2->video_out.video.entity, 0, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap3isp_video_cleanup(&csi2->video_out); error_video: media_entity_cleanup(&csi2->subdev.entity); return ret; @@ -1313,6 +1305,20 @@ int omap3isp_csi2_init(struct isp_device *isp) return 0; } +/* + * omap3isp_csi2_create_pads_links - CSI2 pads links creation + * @isp : Pointer to ISP device + * return negative error code or zero on success + */ +int omap3isp_csi2_create_pads_links(struct isp_device *isp) +{ + struct isp_csi2_device *csi2a = &isp->isp_csi2a; + + /* Connect the CSI2 subdev to the video node. */ + return media_create_pad_link(&csi2a->subdev.entity, CSI2_PAD_SOURCE, + &csi2a->video_out.video.entity, 0, 0); +} + /* * omap3isp_csi2_cleanup - Routine for module driver cleanup */ diff --git a/drivers/media/platform/omap3isp/ispcsi2.h b/drivers/media/platform/omap3isp/ispcsi2.h index 453ed62fe394..452ee239c7d7 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.h +++ b/drivers/media/platform/omap3isp/ispcsi2.h @@ -148,6 +148,7 @@ struct isp_csi2_device { void omap3isp_csi2_isr(struct isp_csi2_device *csi2); int omap3isp_csi2_reset(struct isp_csi2_device *csi2); int omap3isp_csi2_init(struct isp_device *isp); +int omap3isp_csi2_create_pads_links(struct isp_device *isp); void omap3isp_csi2_cleanup(struct isp_device *isp); void omap3isp_csi2_unregister_entities(struct isp_csi2_device *csi2); int omap3isp_csi2_register_entities(struct isp_csi2_device *csi2, diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c index ad38d20c7770..6986d2f65c19 100644 --- a/drivers/media/platform/omap3isp/isppreview.c +++ b/drivers/media/platform/omap3isp/isppreview.c @@ -2311,21 +2311,8 @@ static int preview_init_entities(struct isp_prev_device *prev) if (ret < 0) goto error_video_out; - /* Connect the video nodes to the previewer subdev. */ - ret = media_create_pad_link(&prev->video_in.video.entity, 0, - &prev->subdev.entity, PREV_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link(&prev->subdev.entity, PREV_PAD_SOURCE, - &prev->video_out.video.entity, 0, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap3isp_video_cleanup(&prev->video_out); error_video_out: omap3isp_video_cleanup(&prev->video_in); error_video_in: @@ -2349,6 +2336,26 @@ int omap3isp_preview_init(struct isp_device *isp) return preview_init_entities(prev); } +/* + * omap3isp_preview_create_pads_links - Previewer pads links creation + * @isp : Pointer to ISP device + * return negative error code or zero on success + */ +int omap3isp_preview_create_pads_links(struct isp_device *isp) +{ + struct isp_prev_device *prev = &isp->isp_prev; + int ret; + + /* Connect the video nodes to the previewer subdev. */ + ret = media_create_pad_link(&prev->video_in.video.entity, 0, + &prev->subdev.entity, PREV_PAD_SINK, 0); + if (ret < 0) + return ret; + + return media_create_pad_link(&prev->subdev.entity, PREV_PAD_SOURCE, + &prev->video_out.video.entity, 0, 0); +} + void omap3isp_preview_cleanup(struct isp_device *isp) { struct isp_prev_device *prev = &isp->isp_prev; diff --git a/drivers/media/platform/omap3isp/isppreview.h b/drivers/media/platform/omap3isp/isppreview.h index 16fdc03a3d43..f3593b7cecc7 100644 --- a/drivers/media/platform/omap3isp/isppreview.h +++ b/drivers/media/platform/omap3isp/isppreview.h @@ -148,6 +148,7 @@ struct isp_prev_device { struct isp_device; int omap3isp_preview_init(struct isp_device *isp); +int omap3isp_preview_create_pads_links(struct isp_device *isp); void omap3isp_preview_cleanup(struct isp_device *isp); int omap3isp_preview_register_entities(struct isp_prev_device *prv, diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c index b48ad4d4b834..249af7f524f9 100644 --- a/drivers/media/platform/omap3isp/ispresizer.c +++ b/drivers/media/platform/omap3isp/ispresizer.c @@ -1755,21 +1755,8 @@ static int resizer_init_entities(struct isp_res_device *res) res->video_out.video.entity.flags |= MEDIA_ENT_FL_DEFAULT; - /* Connect the video nodes to the resizer subdev. */ - ret = media_create_pad_link(&res->video_in.video.entity, 0, - &res->subdev.entity, RESZ_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link(&res->subdev.entity, RESZ_PAD_SOURCE, - &res->video_out.video.entity, 0, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap3isp_video_cleanup(&res->video_out); error_video_out: omap3isp_video_cleanup(&res->video_in); error_video_in: @@ -1793,6 +1780,26 @@ int omap3isp_resizer_init(struct isp_device *isp) return resizer_init_entities(res); } +/* + * omap3isp_resizer_create_pads_links - Resizer pads links creation + * @isp : Pointer to ISP device + * return negative error code or zero on success + */ +int omap3isp_resizer_create_pads_links(struct isp_device *isp) +{ + struct isp_res_device *res = &isp->isp_res; + int ret; + + /* Connect the video nodes to the resizer subdev. */ + ret = media_create_pad_link(&res->video_in.video.entity, 0, + &res->subdev.entity, RESZ_PAD_SINK, 0); + if (ret < 0) + return ret; + + return media_create_pad_link(&res->subdev.entity, RESZ_PAD_SOURCE, + &res->video_out.video.entity, 0, 0); +} + void omap3isp_resizer_cleanup(struct isp_device *isp) { struct isp_res_device *res = &isp->isp_res; diff --git a/drivers/media/platform/omap3isp/ispresizer.h b/drivers/media/platform/omap3isp/ispresizer.h index 5414542912e2..8b9fdcdab73d 100644 --- a/drivers/media/platform/omap3isp/ispresizer.h +++ b/drivers/media/platform/omap3isp/ispresizer.h @@ -119,6 +119,7 @@ struct isp_res_device { struct isp_device; int omap3isp_resizer_init(struct isp_device *isp); +int omap3isp_resizer_create_pads_links(struct isp_device *isp); void omap3isp_resizer_cleanup(struct isp_device *isp); int omap3isp_resizer_register_entities(struct isp_res_device *res, -- cgit v1.2.3 From 68a57fa93a9f7776ab502db389469dd1ac6a1c66 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 28 Aug 2015 06:28:33 -0300 Subject: [media] omap3isp: create links after all subdevs have been bound The omap3isp driver parses the graph endpoints to know how many subdevices needs to be registered async and register notifiers callbacks for to know when these are bound and when the async registrations are completed. Currently the entities pad are linked with the correct ISP input interface when the subdevs are bound but it happens before entitities are registered with the media device so that won't work now that the entity links list is initialized on device registration. So instead creating the pad links when the subdevice is bound, create them on the complete callback once all the subdevices have been bound but only try to create for the ones that have a bus configuration set during bound. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index b8f6f81d2db2..69e7733d36cd 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -2321,26 +2321,33 @@ static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async, struct v4l2_subdev *subdev, struct v4l2_async_subdev *asd) { - struct isp_device *isp = container_of(async, struct isp_device, - notifier); struct isp_async_subdev *isd = container_of(asd, struct isp_async_subdev, asd); - int ret; - - ret = isp_link_entity(isp, &subdev->entity, isd->bus.interface); - if (ret < 0) - return ret; isd->sd = subdev; isd->sd->host_priv = &isd->bus; - return ret; + return 0; } static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier); + struct v4l2_device *v4l2_dev = &isp->v4l2_dev; + struct v4l2_subdev *sd; + struct isp_bus_cfg *bus; + int ret; + + list_for_each_entry(sd, &v4l2_dev->subdevs, list) { + /* Only try to link entities whose interface was set on bound */ + if (sd->host_priv) { + bus = (struct isp_bus_cfg *)sd->host_priv; + ret = isp_link_entity(isp, &sd->entity, bus->interface); + if (ret < 0) + return ret; + } + } return v4l2_device_register_subdev_nodes(&isp->v4l2_dev); } -- cgit v1.2.3 From 5837ceea11ca11339e49947aacbccb62f3646993 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Wed, 2 Sep 2015 11:28:08 -0300 Subject: [media] staging: omap4iss: separate links creation from entities init The omap4iss driver initializes the entities and creates the pads links before the entities are registered with the media device. This does not work now that object IDs are used to create links so the media_device has to be set. Split out the pads links creation from the entity initialization so are made after the entities registration. Signed-off-by: Javier Martinez Canillas Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss.c | 101 ++++++++++++++++++--------- drivers/staging/media/omap4iss/iss_csi2.c | 35 +++++++--- drivers/staging/media/omap4iss/iss_csi2.h | 1 + drivers/staging/media/omap4iss/iss_ipipeif.c | 29 ++++---- drivers/staging/media/omap4iss/iss_ipipeif.h | 1 + drivers/staging/media/omap4iss/iss_resizer.c | 29 ++++---- drivers/staging/media/omap4iss/iss_resizer.h | 1 + 7 files changed, 132 insertions(+), 65 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index b405dc93d90a..fa761669fd86 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -1274,6 +1274,68 @@ done: return ret; } +/* + * iss_create_pads_links() - Pads links creation for the subdevices + * @iss : Pointer to ISS device + * + * return negative error code or zero on success + */ +static int iss_create_pads_links(struct iss_device *iss) +{ + int ret; + + ret = omap4iss_csi2_create_pads_links(iss); + if (ret < 0) { + dev_err(iss->dev, "CSI2 pads links creation failed\n"); + return ret; + } + + ret = omap4iss_ipipeif_create_pads_links(iss); + if (ret < 0) { + dev_err(iss->dev, "ISP IPIPEIF pads links creation failed\n"); + return ret; + } + + ret = omap4iss_resizer_create_pads_links(iss); + if (ret < 0) { + dev_err(iss->dev, "ISP RESIZER pads links creation failed\n"); + return ret; + } + + /* Connect the submodules. */ + ret = media_create_pad_link( + &iss->csi2a.subdev.entity, CSI2_PAD_SOURCE, + &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &iss->csi2b.subdev.entity, CSI2_PAD_SOURCE, + &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, + &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, + &iss->ipipe.subdev.entity, IPIPE_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &iss->ipipe.subdev.entity, IPIPE_PAD_SOURCE_VP, + &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); + if (ret < 0) + return ret; + + return 0; +}; + static void iss_cleanup_modules(struct iss_device *iss) { omap4iss_csi2_cleanup(iss); @@ -1316,41 +1378,8 @@ static int iss_initialize_modules(struct iss_device *iss) goto error_resizer; } - /* Connect the submodules. */ - ret = media_create_pad_link( - &iss->csi2a.subdev.entity, CSI2_PAD_SOURCE, - &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &iss->csi2b.subdev.entity, CSI2_PAD_SOURCE, - &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, - &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, - &iss->ipipe.subdev.entity, IPIPE_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_create_pad_link( - &iss->ipipe.subdev.entity, IPIPE_PAD_SOURCE_VP, - &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap4iss_resizer_cleanup(iss); error_resizer: omap4iss_ipipe_cleanup(iss); error_ipipe: @@ -1464,10 +1493,16 @@ static int iss_probe(struct platform_device *pdev) if (ret < 0) goto error_modules; + ret = iss_create_pads_links(iss); + if (ret < 0) + goto error_entities; + omap4iss_put(iss); return 0; +error_entities: + iss_unregister_entities(iss); error_modules: iss_cleanup_modules(iss); error_iss: diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index c6eb5a7a593f..13878a275277 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -1290,16 +1290,8 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) if (ret < 0) goto error_video; - /* Connect the CSI2 subdev to the video node. */ - ret = media_create_pad_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, - &csi2->video_out.video.entity, 0, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap4iss_video_cleanup(&csi2->video_out); error_video: media_entity_cleanup(&csi2->subdev.entity); return ret; @@ -1341,6 +1333,33 @@ int omap4iss_csi2_init(struct iss_device *iss) return 0; } +/* + * omap4iss_csi2_create_pads_links() - CSI2 pads links creation + * @iss: Pointer to ISS device + * + * return negative error code or zero on success + */ +int omap4iss_csi2_create_pads_links(struct iss_device *iss) +{ + struct iss_csi2_device *csi2a = &iss->csi2a; + struct iss_csi2_device *csi2b = &iss->csi2b; + int ret; + + /* Connect the CSI2a subdev to the video node. */ + ret = media_create_pad_link(&csi2a->subdev.entity, CSI2_PAD_SOURCE, + &csi2a->video_out.video.entity, 0, 0); + if (ret < 0) + return ret; + + /* Connect the CSI2b subdev to the video node. */ + ret = media_create_pad_link(&csi2b->subdev.entity, CSI2_PAD_SOURCE, + &csi2b->video_out.video.entity, 0, 0); + if (ret < 0) + return ret; + + return 0; +} + /* * omap4iss_csi2_cleanup - Routine for module driver cleanup */ diff --git a/drivers/staging/media/omap4iss/iss_csi2.h b/drivers/staging/media/omap4iss/iss_csi2.h index f2f5343b4a80..1d5a0d8222a9 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.h +++ b/drivers/staging/media/omap4iss/iss_csi2.h @@ -151,6 +151,7 @@ struct iss_csi2_device { void omap4iss_csi2_isr(struct iss_csi2_device *csi2); int omap4iss_csi2_reset(struct iss_csi2_device *csi2); int omap4iss_csi2_init(struct iss_device *iss); +int omap4iss_csi2_create_pads_links(struct iss_device *iss); void omap4iss_csi2_cleanup(struct iss_device *iss); void omap4iss_csi2_unregister_entities(struct iss_csi2_device *csi2); int omap4iss_csi2_register_entities(struct iss_csi2_device *csi2, diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index b0c5f2431b62..82608cbb1f5f 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -757,18 +757,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) ipipeif->video_out.bpl_zero_padding = 1; ipipeif->video_out.bpl_max = 0x1ffe0; - ret = omap4iss_video_init(&ipipeif->video_out, "ISP IPIPEIF"); - if (ret < 0) - return ret; - - /* Connect the IPIPEIF subdev to the video node. */ - ret = media_create_pad_link(&ipipeif->subdev.entity, - IPIPEIF_PAD_SOURCE_ISIF_SF, - &ipipeif->video_out.video.entity, 0, 0); - if (ret < 0) - return ret; - - return 0; + return omap4iss_video_init(&ipipeif->video_out, "ISP IPIPEIF"); } void omap4iss_ipipeif_unregister_entities(struct iss_ipipeif_device *ipipeif) @@ -820,6 +809,22 @@ int omap4iss_ipipeif_init(struct iss_device *iss) return ipipeif_init_entities(ipipeif); } +/* + * omap4iss_ipipeif_create_pads_links() - IPIPEIF pads links creation + * @iss: Pointer to ISS device + * + * return negative error code or zero on success + */ +int omap4iss_ipipeif_create_pads_links(struct iss_device *iss) +{ + struct iss_ipipeif_device *ipipeif = &iss->ipipeif; + + /* Connect the IPIPEIF subdev to the video node. */ + return media_create_pad_link(&ipipeif->subdev.entity, + IPIPEIF_PAD_SOURCE_ISIF_SF, + &ipipeif->video_out.video.entity, 0, 0); +} + /* * omap4iss_ipipeif_cleanup - IPIPEIF module cleanup. * @iss: Device pointer specific to the OMAP4 ISS. diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.h b/drivers/staging/media/omap4iss/iss_ipipeif.h index c6bd96d9656c..dd906b41cf9b 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.h +++ b/drivers/staging/media/omap4iss/iss_ipipeif.h @@ -78,6 +78,7 @@ struct iss_ipipeif_device { struct iss_device; int omap4iss_ipipeif_init(struct iss_device *iss); +int omap4iss_ipipeif_create_pads_links(struct iss_device *iss); void omap4iss_ipipeif_cleanup(struct iss_device *iss); int omap4iss_ipipeif_register_entities(struct iss_ipipeif_device *ipipeif, struct v4l2_device *vdev); diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index a2cb57cb460d..4a474873a8df 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -799,18 +799,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer) resizer->video_out.bpl_zero_padding = 1; resizer->video_out.bpl_max = 0x1ffe0; - ret = omap4iss_video_init(&resizer->video_out, "ISP resizer a"); - if (ret < 0) - return ret; - - /* Connect the RESIZER subdev to the video node. */ - ret = media_create_pad_link(&resizer->subdev.entity, - RESIZER_PAD_SOURCE_MEM, - &resizer->video_out.video.entity, 0, 0); - if (ret < 0) - return ret; - - return 0; + return omap4iss_video_init(&resizer->video_out, "ISP resizer a"); } void omap4iss_resizer_unregister_entities(struct iss_resizer_device *resizer) @@ -862,6 +851,22 @@ int omap4iss_resizer_init(struct iss_device *iss) return resizer_init_entities(resizer); } +/* + * omap4iss_resizer_create_pads_links() - RESIZER pads links creation + * @iss: Pointer to ISS device + * + * return negative error code or zero on success + */ +int omap4iss_resizer_create_pads_links(struct iss_device *iss) +{ + struct iss_resizer_device *resizer = &iss->resizer; + + /* Connect the RESIZER subdev to the video node. */ + return media_create_pad_link(&resizer->subdev.entity, + RESIZER_PAD_SOURCE_MEM, + &resizer->video_out.video.entity, 0, 0); +} + /* * omap4iss_resizer_cleanup - RESIZER module cleanup. * @iss: Device pointer specific to the OMAP4 ISS. diff --git a/drivers/staging/media/omap4iss/iss_resizer.h b/drivers/staging/media/omap4iss/iss_resizer.h index 1e145abafc65..98ab950253d0 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.h +++ b/drivers/staging/media/omap4iss/iss_resizer.h @@ -61,6 +61,7 @@ struct iss_resizer_device { struct iss_device; int omap4iss_resizer_init(struct iss_device *iss); +int omap4iss_resizer_create_pads_links(struct iss_device *iss); void omap4iss_resizer_cleanup(struct iss_device *iss); int omap4iss_resizer_register_entities(struct iss_resizer_device *resizer, struct v4l2_device *vdev); -- cgit v1.2.3 From 7213fe7eec174fb2b958ecc3ce04a6f811c2d4da Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 3 Sep 2015 11:20:34 -0300 Subject: [media] v4l: vsp1: create pad links after subdev registration The vsp1 driver creates the pads links before the media entities are registered with the media device. This doesn't work now that object IDs are used to create links so the media_device has to be set. Move entities registration logic before pads links creation. Signed-off-by: Javier Martinez Canillas Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vsp1/vsp1_drv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 9cd94a76a9ed..2aa427d3ff39 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -250,6 +250,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) list_add_tail(&wpf->entity.list_dev, &vsp1->entities); } + /* Register all subdevs. */ + list_for_each_entry(entity, &vsp1->entities, list_dev) { + ret = v4l2_device_register_subdev(&vsp1->v4l2_dev, + &entity->subdev); + if (ret < 0) + goto done; + } + /* Create links. */ list_for_each_entry(entity, &vsp1->entities, list_dev) { if (entity->type == VSP1_ENTITY_LIF || @@ -269,14 +277,6 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) return ret; } - /* Register all subdevs. */ - list_for_each_entry(entity, &vsp1->entities, list_dev) { - ret = v4l2_device_register_subdev(&vsp1->v4l2_dev, - &entity->subdev); - if (ret < 0) - goto done; - } - ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev); done: -- cgit v1.2.3 From c7621b3044f705dd20019e82a8418491b8080327 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 3 Sep 2015 12:19:25 -0300 Subject: [media] v4l: vsp1: separate links creation from entities init The vsp1 driver initializes the entities and creates the pads links before the entities are registered with the media device. This doesn't work now that object IDs are used to create links so the media_device has to be set. Split out the pads links creation from the entity initialization so are made after the entities registration. Signed-off-by: Javier Martinez Canillas Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vsp1/vsp1_drv.c | 14 ++++++++++-- drivers/media/platform/vsp1/vsp1_rpf.c | 29 ++++++++++++++++-------- drivers/media/platform/vsp1/vsp1_rwpf.h | 5 +++++ drivers/media/platform/vsp1/vsp1_wpf.c | 40 ++++++++++++++++++++------------- 4 files changed, 62 insertions(+), 26 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 2aa427d3ff39..8f995d267646 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -260,9 +260,19 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) /* Create links. */ list_for_each_entry(entity, &vsp1->entities, list_dev) { - if (entity->type == VSP1_ENTITY_LIF || - entity->type == VSP1_ENTITY_RPF) + if (entity->type == VSP1_ENTITY_LIF) { + ret = vsp1_wpf_create_pads_links(vsp1, entity); + if (ret < 0) + goto done; + continue; + } + + if (entity->type == VSP1_ENTITY_RPF) { + ret = vsp1_rpf_create_pads_links(vsp1, entity); + if (ret < 0) + goto done; continue; + } ret = vsp1_create_links(vsp1, entity); if (ret < 0) diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c index 1bd51d22ff04..847fb6d01a5a 100644 --- a/drivers/media/platform/vsp1/vsp1_rpf.c +++ b/drivers/media/platform/vsp1/vsp1_rpf.c @@ -277,18 +277,29 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) rpf->entity.video = video; - /* Connect the video device to the RPF. */ - ret = media_create_pad_link(&rpf->video.video.entity, 0, - &rpf->entity.subdev.entity, - RWPF_PAD_SINK, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); - if (ret < 0) - goto error; - return rpf; error: vsp1_entity_destroy(&rpf->entity); return ERR_PTR(ret); } + +/* + * vsp1_rpf_create_pads_links_create_pads_links() - RPF pads links creation + * @vsp1: Pointer to VSP1 device + * @entity: Pointer to VSP1 entity + * + * return negative error code or zero on success + */ +int vsp1_rpf_create_pads_links(struct vsp1_device *vsp1, + struct vsp1_entity *entity) +{ + struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); + + /* Connect the video device to the RPF. */ + return media_create_pad_link(&rpf->video.video.entity, 0, + &rpf->entity.subdev.entity, + RWPF_PAD_SINK, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); +} diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h index f452dce1a931..6638b3587369 100644 --- a/drivers/media/platform/vsp1/vsp1_rwpf.h +++ b/drivers/media/platform/vsp1/vsp1_rwpf.h @@ -50,6 +50,11 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev *subdev) struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index); struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index); +int vsp1_rpf_create_pads_links(struct vsp1_device *vsp1, + struct vsp1_entity *entity); +int vsp1_wpf_create_pads_links(struct vsp1_device *vsp1, + struct vsp1_entity *entity); + int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code); diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c index ca19c534dac6..969278bc1d41 100644 --- a/drivers/media/platform/vsp1/vsp1_wpf.c +++ b/drivers/media/platform/vsp1/vsp1_wpf.c @@ -220,7 +220,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) struct v4l2_subdev *subdev; struct vsp1_video *video; struct vsp1_rwpf *wpf; - unsigned int flags; int ret; wpf = devm_kzalloc(vsp1->dev, sizeof(*wpf), GFP_KERNEL); @@ -276,20 +275,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) goto error; wpf->entity.video = video; - - /* Connect the video device to the WPF. All connections are immutable - * except for the WPF0 source link if a LIF is present. - */ - flags = MEDIA_LNK_FL_ENABLED; - if (!(vsp1->pdata.features & VSP1_HAS_LIF) || index != 0) - flags |= MEDIA_LNK_FL_IMMUTABLE; - - ret = media_create_pad_link(&wpf->entity.subdev.entity, - RWPF_PAD_SOURCE, - &wpf->video.video.entity, 0, flags); - if (ret < 0) - goto error; - wpf->entity.sink = &wpf->video.video.entity; return wpf; @@ -298,3 +283,28 @@ error: vsp1_entity_destroy(&wpf->entity); return ERR_PTR(ret); } + +/* + * vsp1_wpf_create_pads_links_create_pads_links() - RPF pads links creation + * @vsp1: Pointer to VSP1 device + * @entity: Pointer to VSP1 entity + * + * return negative error code or zero on success + */ +int vsp1_wpf_create_pads_links(struct vsp1_device *vsp1, + struct vsp1_entity *entity) +{ + struct vsp1_rwpf *wpf = to_rwpf(&entity->subdev); + unsigned int flags; + + /* Connect the video device to the WPF. All connections are immutable + * except for the WPF0 source link if a LIF is present. + */ + flags = MEDIA_LNK_FL_ENABLED; + if (!(vsp1->pdata.features & VSP1_HAS_LIF) || entity->index != 0) + flags |= MEDIA_LNK_FL_IMMUTABLE; + + return media_create_pad_link(&wpf->entity.subdev.entity, + RWPF_PAD_SOURCE, + &wpf->video.video.entity, 0, flags); +} -- cgit v1.2.3 From c5a98cac6ecd78ca647c41cb25e3ea1835579d70 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 3 Sep 2015 08:46:06 -0300 Subject: [media] uvcvideo: create pad links after subdev registration The uvc driver creates the pads links before the media entity is registered with the media device. This doesn't work now that obj IDs are used to create links so the media_device has to be set. Move entities registration logic before pads links creation. Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_entity.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 429e428ccd93..7f82b65b238e 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -25,6 +25,15 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain, struct uvc_entity *entity) +{ + if (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING) + return 0; + + return v4l2_device_register_subdev(&chain->dev->vdev, &entity->subdev); +} + +static int uvc_mc_create_pads_links(struct uvc_video_chain *chain, + struct uvc_entity *entity) { const u32 flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE; struct media_entity *sink; @@ -62,10 +71,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain, return ret; } - if (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING) - return 0; - - return v4l2_device_register_subdev(&chain->dev->vdev, &entity->subdev); + return 0; } static struct v4l2_subdev_ops uvc_subdev_ops = { @@ -124,5 +130,14 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain) } } + list_for_each_entry(entity, &chain->entities, chain) { + ret = uvc_mc_create_pads_links(chain, entity); + if (ret < 0) { + uvc_printk(KERN_INFO, "Failed to create pads links for " + "entity %u\n", entity->id); + return ret; + } + } + return 0; } -- cgit v1.2.3 From ada58ced508ffb75ff59f23b726ffc79ac2282fe Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 3 Sep 2015 09:00:27 -0300 Subject: [media] smiapp: create pad links after subdev registration The smiapp driver creates the pads links before the media entity is registered with the media device. This doesn't work now that object IDs are used to create links so the media_device has to be set. Move entity registration logic before pads links creation. Signed-off-by: Javier Martinez Canillas Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/smiapp/smiapp-core.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index cf0cd507c2d0..df4f8824c344 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2495,23 +2495,23 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) return rval; } - rval = media_create_pad_link(&this->sd.entity, - this->source_pad, - &last->sd.entity, - last->sink_pad, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); + rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, + &this->sd); if (rval) { dev_err(&client->dev, - "media_create_pad_link failed\n"); + "v4l2_device_register_subdev failed\n"); return rval; } - rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, - &this->sd); + rval = media_create_pad_link(&this->sd.entity, + this->source_pad, + &last->sd.entity, + last->sink_pad, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); if (rval) { dev_err(&client->dev, - "v4l2_device_register_subdev failed\n"); + "media_create_pad_link failed\n"); return rval; } } -- cgit v1.2.3 From 8f6d368f726bb4fa069af5ef5806f15ba6da6ad8 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 19 Aug 2015 20:18:35 -0300 Subject: [media] media: Don't accept early-created links Links are graph objects that represent the links of two already existing objects in the graph. While with the current implementation, it is possible to create the links earlier, It doesn't make any sense to allow linking two objects when they are not both created. So, remove the code that would be handling those early-created links and add a BUG_ON() to ensure that. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 7 ------- drivers/media/media-entity.c | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 138b18416460..0d85c6c28004 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -443,13 +443,6 @@ int __must_check media_device_register_entity(struct media_device *mdev, media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); list_add_tail(&entity->list, &mdev->entities); - /* - * Initialize objects at the links - * in the case where links got created before entity register - */ - for (i = 0; i < entity->num_links; i++) - media_gobj_init(mdev, MEDIA_GRAPH_LINK, - &entity->links[i].graph_obj); /* Initialize objects at the pads */ for (i = 0; i < entity->num_pads; i++) media_gobj_init(mdev, MEDIA_GRAPH_PAD, diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 160ce2cc0865..f85a711d4958 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -149,6 +149,8 @@ void media_gobj_init(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj) { + BUG_ON(!mdev); + gobj->mdev = mdev; /* Create a per-type unique object ID */ -- cgit v1.2.3 From 57208e5e25f263d27ea00e530c95f62071573cb7 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 7 Aug 2015 06:55:40 -0300 Subject: [media] media: convert links from array to list The entire logic that represent graph links were developed on a time where there were no needs to dynamic remove links. So, although links are created/removed one by one via some functions, they're stored as an array inside the entity struct. As the array may grow, there's a logic inside the code that checks if the amount of space is not enough to store the needed links. If it isn't the core uses krealloc() to change the size of the link, with is bad, as it leaves the memory fragmented. So, convert links into a list. Also, currently, both source and sink entities need the link at the graph traversal logic inside media_entity. So there's a logic duplicating all links. That makes it to spend twice the memory needed. This is not a big deal for today's usage, where the number of links are not big. Yet, if during the MC workshop discussions, it was said that IIO graphs could have up to 4,000 entities. So, we may want to remove the duplication on some future. The problem is that it would require a separate linked list to store the backlinks inside the entity, or to use a more complex algorithm to do graph backlink traversal, with is something that the current graph traversal inside the core can't cope with. So, let's postpone a such change if/when it is actually needed. It should also be noticed that the media_link structure uses 44 bytes on 32-bit architectures and 84 bytes on 64-bit architecture. It will thus be allocated out of the 64-bytes and 96-bytes pools respectively. That's a 12.5% memory waste on 64-bit architectures and 31.25% on 32-bit architecture. A linked list is less efficient than an array in this case, but this could later be optimized if we can get rid of the reverse links (with would reduce memory allocation by 50%). Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvb_frontend.c | 9 +-- drivers/media/media-device.c | 25 +++--- drivers/media/media-entity.c | 128 +++++++++++++++--------------- drivers/media/usb/au0828/au0828-core.c | 12 ++- drivers/media/usb/au0828/au0828-video.c | 8 +- drivers/media/usb/cx231xx/cx231xx-video.c | 8 +- include/media/media-entity.h | 10 +-- 7 files changed, 97 insertions(+), 103 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index b64f33776b74..42ab6aaeed7d 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -622,7 +622,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) struct media_device *mdev = adapter->mdev; struct media_entity *entity, *source; struct media_link *link, *found_link = NULL; - int i, ret, n_links = 0, active_links = 0; + int ret, n_links = 0, active_links = 0; fepriv->pipe_start_entity = NULL; @@ -632,8 +632,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) entity = fepriv->dvbdev->entity; fepriv->pipe_start_entity = entity; - for (i = 0; i < entity->num_links; i++) { - link = &entity->links[i]; + list_for_each_entry(link, &entity->links, list) { if (link->sink->entity == entity) { found_link = link; n_links++; @@ -659,13 +658,11 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe) source = found_link->source->entity; fepriv->pipe_start_entity = source; - for (i = 0; i < source->num_links; i++) { + list_for_each_entry(link, &source->links, list) { struct media_entity *sink; int flags = 0; - link = &source->links[i]; sink = link->sink->entity; - if (sink == entity) flags = MEDIA_LNK_FL_ENABLED; diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 0d85c6c28004..3e649cacfc07 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -150,22 +151,21 @@ static long __media_device_enum_links(struct media_device *mdev, } if (links->links) { - struct media_link_desc __user *ulink; - unsigned int l; + struct media_link *ent_link; + struct media_link_desc __user *ulink = links->links; - for (l = 0, ulink = links->links; l < entity->num_links; l++) { + list_for_each_entry(ent_link, &entity->links, list) { struct media_link_desc link; /* Ignore backlinks. */ - if (entity->links[l].source->entity != entity) + if (ent_link->source->entity != entity) continue; - memset(&link, 0, sizeof(link)); - media_device_kpad_to_upad(entity->links[l].source, + media_device_kpad_to_upad(ent_link->source, &link.source); - media_device_kpad_to_upad(entity->links[l].sink, + media_device_kpad_to_upad(ent_link->sink, &link.sink); - link.flags = entity->links[l].flags; + link.flags = ent_link->flags; if (copy_to_user(ulink, &link, sizeof(*ulink))) return -EFAULT; ulink++; @@ -437,6 +437,7 @@ int __must_check media_device_register_entity(struct media_device *mdev, /* Warn if we apparently re-register an entity */ WARN_ON(entity->graph_obj.mdev != NULL); entity->graph_obj.mdev = mdev; + INIT_LIST_HEAD(&entity->links); spin_lock(&mdev->lock); /* Initialize media_gobj embedded at the entity */ @@ -465,13 +466,17 @@ void media_device_unregister_entity(struct media_entity *entity) { int i; struct media_device *mdev = entity->graph_obj.mdev; + struct media_link *link, *tmp; if (mdev == NULL) return; spin_lock(&mdev->lock); - for (i = 0; i < entity->num_links; i++) - media_gobj_remove(&entity->links[i].graph_obj); + list_for_each_entry_safe(link, tmp, &entity->links, list) { + media_gobj_remove(&link->graph_obj); + list_del(&link->list); + kfree(link); + } for (i = 0; i < entity->num_pads; i++) media_gobj_remove(&entity->pads[i].graph_obj); media_gobj_remove(&entity->graph_obj); diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index f85a711d4958..df110acdb2f6 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -209,21 +209,13 @@ int media_entity_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads) { - struct media_link *links; - unsigned int max_links = num_pads; unsigned int i; - links = kzalloc(max_links * sizeof(links[0]), GFP_KERNEL); - if (links == NULL) - return -ENOMEM; - entity->group_id = 0; - entity->max_links = max_links; entity->num_links = 0; entity->num_backlinks = 0; entity->num_pads = num_pads; entity->pads = pads; - entity->links = links; for (i = 0; i < num_pads; i++) { pads[i].entity = entity; @@ -237,7 +229,13 @@ EXPORT_SYMBOL_GPL(media_entity_init); void media_entity_cleanup(struct media_entity *entity) { - kfree(entity->links); + struct media_link *link, *tmp; + + list_for_each_entry_safe(link, tmp, &entity->links, list) { + media_gobj_remove(&link->graph_obj); + list_del(&link->list); + kfree(link); + } } EXPORT_SYMBOL_GPL(media_entity_cleanup); @@ -263,7 +261,7 @@ static void stack_push(struct media_entity_graph *graph, return; } graph->top++; - graph->stack[graph->top].link = 0; + graph->stack[graph->top].link = (&entity->links)->next; graph->stack[graph->top].entity = entity; } @@ -305,6 +303,7 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph, } EXPORT_SYMBOL_GPL(media_entity_graph_walk_start); + /** * media_entity_graph_walk_next - Get the next entity in the graph * @graph: Media graph structure @@ -328,14 +327,16 @@ media_entity_graph_walk_next(struct media_entity_graph *graph) * top of the stack until no more entities on the level can be * found. */ - while (link_top(graph) < stack_top(graph)->num_links) { + while (link_top(graph) != &(stack_top(graph)->links)) { struct media_entity *entity = stack_top(graph); - struct media_link *link = &entity->links[link_top(graph)]; + struct media_link *link; struct media_entity *next; + link = list_entry(link_top(graph), typeof(*link), list); + /* The link is not enabled so we do not follow. */ if (!(link->flags & MEDIA_LNK_FL_ENABLED)) { - link_top(graph)++; + link_top(graph) = link_top(graph)->next; continue; } @@ -346,12 +347,12 @@ media_entity_graph_walk_next(struct media_entity_graph *graph) /* Has the entity already been visited? */ if (__test_and_set_bit(media_entity_id(next), graph->entities)) { - link_top(graph)++; + link_top(graph) = link_top(graph)->next; continue; } /* Push the new entity to stack and start over. */ - link_top(graph)++; + link_top(graph) = link_top(graph)->next; stack_push(graph, next); } @@ -383,6 +384,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_device *mdev = entity->graph_obj.mdev; struct media_entity_graph graph; struct media_entity *entity_err = entity; + struct media_link *link; int ret; mutex_lock(&mdev->graph_mutex); @@ -392,7 +394,6 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, while ((entity = media_entity_graph_walk_next(&graph))) { DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS); DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS); - unsigned int i; entity->stream_count++; WARN_ON(entity->pipe && entity->pipe != pipe); @@ -408,8 +409,7 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, bitmap_zero(active, entity->num_pads); bitmap_fill(has_no_links, entity->num_pads); - for (i = 0; i < entity->num_links; i++) { - struct media_link *link = &entity->links[i]; + list_for_each_entry(link, &entity->links, list) { struct media_pad *pad = link->sink->entity == entity ? link->sink : link->source; @@ -570,25 +570,20 @@ EXPORT_SYMBOL_GPL(media_entity_put); static struct media_link *media_entity_add_link(struct media_entity *entity) { - if (entity->num_links >= entity->max_links) { - struct media_link *links = entity->links; - unsigned int max_links = entity->max_links + 2; - unsigned int i; - - links = krealloc(links, max_links * sizeof(*links), GFP_KERNEL); - if (links == NULL) - return NULL; + struct media_link *link; - for (i = 0; i < entity->num_links; i++) - links[i].reverse->reverse = &links[i]; + link = kzalloc(sizeof(*link), GFP_KERNEL); + if (link == NULL) + return NULL; - entity->max_links = max_links; - entity->links = links; - } + list_add_tail(&link->list, &entity->links); - return &entity->links[entity->num_links++]; + return link; } +static void __media_entity_remove_link(struct media_entity *entity, + struct media_link *link); + int media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags) @@ -617,7 +612,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, */ backlink = media_entity_add_link(sink); if (backlink == NULL) { - source->num_links--; + __media_entity_remove_link(source, link); return -ENOMEM; } @@ -633,43 +628,51 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, backlink->reverse = link; sink->num_backlinks++; + sink->num_links++; + source->num_links++; return 0; } EXPORT_SYMBOL_GPL(media_create_pad_link); -void __media_entity_remove_links(struct media_entity *entity) +static void __media_entity_remove_link(struct media_entity *entity, + struct media_link *link) { - unsigned int i; + struct media_link *rlink, *tmp; + struct media_entity *remote; + unsigned int r = 0; + + if (link->source->entity == entity) + remote = link->sink->entity; + else + remote = link->source->entity; - for (i = 0; i < entity->num_links; i++) { - struct media_link *link = &entity->links[i]; - struct media_entity *remote; - unsigned int r = 0; + list_for_each_entry_safe(rlink, tmp, &remote->links, list) { + if (rlink != link->reverse) { + r++; + continue; + } if (link->source->entity == entity) - remote = link->sink->entity; - else - remote = link->source->entity; + remote->num_backlinks--; - while (r < remote->num_links) { - struct media_link *rlink = &remote->links[r]; - - if (rlink != link->reverse) { - r++; - continue; - } + if (--remote->num_links == 0) + break; - if (link->source->entity == entity) - remote->num_backlinks--; + /* Remove the remote link */ + list_del(&rlink->list); + kfree(rlink); + } + list_del(&link->list); + kfree(link); +} - if (--remote->num_links == 0) - break; +void __media_entity_remove_links(struct media_entity *entity) +{ + struct media_link *link, *tmp; - /* Insert last entry in place of the dropped link. */ - *rlink = remote->links[remote->num_links]; - } - } + list_for_each_entry_safe(link, tmp, &entity->links, list) + __media_entity_remove_link(entity, link); entity->num_links = 0; entity->num_backlinks = 0; @@ -794,11 +797,8 @@ struct media_link * media_entity_find_link(struct media_pad *source, struct media_pad *sink) { struct media_link *link; - unsigned int i; - - for (i = 0; i < source->entity->num_links; ++i) { - link = &source->entity->links[i]; + list_for_each_entry(link, &source->entity->links, list) { if (link->source->entity == source->entity && link->source->index == source->index && link->sink->entity == sink->entity && @@ -822,11 +822,9 @@ EXPORT_SYMBOL_GPL(media_entity_find_link); */ struct media_pad *media_entity_remote_pad(struct media_pad *pad) { - unsigned int i; - - for (i = 0; i < pad->entity->num_links; i++) { - struct media_link *link = &pad->entity->links[i]; + struct media_link *link; + list_for_each_entry(link, &pad->entity->links, list) { if (!(link->flags & MEDIA_LNK_FL_ENABLED)) continue; diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index a55eb524ea21..7f645bcb7463 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -261,13 +261,11 @@ static void au0828_create_media_graph(struct au0828_dev *dev) if (tuner) media_create_pad_link(tuner, 0, decoder, 0, - MEDIA_LNK_FL_ENABLED); - if (dev->vdev.entity.links) - media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, - MEDIA_LNK_FL_ENABLED); - if (dev->vbi_dev.entity.links) - media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, - MEDIA_LNK_FL_ENABLED); + MEDIA_LNK_FL_ENABLED); + media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, + MEDIA_LNK_FL_ENABLED); + media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, + MEDIA_LNK_FL_ENABLED); #endif } diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index a1df4eb93b14..97df879c4199 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -644,7 +644,7 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev) struct media_device *mdev = dev->media_dev; struct media_entity *source; struct media_link *link, *found_link = NULL; - int i, ret, active_links = 0; + int ret, active_links = 0; if (!mdev || !dev->decoder) return 0; @@ -656,8 +656,7 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev) * do DVB streaming while the DMA engine is being used for V4L2, * this should be enough for the actual needs. */ - for (i = 0; i < dev->decoder->num_links; i++) { - link = &dev->decoder->links[i]; + list_for_each_entry(link, &dev->decoder->links, list) { if (link->sink->entity == dev->decoder) { found_link = link; if (link->flags & MEDIA_LNK_FL_ENABLED) @@ -670,11 +669,10 @@ static int au0828_enable_analog_tuner(struct au0828_dev *dev) return 0; source = found_link->source->entity; - for (i = 0; i < source->num_links; i++) { + list_for_each_entry(link, &source->links, list) { struct media_entity *sink; int flags = 0; - link = &source->links[i]; sink = link->sink->entity; if (sink == dev->decoder) diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index cbb28c912319..b5eb9f613872 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -106,7 +106,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) struct media_device *mdev = dev->media_dev; struct media_entity *entity, *decoder = NULL, *source; struct media_link *link, *found_link = NULL; - int i, ret, active_links = 0; + int ret, active_links = 0; if (!mdev) return 0; @@ -127,8 +127,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) if (!decoder) return 0; - for (i = 0; i < decoder->num_links; i++) { - link = &decoder->links[i]; + list_for_each_entry(link, &decoder->links, list) { if (link->sink->entity == decoder) { found_link = link; if (link->flags & MEDIA_LNK_FL_ENABLED) @@ -141,11 +140,10 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) return 0; source = found_link->source->entity; - for (i = 0; i < source->num_links; i++) { + list_for_each_entry(link, &source->links, list) { struct media_entity *sink; int flags = 0; - link = &source->links[i]; sink = link->sink->entity; if (sink == entity) diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 4d5fc91c4134..2e5646cf36e7 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -74,6 +74,7 @@ struct media_pipeline { struct media_link { struct media_gobj graph_obj; + struct list_head list; struct media_pad *source; /* Source pad */ struct media_pad *sink; /* Sink pad */ struct media_link *reverse; /* Link in the reverse direction */ @@ -116,10 +117,9 @@ struct media_entity { u16 num_links; /* Number of existing links, both * enabled and disabled */ u16 num_backlinks; /* Number of backlinks */ - u16 max_links; /* Maximum number of links */ - struct media_pad *pads; /* Pads array (num_pads elements) */ - struct media_link *links; /* Links array (max_links elements)*/ + struct media_pad *pads; /* Pads array (num_pads objects) */ + struct list_head links; /* Links list */ const struct media_entity_operations *ops; /* Entity operations */ @@ -220,7 +220,7 @@ static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id) struct media_entity_graph { struct { struct media_entity *entity; - int link; + struct list_head *link; } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH]; DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID); @@ -254,7 +254,7 @@ void media_gobj_init(struct media_device *mdev, void media_gobj_remove(struct media_gobj *gobj); int media_entity_init(struct media_entity *entity, u16 num_pads, - struct media_pad *pads); + struct media_pad *pads); void media_entity_cleanup(struct media_entity *entity); int media_create_pad_link(struct media_entity *source, u16 source_pad, -- cgit v1.2.3 From 23615de5ee742f2f49833777ab015cf1a83fcbc3 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 20 Aug 2015 08:21:35 -0300 Subject: [media] media: make add link more generic The media_entity_add_link() function takes an entity as an argument just to get the list head. Make it more generic by changing the function argument to list_head. No functional changes. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index df110acdb2f6..e7ee666834a2 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -568,7 +568,7 @@ EXPORT_SYMBOL_GPL(media_entity_put); * Links management */ -static struct media_link *media_entity_add_link(struct media_entity *entity) +static struct media_link *media_add_link(struct list_head *head) { struct media_link *link; @@ -576,7 +576,7 @@ static struct media_link *media_entity_add_link(struct media_entity *entity) if (link == NULL) return NULL; - list_add_tail(&link->list, &entity->links); + list_add_tail(&link->list, head); return link; } @@ -595,7 +595,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, BUG_ON(source_pad >= source->num_pads); BUG_ON(sink_pad >= sink->num_pads); - link = media_entity_add_link(source); + link = media_add_link(&source->links); if (link == NULL) return -ENOMEM; @@ -610,7 +610,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, /* Create the backlink. Backlinks are used to help graph traversal and * are not reported to userspace. */ - backlink = media_entity_add_link(sink); + backlink = media_add_link(&sink->links); if (backlink == NULL) { __media_entity_remove_link(source, link); return -ENOMEM; -- cgit v1.2.3 From 3c0e266fba5897c02c4bd23521a3271d338650ad Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Aug 2015 08:45:34 -0300 Subject: [media] media: make link debug printk more generic Remove entity name from the link as this exists only if the object type is PAD on both link ends. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index e7ee666834a2..e22954d2acbd 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -94,16 +94,14 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) struct media_link *link = gobj_to_link(gobj); dev_dbg(gobj->mdev->dev, - "%s: id 0x%08x link#%d: '%s' %s#%d ==> '%s' %s#%d\n", + "%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n", event_name, gobj->id, media_localid(gobj), - link->source->entity->name, - gobj_type(media_type(&link->source->graph_obj)), - media_localid(&link->source->graph_obj), + gobj_type(media_type(link->gobj0)), + media_localid(link->gobj0), - link->sink->entity->name, - gobj_type(media_type(&link->sink->graph_obj)), - media_localid(&link->sink->graph_obj)); + gobj_type(media_type(link->gobj1)), + media_localid(link->gobj1)); break; } case MEDIA_GRAPH_PAD: -- cgit v1.2.3 From 86e2662071d6f26704bb290317746149ce07be7a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 7 Aug 2015 10:36:25 -0300 Subject: [media] media: add support to link interfaces and entities Now that we have a new graph object called "interfaces", we need to be able to link them to the entities. Add a linked list to the interfaces to allow them to be linked to the entities. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 38 ++++++++++++++++++++++++++++++++++++++ include/media/media-entity.h | 9 +++++++++ 2 files changed, 47 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index e22954d2acbd..55cafb016fe8 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -857,6 +857,7 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, intf->type = type; intf->flags = flags; + INIT_LIST_HEAD(&intf->links); devnode->major = major; devnode->minor = minor; @@ -874,3 +875,40 @@ void media_devnode_remove(struct media_intf_devnode *devnode) kfree(devnode); } EXPORT_SYMBOL_GPL(media_devnode_remove); + +struct media_link *media_create_intf_link(struct media_entity *entity, + struct media_interface *intf, + u32 flags) +{ + struct media_link *link; + + link = media_add_link(&intf->links); + if (link == NULL) + return NULL; + + link->intf = intf; + link->entity = entity; + link->flags = flags; + + /* Initialize graph object embedded at the new link */ + media_gobj_init(intf->graph_obj.mdev, MEDIA_GRAPH_LINK, + &link->graph_obj); + + return link; +} +EXPORT_SYMBOL_GPL(media_create_intf_link); + + +static void __media_remove_intf_link(struct media_link *link) +{ + media_gobj_remove(&link->graph_obj); + kfree(link); +} + +void media_remove_intf_link(struct media_link *link) +{ + mutex_lock(&link->graph_obj.mdev->graph_mutex); + __media_remove_intf_link(link); + mutex_unlock(&link->graph_obj.mdev->graph_mutex); +} +EXPORT_SYMBOL_GPL(media_remove_intf_link); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a7b21a7f4c64..d64e8cb4de98 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -78,10 +78,12 @@ struct media_link { union { struct media_gobj *gobj0; struct media_pad *source; + struct media_interface *intf; }; union { struct media_gobj *gobj1; struct media_pad *sink; + struct media_entity *entity; }; struct media_link *reverse; /* Link in the reverse direction */ unsigned long flags; /* Link flags (MEDIA_LNK_FL_*) */ @@ -154,6 +156,7 @@ struct media_entity { * struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object + * @links: List of links pointing to graph entities * @type: Type of the interface as defined at the * uapi/media/media.h header, e. g. * MEDIA_INTF_T_* @@ -161,6 +164,7 @@ struct media_entity { */ struct media_interface { struct media_gobj graph_obj; + struct list_head links; u32 type; u32 flags; }; @@ -290,6 +294,11 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, u32 major, u32 minor, gfp_t gfp_flags); void media_devnode_remove(struct media_intf_devnode *devnode); +struct media_link *media_create_intf_link(struct media_entity *entity, + struct media_interface *intf, + u32 flags); +void media_remove_intf_link(struct media_link *link); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) -- cgit v1.2.3 From 1283f849dce2e64690e610216cd8dc3df9789bae Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 28 Aug 2015 15:43:36 -0300 Subject: [media] media-entity: add a helper function to create interface As we'll be adding other interface types in the future, put the common interface create code on a separate function. Suggested-by: Hans Verkuil Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 55cafb016fe8..d15797e8a142 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -839,6 +839,18 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) EXPORT_SYMBOL_GPL(media_entity_remote_pad); +static void media_interface_init(struct media_device *mdev, + struct media_interface *intf, + u32 gobj_type, + u32 intf_type, u32 flags) +{ + intf->type = intf_type; + intf->flags = flags; + INIT_LIST_HEAD(&intf->links); + + media_gobj_init(mdev, gobj_type, &intf->graph_obj); +} + /* Functions related to the media interface via device nodes */ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, @@ -847,23 +859,16 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev, gfp_t gfp_flags) { struct media_intf_devnode *devnode; - struct media_interface *intf; devnode = kzalloc(sizeof(*devnode), gfp_flags); if (!devnode) return NULL; - intf = &devnode->intf; - - intf->type = type; - intf->flags = flags; - INIT_LIST_HEAD(&intf->links); - devnode->major = major; devnode->minor = minor; - media_gobj_init(mdev, MEDIA_GRAPH_INTF_DEVNODE, - &devnode->intf.graph_obj); + media_interface_init(mdev, &devnode->intf, MEDIA_GRAPH_INTF_DEVNODE, + type, flags); return devnode; } -- cgit v1.2.3 From 8211b187ec6461e8d80a36304bd9fc087e3c490f Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Aug 2015 08:20:22 -0300 Subject: [media] dvbdev: add support for interfaces Now that the infrastruct for that is set, add support for interfaces. Please notice that we're missing two links: DVB FE intf -> tuner DVB demux intf -> dvr Those should be added latter, after having the entire graph set. With the current infrastructure, those should be added at dvb_create_media_graph(), but it would also require some extra core changes, to allow the function to enumerate the interfaces. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 102 ++++++++++++++++++++++++++++++---------- drivers/media/dvb-core/dvbdev.h | 1 + 2 files changed, 79 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 65f59f2124b4..6bf61d42c017 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -180,14 +180,36 @@ skip: return -ENFILE; } -static void dvb_register_media_device(struct dvb_device *dvbdev, - int type, int minor) +static void dvb_create_media_entity(struct dvb_device *dvbdev, + int type, int minor) { #if defined(CONFIG_MEDIA_CONTROLLER_DVB) int ret = 0, npads; - if (!dvbdev->adapter->mdev) + switch (type) { + case DVB_DEVICE_FRONTEND: + npads = 2; + break; + case DVB_DEVICE_DEMUX: + npads = 2; + break; + case DVB_DEVICE_CA: + npads = 2; + break; + case DVB_DEVICE_NET: + /* + * We should be creating entities for the MPE/ULE + * decapsulation hardware (or software implementation). + * + * However, the number of for the MPE/ULE decaps may not be + * fixed. As we don't have yet dynamic support for PADs at + * the Media Controller, let's not create the decap + * entities yet. + */ + return; + default: return; + } dvbdev->entity = kzalloc(sizeof(*dvbdev->entity), GFP_KERNEL); if (!dvbdev->entity) @@ -197,19 +219,6 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->entity->info.dev.minor = minor; dvbdev->entity->name = dvbdev->name; - switch (type) { - case DVB_DEVICE_CA: - case DVB_DEVICE_DEMUX: - case DVB_DEVICE_FRONTEND: - npads = 2; - break; - case DVB_DEVICE_NET: - npads = 0; - break; - default: - npads = 1; - } - if (npads) { dvbdev->pads = kcalloc(npads, sizeof(*dvbdev->pads), GFP_KERNEL); @@ -230,18 +239,11 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; - case DVB_DEVICE_DVR: - dvbdev->entity->type = MEDIA_ENT_T_DEVNODE_DVB_DVR; - dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; - break; case DVB_DEVICE_CA: dvbdev->entity->type = MEDIA_ENT_T_DEVNODE_DVB_CA; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; - case DVB_DEVICE_NET: - dvbdev->entity->type = MEDIA_ENT_T_DEVNODE_DVB_NET; - break; default: kfree(dvbdev->entity); dvbdev->entity = NULL; @@ -263,11 +265,63 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, return; } - printk(KERN_DEBUG "%s: media device '%s' registered.\n", + printk(KERN_DEBUG "%s: media entity '%s' registered.\n", __func__, dvbdev->entity->name); #endif } +static void dvb_register_media_device(struct dvb_device *dvbdev, + int type, int minor) +{ +#if defined(CONFIG_MEDIA_CONTROLLER_DVB) + u32 intf_type; + + if (!dvbdev->adapter->mdev) + return; + + dvb_create_media_entity(dvbdev, type, minor); + + switch (type) { + case DVB_DEVICE_FRONTEND: + intf_type = MEDIA_INTF_T_DVB_FE; + break; + case DVB_DEVICE_DEMUX: + intf_type = MEDIA_INTF_T_DVB_DEMUX; + break; + case DVB_DEVICE_DVR: + intf_type = MEDIA_INTF_T_DVB_DVR; + break; + case DVB_DEVICE_CA: + intf_type = MEDIA_INTF_T_DVB_CA; + break; + case DVB_DEVICE_NET: + intf_type = MEDIA_INTF_T_DVB_NET; + break; + default: + return; + } + + dvbdev->intf_devnode = media_devnode_create(dvbdev->adapter->mdev, + intf_type, 0, + DVB_MAJOR, minor, + GFP_KERNEL); + + /* + * Create the "obvious" link, e. g. the ones that represent + * a direct association between an interface and an entity. + * Other links should be created elsewhere, like: + * DVB FE intf -> tuner + * DVB demux intf -> dvr + */ + + if (!dvbdev->entity || !dvbdev->intf_devnode) + return; + + media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, 0); + +#endif +} + int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, const struct dvb_device *template, void *priv, int type) { diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index 1069a776bbdb..8398c8fb02b0 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -149,6 +149,7 @@ struct dvb_device { /* Allocated and filled inside dvbdev.c */ struct media_entity *entity; + struct media_intf_devnode *intf_devnode; struct media_pad *pads; #endif -- cgit v1.2.3 From 57cf79b79b18d885c144889989b47149e23c8dc2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Aug 2015 09:23:22 -0300 Subject: [media] media: add a linked list to track interfaces by mdev The media device should list the interface objects, so add a linked list for those interfaces in struct media_device. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 1 + drivers/media/media-entity.c | 3 +++ include/media/media-device.h | 2 ++ include/media/media-entity.h | 3 +++ 4 files changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 3e649cacfc07..659507bce63f 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -381,6 +381,7 @@ int __must_check __media_device_register(struct media_device *mdev, return -EINVAL; INIT_LIST_HEAD(&mdev->entities); + INIT_LIST_HEAD(&mdev->interfaces); spin_lock_init(&mdev->lock); mutex_init(&mdev->graph_mutex); diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index d15797e8a142..8449274bb50c 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -849,6 +849,8 @@ static void media_interface_init(struct media_device *mdev, INIT_LIST_HEAD(&intf->links); media_gobj_init(mdev, gobj_type, &intf->graph_obj); + + list_add_tail(&intf->list, &mdev->interfaces); } /* Functions related to the media interface via device nodes */ @@ -877,6 +879,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create); void media_devnode_remove(struct media_intf_devnode *devnode) { media_gobj_remove(&devnode->intf.graph_obj); + list_del(&devnode->intf.list); kfree(devnode); } EXPORT_SYMBOL_GPL(media_devnode_remove); diff --git a/include/media/media-device.h b/include/media/media-device.h index 3b14394d5701..51807efa505b 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -46,6 +46,7 @@ struct device; * @link_id: Unique ID used on the last link registered * @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities + * @interfaces: List of registered interfaces * @lock: Entities list lock * @graph_mutex: Entities graph operation lock * @link_notify: Link state change notification callback @@ -77,6 +78,7 @@ struct media_device { u32 intf_devnode_id; struct list_head entities; + struct list_head interfaces; /* Protects the entities list */ spinlock_t lock; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index d64e8cb4de98..ca35e07d9348 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -156,6 +156,8 @@ struct media_entity { * struct media_intf_devnode - Define a Kernel API interface * * @graph_obj: embedded graph object + * @list: Linked list used to find other interfaces that belong + * to the same media controller * @links: List of links pointing to graph entities * @type: Type of the interface as defined at the * uapi/media/media.h header, e. g. @@ -164,6 +166,7 @@ struct media_entity { */ struct media_interface { struct media_gobj graph_obj; + struct list_head list; struct list_head links; u32 type; u32 flags; -- cgit v1.2.3 From 8ddb90d2e5dc1b80c538d371bfe361e1bae29297 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Aug 2015 09:32:38 -0300 Subject: [media] dvbdev: add support for indirect interface links Some interfaces indirectly control multiple entities. Add support for those. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 6bf61d42c017..ada0738d26f2 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -441,6 +441,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap) struct media_device *mdev = adap->mdev; struct media_entity *entity, *tuner = NULL, *fe = NULL; struct media_entity *demux = NULL, *dvr = NULL, *ca = NULL; + struct media_interface *intf; if (!mdev) return; @@ -476,6 +477,16 @@ void dvb_create_media_graph(struct dvb_adapter *adap) if (demux && ca) media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED); + + /* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */ + list_for_each_entry(intf, &mdev->interfaces, list) { + if (intf->type == MEDIA_INTF_T_DVB_CA && ca) + media_create_intf_link(ca, intf, 0); + if (intf->type == MEDIA_INTF_T_DVB_FE && tuner) + media_create_intf_link(tuner, intf, 0); + if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) + media_create_intf_link(demux, intf, 0); + } } EXPORT_SYMBOL_GPL(dvb_create_media_graph); #endif -- cgit v1.2.3 From 32fdc0e1a87c1ed50f77a9e54413165282e99b8b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Aug 2015 11:40:34 -0300 Subject: [media] uapi/media.h: Fix entity namespace Now that interfaces got created, we need to fix the entity namespace. So, let's create a consistent new namespace and add backward compatibility macros to keep the old namespace preserved. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 26 +++++++------- include/uapi/linux/media.h | 76 ++++++++++++++++++++++++++++++----------- 2 files changed, 70 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index ada0738d26f2..dadcf1655070 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -230,17 +230,17 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev, switch (type) { case DVB_DEVICE_FRONTEND: - dvbdev->entity->type = MEDIA_ENT_T_DEVNODE_DVB_FE; + dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMOD; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; case DVB_DEVICE_DEMUX: - dvbdev->entity->type = MEDIA_ENT_T_DEVNODE_DVB_DEMUX; + dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMUX; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; case DVB_DEVICE_CA: - dvbdev->entity->type = MEDIA_ENT_T_DEVNODE_DVB_CA; + dvbdev->entity->type = MEDIA_ENT_T_DVB_CA; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; @@ -439,7 +439,7 @@ EXPORT_SYMBOL(dvb_unregister_device); void dvb_create_media_graph(struct dvb_adapter *adap) { struct media_device *mdev = adap->mdev; - struct media_entity *entity, *tuner = NULL, *fe = NULL; + struct media_entity *entity, *tuner = NULL, *demod = NULL; struct media_entity *demux = NULL, *dvr = NULL, *ca = NULL; struct media_interface *intf; @@ -451,26 +451,26 @@ void dvb_create_media_graph(struct dvb_adapter *adap) case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: tuner = entity; break; - case MEDIA_ENT_T_DEVNODE_DVB_FE: - fe = entity; + case MEDIA_ENT_T_DVB_DEMOD: + demod = entity; break; - case MEDIA_ENT_T_DEVNODE_DVB_DEMUX: + case MEDIA_ENT_T_DVB_DEMUX: demux = entity; break; - case MEDIA_ENT_T_DEVNODE_DVB_DVR: + case MEDIA_ENT_T_DVB_TSOUT: dvr = entity; break; - case MEDIA_ENT_T_DEVNODE_DVB_CA: + case MEDIA_ENT_T_DVB_CA: ca = entity; break; } } - if (tuner && fe) - media_create_pad_link(tuner, 0, fe, 0, 0); + if (tuner && demod) + media_create_pad_link(tuner, 0, demod, 0, 0); - if (fe && demux) - media_create_pad_link(fe, 1, demux, 0, MEDIA_LNK_FL_ENABLED); + if (demod && demux) + media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED); if (demux && dvr) media_create_pad_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED); diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 3ad3d6be293f..8e9896820bee 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -42,31 +42,69 @@ struct media_device_info { #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) +/* + * Base numbers for entity types + * + * Please notice that the huge gap of 16 bits for each base is overkill! + * 8 bits is more than enough to avoid starving entity types for each + * subsystem. + * + * However, It is kept this way just to avoid binary breakages with the + * namespace provided on legacy versions of this header. + */ +#define MEDIA_ENT_T_DVB_BASE 0x00000000 +#define MEDIA_ENT_T_V4L2_BASE 0x00010000 +#define MEDIA_ENT_T_V4L2_SUBDEV_BASE 0x00020000 + +/* + * V4L2 entities - Those are used for DMA (mmap/DMABUF) and + * read()/write() data I/O associated with the V4L2 devnodes. + */ +#define MEDIA_ENT_T_V4L2_VIDEO (MEDIA_ENT_T_V4L2_BASE + 1) + /* + * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and + * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used + * to be declared for FB, ALSA and DVB entities. + * As those values were never actually used in practice, we're just + * adding them as backward compatibility macros and keeping the + * numberspace clean here. This way, we avoid breaking compilation, + * in the case of having some userspace application using the old + * symbols. + */ +#define MEDIA_ENT_T_V4L2_VBI (MEDIA_ENT_T_V4L2_BASE + 5) +#define MEDIA_ENT_T_V4L2_SWRADIO (MEDIA_ENT_T_V4L2_BASE + 6) + +/* V4L2 Sub-device entities */ +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1) +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2) +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3) + /* A converter of analogue video to its digital representation. */ +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4) + /* Tuner entity is actually both V4L2 and DVB subdev */ +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5) + +/* DVB entities */ +#define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_DVB_BASE + 1) +#define MEDIA_ENT_T_DVB_DEMUX (MEDIA_ENT_T_DVB_BASE + 2) +#define MEDIA_ENT_T_DVB_TSOUT (MEDIA_ENT_T_DVB_BASE + 3) +#define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 4) +#define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 5) + +/* Legacy symbols used to avoid userspace compilation breakages */ #define MEDIA_ENT_TYPE_SHIFT 16 #define MEDIA_ENT_TYPE_MASK 0x00ff0000 #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff -#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT) -#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1) +#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_T_V4L2_BASE +#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_T_V4L2_SUBDEV_BASE + +#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_T_V4L2_VIDEO + #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) -#define MEDIA_ENT_T_DEVNODE_DVB_FE (MEDIA_ENT_T_DEVNODE + 4) -#define MEDIA_ENT_T_DEVNODE_DVB_DEMUX (MEDIA_ENT_T_DEVNODE + 5) -#define MEDIA_ENT_T_DEVNODE_DVB_DVR (MEDIA_ENT_T_DEVNODE + 6) -#define MEDIA_ENT_T_DEVNODE_DVB_CA (MEDIA_ENT_T_DEVNODE + 7) -#define MEDIA_ENT_T_DEVNODE_DVB_NET (MEDIA_ENT_T_DEVNODE + 8) - -/* Legacy symbol. Use it to avoid userspace compilation breakages */ -#define MEDIA_ENT_T_DEVNODE_DVB MEDIA_ENT_T_DEVNODE_DVB_FE - -#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT) -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1) -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2) -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3) -/* A converter of analogue video to its digital representation. */ -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV + 4) - -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV + 5) +#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) + +/* Entity types */ #define MEDIA_ENT_FL_DEFAULT (1 << 0) -- cgit v1.2.3 From cf49066152c5b46c0b90f44593beda27997ca58b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Aug 2015 11:50:17 -0300 Subject: [media] replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L Now that interfaces and entities are distinct, it makes no sense of keeping something named as MEDIA_ENT_T_DEVNODE. This change was done with this script: for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_V4L,MEDIA_ENT_T_V4L2_VIDEO, <$i >a && mv a $i; done Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml | 2 +- drivers/media/platform/xilinx/xilinx-dma.c | 2 +- drivers/media/v4l2-core/v4l2-dev.c | 2 +- drivers/media/v4l2-core/v4l2-subdev.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml index 5872f8bbf774..910243d4edb8 100644 --- a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +++ b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml @@ -183,7 +183,7 @@ Unknown device node - MEDIA_ENT_T_DEVNODE_V4L + MEDIA_ENT_T_V4L2_VIDEO V4L video, radio or vbi device node diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 4b84a0e54a0c..9c8b27254253 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -193,7 +193,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe, while ((entity = media_entity_graph_walk_next(&graph))) { struct xvip_dma *dma; - if (entity->type != MEDIA_ENT_T_DEVNODE_V4L) + if (entity->type != MEDIA_ENT_T_V4L2_VIDEO) continue; dma = to_xvip_dma(media_entity_to_video_device(entity)); diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 6b1eaeddbdb3..2297571a0568 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -922,7 +922,7 @@ int __video_register_device(struct video_device *vdev, int type, int nr, /* Part 5: Register the entity. */ if (vdev->v4l2_dev->mdev && vdev->vfl_type != VFL_TYPE_SUBDEV) { - vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; + vdev->entity.type = MEDIA_ENT_T_V4L2_VIDEO; vdev->entity.name = vdev->name; vdev->entity.info.dev.major = VIDEO_MAJOR; vdev->entity.info.dev.minor = vdev->minor; diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 83615b8fb46a..e6e1115d8215 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad, return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt); } - WARN(pad->entity->type != MEDIA_ENT_T_DEVNODE_V4L, + WARN(pad->entity->type != MEDIA_ENT_T_V4L2_VIDEO, "Driver bug! Wrong media entity type 0x%08x, entity %s\n", pad->entity->type, pad->entity->name); -- cgit v1.2.3 From 3efdf62c5f68007020ef935ad2887e7fc4e31c36 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 7 May 2015 22:12:32 -0300 Subject: [media] media: use macros to check for V4L2 subdev entities Instead of relying on media subtype, use the new macros to detect if an entity is a subdev or an A/V DMA entity. Please note that most drivers assume that there's just AV_DMA or V4L2 subdevs. This is not true anymore, as we've added MC support for DVB, and there are plans to add support for ALSA and FB/DRM too. Ok, on the current pipelines supported by those drivers, just V4L stuff are there, but, assuming that some day a pipeline that also works with other subsystems will ever added, it is better to add explicit checks for the AV_DMA stuff. Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/common.c | 3 +-- drivers/media/platform/exynos4-is/fimc-capture.c | 5 ++--- drivers/media/platform/exynos4-is/fimc-isp-video.c | 3 +-- drivers/media/platform/exynos4-is/fimc-lite.c | 10 ++++------ drivers/media/platform/exynos4-is/media-dev.c | 7 +++---- drivers/media/platform/omap3isp/isp.c | 14 ++++++-------- drivers/media/platform/omap3isp/ispvideo.c | 7 +++---- drivers/media/platform/s3c-camif/camif-capture.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 9 ++++----- drivers/media/platform/xilinx/xilinx-dma.c | 6 ++---- drivers/media/v4l2-core/v4l2-subdev.c | 2 +- drivers/staging/media/davinci_vpfe/vpfe_video.c | 6 +++--- drivers/staging/media/omap4iss/iss.c | 14 ++++++-------- drivers/staging/media/omap4iss/iss_video.c | 5 ++--- 14 files changed, 39 insertions(+), 54 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/exynos4-is/common.c b/drivers/media/platform/exynos4-is/common.c index b6716c57b5db..b90f5bb15517 100644 --- a/drivers/media/platform/exynos4-is/common.c +++ b/drivers/media/platform/exynos4-is/common.c @@ -22,8 +22,7 @@ struct v4l2_subdev *fimc_find_remote_sensor(struct media_entity *entity) while (pad->flags & MEDIA_PAD_FL_SINK) { /* source pad */ pad = media_entity_remote_pad(pad); - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; sd = media_entity_to_v4l2_subdev(pad->entity); diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 8f5bee42783f..48a826372d3d 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -1136,8 +1136,7 @@ static int fimc_pipeline_validate(struct fimc_dev *fimc) } } - if (src_pad == NULL || - media_entity_type(src_pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!src_pad || !is_media_entity_v4l2_subdev(src_pad->entity)) break; /* Don't call FIMC subdev operation to avoid nested locking */ @@ -1392,7 +1391,7 @@ static int fimc_link_setup(struct media_entity *entity, struct fimc_vid_cap *vc = &fimc->vid_cap; struct v4l2_subdev *sensor; - if (media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!is_media_entity_v4l2_subdev(remote->entity)) return -EINVAL; if (WARN_ON(fimc == NULL)) diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c index 239df7d8bd30..9c7794bcf0c3 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c @@ -466,8 +466,7 @@ static int isp_video_pipeline_validate(struct fimc_isp *isp) /* Retrieve format at the source pad */ pad = media_entity_remote_pad(pad); - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; sd = media_entity_to_v4l2_subdev(pad->entity); diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 11d25712153d..957cf144a675 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -808,8 +808,7 @@ static int fimc_pipeline_validate(struct fimc_lite *fimc) } /* Retrieve format at the source pad */ pad = media_entity_remote_pad(pad); - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; sd = media_entity_to_v4l2_subdev(pad->entity); @@ -982,7 +981,6 @@ static int fimc_lite_link_setup(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct fimc_lite *fimc = v4l2_get_subdevdata(sd); - unsigned int remote_ent_type = media_entity_type(remote->entity); int ret = 0; if (WARN_ON(fimc == NULL)) @@ -994,7 +992,7 @@ static int fimc_lite_link_setup(struct media_entity *entity, switch (local->index) { case FLITE_SD_PAD_SINK: - if (remote_ent_type != MEDIA_ENT_T_V4L2_SUBDEV) { + if (!is_media_entity_v4l2_subdev(remote->entity)) { ret = -EINVAL; break; } @@ -1012,7 +1010,7 @@ static int fimc_lite_link_setup(struct media_entity *entity, case FLITE_SD_PAD_SOURCE_DMA: if (!(flags & MEDIA_LNK_FL_ENABLED)) atomic_set(&fimc->out_path, FIMC_IO_NONE); - else if (remote_ent_type == MEDIA_ENT_T_DEVNODE) + else if (is_media_entity_v4l2_io(remote->entity)) atomic_set(&fimc->out_path, FIMC_IO_DMA); else ret = -EINVAL; @@ -1021,7 +1019,7 @@ static int fimc_lite_link_setup(struct media_entity *entity, case FLITE_SD_PAD_SOURCE_ISP: if (!(flags & MEDIA_LNK_FL_ENABLED)) atomic_set(&fimc->out_path, FIMC_IO_NONE); - else if (remote_ent_type == MEDIA_ENT_T_V4L2_SUBDEV) + else if (is_media_entity_v4l2_subdev(remote->entity)) atomic_set(&fimc->out_path, FIMC_IO_ISP); else ret = -EINVAL; diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index a67b98676dd9..a61ecedc1201 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -88,8 +88,7 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p, break; } - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; sd = media_entity_to_v4l2_subdev(pad->entity); @@ -1062,7 +1061,7 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_io(entity)) continue; ret = __fimc_md_modify_pipeline(entity, enable); @@ -1076,7 +1075,7 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) media_entity_graph_walk_start(&graph, entity_err); while ((entity_err = media_entity_graph_walk_next(&graph))) { - if (media_entity_type(entity_err) != MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_io(entity_err)) continue; __fimc_md_modify_pipeline(entity_err, !enable); diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 69e7733d36cd..cb8ac90086c1 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -691,7 +691,7 @@ static int isp_pipeline_pm_use_count(struct media_entity *entity) media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { - if (media_entity_type(entity) == MEDIA_ENT_T_DEVNODE) + if (is_media_entity_v4l2_io(entity)) use += entity->use_count; } @@ -714,7 +714,7 @@ static int isp_pipeline_pm_power_one(struct media_entity *entity, int change) struct v4l2_subdev *subdev; int ret; - subdev = media_entity_type(entity) == MEDIA_ENT_T_V4L2_SUBDEV + subdev = is_media_entity_v4l2_subdev(entity) ? media_entity_to_v4l2_subdev(entity) : NULL; if (entity->use_count == 0 && change > 0 && subdev != NULL) { @@ -754,7 +754,7 @@ static int isp_pipeline_pm_power(struct media_entity *entity, int change) media_entity_graph_walk_start(&graph, entity); while (!ret && (entity = media_entity_graph_walk_next(&graph))) - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + if (is_media_entity_v4l2_subdev(entity)) ret = isp_pipeline_pm_power_one(entity, change); if (!ret) @@ -764,7 +764,7 @@ static int isp_pipeline_pm_power(struct media_entity *entity, int change) while ((first = media_entity_graph_walk_next(&graph)) && first != entity) - if (media_entity_type(first) != MEDIA_ENT_T_DEVNODE) + if (is_media_entity_v4l2_subdev(first)) isp_pipeline_pm_power_one(first, -change); return ret; @@ -897,8 +897,7 @@ static int isp_pipeline_enable(struct isp_pipeline *pipe, break; pad = media_entity_remote_pad(pad); - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; entity = pad->entity; @@ -988,8 +987,7 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe) break; pad = media_entity_remote_pad(pad); - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; entity = pad->entity; diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index a2e53b34d95f..768efd775abc 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -210,8 +210,7 @@ isp_video_remote_subdev(struct isp_video *video, u32 *pad) remote = media_entity_remote_pad(&video->pad); - if (remote == NULL || - media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!remote || !is_media_entity_v4l2_subdev(remote->entity)) return NULL; if (pad) @@ -243,7 +242,7 @@ static int isp_video_get_graph_data(struct isp_video *video, if (entity == &video->video.entity) continue; - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_io(entity)) continue; __video = to_isp_video(media_entity_to_video_device(entity)); @@ -919,7 +918,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video, return -EINVAL; } - if (media_entity_type(source) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!is_media_entity_v4l2_subdev(source)) return 0; pipe->external = media_entity_to_v4l2_subdev(source); diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c index a87ac16273a0..05bfa9d08b19 100644 --- a/drivers/media/platform/s3c-camif/camif-capture.c +++ b/drivers/media/platform/s3c-camif/camif-capture.c @@ -822,7 +822,7 @@ static int camif_pipeline_validate(struct camif_dev *camif) /* Retrieve format at the sensor subdev source pad */ pad = media_entity_remote_pad(&camif->pads[0]); - if (!pad || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) return -EPIPE; src_fmt.pad = pad->index; diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index c2b2281bb530..024d10de3740 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -160,8 +160,7 @@ vsp1_video_remote_subdev(struct media_pad *local, u32 *pad) struct media_pad *remote; remote = media_entity_remote_pad(local); - if (remote == NULL || - media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!remote || !is_media_entity_v4l2_subdev(remote->entity)) return NULL; if (pad) @@ -297,7 +296,7 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe, return -EPIPE; /* We've reached a video node, that shouldn't have happened. */ - if (media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!is_media_entity_v4l2_subdev(pad->entity)) return -EPIPE; entity = to_vsp1_entity(media_entity_to_v4l2_subdev(pad->entity)); @@ -394,7 +393,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe, struct vsp1_rwpf *rwpf; struct vsp1_entity *e; - if (media_entity_type(entity) != MEDIA_ENT_T_V4L2_SUBDEV) { + if (is_media_entity_v4l2_io(entity)) { pipe->num_video++; continue; } @@ -663,7 +662,7 @@ void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, pad = media_entity_remote_pad(&input->pads[RWPF_PAD_SOURCE]); while (pad) { - if (media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!is_media_entity_v4l2_subdev(pad->entity)) break; entity = to_vsp1_entity(media_entity_to_v4l2_subdev(pad->entity)); diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 9c8b27254253..b3fb1570b189 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -49,8 +49,7 @@ xvip_dma_remote_subdev(struct media_pad *local, u32 *pad) struct media_pad *remote; remote = media_entity_remote_pad(local); - if (remote == NULL || - media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!remote || !is_media_entity_v4l2_subdev(remote->entity)) return NULL; if (pad) @@ -113,8 +112,7 @@ static int xvip_pipeline_start_stop(struct xvip_pipeline *pipe, bool start) break; pad = media_entity_remote_pad(pad); - if (pad == NULL || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; entity = pad->entity; diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index e6e1115d8215..60da43772de9 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -526,7 +526,7 @@ static int v4l2_subdev_link_validate_get_format(struct media_pad *pad, struct v4l2_subdev_format *fmt) { - if (media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV) { + if (is_media_entity_v4l2_subdev(pad->entity)) { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(pad->entity); diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 6e0d0375634d..d21d978e139e 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -148,7 +148,7 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video) while ((entity = media_entity_graph_walk_next(&graph))) { if (entity == &video->video_dev.entity) continue; - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + if ((!is_media_entity_v4l2_io(remote->entity)) continue; far_end = to_vpfe_video(media_entity_to_video_device(entity)); if (far_end->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) @@ -293,7 +293,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { - if (media_entity_type(entity) == MEDIA_ENT_T_DEVNODE) + if !is_media_entity_v4l2_subdev(entity)) continue; subdev = media_entity_to_v4l2_subdev(entity); ret = v4l2_subdev_call(subdev, video, s_stream, 1); @@ -334,7 +334,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) while ((entity = media_entity_graph_walk_next(&graph))) { - if (media_entity_type(entity) == MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_subdev(entity)) continue; subdev = media_entity_to_v4l2_subdev(entity); ret = v4l2_subdev_call(subdev, video, s_stream, 0); diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index fa761669fd86..28e4d16544eb 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -397,7 +397,7 @@ static int iss_pipeline_pm_use_count(struct media_entity *entity) media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { - if (media_entity_type(entity) == MEDIA_ENT_T_DEVNODE) + if (is_media_entity_v4l2_io(entity)) use += entity->use_count; } @@ -419,7 +419,7 @@ static int iss_pipeline_pm_power_one(struct media_entity *entity, int change) { struct v4l2_subdev *subdev; - subdev = media_entity_type(entity) == MEDIA_ENT_T_V4L2_SUBDEV + subdev = is_media_entity_v4l2_subdev(entity) ? media_entity_to_v4l2_subdev(entity) : NULL; if (entity->use_count == 0 && change > 0 && subdev) { @@ -461,7 +461,7 @@ static int iss_pipeline_pm_power(struct media_entity *entity, int change) media_entity_graph_walk_start(&graph, entity); while (!ret && (entity = media_entity_graph_walk_next(&graph))) - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + if (is_media_entity_v4l2_subdev(entity)) ret = iss_pipeline_pm_power_one(entity, change); if (!ret) @@ -471,7 +471,7 @@ static int iss_pipeline_pm_power(struct media_entity *entity, int change) while ((first = media_entity_graph_walk_next(&graph)) && first != entity) - if (media_entity_type(first) != MEDIA_ENT_T_DEVNODE) + if (is_media_entity_v4l2_subdev(first)) iss_pipeline_pm_power_one(first, -change); return ret; @@ -590,8 +590,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe, break; pad = media_entity_remote_pad(pad); - if (!pad || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; entity = pad->entity; @@ -658,8 +657,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe, break; pad = media_entity_remote_pad(pad); - if (!pad || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; entity = pad->entity; diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index ea384630aab0..60b7a58e6122 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -190,8 +190,7 @@ iss_video_remote_subdev(struct iss_video *video, u32 *pad) remote = media_entity_remote_pad(&video->pad); - if (!remote || - media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!remote || !is_media_entity_v4l2_subdev(remote->entity)) return NULL; if (pad) @@ -216,7 +215,7 @@ iss_video_far_end(struct iss_video *video) if (entity == &video->video.entity) continue; - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_io(entity)) continue; far_end = to_iss_video(media_entity_to_video_device(entity)); -- cgit v1.2.3 From 59ecd59d782de82d8f2d2bfda2c28f87c0e8b35a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 7 May 2015 22:12:33 -0300 Subject: [media] omap3/omap4/davinci: get rid of MEDIA_ENT_T_V4L2_SUBDEV abuse On omap3/omap4/davinci drivers, MEDIA_ENT_T_V4L2_SUBDEV macro is abused in order to "simplify" the pad checks. Basically, it does a logical or of this macro, in order to check for a local index and if the entity is either a subdev or not. As we'll get rid of MEDIA_ENT_T_V4L2_SUBDEV macro, replace it by 2 << 16 where it occurs, and add a note saying that the code there is actually a hack. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/ispccdc.c | 15 ++++++++----- drivers/media/platform/omap3isp/ispccp2.c | 13 +++++++---- drivers/media/platform/omap3isp/ispcsi2.c | 11 +++++++--- drivers/media/platform/omap3isp/isppreview.c | 15 ++++++++----- drivers/media/platform/omap3isp/ispresizer.c | 13 +++++++---- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 13 +++++++---- drivers/staging/media/davinci_vpfe/dm365_isif.c | 13 +++++++---- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 25 +++++++++++++--------- drivers/staging/media/davinci_vpfe/vpfe_video.c | 4 ++-- drivers/staging/media/omap4iss/iss_csi2.c | 11 +++++++--- drivers/staging/media/omap4iss/iss_ipipeif.c | 13 +++++++---- drivers/staging/media/omap4iss/iss_resizer.c | 11 +++++++--- 12 files changed, 106 insertions(+), 51 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 9a811f5741fa..f0e530c98188 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -2513,9 +2513,14 @@ static int ccdc_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); struct isp_device *isp = to_isp_device(ccdc); + int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case CCDC_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case CCDC_PAD_SINK | 2 << 16: /* Read from the sensor (parallel interface), CCP2, CSI2a or * CSI2c. */ @@ -2543,7 +2548,7 @@ static int ccdc_link_setup(struct media_entity *entity, * Revisit this when it will be implemented, and return -EBUSY for now. */ - case CCDC_PAD_SOURCE_VP | MEDIA_ENT_T_V4L2_SUBDEV: + case CCDC_PAD_SOURCE_VP | 2 << 16: /* Write to preview engine, histogram and H3A. When none of * those links are active, the video port can be disabled. */ @@ -2556,7 +2561,7 @@ static int ccdc_link_setup(struct media_entity *entity, } break; - case CCDC_PAD_SOURCE_OF | MEDIA_ENT_T_DEVNODE: + case CCDC_PAD_SOURCE_OF: /* Write to memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ccdc->output & ~CCDC_OUTPUT_MEMORY) @@ -2567,7 +2572,7 @@ static int ccdc_link_setup(struct media_entity *entity, } break; - case CCDC_PAD_SOURCE_OF | MEDIA_ENT_T_V4L2_SUBDEV: + case CCDC_PAD_SOURCE_OF | 2 << 16: /* Write to resizer */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ccdc->output & ~CCDC_OUTPUT_RESIZER) diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index 6ec7d104ab75..ae3038e643cc 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -956,9 +956,14 @@ static int ccp2_link_setup(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); + int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case CCP2_PAD_SINK | MEDIA_ENT_T_DEVNODE: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case CCP2_PAD_SINK: /* read from memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ccp2->input == CCP2_INPUT_SENSOR) @@ -970,7 +975,7 @@ static int ccp2_link_setup(struct media_entity *entity, } break; - case CCP2_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + case CCP2_PAD_SINK | 2 << 16: /* read from sensor/phy */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ccp2->input == CCP2_INPUT_MEMORY) @@ -981,7 +986,7 @@ static int ccp2_link_setup(struct media_entity *entity, ccp2->input = CCP2_INPUT_NONE; } break; - case CCP2_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case CCP2_PAD_SOURCE | 2 << 16: /* write to video port/ccdc */ if (flags & MEDIA_LNK_FL_ENABLED) ccp2->output = CCP2_OUTPUT_CCDC; diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index 0fb057a74f69..b1617f7efdee 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c @@ -1144,14 +1144,19 @@ static int csi2_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct isp_csi2_ctrl_cfg *ctrl = &csi2->ctrl; + int index = local->index; /* * The ISP core doesn't support pipelines with multiple video outputs. * Revisit this when it will be implemented, and return -EBUSY for now. */ - switch (local->index | media_entity_type(remote->entity)) { - case CSI2_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case CSI2_PAD_SOURCE: if (flags & MEDIA_LNK_FL_ENABLED) { if (csi2->output & ~CSI2_OUTPUT_MEMORY) return -EBUSY; @@ -1161,7 +1166,7 @@ static int csi2_link_setup(struct media_entity *entity, } break; - case CSI2_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case CSI2_PAD_SOURCE | 2 << 16: if (flags & MEDIA_LNK_FL_ENABLED) { if (csi2->output & ~CSI2_OUTPUT_CCDC) return -EBUSY; diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c index 6986d2f65c19..cfb2debb02bf 100644 --- a/drivers/media/platform/omap3isp/isppreview.c +++ b/drivers/media/platform/omap3isp/isppreview.c @@ -2144,9 +2144,14 @@ static int preview_link_setup(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_prev_device *prev = v4l2_get_subdevdata(sd); + int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case PREV_PAD_SINK | MEDIA_ENT_T_DEVNODE: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case PREV_PAD_SINK: /* read from memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (prev->input == PREVIEW_INPUT_CCDC) @@ -2158,7 +2163,7 @@ static int preview_link_setup(struct media_entity *entity, } break; - case PREV_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + case PREV_PAD_SINK | 2 << 16: /* read from ccdc */ if (flags & MEDIA_LNK_FL_ENABLED) { if (prev->input == PREVIEW_INPUT_MEMORY) @@ -2175,7 +2180,7 @@ static int preview_link_setup(struct media_entity *entity, * Revisit this when it will be implemented, and return -EBUSY for now. */ - case PREV_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + case PREV_PAD_SOURCE: /* write to memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (prev->output & ~PREVIEW_OUTPUT_MEMORY) @@ -2186,7 +2191,7 @@ static int preview_link_setup(struct media_entity *entity, } break; - case PREV_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case PREV_PAD_SOURCE | 2 << 16: /* write to resizer */ if (flags & MEDIA_LNK_FL_ENABLED) { if (prev->output & ~PREVIEW_OUTPUT_RESIZER) diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c index 249af7f524f9..e3ecf1787fc4 100644 --- a/drivers/media/platform/omap3isp/ispresizer.c +++ b/drivers/media/platform/omap3isp/ispresizer.c @@ -1623,9 +1623,14 @@ static int resizer_link_setup(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_res_device *res = v4l2_get_subdevdata(sd); + int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case RESZ_PAD_SINK | MEDIA_ENT_T_DEVNODE: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case RESZ_PAD_SINK: /* read from memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (res->input == RESIZER_INPUT_VP) @@ -1637,7 +1642,7 @@ static int resizer_link_setup(struct media_entity *entity, } break; - case RESZ_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + case RESZ_PAD_SINK | 2 << 16: /* read from ccdc or previewer */ if (flags & MEDIA_LNK_FL_ENABLED) { if (res->input == RESIZER_INPUT_MEMORY) @@ -1649,7 +1654,7 @@ static int resizer_link_setup(struct media_entity *entity, } break; - case RESZ_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + case RESZ_PAD_SOURCE: /* resizer always write to memory */ break; diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index d96bdaaae50e..b66584ecb693 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -885,9 +885,14 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct vpfe_device *vpfe = to_vpfe_device(ipipeif); + int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case IPIPEIF_PAD_SINK | MEDIA_ENT_T_DEVNODE: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case IPIPEIF_PAD_SINK: /* Single shot mode */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipeif->input = IPIPEIF_INPUT_NONE; @@ -896,7 +901,7 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, ipipeif->input = IPIPEIF_INPUT_MEMORY; break; - case IPIPEIF_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPEIF_PAD_SINK | 2 << 16: /* read from isif */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipeif->input = IPIPEIF_INPUT_NONE; @@ -908,7 +913,7 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, ipipeif->input = IPIPEIF_INPUT_ISIF; break; - case IPIPEIF_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPEIF_PAD_SOURCE | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipeif->output = IPIPEIF_OUTPUT_NONE; break; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index df77288b0ec0..8ca0c1297ec8 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -1707,9 +1707,14 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd); + int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case ISIF_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case ISIF_PAD_SINK | 2 << 16: /* read from decoder/sensor */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { isif->input = ISIF_INPUT_NONE; @@ -1720,7 +1725,7 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, isif->input = ISIF_INPUT_PARALLEL; break; - case ISIF_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + case ISIF_PAD_SOURCE: /* write to memory */ if (flags & MEDIA_LNK_FL_ENABLED) isif->output = ISIF_OUTPUT_MEMORY; @@ -1728,7 +1733,7 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, isif->output = ISIF_OUTPUT_NONE; break; - case ISIF_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case ISIF_PAD_SOURCE | 2 << 16: if (flags & MEDIA_LNK_FL_ENABLED) isif->output = ISIF_OUTPUT_IPIPEIF; else diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 50c8725c5aa6..ba887efd226a 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1648,10 +1648,15 @@ static int resizer_link_setup(struct media_entity *entity, struct vpfe_device *vpfe_dev = to_vpfe_device(resizer); u16 ipipeif_source = vpfe_dev->vpfe_ipipeif.output; u16 ipipe_source = vpfe_dev->vpfe_ipipe.output; + int index = local->index; + + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; if (&resizer->crop_resizer.subdev == sd) { - switch (local->index | media_entity_type(remote->entity)) { - case RESIZER_CROP_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + switch (index) { + case RESIZER_CROP_PAD_SINK | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->crop_resizer.input = RESIZER_CROP_INPUT_NONE; @@ -1671,7 +1676,7 @@ static int resizer_link_setup(struct media_entity *entity, return -EINVAL; break; - case RESIZER_CROP_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case RESIZER_CROP_PAD_SOURCE | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->crop_resizer.output = RESIZER_CROP_OUTPUT_NONE; @@ -1683,7 +1688,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->crop_resizer.output = RESIZER_A; break; - case RESIZER_CROP_PAD_SOURCE2 | MEDIA_ENT_T_V4L2_SUBDEV: + case RESIZER_CROP_PAD_SOURCE2 | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->crop_resizer.output2 = RESIZER_CROP_OUTPUT_NONE; @@ -1699,8 +1704,8 @@ static int resizer_link_setup(struct media_entity *entity, return -EINVAL; } } else if (&resizer->resizer_a.subdev == sd) { - switch (local->index | media_entity_type(remote->entity)) { - case RESIZER_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + switch (index) { + case RESIZER_PAD_SINK | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->resizer_a.input = RESIZER_INPUT_NONE; break; @@ -1710,7 +1715,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->resizer_a.input = RESIZER_INPUT_CROP_RESIZER; break; - case RESIZER_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + case RESIZER_PAD_SOURCE: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->resizer_a.output = RESIZER_OUTPUT_NONE; break; @@ -1724,8 +1729,8 @@ static int resizer_link_setup(struct media_entity *entity, return -EINVAL; } } else if (&resizer->resizer_b.subdev == sd) { - switch (local->index | media_entity_type(remote->entity)) { - case RESIZER_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + switch (index) { + case RESIZER_PAD_SINK | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->resizer_b.input = RESIZER_INPUT_NONE; break; @@ -1735,7 +1740,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->resizer_b.input = RESIZER_INPUT_CROP_RESIZER; break; - case RESIZER_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + case RESIZER_PAD_SOURCE: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->resizer_b.output = RESIZER_OUTPUT_NONE; break; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index d21d978e139e..290f4b490b76 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -148,7 +148,7 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video) while ((entity = media_entity_graph_walk_next(&graph))) { if (entity == &video->video_dev.entity) continue; - if ((!is_media_entity_v4l2_io(remote->entity)) + if (!is_media_entity_v4l2_io(entity)) continue; far_end = to_vpfe_video(media_entity_to_video_device(entity)); if (far_end->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) @@ -293,7 +293,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { - if !is_media_entity_v4l2_subdev(entity)) + if (!is_media_entity_v4l2_subdev(entity)) continue; subdev = media_entity_to_v4l2_subdev(entity); ret = v4l2_subdev_call(subdev, video, s_stream, 1); diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index 13878a275277..2b9a36cd8fa8 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -1170,14 +1170,19 @@ static int csi2_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct iss_csi2_ctrl_cfg *ctrl = &csi2->ctrl; + int index = local->index; + + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; /* * The ISS core doesn't support pipelines with multiple video outputs. * Revisit this when it will be implemented, and return -EBUSY for now. */ - switch (local->index | media_entity_type(remote->entity)) { - case CSI2_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + switch (index) { + case CSI2_PAD_SOURCE: if (flags & MEDIA_LNK_FL_ENABLED) { if (csi2->output & ~CSI2_OUTPUT_MEMORY) return -EBUSY; @@ -1187,7 +1192,7 @@ static int csi2_link_setup(struct media_entity *entity, } break; - case CSI2_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case CSI2_PAD_SOURCE | 2 << 16: if (flags & MEDIA_LNK_FL_ENABLED) { if (csi2->output & ~CSI2_OUTPUT_IPIPEIF) return -EBUSY; diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index 82608cbb1f5f..8cbb9840a989 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -662,9 +662,14 @@ static int ipipeif_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct iss_device *iss = to_iss_device(ipipeif); + int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case IPIPEIF_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case IPIPEIF_PAD_SINK | 2 << 16: /* Read from the sensor CSI2a or CSI2b. */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipeif->input = IPIPEIF_INPUT_NONE; @@ -681,7 +686,7 @@ static int ipipeif_link_setup(struct media_entity *entity, break; - case IPIPEIF_PAD_SOURCE_ISIF_SF | MEDIA_ENT_T_DEVNODE: + case IPIPEIF_PAD_SOURCE_ISIF_SF: /* Write to memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ipipeif->output & ~IPIPEIF_OUTPUT_MEMORY) @@ -692,7 +697,7 @@ static int ipipeif_link_setup(struct media_entity *entity, } break; - case IPIPEIF_PAD_SOURCE_VP | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPEIF_PAD_SOURCE_VP | 2 << 16: /* Send to IPIPE/RESIZER */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ipipeif->output & ~IPIPEIF_OUTPUT_VP) diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index 4a474873a8df..a3925ecd0ed7 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -716,9 +716,14 @@ static int resizer_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct iss_device *iss = to_iss_device(resizer); + int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case RESIZER_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case RESIZER_PAD_SINK | 2 << 16: /* Read from IPIPE or IPIPEIF. */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->input = RESIZER_INPUT_NONE; @@ -735,7 +740,7 @@ static int resizer_link_setup(struct media_entity *entity, break; - case RESIZER_PAD_SOURCE_MEM | MEDIA_ENT_T_DEVNODE: + case RESIZER_PAD_SOURCE_MEM: /* Write to memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (resizer->output & ~RESIZER_OUTPUT_MEMORY) -- cgit v1.2.3 From cb716165536cde417de54de4657454bf39a8ba4d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 7 May 2015 22:12:34 -0300 Subject: [media] s5c73m3: fix subdev type This sensor driver is abusing MEDIA_ENT_T_V4L2_SUBDEV, creating some subdevs with a non-existing type. As this is a sensor driver, one of the entries is MEDIA_ENT_T_CAM_SENSOR. The other one will be using MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN, because the subdev is not any of the already existing types. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index 45c823b68f48..ee7404ee6659 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE; state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; + sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS, state->sensor_pads); @@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK; state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK; state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE; - oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; + oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS, state->oif_pads); -- cgit v1.2.3 From 26614b9bf8b534406835ea66732c12e6fd7b50fd Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 7 May 2015 22:12:35 -0300 Subject: [media] s5k5baf: fix subdev type The driver creates two subdevs, one for the image sensor pixel array (and the related readout logic) and one for an ISP. The first subdev already uses the MEDIA_ENT_T_V4L2_SUBDEV_SENSOR type, but the second subdev isn't a sensor pixel array. So, rename the second subdev as MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/s5k5baf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index d3bff30bcb6f..3e929858d5be 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK; state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; + sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads); if (!ret) -- cgit v1.2.3 From 14fae6fc53b2b390bbba650d60b9555e9f7f4f26 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 7 May 2015 22:12:36 -0300 Subject: [media] davinci_vbpe: stop MEDIA_ENT_T_V4L2_SUBDEV abuse This driver is abusing MEDIA_ENT_T_V4L2_SUBDEV: - it uses a hack to check if the remote entity is a subdev; - it still uses the legacy entity subtype check macro, that will be removed soon. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 9 ++++++--- drivers/staging/media/davinci_vpfe/vpfe_video.c | 5 ++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 3badf169c419..77837afab0ce 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1712,8 +1712,11 @@ ipipe_link_setup(struct media_entity *entity, const struct media_pad *local, struct vpfe_device *vpfe_dev = to_vpfe_device(ipipe); u16 ipipeif_sink = vpfe_dev->vpfe_ipipeif.input; - switch (local->index | media_entity_type(remote->entity)) { - case IPIPE_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + if (!is_media_entity_v4l2_subdev(remote->entity)) + return -EINVAL; + + switch (local->index) { + case IPIPE_PAD_SINK: if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipe->input = IPIPE_INPUT_NONE; break; @@ -1726,7 +1729,7 @@ ipipe_link_setup(struct media_entity *entity, const struct media_pad *local, ipipe->input = IPIPE_INPUT_CCDC; break; - case IPIPE_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPE_PAD_SOURCE: /* out to RESIZER */ if (flags & MEDIA_LNK_FL_ENABLED) ipipe->output = IPIPE_OUTPUT_RESIZER; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 290f4b490b76..a5e30413fc47 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -88,7 +88,7 @@ vpfe_video_remote_subdev(struct vpfe_video_device *video, u32 *pad) { struct media_pad *remote = media_entity_remote_pad(&video->pad); - if (remote == NULL || remote->entity->type != MEDIA_ENT_T_V4L2_SUBDEV) + if (!remote || !is_media_entity_v4l2_subdev(remote->entity)) return NULL; if (pad) *pad = remote->index; @@ -243,8 +243,7 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe) /* Retrieve the source format */ pad = media_entity_remote_pad(pad); - if (pad == NULL || - pad->entity->type != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; subdev = media_entity_to_v4l2_subdev(pad->entity); -- cgit v1.2.3 From bf4178a4c63443da1475c9c1bbb39963e75aa69b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 7 May 2015 22:12:37 -0300 Subject: [media] omap4iss: change the logic that checks if an entity is a subdev As we're getting rid of an specific number range for the V4L2 subdev, we need to replace the check for MEDIA_ENT_T_V4L2_SUBDEV by a macro. Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss_ipipe.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c index 44220765fb3a..dd9d7d54e6f8 100644 --- a/drivers/staging/media/omap4iss/iss_ipipe.c +++ b/drivers/staging/media/omap4iss/iss_ipipe.c @@ -447,8 +447,11 @@ static int ipipe_link_setup(struct media_entity *entity, struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct iss_device *iss = to_iss_device(ipipe); - switch (local->index | media_entity_type(remote->entity)) { - case IPIPE_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + if (!is_media_entity_v4l2_subdev(remote->entity)) + return -EINVAL; + + switch (local->index) { + case IPIPE_PAD_SINK: /* Read from IPIPEIF. */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipe->input = IPIPE_INPUT_NONE; @@ -463,7 +466,7 @@ static int ipipe_link_setup(struct media_entity *entity, break; - case IPIPE_PAD_SOURCE_VP | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPE_PAD_SOURCE_VP: /* Send to RESIZER */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ipipe->output & ~IPIPE_OUTPUT_VP) -- cgit v1.2.3 From b50bde4e476dede4a28e9c8fdcd134da2f34ef2e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 7 May 2015 22:12:38 -0300 Subject: [media] v4l2-subdev: use MEDIA_ENT_T_UNKNOWN for new subdevs Instead of abusing MEDIA_ENT_T_V4L2_SUBDEV, initialize new subdev entities as MEDIA_ENT_T_UNKNOWN. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 6 ++++++ drivers/media/v4l2-core/v4l2-subdev.c | 2 +- include/uapi/linux/media.h | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 659507bce63f..134fe7510195 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -435,6 +435,12 @@ int __must_check media_device_register_entity(struct media_device *mdev, { int i; + if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN || + entity->type == MEDIA_ENT_T_UNKNOWN) + dev_warn(mdev->dev, + "Entity type for entity %s was not initialized!\n", + entity->name); + /* Warn if we apparently re-register an entity */ WARN_ON(entity->graph_obj.mdev != NULL); entity->graph_obj.mdev = mdev; diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 60da43772de9..b3bcc8253182 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) sd->host_priv = NULL; #if defined(CONFIG_MEDIA_CONTROLLER) sd->entity.name = sd->name; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV; + sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; #endif } EXPORT_SYMBOL(v4l2_subdev_init); diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index c9314645d933..43109445d126 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -42,6 +42,14 @@ struct media_device_info { #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) +/* Used values for media_entity_desc::type */ + +/* + * Initial value to be used when a new entity is created + * Drivers should change it to something useful + */ +#define MEDIA_ENT_T_UNKNOWN 0x00000000 + /* * Base numbers for entity types * @@ -76,6 +84,12 @@ struct media_device_info { /* V4L2 Sub-device entities */ +/* + * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN, + * in order to preserve backward compatibility. + * Drivers should change to the proper subdev type before + * registering the entity. + */ #define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_T_V4L2_SUBDEV_BASE #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1) -- cgit v1.2.3 From df2f94e563edcbcb4b8652d05a3789d03b395366 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Aug 2015 16:18:18 -0300 Subject: [media] dvb: modify core to implement interfaces/entities at MC new gen The Media Controller New Generation redefines the types for both interfaces and entities to be used on DVB. Make the needed changes at the DVB core for all interfaces, entities and data and interface links to appear in the graph. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dmxdev.c | 4 +- drivers/media/dvb-core/dvb_ca_en50221.c | 2 +- drivers/media/dvb-core/dvb_frontend.c | 2 +- drivers/media/dvb-core/dvb_net.c | 2 +- drivers/media/dvb-core/dvbdev.c | 146 +++++++++++++++++++++++++---- drivers/media/dvb-core/dvbdev.h | 9 +- drivers/media/firewire/firedtv-ci.c | 2 +- drivers/media/pci/bt8xx/dst_ca.c | 3 +- drivers/media/pci/ddbridge/ddbridge-core.c | 2 +- drivers/media/pci/ngene/ngene-core.c | 2 +- drivers/media/pci/ttpci/av7110.c | 2 +- drivers/media/pci/ttpci/av7110_av.c | 4 +- drivers/media/pci/ttpci/av7110_ca.c | 2 +- 13 files changed, 148 insertions(+), 34 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c index ea9abde902e9..a168cbe1c998 100644 --- a/drivers/media/dvb-core/dmxdev.c +++ b/drivers/media/dvb-core/dmxdev.c @@ -1244,9 +1244,9 @@ int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter) } dvb_register_device(dvb_adapter, &dmxdev->dvbdev, &dvbdev_demux, dmxdev, - DVB_DEVICE_DEMUX); + DVB_DEVICE_DEMUX, dmxdev->filternum); dvb_register_device(dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr, - dmxdev, DVB_DEVICE_DVR); + dmxdev, DVB_DEVICE_DVR, dmxdev->filternum); dvb_ringbuffer_init(&dmxdev->dvr_buffer, NULL, 8192); diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c index fb66184dc9b6..f82cd1ff4f3a 100644 --- a/drivers/media/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb-core/dvb_ca_en50221.c @@ -1695,7 +1695,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, pubca->private = ca; /* register the DVB device */ - ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA); + ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA, 0); if (ret) goto free_slot_info; diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 42ab6aaeed7d..40080645341e 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -2759,7 +2759,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb, fe->dvb->num, fe->id, fe->ops.info.name); dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template, - fe, DVB_DEVICE_FRONTEND); + fe, DVB_DEVICE_FRONTEND, 0); /* * Initialize the cache to the proper values according with the diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c index ce4332e80a91..ce6a711b42d4 100644 --- a/drivers/media/dvb-core/dvb_net.c +++ b/drivers/media/dvb-core/dvb_net.c @@ -1502,6 +1502,6 @@ int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet, dvbnet->state[i] = 0; return dvb_register_device(adap, &dvbnet->dvbdev, &dvbdev_net, - dvbnet, DVB_DEVICE_NET); + dvbnet, DVB_DEVICE_NET, 0); } EXPORT_SYMBOL(dvb_net_init); diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index dadcf1655070..6babc688801b 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -180,18 +180,86 @@ skip: return -ENFILE; } +static void dvb_create_tsout_entity(struct dvb_device *dvbdev, + const char *name, int npads) +{ +#if defined(CONFIG_MEDIA_CONTROLLER_DVB) + int i, ret = 0; + + dvbdev->tsout_pads = kcalloc(npads, sizeof(*dvbdev->tsout_pads), + GFP_KERNEL); + if (!dvbdev->tsout_pads) + return; + dvbdev->tsout_entity = kcalloc(npads, sizeof(*dvbdev->tsout_entity), + GFP_KERNEL); + if (!dvbdev->tsout_entity) { + kfree(dvbdev->tsout_pads); + dvbdev->tsout_pads = NULL; + return; + } + for (i = 0; i < npads; i++) { + struct media_pad *pads = &dvbdev->tsout_pads[i]; + struct media_entity *entity = &dvbdev->tsout_entity[i]; + + entity->name = kasprintf(GFP_KERNEL, "%s #%d", name, i); + if (!entity->name) { + ret = -ENOMEM; + break; + } + + entity->type = MEDIA_ENT_T_DVB_TSOUT; + pads->flags = MEDIA_PAD_FL_SINK; + + ret = media_entity_init(entity, 1, pads); + if (ret < 0) + break; + + ret = media_device_register_entity(dvbdev->adapter->mdev, + entity); + if (ret < 0) + break; + } + + if (!ret) { + dvbdev->tsout_num_entities = npads; + return; + } + + for (i--; i >= 0; i--) { + media_device_unregister_entity(&dvbdev->tsout_entity[i]); + kfree(dvbdev->tsout_entity[i].name); + } + + printk(KERN_ERR + "%s: media_device_register_entity failed for %s\n", + __func__, name); + + kfree(dvbdev->tsout_entity); + kfree(dvbdev->tsout_pads); + dvbdev->tsout_entity = NULL; + dvbdev->tsout_pads = NULL; +#endif +} + +#define DEMUX_TSOUT "demux-tsout" +#define DVR_TSOUT "dvr-tsout" + static void dvb_create_media_entity(struct dvb_device *dvbdev, - int type, int minor) + int type, int demux_sink_pads) { #if defined(CONFIG_MEDIA_CONTROLLER_DVB) - int ret = 0, npads; + int i, ret = 0, npads; switch (type) { case DVB_DEVICE_FRONTEND: npads = 2; break; + case DVB_DEVICE_DVR: + dvb_create_tsout_entity(dvbdev, DVR_TSOUT, demux_sink_pads); + return; case DVB_DEVICE_DEMUX: - npads = 2; + npads = 1 + demux_sink_pads; + dvb_create_tsout_entity(dvbdev, DEMUX_TSOUT, demux_sink_pads); break; case DVB_DEVICE_CA: npads = 2; @@ -215,8 +283,6 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev, if (!dvbdev->entity) return; - dvbdev->entity->info.dev.major = DVB_MAJOR; - dvbdev->entity->info.dev.minor = minor; dvbdev->entity->name = dvbdev->name; if (npads) { @@ -237,7 +303,8 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev, case DVB_DEVICE_DEMUX: dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMUX; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; - dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; + for (i = 1; i < npads; i++) + dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE; break; case DVB_DEVICE_CA: dvbdev->entity->type = MEDIA_ENT_T_DVB_CA; @@ -259,8 +326,16 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev, printk(KERN_ERR "%s: media_device_register_entity failed for %s\n", __func__, dvbdev->entity->name); + + media_device_unregister_entity(dvbdev->entity); + for (i = 0; i < dvbdev->tsout_num_entities; i++) { + media_device_unregister_entity(&dvbdev->tsout_entity[i]); + kfree(dvbdev->tsout_entity[i].name); + } kfree(dvbdev->pads); kfree(dvbdev->entity); + kfree(dvbdev->tsout_pads); + kfree(dvbdev->tsout_entity); dvbdev->entity = NULL; return; } @@ -271,7 +346,8 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev, } static void dvb_register_media_device(struct dvb_device *dvbdev, - int type, int minor) + int type, int minor, + unsigned demux_sink_pads) { #if defined(CONFIG_MEDIA_CONTROLLER_DVB) u32 intf_type; @@ -279,7 +355,7 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, if (!dvbdev->adapter->mdev) return; - dvb_create_media_entity(dvbdev, type, minor); + dvb_create_media_entity(dvbdev, type, demux_sink_pads); switch (type) { case DVB_DEVICE_FRONTEND: @@ -323,7 +399,8 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, } int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, - const struct dvb_device *template, void *priv, int type) + const struct dvb_device *template, void *priv, int type, + int demux_sink_pads) { struct dvb_device *dvbdev; struct file_operations *dvbdevfops; @@ -402,7 +479,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, dprintk(KERN_DEBUG "DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", adap->num, dnames[type], id, minor, minor); - dvb_register_media_device(dvbdev, type, minor); + dvb_register_media_device(dvbdev, type, minor, demux_sink_pads); return 0; } @@ -422,9 +499,18 @@ void dvb_unregister_device(struct dvb_device *dvbdev) #if defined(CONFIG_MEDIA_CONTROLLER_DVB) if (dvbdev->entity) { + int i; + media_device_unregister_entity(dvbdev->entity); + for (i = 0; i < dvbdev->tsout_num_entities; i++) { + media_device_unregister_entity(&dvbdev->tsout_entity[i]); + kfree(dvbdev->tsout_entity[i].name); + } + kfree(dvbdev->entity); kfree(dvbdev->pads); + kfree(dvbdev->tsout_entity); + kfree(dvbdev->tsout_pads); } #endif @@ -440,8 +526,10 @@ void dvb_create_media_graph(struct dvb_adapter *adap) { struct media_device *mdev = adap->mdev; struct media_entity *entity, *tuner = NULL, *demod = NULL; - struct media_entity *demux = NULL, *dvr = NULL, *ca = NULL; + struct media_entity *demux = NULL, *ca = NULL; struct media_interface *intf; + unsigned demux_pad = 0; + unsigned dvr_pad = 0; if (!mdev) return; @@ -457,9 +545,6 @@ void dvb_create_media_graph(struct dvb_adapter *adap) case MEDIA_ENT_T_DVB_DEMUX: demux = entity; break; - case MEDIA_ENT_T_DVB_TSOUT: - dvr = entity; - break; case MEDIA_ENT_T_DVB_CA: ca = entity; break; @@ -471,21 +556,46 @@ void dvb_create_media_graph(struct dvb_adapter *adap) if (demod && demux) media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED); - - if (demux && dvr) - media_create_pad_link(demux, 1, dvr, 0, MEDIA_LNK_FL_ENABLED); - if (demux && ca) media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED); + /* Create demux links for each ringbuffer/pad */ + if (demux) { + media_device_for_each_entity(entity, mdev) { + if (entity->type == MEDIA_ENT_T_DVB_TSOUT) { + if (!strncmp(entity->name, DVR_TSOUT, + strlen(DVR_TSOUT))) + media_create_pad_link(demux, + ++dvr_pad, + entity, 0, 0); + if (!strncmp(entity->name, DEMUX_TSOUT, + strlen(DEMUX_TSOUT))) + media_create_pad_link(demux, + ++demux_pad, + entity, 0, 0); + } + } + } + /* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */ list_for_each_entry(intf, &mdev->interfaces, list) { if (intf->type == MEDIA_INTF_T_DVB_CA && ca) media_create_intf_link(ca, intf, 0); if (intf->type == MEDIA_INTF_T_DVB_FE && tuner) media_create_intf_link(tuner, intf, 0); + if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) media_create_intf_link(demux, intf, 0); + + media_device_for_each_entity(entity, mdev) { + if (entity->type == MEDIA_ENT_T_DVB_TSOUT) { + if (!strcmp(entity->name, DVR_TSOUT)) + media_create_intf_link(entity, intf, 0); + if (!strcmp(entity->name, DEMUX_TSOUT)) + media_create_intf_link(entity, intf, 0); + break; + } + } } } EXPORT_SYMBOL_GPL(dvb_create_media_graph); diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index 8398c8fb02b0..7af8adbb589b 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -148,9 +148,11 @@ struct dvb_device { const char *name; /* Allocated and filled inside dvbdev.c */ - struct media_entity *entity; struct media_intf_devnode *intf_devnode; - struct media_pad *pads; + + unsigned tsout_num_entities; + struct media_entity *entity, *tsout_entity; + struct media_pad *pads, *tsout_pads; #endif void *priv; @@ -193,7 +195,8 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, const struct dvb_device *template, void *priv, - int type); + int type, + int demux_sink_pads); /** * dvb_unregister_device - Unregisters a DVB device diff --git a/drivers/media/firewire/firedtv-ci.c b/drivers/media/firewire/firedtv-ci.c index e63f582378bf..edbb30fdd9d9 100644 --- a/drivers/media/firewire/firedtv-ci.c +++ b/drivers/media/firewire/firedtv-ci.c @@ -241,7 +241,7 @@ int fdtv_ca_register(struct firedtv *fdtv) return -EFAULT; err = dvb_register_device(&fdtv->adapter, &fdtv->cadev, - &fdtv_ca, fdtv, DVB_DEVICE_CA); + &fdtv_ca, fdtv, DVB_DEVICE_CA, 0); if (stat.ca_application_info == 0) dev_err(fdtv->device, "CaApplicationInfo is not set\n"); diff --git a/drivers/media/pci/bt8xx/dst_ca.c b/drivers/media/pci/bt8xx/dst_ca.c index c5cc14ef8347..da8b414fd824 100644 --- a/drivers/media/pci/bt8xx/dst_ca.c +++ b/drivers/media/pci/bt8xx/dst_ca.c @@ -705,7 +705,8 @@ struct dvb_device *dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_ struct dvb_device *dvbdev; dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device"); - if (dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA) == 0) { + if (dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, + DVB_DEVICE_CA, 0) == 0) { dst->dst_ca = dvbdev; return dst->dst_ca; } diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index fba5b40a869c..9d5b314142f1 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -1065,7 +1065,7 @@ static int ddb_ci_attach(struct ddb_port *port) port->en, 0, 1); ret = dvb_register_device(&port->output->adap, &port->output->dev, &dvbdev_ci, (void *) port->output, - DVB_DEVICE_SEC); + DVB_DEVICE_SEC, 0); return ret; } diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c index 1b92d836a564..4e924e2d1638 100644 --- a/drivers/media/pci/ngene/ngene-core.c +++ b/drivers/media/pci/ngene/ngene-core.c @@ -1513,7 +1513,7 @@ static int init_channel(struct ngene_channel *chan) set_transfer(&chan->dev->channel[2], 1); dvb_register_device(adapter, &chan->ci_dev, &ngene_dvbdev_ci, (void *) chan, - DVB_DEVICE_SEC); + DVB_DEVICE_SEC, 0); if (!chan->ci_dev) goto err; } diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c index 5e18b6796ed9..a69dc6a0752b 100644 --- a/drivers/media/pci/ttpci/av7110.c +++ b/drivers/media/pci/ttpci/av7110.c @@ -1358,7 +1358,7 @@ static int av7110_register(struct av7110 *av7110) #ifdef CONFIG_DVB_AV7110_OSD dvb_register_device(&av7110->dvb_adapter, &av7110->osd_dev, - &dvbdev_osd, av7110, DVB_DEVICE_OSD); + &dvbdev_osd, av7110, DVB_DEVICE_OSD, 0); #endif dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx); diff --git a/drivers/media/pci/ttpci/av7110_av.c b/drivers/media/pci/ttpci/av7110_av.c index 6fc748e22017..26c5696c193b 100644 --- a/drivers/media/pci/ttpci/av7110_av.c +++ b/drivers/media/pci/ttpci/av7110_av.c @@ -1594,10 +1594,10 @@ int av7110_av_register(struct av7110 *av7110) memset(&av7110->video_size, 0, sizeof (video_size_t)); dvb_register_device(&av7110->dvb_adapter, &av7110->video_dev, - &dvbdev_video, av7110, DVB_DEVICE_VIDEO); + &dvbdev_video, av7110, DVB_DEVICE_VIDEO, 0); dvb_register_device(&av7110->dvb_adapter, &av7110->audio_dev, - &dvbdev_audio, av7110, DVB_DEVICE_AUDIO); + &dvbdev_audio, av7110, DVB_DEVICE_AUDIO, 0); return 0; } diff --git a/drivers/media/pci/ttpci/av7110_ca.c b/drivers/media/pci/ttpci/av7110_ca.c index bc4c65ffd4b9..96a130fb4595 100644 --- a/drivers/media/pci/ttpci/av7110_ca.c +++ b/drivers/media/pci/ttpci/av7110_ca.c @@ -378,7 +378,7 @@ static struct dvb_device dvbdev_ca = { int av7110_ca_register(struct av7110 *av7110) { return dvb_register_device(&av7110->dvb_adapter, &av7110->ca_dev, - &dvbdev_ca, av7110, DVB_DEVICE_CA); + &dvbdev_ca, av7110, DVB_DEVICE_CA, 0); } void av7110_ca_unregister(struct av7110 *av7110) -- cgit v1.2.3 From 6c24d4602ebee64128f29944d776c19d4d53fb54 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 21 Aug 2015 18:26:42 -0300 Subject: [media] media: report if a pad is sink or source at debug msg Sometimes, it is important to see if the created pad is sink or source. Add info to track that. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 8449274bb50c..5697735be433 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -109,8 +109,11 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) struct media_pad *pad = gobj_to_pad(gobj); dev_dbg(gobj->mdev->dev, - "%s: id 0x%08x pad#%d: '%s':%d\n", - event_name, gobj->id, media_localid(gobj), + "%s: id 0x%08x %s%spad#%d: '%s':%d\n", + event_name, gobj->id, + pad->flags & MEDIA_PAD_FL_SINK ? " sink " : "", + pad->flags & MEDIA_PAD_FL_SOURCE ? "source " : "", + media_localid(gobj), pad->entity->name, pad->index); break; } -- cgit v1.2.3 From cf975a4b40ec9a947dae614b23128f3984a2d324 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 23 Aug 2015 07:51:22 -0300 Subject: [media] media: Use a macro to interate between all interfaces Just like we do with entities, use a similar macro for the interfaces loop. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 3 ++- include/media/media-device.h | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 6babc688801b..f00f1a5f279c 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -578,9 +578,10 @@ void dvb_create_media_graph(struct dvb_adapter *adap) } /* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */ - list_for_each_entry(intf, &mdev->interfaces, list) { + media_device_for_each_intf(intf, mdev) { if (intf->type == MEDIA_INTF_T_DVB_CA && ca) media_create_intf_link(ca, intf, 0); + if (intf->type == MEDIA_INTF_T_DVB_FE && tuner) media_create_intf_link(tuner, intf, 0); diff --git a/include/media/media-device.h b/include/media/media-device.h index 51807efa505b..f23d686aaac6 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -113,6 +113,11 @@ struct media_device *media_device_find_devres(struct device *dev); #define media_device_for_each_entity(entity, mdev) \ list_for_each_entry(entity, &(mdev)->entities, list) +/* Iterate over all interfaces. */ +#define media_device_for_each_intf(intf, mdev) \ + list_for_each_entry(intf, &(mdev)->interfaces, list) + + #else static inline int media_device_register(struct media_device *mdev) { -- cgit v1.2.3 From 05bfa9fa1cda91953e1b5975b059542b83c5245c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 23 Aug 2015 07:51:33 -0300 Subject: [media] media: move mdev list init to gobj Let's control the topology changes inside the graph_object. So, move the addition and removal of interfaces/entities from the mdev lists to media_gobj_init() and media_gobj_remove(). The main reason is that mdev should have lists for all object types, as the new MC api will require to store objects in separate places. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 4 +--- drivers/media/media-entity.c | 15 ++++++++++++--- include/media/media-device.h | 4 ++-- include/media/media-entity.h | 3 +-- 4 files changed, 16 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 134fe7510195..ec98595b8a7a 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -415,7 +415,7 @@ void media_device_unregister(struct media_device *mdev) struct media_entity *entity; struct media_entity *next; - list_for_each_entry_safe(entity, next, &mdev->entities, list) + list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) media_device_unregister_entity(entity); device_remove_file(&mdev->devnode.dev, &dev_attr_model); @@ -449,7 +449,6 @@ int __must_check media_device_register_entity(struct media_device *mdev, spin_lock(&mdev->lock); /* Initialize media_gobj embedded at the entity */ media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); - list_add_tail(&entity->list, &mdev->entities); /* Initialize objects at the pads */ for (i = 0; i < entity->num_pads; i++) @@ -487,7 +486,6 @@ void media_device_unregister_entity(struct media_entity *entity) for (i = 0; i < entity->num_pads; i++) media_gobj_remove(&entity->pads[i].graph_obj); media_gobj_remove(&entity->graph_obj); - list_del(&entity->list); spin_unlock(&mdev->lock); entity->graph_obj.mdev = NULL; } diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 5697735be433..b3875b0185c1 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -158,6 +158,7 @@ void media_gobj_init(struct media_device *mdev, switch (type) { case MEDIA_GRAPH_ENTITY: gobj->id = media_gobj_gen_id(type, ++mdev->entity_id); + list_add_tail(&gobj->list, &mdev->entities); break; case MEDIA_GRAPH_PAD: gobj->id = media_gobj_gen_id(type, ++mdev->pad_id); @@ -166,6 +167,7 @@ void media_gobj_init(struct media_device *mdev, gobj->id = media_gobj_gen_id(type, ++mdev->link_id); break; case MEDIA_GRAPH_INTF_DEVNODE: + list_add_tail(&gobj->list, &mdev->interfaces); gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id); break; } @@ -181,6 +183,16 @@ void media_gobj_init(struct media_device *mdev, */ void media_gobj_remove(struct media_gobj *gobj) { + /* Remove the object from mdev list */ + switch (media_type(gobj)) { + case MEDIA_GRAPH_ENTITY: + case MEDIA_GRAPH_INTF_DEVNODE: + list_del(&gobj->list); + break; + default: + break; + } + dev_dbg_obj(__func__, gobj); } @@ -852,8 +864,6 @@ static void media_interface_init(struct media_device *mdev, INIT_LIST_HEAD(&intf->links); media_gobj_init(mdev, gobj_type, &intf->graph_obj); - - list_add_tail(&intf->list, &mdev->interfaces); } /* Functions related to the media interface via device nodes */ @@ -882,7 +892,6 @@ EXPORT_SYMBOL_GPL(media_devnode_create); void media_devnode_remove(struct media_intf_devnode *devnode) { media_gobj_remove(&devnode->intf.graph_obj); - list_del(&devnode->intf.list); kfree(devnode); } EXPORT_SYMBOL_GPL(media_devnode_remove); diff --git a/include/media/media-device.h b/include/media/media-device.h index f23d686aaac6..85fa302047bd 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -111,11 +111,11 @@ struct media_device *media_device_find_devres(struct device *dev); /* Iterate over all entities. */ #define media_device_for_each_entity(entity, mdev) \ - list_for_each_entry(entity, &(mdev)->entities, list) + list_for_each_entry(entity, &(mdev)->entities, graph_obj.list) /* Iterate over all interfaces. */ #define media_device_for_each_intf(intf, mdev) \ - list_for_each_entry(intf, &(mdev)->interfaces, list) + list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list) #else diff --git a/include/media/media-entity.h b/include/media/media-entity.h index dbc4da450fc2..f9058601440a 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -66,6 +66,7 @@ enum media_gobj_type { struct media_gobj { struct media_device *mdev; u32 id; + struct list_head list; }; @@ -114,7 +115,6 @@ struct media_entity_operations { struct media_entity { struct media_gobj graph_obj; /* must be first field in struct */ - struct list_head list; const char *name; /* Entity name */ u32 type; /* Entity type (MEDIA_ENT_T_*) */ u32 revision; /* Entity revision, driver specific */ @@ -166,7 +166,6 @@ struct media_entity { */ struct media_interface { struct media_gobj graph_obj; - struct list_head list; struct list_head links; u32 type; u32 flags; -- cgit v1.2.3 From 9155d859b6bec29cdbbd80a509be35de55115f00 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 23 Aug 2015 08:00:33 -0300 Subject: [media] media-device: add pads and links to media_device The MC next gen API sends objects to userspace grouped by their types. In the case of pads and links, in order to improve performance and have a simpler code, the best is to store them also on separate linked lists at MC. If we don't do that, we would need this kind of interaction to send data to userspace (code is in structured english): for each entity: for each pad: store pads for each entity: for each link: store link for each interface: for each link: store link With would require one nested loop for pads and two nested loops for links. By using separate linked lists for them, just one loop would be enough. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 2 ++ drivers/media/media-entity.c | 17 ++++++----------- include/media/media-device.h | 12 ++++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index ec98595b8a7a..5b2c9f7fcd45 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -382,6 +382,8 @@ int __must_check __media_device_register(struct media_device *mdev, INIT_LIST_HEAD(&mdev->entities); INIT_LIST_HEAD(&mdev->interfaces); + INIT_LIST_HEAD(&mdev->pads); + INIT_LIST_HEAD(&mdev->links); spin_lock_init(&mdev->lock); mutex_init(&mdev->graph_mutex); diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index b3875b0185c1..2f3d3aae20a7 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -162,13 +162,15 @@ void media_gobj_init(struct media_device *mdev, break; case MEDIA_GRAPH_PAD: gobj->id = media_gobj_gen_id(type, ++mdev->pad_id); + list_add_tail(&gobj->list, &mdev->pads); break; case MEDIA_GRAPH_LINK: gobj->id = media_gobj_gen_id(type, ++mdev->link_id); + list_add_tail(&gobj->list, &mdev->links); break; case MEDIA_GRAPH_INTF_DEVNODE: - list_add_tail(&gobj->list, &mdev->interfaces); gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id); + list_add_tail(&gobj->list, &mdev->interfaces); break; } dev_dbg_obj(__func__, gobj); @@ -183,17 +185,10 @@ void media_gobj_init(struct media_device *mdev, */ void media_gobj_remove(struct media_gobj *gobj) { - /* Remove the object from mdev list */ - switch (media_type(gobj)) { - case MEDIA_GRAPH_ENTITY: - case MEDIA_GRAPH_INTF_DEVNODE: - list_del(&gobj->list); - break; - default: - break; - } - dev_dbg_obj(__func__, gobj); + + /* Remove the object from mdev list */ + list_del(&gobj->list); } /** diff --git a/include/media/media-device.h b/include/media/media-device.h index 85fa302047bd..0d1b9c687454 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -47,6 +47,8 @@ struct device; * @intf_devnode_id: Unique ID used on the last interface devnode registered * @entities: List of registered entities * @interfaces: List of registered interfaces + * @pads: List of registered pads + * @links: List of registered links * @lock: Entities list lock * @graph_mutex: Entities graph operation lock * @link_notify: Link state change notification callback @@ -79,6 +81,8 @@ struct media_device { struct list_head entities; struct list_head interfaces; + struct list_head pads; + struct list_head links; /* Protects the entities list */ spinlock_t lock; @@ -117,6 +121,14 @@ struct media_device *media_device_find_devres(struct device *dev); #define media_device_for_each_intf(intf, mdev) \ list_for_each_entry(intf, &(mdev)->interfaces, graph_obj.list) +/* Iterate over all pads. */ +#define media_device_for_each_pad(pad, mdev) \ + list_for_each_entry(pad, &(mdev)->pads, graph_obj.list) + +/* Iterate over all links. */ +#define media_device_for_each_link(link, mdev) \ + list_for_each_entry(link, &(mdev)->links, graph_obj.list) + #else static inline int media_device_register(struct media_device *mdev) -- cgit v1.2.3 From 2521fdac28d0ceea659be1620fef96b1cbff09b6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 23 Aug 2015 09:40:26 -0300 Subject: [media] media_device: add a topology version field Every time a graph object is added or removed, the version of the topology changes. That's a requirement for the new MEDIA_IOC_G_TOPOLOGY, in order to allow userspace to know that the topology has changed after a previous call to it. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 5 +++++ include/media/media-device.h | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 2f3d3aae20a7..1b2fd724cdbf 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -173,6 +173,9 @@ void media_gobj_init(struct media_device *mdev, list_add_tail(&gobj->list, &mdev->interfaces); break; } + + mdev->topology_version++; + dev_dbg_obj(__func__, gobj); } @@ -187,6 +190,8 @@ void media_gobj_remove(struct media_gobj *gobj) { dev_dbg_obj(__func__, gobj); + gobj->mdev->topology_version++; + /* Remove the object from mdev list */ list_del(&gobj->list); } diff --git a/include/media/media-device.h b/include/media/media-device.h index 0d1b9c687454..1b12774a9ab4 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -41,6 +41,8 @@ struct device; * @bus_info: Unique and stable device location identifier * @hw_revision: Hardware device revision * @driver_version: Device driver version + * @topology_version: Monotonic counter for storing the version of the graph + * topology. Should be incremented each time the topology changes. * @entity_id: Unique ID used on the last entity registered * @pad_id: Unique ID used on the last pad registered * @link_id: Unique ID used on the last link registered @@ -74,6 +76,8 @@ struct media_device { u32 hw_revision; u32 driver_version; + u32 topology_version; + u32 entity_id; u32 pad_id; u32 link_id; -- cgit v1.2.3 From 8309f47c32c04aae30698389073ec8c6d1b7e986 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 23 Aug 2015 10:36:41 -0300 Subject: [media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl Add support for the new MEDIA_IOC_G_TOPOLOGY ioctl, according with the RFC for the MC next generation. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 158 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 5b2c9f7fcd45..96a476eeb16e 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -232,6 +232,156 @@ static long media_device_setup_link(struct media_device *mdev, return ret; } +static long __media_device_get_topology(struct media_device *mdev, + struct media_v2_topology *topo) +{ + struct media_entity *entity; + struct media_interface *intf; + struct media_pad *pad; + struct media_link *link; + struct media_v2_entity uentity; + struct media_v2_interface uintf; + struct media_v2_pad upad; + struct media_v2_link ulink; + int ret = 0, i; + + topo->topology_version = mdev->topology_version; + + /* Get entities and number of entities */ + i = 0; + media_device_for_each_entity(entity, mdev) { + i++; + + if (ret || !topo->entities) + continue; + + if (i > topo->num_entities) { + ret = -ENOSPC; + continue; + } + + /* Copy fields to userspace struct if not error */ + memset(&uentity, 0, sizeof(uentity)); + uentity.id = entity->graph_obj.id; + strncpy(uentity.name, entity->name, + sizeof(uentity.name)); + + if (copy_to_user(&topo->entities[i - 1], &uentity, sizeof(uentity))) + ret = -EFAULT; + } + topo->num_entities = i; + + /* Get interfaces and number of interfaces */ + i = 0; + media_device_for_each_intf(intf, mdev) { + i++; + + if (ret || !topo->interfaces) + continue; + + if (i > topo->num_interfaces) { + ret = -ENOSPC; + continue; + } + + memset(&uintf, 0, sizeof(uintf)); + + /* Copy intf fields to userspace struct */ + uintf.id = intf->graph_obj.id; + uintf.intf_type = intf->type; + uintf.flags = intf->flags; + + if (media_type(&intf->graph_obj) == MEDIA_GRAPH_INTF_DEVNODE) { + struct media_intf_devnode *devnode; + + devnode = intf_to_devnode(intf); + + uintf.devnode.major = devnode->major; + uintf.devnode.minor = devnode->minor; + } + + if (copy_to_user(&topo->interfaces[i - 1], &uintf, sizeof(uintf))) + ret = -EFAULT; + } + topo->num_interfaces = i; + + /* Get pads and number of pads */ + i = 0; + media_device_for_each_pad(pad, mdev) { + i++; + + if (ret || !topo->pads) + continue; + + if (i > topo->num_pads) { + ret = -ENOSPC; + continue; + } + + memset(&upad, 0, sizeof(upad)); + + /* Copy pad fields to userspace struct */ + upad.id = pad->graph_obj.id; + upad.entity_id = pad->entity->graph_obj.id; + upad.flags = pad->flags; + + if (copy_to_user(&topo->pads[i - 1], &upad, sizeof(upad))) + ret = -EFAULT; + } + topo->num_pads = i; + + /* Get links and number of links */ + i = 0; + media_device_for_each_link(link, mdev) { + i++; + + if (ret || !topo->links) + continue; + + if (i > topo->num_links) { + ret = -ENOSPC; + continue; + } + + memset(&ulink, 0, sizeof(ulink)); + + /* Copy link fields to userspace struct */ + ulink.id = link->graph_obj.id; + ulink.source_id = link->gobj0->id; + ulink.sink_id = link->gobj1->id; + ulink.flags = link->flags; + + if (media_type(link->gobj0) != MEDIA_GRAPH_PAD) + ulink.flags |= MEDIA_LNK_FL_INTERFACE_LINK; + + if (copy_to_user(&topo->links[i - 1], &ulink, sizeof(ulink))) + ret = -EFAULT; + } + topo->num_links = i; + + return ret; +} + +static long media_device_get_topology(struct media_device *mdev, + struct media_v2_topology __user *utopo) +{ + struct media_v2_topology ktopo; + int ret; + + ret = copy_from_user(&ktopo, utopo, sizeof(ktopo)); + + if (ret < 0) + return ret; + + ret = __media_device_get_topology(mdev, &ktopo); + if (ret < 0) + return ret; + + ret = copy_to_user(utopo, &ktopo, sizeof(*utopo)); + + return ret; +} + static long media_device_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { @@ -264,6 +414,13 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd, mutex_unlock(&dev->graph_mutex); break; + case MEDIA_IOC_G_TOPOLOGY: + mutex_lock(&dev->graph_mutex); + ret = media_device_get_topology(dev, + (struct media_v2_topology __user *)arg); + mutex_unlock(&dev->graph_mutex); + break; + default: ret = -ENOIOCTLCMD; } @@ -312,6 +469,7 @@ static long media_device_compat_ioctl(struct file *filp, unsigned int cmd, case MEDIA_IOC_DEVICE_INFO: case MEDIA_IOC_ENUM_ENTITIES: case MEDIA_IOC_SETUP_LINK: + case MEDIA_IOC_G_TOPOLOGY: return media_device_ioctl(filp, cmd, arg); case MEDIA_IOC_ENUM_LINKS32: -- cgit v1.2.3 From 7c4696a910d404eda3477e76a35c155a6b83ca3e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 24 Aug 2015 08:46:46 -0300 Subject: [media] media-entity: unregister entity links Add functions to explicitly unregister all entity links. This function is called automatically when an entity link is destroyed. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 23 +++++++++++++++++++++++ include/media/media-entity.h | 3 +++ 2 files changed, 26 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 1b2fd724cdbf..ceae708bdad4 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -891,6 +891,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create); void media_devnode_remove(struct media_intf_devnode *devnode) { + media_remove_intf_links(&devnode->intf); media_gobj_remove(&devnode->intf.graph_obj); kfree(devnode); } @@ -932,3 +933,25 @@ void media_remove_intf_link(struct media_link *link) mutex_unlock(&link->graph_obj.mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_remove_intf_link); + +void __media_remove_intf_links(struct media_interface *intf) +{ + struct media_link *link, *tmp; + + list_for_each_entry_safe(link, tmp, &intf->links, list) + __media_remove_intf_link(link); + +} +EXPORT_SYMBOL_GPL(__media_remove_intf_links); + +void media_remove_intf_links(struct media_interface *intf) +{ + /* Do nothing if the intf is not registered. */ + if (intf->graph_obj.mdev == NULL) + return; + + mutex_lock(&intf->graph_obj.mdev->graph_mutex); + __media_remove_intf_links(intf); + mutex_unlock(&intf->graph_obj.mdev->graph_mutex); +} +EXPORT_SYMBOL_GPL(media_remove_intf_links); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index f9058601440a..0753f3029d06 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -326,6 +326,9 @@ struct media_link *media_create_intf_link(struct media_entity *entity, struct media_interface *intf, u32 flags); void media_remove_intf_link(struct media_link *link); +void __media_remove_intf_links(struct media_interface *intf); +void media_remove_intf_links(struct media_interface *intf); + #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ -- cgit v1.2.3 From a28971ad141bf41b8d6c24f8c4e8736be0c57677 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 29 Aug 2015 19:07:09 -0300 Subject: [media] remove interface links at media_entity_unregister() Interface links connected to an entity should be removed before the entity itself can be removed. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 96a476eeb16e..7c37aeab05bb 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -638,14 +638,30 @@ void media_device_unregister_entity(struct media_entity *entity) return; spin_lock(&mdev->lock); + + /* Remove interface links with this entity on it */ + list_for_each_entry_safe(link, tmp, &mdev->links, graph_obj.list) { + if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY + && link->entity == entity) { + media_gobj_remove(&link->graph_obj); + kfree(link); + } + } + + /* Remove all data links that belong to this entity */ list_for_each_entry_safe(link, tmp, &entity->links, list) { media_gobj_remove(&link->graph_obj); list_del(&link->list); kfree(link); } + + /* Remove all pads that belong to this entity */ for (i = 0; i < entity->num_pads; i++) media_gobj_remove(&entity->pads[i].graph_obj); + + /* Remove the entity */ media_gobj_remove(&entity->graph_obj); + spin_unlock(&mdev->lock); entity->graph_obj.mdev = NULL; } -- cgit v1.2.3 From d47109fa45ee2dc4e0b2710a8225e6c3ac7ea9fd Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 29 Aug 2015 21:23:44 -0300 Subject: [media] media-device: remove interfaces and interface links Just like what's done with entities, when the media controller is unregistered, release any interface and interface links that might still be there. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 30 +++++++++++++++++++----------- drivers/media/media-entity.c | 6 +++++- include/media/media-entity.h | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 7c37aeab05bb..96700843b1e4 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -574,6 +574,17 @@ void media_device_unregister(struct media_device *mdev) { struct media_entity *entity; struct media_entity *next; + struct media_interface *intf, *tmp_intf; + + /* Remove all interfaces from the media device */ + spin_lock(&mdev->lock); + list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, + graph_obj.list) { + __media_remove_intf_links(intf); + media_gobj_remove(&intf->graph_obj); + kfree(intf); + } + spin_unlock(&mdev->lock); list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) media_device_unregister_entity(entity); @@ -633,27 +644,24 @@ void media_device_unregister_entity(struct media_entity *entity) int i; struct media_device *mdev = entity->graph_obj.mdev; struct media_link *link, *tmp; + struct media_interface *intf; if (mdev == NULL) return; spin_lock(&mdev->lock); - /* Remove interface links with this entity on it */ - list_for_each_entry_safe(link, tmp, &mdev->links, graph_obj.list) { - if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY - && link->entity == entity) { - media_gobj_remove(&link->graph_obj); - kfree(link); + /* Remove all interface links pointing to this entity */ + list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { + list_for_each_entry_safe(link, tmp, &intf->links, list) { + if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY + && link->entity == entity) + __media_remove_intf_link(link); } } /* Remove all data links that belong to this entity */ - list_for_each_entry_safe(link, tmp, &entity->links, list) { - media_gobj_remove(&link->graph_obj); - list_del(&link->list); - kfree(link); - } + __media_entity_remove_links(entity); /* Remove all pads that belong to this entity */ for (i = 0; i < entity->num_pads; i++) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index ceae708bdad4..ee0f81364960 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -674,9 +674,11 @@ static void __media_entity_remove_link(struct media_entity *entity, /* Remove the remote link */ list_del(&rlink->list); + media_gobj_remove(&rlink->graph_obj); kfree(rlink); } list_del(&link->list); + media_gobj_remove(&link->graph_obj); kfree(link); } @@ -920,11 +922,13 @@ struct media_link *media_create_intf_link(struct media_entity *entity, EXPORT_SYMBOL_GPL(media_create_intf_link); -static void __media_remove_intf_link(struct media_link *link) +void __media_remove_intf_link(struct media_link *link) { + list_del(&link->list); media_gobj_remove(&link->graph_obj); kfree(link); } +EXPORT_SYMBOL_GPL(__media_remove_intf_link); void media_remove_intf_link(struct media_link *link) { diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 0753f3029d06..f165d303f03c 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -325,6 +325,7 @@ void media_devnode_remove(struct media_intf_devnode *devnode); struct media_link *media_create_intf_link(struct media_entity *entity, struct media_interface *intf, u32 flags); +void __media_remove_intf_link(struct media_link *link); void media_remove_intf_link(struct media_link *link); void __media_remove_intf_links(struct media_interface *intf); void media_remove_intf_links(struct media_interface *intf); -- cgit v1.2.3 From a08fad1ec80c69c79b3ffb6d84968b0952d32da1 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 9 Dec 2015 19:47:35 -0200 Subject: [media] media-entity: protect object creation/removal using spin lock Some parts of the media controller are using mutexes while others are using spin locks in order to protect creation and removal of elements in the graph. That's wrong! Also, the V4L2 core can remove graph elements on non-interactive context: BUG: sleeping function called from invalid context at include/linux/sched.h:2776 Fix it by always using spin locks for graph element addition/removal, just like entity creation/removal is protected at media-device.c Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 16 ++++++++-------- include/media/media-device.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index ee0f81364960..b1390d843909 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -700,9 +700,9 @@ void media_entity_remove_links(struct media_entity *entity) if (entity->graph_obj.mdev == NULL) return; - mutex_lock(&entity->graph_obj.mdev->graph_mutex); + spin_lock(&entity->graph_obj.mdev->lock); __media_entity_remove_links(entity); - mutex_unlock(&entity->graph_obj.mdev->graph_mutex); + spin_unlock(&entity->graph_obj.mdev->lock); } EXPORT_SYMBOL_GPL(media_entity_remove_links); @@ -792,9 +792,9 @@ int media_entity_setup_link(struct media_link *link, u32 flags) { int ret; - mutex_lock(&link->source->entity->graph_obj.mdev->graph_mutex); + spin_lock(&link->source->entity->graph_obj.mdev->lock); ret = __media_entity_setup_link(link, flags); - mutex_unlock(&link->source->entity->graph_obj.mdev->graph_mutex); + spin_unlock(&link->source->entity->graph_obj.mdev->lock); return ret; } @@ -932,9 +932,9 @@ EXPORT_SYMBOL_GPL(__media_remove_intf_link); void media_remove_intf_link(struct media_link *link) { - mutex_lock(&link->graph_obj.mdev->graph_mutex); + spin_lock(&link->graph_obj.mdev->lock); __media_remove_intf_link(link); - mutex_unlock(&link->graph_obj.mdev->graph_mutex); + spin_unlock(&link->graph_obj.mdev->lock); } EXPORT_SYMBOL_GPL(media_remove_intf_link); @@ -954,8 +954,8 @@ void media_remove_intf_links(struct media_interface *intf) if (intf->graph_obj.mdev == NULL) return; - mutex_lock(&intf->graph_obj.mdev->graph_mutex); + spin_lock(&intf->graph_obj.mdev->lock); __media_remove_intf_links(intf); - mutex_unlock(&intf->graph_obj.mdev->graph_mutex); + spin_unlock(&intf->graph_obj.mdev->lock); } EXPORT_SYMBOL_GPL(media_remove_intf_links); diff --git a/include/media/media-device.h b/include/media/media-device.h index 1b12774a9ab4..87ff299e1265 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -88,7 +88,7 @@ struct media_device { struct list_head pads; struct list_head links; - /* Protects the entities list */ + /* Protects the graph objects creation/removal */ spinlock_t lock; /* Serializes graph operations. */ struct mutex graph_mutex; -- cgit v1.2.3 From 188d2d551244f4196b616c90f3411732a6ebb2ab Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 31 Aug 2015 13:23:03 -0300 Subject: [media] tuner-core: add an input pad Tuners actually have at least one connector on its input. Add a PAD to connect it. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 5 ++++- drivers/media/usb/au0828/au0828-core.c | 5 ++++- drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +- drivers/media/v4l2-core/tuner-core.c | 8 +++++--- include/media/tuner.h | 8 ++++++++ 5 files changed, 22 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index f00f1a5f279c..a8e7e2398f7a 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -34,6 +34,9 @@ #include #include "dvbdev.h" +/* Due to enum tuner_pad_index */ +#include + static DEFINE_MUTEX(dvbdev_mutex); static int dvbdev_debug; @@ -552,7 +555,7 @@ void dvb_create_media_graph(struct dvb_adapter *adap) } if (tuner && demod) - media_create_pad_link(tuner, 0, demod, 0, 0); + media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, 0); if (demod && demux) media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 7f645bcb7463..ee20f4354ba2 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -27,6 +27,9 @@ #include #include +/* Due to enum tuner_pad_index */ +#include + /* * 1 = General debug messages * 2 = USB handling @@ -260,7 +263,7 @@ static void au0828_create_media_graph(struct au0828_dev *dev) return; if (tuner) - media_create_pad_link(tuner, 0, decoder, 0, + media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0, MEDIA_LNK_FL_ENABLED); media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 695f0c092c79..29cf0c268b19 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1264,7 +1264,7 @@ static void cx231xx_create_media_graph(struct cx231xx *dev) return; if (tuner) - media_create_pad_link(tuner, 0, decoder, 0, + media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0, MEDIA_LNK_FL_ENABLED); media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index 100b8f069640..b90f2a52db96 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -134,8 +134,9 @@ struct tuner { unsigned int type; /* chip type id */ void *config; const char *name; + #if defined(CONFIG_MEDIA_CONTROLLER) - struct media_pad pad; + struct media_pad pad[TUNER_NUM_PADS]; #endif }; @@ -695,11 +696,12 @@ static int tuner_probe(struct i2c_client *client, /* Should be just before return */ register_client: #if defined(CONFIG_MEDIA_CONTROLLER) - t->pad.flags = MEDIA_PAD_FL_SOURCE; + t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK; + t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE; t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER; t->sd.entity.name = t->name; - ret = media_entity_init(&t->sd.entity, 1, &t->pad); + ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]); if (ret < 0) { tuner_err("failed to initialize media entity!\n"); kfree(t); diff --git a/include/media/tuner.h b/include/media/tuner.h index 486b6a54363b..e5321fda5489 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -21,6 +21,14 @@ #include +/* Tuner PADs */ +/* FIXME: is this the right place for it? */ +enum tuner_pad_index { + TUNER_PAD_RF_INPUT, + TUNER_PAD_IF_OUTPUT, + TUNER_NUM_PADS +}; + #define ADDR_UNSET (255) #define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ -- cgit v1.2.3 From 04bf12c2d313478a3e5c9ff59a7ba92ce418bee6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 10 Dec 2015 09:16:34 -0200 Subject: [media] dvbdev: enable all interface links at init Interface links are normally enabled, meaning that the interfaces are bound to the entities. So, any ioctl sent to the interface are reflected at the entities managed by the interface. However, when a device is in use, other interfaces for the same hardware could be decoupled from the entities linked to them, because the hardware may have some parts busy. That's for example, what happens when an hybrid TV device is in use. If it is streaming analog TV or capturing signals from S-Video/Composite connectors, typically the digital part of the hardware can't be used and vice-versa. This is generally due to some internal hardware or firmware limitation, that it is not easily mapped via data pipelines. What the Kernel drivers do internally is that they decouple the hardware from the interface. So, all changes, if allowed, are done only at some interface cache, but not physically changed at the hardware. The usage is similar to the usage of the MEDIA_LNK_FL_ENABLED on data links. So, let's use the same flag to indicate if either the interface to entity link is bound/enabled or not. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index a8e7e2398f7a..5c4fb41060b4 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -396,7 +396,8 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, if (!dvbdev->entity || !dvbdev->intf_devnode) return; - media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, 0); + media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, + MEDIA_LNK_FL_ENABLED); #endif } @@ -583,20 +584,24 @@ void dvb_create_media_graph(struct dvb_adapter *adap) /* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */ media_device_for_each_intf(intf, mdev) { if (intf->type == MEDIA_INTF_T_DVB_CA && ca) - media_create_intf_link(ca, intf, 0); + media_create_intf_link(ca, intf, MEDIA_LNK_FL_ENABLED); if (intf->type == MEDIA_INTF_T_DVB_FE && tuner) - media_create_intf_link(tuner, intf, 0); + media_create_intf_link(tuner, intf, + MEDIA_LNK_FL_ENABLED); if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) - media_create_intf_link(demux, intf, 0); + media_create_intf_link(demux, intf, + MEDIA_LNK_FL_ENABLED); media_device_for_each_entity(entity, mdev) { if (entity->type == MEDIA_ENT_T_DVB_TSOUT) { if (!strcmp(entity->name, DVR_TSOUT)) - media_create_intf_link(entity, intf, 0); + media_create_intf_link(entity, intf, + MEDIA_LNK_FL_ENABLED); if (!strcmp(entity->name, DEMUX_TSOUT)) - media_create_intf_link(entity, intf, 0); + media_create_intf_link(entity, intf, + MEDIA_LNK_FL_ENABLED); break; } } -- cgit v1.2.3 From 7e9a8ad57c097b7fe7ed9ba514f78789363aa6b8 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 10 Dec 2015 10:58:04 -0200 Subject: [media] au0828: postpone call to au0828_unregister_media_device() The DVB core needs to unregister the media device. So, we can't call au0828_unregister_media_device() before calling au0828_dvb_unregister(), otherwise the DVB MC free code (that will be implemented on the next patch) will fail. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index ee20f4354ba2..e7ebb5e638be 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -178,8 +178,6 @@ static void au0828_usb_disconnect(struct usb_interface *interface) */ dev->dev_state = DEV_DISCONNECTED; - au0828_unregister_media_device(dev); - au0828_rc_unregister(dev); /* Digital TV */ au0828_dvb_unregister(dev); @@ -193,6 +191,10 @@ static void au0828_usb_disconnect(struct usb_interface *interface) au0828_analog_unregister(dev); v4l2_device_disconnect(&dev->v4l2_dev); v4l2_device_put(&dev->v4l2_dev); + /* + * No need to call au0828_usb_release() if V4L2 is enabled, + * as this is already called via au0828_usb_v4l2_release() + */ return; } #endif -- cgit v1.2.3 From a9709e435454cf84d8971261ff8ded3a453b9b13 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 24 Aug 2015 14:57:53 -0300 Subject: [media] media: don't try to empty links list in media_entity_cleanup() The media_entity_cleanup() function only cleans up the entity links list but this operation is already made in media_device_unregister_entity(). In most cases this should be harmless (besides having duplicated code) since the links list would be empty so the iteration would not happen but the links list is initialized in media_device_register_entity() so if a driver fails to register an entity with a media device and clean up the entity in the error path, a NULL deference pointer error will happen. So don't try to empty the links list in media_entity_cleanup() since is either done already or haven't been initialized yet. Signed-off-by: Javier Martinez Canillas --- drivers/media/media-entity.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index b1390d843909..d7243cb56c79 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -242,13 +242,6 @@ EXPORT_SYMBOL_GPL(media_entity_init); void media_entity_cleanup(struct media_entity *entity) { - struct media_link *link, *tmp; - - list_for_each_entry_safe(link, tmp, &entity->links, list) { - media_gobj_remove(&link->graph_obj); - list_del(&link->list); - kfree(link); - } } EXPORT_SYMBOL_GPL(media_entity_cleanup); -- cgit v1.2.3 From eb83a5176801d53f9f78eff8c0bf03e627110206 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 10 Dec 2015 15:29:22 -0200 Subject: [media] media-entity: fix backlink removal on __media_entity_remove_link() The logic is testing if num_links==0 at the wrong place. Due to that, a backlink may be kept without removal, causing KASAN to complain about usage after free during either entity or link removal. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index d7243cb56c79..d9d42fab22ad 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -662,13 +662,13 @@ static void __media_entity_remove_link(struct media_entity *entity, if (link->source->entity == entity) remote->num_backlinks--; - if (--remote->num_links == 0) - break; - /* Remove the remote link */ list_del(&rlink->list); media_gobj_remove(&rlink->graph_obj); kfree(rlink); + + if (--remote->num_links == 0) + break; } list_del(&link->list); media_gobj_remove(&link->graph_obj); -- cgit v1.2.3 From f50d51661af375c40cae894753e8cd9b1fe82c65 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 4 Sep 2015 15:10:29 -0300 Subject: [media] dvbdev: returns error if graph object creation fails Right now, if something gets wrong at dvb_create_media_entity() or at dvb_create_media_graph(), the device will still be registered. Change the logic to properly handle it and free all media graph objects if something goes wrong at dvb_register_device(). Also, change the logic at dvb_create_media_graph() to return an error code if something goes wrong. It is up to the caller to implement the right logic and to call dvb_unregister_device() to unregister the already-created objects. While here, add a missing logic to unregister the created interfaces. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 313 +++++++++++++++++++++++----------------- drivers/media/dvb-core/dvbdev.h | 7 +- drivers/media/media-device.c | 10 +- 3 files changed, 193 insertions(+), 137 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 5c4fb41060b4..bc650c637fc0 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -183,7 +183,40 @@ skip: return -ENFILE; } -static void dvb_create_tsout_entity(struct dvb_device *dvbdev, +static void dvb_media_device_free(struct dvb_device *dvbdev) +{ +#if defined(CONFIG_MEDIA_CONTROLLER_DVB) + if (dvbdev->entity) { + media_device_unregister_entity(dvbdev->entity); + kfree(dvbdev->entity); + kfree(dvbdev->pads); + dvbdev->entity = NULL; + dvbdev->pads = NULL; + } + + if (dvbdev->tsout_entity) { + int i; + + for (i = 0; i < dvbdev->tsout_num_entities; i++) { + media_device_unregister_entity(&dvbdev->tsout_entity[i]); + kfree(dvbdev->tsout_entity[i].name); + } + kfree(dvbdev->tsout_entity); + kfree(dvbdev->tsout_pads); + dvbdev->tsout_entity = NULL; + dvbdev->tsout_pads = NULL; + + dvbdev->tsout_num_entities = 0; + } + + if (dvbdev->intf_devnode) { + media_devnode_remove(dvbdev->intf_devnode); + dvbdev->intf_devnode = NULL; + } +#endif +} + +static int dvb_create_tsout_entity(struct dvb_device *dvbdev, const char *name, int npads) { #if defined(CONFIG_MEDIA_CONTROLLER_DVB) @@ -192,77 +225,62 @@ static void dvb_create_tsout_entity(struct dvb_device *dvbdev, dvbdev->tsout_pads = kcalloc(npads, sizeof(*dvbdev->tsout_pads), GFP_KERNEL); if (!dvbdev->tsout_pads) - return; + return -ENOMEM; + dvbdev->tsout_entity = kcalloc(npads, sizeof(*dvbdev->tsout_entity), GFP_KERNEL); - if (!dvbdev->tsout_entity) { - kfree(dvbdev->tsout_pads); - dvbdev->tsout_pads = NULL; - return; - } + if (!dvbdev->tsout_entity) + return -ENOMEM; + + dvbdev->tsout_num_entities = npads; + for (i = 0; i < npads; i++) { struct media_pad *pads = &dvbdev->tsout_pads[i]; struct media_entity *entity = &dvbdev->tsout_entity[i]; entity->name = kasprintf(GFP_KERNEL, "%s #%d", name, i); - if (!entity->name) { - ret = -ENOMEM; - break; - } + if (!entity->name) + return -ENOMEM; entity->type = MEDIA_ENT_T_DVB_TSOUT; pads->flags = MEDIA_PAD_FL_SINK; ret = media_entity_init(entity, 1, pads); if (ret < 0) - break; + return ret; ret = media_device_register_entity(dvbdev->adapter->mdev, entity); if (ret < 0) - break; - } - - if (!ret) { - dvbdev->tsout_num_entities = npads; - return; + return ret; } - - for (i--; i >= 0; i--) { - media_device_unregister_entity(&dvbdev->tsout_entity[i]); - kfree(dvbdev->tsout_entity[i].name); - } - - printk(KERN_ERR - "%s: media_device_register_entity failed for %s\n", - __func__, name); - - kfree(dvbdev->tsout_entity); - kfree(dvbdev->tsout_pads); - dvbdev->tsout_entity = NULL; - dvbdev->tsout_pads = NULL; #endif + return 0; } #define DEMUX_TSOUT "demux-tsout" #define DVR_TSOUT "dvr-tsout" -static void dvb_create_media_entity(struct dvb_device *dvbdev, - int type, int demux_sink_pads) +static int dvb_create_media_entity(struct dvb_device *dvbdev, + int type, int demux_sink_pads) { #if defined(CONFIG_MEDIA_CONTROLLER_DVB) - int i, ret = 0, npads; + int i, ret, npads; switch (type) { case DVB_DEVICE_FRONTEND: npads = 2; break; case DVB_DEVICE_DVR: - dvb_create_tsout_entity(dvbdev, DVR_TSOUT, demux_sink_pads); - return; + ret = dvb_create_tsout_entity(dvbdev, DVR_TSOUT, + demux_sink_pads); + return ret; case DVB_DEVICE_DEMUX: npads = 1 + demux_sink_pads; - dvb_create_tsout_entity(dvbdev, DEMUX_TSOUT, demux_sink_pads); + ret = dvb_create_tsout_entity(dvbdev, DEMUX_TSOUT, + demux_sink_pads); + if (ret < 0) + return ret; break; case DVB_DEVICE_CA: npads = 2; @@ -277,24 +295,22 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev, * the Media Controller, let's not create the decap * entities yet. */ - return; + return 0; default: - return; + return 0; } dvbdev->entity = kzalloc(sizeof(*dvbdev->entity), GFP_KERNEL); if (!dvbdev->entity) - return; + return -ENOMEM; dvbdev->entity->name = dvbdev->name; if (npads) { dvbdev->pads = kcalloc(npads, sizeof(*dvbdev->pads), GFP_KERNEL); - if (!dvbdev->pads) { - kfree(dvbdev->entity); - return; - } + if (!dvbdev->pads) + return -ENOMEM; } switch (type) { @@ -315,50 +331,46 @@ static void dvb_create_media_entity(struct dvb_device *dvbdev, dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; default: + /* Should never happen, as the first switch prevents it */ kfree(dvbdev->entity); + kfree(dvbdev->pads); dvbdev->entity = NULL; - return; + dvbdev->pads = NULL; + return 0; } - if (npads) + if (npads) { ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads); - if (!ret) - ret = media_device_register_entity(dvbdev->adapter->mdev, - dvbdev->entity); - if (ret < 0) { - printk(KERN_ERR - "%s: media_device_register_entity failed for %s\n", - __func__, dvbdev->entity->name); - - media_device_unregister_entity(dvbdev->entity); - for (i = 0; i < dvbdev->tsout_num_entities; i++) { - media_device_unregister_entity(&dvbdev->tsout_entity[i]); - kfree(dvbdev->tsout_entity[i].name); - } - kfree(dvbdev->pads); - kfree(dvbdev->entity); - kfree(dvbdev->tsout_pads); - kfree(dvbdev->tsout_entity); - dvbdev->entity = NULL; - return; + if (ret) + return ret; } + ret = media_device_register_entity(dvbdev->adapter->mdev, + dvbdev->entity); + if (ret) + return (ret); printk(KERN_DEBUG "%s: media entity '%s' registered.\n", __func__, dvbdev->entity->name); + #endif + return 0; } -static void dvb_register_media_device(struct dvb_device *dvbdev, - int type, int minor, - unsigned demux_sink_pads) +static int dvb_register_media_device(struct dvb_device *dvbdev, + int type, int minor, + unsigned demux_sink_pads) { #if defined(CONFIG_MEDIA_CONTROLLER_DVB) + struct media_link *link; u32 intf_type; + int ret; if (!dvbdev->adapter->mdev) - return; + return 0; - dvb_create_media_entity(dvbdev, type, demux_sink_pads); + ret = dvb_create_media_entity(dvbdev, type, demux_sink_pads); + if (ret) + return ret; switch (type) { case DVB_DEVICE_FRONTEND: @@ -377,13 +389,16 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, intf_type = MEDIA_INTF_T_DVB_NET; break; default: - return; + return 0; } dvbdev->intf_devnode = media_devnode_create(dvbdev->adapter->mdev, - intf_type, 0, - DVB_MAJOR, minor, - GFP_KERNEL); + intf_type, 0, + DVB_MAJOR, minor, + GFP_KERNEL); + + if (!dvbdev->intf_devnode) + return -ENOMEM; /* * Create the "obvious" link, e. g. the ones that represent @@ -393,13 +408,15 @@ static void dvb_register_media_device(struct dvb_device *dvbdev, * DVB demux intf -> dvr */ - if (!dvbdev->entity || !dvbdev->intf_devnode) - return; - - media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, - MEDIA_LNK_FL_ENABLED); + if (!dvbdev->entity) + return 0; + link = media_create_intf_link(dvbdev->entity, &dvbdev->intf_devnode->intf, + MEDIA_LNK_FL_ENABLED); + if (!link) + return -ENOMEM; #endif + return 0; } int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, @@ -410,7 +427,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, struct file_operations *dvbdevfops; struct device *clsdev; int minor; - int id; + int id, ret; mutex_lock(&dvbdev_register_lock); @@ -421,7 +438,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, return -ENFILE; } - *pdvbdev = dvbdev = kmalloc(sizeof(struct dvb_device), GFP_KERNEL); + *pdvbdev = dvbdev = kzalloc(sizeof(*dvbdev), GFP_KERNEL); if (!dvbdev){ mutex_unlock(&dvbdev_register_lock); @@ -470,6 +487,20 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, dvb_minors[minor] = dvbdev; up_write(&minor_rwsem); + ret = dvb_register_media_device(dvbdev, type, minor, demux_sink_pads); + if (ret) { + printk(KERN_ERR + "%s: dvb_register_media_device failed to create the mediagraph\n", + __func__); + + dvb_media_device_free(dvbdev); + kfree(dvbdevfops); + kfree(dvbdev); + up_write(&minor_rwsem); + mutex_unlock(&dvbdev_register_lock); + return ret; + } + mutex_unlock(&dvbdev_register_lock); clsdev = device_create(dvb_class, adap->device, @@ -483,8 +514,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, dprintk(KERN_DEBUG "DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", adap->num, dnames[type], id, minor, minor); - dvb_register_media_device(dvbdev, type, minor, demux_sink_pads); - return 0; } EXPORT_SYMBOL(dvb_register_device); @@ -499,24 +528,9 @@ void dvb_unregister_device(struct dvb_device *dvbdev) dvb_minors[dvbdev->minor] = NULL; up_write(&minor_rwsem); - device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor)); - -#if defined(CONFIG_MEDIA_CONTROLLER_DVB) - if (dvbdev->entity) { - int i; + dvb_media_device_free(dvbdev); - media_device_unregister_entity(dvbdev->entity); - for (i = 0; i < dvbdev->tsout_num_entities; i++) { - media_device_unregister_entity(&dvbdev->tsout_entity[i]); - kfree(dvbdev->tsout_entity[i].name); - } - - kfree(dvbdev->entity); - kfree(dvbdev->pads); - kfree(dvbdev->tsout_entity); - kfree(dvbdev->tsout_pads); - } -#endif + device_destroy(dvb_class, MKDEV(DVB_MAJOR, dvbdev->minor)); list_del (&dvbdev->list_head); kfree (dvbdev->fops); @@ -526,17 +540,19 @@ EXPORT_SYMBOL(dvb_unregister_device); #ifdef CONFIG_MEDIA_CONTROLLER_DVB -void dvb_create_media_graph(struct dvb_adapter *adap) +int dvb_create_media_graph(struct dvb_adapter *adap) { struct media_device *mdev = adap->mdev; struct media_entity *entity, *tuner = NULL, *demod = NULL; struct media_entity *demux = NULL, *ca = NULL; + struct media_link *link; struct media_interface *intf; unsigned demux_pad = 0; unsigned dvr_pad = 0; + int ret; if (!mdev) - return; + return 0; media_device_for_each_entity(entity, mdev) { switch (entity->type) { @@ -555,57 +571,94 @@ void dvb_create_media_graph(struct dvb_adapter *adap) } } - if (tuner && demod) - media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, 0); + if (tuner && demod) { + ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, + demod, 0, MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; + } - if (demod && demux) - media_create_pad_link(demod, 1, demux, 0, MEDIA_LNK_FL_ENABLED); - if (demux && ca) - media_create_pad_link(demux, 1, ca, 0, MEDIA_LNK_FL_ENABLED); + if (demod && demux) { + ret = media_create_pad_link(demod, 1, demux, + 0, MEDIA_LNK_FL_ENABLED); + if (ret) + return -ENOMEM; + } + if (demux && ca) { + ret = media_create_pad_link(demux, 1, ca, + 0, MEDIA_LNK_FL_ENABLED); + if (!ret) + return -ENOMEM; + } /* Create demux links for each ringbuffer/pad */ if (demux) { media_device_for_each_entity(entity, mdev) { if (entity->type == MEDIA_ENT_T_DVB_TSOUT) { if (!strncmp(entity->name, DVR_TSOUT, - strlen(DVR_TSOUT))) - media_create_pad_link(demux, - ++dvr_pad, - entity, 0, 0); + strlen(DVR_TSOUT))) { + ret = media_create_pad_link(demux, + ++dvr_pad, + entity, 0, 0); + if (ret) + return ret; + } if (!strncmp(entity->name, DEMUX_TSOUT, - strlen(DEMUX_TSOUT))) - media_create_pad_link(demux, + strlen(DEMUX_TSOUT))) { + ret = media_create_pad_link(demux, ++demux_pad, - entity, 0, 0); + entity, 0, 0); + if (ret) + return ret; + } } } } /* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */ media_device_for_each_intf(intf, mdev) { - if (intf->type == MEDIA_INTF_T_DVB_CA && ca) - media_create_intf_link(ca, intf, MEDIA_LNK_FL_ENABLED); + if (intf->type == MEDIA_INTF_T_DVB_CA && ca) { + link = media_create_intf_link(ca, intf, + MEDIA_LNK_FL_ENABLED); + if (!link) + return -ENOMEM; + } - if (intf->type == MEDIA_INTF_T_DVB_FE && tuner) - media_create_intf_link(tuner, intf, - MEDIA_LNK_FL_ENABLED); + if (intf->type == MEDIA_INTF_T_DVB_FE && tuner) { + link = media_create_intf_link(tuner, intf, + MEDIA_LNK_FL_ENABLED); + if (!link) + return -ENOMEM; + } - if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) - media_create_intf_link(demux, intf, - MEDIA_LNK_FL_ENABLED); + if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) { + link = media_create_intf_link(demux, intf, + MEDIA_LNK_FL_ENABLED); + if (!link) + return -ENOMEM; + } media_device_for_each_entity(entity, mdev) { if (entity->type == MEDIA_ENT_T_DVB_TSOUT) { - if (!strcmp(entity->name, DVR_TSOUT)) - media_create_intf_link(entity, intf, - MEDIA_LNK_FL_ENABLED); - if (!strcmp(entity->name, DEMUX_TSOUT)) - media_create_intf_link(entity, intf, - MEDIA_LNK_FL_ENABLED); + if (!strcmp(entity->name, DVR_TSOUT)) { + link = media_create_intf_link(entity, + intf, + MEDIA_LNK_FL_ENABLED); + if (!link) + return -ENOMEM; + } + if (!strcmp(entity->name, DEMUX_TSOUT)) { + link = media_create_intf_link(entity, + intf, + MEDIA_LNK_FL_ENABLED); + if (!link) + return -ENOMEM; + } break; } } } + return 0; } EXPORT_SYMBOL_GPL(dvb_create_media_graph); #endif diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index 7af8adbb589b..3840dd62bfee 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -206,7 +206,7 @@ int dvb_register_device(struct dvb_adapter *adap, void dvb_unregister_device(struct dvb_device *dvbdev); #ifdef CONFIG_MEDIA_CONTROLLER_DVB -void dvb_create_media_graph(struct dvb_adapter *adap); +int dvb_create_media_graph(struct dvb_adapter *adap); static inline void dvb_register_media_controller(struct dvb_adapter *adap, struct media_device *mdev) { @@ -214,7 +214,10 @@ static inline void dvb_register_media_controller(struct dvb_adapter *adap, } #else -static inline void dvb_create_media_graph(struct dvb_adapter *adap) {} +static inline int dvb_create_media_graph(struct dvb_adapter *adap) +{ + return 0; +}; #define dvb_register_media_controller(a, b) {} #endif diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 96700843b1e4..c7d97190a67e 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -576,6 +576,10 @@ void media_device_unregister(struct media_device *mdev) struct media_entity *next; struct media_interface *intf, *tmp_intf; + /* Remove all entities from the media device */ + list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) + media_device_unregister_entity(entity); + /* Remove all interfaces from the media device */ spin_lock(&mdev->lock); list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, @@ -586,9 +590,6 @@ void media_device_unregister(struct media_device *mdev) } spin_unlock(&mdev->lock); - list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) - media_device_unregister_entity(entity); - device_remove_file(&mdev->devnode.dev, &dev_attr_model); media_devnode_unregister(&mdev->devnode); @@ -654,8 +655,7 @@ void media_device_unregister_entity(struct media_entity *entity) /* Remove all interface links pointing to this entity */ list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { list_for_each_entry_safe(link, tmp, &intf->links, list) { - if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY - && link->entity == entity) + if (link->entity == entity) __media_remove_intf_link(link); } } -- cgit v1.2.3 From d9c21e3e4b459b45e11406b83ebde163181508a1 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 24 Aug 2015 08:47:54 -0300 Subject: [media] v4l2-core: create MC interfaces for devnodes V4L2 device (and subdevice) nodes should create an interface, if the Media Controller support is enabled. Please notice that radio devices should not create an entity, as radio input/output is either via wires or via ALSA. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-dev.c | 111 ++++++++++++++++++++++++++++------ drivers/media/v4l2-core/v4l2-device.c | 16 ++++- include/media/v4l2-dev.h | 1 + 3 files changed, 109 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 2297571a0568..077cdc92778c 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -194,9 +194,12 @@ static void v4l2_device_release(struct device *cd) mutex_unlock(&videodev_lock); #if defined(CONFIG_MEDIA_CONTROLLER) - if (v4l2_dev->mdev && - vdev->vfl_type != VFL_TYPE_SUBDEV) - media_device_unregister_entity(&vdev->entity); + if (v4l2_dev->mdev) { + /* Remove interfaces and interface links */ + media_devnode_remove(vdev->intf_devnode); + if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) + media_device_unregister_entity(&vdev->entity); + } #endif /* Do not call v4l2_device_put if there is no release callback set. @@ -723,6 +726,91 @@ static void determine_valid_ioctls(struct video_device *vdev) BASE_VIDIOC_PRIVATE); } +static int video_register_media_controller(struct video_device *vdev, int type) +{ +#if defined(CONFIG_MEDIA_CONTROLLER) + u32 intf_type; + int ret; + + if (!vdev->v4l2_dev->mdev) + return 0; + + vdev->entity.type = MEDIA_ENT_T_UNKNOWN; + + switch (type) { + case VFL_TYPE_GRABBER: + intf_type = MEDIA_INTF_T_V4L_VIDEO; + vdev->entity.type = MEDIA_ENT_T_V4L2_VIDEO; + break; + case VFL_TYPE_VBI: + intf_type = MEDIA_INTF_T_V4L_VBI; + vdev->entity.type = MEDIA_ENT_T_V4L2_VBI; + break; + case VFL_TYPE_SDR: + intf_type = MEDIA_INTF_T_V4L_SWRADIO; + vdev->entity.type = MEDIA_ENT_T_V4L2_SWRADIO; + break; + case VFL_TYPE_RADIO: + intf_type = MEDIA_INTF_T_V4L_RADIO; + /* + * Radio doesn't have an entity at the V4L2 side to represent + * radio input or output. Instead, the audio input/output goes + * via either physical wires or ALSA. + */ + break; + case VFL_TYPE_SUBDEV: + intf_type = MEDIA_INTF_T_V4L_SUBDEV; + /* Entity will be created via v4l2_device_register_subdev() */ + break; + default: + return 0; + } + + if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) { + vdev->entity.name = vdev->name; + + /* Needed just for backward compatibility with legacy MC API */ + vdev->entity.info.dev.major = VIDEO_MAJOR; + vdev->entity.info.dev.minor = vdev->minor; + + ret = media_device_register_entity(vdev->v4l2_dev->mdev, + &vdev->entity); + if (ret < 0) { + printk(KERN_WARNING + "%s: media_device_register_entity failed\n", + __func__); + return ret; + } + } + + vdev->intf_devnode = media_devnode_create(vdev->v4l2_dev->mdev, + intf_type, + 0, VIDEO_MAJOR, + vdev->minor, + GFP_KERNEL); + if (!vdev->intf_devnode) { + media_device_unregister_entity(&vdev->entity); + return -ENOMEM; + } + + if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) { + struct media_link *link; + + link = media_create_intf_link(&vdev->entity, + &vdev->intf_devnode->intf, 0); + if (!link) { + media_devnode_remove(vdev->intf_devnode); + media_device_unregister_entity(&vdev->entity); + return -ENOMEM; + } + } + + /* FIXME: how to create the other interface links? */ + +#endif + return 0; +} + /** * __video_register_device - register video4linux devices * @vdev: video device structure we want to register @@ -918,22 +1006,9 @@ int __video_register_device(struct video_device *vdev, int type, int nr, /* Increase v4l2_device refcount */ v4l2_device_get(vdev->v4l2_dev); -#if defined(CONFIG_MEDIA_CONTROLLER) /* Part 5: Register the entity. */ - if (vdev->v4l2_dev->mdev && - vdev->vfl_type != VFL_TYPE_SUBDEV) { - vdev->entity.type = MEDIA_ENT_T_V4L2_VIDEO; - vdev->entity.name = vdev->name; - vdev->entity.info.dev.major = VIDEO_MAJOR; - vdev->entity.info.dev.minor = vdev->minor; - ret = media_device_register_entity(vdev->v4l2_dev->mdev, - &vdev->entity); - if (ret < 0) - printk(KERN_WARNING - "%s: media_device_register_entity failed\n", - __func__); - } -#endif + ret = video_register_media_controller(vdev, type); + /* Part 6: Activate this minor. The char device can now be used. */ set_bit(V4L2_FL_REGISTERED, &vdev->flags); diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 7129e438f29e..3c87307e56f0 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -258,6 +258,17 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) #if defined(CONFIG_MEDIA_CONTROLLER) sd->entity.info.dev.major = VIDEO_MAJOR; sd->entity.info.dev.minor = vdev->minor; + + /* Interface is created by __video_register_device() */ + if (vdev->v4l2_dev->mdev) { + struct media_link *link; + + link = media_create_intf_link(&sd->entity, + &vdev->intf_devnode->intf, + 0); + if (!link) + goto clean_up; + } #endif sd->devnode = vdev; } @@ -294,7 +305,10 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd) #if defined(CONFIG_MEDIA_CONTROLLER) if (v4l2_dev->mdev) { - media_entity_remove_links(&sd->entity); + /* + * No need to explicitly remove links, as both pads and + * links are removed by the function below, in the right order + */ media_device_unregister_entity(&sd->entity); } #endif diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index acbcd2f5fe7f..eeabf20e87a6 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h @@ -86,6 +86,7 @@ struct video_device { #if defined(CONFIG_MEDIA_CONTROLLER) struct media_entity entity; + struct media_intf_devnode *intf_devnode; #endif /* device ops */ const struct v4l2_file_operations *fops; -- cgit v1.2.3 From d1f337375aedb2999bdca24b40ba6e5c1a796eb4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 31 Aug 2015 11:43:09 -0300 Subject: [media] au0828: add support for the connectors Depending on the input, an au0828 may have a different number of connectors. add entities to represent them. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-core.c | 15 +++++++ drivers/media/usb/au0828/au0828-video.c | 76 ++++++++++++++++++++++++++++----- drivers/media/usb/au0828/au0828.h | 3 +- 3 files changed, 82 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index e7ebb5e638be..02aa6d3edffd 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -153,11 +153,26 @@ static void au0828_usb_release(struct au0828_dev *dev) } #ifdef CONFIG_VIDEO_AU0828_V4L2 + +static void au0828_usb_v4l2_media_release(struct au0828_dev *dev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER + int i; + + for (i = 0; i < AU0828_MAX_INPUT; i++) { + if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED) + return; + media_device_unregister_entity(&dev->input_ent[i]); + } +#endif +} + static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev) { struct au0828_dev *dev = container_of(v4l2_dev, struct au0828_dev, v4l2_dev); + au0828_usb_v4l2_media_release(dev); v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl); v4l2_device_unregister(&dev->v4l2_dev); au0828_usb_release(dev); diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 97df879c4199..75f2e02908f4 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -1795,6 +1795,69 @@ static int au0828_vb2_setup(struct au0828_dev *dev) return 0; } +static void au0828_analog_create_entities(struct au0828_dev *dev) +{ +#if defined(CONFIG_MEDIA_CONTROLLER) + static const char * const inames[] = { + [AU0828_VMUX_COMPOSITE] = "Composite", + [AU0828_VMUX_SVIDEO] = "S-Video", + [AU0828_VMUX_CABLE] = "Cable TV", + [AU0828_VMUX_TELEVISION] = "Television", + [AU0828_VMUX_DVB] = "DVB", + [AU0828_VMUX_DEBUG] = "tv debug" + }; + int ret, i; + + /* Initialize Video and VBI pads */ + dev->video_pad.flags = MEDIA_PAD_FL_SINK; + ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad); + if (ret < 0) + pr_err("failed to initialize video media entity!\n"); + + dev->vbi_pad.flags = MEDIA_PAD_FL_SINK; + ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); + if (ret < 0) + pr_err("failed to initialize vbi media entity!\n"); + + /* Create entities for each input connector */ + for (i = 0; i < AU0828_MAX_INPUT; i++) { + struct media_entity *ent = &dev->input_ent[i]; + + if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED) + break; + + ent->name = inames[AUVI_INPUT(i).type]; + ent->flags = MEDIA_ENT_FL_CONNECTOR; + dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE; + + switch (AUVI_INPUT(i).type) { + case AU0828_VMUX_COMPOSITE: + ent->type = MEDIA_ENT_T_CONN_COMPOSITE; + break; + case AU0828_VMUX_SVIDEO: + ent->type = MEDIA_ENT_T_CONN_SVIDEO; + break; + case AU0828_VMUX_CABLE: + case AU0828_VMUX_TELEVISION: + case AU0828_VMUX_DVB: + ent->type = MEDIA_ENT_T_CONN_RF; + break; + default: /* AU0828_VMUX_DEBUG */ + ent->type = MEDIA_ENT_T_CONN_TEST; + break; + } + + ret = media_entity_init(ent, 1, &dev->input_pad[i]); + if (ret < 0) + pr_err("failed to initialize input pad[%d]!\n", i); + + ret = media_device_register_entity(dev->media_dev, ent); + if (ret < 0) + pr_err("failed to register input entity %d!\n", i); + } +#endif +} + /**************************************************************************/ int au0828_analog_register(struct au0828_dev *dev, @@ -1883,17 +1946,8 @@ int au0828_analog_register(struct au0828_dev *dev, dev->vbi_dev.queue->lock = &dev->vb_vbi_queue_lock; strcpy(dev->vbi_dev.name, "au0828a vbi"); -#if defined(CONFIG_MEDIA_CONTROLLER) - dev->video_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad); - if (ret < 0) - pr_err("failed to initialize video media entity!\n"); - - dev->vbi_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); - if (ret < 0) - pr_err("failed to initialize vbi media entity!\n"); -#endif + /* Init entities at the Media Controller */ + au0828_analog_create_entities(dev); /* initialize videobuf2 stuff */ retval = au0828_vb2_setup(dev); diff --git a/drivers/media/usb/au0828/au0828.h b/drivers/media/usb/au0828/au0828.h index 3577b931157b..8276072bc55a 100644 --- a/drivers/media/usb/au0828/au0828.h +++ b/drivers/media/usb/au0828/au0828.h @@ -94,7 +94,6 @@ struct au0828_board { unsigned char has_ir_i2c:1; unsigned char has_analog:1; struct au0828_input input[AU0828_MAX_INPUT]; - }; struct au0828_dvb { @@ -282,6 +281,8 @@ struct au0828_dev { struct media_device *media_dev; struct media_pad video_pad, vbi_pad; struct media_entity *decoder; + struct media_entity input_ent[AU0828_MAX_INPUT]; + struct media_pad input_pad[AU0828_MAX_INPUT]; #endif }; -- cgit v1.2.3 From 28b6ba1106b5864e6bdd1b75840ccf5b1ca3d1b7 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 31 Aug 2015 13:23:28 -0300 Subject: [media] au0828: Create connector links Now that connectors are entities, we need to represent the connector links. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-core.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'drivers') diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 02aa6d3edffd..0d77e9cc303b 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -259,6 +259,7 @@ static void au0828_create_media_graph(struct au0828_dev *dev) struct media_device *mdev = dev->media_dev; struct media_entity *entity; struct media_entity *tuner = NULL, *decoder = NULL; + int i; if (!mdev) return; @@ -276,6 +277,7 @@ static void au0828_create_media_graph(struct au0828_dev *dev) /* Analog setup, using tuner as a link */ + /* Something bad happened! */ if (!decoder) return; @@ -286,6 +288,30 @@ static void au0828_create_media_graph(struct au0828_dev *dev) MEDIA_LNK_FL_ENABLED); media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, MEDIA_LNK_FL_ENABLED); + + for (i = 0; i < AU0828_MAX_INPUT; i++) { + struct media_entity *ent = &dev->input_ent[i]; + + if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED) + break; + + switch (AUVI_INPUT(i).type) { + case AU0828_VMUX_CABLE: + case AU0828_VMUX_TELEVISION: + case AU0828_VMUX_DVB: + if (tuner) + media_create_pad_link(ent, 0, tuner, + TUNER_PAD_RF_INPUT, + MEDIA_LNK_FL_ENABLED); + break; + case AU0828_VMUX_COMPOSITE: + case AU0828_VMUX_SVIDEO: + default: /* AU0828_VMUX_DEBUG */ + /* FIXME: fix the decoder PAD */ + media_create_pad_link(ent, 0, decoder, 0, 0); + break; + } + } #endif } -- cgit v1.2.3 From 39d1ebc6092f8266fb788733ca92b8492b1d69f2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 30 Aug 2015 09:53:57 -0300 Subject: [media] media-device: supress backlinks at G_TOPOLOGY ioctl Due to the graph traversal algorithm currently in usage, we need a copy of all data links. Those backlinks should not be send to userspace, as otherwise, all links there will be duplicated. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 3 +++ drivers/media/media-entity.c | 1 + include/media/media-entity.h | 2 ++ 3 files changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index c7d97190a67e..30cef8740afa 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -333,6 +333,9 @@ static long __media_device_get_topology(struct media_device *mdev, /* Get links and number of links */ i = 0; media_device_for_each_link(link, mdev) { + if (link->is_backlink) + continue; + i++; if (ret || !topo->links) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index d9d42fab22ad..246d7e65aded 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -625,6 +625,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, backlink->source = &source->pads[source_pad]; backlink->sink = &sink->pads[sink_pad]; backlink->flags = flags; + backlink->is_backlink = true; /* Initialize graph object embedded at the new link */ media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK, diff --git a/include/media/media-entity.h b/include/media/media-entity.h index fd19aecdcbb6..3b591d72c703 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -96,6 +96,7 @@ struct media_pipeline { * @reverse: Pointer to the link for the reverse direction of a pad to pad * link. * @flags: Link flags, as defined in uapi/media.h (MEDIA_LNK_FL_*) + * @is_backlink: Indicate if the link is a backlink. */ struct media_link { struct media_gobj graph_obj; @@ -112,6 +113,7 @@ struct media_link { }; struct media_link *reverse; unsigned long flags; + bool is_backlink; }; /** -- cgit v1.2.3 From 13f6e8887a1f61764a05a3348476d38071201f08 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 4 Sep 2015 15:39:43 -0300 Subject: [media] v4l2 core: enable all interface links at init Interface links are normally enabled, meaning that the interfaces are bound to the entities. So, any ioctl send to the interface are reflected at the entities managed by the interface. However, when a device is used, other interfaces for the same hardware could be decoupled from the entities linked to them, because the hardware may have some parts busy. That's for example, what happens when an hybrid TV device is in use. If it is streaming analog TV or capturing signals from S-Video/Composite connectors, typically the digital part of the hardware can't be used and vice-versa. This is generally due to some internal hardware or firmware limitation, that it is not easily mapped via data pipelines. What the Kernel drivers do internally is that they decouple the hardware from the interface. So, all changes, if allowed, are done only at some interface cache, but not physically changed at the hardware. The usage is similar to the usage of the MEDIA_LNK_FL_ENABLED on data links. So, let's use the same flag to indicate if either the interface to entity link is bound/enabled or not. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-dev.c | 3 ++- drivers/media/v4l2-core/v4l2-device.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 077cdc92778c..d36436582de9 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -797,7 +797,8 @@ static int video_register_media_controller(struct video_device *vdev, int type) struct media_link *link; link = media_create_intf_link(&vdev->entity, - &vdev->intf_devnode->intf, 0); + &vdev->intf_devnode->intf, + MEDIA_LNK_FL_ENABLED); if (!link) { media_devnode_remove(vdev->intf_devnode); media_device_unregister_entity(&vdev->entity); diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 3c87307e56f0..85f724b53a14 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -265,7 +265,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) link = media_create_intf_link(&sd->entity, &vdev->intf_devnode->intf, - 0); + MEDIA_LNK_FL_ENABLED); if (!link) goto clean_up; } -- cgit v1.2.3 From 0d3ab8410dcb60aef2104231ba817037b3ba73bd Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 4 Sep 2015 15:33:46 -0300 Subject: [media] dvb core: must check dvb_create_media_graph() If media controller is enabled and mdev is filled, it should ensure that the media graph will be properly initialized. Enforce that. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smsdvb-main.c | 6 +++++- drivers/media/dvb-core/dvbdev.h | 2 +- drivers/media/usb/au0828/au0828-dvb.c | 8 +++++--- drivers/media/usb/cx231xx/cx231xx-dvb.c | 6 +++++- drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 4 +++- drivers/media/usb/dvb-usb/dvb-usb-dvb.c | 6 ++++-- 6 files changed, 23 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c index f4305ae800f4..ab345490a43a 100644 --- a/drivers/media/common/siano/smsdvb-main.c +++ b/drivers/media/common/siano/smsdvb-main.c @@ -1183,7 +1183,11 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev, if (smsdvb_debugfs_create(client) < 0) pr_info("failed to create debugfs node\n"); - dvb_create_media_graph(&client->adapter); + rc = dvb_create_media_graph(&client->adapter); + if (rc < 0) { + pr_err("dvb_create_media_graph failed %d\n", rc); + goto client_error; + } pr_info("DVB interface registered.\n"); return 0; diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index 3840dd62bfee..de85ba0f570a 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -206,7 +206,7 @@ int dvb_register_device(struct dvb_adapter *adap, void dvb_unregister_device(struct dvb_device *dvbdev); #ifdef CONFIG_MEDIA_CONTROLLER_DVB -int dvb_create_media_graph(struct dvb_adapter *adap); +__must_check int dvb_create_media_graph(struct dvb_adapter *adap); static inline void dvb_register_media_controller(struct dvb_adapter *adap, struct media_device *mdev) { diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c index c01772c4f9f0..cd542b49a6c2 100644 --- a/drivers/media/usb/au0828/au0828-dvb.c +++ b/drivers/media/usb/au0828/au0828-dvb.c @@ -486,12 +486,14 @@ static int dvb_register(struct au0828_dev *dev) dvb->start_count = 0; dvb->stop_count = 0; -#ifdef CONFIG_MEDIA_CONTROLLER_DVB - dvb_create_media_graph(&dvb->adapter); -#endif + result = dvb_create_media_graph(&dvb->adapter); + if (result < 0) + goto fail_create_graph; return 0; +fail_create_graph: + dvb_net_release(&dvb->net); fail_fe_conn: dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); fail_fe_mem: diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c index e3594b9fab4a..b7552d20ebdb 100644 --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c @@ -551,10 +551,14 @@ static int register_dvb(struct cx231xx_dvb *dvb, /* register network adapter */ dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); - dvb_create_media_graph(&dvb->adapter); + result = dvb_create_media_graph(&dvb->adapter); + if (result < 0) + goto fail_create_graph; return 0; +fail_create_graph: + dvb_net_release(&dvb->net); fail_fe_conn: dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); fail_fe_mem: diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index f5df9eaba04f..6d3f61f6dc77 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c @@ -698,7 +698,9 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap) } } - dvb_create_media_graph(&adap->dvb_adap); + ret = dvb_create_media_graph(&adap->dvb_adap); + if (ret < 0) + goto err_dvb_unregister_frontend; return 0; diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c index 8a260c854653..b51dbdf03f42 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c @@ -318,10 +318,12 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) adap->num_frontends_initialized++; } + if (ret) + return ret; - dvb_create_media_graph(&adap->dvb_adap); + ret = dvb_create_media_graph(&adap->dvb_adap); - return 0; + return ret; } int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap) -- cgit v1.2.3 From ab232e46bf01db5c540a00f478853a3572b0b88b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 4 Sep 2015 16:07:03 -0300 Subject: [media] cx231xx: enforce check for graph creation If the graph creation fails, don't register the device. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/cx231xx/cx231xx-cards.c | 40 ++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 29cf0c268b19..b842bfc799cc 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1185,8 +1185,6 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev) */ void cx231xx_release_resources(struct cx231xx *dev) { - cx231xx_unregister_media_device(dev); - cx231xx_release_analog_resources(dev); cx231xx_remove_from_devlist(dev); @@ -1199,6 +1197,8 @@ void cx231xx_release_resources(struct cx231xx *dev) /* delete v4l2 device */ v4l2_device_unregister(&dev->v4l2_dev); + cx231xx_unregister_media_device(dev); + usb_put_dev(dev->udev); /* Mark device as unused */ @@ -1237,15 +1237,16 @@ static void cx231xx_media_device_register(struct cx231xx *dev, #endif } -static void cx231xx_create_media_graph(struct cx231xx *dev) +static int cx231xx_create_media_graph(struct cx231xx *dev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev = dev->media_dev; struct media_entity *entity; struct media_entity *tuner = NULL, *decoder = NULL; + int ret; if (!mdev) - return; + return 0; media_device_for_each_entity(entity, mdev) { switch (entity->type) { @@ -1261,16 +1262,24 @@ static void cx231xx_create_media_graph(struct cx231xx *dev) /* Analog setup, using tuner as a link */ if (!decoder) - return; + return 0; - if (tuner) - media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0, - MEDIA_LNK_FL_ENABLED); - media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, - MEDIA_LNK_FL_ENABLED); - media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, - MEDIA_LNK_FL_ENABLED); + if (tuner) { + ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0, + MEDIA_LNK_FL_ENABLED); + if (ret < 0) + return ret; + } + ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, + MEDIA_LNK_FL_ENABLED); + if (ret < 0) + return ret; + ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, + MEDIA_LNK_FL_ENABLED); + if (ret < 0) + return ret; #endif + return 0; } /* @@ -1732,9 +1741,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface, /* load other modules required */ request_modules(dev); - cx231xx_create_media_graph(dev); + retval = cx231xx_create_media_graph(dev); + if (retval < 0) { + cx231xx_release_resources(dev); + } - return 0; + return retval; err_video_alt: /* cx231xx_uninit_dev: */ cx231xx_close_extension(dev); -- cgit v1.2.3 From 4e26f3abafa9d0f635e105c8b9021f3b5bae6702 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 4 Sep 2015 16:08:02 -0300 Subject: [media] au0828: enforce check for graph creation If the graph creation fails, don't register the device. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-core.c | 58 +++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 0d77e9cc303b..27679e5cdca1 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -172,9 +172,9 @@ static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev) struct au0828_dev *dev = container_of(v4l2_dev, struct au0828_dev, v4l2_dev); - au0828_usb_v4l2_media_release(dev); v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl); v4l2_device_unregister(&dev->v4l2_dev); + au0828_usb_v4l2_media_release(dev); au0828_usb_release(dev); } #endif @@ -253,16 +253,16 @@ static void au0828_media_device_register(struct au0828_dev *dev, } -static void au0828_create_media_graph(struct au0828_dev *dev) +static int au0828_create_media_graph(struct au0828_dev *dev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev = dev->media_dev; struct media_entity *entity; struct media_entity *tuner = NULL, *decoder = NULL; - int i; + int i, ret; if (!mdev) - return; + return 0; media_device_for_each_entity(entity, mdev) { switch (entity->type) { @@ -279,15 +279,23 @@ static void au0828_create_media_graph(struct au0828_dev *dev) /* Something bad happened! */ if (!decoder) - return; - - if (tuner) - media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0, - MEDIA_LNK_FL_ENABLED); - media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, - MEDIA_LNK_FL_ENABLED); - media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, - MEDIA_LNK_FL_ENABLED); + return -EINVAL; + + if (tuner) { + ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, + decoder, 0, + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; + } + ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; + ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; for (i = 0; i < AU0828_MAX_INPUT; i++) { struct media_entity *ent = &dev->input_ent[i]; @@ -299,20 +307,27 @@ static void au0828_create_media_graph(struct au0828_dev *dev) case AU0828_VMUX_CABLE: case AU0828_VMUX_TELEVISION: case AU0828_VMUX_DVB: - if (tuner) - media_create_pad_link(ent, 0, tuner, - TUNER_PAD_RF_INPUT, - MEDIA_LNK_FL_ENABLED); + if (!tuner) + break; + + ret = media_create_pad_link(ent, 0, tuner, + TUNER_PAD_RF_INPUT, + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; break; case AU0828_VMUX_COMPOSITE: case AU0828_VMUX_SVIDEO: default: /* AU0828_VMUX_DEBUG */ /* FIXME: fix the decoder PAD */ - media_create_pad_link(ent, 0, decoder, 0, 0); + ret = media_create_pad_link(ent, 0, decoder, 0, 0); + if (ret) + return ret; break; } } #endif + return 0; } static int au0828_usb_probe(struct usb_interface *interface, @@ -427,7 +442,12 @@ static int au0828_usb_probe(struct usb_interface *interface, mutex_unlock(&dev->lock); - au0828_create_media_graph(dev); + retval = au0828_create_media_graph(dev); + if (retval) { + pr_err("%s() au0282_dev_register failed to create graph\n", + __func__); + au0828_usb_disconnect(interface); + } return retval; } -- cgit v1.2.3 From 0e576b76f5470a2f8b2287958a2b9a3dd0f56f10 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 6 Sep 2015 09:33:39 -0300 Subject: [media] media-entity.h: rename entity.type to entity.function Entities should have one or more functions. Calling it as a type proofed to not be correct, as an entity could eventually have more than one type. So, rename the field as function. Please notice that this patch doesn't extend support for multiple function entities. Such change will happen when we have real case drivers using it. No functional changes. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/v4l2-framework.txt | 4 ++-- drivers/media/dvb-core/dvbdev.c | 14 +++++++------- drivers/media/dvb-frontends/au8522_decoder.c | 2 +- drivers/media/i2c/adp1653.c | 2 +- drivers/media/i2c/as3645a.c | 2 +- drivers/media/i2c/cx25840/cx25840-core.c | 2 +- drivers/media/i2c/lm3560.c | 2 +- drivers/media/i2c/lm3646.c | 2 +- drivers/media/i2c/m5mols/m5mols_core.c | 2 +- drivers/media/i2c/noon010pc30.c | 2 +- drivers/media/i2c/ov2659.c | 2 +- drivers/media/i2c/ov9650.c | 2 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 ++-- drivers/media/i2c/s5k4ecgx.c | 2 +- drivers/media/i2c/s5k5baf.c | 6 +++--- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 2 +- drivers/media/media-device.c | 6 +++--- drivers/media/platform/xilinx/xilinx-dma.c | 2 +- drivers/media/usb/au0828/au0828-core.c | 2 +- drivers/media/usb/au0828/au0828-video.c | 8 ++++---- drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +- drivers/media/usb/cx231xx/cx231xx-video.c | 2 +- drivers/media/v4l2-core/tuner-core.c | 2 +- drivers/media/v4l2-core/v4l2-dev.c | 14 +++++++------- drivers/media/v4l2-core/v4l2-flash-led-class.c | 2 +- drivers/media/v4l2-core/v4l2-subdev.c | 6 +++--- include/media/media-entity.h | 9 +++++---- 28 files changed, 55 insertions(+), 54 deletions(-) (limited to 'drivers') diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 109cc3792534..2e0fc28fa12f 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt @@ -303,8 +303,8 @@ calling media_entity_init(): err = media_entity_init(&sd->entity, npads, pads); The pads array must have been previously initialized. There is no need to -manually set the struct media_entity type and name fields, but the revision -field must be initialized if needed. +manually set the struct media_entity function and name fields, but the +revision field must be initialized if needed. A reference to the entity will be automatically acquired/released when the subdev device node (if any) is opened/closed. diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index bc650c637fc0..f6fc95d1345b 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -242,7 +242,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev, if (!entity->name) return -ENOMEM; - entity->type = MEDIA_ENT_T_DVB_TSOUT; + entity->function = MEDIA_ENT_T_DVB_TSOUT; pads->flags = MEDIA_PAD_FL_SINK; ret = media_entity_init(entity, 1, pads); @@ -315,18 +315,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev, switch (type) { case DVB_DEVICE_FRONTEND: - dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMOD; + dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; case DVB_DEVICE_DEMUX: - dvbdev->entity->type = MEDIA_ENT_T_DVB_DEMUX; + dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; for (i = 1; i < npads; i++) dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE; break; case DVB_DEVICE_CA: - dvbdev->entity->type = MEDIA_ENT_T_DVB_CA; + dvbdev->entity->function = MEDIA_ENT_T_DVB_CA; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; @@ -555,7 +555,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap) return 0; media_device_for_each_entity(entity, mdev) { - switch (entity->type) { + switch (entity->function) { case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: tuner = entity; break; @@ -594,7 +594,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap) /* Create demux links for each ringbuffer/pad */ if (demux) { media_device_for_each_entity(entity, mdev) { - if (entity->type == MEDIA_ENT_T_DVB_TSOUT) { + if (entity->function == MEDIA_ENT_T_DVB_TSOUT) { if (!strncmp(entity->name, DVR_TSOUT, strlen(DVR_TSOUT))) { ret = media_create_pad_link(demux, @@ -639,7 +639,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap) } media_device_for_each_entity(entity, mdev) { - if (entity->type == MEDIA_ENT_T_DVB_TSOUT) { + if (entity->function == MEDIA_ENT_T_DVB_TSOUT) { if (!strcmp(entity->name, DVR_TSOUT)) { link = media_create_intf_link(entity, intf, diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c index 580859c89da1..664ec0dcd02a 100644 --- a/drivers/media/dvb-frontends/au8522_decoder.c +++ b/drivers/media/dvb-frontends/au8522_decoder.c @@ -766,7 +766,7 @@ static int au8522_probe(struct i2c_client *client, state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK; state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), state->pads); diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index 07e46b5b849c..9d99182cd165 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client, if (ret < 0) goto free_and_quit; - flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; return 0; diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c index b83c7fc988ae..f45108c84f4d 100644 --- a/drivers/media/i2c/as3645a.c +++ b/drivers/media/i2c/as3645a.c @@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client, if (ret < 0) goto done; - flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; mutex_init(&flash->power_lock); diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index 022ad5ae8869..73bd05ee2fee 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -5211,7 +5211,7 @@ static int cx25840_probe(struct i2c_client *client, state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK; state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), state->pads); diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index 91c1ed27a458..aa8b4832a1bc 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash, rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL); if (rval < 0) goto err_out; - flash->subdev_led[led_no].entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; return rval; diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c index a037616bbab0..a52cc3a6fb55 100644 --- a/drivers/media/i2c/lm3646.c +++ b/drivers/media/i2c/lm3646.c @@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash) rval = media_entity_init(&flash->subdev_led.entity, 0, NULL); if (rval < 0) goto err_out; - flash->subdev_led.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; return rval; err_out: diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index 0788c1908f9c..ae5645fe3a6e 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client, ret = media_entity_init(&sd->entity, 1, &info->pad); if (ret < 0) return ret; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; init_waitqueue_head(&info->irq_waitq); mutex_init(&info->lock); diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 2e614ad473f1..0226fc668529 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client, goto np_err; info->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, 1, &info->pad); if (ret < 0) goto np_err; diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c index ea95f854a519..8a2efe2a24c4 100644 --- a/drivers/media/i2c/ov2659.c +++ b/drivers/media/i2c/ov2659.c @@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client, #if defined(CONFIG_MEDIA_CONTROLLER) ov2659->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, 1, &ov2659->pad); if (ret < 0) { v4l2_ctrl_handler_free(&ov2659->ctrls); diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index b4c408f2a2b0..27c4def7e4fc 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c @@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client, return ret; ov965x->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, 1, &ov965x->pad); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index ee7404ee6659..dd48e35ede28 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE; state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS, state->sensor_pads); @@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK; state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK; state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE; - oif_sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; + oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS, state->oif_pads); diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c index 445a89e30949..026d08740537 100644 --- a/drivers/media/i2c/s5k4ecgx.c +++ b/drivers/media/i2c/s5k4ecgx.c @@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client, sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; priv->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, 1, &priv->pad); if (ret) return ret; diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 3e929858d5be..1d47b30953a4 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl) static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd) { - return sd->entity.type == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; } static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd) @@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; state->cis_pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad); if (ret < 0) goto err; @@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK; state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads); if (!ret) diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c index 31be29d25093..d7244234473e 100644 --- a/drivers/media/i2c/s5k6aa.c +++ b/drivers/media/i2c/s5k6aa.c @@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client, sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad); if (ret) return ret; diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index df4f8824c344..ef325b653697 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor) dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile); - sensor->pixel_array->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; /* final steps */ smiapp_read_frame_fmt(sensor); diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 30cef8740afa..4f8388423edc 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -108,7 +108,7 @@ static long media_device_enum_entities(struct media_device *mdev, u_ent.id = media_entity_id(ent); if (ent->name) strlcpy(u_ent.name, ent->name, sizeof(u_ent.name)); - u_ent.type = ent->type; + u_ent.type = ent->function; u_ent.revision = ent->revision; u_ent.flags = ent->flags; u_ent.group_id = ent->group_id; @@ -610,8 +610,8 @@ int __must_check media_device_register_entity(struct media_device *mdev, { int i; - if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN || - entity->type == MEDIA_ENT_T_UNKNOWN) + if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN || + entity->function == MEDIA_ENT_T_UNKNOWN) dev_warn(mdev->dev, "Entity type for entity %s was not initialized!\n", entity->name); diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index b3fb1570b189..1f0043f3ec4d 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe, while ((entity = media_entity_graph_walk_next(&graph))) { struct xvip_dma *dma; - if (entity->type != MEDIA_ENT_T_V4L2_VIDEO) + if (entity->function != MEDIA_ENT_T_V4L2_VIDEO) continue; dma = to_xvip_dma(media_entity_to_video_device(entity)); diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 27679e5cdca1..865d68dc4dc8 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -265,7 +265,7 @@ static int au0828_create_media_graph(struct au0828_dev *dev) return 0; media_device_for_each_entity(entity, mdev) { - switch (entity->type) { + switch (entity->function) { case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: tuner = entity; break; diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 75f2e02908f4..066ba4b7c746 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -1832,18 +1832,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev) switch (AUVI_INPUT(i).type) { case AU0828_VMUX_COMPOSITE: - ent->type = MEDIA_ENT_T_CONN_COMPOSITE; + ent->function = MEDIA_ENT_T_CONN_COMPOSITE; break; case AU0828_VMUX_SVIDEO: - ent->type = MEDIA_ENT_T_CONN_SVIDEO; + ent->function = MEDIA_ENT_T_CONN_SVIDEO; break; case AU0828_VMUX_CABLE: case AU0828_VMUX_TELEVISION: case AU0828_VMUX_DVB: - ent->type = MEDIA_ENT_T_CONN_RF; + ent->function = MEDIA_ENT_T_CONN_RF; break; default: /* AU0828_VMUX_DEBUG */ - ent->type = MEDIA_ENT_T_CONN_TEST; + ent->function = MEDIA_ENT_T_CONN_TEST; break; } diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index b842bfc799cc..5062c42a694c 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1249,7 +1249,7 @@ static int cx231xx_create_media_graph(struct cx231xx *dev) return 0; media_device_for_each_entity(entity, mdev) { - switch (entity->type) { + switch (entity->function) { case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: tuner = entity; break; diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index b5eb9f613872..110359deab37 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) * this should be enough for the actual needs. */ media_device_for_each_entity(entity, mdev) { - if (entity->type == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) { + if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) { decoder = entity; break; } diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index b90f2a52db96..e8fc5ec8fc35 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -698,7 +698,7 @@ register_client: #if defined(CONFIG_MEDIA_CONTROLLER) t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK; t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE; - t->sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_TUNER; + t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER; t->sd.entity.name = t->name; ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]); diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index d36436582de9..965449958e97 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd) if (v4l2_dev->mdev) { /* Remove interfaces and interface links */ media_devnode_remove(vdev->intf_devnode); - if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) + if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) media_device_unregister_entity(&vdev->entity); } #endif @@ -735,20 +735,20 @@ static int video_register_media_controller(struct video_device *vdev, int type) if (!vdev->v4l2_dev->mdev) return 0; - vdev->entity.type = MEDIA_ENT_T_UNKNOWN; + vdev->entity.function = MEDIA_ENT_T_UNKNOWN; switch (type) { case VFL_TYPE_GRABBER: intf_type = MEDIA_INTF_T_V4L_VIDEO; - vdev->entity.type = MEDIA_ENT_T_V4L2_VIDEO; + vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO; break; case VFL_TYPE_VBI: intf_type = MEDIA_INTF_T_V4L_VBI; - vdev->entity.type = MEDIA_ENT_T_V4L2_VBI; + vdev->entity.function = MEDIA_ENT_T_V4L2_VBI; break; case VFL_TYPE_SDR: intf_type = MEDIA_INTF_T_V4L_SWRADIO; - vdev->entity.type = MEDIA_ENT_T_V4L2_SWRADIO; + vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO; break; case VFL_TYPE_RADIO: intf_type = MEDIA_INTF_T_V4L_RADIO; @@ -766,7 +766,7 @@ static int video_register_media_controller(struct video_device *vdev, int type) return 0; } - if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) { + if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) { vdev->entity.name = vdev->name; /* Needed just for backward compatibility with legacy MC API */ @@ -793,7 +793,7 @@ static int video_register_media_controller(struct video_device *vdev, int type) return -ENOMEM; } - if (vdev->entity.type != MEDIA_ENT_T_UNKNOWN) { + if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) { struct media_link *link; link = media_create_intf_link(&vdev->entity, diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c index 34c489fed55e..cf7b3cb9a373 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init( if (ret < 0) return ERR_PTR(ret); - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; ret = v4l2_flash_init_controls(v4l2_flash, config); if (ret < 0) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index b3bcc8253182..b440cb66669c 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -535,9 +535,9 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad, return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt); } - WARN(pad->entity->type != MEDIA_ENT_T_V4L2_VIDEO, + WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO, "Driver bug! Wrong media entity type 0x%08x, entity %s\n", - pad->entity->type, pad->entity->name); + pad->entity->function, pad->entity->name); return -EINVAL; } @@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) sd->host_priv = NULL; #if defined(CONFIG_MEDIA_CONTROLLER) sd->entity.name = sd->name; - sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; + sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; #endif } EXPORT_SYMBOL(v4l2_subdev_init); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 0c7390d2edae..70ccd6cf14c1 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -152,7 +152,8 @@ struct media_entity_operations { * * @graph_obj: Embedded structure containing the media object common data. * @name: Entity name. - * @type: Entity type, as defined in uapi/media.h (MEDIA_ENT_T_*) + * @function: Entity main function, as defined in uapi/media.h + * (MEDIA_ENT_F_*) * @revision: Entity revision - OBSOLETE - should be removed soon. * @flags: Entity flags, as defined in uapi/media.h (MEDIA_ENT_FL_*) * @group_id: Entity group ID - OBSOLETE - should be removed soon. @@ -179,7 +180,7 @@ struct media_entity_operations { struct media_entity { struct media_gobj graph_obj; /* must be first field in struct */ const char *name; - u32 type; + u32 function; u32 revision; unsigned long flags; u32 group_id; @@ -272,7 +273,7 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity) if (!entity) return false; - switch (entity->type) { + switch (entity->function) { case MEDIA_ENT_T_V4L2_VIDEO: case MEDIA_ENT_T_V4L2_VBI: case MEDIA_ENT_T_V4L2_SWRADIO: @@ -287,7 +288,7 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity) if (!entity) return false; - switch (entity->type) { + switch (entity->function) { case MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN: case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR: case MEDIA_ENT_T_V4L2_SUBDEV_FLASH: -- cgit v1.2.3 From d87cdb884486bfa795be99c83a5b3ac4d428ca84 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 6 Sep 2015 10:59:08 -0300 Subject: [media] media-device: export the entity function via new ioctl Now that entities have a main function, expose it via MEDIA_IOC_G_TOPOLOGY ioctl. Please notice that some entities may have secundary functions. Such use case will be addressed later, when we add support for the Media Controller properties. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 1 + include/uapi/linux/media.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 4f8388423edc..83525ac29328 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -263,6 +263,7 @@ static long __media_device_get_topology(struct media_device *mdev, /* Copy fields to userspace struct if not error */ memset(&uentity, 0, sizeof(uentity)); uentity.id = entity->graph_obj.id; + uentity.function = entity->function; strncpy(uentity.name, entity->name, sizeof(uentity.name)); diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index f9520225a211..290dd5585dc8 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -276,7 +276,8 @@ struct media_links_enum { struct media_v2_entity { __u32 id; char name[64]; /* FIXME: move to a property? (RFC says so) */ - __u16 reserved[14]; + __u32 function; /* Main function of the entity */ + __u16 reserved[12]; }; /* Should match the specific fields at media_intf_devnode */ -- cgit v1.2.3 From 4ca72efaeffd0d244c44307abc9d4cb11f8ad475 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 10 Dec 2015 17:25:41 -0200 Subject: [media] uapi/media.h: Rename entities types to functions Rename the userspace types from MEDIA_ENT_T_ to MEDIA_ENT_F_ and add the backward compatibility bits. The changes at the .c files was generated by the following coccinelle script: @@ @@ -MEDIA_ENT_T_UNKNOWN +MEDIA_ENT_F_UNKNOWN @@ @@ -MEDIA_ENT_T_DVB_BASE +MEDIA_ENT_F_DVB_BASE @@ @@ -MEDIA_ENT_T_V4L2_BASE +MEDIA_ENT_F_V4L2_BASE @@ @@ -MEDIA_ENT_T_V4L2_SUBDEV_BASE +MEDIA_ENT_F_V4L2_SUBDEV_BASE @@ @@ -MEDIA_ENT_T_CONNECTOR_BASE +MEDIA_ENT_F_CONNECTOR_BASE @@ @@ -MEDIA_ENT_T_V4L2_VIDEO +MEDIA_ENT_F_IO_V4L @@ @@ -MEDIA_ENT_T_V4L2_VBI +MEDIA_ENT_F_IO_VBI @@ @@ -MEDIA_ENT_T_V4L2_SWRADIO +MEDIA_ENT_F_IO_SWRADIO @@ @@ -MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN +MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN @@ @@ -MEDIA_ENT_T_CONN_RF +MEDIA_ENT_F_CONN_RF @@ @@ -MEDIA_ENT_T_CONN_SVIDEO +MEDIA_ENT_F_CONN_SVIDEO @@ @@ -MEDIA_ENT_T_CONN_COMPOSITE +MEDIA_ENT_F_CONN_COMPOSITE @@ @@ -MEDIA_ENT_T_CONN_TEST +MEDIA_ENT_F_CONN_TEST @@ @@ -MEDIA_ENT_T_V4L2_SUBDEV_SENSOR +MEDIA_ENT_F_CAM_SENSOR @@ @@ -MEDIA_ENT_T_V4L2_SUBDEV_FLASH +MEDIA_ENT_F_FLASH @@ @@ -MEDIA_ENT_T_V4L2_SUBDEV_LENS +MEDIA_ENT_F_LENS @@ @@ -MEDIA_ENT_T_V4L2_SUBDEV_DECODER +MEDIA_ENT_F_ATV_DECODER @@ @@ -MEDIA_ENT_T_V4L2_SUBDEV_TUNER +MEDIA_ENT_F_TUNER @@ @@ -MEDIA_ENT_T_DVB_DEMOD +MEDIA_ENT_F_DTV_DEMOD @@ @@ -MEDIA_ENT_T_DVB_DEMUX +MEDIA_ENT_F_TS_DEMUX @@ @@ -MEDIA_ENT_T_DVB_TSOUT +MEDIA_ENT_F_IO_DTV @@ @@ -MEDIA_ENT_T_DVB_CA +MEDIA_ENT_F_DTV_CA @@ @@ -MEDIA_ENT_T_DVB_NET_DECAP +MEDIA_ENT_F_DTV_NET_DECAP Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 20 ++-- drivers/media/dvb-frontends/au8522_decoder.c | 2 +- drivers/media/i2c/adp1653.c | 2 +- drivers/media/i2c/adv7180.c | 2 +- drivers/media/i2c/as3645a.c | 2 +- drivers/media/i2c/cx25840/cx25840-core.c | 2 +- drivers/media/i2c/lm3560.c | 2 +- drivers/media/i2c/lm3646.c | 2 +- drivers/media/i2c/m5mols/m5mols_core.c | 2 +- drivers/media/i2c/noon010pc30.c | 2 +- drivers/media/i2c/ov2659.c | 2 +- drivers/media/i2c/ov9650.c | 2 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 +- drivers/media/i2c/s5k4ecgx.c | 2 +- drivers/media/i2c/s5k5baf.c | 6 +- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 2 +- drivers/media/i2c/tvp514x.c | 2 +- drivers/media/i2c/tvp7002.c | 2 +- drivers/media/media-device.c | 4 +- drivers/media/platform/xilinx/xilinx-dma.c | 2 +- drivers/media/usb/au0828/au0828-core.c | 4 +- drivers/media/usb/au0828/au0828-video.c | 8 +- drivers/media/usb/cx231xx/cx231xx-cards.c | 4 +- drivers/media/usb/cx231xx/cx231xx-video.c | 2 +- drivers/media/v4l2-core/tuner-core.c | 2 +- drivers/media/v4l2-core/v4l2-dev.c | 14 +-- drivers/media/v4l2-core/v4l2-flash-led-class.c | 2 +- drivers/media/v4l2-core/v4l2-subdev.c | 4 +- include/media/media-entity.h | 18 ++-- include/uapi/linux/media.h | 122 +++++++++++++------------ 31 files changed, 127 insertions(+), 121 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index f6fc95d1345b..f64e8b3fb687 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -242,7 +242,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev, if (!entity->name) return -ENOMEM; - entity->function = MEDIA_ENT_T_DVB_TSOUT; + entity->function = MEDIA_ENT_F_IO_DTV; pads->flags = MEDIA_PAD_FL_SINK; ret = media_entity_init(entity, 1, pads); @@ -315,18 +315,18 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev, switch (type) { case DVB_DEVICE_FRONTEND: - dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMOD; + dvbdev->entity->function = MEDIA_ENT_F_DTV_DEMOD; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; case DVB_DEVICE_DEMUX: - dvbdev->entity->function = MEDIA_ENT_T_DVB_DEMUX; + dvbdev->entity->function = MEDIA_ENT_F_TS_DEMUX; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; for (i = 1; i < npads; i++) dvbdev->pads[i].flags = MEDIA_PAD_FL_SOURCE; break; case DVB_DEVICE_CA: - dvbdev->entity->function = MEDIA_ENT_T_DVB_CA; + dvbdev->entity->function = MEDIA_ENT_F_DTV_CA; dvbdev->pads[0].flags = MEDIA_PAD_FL_SINK; dvbdev->pads[1].flags = MEDIA_PAD_FL_SOURCE; break; @@ -556,16 +556,16 @@ int dvb_create_media_graph(struct dvb_adapter *adap) media_device_for_each_entity(entity, mdev) { switch (entity->function) { - case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: + case MEDIA_ENT_F_TUNER: tuner = entity; break; - case MEDIA_ENT_T_DVB_DEMOD: + case MEDIA_ENT_F_DTV_DEMOD: demod = entity; break; - case MEDIA_ENT_T_DVB_DEMUX: + case MEDIA_ENT_F_TS_DEMUX: demux = entity; break; - case MEDIA_ENT_T_DVB_CA: + case MEDIA_ENT_F_DTV_CA: ca = entity; break; } @@ -594,7 +594,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap) /* Create demux links for each ringbuffer/pad */ if (demux) { media_device_for_each_entity(entity, mdev) { - if (entity->function == MEDIA_ENT_T_DVB_TSOUT) { + if (entity->function == MEDIA_ENT_F_IO_DTV) { if (!strncmp(entity->name, DVR_TSOUT, strlen(DVR_TSOUT))) { ret = media_create_pad_link(demux, @@ -639,7 +639,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap) } media_device_for_each_entity(entity, mdev) { - if (entity->function == MEDIA_ENT_T_DVB_TSOUT) { + if (entity->function == MEDIA_ENT_F_IO_DTV) { if (!strcmp(entity->name, DVR_TSOUT)) { link = media_create_intf_link(entity, intf, diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c index 664ec0dcd02a..464a2beca30d 100644 --- a/drivers/media/dvb-frontends/au8522_decoder.c +++ b/drivers/media/dvb-frontends/au8522_decoder.c @@ -766,7 +766,7 @@ static int au8522_probe(struct i2c_client *client, state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK; state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + sd->entity.function = MEDIA_ENT_F_ATV_DECODER; ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), state->pads); diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index 9d99182cd165..7150f35d5935 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -516,7 +516,7 @@ static int adp1653_probe(struct i2c_client *client, if (ret < 0) goto free_and_quit; - flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + flash->subdev.entity.function = MEDIA_ENT_F_FLASH; return 0; diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 0fca8677014c..2ebe9efdfc1b 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -1213,7 +1213,7 @@ static int adv7180_probe(struct i2c_client *client, goto err_unregister_vpp_client; state->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER; ret = media_entity_init(&sd->entity, 1, &state->pad); if (ret) goto err_free_ctrl; diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c index f45108c84f4d..b1bc4d0f76f2 100644 --- a/drivers/media/i2c/as3645a.c +++ b/drivers/media/i2c/as3645a.c @@ -831,7 +831,7 @@ static int as3645a_probe(struct i2c_client *client, if (ret < 0) goto done; - flash->subdev.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + flash->subdev.entity.function = MEDIA_ENT_F_FLASH; mutex_init(&flash->power_lock); diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index 73bd05ee2fee..4d975aa5be36 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -5211,7 +5211,7 @@ static int cx25840_probe(struct i2c_client *client, state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK; state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + sd->entity.function = MEDIA_ENT_F_ATV_DECODER; ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), state->pads); diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index aa8b4832a1bc..98266f707ea0 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -368,7 +368,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash, rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL); if (rval < 0) goto err_out; - flash->subdev_led[led_no].entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH; return rval; diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c index a52cc3a6fb55..ba5ee0d7a78e 100644 --- a/drivers/media/i2c/lm3646.c +++ b/drivers/media/i2c/lm3646.c @@ -285,7 +285,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash) rval = media_entity_init(&flash->subdev_led.entity, 0, NULL); if (rval < 0) goto err_out; - flash->subdev_led.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + flash->subdev_led.entity.function = MEDIA_ENT_F_FLASH; return rval; err_out: diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index ae5645fe3a6e..bec5cea23b65 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -978,7 +978,7 @@ static int m5mols_probe(struct i2c_client *client, ret = media_entity_init(&sd->entity, 1, &info->pad); if (ret < 0) return ret; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; init_waitqueue_head(&info->irq_waitq); mutex_init(&info->lock); diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 0226fc668529..47ea3f79eacc 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -779,7 +779,7 @@ static int noon010_probe(struct i2c_client *client, goto np_err; info->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_init(&sd->entity, 1, &info->pad); if (ret < 0) goto np_err; diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c index 8a2efe2a24c4..cf8e71610248 100644 --- a/drivers/media/i2c/ov2659.c +++ b/drivers/media/i2c/ov2659.c @@ -1445,7 +1445,7 @@ static int ov2659_probe(struct i2c_client *client, #if defined(CONFIG_MEDIA_CONTROLLER) ov2659->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_init(&sd->entity, 1, &ov2659->pad); if (ret < 0) { v4l2_ctrl_handler_free(&ov2659->ctrls); diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index 27c4def7e4fc..adb4aab45c10 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c @@ -1500,7 +1500,7 @@ static int ov965x_probe(struct i2c_client *client, return ret; ov965x->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_init(&sd->entity, 1, &ov965x->pad); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index dd48e35ede28..3d578f2ce7b2 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1688,7 +1688,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->sensor_pads[S5C73M3_JPEG_PAD].flags = MEDIA_PAD_FL_SOURCE; state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS, state->sensor_pads); @@ -1704,7 +1704,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->oif_pads[OIF_ISP_PAD].flags = MEDIA_PAD_FL_SINK; state->oif_pads[OIF_JPEG_PAD].flags = MEDIA_PAD_FL_SINK; state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE; - oif_sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; + oif_sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS, state->oif_pads); diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c index 026d08740537..bacec84e773f 100644 --- a/drivers/media/i2c/s5k4ecgx.c +++ b/drivers/media/i2c/s5k4ecgx.c @@ -961,7 +961,7 @@ static int s5k4ecgx_probe(struct i2c_client *client, sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; priv->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_init(&sd->entity, 1, &priv->pad); if (ret) return ret; diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 1d47b30953a4..564938ab2abd 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -408,7 +408,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl) static inline bool s5k5baf_is_cis_subdev(struct v4l2_subdev *sd) { - return sd->entity.function == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + return sd->entity.function == MEDIA_ENT_F_CAM_SENSOR; } static inline struct s5k5baf *to_s5k5baf(struct v4l2_subdev *sd) @@ -1904,7 +1904,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; state->cis_pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad); if (ret < 0) goto err; @@ -1919,7 +1919,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK; state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; + sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads); if (!ret) diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c index d7244234473e..d71d104441bd 100644 --- a/drivers/media/i2c/s5k6aa.c +++ b/drivers/media/i2c/s5k6aa.c @@ -1577,7 +1577,7 @@ static int s5k6aa_probe(struct i2c_client *client, sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad); if (ret) return ret; diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index ef325b653697..3eaa69ee341b 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2763,7 +2763,7 @@ static int smiapp_init(struct smiapp_sensor *sensor) dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile); - sensor->pixel_array->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR; + sensor->pixel_array->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; /* final steps */ smiapp_read_frame_fmt(sensor); diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index 11e426dbe891..455dd4e6a1da 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -1095,7 +1095,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) #if defined(CONFIG_MEDIA_CONTROLLER) decoder->pad.flags = MEDIA_PAD_FL_SOURCE; decoder->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - decoder->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER; ret = media_entity_init(&decoder->sd.entity, 1, &decoder->pad); if (ret < 0) { diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index a5ee2b8df429..216a07956fe9 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -1012,7 +1012,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) #if defined(CONFIG_MEDIA_CONTROLLER) device->pad.flags = MEDIA_PAD_FL_SOURCE; device->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - device->sd.entity.flags |= MEDIA_ENT_T_V4L2_SUBDEV_DECODER; + device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER; error = media_entity_init(&device->sd.entity, 1, &device->pad); if (error < 0) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 83525ac29328..f177d50c7a44 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -611,8 +611,8 @@ int __must_check media_device_register_entity(struct media_device *mdev, { int i; - if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN || - entity->function == MEDIA_ENT_T_UNKNOWN) + if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN || + entity->function == MEDIA_ENT_F_UNKNOWN) dev_warn(mdev->dev, "Entity type for entity %s was not initialized!\n", entity->name); diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 1f0043f3ec4d..b69c9630114d 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -191,7 +191,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe, while ((entity = media_entity_graph_walk_next(&graph))) { struct xvip_dma *dma; - if (entity->function != MEDIA_ENT_T_V4L2_VIDEO) + if (entity->function != MEDIA_ENT_F_IO_V4L) continue; dma = to_xvip_dma(media_entity_to_video_device(entity)); diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 865d68dc4dc8..1b207fa16a55 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -266,10 +266,10 @@ static int au0828_create_media_graph(struct au0828_dev *dev) media_device_for_each_entity(entity, mdev) { switch (entity->function) { - case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: + case MEDIA_ENT_F_TUNER: tuner = entity; break; - case MEDIA_ENT_T_V4L2_SUBDEV_DECODER: + case MEDIA_ENT_F_ATV_DECODER: decoder = entity; break; } diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 066ba4b7c746..839361c035ff 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -1832,18 +1832,18 @@ static void au0828_analog_create_entities(struct au0828_dev *dev) switch (AUVI_INPUT(i).type) { case AU0828_VMUX_COMPOSITE: - ent->function = MEDIA_ENT_T_CONN_COMPOSITE; + ent->function = MEDIA_ENT_F_CONN_COMPOSITE; break; case AU0828_VMUX_SVIDEO: - ent->function = MEDIA_ENT_T_CONN_SVIDEO; + ent->function = MEDIA_ENT_F_CONN_SVIDEO; break; case AU0828_VMUX_CABLE: case AU0828_VMUX_TELEVISION: case AU0828_VMUX_DVB: - ent->function = MEDIA_ENT_T_CONN_RF; + ent->function = MEDIA_ENT_F_CONN_RF; break; default: /* AU0828_VMUX_DEBUG */ - ent->function = MEDIA_ENT_T_CONN_TEST; + ent->function = MEDIA_ENT_F_CONN_TEST; break; } diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 5062c42a694c..0e1efc59ff58 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1250,10 +1250,10 @@ static int cx231xx_create_media_graph(struct cx231xx *dev) media_device_for_each_entity(entity, mdev) { switch (entity->function) { - case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: + case MEDIA_ENT_F_TUNER: tuner = entity; break; - case MEDIA_ENT_T_V4L2_SUBDEV_DECODER: + case MEDIA_ENT_F_ATV_DECODER: decoder = entity; break; } diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index 110359deab37..905ccd7cbc6d 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -119,7 +119,7 @@ static int cx231xx_enable_analog_tuner(struct cx231xx *dev) * this should be enough for the actual needs. */ media_device_for_each_entity(entity, mdev) { - if (entity->function == MEDIA_ENT_T_V4L2_SUBDEV_DECODER) { + if (entity->function == MEDIA_ENT_F_ATV_DECODER) { decoder = entity; break; } diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index e8fc5ec8fc35..05fc4df61b85 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -698,7 +698,7 @@ register_client: #if defined(CONFIG_MEDIA_CONTROLLER) t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK; t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE; - t->sd.entity.function = MEDIA_ENT_T_V4L2_SUBDEV_TUNER; + t->sd.entity.function = MEDIA_ENT_F_TUNER; t->sd.entity.name = t->name; ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]); diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 965449958e97..ed96642c27bf 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -197,7 +197,7 @@ static void v4l2_device_release(struct device *cd) if (v4l2_dev->mdev) { /* Remove interfaces and interface links */ media_devnode_remove(vdev->intf_devnode); - if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) + if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) media_device_unregister_entity(&vdev->entity); } #endif @@ -735,20 +735,20 @@ static int video_register_media_controller(struct video_device *vdev, int type) if (!vdev->v4l2_dev->mdev) return 0; - vdev->entity.function = MEDIA_ENT_T_UNKNOWN; + vdev->entity.function = MEDIA_ENT_F_UNKNOWN; switch (type) { case VFL_TYPE_GRABBER: intf_type = MEDIA_INTF_T_V4L_VIDEO; - vdev->entity.function = MEDIA_ENT_T_V4L2_VIDEO; + vdev->entity.function = MEDIA_ENT_F_IO_V4L; break; case VFL_TYPE_VBI: intf_type = MEDIA_INTF_T_V4L_VBI; - vdev->entity.function = MEDIA_ENT_T_V4L2_VBI; + vdev->entity.function = MEDIA_ENT_F_IO_VBI; break; case VFL_TYPE_SDR: intf_type = MEDIA_INTF_T_V4L_SWRADIO; - vdev->entity.function = MEDIA_ENT_T_V4L2_SWRADIO; + vdev->entity.function = MEDIA_ENT_F_IO_SWRADIO; break; case VFL_TYPE_RADIO: intf_type = MEDIA_INTF_T_V4L_RADIO; @@ -766,7 +766,7 @@ static int video_register_media_controller(struct video_device *vdev, int type) return 0; } - if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) { + if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { vdev->entity.name = vdev->name; /* Needed just for backward compatibility with legacy MC API */ @@ -793,7 +793,7 @@ static int video_register_media_controller(struct video_device *vdev, int type) return -ENOMEM; } - if (vdev->entity.function != MEDIA_ENT_T_UNKNOWN) { + if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { struct media_link *link; link = media_create_intf_link(&vdev->entity, diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c index cf7b3cb9a373..5c686a24712b 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -655,7 +655,7 @@ struct v4l2_flash *v4l2_flash_init( if (ret < 0) return ERR_PTR(ret); - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; + sd->entity.function = MEDIA_ENT_F_FLASH; ret = v4l2_flash_init_controls(v4l2_flash, config); if (ret < 0) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index b440cb66669c..d63083803144 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -535,7 +535,7 @@ v4l2_subdev_link_validate_get_format(struct media_pad *pad, return v4l2_subdev_call(sd, pad, get_fmt, NULL, fmt); } - WARN(pad->entity->function != MEDIA_ENT_T_V4L2_VIDEO, + WARN(pad->entity->function != MEDIA_ENT_F_IO_V4L, "Driver bug! Wrong media entity type 0x%08x, entity %s\n", pad->entity->function, pad->entity->name); @@ -584,7 +584,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) sd->host_priv = NULL; #if defined(CONFIG_MEDIA_CONTROLLER) sd->entity.name = sd->name; - sd->entity.function = MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN; + sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; #endif } EXPORT_SYMBOL(v4l2_subdev_init); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 70ccd6cf14c1..df84e8eeb24b 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -274,9 +274,9 @@ static inline bool is_media_entity_v4l2_io(struct media_entity *entity) return false; switch (entity->function) { - case MEDIA_ENT_T_V4L2_VIDEO: - case MEDIA_ENT_T_V4L2_VBI: - case MEDIA_ENT_T_V4L2_SWRADIO: + case MEDIA_ENT_F_IO_V4L: + case MEDIA_ENT_F_IO_VBI: + case MEDIA_ENT_F_IO_SWRADIO: return true; default: return false; @@ -289,12 +289,12 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity) return false; switch (entity->function) { - case MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN: - case MEDIA_ENT_T_V4L2_SUBDEV_SENSOR: - case MEDIA_ENT_T_V4L2_SUBDEV_FLASH: - case MEDIA_ENT_T_V4L2_SUBDEV_LENS: - case MEDIA_ENT_T_V4L2_SUBDEV_DECODER: - case MEDIA_ENT_T_V4L2_SUBDEV_TUNER: + case MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN: + case MEDIA_ENT_F_CAM_SENSOR: + case MEDIA_ENT_F_FLASH: + case MEDIA_ENT_F_LENS: + case MEDIA_ENT_F_ATV_DECODER: + case MEDIA_ENT_F_TUNER: return true; default: diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 290dd5585dc8..ff6a8010c520 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -46,87 +46,93 @@ struct media_device_info { * Initial value to be used when a new entity is created * Drivers should change it to something useful */ -#define MEDIA_ENT_T_UNKNOWN 0x00000000 +#define MEDIA_ENT_F_UNKNOWN 0x00000000 /* - * Base numbers for entity types + * Base number ranges for entity functions * - * Please notice that the huge gap of 16 bits for each base is overkill! - * 8 bits is more than enough to avoid starving entity types for each - * subsystem. - * - * However, It is kept this way just to avoid binary breakages with the - * namespace provided on legacy versions of this header. + * NOTE: those ranges and entity function number are phased just to + * make it easier to maintain this file. Userspace should not rely on + * the ranges to identify a group of function types, as newer + * functions can be added with any name within the full u32 range. */ -#define MEDIA_ENT_T_DVB_BASE 0x00000000 -#define MEDIA_ENT_T_V4L2_BASE 0x00010000 -#define MEDIA_ENT_T_V4L2_SUBDEV_BASE 0x00020000 -#define MEDIA_ENT_T_CONNECTOR_BASE 0x00030000 +#define MEDIA_ENT_F_BASE 0x00000000 +#define MEDIA_ENT_F_OLD_BASE 0x00010000 +#define MEDIA_ENT_F_OLD_SUBDEV_BASE 0x00020000 /* - * V4L2 entities - Those are used for DMA (mmap/DMABUF) and - * read()/write() data I/O associated with the V4L2 devnodes. + * DVB entities */ -#define MEDIA_ENT_T_V4L2_VIDEO (MEDIA_ENT_T_V4L2_BASE + 1) - /* - * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and - * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used - * to be declared for FB, ALSA and DVB entities. - * As those values were never actually used in practice, we're just - * adding them as backward compatibility macros and keeping the - * numberspace clean here. This way, we avoid breaking compilation, - * in the case of having some userspace application using the old - * symbols. - */ -#define MEDIA_ENT_T_V4L2_VBI (MEDIA_ENT_T_V4L2_BASE + 5) -#define MEDIA_ENT_T_V4L2_SWRADIO (MEDIA_ENT_T_V4L2_BASE + 6) - -/* V4L2 Sub-device entities */ +#define MEDIA_ENT_F_DTV_DEMOD (MEDIA_ENT_F_BASE + 1) +#define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 2) +#define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 3) +#define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 4) /* + * Connectors + */ +#define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 21) +#define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 22) +#define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 23) + /* For internal test signal generators and other debug connectors */ +#define MEDIA_ENT_F_CONN_TEST (MEDIA_ENT_F_BASE + 24) + +/* + * I/O entities + */ +#define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 31) +#define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 32) +#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 33) + +/* + * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and + * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility + * with the legacy v1 API.The number range is out of range by purpose: + * several previously reserved numbers got excluded from this range. + * * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN, * in order to preserve backward compatibility. * Drivers should change to the proper subdev type before * registering the entity. */ -#define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_T_V4L2_SUBDEV_BASE - -#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1) -#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2) -#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3) - /* A converter of analogue video to its digital representation. */ -#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4) - /* Tuner entity is actually both V4L2 and DVB subdev */ -#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5) - -/* DVB entities */ -#define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_DVB_BASE + 1) -#define MEDIA_ENT_T_DVB_DEMUX (MEDIA_ENT_T_DVB_BASE + 2) -#define MEDIA_ENT_T_DVB_TSOUT (MEDIA_ENT_T_DVB_BASE + 3) -#define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 4) -#define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 5) - -/* Connectors */ -#define MEDIA_ENT_T_CONN_RF (MEDIA_ENT_T_CONNECTOR_BASE + 1) -#define MEDIA_ENT_T_CONN_SVIDEO (MEDIA_ENT_T_CONNECTOR_BASE + 2) -#define MEDIA_ENT_T_CONN_COMPOSITE (MEDIA_ENT_T_CONNECTOR_BASE + 3) -/* For internal test signal generators and other debug connectors */ -#define MEDIA_ENT_T_CONN_TEST (MEDIA_ENT_T_CONNECTOR_BASE + 4) + +#define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1) + +#define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1) +#define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2) +#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3) +#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4) +#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5) + +#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE #ifndef __KERNEL__ -/* Legacy symbols used to avoid userspace compilation breakages */ + +/* + * Legacy symbols used to avoid userspace compilation breakages + * + * Those symbols map the entity function into types and should be + * used only on legacy programs for legacy hardware. Don't rely + * on those for MEDIA_IOC_G_TOPOLOGY. + */ #define MEDIA_ENT_TYPE_SHIFT 16 #define MEDIA_ENT_TYPE_MASK 0x00ff0000 #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff -#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_T_V4L2_BASE -#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_T_V4L2_SUBDEV_BASE - -#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_T_V4L2_VIDEO - +#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE +#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) + +#define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN +#define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L +#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN +#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR +#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH +#define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS +#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER +#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER #endif /* Entity flags */ -- cgit v1.2.3 From 17813e2aa2f745545643df24af8f308bc36a04b0 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 6 Sep 2015 13:28:48 -0300 Subject: [media] dvbdev: move indirect links on dvr/demux to a separate function Cleanup the code a little bit by moving the routine that creates links between DVR and demux to the I/O entitis into a separate function. While here, fix the code to use strncmp() instead of strcmp(). Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 50 +++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index f64e8b3fb687..d51a328bdcf9 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -540,6 +540,28 @@ EXPORT_SYMBOL(dvb_unregister_device); #ifdef CONFIG_MEDIA_CONTROLLER_DVB + +static int dvb_create_io_intf_links(struct dvb_adapter *adap, + struct media_interface *intf, + char *name) +{ + struct media_device *mdev = adap->mdev; + struct media_entity *entity; + struct media_link *link; + + media_device_for_each_entity(entity, mdev) { + if (entity->function == MEDIA_ENT_F_IO_DTV) { + if (strncmp(entity->name, name, strlen(name))) + continue; + link = media_create_intf_link(entity, intf, + MEDIA_LNK_FL_ENABLED); + if (!link) + return -ENOMEM; + } + } + return 0; +} + int dvb_create_media_graph(struct dvb_adapter *adap) { struct media_device *mdev = adap->mdev; @@ -637,25 +659,15 @@ int dvb_create_media_graph(struct dvb_adapter *adap) if (!link) return -ENOMEM; } - - media_device_for_each_entity(entity, mdev) { - if (entity->function == MEDIA_ENT_F_IO_DTV) { - if (!strcmp(entity->name, DVR_TSOUT)) { - link = media_create_intf_link(entity, - intf, - MEDIA_LNK_FL_ENABLED); - if (!link) - return -ENOMEM; - } - if (!strcmp(entity->name, DEMUX_TSOUT)) { - link = media_create_intf_link(entity, - intf, - MEDIA_LNK_FL_ENABLED); - if (!link) - return -ENOMEM; - } - break; - } + if (intf->type == MEDIA_INTF_T_DVB_DVR) { + ret = dvb_create_io_intf_links(adap, intf, DVR_TSOUT); + if (ret) + return ret; + } + if (intf->type == MEDIA_INTF_T_DVB_DEMUX) { + ret = dvb_create_io_intf_links(adap, intf, DEMUX_TSOUT); + if (ret) + return ret; } } return 0; -- cgit v1.2.3 From 8ed071426ee48879024c350ae92fc41062039b13 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 6 Sep 2015 13:38:23 -0300 Subject: [media] dvbdev: Don't create indirect links Indirect links are those whose interface indirectly controls other functions. There are two interfaces that have indirect controls at the DVB side: - the network interface, which also controls the demux; - the DVR interface which also controls the demux. One could argue that the frontend control to the tuner is indirect. Well, that's debatable. There's no way to create subdev interfaces for tuner and demod, as those devices are tightly coupled. So, it was decided that just one interface is the best to control both entities, and there's no plan (or easy way) to decouple both. So, the DVB frontend interface should link to both entities. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index d51a328bdcf9..cc52c24bff72 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -637,7 +637,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap) } } - /* Create indirect interface links for FE->tuner, DVR->demux and CA->ca */ + /* Create interface links for FE->tuner, DVR->demux and CA->ca */ media_device_for_each_intf(intf, mdev) { if (intf->type == MEDIA_INTF_T_DVB_CA && ca) { link = media_create_intf_link(ca, intf, @@ -652,13 +652,19 @@ int dvb_create_media_graph(struct dvb_adapter *adap) if (!link) return -ENOMEM; } - +#if 0 + /* + * Indirect link - let's not create yet, as we don't know how + * to handle indirect links, nor if this will + * actually be needed. + */ if (intf->type == MEDIA_INTF_T_DVB_DVR && demux) { link = media_create_intf_link(demux, intf, MEDIA_LNK_FL_ENABLED); if (!link) return -ENOMEM; } +#endif if (intf->type == MEDIA_INTF_T_DVB_DVR) { ret = dvb_create_io_intf_links(adap, intf, DVR_TSOUT); if (ret) -- cgit v1.2.3 From 0b3b72df9018c0386293c2f529b91ed17448288a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 9 Sep 2015 08:19:25 -0300 Subject: [media] media_entity: remove gfp_flags argument We should not be creating device nodes at IRQ contexts. So, the only flags we'll be using will be GFP_KERNEL. Let's remove the gfp_flags, in order to make the interface simpler. If we ever need it, it would be easy to revert those changes. While here, remove an extra blank line. Suggested-by: Sakari Ailus Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 3 +-- drivers/media/media-entity.c | 5 ++--- drivers/media/v4l2-core/v4l2-dev.c | 3 +-- include/media/media-entity.h | 4 +--- 4 files changed, 5 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index cc52c24bff72..1d4e35693d09 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -394,8 +394,7 @@ static int dvb_register_media_device(struct dvb_device *dvbdev, dvbdev->intf_devnode = media_devnode_create(dvbdev->adapter->mdev, intf_type, 0, - DVB_MAJOR, minor, - GFP_KERNEL); + DVB_MAJOR, minor); if (!dvbdev->intf_devnode) return -ENOMEM; diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 246d7e65aded..5f61642b2a97 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -866,12 +866,11 @@ static void media_interface_init(struct media_device *mdev, struct media_intf_devnode *media_devnode_create(struct media_device *mdev, u32 type, u32 flags, - u32 major, u32 minor, - gfp_t gfp_flags) + u32 major, u32 minor) { struct media_intf_devnode *devnode; - devnode = kzalloc(sizeof(*devnode), gfp_flags); + devnode = kzalloc(sizeof(*devnode), GFP_KERNEL); if (!devnode) return NULL; diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index ed96642c27bf..d8e5994cccf1 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -786,8 +786,7 @@ static int video_register_media_controller(struct video_device *vdev, int type) vdev->intf_devnode = media_devnode_create(vdev->v4l2_dev->mdev, intf_type, 0, VIDEO_MAJOR, - vdev->minor, - GFP_KERNEL); + vdev->minor); if (!vdev->intf_devnode) { media_device_unregister_entity(&vdev->entity); return -ENOMEM; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index df84e8eeb24b..cd3f3a77df2d 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -71,7 +71,6 @@ struct media_gobj { struct list_head list; }; - struct media_pipeline { }; @@ -378,8 +377,7 @@ void media_entity_pipeline_stop(struct media_entity *entity); struct media_intf_devnode * __must_check media_devnode_create(struct media_device *mdev, u32 type, u32 flags, - u32 major, u32 minor, - gfp_t gfp_flags); + u32 major, u32 minor); void media_devnode_remove(struct media_intf_devnode *devnode); struct media_link * __must_check media_create_intf_link(struct media_entity *entity, -- cgit v1.2.3 From 9033b1a47038fdba388fc13613de23508dccb075 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 9 Sep 2015 08:23:51 -0300 Subject: [media] media-device: use unsigned ints on some places The entity->num_pads are defined as u16. So, better to use an unsigned int, as this prevents additional warnings when W=2 (or W=1 on some architectures). The "i" counter at __media_device_get_topology() is also a monotonic counter that should never be below zero. So, make it unsigned too. Suggested-by: Sakari Ailus Acked-by: Hans Verkuil Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index f177d50c7a44..3d0a77c1c899 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -243,7 +243,8 @@ static long __media_device_get_topology(struct media_device *mdev, struct media_v2_interface uintf; struct media_v2_pad upad; struct media_v2_link ulink; - int ret = 0, i; + unsigned int i; + int ret = 0; topo->topology_version = mdev->topology_version; @@ -609,7 +610,7 @@ EXPORT_SYMBOL_GPL(media_device_unregister); int __must_check media_device_register_entity(struct media_device *mdev, struct media_entity *entity) { - int i; + unsigned int i; if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN || entity->function == MEDIA_ENT_F_UNKNOWN) @@ -646,10 +647,10 @@ EXPORT_SYMBOL_GPL(media_device_register_entity); */ void media_device_unregister_entity(struct media_entity *entity) { - int i; struct media_device *mdev = entity->graph_obj.mdev; struct media_link *link, *tmp; struct media_interface *intf; + unsigned int i; if (mdev == NULL) return; -- cgit v1.2.3 From db141a355d8914fe80c9e4a6c25c686f64d7e905 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 8 Sep 2015 14:10:56 -0300 Subject: [media] media-entity: init pads on entity init if was registered before If an entity is registered with a media device before is initialized with media_device_register_entity(), the number of pads won't be set so media_device_register_entity() won't create pad objects and add it to the media device pads list. Do this at entity initialization time if the entity was registered before so the graph is complete and correct regardless of the order in which the entities are initialized and registered. Suggested-by: Mauro Carvalho Chehab Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 5f61642b2a97..07f2dc6c2df6 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -222,6 +222,7 @@ int media_entity_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads) { + struct media_device *mdev = entity->graph_obj.mdev; unsigned int i; entity->group_id = 0; @@ -230,11 +231,20 @@ media_entity_init(struct media_entity *entity, u16 num_pads, entity->num_pads = num_pads; entity->pads = pads; + if (mdev) + spin_lock(&mdev->lock); + for (i = 0; i < num_pads; i++) { pads[i].entity = entity; pads[i].index = i; + if (mdev) + media_gobj_init(mdev, MEDIA_GRAPH_PAD, + &entity->pads[i].graph_obj); } + if (mdev) + spin_unlock(&mdev->lock); + return 0; } EXPORT_SYMBOL_GPL(media_entity_init); -- cgit v1.2.3 From 497e80cdf98ac72aaa1a4860b833920e1ba23aef Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 07:23:09 -0200 Subject: [media] media-device: put headers in alphabetic order It is better to keep the headers in alphabetic order. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 3d0a77c1c899..61883abaf095 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -24,8 +24,8 @@ #include #include #include -#include #include +#include #include #include -- cgit v1.2.3 From b83e250833e6c40a9e92935ea6fc125b64792357 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 07:25:01 -0200 Subject: [media] media-device: better name Kernelspace/Userspace links The __media_device_enum_links() copies links definitions from Kernelspace to userspace. It has to work with 3 structs that handle with links. Better name them to: link: Kernelspace internal link representation, of the type media_link; klink_desc: struct media_link_desc pointer to the kernel memory where the data will be filled; ulink_desc: struct media_link_desc pointer to the memory where the data will be copied to userspace. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 61883abaf095..14bd568e2f41 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -151,24 +151,25 @@ static long __media_device_enum_links(struct media_device *mdev, } if (links->links) { - struct media_link *ent_link; - struct media_link_desc __user *ulink = links->links; + struct media_link *link; + struct media_link_desc __user *ulink_desc = links->links; - list_for_each_entry(ent_link, &entity->links, list) { - struct media_link_desc link; + list_for_each_entry(link, &entity->links, list) { + struct media_link_desc klink_desc; /* Ignore backlinks. */ - if (ent_link->source->entity != entity) + if (link->source->entity != entity) continue; - memset(&link, 0, sizeof(link)); - media_device_kpad_to_upad(ent_link->source, - &link.source); - media_device_kpad_to_upad(ent_link->sink, - &link.sink); - link.flags = ent_link->flags; - if (copy_to_user(ulink, &link, sizeof(*ulink))) + memset(&klink_desc, 0, sizeof(klink_desc)); + media_device_kpad_to_upad(link->source, + &klink_desc.source); + media_device_kpad_to_upad(link->sink, + &klink_desc.sink); + klink_desc.flags = link->flags; + if (copy_to_user(ulink_desc, &klink_desc, + sizeof(*ulink_desc))) return -EFAULT; - ulink++; + ulink_desc++; } } -- cgit v1.2.3 From ab22e77cd3d3073c8cac51b59713ef635678dfbe Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 07:44:40 -0200 Subject: [media] media framework: rename pads init function to media_entity_pads_init() With the MC next gen rework, what's left for media_entity_init() is to just initialize the PADs. However, certain devices, like a FLASH led/light doesn't have any input or output PAD. So, there's no reason why calling media_entity_init() would be mandatory. Also, despite its name, what this function actually does is to initialize the PADs data. So, rename it to media_entity_pads_init() in order to reflect that. The media entity actual init happens during entity register, at media_device_register_entity(). We should move init of num_links and num_backlinks to it. Signed-off-by: Mauro Carvalho Chehab --- Documentation/media-framework.txt | 18 +++++++++++------- Documentation/video4linux/v4l2-framework.txt | 8 ++++---- Documentation/zh_CN/video4linux/v4l2-framework.txt | 8 ++++---- drivers/media/dvb-core/dvbdev.c | 4 ++-- drivers/media/dvb-frontends/au8522_decoder.c | 2 +- drivers/media/i2c/ad9389b.c | 2 +- drivers/media/i2c/adp1653.c | 2 +- drivers/media/i2c/adv7180.c | 2 +- drivers/media/i2c/adv7511.c | 2 +- drivers/media/i2c/adv7604.c | 2 +- drivers/media/i2c/adv7842.c | 2 +- drivers/media/i2c/as3645a.c | 2 +- drivers/media/i2c/cx25840/cx25840-core.c | 2 +- drivers/media/i2c/lm3560.c | 2 +- drivers/media/i2c/lm3646.c | 2 +- drivers/media/i2c/m5mols/m5mols_core.c | 2 +- drivers/media/i2c/mt9m032.c | 2 +- drivers/media/i2c/mt9p031.c | 2 +- drivers/media/i2c/mt9t001.c | 2 +- drivers/media/i2c/mt9v032.c | 2 +- drivers/media/i2c/noon010pc30.c | 2 +- drivers/media/i2c/ov2659.c | 2 +- drivers/media/i2c/ov9650.c | 2 +- drivers/media/i2c/s5c73m3/s5c73m3-core.c | 4 ++-- drivers/media/i2c/s5k4ecgx.c | 2 +- drivers/media/i2c/s5k5baf.c | 4 ++-- drivers/media/i2c/s5k6a3.c | 2 +- drivers/media/i2c/s5k6aa.c | 2 +- drivers/media/i2c/smiapp/smiapp-core.c | 6 +++--- drivers/media/i2c/tc358743.c | 2 +- drivers/media/i2c/tvp514x.c | 2 +- drivers/media/i2c/tvp7002.c | 2 +- drivers/media/media-device.c | 2 ++ drivers/media/media-entity.c | 11 ++++------- drivers/media/platform/exynos4-is/fimc-capture.c | 4 ++-- drivers/media/platform/exynos4-is/fimc-isp-video.c | 2 +- drivers/media/platform/exynos4-is/fimc-isp.c | 2 +- drivers/media/platform/exynos4-is/fimc-lite.c | 4 ++-- drivers/media/platform/exynos4-is/fimc-m2m.c | 2 +- drivers/media/platform/exynos4-is/mipi-csis.c | 2 +- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/isppreview.c | 2 +- drivers/media/platform/omap3isp/ispresizer.c | 2 +- drivers/media/platform/omap3isp/ispstat.c | 2 +- drivers/media/platform/omap3isp/ispvideo.c | 2 +- drivers/media/platform/s3c-camif/camif-capture.c | 4 ++-- drivers/media/platform/vsp1/vsp1_entity.c | 2 +- drivers/media/platform/vsp1/vsp1_video.c | 2 +- drivers/media/platform/xilinx/xilinx-dma.c | 2 +- drivers/media/platform/xilinx/xilinx-tpg.c | 2 +- drivers/media/usb/au0828/au0828-video.c | 6 +++--- drivers/media/usb/cx231xx/cx231xx-video.c | 4 ++-- drivers/media/usb/uvc/uvc_entity.c | 4 ++-- drivers/media/v4l2-core/tuner-core.c | 2 +- drivers/media/v4l2-core/v4l2-flash-led-class.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 6 +++--- drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 +- drivers/staging/media/omap4iss/iss_csi2.c | 2 +- drivers/staging/media/omap4iss/iss_ipipe.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 2 +- drivers/staging/media/omap4iss/iss_resizer.c | 2 +- drivers/staging/media/omap4iss/iss_video.c | 2 +- include/media/media-entity.h | 2 +- 68 files changed, 102 insertions(+), 99 deletions(-) (limited to 'drivers') diff --git a/Documentation/media-framework.txt b/Documentation/media-framework.txt index b424de6c3bb3..7fbfe4bd1f47 100644 --- a/Documentation/media-framework.txt +++ b/Documentation/media-framework.txt @@ -101,14 +101,18 @@ include/media/media-entity.h. The structure is usually embedded into a higher-level structure, such as a v4l2_subdev or video_device instance, although drivers can allocate entities directly. -Drivers initialize entities by calling +Drivers initialize entity pads by calling - media_entity_init(struct media_entity *entity, u16 num_pads, + media_entity_pads_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads); -The media_entity name, type, flags, revision and group_id fields can be -initialized before or after calling media_entity_init. Entities embedded in -higher-level standard structures can have some of those fields set by the +If no pads are needed, drivers could directly fill entity->num_pads +with 0 and entity->pads with NULL or to call the above function that +will do the same. + +The media_entity name, type, flags, revision and group_id fields should be +initialized before calling media_device_register_entity(). Entities embedded +in higher-level standard structures can have some of those fields set by the higher-level framework. As the number of pads is known in advance, the pads array is not allocated @@ -116,10 +120,10 @@ dynamically but is managed by the entity driver. Most drivers will embed the pads array in a driver-specific structure, avoiding dynamic allocation. Drivers must set the direction of every pad in the pads array before calling -media_entity_init. The function will initialize the other pads fields. +media_entity_pads_init. The function will initialize the other pads fields. Unlike the number of pads, the total number of links isn't always known in -advance by the entity driver. As an initial estimate, media_entity_init +advance by the entity driver. As an initial estimate, media_entity_pads_init pre-allocates a number of links equal to the number of pads. The links array will be reallocated if it grows beyond the initial estimate. diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 2e0fc28fa12f..fa41608ab2b4 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt @@ -295,12 +295,12 @@ module owner. This is done for you if you use the i2c helper functions. If integration with the media framework is needed, you must initialize the media_entity struct embedded in the v4l2_subdev struct (entity field) by -calling media_entity_init(): +calling media_entity_pads_init(), if the entity has pads: struct media_pad *pads = &my_sd->pads; int err; - err = media_entity_init(&sd->entity, npads, pads); + err = media_entity_pads_init(&sd->entity, npads, pads); The pads array must have been previously initialized. There is no need to manually set the struct media_entity function and name fields, but the @@ -695,12 +695,12 @@ difference is that the inode argument is omitted since it is never used. If integration with the media framework is needed, you must initialize the media_entity struct embedded in the video_device struct (entity field) by -calling media_entity_init(): +calling media_entity_pads_init(): struct media_pad *pad = &my_vdev->pad; int err; - err = media_entity_init(&vdev->entity, 1, pad); + err = media_entity_pads_init(&vdev->entity, 1, pad); The pads array must have been previously initialized. There is no need to manually set the struct media_entity type and name fields. diff --git a/Documentation/zh_CN/video4linux/v4l2-framework.txt b/Documentation/zh_CN/video4linux/v4l2-framework.txt index ff815cb92031..698660b7f21f 100644 --- a/Documentation/zh_CN/video4linux/v4l2-framework.txt +++ b/Documentation/zh_CN/video4linux/v4l2-framework.txt @@ -289,13 +289,13 @@ struct v4l2_subdev_ops { 然后,你必须用一个唯一的名字初始化 subdev->name,并初始化模块的 owner 域。若使用 i2c 辅助函数,这些都会帮你处理好。 -若需同媒体框架整合,你必须调用 media_entity_init() 初始化 v4l2_subdev +若需同媒体框架整合,你必须调用 media_entity_pads_init() 初始化 v4l2_subdev 结构体中的 media_entity 结构体(entity 域): struct media_pad *pads = &my_sd->pads; int err; - err = media_entity_init(&sd->entity, npads, pads); + err = media_entity_pads_init(&sd->entity, npads, pads); pads 数组必须预先初始化。无须手动设置 media_entity 的 type 和 name 域,但如有必要,revision 域必须初始化。 @@ -596,13 +596,13 @@ void v4l2_disable_ioctl(struct video_device *vdev, unsigned int cmd); v4l2_file_operations 结构体是 file_operations 的一个子集。其主要 区别在于:因 inode 参数从未被使用,它将被忽略。 -如果需要与媒体框架整合,你必须通过调用 media_entity_init() 初始化 +如果需要与媒体框架整合,你必须通过调用 media_entity_pads_init() 初始化 嵌入在 video_device 结构体中的 media_entity(entity 域)结构体: struct media_pad *pad = &my_vdev->pad; int err; - err = media_entity_init(&vdev->entity, 1, pad); + err = media_entity_pads_init(&vdev->entity, 1, pad); pads 数组必须预先初始化。没有必要手动设置 media_entity 的 type 和 name 域。 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 1d4e35693d09..b56e00817d3f 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -245,7 +245,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev, entity->function = MEDIA_ENT_F_IO_DTV; pads->flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(entity, 1, pads); + ret = media_entity_pads_init(entity, 1, pads); if (ret < 0) return ret; @@ -340,7 +340,7 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev, } if (npads) { - ret = media_entity_init(dvbdev->entity, npads, dvbdev->pads); + ret = media_entity_pads_init(dvbdev->entity, npads, dvbdev->pads); if (ret) return ret; } diff --git a/drivers/media/dvb-frontends/au8522_decoder.c b/drivers/media/dvb-frontends/au8522_decoder.c index 464a2beca30d..73612c5353d1 100644 --- a/drivers/media/dvb-frontends/au8522_decoder.c +++ b/drivers/media/dvb-frontends/au8522_decoder.c @@ -768,7 +768,7 @@ static int au8522_probe(struct i2c_client *client, state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_ATV_DECODER; - ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), + ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads), state->pads); if (ret < 0) { v4l_info(client, "failed to initialize media entity!\n"); diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index a02dc4925707..788967dadd29 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c @@ -1158,7 +1158,7 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id * state->rgb_quantization_range_ctrl->is_private = true; state->pad.flags = MEDIA_PAD_FL_SINK; - err = media_entity_init(&sd->entity, 1, &state->pad); + err = media_entity_pads_init(&sd->entity, 1, &state->pad); if (err) goto err_hdl; diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index 7150f35d5935..7e9cbf757e95 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -512,7 +512,7 @@ static int adp1653_probe(struct i2c_client *client, if (ret) goto free_and_quit; - ret = media_entity_init(&flash->subdev.entity, 0, NULL); + ret = media_entity_pads_init(&flash->subdev.entity, 0, NULL); if (ret < 0) goto free_and_quit; diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 2ebe9efdfc1b..ff57c1dcb8af 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -1214,7 +1214,7 @@ static int adv7180_probe(struct i2c_client *client, state->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER; - ret = media_entity_init(&sd->entity, 1, &state->pad); + ret = media_entity_pads_init(&sd->entity, 1, &state->pad); if (ret) goto err_free_ctrl; diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c index cbcf81b1d29e..471fd23b5c5c 100644 --- a/drivers/media/i2c/adv7511.c +++ b/drivers/media/i2c/adv7511.c @@ -1482,7 +1482,7 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id * state->rgb_quantization_range_ctrl->is_private = true; state->pad.flags = MEDIA_PAD_FL_SINK; - err = media_entity_init(&sd->entity, 1, &state->pad); + err = media_entity_pads_init(&sd->entity, 1, &state->pad); if (err) goto err_hdl; diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index c2df7e8053f3..f8dd7505b529 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -3208,7 +3208,7 @@ static int adv76xx_probe(struct i2c_client *client, state->pads[i].flags = MEDIA_PAD_FL_SINK; state->pads[state->source_pad].flags = MEDIA_PAD_FL_SOURCE; - err = media_entity_init(&sd->entity, state->source_pad + 1, + err = media_entity_pads_init(&sd->entity, state->source_pad + 1, state->pads); if (err) goto err_work_queues; diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index b5013a937254..5fbb788e7b59 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -3309,7 +3309,7 @@ static int adv7842_probe(struct i2c_client *client, adv7842_delayed_work_enable_hotplug); state->pad.flags = MEDIA_PAD_FL_SOURCE; - err = media_entity_init(&sd->entity, 1, &state->pad); + err = media_entity_pads_init(&sd->entity, 1, &state->pad); if (err) goto err_work_queues; diff --git a/drivers/media/i2c/as3645a.c b/drivers/media/i2c/as3645a.c index b1bc4d0f76f2..2e90e4094b79 100644 --- a/drivers/media/i2c/as3645a.c +++ b/drivers/media/i2c/as3645a.c @@ -827,7 +827,7 @@ static int as3645a_probe(struct i2c_client *client, if (ret < 0) goto done; - ret = media_entity_init(&flash->subdev.entity, 0, NULL); + ret = media_entity_pads_init(&flash->subdev.entity, 0, NULL); if (ret < 0) goto done; diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c index 4d975aa5be36..07a3e7173144 100644 --- a/drivers/media/i2c/cx25840/cx25840-core.c +++ b/drivers/media/i2c/cx25840/cx25840-core.c @@ -5213,7 +5213,7 @@ static int cx25840_probe(struct i2c_client *client, state->pads[CX25840_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_ATV_DECODER; - ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads), + ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads), state->pads); if (ret < 0) { v4l_info(client, "failed to initialize media entity!\n"); diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index 98266f707ea0..251a2aaf98c3 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -365,7 +365,7 @@ static int lm3560_subdev_init(struct lm3560_flash *flash, rval = lm3560_init_controls(flash, led_no); if (rval) goto err_out; - rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL); + rval = media_entity_pads_init(&flash->subdev_led[led_no].entity, 0, NULL); if (rval < 0) goto err_out; flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH; diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c index ba5ee0d7a78e..7e9967af36ec 100644 --- a/drivers/media/i2c/lm3646.c +++ b/drivers/media/i2c/lm3646.c @@ -282,7 +282,7 @@ static int lm3646_subdev_init(struct lm3646_flash *flash) rval = lm3646_init_controls(flash); if (rval) goto err_out; - rval = media_entity_init(&flash->subdev_led.entity, 0, NULL); + rval = media_entity_pads_init(&flash->subdev_led.entity, 0, NULL); if (rval < 0) goto err_out; flash->subdev_led.entity.function = MEDIA_ENT_F_FLASH; diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c index bec5cea23b65..acb804bceccb 100644 --- a/drivers/media/i2c/m5mols/m5mols_core.c +++ b/drivers/media/i2c/m5mols/m5mols_core.c @@ -975,7 +975,7 @@ static int m5mols_probe(struct i2c_client *client, sd->internal_ops = &m5mols_subdev_internal_ops; info->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sd->entity, 1, &info->pad); + ret = media_entity_pads_init(&sd->entity, 1, &info->pad); if (ret < 0) return ret; sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c index a2a450839ca1..da076796999e 100644 --- a/drivers/media/i2c/mt9m032.c +++ b/drivers/media/i2c/mt9m032.c @@ -799,7 +799,7 @@ static int mt9m032_probe(struct i2c_client *client, sensor->subdev.ctrl_handler = &sensor->ctrls; sensor->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sensor->subdev.entity, 1, &sensor->pad); + ret = media_entity_pads_init(&sensor->subdev.entity, 1, &sensor->pad); if (ret < 0) goto error_ctrl; diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index 165f29cddca6..237737fec09c 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -1112,7 +1112,7 @@ static int mt9p031_probe(struct i2c_client *client, mt9p031->subdev.internal_ops = &mt9p031_subdev_internal_ops; mt9p031->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&mt9p031->subdev.entity, 1, &mt9p031->pad); + ret = media_entity_pads_init(&mt9p031->subdev.entity, 1, &mt9p031->pad); if (ret < 0) goto done; diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c index 7d3df84651d8..702d562f8e39 100644 --- a/drivers/media/i2c/mt9t001.c +++ b/drivers/media/i2c/mt9t001.c @@ -933,7 +933,7 @@ static int mt9t001_probe(struct i2c_client *client, mt9t001->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; mt9t001->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&mt9t001->subdev.entity, 1, &mt9t001->pad); + ret = media_entity_pads_init(&mt9t001->subdev.entity, 1, &mt9t001->pad); done: if (ret < 0) { diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index b4f0f042c6c3..2e1d116a64e7 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c @@ -1046,7 +1046,7 @@ static int mt9v032_probe(struct i2c_client *client, mt9v032->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad); + ret = media_entity_pads_init(&mt9v032->subdev.entity, 1, &mt9v032->pad); if (ret < 0) goto err; diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index 47ea3f79eacc..30cb90b88d75 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -780,7 +780,7 @@ static int noon010_probe(struct i2c_client *client, info->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; - ret = media_entity_init(&sd->entity, 1, &info->pad); + ret = media_entity_pads_init(&sd->entity, 1, &info->pad); if (ret < 0) goto np_err; diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c index cf8e71610248..02b9a3440557 100644 --- a/drivers/media/i2c/ov2659.c +++ b/drivers/media/i2c/ov2659.c @@ -1446,7 +1446,7 @@ static int ov2659_probe(struct i2c_client *client, #if defined(CONFIG_MEDIA_CONTROLLER) ov2659->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; - ret = media_entity_init(&sd->entity, 1, &ov2659->pad); + ret = media_entity_pads_init(&sd->entity, 1, &ov2659->pad); if (ret < 0) { v4l2_ctrl_handler_free(&ov2659->ctrls); return ret; diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index adb4aab45c10..a0b3c9bde53d 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c @@ -1501,7 +1501,7 @@ static int ov965x_probe(struct i2c_client *client, ov965x->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; - ret = media_entity_init(&sd->entity, 1, &ov965x->pad); + ret = media_entity_pads_init(&sd->entity, 1, &ov965x->pad); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c index 3d578f2ce7b2..57b3d27993a4 100644 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c @@ -1690,7 +1690,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->sensor_pads[S5C73M3_ISP_PAD].flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; - ret = media_entity_init(&sd->entity, S5C73M3_NUM_PADS, + ret = media_entity_pads_init(&sd->entity, S5C73M3_NUM_PADS, state->sensor_pads); if (ret < 0) return ret; @@ -1706,7 +1706,7 @@ static int s5c73m3_probe(struct i2c_client *client, state->oif_pads[OIF_SOURCE_PAD].flags = MEDIA_PAD_FL_SOURCE; oif_sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; - ret = media_entity_init(&oif_sd->entity, OIF_NUM_PADS, + ret = media_entity_pads_init(&oif_sd->entity, OIF_NUM_PADS, state->oif_pads); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c index bacec84e773f..8a0f22da590f 100644 --- a/drivers/media/i2c/s5k4ecgx.c +++ b/drivers/media/i2c/s5k4ecgx.c @@ -962,7 +962,7 @@ static int s5k4ecgx_probe(struct i2c_client *client, priv->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; - ret = media_entity_init(&sd->entity, 1, &priv->pad); + ret = media_entity_pads_init(&sd->entity, 1, &priv->pad); if (ret) return ret; diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 564938ab2abd..fc3a5a8e6c9c 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -1905,7 +1905,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->cis_pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; - ret = media_entity_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad); + ret = media_entity_pads_init(&sd->entity, NUM_CIS_PADS, &state->cis_pad); if (ret < 0) goto err; @@ -1920,7 +1920,7 @@ static int s5k5baf_configure_subdevs(struct s5k5baf *state, state->pads[PAD_CIS].flags = MEDIA_PAD_FL_SINK; state->pads[PAD_OUT].flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN; - ret = media_entity_init(&sd->entity, NUM_ISP_PADS, state->pads); + ret = media_entity_pads_init(&sd->entity, NUM_ISP_PADS, state->pads); if (!ret) return 0; diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c index 2434a7944781..b9e43ffa5085 100644 --- a/drivers/media/i2c/s5k6a3.c +++ b/drivers/media/i2c/s5k6a3.c @@ -333,7 +333,7 @@ static int s5k6a3_probe(struct i2c_client *client, sensor->format.height = S5K6A3_DEFAULT_HEIGHT; sensor->pad.flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sd->entity, 1, &sensor->pad); + ret = media_entity_pads_init(&sd->entity, 1, &sensor->pad); if (ret < 0) return ret; diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c index d71d104441bd..faee11383cb7 100644 --- a/drivers/media/i2c/s5k6aa.c +++ b/drivers/media/i2c/s5k6aa.c @@ -1578,7 +1578,7 @@ static int s5k6aa_probe(struct i2c_client *client, s5k6aa->pad.flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; - ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad); + ret = media_entity_pads_init(&sd->entity, 1, &s5k6aa->pad); if (ret) return ret; diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 3eaa69ee341b..a215efe7a8ba 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2487,11 +2487,11 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) if (!last) continue; - rval = media_entity_init(&this->sd.entity, + rval = media_entity_pads_init(&this->sd.entity, this->npads, this->pads); if (rval) { dev_err(&client->dev, - "media_entity_init failed\n"); + "media_entity_pads_init failed\n"); return rval; } @@ -3077,7 +3077,7 @@ static int smiapp_probe(struct i2c_client *client, sensor->src->sensor = sensor; sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE; - rval = media_entity_init(&sensor->src->sd.entity, 2, + rval = media_entity_pads_init(&sensor->src->sd.entity, 2, sensor->src->pads); if (rval < 0) return rval; diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index 78e5b644d400..3397eb99c67b 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -1889,7 +1889,7 @@ static int tc358743_probe(struct i2c_client *client, } state->pad.flags = MEDIA_PAD_FL_SOURCE; - err = media_entity_init(&sd->entity, 1, &state->pad); + err = media_entity_pads_init(&sd->entity, 1, &state->pad); if (err < 0) goto err_hdl; diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c index 455dd4e6a1da..7fa5f1e4fe37 100644 --- a/drivers/media/i2c/tvp514x.c +++ b/drivers/media/i2c/tvp514x.c @@ -1097,7 +1097,7 @@ tvp514x_probe(struct i2c_client *client, const struct i2c_device_id *id) decoder->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; decoder->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER; - ret = media_entity_init(&decoder->sd.entity, 1, &decoder->pad); + ret = media_entity_pads_init(&decoder->sd.entity, 1, &decoder->pad); if (ret < 0) { v4l2_err(sd, "%s decoder driver failed to register !!\n", sd->name); diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index 216a07956fe9..83c79fa5f61d 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -1014,7 +1014,7 @@ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) device->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; device->sd.entity.flags |= MEDIA_ENT_F_ATV_DECODER; - error = media_entity_init(&device->sd.entity, 1, &device->pad); + error = media_entity_pads_init(&device->sd.entity, 1, &device->pad); if (error < 0) return error; #endif diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 14bd568e2f41..b8cd7733a31c 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -623,6 +623,8 @@ int __must_check media_device_register_entity(struct media_device *mdev, WARN_ON(entity->graph_obj.mdev != NULL); entity->graph_obj.mdev = mdev; INIT_LIST_HEAD(&entity->links); + entity->num_links = 0; + entity->num_backlinks = 0; spin_lock(&mdev->lock); /* Initialize media_gobj embedded at the entity */ diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 07f2dc6c2df6..ef2102ac0c66 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -197,7 +197,7 @@ void media_gobj_remove(struct media_gobj *gobj) } /** - * media_entity_init - Initialize a media entity + * media_entity_pads_init - Initialize a media entity * * @num_pads: Total number of sink and source pads. * @pads: Array of 'num_pads' pads. @@ -216,18 +216,15 @@ void media_gobj_remove(struct media_gobj *gobj) * number of allocated elements. * * The pads array is managed by the entity driver and passed to - * media_entity_init() where its pointer will be stored in the entity structure. + * media_entity_pads_init() where its pointer will be stored in the entity structure. */ int -media_entity_init(struct media_entity *entity, u16 num_pads, +media_entity_pads_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads) { struct media_device *mdev = entity->graph_obj.mdev; unsigned int i; - entity->group_id = 0; - entity->num_links = 0; - entity->num_backlinks = 0; entity->num_pads = num_pads; entity->pads = pads; @@ -247,7 +244,7 @@ media_entity_init(struct media_entity *entity, u16 num_pads, return 0; } -EXPORT_SYMBOL_GPL(media_entity_init); +EXPORT_SYMBOL_GPL(media_entity_pads_init); void media_entity_cleanup(struct media_entity *entity) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 48a826372d3d..bf47d3b9cbe7 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -1799,7 +1799,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc, vid_cap->wb_fmt.code = fmt->mbus_code; vid_cap->vd_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&vfd->entity, 1, &vid_cap->vd_pad); + ret = media_entity_pads_init(&vfd->entity, 1, &vid_cap->vd_pad); if (ret) goto err_free_ctx; @@ -1891,7 +1891,7 @@ int fimc_initialize_capture_subdev(struct fimc_dev *fimc) fimc->vid_cap.sd_pads[FIMC_SD_PAD_SINK_CAM].flags = MEDIA_PAD_FL_SINK; fimc->vid_cap.sd_pads[FIMC_SD_PAD_SINK_FIFO].flags = MEDIA_PAD_FL_SINK; fimc->vid_cap.sd_pads[FIMC_SD_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sd->entity, FIMC_SD_PADS_NUM, + ret = media_entity_pads_init(&sd->entity, FIMC_SD_PADS_NUM, fimc->vid_cap.sd_pads); if (ret) return ret; diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c index 9c7794bcf0c3..bf9261eb57a1 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c @@ -616,7 +616,7 @@ int fimc_isp_video_device_register(struct fimc_isp *isp, vdev->lock = &isp->video_lock; iv->pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&vdev->entity, 1, &iv->pad); + ret = media_entity_pads_init(&vdev->entity, 1, &iv->pad); if (ret < 0) return ret; diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index f52eebf765c1..293b807020c4 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c @@ -708,7 +708,7 @@ int fimc_isp_subdev_create(struct fimc_isp *isp) isp->subdev_pads[FIMC_ISP_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK; isp->subdev_pads[FIMC_ISP_SD_PAD_SRC_FIFO].flags = MEDIA_PAD_FL_SOURCE; isp->subdev_pads[FIMC_ISP_SD_PAD_SRC_DMA].flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sd->entity, FIMC_ISP_SD_PADS_NUM, + ret = media_entity_pads_init(&sd->entity, FIMC_ISP_SD_PADS_NUM, isp->subdev_pads); if (ret) return ret; diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 957cf144a675..e85649147dc8 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1314,7 +1314,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd) return ret; fimc->vd_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad); + ret = media_entity_pads_init(&vfd->entity, 1, &fimc->vd_pad); if (ret < 0) return ret; @@ -1428,7 +1428,7 @@ static int fimc_lite_create_capture_subdev(struct fimc_lite *fimc) fimc->subdev_pads[FLITE_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK; fimc->subdev_pads[FLITE_SD_PAD_SOURCE_DMA].flags = MEDIA_PAD_FL_SOURCE; fimc->subdev_pads[FLITE_SD_PAD_SOURCE_ISP].flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sd->entity, FLITE_SD_PADS_NUM, + ret = media_entity_pads_init(&sd->entity, FLITE_SD_PADS_NUM, fimc->subdev_pads); if (ret) return ret; diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c index 8ff4e6f76b84..55ec4c99d484 100644 --- a/drivers/media/platform/exynos4-is/fimc-m2m.c +++ b/drivers/media/platform/exynos4-is/fimc-m2m.c @@ -739,7 +739,7 @@ int fimc_register_m2m_device(struct fimc_dev *fimc, return PTR_ERR(fimc->m2m.m2m_dev); } - ret = media_entity_init(&vfd->entity, 0, NULL); + ret = media_entity_pads_init(&vfd->entity, 0, NULL); if (ret) goto err_me; diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c index 8847797b0d0b..ac5e50e595be 100644 --- a/drivers/media/platform/exynos4-is/mipi-csis.c +++ b/drivers/media/platform/exynos4-is/mipi-csis.c @@ -866,7 +866,7 @@ static int s5pcsis_probe(struct platform_device *pdev) state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK; state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&state->sd.entity, + ret = media_entity_pads_init(&state->sd.entity, CSIS_PADS_NUM, state->pads); if (ret < 0) goto e_clkdis; diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index f0e530c98188..dae674cd3f74 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -2655,7 +2655,7 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) pads[CCDC_PAD_SOURCE_OF].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ccdc_media_ops; - ret = media_entity_init(me, CCDC_PADS_NUM, pads); + ret = media_entity_pads_init(me, CCDC_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index ae3038e643cc..0c790b25f6f9 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -1076,7 +1076,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) pads[CCP2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ccp2_media_ops; - ret = media_entity_init(me, CCP2_PADS_NUM, pads); + ret = media_entity_pads_init(me, CCP2_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index b1617f7efdee..f50f6b305204 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c @@ -1250,7 +1250,7 @@ static int csi2_init_entities(struct isp_csi2_device *csi2) | MEDIA_PAD_FL_MUST_CONNECT; me->ops = &csi2_media_ops; - ret = media_entity_init(me, CSI2_PADS_NUM, pads); + ret = media_entity_pads_init(me, CSI2_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c index cfb2debb02bf..c300cb7219e9 100644 --- a/drivers/media/platform/omap3isp/isppreview.c +++ b/drivers/media/platform/omap3isp/isppreview.c @@ -2287,7 +2287,7 @@ static int preview_init_entities(struct isp_prev_device *prev) pads[PREV_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; me->ops = &preview_media_ops; - ret = media_entity_init(me, PREV_PADS_NUM, pads); + ret = media_entity_pads_init(me, PREV_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c index e3ecf1787fc4..cd0a9f6e1fed 100644 --- a/drivers/media/platform/omap3isp/ispresizer.c +++ b/drivers/media/platform/omap3isp/ispresizer.c @@ -1733,7 +1733,7 @@ static int resizer_init_entities(struct isp_res_device *res) pads[RESZ_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESZ_PADS_NUM, pads); + ret = media_entity_pads_init(me, RESZ_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c index f7a5eee9f11d..1b9217d3b1b6 100644 --- a/drivers/media/platform/omap3isp/ispstat.c +++ b/drivers/media/platform/omap3isp/ispstat.c @@ -1028,7 +1028,7 @@ static int isp_stat_init_entities(struct ispstat *stat, const char *name, stat->pad.flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; me->ops = NULL; - return media_entity_init(me, 1, &stat->pad); + return media_entity_pads_init(me, 1, &stat->pad); } int omap3isp_stat_init(struct ispstat *stat, const char *name, diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index 768efd775abc..1240b06202f0 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -1368,7 +1368,7 @@ int omap3isp_video_init(struct isp_video *video, const char *name) if (IS_ERR(video->alloc_ctx)) return PTR_ERR(video->alloc_ctx); - ret = media_entity_init(&video->video.entity, 1, &video->pad); + ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); if (ret < 0) { vb2_dma_contig_cleanup_ctx(video->alloc_ctx); return ret; diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c index 05bfa9d08b19..bd060ef5d1e1 100644 --- a/drivers/media/platform/s3c-camif/camif-capture.c +++ b/drivers/media/platform/s3c-camif/camif-capture.c @@ -1144,7 +1144,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx) goto err_vd_rel; vp->pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&vfd->entity, 1, &vp->pad); + ret = media_entity_pads_init(&vfd->entity, 1, &vp->pad); if (ret) goto err_vd_rel; @@ -1559,7 +1559,7 @@ int s3c_camif_create_subdev(struct camif_dev *camif) camif->pads[CAMIF_SD_PAD_SOURCE_C].flags = MEDIA_PAD_FL_SOURCE; camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&sd->entity, CAMIF_SD_PADS_NUM, + ret = media_entity_pads_init(&sd->entity, CAMIF_SD_PADS_NUM, camif->pads); if (ret) return ret; diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c index 619942ff2058..d7308530952f 100644 --- a/drivers/media/platform/vsp1/vsp1_entity.c +++ b/drivers/media/platform/vsp1/vsp1_entity.c @@ -219,7 +219,7 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, entity->pads[num_pads - 1].flags = MEDIA_PAD_FL_SOURCE; /* Initialize the media entity. */ - return media_entity_init(&entity->subdev.entity, num_pads, + return media_entity_pads_init(&entity->subdev.entity, num_pads, entity->pads); } diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index 024d10de3740..e3304303dce3 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -1192,7 +1192,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf) video->pipe.state = VSP1_PIPELINE_STOPPED; /* Initialize the media entity... */ - ret = media_entity_init(&video->video.entity, 1, &video->pad); + ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); if (ret < 0) return ret; diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index b69c9630114d..0181ff402a5a 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -675,7 +675,7 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma, dma->pad.flags = type == V4L2_BUF_TYPE_VIDEO_CAPTURE ? MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; - ret = media_entity_init(&dma->video.entity, 1, &dma->pad); + ret = media_entity_pads_init(&dma->video.entity, 1, &dma->pad); if (ret < 0) goto error; diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c b/drivers/media/platform/xilinx/xilinx-tpg.c index c09ca513a9dc..2ec1f6c4b274 100644 --- a/drivers/media/platform/xilinx/xilinx-tpg.c +++ b/drivers/media/platform/xilinx/xilinx-tpg.c @@ -838,7 +838,7 @@ static int xtpg_probe(struct platform_device *pdev) subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; subdev->entity.ops = &xtpg_media_ops; - ret = media_entity_init(&subdev->entity, xtpg->npads, xtpg->pads); + ret = media_entity_pads_init(&subdev->entity, xtpg->npads, xtpg->pads); if (ret < 0) goto error; diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 839361c035ff..8c54fd21022e 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -1810,12 +1810,12 @@ static void au0828_analog_create_entities(struct au0828_dev *dev) /* Initialize Video and VBI pads */ dev->video_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad); + ret = media_entity_pads_init(&dev->vdev.entity, 1, &dev->video_pad); if (ret < 0) pr_err("failed to initialize video media entity!\n"); dev->vbi_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); + ret = media_entity_pads_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); if (ret < 0) pr_err("failed to initialize vbi media entity!\n"); @@ -1847,7 +1847,7 @@ static void au0828_analog_create_entities(struct au0828_dev *dev) break; } - ret = media_entity_init(ent, 1, &dev->input_pad[i]); + ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]); if (ret < 0) pr_err("failed to initialize input pad[%d]!\n", i); diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c index 905ccd7cbc6d..9b88cd8127ac 100644 --- a/drivers/media/usb/cx231xx/cx231xx-video.c +++ b/drivers/media/usb/cx231xx/cx231xx-video.c @@ -2175,7 +2175,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) cx231xx_vdev_init(dev, &dev->vdev, &cx231xx_video_template, "video"); #if defined(CONFIG_MEDIA_CONTROLLER) dev->video_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vdev.entity, 1, &dev->video_pad); + ret = media_entity_pads_init(&dev->vdev.entity, 1, &dev->video_pad); if (ret < 0) dev_err(dev->dev, "failed to initialize video media entity!\n"); #endif @@ -2202,7 +2202,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev) #if defined(CONFIG_MEDIA_CONTROLLER) dev->vbi_pad.flags = MEDIA_PAD_FL_SINK; - ret = media_entity_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); + ret = media_entity_pads_init(&dev->vbi_dev.entity, 1, &dev->vbi_pad); if (ret < 0) dev_err(dev->dev, "failed to initialize vbi media entity!\n"); #endif diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 7f82b65b238e..38e893a1408b 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -94,10 +94,10 @@ static int uvc_mc_init_entity(struct uvc_entity *entity) strlcpy(entity->subdev.name, entity->name, sizeof(entity->subdev.name)); - ret = media_entity_init(&entity->subdev.entity, + ret = media_entity_pads_init(&entity->subdev.entity, entity->num_pads, entity->pads); } else if (entity->vdev != NULL) { - ret = media_entity_init(&entity->vdev->entity, + ret = media_entity_pads_init(&entity->vdev->entity, entity->num_pads, entity->pads); if (entity->flags & UVC_ENTITY_FLAG_DEFAULT) entity->vdev->entity.flags |= MEDIA_ENT_FL_DEFAULT; diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index 05fc4df61b85..76496fd282aa 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -701,7 +701,7 @@ register_client: t->sd.entity.function = MEDIA_ENT_F_TUNER; t->sd.entity.name = t->name; - ret = media_entity_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]); + ret = media_entity_pads_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]); if (ret < 0) { tuner_err("failed to initialize media entity!\n"); kfree(t); diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c index 5c686a24712b..13d5a36bc5d8 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -651,7 +651,7 @@ struct v4l2_flash *v4l2_flash_init( sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; strlcpy(sd->name, config->dev_name, sizeof(sd->name)); - ret = media_entity_init(&sd->entity, 0, NULL); + ret = media_entity_pads_init(&sd->entity, 0, NULL); if (ret < 0) return ERR_PTR(ret); diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 77837afab0ce..ac78ed2f8bcc 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1843,7 +1843,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev) v4l2_ctrl_handler_setup(&ipipe->ctrls); sd->ctrl_handler = &ipipe->ctrls; - return media_entity_init(me, IPIPE_PADS_NUM, pads); + return media_entity_pads_init(me, IPIPE_PADS_NUM, pads); } /* diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index b66584ecb693..a54c60fce3d5 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -1031,7 +1031,7 @@ int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif, ipipeif->output = IPIPEIF_OUTPUT_NONE; me->ops = &ipipeif_media_ops; - ret = media_entity_init(me, IPIPEIF_NUM_PADS, pads); + ret = media_entity_pads_init(me, IPIPEIF_NUM_PADS, pads); if (ret) goto fail; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index 8ca0c1297ec8..b35667afb73f 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -2057,7 +2057,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev) isif->input = ISIF_INPUT_NONE; isif->output = ISIF_OUTPUT_NONE; me->ops = &isif_media_ops; - status = media_entity_init(me, ISIF_PADS_NUM, pads); + status = media_entity_pads_init(me, ISIF_PADS_NUM, pads); if (status) goto isif_fail; isif->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index ba887efd226a..669ae3f9791f 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1915,7 +1915,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->crop_resizer.output2 = RESIZER_CROP_OUTPUT_NONE; vpfe_rsz->crop_resizer.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_CROP_PADS_NUM, pads); + ret = media_entity_pads_init(me, RESIZER_CROP_PADS_NUM, pads); if (ret) return ret; @@ -1937,7 +1937,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->resizer_a.output = RESIZER_OUTPUT_NONE; vpfe_rsz->resizer_a.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads); + ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads); if (ret) return ret; @@ -1959,7 +1959,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->resizer_b.output = RESIZER_OUTPUT_NONE; vpfe_rsz->resizer_b.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads); + ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads); if (ret) return ret; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index a5e30413fc47..285dc1a69b2c 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -1599,7 +1599,7 @@ int vpfe_video_init(struct vpfe_video_device *video, const char *name) spin_lock_init(&video->irqlock); spin_lock_init(&video->dma_queue_lock); mutex_init(&video->lock); - ret = media_entity_init(&video->video_dev.entity, + ret = media_entity_pads_init(&video->video_dev.entity, 1, &video->pad); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index 2b9a36cd8fa8..226366a03661 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -1276,7 +1276,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK; me->ops = &csi2_media_ops; - ret = media_entity_init(me, CSI2_PADS_NUM, pads); + ret = media_entity_pads_init(me, CSI2_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c index dd9d7d54e6f8..d38782e8e84c 100644 --- a/drivers/staging/media/omap4iss/iss_ipipe.c +++ b/drivers/staging/media/omap4iss/iss_ipipe.c @@ -516,7 +516,7 @@ static int ipipe_init_entities(struct iss_ipipe_device *ipipe) pads[IPIPE_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ipipe_media_ops; - ret = media_entity_init(me, IPIPE_PADS_NUM, pads); + ret = media_entity_pads_init(me, IPIPE_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index 8cbb9840a989..c2b5638a0898 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -748,7 +748,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) pads[IPIPEIF_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ipipeif_media_ops; - ret = media_entity_init(me, IPIPEIF_PADS_NUM, pads); + ret = media_entity_pads_init(me, IPIPEIF_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index a3925ecd0ed7..fea13ab4041f 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -790,7 +790,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer) pads[RESIZER_PAD_SOURCE_MEM].flags = MEDIA_PAD_FL_SOURCE; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads); + ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index 60b7a58e6122..8c6af412bc16 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -1101,7 +1101,7 @@ int omap4iss_video_init(struct iss_video *video, const char *name) return -EINVAL; } - ret = media_entity_init(&video->video.entity, 1, &video->pad); + ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); if (ret < 0) return ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index cd3f3a77df2d..32fef503d950 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -347,7 +347,7 @@ void media_gobj_init(struct media_device *mdev, struct media_gobj *gobj); void media_gobj_remove(struct media_gobj *gobj); -int media_entity_init(struct media_entity *entity, u16 num_pads, +int media_entity_pads_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads); void media_entity_cleanup(struct media_entity *entity); -- cgit v1.2.3 From 8ed8c88c460fa6ce71deb9847f78a5bff4dfcb0e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 08:02:19 -0200 Subject: [media] media-entity.h: get rid of revision and group_id fields Both revision and group_id fields were never used and were always initialized to zero. Remove them. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml | 13 ++----------- Documentation/media-framework.txt | 12 +++++------- drivers/media/media-device.c | 4 ++-- include/media/media-entity.h | 4 ---- 4 files changed, 9 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml index 27f8817e7abe..9f7614a01234 100644 --- a/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml +++ b/Documentation/DocBook/media/v4l/media-ioc-enum-entities.xml @@ -59,15 +59,6 @@ Entity IDs can be non-contiguous. Applications must not try to enumerate entities by calling MEDIA_IOC_ENUM_ENTITIES with increasing id's until they get an error. - Two or more entities that share a common non-zero - group_id value are considered as logically - grouped. Groups are used to report - - ALSA, VBI and video nodes that carry the same media - stream - lens and flash controllers associated with a sensor - - struct <structname>media_entity_desc</structname> @@ -106,7 +97,7 @@ revision - Entity revision in a driver/hardware specific format. + Entity revision. Always zero (obsolete) __u32 @@ -120,7 +111,7 @@ group_id - Entity group ID + Entity group ID. Always zero (obsolete) __u16 diff --git a/Documentation/media-framework.txt b/Documentation/media-framework.txt index 7fbfe4bd1f47..ef3663af1db3 100644 --- a/Documentation/media-framework.txt +++ b/Documentation/media-framework.txt @@ -110,10 +110,10 @@ If no pads are needed, drivers could directly fill entity->num_pads with 0 and entity->pads with NULL or to call the above function that will do the same. -The media_entity name, type, flags, revision and group_id fields should be -initialized before calling media_device_register_entity(). Entities embedded -in higher-level standard structures can have some of those fields set by the -higher-level framework. +The media_entity name, type and flags fields should be initialized before +calling media_device_register_entity(). Entities embedded in higher-level +standard structures can have some of those fields set by the higher-level +framework. As the number of pads is known in advance, the pads array is not allocated dynamically but is managed by the entity driver. Most drivers will embed the @@ -164,9 +164,7 @@ Entities have flags that describe the entity capabilities and state. Logical entity groups can be defined by setting the group ID of all member entities to the same non-zero value. An entity group serves no purpose in the -kernel, but is reported to userspace during entities enumeration. The group_id -field belongs to the media device driver and must not by touched by entity -drivers. +kernel, but is reported to userspace during entities enumeration. Media device drivers should define groups if several entities are logically bound together. Example usages include reporting diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index b8cd7733a31c..537160bb461e 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -109,9 +109,9 @@ static long media_device_enum_entities(struct media_device *mdev, if (ent->name) strlcpy(u_ent.name, ent->name, sizeof(u_ent.name)); u_ent.type = ent->function; - u_ent.revision = ent->revision; + u_ent.revision = 0; /* Unused */ u_ent.flags = ent->flags; - u_ent.group_id = ent->group_id; + u_ent.group_id = 0; /* Unused */ u_ent.pads = ent->num_pads; u_ent.links = ent->num_links - ent->num_backlinks; memcpy(&u_ent.raw, &ent->info, sizeof(ent->info)); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 32fef503d950..031536723d8c 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -153,9 +153,7 @@ struct media_entity_operations { * @name: Entity name. * @function: Entity main function, as defined in uapi/media.h * (MEDIA_ENT_F_*) - * @revision: Entity revision - OBSOLETE - should be removed soon. * @flags: Entity flags, as defined in uapi/media.h (MEDIA_ENT_FL_*) - * @group_id: Entity group ID - OBSOLETE - should be removed soon. * @num_pads: Number of sink and source pads. * @num_links: Total number of links, forward and back, enabled and disabled. * @num_backlinks: Number of backlinks @@ -180,9 +178,7 @@ struct media_entity { struct media_gobj graph_obj; /* must be first field in struct */ const char *name; u32 function; - u32 revision; unsigned long flags; - u32 group_id; u16 num_pads; u16 num_links; -- cgit v1.2.3 From f1fd3289e8c2b99cdf5c1c4426a7d28a809159c2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 09:13:23 -0200 Subject: [media] media-entity.h: convert media_entity_cleanup to inline This function was used in the past to free the links that were allocated by the media controller core. However, this is not needed anymore. We should likely get rid of the funcion on some function, but, for now, let's just convert into an inlined function and let the compiler to get rid of it. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 6 ------ include/media/media-entity.h | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index ef2102ac0c66..849db4f6f1f3 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -246,12 +246,6 @@ media_entity_pads_init(struct media_entity *entity, u16 num_pads, } EXPORT_SYMBOL_GPL(media_entity_pads_init); -void -media_entity_cleanup(struct media_entity *entity) -{ -} -EXPORT_SYMBOL_GPL(media_entity_cleanup); - /* ----------------------------------------------------------------------------- * Graph traversal */ diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 031536723d8c..e9bc5857899c 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -345,7 +345,8 @@ void media_gobj_remove(struct media_gobj *gobj); int media_entity_pads_init(struct media_entity *entity, u16 num_pads, struct media_pad *pads); -void media_entity_cleanup(struct media_entity *entity); + +static inline void media_entity_cleanup(struct media_entity *entity) {}; __must_check int media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, -- cgit v1.2.3 From 97d0a70ae5e2391f213966a69c3b6f96f2c9f25b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 11:12:57 -0200 Subject: [media] media: remove extra blank lines No functional changes. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 3 --- include/media/media-device.h | 2 -- 2 files changed, 5 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 849db4f6f1f3..5a5432524c10 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -310,7 +310,6 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph, } EXPORT_SYMBOL_GPL(media_entity_graph_walk_start); - /** * media_entity_graph_walk_next - Get the next entity in the graph * @graph: Media graph structure @@ -850,7 +849,6 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad) } EXPORT_SYMBOL_GPL(media_entity_remote_pad); - static void media_interface_init(struct media_device *mdev, struct media_interface *intf, u32 gobj_type, @@ -915,7 +913,6 @@ struct media_link *media_create_intf_link(struct media_entity *entity, } EXPORT_SYMBOL_GPL(media_create_intf_link); - void __media_remove_intf_link(struct media_link *link) { list_del(&link->list); diff --git a/include/media/media-device.h b/include/media/media-device.h index 65fdd44e05ef..f9907a7728d4 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -463,8 +463,6 @@ struct media_device *media_device_find_devres(struct device *dev); /* Iterate over all links. */ #define media_device_for_each_link(link, mdev) \ list_for_each_entry(link, &(mdev)->links, graph_obj.list) - - #else static inline int media_device_register(struct media_device *mdev) { -- cgit v1.2.3 From 5abad22fd1402c23da1f6ade8cec59ac07a28fc5 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 11:19:38 -0200 Subject: [media] media-entity: get rid of forward __media_entity_remove_link() declaration Move this function to happen earlier, in order to avoid a uneeded forward declaration. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 67 +++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 5a5432524c10..452af1d5a20d 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -588,7 +588,38 @@ static struct media_link *media_add_link(struct list_head *head) } static void __media_entity_remove_link(struct media_entity *entity, - struct media_link *link); + struct media_link *link) +{ + struct media_link *rlink, *tmp; + struct media_entity *remote; + unsigned int r = 0; + + if (link->source->entity == entity) + remote = link->sink->entity; + else + remote = link->source->entity; + + list_for_each_entry_safe(rlink, tmp, &remote->links, list) { + if (rlink != link->reverse) { + r++; + continue; + } + + if (link->source->entity == entity) + remote->num_backlinks--; + + /* Remove the remote link */ + list_del(&rlink->list); + media_gobj_remove(&rlink->graph_obj); + kfree(rlink); + + if (--remote->num_links == 0) + break; + } + list_del(&link->list); + media_gobj_remove(&link->graph_obj); + kfree(link); +} int media_create_pad_link(struct media_entity *source, u16 source_pad, @@ -642,40 +673,6 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, } EXPORT_SYMBOL_GPL(media_create_pad_link); -static void __media_entity_remove_link(struct media_entity *entity, - struct media_link *link) -{ - struct media_link *rlink, *tmp; - struct media_entity *remote; - unsigned int r = 0; - - if (link->source->entity == entity) - remote = link->sink->entity; - else - remote = link->source->entity; - - list_for_each_entry_safe(rlink, tmp, &remote->links, list) { - if (rlink != link->reverse) { - r++; - continue; - } - - if (link->source->entity == entity) - remote->num_backlinks--; - - /* Remove the remote link */ - list_del(&rlink->list); - media_gobj_remove(&rlink->graph_obj); - kfree(rlink); - - if (--remote->num_links == 0) - break; - } - list_del(&link->list); - media_gobj_remove(&link->graph_obj); - kfree(link); -} - void __media_entity_remove_links(struct media_entity *entity) { struct media_link *link, *tmp; -- cgit v1.2.3 From 58f69ee9da3a2486450dac626c352f69faf964e9 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 11:25:23 -0200 Subject: [media] media_entity: get rid of a unused var > > > + if (rlink != link->reverse) { > > > + r++; > > > > The variable is incremented here but otherwise never used, you can remove it. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 452af1d5a20d..57de11281af1 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -592,7 +592,6 @@ static void __media_entity_remove_link(struct media_entity *entity, { struct media_link *rlink, *tmp; struct media_entity *remote; - unsigned int r = 0; if (link->source->entity == entity) remote = link->sink->entity; @@ -600,10 +599,8 @@ static void __media_entity_remove_link(struct media_entity *entity, remote = link->source->entity; list_for_each_entry_safe(rlink, tmp, &remote->links, list) { - if (rlink != link->reverse) { - r++; + if (rlink != link->reverse) continue; - } if (link->source->entity == entity) remote->num_backlinks--; -- cgit v1.2.3 From c350ef830f2c3dfe80e9a777c8a64ac1fb186b9a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 11:55:40 -0200 Subject: [media] media_entity: rename media_obj functions to *_create *_destroy Those media_obj_* functions are actually creating/destroying media graph objects. So, rename them to better represent what they're actually doing. No functional changes. This was created via this small shell script: for i in $(git grep -l media_gobj_init); do sed s,media_gobj_init,media_gobj_create,g <$i >a && mv a $i; done for i in $(git grep -l media_gobj_remove); do sed s,media_gobj_remove,media_gobj_destroy,g <$i >a && mv a $i; done Suggested-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 10 +++++----- drivers/media/media-entity.c | 26 +++++++++++++------------- include/media/media-entity.h | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 537160bb461e..f09f3a6f9c50 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -591,7 +591,7 @@ void media_device_unregister(struct media_device *mdev) list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, graph_obj.list) { __media_remove_intf_links(intf); - media_gobj_remove(&intf->graph_obj); + media_gobj_destroy(&intf->graph_obj); kfree(intf); } spin_unlock(&mdev->lock); @@ -628,11 +628,11 @@ int __must_check media_device_register_entity(struct media_device *mdev, spin_lock(&mdev->lock); /* Initialize media_gobj embedded at the entity */ - media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); + media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); /* Initialize objects at the pads */ for (i = 0; i < entity->num_pads; i++) - media_gobj_init(mdev, MEDIA_GRAPH_PAD, + media_gobj_create(mdev, MEDIA_GRAPH_PAD, &entity->pads[i].graph_obj); spin_unlock(&mdev->lock); @@ -673,10 +673,10 @@ void media_device_unregister_entity(struct media_entity *entity) /* Remove all pads that belong to this entity */ for (i = 0; i < entity->num_pads; i++) - media_gobj_remove(&entity->pads[i].graph_obj); + media_gobj_destroy(&entity->pads[i].graph_obj); /* Remove the entity */ - media_gobj_remove(&entity->graph_obj); + media_gobj_destroy(&entity->graph_obj); spin_unlock(&mdev->lock); entity->graph_obj.mdev = NULL; diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 57de11281af1..861c8e7b8773 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -134,7 +134,7 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) } /** - * media_gobj_init - Initialize a graph object + * media_gobj_create - Initialize a graph object * * @mdev: Pointer to the media_device that contains the object * @type: Type of the object @@ -146,7 +146,7 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) * is embedded on some other object, this function should be called before * registering the object at the media controller. */ -void media_gobj_init(struct media_device *mdev, +void media_gobj_create(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj) { @@ -180,13 +180,13 @@ void media_gobj_init(struct media_device *mdev, } /** - * media_gobj_remove - Stop using a graph object on a media device + * media_gobj_destroy - Stop using a graph object on a media device * * @graph_obj: Pointer to the object * * This should be called at media_device_unregister_*() routines */ -void media_gobj_remove(struct media_gobj *gobj) +void media_gobj_destroy(struct media_gobj *gobj) { dev_dbg_obj(__func__, gobj); @@ -235,7 +235,7 @@ media_entity_pads_init(struct media_entity *entity, u16 num_pads, pads[i].entity = entity; pads[i].index = i; if (mdev) - media_gobj_init(mdev, MEDIA_GRAPH_PAD, + media_gobj_create(mdev, MEDIA_GRAPH_PAD, &entity->pads[i].graph_obj); } @@ -607,14 +607,14 @@ static void __media_entity_remove_link(struct media_entity *entity, /* Remove the remote link */ list_del(&rlink->list); - media_gobj_remove(&rlink->graph_obj); + media_gobj_destroy(&rlink->graph_obj); kfree(rlink); if (--remote->num_links == 0) break; } list_del(&link->list); - media_gobj_remove(&link->graph_obj); + media_gobj_destroy(&link->graph_obj); kfree(link); } @@ -638,7 +638,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, link->flags = flags; /* Initialize graph object embedded at the new link */ - media_gobj_init(source->graph_obj.mdev, MEDIA_GRAPH_LINK, + media_gobj_create(source->graph_obj.mdev, MEDIA_GRAPH_LINK, &link->graph_obj); /* Create the backlink. Backlinks are used to help graph traversal and @@ -656,7 +656,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, backlink->is_backlink = true; /* Initialize graph object embedded at the new link */ - media_gobj_init(sink->graph_obj.mdev, MEDIA_GRAPH_LINK, + media_gobj_create(sink->graph_obj.mdev, MEDIA_GRAPH_LINK, &backlink->graph_obj); link->reverse = backlink; @@ -852,7 +852,7 @@ static void media_interface_init(struct media_device *mdev, intf->flags = flags; INIT_LIST_HEAD(&intf->links); - media_gobj_init(mdev, gobj_type, &intf->graph_obj); + media_gobj_create(mdev, gobj_type, &intf->graph_obj); } /* Functions related to the media interface via device nodes */ @@ -880,7 +880,7 @@ EXPORT_SYMBOL_GPL(media_devnode_create); void media_devnode_remove(struct media_intf_devnode *devnode) { media_remove_intf_links(&devnode->intf); - media_gobj_remove(&devnode->intf.graph_obj); + media_gobj_destroy(&devnode->intf.graph_obj); kfree(devnode); } EXPORT_SYMBOL_GPL(media_devnode_remove); @@ -900,7 +900,7 @@ struct media_link *media_create_intf_link(struct media_entity *entity, link->flags = flags; /* Initialize graph object embedded at the new link */ - media_gobj_init(intf->graph_obj.mdev, MEDIA_GRAPH_LINK, + media_gobj_create(intf->graph_obj.mdev, MEDIA_GRAPH_LINK, &link->graph_obj); return link; @@ -910,7 +910,7 @@ EXPORT_SYMBOL_GPL(media_create_intf_link); void __media_remove_intf_link(struct media_link *link) { list_del(&link->list); - media_gobj_remove(&link->graph_obj); + media_gobj_destroy(&link->graph_obj); kfree(link); } EXPORT_SYMBOL_GPL(__media_remove_intf_link); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 51a7353effd0..1b954fb88def 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -338,10 +338,10 @@ struct media_entity_graph { #define intf_to_devnode(intf) \ container_of(intf, struct media_intf_devnode, intf) -void media_gobj_init(struct media_device *mdev, +void media_gobj_create(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj); -void media_gobj_remove(struct media_gobj *gobj); +void media_gobj_destroy(struct media_gobj *gobj); /** * media_entity_pads_init() - Initialize the entity pads -- cgit v1.2.3 From 1fc25d30a40c27b85510e6e598aec629532eb85c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 12:14:58 -0200 Subject: [media] media-entity.h: move kernel-doc tags from media-entity.c Several additional functions are described at media-entity.c. Moving them to the header file, to make the code cleaner and to have all such macros at the same place. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 163 +++---------------------------------------- include/media/media-entity.h | 136 +++++++++++++++++++++++++++++++++++- 2 files changed, 145 insertions(+), 154 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 861c8e7b8773..ada2b44ea4e1 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -26,15 +26,6 @@ #include #include -/** - * dev_dbg_obj - Prints in debug mode a change on some object - * - * @event_name: Name of the event to report. Could be __func__ - * @gobj: Pointer to the object - * - * Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it - * won't produce any code. - */ static inline const char *gobj_type(enum media_gobj_type type) { switch (type) { @@ -79,6 +70,15 @@ static inline const char *intf_type(struct media_interface *intf) } }; +/** + * dev_dbg_obj - Prints in debug mode a change on some object + * + * @event_name: Name of the event to report. Could be __func__ + * @gobj: Pointer to the object + * + * Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it + * won't produce any code. + */ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) { #if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG) @@ -133,19 +133,6 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) #endif } -/** - * media_gobj_create - Initialize a graph object - * - * @mdev: Pointer to the media_device that contains the object - * @type: Type of the object - * @gobj: Pointer to the object - * - * This routine initializes the embedded struct media_gobj inside a - * media graph object. It is called automatically if media_*_create() - * calls are used. However, if the object (entity, link, pad, interface) - * is embedded on some other object, this function should be called before - * registering the object at the media controller. - */ void media_gobj_create(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj) @@ -179,13 +166,6 @@ void media_gobj_create(struct media_device *mdev, dev_dbg_obj(__func__, gobj); } -/** - * media_gobj_destroy - Stop using a graph object on a media device - * - * @graph_obj: Pointer to the object - * - * This should be called at media_device_unregister_*() routines - */ void media_gobj_destroy(struct media_gobj *gobj) { dev_dbg_obj(__func__, gobj); @@ -196,31 +176,8 @@ void media_gobj_destroy(struct media_gobj *gobj) list_del(&gobj->list); } -/** - * media_entity_pads_init - Initialize a media entity - * - * @num_pads: Total number of sink and source pads. - * @pads: Array of 'num_pads' pads. - * - * The total number of pads is an intrinsic property of entities known by the - * entity driver, while the total number of links depends on hardware design - * and is an extrinsic property unknown to the entity driver. However, in most - * use cases the number of links can safely be assumed to be equal to or - * larger than the number of pads. - * - * For those reasons the links array can be preallocated based on the number - * of pads and will be reallocated later if extra links need to be created. - * - * This function allocates a links array with enough space to hold at least - * 'num_pads' elements. The media_entity::max_links field will be set to the - * number of allocated elements. - * - * The pads array is managed by the entity driver and passed to - * media_entity_pads_init() where its pointer will be stored in the entity structure. - */ -int -media_entity_pads_init(struct media_entity *entity, u16 num_pads, - struct media_pad *pads) +int media_entity_pads_init(struct media_entity *entity, u16 num_pads, + struct media_pad *pads) { struct media_device *mdev = entity->graph_obj.mdev; unsigned int i; @@ -285,16 +242,6 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph) #define link_top(en) ((en)->stack[(en)->top].link) #define stack_top(en) ((en)->stack[(en)->top].entity) -/** - * media_entity_graph_walk_start - Start walking the media graph at a given entity - * @graph: Media graph structure that will be used to walk the graph - * @entity: Starting entity - * - * This function initializes the graph traversal structure to walk the entities - * graph starting at the given entity. The traversal structure must not be - * modified by the caller during graph traversal. When done the structure can - * safely be freed. - */ void media_entity_graph_walk_start(struct media_entity_graph *graph, struct media_entity *entity) { @@ -310,18 +257,6 @@ void media_entity_graph_walk_start(struct media_entity_graph *graph, } EXPORT_SYMBOL_GPL(media_entity_graph_walk_start); -/** - * media_entity_graph_walk_next - Get the next entity in the graph - * @graph: Media graph structure - * - * Perform a depth-first traversal of the given media entities graph. - * - * The graph structure must have been previously initialized with a call to - * media_entity_graph_walk_start(). - * - * Return the next entity in the graph or NULL if the whole graph have been - * traversed. - */ struct media_entity * media_entity_graph_walk_next(struct media_entity_graph *graph) { @@ -370,20 +305,6 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next); * Pipeline management */ -/** - * media_entity_pipeline_start - Mark a pipeline as streaming - * @entity: Starting entity - * @pipe: Media pipeline to be assigned to all entities in the pipeline. - * - * Mark all entities connected to a given entity through enabled links, either - * directly or indirectly, as streaming. The given pipeline object is assigned to - * every entity in the pipeline and stored in the media_entity pipe field. - * - * Calls to this function can be nested, in which case the same number of - * media_entity_pipeline_stop() calls will be required to stop streaming. The - * pipeline pointer must be identical for all nested calls to - * media_entity_pipeline_start(). - */ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe) { @@ -494,18 +415,6 @@ error: } EXPORT_SYMBOL_GPL(media_entity_pipeline_start); -/** - * media_entity_pipeline_stop - Mark a pipeline as not streaming - * @entity: Starting entity - * - * Mark all entities connected to a given entity through enabled links, either - * directly or indirectly, as not streaming. The media_entity pipe field is - * reset to NULL. - * - * If multiple calls to media_entity_pipeline_start() have been made, the same - * number of calls to this function are required to mark the pipeline as not - * streaming. - */ void media_entity_pipeline_stop(struct media_entity *entity) { struct media_device *mdev = entity->graph_obj.mdev; @@ -529,16 +438,6 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_stop); * Module use count */ -/* - * media_entity_get - Get a reference to the parent module - * @entity: The entity - * - * Get a reference to the parent media device module. - * - * The function will return immediately if @entity is NULL. - * - * Return a pointer to the entity on success or NULL on failure. - */ struct media_entity *media_entity_get(struct media_entity *entity) { if (entity == NULL) @@ -552,14 +451,6 @@ struct media_entity *media_entity_get(struct media_entity *entity) } EXPORT_SYMBOL_GPL(media_entity_get); -/* - * media_entity_put - Release the reference to the parent module - * @entity: The entity - * - * Release the reference count acquired by media_entity_get(). - * - * The function will return immediately if @entity is NULL. - */ void media_entity_put(struct media_entity *entity) { if (entity == NULL) @@ -718,20 +609,6 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags) return 0; } -/** - * __media_entity_setup_link - Configure a media link - * @link: The link being configured - * @flags: Link configuration flags - * - * The bulk of link setup is handled by the two entities connected through the - * link. This function notifies both entities of the link configuration change. - * - * If the link is immutable or if the current and new configuration are - * identical, return immediately. - * - * The user is expected to hold link->source->parent->mutex. If not, - * media_entity_setup_link() should be used instead. - */ int __media_entity_setup_link(struct media_link *link, u32 flags) { const u32 mask = MEDIA_LNK_FL_ENABLED; @@ -788,14 +665,6 @@ int media_entity_setup_link(struct media_link *link, u32 flags) } EXPORT_SYMBOL_GPL(media_entity_setup_link); -/** - * media_entity_find_link - Find a link between two pads - * @source: Source pad - * @sink: Sink pad - * - * Return a pointer to the link between the two entities. If no such link - * exists, return NULL. - */ struct media_link * media_entity_find_link(struct media_pad *source, struct media_pad *sink) { @@ -813,16 +682,6 @@ media_entity_find_link(struct media_pad *source, struct media_pad *sink) } EXPORT_SYMBOL_GPL(media_entity_find_link); -/** - * media_entity_remote_pad - Find the pad at the remote end of a link - * @pad: Pad at the local end of the link - * - * Search for a remote pad connected to the given pad by iterating over all - * links originating or terminating at that pad until an enabled link is found. - * - * Return a pointer to the pad at the remote end of the first found enabled - * link, or NULL if no enabled link has been found. - */ struct media_pad *media_entity_remote_pad(struct media_pad *pad) { struct media_link *link; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 1b954fb88def..d073b205e6a6 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -338,17 +338,43 @@ struct media_entity_graph { #define intf_to_devnode(intf) \ container_of(intf, struct media_intf_devnode, intf) +/** + * media_gobj_create - Initialize a graph object + * + * @mdev: Pointer to the media_device that contains the object + * @type: Type of the object + * @gobj: Pointer to the graph object + * + * This routine initializes the embedded struct media_gobj inside a + * media graph object. It is called automatically if media_*_create() + * calls are used. However, if the object (entity, link, pad, interface) + * is embedded on some other object, this function should be called before + * registering the object at the media controller. + */ void media_gobj_create(struct media_device *mdev, enum media_gobj_type type, struct media_gobj *gobj); + +/** + * media_gobj_destroy - Stop using a graph object on a media device + * + * @gobj: Pointer to the graph object + * + * This should be called by all routines like media_device_unregister() + * that remove/destroy media graph objects. + */ void media_gobj_destroy(struct media_gobj *gobj); /** * media_entity_pads_init() - Initialize the entity pads * * @entity: entity where the pads belong - * @num_pads: number of pads to be initialized - * @pads: pads array + * @num_pads: total number of sink and source pads + * @pads: Array of @num_pads pads. + * + * The pads array is managed by the entity driver and passed to + * media_entity_pads_init() where its pointer will be stored in the entity + * structure. * * If no pads are needed, drivers could either directly fill * &media_entity->@num_pads with 0 and &media_entity->@pads with NULL or call @@ -413,6 +439,20 @@ void __media_entity_remove_links(struct media_entity *entity); */ void media_entity_remove_links(struct media_entity *entity); +/** + * __media_entity_setup_link - Configure a media link without locking + * @link: The link being configured + * @flags: Link configuration flags + * + * The bulk of link setup is handled by the two entities connected through the + * link. This function notifies both entities of the link configuration change. + * + * If the link is immutable or if the current and new configuration are + * identical, return immediately. + * + * The user is expected to hold link->source->parent->mutex. If not, + * media_entity_setup_link() should be used instead. + */ int __media_entity_setup_link(struct media_link *link, u32 flags); /** @@ -450,19 +490,111 @@ int __media_entity_setup_link(struct media_link *link, u32 flags); * on media_create_intf_link(), for interface to entity links. */ int media_entity_setup_link(struct media_link *link, u32 flags); + +/** + * media_entity_find_link - Find a link between two pads + * @source: Source pad + * @sink: Sink pad + * + * Return a pointer to the link between the two entities. If no such link + * exists, return NULL. + */ struct media_link *media_entity_find_link(struct media_pad *source, struct media_pad *sink); + +/** + * media_entity_remote_pad - Find the pad at the remote end of a link + * @pad: Pad at the local end of the link + * + * Search for a remote pad connected to the given pad by iterating over all + * links originating or terminating at that pad until an enabled link is found. + * + * Return a pointer to the pad at the remote end of the first found enabled + * link, or NULL if no enabled link has been found. + */ struct media_pad *media_entity_remote_pad(struct media_pad *pad); +/** + * media_entity_get - Get a reference to the parent module + * + * @entity: The entity + * + * Get a reference to the parent media device module. + * + * The function will return immediately if @entity is NULL. + * + * Return a pointer to the entity on success or NULL on failure. + */ struct media_entity *media_entity_get(struct media_entity *entity); + +/** + * media_entity_put - Release the reference to the parent module + * + * @entity: The entity + * + * Release the reference count acquired by media_entity_get(). + * + * The function will return immediately if @entity is NULL. + */ void media_entity_put(struct media_entity *entity); +/** + * media_entity_graph_walk_start - Start walking the media graph at a given entity + * @graph: Media graph structure that will be used to walk the graph + * @entity: Starting entity + * + * This function initializes the graph traversal structure to walk the entities + * graph starting at the given entity. The traversal structure must not be + * modified by the caller during graph traversal. When done the structure can + * safely be freed. + */ void media_entity_graph_walk_start(struct media_entity_graph *graph, struct media_entity *entity); + +/** + * media_entity_graph_walk_next - Get the next entity in the graph + * @graph: Media graph structure + * + * Perform a depth-first traversal of the given media entities graph. + * + * The graph structure must have been previously initialized with a call to + * media_entity_graph_walk_start(). + * + * Return the next entity in the graph or NULL if the whole graph have been + * traversed. + */ struct media_entity * media_entity_graph_walk_next(struct media_entity_graph *graph); + +/** + * media_entity_pipeline_start - Mark a pipeline as streaming + * @entity: Starting entity + * @pipe: Media pipeline to be assigned to all entities in the pipeline. + * + * Mark all entities connected to a given entity through enabled links, either + * directly or indirectly, as streaming. The given pipeline object is assigned to + * every entity in the pipeline and stored in the media_entity pipe field. + * + * Calls to this function can be nested, in which case the same number of + * media_entity_pipeline_stop() calls will be required to stop streaming. The + * pipeline pointer must be identical for all nested calls to + * media_entity_pipeline_start(). + */ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe); + +/** + * media_entity_pipeline_stop - Mark a pipeline as not streaming + * @entity: Starting entity + * + * Mark all entities connected to a given entity through enabled links, either + * directly or indirectly, as not streaming. The media_entity pipe field is + * reset to NULL. + * + * If multiple calls to media_entity_pipeline_start() have been made, the same + * number of calls to this function are required to mark the pipeline as not + * streaming. + */ void media_entity_pipeline_stop(struct media_entity *entity); /** -- cgit v1.2.3 From 829de29bfe5a0568831f1c52a760306d642d99d4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 12:23:23 -0200 Subject: [media] media: use unsigned for pad index The pad index is unsigned. Replace the occurences of it where pertinent. Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/isppreview.c | 2 +- drivers/media/platform/omap3isp/ispresizer.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 2 +- drivers/staging/media/omap4iss/iss_csi2.c | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 2 +- drivers/staging/media/omap4iss/iss_resizer.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index dae674cd3f74..749462c1af8e 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -2513,7 +2513,7 @@ static int ccdc_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); struct isp_device *isp = to_isp_device(ccdc); - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index 0c790b25f6f9..59686dd1bb0a 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -956,7 +956,7 @@ static int ccp2_link_setup(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index f50f6b305204..886f148755b0 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c @@ -1144,7 +1144,7 @@ static int csi2_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct isp_csi2_ctrl_cfg *ctrl = &csi2->ctrl; - int index = local->index; + unsigned int index = local->index; /* * The ISP core doesn't support pipelines with multiple video outputs. diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c index c300cb7219e9..e15ad4133632 100644 --- a/drivers/media/platform/omap3isp/isppreview.c +++ b/drivers/media/platform/omap3isp/isppreview.c @@ -2144,7 +2144,7 @@ static int preview_link_setup(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_prev_device *prev = v4l2_get_subdevdata(sd); - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c index cd0a9f6e1fed..20b98d876d7e 100644 --- a/drivers/media/platform/omap3isp/ispresizer.c +++ b/drivers/media/platform/omap3isp/ispresizer.c @@ -1623,7 +1623,7 @@ static int resizer_link_setup(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct isp_res_device *res = v4l2_get_subdevdata(sd); - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index a54c60fce3d5..633d6456fdce 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -885,7 +885,7 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct vpfe_device *vpfe = to_vpfe_device(ipipeif); - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index b35667afb73f..99057892d88d 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -1707,7 +1707,7 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd); - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 669ae3f9791f..a91395ce91e1 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1648,7 +1648,7 @@ static int resizer_link_setup(struct media_entity *entity, struct vpfe_device *vpfe_dev = to_vpfe_device(resizer); u16 ipipeif_source = vpfe_dev->vpfe_ipipeif.output; u16 ipipe_source = vpfe_dev->vpfe_ipipe.output; - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index 226366a03661..f0fa037ce173 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -1170,7 +1170,7 @@ static int csi2_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct iss_csi2_ctrl_cfg *ctrl = &csi2->ctrl; - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index c2b5638a0898..88b22f7f8b13 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -662,7 +662,7 @@ static int ipipeif_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct iss_device *iss = to_iss_device(ipipeif); - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index fea13ab4041f..fe7b253bb0d3 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -716,7 +716,7 @@ static int resizer_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct iss_device *iss = to_iss_device(resizer); - int index = local->index; + unsigned int index = local->index; /* FIXME: this is actually a hack! */ if (is_media_entity_v4l2_subdev(remote->entity)) -- cgit v1.2.3 From b3b7a9f138b7539c25e036d398616f6737b08ff7 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 16:07:57 -0200 Subject: [media] media-device: Use u64 ints for pointers By using u64 integers and pointers, we can get rid of compat32 logic. So, let's do it! Suggested-by: Arnd Bergmann Suggested-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 77 +++++++++++++++++++++++--------------------- include/uapi/linux/media.h | 32 +++++++++--------- 2 files changed, 58 insertions(+), 51 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index f09f3a6f9c50..6406914a9bf5 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -240,10 +240,10 @@ static long __media_device_get_topology(struct media_device *mdev, struct media_interface *intf; struct media_pad *pad; struct media_link *link; - struct media_v2_entity uentity; - struct media_v2_interface uintf; - struct media_v2_pad upad; - struct media_v2_link ulink; + struct media_v2_entity kentity, *uentity; + struct media_v2_interface kintf, *uintf; + struct media_v2_pad kpad, *upad; + struct media_v2_link klink, *ulink; unsigned int i; int ret = 0; @@ -251,10 +251,10 @@ static long __media_device_get_topology(struct media_device *mdev, /* Get entities and number of entities */ i = 0; + uentity = media_get_uptr(topo->ptr_entities); media_device_for_each_entity(entity, mdev) { i++; - - if (ret || !topo->entities) + if (ret || !uentity) continue; if (i > topo->num_entities) { @@ -263,23 +263,24 @@ static long __media_device_get_topology(struct media_device *mdev, } /* Copy fields to userspace struct if not error */ - memset(&uentity, 0, sizeof(uentity)); - uentity.id = entity->graph_obj.id; - uentity.function = entity->function; - strncpy(uentity.name, entity->name, - sizeof(uentity.name)); + memset(&kentity, 0, sizeof(kentity)); + kentity.id = entity->graph_obj.id; + kentity.function = entity->function; + strncpy(kentity.name, entity->name, + sizeof(kentity.name)); - if (copy_to_user(&topo->entities[i - 1], &uentity, sizeof(uentity))) + if (copy_to_user(uentity, &kentity, sizeof(kentity))) ret = -EFAULT; + uentity++; } topo->num_entities = i; /* Get interfaces and number of interfaces */ i = 0; + uintf = media_get_uptr(topo->ptr_interfaces); media_device_for_each_intf(intf, mdev) { i++; - - if (ret || !topo->interfaces) + if (ret || !uintf) continue; if (i > topo->num_interfaces) { @@ -287,33 +288,34 @@ static long __media_device_get_topology(struct media_device *mdev, continue; } - memset(&uintf, 0, sizeof(uintf)); + memset(&kintf, 0, sizeof(kintf)); /* Copy intf fields to userspace struct */ - uintf.id = intf->graph_obj.id; - uintf.intf_type = intf->type; - uintf.flags = intf->flags; + kintf.id = intf->graph_obj.id; + kintf.intf_type = intf->type; + kintf.flags = intf->flags; if (media_type(&intf->graph_obj) == MEDIA_GRAPH_INTF_DEVNODE) { struct media_intf_devnode *devnode; devnode = intf_to_devnode(intf); - uintf.devnode.major = devnode->major; - uintf.devnode.minor = devnode->minor; + kintf.devnode.major = devnode->major; + kintf.devnode.minor = devnode->minor; } - if (copy_to_user(&topo->interfaces[i - 1], &uintf, sizeof(uintf))) + if (copy_to_user(uintf, &kintf, sizeof(kintf))) ret = -EFAULT; + uintf++; } topo->num_interfaces = i; /* Get pads and number of pads */ i = 0; + upad = media_get_uptr(topo->ptr_pads); media_device_for_each_pad(pad, mdev) { i++; - - if (ret || !topo->pads) + if (ret || !upad) continue; if (i > topo->num_pads) { @@ -321,27 +323,29 @@ static long __media_device_get_topology(struct media_device *mdev, continue; } - memset(&upad, 0, sizeof(upad)); + memset(&kpad, 0, sizeof(kpad)); /* Copy pad fields to userspace struct */ - upad.id = pad->graph_obj.id; - upad.entity_id = pad->entity->graph_obj.id; - upad.flags = pad->flags; + kpad.id = pad->graph_obj.id; + kpad.entity_id = pad->entity->graph_obj.id; + kpad.flags = pad->flags; - if (copy_to_user(&topo->pads[i - 1], &upad, sizeof(upad))) + if (copy_to_user(upad, &kpad, sizeof(kpad))) ret = -EFAULT; + upad++; } topo->num_pads = i; /* Get links and number of links */ i = 0; + ulink = media_get_uptr(topo->ptr_links); media_device_for_each_link(link, mdev) { if (link->is_backlink) continue; i++; - if (ret || !topo->links) + if (ret || !ulink) continue; if (i > topo->num_links) { @@ -349,19 +353,20 @@ static long __media_device_get_topology(struct media_device *mdev, continue; } - memset(&ulink, 0, sizeof(ulink)); + memset(&klink, 0, sizeof(klink)); /* Copy link fields to userspace struct */ - ulink.id = link->graph_obj.id; - ulink.source_id = link->gobj0->id; - ulink.sink_id = link->gobj1->id; - ulink.flags = link->flags; + klink.id = link->graph_obj.id; + klink.source_id = link->gobj0->id; + klink.sink_id = link->gobj1->id; + klink.flags = link->flags; if (media_type(link->gobj0) != MEDIA_GRAPH_PAD) - ulink.flags |= MEDIA_LNK_FL_INTERFACE_LINK; + klink.flags |= MEDIA_LNK_FL_INTERFACE_LINK; - if (copy_to_user(&topo->links[i - 1], &ulink, sizeof(ulink))) + if (copy_to_user(ulink, &klink, sizeof(klink))) ret = -EFAULT; + ulink++; } topo->num_links = i; diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 8d8e1a3e6e1a..86f9753e5c03 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -23,6 +23,9 @@ #ifndef __LINUX_MEDIA_H #define __LINUX_MEDIA_H +#ifndef __KERNEL__ +#include +#endif #include #include #include @@ -320,27 +323,26 @@ struct media_v2_link { }; struct media_v2_topology { - __u32 topology_version; + __u64 topology_version; - __u32 num_entities; - struct media_v2_entity *entities; + __u64 num_entities; + __u64 ptr_entities; - __u32 num_interfaces; - struct media_v2_interface *interfaces; + __u64 num_interfaces; + __u64 ptr_interfaces; - __u32 num_pads; - struct media_v2_pad *pads; + __u64 num_pads; + __u64 ptr_pads; - __u32 num_links; - struct media_v2_link *links; - - struct { - __u32 reserved_num; - void *reserved_ptr; - } reserved_types[16]; - __u32 reserved[8]; + __u64 num_links; + __u64 ptr_links; }; +static inline void __user *media_get_uptr(__u64 arg) +{ + return (void __user *)(uintptr_t)arg; +} + /* ioctls */ #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info) -- cgit v1.2.3 From b5f6df0607b767fe48b179c6ccee204ee17c3373 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:27 -0200 Subject: [media] omap3isp: remove per ISP module link creation functions The entities to video nodes links were created on separate functions for each ISP module but since the only thing that these functions do is to call media_create_pad_link(), there's no need for that indirection level and all link creation logic can be just inlined in the caller function. Also, since the only possible failure for the link creation is a memory allocation, there is no need for error messages since the core already reports a very verbose message in that case. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 56 +++++++++++++++++----------- drivers/media/platform/omap3isp/ispccdc.c | 14 ------- drivers/media/platform/omap3isp/ispccdc.h | 1 - drivers/media/platform/omap3isp/ispccp2.c | 14 ------- drivers/media/platform/omap3isp/ispccp2.h | 1 - drivers/media/platform/omap3isp/ispcsi2.c | 14 ------- drivers/media/platform/omap3isp/ispcsi2.h | 1 - drivers/media/platform/omap3isp/isppreview.c | 20 ---------- drivers/media/platform/omap3isp/isppreview.h | 1 - drivers/media/platform/omap3isp/ispresizer.c | 20 ---------- drivers/media/platform/omap3isp/ispresizer.h | 1 - 11 files changed, 35 insertions(+), 108 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index cb8ac90086c1..40aee11805c7 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -1940,37 +1940,51 @@ static int isp_create_pads_links(struct isp_device *isp) { int ret; - ret = omap3isp_csi2_create_pads_links(isp); - if (ret < 0) { - dev_err(isp->dev, "CSI2 pads links creation failed\n"); + /* Create links between entities and video nodes. */ + ret = media_create_pad_link( + &isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE, + &isp->isp_csi2a.video_out.video.entity, 0, 0); + if (ret < 0) return ret; - } - ret = omap3isp_ccp2_create_pads_links(isp); - if (ret < 0) { - dev_err(isp->dev, "CCP2 pads links creation failed\n"); + ret = media_create_pad_link( + &isp->isp_ccp2.video_in.video.entity, 0, + &isp->isp_ccp2.subdev.entity, CCP2_PAD_SINK, 0); + if (ret < 0) return ret; - } - ret = omap3isp_ccdc_create_pads_links(isp); - if (ret < 0) { - dev_err(isp->dev, "CCDC pads links creation failed\n"); + ret = media_create_pad_link( + &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF, + &isp->isp_ccdc.video_out.video.entity, 0, 0); + if (ret < 0) return ret; - } - ret = omap3isp_preview_create_pads_links(isp); - if (ret < 0) { - dev_err(isp->dev, "Preview pads links creation failed\n"); + ret = media_create_pad_link( + &isp->isp_prev.video_in.video.entity, 0, + &isp->isp_prev.subdev.entity, PREV_PAD_SINK, 0); + if (ret < 0) return ret; - } - ret = omap3isp_resizer_create_pads_links(isp); - if (ret < 0) { - dev_err(isp->dev, "Resizer pads links creation failed\n"); + ret = media_create_pad_link( + &isp->isp_prev.subdev.entity, PREV_PAD_SOURCE, + &isp->isp_prev.video_out.video.entity, 0, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_res.video_in.video.entity, 0, + &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &isp->isp_res.subdev.entity, RESZ_PAD_SOURCE, + &isp->isp_res.video_out.video.entity, 0, 0); + + if (ret < 0) return ret; - } - /* Connect the submodules. */ + /* Create links between entities. */ ret = media_create_pad_link( &isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE, &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0); diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 749462c1af8e..5e16b5f594b7 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -2717,20 +2717,6 @@ int omap3isp_ccdc_init(struct isp_device *isp) return 0; } -/* - * omap3isp_ccdc_create_pads_links - CCDC pads links creation - * @isp : Pointer to ISP device - * return negative error code or zero on success - */ -int omap3isp_ccdc_create_pads_links(struct isp_device *isp) -{ - struct isp_ccdc_device *ccdc = &isp->isp_ccdc; - - /* Connect the CCDC subdev to the video node. */ - return media_create_pad_link(&ccdc->subdev.entity, CCDC_PAD_SOURCE_OF, - &ccdc->video_out.video.entity, 0, 0); -} - /* * omap3isp_ccdc_cleanup - CCDC module cleanup. * @isp: Device pointer specific to the OMAP3 ISP. diff --git a/drivers/media/platform/omap3isp/ispccdc.h b/drivers/media/platform/omap3isp/ispccdc.h index 2128203ef6fb..3440a7097940 100644 --- a/drivers/media/platform/omap3isp/ispccdc.h +++ b/drivers/media/platform/omap3isp/ispccdc.h @@ -163,7 +163,6 @@ struct isp_ccdc_device { struct isp_device; int omap3isp_ccdc_init(struct isp_device *isp); -int omap3isp_ccdc_create_pads_links(struct isp_device *isp); void omap3isp_ccdc_cleanup(struct isp_device *isp); int omap3isp_ccdc_register_entities(struct isp_ccdc_device *ccdc, struct v4l2_device *vdev); diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index 59686dd1bb0a..27f5fe4edefc 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -1153,20 +1153,6 @@ int omap3isp_ccp2_init(struct isp_device *isp) return 0; } -/* - * omap3isp_ccp2_create_pads_links - CCP2 pads links creation - * @isp : Pointer to ISP device - * return negative error code or zero on success - */ -int omap3isp_ccp2_create_pads_links(struct isp_device *isp) -{ - struct isp_ccp2_device *ccp2 = &isp->isp_ccp2; - - /* Connect the video node to the ccp2 subdev. */ - return media_create_pad_link(&ccp2->video_in.video.entity, 0, - &ccp2->subdev.entity, CCP2_PAD_SINK, 0); -} - /* * omap3isp_ccp2_cleanup - CCP2 un-initialization * @isp : Pointer to ISP device diff --git a/drivers/media/platform/omap3isp/ispccp2.h b/drivers/media/platform/omap3isp/ispccp2.h index fb74bc67878b..4662bffa79e3 100644 --- a/drivers/media/platform/omap3isp/ispccp2.h +++ b/drivers/media/platform/omap3isp/ispccp2.h @@ -79,7 +79,6 @@ struct isp_ccp2_device { /* Function declarations */ int omap3isp_ccp2_init(struct isp_device *isp); -int omap3isp_ccp2_create_pads_links(struct isp_device *isp); void omap3isp_ccp2_cleanup(struct isp_device *isp); int omap3isp_ccp2_register_entities(struct isp_ccp2_device *ccp2, struct v4l2_device *vdev); diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c index 886f148755b0..f75a1be29d84 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.c +++ b/drivers/media/platform/omap3isp/ispcsi2.c @@ -1310,20 +1310,6 @@ int omap3isp_csi2_init(struct isp_device *isp) return 0; } -/* - * omap3isp_csi2_create_pads_links - CSI2 pads links creation - * @isp : Pointer to ISP device - * return negative error code or zero on success - */ -int omap3isp_csi2_create_pads_links(struct isp_device *isp) -{ - struct isp_csi2_device *csi2a = &isp->isp_csi2a; - - /* Connect the CSI2 subdev to the video node. */ - return media_create_pad_link(&csi2a->subdev.entity, CSI2_PAD_SOURCE, - &csi2a->video_out.video.entity, 0, 0); -} - /* * omap3isp_csi2_cleanup - Routine for module driver cleanup */ diff --git a/drivers/media/platform/omap3isp/ispcsi2.h b/drivers/media/platform/omap3isp/ispcsi2.h index 452ee239c7d7..453ed62fe394 100644 --- a/drivers/media/platform/omap3isp/ispcsi2.h +++ b/drivers/media/platform/omap3isp/ispcsi2.h @@ -148,7 +148,6 @@ struct isp_csi2_device { void omap3isp_csi2_isr(struct isp_csi2_device *csi2); int omap3isp_csi2_reset(struct isp_csi2_device *csi2); int omap3isp_csi2_init(struct isp_device *isp); -int omap3isp_csi2_create_pads_links(struct isp_device *isp); void omap3isp_csi2_cleanup(struct isp_device *isp); void omap3isp_csi2_unregister_entities(struct isp_csi2_device *csi2); int omap3isp_csi2_register_entities(struct isp_csi2_device *csi2, diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c index e15ad4133632..84a96670e2e7 100644 --- a/drivers/media/platform/omap3isp/isppreview.c +++ b/drivers/media/platform/omap3isp/isppreview.c @@ -2341,26 +2341,6 @@ int omap3isp_preview_init(struct isp_device *isp) return preview_init_entities(prev); } -/* - * omap3isp_preview_create_pads_links - Previewer pads links creation - * @isp : Pointer to ISP device - * return negative error code or zero on success - */ -int omap3isp_preview_create_pads_links(struct isp_device *isp) -{ - struct isp_prev_device *prev = &isp->isp_prev; - int ret; - - /* Connect the video nodes to the previewer subdev. */ - ret = media_create_pad_link(&prev->video_in.video.entity, 0, - &prev->subdev.entity, PREV_PAD_SINK, 0); - if (ret < 0) - return ret; - - return media_create_pad_link(&prev->subdev.entity, PREV_PAD_SOURCE, - &prev->video_out.video.entity, 0, 0); -} - void omap3isp_preview_cleanup(struct isp_device *isp) { struct isp_prev_device *prev = &isp->isp_prev; diff --git a/drivers/media/platform/omap3isp/isppreview.h b/drivers/media/platform/omap3isp/isppreview.h index f3593b7cecc7..16fdc03a3d43 100644 --- a/drivers/media/platform/omap3isp/isppreview.h +++ b/drivers/media/platform/omap3isp/isppreview.h @@ -148,7 +148,6 @@ struct isp_prev_device { struct isp_device; int omap3isp_preview_init(struct isp_device *isp); -int omap3isp_preview_create_pads_links(struct isp_device *isp); void omap3isp_preview_cleanup(struct isp_device *isp); int omap3isp_preview_register_entities(struct isp_prev_device *prv, diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c index 20b98d876d7e..0b6a87508584 100644 --- a/drivers/media/platform/omap3isp/ispresizer.c +++ b/drivers/media/platform/omap3isp/ispresizer.c @@ -1785,26 +1785,6 @@ int omap3isp_resizer_init(struct isp_device *isp) return resizer_init_entities(res); } -/* - * omap3isp_resizer_create_pads_links - Resizer pads links creation - * @isp : Pointer to ISP device - * return negative error code or zero on success - */ -int omap3isp_resizer_create_pads_links(struct isp_device *isp) -{ - struct isp_res_device *res = &isp->isp_res; - int ret; - - /* Connect the video nodes to the resizer subdev. */ - ret = media_create_pad_link(&res->video_in.video.entity, 0, - &res->subdev.entity, RESZ_PAD_SINK, 0); - if (ret < 0) - return ret; - - return media_create_pad_link(&res->subdev.entity, RESZ_PAD_SOURCE, - &res->video_out.video.entity, 0, 0); -} - void omap3isp_resizer_cleanup(struct isp_device *isp) { struct isp_res_device *res = &isp->isp_res; diff --git a/drivers/media/platform/omap3isp/ispresizer.h b/drivers/media/platform/omap3isp/ispresizer.h index 8b9fdcdab73d..5414542912e2 100644 --- a/drivers/media/platform/omap3isp/ispresizer.h +++ b/drivers/media/platform/omap3isp/ispresizer.h @@ -119,7 +119,6 @@ struct isp_res_device { struct isp_device; int omap3isp_resizer_init(struct isp_device *isp); -int omap3isp_resizer_create_pads_links(struct isp_device *isp); void omap3isp_resizer_cleanup(struct isp_device *isp); int omap3isp_resizer_register_entities(struct isp_res_device *res, -- cgit v1.2.3 From b285d5afcf80270fafc57b1a7f1ffab9e77e4686 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:28 -0200 Subject: [media] omap3isp: remove pads prefix from isp_create_pads_links() The function that creates the links between ISP internal and external entities is called isp_create_pads_links() but the "pads" prefix is redundant since the driver doesn't handle any other kind of link so it can just be removed. While being there, fix the function's kernel-doc since is not using a proper format. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 40aee11805c7..fb17746e4209 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -1932,11 +1932,15 @@ done: } /* - * isp_create_pads_links - Pads links creation for the subdevices + * isp_create_links() - Create links for internal and external ISP entities * @isp : Pointer to ISP device - * return negative error code or zero on success + * + * This function creates all links between ISP internal and external entities. + * + * Return: A negative error code on failure or zero on success. Possible error + * codes are those returned by media_create_pad_link(). */ -static int isp_create_pads_links(struct isp_device *isp) +static int isp_create_links(struct isp_device *isp) { int ret; @@ -2527,7 +2531,7 @@ static int isp_probe(struct platform_device *pdev) if (ret < 0) goto error_modules; - ret = isp_create_pads_links(isp); + ret = isp_create_links(isp); if (ret < 0) goto error_register_entities; -- cgit v1.2.3 From a64860e56b2f97bdcd367a6e10624cd0e51b5406 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:29 -0200 Subject: [media] omap3isp: rename single labels to just error Commit bc36b30fe06b ("[media] omap3isp: separate links creation from entities init") moved the link creation logic from the entities init functions and so removed the error_link labels from the error paths. But after that, some functions have a single error label so it makes more sense to rename the label to just "error" in thi case. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/ispccdc.c | 4 ++-- drivers/media/platform/omap3isp/ispccp2.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 5e16b5f594b7..4eaf926d6073 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -2669,11 +2669,11 @@ static int ccdc_init_entities(struct isp_ccdc_device *ccdc) ret = omap3isp_video_init(&ccdc->video_out, "CCDC"); if (ret < 0) - goto error_video; + goto error; return 0; -error_video: +error: media_entity_cleanup(me); return ret; } diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c index 27f5fe4edefc..ca095238510d 100644 --- a/drivers/media/platform/omap3isp/ispccp2.c +++ b/drivers/media/platform/omap3isp/ispccp2.c @@ -1102,11 +1102,11 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2) ret = omap3isp_video_init(&ccp2->video_in, "CCP2"); if (ret < 0) - goto error_video; + goto error; return 0; -error_video: +error: media_entity_cleanup(&ccp2->subdev.entity); return ret; } -- cgit v1.2.3 From 06a1368faf2184c71f086bfc13e81ea153d98798 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:30 -0200 Subject: [media] omap3isp: consistently use v4l2_dev var in complete notifier The isp_subdev_notifier_complete() complete callback defines a struct v4l2_device *v4l2_dev to avoid needing two level of indirections to access the V4L2 subdevs but the var is not always used when possible as when calling v4l2_device_register_subdev_nodes(). So change that to consistently use the defined v4l2_dev pointer var. Suggested-by: Sakari Ailus Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index fb17746e4209..8226eca83327 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -2365,7 +2365,7 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) } } - return v4l2_device_register_subdev_nodes(&isp->v4l2_dev); + return v4l2_device_register_subdev_nodes(v4l2_dev); } /* -- cgit v1.2.3 From 04e021511abc189ca43f1f11ec53121b9345c9fa Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:31 -0200 Subject: [media] staging: omap4iss: remove pads prefix from *_create_pads_links() The functions that create ISS internal and external entities links are called *_create_pads_links() but the "pads" prefix is redundant since the driver doesn't handle any other kind of link so it can be removed. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss.c | 12 ++++++------ drivers/staging/media/omap4iss/iss_csi2.c | 4 ++-- drivers/staging/media/omap4iss/iss_csi2.h | 2 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 4 ++-- drivers/staging/media/omap4iss/iss_ipipeif.h | 2 +- drivers/staging/media/omap4iss/iss_resizer.c | 4 ++-- drivers/staging/media/omap4iss/iss_resizer.h | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index 28e4d16544eb..7209b92b1f86 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -1273,28 +1273,28 @@ done: } /* - * iss_create_pads_links() - Pads links creation for the subdevices + * iss_create_links() - Pads links creation for the subdevices * @iss : Pointer to ISS device * * return negative error code or zero on success */ -static int iss_create_pads_links(struct iss_device *iss) +static int iss_create_links(struct iss_device *iss) { int ret; - ret = omap4iss_csi2_create_pads_links(iss); + ret = omap4iss_csi2_create_links(iss); if (ret < 0) { dev_err(iss->dev, "CSI2 pads links creation failed\n"); return ret; } - ret = omap4iss_ipipeif_create_pads_links(iss); + ret = omap4iss_ipipeif_create_links(iss); if (ret < 0) { dev_err(iss->dev, "ISP IPIPEIF pads links creation failed\n"); return ret; } - ret = omap4iss_resizer_create_pads_links(iss); + ret = omap4iss_resizer_create_links(iss); if (ret < 0) { dev_err(iss->dev, "ISP RESIZER pads links creation failed\n"); return ret; @@ -1491,7 +1491,7 @@ static int iss_probe(struct platform_device *pdev) if (ret < 0) goto error_modules; - ret = iss_create_pads_links(iss); + ret = iss_create_links(iss); if (ret < 0) goto error_entities; diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index f0fa037ce173..aaca39d751a5 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -1339,12 +1339,12 @@ int omap4iss_csi2_init(struct iss_device *iss) } /* - * omap4iss_csi2_create_pads_links() - CSI2 pads links creation + * omap4iss_csi2_create_links() - CSI2 pads links creation * @iss: Pointer to ISS device * * return negative error code or zero on success */ -int omap4iss_csi2_create_pads_links(struct iss_device *iss) +int omap4iss_csi2_create_links(struct iss_device *iss) { struct iss_csi2_device *csi2a = &iss->csi2a; struct iss_csi2_device *csi2b = &iss->csi2b; diff --git a/drivers/staging/media/omap4iss/iss_csi2.h b/drivers/staging/media/omap4iss/iss_csi2.h index 1d5a0d8222a9..24ab378d469f 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.h +++ b/drivers/staging/media/omap4iss/iss_csi2.h @@ -151,7 +151,7 @@ struct iss_csi2_device { void omap4iss_csi2_isr(struct iss_csi2_device *csi2); int omap4iss_csi2_reset(struct iss_csi2_device *csi2); int omap4iss_csi2_init(struct iss_device *iss); -int omap4iss_csi2_create_pads_links(struct iss_device *iss); +int omap4iss_csi2_create_links(struct iss_device *iss); void omap4iss_csi2_cleanup(struct iss_device *iss); void omap4iss_csi2_unregister_entities(struct iss_csi2_device *csi2); int omap4iss_csi2_register_entities(struct iss_csi2_device *csi2, diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index 88b22f7f8b13..23de8330731d 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -815,12 +815,12 @@ int omap4iss_ipipeif_init(struct iss_device *iss) } /* - * omap4iss_ipipeif_create_pads_links() - IPIPEIF pads links creation + * omap4iss_ipipeif_create_links() - IPIPEIF pads links creation * @iss: Pointer to ISS device * * return negative error code or zero on success */ -int omap4iss_ipipeif_create_pads_links(struct iss_device *iss) +int omap4iss_ipipeif_create_links(struct iss_device *iss) { struct iss_ipipeif_device *ipipeif = &iss->ipipeif; diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.h b/drivers/staging/media/omap4iss/iss_ipipeif.h index dd906b41cf9b..bad32b1d6ad8 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.h +++ b/drivers/staging/media/omap4iss/iss_ipipeif.h @@ -78,7 +78,7 @@ struct iss_ipipeif_device { struct iss_device; int omap4iss_ipipeif_init(struct iss_device *iss); -int omap4iss_ipipeif_create_pads_links(struct iss_device *iss); +int omap4iss_ipipeif_create_links(struct iss_device *iss); void omap4iss_ipipeif_cleanup(struct iss_device *iss); int omap4iss_ipipeif_register_entities(struct iss_ipipeif_device *ipipeif, struct v4l2_device *vdev); diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index fe7b253bb0d3..f1d352c711d5 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -857,12 +857,12 @@ int omap4iss_resizer_init(struct iss_device *iss) } /* - * omap4iss_resizer_create_pads_links() - RESIZER pads links creation + * omap4iss_resizer_create_links() - RESIZER pads links creation * @iss: Pointer to ISS device * * return negative error code or zero on success */ -int omap4iss_resizer_create_pads_links(struct iss_device *iss) +int omap4iss_resizer_create_links(struct iss_device *iss) { struct iss_resizer_device *resizer = &iss->resizer; diff --git a/drivers/staging/media/omap4iss/iss_resizer.h b/drivers/staging/media/omap4iss/iss_resizer.h index 98ab950253d0..8b7c5fe9ffed 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.h +++ b/drivers/staging/media/omap4iss/iss_resizer.h @@ -61,7 +61,7 @@ struct iss_resizer_device { struct iss_device; int omap4iss_resizer_init(struct iss_device *iss); -int omap4iss_resizer_create_pads_links(struct iss_device *iss); +int omap4iss_resizer_create_links(struct iss_device *iss); void omap4iss_resizer_cleanup(struct iss_device *iss); int omap4iss_resizer_register_entities(struct iss_resizer_device *resizer, struct v4l2_device *vdev); -- cgit v1.2.3 From d8a2cf41cc1c1b4af35eaf0414f83653b7b17c8b Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:32 -0200 Subject: [media] v4l: vsp1: remove pads prefix from *_create_pads_links() The functions that create entities links are called *_create_pads_links() but the "pads" prefix is redundant since the driver doesn't handle any other kind of link so it can be removed. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vsp1/vsp1_drv.c | 4 ++-- drivers/media/platform/vsp1/vsp1_rpf.c | 4 ++-- drivers/media/platform/vsp1/vsp1_rwpf.h | 4 ++-- drivers/media/platform/vsp1/vsp1_wpf.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 8f995d267646..4209d8615f72 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -261,14 +261,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) /* Create links. */ list_for_each_entry(entity, &vsp1->entities, list_dev) { if (entity->type == VSP1_ENTITY_LIF) { - ret = vsp1_wpf_create_pads_links(vsp1, entity); + ret = vsp1_wpf_create_links(vsp1, entity); if (ret < 0) goto done; continue; } if (entity->type == VSP1_ENTITY_RPF) { - ret = vsp1_rpf_create_pads_links(vsp1, entity); + ret = vsp1_rpf_create_links(vsp1, entity); if (ret < 0) goto done; continue; diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c index 847fb6d01a5a..924538223d3e 100644 --- a/drivers/media/platform/vsp1/vsp1_rpf.c +++ b/drivers/media/platform/vsp1/vsp1_rpf.c @@ -285,13 +285,13 @@ error: } /* - * vsp1_rpf_create_pads_links_create_pads_links() - RPF pads links creation + * vsp1_rpf_create_links() - RPF pads links creation * @vsp1: Pointer to VSP1 device * @entity: Pointer to VSP1 entity * * return negative error code or zero on success */ -int vsp1_rpf_create_pads_links(struct vsp1_device *vsp1, +int vsp1_rpf_create_links(struct vsp1_device *vsp1, struct vsp1_entity *entity) { struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev); diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h index 6638b3587369..731d36e5258d 100644 --- a/drivers/media/platform/vsp1/vsp1_rwpf.h +++ b/drivers/media/platform/vsp1/vsp1_rwpf.h @@ -50,9 +50,9 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev *subdev) struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index); struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index); -int vsp1_rpf_create_pads_links(struct vsp1_device *vsp1, +int vsp1_rpf_create_links(struct vsp1_device *vsp1, struct vsp1_entity *entity); -int vsp1_wpf_create_pads_links(struct vsp1_device *vsp1, +int vsp1_wpf_create_links(struct vsp1_device *vsp1, struct vsp1_entity *entity); int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c index 969278bc1d41..cbf514a6582d 100644 --- a/drivers/media/platform/vsp1/vsp1_wpf.c +++ b/drivers/media/platform/vsp1/vsp1_wpf.c @@ -285,13 +285,13 @@ error: } /* - * vsp1_wpf_create_pads_links_create_pads_links() - RPF pads links creation + * vsp1_wpf_create_links() - RPF pads links creation * @vsp1: Pointer to VSP1 device * @entity: Pointer to VSP1 entity * * return negative error code or zero on success */ -int vsp1_wpf_create_pads_links(struct vsp1_device *vsp1, +int vsp1_wpf_create_links(struct vsp1_device *vsp1, struct vsp1_entity *entity) { struct vsp1_rwpf *wpf = to_rwpf(&entity->subdev); -- cgit v1.2.3 From 1488eee3b46736eefd9aec1e9d944f7a828773b9 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:33 -0200 Subject: [media] v4l: vsp1: use else if instead of continue when creating links The for loop in the vsp1_create_entities() function that create the links, checks the entity type and call the proper link creation function but then it uses continue to force the next iteration of the loop to take place and skipping code in between that creates links for different entities types. It is more readable and easier to understand if the if else constructs is used instead of the continue statement. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vsp1/vsp1_drv.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 4209d8615f72..0b251147bfff 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -264,19 +264,15 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) ret = vsp1_wpf_create_links(vsp1, entity); if (ret < 0) goto done; - continue; - } - - if (entity->type == VSP1_ENTITY_RPF) { + } else if (entity->type == VSP1_ENTITY_RPF) { ret = vsp1_rpf_create_links(vsp1, entity); if (ret < 0) goto done; - continue; + } else { + ret = vsp1_create_links(vsp1, entity); + if (ret < 0) + goto done; } - - ret = vsp1_create_links(vsp1, entity); - if (ret < 0) - goto done; } if (vsp1->pdata.features & VSP1_HAS_LIF) { -- cgit v1.2.3 From 552faf4c083d8e86c6d86160ae3da0412280f690 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:34 -0200 Subject: [media] uvcvideo: remove pads prefix from uvc_mc_create_pads_links() The function uvc_mc_create_pads_links() creates entities links but the "pads" prefix is redundant since the driver doesn't handle any other kind of link, so it can be removed. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_entity.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 38e893a1408b..33119dcb7cec 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -32,7 +32,7 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain, return v4l2_device_register_subdev(&chain->dev->vdev, &entity->subdev); } -static int uvc_mc_create_pads_links(struct uvc_video_chain *chain, +static int uvc_mc_create_links(struct uvc_video_chain *chain, struct uvc_entity *entity) { const u32 flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE; @@ -131,9 +131,9 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain) } list_for_each_entry(entity, &chain->entities, chain) { - ret = uvc_mc_create_pads_links(chain, entity); + ret = uvc_mc_create_links(chain, entity); if (ret < 0) { - uvc_printk(KERN_INFO, "Failed to create pads links for " + uvc_printk(KERN_INFO, "Failed to create links for " "entity %u\n", entity->id); return ret; } -- cgit v1.2.3 From 1cb2f6f4b1652ad4e19894a4b4b82b0c2ea8a4b6 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:35 -0200 Subject: [media] uvcvideo: register entity subdev on init The uvc_mc_register_entities() function iterated over the entities three times to initialize the entities, register the subdev for the ones whose type was UVC_TT_STREAMING and to create the entities links. But this can be simplied by merging the init and registration logic in a single loop. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/uvc/uvc_entity.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 33119dcb7cec..ac386bb547e6 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -19,19 +19,6 @@ #include "uvcvideo.h" -/* ------------------------------------------------------------------------ - * Video subdevices registration and unregistration - */ - -static int uvc_mc_register_entity(struct uvc_video_chain *chain, - struct uvc_entity *entity) -{ - if (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING) - return 0; - - return v4l2_device_register_subdev(&chain->dev->vdev, &entity->subdev); -} - static int uvc_mc_create_links(struct uvc_video_chain *chain, struct uvc_entity *entity) { @@ -85,7 +72,8 @@ void uvc_mc_cleanup_entity(struct uvc_entity *entity) media_entity_cleanup(&entity->vdev->entity); } -static int uvc_mc_init_entity(struct uvc_entity *entity) +static int uvc_mc_init_entity(struct uvc_video_chain *chain, + struct uvc_entity *entity) { int ret; @@ -96,6 +84,12 @@ static int uvc_mc_init_entity(struct uvc_entity *entity) ret = media_entity_pads_init(&entity->subdev.entity, entity->num_pads, entity->pads); + + if (ret < 0) + return ret; + + ret = v4l2_device_register_subdev(&chain->dev->vdev, + &entity->subdev); } else if (entity->vdev != NULL) { ret = media_entity_pads_init(&entity->vdev->entity, entity->num_pads, entity->pads); @@ -113,7 +107,7 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain) int ret; list_for_each_entry(entity, &chain->entities, chain) { - ret = uvc_mc_init_entity(entity); + ret = uvc_mc_init_entity(chain, entity); if (ret < 0) { uvc_printk(KERN_INFO, "Failed to initialize entity for " "entity %u\n", entity->id); @@ -121,15 +115,6 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain) } } - list_for_each_entry(entity, &chain->entities, chain) { - ret = uvc_mc_register_entity(chain, entity); - if (ret < 0) { - uvc_printk(KERN_INFO, "Failed to register entity for " - "entity %u\n", entity->id); - return ret; - } - } - list_for_each_entry(entity, &chain->entities, chain) { ret = uvc_mc_create_links(chain, entity); if (ret < 0) { -- cgit v1.2.3 From 313895fba2040c7f223db3d6aa6cb3b5c5022042 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 15:16:36 -0200 Subject: [media] media-entity: remove unneded enclosing parenthesis Commit 86ee417578a2 ("[media] media: convert links from array to list") had many changes that were automated using coccinelle but the semantic patch was not smart enough to rely on operators precedence and avoid using unnecessary enclosing parenthesis. This patch removes them since are not needed. Suggested-by: Laurent Pinchart Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index ada2b44ea4e1..181ca0de6e52 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -225,7 +225,7 @@ static void stack_push(struct media_entity_graph *graph, return; } graph->top++; - graph->stack[graph->top].link = (&entity->links)->next; + graph->stack[graph->top].link = entity->links.next; graph->stack[graph->top].entity = entity; } @@ -268,7 +268,7 @@ media_entity_graph_walk_next(struct media_entity_graph *graph) * top of the stack until no more entities on the level can be * found. */ - while (link_top(graph) != &(stack_top(graph)->links)) { + while (link_top(graph) != &stack_top(graph)->links) { struct media_entity *entity = stack_top(graph); struct media_link *link; struct media_entity *next; -- cgit v1.2.3 From 82ae2a50597565cbb2c758b44a3f39adb158ef0a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 11 Dec 2015 18:09:13 -0200 Subject: [media] media: move MEDIA_LNK_FL_INTERFACE_LINK logic to link creation Instead of flagging an interface link as MEDIA_LNK_FL_INTERFACE_LINK only when returning to userspace, do it at link creation time. That would allow using such flag internally, and cleans up a little bit the code for G_TOPOLOGY ioctl. [mchehab@osg.samsung.com: folded with a fixup from Dan Carpenter, replacing & by &&] Suggested-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 3 --- drivers/media/media-entity.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 6406914a9bf5..c12481c753a0 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -361,9 +361,6 @@ static long __media_device_get_topology(struct media_device *mdev, klink.sink_id = link->gobj1->id; klink.flags = link->flags; - if (media_type(link->gobj0) != MEDIA_GRAPH_PAD) - klink.flags |= MEDIA_LNK_FL_INTERFACE_LINK; - if (copy_to_user(ulink, &klink, sizeof(klink))) ret = -EFAULT; ulink++; diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 181ca0de6e52..6926e0685d0a 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -526,7 +526,7 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, link->source = &source->pads[source_pad]; link->sink = &sink->pads[sink_pad]; - link->flags = flags; + link->flags = flags & ~MEDIA_LNK_FL_INTERFACE_LINK; /* Initialize graph object embedded at the new link */ media_gobj_create(source->graph_obj.mdev, MEDIA_GRAPH_LINK, @@ -756,7 +756,7 @@ struct media_link *media_create_intf_link(struct media_entity *entity, link->intf = intf; link->entity = entity; - link->flags = flags; + link->flags = flags | MEDIA_LNK_FL_INTERFACE_LINK; /* Initialize graph object embedded at the new link */ media_gobj_create(intf->graph_obj.mdev, MEDIA_GRAPH_LINK, -- cgit v1.2.3 From fdc40b5e95ac6480f6160081774aa2ec24784ccb Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 12 Dec 2015 08:25:44 -0200 Subject: [media] dvbdev: Document the new MC-related fields The Media Controller next gen patchset added several new fields to be used with it. Document them. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index de85ba0f570a..abee18a402e1 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -120,6 +120,11 @@ struct dvb_adapter { * @entity: pointer to struct media_entity associated with the device node * @pads: pointer to struct media_pad associated with @entity; * @priv: private data + * @intf_devnode: Pointer to media_intf_devnode. Used by the dvbdev core to + * store the MC device node interface + * @tsout_num_entities: Number of Transport Stream output entities + * @tsout_entity: array with MC entities associated to each TS output node + * @tsout_pads: array with the source pads for each @tsout_entity * * This structure is used by the DVB core (frontend, CA, net, demux) in * order to create the device nodes. Usually, driver should not initialize @@ -188,8 +193,11 @@ int dvb_unregister_adapter(struct dvb_adapter *adap); * stored * @template: Template used to create &pdvbdev; * @priv: private data - * @type: type of the device: DVB_DEVICE_SEC, DVB_DEVICE_FRONTEND, - * DVB_DEVICE_DEMUX, DVB_DEVICE_DVR, DVB_DEVICE_CA, DVB_DEVICE_NET + * @type: type of the device: %DVB_DEVICE_SEC, %DVB_DEVICE_FRONTEND, + * %DVB_DEVICE_DEMUX, %DVB_DEVICE_DVR, %DVB_DEVICE_CA, + * %DVB_DEVICE_NET + * @demux_sink_pads: Number of demux outputs, to be used to create the TS + * outputs via the Media Controller. */ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, -- cgit v1.2.3 From 8aaf62b5b9bef73978973e4b825c7818528d3ca2 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Sun, 29 Nov 2015 17:20:02 -0200 Subject: [media] media: Enforce single entity->pipe in a pipeline If a different entity->pipe in a pipeline was encountered, a warning was issued but the execution continued as if nothing had happened. Return an error instead right there. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 6926e0685d0a..4822763dcefa 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -323,7 +323,12 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS); entity->stream_count++; - WARN_ON(entity->pipe && entity->pipe != pipe); + + if (WARN_ON(entity->pipe && entity->pipe != pipe)) { + ret = -EBUSY; + goto error; + } + entity->pipe = pipe; /* Already streaming --- no need to check. */ -- cgit v1.2.3 From b6e4ca8129ad65a0b1552586c1d42d2fd219661e Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 13 Dec 2015 08:36:58 -0200 Subject: [media] media-device.h: document the last functions Add kernel-doc documentation for media_device_get_devres and media_device_find_devres. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 7 ------- include/media/media-device.h | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index c12481c753a0..ca16bd3091bd 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -689,10 +689,6 @@ static void media_device_release_devres(struct device *dev, void *res) { } -/* - * media_device_get_devres() - get media device as device resource - * creates if one doesn't exist -*/ struct media_device *media_device_get_devres(struct device *dev) { struct media_device *mdev; @@ -709,9 +705,6 @@ struct media_device *media_device_get_devres(struct device *dev) } EXPORT_SYMBOL_GPL(media_device_get_devres); -/* - * media_device_find_devres() - find media device as device resource -*/ struct media_device *media_device_find_devres(struct device *dev) { return devres_find(dev, media_device_release_devres, NULL, NULL); diff --git a/include/media/media-device.h b/include/media/media-device.h index 215a0d88241d..ebc2f3a239eb 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -449,7 +449,29 @@ int __must_check media_device_register_entity(struct media_device *mdev, * the driver if required. */ void media_device_unregister_entity(struct media_entity *entity); + +/** + * media_device_get_devres() - get media device as device resource + * creates if one doesn't exist + * + * @dev: pointer to struct &device. + * + * Sometimes, the media controller &media_device needs to be shared by more + * than one driver. This function adds support for that, by dynamically + * allocating the &media_device and allowing it to be obtained from the + * struct &device associated with the common device where all sub-device + * components belong. So, for example, on an USB device with multiple + * interfaces, each interface may be handled by a separate per-interface + * drivers. While each interface have its own &device, they all share a + * common &device associated with the hole USB device. + */ struct media_device *media_device_get_devres(struct device *dev); + +/** + * media_device_find_devres() - find media device as device resource + * + * @dev: pointer to struct &device. + */ struct media_device *media_device_find_devres(struct device *dev); /* Iterate over all entities. */ -- cgit v1.2.3 From fe3c565e4cbcb2adeef063accc7852de739aaa36 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 13 Dec 2015 08:40:45 -0200 Subject: [media] media-devnode: move kernel-doc documentation to the header As we're using the headers file only for documentation, move the two kernel-doc macros to the header, and fix it to avoid warnings. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-devnode.c | 24 ------------------------ include/media/media-devnode.h | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 24 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c index ebf9626e5ae5..cea35bf20011 100644 --- a/drivers/media/media-devnode.c +++ b/drivers/media/media-devnode.c @@ -217,20 +217,6 @@ static const struct file_operations media_devnode_fops = { .llseek = no_llseek, }; -/** - * media_devnode_register - register a media device node - * @mdev: media device node structure we want to register - * - * The registration code assigns minor numbers and registers the new device node - * with the kernel. An error is returned if no free minor number can be found, - * or if the registration of the device node fails. - * - * Zero is returned on success. - * - * Note that if the media_devnode_register call fails, the release() callback of - * the media_devnode structure is *not* called, so the caller is responsible for - * freeing any data. - */ int __must_check media_devnode_register(struct media_devnode *mdev, struct module *owner) { @@ -285,16 +271,6 @@ error: return ret; } -/** - * media_devnode_unregister - unregister a media device node - * @mdev: the device node to unregister - * - * This unregisters the passed device. Future open calls will be met with - * errors. - * - * This function can safely be called if the device node has never been - * registered or has already been unregistered. - */ void media_devnode_unregister(struct media_devnode *mdev) { /* Check if mdev was ever registered at all */ diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h index 17ddae32060d..77e9d3159be8 100644 --- a/include/media/media-devnode.h +++ b/include/media/media-devnode.h @@ -86,8 +86,35 @@ struct media_devnode { /* dev to media_devnode */ #define to_media_devnode(cd) container_of(cd, struct media_devnode, dev) +/** + * media_devnode_register - register a media device node + * + * @mdev: media device node structure we want to register + * @owner: should be filled with %THIS_MODULE + * + * The registration code assigns minor numbers and registers the new device node + * with the kernel. An error is returned if no free minor number can be found, + * or if the registration of the device node fails. + * + * Zero is returned on success. + * + * Note that if the media_devnode_register call fails, the release() callback of + * the media_devnode structure is *not* called, so the caller is responsible for + * freeing any data. + */ int __must_check media_devnode_register(struct media_devnode *mdev, struct module *owner); + +/** + * media_devnode_unregister - unregister a media device node + * @mdev: the device node to unregister + * + * This unregisters the passed device. Future open calls will be met with + * errors. + * + * This function can safely be called if the device node has never been + * registered or has already been unregistered. + */ void media_devnode_unregister(struct media_devnode *mdev); static inline struct media_devnode *media_devnode_data(struct file *filp) -- cgit v1.2.3 From 5c883edb5b2c34e96e57037c95f9a72c4feccc50 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 15 Dec 2015 07:58:18 -0200 Subject: [media] media-entity: use mutes for link setup Changeset f8fd4c61b5ae ("[media] media-entity: protect object creation/removal using spin lock") changed the object creation/removal protection to spin lock, as this is what's used on media-device, keeping the mutex reserved for graph traversal routines. However, it also changed the link setup, by mistake. This could cause troubles, as the link setup can affect the graph traversal, and this is likely the reason for a mutex there. So, revert media_entity_setup_link() to use mutex. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 4822763dcefa..f88740b12879 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -662,9 +662,9 @@ int media_entity_setup_link(struct media_link *link, u32 flags) { int ret; - spin_lock(&link->source->entity->graph_obj.mdev->lock); + mutex_lock(&link->graph_obj.mdev->graph_mutex); ret = __media_entity_setup_link(link, flags); - spin_unlock(&link->source->entity->graph_obj.mdev->lock); + mutex_unlock(&link->graph_obj.mdev->graph_mutex); return ret; } -- cgit v1.2.3 From cc4a82581cb604444b0f9f2e7d999624964695e2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 15 Dec 2015 08:01:13 -0200 Subject: [media] media-entity: cache media_device on object removal As pointed by Dan, the commit f8fd4c61b5ae ("[media] media-entity: protect object creation/removal using spin lock")' leads to the following static checker warning: drivers/media/media-entity.c:781 media_remove_intf_link() error: dereferencing freed memory 'link' drivers/media/media-entity.c 777 void media_remove_intf_link(struct media_link *link) 778 { 779 spin_lock(&link->graph_obj.mdev->lock); 780 __media_remove_intf_link(link); 781 spin_unlock(&link->graph_obj.mdev->lock); In practice, I didn't see any troubles even with KASAN enabled. I guess gcc optimizer internally cached the mdev reference, instead of getting it twice. Yet, it is a very bad idea to rely on such optimization. So, let's fix the code. Reported-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index f88740b12879..13c8ca11f169 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -580,13 +580,15 @@ EXPORT_SYMBOL_GPL(__media_entity_remove_links); void media_entity_remove_links(struct media_entity *entity) { + struct media_device *mdev = entity->graph_obj.mdev; + /* Do nothing if the entity is not registered. */ - if (entity->graph_obj.mdev == NULL) + if (mdev == NULL) return; - spin_lock(&entity->graph_obj.mdev->lock); + spin_lock(&mdev->lock); __media_entity_remove_links(entity); - spin_unlock(&entity->graph_obj.mdev->lock); + spin_unlock(&mdev->lock); } EXPORT_SYMBOL_GPL(media_entity_remove_links); @@ -781,9 +783,15 @@ EXPORT_SYMBOL_GPL(__media_remove_intf_link); void media_remove_intf_link(struct media_link *link) { - spin_lock(&link->graph_obj.mdev->lock); + struct media_device *mdev = link->graph_obj.mdev; + + /* Do nothing if the intf is not registered. */ + if (mdev == NULL) + return; + + spin_lock(&mdev->lock); __media_remove_intf_link(link); - spin_unlock(&link->graph_obj.mdev->lock); + spin_unlock(&mdev->lock); } EXPORT_SYMBOL_GPL(media_remove_intf_link); @@ -799,12 +807,14 @@ EXPORT_SYMBOL_GPL(__media_remove_intf_links); void media_remove_intf_links(struct media_interface *intf) { + struct media_device *mdev = intf->graph_obj.mdev; + /* Do nothing if the intf is not registered. */ - if (intf->graph_obj.mdev == NULL) + if (mdev == NULL) return; - spin_lock(&intf->graph_obj.mdev->lock); + spin_lock(&mdev->lock); __media_remove_intf_links(intf); - spin_unlock(&intf->graph_obj.mdev->lock); + spin_unlock(&mdev->lock); } EXPORT_SYMBOL_GPL(media_remove_intf_links); -- cgit v1.2.3 From 223d19c56651a0204253035f9ed28834653d2b4b Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 20:57:07 -0200 Subject: [media] media-device: check before unregister if mdev was registered Most media functions that unregister, check if the corresponding register function succeed before. So these functions can safely be called even if a registration was never made or the component as already been unregistered. Add the same check to media_device_unregister() function for consistency. This will also allow to split the media_device_register() function in an initialization and registration functions without the need to change the generic cleanup functions and error code paths for all the media drivers. Suggested-by: Sakari Ailus Signed-off-by: Javier Martinez Canillas Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index ca16bd3091bd..da4126863ecc 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -577,6 +577,8 @@ EXPORT_SYMBOL_GPL(__media_device_register); * media_device_unregister - unregister a media device * @mdev: The media device * + * It is safe to call this function on an unregistered + * (but initialised) media device. */ void media_device_unregister(struct media_device *mdev) { @@ -584,6 +586,10 @@ void media_device_unregister(struct media_device *mdev) struct media_entity *next; struct media_interface *intf, *tmp_intf; + /* Check if mdev was ever registered at all */ + if (!media_devnode_is_registered(&mdev->devnode)) + return; + /* Remove all entities from the media device */ list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) media_device_unregister_entity(entity); -- cgit v1.2.3 From b2ed8af910a436e12038f8ec8ca6c039f43767a4 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 15 Dec 2015 08:26:52 -0200 Subject: [media] media-device: move media entity register/unregister functions media entity register and unregister functions are called by media device register/unregister. Move them to occur earlier, as we'll need an unlocked version of media_device_entity_unregister() and we don't want to add a function prototype without needing it. No functional changes. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 160 +++++++++++++++++++++---------------------- 1 file changed, 80 insertions(+), 80 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index da4126863ecc..1222fa642ad8 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -528,6 +528,86 @@ static void media_device_release(struct media_devnode *mdev) dev_dbg(mdev->parent, "Media device released\n"); } +/** + * media_device_register_entity - Register an entity with a media device + * @mdev: The media device + * @entity: The entity + */ +int __must_check media_device_register_entity(struct media_device *mdev, + struct media_entity *entity) +{ + unsigned int i; + + if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN || + entity->function == MEDIA_ENT_F_UNKNOWN) + dev_warn(mdev->dev, + "Entity type for entity %s was not initialized!\n", + entity->name); + + /* Warn if we apparently re-register an entity */ + WARN_ON(entity->graph_obj.mdev != NULL); + entity->graph_obj.mdev = mdev; + INIT_LIST_HEAD(&entity->links); + entity->num_links = 0; + entity->num_backlinks = 0; + + spin_lock(&mdev->lock); + /* Initialize media_gobj embedded at the entity */ + media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); + + /* Initialize objects at the pads */ + for (i = 0; i < entity->num_pads; i++) + media_gobj_create(mdev, MEDIA_GRAPH_PAD, + &entity->pads[i].graph_obj); + + spin_unlock(&mdev->lock); + + return 0; +} +EXPORT_SYMBOL_GPL(media_device_register_entity); + +/** + * media_device_unregister_entity - Unregister an entity + * @entity: The entity + * + * If the entity has never been registered this function will return + * immediately. + */ +void media_device_unregister_entity(struct media_entity *entity) +{ + struct media_device *mdev = entity->graph_obj.mdev; + struct media_link *link, *tmp; + struct media_interface *intf; + unsigned int i; + + if (mdev == NULL) + return; + + spin_lock(&mdev->lock); + + /* Remove all interface links pointing to this entity */ + list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { + list_for_each_entry_safe(link, tmp, &intf->links, list) { + if (link->entity == entity) + __media_remove_intf_link(link); + } + } + + /* Remove all data links that belong to this entity */ + __media_entity_remove_links(entity); + + /* Remove all pads that belong to this entity */ + for (i = 0; i < entity->num_pads; i++) + media_gobj_destroy(&entity->pads[i].graph_obj); + + /* Remove the entity */ + media_gobj_destroy(&entity->graph_obj); + + spin_unlock(&mdev->lock); + entity->graph_obj.mdev = NULL; +} +EXPORT_SYMBOL_GPL(media_device_unregister_entity); + /** * media_device_register - register a media device * @mdev: The media device @@ -611,86 +691,6 @@ void media_device_unregister(struct media_device *mdev) } EXPORT_SYMBOL_GPL(media_device_unregister); -/** - * media_device_register_entity - Register an entity with a media device - * @mdev: The media device - * @entity: The entity - */ -int __must_check media_device_register_entity(struct media_device *mdev, - struct media_entity *entity) -{ - unsigned int i; - - if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN || - entity->function == MEDIA_ENT_F_UNKNOWN) - dev_warn(mdev->dev, - "Entity type for entity %s was not initialized!\n", - entity->name); - - /* Warn if we apparently re-register an entity */ - WARN_ON(entity->graph_obj.mdev != NULL); - entity->graph_obj.mdev = mdev; - INIT_LIST_HEAD(&entity->links); - entity->num_links = 0; - entity->num_backlinks = 0; - - spin_lock(&mdev->lock); - /* Initialize media_gobj embedded at the entity */ - media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); - - /* Initialize objects at the pads */ - for (i = 0; i < entity->num_pads; i++) - media_gobj_create(mdev, MEDIA_GRAPH_PAD, - &entity->pads[i].graph_obj); - - spin_unlock(&mdev->lock); - - return 0; -} -EXPORT_SYMBOL_GPL(media_device_register_entity); - -/** - * media_device_unregister_entity - Unregister an entity - * @entity: The entity - * - * If the entity has never been registered this function will return - * immediately. - */ -void media_device_unregister_entity(struct media_entity *entity) -{ - struct media_device *mdev = entity->graph_obj.mdev; - struct media_link *link, *tmp; - struct media_interface *intf; - unsigned int i; - - if (mdev == NULL) - return; - - spin_lock(&mdev->lock); - - /* Remove all interface links pointing to this entity */ - list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { - list_for_each_entry_safe(link, tmp, &intf->links, list) { - if (link->entity == entity) - __media_remove_intf_link(link); - } - } - - /* Remove all data links that belong to this entity */ - __media_entity_remove_links(entity); - - /* Remove all pads that belong to this entity */ - for (i = 0; i < entity->num_pads; i++) - media_gobj_destroy(&entity->pads[i].graph_obj); - - /* Remove the entity */ - media_gobj_destroy(&entity->graph_obj); - - spin_unlock(&mdev->lock); - entity->graph_obj.mdev = NULL; -} -EXPORT_SYMBOL_GPL(media_device_unregister_entity); - static void media_device_release_devres(struct device *dev, void *res) { } -- cgit v1.2.3 From 821ed3662913faca0653c201fa9e36fbab81f17c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 15 Dec 2015 08:36:51 -0200 Subject: [media] media-device: better lock media_device_unregister() If media_device_unregister() is called by two different drivers, a race condition may happen, as the check if the device is not registered is not protected. Move the spin_lock() to happen earlier in the function, in order to prevent such race condition. Reported-by: Shuah Khan Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 1222fa642ad8..189c2ba8c3d3 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -573,18 +573,13 @@ EXPORT_SYMBOL_GPL(media_device_register_entity); * If the entity has never been registered this function will return * immediately. */ -void media_device_unregister_entity(struct media_entity *entity) +static void __media_device_unregister_entity(struct media_entity *entity) { struct media_device *mdev = entity->graph_obj.mdev; struct media_link *link, *tmp; struct media_interface *intf; unsigned int i; - if (mdev == NULL) - return; - - spin_lock(&mdev->lock); - /* Remove all interface links pointing to this entity */ list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { list_for_each_entry_safe(link, tmp, &intf->links, list) { @@ -603,11 +598,23 @@ void media_device_unregister_entity(struct media_entity *entity) /* Remove the entity */ media_gobj_destroy(&entity->graph_obj); - spin_unlock(&mdev->lock); entity->graph_obj.mdev = NULL; } + +void media_device_unregister_entity(struct media_entity *entity) +{ + struct media_device *mdev = entity->graph_obj.mdev; + + if (mdev == NULL) + return; + + spin_lock(&mdev->lock); + __media_device_unregister_entity(entity); + spin_unlock(&mdev->lock); +} EXPORT_SYMBOL_GPL(media_device_unregister_entity); + /** * media_device_register - register a media device * @mdev: The media device @@ -666,22 +673,29 @@ void media_device_unregister(struct media_device *mdev) struct media_entity *next; struct media_interface *intf, *tmp_intf; + if (mdev == NULL) + return; + + spin_lock(&mdev->lock); + /* Check if mdev was ever registered at all */ - if (!media_devnode_is_registered(&mdev->devnode)) + if (!media_devnode_is_registered(&mdev->devnode)) { + spin_unlock(&mdev->lock); return; + } /* Remove all entities from the media device */ list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list) - media_device_unregister_entity(entity); + __media_device_unregister_entity(entity); /* Remove all interfaces from the media device */ - spin_lock(&mdev->lock); list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces, graph_obj.list) { __media_remove_intf_links(intf); media_gobj_destroy(&intf->graph_obj); kfree(intf); } + spin_unlock(&mdev->lock); device_remove_file(&mdev->devnode.dev, &dev_attr_model); -- cgit v1.2.3 From 9832e155f1ed3030fdfaa19e72c06472dc2ecb1d Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 20:57:08 -0200 Subject: [media] media-device: split media initialization and registration The media device node is registered and so made visible to user-space before entities are registered and links created which means that the media graph obtained by user-space could be only partially enumerated if that happens too early before all the graph has been created. To avoid this race condition, split the media init and registration in separate functions and only register the media device node when all the pending subdevices have been registered, either explicitly by the driver or asynchronously using v4l2_async_register_subdev(). The media_device_register() had a check for drivers not filling dev and model fields but all drivers in mainline set them and not doing it will be a driver bug so change the function return to void and add a BUG_ON() for dev being NULL instead. Also, add a media_device_cleanup() function that will destroy the graph_mutex that is initialized in media_device_init(). [mchehab@osg.samsung.com: Fix compilation if !CONFIG_MEDIA_CONTROLLER and remove two warnings added by this changeset] Suggested-by: Sakari Ailus Signed-off-by: Javier Martinez Canillas Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smsdvb-main.c | 1 + drivers/media/media-device.c | 37 +++++++++++++++++++++------ drivers/media/platform/exynos4-is/media-dev.c | 15 +++++------ drivers/media/platform/omap3isp/isp.c | 14 +++++----- drivers/media/platform/s3c-camif/camif-core.c | 15 +++++++---- drivers/media/platform/vsp1/vsp1_drv.c | 12 ++++----- drivers/media/platform/xilinx/xilinx-vipp.c | 12 +++------ drivers/media/usb/au0828/au0828-core.c | 29 +++++++++++---------- drivers/media/usb/cx231xx/cx231xx-cards.c | 32 +++++++++++------------ drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 23 +++++++++-------- drivers/media/usb/dvb-usb/dvb-usb-dvb.c | 25 ++++++++++-------- drivers/media/usb/siano/smsusb.c | 5 ++-- drivers/media/usb/uvc/uvc_driver.c | 11 +++++--- include/media/media-device.h | 26 +++++++++++++++++++ 14 files changed, 158 insertions(+), 99 deletions(-) (limited to 'drivers') diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c index ab345490a43a..8a1ea2192439 100644 --- a/drivers/media/common/siano/smsdvb-main.c +++ b/drivers/media/common/siano/smsdvb-main.c @@ -617,6 +617,7 @@ static void smsdvb_media_device_unregister(struct smsdvb_client_t *client) if (!coredev->media_dev) return; media_device_unregister(coredev->media_dev); + media_device_cleanup(coredev->media_dev); kfree(coredev->media_dev); coredev->media_dev = NULL; #endif diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 189c2ba8c3d3..b718c783debd 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -616,7 +616,7 @@ EXPORT_SYMBOL_GPL(media_device_unregister_entity); /** - * media_device_register - register a media device + * media_device_init() - initialize a media device * @mdev: The media device * * The caller is responsible for initializing the media device before @@ -625,14 +625,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister_entity); * - dev must point to the parent device * - model must be filled with the device model name */ -int __must_check __media_device_register(struct media_device *mdev, - struct module *owner) +void media_device_init(struct media_device *mdev) { - int ret; - - if (WARN_ON(mdev->dev == NULL || mdev->model[0] == 0)) - return -EINVAL; - INIT_LIST_HEAD(&mdev->entities); INIT_LIST_HEAD(&mdev->interfaces); INIT_LIST_HEAD(&mdev->pads); @@ -640,6 +634,33 @@ int __must_check __media_device_register(struct media_device *mdev, spin_lock_init(&mdev->lock); mutex_init(&mdev->graph_mutex); + dev_dbg(mdev->dev, "Media device initialized\n"); +} +EXPORT_SYMBOL_GPL(media_device_init); + +/** + * media_device_cleanup() - Cleanup a media device + * @mdev: The media device + * + */ +void media_device_cleanup(struct media_device *mdev) +{ + mutex_destroy(&mdev->graph_mutex); +} +EXPORT_SYMBOL_GPL(media_device_cleanup); + +/** + * __media_device_register() - register a media device + * @mdev: The media device + * @owner: The module owner + * + * returns zero on success or a negative error code. + */ +int __must_check __media_device_register(struct media_device *mdev, + struct module *owner) +{ + int ret; + /* Register the device node. */ mdev->devnode.fops = &media_device_fops; mdev->devnode.parent = mdev->dev; diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index a61ecedc1201..27663dd45294 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1313,7 +1313,10 @@ static int subdev_notifier_complete(struct v4l2_async_notifier *notifier) ret = v4l2_device_register_subdev_nodes(&fmd->v4l2_dev); unlock: mutex_unlock(&fmd->media_dev.graph_mutex); - return ret; + if (ret < 0) + return ret; + + return media_device_register(&fmd->media_dev); } static int fimc_md_probe(struct platform_device *pdev) @@ -1350,11 +1353,7 @@ static int fimc_md_probe(struct platform_device *pdev) return ret; } - ret = media_device_register(&fmd->media_dev); - if (ret < 0) { - v4l2_err(v4l2_dev, "Failed to register media device: %d\n", ret); - goto err_v4l2_dev; - } + media_device_init(&fmd->media_dev); ret = fimc_md_get_clocks(fmd); if (ret) @@ -1424,8 +1423,7 @@ err_clk: err_m_ent: fimc_md_unregister_entities(fmd); err_md: - media_device_unregister(&fmd->media_dev); -err_v4l2_dev: + media_device_cleanup(&fmd->media_dev); v4l2_device_unregister(&fmd->v4l2_dev); return ret; } @@ -1445,6 +1443,7 @@ static int fimc_md_remove(struct platform_device *pdev) fimc_md_unregister_entities(fmd); fimc_md_pipelines_free(fmd); media_device_unregister(&fmd->media_dev); + media_device_cleanup(&fmd->media_dev); fimc_md_put_clocks(fmd); return 0; diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 8226eca83327..942b189c0eca 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -1793,6 +1793,7 @@ static void isp_unregister_entities(struct isp_device *isp) v4l2_device_unregister(&isp->v4l2_dev); media_device_unregister(&isp->media_dev); + media_device_cleanup(&isp->media_dev); } static int isp_link_entity( @@ -1875,12 +1876,7 @@ static int isp_register_entities(struct isp_device *isp) sizeof(isp->media_dev.model)); isp->media_dev.hw_revision = isp->revision; isp->media_dev.link_notify = isp_pipeline_link_notify; - ret = media_device_register(&isp->media_dev); - if (ret < 0) { - dev_err(isp->dev, "%s: Media device registration failed (%d)\n", - __func__, ret); - return ret; - } + media_device_init(&isp->media_dev); isp->v4l2_dev.mdev = &isp->media_dev; ret = v4l2_device_register(isp->dev, &isp->v4l2_dev); @@ -2365,7 +2361,11 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) } } - return v4l2_device_register_subdev_nodes(v4l2_dev); + ret = v4l2_device_register_subdev_nodes(&isp->v4l2_dev); + if (ret < 0) + return ret; + + return media_device_register(&isp->media_dev); } /* diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c index 8649d4c0e90d..ea02b7ef2119 100644 --- a/drivers/media/platform/s3c-camif/camif-core.c +++ b/drivers/media/platform/s3c-camif/camif-core.c @@ -305,7 +305,7 @@ static void camif_unregister_media_entities(struct camif_dev *camif) /* * Media device */ -static int camif_media_dev_register(struct camif_dev *camif) +static int camif_media_dev_init(struct camif_dev *camif) { struct media_device *md = &camif->media_dev; struct v4l2_device *v4l2_dev = &camif->v4l2_dev; @@ -328,9 +328,7 @@ static int camif_media_dev_register(struct camif_dev *camif) if (ret < 0) return ret; - ret = media_device_register(md); - if (ret < 0) - v4l2_device_unregister(v4l2_dev); + media_device_init(md); return ret; } @@ -483,7 +481,7 @@ static int s3c_camif_probe(struct platform_device *pdev) goto err_alloc; } - ret = camif_media_dev_register(camif); + ret = camif_media_dev_init(camif); if (ret < 0) goto err_mdev; @@ -510,6 +508,11 @@ static int s3c_camif_probe(struct platform_device *pdev) goto err_unlock; mutex_unlock(&camif->media_dev.graph_mutex); + + ret = media_device_register(&camif->media_dev); + if (ret < 0) + goto err_sens; + pm_runtime_put(dev); return 0; @@ -518,6 +521,7 @@ err_unlock: err_sens: v4l2_device_unregister(&camif->v4l2_dev); media_device_unregister(&camif->media_dev); + media_device_cleanup(&camif->media_dev); camif_unregister_media_entities(camif); err_mdev: vb2_dma_contig_cleanup_ctx(camif->alloc_ctx); @@ -539,6 +543,7 @@ static int s3c_camif_remove(struct platform_device *pdev) struct s3c_camif_plat_data *pdata = &camif->pdata; media_device_unregister(&camif->media_dev); + media_device_cleanup(&camif->media_dev); camif_unregister_media_entities(camif); v4l2_device_unregister(&camif->v4l2_dev); diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index 0b251147bfff..42dff9d020af 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -127,6 +127,7 @@ static void vsp1_destroy_entities(struct vsp1_device *vsp1) v4l2_device_unregister(&vsp1->v4l2_dev); media_device_unregister(&vsp1->media_dev); + media_device_cleanup(&vsp1->media_dev); } static int vsp1_create_entities(struct vsp1_device *vsp1) @@ -141,12 +142,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) strlcpy(mdev->model, "VSP1", sizeof(mdev->model)); snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s", dev_name(mdev->dev)); - ret = media_device_register(mdev); - if (ret < 0) { - dev_err(vsp1->dev, "media device registration failed (%d)\n", - ret); - return ret; - } + media_device_init(mdev); vdev->mdev = mdev; ret = v4l2_device_register(vsp1->dev, vdev); @@ -284,6 +280,10 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) } ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev); + if (ret < 0) + goto done; + + ret = media_device_register(mdev); done: if (ret < 0) diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index 2352f7e5a6a3..e795a4501e8b 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -311,7 +311,7 @@ static int xvip_graph_notify_complete(struct v4l2_async_notifier *notifier) if (ret < 0) dev_err(xdev->dev, "failed to register subdev nodes\n"); - return ret; + return media_device_register(&xdev->media_dev); } static int xvip_graph_notify_bound(struct v4l2_async_notifier *notifier, @@ -573,6 +573,7 @@ static void xvip_composite_v4l2_cleanup(struct xvip_composite_device *xdev) { v4l2_device_unregister(&xdev->v4l2_dev); media_device_unregister(&xdev->media_dev); + media_device_cleanup(&xdev->media_dev); } static int xvip_composite_v4l2_init(struct xvip_composite_device *xdev) @@ -584,19 +585,14 @@ static int xvip_composite_v4l2_init(struct xvip_composite_device *xdev) sizeof(xdev->media_dev.model)); xdev->media_dev.hw_revision = 0; - ret = media_device_register(&xdev->media_dev); - if (ret < 0) { - dev_err(xdev->dev, "media device registration failed (%d)\n", - ret); - return ret; - } + media_device_init(&xdev->media_dev); xdev->v4l2_dev.mdev = &xdev->media_dev; ret = v4l2_device_register(xdev->dev, &xdev->v4l2_dev); if (ret < 0) { dev_err(xdev->dev, "V4L2 device registration failed (%d)\n", ret); - media_device_unregister(&xdev->media_dev); + media_device_cleanup(&xdev->media_dev); return ret; } diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 1b207fa16a55..fbdaeb206565 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -136,6 +136,7 @@ static void au0828_unregister_media_device(struct au0828_dev *dev) #ifdef CONFIG_MEDIA_CONTROLLER if (dev->media_dev) { media_device_unregister(dev->media_dev); + media_device_cleanup(dev->media_dev); kfree(dev->media_dev); dev->media_dev = NULL; } @@ -216,12 +217,11 @@ static void au0828_usb_disconnect(struct usb_interface *interface) au0828_usb_release(dev); } -static void au0828_media_device_register(struct au0828_dev *dev, - struct usb_device *udev) +static void au0828_media_device_init(struct au0828_dev *dev, + struct usb_device *udev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev; - int ret; mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) @@ -239,14 +239,7 @@ static void au0828_media_device_register(struct au0828_dev *dev, mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); mdev->driver_version = LINUX_VERSION_CODE; - ret = media_device_register(mdev); - if (ret) { - pr_err( - "Couldn't create a media device. Error: %d\n", - ret); - kfree(mdev); - return; - } + media_device_init(mdev); dev->media_dev = mdev; #endif @@ -374,8 +367,8 @@ static int au0828_usb_probe(struct usb_interface *interface, dev->boardnr = id->driver_info; dev->board = au0828_boards[dev->boardnr]; - /* Register the media controller */ - au0828_media_device_register(dev, usbdev); + /* Initialize the media controller */ + au0828_media_device_init(dev, usbdev); #ifdef CONFIG_VIDEO_AU0828_V4L2 dev->v4l2_dev.release = au0828_usb_v4l2_release; @@ -446,9 +439,17 @@ static int au0828_usb_probe(struct usb_interface *interface, if (retval) { pr_err("%s() au0282_dev_register failed to create graph\n", __func__); - au0828_usb_disconnect(interface); + goto done; } +#ifdef CONFIG_MEDIA_CONTROLLER + retval = media_device_register(dev->media_dev); +#endif + +done: + if (retval < 0) + au0828_usb_disconnect(interface); + return retval; } diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 0e1efc59ff58..de0026b5265c 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1172,6 +1172,7 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev) #ifdef CONFIG_MEDIA_CONTROLLER if (dev->media_dev) { media_device_unregister(dev->media_dev); + media_device_cleanup(dev->media_dev); kfree(dev->media_dev); dev->media_dev = NULL; } @@ -1205,12 +1206,11 @@ void cx231xx_release_resources(struct cx231xx *dev) clear_bit(dev->devno, &cx231xx_devused); } -static void cx231xx_media_device_register(struct cx231xx *dev, - struct usb_device *udev) +static void cx231xx_media_device_init(struct cx231xx *dev, + struct usb_device *udev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev; - int ret; mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) @@ -1224,14 +1224,7 @@ static void cx231xx_media_device_register(struct cx231xx *dev, mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); mdev->driver_version = LINUX_VERSION_CODE; - ret = media_device_register(mdev); - if (ret) { - dev_err(dev->dev, - "Couldn't create a media device. Error: %d\n", - ret); - kfree(mdev); - return; - } + media_device_init(mdev); dev->media_dev = mdev; #endif @@ -1669,8 +1662,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface, /* save our data pointer in this interface device */ usb_set_intfdata(interface, dev); - /* Register the media controller */ - cx231xx_media_device_register(dev, udev); + /* Initialize the media controller */ + cx231xx_media_device_init(dev, udev); /* Create v4l2 device */ #ifdef CONFIG_MEDIA_CONTROLLER @@ -1742,11 +1735,18 @@ static int cx231xx_usb_probe(struct usb_interface *interface, request_modules(dev); retval = cx231xx_create_media_graph(dev); - if (retval < 0) { - cx231xx_release_resources(dev); - } + if (retval < 0) + goto done; + +#ifdef CONFIG_MEDIA_CONTROLLER + retval = media_device_register(dev->media_dev); +#endif +done: + if (retval < 0) + cx231xx_release_resources(dev); return retval; + err_video_alt: /* cx231xx_uninit_dev: */ cx231xx_close_extension(dev); diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index 6d3f61f6dc77..7f52bcbd8b0d 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c @@ -400,13 +400,12 @@ skip_feed_stop: return ret; } -static void dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap) +static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap) { #ifdef CONFIG_MEDIA_CONTROLLER_DVB struct media_device *mdev; struct dvb_usb_device *d = adap_to_d(adap); struct usb_device *udev = d->udev; - int ret; mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) @@ -420,19 +419,18 @@ static void dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap) mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); mdev->driver_version = LINUX_VERSION_CODE; - ret = media_device_register(mdev); - if (ret) { - dev_err(&d->udev->dev, - "Couldn't create a media device. Error: %d\n", - ret); - kfree(mdev); - return; - } + media_device_init(mdev); dvb_register_media_controller(&adap->dvb_adap, mdev); dev_info(&d->udev->dev, "media controller created\n"); +#endif +} +static void dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap) +{ +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + media_device_register(adap->dvb_adap.mdev); #endif } @@ -444,6 +442,7 @@ static void dvb_usbv2_media_device_unregister(struct dvb_usb_adapter *adap) return; media_device_unregister(adap->dvb_adap.mdev); + media_device_cleanup(adap->dvb_adap.mdev); kfree(adap->dvb_adap.mdev); adap->dvb_adap.mdev = NULL; @@ -467,7 +466,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) adap->dvb_adap.priv = adap; - dvb_usbv2_media_device_register(adap); + dvb_usbv2_media_device_init(adap); if (d->props->read_mac_address) { ret = d->props->read_mac_address(adap, @@ -702,6 +701,8 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap) if (ret < 0) goto err_dvb_unregister_frontend; + dvb_usbv2_media_device_register(adap); + return 0; err_dvb_unregister_frontend: diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c index b51dbdf03f42..6a4bb2d86175 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c @@ -95,13 +95,12 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) return dvb_usb_ctrl_feed(dvbdmxfeed, 0); } -static void dvb_usb_media_device_register(struct dvb_usb_adapter *adap) +static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap) { #ifdef CONFIG_MEDIA_CONTROLLER_DVB struct media_device *mdev; struct dvb_usb_device *d = adap->dev; struct usb_device *udev = d->udev; - int ret; mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) @@ -115,20 +114,21 @@ static void dvb_usb_media_device_register(struct dvb_usb_adapter *adap) mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); mdev->driver_version = LINUX_VERSION_CODE; - ret = media_device_register(mdev); - if (ret) { - dev_err(&d->udev->dev, - "Couldn't create a media device. Error: %d\n", - ret); - kfree(mdev); - return; - } + media_device_init(mdev); + dvb_register_media_controller(&adap->dvb_adap, mdev); dev_info(&d->udev->dev, "media controller created\n"); #endif } +static void dvb_usb_media_device_register(struct dvb_usb_adapter *adap) +{ +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + media_device_register(adap->dvb_adap.mdev); +#endif +} + static void dvb_usb_media_device_unregister(struct dvb_usb_adapter *adap) { #ifdef CONFIG_MEDIA_CONTROLLER_DVB @@ -136,6 +136,7 @@ static void dvb_usb_media_device_unregister(struct dvb_usb_adapter *adap) return; media_device_unregister(adap->dvb_adap.mdev); + media_device_cleanup(adap->dvb_adap.mdev); kfree(adap->dvb_adap.mdev); adap->dvb_adap.mdev = NULL; #endif @@ -154,7 +155,7 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums) } adap->dvb_adap.priv = adap; - dvb_usb_media_device_register(adap); + dvb_usb_media_device_init(adap); if (adap->dev->props.read_mac_address) { if (adap->dev->props.read_mac_address(adap->dev, adap->dvb_adap.proposed_mac) == 0) @@ -323,6 +324,8 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) ret = dvb_create_media_graph(&adap->dvb_adap); + dvb_usb_media_device_register(adap); + return ret; } diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c index c945e4c2fbd4..8abbd3cc8eba 100644 --- a/drivers/media/usb/siano/smsusb.c +++ b/drivers/media/usb/siano/smsusb.c @@ -361,10 +361,11 @@ static void *siano_media_device_register(struct smsusb_device_t *dev, mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); mdev->driver_version = LINUX_VERSION_CODE; + media_device_init(mdev); + ret = media_device_register(mdev); if (ret) { - pr_err("Couldn't create a media device. Error: %d\n", - ret); + media_device_cleanup(mdev); kfree(mdev); return NULL; } diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 39abbafad796..4e7148815a78 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1656,6 +1656,7 @@ static void uvc_delete(struct uvc_device *dev) #ifdef CONFIG_MEDIA_CONTROLLER if (media_devnode_is_registered(&dev->mdev.devnode)) media_device_unregister(&dev->mdev); + media_device_cleanup(&dev->mdev); #endif list_for_each_safe(p, n, &dev->chains) { @@ -1906,7 +1907,7 @@ static int uvc_probe(struct usb_interface *intf, "linux-uvc-devel mailing list.\n"); } - /* Register the media and V4L2 devices. */ + /* Initialize the media device and register the V4L2 device. */ #ifdef CONFIG_MEDIA_CONTROLLER dev->mdev.dev = &intf->dev; strlcpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model)); @@ -1916,8 +1917,7 @@ static int uvc_probe(struct usb_interface *intf, strcpy(dev->mdev.bus_info, udev->devpath); dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); dev->mdev.driver_version = LINUX_VERSION_CODE; - if (media_device_register(&dev->mdev) < 0) - goto error; + media_device_init(&dev->mdev); dev->vdev.mdev = &dev->mdev; #endif @@ -1936,6 +1936,11 @@ static int uvc_probe(struct usb_interface *intf, if (uvc_register_chains(dev) < 0) goto error; +#ifdef CONFIG_MEDIA_CONTROLLER + /* Register the media device node */ + if (media_device_register(&dev->mdev) < 0) + goto error; +#endif /* Save our data pointer in the interface data. */ usb_set_intfdata(intf, dev); diff --git a/include/media/media-device.h b/include/media/media-device.h index ebc2f3a239eb..e01bbc427fcd 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -337,6 +337,32 @@ struct media_device { /* media_devnode to media_device */ #define to_media_device(node) container_of(node, struct media_device, devnode) +/** + * media_device_init() - Initializes a media device element + * + * @mdev: pointer to struct &media_device + * + * This function initializes the media device prior to its registration. + * The media device initialization and registration is split in two functions + * to avoid race conditions and make the media device available to user-space + * before the media graph has been completed. + * + * So drivers need to first initialize the media device, register any entity + * within the media device, create pad to pad links and then finally register + * the media device by calling media_device_register() as a final step. + */ +void media_device_init(struct media_device *mdev); + +/** + * media_device_cleanup() - Cleanups a media device element + * + * @mdev: pointer to struct &media_device + * + * This function that will destroy the graph_mutex that is + * initialized in media_device_init(). + */ +void media_device_cleanup(struct media_device *mdev); + /** * __media_device_register() - Registers a media device element * -- cgit v1.2.3 From 9f80679511b0544d1ed8c9bc2d80030183e9f1ed Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 28 Dec 2015 09:55:49 -0200 Subject: [media] usb: check media device errors There are now two new warnings: drivers/media/usb/dvb-usb-v2/dvb_usb_core.c: In function 'dvb_usbv2_media_device_register': drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:433:2: warning: ignoring return value of '__media_device_register', declared with attribute warn_unused_result [-Wunused-result] media_device_register(adap->dvb_adap.mdev); ^ drivers/media/usb/dvb-usb/dvb-usb-dvb.c: In function 'dvb_usb_media_device_register': drivers/media/usb/dvb-usb/dvb-usb-dvb.c:128:2: warning: ignoring return value of '__media_device_register', declared with attribute warn_unused_result [-Wunused-result] media_device_register(adap->dvb_adap.mdev); ^ Those are because the drivers are not properly checking if the media device init and register were succeeded. Fix it. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-core.c | 16 ++++++++++++---- drivers/media/usb/cx231xx/cx231xx-cards.c | 13 ++++++++++--- drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 23 ++++++++++++++++------- drivers/media/usb/dvb-usb/dvb-usb-dvb.c | 22 ++++++++++++++++------ 4 files changed, 54 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index fbdaeb206565..9e29e70a78d7 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -217,15 +217,15 @@ static void au0828_usb_disconnect(struct usb_interface *interface) au0828_usb_release(dev); } -static void au0828_media_device_init(struct au0828_dev *dev, - struct usb_device *udev) +static int au0828_media_device_init(struct au0828_dev *dev, + struct usb_device *udev) { #ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev; mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) - return; + return -ENOMEM; mdev->dev = &udev->dev; @@ -243,6 +243,7 @@ static void au0828_media_device_init(struct au0828_dev *dev, dev->media_dev = mdev; #endif + return 0; } @@ -368,7 +369,14 @@ static int au0828_usb_probe(struct usb_interface *interface, dev->board = au0828_boards[dev->boardnr]; /* Initialize the media controller */ - au0828_media_device_init(dev, usbdev); + retval = au0828_media_device_init(dev, usbdev); + if (retval) { + pr_err("%s() au0828_media_device_init failed\n", + __func__); + mutex_unlock(&dev->lock); + kfree(dev); + return retval; + } #ifdef CONFIG_VIDEO_AU0828_V4L2 dev->v4l2_dev.release = au0828_usb_v4l2_release; diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index de0026b5265c..620b83d03f75 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1206,7 +1206,7 @@ void cx231xx_release_resources(struct cx231xx *dev) clear_bit(dev->devno, &cx231xx_devused); } -static void cx231xx_media_device_init(struct cx231xx *dev, +static int cx231xx_media_device_init(struct cx231xx *dev, struct usb_device *udev) { #ifdef CONFIG_MEDIA_CONTROLLER @@ -1214,7 +1214,7 @@ static void cx231xx_media_device_init(struct cx231xx *dev, mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) - return; + return -ENOMEM; mdev->dev = dev->dev; strlcpy(mdev->model, dev->board.name, sizeof(mdev->model)); @@ -1228,6 +1228,7 @@ static void cx231xx_media_device_init(struct cx231xx *dev, dev->media_dev = mdev; #endif + return 0; } static int cx231xx_create_media_graph(struct cx231xx *dev) @@ -1663,7 +1664,11 @@ static int cx231xx_usb_probe(struct usb_interface *interface, usb_set_intfdata(interface, dev); /* Initialize the media controller */ - cx231xx_media_device_init(dev, udev); + retval = cx231xx_media_device_init(dev, udev); + if (retval) { + dev_err(d, "cx231xx_media_device_init failed\n"); + goto err_media_init; + } /* Create v4l2 device */ #ifdef CONFIG_MEDIA_CONTROLLER @@ -1758,6 +1763,8 @@ err_video_alt: err_init: v4l2_device_unregister(&dev->v4l2_dev); err_v4l2: + cx231xx_unregister_media_device(dev); +err_media_init: usb_set_intfdata(interface, NULL); err_if: usb_put_dev(udev); diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index 7f52bcbd8b0d..0fa2c45917b0 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c @@ -400,7 +400,7 @@ skip_feed_stop: return ret; } -static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap) +static int dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap) { #ifdef CONFIG_MEDIA_CONTROLLER_DVB struct media_device *mdev; @@ -409,7 +409,7 @@ static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap) mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) - return; + return -ENOMEM; mdev->dev = &udev->dev; strlcpy(mdev->model, d->name, sizeof(mdev->model)); @@ -425,12 +425,15 @@ static void dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap) dev_info(&d->udev->dev, "media controller created\n"); #endif + return 0; } -static void dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap) +static int dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap) { #ifdef CONFIG_MEDIA_CONTROLLER_DVB - media_device_register(adap->dvb_adap.mdev); + return media_device_register(adap->dvb_adap.mdev); +#else + return 0; #endif } @@ -466,7 +469,12 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) adap->dvb_adap.priv = adap; - dvb_usbv2_media_device_init(adap); + ret = dvb_usbv2_media_device_init(adap); + if (ret < 0) { + dev_dbg(&d->udev->dev, "%s: dvb_usbv2_media_device_init() failed=%d\n", + __func__, ret); + goto err_dvb_register_mc; + } if (d->props->read_mac_address) { ret = d->props->read_mac_address(adap, @@ -517,6 +525,7 @@ err_dvb_dmxdev_init: dvb_dmx_release(&adap->demux); err_dvb_dmx_init: dvb_usbv2_media_device_unregister(adap); +err_dvb_register_mc: dvb_unregister_adapter(&adap->dvb_adap); err_dvb_register_adapter: adap->dvb_adap.priv = NULL; @@ -701,9 +710,9 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap) if (ret < 0) goto err_dvb_unregister_frontend; - dvb_usbv2_media_device_register(adap); + ret = dvb_usbv2_media_device_register(adap); - return 0; + return ret; err_dvb_unregister_frontend: for (i = count_registered - 1; i >= 0; i--) diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c index 6a4bb2d86175..241463ef631e 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c @@ -95,7 +95,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) return dvb_usb_ctrl_feed(dvbdmxfeed, 0); } -static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap) +static int dvb_usb_media_device_init(struct dvb_usb_adapter *adap) { #ifdef CONFIG_MEDIA_CONTROLLER_DVB struct media_device *mdev; @@ -104,7 +104,7 @@ static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap) mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); if (!mdev) - return; + return -ENOMEM; mdev->dev = &udev->dev; strlcpy(mdev->model, d->desc->name, sizeof(mdev->model)); @@ -120,12 +120,15 @@ static void dvb_usb_media_device_init(struct dvb_usb_adapter *adap) dev_info(&d->udev->dev, "media controller created\n"); #endif + return 0; } -static void dvb_usb_media_device_register(struct dvb_usb_adapter *adap) +static int dvb_usb_media_device_register(struct dvb_usb_adapter *adap) { #ifdef CONFIG_MEDIA_CONTROLLER_DVB - media_device_register(adap->dvb_adap.mdev); + return media_device_register(adap->dvb_adap.mdev); +#else + return 0; #endif } @@ -155,7 +158,11 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums) } adap->dvb_adap.priv = adap; - dvb_usb_media_device_init(adap); + ret = dvb_usb_media_device_init(adap); + if (ret < 0) { + deb_info("dvb_usb_media_device_init failed: error %d", ret); + goto err_mc; + } if (adap->dev->props.read_mac_address) { if (adap->dev->props.read_mac_address(adap->dev, adap->dvb_adap.proposed_mac) == 0) @@ -205,6 +212,7 @@ err_dmx_dev: dvb_dmx_release(&adap->demux); err_dmx: dvb_usb_media_device_unregister(adap); +err_mc: dvb_unregister_adapter(&adap->dvb_adap); err: return ret; @@ -323,8 +331,10 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) return ret; ret = dvb_create_media_graph(&adap->dvb_adap); + if (ret) + return ret; - dvb_usb_media_device_register(adap); + ret = dvb_usb_media_device_register(adap); return ret; } -- cgit v1.2.3 From bdf5c198261cdda8dcc5375315afe9d8bf4d77d1 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Mon, 28 Dec 2015 01:45:00 +0200 Subject: [media] v4l2-device: Register entity before calling subdev's registered ops Registering a V4L2 sub-device includes, among other things, registering the related media entity and calling the sub-device's registered op. Since patch "media: convert links from array to list", creating a link between two pads requires registering the entity first. If the registered() op involves link creation, the link list head will not be initialised before it is used. Resolve this by first registering the entity, then calling its registered() op. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-device.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 85f724b53a14..2aa72aba4f17 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -180,26 +180,26 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, return -ENODEV; sd->v4l2_dev = v4l2_dev; - if (sd->internal_ops && sd->internal_ops->registered) { - err = sd->internal_ops->registered(sd); - if (err) - goto error_module; - } - /* This just returns 0 if either of the two args is NULL */ err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler, NULL); if (err) - goto error_unregister; + goto error_module; #if defined(CONFIG_MEDIA_CONTROLLER) /* Register the entity. */ if (v4l2_dev->mdev) { err = media_device_register_entity(v4l2_dev->mdev, entity); if (err < 0) - goto error_unregister; + goto error_module; } #endif + if (sd->internal_ops && sd->internal_ops->registered) { + err = sd->internal_ops->registered(sd); + if (err) + goto error_unregister; + } + spin_lock(&v4l2_dev->lock); list_add_tail(&sd->list, &v4l2_dev->subdevs); spin_unlock(&v4l2_dev->lock); @@ -207,8 +207,9 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, return 0; error_unregister: - if (sd->internal_ops && sd->internal_ops->unregistered) - sd->internal_ops->unregistered(sd); +#if defined(CONFIG_MEDIA_CONTROLLER) + media_device_unregister_entity(entity); +#endif error_module: if (!sd->owner_v4l2_dev) module_put(sd->owner); -- cgit v1.2.3 From 8a95079668bf35b265d3bb6381b8badb5bfa826a Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Fri, 11 Dec 2015 20:57:09 -0200 Subject: [media] media-device: set topology version 0 at media registration The G_TOPOLOGY ioctl is used to get a graph topology and since in the future a graph can be dynamically updated, there is a way to know the topology version so userspace can be aware that the graph has changed. The version 0 is reserved to indicate that the graph is static (i.e no graphs updates since the media device was registered). So, now that the media device initialization and registration has been split and the media device node is not exposed to user-space until all the entities have been registered and links created, it is safe to set a topology version 0 in media_device_register(). Suggested-by: Laurent Pinchart Suggested-by: Mauro Carvalho Chehab Signed-off-by: Javier Martinez Canillas Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index b718c783debd..b3e19c22e699 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -665,6 +665,10 @@ int __must_check __media_device_register(struct media_device *mdev, mdev->devnode.fops = &media_device_fops; mdev->devnode.parent = mdev->dev; mdev->devnode.release = media_device_release; + + /* Set version 0 to indicate user-space that the graph is static */ + mdev->topology_version = 0; + ret = media_devnode_register(&mdev->devnode, owner); if (ret < 0) return ret; -- cgit v1.2.3 From a5c82e5622d1b7f479c9a43873c2c5ac1f67765c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 15 Dec 2015 09:00:40 -0200 Subject: [media] media-device: copy_to/from_user() returns positive The copy_to/from_user() functions return the number of bytes *not* copied. They don't return error codes. Fixes: 4f6b3f363475 ('media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl') Signed-off-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index b3e19c22e699..30e3354d7481 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -376,18 +376,17 @@ static long media_device_get_topology(struct media_device *mdev, struct media_v2_topology ktopo; int ret; - ret = copy_from_user(&ktopo, utopo, sizeof(ktopo)); - - if (ret < 0) - return ret; + if (copy_from_user(&ktopo, utopo, sizeof(ktopo))) + return -EFAULT; ret = __media_device_get_topology(mdev, &ktopo); if (ret < 0) return ret; - ret = copy_to_user(utopo, &ktopo, sizeof(*utopo)); + if (copy_to_user(utopo, &ktopo, sizeof(*utopo))) + return -EFAULT; - return ret; + return 0; } static long media_device_ioctl(struct file *filp, unsigned int cmd, -- cgit v1.2.3 From 1630b832355399dd0dc4fcc2cadbcad47153a748 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 15 Dec 2015 09:04:14 -0200 Subject: [media] v4l2-device: fix a missing error code We need to set "err = -ENOMEM" here. Fixes: 38b11f19667a ('[media] v4l2-core: create MC interfaces for devnodes') Signed-off-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index 2aa72aba4f17..06fa5f1b2cff 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -267,8 +267,10 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) link = media_create_intf_link(&sd->entity, &vdev->intf_devnode->intf, MEDIA_LNK_FL_ENABLED); - if (!link) + if (!link) { + err = -ENOMEM; goto clean_up; + } } #endif sd->devnode = vdev; -- cgit v1.2.3 From 665faa971d087e8b968ef75d04079a7a462ddfca Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:17 -0200 Subject: [media] media: Introduce internal index for media entities The internal index can be used internally by the framework in order to keep track of entities for a purpose or another. The internal index is constant while it's registered to a media device, but the same index may be re-used once the entity having that index is unregistered. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 17 +++++++++++++++++ include/media/media-device.h | 4 ++++ include/media/media-entity.h | 3 +++ 3 files changed, 24 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 30e3354d7481..ce97f8f196f3 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -551,6 +552,17 @@ int __must_check media_device_register_entity(struct media_device *mdev, entity->num_backlinks = 0; spin_lock(&mdev->lock); + + entity->internal_idx = ida_simple_get(&mdev->entity_internal_idx, 1, 0, + GFP_KERNEL); + if (entity->internal_idx < 0) { + spin_unlock(&mdev->lock); + return entity->internal_idx; + } + + mdev->entity_internal_idx_max = + max(mdev->entity_internal_idx_max, entity->internal_idx); + /* Initialize media_gobj embedded at the entity */ media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj); @@ -579,6 +591,8 @@ static void __media_device_unregister_entity(struct media_entity *entity) struct media_interface *intf; unsigned int i; + ida_simple_remove(&mdev->entity_internal_idx, entity->internal_idx); + /* Remove all interface links pointing to this entity */ list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) { list_for_each_entry_safe(link, tmp, &intf->links, list) { @@ -632,6 +646,7 @@ void media_device_init(struct media_device *mdev) INIT_LIST_HEAD(&mdev->links); spin_lock_init(&mdev->lock); mutex_init(&mdev->graph_mutex); + ida_init(&mdev->entity_internal_idx); dev_dbg(mdev->dev, "Media device initialized\n"); } @@ -644,6 +659,8 @@ EXPORT_SYMBOL_GPL(media_device_init); */ void media_device_cleanup(struct media_device *mdev) { + ida_destroy(&mdev->entity_internal_idx); + mdev->entity_internal_idx_max = 0; mutex_destroy(&mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_device_cleanup); diff --git a/include/media/media-device.h b/include/media/media-device.h index e01bbc427fcd..2ab4e6803842 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -261,6 +261,7 @@ * in the end provide a way to use driver-specific callbacks. */ +struct ida; struct device; /** @@ -278,6 +279,7 @@ struct device; * @pad_id: Unique ID used on the last pad registered * @link_id: Unique ID used on the last link registered * @intf_devnode_id: Unique ID used on the last interface devnode registered + * @entity_internal_idx: Allocated internal entity indices * @entities: List of registered entities * @interfaces: List of registered interfaces * @pads: List of registered pads @@ -313,6 +315,8 @@ struct media_device { u32 pad_id; u32 link_id; u32 intf_devnode_id; + struct ida entity_internal_idx; + int entity_internal_idx_max; struct list_head entities; struct list_head interfaces; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 81aca1f5a09a..30e8f9fd3efa 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -157,6 +157,8 @@ struct media_entity_operations { * @num_pads: Number of sink and source pads. * @num_links: Total number of links, forward and back, enabled and disabled. * @num_backlinks: Number of backlinks + * @internal_idx: An unique internal entity specific number. The numbers are + * re-used if entities are unregistered or registered again. * @pads: Pads array with the size defined by @num_pads. * @links: List of data links. * @ops: Entity operations. @@ -183,6 +185,7 @@ struct media_entity { u16 num_pads; u16 num_links; u16 num_backlinks; + int internal_idx; struct media_pad *pads; struct list_head links; -- cgit v1.2.3 From c8d54cd53b43c514fbd8d36abf0f2f00f719dd54 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:44:32 -0200 Subject: [media] media: Add an API to manage entity enumerations This is useful in e.g. knowing whether certain operations have already been performed for an entity. The users include the framework itself (for graph walking) and a number of drivers. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 40 ++++++++++++ include/media/media-device.h | 15 +++++ include/media/media-entity.h | 141 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 188 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 13c8ca11f169..5e3f32f63187 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -70,6 +70,46 @@ static inline const char *intf_type(struct media_interface *intf) } }; +/** + * __media_entity_enum_init - Initialise an entity enumeration + * + * @ent_enum: Entity enumeration to be initialised + * @idx_max: Maximum number of entities in the enumeration + * + * Returns zero on success or a negative error code. + */ +__must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, + int idx_max) +{ + if (idx_max > MEDIA_ENTITY_ENUM_MAX_ID) { + ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG), + sizeof(long), GFP_KERNEL); + if (!ent_enum->bmap) + return -ENOMEM; + } else { + ent_enum->bmap = ent_enum->prealloc_bmap; + } + + bitmap_zero(ent_enum->bmap, idx_max); + ent_enum->idx_max = idx_max; + + return 0; +} +EXPORT_SYMBOL_GPL(__media_entity_enum_init); + +/** + * media_entity_enum_cleanup - Release resources of an entity enumeration + * + * @e: Entity enumeration to be released + */ +void media_entity_enum_cleanup(struct media_entity_enum *ent_enum) +{ + if (ent_enum->bmap != ent_enum->prealloc_bmap) + kfree(ent_enum->bmap); + ent_enum->bmap = NULL; +} +EXPORT_SYMBOL_GPL(media_entity_enum_cleanup); + /** * dev_dbg_obj - Prints in debug mode a change on some object * diff --git a/include/media/media-device.h b/include/media/media-device.h index 2ab4e6803842..da4e12ca259c 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -341,6 +341,21 @@ struct media_device { /* media_devnode to media_device */ #define to_media_device(node) container_of(node, struct media_device, devnode) +/** + * media_entity_enum_init - Initialise an entity enumeration + * + * @e: Entity enumeration to be initialised + * @mdev: The related media device + * + * Returns zero on success or a negative error code. + */ +static inline __must_check int media_entity_enum_init( + struct media_entity_enum *ent_enum, struct media_device *mdev) +{ + return __media_entity_enum_init(ent_enum, + mdev->entity_internal_idx_max + 1); +} + /** * media_device_init() - Initializes a media device element * diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 30e8f9fd3efa..c593dbd3e030 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -23,7 +23,7 @@ #ifndef _MEDIA_ENTITY_H #define _MEDIA_ENTITY_H -#include +#include #include #include #include @@ -71,6 +71,32 @@ struct media_gobj { struct list_head list; }; +#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 +#define MEDIA_ENTITY_ENUM_MAX_ID 64 + +/* + * The number of pads can't be bigger than the number of entities, + * as the worse-case scenario is to have one entity linked up to + * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities. + */ +#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1) + +/** + * struct media_entity_enum - An enumeration of media entities. + * + * @prealloc_bmap: Pre-allocated space reserved for media entities if the + * total number of entities does not exceed + * MEDIA_ENTITY_ENUM_MAX_ID. + * @bmap: Bit map in which each bit represents one entity at struct + * media_entity->internal_idx. + * @idx_max: Number of bits in bmap + */ +struct media_entity_enum { + DECLARE_BITMAP(prealloc_bmap, MEDIA_ENTITY_ENUM_MAX_ID); + unsigned long *bmap; + int idx_max; +}; + struct media_pipeline { }; @@ -329,15 +355,114 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity) } } -#define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 -#define MEDIA_ENTITY_ENUM_MAX_ID 64 +__must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, + int idx_max); +void media_entity_enum_cleanup(struct media_entity_enum *e); -/* - * The number of pads can't be bigger than the number of entities, - * as the worse-case scenario is to have one entity linked up to - * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities. +/** + * media_entity_enum_zero - Clear the entire enum + * + * @e: Entity enumeration to be cleared */ -#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1) +static inline void media_entity_enum_zero(struct media_entity_enum *ent_enum) +{ + bitmap_zero(ent_enum->bmap, ent_enum->idx_max); +} + +/** + * media_entity_enum_set - Mark a single entity in the enum + * + * @e: Entity enumeration + * @entity: Entity to be marked + */ +static inline void media_entity_enum_set(struct media_entity_enum *ent_enum, + struct media_entity *entity) +{ + if (WARN_ON(entity->internal_idx >= ent_enum->idx_max)) + return; + + __set_bit(entity->internal_idx, ent_enum->bmap); +} + +/** + * media_entity_enum_clear - Unmark a single entity in the enum + * + * @e: Entity enumeration + * @entity: Entity to be unmarked + */ +static inline void media_entity_enum_clear(struct media_entity_enum *ent_enum, + struct media_entity *entity) +{ + if (WARN_ON(entity->internal_idx >= ent_enum->idx_max)) + return; + + __clear_bit(entity->internal_idx, ent_enum->bmap); +} + +/** + * media_entity_enum_test - Test whether the entity is marked + * + * @e: Entity enumeration + * @entity: Entity to be tested + * + * Returns true if the entity was marked. + */ +static inline bool media_entity_enum_test(struct media_entity_enum *ent_enum, + struct media_entity *entity) +{ + if (WARN_ON(entity->internal_idx >= ent_enum->idx_max)) + return true; + + return test_bit(entity->internal_idx, ent_enum->bmap); +} + +/** + * media_entity_enum_test - Test whether the entity is marked, and mark it + * + * @e: Entity enumeration + * @entity: Entity to be tested + * + * Returns true if the entity was marked, and mark it before doing so. + */ +static inline bool media_entity_enum_test_and_set( + struct media_entity_enum *ent_enum, struct media_entity *entity) +{ + if (WARN_ON(entity->internal_idx >= ent_enum->idx_max)) + return true; + + return __test_and_set_bit(entity->internal_idx, ent_enum->bmap); +} + +/** + * media_entity_enum_test - Test whether the entire enum is empty + * + * @e: Entity enumeration + * @entity: Entity to be tested + * + * Returns true if the entity was marked. + */ +static inline bool media_entity_enum_empty(struct media_entity_enum *ent_enum) +{ + return bitmap_empty(ent_enum->bmap, ent_enum->idx_max); +} + +/** + * media_entity_enum_intersects - Test whether two enums intersect + * + * @e: First entity enumeration + * @f: Second entity enumeration + * + * Returns true if entity enumerations e and f intersect, otherwise false. + */ +static inline bool media_entity_enum_intersects( + struct media_entity_enum *ent_enum1, + struct media_entity_enum *ent_enum2) +{ + WARN_ON(ent_enum1->idx_max != ent_enum2->idx_max); + + return bitmap_intersects(ent_enum1->bmap, ent_enum2->bmap, + min(ent_enum1->idx_max, ent_enum2->idx_max)); +} struct media_entity_graph { struct { -- cgit v1.2.3 From 5dd8775dc6b480f67be11108d7cd798fba724cab Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:21 -0200 Subject: [media] media: Move media graph state for streamon/off to the pipeline The struct media_entity_graph was allocated in the stack, limiting the number of entities that could be reasonably allocated. Instead, move the struct to struct media_pipeline which is typically allocated using kmalloc() instead. The intent is to keep the enumeration around for later use for the duration of the streaming. As streaming is eventually stopped, an unfortunate memory allocation failure would prevent stopping the streaming. As no memory will need to be allocated, the problem is avoided altogether. Signed-off-by: Sakari Ailus Reviewed-by: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 16 ++++++++-------- include/media/media-entity.h | 6 ++++++ 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 5e3f32f63187..83cfde6dcb1c 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -349,16 +349,16 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, struct media_pipeline *pipe) { struct media_device *mdev = entity->graph_obj.mdev; - struct media_entity_graph graph; + struct media_entity_graph *graph = &pipe->graph; struct media_entity *entity_err = entity; struct media_link *link; int ret; mutex_lock(&mdev->graph_mutex); - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + while ((entity = media_entity_graph_walk_next(graph))) { DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS); DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS); @@ -439,9 +439,9 @@ error: * Link validation on graph failed. We revert what we did and * return the error. */ - media_entity_graph_walk_start(&graph, entity_err); + media_entity_graph_walk_start(graph, entity_err); - while ((entity_err = media_entity_graph_walk_next(&graph))) { + while ((entity_err = media_entity_graph_walk_next(graph))) { entity_err->stream_count--; if (entity_err->stream_count == 0) entity_err->pipe = NULL; @@ -463,13 +463,13 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start); void media_entity_pipeline_stop(struct media_entity *entity) { struct media_device *mdev = entity->graph_obj.mdev; - struct media_entity_graph graph; + struct media_entity_graph *graph = &entity->pipe->graph; mutex_lock(&mdev->graph_mutex); - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + while ((entity = media_entity_graph_walk_next(graph))) { entity->stream_count--; if (entity->stream_count == 0) entity->pipe = NULL; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index edfb6163caa3..4dc3bef72c9d 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -116,7 +116,13 @@ struct media_entity_graph { int top; }; +/* + * struct media_pipeline - Media pipeline related information + * + * @graph: Media graph walk during pipeline start / stop + */ struct media_pipeline { + struct media_entity_graph graph; }; /** -- cgit v1.2.3 From e03d220336dd69292370393f5eee98ac17eda308 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:22 -0200 Subject: [media] media: Amend media graph walk API by init and cleanup functions Add media_entity_graph_walk_init() and media_entity_graph_walk_cleanup() functions in order to dynamically allocate memory for the graph. This is not done in media_entity_graph_walk_start() as there are situations where e.g. correct error handling, that itself may not fail, requires successful graph walk. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 27 +++++++++++++++++++++++++++ include/media/media-entity.h | 17 ++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 83cfde6dcb1c..9bf96c71374e 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -282,6 +282,33 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph) #define link_top(en) ((en)->stack[(en)->top].link) #define stack_top(en) ((en)->stack[(en)->top].entity) +/** + * media_entity_graph_walk_init - Allocate resources for graph walk + * @graph: Media graph structure that will be used to walk the graph + * @mdev: Media device + * + * Reserve resources for graph walk in media device's current + * state. The memory must be released using + * media_entity_graph_walk_free(). + * + * Returns error on failure, zero on success. + */ +__must_check int media_entity_graph_walk_init( + struct media_entity_graph *graph, struct media_device *mdev) +{ + return 0; +} +EXPORT_SYMBOL_GPL(media_entity_graph_walk_init); + +/** + * media_entity_graph_walk_cleanup - Release resources related to graph walking + * @graph: Media graph structure that was used to walk the graph + */ +void media_entity_graph_walk_cleanup(struct media_entity_graph *graph) +{ +} +EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup); + void media_entity_graph_walk_start(struct media_entity_graph *graph, struct media_entity *entity) { diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 4dc3bef72c9d..7f028ea84911 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -699,6 +699,10 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad); */ struct media_entity *media_entity_get(struct media_entity *entity); +__must_check int media_entity_graph_walk_init( + struct media_entity_graph *graph, struct media_device *mdev); +void media_entity_graph_walk_cleanup(struct media_entity_graph *graph); + /** * media_entity_put - Release the reference to the parent module * @@ -715,13 +719,16 @@ void media_entity_put(struct media_entity *entity); * @graph: Media graph structure that will be used to walk the graph * @entity: Starting entity * - * This function initializes the graph traversal structure to walk the entities - * graph starting at the given entity. The traversal structure must not be - * modified by the caller during graph traversal. When done the structure can - * safely be freed. + * Before using this function, media_entity_graph_walk_init() must be + * used to allocate resources used for walking the graph. This + * function initializes the graph traversal structure to walk the + * entities graph starting at the given entity. The traversal + * structure must not be modified by the caller during graph + * traversal. After the graph walk, the resources must be released + * using media_entity_graph_walk_cleanup(). */ void media_entity_graph_walk_start(struct media_entity_graph *graph, - struct media_entity *entity); + struct media_entity *entity); /** * media_entity_graph_walk_next - Get the next entity in the graph -- cgit v1.2.3 From 106b9907c368e32d0b01d8ea682c44ef811e6e36 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 15:32:23 +0200 Subject: [media] media: Use the new media graph walk interface The media graph walk requires initialisation and cleanup soon. Update the users to perform the soon necessary API calls. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 9bf96c71374e..85af715d2a20 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -383,7 +383,13 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, mutex_lock(&mdev->graph_mutex); - media_entity_graph_walk_start(graph, entity); + ret = media_entity_graph_walk_init(&pipe->graph, mdev); + if (ret) { + mutex_unlock(&mdev->graph_mutex); + return ret; + } + + media_entity_graph_walk_start(&pipe->graph, entity); while ((entity = media_entity_graph_walk_next(graph))) { DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS); @@ -481,6 +487,8 @@ error: break; } + media_entity_graph_walk_cleanup(graph); + mutex_unlock(&mdev->graph_mutex); return ret; @@ -502,6 +510,8 @@ void media_entity_pipeline_stop(struct media_entity *entity) entity->pipe = NULL; } + media_entity_graph_walk_cleanup(graph); + mutex_unlock(&mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_entity_pipeline_stop); -- cgit v1.2.3 From 28461451c0fc943fa9271e653483857f20d9b489 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:24 -0200 Subject: [media] v4l: omap3isp: Use the new media graph walk interface The media graph walk requires initialisation and cleanup soon. Update the users to perform the soon necessary API calls. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 63 ++++++++++++++++++------------ drivers/media/platform/omap3isp/isp.h | 4 +- drivers/media/platform/omap3isp/ispvideo.c | 20 +++++++++- drivers/media/platform/omap3isp/ispvideo.h | 1 + 4 files changed, 61 insertions(+), 27 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 942b189c0eca..581c50e86621 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -683,14 +683,14 @@ static irqreturn_t isp_isr(int irq, void *_isp) * * Return the total number of users of all video device nodes in the pipeline. */ -static int isp_pipeline_pm_use_count(struct media_entity *entity) +static int isp_pipeline_pm_use_count(struct media_entity *entity, + struct media_entity_graph *graph) { - struct media_entity_graph graph; int use = 0; - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + while ((entity = media_entity_graph_walk_next(graph))) { if (is_media_entity_v4l2_io(entity)) use += entity->use_count; } @@ -742,27 +742,27 @@ static int isp_pipeline_pm_power_one(struct media_entity *entity, int change) * * Return 0 on success or a negative error code on failure. */ -static int isp_pipeline_pm_power(struct media_entity *entity, int change) +static int isp_pipeline_pm_power(struct media_entity *entity, int change, + struct media_entity_graph *graph) { - struct media_entity_graph graph; struct media_entity *first = entity; int ret = 0; if (!change) return 0; - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while (!ret && (entity = media_entity_graph_walk_next(&graph))) + while (!ret && (entity = media_entity_graph_walk_next(graph))) if (is_media_entity_v4l2_subdev(entity)) ret = isp_pipeline_pm_power_one(entity, change); if (!ret) - return 0; + return ret; - media_entity_graph_walk_start(&graph, first); + media_entity_graph_walk_start(graph, first); - while ((first = media_entity_graph_walk_next(&graph)) + while ((first = media_entity_graph_walk_next(graph)) && first != entity) if (is_media_entity_v4l2_subdev(first)) isp_pipeline_pm_power_one(first, -change); @@ -782,7 +782,8 @@ static int isp_pipeline_pm_power(struct media_entity *entity, int change) * off is assumed to never fail. No failure can occur when the use parameter is * set to 0. */ -int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) +int omap3isp_pipeline_pm_use(struct media_entity *entity, int use, + struct media_entity_graph *graph) { int change = use ? 1 : -1; int ret; @@ -794,7 +795,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) WARN_ON(entity->use_count < 0); /* Apply power change to connected non-nodes. */ - ret = isp_pipeline_pm_power(entity, change); + ret = isp_pipeline_pm_power(entity, change, graph); if (ret < 0) entity->use_count -= change; @@ -820,35 +821,49 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, int use) static int isp_pipeline_link_notify(struct media_link *link, u32 flags, unsigned int notification) { + struct media_entity_graph *graph = + &container_of(link->graph_obj.mdev, struct isp_device, + media_dev)->pm_count_graph; struct media_entity *source = link->source->entity; struct media_entity *sink = link->sink->entity; - int source_use = isp_pipeline_pm_use_count(source); - int sink_use = isp_pipeline_pm_use_count(sink); - int ret; + int source_use; + int sink_use; + int ret = 0; + + if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) { + ret = media_entity_graph_walk_init(graph, + link->graph_obj.mdev); + if (ret) + return ret; + } + + source_use = isp_pipeline_pm_use_count(source, graph); + sink_use = isp_pipeline_pm_use_count(sink, graph); if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && !(flags & MEDIA_LNK_FL_ENABLED)) { /* Powering off entities is assumed to never fail. */ - isp_pipeline_pm_power(source, -sink_use); - isp_pipeline_pm_power(sink, -source_use); + isp_pipeline_pm_power(source, -sink_use, graph); + isp_pipeline_pm_power(sink, -source_use, graph); return 0; } if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH && (flags & MEDIA_LNK_FL_ENABLED)) { - ret = isp_pipeline_pm_power(source, sink_use); + ret = isp_pipeline_pm_power(source, sink_use, graph); if (ret < 0) return ret; - ret = isp_pipeline_pm_power(sink, source_use); + ret = isp_pipeline_pm_power(sink, source_use, graph); if (ret < 0) - isp_pipeline_pm_power(source, -sink_use); - - return ret; + isp_pipeline_pm_power(source, -sink_use, graph); } - return 0; + if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH) + media_entity_graph_walk_cleanup(graph); + + return ret; } /* ----------------------------------------------------------------------------- diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h index 5acc2e6511a5..b6f81f20aa73 100644 --- a/drivers/media/platform/omap3isp/isp.h +++ b/drivers/media/platform/omap3isp/isp.h @@ -176,6 +176,7 @@ struct isp_device { struct v4l2_device v4l2_dev; struct v4l2_async_notifier notifier; struct media_device media_dev; + struct media_entity_graph pm_count_graph; struct device *dev; u32 revision; @@ -265,7 +266,8 @@ void omap3isp_subclk_enable(struct isp_device *isp, void omap3isp_subclk_disable(struct isp_device *isp, enum isp_subclk_resource res); -int omap3isp_pipeline_pm_use(struct media_entity *entity, int use); +int omap3isp_pipeline_pm_use(struct media_entity *entity, int use, + struct media_entity_graph *graph); int omap3isp_register_entities(struct platform_device *pdev, struct v4l2_device *v4l2_dev); diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index 1240b06202f0..33123f112151 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -227,8 +227,15 @@ static int isp_video_get_graph_data(struct isp_video *video, struct media_entity *entity = &video->video.entity; struct media_device *mdev = entity->graph_obj.mdev; struct isp_video *far_end = NULL; + int ret; mutex_lock(&mdev->graph_mutex); + ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); + if (ret) { + mutex_unlock(&mdev->graph_mutex); + return ret; + } + media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { @@ -252,6 +259,8 @@ static int isp_video_get_graph_data(struct isp_video *video, mutex_unlock(&mdev->graph_mutex); + media_entity_graph_walk_cleanup(&graph); + if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { pipe->input = far_end; pipe->output = video; @@ -1244,7 +1253,12 @@ static int isp_video_open(struct file *file) goto done; } - ret = omap3isp_pipeline_pm_use(&video->video.entity, 1); + ret = media_entity_graph_walk_init(&handle->graph, + &video->isp->media_dev); + if (ret) + goto done; + + ret = omap3isp_pipeline_pm_use(&video->video.entity, 1, &handle->graph); if (ret < 0) { omap3isp_put(video->isp); goto done; @@ -1275,6 +1289,7 @@ static int isp_video_open(struct file *file) done: if (ret < 0) { v4l2_fh_del(&handle->vfh); + media_entity_graph_walk_cleanup(&handle->graph); kfree(handle); } @@ -1294,7 +1309,8 @@ static int isp_video_release(struct file *file) vb2_queue_release(&handle->queue); mutex_unlock(&video->queue_lock); - omap3isp_pipeline_pm_use(&video->video.entity, 0); + omap3isp_pipeline_pm_use(&video->video.entity, 0, &handle->graph); + media_entity_graph_walk_cleanup(&handle->graph); /* Release the file handle. */ v4l2_fh_del(vfh); diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h index bcf0e0acc8f3..a340165732db 100644 --- a/drivers/media/platform/omap3isp/ispvideo.h +++ b/drivers/media/platform/omap3isp/ispvideo.h @@ -189,6 +189,7 @@ struct isp_video_fh { struct vb2_queue queue; struct v4l2_format format; struct v4l2_fract timeperframe; + struct media_entity_graph graph; }; #define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh) -- cgit v1.2.3 From fd7e5309a5324c243cb285257a2e5e35d9bcaa56 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 15:32:25 +0200 Subject: [media] v4l: exynos4-is: Use the new media graph walk interface The media graph walk requires initialisation and cleanup soon. Update the users to perform the soon necessary API calls. Signed-off-by: Sakari Ailus Cc: Javier Martinez Canillas Cc: Kamil Debski Cc: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/media-dev.c | 31 +++++++++++++++++---------- drivers/media/platform/exynos4-is/media-dev.h | 1 + 2 files changed, 21 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 27663dd45294..f6b391e795c6 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1046,10 +1046,10 @@ static int __fimc_md_modify_pipeline(struct media_entity *entity, bool enable) } /* Locking: called with entity->graph_obj.mdev->graph_mutex mutex held. */ -static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) +static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable, + struct media_entity_graph *graph) { struct media_entity *entity_err = entity; - struct media_entity_graph graph; int ret; /* @@ -1058,9 +1058,9 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) * through active links. This is needed as we cannot power on/off the * subdevs in random order. */ - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + while ((entity = media_entity_graph_walk_next(graph))) { if (!is_media_entity_v4l2_io(entity)) continue; @@ -1071,10 +1071,11 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) } return 0; - err: - media_entity_graph_walk_start(&graph, entity_err); - while ((entity_err = media_entity_graph_walk_next(&graph))) { +err: + media_entity_graph_walk_start(graph, entity_err); + + while ((entity_err = media_entity_graph_walk_next(graph))) { if (!is_media_entity_v4l2_io(entity_err)) continue; @@ -1090,21 +1091,29 @@ static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable) static int fimc_md_link_notify(struct media_link *link, unsigned int flags, unsigned int notification) { + struct media_entity_graph *graph = + &container_of(link->graph_obj.mdev, struct fimc_md, + media_dev)->link_setup_graph; struct media_entity *sink = link->sink->entity; int ret = 0; /* Before link disconnection */ if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) { + ret = media_entity_graph_walk_init(graph, + link->graph_obj.mdev); + if (ret) + return ret; if (!(flags & MEDIA_LNK_FL_ENABLED)) - ret = __fimc_md_modify_pipelines(sink, false); + ret = __fimc_md_modify_pipelines(sink, false, graph); #if 0 else /* TODO: Link state change validation */ #endif /* After link activation */ - } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && - (link->flags & MEDIA_LNK_FL_ENABLED)) { - ret = __fimc_md_modify_pipelines(sink, true); + } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH) { + if (link->flags & MEDIA_LNK_FL_ENABLED) + ret = __fimc_md_modify_pipelines(sink, true, graph); + media_entity_graph_walk_cleanup(graph); } return ret ? -EPIPE : 0; diff --git a/drivers/media/platform/exynos4-is/media-dev.h b/drivers/media/platform/exynos4-is/media-dev.h index e8845e1f5aab..ed122cb2dd74 100644 --- a/drivers/media/platform/exynos4-is/media-dev.h +++ b/drivers/media/platform/exynos4-is/media-dev.h @@ -154,6 +154,7 @@ struct fimc_md { bool user_subdev_api; spinlock_t slock; struct list_head pipelines; + struct media_entity_graph link_setup_graph; }; static inline -- cgit v1.2.3 From 08613c549ff5ac98d04d9dd28a4ffafa3918e2ca Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:26 -0200 Subject: [media] v4l: xilinx: Use the new media graph walk interface The media graph walk requires initialisation and cleanup soon. Update the users to perform the soon necessary API calls. Signed-off-by: Sakari Ailus Cc: Hyun Kwon Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/xilinx/xilinx-dma.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/media/platform/xilinx/xilinx-dma.c b/drivers/media/platform/xilinx/xilinx-dma.c index 0181ff402a5a..7f6898b13cac 100644 --- a/drivers/media/platform/xilinx/xilinx-dma.c +++ b/drivers/media/platform/xilinx/xilinx-dma.c @@ -182,10 +182,17 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe, struct media_device *mdev = entity->graph_obj.mdev; unsigned int num_inputs = 0; unsigned int num_outputs = 0; + int ret; mutex_lock(&mdev->graph_mutex); /* Walk the graph to locate the video nodes. */ + ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); + if (ret) { + mutex_unlock(&mdev->graph_mutex); + return ret; + } + media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { @@ -206,6 +213,8 @@ static int xvip_pipeline_validate(struct xvip_pipeline *pipe, mutex_unlock(&mdev->graph_mutex); + media_entity_graph_walk_cleanup(&graph); + /* We need exactly one output and zero or one input. */ if (num_outputs != 1 || num_inputs > 1) return -EPIPE; -- cgit v1.2.3 From c1a5f1bc0b7a585efaeda40c1eb8f5f4bd9d328d Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 15:32:27 +0200 Subject: [media] v4l: vsp1: Use the new media graph walk interface The media graph walk requires initialisation and cleanup soon. Update the users to perform the soon necessary API calls. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vsp1/vsp1_video.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index e3304303dce3..a6b1bd1225ef 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -386,6 +386,12 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe, mutex_lock(&mdev->graph_mutex); /* Walk the graph to locate the entities and video nodes. */ + ret = media_entity_graph_walk_init(&graph, mdev); + if (ret) { + mutex_unlock(&mdev->graph_mutex); + return ret; + } + media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { @@ -419,6 +425,8 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe, mutex_unlock(&mdev->graph_mutex); + media_entity_graph_walk_cleanup(&graph); + /* We need one output and at least one input. */ if (pipe->num_inputs == 0 || !pipe->output) { ret = -EPIPE; -- cgit v1.2.3 From 29d8da02d13020a18929a30692d454bd863d4207 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:28 -0200 Subject: [media] media: Use entity enums in graph walk This will also mean that the necessary graph related data structures will be allocated dynamically, removing the need for maximum ID checks. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 16 ++++++---------- include/media/media-entity.h | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 85af715d2a20..86a8396f6ec2 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -296,7 +296,7 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph) __must_check int media_entity_graph_walk_init( struct media_entity_graph *graph, struct media_device *mdev) { - return 0; + return media_entity_enum_init(&graph->ent_enum, mdev); } EXPORT_SYMBOL_GPL(media_entity_graph_walk_init); @@ -306,20 +306,18 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_init); */ void media_entity_graph_walk_cleanup(struct media_entity_graph *graph) { + media_entity_enum_cleanup(&graph->ent_enum); } EXPORT_SYMBOL_GPL(media_entity_graph_walk_cleanup); void media_entity_graph_walk_start(struct media_entity_graph *graph, struct media_entity *entity) { + media_entity_enum_zero(&graph->ent_enum); + media_entity_enum_set(&graph->ent_enum, entity); + graph->top = 0; graph->stack[graph->top].entity = NULL; - bitmap_zero(graph->entities, MEDIA_ENTITY_ENUM_MAX_ID); - - if (WARN_ON(media_entity_id(entity) >= MEDIA_ENTITY_ENUM_MAX_ID)) - return; - - __set_bit(media_entity_id(entity), graph->entities); stack_push(graph, entity); } EXPORT_SYMBOL_GPL(media_entity_graph_walk_start); @@ -350,11 +348,9 @@ media_entity_graph_walk_next(struct media_entity_graph *graph) /* Get the entity in the other end of the link . */ next = media_entity_other(entity, link); - if (WARN_ON(media_entity_id(next) >= MEDIA_ENTITY_ENUM_MAX_ID)) - return NULL; /* Has the entity already been visited? */ - if (__test_and_set_bit(media_entity_id(next), graph->entities)) { + if (media_entity_enum_test_and_set(&graph->ent_enum, next)) { link_top(graph) = link_top(graph)->next; continue; } diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 7f028ea84911..a53acb099c16 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -103,7 +103,7 @@ struct media_entity_enum { * @stack: Graph traversal stack; the stack contains information * on the path the media entities to be walked and the * links through which they were reached. - * @entities: Visited entities + * @ent_enum: Visited entities * @top: The top of the stack */ struct media_entity_graph { @@ -112,7 +112,7 @@ struct media_entity_graph { struct list_head *link; } stack[MEDIA_ENTITY_ENUM_MAX_DEPTH]; - DECLARE_BITMAP(entities, MEDIA_ENTITY_ENUM_MAX_ID); + struct media_entity_enum ent_enum; int top; }; -- cgit v1.2.3 From 74a4133079f739eb2f4604263fdb974ce10120a8 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:29 -0200 Subject: [media] media: Keep using the same graph walk object for a given pipeline Initialise a given graph walk object once, and then keep using it whilst the same pipeline is running. Once the pipeline is stopped, release the graph walk object. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 17 +++++++++++------ include/media/media-entity.h | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 86a8396f6ec2..3cad525c2ac1 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -379,10 +379,10 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, mutex_lock(&mdev->graph_mutex); - ret = media_entity_graph_walk_init(&pipe->graph, mdev); - if (ret) { - mutex_unlock(&mdev->graph_mutex); - return ret; + if (!pipe->streaming_count++) { + ret = media_entity_graph_walk_init(&pipe->graph, mdev); + if (ret) + goto error_graph_walk_start; } media_entity_graph_walk_start(&pipe->graph, entity); @@ -483,7 +483,9 @@ error: break; } - media_entity_graph_walk_cleanup(graph); +error_graph_walk_start: + if (!--pipe->streaming_count) + media_entity_graph_walk_cleanup(graph); mutex_unlock(&mdev->graph_mutex); @@ -495,9 +497,11 @@ void media_entity_pipeline_stop(struct media_entity *entity) { struct media_device *mdev = entity->graph_obj.mdev; struct media_entity_graph *graph = &entity->pipe->graph; + struct media_pipeline *pipe = entity->pipe; mutex_lock(&mdev->graph_mutex); + WARN_ON(!pipe->streaming_count); media_entity_graph_walk_start(graph, entity); while ((entity = media_entity_graph_walk_next(graph))) { @@ -506,7 +510,8 @@ void media_entity_pipeline_stop(struct media_entity *entity) entity->pipe = NULL; } - media_entity_graph_walk_cleanup(graph); + if (!--pipe->streaming_count) + media_entity_graph_walk_cleanup(graph); mutex_unlock(&mdev->graph_mutex); } diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a53acb099c16..a47a7c8a93cf 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -119,9 +119,11 @@ struct media_entity_graph { /* * struct media_pipeline - Media pipeline related information * - * @graph: Media graph walk during pipeline start / stop + * @streaming_count: Streaming start count - streaming stop count + * @graph: Media graph walk during pipeline start / stop */ struct media_pipeline { + int streaming_count; struct media_entity_graph graph; }; -- cgit v1.2.3 From 17d3d4058a61329a6a4384054da6a57c65c7e8ba Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:30 -0200 Subject: [media] v4l: omap3isp: Use media entity enumeration interface Instead of using a bitmap directly in a driver, use the new media entity enumeration interface to perform the same. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/omap3isp/isp.c | 21 +++++++++++++-------- drivers/media/platform/omap3isp/isp.h | 5 +++-- drivers/media/platform/omap3isp/ispccdc.c | 2 +- drivers/media/platform/omap3isp/ispvideo.c | 20 ++++++++++++++------ drivers/media/platform/omap3isp/ispvideo.h | 4 ++-- 5 files changed, 33 insertions(+), 19 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 581c50e86621..0bcfa553c1aa 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -896,7 +896,7 @@ static int isp_pipeline_enable(struct isp_pipeline *pipe, * starting entities if the pipeline won't start anyway (those entities * would then likely fail to stop, making the problem worse). */ - if (pipe->entities & isp->crashed) + if (media_entity_enum_intersects(&pipe->ent_enum, &isp->crashed)) return -EIO; spin_lock_irqsave(&pipe->lock, flags); @@ -989,7 +989,6 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe) struct v4l2_subdev *subdev; int failure = 0; int ret; - u32 id; /* * We need to stop all the modules after CCDC first or they'll @@ -1041,10 +1040,9 @@ static int isp_pipeline_disable(struct isp_pipeline *pipe) if (ret) { dev_info(isp->dev, "Unable to stop %s\n", subdev->name); isp->stop_failure = true; - if (subdev == &isp->isp_prev.subdev) { - id = media_entity_id(&subdev->entity); - isp->crashed |= 1U << id; - } + if (subdev == &isp->isp_prev.subdev) + media_entity_enum_set(&isp->crashed, + &subdev->entity); failure = -ETIMEDOUT; } } @@ -1250,7 +1248,7 @@ static int isp_reset(struct isp_device *isp) } isp->stop_failure = false; - isp->crashed = 0; + media_entity_enum_zero(&isp->crashed); return 0; } @@ -1661,7 +1659,8 @@ static void __omap3isp_put(struct isp_device *isp, bool save_ctx) /* Reset the ISP if an entity has failed to stop. This is the * only way to recover from such conditions. */ - if (isp->crashed || isp->stop_failure) + if (!media_entity_enum_empty(&isp->crashed) || + isp->stop_failure) isp_reset(isp); isp_disable_clocks(isp); } @@ -2219,6 +2218,8 @@ static int isp_remove(struct platform_device *pdev) isp_detach_iommu(isp); __omap3isp_put(isp, false); + media_entity_enum_cleanup(&isp->crashed); + return 0; } @@ -2366,6 +2367,10 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) struct isp_bus_cfg *bus; int ret; + ret = media_entity_enum_init(&isp->crashed, &isp->media_dev); + if (ret) + return ret; + list_for_each_entry(sd, &v4l2_dev->subdevs, list) { /* Only try to link entities whose interface was set on bound */ if (sd->host_priv) { diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h index b6f81f20aa73..49b7f71ac968 100644 --- a/drivers/media/platform/omap3isp/isp.h +++ b/drivers/media/platform/omap3isp/isp.h @@ -17,6 +17,7 @@ #ifndef OMAP3_ISP_CORE_H #define OMAP3_ISP_CORE_H +#include #include #include #include @@ -152,7 +153,7 @@ struct isp_xclk { * @stat_lock: Spinlock for handling statistics * @isp_mutex: Mutex for serializing requests to ISP. * @stop_failure: Indicates that an entity failed to stop. - * @crashed: Bitmask of crashed entities (indexed by entity ID) + * @crashed: Crashed ent_enum * @has_context: Context has been saved at least once and can be restored. * @ref_count: Reference count for handling multiple ISP requests. * @cam_ick: Pointer to camera interface clock structure. @@ -195,7 +196,7 @@ struct isp_device { spinlock_t stat_lock; /* common lock for statistic drivers */ struct mutex isp_mutex; /* For handling ref_count field */ bool stop_failure; - u32 crashed; + struct media_entity_enum crashed; int has_context; int ref_count; unsigned int autoidle; diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c index 4eaf926d6073..bb3974c98e37 100644 --- a/drivers/media/platform/omap3isp/ispccdc.c +++ b/drivers/media/platform/omap3isp/ispccdc.c @@ -1608,7 +1608,7 @@ static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc) /* Wait for the CCDC to become idle. */ if (ccdc_sbl_wait_idle(ccdc, 1000)) { dev_info(isp->dev, "CCDC won't become idle!\n"); - isp->crashed |= 1U << media_entity_id(&ccdc->subdev.entity); + media_entity_enum_set(&isp->crashed, &ccdc->subdev.entity); omap3isp_pipeline_cancel_stream(pipe); return 0; } diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index 33123f112151..994dfc0813f6 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -241,7 +241,7 @@ static int isp_video_get_graph_data(struct isp_video *video, while ((entity = media_entity_graph_walk_next(&graph))) { struct isp_video *__video; - pipe->entities |= 1 << media_entity_id(entity); + media_entity_enum_set(&pipe->ent_enum, entity); if (far_end != NULL) continue; @@ -901,7 +901,6 @@ static int isp_video_check_external_subdevs(struct isp_video *video, struct v4l2_ext_control ctrl; unsigned int i; int ret; - u32 id; /* Memory-to-memory pipelines have no external subdev. */ if (pipe->input != NULL) @@ -909,7 +908,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video, for (i = 0; i < ARRAY_SIZE(ents); i++) { /* Is the entity part of the pipeline? */ - if (!(pipe->entities & (1 << media_entity_id(ents[i])))) + if (!media_entity_enum_test(&pipe->ent_enum, ents[i])) continue; /* ISP entities have always sink pad == 0. Find source. */ @@ -961,8 +960,8 @@ static int isp_video_check_external_subdevs(struct isp_video *video, pipe->external_rate = ctrl.value64; - id = media_entity_id(&isp->isp_ccdc.subdev.entity); - if (pipe->entities & (1 << id)) { + if (media_entity_enum_test(&pipe->ent_enum, + &isp->isp_ccdc.subdev.entity)) { unsigned int rate = UINT_MAX; /* * Check that maximum allowed CCDC pixel rate isn't @@ -1028,7 +1027,9 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) pipe = video->video.entity.pipe ? to_isp_pipeline(&video->video.entity) : &video->pipe; - pipe->entities = 0; + ret = media_entity_enum_init(&pipe->ent_enum, &video->isp->media_dev); + if (ret) + goto err_enum_init; /* TODO: Implement PM QoS */ pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]); @@ -1102,6 +1103,7 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) } mutex_unlock(&video->stream_lock); + return 0; err_set_stream: @@ -1122,7 +1124,11 @@ err_pipeline_start: INIT_LIST_HEAD(&video->dmaqueue); video->queue = NULL; + media_entity_enum_cleanup(&pipe->ent_enum); + +err_enum_init: mutex_unlock(&video->stream_lock); + return ret; } @@ -1174,6 +1180,8 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) /* TODO: Implement PM QoS */ media_entity_pipeline_stop(&video->video.entity); + media_entity_enum_cleanup(&pipe->ent_enum); + done: mutex_unlock(&video->stream_lock); return 0; diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h index a340165732db..156429878d64 100644 --- a/drivers/media/platform/omap3isp/ispvideo.h +++ b/drivers/media/platform/omap3isp/ispvideo.h @@ -80,7 +80,7 @@ enum isp_pipeline_state { * struct isp_pipeline - An ISP hardware pipeline * @field: The field being processed by the pipeline * @error: A hardware error occurred during capture - * @entities: Bitmask of entities in the pipeline (indexed by entity ID) + * @ent_enum: Entities in the pipeline */ struct isp_pipeline { struct media_pipeline pipe; @@ -89,7 +89,7 @@ struct isp_pipeline { enum isp_pipeline_stream_state stream_state; struct isp_video *input; struct isp_video *output; - u32 entities; + struct media_entity_enum ent_enum; unsigned long l3_ick; unsigned int max_rate; enum v4l2_field field; -- cgit v1.2.3 From 54b5a749b4f3010b3b657507b8ef1eee3a100b09 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:31 -0200 Subject: [media] v4l: vsp1: Use media entity enumeration interface Instead of using a bitmap directly in a driver, use the new media entity enumeration interface to perform the same. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vsp1/vsp1_video.c | 45 ++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c index a6b1bd1225ef..637d0d6f79fb 100644 --- a/drivers/media/platform/vsp1/vsp1_video.c +++ b/drivers/media/platform/vsp1/vsp1_video.c @@ -282,24 +282,35 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe, struct vsp1_rwpf *output) { struct vsp1_entity *entity; - unsigned int entities = 0; + struct media_entity_enum ent_enum; struct media_pad *pad; + int rval; bool bru_found = false; input->location.left = 0; input->location.top = 0; + rval = media_entity_enum_init( + &ent_enum, input->entity.pads[RWPF_PAD_SOURCE].graph_obj.mdev); + if (rval) + return rval; + pad = media_entity_remote_pad(&input->entity.pads[RWPF_PAD_SOURCE]); while (1) { - if (pad == NULL) - return -EPIPE; + if (pad == NULL) { + rval = -EPIPE; + goto out; + } /* We've reached a video node, that shouldn't have happened. */ - if (!is_media_entity_v4l2_subdev(pad->entity)) - return -EPIPE; + if (!is_media_entity_v4l2_subdev(pad->entity)) { + rval = -EPIPE; + goto out; + } - entity = to_vsp1_entity(media_entity_to_v4l2_subdev(pad->entity)); + entity = to_vsp1_entity( + media_entity_to_v4l2_subdev(pad->entity)); /* A BRU is present in the pipeline, store the compose rectangle * location in the input RPF for use when configuring the RPF. @@ -322,15 +333,18 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe, break; /* Ensure the branch has no loop. */ - if (entities & (1 << media_entity_id(&entity->subdev.entity))) - return -EPIPE; - - entities |= 1 << media_entity_id(&entity->subdev.entity); + if (media_entity_enum_test_and_set(&ent_enum, + &entity->subdev.entity)) { + rval = -EPIPE; + goto out; + } /* UDS can't be chained. */ if (entity->type == VSP1_ENTITY_UDS) { - if (pipe->uds) - return -EPIPE; + if (pipe->uds) { + rval = -EPIPE; + goto out; + } pipe->uds = entity; pipe->uds_input = bru_found ? pipe->bru @@ -348,9 +362,12 @@ static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe, /* The last entity must be the output WPF. */ if (entity != &output->entity) - return -EPIPE; + rval = -EPIPE; - return 0; +out: + media_entity_enum_cleanup(&ent_enum); + + return rval; } static void __vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe) -- cgit v1.2.3 From ad92b5cf35adc2d3ec0116f4744561d5405a0db7 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:32 -0200 Subject: [media] staging: v4l: omap4iss: Fix sub-device power management code The same bug was present in the omap4iss driver as was in the omap3isp driver. The code got copied to the omap4iss driver while broken. Fix the omap4iss driver as well. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index 7209b92b1f86..2f7a9bb0a9e7 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -533,14 +533,14 @@ static int iss_pipeline_link_notify(struct media_link *link, u32 flags, int ret; if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && - !(link->flags & MEDIA_LNK_FL_ENABLED)) { + !(flags & MEDIA_LNK_FL_ENABLED)) { /* Powering off entities is assumed to never fail. */ iss_pipeline_pm_power(source, -sink_use); iss_pipeline_pm_power(sink, -source_use); return 0; } - if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && + if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH && (flags & MEDIA_LNK_FL_ENABLED)) { ret = iss_pipeline_pm_power(source, sink_use); if (ret < 0) -- cgit v1.2.3 From 6246b2a7ad1ffab5a712c38005b668f3e4ca2825 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:33 -0200 Subject: [media] staging: v4l: omap4iss: Use media entity enumeration interface Instead of using a bitmap directly in a driver, use the new media entity enumeration interface to perform the same. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss.c | 15 +++++++++++---- drivers/staging/media/omap4iss/iss.h | 4 ++-- drivers/staging/media/omap4iss/iss_video.c | 23 ++++++++++++++++------- drivers/staging/media/omap4iss/iss_video.h | 4 ++-- 4 files changed, 31 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index 2f7a9bb0a9e7..6f57f41511d5 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -606,7 +606,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe, * crashed. Mark it as such, the ISS will be reset when * applications will release it. */ - iss->crashed |= 1U << media_entity_id(&subdev->entity); + media_entity_enum_set(&iss->crashed, &subdev->entity); failure = -ETIMEDOUT; } } @@ -641,7 +641,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe, * pipeline won't start anyway (those entities would then likely fail to * stop, making the problem worse). */ - if (pipe->entities & iss->crashed) + if (media_entity_enum_intersects(&pipe->ent_enum, &iss->crashed)) return -EIO; spin_lock_irqsave(&pipe->lock, flags); @@ -761,7 +761,8 @@ static int iss_reset(struct iss_device *iss) return -ETIMEDOUT; } - iss->crashed = 0; + media_entity_enum_zero(&iss->crashed); + return 0; } @@ -1090,7 +1091,7 @@ void omap4iss_put(struct iss_device *iss) * be worth investigating whether resetting the ISP only can't * fix the problem in some cases. */ - if (iss->crashed) + if (!media_entity_enum_empty(&iss->crashed)) iss_reset(iss); iss_disable_clocks(iss); } @@ -1491,6 +1492,10 @@ static int iss_probe(struct platform_device *pdev) if (ret < 0) goto error_modules; + ret = media_entity_enum_init(&iss->crashed, &iss->media_dev); + if (ret) + goto error_entities; + ret = iss_create_links(iss); if (ret < 0) goto error_entities; @@ -1501,6 +1506,7 @@ static int iss_probe(struct platform_device *pdev) error_entities: iss_unregister_entities(iss); + media_entity_enum_cleanup(&iss->crashed); error_modules: iss_cleanup_modules(iss); error_iss: @@ -1518,6 +1524,7 @@ static int iss_remove(struct platform_device *pdev) struct iss_device *iss = platform_get_drvdata(pdev); iss_unregister_entities(iss); + media_entity_enum_cleanup(&iss->crashed); iss_cleanup_modules(iss); return 0; diff --git a/drivers/staging/media/omap4iss/iss.h b/drivers/staging/media/omap4iss/iss.h index 5929357fe687..693a8f112960 100644 --- a/drivers/staging/media/omap4iss/iss.h +++ b/drivers/staging/media/omap4iss/iss.h @@ -82,7 +82,7 @@ struct iss_reg { /* * struct iss_device - ISS device structure. * @syscon: Regmap for the syscon register space - * @crashed: Bitmask of crashed entities (indexed by entity ID) + * @crashed: Crashed entities */ struct iss_device { struct v4l2_device v4l2_dev; @@ -101,7 +101,7 @@ struct iss_device { u64 raw_dmamask; struct mutex iss_mutex; /* For handling ref_count field */ - unsigned int crashed; + struct media_entity_enum crashed; int has_context; int ref_count; diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index 8c6af412bc16..5f8201f861bc 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -749,7 +749,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) struct iss_video_fh *vfh = to_iss_video_fh(fh); struct iss_video *video = video_drvdata(file); struct media_entity_graph graph; - struct media_entity *entity; + struct media_entity *entity = &video->video.entity; enum iss_pipeline_state state; struct iss_pipeline *pipe; struct iss_video *far_end; @@ -764,24 +764,26 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) /* Start streaming on the pipeline. No link touching an entity in the * pipeline can be activated or deactivated once streaming is started. */ - pipe = video->video.entity.pipe - ? to_iss_pipeline(&video->video.entity) : &video->pipe; + pipe = entity->pipe + ? to_iss_pipeline(entity) : &video->pipe; pipe->external = NULL; pipe->external_rate = 0; pipe->external_bpp = 0; - pipe->entities = 0; + + ret = media_entity_enum_init(&pipe->ent_enum, entity->graph_obj.mdev); + if (ret) + goto err_enum_init; if (video->iss->pdata->set_constraints) video->iss->pdata->set_constraints(video->iss, true); - ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); + ret = media_entity_pipeline_start(entity, &pipe->pipe); if (ret < 0) goto err_media_entity_pipeline_start; - entity = &video->video.entity; media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) - pipe->entities |= 1 << media_entity_id(entity); + media_entity_enum_set(&pipe->ent_enum, entity); /* Verify that the currently configured format matches the output of * the connected subdev. @@ -852,6 +854,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) } mutex_unlock(&video->stream_lock); + return 0; err_omap4iss_set_stream: @@ -863,7 +866,11 @@ err_media_entity_pipeline_start: video->iss->pdata->set_constraints(video->iss, false); video->queue = NULL; + media_entity_enum_cleanup(&pipe->ent_enum); + +err_enum_init: mutex_unlock(&video->stream_lock); + return ret; } @@ -901,6 +908,8 @@ iss_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) vb2_streamoff(&vfh->queue, type); video->queue = NULL; + media_entity_enum_cleanup(&pipe->ent_enum); + if (video->iss->pdata->set_constraints) video->iss->pdata->set_constraints(video->iss, false); media_entity_pipeline_stop(&video->video.entity); diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h index 41532eda1277..c8bd2958a3f8 100644 --- a/drivers/staging/media/omap4iss/iss_video.h +++ b/drivers/staging/media/omap4iss/iss_video.h @@ -77,7 +77,7 @@ enum iss_pipeline_state { /* * struct iss_pipeline - An OMAP4 ISS hardware pipeline - * @entities: Bitmask of entities in the pipeline (indexed by entity ID) + * @ent_enum: Entities in the pipeline * @error: A hardware error occurred during capture */ struct iss_pipeline { @@ -87,7 +87,7 @@ struct iss_pipeline { enum iss_pipeline_stream_state stream_state; struct iss_video *input; struct iss_video *output; - unsigned int entities; + struct media_entity_enum ent_enum; atomic_t frame_number; bool do_propagation; /* of frame number */ bool error; -- cgit v1.2.3 From 809fe79a5f59621202a30c248349a50765b98e1c Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:34 -0200 Subject: [media] staging: v4l: omap4iss: Use the new media graph walk interface The media graph walk requires initialisation and cleanup soon. Update the users to perform the soon necessary API calls. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap4iss/iss.c | 59 +++++++++++++++++++----------- drivers/staging/media/omap4iss/iss.h | 4 +- drivers/staging/media/omap4iss/iss_video.c | 33 +++++++++++++++-- drivers/staging/media/omap4iss/iss_video.h | 1 + 4 files changed, 70 insertions(+), 27 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index 6f57f41511d5..30b473cfb020 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -389,14 +389,14 @@ static irqreturn_t iss_isr(int irq, void *_iss) * * Return the total number of users of all video device nodes in the pipeline. */ -static int iss_pipeline_pm_use_count(struct media_entity *entity) +static int iss_pipeline_pm_use_count(struct media_entity *entity, + struct media_entity_graph *graph) { - struct media_entity_graph graph; int use = 0; - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + while ((entity = media_entity_graph_walk_next(graph))) { if (is_media_entity_v4l2_io(entity)) use += entity->use_count; } @@ -449,27 +449,27 @@ static int iss_pipeline_pm_power_one(struct media_entity *entity, int change) * * Return 0 on success or a negative error code on failure. */ -static int iss_pipeline_pm_power(struct media_entity *entity, int change) +static int iss_pipeline_pm_power(struct media_entity *entity, int change, + struct media_entity_graph *graph) { - struct media_entity_graph graph; struct media_entity *first = entity; int ret = 0; if (!change) return 0; - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while (!ret && (entity = media_entity_graph_walk_next(&graph))) + while (!ret && (entity = media_entity_graph_walk_next(graph))) if (is_media_entity_v4l2_subdev(entity)) ret = iss_pipeline_pm_power_one(entity, change); if (!ret) return 0; - media_entity_graph_walk_start(&graph, first); + media_entity_graph_walk_start(graph, first); - while ((first = media_entity_graph_walk_next(&graph)) && + while ((first = media_entity_graph_walk_next(graph)) && first != entity) if (is_media_entity_v4l2_subdev(first)) iss_pipeline_pm_power_one(first, -change); @@ -489,7 +489,8 @@ static int iss_pipeline_pm_power(struct media_entity *entity, int change) * off is assumed to never fail. No failure can occur when the use parameter is * set to 0. */ -int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) +int omap4iss_pipeline_pm_use(struct media_entity *entity, int use, + struct media_entity_graph *graph) { int change = use ? 1 : -1; int ret; @@ -501,7 +502,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) WARN_ON(entity->use_count < 0); /* Apply power change to connected non-nodes. */ - ret = iss_pipeline_pm_power(entity, change); + ret = iss_pipeline_pm_power(entity, change, graph); if (ret < 0) entity->use_count -= change; @@ -526,34 +527,48 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) static int iss_pipeline_link_notify(struct media_link *link, u32 flags, unsigned int notification) { + struct media_entity_graph *graph = + &container_of(link->graph_obj.mdev, struct iss_device, + media_dev)->pm_count_graph; struct media_entity *source = link->source->entity; struct media_entity *sink = link->sink->entity; - int source_use = iss_pipeline_pm_use_count(source); - int sink_use = iss_pipeline_pm_use_count(sink); + int source_use; + int sink_use; int ret; + if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) { + ret = media_entity_graph_walk_init(graph, + link->graph_obj.mdev); + if (ret) + return ret; + } + + source_use = iss_pipeline_pm_use_count(source, graph); + sink_use = iss_pipeline_pm_use_count(sink, graph); + if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && !(flags & MEDIA_LNK_FL_ENABLED)) { /* Powering off entities is assumed to never fail. */ - iss_pipeline_pm_power(source, -sink_use); - iss_pipeline_pm_power(sink, -source_use); + iss_pipeline_pm_power(source, -sink_use, graph); + iss_pipeline_pm_power(sink, -source_use, graph); return 0; } if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH && (flags & MEDIA_LNK_FL_ENABLED)) { - ret = iss_pipeline_pm_power(source, sink_use); + ret = iss_pipeline_pm_power(source, sink_use, graph); if (ret < 0) return ret; - ret = iss_pipeline_pm_power(sink, source_use); + ret = iss_pipeline_pm_power(sink, source_use, graph); if (ret < 0) - iss_pipeline_pm_power(source, -sink_use); - - return ret; + iss_pipeline_pm_power(source, -sink_use, graph); } - return 0; + if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH) + media_entity_graph_walk_cleanup(graph); + + return ret; } /* ----------------------------------------------------------------------------- diff --git a/drivers/staging/media/omap4iss/iss.h b/drivers/staging/media/omap4iss/iss.h index 693a8f112960..05f08a3caa19 100644 --- a/drivers/staging/media/omap4iss/iss.h +++ b/drivers/staging/media/omap4iss/iss.h @@ -87,6 +87,7 @@ struct iss_reg { struct iss_device { struct v4l2_device v4l2_dev; struct media_device media_dev; + struct media_entity_graph pm_count_graph; struct device *dev; u32 revision; @@ -151,7 +152,8 @@ void omap4iss_isp_subclk_enable(struct iss_device *iss, void omap4iss_isp_subclk_disable(struct iss_device *iss, enum iss_isp_subclk_resource res); -int omap4iss_pipeline_pm_use(struct media_entity *entity, int use); +int omap4iss_pipeline_pm_use(struct media_entity *entity, int use, + struct media_entity_graph *graph); int omap4iss_register_entities(struct platform_device *pdev, struct v4l2_device *v4l2_dev); diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index 5f8201f861bc..058233a9de67 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -209,6 +209,12 @@ iss_video_far_end(struct iss_video *video) struct iss_video *far_end = NULL; mutex_lock(&mdev->graph_mutex); + + if (media_entity_graph_walk_init(&graph, mdev)) { + mutex_unlock(&mdev->graph_mutex); + return NULL; + } + media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { @@ -226,6 +232,9 @@ iss_video_far_end(struct iss_video *video) } mutex_unlock(&mdev->graph_mutex); + + media_entity_graph_walk_cleanup(&graph); + return far_end; } @@ -772,7 +781,11 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) ret = media_entity_enum_init(&pipe->ent_enum, entity->graph_obj.mdev); if (ret) - goto err_enum_init; + goto err_graph_walk_init; + + ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); + if (ret) + goto err_graph_walk_init; if (video->iss->pdata->set_constraints) video->iss->pdata->set_constraints(video->iss, true); @@ -853,6 +866,8 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) spin_unlock_irqrestore(&video->qlock, flags); } + media_entity_graph_walk_cleanup(&graph); + mutex_unlock(&video->stream_lock); return 0; @@ -866,9 +881,11 @@ err_media_entity_pipeline_start: video->iss->pdata->set_constraints(video->iss, false); video->queue = NULL; + media_entity_graph_walk_cleanup(&graph); + +err_graph_walk_init: media_entity_enum_cleanup(&pipe->ent_enum); -err_enum_init: mutex_unlock(&video->stream_lock); return ret; @@ -992,7 +1009,13 @@ static int iss_video_open(struct file *file) goto done; } - ret = omap4iss_pipeline_pm_use(&video->video.entity, 1); + ret = media_entity_graph_walk_init(&handle->graph, + &video->iss->media_dev); + if (ret) + goto done; + + ret = omap4iss_pipeline_pm_use(&video->video.entity, 1, + &handle->graph); if (ret < 0) { omap4iss_put(video->iss); goto done; @@ -1031,6 +1054,7 @@ static int iss_video_open(struct file *file) done: if (ret < 0) { v4l2_fh_del(&handle->vfh); + media_entity_graph_walk_cleanup(&handle->graph); kfree(handle); } @@ -1046,12 +1070,13 @@ static int iss_video_release(struct file *file) /* Disable streaming and free the buffers queue resources. */ iss_video_streamoff(file, vfh, video->type); - omap4iss_pipeline_pm_use(&video->video.entity, 0); + omap4iss_pipeline_pm_use(&video->video.entity, 0, &handle->graph); /* Release the videobuf2 queue */ vb2_queue_release(&handle->queue); /* Release the file handle. */ + media_entity_graph_walk_cleanup(&handle->graph); v4l2_fh_del(vfh); kfree(handle); file->private_data = NULL; diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h index c8bd2958a3f8..34588b7176ca 100644 --- a/drivers/staging/media/omap4iss/iss_video.h +++ b/drivers/staging/media/omap4iss/iss_video.h @@ -183,6 +183,7 @@ struct iss_video_fh { struct vb2_queue queue; struct v4l2_format format; struct v4l2_fract timeperframe; + struct media_entity_graph graph; }; #define to_iss_video_fh(fh) container_of(fh, struct iss_video_fh, vfh) -- cgit v1.2.3 From bb0faebdc1d377705081fed67af3f3f3001ac7b8 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:35 -0200 Subject: [media] staging: v4l: davinci_vpbe: Use the new media graph walk interface The media graph walk requires initialisation and cleanup soon. Update the users to perform the soon necessary API calls. Signed-off-by: Sakari Ailus Cc: Prabhakar Lad Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/davinci_vpfe/vpfe_video.c | 37 ++++++++++++++++++------- drivers/staging/media/davinci_vpfe/vpfe_video.h | 1 + 2 files changed, 28 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 285dc1a69b2c..3ec7e65a3ffa 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -127,13 +127,14 @@ __vpfe_video_get_format(struct vpfe_video_device *video, } /* make a note of pipeline details */ -static void vpfe_prepare_pipeline(struct vpfe_video_device *video) +static int vpfe_prepare_pipeline(struct vpfe_video_device *video) { + struct media_entity_graph graph; struct media_entity *entity = &video->video_dev.entity; struct media_device *mdev = entity->graph_obj.mdev; struct vpfe_pipeline *pipe = &video->pipe; struct vpfe_video_device *far_end = NULL; - struct media_entity_graph graph; + int ret; pipe->input_num = 0; pipe->output_num = 0; @@ -144,6 +145,11 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video) pipe->outputs[pipe->output_num++] = video; mutex_lock(&mdev->graph_mutex); + ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); + if (ret) { + mutex_unlock(&video->lock); + return -ENOMEM; + } media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { if (entity == &video->video_dev.entity) @@ -156,7 +162,10 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video) else pipe->outputs[pipe->output_num++] = far_end; } + media_entity_graph_walk_cleanup(&graph); mutex_unlock(&mdev->graph_mutex); + + return 0; } /* update pipe state selected by user */ @@ -165,7 +174,9 @@ static int vpfe_update_pipe_state(struct vpfe_video_device *video) struct vpfe_pipeline *pipe = &video->pipe; int ret; - vpfe_prepare_pipeline(video); + ret = vpfe_prepare_pipeline(video); + if (ret) + return ret; /* Find out if there is any input video if yes, it is single shot. @@ -276,11 +287,10 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe) */ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) { - struct media_entity_graph graph; struct media_entity *entity; struct v4l2_subdev *subdev; struct media_device *mdev; - int ret = 0; + int ret; if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS) entity = vpfe_get_input_entity(pipe->outputs[0]); @@ -289,8 +299,12 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) mdev = entity->graph_obj.mdev; mutex_lock(&mdev->graph_mutex); - media_entity_graph_walk_start(&graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + ret = media_entity_graph_walk_init(&pipe->graph, + entity->graph_obj.mdev); + if (ret) + goto out; + media_entity_graph_walk_start(&pipe->graph, entity); + while ((entity = media_entity_graph_walk_next(&pipe->graph))) { if (!is_media_entity_v4l2_subdev(entity)) continue; @@ -299,6 +313,9 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) if (ret < 0 && ret != -ENOIOCTLCMD) break; } +out: + if (ret) + media_entity_graph_walk_cleanup(&pipe->graph); mutex_unlock(&mdev->graph_mutex); return ret; } @@ -316,7 +333,6 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) */ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) { - struct media_entity_graph graph; struct media_entity *entity; struct v4l2_subdev *subdev; struct media_device *mdev; @@ -329,9 +345,9 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) mdev = entity->graph_obj.mdev; mutex_lock(&mdev->graph_mutex); - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(&pipe->graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + while ((entity = media_entity_graph_walk_next(&pipe->graph))) { if (!is_media_entity_v4l2_subdev(entity)) continue; @@ -342,6 +358,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) } mutex_unlock(&mdev->graph_mutex); + media_entity_graph_walk_cleanup(&pipe->graph); return ret ? -ETIMEDOUT : 0; } diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h b/drivers/staging/media/davinci_vpfe/vpfe_video.h index 673cefe3ef61..653334d537d3 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.h +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h @@ -52,6 +52,7 @@ enum vpfe_video_state { struct vpfe_pipeline { /* media pipeline */ struct media_pipeline *pipe; + struct media_entity_graph graph; /* state of the pipeline, continuous, * single-shot or stopped */ -- cgit v1.2.3 From 030e89ecab55b6e105e19fa830a7a7160237f19a Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:36 -0200 Subject: [media] media: Remove pre-allocated entity enumeration bitmap The bitmaps for entity enumerations used to be statically allocated. Now that the drivers have been converted to use the new interface which explicitly initialises the enum objects, drop the pre-allocated bitmaps. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 16 +++++----------- include/media/media-entity.h | 9 ++------- 2 files changed, 7 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 3cad525c2ac1..5bd6f88501e2 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -81,14 +81,10 @@ static inline const char *intf_type(struct media_interface *intf) __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, int idx_max) { - if (idx_max > MEDIA_ENTITY_ENUM_MAX_ID) { - ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG), - sizeof(long), GFP_KERNEL); - if (!ent_enum->bmap) - return -ENOMEM; - } else { - ent_enum->bmap = ent_enum->prealloc_bmap; - } + ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG), + sizeof(long), GFP_KERNEL); + if (!ent_enum->bmap) + return -ENOMEM; bitmap_zero(ent_enum->bmap, idx_max); ent_enum->idx_max = idx_max; @@ -104,9 +100,7 @@ EXPORT_SYMBOL_GPL(__media_entity_enum_init); */ void media_entity_enum_cleanup(struct media_entity_enum *ent_enum) { - if (ent_enum->bmap != ent_enum->prealloc_bmap) - kfree(ent_enum->bmap); - ent_enum->bmap = NULL; + kfree(ent_enum->bmap); } EXPORT_SYMBOL_GPL(media_entity_enum_cleanup); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a47a7c8a93cf..4d963a3684c9 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -72,27 +72,22 @@ struct media_gobj { }; #define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 -#define MEDIA_ENTITY_ENUM_MAX_ID 64 /* * The number of pads can't be bigger than the number of entities, * as the worse-case scenario is to have one entity linked up to - * MEDIA_ENTITY_ENUM_MAX_ID - 1 entities. + * 63 entities. */ -#define MEDIA_ENTITY_MAX_PADS (MEDIA_ENTITY_ENUM_MAX_ID - 1) +#define MEDIA_ENTITY_MAX_PADS 63 /** * struct media_entity_enum - An enumeration of media entities. * - * @prealloc_bmap: Pre-allocated space reserved for media entities if the - * total number of entities does not exceed - * MEDIA_ENTITY_ENUM_MAX_ID. * @bmap: Bit map in which each bit represents one entity at struct * media_entity->internal_idx. * @idx_max: Number of bits in bmap */ struct media_entity_enum { - DECLARE_BITMAP(prealloc_bmap, MEDIA_ENTITY_ENUM_MAX_ID); unsigned long *bmap; int idx_max; }; -- cgit v1.2.3 From 0798ce4a386d605af9ddbed724a8f4c8cccc1dab Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 16 Dec 2015 11:32:37 -0200 Subject: [media] media: Move MEDIA_ENTITY_MAX_PADS from media-entity.h to media-entity.c This isn't really a part of any interface drivers are expected to use. In order to keep drivers from using it, hide it in media-entity.c. This was always an arbitrary number and should be removed in the long run. Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 5 +++++ include/media/media-entity.h | 7 ------- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 5bd6f88501e2..32a5f8cae72d 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -276,6 +276,11 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph) #define link_top(en) ((en)->stack[(en)->top].link) #define stack_top(en) ((en)->stack[(en)->top].entity) +/* + * TODO: Get rid of this. + */ +#define MEDIA_ENTITY_MAX_PADS 63 + /** * media_entity_graph_walk_init - Allocate resources for graph walk * @graph: Media graph structure that will be used to walk the graph diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 4d963a3684c9..f915ed62ac81 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -73,13 +73,6 @@ struct media_gobj { #define MEDIA_ENTITY_ENUM_MAX_DEPTH 16 -/* - * The number of pads can't be bigger than the number of entities, - * as the worse-case scenario is to have one entity linked up to - * 63 entities. - */ -#define MEDIA_ENTITY_MAX_PADS 63 - /** * struct media_entity_enum - An enumeration of media entities. * -- cgit v1.2.3 From 92777994a52e6c1fe0a6156a8b49e83efea6fd2c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 16 Dec 2015 13:53:04 -0200 Subject: [media] move documentation to the header files Some exported functions were still documented at the .c file, instead of documenting at the .h one. Move the documentation to the right place, as we only use headers at media device-drivers.xml DocBook. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 27 --------------------------- drivers/media/media-entity.c | 13 ------------- include/media/media-device.h | 6 ++++++ include/media/media-entity.h | 18 ++++++++++++++++-- 4 files changed, 22 insertions(+), 42 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index ce97f8f196f3..fd67b34dcda3 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -577,13 +577,6 @@ int __must_check media_device_register_entity(struct media_device *mdev, } EXPORT_SYMBOL_GPL(media_device_register_entity); -/** - * media_device_unregister_entity - Unregister an entity - * @entity: The entity - * - * If the entity has never been registered this function will return - * immediately. - */ static void __media_device_unregister_entity(struct media_entity *entity) { struct media_device *mdev = entity->graph_obj.mdev; @@ -627,7 +620,6 @@ void media_device_unregister_entity(struct media_entity *entity) } EXPORT_SYMBOL_GPL(media_device_unregister_entity); - /** * media_device_init() - initialize a media device * @mdev: The media device @@ -652,11 +644,6 @@ void media_device_init(struct media_device *mdev) } EXPORT_SYMBOL_GPL(media_device_init); -/** - * media_device_cleanup() - Cleanup a media device - * @mdev: The media device - * - */ void media_device_cleanup(struct media_device *mdev) { ida_destroy(&mdev->entity_internal_idx); @@ -665,13 +652,6 @@ void media_device_cleanup(struct media_device *mdev) } EXPORT_SYMBOL_GPL(media_device_cleanup); -/** - * __media_device_register() - register a media device - * @mdev: The media device - * @owner: The module owner - * - * returns zero on success or a negative error code. - */ int __must_check __media_device_register(struct media_device *mdev, struct module *owner) { @@ -701,13 +681,6 @@ int __must_check __media_device_register(struct media_device *mdev, } EXPORT_SYMBOL_GPL(__media_device_register); -/** - * media_device_unregister - unregister a media device - * @mdev: The media device - * - * It is safe to call this function on an unregistered - * (but initialised) media device. - */ void media_device_unregister(struct media_device *mdev) { struct media_entity *entity; diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index 32a5f8cae72d..a2d28162213e 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -70,14 +70,6 @@ static inline const char *intf_type(struct media_interface *intf) } }; -/** - * __media_entity_enum_init - Initialise an entity enumeration - * - * @ent_enum: Entity enumeration to be initialised - * @idx_max: Maximum number of entities in the enumeration - * - * Returns zero on success or a negative error code. - */ __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, int idx_max) { @@ -93,11 +85,6 @@ __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, } EXPORT_SYMBOL_GPL(__media_entity_enum_init); -/** - * media_entity_enum_cleanup - Release resources of an entity enumeration - * - * @e: Entity enumeration to be released - */ void media_entity_enum_cleanup(struct media_entity_enum *ent_enum) { kfree(ent_enum->bmap); diff --git a/include/media/media-device.h b/include/media/media-device.h index da4e12ca259c..706afdb22d0d 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -428,6 +428,8 @@ void media_device_cleanup(struct media_device *mdev); * a sysfs attribute. * * Unregistering a media device that hasn't been registered is *NOT* safe. + * + * Return: returns zero on success or a negative error code. */ int __must_check __media_device_register(struct media_device *mdev, struct module *owner); @@ -437,6 +439,10 @@ int __must_check __media_device_register(struct media_device *mdev, * __media_device_unregister() - Unegisters a media device element * * @mdev: pointer to struct &media_device + * + * + * It is safe to call this function on an unregistered (but initialised) + * media device. */ void media_device_unregister(struct media_device *mdev); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index f915ed62ac81..c4aaeb85229c 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -370,9 +370,23 @@ static inline bool is_media_entity_v4l2_subdev(struct media_entity *entity) } } +/** + * __media_entity_enum_init - Initialise an entity enumeration + * + * @ent_enum: Entity enumeration to be initialised + * @idx_max: Maximum number of entities in the enumeration + * + * Return: Returns zero on success or a negative error code. + */ __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, int idx_max); -void media_entity_enum_cleanup(struct media_entity_enum *e); + +/** + * media_entity_enum_cleanup - Release resources of an entity enumeration + * + * @ent_enum: Entity enumeration to be released + */ +void media_entity_enum_cleanup(struct media_entity_enum *ent_enum); /** * media_entity_enum_zero - Clear the entire enum @@ -847,6 +861,7 @@ void media_remove_intf_link(struct media_link *link); * Note: this is an unlocked version of media_remove_intf_links(). */ void __media_remove_intf_links(struct media_interface *intf); + /** * media_remove_intf_links() - remove all links associated with an interface * @@ -861,7 +876,6 @@ void __media_remove_intf_links(struct media_interface *intf); */ void media_remove_intf_links(struct media_interface *intf); - #define media_entity_call(entity, operation, args...) \ (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) -- cgit v1.2.3 From 05b3b77cbbb01180b681bc9211f3d471123809ca Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 16 Dec 2015 14:28:01 -0200 Subject: [media] media-device.h: use just one u32 counter for object ID Instead of using one u32 counter per type for object IDs, use just one counter. With such change, it makes sense to simplify the debug logs too. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 35 +++++++++++++++-------------------- include/media/media-device.h | 10 ++-------- include/media/media-entity.h | 21 ++++++++++----------- 3 files changed, 27 insertions(+), 39 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index a2d28162213e..f63be23e6ed4 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -106,8 +106,8 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) switch (media_type(gobj)) { case MEDIA_GRAPH_ENTITY: dev_dbg(gobj->mdev->dev, - "%s: id 0x%08x entity#%d: '%s'\n", - event_name, gobj->id, media_localid(gobj), + "%s id %u: entity '%s'\n", + event_name, media_id(gobj), gobj_to_entity(gobj)->name); break; case MEDIA_GRAPH_LINK: @@ -115,14 +115,12 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) struct media_link *link = gobj_to_link(gobj); dev_dbg(gobj->mdev->dev, - "%s: id 0x%08x link#%d: %s#%d ==> %s#%d\n", - event_name, gobj->id, media_localid(gobj), - - gobj_type(media_type(link->gobj0)), - media_localid(link->gobj0), - - gobj_type(media_type(link->gobj1)), - media_localid(link->gobj1)); + "%s id %u: %s link id %u ==> id %u\n", + event_name, media_id(gobj), + media_type(link->gobj0) == MEDIA_GRAPH_PAD ? + "data" : "interface", + media_id(link->gobj0), + media_id(link->gobj1)); break; } case MEDIA_GRAPH_PAD: @@ -130,11 +128,10 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) struct media_pad *pad = gobj_to_pad(gobj); dev_dbg(gobj->mdev->dev, - "%s: id 0x%08x %s%spad#%d: '%s':%d\n", - event_name, gobj->id, - pad->flags & MEDIA_PAD_FL_SINK ? " sink " : "", + "%s id %u: %s%spad '%s':%d\n", + event_name, media_id(gobj), + pad->flags & MEDIA_PAD_FL_SINK ? "sink " : "", pad->flags & MEDIA_PAD_FL_SOURCE ? "source " : "", - media_localid(gobj), pad->entity->name, pad->index); break; } @@ -144,8 +141,8 @@ static void dev_dbg_obj(const char *event_name, struct media_gobj *gobj) struct media_intf_devnode *devnode = intf_to_devnode(intf); dev_dbg(gobj->mdev->dev, - "%s: id 0x%08x intf_devnode#%d: %s - major: %d, minor: %d\n", - event_name, gobj->id, media_localid(gobj), + "%s id %u: intf_devnode %s - major: %d, minor: %d\n", + event_name, media_id(gobj), intf_type(intf), devnode->major, devnode->minor); break; @@ -163,21 +160,19 @@ void media_gobj_create(struct media_device *mdev, gobj->mdev = mdev; /* Create a per-type unique object ID */ + gobj->id = media_gobj_gen_id(type, ++mdev->id); + switch (type) { case MEDIA_GRAPH_ENTITY: - gobj->id = media_gobj_gen_id(type, ++mdev->entity_id); list_add_tail(&gobj->list, &mdev->entities); break; case MEDIA_GRAPH_PAD: - gobj->id = media_gobj_gen_id(type, ++mdev->pad_id); list_add_tail(&gobj->list, &mdev->pads); break; case MEDIA_GRAPH_LINK: - gobj->id = media_gobj_gen_id(type, ++mdev->link_id); list_add_tail(&gobj->list, &mdev->links); break; case MEDIA_GRAPH_INTF_DEVNODE: - gobj->id = media_gobj_gen_id(type, ++mdev->intf_devnode_id); list_add_tail(&gobj->list, &mdev->interfaces); break; } diff --git a/include/media/media-device.h b/include/media/media-device.h index 0dc67f2c2d0a..d3855898c3fc 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -275,10 +275,7 @@ struct device; * @driver_version: Device driver version * @topology_version: Monotonic counter for storing the version of the graph * topology. Should be incremented each time the topology changes. - * @entity_id: Unique ID used on the last entity registered - * @pad_id: Unique ID used on the last pad registered - * @link_id: Unique ID used on the last link registered - * @intf_devnode_id: Unique ID used on the last interface devnode registered + * @id: Unique ID used on the last registered graph object * @entity_internal_idx: Unique internal entity ID used by the graph traversal * algorithms * @entity_internal_idx_max: Allocated internal entity indices @@ -313,10 +310,7 @@ struct media_device { u32 topology_version; - u32 entity_id; - u32 pad_id; - u32 link_id; - u32 intf_devnode_id; + u32 id; struct ida entity_internal_idx; int entity_internal_idx_max; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 855b47df6ed5..54be1496d542 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -47,8 +47,8 @@ enum media_gobj_type { }; #define MEDIA_BITS_PER_TYPE 8 -#define MEDIA_BITS_PER_LOCAL_ID (32 - MEDIA_BITS_PER_TYPE) -#define MEDIA_LOCAL_ID_MASK GENMASK(MEDIA_BITS_PER_LOCAL_ID - 1, 0) +#define MEDIA_BITS_PER_ID (32 - MEDIA_BITS_PER_TYPE) +#define MEDIA_ID_MASK GENMASK_ULL(MEDIA_BITS_PER_ID - 1, 0) /* Structs to represent the objects that belong to a media graph */ @@ -58,9 +58,8 @@ enum media_gobj_type { * @mdev: Pointer to the struct media_device that owns the object * @id: Non-zero object ID identifier. The ID should be unique * inside a media_device, as it is composed by - * MEDIA_BITS_PER_TYPE to store the type plus - * MEDIA_BITS_PER_LOCAL_ID to store a per-type ID - * (called as "local ID"). + * %MEDIA_BITS_PER_TYPE to store the type plus + * %MEDIA_BITS_PER_ID to store the ID * @list: List entry stored in one of the per-type mdev object lists * * All objects on the media graph should have this struct embedded @@ -299,20 +298,20 @@ static inline u32 media_entity_id(struct media_entity *entity) */ static inline enum media_gobj_type media_type(struct media_gobj *gobj) { - return gobj->id >> MEDIA_BITS_PER_LOCAL_ID; + return gobj->id >> MEDIA_BITS_PER_ID; } -static inline u32 media_localid(struct media_gobj *gobj) +static inline u32 media_id(struct media_gobj *gobj) { - return gobj->id & MEDIA_LOCAL_ID_MASK; + return gobj->id & MEDIA_ID_MASK; } -static inline u32 media_gobj_gen_id(enum media_gobj_type type, u32 local_id) +static inline u32 media_gobj_gen_id(enum media_gobj_type type, u64 local_id) { u32 id; - id = type << MEDIA_BITS_PER_LOCAL_ID; - id |= local_id & MEDIA_LOCAL_ID_MASK; + id = type << MEDIA_BITS_PER_ID; + id |= local_id & MEDIA_ID_MASK; return id; } -- cgit v1.2.3 From 430a672c83c3e2e9a96c777a874f345c8d21f929 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 16 Dec 2015 15:18:25 -0200 Subject: [media] media-entity: increase max number of PADs The DVB drivers may have 257 PADs. Get the next power of two that would accomodate that amount. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index f63be23e6ed4..eb38bc35320a 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -261,7 +261,7 @@ static struct media_entity *stack_pop(struct media_entity_graph *graph) /* * TODO: Get rid of this. */ -#define MEDIA_ENTITY_MAX_PADS 63 +#define MEDIA_ENTITY_MAX_PADS 512 /** * media_entity_graph_walk_init - Allocate resources for graph walk -- cgit v1.2.3 From ba0dd729bfc09e51af238a630deba70205442afe Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 16 Dec 2015 15:33:54 -0200 Subject: [media] media-entity: don't sleep at media_device_register_entity() media_device_register_entity() is protected by a spin_lock. Calling ida_pre_get() with GFP_KERNEL may put it to sleep, with is a bad idea and causes this warning: [ 8812.397195] BUG: sleeping function called from invalid context at mm/slub.c:1287 [ 8812.397203] in_atomic(): 1, irqs_disabled(): 0, pid: 15179, name: modprobe [ 8812.397207] INFO: lockdep is turned off. [ 8812.397213] CPU: 2 PID: 15179 Comm: modprobe Tainted: G B 4.4.0-rc2+ #41 [ 8812.397218] Hardware name: /NUC5i7RYB, BIOS RYBDWi35.86A.0350.2015.0812.1722 08/12/2015 [ 8812.397222] 0000000000000000 ffff880314c77268 ffffffff818f8ba7 ffff8803b17dde00 [ 8812.397232] ffff880314c77290 ffffffff811c2ee5 ffff8803b17dde00 ffffffff8284dbc9 [ 8812.397241] 0000000000000507 ffff880314c772d0 ffffffff811c30d5 0000000041b58ab3 [ 8812.397250] Call Trace: [ 8812.397258] [] dump_stack+0x4b/0x64 [ 8812.397265] [] ___might_sleep+0x245/0x3a0 [ 8812.397270] [] __might_sleep+0x95/0x1a0 [ 8812.397276] [] ? ida_pre_get+0x113/0x250 [ 8812.397282] [] kmem_cache_alloc+0x197/0x250 [ 8812.397288] [] ida_pre_get+0x113/0x250 [ 8812.397293] [] ida_simple_get+0xa5/0x170 [ 8812.397298] [] ? ida_pre_get+0x250/0x250 [ 8812.397306] [] media_device_register_entity+0x171/0x420 [media] [ 8812.397318] [] v4l2_device_register_subdev+0x34f/0x640 [videodev] [ 8812.397324] [] v4l2_i2c_new_subdev_board+0x12a/0x250 [v4l2_common] [ 8812.397330] [] v4l2_i2c_new_subdev+0xd7/0x110 [v4l2_common] [ 8812.397337] [] ? v4l2_i2c_new_subdev_board+0x250/0x250 [v4l2_common] [ 8812.397347] [] au0828_card_analog_fe_setup+0x2e6/0x3f0 [au0828] [ 8812.397352] [] ? power_down+0xc4/0xc4 [ 8812.397361] [] ? au0828_tuner_callback+0x160/0x160 [au0828] [ 8812.397370] [] au0828_card_setup+0x11f/0x340 [au0828] [ 8812.397378] [] ? au0828_card_analog_fe_setup+0x3f0/0x3f0 [au0828] [ 8812.397384] [] ? msleep+0x7b/0xc0 [ 8812.397393] [] au0828_usb_probe+0x679/0xcf0 [au0828] [ 8812.397399] [] usb_probe_interface+0x45d/0x940 [ 8812.397406] [] driver_probe_device+0x454/0xd90 [ 8812.397411] [] ? driver_probe_device+0xd90/0xd90 [ 8812.397417] [] ? driver_probe_device+0xd90/0xd90 [ 8812.397422] [] __driver_attach+0x121/0x160 [ 8812.397427] [] bus_for_each_dev+0x11f/0x1a0 [ 8812.397433] [] ? subsys_dev_iter_exit+0x10/0x10 [ 8812.397439] [] ? _raw_spin_unlock+0x27/0x40 [ 8812.397445] [] driver_attach+0x3d/0x50 [ 8812.397450] [] bus_add_driver+0x4c9/0x770 [ 8812.397456] [] driver_register+0x18c/0x3b0 [ 8812.397462] [] ? __raw_spin_lock_init+0x32/0x100 [ 8812.397468] [] usb_register_driver+0x1f8/0x440 [ 8812.397473] [] ? 0xffffffffa0208000 [ 8812.397481] [] au0828_init+0xb7/0x1000 [au0828] [ 8812.397486] [] do_one_initcall+0x141/0x300 [ 8812.397492] [] ? try_to_run_init_process+0x40/0x40 [ 8812.397497] [] ? trace_hardirqs_on_caller+0x16/0x590 [ 8812.397502] [] ? kasan_unpoison_shadow+0x36/0x50 [ 8812.397507] [] ? kasan_unpoison_shadow+0x36/0x50 [ 8812.397512] [] ? kasan_unpoison_shadow+0x36/0x50 [ 8812.397517] [] ? __asan_register_globals+0x87/0xa0 [ 8812.397524] [] do_init_module+0x1d0/0x5a4 [ 8812.397530] [] load_module+0x6648/0x9d70 [ 8812.397535] [] ? symbol_put_addr+0x50/0x50 [ 8812.397546] [] ? module_frob_arch_sections+0x20/0x20 [ 8812.397552] [] ? open_exec+0x50/0x50 [ 8812.397559] [] ? ns_capable+0x5b/0xd0 [ 8812.397565] [] SyS_finit_module+0x108/0x130 [ 8812.397571] [] ? SyS_init_module+0x1f0/0x1f0 [ 8812.397576] [] ? lockdep_sys_exit_thunk+0x12/0x14 [ 8812.397582] [] entry_SYSCALL_64_fastpath+0x16/0x7a Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-device.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index fd67b34dcda3..4d1c13de494b 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -537,6 +537,7 @@ int __must_check media_device_register_entity(struct media_device *mdev, struct media_entity *entity) { unsigned int i; + int ret; if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN || entity->function == MEDIA_ENT_F_UNKNOWN) @@ -551,13 +552,16 @@ int __must_check media_device_register_entity(struct media_device *mdev, entity->num_links = 0; entity->num_backlinks = 0; + if (!ida_pre_get(&mdev->entity_internal_idx, GFP_KERNEL)) + return -ENOMEM; + spin_lock(&mdev->lock); - entity->internal_idx = ida_simple_get(&mdev->entity_internal_idx, 1, 0, - GFP_KERNEL); - if (entity->internal_idx < 0) { + ret = ida_get_new_above(&mdev->entity_internal_idx, 1, + &entity->internal_idx); + if (ret < 0) { spin_unlock(&mdev->lock); - return entity->internal_idx; + return ret; } mdev->entity_internal_idx_max = -- cgit v1.2.3 From 2e7508e40f6391762499d802226d8a31b0ea3944 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 28 Dec 2015 09:24:23 -0200 Subject: [media] call media_device_init() before registering the V4L2 device Currently, v4l2_device_register() doesn't use the media_device struct. So, calling media_device_init() could be called either before or after v4l2_device_register(). Yet, it is a good practice to initialize everything before calling the register functions. Also, the other drivers call media_device_init() before registering the V4L2 device. So, move the call for media_device_init() to happen earlier on exynos4-is and s3c-camif. This is just a cleanup patch. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/media-dev.c | 4 ++-- drivers/media/platform/s3c-camif/camif-core.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index f6b391e795c6..f3b2dd30ec77 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -1356,14 +1356,14 @@ static int fimc_md_probe(struct platform_device *pdev) fmd->use_isp = fimc_md_is_isp_available(dev->of_node); fmd->user_subdev_api = true; + media_device_init(&fmd->media_dev); + ret = v4l2_device_register(dev, &fmd->v4l2_dev); if (ret < 0) { v4l2_err(v4l2_dev, "Failed to register v4l2_device: %d\n", ret); return ret; } - media_device_init(&fmd->media_dev); - ret = fimc_md_get_clocks(fmd); if (ret) goto err_md; diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c index ea02b7ef2119..0b44b9accf50 100644 --- a/drivers/media/platform/s3c-camif/camif-core.c +++ b/drivers/media/platform/s3c-camif/camif-core.c @@ -324,12 +324,12 @@ static int camif_media_dev_init(struct camif_dev *camif) strlcpy(v4l2_dev->name, "s3c-camif", sizeof(v4l2_dev->name)); v4l2_dev->mdev = md; + media_device_init(md); + ret = v4l2_device_register(camif->dev, v4l2_dev); if (ret < 0) return ret; - media_device_init(md); - return ret; } -- cgit v1.2.3 From 0820eb5c5510b0a5c25a17c8be5e40156ace4991 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 28 Dec 2015 10:30:06 -0200 Subject: [media] dvbdev: remove two dead functions if !CONFIG_MEDIA_CONTROLLER_DVB Those functions are used only if CONFIG_MEDIA_CONTROLLER_DVB. Without that, if !CONFIG_MEDIA_CONTROLLER_DVB, it would produce two warnings: drivers/media/dvb-core/dvbdev.c:219:12: warning: 'dvb_create_tsout_entity' defined but not used [-Wunused-function] static int dvb_create_tsout_entity(struct dvb_device *dvbdev, ^ drivers/media/dvb-core/dvbdev.c:264:12: warning: 'dvb_create_media_entity' defined but not used [-Wunused-function] static int dvb_create_media_entity(struct dvb_device *dvbdev, ^ Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index b56e00817d3f..860dd7d06b60 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -216,10 +216,10 @@ static void dvb_media_device_free(struct dvb_device *dvbdev) #endif } +#if defined(CONFIG_MEDIA_CONTROLLER_DVB) static int dvb_create_tsout_entity(struct dvb_device *dvbdev, const char *name, int npads) { -#if defined(CONFIG_MEDIA_CONTROLLER_DVB) int i, ret = 0; dvbdev->tsout_pads = kcalloc(npads, sizeof(*dvbdev->tsout_pads), @@ -254,7 +254,6 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev, if (ret < 0) return ret; } -#endif return 0; } @@ -264,7 +263,6 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev, static int dvb_create_media_entity(struct dvb_device *dvbdev, int type, int demux_sink_pads) { -#if defined(CONFIG_MEDIA_CONTROLLER_DVB) int i, ret, npads; switch (type) { @@ -352,9 +350,9 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev, printk(KERN_DEBUG "%s: media entity '%s' registered.\n", __func__, dvbdev->entity->name); -#endif return 0; } +#endif static int dvb_register_media_device(struct dvb_device *dvbdev, int type, int minor, -- cgit v1.2.3 From 0230d60e4661d9ced6fb0b9a30f182ebdafbba7a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 29 Dec 2015 11:52:23 -0200 Subject: [media] dvbdev: Add RF connector if needed Several pure digital TV devices have a frontend with the tuner integrated on it. Add the RF connector when dvb_create_media_graph() is called on such devices. Tested with siano and dvb_usb_mxl111sf drivers. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/common/siano/smsdvb-main.c | 2 +- drivers/media/dvb-core/dvbdev.c | 49 +++++++++++++++++++++++++++-- drivers/media/dvb-core/dvbdev.h | 20 ++++++++++-- drivers/media/usb/au0828/au0828-dvb.c | 2 +- drivers/media/usb/cx231xx/cx231xx-dvb.c | 2 +- drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 2 +- drivers/media/usb/dvb-usb/dvb-usb-dvb.c | 2 +- 7 files changed, 70 insertions(+), 9 deletions(-) (limited to 'drivers') diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c index 8a1ea2192439..d31f468830cf 100644 --- a/drivers/media/common/siano/smsdvb-main.c +++ b/drivers/media/common/siano/smsdvb-main.c @@ -1184,7 +1184,7 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev, if (smsdvb_debugfs_create(client) < 0) pr_info("failed to create debugfs node\n"); - rc = dvb_create_media_graph(&client->adapter); + rc = dvb_create_media_graph(&client->adapter, true); if (rc < 0) { pr_err("dvb_create_media_graph failed %d\n", rc); goto client_error; diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 860dd7d06b60..28e340583ede 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -213,6 +213,13 @@ static void dvb_media_device_free(struct dvb_device *dvbdev) media_devnode_remove(dvbdev->intf_devnode); dvbdev->intf_devnode = NULL; } + + if (dvbdev->adapter->conn) { + media_device_unregister_entity(dvbdev->adapter->conn); + dvbdev->adapter->conn = NULL; + kfree(dvbdev->adapter->conn_pads); + dvbdev->adapter->conn_pads = NULL; + } #endif } @@ -559,16 +566,18 @@ static int dvb_create_io_intf_links(struct dvb_adapter *adap, return 0; } -int dvb_create_media_graph(struct dvb_adapter *adap) +int dvb_create_media_graph(struct dvb_adapter *adap, + bool create_rf_connector) { struct media_device *mdev = adap->mdev; - struct media_entity *entity, *tuner = NULL, *demod = NULL; + struct media_entity *entity, *tuner = NULL, *demod = NULL, *conn; struct media_entity *demux = NULL, *ca = NULL; struct media_link *link; struct media_interface *intf; unsigned demux_pad = 0; unsigned dvr_pad = 0; int ret; + static const char *connector_name = "Television"; if (!mdev) return 0; @@ -590,6 +599,42 @@ int dvb_create_media_graph(struct dvb_adapter *adap) } } + if (create_rf_connector) { + conn = kzalloc(sizeof(*conn), GFP_KERNEL); + if (!conn) + return -ENOMEM; + adap->conn = conn; + + adap->conn_pads = kcalloc(1, sizeof(*adap->conn_pads), + GFP_KERNEL); + if (!adap->conn_pads) + return -ENOMEM; + + conn->flags = MEDIA_ENT_FL_CONNECTOR; + conn->function = MEDIA_ENT_F_CONN_RF; + conn->name = connector_name; + adap->conn_pads->flags = MEDIA_PAD_FL_SOURCE; + + ret = media_entity_pads_init(conn, 1, adap->conn_pads); + if (ret) + return ret; + + ret = media_device_register_entity(mdev, conn); + if (ret) + return ret; + + if (!tuner) + ret = media_create_pad_link(conn, 0, + demod, 0, + MEDIA_LNK_FL_ENABLED); + else + ret = media_create_pad_link(conn, 0, + tuner, TUNER_PAD_RF_INPUT, + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; + } + if (tuner && demod) { ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, demod, 0, MEDIA_LNK_FL_ENABLED); diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index abee18a402e1..b622d6a3b95e 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -75,6 +75,9 @@ struct dvb_frontend; * used. * @mdev: pointer to struct media_device, used when the media * controller is used. + * @conn: RF connector. Used only if the device has no separate + * tuner. + * @conn_pads: pointer to struct media_pad associated with @conn; */ struct dvb_adapter { int num; @@ -94,6 +97,8 @@ struct dvb_adapter { #if defined(CONFIG_MEDIA_CONTROLLER_DVB) struct media_device *mdev; + struct media_entity *conn; + struct media_pad *conn_pads; #endif }; @@ -214,7 +219,16 @@ int dvb_register_device(struct dvb_adapter *adap, void dvb_unregister_device(struct dvb_device *dvbdev); #ifdef CONFIG_MEDIA_CONTROLLER_DVB -__must_check int dvb_create_media_graph(struct dvb_adapter *adap); +/** + * dvb_create_media_graph - Creates media graph for the Digital TV part of the + * device. + * + * @adap: pointer to struct dvb_adapter + * @create_rf_connector: if true, it creates the RF connector too + */ +__must_check int dvb_create_media_graph(struct dvb_adapter *adap, + bool create_rf_connector); + static inline void dvb_register_media_controller(struct dvb_adapter *adap, struct media_device *mdev) { @@ -222,7 +236,9 @@ static inline void dvb_register_media_controller(struct dvb_adapter *adap, } #else -static inline int dvb_create_media_graph(struct dvb_adapter *adap) +static inline +int dvb_create_media_graph(struct dvb_adapter *adap, + bool create_rf_connector) { return 0; }; diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c index cd542b49a6c2..94363a3ba400 100644 --- a/drivers/media/usb/au0828/au0828-dvb.c +++ b/drivers/media/usb/au0828/au0828-dvb.c @@ -486,7 +486,7 @@ static int dvb_register(struct au0828_dev *dev) dvb->start_count = 0; dvb->stop_count = 0; - result = dvb_create_media_graph(&dvb->adapter); + result = dvb_create_media_graph(&dvb->adapter, false); if (result < 0) goto fail_create_graph; diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c index b7552d20ebdb..b8d5b2be9293 100644 --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c @@ -551,7 +551,7 @@ static int register_dvb(struct cx231xx_dvb *dvb, /* register network adapter */ dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); - result = dvb_create_media_graph(&dvb->adapter); + result = dvb_create_media_graph(&dvb->adapter, false); if (result < 0) goto fail_create_graph; diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index 0fa2c45917b0..e8491f73c0d9 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c @@ -706,7 +706,7 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap) } } - ret = dvb_create_media_graph(&adap->dvb_adap); + ret = dvb_create_media_graph(&adap->dvb_adap, true); if (ret < 0) goto err_dvb_unregister_frontend; diff --git a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c index 241463ef631e..9ddfcab268be 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-dvb.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-dvb.c @@ -330,7 +330,7 @@ int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap) if (ret) return ret; - ret = dvb_create_media_graph(&adap->dvb_adap); + ret = dvb_create_media_graph(&adap->dvb_adap, true); if (ret) return ret; -- cgit v1.2.3 From 33c6853347c13b7cf8d11c12714cd855a84bc992 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 29 Dec 2015 16:45:21 -0200 Subject: [media] dvb-usb-v2: postpone removal of media_device We should not remove the media_device until its last usage, or we may have use after free troubles. So, move the per-adapter media_device removal to happen at the end of the adapter removal code. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index e8491f73c0d9..f0565bf3673e 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c @@ -542,7 +542,6 @@ static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap) adap->demux.dmx.close(&adap->demux.dmx); dvb_dmxdev_release(&adap->dmxdev); dvb_dmx_release(&adap->demux); - dvb_usbv2_media_device_unregister(adap); dvb_unregister_adapter(&adap->dvb_adap); } @@ -852,6 +851,7 @@ static int dvb_usbv2_adapter_exit(struct dvb_usb_device *d) dvb_usbv2_adapter_dvb_exit(&d->adapter[i]); dvb_usbv2_adapter_stream_exit(&d->adapter[i]); dvb_usbv2_adapter_frontend_exit(&d->adapter[i]); + dvb_usbv2_media_device_unregister(&d->adapter[i]); } } -- cgit v1.2.3 From b01cc9ce7c13e0463575332dfa3171727f706afb Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 30 Dec 2015 09:45:48 -0200 Subject: [media] media-entitiy: add a function to create multiple links Sometimes, it is desired to create 1:n and n:1 or even n:n links between different entities with the same function. This is actually needed to support DVB devices that have multiple frontends. While we could do a function like that internally at the DVB core, such function is generic enough to be at media-entity, and it could be useful on some other places. So, add such function. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/media-entity.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ include/media/media-entity.h | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) (limited to 'drivers') diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index eb38bc35320a..e89d85a7d31b 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -625,6 +625,71 @@ media_create_pad_link(struct media_entity *source, u16 source_pad, } EXPORT_SYMBOL_GPL(media_create_pad_link); +int media_create_pad_links(const struct media_device *mdev, + const u32 source_function, + struct media_entity *source, + const u16 source_pad, + const u32 sink_function, + struct media_entity *sink, + const u16 sink_pad, + u32 flags, + const bool allow_both_undefined) +{ + struct media_entity *entity; + unsigned function; + int ret; + + /* Trivial case: 1:1 relation */ + if (source && sink) + return media_create_pad_link(source, source_pad, + sink, sink_pad, flags); + + /* Worse case scenario: n:n relation */ + if (!source && !sink) { + if (!allow_both_undefined) + return 0; + media_device_for_each_entity(source, mdev) { + if (source->function != source_function) + continue; + media_device_for_each_entity(sink, mdev) { + if (sink->function != sink_function) + continue; + ret = media_create_pad_link(source, source_pad, + sink, sink_pad, + flags); + if (ret) + return ret; + flags &= ~(MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + } + } + return 0; + } + + /* Handle 1:n and n:1 cases */ + if (source) + function = sink_function; + else + function = source_function; + + media_device_for_each_entity(entity, mdev) { + if (entity->function != function) + continue; + + if (source) + ret = media_create_pad_link(source, source_pad, + entity, sink_pad, flags); + else + ret = media_create_pad_link(entity, source_pad, + sink, sink_pad, flags); + if (ret) + return ret; + flags &= ~(MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); + } + return 0; +} +EXPORT_SYMBOL_GPL(media_create_pad_links); + void __media_entity_remove_links(struct media_entity *entity) { struct media_link *link, *tmp; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 79dd81fd463e..fe485d367985 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -613,6 +613,57 @@ static inline void media_entity_cleanup(struct media_entity *entity) {}; __must_check int media_create_pad_link(struct media_entity *source, u16 source_pad, struct media_entity *sink, u16 sink_pad, u32 flags); + +/** + * media_create_pad_links() - creates a link between two entities. + * + * @mdev: Pointer to the media_device that contains the object + * @source_function: Function of the source entities. Used only if @source is + * NULL. + * @source: pointer to &media_entity of the source pad. If NULL, it will use + * all entities that matches the @sink_function. + * @source_pad: number of the source pad in the pads array + * @sink_function: Function of the sink entities. Used only if @sink is NULL. + * @sink: pointer to &media_entity of the sink pad. If NULL, it will use + * all entities that matches the @sink_function. + * @sink_pad: number of the sink pad in the pads array. + * @flags: Link flags, as defined in include/uapi/linux/media.h. + * @allow_both_undefined: if true, then both @source and @sink can be NULL. + * In such case, it will create a crossbar between all entities that + * matches @source_function to all entities that matches @sink_function. + * If false, it will return 0 and won't create any link if both @source + * and @sink are NULL. + * + * Valid values for flags: + * A %MEDIA_LNK_FL_ENABLED flag indicates that the link is enabled and can be + * used to transfer media data. If multiple links are created and this + * flag is passed as an argument, only the first created link will have + * this flag. + * + * A %MEDIA_LNK_FL_IMMUTABLE flag indicates that the link enabled state can't + * be modified at runtime. If %MEDIA_LNK_FL_IMMUTABLE is set, then + * %MEDIA_LNK_FL_ENABLED must also be set since an immutable link is + * always enabled. + * + * It is common for some devices to have multiple source and/or sink entities + * of the same type that should be linked. While media_create_pad_link() + * creates link by link, this function is meant to allow 1:n, n:1 and even + * cross-bar (n:n) links. + * + * NOTE: Before calling this function, media_entity_pads_init() and + * media_device_register_entity() should be called previously for the entities + * to be linked. + */ +int media_create_pad_links(const struct media_device *mdev, + const u32 source_function, + struct media_entity *source, + const u16 source_pad, + const u32 sink_function, + struct media_entity *sink, + const u16 sink_pad, + u32 flags, + const bool allow_both_undefined); + void __media_entity_remove_links(struct media_entity *entity); /** -- cgit v1.2.3 From a0cce2a05756c9308f59c0303afe2c199e0789b0 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 30 Dec 2015 10:11:53 -0200 Subject: [media] dvbdev: create links on devices with multiple frontends Devices like mxl111sf-based WinTV Aero-m have multiple frontends, all linked on the same demod. Currently, the dvb_create_graph() function is not smart enough to create multiple links. Fix it. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 57 +++++++++++++++++++++++++++++++---------- drivers/media/dvb-core/dvbdev.h | 7 +++++ 2 files changed, 51 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 28e340583ede..560450a0b32a 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -576,6 +576,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap, struct media_interface *intf; unsigned demux_pad = 0; unsigned dvr_pad = 0; + unsigned ntuner = 0, ndemod = 0; int ret; static const char *connector_name = "Television"; @@ -586,9 +587,11 @@ int dvb_create_media_graph(struct dvb_adapter *adap, switch (entity->function) { case MEDIA_ENT_F_TUNER: tuner = entity; + ntuner++; break; case MEDIA_ENT_F_DTV_DEMOD: demod = entity; + ndemod++; break; case MEDIA_ENT_F_TS_DEMUX: demux = entity; @@ -599,6 +602,18 @@ int dvb_create_media_graph(struct dvb_adapter *adap, } } + /* + * Prepare to signalize to media_create_pad_links() that multiple + * entities of the same type exists and a 1:n or n:1 links need to be + * created. + * NOTE: if both tuner and demod have multiple instances, it is up + * to the caller driver to create such links. + */ + if (ntuner > 1) + tuner = NULL; + if (ndemod > 1) + demod = NULL; + if (create_rf_connector) { conn = kzalloc(sizeof(*conn), GFP_KERNEL); if (!conn) @@ -623,28 +638,44 @@ int dvb_create_media_graph(struct dvb_adapter *adap, if (ret) return ret; - if (!tuner) - ret = media_create_pad_link(conn, 0, - demod, 0, - MEDIA_LNK_FL_ENABLED); + if (!ntuner) + ret = media_create_pad_links(mdev, + MEDIA_ENT_F_CONN_RF, + conn, 0, + MEDIA_ENT_F_DTV_DEMOD, + demod, 0, + MEDIA_LNK_FL_ENABLED, + false); else - ret = media_create_pad_link(conn, 0, - tuner, TUNER_PAD_RF_INPUT, - MEDIA_LNK_FL_ENABLED); + ret = media_create_pad_links(mdev, + MEDIA_ENT_F_CONN_RF, + conn, 0, + MEDIA_ENT_F_TUNER, + tuner, TUNER_PAD_RF_INPUT, + MEDIA_LNK_FL_ENABLED, + false); if (ret) return ret; } - if (tuner && demod) { - ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, - demod, 0, MEDIA_LNK_FL_ENABLED); + if (ntuner && ndemod) { + ret = media_create_pad_links(mdev, + MEDIA_ENT_F_TUNER, + tuner, TUNER_PAD_IF_OUTPUT, + MEDIA_ENT_F_DTV_DEMOD, + demod, 0, MEDIA_LNK_FL_ENABLED, + false); if (ret) return ret; } - if (demod && demux) { - ret = media_create_pad_link(demod, 1, demux, - 0, MEDIA_LNK_FL_ENABLED); + if (ndemod && demux) { + ret = media_create_pad_links(mdev, + MEDIA_ENT_F_DTV_DEMOD, + demod, 1, + MEDIA_ENT_F_TS_DEMUX, + demux, 0, MEDIA_LNK_FL_ENABLED, + false); if (ret) return -ENOMEM; } diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index b622d6a3b95e..d7c67baa885e 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -225,6 +225,13 @@ void dvb_unregister_device(struct dvb_device *dvbdev); * * @adap: pointer to struct dvb_adapter * @create_rf_connector: if true, it creates the RF connector too + * + * This function checks all DVB-related functions at the media controller + * entities and creates the needed links for the media graph. It is + * capable of working with multiple tuners or multiple frontends, but it + * won't create links if the device has multiple tuners and multiple frontends + * or if the device has multiple muxes. In such case, the caller driver should + * manually create the remaining links. */ __must_check int dvb_create_media_graph(struct dvb_adapter *adap, bool create_rf_connector); -- cgit v1.2.3 From ce084d487c8a0731bff5739e735b7bb82b94e53b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 30 Dec 2015 11:09:39 -0200 Subject: [media] mxl111sf: Add a tuner entity While mxl111sf may have multiple frontends, it has just one tuner. Reflect that on the media graph. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.h | 6 ++++++ drivers/media/usb/dvb-usb-v2/mxl111sf.c | 20 ++++++++++++++++++++ drivers/media/usb/dvb-usb-v2/mxl111sf.h | 5 +++++ 3 files changed, 31 insertions(+) (limited to 'drivers') diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index d7c67baa885e..4aff7bd3dea8 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -242,6 +242,11 @@ static inline void dvb_register_media_controller(struct dvb_adapter *adap, adap->mdev = mdev; } +static inline struct media_device +*dvb_get_media_controller(struct dvb_adapter *adap) +{ + return adap->mdev; +} #else static inline int dvb_create_media_graph(struct dvb_adapter *adap, @@ -250,6 +255,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap, return 0; }; #define dvb_register_media_controller(a, b) {} +#define dvb_get_media_controller(a) NULL #endif int dvb_generic_open (struct inode *inode, struct file *file); diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c index 1710f9038d75..b669deccc34c 100644 --- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c +++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c @@ -10,6 +10,7 @@ #include #include +#include #include "mxl111sf.h" #include "mxl111sf-reg.h" @@ -868,6 +869,10 @@ static struct mxl111sf_tuner_config mxl_tuner_config = { static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap) { struct mxl111sf_state *state = adap_to_priv(adap); +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + struct media_device *mdev = dvb_get_media_controller(&adap->dvb_adap); + int ret; +#endif int i; pr_debug("%s()\n", __func__); @@ -879,6 +884,21 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap) adap->fe[i]->ops.read_signal_strength = adap->fe[i]->ops.tuner_ops.get_rf_strength; } +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + state->tuner.function = MEDIA_ENT_F_TUNER; + state->tuner.name = "mxl111sf tuner"; + state->tuner_pads[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK; + state->tuner_pads[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE; + + ret = media_entity_pads_init(&state->tuner, + TUNER_NUM_PADS, state->tuner_pads); + if (ret) + return ret; + + ret = media_device_register_entity(mdev, &state->tuner); + if (ret) + return ret; +#endif return 0; } diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.h b/drivers/media/usb/dvb-usb-v2/mxl111sf.h index ee70df1f1e94..846260e0eec0 100644 --- a/drivers/media/usb/dvb-usb-v2/mxl111sf.h +++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.h @@ -17,6 +17,7 @@ #define DVB_USB_LOG_PREFIX "mxl111sf" #include "dvb_usb.h" #include +#include #define MXL_EP1_REG_READ 1 #define MXL_EP2_REG_WRITE 2 @@ -85,6 +86,10 @@ struct mxl111sf_state { struct mutex fe_lock; u8 num_frontends; struct mxl111sf_adap_state adap_state[3]; +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + struct media_entity tuner; + struct media_pad tuner_pads[2]; +#endif }; int mxl111sf_read_reg(struct mxl111sf_state *state, u8 addr, u8 *data); -- cgit v1.2.3 From be0270ec89e6b9b49de7e533dd1f3a89ad34d205 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 28 Dec 2015 12:03:47 -0200 Subject: [media] Postpone the addition of MEDIA_IOC_G_TOPOLOGY There are a few discussions left with regards to this ioctl: 1) the name of the new structs will contain _v2_ on it? 2) what's the best alternative to avoid compat32 issues? Due to that, let's postpone the addition of this new ioctl to the next Kernel version, to give people more time to discuss it. Signed-off-by: Mauro Carvalho Chehab --- Documentation/DocBook/media/v4l/media-ioc-g-topology.xml | 3 +++ drivers/media/media-device.c | 7 ++++++- include/uapi/linux/media.h | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/Documentation/DocBook/media/v4l/media-ioc-g-topology.xml b/Documentation/DocBook/media/v4l/media-ioc-g-topology.xml index e0d49fa329f0..63152ab9efba 100644 --- a/Documentation/DocBook/media/v4l/media-ioc-g-topology.xml +++ b/Documentation/DocBook/media/v4l/media-ioc-g-topology.xml @@ -48,6 +48,9 @@ Description + + NOTE: This new ioctl is programmed to be added on Kernel 4.6. Its definition/arguments may change until its final version. + The typical usage of this ioctl is to call it twice. On the first call, the structure defined at &media-v2-topology; should be zeroed. At return, if no errors happen, this ioctl will return the diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 4d1c13de494b..7dae0ac0f3ae 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -234,6 +234,7 @@ static long media_device_setup_link(struct media_device *mdev, return ret; } +#if 0 /* Let's postpone it to Kernel 4.6 */ static long __media_device_get_topology(struct media_device *mdev, struct media_v2_topology *topo) { @@ -389,6 +390,7 @@ static long media_device_get_topology(struct media_device *mdev, return 0; } +#endif static long media_device_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) @@ -422,13 +424,14 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd, mutex_unlock(&dev->graph_mutex); break; +#if 0 /* Let's postpone it to Kernel 4.6 */ case MEDIA_IOC_G_TOPOLOGY: mutex_lock(&dev->graph_mutex); ret = media_device_get_topology(dev, (struct media_v2_topology __user *)arg); mutex_unlock(&dev->graph_mutex); break; - +#endif default: ret = -ENOIOCTLCMD; } @@ -477,7 +480,9 @@ static long media_device_compat_ioctl(struct file *filp, unsigned int cmd, case MEDIA_IOC_DEVICE_INFO: case MEDIA_IOC_ENUM_ENTITIES: case MEDIA_IOC_SETUP_LINK: +#if 0 /* Let's postpone it to Kernel 4.6 */ case MEDIA_IOC_G_TOPOLOGY: +#endif return media_device_ioctl(filp, cmd, arg); case MEDIA_IOC_ENUM_LINKS32: diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 5dbb208e5451..1e3c8cb43bd7 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -286,7 +286,7 @@ struct media_links_enum { * later, before the adding this API upstream. */ - +#if 0 /* Let's postpone it to Kernel 4.6 */ struct media_v2_entity { __u32 id; char name[64]; /* FIXME: move to a property? (RFC says so) */ @@ -351,6 +351,7 @@ static inline void __user *media_get_uptr(__u64 arg) { return (void __user *)(uintptr_t)arg; } +#endif /* ioctls */ @@ -358,6 +359,9 @@ static inline void __user *media_get_uptr(__u64 arg) #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc) #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum) #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) + +#if 0 /* Let's postpone it to Kernel 4.6 */ #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology) +#endif #endif /* __LINUX_MEDIA_H */ -- cgit v1.2.3