From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] rcar-csi2: Allow configuring of video standard
Date: Thu, 7 Mar 2019 02:26:45 +0200 [thread overview]
Message-ID: <20190307002645.GJ4791@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20190307002236.GJ9239@bigcity.dyn.berto.se>
Hi Niklas,
On Thu, Mar 07, 2019 at 01:22:36AM +0100, Niklas Söderlund wrote:
> On 2019-03-07 02:13:18 +0200, Laurent Pinchart wrote:
> > On Sat, Feb 16, 2019 at 11:57:58PM +0100, Niklas Söderlund wrote:
> >> Allow the hardware to to do proper field detection for interlaced field
> >> formats by implementing s_std() and g_std(). Depending on which video
> >> standard is selected the driver needs to setup the hardware to correctly
> >> identify fields.
> >
> > I don't think this belongs to the CSI-2 receiver. Standards are really
> > an analog concept, and should be handled by the analog front-end. At the
> > CSI-2 level there's no concept of analog standard anymore.
>
> I agree it should be handled by the analog front-end. This is patch just
> lets the user propagate the information in the pipeline. The driver
> could instead find its source subdevice in the media graph and ask which
> standard it's supplying.
>
> I wrestled a bit with this and went with this approach as it then works
> the same as with other format information, such as dimensions and pixel
> format. If the driver acquires the standard by itself why should it no
> the same for the format? I'm willing to change this but I would like to
> understand where the divider for format propagating in kernel and
> user-space is :-)
>
> Also what if there are subdevices between rcar-csi2 and the analog
> front-end which do not support the g_std operation?
My point is that the analog standard shouldn't be propagated at all,
neither inside the kernel nor in userspace, as it is not applicable to
CSI-2.
> >> Later versions of the datasheet have also been updated to make it clear
> >> that FLD register should be set to 0 when dealing with none interlaced
> >> field formats.
> >>
> >> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> >> ---
> >> drivers/media/platform/rcar-vin/rcar-csi2.c | 33 +++++++++++++++++++--
> >> 1 file changed, 30 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> >> index f3099f3e536d808a..664d3784be2b9db9 100644
> >> --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> >> +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> >> @@ -361,6 +361,7 @@ struct rcar_csi2 {
> >> struct v4l2_subdev *remote;
> >>
> >> struct v4l2_mbus_framefmt mf;
> >> + v4l2_std_id std;
> >>
> >> struct mutex lock;
> >> int stream_count;
> >> @@ -389,6 +390,22 @@ static void rcsi2_write(struct rcar_csi2 *priv, unsigned int reg, u32 data)
> >> iowrite32(data, priv->base + reg);
> >> }
> >>
> >> +static int rcsi2_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
> >> +{
> >> + struct rcar_csi2 *priv = sd_to_csi2(sd);
> >> +
> >> + priv->std = std;
> >> + return 0;
> >> +}
> >> +
> >> +static int rcsi2_g_std(struct v4l2_subdev *sd, v4l2_std_id *std)
> >> +{
> >> + struct rcar_csi2 *priv = sd_to_csi2(sd);
> >> +
> >> + *std = priv->std;
> >> + return 0;
> >> +}
> >> +
> >> static void rcsi2_standby_mode(struct rcar_csi2 *priv, int on)
> >> {
> >> if (!on) {
> >> @@ -475,7 +492,7 @@ static int rcsi2_calc_mbps(struct rcar_csi2 *priv, unsigned int bpp)
> >> static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> >> {
> >> const struct rcar_csi2_format *format;
> >> - u32 phycnt, vcdt = 0, vcdt2 = 0;
> >> + u32 phycnt, vcdt = 0, vcdt2 = 0, fld = 0;
> >> unsigned int i;
> >> int mbps, ret;
> >>
> >> @@ -507,6 +524,15 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> >> vcdt2 |= vcdt_part << ((i % 2) * 16);
> >> }
> >>
> >> + if (priv->mf.field != V4L2_FIELD_NONE) {
> >> + fld = FLD_FLD_EN4 | FLD_FLD_EN3 | FLD_FLD_EN2 | FLD_FLD_EN;
> >> +
> >> + if (priv->std & V4L2_STD_525_60)
> >> + fld |= FLD_FLD_NUM(2);
> >> + else
> >> + fld |= FLD_FLD_NUM(1);
> >> + }
> >> +
> >> phycnt = PHYCNT_ENABLECLK;
> >> phycnt |= (1 << priv->lanes) - 1;
> >>
> >> @@ -519,8 +545,7 @@ static int rcsi2_start_receiver(struct rcar_csi2 *priv)
> >> rcsi2_write(priv, PHTC_REG, 0);
> >>
> >> /* Configure */
> >> - rcsi2_write(priv, FLD_REG, FLD_FLD_NUM(2) | FLD_FLD_EN4 |
> >> - FLD_FLD_EN3 | FLD_FLD_EN2 | FLD_FLD_EN);
> >> + rcsi2_write(priv, FLD_REG, fld);
> >> rcsi2_write(priv, VCDT_REG, vcdt);
> >> if (vcdt2)
> >> rcsi2_write(priv, VCDT2_REG, vcdt2);
> >> @@ -662,6 +687,8 @@ static int rcsi2_get_pad_format(struct v4l2_subdev *sd,
> >> }
> >>
> >> static const struct v4l2_subdev_video_ops rcar_csi2_video_ops = {
> >> + .s_std = rcsi2_s_std,
> >> + .g_std = rcsi2_g_std,
> >> .s_stream = rcsi2_s_stream,
> >> };
> >>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2019-03-07 0:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-16 22:57 [PATCH] rcar-csi2: Allow configuring of video standard Niklas Söderlund
2019-02-17 8:47 ` Sergei Shtylyov
2019-03-07 0:11 ` Niklas Söderlund
2019-02-17 18:41 ` Jacopo Mondi
2019-03-07 0:10 ` Niklas Söderlund
2019-03-07 0:13 ` Laurent Pinchart
2019-03-07 0:22 ` Niklas Söderlund
2019-03-07 0:26 ` Laurent Pinchart [this message]
2019-03-07 0:38 ` Niklas Söderlund
2019-03-08 13:03 ` Laurent Pinchart
2019-03-08 14:12 ` Hans Verkuil
2019-03-08 16:11 ` Niklas Söderlund
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=20190307002645.GJ4791@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=niklas.soderlund@ragnatech.se \
/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