From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 12DAB3A1E96 for ; Wed, 29 Apr 2026 07:07:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777446443; cv=none; b=ODCKHOrzuwYcEiBCTmw9NTh7e+76W9ytP2ldnI8VhaxVqT4dANGSLQ8uAEDNpHVigVfcEMIPRU1W6K5BnDEWPlox5DCFd6ybabUEStbDaZrFi9X6qcLrdUMMIFI8A5gMkR3KIBdC8MMTY9+73bsW/n2AMoXjwgkmPpoqwFKwX6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777446443; c=relaxed/simple; bh=STuMPaiIorE5/ZpGHFTixiueZ4xCup3lmUwU+kg2Q3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gzWEa7ZaukHFKrRlweVrZaIEVB7ERRZOye/k0+YNdwpvQ+MmgAktJcL6Ja6SRJed/ziy7yZBcJlatZIvDqtabpxuKCkUC5UWSviLOLCcpdJg+0AMazSjtWYsCaLkVli0h9DTs0jkCLPVR35h0qlGLZzpO0MR6MemXElzD2glmZU= 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=eD8ugfLk; arc=none smtp.client-ip=209.85.214.173 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="eD8ugfLk" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2ad21f437eeso4076185ad.0 for ; Wed, 29 Apr 2026 00:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777446441; x=1778051241; 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=6oVFH+csygmP1sWydNHLJM4Vcbd2v84Tr8Rqn/xPsZw=; b=eD8ugfLkFW+kGzYRx996VCnYgsLJ/z26AVfdOIH0fKBxYyQYZVJX4k64xeQhh7kesL ZUwIiPrbs1FCGkJUDhsUZK/21IsLZURP1dn2N4lQcv3lBGUIBb1GsIEYAacCSQvN0O5e qwRnYe+jtYUe5h9xMDixlnP5lSmvxs7fWHeVbvHvX7mc3tBTXSh99HraWjMMn5GcD1Kv 0+7IF3qYhTrU3iAyamvsKkmkkgon1l8msT0oIwJHEN9M6ZrATv5QoBZS2WQIVnylGpB7 FFFcDDREaiFPqHJeHDqFC+bWfFi1VaaTQvr4lD5wuxFGPmRev0996pEVSA9+nU/JK03L mnDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777446441; x=1778051241; 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=6oVFH+csygmP1sWydNHLJM4Vcbd2v84Tr8Rqn/xPsZw=; b=rwrAU+L7AnkR+QoZP5aX6Iyh3OJ6SbNwWVB0IYuNmBpoxeB5jrgnRjridB7OkCVA2s AU4HVwwyVO27P934JbEDDJHhuxA4arRGBbUGCOfGo0l5+RGQykBJZyO0IBlZ0QbvZnId suj+TuiCPqOCIJptsV/R+WVP9Qld+vDDM+LW3GVtXyf8e5DvFaspJuUKyNoSH7WkJGBY Ds3izRMqafUj+fXxDGEXdXQo+jcLE9auGj67001UBGpVYmlxRrFGu44nDcbO33jqhO5B tbcdzTW/5cqjURH53YIR3JPOInf2S7E4YNvwS1y0S5FkkKjyL1MkiiMUvcL/ltsuSzZF /tAA== X-Forwarded-Encrypted: i=1; AFNElJ+XiPqJAvNe4yR7l5yXEWH1vwVR/IzgnNE0av6SWk9yfNgQlfpKyA+IoUyDoSGqGvxnbnWSE1F9qMMtKsg=@vger.kernel.org X-Gm-Message-State: AOJu0YzWIUIgN1Fm+VS+Y/8Of5w4a+11e31tyzskesBK7jHWvORePjy3 bQeog3AmCscUi5hFrZscWcJBeh2qU+KMXPI26q8WaxrcA+xbyPx899BP X-Gm-Gg: AeBDievQgIC4QbCgxNBCqMOcxGr/7arg3iT9oFvkQh2XYSkeb3Y7hPCenYJiiADgtBP N1O0sY1RwVkWGkJdIBtDeVgD4pTthrf9SUvD6RA2yuUZUa7MhQ4X/3fB4nSCglZLd3fTc18shXz W3U1jG9X8CbE5+WtVorOBjXwGhpOW4jahwkcvObR1whYX90QckPmYYibtRDQwt2ZUpv+ZL0/1hK MNjYhiGNC3K6DgEE4o+fiLvRYLRbbj058CvvBw6Cge7zXTMNWUkfd3wBKYhr0NuUu5WgduksLsG qzW+6C3ZWqIINS5Y4NKcx4S4uOCi7guxIgHmqX7G+1gZ8uaiGPCch00hCeaDpsnhz1DI6qOEK00 LubJl/rjfJ0ynfVFLwfI702NhzkVKtxEG+RWdzz3GblczGtzmuK6GXIen8yeSEfyWas+7mJXpr3 NVqxxCCTbKB+/442GcsTvUDDcRwqqnwVsC47Dx85E= X-Received: by 2002:a17:903:3846:b0:2b0:be79:e521 with SMTP id d9443c01a7336-2b9882607d0mr18559955ad.26.1777446441258; Wed, 29 Apr 2026 00:07:21 -0700 (PDT) Received: from nuvole ([144.202.86.13]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b988772e6dsm11872125ad.16.2026.04.29.00.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 00:07:20 -0700 (PDT) From: Pengyu Luo To: Sakari Ailus , Martin Kepplinger-Novakovic , Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Pengyu Luo Subject: [PATCH 2/2] media: hi846: Add 6MP and 8MP modes support Date: Wed, 29 Apr 2026 15:03:51 +0800 Message-ID: <20260429070351.1307204-3-mitltlatltl@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260429070351.1307204-1-mitltlatltl@gmail.com> References: <20260429070351.1307204-1-mitltlatltl@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@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, 153 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c index 09c109f3fba9..b8ae7344f1a0 100644 --- a/drivers/media/i2c/hi846.c +++ b/drivers/media/i2c/hi846.c @@ -1027,6 +1027,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", @@ -1042,9 +1142,11 @@ static const char * const hi846_test_pattern_menu[] = { #define FREQ_INDEX_640 0 #define FREQ_INDEX_1280 1 +#define FREQ_INDEX_3264 2 static const s64 hi846_link_freqs[] = { [FREQ_INDEX_640] = 80000000, [FREQ_INDEX_1280] = 200000000, + [FREQ_INDEX_3264] = 288000000, }; static const struct hi846_reg_list hi846_init_regs_list_2lane = { @@ -1134,7 +1236,57 @@ static const struct hi846_mode supported_modes[] = { .width = 1632 * 2, .height = 1224 * 2, }, - } + }, + { + .width = 3264, + .height = 1836, + .link_freq_index = FREQ_INDEX_3264, + .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, + .link_freq_index = FREQ_INDEX_3264, + .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, + }, + }, }; struct hi846_datafmt { -- 2.54.0