From patchwork Sat Feb 16 22:57:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10816737 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31AC817E0 for ; Sat, 16 Feb 2019 22:58:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23A962A6B9 for ; Sat, 16 Feb 2019 22:58:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 155AD2ACFA; Sat, 16 Feb 2019 22:58:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5FD32ACEC for ; Sat, 16 Feb 2019 22:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727695AbfBPW6L (ORCPT ); Sat, 16 Feb 2019 17:58:11 -0500 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:56738 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727734AbfBPW6L (ORCPT ); Sat, 16 Feb 2019 17:58:11 -0500 X-Halon-ID: 4eab7ffa-323e-11e9-a58a-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 4eab7ffa-323e-11e9-a58a-005056917f90; Sat, 16 Feb 2019 23:58:07 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH] rcar-csi2: Allow configuring of video standard Date: Sat, 16 Feb 2019 23:57:58 +0100 Message-Id: <20190216225758.7699-1-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. 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 Nacked-by: Hans Verkuil --- 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, };