From patchwork Tue Apr 18 10:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 674917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 333EEC77B71 for ; Tue, 18 Apr 2023 10:04:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbjDRKEL (ORCPT ); Tue, 18 Apr 2023 06:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjDRKEK (ORCPT ); Tue, 18 Apr 2023 06:04:10 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E95546B8 for ; Tue, 18 Apr 2023 03:04:08 -0700 (PDT) Received: from pendragon.ideasonboard.com (133-32-181-51.west.xps.vectant.ne.jp [133.32.181.51]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4895EF07; Tue, 18 Apr 2023 12:03:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1681812240; bh=10Ei9nqKwkA5fMOTYYArhMOWhmSN1lqc3pFQPXZlkdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pFJbZUvpZT1D9OZph+BhxCv1j8C8xzR7iW7bdcPsrhBJbkoUt72tr+TZ6NFgUrMVF cuNNB/NlxF7I6pG45mvROm9upuCLH52sXp9hPWBU2EZe54HLdpin19lH/xSNz2Q2Jm c1QnR8Apdf2AvWeu7rkbAsuYPxbcnYGQJZpaUk1U= From: Laurent Pinchart To: linux-media@vger.kernel.org, Alexander Stein Cc: Rui Miguel Silva , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam , Pengutronix Kernel Team , NXP Linux Team , linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt() Date: Tue, 18 Apr 2023 13:04:17 +0300 Message-Id: <20230418100417.20428-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> References: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use the __imx7_csi_video_try_fmt() helper function to initialize the default format at probe time. This improves consistency by using the same code path for both default initialization and validation at runtime, and allows dropping the now unused imx7_csi_find_pixel_format() function. Signed-off-by: Laurent Pinchart --- Hi Alexander, This is an additional cleanup that applies on top of "[PATCH v2 0/3] Fix imx7-media-csi format settings". I've only compile-tested it as I'm currently lacking access to test hardware. Would you be able to test the patch ? If so, could you please include it in the v2 of your series ? --- drivers/media/platform/nxp/imx7-media-csi.c | 55 +++------------------ 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 5240670476b2..e52d617eea59 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1014,39 +1014,6 @@ static int imx7_csi_enum_mbus_formats(u32 *code, u32 index) return -EINVAL; } -static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, - const struct v4l2_mbus_framefmt *mbus, - const struct imx7_csi_pixfmt *cc) -{ - u32 width; - u32 stride; - - if (!cc) { - cc = imx7_csi_find_mbus_format(mbus->code); - if (!cc) - return -EINVAL; - } - - /* Round up width for minimum burst size */ - width = round_up(mbus->width, 8); - - /* Round up stride for IDMAC line start address alignment */ - stride = round_up((width * cc->bpp) >> 3, 8); - - pix->width = width; - pix->height = mbus->height; - pix->pixelformat = cc->fourcc; - pix->colorspace = mbus->colorspace; - pix->xfer_func = mbus->xfer_func; - pix->ycbcr_enc = mbus->ycbcr_enc; - pix->quantization = mbus->quantization; - pix->field = mbus->field; - pix->bytesperline = stride; - pix->sizeimage = stride * pix->height; - - return 0; -} - /* ----------------------------------------------------------------------------- * Video Capture Device - IOCTLs */ @@ -1618,22 +1585,14 @@ static struct imx7_csi_vb2_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi) return buf; } -static int imx7_csi_video_init_format(struct imx7_csi *csi) +static void imx7_csi_video_init_format(struct imx7_csi *csi) { - struct v4l2_mbus_framefmt format = { }; + struct v4l2_pix_format *pixfmt = &csi->vdev_fmt; - format.code = IMX7_CSI_DEF_MBUS_CODE; - format.width = IMX7_CSI_DEF_PIX_WIDTH; - format.height = IMX7_CSI_DEF_PIX_HEIGHT; - format.field = V4L2_FIELD_NONE; + pixfmt->width = IMX7_CSI_DEF_PIX_WIDTH; + pixfmt->height = IMX7_CSI_DEF_PIX_HEIGHT; - imx7_csi_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &format, NULL); - csi->vdev_compose.width = format.width; - csi->vdev_compose.height = format.height; - - csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat); - - return 0; + csi->vdev_cc = __imx7_csi_video_try_fmt(pixfmt, &csi->vdev_compose); } static int imx7_csi_video_register(struct imx7_csi *csi) @@ -1646,9 +1605,7 @@ static int imx7_csi_video_register(struct imx7_csi *csi) vdev->v4l2_dev = v4l2_dev; /* Initialize the default format and compose rectangle. */ - ret = imx7_csi_video_init_format(csi); - if (ret < 0) - return ret; + imx7_csi_video_init_format(csi); /* Register the video device. */ ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); From patchwork Tue Apr 18 07:14:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 675501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACD37C77B76 for ; Tue, 18 Apr 2023 07:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbjDRHO4 (ORCPT ); Tue, 18 Apr 2023 03:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbjDRHOy (ORCPT ); Tue, 18 Apr 2023 03:14:54 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7ED826AC for ; Tue, 18 Apr 2023 00:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681802092; x=1713338092; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2EYb/WP0dlj6VHt6K2PVtPnez7y5ZDVOsDqBPCYyofs=; b=YLdzbB1+Mo8mz0C+FQBnHRDk9pC47nAOTIOa9vb5rqsGbt1FTE7cu/Pz Tr6JifGamO7vPSeIdPA5jayo0ZHEKrfdCwnyrmqJoaZ+wik6vSRjcfzPk WZO83CznwLZ12T8h1sCLShtYVwK4VaFZ9rnyeQMUYNDYZnQcBBeQaDdwK RzbfkgO189Z3iAMJf4XalvSaLdm27Z5xCEO/NY8a9ltpLtGlDjSD0xGC/ 5hl5o0j2Fl7rcQ/ekH/OomGLkzWq14b7Se4PLfX+oa6EVNNA7G6mabJ+V rSDTNMOElGXU3ABRFkbgLWga2sEnBpKkxdR5xBbpKN4Fwaz95o16+zyuU Q==; X-IronPort-AV: E=Sophos;i="5.99,206,1677538800"; d="scan'208";a="30385556" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 18 Apr 2023 09:14:47 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Tue, 18 Apr 2023 09:14:47 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 18 Apr 2023 09:14:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681802087; x=1713338087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2EYb/WP0dlj6VHt6K2PVtPnez7y5ZDVOsDqBPCYyofs=; b=bTA0rAlLgYMqtpqCACot7AYTUVAHnMw0sSFLlA0acHgrIPguaZV1TJeU tNVhdKUPDQsJyr4X9Yuc60l9DVluLmZFXNkhZE12aTZu2hy9s0E+T/3AW jMNqHkgfAJ2xC+jjyyuYGCQAU7Iw60d3JZX4OP+UGz3FdBtcIzOZD9rcc jQ6W34tjSe2nO4QA7iCXVo7rRBccbNWes1hd0uoJ0uABvEFfU3EAB+P9o g/5sBUGyb1iKTREcTWwyjTzMMkfJfx/bSYfPz565tu0vKqZhC+YfpNb5V SuK9pPjaz2/aDgBakaup2ltFO4po97MyMIn6rx+5+xe99wyk/Op2Mi2Aq A==; X-IronPort-AV: E=Sophos;i="5.99,206,1677538800"; d="scan'208";a="30385555" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 18 Apr 2023 09:14:47 +0200 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id C809E280073; Tue, 18 Apr 2023 09:14:46 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Alexander Stein , Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/3] media: imx: imx7-media-csi: Remove interlave fields Date: Tue, 18 Apr 2023 09:14:38 +0200 Message-Id: <20230418071439.197735-3-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> References: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Interlaced mode is currently not supported, so disable fields in try_fmt. Signed-off-by: Alexander Stein --- drivers/media/platform/nxp/imx7-media-csi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index bd649fd9166fd..1508f6ba20e91 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1178,6 +1178,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, stride = round_up((pixfmt->width * cc->bpp) / 8, 8); pixfmt->bytesperline = stride; pixfmt->sizeimage = stride * pixfmt->height; + pixfmt->field = V4L2_FIELD_NONE; if (compose) { compose->width = pixfmt->width; From patchwork Tue Apr 18 07:14:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 674930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4453C77B71 for ; Tue, 18 Apr 2023 07:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbjDRHO6 (ORCPT ); Tue, 18 Apr 2023 03:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231249AbjDRHOy (ORCPT ); Tue, 18 Apr 2023 03:14:54 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 075C7273C for ; Tue, 18 Apr 2023 00:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681802093; x=1713338093; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=edaL6dP8udaoBENjAOXy9u4eKuGvdt1NYMIa3nDzb9Q=; b=p2FK9wFpG8SKNbgvp8SN4VZZii0haBfP+9g6Ahlg5JA4emgDzzCsNnuS E4Bfy/r9/RO0BXIGtw3WdkDwYh5qEhiglKwu93s8L81mrf4+CE2UXu5IP NaJR/W8auwvh9ULqs4zMx0vB18k/fE8It6hZprAu8VtdX7Kmn5FGQusCE 1n3QFc9YzUU9AJEc9sDWNqDDoeC3kqLKikBWbCQ/n+QCVkS1yRjkrR1yg v6xB8zYYYVWdkAwYPdCZtkLVmNQH/IG+F810OGr5i3aTVjuczQszQXrWs zWqKKdTzZVYIsBLlj+bScz1FyufhvgEfNArK2YucDzPdSwDoRR1fzljqg w==; X-IronPort-AV: E=Sophos;i="5.99,206,1677538800"; d="scan'208";a="30385558" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 18 Apr 2023 09:14:47 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Tue, 18 Apr 2023 09:14:47 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 18 Apr 2023 09:14:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681802087; x=1713338087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=edaL6dP8udaoBENjAOXy9u4eKuGvdt1NYMIa3nDzb9Q=; b=l6XcpwZaYyDwzkEE71WvcRI6G29deS/DKUHq/w9v/4PLC8FwLMaNpj6y ya3d22G7+Vz+hygEA0jnztKByExWgLjkT1lL+6KwEkIF0iQPsWCGQ2gFA /ZW8ZpJTZkc0guHvVOXU8ggY1TsJDFicHvvXdwEVm/AztIyBK+03Fdujt ubJ2Kgq9oHXHuTNVGAjn+GXKQXQXaI35yED9Y8TUI4dOwUgUlujNt4ep3 6KVT1Zj9361oL1otLRUUwxH3bpbWe0Bn+MAIpKgIfsLBbWsc9QtQoS7SK veylED7rPUFR4kfJKs2uIcVHUdkEiSjf+k6Qi1X0xSgqxwL7zk9MwOvXv Q==; X-IronPort-AV: E=Sophos;i="5.99,206,1677538800"; d="scan'208";a="30385557" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 18 Apr 2023 09:14:47 +0200 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 3AA40280074; Tue, 18 Apr 2023 09:14:47 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Alexander Stein , Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/3] media: imx: imx7-media-csi: Lift width constraints for 8bpp formats Date: Tue, 18 Apr 2023 09:14:39 +0200 Message-Id: <20230418071439.197735-4-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> References: <20230418071439.197735-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For 8-bit formats the image_width just needs to be a multiple of 4 pixels. Signed-off-by: Alexander Stein --- drivers/media/platform/nxp/imx7-media-csi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c index 1508f6ba20e91..5240670476b2b 100644 --- a/drivers/media/platform/nxp/imx7-media-csi.c +++ b/drivers/media/platform/nxp/imx7-media-csi.c @@ -1147,6 +1147,7 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, { const struct imx7_csi_pixfmt *cc; u32 stride; + u32 walign; /* * Find the pixel format, default to the first supported format if not @@ -1172,7 +1173,13 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, } } - v4l_bound_align_image(&pixfmt->width, 1, 0xffff, 8, + /* Refer to CSI_IMAG_PARA.IMAGE_WIDTH description */ + if (cc->bpp == 8) + walign = 8; + else + walign = 4; + + v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign, &pixfmt->height, 1, 0xffff, 1, 0); stride = round_up((pixfmt->width * cc->bpp) / 8, 8);