diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-06 11:27:48 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-06 11:27:48 -0800 |
commit | 68c5735eaa5e680e701c9a2d1e3c7880bdf5ab66 (patch) | |
tree | 4f584693638bf257b66a1646cc30d823cacc0a58 /drivers/staging/media/imx/imx-media-utils.c | |
parent | 2246edfaf88dc368e8671b04afd54412625df60a (diff) | |
parent | 273caa260035c03d89ad63d72d8cd3d9e5c5e3f1 (diff) |
Merge tag 'media/v4.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab:
- videobuf2 was moved to a media/common dir, as it is now used by the
DVB subsystem too
- Digital TV core memory mapped support interface
- new sensor driver: ov7740
- several improvements at ddbridge driver
- new V4L2 driver: IPU3 CIO2 CSI-2 receiver unit, found on some Intel
SoCs
- new tuner driver: tda18250
- finally got rid of all LIRC staging drivers
- as we don't have old lirc drivers anymore, restruct the lirc device
code
- add support for UVC metadata
- add a new staging driver for NVIDIA Tegra Video Decoder Engine
- DVB kAPI headers moved to include/media
- synchronize the kAPI and uAPI for the DVB subsystem, removing the gap
for non-legacy APIs
- reduce the kAPI gap for V4L2
- lots of other driver enhancements, cleanups, etc.
* tag 'media/v4.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (407 commits)
media: v4l2-compat-ioctl32.c: make ctrl_is_pointer work for subdevs
media: v4l2-compat-ioctl32.c: refactor compat ioctl32 logic
media: v4l2-compat-ioctl32.c: don't copy back the result for certain errors
media: v4l2-compat-ioctl32.c: drop pr_info for unknown buffer type
media: v4l2-compat-ioctl32.c: copy clip list in put_v4l2_window32
media: v4l2-compat-ioctl32.c: fix ctrl_is_pointer
media: v4l2-compat-ioctl32.c: copy m.userptr in put_v4l2_plane32
media: v4l2-compat-ioctl32.c: avoid sizeof(type)
media: v4l2-compat-ioctl32.c: move 'helper' functions to __get/put_v4l2_format32
media: v4l2-compat-ioctl32.c: fix the indentation
media: v4l2-compat-ioctl32.c: add missing VIDIOC_PREPARE_BUF
media: v4l2-ioctl.c: don't copy back the result for -ENOTTY
media: v4l2-ioctl.c: use check_fmt for enum/g/s/try_fmt
media: vivid: fix module load error when enabling fb and no_error_inj=1
media: dvb_demux: improve debug messages
media: dvb_demux: Better handle discontinuity errors
media: cxusb, dib0700: ignore XC2028_I2C_FLUSH
media: ts2020: avoid integer overflows on 32 bit machines
media: i2c: ov7740: use gpio/consumer.h instead of gpio.h
media: entity: Add a nop variant of media_entity_cleanup
...
Diffstat (limited to 'drivers/staging/media/imx/imx-media-utils.c')
-rw-r--r-- | drivers/staging/media/imx/imx-media-utils.c | 122 |
1 files changed, 54 insertions, 68 deletions
diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 59523872a886..13dafa77a2eb 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -668,38 +668,35 @@ void imx_media_grp_id_to_sd_name(char *sd_name, int sz, u32 grp_id, int ipu_id) } EXPORT_SYMBOL_GPL(imx_media_grp_id_to_sd_name); -struct imx_media_subdev * -imx_media_find_subdev_by_sd(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd) +struct v4l2_subdev * +imx_media_find_subdev_by_fwnode(struct imx_media_dev *imxmd, + struct fwnode_handle *fwnode) { - struct imx_media_subdev *imxsd; - int i; + struct v4l2_subdev *sd; - for (i = 0; i < imxmd->num_subdevs; i++) { - imxsd = &imxmd->subdev[i]; - if (sd == imxsd->sd) - return imxsd; + list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { + if (sd->fwnode == fwnode) + return sd; } - return ERR_PTR(-ENODEV); + return NULL; } -EXPORT_SYMBOL_GPL(imx_media_find_subdev_by_sd); +EXPORT_SYMBOL_GPL(imx_media_find_subdev_by_fwnode); -struct imx_media_subdev * -imx_media_find_subdev_by_id(struct imx_media_dev *imxmd, u32 grp_id) +struct v4l2_subdev * +imx_media_find_subdev_by_devname(struct imx_media_dev *imxmd, + const char *devname) { - struct imx_media_subdev *imxsd; - int i; + struct v4l2_subdev *sd; - for (i = 0; i < imxmd->num_subdevs; i++) { - imxsd = &imxmd->subdev[i]; - if (imxsd->sd && imxsd->sd->grp_id == grp_id) - return imxsd; + list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { + if (!strcmp(devname, dev_name(sd->dev))) + return sd; } - return ERR_PTR(-ENODEV); + return NULL; } -EXPORT_SYMBOL_GPL(imx_media_find_subdev_by_id); +EXPORT_SYMBOL_GPL(imx_media_find_subdev_by_devname); /* * Adds a video device to the master video device list. This is called by @@ -708,32 +705,21 @@ EXPORT_SYMBOL_GPL(imx_media_find_subdev_by_id); int imx_media_add_video_device(struct imx_media_dev *imxmd, struct imx_media_video_dev *vdev) { - int vdev_idx, ret = 0; - mutex_lock(&imxmd->mutex); - vdev_idx = imxmd->num_vdevs; - if (vdev_idx >= IMX_MEDIA_MAX_VDEVS) { - dev_err(imxmd->md.dev, - "%s: too many video devices! can't add %s\n", - __func__, vdev->vfd->name); - ret = -ENOSPC; - goto out; - } + list_add_tail(&vdev->list, &imxmd->vdev_list); - imxmd->vdev[vdev_idx] = vdev; - imxmd->num_vdevs++; -out: mutex_unlock(&imxmd->mutex); - return ret; + return 0; } EXPORT_SYMBOL_GPL(imx_media_add_video_device); /* - * Search upstream or downstream for a subdevice in the current pipeline + * Search upstream/downstream for a subdevice in the current pipeline * with given grp_id, starting from start_entity. Returns the subdev's - * source/sink pad that it was reached from. Must be called with - * mdev->graph_mutex held. + * source/sink pad that it was reached from. If grp_id is zero, just + * returns the nearest source/sink pad to start_entity. Must be called + * with mdev->graph_mutex held. */ static struct media_pad * find_pipeline_pad(struct imx_media_dev *imxmd, @@ -756,11 +742,16 @@ find_pipeline_pad(struct imx_media_dev *imxmd, if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) continue; - sd = media_entity_to_v4l2_subdev(pad->entity); - if (sd->grp_id & grp_id) - return pad; + if (grp_id != 0) { + sd = media_entity_to_v4l2_subdev(pad->entity); + if (sd->grp_id & grp_id) + return pad; - return find_pipeline_pad(imxmd, pad->entity, grp_id, upstream); + return find_pipeline_pad(imxmd, pad->entity, + grp_id, upstream); + } else { + return pad; + } } return NULL; @@ -789,7 +780,6 @@ find_upstream_subdev(struct imx_media_dev *imxmd, return pad ? media_entity_to_v4l2_subdev(pad->entity) : NULL; } - /* * Find the upstream mipi-csi2 virtual channel reached from the given * start entity in the current pipeline. @@ -814,11 +804,30 @@ int imx_media_find_mipi_csi2_channel(struct imx_media_dev *imxmd, EXPORT_SYMBOL_GPL(imx_media_find_mipi_csi2_channel); /* + * Find a source pad reached upstream from the given start entity in + * the current pipeline. Must be called with mdev->graph_mutex held. + */ +struct media_pad * +imx_media_find_upstream_pad(struct imx_media_dev *imxmd, + struct media_entity *start_entity, + u32 grp_id) +{ + struct media_pad *pad; + + pad = find_pipeline_pad(imxmd, start_entity, grp_id, true); + if (!pad) + return ERR_PTR(-ENODEV); + + return pad; +} +EXPORT_SYMBOL_GPL(imx_media_find_upstream_pad); + +/* * Find a subdev reached upstream from the given start entity in * the current pipeline. * Must be called with mdev->graph_mutex held. */ -struct imx_media_subdev * +struct v4l2_subdev * imx_media_find_upstream_subdev(struct imx_media_dev *imxmd, struct media_entity *start_entity, u32 grp_id) @@ -829,33 +838,10 @@ imx_media_find_upstream_subdev(struct imx_media_dev *imxmd, if (!sd) return ERR_PTR(-ENODEV); - return imx_media_find_subdev_by_sd(imxmd, sd); + return sd; } EXPORT_SYMBOL_GPL(imx_media_find_upstream_subdev); -struct imx_media_subdev * -__imx_media_find_sensor(struct imx_media_dev *imxmd, - struct media_entity *start_entity) -{ - return imx_media_find_upstream_subdev(imxmd, start_entity, - IMX_MEDIA_GRP_ID_SENSOR); -} -EXPORT_SYMBOL_GPL(__imx_media_find_sensor); - -struct imx_media_subdev * -imx_media_find_sensor(struct imx_media_dev *imxmd, - struct media_entity *start_entity) -{ - struct imx_media_subdev *sensor; - - mutex_lock(&imxmd->md.graph_mutex); - sensor = __imx_media_find_sensor(imxmd, start_entity); - mutex_unlock(&imxmd->md.graph_mutex); - - return sensor; -} -EXPORT_SYMBOL_GPL(imx_media_find_sensor); - /* * Turn current pipeline streaming on/off starting from entity. */ |