Message ID | 20180419101812.30688-1-rui.silva@linaro.org |
---|---|
Headers | show |
Series | media: staging/imx7: add i.MX7 media driver | expand |
On Thu, Apr 19, 2018 at 11:17:59AM +0100, Rui Miguel Silva wrote: > +static int imx7_csi_link_setup(struct media_entity *entity, > + const struct media_pad *local, > + const struct media_pad *remote, u32 flags) > +{ > + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); > + struct imx7_csi *csi = v4l2_get_subdevdata(sd); > + struct v4l2_subdev *remote_sd; > + int ret = 0; > + > + dev_dbg(csi->dev, "link setup %s -> %s\n", remote->entity->name, > + local->entity->name); > + > + mutex_lock(&csi->lock); > + > + if (local->flags & MEDIA_PAD_FL_SINK) { > + if (!is_media_entity_v4l2_subdev(remote->entity)) { > + ret = -EINVAL; > + goto unlock; > + } > + > + remote_sd = media_entity_to_v4l2_subdev(remote->entity); > + > + if (flags & MEDIA_LNK_FL_ENABLED) { > + if (csi->src_sd) { > + ret = -EBUSY; > + goto unlock; > + } > + csi->src_sd = remote_sd; > + } else { > + csi->src_sd = NULL; > + } > + > + goto init; > + } > + > + /* source pad */ > + if (flags & MEDIA_LNK_FL_ENABLED) { > + if (csi->sink) { > + ret = -EBUSY; > + goto unlock; > + } > + csi->sink = remote->entity; > + } else { > + v4l2_ctrl_handler_free(&csi->ctrl_hdlr); > + v4l2_ctrl_handler_init(&csi->ctrl_hdlr, 0); > + csi->sink = NULL; > + } > + > +init: > + if (csi->sink || csi->src_sd) > + imx7_csi_init(csi); > + else > + imx7_csi_deinit(csi); > + > +unlock: > + mutex_unlock(&csi->lock); > + > + return 0; This should be "return ret;" because the failure paths go through here as well. > +} > + > +static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, > + struct media_link *link, > + struct v4l2_subdev_format *source_fmt, > + struct v4l2_subdev_format *sink_fmt) > +{ > + struct imx7_csi *csi = v4l2_get_subdevdata(sd); > + struct v4l2_fwnode_endpoint upstream_ep; > + int ret; > + > + ret = v4l2_subdev_link_validate_default(sd, link, source_fmt, sink_fmt); > + if (ret) > + return ret; > + > + ret = imx7_csi_get_upstream_endpoint(csi, &upstream_ep, true); > + if (ret) { > + v4l2_err(&csi->sd, "failed to find upstream endpoint\n"); > + return ret; > + } > + > + mutex_lock(&csi->lock); > + > + csi->upstream_ep = upstream_ep; > + csi->is_csi2 = (upstream_ep.bus_type == V4L2_MBUS_CSI2); > + > + mutex_unlock(&csi->lock); > + > + return ret; return 0; > +} > + [ snip ] > + > +static int imx7_csi_remove(struct platform_device *pdev) > +{ > + return 0; > +} There is no need for this empty (struct platform_driver)->remove() function. See platform_drv_remove() for how it's called. This looks nice, though. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Philip, Thanks for the review. On Thu 19 Apr 2018 at 13:38, Philipp Zabel wrote: > On Thu, 2018-04-19 at 11:18 +0100, Rui Miguel Silva wrote: >> Some sensors can only output 10 bit bayer formats, like the >> OV2680. Add support >> for that in imx-media. >> >> Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> >> --- >> drivers/staging/media/imx/imx-media-utils.c | 24 >> +++++++++++++++++++++ >> 1 file changed, 24 insertions(+) >> >> diff --git a/drivers/staging/media/imx/imx-media-utils.c >> b/drivers/staging/media/imx/imx-media-utils.c >> index fab98fc0d6a0..99527daba29a 100644 >> --- a/drivers/staging/media/imx/imx-media-utils.c >> +++ b/drivers/staging/media/imx/imx-media-utils.c >> @@ -118,6 +118,30 @@ static const struct imx_media_pixfmt >> rgb_formats[] = { >> .cs = IPUV3_COLORSPACE_RGB, >> .bpp = 8, >> .bayer = true, >> + }, { >> + .fourcc = V4L2_PIX_FMT_SBGGR10, >> + .codes = {MEDIA_BUS_FMT_SBGGR10_1X10}, >> + .cs = IPUV3_COLORSPACE_RGB, >> + .bpp = 16, >> + .bayer = true, >> + }, { >> + .fourcc = V4L2_PIX_FMT_SGBRG10, >> + .codes = {MEDIA_BUS_FMT_SGBRG10_1X10}, >> + .cs = IPUV3_COLORSPACE_RGB, >> + .bpp = 16, >> + .bayer = true, >> + }, { >> + .fourcc = V4L2_PIX_FMT_SGRBG10, >> + .codes = {MEDIA_BUS_FMT_SGRBG10_1X10}, >> + .cs = IPUV3_COLORSPACE_RGB, >> + .bpp = 16, >> + .bayer = true, >> + }, { >> + .fourcc = V4L2_PIX_FMT_SRGGB10, >> + .codes = {MEDIA_BUS_FMT_SRGGB10_1X10}, >> + .cs = IPUV3_COLORSPACE_RGB, >> + .bpp = 16, >> + .bayer = true, > > This will break 10-bit bayer formats on i.MX6, which currently > stores > them in memory expanded to 16-bit, as listed in the entries > below: Oh, I see... i.MX7 also store it expanded, I will change my code to use the format array as it is for i.MX6. Thanks, --- Cheers, Rui -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html