From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7858E2C9E for ; Fri, 28 Jan 2022 10:57:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB35FC340E0; Fri, 28 Jan 2022 10:57:01 +0000 (UTC) Message-ID: <3f5a10aa-fda8-ea3d-9ca2-eba77c720338@xs4all.nl> Date: Fri, 28 Jan 2022 11:57:00 +0100 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8 Content-Language: en-US To: Dorota Czaplejewicz , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@puri.sm, phone-devel@vger.kernel.org References: <20211019120047.827915-1-dorota.czaplejewicz@puri.sm> <20211019120047.827915-4-dorota.czaplejewicz@puri.sm> From: Hans Verkuil In-Reply-To: <20211019120047.827915-4-dorota.czaplejewicz@puri.sm> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Dorota, Since I marked "media: Add 16-bit Bayer formats" as 'Changes Requested', and since this patch appears to depend on that patch based on a comment in the first patch, I decided to mark this series as 'Changes Requested' (except for patch 1 which has already been accepted). Please post a v4 if you want this in, and add the "media: Add 16-bit Bayer formats" patch as well to that v4 series. Thanks! Hans On 19/10/2021 14:14, Dorota Czaplejewicz wrote: > This splits out a format handler which takes into account > the capabilities of the i.MX7/8 video device, > as opposed to the default handler compatible with both i.MX5/6 and i.MX7/8. > > Signed-off-by: Dorota Czaplejewicz > --- > drivers/staging/media/imx/imx-media-utils.c | 56 +++++++++++++++++++-- > 1 file changed, 52 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c > index 8b5c6bcfd4fa..1ff7ec4c877a 100644 > --- a/drivers/staging/media/imx/imx-media-utils.c > +++ b/drivers/staging/media/imx/imx-media-utils.c > @@ -516,10 +516,9 @@ void imx_media_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt, > } > EXPORT_SYMBOL_GPL(imx_media_try_colorimetry); > > -int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > - const struct v4l2_mbus_framefmt *mbus, > - const struct imx_media_pixfmt *cc, > - enum imx_media_device_type type) > +static int imx56_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > + const struct v4l2_mbus_framefmt *mbus, > + const struct imx_media_pixfmt *cc) > { > u32 width; > u32 stride; > @@ -568,6 +567,55 @@ int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > > return 0; > } > + > +static int imx78_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > + const struct v4l2_mbus_framefmt *mbus, > + const struct imx_media_pixfmt *cc) > +{ > + int ret; > + > + if (!cc) > + cc = imx_media_find_mbus_format(mbus->code, PIXFMT_SEL_ANY); > + > + /* > + * The hardware can handle line lengths divisible by 4 pixels > + * as long as the whole buffer size ends up divisible by 8 bytes. > + * If not, use the value of 8 pixels recommended in the datasheet. > + */ > + ret = v4l2_fill_pixfmt(pix, cc->fourcc, > + round_up(mbus->width, 4), mbus->height); > + if (ret) > + return ret; > + > + /* Only 8bits-per-pixel formats may need to get aligned to 8 pixels, > + * because both 10-bit and 16-bit pixels occupy 2 bytes. > + * In those, 4-pixel aligmnent is equal to 8-byte alignment. > + */ > + if (pix->sizeimage % 8 != 0) > + ret = v4l2_fill_pixfmt(pix, cc->fourcc, > + round_up(mbus->width, 8), mbus->height); > + > + pix->colorspace = mbus->colorspace; > + pix->xfer_func = mbus->xfer_func; > + pix->ycbcr_enc = mbus->ycbcr_enc; > + pix->quantization = mbus->quantization; > + pix->field = mbus->field; > + > + return ret; > +} > + > +int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > + const struct v4l2_mbus_framefmt *mbus, > + const struct imx_media_pixfmt *cc, > + enum imx_media_device_type type) { > + switch (type) { > + case DEVICE_TYPE_IMX56: > + return imx56_media_mbus_fmt_to_pix_fmt(pix, mbus, cc); > + case DEVICE_TYPE_IMX78: > + return imx78_media_mbus_fmt_to_pix_fmt(pix, mbus, cc); > + } > + return -EINVAL; > +} > EXPORT_SYMBOL_GPL(imx_media_mbus_fmt_to_pix_fmt); > > void imx_media_free_dma_buf(struct device *dev, From mboxrd@z Thu Jan 1 00:00:00 1970 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 3E251C4332F for ; Fri, 28 Jan 2022 10:58:26 +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:In-Reply-To:From:References:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oCVHT626iYAyr/MBHsf5fbwXxo+rc2AGTr/p+sjMzfk=; b=COVaeedKE+lih5 cbl3hZWFBSB8qMLTk1RkxzT3r7Z0cLZNWC+rptZNDq4z25vja+3QirtpxhgXANoOr/nYzui/z4V9d UMyRNCTMAVKgFllW+oBmL5RSylXXdG/4zUDW3bTCI3IXmX3sUKtleaGWXGLVOlQryAOB3HC/zBhII 4OK9AUs8pH53n8hZ8vbARms7E8nEyfnwVkriCPYcdIg5vuf2lv3OCvAmCtK8pyVAqRQnzfkPTujFZ syoRfEynHjNyuVw37/ihgQO+JLyDqIh4e/GMxbAb8NrgUMmqxx1/GGka61Djb/Bx3jNuq+Z5cxxS+ 4bRA4PYAKWhkQ1/asyYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDOwI-001Z9Y-MP; Fri, 28 Jan 2022 10:57:10 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDOwE-001Z7s-KU for linux-arm-kernel@lists.infradead.org; Fri, 28 Jan 2022 10:57:08 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5466DB81D4E; Fri, 28 Jan 2022 10:57:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB35FC340E0; Fri, 28 Jan 2022 10:57:01 +0000 (UTC) Message-ID: <3f5a10aa-fda8-ea3d-9ca2-eba77c720338@xs4all.nl> Date: Fri, 28 Jan 2022 11:57:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCHv3 4/4] media: imx: Use dedicated format handler for i.MX7/8 Content-Language: en-US To: Dorota Czaplejewicz , Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@puri.sm, phone-devel@vger.kernel.org References: <20211019120047.827915-1-dorota.czaplejewicz@puri.sm> <20211019120047.827915-4-dorota.czaplejewicz@puri.sm> From: Hans Verkuil In-Reply-To: <20211019120047.827915-4-dorota.czaplejewicz@puri.sm> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220128_025706_978924_7E9B0C87 X-CRM114-Status: GOOD ( 24.41 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Dorota, Since I marked "media: Add 16-bit Bayer formats" as 'Changes Requested', and since this patch appears to depend on that patch based on a comment in the first patch, I decided to mark this series as 'Changes Requested' (except for patch 1 which has already been accepted). Please post a v4 if you want this in, and add the "media: Add 16-bit Bayer formats" patch as well to that v4 series. Thanks! Hans On 19/10/2021 14:14, Dorota Czaplejewicz wrote: > This splits out a format handler which takes into account > the capabilities of the i.MX7/8 video device, > as opposed to the default handler compatible with both i.MX5/6 and i.MX7/8. > > Signed-off-by: Dorota Czaplejewicz > --- > drivers/staging/media/imx/imx-media-utils.c | 56 +++++++++++++++++++-- > 1 file changed, 52 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c > index 8b5c6bcfd4fa..1ff7ec4c877a 100644 > --- a/drivers/staging/media/imx/imx-media-utils.c > +++ b/drivers/staging/media/imx/imx-media-utils.c > @@ -516,10 +516,9 @@ void imx_media_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt, > } > EXPORT_SYMBOL_GPL(imx_media_try_colorimetry); > > -int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > - const struct v4l2_mbus_framefmt *mbus, > - const struct imx_media_pixfmt *cc, > - enum imx_media_device_type type) > +static int imx56_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > + const struct v4l2_mbus_framefmt *mbus, > + const struct imx_media_pixfmt *cc) > { > u32 width; > u32 stride; > @@ -568,6 +567,55 @@ int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > > return 0; > } > + > +static int imx78_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > + const struct v4l2_mbus_framefmt *mbus, > + const struct imx_media_pixfmt *cc) > +{ > + int ret; > + > + if (!cc) > + cc = imx_media_find_mbus_format(mbus->code, PIXFMT_SEL_ANY); > + > + /* > + * The hardware can handle line lengths divisible by 4 pixels > + * as long as the whole buffer size ends up divisible by 8 bytes. > + * If not, use the value of 8 pixels recommended in the datasheet. > + */ > + ret = v4l2_fill_pixfmt(pix, cc->fourcc, > + round_up(mbus->width, 4), mbus->height); > + if (ret) > + return ret; > + > + /* Only 8bits-per-pixel formats may need to get aligned to 8 pixels, > + * because both 10-bit and 16-bit pixels occupy 2 bytes. > + * In those, 4-pixel aligmnent is equal to 8-byte alignment. > + */ > + if (pix->sizeimage % 8 != 0) > + ret = v4l2_fill_pixfmt(pix, cc->fourcc, > + round_up(mbus->width, 8), mbus->height); > + > + pix->colorspace = mbus->colorspace; > + pix->xfer_func = mbus->xfer_func; > + pix->ycbcr_enc = mbus->ycbcr_enc; > + pix->quantization = mbus->quantization; > + pix->field = mbus->field; > + > + return ret; > +} > + > +int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, > + const struct v4l2_mbus_framefmt *mbus, > + const struct imx_media_pixfmt *cc, > + enum imx_media_device_type type) { > + switch (type) { > + case DEVICE_TYPE_IMX56: > + return imx56_media_mbus_fmt_to_pix_fmt(pix, mbus, cc); > + case DEVICE_TYPE_IMX78: > + return imx78_media_mbus_fmt_to_pix_fmt(pix, mbus, cc); > + } > + return -EINVAL; > +} > EXPORT_SYMBOL_GPL(imx_media_mbus_fmt_to_pix_fmt); > > void imx_media_free_dma_buf(struct device *dev, _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel