From patchwork Tue Jul 19 14:20:54 2016 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: 9237617 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BA5D607DA for ; Tue, 19 Jul 2016 14:24:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D3A927165 for ; Tue, 19 Jul 2016 14:24:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 119892793B; Tue, 19 Jul 2016 14:24:06 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 8C98227165 for ; Tue, 19 Jul 2016 14:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754096AbcGSOXw (ORCPT ); Tue, 19 Jul 2016 10:23:52 -0400 Received: from smtp-4.sys.kth.se ([130.237.48.193]:56012 "EHLO smtp-4.sys.kth.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753630AbcGSOXK (ORCPT ); Tue, 19 Jul 2016 10:23:10 -0400 Received: from smtp-4.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-4.sys.kth.se (Postfix) with ESMTP id 9C75C1E97; Tue, 19 Jul 2016 16:23:08 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-4.sys.kth.se ([127.0.0.1]) by smtp-4.sys.kth.se (smtp-4.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id DKQTbm74JxtJ; Tue, 19 Jul 2016 16:23:07 +0200 (CEST) X-KTH-Auth: niso [89.233.230.99] X-KTH-mail-from: niklas.soderlund+renesas@ragnatech.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by smtp-4.sys.kth.se (Postfix) with ESMTPSA id 3380B2431; Tue, 19 Jul 2016 16:23:07 +0200 (CEST) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: linux-media@vger.kernel.org, ulrich.hecht@gmail.com, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com Cc: linux-renesas-soc@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCHv2 03/16] [media] rcar-vin: add legacy mode for wrong media bus formats Date: Tue, 19 Jul 2016 16:20:54 +0200 Message-Id: <20160719142107.22358-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160719142107.22358-1-niklas.soderlund+renesas@ragnatech.se> References: <20160719142107.22358-1-niklas.soderlund+renesas@ragnatech.se> 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 A recent bugfix to adv7180 brought to light that the rcar-vin driver are looking for the wrong media bus format. It was looking for a YUVU format but then expecting UYVY data. The bugfix for adv7180 will break the usage of rcar-vin together with a adv7180 as found on Renesas R-Car2 Koelsch boards for example. This patch fix the rcar-vin driver to look for the correct UYVU formats and adds a legacy mode. The legacy mode is needed since I don't know if other devices provide a incorrect media bus format and I don't want to break any working configurations. Hopefully the legacy mode can be removed sometime in the future. Signed-off-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-core.c | 39 +++++++++++++++++++++++++++-- drivers/media/platform/rcar-vin/rcar-dma.c | 4 +-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index 4b2007b..481d82a 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -37,6 +37,7 @@ static int rvin_mbus_supported(struct rvin_dev *vin) struct v4l2_subdev_mbus_code_enum code = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; + bool found; sd = vin_to_source(vin); @@ -45,8 +46,8 @@ static int rvin_mbus_supported(struct rvin_dev *vin) code.index++; switch (code.code) { case MEDIA_BUS_FMT_YUYV8_1X16: - case MEDIA_BUS_FMT_YUYV8_2X8: - case MEDIA_BUS_FMT_YUYV10_2X10: + case MEDIA_BUS_FMT_UYVY8_2X8: + case MEDIA_BUS_FMT_UYVY10_2X10: case MEDIA_BUS_FMT_RGB888_1X24: vin->source.code = code.code; vin_dbg(vin, "Found supported media bus format: %d\n", @@ -57,6 +58,40 @@ static int rvin_mbus_supported(struct rvin_dev *vin) } } + /* + * Older versions where looking for the wrong media bus format. + * It where looking for a YUVY format but then treated it as a + * UYVY format. This was not noticed since atlest one subdevice + * used for testing (adv7180) reported a YUVY media bus format + * but provided UYVY data. There might be other unknown subdevices + * which also do this, to not break compatibility try to use them + * in legacy mode. + */ + found = false; + code.index = 0; + while (!v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, &code)) { + code.index++; + switch (code.code) { + case MEDIA_BUS_FMT_YUYV8_2X8: + vin->source.code = MEDIA_BUS_FMT_UYVY8_2X8; + found = true; + break; + case MEDIA_BUS_FMT_YUYV10_2X10: + vin->source.code = MEDIA_BUS_FMT_UYVY10_2X10; + found = true; + break; + default: + break; + } + + if (found) { + vin_err(vin, + "media bus %d not supported, trying legacy mode %d\n", + code.code, vin->source.code); + return true; + } + } + return false; } diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index dad3b03..0836b15 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -169,7 +169,7 @@ static int rvin_setup(struct rvin_dev *vin) vnmc |= VNMC_INF_YUV16; input_is_yuv = true; break; - case MEDIA_BUS_FMT_YUYV8_2X8: + case MEDIA_BUS_FMT_UYVY8_2X8: /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */ vnmc |= vin->mbus_cfg.type == V4L2_MBUS_BT656 ? VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601; @@ -178,7 +178,7 @@ static int rvin_setup(struct rvin_dev *vin) case MEDIA_BUS_FMT_RGB888_1X24: vnmc |= VNMC_INF_RGB888; break; - case MEDIA_BUS_FMT_YUYV10_2X10: + case MEDIA_BUS_FMT_UYVY10_2X10: /* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */ vnmc |= vin->mbus_cfg.type == V4L2_MBUS_BT656 ? VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;