media: imx: Various fixes for i.MX5 support
Subsystems (5)
Steve Longerbeam
maintainercover media: imx: Various fixes for i.MX5 support
Some fixes and improvements to support video capture on i.MX5.
Steve Longerbeam (4):
media: imx: csi: Allow unknown nearest upstream entities
media: imx: Clear fwnode link struct for each endpoint iteration
media: imx: Rename functions that add IPU-internal subdevs/links
media: imx: Don't register IPU subdevs/links if CSI port missing
drivers/staging/media/imx/imx-ic-common.c | 2 +- drivers/staging/media/imx/imx-media-csi.c | 18 +++- drivers/staging/media/imx/imx-media-dev.c | 13 +-- .../staging/media/imx/imx-media-internal-sd.c | 36 +++----- drivers/staging/media/imx/imx-media-of.c | 91 ++++++++++++------- drivers/staging/media/imx/imx-media-vdic.c | 2 +- drivers/staging/media/imx/imx-media.h | 11 ++- 7 files changed, 92 insertions(+), 81 deletions(-)
Signature · 1 line
2.17.1
Steve Longerbeam
maintainerPATCH 1/4 media: imx: csi: Allow unknown nearest upstream entities
On i.MX6, the nearest upstream entity to the CSI can only be the CSI video muxes or the Synopsys DW MIPI CSI-2 receiver.
However the i.MX53 has no CSI video muxes or a MIPI CSI-2 receiver. So allow for the nearest upstream entity to the CSI to be something other than those.
upstream entity")
--- drivers/staging/media/imx/imx-media-csi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/staging/media/imx/imx-media-csi.c +14 -4
@@ -154,9 +154,10 @@ static inline bool requires_passthrough(struct v4l2_fwnode_endpoint *ep,/* * Parses the fwnode endpoint from the source pad of the entity * connected to this CSI. This will either be the entity directly -* upstream from the CSI-2 receiver, or directly upstream from the -* video mux. The endpoint is needed to determine the bus type and -* bus config coming into the CSI. +* upstream from the CSI-2 receiver, directly upstream from the +* video mux, or directly upstream from the CSI itself. The endpoint +* is needed to determine the bus type and bus config coming into +* the CSI. */ static int csi_get_upstream_endpoint (struct csi_priv *priv,struct v4l2_fwnode_endpoint *ep)
@@ -172,7 +173,8 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv,if (!priv->src_sd)return -EPIPE ; - src = &priv->src_sd->entity; + sd = priv->src_sd; + src = &sd->entity;if (src->function ==MEDIA_ENT_F_VID_MUX ) {/*
@@ -186,6 +188,14 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv, src = &sd->entity; } +/* +* If the source is neither the video mux nor the CSI-2 receiver, +* get the source pad directly upstream from CSI itself. +*/ +if (src->function !=MEDIA_ENT_F_VID_MUX && + sd->grp_id !=IMX_MEDIA_GRP_ID_CSI2 ) + src = &priv->sd.entity; +/* get source pad of entity directly upstream from src */ pad =imx_media_find_upstream_pad (priv->md, src,0 );if (IS_ERR (pad))
Signature · 1 line
2.17.1
Philipp Zabel
maintainerRe: [PATCH 1/4] media: imx: csi: Allow unknown nearest upstream entities
Quoted 45 lines · Steve Longerbeam
On i.MX6, the nearest upstream entity to the CSI can only be the CSI video muxes or the Synopsys DW MIPI CSI-2 receiver.
However the i.MX53 has no CSI video muxes or a MIPI CSI-2 receiver. So allow for the nearest upstream entity to the CSI to be something other than those.
Fixes bf3cfaa712e5c ("media: staging/imx: get CSI bus type from nearestupstream entity")
Signed-off-by Steve Longerbeam <[email protected]>--- drivers/staging/media/imx/imx-media-csi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/staging/media/imx/imx-media-csi.c +6
-4@@ -154,9 +154,10 @@ static inline bool requires_passthrough(struct v4l2_fwnode_endpoint *ep,/* * Parses the fwnode endpoint from the source pad of the entity * connected to this CSI. This will either be the entity directly -* upstream from the CSI-2 receiver, or directly upstream from the -* video mux. The endpoint is needed to determine the bus type and -* bus config coming into the CSI. +* upstream from the CSI-2 receiver, directly upstream from the +* video mux, or directly upstream from the CSI itself. The endpoint +* is needed to determine the bus type and bus config coming into +* the CSI. */ static int csi_get_upstream_endpoint (struct csi_priv *priv,struct v4l2_fwnode_endpoint *ep)@@ -172,7 +173,8 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv,if (!priv->src_sd)return -EPIPE ; - src = &priv->src_sd->entity; + sd = priv->src_sd; + src = &sd->entity;if (src->function ==MEDIA_ENT_F_VID_MUX ) {/*
drivers/staging/media/imx/imx-media-csi.c static int csi_get_upstream_endpoint(struct csi_priv *priv, · line 195
Quoted 8 lines
drivers/staging/media/imx/imx-media-csi.c +5
-0@@ -186,6 +188,14 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv, src = &sd->entity; } +/* +* If the source is neither the video mux nor the CSI-2 receiver, +* get the source pad directly upstream from CSI itself. +*/ + if (src->function != MEDIA_ENT_F_VID_MUX &&
Will it work correctly if there's an external MUX connected to the CSI?
drivers/staging/media/imx/imx-media-csi.c static int csi_get_upstream_endpoint(struct csi_priv *priv, · line 201
Quoted 6 lines
drivers/staging/media/imx/imx-media-csi.c +3
-0+ sd->grp_id != IMX_MEDIA_GRP_ID_CSI2) + src = &priv->sd.entity; +/* get source pad of entity directly upstream from src */ pad =imx_media_find_upstream_pad (priv->md, src,0 );if (IS_ERR (pad))
regards
Philipp
Steve Longerbeam
maintainerRe: [PATCH 1/4] media: imx: csi: Allow unknown nearest upstream entities
Quoted 49 lines · Philipp Zabel
Quoted 48 lines · Steve Longerbeam
On i.MX6, the nearest upstream entity to the CSI can only be the CSI video muxes or the Synopsys DW MIPI CSI-2 receiver.
However the i.MX53 has no CSI video muxes or a MIPI CSI-2 receiver. So allow for the nearest upstream entity to the CSI to be something other than those.
Fixes bf3cfaa712e5c ("media: staging/imx: get CSI bus type from nearestupstream entity")
Signed-off-by Steve Longerbeam <[email protected]>--- drivers/staging/media/imx/imx-media-csi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/staging/media/imx/imx-media-csi.c +6
-4@@ -154,9 +154,10 @@ static inline bool requires_passthrough(struct v4l2_fwnode_endpoint *ep,/* * Parses the fwnode endpoint from the source pad of the entity * connected to this CSI. This will either be the entity directly -* upstream from the CSI-2 receiver, or directly upstream from the -* video mux. The endpoint is needed to determine the bus type and -* bus config coming into the CSI. +* upstream from the CSI-2 receiver, directly upstream from the +* video mux, or directly upstream from the CSI itself. The endpoint +* is needed to determine the bus type and bus config coming into +* the CSI. */ static int csi_get_upstream_endpoint (struct csi_priv *priv,struct v4l2_fwnode_endpoint *ep)@@ -172,7 +173,8 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv,if (!priv->src_sd)return -EPIPE ; - src = &priv->src_sd->entity; + sd = priv->src_sd; + src = &sd->entity;if (src->function ==MEDIA_ENT_F_VID_MUX ) {/* @@ -186,6 +188,14 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv, src = &sd->entity; }
Quoted 6 lines
drivers/staging/media/imx/imx-media-csi.c static int csi_get_upstream_endpoint(struct csi_priv *priv, · line 195
Quoted 5 lines
drivers/staging/media/imx/imx-media-csi.c +5
-0+/* +* If the source is neither the video mux nor the CSI-2 receiver, +* get the source pad directly upstream from CSI itself. +*/ + if (src->function != MEDIA_ENT_F_VID_MUX &&Will it work correctly if there's an external MUX connected to the CSI?
By external MUX are you referring to some MUX that's external to the SoC (e.g. not the CSI muxes which are external to the IPU but internal to the SoC)? If so then yes it will still work (and of course it works if the MUX in question is the CSI muxes).
The function csi_get_upstream_endpoint() is only looking for, and stops at, the first sub-device that is external to the SoC, in order to determine the bus type coming into the SoC of the currently enabled pipeline. And that sub-device could be anything, including another MUX.
Steve
Quoted 9 lines
drivers/staging/media/imx/imx-media-csi.c static int csi_get_upstream_endpoint(struct csi_priv *priv, · line 201
Quoted 7 lines
drivers/staging/media/imx/imx-media-csi.c +3
-0+ sd->grp_id != IMX_MEDIA_GRP_ID_CSI2) + src = &priv->sd.entity; +/* get source pad of entity directly upstream from src */ pad =imx_media_find_upstream_pad (priv->md, src,0 );if (IS_ERR (pad))regards
Philipp
Steve Longerbeam
maintainerPATCH 2/4 media: imx: Clear fwnode link struct for each endpoint iteration
In reply to Steve LongerbeamIn imx_media_create_csi_of_links(), the 'struct v4l2_fwnode_link' must be cleared for each endpoint iteration, otherwise if the remote port has no "reg" property, link.remote_port will not be reset to zero. This was discovered on the i.MX53 SMD board, since the OV5642 connects directly to ipu1_csi0 and has a single source port with no "reg" property.
--- drivers/staging/media/imx/imx-media-of.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/staging/media/imx/imx-media-of.c +9 -6
@@ -143,15 +143,18 @@ int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, struct v4l2_subdev *csi) {struct device_node *csi_np = csi->dev->of_node; -struct fwnode_handle *fwnode, *csi_ep; -struct v4l2_fwnode_link link;struct device_node *ep; -int ret; - - link.local_node =of_fwnode_handle (csi_np); - link.local_port =CSI_SINK_PAD ;for_each_child_of_node (csi_np, ep) { +struct fwnode_handle *fwnode, *csi_ep; +struct v4l2_fwnode_link link; +int ret; + +memset (&link,0 ,sizeof (link)); + + link.local_node =of_fwnode_handle (csi_np); + link.local_port =CSI_SINK_PAD ; + csi_ep =of_fwnode_handle (ep); fwnode =fwnode_graph_get_remote_endpoint (csi_ep);
Signature · 1 line
2.17.1
Steve Longerbeam
maintainerPATCH 3/4 media: imx: Rename functions that add IPU-internal subdevs/links
In reply to Steve LongerbeamFor the functions that add and remove the internal IPU subdevice descriptors and links between them, rename them to make clear they are the subdevs and links internal to the IPU. Also rename the platform data structure for the internal IPU subdevices. No functional changes.
--- drivers/staging/media/imx/imx-ic-common.c | 2 +- drivers/staging/media/imx/imx-media-dev.c | 10 +++++----- .../staging/media/imx/imx-media-internal-sd.c | 16 ++++++++-------- drivers/staging/media/imx/imx-media-vdic.c | 2 +- drivers/staging/media/imx/imx-media.h | 10 +++++----- 5 files changed, 20 insertions(+), 20 deletions(-)
drivers/staging/media/imx/imx-ic-common.c +1 -1
@@ -26,7 +26,7 @@ static struct imx_ic_ops *ic_ops[IC_NUM_OPS] = {static int imx_ic_probe (struct platform_device *pdev) { -struct imx_media_internal_sd_platformdata *pdata; +struct imx_media_ipu_internal_sd_pdata *pdata;struct imx_ic_priv *priv;int ret;
drivers/staging/media/imx/imx-media-dev.c +5 -5
@@ -155,7 +155,7 @@ static int imx_media_create_links(struct v4l2_async_notifier *notifier)case IMX_MEDIA_GRP_ID_IC_PRPVF :case IMX_MEDIA_GRP_ID_CSI0 :case IMX_MEDIA_GRP_ID_CSI1 : - ret =imx_media_create_internal_links (imxmd, sd); + ret =imx_media_create_ipu_internal_links (imxmd, sd);if (ret)return ret;/*
@@ -487,10 +487,10 @@ static int imx_media_probe(struct platform_device *pdev) goto notifier_cleanup; } - ret =imx_media_add_internal_subdevs (imxmd); + ret =imx_media_add_ipu_internal_subdevs (imxmd);if (ret) {v4l2_err (&imxmd->v4l2_dev, -"add_internal_subdevs failed with %d\n" , ret); +"add_ipu_internal_subdevs failed with %d\n" , ret); goto notifier_cleanup; }
@@ -513,7 +513,7 @@ static int imx_media_probe(struct platform_device *pdev)return 0 ; del_int: -imx_media_remove_internal_subdevs (imxmd); +imx_media_remove_ipu_internal_subdevs (imxmd); notifier_cleanup:v4l2_async_notifier_cleanup (&imxmd->notifier);v4l2_device_unregister (&imxmd->v4l2_dev);
@@ -530,7 +530,7 @@ static int imx_media_remove(struct platform_device *pdev)v4l2_info (&imxmd->v4l2_dev,"Removing imx-media\n" );v4l2_async_notifier_unregister (&imxmd->notifier); -imx_media_remove_internal_subdevs (imxmd); +imx_media_remove_ipu_internal_subdevs (imxmd);v4l2_async_notifier_cleanup (&imxmd->notifier);v4l2_device_unregister (&imxmd->v4l2_dev);media_device_unregister (&imxmd->md);
drivers/staging/media/imx/imx-media-internal-sd.c +8 -8
@@ -1,7 +1,7 @@/* * Media driver for Freescale i.MX5/6 SOC * -* Adds the internal subdevices and the media links between them. +* Adds the IPU internal subdevices and the media links between them. * * Copyright (c) 2016 Mentor Graphics Inc. *
@@ -192,7 +192,7 @@ static struct v4l2_subdev *find_sink(struct imx_media_dev *imxmd,/* * retrieve IPU id from subdev name, note: can't get this from -* struct imx_media_internal_sd_platformdata because if src is +* struct imx_media_ipu_internal_sd_pdata because if src is * a CSI, it has different struct ipu_client_platformdata which * does not contain IPU id. */
@@ -229,8 +229,8 @@ static int create_ipu_internal_link(struct imx_media_dev *imxmd,return ret; } -int imx_media_create_internal_links (struct imx_media_dev *imxmd, -struct v4l2_subdev *sd) +int imx_media_create_ipu_internal_links (struct imx_media_dev *imxmd, +struct v4l2_subdev *sd) {const struct internal_subdev *intsd;const struct internal_pad *intpad;
@@ -270,7 +270,7 @@ static int add_internal_subdev(struct imx_media_dev *imxmd, const struct internal_subdev *isd, int ipu_id) { -struct imx_media_internal_sd_platformdata pdata; +struct imx_media_ipu_internal_sd_pdata pdata;struct platform_device_info pdevinfo = {};struct platform_device *pdev;
@@ -328,7 +328,7 @@ static int add_ipu_internal_subdevs(struct imx_media_dev *imxmd, int ipu_id)return 0 ; } -int imx_media_add_internal_subdevs (struct imx_media_dev *imxmd) +int imx_media_add_ipu_internal_subdevs (struct imx_media_dev *imxmd) {int ret;
@@ -343,11 +343,11 @@ int imx_media_add_internal_subdevs(struct imx_media_dev *imxmd)return 0 ; remove: -imx_media_remove_internal_subdevs (imxmd); +imx_media_remove_ipu_internal_subdevs (imxmd);return ret; } -void imx_media_remove_internal_subdevs (struct imx_media_dev *imxmd) +void imx_media_remove_ipu_internal_subdevs (struct imx_media_dev *imxmd) {struct imx_media_async_subdev *imxasd;struct v4l2_async_subdev *asd;
drivers/staging/media/imx/imx-media-vdic.c +1 -1
@@ -931,7 +931,7 @@ static const struct v4l2_subdev_internal_ops vdic_internal_ops = {static int imx_vdic_probe (struct platform_device *pdev) { -struct imx_media_internal_sd_platformdata *pdata; +struct imx_media_ipu_internal_sd_pdata *pdata;struct vdic_priv *priv;int ret;
drivers/staging/media/imx/imx-media.h +5 -5
@@ -113,7 +113,7 @@ struct imx_media_pad_vdev {struct list_head list; }; -struct imx_media_internal_sd_platformdata { +struct imx_media_ipu_internal_sd_pdata {char sd_name[V4L2_SUBDEV_NAME_SIZE ];u32 grp_id;int ipu_id;
@@ -237,10 +237,10 @@ struct imx_media_fim *imx_media_fim_init(struct v4l2_subdev *sd);void imx_media_fim_free (struct imx_media_fim *fim);/* imx-media-internal-sd.c */ -int imx_media_add_internal_subdevs (struct imx_media_dev *imxmd); -int imx_media_create_internal_links (struct imx_media_dev *imxmd, -struct v4l2_subdev *sd); -void imx_media_remove_internal_subdevs (struct imx_media_dev *imxmd); +int imx_media_add_ipu_internal_subdevs (struct imx_media_dev *imxmd); +int imx_media_create_ipu_internal_links (struct imx_media_dev *imxmd, +struct v4l2_subdev *sd); +void imx_media_remove_ipu_internal_subdevs (struct imx_media_dev *imxmd);/* imx-media-of.c */ int imx_media_add_of_subdevs(struct imx_media_dev *dev,
Signature · 1 line
2.17.1
Re: [PATCH 3/4] media: imx: Rename functions that add IPU-internal subdevs/links
Quoted 7 lines · Steve Longerbeam
For the functions that add and remove the internal IPU subdevice descriptors and links between them, rename them to make clear they are the subdevs and links internal to the IPU. Also rename the platform data structure for the internal IPU subdevices. No functional changes.
Signed-off-by Steve Longerbeam <[email protected]>
regards
Philipp
Steve Longerbeam
maintainerPATCH 4/4 media: imx: Don't register IPU subdevs/links if CSI port missing
In reply to Steve LongerbeamThe second IPU internal sub-devices were being registered and links to them created even when the second IPU is not present. This is wrong for i.MX6 S/DL and i.MX53 which have only a single IPU.
--- drivers/staging/media/imx/imx-media-dev.c | 7 -- .../staging/media/imx/imx-media-internal-sd.c | 22 +----- drivers/staging/media/imx/imx-media-of.c | 76 ++++++++++++------- drivers/staging/media/imx/imx-media.h | 3 +- 4 files changed, 53 insertions(+), 55 deletions(-)
drivers/staging/media/imx/imx-media-dev.c +0 -7
@@ -487,13 +487,6 @@ static int imx_media_probe(struct platform_device *pdev) goto notifier_cleanup; } - ret =imx_media_add_ipu_internal_subdevs (imxmd); -if (ret) { -v4l2_err (&imxmd->v4l2_dev, -"add_ipu_internal_subdevs failed with %d\n" , ret); - goto notifier_cleanup; - } -/* no subdevs? just bail */ if (list_empty (&imxmd->notifier.asd_list)) { ret = -ENODEV ;
drivers/staging/media/imx/imx-media-internal-sd.c +4 -18
@@ -298,13 +298,14 @@ static int add_internal_subdev(struct imx_media_dev *imxmd, }/* adds the internal subdevs in one ipu */ -static int add_ipu_internal_subdevs (struct imx_media_dev *imxmd,int ipu_id) +int imx_media_add_ipu_internal_subdevs (struct imx_media_dev *imxmd, +int ipu_id) {enum isd_enum i; +int ret;for (i =0 ; i < num_isd; i++) {const struct internal_subdev *isd = &int_subdev[i]; -int ret;/* * the CSIs are represented in the device-tree, so those
@@ -322,25 +323,10 @@ static int add_ipu_internal_subdevs(struct imx_media_dev *imxmd, int ipu_id) }if (ret) -return ret; + goto remove; }return 0 ; -} - -int imx_media_add_ipu_internal_subdevs (struct imx_media_dev *imxmd) -{ -int ret; - - ret =add_ipu_internal_subdevs (imxmd,0 ); -if (ret) - goto remove; - - ret =add_ipu_internal_subdevs (imxmd,1 ); -if (ret) - goto remove; - -return 0 ; remove:imx_media_remove_ipu_internal_subdevs (imxmd);
drivers/staging/media/imx/imx-media-of.c +47 -29
97 lines not on this page · raw message
drivers/staging/media/imx/imx-media.h +2 -1
@@ -237,7 +237,8 @@ struct imx_media_fim *imx_media_fim_init(struct v4l2_subdev *sd);void imx_media_fim_free (struct imx_media_fim *fim);/* imx-media-internal-sd.c */ -int imx_media_add_ipu_internal_subdevs (struct imx_media_dev *imxmd); +int imx_media_add_ipu_internal_subdevs (struct imx_media_dev *imxmd, +int ipu_id);int imx_media_create_ipu_internal_links (struct imx_media_dev *imxmd,struct v4l2_subdev *sd);void imx_media_remove_ipu_internal_subdevs (struct imx_media_dev *imxmd);
Signature · 1 line
2.17.1
Re: [PATCH 4/4] media: imx: Don't register IPU subdevs/links if CSI port missing
Quoted 7 lines · Steve Longerbeam
The second IPU internal sub-devices were being registered and links to them created even when the second IPU is not present. This is wrong for i.MX6 S/DL and i.MX53 which have only a single IPU.
Fixes e130291212df5 ("[media] media: Add i.MX media core driver")Signed-off-by Steve Longerbeam <[email protected]>
regards
Philipp