linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
To: Steve Longerbeam <slongerbeam@gmail.com>, <shawnguo@kernel.org>,
	<kernel@pengutronix.de>, <fabio.estevam@nxp.com>,
	<robh+dt@kernel.org>, <mark.rutland@arm.com>,
	<linux@armlinux.org.uk>, <mchehab@kernel.org>,
	<gregkh@linuxfoundation.org>, <p.zabel@pengutronix.de>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-media@vger.kernel.org>, <devel@driverdev.osuosl.org>,
	Steve Longerbeam <steve_longerbeam@mentor.com>
Subject: Re: [PATCH v2 15/19] media: imx: Add MIPI CSI-2 Receiver subdev driver
Date: Wed, 4 Jan 2017 17:05:10 +0200	[thread overview]
Message-ID: <ecfcd8e5-01bd-b9a4-8653-7bbbdece4231@mentor.com> (raw)
In-Reply-To: <1483477049-19056-16-git-send-email-steve_longerbeam@mentor.com>

On 01/03/2017 10:57 PM, Steve Longerbeam wrote:
> Adds MIPI CSI-2 Receiver subdev driver. This subdev is required
> for sensors with a MIPI CSI2 interface.
> 
> Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
> ---
>  drivers/staging/media/imx/Makefile        |   1 +
>  drivers/staging/media/imx/imx-mipi-csi2.c | 509 ++++++++++++++++++++++++++++++
>  2 files changed, 510 insertions(+)
>  create mode 100644 drivers/staging/media/imx/imx-mipi-csi2.c
> 
> diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile
> index fe9e992..0decef7 100644
> --- a/drivers/staging/media/imx/Makefile
> +++ b/drivers/staging/media/imx/Makefile
> @@ -9,3 +9,4 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-ic.o
>  obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-csi.o
>  obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-smfc.o
>  obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-camif.o
> +obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-mipi-csi2.o
> diff --git a/drivers/staging/media/imx/imx-mipi-csi2.c b/drivers/staging/media/imx/imx-mipi-csi2.c
> new file mode 100644
> index 0000000..84df16e
> --- /dev/null
> +++ b/drivers/staging/media/imx/imx-mipi-csi2.c
> @@ -0,0 +1,509 @@
> +/*
> + * MIPI CSI-2 Receiver Subdev for Freescale i.MX5/6 SOC.
> + *
> + * Copyright (c) 2012-2014 Mentor Graphics Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +#include <linux/module.h>
> +#include <linux/export.h>
> +#include <linux/types.h>
> +#include <linux/init.h>
> +#include <linux/platform_device.h>
> +#include <linux/err.h>
> +#include <linux/delay.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/clk.h>
> +#include <linux/list.h>
> +#include <linux/irq.h>
> +#include <linux/of_device.h>
> +#include <media/v4l2-device.h>
> +#include <media/v4l2-of.h>
> +#include <media/v4l2-subdev.h>
> +#include <media/v4l2-async.h>

Please sort the list of headers alphabetically.

> +#include <asm/mach/irq.h>

Why do you need to include this header?

> +#include <video/imx-ipu-v3.h>
> +#include "imx-media.h"
> +

[snip]

> +static int imxcsi2_s_stream(struct v4l2_subdev *sd, int enable)
> +{
> +	struct imxcsi2_dev *csi2 = sd_to_dev(sd);
> +	int i, ret = 0;
> +
> +	if (!csi2->src_sd)
> +		return -EPIPE;
> +	for (i = 0; i < CSI2_NUM_SRC_PADS; i++) {
> +		if (csi2->sink_sd[i])
> +			break;
> +	}
> +	if (i >= CSI2_NUM_SRC_PADS)
> +		return -EPIPE;
> +
> +	v4l2_info(sd, "stream %s\n", enable ? "ON" : "OFF");
> +
> +	if (enable && !csi2->stream_on) {
> +		clk_prepare_enable(csi2->pix_clk);

It can complicate the design for you, but in general clk_prepare_enable()
can return an error.

> +		ret = imxcsi2_dphy_wait(csi2);
> +		if (ret)
> +			clk_disable_unprepare(csi2->pix_clk);
> +	} else if (!enable && csi2->stream_on) {
> +		clk_disable_unprepare(csi2->pix_clk);
> +	}
> +
> +	if (!ret)
> +		csi2->stream_on = enable;
> +	return ret;
> +}
> +

[snip]

> +
> +static int imxcsi2_parse_endpoints(struct imxcsi2_dev *csi2)
> +{
> +	struct device_node *node = csi2->dev->of_node;
> +	struct device_node *epnode;
> +	struct v4l2_of_endpoint ep;
> +	int ret = 0;
> +
> +	epnode = of_graph_get_next_endpoint(node, NULL);
> +	if (!epnode) {
> +		v4l2_err(&csi2->sd, "failed to get endpoint node\n");
> +		return -EINVAL;
> +	}
> +
> +	v4l2_of_parse_endpoint(epnode, &ep);

Do of_node_put(epnode) here and remove 'out' goto label.

> +	if (ep.bus_type != V4L2_MBUS_CSI2) {
> +		v4l2_err(&csi2->sd, "invalid bus type, must be MIPI CSI2\n");
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
> +	csi2->bus = ep.bus.mipi_csi2;
> +
> +	v4l2_info(&csi2->sd, "data lanes: %d\n", csi2->bus.num_data_lanes);
> +	v4l2_info(&csi2->sd, "flags: 0x%08x\n", csi2->bus.flags);
> +out:
> +	of_node_put(epnode);
> +	return ret;
> +}
> +

[snip]

> +static const struct of_device_id imxcsi2_dt_ids[] = {
> +	{ .compatible = "fsl,imx-mipi-csi2", },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, imxcsi2_dt_ids);
> +
> +static struct platform_driver imxcsi2_driver = {
> +	.driver = {
> +		.name = DEVICE_NAME,
> +		.owner = THIS_MODULE,

Please drop .owner assignment.

> +		.of_match_table = imxcsi2_dt_ids,
> +	},
> +	.probe = imxcsi2_probe,
> +	.remove = imxcsi2_remove,
> +};
> +
> +module_platform_driver(imxcsi2_driver);
> +
> +MODULE_DESCRIPTION("i.MX5/6 MIPI CSI-2 Receiver driver");
> +MODULE_AUTHOR("Steve Longerbeam <steve_longerbeam@mentor.com>");
> +MODULE_LICENSE("GPL");
> +
> 

--
With best wishes,
Vladimir

  reply	other threads:[~2017-01-04 15:05 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03 20:57 [PATCH v2 00/19] i.MX Media Driver Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 01/19] ARM: dts: imx6qdl: Add compatible, clocks, irqs to MIPI CSI-2 node Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 02/19] ARM: dts: imx6qdl: Add mipi_ipu1/2 multiplexers, mipi_csi, and their connections Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 03/19] ARM: dts: imx6qdl: add media device Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 04/19] ARM: dts: imx6-sabrelite: add OV5642 and OV5640 camera sensors Steve Longerbeam
2017-01-04 12:25   ` Vladimir Zapolskiy
2017-01-05 19:20     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 05/19] ARM: dts: imx6-sabresd: " Steve Longerbeam
2017-01-04 12:33   ` Vladimir Zapolskiy
2017-01-05 22:30     ` Steve Longerbeam
2017-01-04 15:26   ` Fabio Estevam
2017-01-07  0:25     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 06/19] ARM: dts: imx6-sabreauto: create i2cmux for i2c3 Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 07/19] ARM: dts: imx6-sabreauto: add reset-gpios property for max7310_b Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 08/19] ARM: dts: imx6-sabreauto: add pinctrl for gpt input capture Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 09/19] ARM: dts: imx6-sabreauto: add the ADV7180 video decoder Steve Longerbeam
2017-01-04 12:41   ` Vladimir Zapolskiy
2017-01-05 22:31     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 10/19] media: Add i.MX media core driver Steve Longerbeam
2017-01-04 13:33   ` Vladimir Zapolskiy
2017-01-06  1:21     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 11/19] media: imx: Add CSI subdev driver Steve Longerbeam
2017-01-04 13:44   ` Vladimir Zapolskiy
2017-01-06 18:05     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 12/19] media: imx: Add SMFC " Steve Longerbeam
2017-01-04 14:23   ` Vladimir Zapolskiy
2017-01-06 18:11     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 13/19] media: imx: Add IC subdev drivers Steve Longerbeam
2017-01-04 14:48   ` Vladimir Zapolskiy
2017-01-06 18:34     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 14/19] media: imx: Add Camera Interface subdev driver Steve Longerbeam
2017-01-04 14:55   ` Vladimir Zapolskiy
2017-01-06 18:42     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 15/19] media: imx: Add MIPI CSI-2 Receiver " Steve Longerbeam
2017-01-04 15:05   ` Vladimir Zapolskiy [this message]
2017-01-06 18:58     ` Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 16/19] media: imx: Add video switch " Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 17/19] media: imx: Add MIPI CSI-2 OV5640 sensor " Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 18/19] media: imx: Add Parallel OV5642 " Steve Longerbeam
2017-01-03 20:57 ` [PATCH v2 19/19] ARM: imx_v6_v7_defconfig: Enable staging video4linux drivers Steve Longerbeam
2017-01-03 21:10 ` [PATCH v2 00/19] i.MX Media Driver Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ecfcd8e5-01bd-b9a4-8653-7bbbdece4231@mentor.com \
    --to=vladimir_zapolskiy@mentor.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fabio.estevam@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=slongerbeam@gmail.com \
    --cc=steve_longerbeam@mentor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).