From patchwork Fri Mar 24 15:12:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 667130 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 3211FC6FD1C for ; Fri, 24 Mar 2023 15:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232414AbjCXPNH (ORCPT ); Fri, 24 Mar 2023 11:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232420AbjCXPM7 (ORCPT ); Fri, 24 Mar 2023 11:12:59 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21CDF13DD4; Fri, 24 Mar 2023 08:12:43 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id C74B1E000D; Fri, 24 Mar 2023 15:12:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nuHXzKpXc+QOxViVd32U4/MzFVTvFJW4e0KVbYx+BXQ=; b=Ul4YiBEwyLYjwroEHTKgggS3IAzkyElWryfnXFblmDiSdMgD57U7KiJHzPXJ8KluNgIHF+ ldduUcpDiwMZOkoBcRPpGLvQaBEqAop/ciNNzqeQeW4K9Bh12h9VXmc/I8/EnT7jhIDnn2 j3ytX7hq8xIAdhTtKS0BuFmzvTxiutXxmnkvylNS+0U0sVzZ9jc/hHGPqygaWmhUlxhbrP HL6kLOcVcMw4TSdF/yZ6yrKrQ92KAFPiueGWk6LaA/CSyToaNUjVbGxSQewKyQ3hl/OIhP ilSOUKE35vScni/l1gzPzM+sYYA59GthtCi/UQ/l0BycUmFdAD+oTvJylE6CAA== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 1/9] media: v4l2: Add RGB565X pixel format to v4l2 format info Date: Fri, 24 Mar 2023 16:12:20 +0100 Message-Id: <20230324151228.2778112-2-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Represent the RGB565X pixel format in the v4l2 format info table. This is a big-endian variant of the already present RGB565 format, which has the same characteristics. Signed-off-by: Paul Kocialkowski Reviewed-by: Laurent Pinchart --- drivers/media/v4l2-core/v4l2-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 40f56e044640..3d044b31caad 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -250,6 +250,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_ABGR32, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_BGRA32, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_RGB565, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, + { .format = V4L2_PIX_FMT_RGB565X, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_RGB555, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_BGR666, .pixel_enc = V4L2_PIXEL_ENC_RGB, .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, From patchwork Fri Mar 24 15:12:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 666785 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 DCDD8C76196 for ; Fri, 24 Mar 2023 15:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231906AbjCXPNI (ORCPT ); Fri, 24 Mar 2023 11:13:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232425AbjCXPNA (ORCPT ); Fri, 24 Mar 2023 11:13:00 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A91E1ABD6; Fri, 24 Mar 2023 08:12:45 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 9488EE0004; Fri, 24 Mar 2023 15:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AKMjsmVuGQnB8YMrE/mZMGkPMHIYStzAUAeMUrSpOig=; b=jzaazBv+z6bdh0gBL92QPHmZc0eELjmoGevdGLM7N6FfRiB2GYonK0XKPF/vtEi6PgHWBu UZUITF62qUdyB0fwVDZXvGA+h4HzZGy0j4DngD5CPwXNeBeG29t7vsiHDQ6HvuKc8+1At0 AO/AkbWLYf5xiHuGBw8QBgIvYGLILygVZDoRJn0MWMeBUrtpXceaGA+VzrueZYE+VSiKSS WLB68dEMLfBkefeOQ2IHHBNtgcsOExgTSICYKdq5rsBu27z/CdyCejOlcEusQUK9HVO9p2 eiDmvmUlU0xCm/DfuukMydXjoMxLMSjwWOe8VXDm0PqSrlbbvkHOZVjxvKx3Ng== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 2/9] media: v4l2: Add NV12_16L16 pixel format to v4l2 format info Date: Fri, 24 Mar 2023 16:12:21 +0100 Message-Id: <20230324151228.2778112-3-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Represent the NV12_16L16 pixel format in the v4l2 format info table. This is a 16x16 tiled version of NV12. Signed-off-by: Paul Kocialkowski Reviewed-by: Jernej Skrabec --- drivers/media/v4l2-core/v4l2-common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 3d044b31caad..5101989716aa 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -280,6 +280,8 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) /* Tiled YUV formats */ { .format = V4L2_PIX_FMT_NV12_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2 }, { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .hdiv = 2, .vdiv = 2 }, + { .format = V4L2_PIX_FMT_NV12_16L16, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 2, + .block_w = { 16, 16, 0, 0 }, .block_h = { 16, 16, 0, 0 } }, /* YUV planar formats, non contiguous variant */ { .format = V4L2_PIX_FMT_YUV420M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 3, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 2, .vdiv = 2 }, From patchwork Fri Mar 24 15:12:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 667129 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 C9049C761AF for ; Fri, 24 Mar 2023 15:13:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232424AbjCXPNK (ORCPT ); Fri, 24 Mar 2023 11:13:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbjCXPND (ORCPT ); Fri, 24 Mar 2023 11:13:03 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 914B41D92D; Fri, 24 Mar 2023 08:12:46 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 19EA7E0015; Fri, 24 Mar 2023 15:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8gIn39Y6zA0CFaVJ6us4+7VwM4cTlinJOP/M7fEZG7Y=; b=TX4hxQ9RP7XPd8vlAYXjTa8wCMrPziKlOupK2OrOzG5+o3vFMT+sIk3bH+cgHZGrioCslu cUSVKOFWdsQFwRsIBvf6lZNNVLfIlwljTuINbonSNl8WMSzdwFKhB3uBIsbInMZAyBx5rK BibBAi5OW3OuvgvSV4yo9PqsdTEe3PrwAZG8Y75zRgQT05IUfRj8CFOEy/d+B+aXplhooC zPehihj1vvb9fIIcfkwlSR9fC1Tn1r3/HUawg99RgKEYNV93ZL/B6KdK0pMrgNYEOLLOW9 IFT9bttX58/dwOtb3iZz21JbY+hAvBgFkAaprkVe01g0n2YuotYU/YLywPdyTA== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 3/9] media: v4l2: Introduce compressed pixel encoding definition and helper Date: Fri, 24 Mar 2023 16:12:22 +0100 Message-Id: <20230324151228.2778112-4-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Some pixel formats (such as JPEG) have their data compressed and encoded in a specific way, which is not directly YUV, RGB or Bayer. Add a new definition and helper for compressed pixel encoding to represent this situation. Signed-off-by: Paul Kocialkowski --- include/media/v4l2-common.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 1bdaea248089..37554bc10e2a 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -465,12 +465,14 @@ int v4l2_s_parm_cap(struct video_device *vdev, * @V4L2_PIXEL_ENC_YUV: Pixel encoding is YUV * @V4L2_PIXEL_ENC_RGB: Pixel encoding is RGB * @V4L2_PIXEL_ENC_BAYER: Pixel encoding is Bayer + * @V4L2_PIXEL_ENC_COMPRESSED: Pixel encoding is compressed */ enum v4l2_pixel_encoding { V4L2_PIXEL_ENC_UNKNOWN = 0, V4L2_PIXEL_ENC_YUV = 1, V4L2_PIXEL_ENC_RGB = 2, V4L2_PIXEL_ENC_BAYER = 3, + V4L2_PIXEL_ENC_COMPRESSED = 4, }; /** @@ -512,6 +514,11 @@ static inline bool v4l2_is_format_bayer(const struct v4l2_format_info *f) return f && f->pixel_enc == V4L2_PIXEL_ENC_BAYER; } +static inline bool v4l2_is_format_compressed(const struct v4l2_format_info *f) +{ + return f && f->pixel_enc == V4L2_PIXEL_ENC_COMPRESSED; +} + const struct v4l2_format_info *v4l2_format_info(u32 format); void v4l2_apply_frmsize_constraints(u32 *width, u32 *height, const struct v4l2_frmsize_stepwise *frmsize); From patchwork Fri Mar 24 15:12:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 666784 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 D8388C761AF for ; Fri, 24 Mar 2023 15:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232455AbjCXPNO (ORCPT ); Fri, 24 Mar 2023 11:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232400AbjCXPNF (ORCPT ); Fri, 24 Mar 2023 11:13:05 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83013231D3; Fri, 24 Mar 2023 08:12:48 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 5C5DFE000C; Fri, 24 Mar 2023 15:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P0SoD3SIFdJN2ETvwmYpRhGM53wgfEmd1zIDvKZ41MI=; b=RXXqYT16dg0xiL/C6DkElG3MssGV6/wUL7QteAqOstGSrdTfoXiSqXhpSy3J5xlGrwqsyv 5P3Mh4QCrbjsxtam0Q0ezKDykqM8xxBthXPpY0qLCwwRgcLFoefZWK1F+rPnKwGlAuJcq7 na924dK4iN0em6zSOTKBVPkOFJ7Cw88te/omkn4AKmtfyQa9i2UlV1oTnVbACQNLZxSYCu F2kcn+gLQlzXEwyJe4idHgxZslC06IbDW8o6VCl7EwJofgnJ5dmfr0cMLz53Jw0iFiXa/9 Q8YUMkA914R4QYD4nOlXu204Wwe6a/nZQtnNaPlUls0H9NO6rDKzay5nTKphBQ== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 4/9] media: v4l2: Add JPEG pixel format to v4l2 format info Date: Fri, 24 Mar 2023 16:12:23 +0100 Message-Id: <20230324151228.2778112-5-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Represent the JPEG pixel format in the v4l2 format info table. Note that the bpp is set to 1 which is not a proper way to estimate the needed buffer size for a given JPEG image. However the compression ratios of JPEG typically allow fitting the image in a smaller size, even though extra metadata could increase the total size by an arbitrary amount. Thus it is not a perfectly safe way to calculate the size of a JPEG buffer for given dimensions but it still provides a reasonable approach. Signed-off-by: Paul Kocialkowski Acked-by: Jernej Skrabec --- drivers/media/v4l2-core/v4l2-common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 5101989716aa..8b2f201a8918 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -317,6 +317,9 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_SGBRG12, .pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_SGRBG12, .pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_SRGGB12, .pixel_enc = V4L2_PIXEL_ENC_BAYER, .mem_planes = 1, .comp_planes = 1, .bpp = { 2, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, + + /* Compressed formats */ + { .format = V4L2_PIX_FMT_JPEG, .pixel_enc = V4L2_PIXEL_ENC_COMPRESSED, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 }, }; unsigned int i; From patchwork Fri Mar 24 15:12:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 667128 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 D8363C6FD1C for ; Fri, 24 Mar 2023 15:13:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232484AbjCXPNS (ORCPT ); Fri, 24 Mar 2023 11:13:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232437AbjCXPNJ (ORCPT ); Fri, 24 Mar 2023 11:13:09 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18BC81ABCF; Fri, 24 Mar 2023 08:12:49 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 5BE5EE000A; Fri, 24 Mar 2023 15:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qIH2xOa232Fh48wwCufBRlgNNrR+ve7uu9Q9Dipak/I=; b=RxOthW9u+Vl0zGq8JoSMX6HQFR1X25CEf9s1nVTPrvCV2/e5Gw8o030kbApFZKm31/MCoS 6GBEYnTar7QpOCpMMqcqv6EWrnfpEi3+X7lD528EH7XtAf91Xti+Bp0422oYW6A6I3HQM+ 1t8DUnc7vY2+/bZZyDs66DALDYGPlzXP9JOdZkZeQmVar/TOe7ieR12QXiTQLeEHJdbnJ5 31IdRnNUA232yEWtpEgxGIpO3tstJvL3bBfT8YUvfcNEOufYhufkvKJafYHdSxl522Rp70 Cud4OLUX9hwKkPZs7L7XOfCm3VKiZ4f8TZnz8FL7z70JeNzn6quDGAvSxFQebg== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 5/9] media: sun6i-csi: capture: Rework and separate format validation Date: Fri, 24 Mar 2023 16:12:24 +0100 Message-Id: <20230324151228.2778112-6-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Introduce a new sun6i_csi_capture_format_check helper to indicate whether a set of pixel format and mbus code are compatible. Most of the logic is taken from sun6i_csi_capture_link_validate, with extra checks added along the way. Note that v4l2_format_info is now used for all pixel formats since they should all be listed in the helper at this point. The motivation behind this change is to pave the way for supporting the mc-style enum_fmt. Signed-off-by: Paul Kocialkowski --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 95 ++++++++++--------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index cf6aadbc130b..6ce7f1d3ed57 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -327,6 +327,52 @@ static bool sun6i_csi_capture_format_match(u32 pixelformat, u32 mbus_code) return false; } +static bool sun6i_csi_capture_format_check(u32 pixelformat, u32 mbus_code) +{ + const struct sun6i_csi_capture_format *capture_format; + const struct sun6i_csi_bridge_format *bridge_format; + const struct v4l2_format_info *format_info; + + format_info = v4l2_format_info(pixelformat); + if (WARN_ON(!format_info)) + return false; + + capture_format = sun6i_csi_capture_format_find(pixelformat); + if (WARN_ON(!capture_format)) + return false; + + bridge_format = sun6i_csi_bridge_format_find(mbus_code); + if (WARN_ON(!bridge_format)) + return false; + + /* Raw input is required for non-YUV formats. */ + if (bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW && + (format_info->pixel_enc == V4L2_PIXEL_ENC_BAYER || + format_info->pixel_enc == V4L2_PIXEL_ENC_RGB || + format_info->pixel_enc == V4L2_PIXEL_ENC_COMPRESSED)) + return false; + + if (format_info->pixel_enc == V4L2_PIXEL_ENC_YUV) { + /* YUV input is required for YUV pixels. */ + if (bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV420 && + bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV422) + return false; + + /* YUV420 input can't produce (upsampled) YUV422 output. */ + if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_YUV420 && + format_info->vdiv == 1) + return false; + } + + /* Raw input requires a 1:1 match between input and output. */ + if ((bridge_format->input_format == SUN6I_CSI_INPUT_FMT_RAW || + capture_format->input_format_raw) && + !sun6i_csi_capture_format_match(pixelformat, mbus_code)) + return false; + + return true; +} + /* Capture */ static void @@ -890,28 +936,16 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) media_entity_to_video_device(link->sink->entity); struct sun6i_csi_device *csi_dev = video_get_drvdata(video_dev); struct v4l2_device *v4l2_dev = csi_dev->v4l2_dev; - const struct sun6i_csi_capture_format *capture_format; - const struct sun6i_csi_bridge_format *bridge_format; unsigned int capture_width, capture_height; unsigned int bridge_width, bridge_height; - const struct v4l2_format_info *format_info; u32 pixelformat, capture_field; u32 mbus_code, bridge_field; - bool match; sun6i_csi_capture_dimensions(csi_dev, &capture_width, &capture_height); - sun6i_csi_capture_format(csi_dev, &pixelformat, &capture_field); - capture_format = sun6i_csi_capture_format_find(pixelformat); - if (WARN_ON(!capture_format)) - return -EINVAL; sun6i_csi_bridge_dimensions(csi_dev, &bridge_width, &bridge_height); - sun6i_csi_bridge_format(csi_dev, &mbus_code, &bridge_field); - bridge_format = sun6i_csi_bridge_format_find(mbus_code); - if (WARN_ON(!bridge_format)) - return -EINVAL; /* No cropping/scaling is supported. */ if (capture_width != bridge_width || capture_height != bridge_height) { @@ -922,43 +956,12 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) return -EINVAL; } - format_info = v4l2_format_info(pixelformat); - /* Some formats are not listed. */ - if (!format_info) - return 0; - - if (format_info->pixel_enc == V4L2_PIXEL_ENC_BAYER && - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW) - goto invalid; - - if (format_info->pixel_enc == V4L2_PIXEL_ENC_RGB && - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW) - goto invalid; - - if (format_info->pixel_enc == V4L2_PIXEL_ENC_YUV) { - if (bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV420 && - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV422) - goto invalid; - - /* YUV420 input can't produce YUV422 output. */ - if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_YUV420 && - format_info->vdiv == 1) - goto invalid; - } - - /* With raw input mode, we need a 1:1 match between input and output. */ - if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_RAW || - capture_format->input_format_raw) { - match = sun6i_csi_capture_format_match(pixelformat, mbus_code); - if (!match) - goto invalid; + if (!sun6i_csi_capture_format_check(pixelformat, mbus_code)) { + v4l2_err(v4l2_dev, "invalid input/output format combination\n"); + return -EINVAL; } return 0; - -invalid: - v4l2_err(v4l2_dev, "invalid input/output format combination\n"); - return -EINVAL; } static const struct media_entity_operations sun6i_csi_capture_media_ops = { From patchwork Fri Mar 24 15:12:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 666783 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 B65FBC76196 for ; Fri, 24 Mar 2023 15:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232378AbjCXPNY (ORCPT ); Fri, 24 Mar 2023 11:13:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232421AbjCXPNK (ORCPT ); Fri, 24 Mar 2023 11:13:10 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5380BB476; Fri, 24 Mar 2023 08:12:51 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 87CD6E000F; Fri, 24 Mar 2023 15:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ibm3tSrzHRilK0eBOck6yRC9NMDYkOhhKkBru4BHJTA=; b=maCXEZC95D2g/i9VZ5tpBHfFcnTLOUQJ1MypJvDDCf74A0M9WoHL5bs+RIwRk8bgrDLnXN ua+6SzvTtX7A4/h0T2boXWqL1VIW6zkPeSCNR52PjXpryFVOjA6Oz6PBLrvsX1wfsnaL1E qclE37AWysUEkygHd3MtLrv4KLfIs5Y8gjsghOpL6KtjSRx17KThxcbBbvCcOHnABoymVD c1MHQi4omFqhwewKM1z0AAYQXC9qoHtqm42V6XMfGgF0u/oAxzDYdcEsSvqLAg+8usLb53 MyqNJceNgYZwmqZsRjerh54qvZj3tWEhcGtvZL5gXJVE11aNVvUDVHvoouwQ7A== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 6/9] media: sun6i-csi: capture: Implement MC I/O with extended enum_fmt Date: Fri, 24 Mar 2023 16:12:25 +0100 Message-Id: <20230324151228.2778112-7-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This driver needs the media-controller API to operate and should not be considered as a video-device-centric implementation. Properly report the IO_MC device cap and extend the enum_fmt implementation to support enumeration with an explicit mbus_code. Signed-off-by: Paul Kocialkowski Reviewed-by: Jernej Skrabec --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index 6ce7f1d3ed57..9627030ff060 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -777,13 +777,40 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *private, struct v4l2_fmtdesc *fmtdesc) { u32 index = fmtdesc->index; + u32 mbus_code = fmtdesc->mbus_code; + unsigned int index_valid = 0; + unsigned int i; + + if (!mbus_code) { + if (index >= ARRAY_SIZE(sun6i_csi_capture_formats)) + return -EINVAL; + + fmtdesc->pixelformat = + sun6i_csi_capture_formats[index].pixelformat; + + return 0; + } + + /* Check capture pixel format matching with mbus code. */ - if (index >= ARRAY_SIZE(sun6i_csi_capture_formats)) + if (!sun6i_csi_bridge_format_find(mbus_code)) return -EINVAL; - fmtdesc->pixelformat = sun6i_csi_capture_formats[index].pixelformat; + for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_formats); i++) { + u32 pixelformat = sun6i_csi_capture_formats[i].pixelformat; - return 0; + if (!sun6i_csi_capture_format_check(pixelformat, mbus_code)) + continue; + + if (index == index_valid) { + fmtdesc->pixelformat = pixelformat; + return 0; + } + + index_valid++; + } + + return -EINVAL; } static int sun6i_csi_capture_g_fmt(struct file *file, void *private, @@ -1039,7 +1066,8 @@ int sun6i_csi_capture_setup(struct sun6i_csi_device *csi_dev) strscpy(video_dev->name, SUN6I_CSI_CAPTURE_NAME, sizeof(video_dev->name)); - video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | + V4L2_CAP_IO_MC; video_dev->vfl_dir = VFL_DIR_RX; video_dev->release = video_device_release_empty; video_dev->fops = &sun6i_csi_capture_fops; From patchwork Fri Mar 24 15:12:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 667127 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 E7CFBC761AF for ; Fri, 24 Mar 2023 15:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232518AbjCXPNZ (ORCPT ); Fri, 24 Mar 2023 11:13:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232439AbjCXPNK (ORCPT ); Fri, 24 Mar 2023 11:13:10 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 350AB13D59; Fri, 24 Mar 2023 08:12:52 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id E3D4FE001B; Fri, 24 Mar 2023 15:12:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1pmURX5WiQgok7667LNCdKhn4LBPmmToQ7P/mWQBXOQ=; b=kSIc7RsqSmQa+l+Wc/6gZkQKyA2eHwyjnSctaczCtZ/53kUxIZ4X8JtFlaNszeAzTuXE/u Z6d5OfG01Q6aakLjKQ8wkgsizTuz7BK5BH0Xxi1A7BPtd8tZW3fKgdKShaWPW1B20cpyGu v4ZQCgC/XJbyR9iN403ta3N49XowLYEbpvaBpdW2dbtl0FGWJ0HZK9ZBDthm57t2VvAubX lAaiJsWGXWSV5UGSI/f75Wh0NskUANgqksOqWAt5LAIF+9xbtVucdFUzFZICzLtNg4dmSX Bo75LHPxRbEbSK0TAxDBkcYs7NVWIAiAzl8sF+hXaY3LpFUQm23SK/qUR6XTwA== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 7/9] media: sun6i-csi: capture: Implement enum_framesizes Date: Fri, 24 Mar 2023 16:12:26 +0100 Message-Id: <20230324151228.2778112-8-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Report available frame sizes as a continuous range between the hardware min/max limits. Signed-off-by: Paul Kocialkowski Co-authored-by: Adam Pigg Signed-off-by: Adam Pigg --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index 9627030ff060..31ba83014086 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -847,6 +847,30 @@ static int sun6i_csi_capture_try_fmt(struct file *file, void *private, return 0; } +static int +sun6i_csi_capture_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *frmsizeenum) +{ + const struct sun6i_csi_capture_format *format; + + if (frmsizeenum->index > 0) + return -EINVAL; + + format = sun6i_csi_capture_format_find(frmsizeenum->pixel_format); + if (!format) + return -EINVAL; + + frmsizeenum->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; + frmsizeenum->stepwise.min_width = SUN6I_CSI_CAPTURE_WIDTH_MIN; + frmsizeenum->stepwise.max_width = SUN6I_CSI_CAPTURE_WIDTH_MAX; + frmsizeenum->stepwise.min_height = SUN6I_CSI_CAPTURE_HEIGHT_MIN; + frmsizeenum->stepwise.max_height = SUN6I_CSI_CAPTURE_HEIGHT_MAX; + frmsizeenum->stepwise.step_width = 1; + frmsizeenum->stepwise.step_height = 1; + + return 0; +} + static int sun6i_csi_capture_enum_input(struct file *file, void *private, struct v4l2_input *input) { @@ -884,6 +908,8 @@ static const struct v4l2_ioctl_ops sun6i_csi_capture_ioctl_ops = { .vidioc_s_fmt_vid_cap = sun6i_csi_capture_s_fmt, .vidioc_try_fmt_vid_cap = sun6i_csi_capture_try_fmt, + .vidioc_enum_framesizes = sun6i_csi_capture_enum_framesizes, + .vidioc_enum_input = sun6i_csi_capture_enum_input, .vidioc_g_input = sun6i_csi_capture_g_input, .vidioc_s_input = sun6i_csi_capture_s_input, From patchwork Fri Mar 24 15:12:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 666782 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 D2F4FC6FD20 for ; Fri, 24 Mar 2023 15:13:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232421AbjCXPN0 (ORCPT ); Fri, 24 Mar 2023 11:13:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232394AbjCXPNN (ORCPT ); Fri, 24 Mar 2023 11:13:13 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E573E144B0; Fri, 24 Mar 2023 08:12:53 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 2A7AFE0018; Fri, 24 Mar 2023 15:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=enDGYKXiM7Q8LTC31mohdS3fckSaBNzhC8rrVAHdczM=; b=CuXi9HpMMawNmx1FJsELZhOeL/RZrZQ7VftiVYaBPSB3jaNIGNsCOclXvviJBNFCJrlDLi x0+54NA2avOS52wW3z+MpNrDKmc2O0aM+rGv3quwOyAQSw33LWwZAIvCjgVJYKnIURIHy3 3rp7hfBKh6ikj4t+KCTQSoQl+pFVarQzbqn8c3fxTkPa7SD09aQsjmW4/3RhvhfCqMTAIL N6Yka5CE4pckxRyIRUwDT+JEg9BKCV9XfLp0zwK2YFab18Zg0YuqMmP28u+QRqx0+1w362 iQeUuB9QqG75evhP/bKkPdp0TMZbUv7tH87DXMowSeDCCFHjN59MaxJgAugTzg== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 8/9] media: sun6i-isp: capture: Implement MC I/O with extended enum_fmt Date: Fri, 24 Mar 2023 16:12:27 +0100 Message-Id: <20230324151228.2778112-9-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This driver needs the media-controller API to operate and should not be considered as a video-device-centric implementation. Properly report the IO_MC device cap and extend the enum_fmt implementation to support enumeration with an explicit mbus_code. Signed-off-by: Paul Kocialkowski Reviewed-by: Jernej Skrabec --- .../staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c index 1595a9607775..5160b93b69ff 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c @@ -439,6 +439,12 @@ static int sun6i_isp_capture_enum_fmt(struct file *file, void *private, struct v4l2_fmtdesc *fmtdesc) { u32 index = fmtdesc->index; + u32 mbus_code = fmtdesc->mbus_code; + + if (mbus_code && !sun6i_isp_proc_format_find(mbus_code)) + return -EINVAL; + + /* Capture format is independent from proc format. */ if (index >= ARRAY_SIZE(sun6i_isp_capture_formats)) return -EINVAL; @@ -685,7 +691,8 @@ int sun6i_isp_capture_setup(struct sun6i_isp_device *isp_dev) strscpy(video_dev->name, SUN6I_ISP_CAPTURE_NAME, sizeof(video_dev->name)); - video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | + V4L2_CAP_IO_MC; video_dev->vfl_dir = VFL_DIR_RX; video_dev->release = video_device_release_empty; video_dev->fops = &sun6i_isp_capture_fops; From patchwork Fri Mar 24 15:12:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 667126 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 E62C0C6FD1C for ; Fri, 24 Mar 2023 15:13:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232157AbjCXPN3 (ORCPT ); Fri, 24 Mar 2023 11:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbjCXPNO (ORCPT ); Fri, 24 Mar 2023 11:13:14 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0488D1B0; Fri, 24 Mar 2023 08:12:56 -0700 (PDT) Received: (Authenticated sender: paul.kocialkowski@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id A116DE001E; Fri, 24 Mar 2023 15:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1679670775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r+i8mUIhWtFV9XGBR7tTV1Ij/OB6oMkb1et6Czsk7zo=; b=OMh9PlANLksoDm/e9yK92YUnsJXBS/POfKawy8xHW9nxfgiKoQbPauHSCwWiE3IocUCGZS vUzyfYwKPKwg0wLAnJLHUclfwpd4Pu4AXDG9PgEyEGzorETZxE+pAQPhzRByVk9mMujomw hexpUhnbpgaNJKJWXc2tOeZ8Nq4X25oQ5PK2sznsE8hT+CB4luzkdCZwSLyMp2RLdZOd0F yECcBPXygUkQLkwC/Qm+T7OtCu9NZu/03hz2C6+2F0hoZnmECKIDTOC9G/dmMTwKdENNlH BFBNkVH1D5yybztsVVufy8SurlRs3ChUkW2UNuzgXJXkodSPBW8vqKbt9zqgGA== From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Laurent Pinchart , Adam Pigg , Thomas Petazzoni Subject: [PATCH 9/9] media: sun6i-isp: capture: Implement enum_framesizes Date: Fri, 24 Mar 2023 16:12:28 +0100 Message-Id: <20230324151228.2778112-10-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> References: <20230324151228.2778112-1-paul.kocialkowski@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Report available frame sizes as a continuous range between the hardware min/max limits. Signed-off-by: Paul Kocialkowski Co-authored-by: Adam Pigg Signed-off-by: Adam Pigg --- .../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c index 5160b93b69ff..a368f90a9beb 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c @@ -487,6 +487,30 @@ static int sun6i_isp_capture_try_fmt(struct file *file, void *private, return 0; } +static int +sun6i_isp_capture_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *frmsizeenum) +{ + const struct sun6i_isp_capture_format *format; + + if (frmsizeenum->index > 0) + return -EINVAL; + + format = sun6i_isp_capture_format_find(frmsizeenum->pixel_format); + if (!format) + return -EINVAL; + + frmsizeenum->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; + frmsizeenum->stepwise.min_width = SUN6I_ISP_CAPTURE_WIDTH_MIN; + frmsizeenum->stepwise.max_width = SUN6I_ISP_CAPTURE_WIDTH_MAX; + frmsizeenum->stepwise.min_height = SUN6I_ISP_CAPTURE_HEIGHT_MIN; + frmsizeenum->stepwise.max_height = SUN6I_ISP_CAPTURE_HEIGHT_MAX; + frmsizeenum->stepwise.step_width = 1; + frmsizeenum->stepwise.step_height = 1; + + return 0; +} + static int sun6i_isp_capture_enum_input(struct file *file, void *private, struct v4l2_input *input) { @@ -524,6 +548,8 @@ static const struct v4l2_ioctl_ops sun6i_isp_capture_ioctl_ops = { .vidioc_s_fmt_vid_cap = sun6i_isp_capture_s_fmt, .vidioc_try_fmt_vid_cap = sun6i_isp_capture_try_fmt, + .vidioc_enum_framesizes = sun6i_isp_capture_enum_framesizes, + .vidioc_enum_input = sun6i_isp_capture_enum_input, .vidioc_g_input = sun6i_isp_capture_g_input, .vidioc_s_input = sun6i_isp_capture_s_input,