From: Sakari Ailus <sakari.ailus@iki.fi>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, hverkuil@xs4all.nl,
teturtia@gmail.com, dacohen@gmail.com, snjw23@gmail.com,
andriy.shevchenko@linux.intel.com, t.stanislaws@samsung.com,
tuukkat76@gmail.com, k.debski@gmail.com, riverful@gmail.com
Subject: Re: [PATCH 14/23] omap3isp: Configure CSI-2 phy based on platform data
Date: Thu, 19 Jan 2012 21:11:15 +0200 [thread overview]
Message-ID: <20120119191114.GH13236@valkosipuli.localdomain> (raw)
In-Reply-To: <201201191716.50660.laurent.pinchart@ideasonboard.com>
Hi Laurent,
On Thu, Jan 19, 2012 at 05:16:50PM +0100, Laurent Pinchart wrote:
> On Tuesday 17 January 2012 20:45:18 Sakari Ailus wrote:
> > On Mon, Jan 16, 2012 at 03:22:42PM +0100, Laurent Pinchart wrote:
> > > On Wednesday 11 January 2012 22:26:51 Sakari Ailus wrote:
> > > > Configure CSI-2 phy based on platform data in the ISP driver. For that,
> > > > the new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously
> > > > the same was configured from the board code.
> > > >
> > > > Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
> > > > ---
> > > >
> > > > drivers/media/video/omap3isp/isp.c | 29 ++++++++++-
> > > > drivers/media/video/omap3isp/isp.h | 4 --
> > > > drivers/media/video/omap3isp/ispcsi2.c | 42 ++++++++++++++-
> > > > drivers/media/video/omap3isp/ispcsiphy.c | 84
> > > >
> > > > ++++++++++++++++++++++++++---- drivers/media/video/omap3isp/ispcsiphy.h
> > > > |
> > > >
> > > > 5 ++
> > > >
> > > > 5 files changed, 148 insertions(+), 16 deletions(-)
> > > >
> > > > diff --git a/drivers/media/video/omap3isp/isp.c
> > > > b/drivers/media/video/omap3isp/isp.c index b818cac..d268d55 100644
> > > > --- a/drivers/media/video/omap3isp/isp.c
> > > > +++ b/drivers/media/video/omap3isp/isp.c
> > > > @@ -765,6 +765,34 @@ static int isp_pipeline_enable(struct isp_pipeline
> > > > *pipe, if (ret < 0 && ret != -ENOIOCTLCMD)
> > > >
> > > > return ret;
> > > >
> > > > + /*
> > > > + * Configure CCDC pixel clock. host_priv != NULL so
> > > > + * this one is a sensor.
> > > > + */
> > > > + if (subdev->host_priv) {
> > > > + struct v4l2_ext_controls ctrls;
> > > > + struct v4l2_ext_control ctrl;
> > > > +
> > > > + memset(&ctrls, 0, sizeof(ctrls));
> > > > + memset(&ctrl, 0, sizeof(ctrl));
> > > > +
> > > > + ctrl.id = V4L2_CID_IMAGE_SOURCE_PIXEL_RATE;
> > > > +
> > > > + ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(ctrl.id);
> > > > + ctrls.count = 1;
> > > > + ctrls.controls = &ctrl;
> > > > +
> > > > + ret = v4l2_g_ext_ctrls(subdev->ctrl_handler, &ctrls);
> > > > + if (ret < 0) {
> > > > + dev_warn(isp->dev,
> > > > + "no pixel rate control in subdev %s\n",
> > > > + subdev->name);
> > > > + return -EPIPE;
> > > > + }
> > > > +
> > > > + isp_set_pixel_clock(isp, ctrl.value64);
> > >
> > > Isn't this too late ? The CCDC has already been started. What about
> > > moving this code to ccdc_config_vp() ?
> >
> > I think you're right. I've mostly rewritten this part of the patchset and I
> > think it's much cleaner now.
> >
> > I have validate_link() functions where I'm validating the link and also
> > gathering information alongside that process into a few fields in
> > isp_pipeline struct.
> >
> > Then those fields can be used in streamon time. Some additional checks for
> > those parameters are also done there and they may result into an error
> > which is then handled.
> >
> > > > + }
> > > > +
> > > >
> > > > if (subdev == &isp->isp_ccdc.subdev) {
> > > >
> > > > v4l2_subdev_call(&isp->isp_aewb.subdev, video,
> > > >
> > > > s_stream, mode);
> > > >
> > > > @@ -2072,7 +2100,6 @@ static int isp_probe(struct platform_device
> > > > *pdev)
> > > >
> > > > isp->autoidle = autoidle;
> > > > isp->platform_cb.set_xclk = isp_set_xclk;
> > > >
> > > > - isp->platform_cb.set_pixel_clock = isp_set_pixel_clock;
> > > >
> > > > mutex_init(&isp->isp_mutex);
> > > > spin_lock_init(&isp->stat_lock);
> > > >
> > > > diff --git a/drivers/media/video/omap3isp/isp.h
> > > > b/drivers/media/video/omap3isp/isp.h index ff1c422..dd1b61e 100644
> > > > --- a/drivers/media/video/omap3isp/isp.h
> > > > +++ b/drivers/media/video/omap3isp/isp.h
> > > > @@ -126,10 +126,6 @@ struct isp_reg {
> > > >
> > > > struct isp_platform_callback {
> > > >
> > > > u32 (*set_xclk)(struct isp_device *isp, u32 xclk, u8 xclksel);
> > > >
> > > > - int (*csiphy_config)(struct isp_csiphy *phy,
> > > > - struct isp_csiphy_dphy_cfg *dphy,
> > > > - struct isp_csiphy_lanes_cfg *lanes);
> > > > - void (*set_pixel_clock)(struct isp_device *isp, unsigned int
> > > > pixelclk);
> > > >
> > > > };
> > > >
> > > > /*
> > > >
> > > > diff --git a/drivers/media/video/omap3isp/ispcsi2.c
> > > > b/drivers/media/video/omap3isp/ispcsi2.c index 0c5f1cb..0b3e705 100644
> > > > --- a/drivers/media/video/omap3isp/ispcsi2.c
> > > > +++ b/drivers/media/video/omap3isp/ispcsi2.c
> > > > @@ -1055,7 +1055,45 @@ static int csi2_set_stream(struct v4l2_subdev
> > > > *sd, int enable) struct isp_video *video_out = &csi2->video_out;
> > > >
> > > > switch (enable) {
> > > >
> > > > - case ISP_PIPELINE_STREAM_CONTINUOUS:
> > > > + case ISP_PIPELINE_STREAM_CONTINUOUS: {
> > > > + struct media_pad *remote_pad =
> > > > + media_entity_remote_source(&sd->entity.pads[0]);
> > >
> > > As you will need to locate the sensor in ccdc_config_vp() as well, you
> > > should store a pointer to the sensor in the pipeline structure in
> > > isp_video_streamon(). I think I've sent you code that does just that,
> > > originally written by Stan if my memory is correct.
> >
> > Stan's patch assumed all external subdevs will be sensors. That may not be
> > true in all possible cases. That's not the fault of the patch, things have
> > changed after it has been written.
> >
> > I'd be suspicious calling the SMIA++ sensor's scaler subdev a sensor.
> > Definitely an external ISP will not be a sensor.
>
> Then just rename the field to something else than sensor :-) We need to access
> the external subdev in various places in the driver, instead of trying to
> locate it every time, it would be better to locate it once in
> isp_video_streamon (or one of the helper functions it calls) and store the
> pointer in the isp_pipeline structure.
My point was that Stan's patch located the subdev based on its type. We
can't rely on that. But yes, I'll store the information to isp_pipeline. I'm
not even sure the external subdev has to be there, just some information
related to it.
>
> > The check I'm doing is that if something's connected to either ccp2 or csi2
> > (and they're subdevs!) it's the external subdev we're interested in. Same
> > for ccdc if the entity is neither of the csi2 receivers or the ccp2
> > receiver.
> >
> > > > + struct v4l2_subdev *remote_subdev =
> > > > + media_entity_to_v4l2_subdev(remote_pad->entity);
> > > > + struct v4l2_subdev_format fmt;
> > > > + struct v4l2_ext_controls ctrls;
> > > > + struct v4l2_ext_control ctrl;
> > > > + int ret;
> > > > +
> > > > + fmt.pad = remote_pad->index;
> > > > + fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
> > > > + ret = v4l2_subdev_call(
> > > > + remote_subdev, pad, get_fmt, NULL, &fmt);
> > > > + if (ret < 0)
> > > > + return -EPIPE;
> > > > +
> > > > + memset(&ctrls, 0, sizeof(ctrls));
> > > > + memset(&ctrl, 0, sizeof(ctrl));
> > > > +
> > > > + ctrl.id = V4L2_CID_IMAGE_SOURCE_PIXEL_RATE;
> > > > +
> > > > + ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(ctrl.id);
> > > > + ctrls.count = 1;
> > > > + ctrls.controls = &ctrl;
> > > > +
> > > > + ret = v4l2_g_ext_ctrls(remote_subdev->ctrl_handler, &ctrls);
> > >
> > > Wouldn't v4l2_g_ctrl be easier ?
> >
> > Yes, but it's a 64-bit control so I must use extended controls.
>
> Right.
>
> > > An option to avoid duplicating this code in ccdc_config_vp() would be to
> > > move pixel rate retrieval to isp_video_streamon().
> >
> > It's gathered during link validation now.
> >
> > > > + if (ret < 0) {
> > > > + dev_warn(isp->dev,
> > > > + "no pixel rate control in subdev %s\n",
> > > > + remote_subdev->name);
> > > > + return -EPIPE;
> > > > + }
> > > > +
> > > > + ret = omap3isp_csiphy_config(
> > > > + isp, sd, remote_subdev, &fmt.format, ctrl.value64);
> > > > + if (ret < 0)
> > > > + return -EPIPE;
> > > > +
> > > >
> > > > if (omap3isp_csiphy_acquire(csi2->phy) < 0)
> > > >
> > > > return -ENODEV;
> > > >
> > > > csi2->use_fs_irq = pipe->do_propagation;
> > > >
> > > > @@ -1080,6 +1118,8 @@ static int csi2_set_stream(struct v4l2_subdev
> > > > *sd, int enable) isp_video_dmaqueue_flags_clr(video_out);
> > > >
> > > > break;
> > > >
> > > > + }
> > > > +
> > > >
> > > > case ISP_PIPELINE_STREAM_STOPPED:
> > > > if (csi2->state == ISP_PIPELINE_STREAM_STOPPED)
> > > >
> > > > return 0;
> > > >
> > > > diff --git a/drivers/media/video/omap3isp/ispcsiphy.c
> > > > b/drivers/media/video/omap3isp/ispcsiphy.c index 5be37ce..f286a01
> > > > 100644 --- a/drivers/media/video/omap3isp/ispcsiphy.c
> > > > +++ b/drivers/media/video/omap3isp/ispcsiphy.c
> > > > @@ -28,6 +28,8 @@
> > > >
> > > > #include <linux/device.h>
> > > > #include <linux/regulator/consumer.h>
> > > >
> > > > +#include "../../../../arch/arm/mach-omap2/control.h"
> > > > +
> > >
> > > Still no solution for this ?
> >
> > Not yet. I'll have to see the discussion again to say more on that. I think
> > we can find _something_ but it might not be more compatible with the device
> > tree than this.
>
> I proposed adding an exported function to arch/arm/mach-omap2/control.c to
> access the field, but there was no reply.
I remember that. I think it's a better solution but not ideal. We also must
provide the function on all platforms the OMAP 3 ISP driver is to be used,
i.e. OMAP 3s. On 3[45]xx it just wouldn't do anything.
> > > > #include "isp.h"
> > > > #include "ispreg.h"
> > > > #include "ispcsiphy.h"
> > > >
> > > > @@ -138,15 +140,79 @@ static void csiphy_dphy_config(struct isp_csiphy
> > > > *phy) isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
> > > >
> > > > }
> > > >
> > > > -static int csiphy_config(struct isp_csiphy *phy,
> > > > - struct isp_csiphy_dphy_cfg *dphy,
> > > > - struct isp_csiphy_lanes_cfg *lanes)
> > > > +/*
> > > > + * TCLK values are OK at their reset values
> > > > + */
> > > > +#define TCLK_TERM 0
> > > > +#define TCLK_MISS 1
> > > > +#define TCLK_SETTLE 14
> > > > +
> > > > +int omap3isp_csiphy_config(struct isp_device *isp,
> > > > + struct v4l2_subdev *csi2_subdev,
> > > > + struct v4l2_subdev *sensor,
> > > > + struct v4l2_mbus_framefmt *sensor_fmt,
> > > > + uint32_t pixel_rate)
> > > >
> > > > {
> > > >
> > > > + struct isp_v4l2_subdevs_group *subdevs = sensor->host_priv;
> > > > + struct isp_csi2_device *csi2 = v4l2_get_subdevdata(csi2_subdev);
> > > > + struct isp_csiphy_dphy_cfg csi2phy;
> > > > + int csi2_ddrclk_khz;
> > > > + struct isp_csiphy_lanes_cfg *lanes;
> > > >
> > > > unsigned int used_lanes = 0;
> > > > unsigned int i;
> > > >
> > > > + if (subdevs->interface == ISP_INTERFACE_CCP2B_PHY1
> > > > + || subdevs->interface == ISP_INTERFACE_CCP2B_PHY2)
> > > > + lanes = &subdevs->bus.ccp2.lanecfg;
> > > > + else
> > > > + lanes = &subdevs->bus.csi2.lanecfg;
> > > > +
> > > > + if (!lanes) {
> > >
> > > This can't happen.
> >
> > Fixed.
Cheers,
--
Sakari Ailus
e-mail: sakari.ailus@iki.fi jabber/XMPP/Gmail: sailus@retiisi.org.uk
next prev parent reply other threads:[~2012-01-19 19:11 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-11 21:26 [PATCH 0/23] V4L2 subdev and sensor control changes, SMIA++ driver and N9 camera board code Sakari Ailus
2012-01-11 21:26 ` [PATCH 01/23] v4l: Introduce integer menu controls Sakari Ailus
2012-01-16 13:49 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 02/23] v4l: Document " Sakari Ailus
2012-01-16 13:50 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 03/23] vivi: Add an integer menu test control Sakari Ailus
2012-01-16 13:52 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 04/23] v4l: VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_G_SELECTION IOCTLs Sakari Ailus
2012-01-11 21:26 ` [PATCH 05/23] v4l: Support s_crop and g_crop through s/g_selection Sakari Ailus
2012-01-16 13:54 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 06/23] v4l: Add selections documentation Sakari Ailus
2012-01-11 21:26 ` [PATCH 07/23] v4l: Mark VIDIOC_SUBDEV_G_CROP and VIDIOC_SUBDEV_S_CROP obsolete Sakari Ailus
2012-01-11 21:26 ` [PATCH 08/23] v4l: Image source control class Sakari Ailus
2012-01-16 13:57 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 09/23] v4l: Add DPCM compressed formats Sakari Ailus
2012-01-16 14:01 ` Laurent Pinchart
2012-01-17 19:35 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 10/23] omap3isp: Support additional in-memory compressed bayer formats Sakari Ailus
2012-01-16 14:05 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 11/23] omap3isp: Move definitions required by board code under include/media Sakari Ailus
2012-01-16 14:05 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 12/23] omap3: add definition for CONTROL_CAMERA_PHY_CTRL Sakari Ailus
2012-01-16 14:06 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 13/23] omap3isp: Add lane configuration to platform data Sakari Ailus
2012-01-16 14:08 ` Laurent Pinchart
2012-01-17 19:27 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 14/23] omap3isp: Configure CSI-2 phy based on " Sakari Ailus
2012-01-16 14:22 ` Laurent Pinchart
2012-01-17 19:45 ` Sakari Ailus
2012-01-19 16:16 ` Laurent Pinchart
2012-01-19 19:11 ` Sakari Ailus [this message]
2012-01-11 21:26 ` [PATCH 15/23] omap3isp: Do not attempt to walk the pipeline outside the ISP Sakari Ailus
2012-01-11 21:26 ` [PATCH 16/23] media: Add link_validate op to check links to the sink pad Sakari Ailus
2012-01-16 14:35 ` Laurent Pinchart
2012-01-17 20:09 ` Sakari Ailus
2012-01-19 16:20 ` Laurent Pinchart
2012-01-19 19:13 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 17/23] v4l: Implement v4l2_subdev_link_validate() Sakari Ailus
2012-01-16 14:44 ` Laurent Pinchart
2012-01-17 20:21 ` Sakari Ailus
2012-01-19 16:21 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 18/23] omap3isp: Assume media_entity_pipeline_start may fail Sakari Ailus
2012-01-16 14:46 ` Laurent Pinchart
2012-01-11 21:26 ` [PATCH 19/23] omap3isp: Default error handling for ccp2, csi2, preview and resizer Sakari Ailus
2012-01-16 14:50 ` Laurent Pinchart
2012-01-17 20:22 ` Sakari Ailus
2012-01-11 21:26 ` [PATCH 20/23] omap3isp: Move CCDC link validation to ispccdc.c Sakari Ailus
2012-01-11 21:26 ` [PATCH 21/23] omap3isp: Move resizer link validation to ispresizer.c Sakari Ailus
2012-01-11 21:26 ` [PATCH 22/23] smiapp: Add driver Sakari Ailus
2012-01-11 21:27 ` [PATCH 23/23] rm680: Add camera init Sakari Ailus
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=20120119191114.GH13236@valkosipuli.localdomain \
--to=sakari.ailus@iki.fi \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dacohen@gmail.com \
--cc=hverkuil@xs4all.nl \
--cc=k.debski@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=riverful@gmail.com \
--cc=snjw23@gmail.com \
--cc=t.stanislaws@samsung.com \
--cc=teturtia@gmail.com \
--cc=tuukkat76@gmail.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