From patchwork Fri Dec 6 16:39:31 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: 11276817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBB76138C for ; Fri, 6 Dec 2019 16:40:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA0962464E for ; Fri, 6 Dec 2019 16:40:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbfLFQkV (ORCPT ); Fri, 6 Dec 2019 11:40:21 -0500 Received: from bin-mail-out-06.binero.net ([195.74.38.229]:10269 "EHLO bin-mail-out-06.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbfLFQkV (ORCPT ); Fri, 6 Dec 2019 11:40:21 -0500 X-Halon-ID: 055a7003-1847-11ea-8e92-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac5865.dip0.t-ipconnect.de [84.172.88.101]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 055a7003-1847-11ea-8e92-005056917f90; Fri, 06 Dec 2019 17:40:14 +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?= , Geert Uytterhoeven Subject: [PATCH v2 1/2] rcar-vin: Handle special pixel formats in a switch Date: Fri, 6 Dec 2019 17:39:31 +0100 Message-Id: <20191206163932.3295865-1-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Before extending the special pixel format handling turn the multiple if statements into a switch. Suggested-by: Geert Uytterhoeven Signed-off-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 9e2e63ffcc47acad..7f6c40f1f264515d 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -73,11 +73,18 @@ const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin, { int i; - if (vin->info->model == RCAR_M1 && pixelformat == V4L2_PIX_FMT_XBGR32) - return NULL; - - if (pixelformat == V4L2_PIX_FMT_NV12 && !vin->info->nv12) - return NULL; + switch (pixelformat) { + case V4L2_PIX_FMT_XBGR32: + if (vin->info->model == RCAR_M1) + return NULL; + break; + case V4L2_PIX_FMT_NV12: + if (!vin->info->nv12) + return NULL; + break; + default: + break; + } for (i = 0; i < ARRAY_SIZE(rvin_formats); i++) if (rvin_formats[i].fourcc == pixelformat) From patchwork Fri Dec 6 16:39:32 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: 11276823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D816D138C for ; Fri, 6 Dec 2019 16:40:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B72252464E for ; Fri, 6 Dec 2019 16:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726374AbfLFQkW (ORCPT ); Fri, 6 Dec 2019 11:40:22 -0500 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:10287 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbfLFQkV (ORCPT ); Fri, 6 Dec 2019 11:40:21 -0500 X-Halon-ID: 14b553ad-1847-11ea-8e92-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac5865.dip0.t-ipconnect.de [84.172.88.101]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 14b553ad-1847-11ea-8e92-005056917f90; Fri, 06 Dec 2019 17:40:16 +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 v2 2/2] rcar-vin: Limit NV12 availability to supported VIN channels only Date: Fri, 6 Dec 2019 17:39:32 +0100 Message-Id: <20191206163932.3295865-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206163932.3295865-1-niklas.soderlund+renesas@ragnatech.se> References: <20191206163932.3295865-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When adding support for NV12 it was overlooked that the pixel format is only supported on some VIN channels. Fix this by adding a check to only accept NV12 on the supported channels 0, 1, 4, 5, 8, 9, 12 and 13. Signed-off-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-v4l2.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 7f6c40f1f264515d..9f556d2bee593c73 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -79,7 +79,11 @@ const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin, return NULL; break; case V4L2_PIX_FMT_NV12: - if (!vin->info->nv12) + /* + * If NV12 is supported it's only supported on channels 0, 1, 4, + * 5, 8, 9, 12 and 13. + */ + if (!vin->info->nv12 || !(BIT(vin->id) & 0x3333)) return NULL; break; default: