From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D90D7CD37AC for ; Mon, 11 May 2026 09:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=DvqNnKoL2Rdmo5K4e7ujzJasS4PL0erGyYw5kyGQiVk=; b=nDr14wv2DwagOJqDw2aoQISLQo 7+O64sO4LOCkG0mGxEZ9xX5pgf7gJIL1hcxI0MtRCUx7SN/8zdB1bXBqiAr0yOE04uo5y5K34Lsr8 sHNIIXpZBlpZW/b1bNoLoB7L67/xSZIqo2Cji5EaUpMllW0x19EtNxe3BEku9IIONIY7yNRhIedUu VcAXQ1B3TGBYqirt7ArVDaMB16CGOO3L3ucacoXbnPBfVG420jzkfHR891UHpniXg5uT1Rla23gGF 9EitHUFcy9kG1V36njomjniYwk5Rxl/spqgtINm5E9gWlmONCyOyC1LW9S8aogOpjoGL7B3cpRu+Z pnq2k9hA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wMMg2-0000000CrHB-0LsU; Mon, 11 May 2026 09:11:50 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wMMg0-0000000CrFU-1PlR for linux-arm-kernel@lists.infradead.org; Mon, 11 May 2026 09:11:49 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-835c98b659eso2756072b3a.0 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=lists.infradead.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=KT2gOH82wIDGdHD0RS5+yhhXa+oAvmSh8o6nGp/N+7WCb8bkgJUQNhGiJZojNABZiu Sx7Qi9uVWgV1Wxrf7P2WeCIFsO5yLBR7kmSF7/i8lm/RAAO0/4gIs9bj7XCyOysKNMT1 IjggpeaM4C4VLH4eyL+wptU+9KZ8KWx0XN/Rqfmc2EUFq/2qM0CztiPY0FsTzOqAltvk M/NaLftDtAnloo0EF3R7tlF2V0nRxL0L4pNKcfWnrTZ3vCHRisDdYGLU7+BbakPX0914 b56WzVEa/MLRmrOBRLwa7JhDDgjlXqzzCLGCSOqGpEPEq9MTxtA+TQC3HzdAJd9HsrEc iLgA== 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=CB43VcTwhCiYBIQT+PpV7g7ESRM/R4BzbjBf7ds7xlWVG1TJiZ/cScV3J6xjAWFpZ/ tzKKp5VZVi1H0+8AVfcS6FTTCY7yxgWLzp4nMA4HrLLmeZX29yqSEt41hCwxjg/04/UU EPn4HPPP2Oikh8gJrGADS3eJGrFFb8JE6stIQw3Hu5ra7x46Uukqj7PXJoiLKcdREwzU 37uTdA97j5vzP2CYewnphgAkynD586N2WGVGY0yw5/wfp+rNEg2mpJQXDjKPBgidD3C0 OyFXqnQl1lT3+IsG/krIkkb0uPPzSLS9oSwQH4sch+RXmQhrsvNsNU0ZeHBLLVQuM6uK gFOw== X-Forwarded-Encrypted: i=1; AFNElJ9BJ0L747y82ZvMrXzns96oU40SD+np4NjbYiGl6PZmlcSorHqKe1vzkcDDTEkR4141sDqUYw2RB1VRgjTmWNUG@lists.infradead.org X-Gm-Message-State: AOJu0YxODZ2fUVDTqQQ7hnlVh92lnI6N+LNU8mAdHEd/prKnIE35gE0x 49DkpWXDRz+tNhT4BO4zCXmGs3cIqYBuyWequfC7eTulmg3g2zIAc+DP X-Gm-Gg: Acq92OH1VXKhy4cz0PSadIYFU4GAfRvq/xTyaAKyA5GUESsOXRbmnmLdo0hTpjOx2Hy e5GAJrgQOqRgi3ZNmDokl3OkVEj6R/988FMV1Vuq8Oex7rTwvJFV9l8XMzdmlb2W3NannR0JAiS /PX0M+cd92+Y8M2Uw2TxTDL1hLxi5FyB6huQtV7fugLVYFO1zU7Z7oUzv00Ax5SSPyrKFkpZ1D+ eHQM8s/YDy3VVy5QmZzhOfEQsmgw/x2hgJj8zi6QOREYB0I5OMHKVnpRswgwp0xOfxWxVl1qkfG U+TpiwRICry7cVH3QTwtL4BMw4qCRflEr95AFiYV8lnPEs5gACNZ5+US9BM21S7t9caR4BvtslT J3tm6vyp0oWFtCssTI4ubYNywBSwYqa3uAvYpaXS4sHY+YheEOgYKjEEvp7aRvN3bIA8CUilhC0 WxvO+IylNrnfBU0zPpVj8bxNo= 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> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260511_021148_384847_FE72712E X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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