Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp108817lql; Fri, 12 Apr 2024 05:29:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWF+me9e/7z0v8dtUczfnET4lrZfSxKjQwr6TCwxZbONdy61riZ61QEbQorr1LHvsyj0iPRgOZFzFz8DbN7dfDKMEY2nyqxvTCYg4oZ9Q== X-Google-Smtp-Source: AGHT+IGpMrMfaTzPt6/PTnuoJNadus1FYMyOYnPwhubS8+hBWi/nEltXwNgnTGOE7I1/QlNUtwUQ X-Received: by 2002:a05:6830:3b0a:b0:6e6:96c0:9f3f with SMTP id dk10-20020a0568303b0a00b006e696c09f3fmr2473140otb.7.1712924961481; Fri, 12 Apr 2024 05:29:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712924961; cv=pass; d=google.com; s=arc-20160816; b=ucUXy9Pahp9vODV/gTVUtTzlXWkn+KmQ26hw4OPxeslkRfoAepy48HqcoRV9MFl6pw A+fklFkCklky8BZ9JPA3IlBCNIT4aEX/LvRQF65PaLhWGbIsXM71wDbkkm583+tv5gIf 0wznSGMjAFtfnJkEXK0Nuq5tbJyICppnyzAiTadUV1TsAWV8w5XlsrmMbMsWYqxLolLv SDVm80+MFPjkMIsBnHg37/+VhoGOUocqJETS9eKdNcUpRppNUw4pcoP7fp0eI51QG4yy OIiV4AMnQUgabT0f0AehHn2KN++KdfUoll1SUwYQ9DvSAT0FVgHX8H4YsR6x8eyNglZ5 hXiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=NUUkr8yZSobBLabz/skEjYE2cV1VS59Krz2TXGU382Q=; fh=PwuX4C2HmGU5MrGYDEjuOgzg+b3lY8lqiW7EvmPok7I=; b=SPP2W879lvC9ohw93IOL5iBn+tC8Wsm4oz5LRKFfXfxeC7R9Fi7LHVcgeEkJJxd21o ZrxhlVRr2nCYGV4pCt8w6Qwktq3Xj295E/MSkymp5dV4C3B+oBaxByB2jb8/6Ac0QSaL UWUyLQVhgDaBCejtXd2yXDVSITRq4dWJUifuUlHI/hNdO3mYDWg7HsbXI1hiM0lApUwU J5shNcUdFt82bU9lLS+rVLBntGkO3rrEQpkXKVXyGB2teFWglKI/+12FlVS5vegm5aeo zNdpUQk6NQQCI2C5IRSk50UP4nYIHEvh2d6O2IvdsIykH+bOuUybNYuAeUPXhC7w0Z1O tG4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=u10uNM7C; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-142645-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142645-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bs18-20020a05620a471200b0078ed35fb98esi96866qkb.390.2024.04.12.05.29.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 05:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142645-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=u10uNM7C; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-142645-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142645-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C89C11C22C6E for ; Fri, 12 Apr 2024 12:29:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01E1457316; Fri, 12 Apr 2024 12:28:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="u10uNM7C" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAC6256B64; Fri, 12 Apr 2024 12:28:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712924934; cv=none; b=MTMWZNGYyv5cX4fa6i0pJl6DFy3RwTS3XCieWqDaM7F1JckTcTbRAFI7JfiYCrTBlgkAkyh6o/bSex7cPgH96XHioo6uBa06EF2DZxJXzIjxZDib7aNhD6y6rU8TVeLdNOIIhe8z555liGjPfbEV/1UyN5mDh3qo/JVzLmA516Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712924934; c=relaxed/simple; bh=CKkaIB1VMOnmqCrBsV70ZTXEjY9urL8LUoJA5O5CNOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VztxVMGMlVLnbxvqV/MaLZXP5ews8x/B6BuwUfxaQUtoO7olAHfvqRIM8zQUfWo3PKK0AsuDIlJ+qKkqKqI4Dhwye8x8FEagNxPFcI0KpViBDgbpZXHUXKBQCA4P61I2mbsrZSpw8ydrVxxuFXfcVBWbNf67ZRFVBpPbiRmrGSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=u10uNM7C; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from umang.jain (unknown [103.251.226.65]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B2370A12; Fri, 12 Apr 2024 14:28:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712924887; bh=CKkaIB1VMOnmqCrBsV70ZTXEjY9urL8LUoJA5O5CNOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u10uNM7C8RUMZJh57UgWW4w5Rfg9CPg/BOQaWJI+Ti3nBWBeAkAgz0koDsxjCfWFn 0J2H4vSXAWgna+v/yBq3UVYJW6MzWGcMBXhjM2PWyWD0md7ziQr1PIxulic4CH5km9 KD+un5e5Rc9nQ+S9D9ZP7bUmu6DHYljRhIa+JMWM= From: Umang Jain To: linux-media@vger.kernel.org Cc: Alexander Shiyan , Kieran Bingham , Sakari Ailus , open list , Umang Jain , Tommaso Merciai Subject: [PATCH v5 1/6] media: imx335: Support 2 or 4 lane operation modes Date: Fri, 12 Apr 2024 17:58:37 +0530 Message-ID: <20240412122842.193713-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240412122842.193713-1-umang.jain@ideasonboard.com> References: <20240412122842.193713-1-umang.jain@ideasonboard.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 From: Kieran Bingham The IMX335 can support both 2 and 4 lane configurations. Extend the driver to configure the lane mode accordingly. Update the pixel rate depending on the number of lanes in use. Signed-off-by: Kieran Bingham Signed-off-by: Umang Jain Reviewed-by: Tommaso Merciai --- drivers/media/i2c/imx335.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index dab6d080bc4c..c633ea1380e7 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -21,6 +21,11 @@ #define IMX335_MODE_STANDBY 0x01 #define IMX335_MODE_STREAMING 0x00 +/* Data Lanes */ +#define IMX335_LANEMODE 0x3a01 +#define IMX335_2LANE 1 +#define IMX335_4LANE 3 + /* Lines per frame */ #define IMX335_REG_LPFR 0x3030 @@ -147,6 +152,7 @@ struct imx335_mode { * @exp_ctrl: Pointer to exposure control * @again_ctrl: Pointer to analog gain control * @vblank: Vertical blanking in lines + * @lane_mode Mode for number of connected data lanes * @cur_mode: Pointer to current selected sensor mode * @mutex: Mutex for serializing sensor controls * @link_freq_bitmap: Menu bitmap for link_freq_ctrl @@ -171,6 +177,7 @@ struct imx335 { struct v4l2_ctrl *again_ctrl; }; u32 vblank; + u32 lane_mode; const struct imx335_mode *cur_mode; struct mutex mutex; unsigned long link_freq_bitmap; @@ -936,6 +943,11 @@ static int imx335_start_streaming(struct imx335 *imx335) return ret; } + /* Configure lanes */ + ret = imx335_write_reg(imx335, IMX335_LANEMODE, 1, imx335->lane_mode); + if (ret) + return ret; + /* Setup handler will write actual exposure and gain */ ret = __v4l2_ctrl_handler_setup(imx335->sd.ctrl_handler); if (ret) { @@ -1096,7 +1108,14 @@ static int imx335_parse_hw_config(struct imx335 *imx335) if (ret) return ret; - if (bus_cfg.bus.mipi_csi2.num_data_lanes != IMX335_NUM_DATA_LANES) { + switch (bus_cfg.bus.mipi_csi2.num_data_lanes) { + case 2: + imx335->lane_mode = IMX335_2LANE; + break; + case 4: + imx335->lane_mode = IMX335_4LANE; + break; + default: dev_err(imx335->dev, "number of CSI2 data lanes %d is not supported\n", bus_cfg.bus.mipi_csi2.num_data_lanes); -- 2.43.0