From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 4D39F3C0635 for ; Mon, 11 May 2026 09:11:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778490709; cv=none; b=FHhULE4FjrgMN92+bIZ3q3xuS4OgM8zjqBwaqaoYeHp9RdHuhKWM5oXeBePnaXze7aZY11ACSAzG393JPQDAECirk6huwZcjSnfSP0f71rVaI+STPjrciZLSCBqpbwzHaGFi0pRSvaTVn5eENk2JrVv76sM3uOZqaMZdVljxX7M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778490709; c=relaxed/simple; bh=0qhvDT+Vwxn5ikuiZQZ9E4RW4aatCiSTKKq4yBlK8jU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SYxUMGIx9BQUbP7Qdoux/Xy75+a5+vS6XgfetFVNvln93iwK7JWj/MT6TE7Qf1oEycXCcKZAL7a4Fw7Nk6XGsMZ++yj9Xdte64ofm9VFu9rgNnaHQSs83Y7eqBdEZZTci5GmzlxGA7ZAr18lyMx6vyrhzBW99qvZlaE/qgXlIuc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dN0qAkYG; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dN0qAkYG" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-82fbdd60b64so3034512b3a.3 for ; Mon, 11 May 2026 02:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778490708; x=1779095508; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DvqNnKoL2Rdmo5K4e7ujzJasS4PL0erGyYw5kyGQiVk=; b=dN0qAkYGwA5n+6dbmMEO+7t3b8++nMQk+Y9b9QB1eFTk8tW35U3t7BQ5D3TvGGKrFk cxHBbvAIdSkii+oEOhU/+/d1CMvTCX7YSRouD+IUKaXxjg/MOw6wJtMAIo88uqnRGDa/ PAYJ0EzHlmHyBICmO1u8LS5ISXhaQOljVKp/vbLpufnX5C3u8QK7hk3WV+TS4PU4q565 3mam6RFPifqPCbioKN4Rm+u6ayjte8es5WvQEVtnesWNV3y0WC3ktldiaXhuIy5FkaFi WiPDuOjf5xEZ9rIJZprI2o30mRzNHc9p5Y/AaOmBbTYPT3xYmVIlf0eeVSUgYjnM1E/3 4jiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778490708; x=1779095508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DvqNnKoL2Rdmo5K4e7ujzJasS4PL0erGyYw5kyGQiVk=; b=hLhVzRd0QqxfB1vFSsMfcU6RRkK8gIKV6/GauFZJ0TZLYG34sLq/URqOQ67JYEs8m+ IS0HNhfU34Z6Kd8Cf6QwyxSu+TseBd9qppous+Nqjo5YALJZkY+qbA8d8ig2El8peniE r6fc/3eWmHiGg3I9KEmSPT0g+fSDqG18ehMx3M1eJVQdc3TRx0u75kq2nZlDH2Cj3TRO MgITK+poAB1mwBS7onjDT6BioOc8gOliM0x1EsT1mI+DIXHi8j2iQE8IkYlGetCSssW9 Db2itAtwRsVKobXjwrnCbRTHK6L64Vj9SyiG8FhtJvcBlmdUxF7gSeUQPeWGE2mPSNmp fCAQ== X-Forwarded-Encrypted: i=1; AFNElJ9SKox+KkpC+yjDqHhr4cJVcsgzZA0OBqxvONql9ZRR43wl3ITr4tp4NwQ8jdjZkG2XIsbJUbUbEUVn6Q==@vger.kernel.org X-Gm-Message-State: AOJu0Yy4RV/x4d/446cnH4iqR4E26UcXCPp3jKxvEcw8vW2ur6hM/PSG LT1kV0v9WTHV1yk+WfJB+vF8R79C3GUxQw/J10NB78vAFNf6oMJ0TTpz X-Gm-Gg: Acq92OF9RMsAUoO3hDqMZ3Fz1zmtbB/7N2AihpN4CBU93XghUYW542p+u4qML4/Qfl1 ArHK2JS6rrTpnFxSoPP2CmPpANreS72e1VSfFj6GPgwCFn6irFzAEg8VvrlyNfz2ojF2hUnpHRy FB3mtq8jtMSx5lRVaSTKbBdzQ0Uh7fC9zPWVyPoABiuoyRRHaQKpIkZ2iq0lPLB+yPZUL8ONOhO LsD19pz1ZFKH8dL4vnS1VWe3itS9sRl9YrsL7Y94jKAKsAU3/XJnzqFTyhl8Gxo0QvxwB8ctF5J 5LZ0fx47tuODnEshfycXfAvjpmfmTHuJ01nGnZ+brMBiExBDoGfvsV8ZuaspRI7yULP15+Axr+a nmp21FQEEWuj25fPGAIoB3Yor/ubQgvKjAF22SPcS+3v/HIh9+AQKf/yaaXUl2skuVTrafBctf3 qpeZBfOOHV3Bm4OK3E21HeDt0= X-Received: by 2002:a05:6a00:4b52:b0:835:cc47:6fe7 with SMTP id d2e1a72fcca58-83e3afd76b0mr8548676b3a.30.1778490707607; Mon, 11 May 2026 02:11:47 -0700 (PDT) Received: from nuvole ([2409:8a34:5f37:1974:abc5:99cd:a924:4e86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8396563f11csm24775517b3a.3.2026.05.11.02.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 02:11:47 -0700 (PDT) From: Pengyu Luo To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sakari Ailus , Martin Kepplinger-Novakovic , Mauro Carvalho Chehab , Hans Verkuil , Sebastian Krzyszkowiak Cc: devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Pengyu Luo Subject: [PATCH v3 4/5] media: hi846: Add 6MP and 8MP modes support Date: Mon, 11 May 2026 17:09:23 +0800 Message-ID: <20260511090924.269106-5-mitltlatltl@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260511090924.269106-1-mitltlatltl@gmail.com> References: <20260511090924.269106-1-mitltlatltl@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi846 is an 8MP sensor, but the upstream driver has only supported 2MP mode for years. This patch adds 6MP and 8MP modes to maximize sensor utilization. Note that these modes require 4-lane MIPI CSI-2, as the downstream driver only exposes 2MP, 6MP, and 8MP configurations in 4-lane operation on the target device. The register sequences are extracted from the downstream Windows driver. Signed-off-by: Pengyu Luo --- drivers/media/i2c/hi846.c | 154 +++++++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c index 9decfda74787..68302d0b7ca5 100644 --- a/drivers/media/i2c/hi846.c +++ b/drivers/media/i2c/hi846.c @@ -1028,6 +1028,106 @@ static const struct hi846_reg mode_1632x1224_mipi_4lane[] = { {HI846_REG_TG_ENABLE, 0x0100}, }; +static const struct hi846_reg mode_3264x1836_config[] = { + {HI846_REG_MODE_SELECT, 0x0000}, + {HI846_REG_Y_ODD_INC_FOBP, 0x1111}, + {HI846_REG_Y_ODD_INC_VACT, 0x1111}, + {HI846_REG_Y_ADDR_START_VACT_H, 0x0172}, + {HI846_REG_Y_ADDR_END_VACT_H, 0x089d}, + {HI846_REG_UNKNOWN_005C, 0x2101}, + {HI846_REG_FLL, 0x09de}, + {HI846_REG_LLP, 0x0ed8}, + {HI846_REG_BINNING_MODE, 0x0022}, + {HI846_REG_HBIN_MODE, 0x0000}, + {HI846_REG_UNKNOWN_0A24, 0x0000}, + {HI846_REG_X_START_H, 0x0000}, + {HI846_REG_X_OUTPUT_SIZE_H, 0x0cc0}, + {HI846_REG_Y_OUTPUT_SIZE_H, 0x072c}, + {HI846_REG_EXPOSURE, 0x09d8}, + + /* For OTP */ + {HI846_REG_UNKNOWN_021C, 0x0001}, + {HI846_REG_UNKNOWN_021E, 0x0235}, + + {HI846_REG_ISP_EN_H, 0x014a}, + {HI846_REG_UNKNOWN_0418, 0x023e}, + {HI846_REG_UNKNOWN_0B02, 0xe04d}, + {HI846_REG_UNKNOWN_0B10, 0x6821}, + {HI846_REG_UNKNOWN_0B12, 0x0120}, + {HI846_REG_UNKNOWN_0B14, 0x0001}, + {HI846_REG_UNKNOWN_2008, 0x38fd}, + {HI846_REG_UNKNOWN_326E, 0x0000}, +}; + +static const struct hi846_reg mode_3264x1836_mipi_4lane[] = { + {HI846_REG_UNKNOWN_0900, 0x0300}, + {HI846_REG_MIPI_TX_OP_MODE, 0xc319}, + {HI846_REG_UNKNOWN_0914, 0xc109}, + {HI846_REG_TCLK_PREPARE, 0x061a}, + {HI846_REG_UNKNOWN_0918, 0x0407}, + {HI846_REG_THS_ZERO, 0x0a0b}, + {HI846_REG_TCLK_POST, 0x0e08}, + {HI846_REG_UNKNOWN_091E, 0x0a00}, + {HI846_REG_UNKNOWN_090C, 0x0427}, + {HI846_REG_UNKNOWN_090E, 0x0059}, + {HI846_REG_UNKNOWN_0954, 0x0089}, + {HI846_REG_UNKNOWN_0956, 0x0000}, + {HI846_REG_UNKNOWN_0958, 0xca80}, + {HI846_REG_UNKNOWN_095A, 0x9240}, + {HI846_REG_PLL_CFG_MIPI2_H, 0x4124}, + {HI846_REG_TG_ENABLE, 0x0100}, +}; + +static const struct hi846_reg mode_3264x2448_config[] = { + {HI846_REG_MODE_SELECT, 0x0000}, + {HI846_REG_Y_ODD_INC_FOBP, 0x1111}, + {HI846_REG_Y_ODD_INC_VACT, 0x1111}, + {HI846_REG_Y_ADDR_START_VACT_H, 0x0040}, + {HI846_REG_Y_ADDR_END_VACT_H, 0x09cf}, + {HI846_REG_UNKNOWN_005C, 0x2101}, + {HI846_REG_FLL, 0x09de}, + {HI846_REG_LLP, 0x0ed8}, + {HI846_REG_BINNING_MODE, 0x0022}, + {HI846_REG_HBIN_MODE, 0x0000}, + {HI846_REG_UNKNOWN_0A24, 0x0000}, + {HI846_REG_X_START_H, 0x0000}, + {HI846_REG_X_OUTPUT_SIZE_H, 0x0cc0}, + {HI846_REG_Y_OUTPUT_SIZE_H, 0x0990}, + {HI846_REG_EXPOSURE, 0x09d8}, + + /* For OTP */ + {HI846_REG_UNKNOWN_021C, 0x0001}, + {HI846_REG_UNKNOWN_021E, 0x0235}, + + {HI846_REG_ISP_EN_H, 0x014a}, + {HI846_REG_UNKNOWN_0418, 0x0000}, + {HI846_REG_UNKNOWN_0B02, 0xe04d}, + {HI846_REG_UNKNOWN_0B10, 0x6821}, + {HI846_REG_UNKNOWN_0B12, 0x0120}, + {HI846_REG_UNKNOWN_0B14, 0x0001}, + {HI846_REG_UNKNOWN_2008, 0x38fd}, + {HI846_REG_UNKNOWN_326E, 0x0000}, +}; + +static const struct hi846_reg mode_3264x2448_mipi_4lane[] = { + {HI846_REG_UNKNOWN_0900, 0x0300}, + {HI846_REG_MIPI_TX_OP_MODE, 0xc319}, + {HI846_REG_UNKNOWN_0914, 0xc109}, + {HI846_REG_TCLK_PREPARE, 0x061a}, + {HI846_REG_UNKNOWN_0918, 0x0407}, + {HI846_REG_THS_ZERO, 0x0a0b}, + {HI846_REG_TCLK_POST, 0x0e08}, + {HI846_REG_UNKNOWN_091E, 0x0a00}, + {HI846_REG_UNKNOWN_090C, 0x0427}, + {HI846_REG_UNKNOWN_090E, 0x0059}, + {HI846_REG_UNKNOWN_0954, 0x0089}, + {HI846_REG_UNKNOWN_0956, 0x0000}, + {HI846_REG_UNKNOWN_0958, 0xca80}, + {HI846_REG_UNKNOWN_095A, 0x9240}, + {HI846_REG_PLL_CFG_MIPI2_H, 0x4124}, + {HI846_REG_TG_ENABLE, 0x0100}, +}; + static const char * const hi846_test_pattern_menu[] = { "Disabled", "Solid Colour", @@ -1128,9 +1228,59 @@ static const struct hi846_mode supported_modes[] = { .width = 1632 * 2, .height = 1224 * 2, }, - } + }, + { + .width = 3264, + .height = 1836, + .pll_cfg_4lane = 0x4124, /* HI846_REG_PLL_CFG_MIPI2_H */ + .fps = 30, + .frame_len = 2526, + .llp = HI846_LINE_LENGTH, + .reg_list_config = { + .num_of_regs = ARRAY_SIZE(mode_3264x1836_config), + .regs = mode_3264x1836_config, + }, + .reg_list_2lane = { + .num_of_regs = 0, + }, + .reg_list_4lane = { + .num_of_regs = ARRAY_SIZE(mode_3264x1836_mipi_4lane), + .regs = mode_3264x1836_mipi_4lane, + }, + .crop = { + .left = 0x46, + .top = 0x172, + .width = 3264, + .height = 1836, + }, + }, + { + .width = 3264, + .height = 2448, + .pll_cfg_4lane = 0x4124, /* HI846_REG_PLL_CFG_MIPI2_H */ + .fps = 30, + .frame_len = 2526, + .llp = HI846_LINE_LENGTH, + .reg_list_config = { + .num_of_regs = ARRAY_SIZE(mode_3264x2448_config), + .regs = mode_3264x2448_config, + }, + .reg_list_2lane = { + .num_of_regs = 0, + }, + .reg_list_4lane = { + .num_of_regs = ARRAY_SIZE(mode_3264x2448_mipi_4lane), + .regs = mode_3264x2448_mipi_4lane, + }, + .crop = { + .left = 0x46, + .top = 0x40, + .width = 3264, + .height = 2448, + }, + }, }; -#define NUM_MODES_2LANE ARRAY_SIZE(supported_modes) +#define NUM_MODES_2LANE (ARRAY_SIZE(supported_modes) - 2) #define NUM_MODES_4LANE (ARRAY_SIZE(supported_modes) - 1) struct hi846_datafmt { -- 2.54.0