From patchwork Wed Apr 19 07:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 13216457 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3BC2C77B73 for ; Wed, 19 Apr 2023 07:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jQrzjmElH0EGWMbgRSbPjTnB7TxMzdNtID8uJYCwgFg=; b=ILuKgXLuODJ3FK QVJM5jkIrTMcojybkD+GduWJlMuQB4KYxbd9Va1eo6hKDI05LGEGLopMVC4BFKn6aJeK0FYJmHjvn 1cuz2EfOkJBl1SyTfk03ddPIgXOnt+Yq1voawnIV8Gm0Y8MlRARR2q7xoo+aR1/rIR7T7GjdPPWzL 4+m9U5242ZSMkTqOxRYwkxmdUZsY1HtjH3aTyVnHByJvAHBmvAJT3pGjAVlP14vrfvndVdFtzTpHR 8xt/JQcf7wFCnVmMLHfJvD7uSJHO9ol1zti/I+pNZT2Z7JEmpugIWTuTLDsRkLyzC5/vf/4vhedVF vCEzeiskwpnzYE1h7G5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp1uc-004MFl-0u; Wed, 19 Apr 2023 07:07:30 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp1uV-004MBO-0L for linux-arm-kernel@lists.infradead.org; Wed, 19 Apr 2023 07:07:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1681888043; x=1713424043; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3o1/ma89daUDddWkyBxC7A/MJ6L/SjM7+gDduhH0vmE=; b=LAqZoVWrSdemJrQtannnm1tokvVotZoT5epUUPdmwd5NPltuQQrY1qGc jG3KQip3uUUgyqw08lT5oaVOzVmWDWgY+AOIk96or61jmc6M3pn9bT12D RbAd2ZQ4amcy5cLv1vDD8HoqL5Z3x4dzxmun7qwbjGhLE/HpNUBD9xq5K FcorC2BJ3pwah80U+OHJIjTcLNbiEOAG7XkN8GhLdTadYZlbpTj4eop00 FrvA8k+BGxTi/swluXCLfz0gk1U9cqVE6p7bHJfiG4RCCuLnbZ7gL4ank BLo9Ew283sH3gHGNt8iTPFQFik9Ts1cNrKR7XyT2BO8iepStQ5Athzzfe w==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415573" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Wed, 19 Apr 2023 09:07:16 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Wed, 19 Apr 2023 09:07:16 +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=1681888036; x=1713424036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3o1/ma89daUDddWkyBxC7A/MJ6L/SjM7+gDduhH0vmE=; b=FQUUPwQOskgTmR4wiVAfBrvhPPRuQENWDYswW+PueLgDw8Sqw8Xl21X7 o/DqeeKjVMxkGJwNm7FuDuUhxyTaTqWd/4QUMmHATxuVSm1VksdbfqRBf jVLxhUdyF7xuX/WL5QAOoOU4oS20OUvewQ9KXf8BLLpB2AMUADcdbUPau yZf2dlwmc5Bjd4x4ItmJ3Q75weoyoenfNssDSn90Am+h5PWtbJAnle2Ho /A2V2TFP7V2Ncx6iCyrls+C2nyt8bKFVN9z1mJcSyfrrb0Jnf3bfcEf1c A1qCSxqyOEUym/piZ1ODUyL7zGdWN05cirCrypUv7DbOkXJNCm+vzETkY w==; X-IronPort-AV: E=Sophos;i="5.99,208,1677538800"; d="scan'208";a="30415572" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 19 Apr 2023 09:07:16 +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 92760280056; Wed, 19 Apr 2023 09:07:16 +0200 (CEST) From: Alexander Stein To: Rui Miguel Silva , Laurent Pinchart , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Pengutronix Kernel Team , NXP Linux Team , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexander Stein Subject: [PATCH v4 4/4] media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt() Date: Wed, 19 Apr 2023 09:07:12 +0200 Message-Id: <20230419070712.1422335-5-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> References: <20230419070712.1422335-1-alexander.stein@ew.tq-group.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_000723_442170_136844B6 X-CRM114-Status: GOOD ( 17.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Laurent Pinchart 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 Signed-off-by: Alexander Stein --- Changes in v4: * None 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 e6abbfbc5c129..0bd2613b9320f 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 */ @@ -1603,22 +1570,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 = { }; - - 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; + struct v4l2_pix_format *pixfmt = &csi->vdev_fmt; - imx7_csi_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &format, NULL); - csi->vdev_compose.width = format.width; - csi->vdev_compose.height = format.height; + pixfmt->width = IMX7_CSI_DEF_PIX_WIDTH; + pixfmt->height = IMX7_CSI_DEF_PIX_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) @@ -1631,9 +1590,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);