Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2094175lqz; Tue, 2 Apr 2024 07:10:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU0EINmd1yHoGLmPSpgLavAv8L76DcSdVvylfdS0v69XN1yB1+7eb2JhGxl3djBAy1+LqF6fXbJEjR0Qlv2JLaaEA5MULFLc98aboAGOw== X-Google-Smtp-Source: AGHT+IHhN94py9EBBnxe+07JemIagRgs/iNGPhGx7RFXU/7k6btVa9WNDcFlQFPc0ZD4WZEI/LMB X-Received: by 2002:a67:fe42:0:b0:478:5e07:939c with SMTP id m2-20020a67fe42000000b004785e07939cmr8503036vsr.5.1712067005180; Tue, 02 Apr 2024 07:10:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712067005; cv=pass; d=google.com; s=arc-20160816; b=DjrjQcP+0Wa6EzpydnFwmwlHPz/nbCUguJdnNV7nCPFjrx6Fo8lSosXnFmlYVifRIV mnjcHaEch5l4mrYWNk6XWsr3ruWcJtLZd/v3ih/+GdU8p0e6gGgi7/yIrhhwCbDKK+GG JnJ9heD4cmJ6fHM/EsLygzd9Pt88WNEzj+NBxiNo9J0Hu4NbOAMv8uMcOYd2UJE3b/LA b9xAJO077L3phuesd1QsSbEkgsR5cmZk3RCdgbAStoFtz19ZbD/HVtOQ7yo7adpJ+F9p nBMsNwtLAtxs2F9YSuvacnn2pQ7U3yBXLjWDS8lZ7AwDTwTkI9Nanl4QvBFMFNADnGTe zggQ== 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=Wh0rRhYpIr3YqWADih4BR7TgH8kLEKTNQFyDnd/qf4E=; b=bwPQsloAiTIM8s1fPdU95lIYtmQUSQ71ijops/ajyQvCrmGSYpvf6jwgIugZMIB/j3 McYbeE9fDDKPUUimF+1Zlsh02f/KHzf1N3UXOjRdGk+qQphra7swtTdwaO5UMvcfO4Iq lQvceopDWXwKBmGhEZR7cxCXR9kp0qfxpwV4AsPkJahZEV9zvhf10RsiOTET0B1ilKe4 cB6i8HDAcqUZWIi8aqn86XJSNp+xpo8CpGz8Y417Joa/KUvTO41uaNTQs4t/5QbQ25cv npTY2ivu8NhuwJ0O+MPLZwRezB8U9MwfjogGEOuFSXER7KWOUkP8bO7OrAHk1lyy7NfE 6IwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=iXqiUrDp; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-128108-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128108-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 c19-20020a0561023c9300b004785385500csi1310516vsv.223.2024.04.02.07.10.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 07:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128108-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=iXqiUrDp; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-128108-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128108-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 BA8C91C22880 for ; Tue, 2 Apr 2024 14:10:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1AF485C7B; Tue, 2 Apr 2024 14:09:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iXqiUrDp" 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 8070686248; Tue, 2 Apr 2024 14:09:38 +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=1712066982; cv=none; b=SjHGbVtti/vLu1ho3jOfSJqfe+jRye9lZg6YUOlbiaiyAxcBjk+enz4NDlkIwQzmPL1Qv9xsTt+1aoBJ8oDC0u6R/uUUwc+eCBgYo4yBiOBVq49mz97lf0sa8nupzwxjLrRxekoH3HZ5MtUMvDT7M9BZvGoZ34CPnv/42Fm/a2U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712066982; c=relaxed/simple; bh=CKkaIB1VMOnmqCrBsV70ZTXEjY9urL8LUoJA5O5CNOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h3feAlw12R4Kb9GSdpRftu5dQNBrGOp4JyP2rrJc337OPQlZrLvIgQxII7C88zCWdzNdR/B84nnKzzXJX94MYPUdBDpIxR9TuPAaUQJNZqN+BUKmZHrZMWXv8kw3ydp5M/uI1hNuOlkKTQSjTxnYPVWsbwPpZyERXCT4q2Mg0fg= 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=iXqiUrDp; 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.86.18.232]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9F01983F; Tue, 2 Apr 2024 16:08:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1712066940; bh=CKkaIB1VMOnmqCrBsV70ZTXEjY9urL8LUoJA5O5CNOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXqiUrDpB7Aue/KqawD4MZlxpVlYHfObBm9hE42vTXfNva+gw5FkpxNGg+o+mjCBT zKM4CDVGNQTDxi8VcOkVlxpnN0TjWcTRtEKNfGEG9nTKnJm2BbKTk2whO/kU+My8uH ODKZv+Emg3JE/lG+/cEH3nKPDZf38geftjWTL7Kg= From: Umang Jain To: linux-media@vger.kernel.org Cc: Alexander Shiyan , Kieran Bingham , Sakari Ailus , open list , Dave Stevenson , Umang Jain , Tommaso Merciai Subject: [PATCH v4 1/6] media: imx335: Support 2 or 4 lane operation modes Date: Tue, 2 Apr 2024 19:39:19 +0530 Message-ID: <20240402140924.10009-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240402140924.10009-1-umang.jain@ideasonboard.com> References: <20240402140924.10009-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