From nobody Thu Aug 27 00:54:23 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5E0840FD9B for ; Wed, 8 Jul 2026 14:49:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522163; cv=none; b=rcpfOqebQo8Yc9WwncMDgJKyorKyeudFugVv/W/Xlh5YHw3G2isFAm252yr5eIkuUnffOKjh2LwXYh7qOPHV4Lgn+AJr0a+xiZ6uDQKtyB2NJ/iQAySfQZTfkh9RItAf/7PcRe7I24tSa4muo7wsXfMZn4LzDZQ+gpMminiYQ2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783522163; c=relaxed/simple; bh=uptn9HEahdMTaqGmQxVJEJT5YRUy1nkqgIMVl2o0djI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hum2GVeEwQx0Mb0z0d5mexYlYtHKsDqFmZrdJl84B2taIAaCTsvL7UlKitI7QSTK+JtvG9OFd63o22LM/raUNJmC7xJkxT1wHq1T7CafL327VMn1QWPNZFBOOpMCn30aCaYuY3mv6RfpA42jEsMFlPxEz0k0cFzxElm/y/HPFUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=HYqRnJDb; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="HYqRnJDb" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-493c486f012so3333915e9.3 for ; Wed, 08 Jul 2026 07:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1783522154; x=1784126954; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Pwzhsyb87YU04avI9KvPGSuu5cY5C4k8J1lsuCyaRo8=; b=HYqRnJDb3n44V1/+5cT3mQMyqFlUG9kGDrugka+tQ6UZTslRnadbotSiaqdoBjBo2Y NT5kxe0FwPlqIX8aHBurVH2IvjX/siZ6F5d15SWgzX6cJPGcOqkEVgnA5GLItoCpQf/A fVx605JQ7i2a3VcjmhUV4LCEcH3spX2mVt+cN8gS/tnyFZMGXz3vaFezufy7dOnxmRlo +9l5bRoa+2ql+Xj1pANWf+KyYVfeu4YSqNqkqT5Qk/2YL/7aVMgecYGZj4l/bax/iklA c4CNJhQDGLrDAZlEa4LWfYcOFT9xezdCpCohsFvIdQoUr3Rks3s0oAn7kn0uv8gp/jQi adNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783522154; x=1784126954; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Pwzhsyb87YU04avI9KvPGSuu5cY5C4k8J1lsuCyaRo8=; b=pE52q3dIzynFYD/wlv4MMEzb4VWIpnK9AXz7pE3kxk7h4KOnQhNYsJex6Q841Y6ntK vahwAGM6oCDOxu5Xfj4Fl+iqHhqaJ5+s35s1vUzTRK5DduRuG1SVu5OaKUXpLhaAQXZV 80de6K0Gh7v3FuZtqUTIZv9H5ScfEa/n+8g4w4IvI5+h6ZLjmXbE6Im3dXhDdo4F6zXf vIDbnkKijoslpgNCWbX6SOukUrq5/dUDUhXj8xmFcDHCFpYUUlNqRPw8I+cfZSey/X/1 hm+em74rJuAHGWT//Kxo3hs31VQEhggzOt60dSYSDiNGEH9K+K2zptzkScgo/bbxRmYU W7GA== X-Forwarded-Encrypted: i=1; AHgh+RoLJqUBiubQnRdUAB+8Y4/zktIOSbg7UiUEEwrWRzqtNAJRdhWXVkvONFatXweyL2h46Tk7KUdYkfHfrjU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz77ZzsJ2oZM8VHeBrEpIsdAsuBeSU+H7WJp5xXcd00x9Z1Xa3x oNur5vXk094lRr4w9QdxoHIY4u3bkULXqLLGXO4hz9dY43YOCXUzebSOYTKFo6+dn80= X-Gm-Gg: AfdE7cmh6HRAIbnXGIspMz4q1Y1eCen43b7OtTMZtEoQyTNeVxFbrO2RkY3iYmSC5hT Imt1pPuv/bkFMek1KHZp2YBZjpIin2pZ2+LqFhI7nBFL+D7iyQ2PhUY+iqb7VRDx4ktpB8Allv5 tOcpVVyEcF2h7mcK5ZhseB+Tsx1Jl5GRQiYWK0EZyJE5cX4sKVxj7Ed96ch19pCO4nUo67y2V+C tO9GuAYL7MyChjD1OfIJmtyV9Q4M3RT8MAZvbEK5XMKszBN8IkqW9MTrl2xzAst+uQzm/TcJw3C mZbtJxpcNGcYxTt7WpMohL/YPlEFYTv4xJWh7v5Kkfix7U+Uqt3r2sYcDpoNElGk4L0/kNdQ6q5 GlQ/d2QwtrnepodIXbpQAgNh2W8lHZNFm+n/ng15qXTTM5ivMBJWFbSE31I0p4ZuEw/Lc3z3Scj vg8XKkY9I2cEe6S+4CigSr/Mk5HoQnXPj7Wt4p5+R9uHCnVGY2Z7gHarzas+LxRhAaoxxLShI03 Mo= X-Received: by 2002:a05:600c:1f8e:b0:492:5e22:ef18 with SMTP id 5b1f17b1804b1-493e6861bc8mr26602435e9.9.1783522153744; Wed, 08 Jul 2026 07:49:13 -0700 (PDT) Received: from [127.0.1.1] ([2a00:1098:3142:e::8]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-493e0fbd355sm135363315e9.13.2026.07.08.07.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:49:13 -0700 (PDT) From: Dave Stevenson Date: Wed, 08 Jul 2026 15:48:41 +0100 Subject: [PATCH v3 05/20] media: imx355: Programmatically set the crop parameters for each mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260708-media-imx355-v3-5-9df386a623d7@raspberrypi.com> References: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> In-Reply-To: <20260708-media-imx355-v3-0-9df386a623d7@raspberrypi.com> To: Sakari Ailus , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Richard Acayan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Heidelberg , Jacopo Mondi , devicetree@vger.kernel.org, Dave Stevenson X-Mailer: b4 0.14.1 Currently the cropping is set via register entries in the per mode register lists. Add the crop information to the mode structure as a v4l2_rect, and set the registers programmatically. Signed-off-by: Dave Stevenson --- drivers/media/i2c/imx355.c | 290 +++++++++++++++++++----------------------= ---- 1 file changed, 121 insertions(+), 169 deletions(-) diff --git a/drivers/media/i2c/imx355.c b/drivers/media/i2c/imx355.c index 24c883a6c520..29bca1d98791 100644 --- a/drivers/media/i2c/imx355.c +++ b/drivers/media/i2c/imx355.c @@ -33,6 +33,13 @@ #define IMX355_REG_FLL 0x0340 #define IMX355_FLL_MAX 0xffff =20 +#define IMX355_REG_X_ADD_START 0x0344 +#define IMX355_REG_Y_ADD_START 0x0346 +#define IMX355_REG_X_ADD_END 0x0348 +#define IMX355_REG_Y_ADD_END 0x034a +#define IMX355_REG_X_OUT_SIZE 0x034c +#define IMX355_REG_Y_OUT_SIZE 0x034e + /* Exposure control */ #define IMX355_REG_EXPOSURE 0x0202 #define IMX355_EXPOSURE_MIN 1 @@ -88,6 +95,7 @@ struct imx355_mode { u32 width; /* Frame height */ u32 height; + struct v4l2_rect crop; =20 /* V-timing */ u32 fll_def; @@ -254,21 +262,9 @@ static const struct imx355_reg_list imx355_global_sett= ing =3D { static const struct imx355_reg mode_3268x2448_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x00 }, - { 0x0345, 0x08 }, - { 0x0346, 0x00 }, - { 0x0347, 0x08 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcb }, - { 0x034a, 0x09 }, - { 0x034b, 0x97 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x0c }, - { 0x034d, 0xc4 }, - { 0x034e, 0x09 }, - { 0x034f, 0x90 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -276,21 +272,9 @@ static const struct imx355_reg mode_3268x2448_regs[] = =3D { static const struct imx355_reg mode_3264x2448_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x00 }, - { 0x0345, 0x08 }, - { 0x0346, 0x00 }, - { 0x0347, 0x08 }, - { 0x0348, 0x0c }, - { 0x0349, 0xc7 }, - { 0x034a, 0x09 }, - { 0x034b, 0x97 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x0c }, - { 0x034d, 0xc0 }, - { 0x034e, 0x09 }, - { 0x034f, 0x90 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -298,21 +282,9 @@ static const struct imx355_reg mode_3264x2448_regs[] = =3D { static const struct imx355_reg mode_3280x2464_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x00 }, - { 0x0345, 0x00 }, - { 0x0346, 0x00 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcf }, - { 0x034a, 0x09 }, - { 0x034b, 0x9f }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x0c }, - { 0x034d, 0xd0 }, - { 0x034e, 0x09 }, - { 0x034f, 0xa0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -320,21 +292,9 @@ static const struct imx355_reg mode_3280x2464_regs[] = =3D { static const struct imx355_reg mode_1940x1096_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x02 }, - { 0x0345, 0xa0 }, - { 0x0346, 0x02 }, - { 0x0347, 0xac }, - { 0x0348, 0x0a }, - { 0x0349, 0x33 }, - { 0x034a, 0x06 }, - { 0x034b, 0xf3 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x07 }, - { 0x034d, 0x94 }, - { 0x034e, 0x04 }, - { 0x034f, 0x48 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -342,21 +302,9 @@ static const struct imx355_reg mode_1940x1096_regs[] = =3D { static const struct imx355_reg mode_1936x1096_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x02 }, - { 0x0345, 0xa0 }, - { 0x0346, 0x02 }, - { 0x0347, 0xac }, - { 0x0348, 0x0a }, - { 0x0349, 0x2f }, - { 0x034a, 0x06 }, - { 0x034b, 0xf3 }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x07 }, - { 0x034d, 0x90 }, - { 0x034e, 0x04 }, - { 0x034f, 0x48 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -364,21 +312,9 @@ static const struct imx355_reg mode_1936x1096_regs[] = =3D { static const struct imx355_reg mode_1924x1080_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x02 }, - { 0x0345, 0xa8 }, - { 0x0346, 0x02 }, - { 0x0347, 0xb4 }, - { 0x0348, 0x0a }, - { 0x0349, 0x2b }, - { 0x034a, 0x06 }, - { 0x034b, 0xeb }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x07 }, - { 0x034d, 0x84 }, - { 0x034e, 0x04 }, - { 0x034f, 0x38 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -386,21 +322,9 @@ static const struct imx355_reg mode_1924x1080_regs[] = =3D { static const struct imx355_reg mode_1920x1080_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x02 }, - { 0x0345, 0xa8 }, - { 0x0346, 0x02 }, - { 0x0347, 0xb4 }, - { 0x0348, 0x0a }, - { 0x0349, 0x27 }, - { 0x034a, 0x06 }, - { 0x034b, 0xeb }, { 0x0900, 0x00 }, { 0x0901, 0x11 }, { 0x0902, 0x00 }, - { 0x034c, 0x07 }, - { 0x034d, 0x80 }, - { 0x034e, 0x04 }, - { 0x034f, 0x38 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -408,21 +332,9 @@ static const struct imx355_reg mode_1920x1080_regs[] = =3D { static const struct imx355_reg mode_1640x1232_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x00 }, - { 0x0345, 0x00 }, - { 0x0346, 0x00 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcf }, - { 0x034a, 0x09 }, - { 0x034b, 0x9f }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x06 }, - { 0x034d, 0x68 }, - { 0x034e, 0x04 }, - { 0x034f, 0xd0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -430,21 +342,9 @@ static const struct imx355_reg mode_1640x1232_regs[] = =3D { static const struct imx355_reg mode_1640x922_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x00 }, - { 0x0345, 0x00 }, - { 0x0346, 0x01 }, - { 0x0347, 0x30 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcf }, - { 0x034a, 0x08 }, - { 0x034b, 0x63 }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x06 }, - { 0x034d, 0x68 }, - { 0x034e, 0x03 }, - { 0x034f, 0x9a }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -452,21 +352,9 @@ static const struct imx355_reg mode_1640x922_regs[] = =3D { static const struct imx355_reg mode_1300x736_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x01 }, - { 0x0345, 0x58 }, - { 0x0346, 0x01 }, - { 0x0347, 0xf0 }, - { 0x0348, 0x0b }, - { 0x0349, 0x7f }, - { 0x034a, 0x07 }, - { 0x034b, 0xaf }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x05 }, - { 0x034d, 0x14 }, - { 0x034e, 0x02 }, - { 0x034f, 0xe0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -474,21 +362,9 @@ static const struct imx355_reg mode_1300x736_regs[] = =3D { static const struct imx355_reg mode_1296x736_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x01 }, - { 0x0345, 0x58 }, - { 0x0346, 0x01 }, - { 0x0347, 0xf0 }, - { 0x0348, 0x0b }, - { 0x0349, 0x77 }, - { 0x034a, 0x07 }, - { 0x034b, 0xaf }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x05 }, - { 0x034d, 0x10 }, - { 0x034e, 0x02 }, - { 0x034f, 0xe0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -496,21 +372,9 @@ static const struct imx355_reg mode_1296x736_regs[] = =3D { static const struct imx355_reg mode_1284x720_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x01 }, - { 0x0345, 0x68 }, - { 0x0346, 0x02 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0b }, - { 0x0349, 0x6f }, - { 0x034a, 0x07 }, - { 0x034b, 0x9f }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x05 }, - { 0x034d, 0x04 }, - { 0x034e, 0x02 }, - { 0x034f, 0xd0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -518,21 +382,9 @@ static const struct imx355_reg mode_1284x720_regs[] = =3D { static const struct imx355_reg mode_1280x720_regs[] =3D { { 0x0342, 0x07 }, { 0x0343, 0x2c }, - { 0x0344, 0x01 }, - { 0x0345, 0x68 }, - { 0x0346, 0x02 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0b }, - { 0x0349, 0x67 }, - { 0x034a, 0x07 }, - { 0x034b, 0x9f }, { 0x0900, 0x01 }, { 0x0901, 0x22 }, { 0x0902, 0x00 }, - { 0x034c, 0x05 }, - { 0x034d, 0x00 }, - { 0x034e, 0x02 }, - { 0x034f, 0xd0 }, { 0x0700, 0x00 }, { 0x0701, 0x10 }, }; @@ -540,21 +392,9 @@ static const struct imx355_reg mode_1280x720_regs[] = =3D { static const struct imx355_reg mode_820x616_regs[] =3D { { 0x0342, 0x0e }, { 0x0343, 0x58 }, - { 0x0344, 0x00 }, - { 0x0345, 0x00 }, - { 0x0346, 0x00 }, - { 0x0347, 0x00 }, - { 0x0348, 0x0c }, - { 0x0349, 0xcf }, - { 0x034a, 0x09 }, - { 0x034b, 0x9f }, { 0x0900, 0x01 }, { 0x0901, 0x44 }, { 0x0902, 0x00 }, - { 0x034c, 0x03 }, - { 0x034d, 0x34 }, - { 0x034e, 0x02 }, - { 0x034f, 0x68 }, { 0x0700, 0x02 }, { 0x0701, 0x78 }, }; @@ -580,6 +420,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 3280, .height =3D 2464, + .crop =3D { + .width =3D 3280, + .height =3D 2464, + .left =3D 0, + .top =3D 0, + }, .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, @@ -592,6 +438,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 3268, .height =3D 2448, + .crop =3D { + .width =3D 3268, + .height =3D 2448, + .left =3D 8, + .top =3D 8, + }, .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, @@ -604,6 +456,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 3264, .height =3D 2448, + .crop =3D { + .width =3D 3264, + .height =3D 2448, + .left =3D 8, + .top =3D 8, + }, .fll_def =3D 2615, .fll_min =3D 2615, .llp =3D 3672, @@ -616,6 +474,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1940, .height =3D 1096, + .crop =3D { + .width =3D 1940, + .height =3D 1096, + .left =3D 672, + .top =3D 684, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, @@ -628,6 +492,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1936, .height =3D 1096, + .crop =3D { + .width =3D 1936, + .height =3D 1096, + .left =3D 672, + .top =3D 684, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, @@ -640,6 +510,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1924, .height =3D 1080, + .crop =3D { + .width =3D 1924, + .height =3D 1080, + .left =3D 680, + .top =3D 692, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, @@ -652,6 +528,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1920, .height =3D 1080, + .crop =3D { + .width =3D 1920, + .height =3D 1080, + .left =3D 680, + .top =3D 692, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 3672, @@ -664,6 +546,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1640, .height =3D 1232, + .crop =3D { + .width =3D 3280, + .height =3D 2464, + .left =3D 0, + .top =3D 0, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -676,6 +564,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1640, .height =3D 922, + .crop =3D { + .width =3D 3280, + .height =3D 1844, + .left =3D 0, + .top =3D 304, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -688,6 +582,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1300, .height =3D 736, + .crop =3D { + .width =3D 2600, + .height =3D 1472, + .left =3D 344, + .top =3D 496, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -700,6 +600,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1296, .height =3D 736, + .crop =3D { + .width =3D 2592, + .height =3D 1472, + .left =3D 344, + .top =3D 496, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -712,6 +618,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1284, .height =3D 720, + .crop =3D { + .width =3D 2568, + .height =3D 1440, + .left =3D 360, + .top =3D 512, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -724,6 +636,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 1280, .height =3D 720, + .crop =3D { + .width =3D 2560, + .height =3D 1440, + .left =3D 360, + .top =3D 512, + }, .fll_def =3D 1306, .fll_min =3D 1306, .llp =3D 1836, @@ -736,6 +654,12 @@ static const struct imx355_mode supported_modes[] =3D { { .width =3D 820, .height =3D 616, + .crop =3D { + .width =3D 3280, + .height =3D 2464, + .left =3D 0, + .top =3D 0, + }, .fll_def =3D 652, .fll_min =3D 652, .llp =3D 3672, @@ -1074,6 +998,7 @@ imx355_set_pad_format(struct v4l2_subdev *sd, static int imx355_start_streaming(struct imx355 *imx355) { const struct imx355_reg_list *reg_list; + const struct imx355_mode *mode; int ret; =20 /* Global Setting */ @@ -1085,13 +1010,40 @@ static int imx355_start_streaming(struct imx355 *im= x355) } =20 /* Apply default values of current mode */ - reg_list =3D &imx355->cur_mode->reg_list; + mode =3D imx355->cur_mode; + reg_list =3D &mode->reg_list; ret =3D imx355_write_regs(imx355, reg_list->regs, reg_list->num_of_regs); if (ret) { dev_err(imx355->dev, "failed to set mode"); return ret; } =20 + /* Set readout crop and size registers */ + ret =3D imx355_write_reg(imx355, IMX355_REG_X_ADD_START, 2, + mode->crop.left); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_Y_ADD_START, 2, + mode->crop.top); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_X_ADD_END, 2, + mode->crop.width + mode->crop.left - 1); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_Y_ADD_END, 2, + mode->crop.height + mode->crop.top - 1); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_X_OUT_SIZE, 2, + mode->width); + if (ret) + return ret; + ret =3D imx355_write_reg(imx355, IMX355_REG_Y_OUT_SIZE, 2, + mode->height); + if (ret) + return ret; + /* Set PLL registers for the external clock frequency */ ret =3D imx355_write_reg(imx355, IMX355_REG_EXTCLK_FREQ, 2, imx355->clk_params->extclk_freq); --=20 2.34.1