From patchwork Sat Dec 5 13:41:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Fricke X-Patchwork-Id: 10587 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 76E84BDB1F for ; Sat, 5 Dec 2020 13:41:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E79AE635FC; Sat, 5 Dec 2020 14:41:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="s6CpqwYv"; dkim-atps=neutral Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 70292635F0 for ; Sat, 5 Dec 2020 14:41:29 +0100 (CET) Received: by mail-ej1-x644.google.com with SMTP id f23so12850141ejk.2 for ; Sat, 05 Dec 2020 05:41:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JszvQxiQ+jUlEOzG2swQ7gaMo97fIzwTLLQMuYKMPfs=; b=s6CpqwYvz/nusMvIhQOrsYxUYNmq5EHpOiHvZJTZh2NITIvgKMr16FKW8Oyr8PVORX 9BF+IcfZESjDmxJ++v2da9qyjqtbSSYq9VW7JdN2xt0IWANMpdNzgwO9qdf58tyq2wU8 GJ6XpRZxvMs0qq3oz3MWNVdPiSkDYAnZ7jnveEhoiCWD6zZXXhdJWDhWELFiB07ZqE8y r/mS8CaOifooPsV2yEtO/E+SghJ+S9J+OaUHKCZWIExHDFud4DjPyyiLOIBHeuZbc7tu S2eUFMRPCGa00qSQ5+A/O+1ukD76eJ9GvJum4n5xYP+WNpQ9BEOKitGls5Eou9aPe2gi bRJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JszvQxiQ+jUlEOzG2swQ7gaMo97fIzwTLLQMuYKMPfs=; b=GOuYyRLXFF6g+Opkh4RI3Vg4wCr84r0K4gSmjTZyi+MFDFr04D9cgJmHxScFK2+FbS oorINf50YRUsN36kHehFPdv5ttHklhqgEJdB191Os+MdHPsJcLB6s5XienooPhXn5Ju+ 6EJfZw7nXFPuv9SYo86ifB62s+xg/zhPJdVr6I2iRf5VHjEm9bx5PMktfrRMbnOkqXuF gg8mN7qPX3iiKoB7aOXvSDpkhVA37FAlKYPB9dlvDxsaj6yyRk1fBZ1QJKt9O3RTVJdS okHLD6w48EvA7m/wMJRGFmnB/ZhxyGc2pyXNiJ1bJVTEIM1ThMZ6nS5kEdFMEVrwE4Zp D0BA== X-Gm-Message-State: AOAM530hiBiEZn2rDTrGCbjOG1BQttaxTvPeKkssVp+54a3jAPr0+tpu Y0G84QMk3yMkUTT29X2Z/WlizUsCdGc= X-Google-Smtp-Source: ABdhPJymmUKVZPjqtnnfaoYlPFRYA+m5pvUm9SdKYS3Nuw6hQwQlnk6K9VtZvL7+AcCZf22LyuhlaQ== X-Received: by 2002:a17:906:385b:: with SMTP id w27mr11575639ejc.109.1607175688662; Sat, 05 Dec 2020 05:41:28 -0800 (PST) Received: from basti.fritz.box (p200300d1ff2c9400e0800a04f2527278.dip0.t-ipconnect.de. [2003:d1:ff2c:9400:e080:a04:f252:7278]) by smtp.gmail.com with ESMTPSA id mc25sm5291779ejb.58.2020.12.05.05.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 05:41:28 -0800 (PST) From: Sebastian Fricke To: libcamera-devel@lists.libcamera.org Date: Sat, 5 Dec 2020 14:41:25 +0100 Message-Id: <20201205134125.11115-1-sebastian.fricke.linux@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] media: rkisp1: Add the enum_frame_size ioctl X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Implement the VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl, check if the mbus code is valid for the given pad. This call is not available for the parameter or metadata pads of the RkISP1. Signed-off-by: Sebastian Fricke --- I have tested this patch with the following script: https://github.com/initBasti/Linux_kernel_media_tree_fork/commit/efc4b399cff53fb36fadde999594961a3d84073e The results on my NanoPC-T4 (Linux nanopct4 5.10.0-rc6-rockchip64): pad 0 = RKISP1_ISP_PAD_SINK_VIDEO pad 1 = RKISP1_ISP_PAD_SINK_PARAMS pad 2 = RKISP1_ISP_PAD_SOURCE_VIDEO pad 3 = RKISP1_ISP_PAD_SOURCE_STATS basti@nanopct4:~$ python3 rkisp1_enum_frame_size_test.py TEST 0: pad 0 - code 0x300f - size 32x32 - 4032x3024 TEST 1: pad 0 - code 0x3007 - size 32x32 - 4032x3024 TEST 2: pad 0 - code 0x300e - size 32x32 - 4032x3024 TEST 3: pad 0 - code 0x300a - size 32x32 - 4032x3024 TEST 4: pad 0 - code 0x3012 - size 32x32 - 4032x3024 TEST 5: pad 0 - code 0x3008 - size 32x32 - 4032x3024 TEST 6: pad 0 - code 0x3010 - size 32x32 - 4032x3024 TEST 7: pad 0 - code 0x3011 - size 32x32 - 4032x3024 TEST 8: pad 0 - code 0x3014 - size 32x32 - 4032x3024 TEST 9: pad 0 - code 0x3001 - size 32x32 - 4032x3024 TEST 10: pad 0 - code 0x3013 - size 32x32 - 4032x3024 TEST 11: pad 0 - code 0x3002 - size 32x32 - 4032x3024 TEST 12: pad 0 - code 0x2011 - size 32x32 - 4032x3024 TEST 13: pad 0 - code 0x2012 - size 32x32 - 4032x3024 TEST 14: pad 0 - code 0x200f - size 32x32 - 4032x3024 TEST 15: pad 0 - code 0x2010 - size 32x32 - 4032x3024 TEST 16: pad 1 - code 0x7001 - size / TEST 17: pad 2 - code 0x2008 - size 32x32 - 4032x3024 TEST 18: pad 2 - code 0x300f - size 32x32 - 4032x3024 TEST 19: pad 2 - code 0x3007 - size 32x32 - 4032x3024 TEST 20: pad 2 - code 0x300e - size 32x32 - 4032x3024 TEST 21: pad 2 - code 0x300a - size 32x32 - 4032x3024 TEST 22: pad 2 - code 0x3012 - size 32x32 - 4032x3024 TEST 23: pad 2 - code 0x3008 - size 32x32 - 4032x3024 TEST 24: pad 2 - code 0x3010 - size 32x32 - 4032x3024 TEST 25: pad 2 - code 0x3011 - size 32x32 - 4032x3024 TEST 26: pad 2 - code 0x3014 - size 32x32 - 4032x3024 TEST 27: pad 2 - code 0x3001 - size 32x32 - 4032x3024 TEST 28: pad 2 - code 0x3013 - size 32x32 - 4032x3024 TEST 29: pad 2 - code 0x3002 - size 32x32 - 4032x3024 TEST 30: pad 3 - code 0x7001 - size / TEST 31: pad 0 - code 0xdead - size / (test with an invalid media bus code) TEST 32: pad 6 - code 0x300f - size / (test with an invalid pad) TEST 33: pad 0 - code 0x2008 - size / (test with a format that is not supported by the pad) TEST 34: pad 2 - code 0x2010 - size / (test with a format that is not supported by the pad) --- .../platform/rockchip/rkisp1/rkisp1-isp.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 889982d8ca41..fa7540155d71 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -599,6 +599,44 @@ static int rkisp1_isp_enum_mbus_code(struct v4l2_subdev *sd, return -EINVAL; } +static int rkisp1_isp_enum_frame_size(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) +{ + int i; + bool code_match = false; + + if (fse->pad == RKISP1_ISP_PAD_SINK_PARAMS || + fse->pad == RKISP1_ISP_PAD_SOURCE_STATS) + return -EINVAL; + + if (fse->index > 0) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(rkisp1_isp_formats); i++) { + const struct rkisp1_isp_mbus_info *fmt = &rkisp1_isp_formats[i]; + + if (fmt->mbus_code == fse->code) { + code_match = true; + if (!(fmt->direction & RKISP1_ISP_SD_SINK) && + fse->pad == RKISP1_ISP_PAD_SINK_VIDEO) + return -EINVAL; + if (!(fmt->direction & RKISP1_ISP_SD_SRC) && + fse->pad == RKISP1_ISP_PAD_SOURCE_VIDEO) + return -EINVAL; + } + } + + if (!code_match) + return -EINVAL; + + fse->min_width = RKISP1_ISP_MIN_WIDTH; + fse->max_width = RKISP1_ISP_MAX_WIDTH; + fse->min_height = RKISP1_ISP_MIN_HEIGHT; + fse->max_height = RKISP1_ISP_MAX_HEIGHT; + + return 0; +} static int rkisp1_isp_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg) @@ -880,6 +918,7 @@ static int rkisp1_subdev_link_validate(struct media_link *link) static const struct v4l2_subdev_pad_ops rkisp1_isp_pad_ops = { .enum_mbus_code = rkisp1_isp_enum_mbus_code, + .enum_frame_size = rkisp1_isp_enum_frame_size, .get_selection = rkisp1_isp_get_selection, .set_selection = rkisp1_isp_set_selection, .init_cfg = rkisp1_isp_init_config,