Message ID | 20200501171556.14731-15-slongerbeam@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: imx: Create media links in bound notifiers | expand |
Hi Steve, On Fri, May 01, 2020 at 10:15:48AM -0700, Steve Longerbeam wrote: > Implement a notifier bound op to register media links from the remote > sub-device's source pad(s) to the mipi csi-2 receiver sink pad. > > Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Acked-by: Rui Miguel Silva <rmfrfs@gmail.com> ------ Cheers, Rui > --- > Changes in v5: > - imx_media_create_fwnode_pad_link() has been moved to core as > v4l2_create_fwnode_links_to_pad(). > Changes in v4: > - none > Changes in v3: > - call a local imx-media utility imx_media_create_fwnode_pad_link(). > Changes in v2: > - Move notifier_to_csis_state() next to mipi_sd_to_csis_state(), remove > unnecessary inline, and rename to mipi_notifier_to_csis_state(). > Suggested by Rui Silva. > --- > drivers/staging/media/imx/imx7-mipi-csis.c | 23 ++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c > index 7b5c3e662d0d..1025e42740f1 100644 > --- a/drivers/staging/media/imx/imx7-mipi-csis.c > +++ b/drivers/staging/media/imx/imx7-mipi-csis.c > @@ -26,6 +26,7 @@ > > #include <media/v4l2-device.h> > #include <media/v4l2-fwnode.h> > +#include <media/v4l2-mc.h> > #include <media/v4l2-subdev.h> > > #define CSIS_DRIVER_NAME "imx7-mipi-csis" > @@ -385,6 +386,12 @@ static int mipi_csis_dump_regs(struct csi_state *state) > return 0; > } > > +static struct csi_state * > +mipi_notifier_to_csis_state(struct v4l2_async_notifier *n) > +{ > + return container_of(n, struct csi_state, notifier); > +} > + > static struct csi_state *mipi_sd_to_csis_state(struct v4l2_subdev *sdev) > { > return container_of(sdev, struct csi_state, mipi_sd); > @@ -948,6 +955,20 @@ static int mipi_csis_parse_dt(struct platform_device *pdev, > > static int mipi_csis_pm_resume(struct device *dev, bool runtime); > > +static int mipi_csis_notify_bound(struct v4l2_async_notifier *notifier, > + struct v4l2_subdev *sd, > + struct v4l2_async_subdev *asd) > +{ > + struct csi_state *state = mipi_notifier_to_csis_state(notifier); > + struct media_pad *sink = &state->mipi_sd.entity.pads[CSIS_PAD_SINK]; > + > + return v4l2_create_fwnode_links_to_pad(sd, sink); > +} > + > +static const struct v4l2_async_notifier_operations mipi_csis_notify_ops = { > + .bound = mipi_csis_notify_bound, > +}; > + > static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, > struct platform_device *pdev, > const struct v4l2_subdev_ops *ops) > @@ -1016,6 +1037,8 @@ static int mipi_csis_async_register(struct csi_state *state) > > fwnode_handle_put(ep); > > + state->notifier.ops = &mipi_csis_notify_ops; > + > ret = v4l2_async_subdev_notifier_register(&state->mipi_sd, > &state->notifier); > if (ret) > -- > 2.17.1 >
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index 7b5c3e662d0d..1025e42740f1 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -26,6 +26,7 @@ #include <media/v4l2-device.h> #include <media/v4l2-fwnode.h> +#include <media/v4l2-mc.h> #include <media/v4l2-subdev.h> #define CSIS_DRIVER_NAME "imx7-mipi-csis" @@ -385,6 +386,12 @@ static int mipi_csis_dump_regs(struct csi_state *state) return 0; } +static struct csi_state * +mipi_notifier_to_csis_state(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi_state, notifier); +} + static struct csi_state *mipi_sd_to_csis_state(struct v4l2_subdev *sdev) { return container_of(sdev, struct csi_state, mipi_sd); @@ -948,6 +955,20 @@ static int mipi_csis_parse_dt(struct platform_device *pdev, static int mipi_csis_pm_resume(struct device *dev, bool runtime); +static int mipi_csis_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi_state *state = mipi_notifier_to_csis_state(notifier); + struct media_pad *sink = &state->mipi_sd.entity.pads[CSIS_PAD_SINK]; + + return v4l2_create_fwnode_links_to_pad(sd, sink); +} + +static const struct v4l2_async_notifier_operations mipi_csis_notify_ops = { + .bound = mipi_csis_notify_bound, +}; + static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, struct platform_device *pdev, const struct v4l2_subdev_ops *ops) @@ -1016,6 +1037,8 @@ static int mipi_csis_async_register(struct csi_state *state) fwnode_handle_put(ep); + state->notifier.ops = &mipi_csis_notify_ops; + ret = v4l2_async_subdev_notifier_register(&state->mipi_sd, &state->notifier); if (ret)
Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the mipi csi-2 receiver sink pad. Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> --- Changes in v5: - imx_media_create_fwnode_pad_link() has been moved to core as v4l2_create_fwnode_links_to_pad(). Changes in v4: - none Changes in v3: - call a local imx-media utility imx_media_create_fwnode_pad_link(). Changes in v2: - Move notifier_to_csis_state() next to mipi_sd_to_csis_state(), remove unnecessary inline, and rename to mipi_notifier_to_csis_state(). Suggested by Rui Silva. --- drivers/staging/media/imx/imx7-mipi-csis.c | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)