Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp700075lqt; Tue, 19 Mar 2024 00:28:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUcvflX3/7uOHLDY1EjgD9OrbRAZh7tvBkFR5GV3Y+YLIWbVX1CQhI3dYhzC+r3BCf3gdQU8J7y3j2s3gm+i92AazPqSeDJjBFV6ZRtAA== X-Google-Smtp-Source: AGHT+IEs0LD9DNZssGCs4kS3LKrqUNI4GhkgUQ/U0djUxcrK797LBJTIWTrsaHmYmNIuigp3U3Yu X-Received: by 2002:a05:6358:2619:b0:17b:f3f0:8fe with SMTP id l25-20020a056358261900b0017bf3f008femr13595536rwc.25.1710833297912; Tue, 19 Mar 2024 00:28:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710833297; cv=pass; d=google.com; s=arc-20160816; b=GpRTEc7VuIb6lZ1Uf44+ZqQ3Xrs6iTvRDnzJexRcWsQE5FdjHJkydJRHmp3LTkQkfJ 20kIoSZM35zQ4n+h2/Ew2kKgJGAGMXV2Yu2k7vz6rhahiuKI/FwKWaxSxcnU7djuqM2H bHrMFIeHT4yRUND8dEatdQJpnW/qisVGTSVoA9frLf/SyHA8sBLpLSwfPJSFc8+MaVCc lXSpca7B3SwO6jlxnOpt5+VE0vK+khqH4w2/rV8Xlj6VNubv5Lb05z/NBXaFtRXa45Qs 67o6HxJSdYCnDkk4Dx/it1TnK4MhbgawSaAr6uMBMAzXNEHOqhaHbhcZnCQHDuuDYVv7 nnZw== 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=SUBZs3HSsKFG4pgg9oraWuHwxJN9i6/jk8SlM+O/J1s=; b=NnaZQxYa4vV9tse9zS5y7gISNlkdoehCvMZx4iMOTRmdunKtD0f1IHP2KzYl8nx6ga x+6ejf2MHj/GAZkelwSo37QGs3T5kqfmKq2FZBP2blxmpCHDAuBRI7bOp7necI+JavgR AaODOjjNJVW/0VwrYIfItk3RARCXaT1151VVJ67+krmZ4cyYHneKvxNObkOlQ56Godo7 RRR+KASlamI5uM6DG2ixTKmyobgXVtJ76X/zcpn4iJnY//VJvW59Snb3+FbcSMbli1LK 579bCStCoY8iO/Vj+dMGbmY/ylAB3UWXsWPoCUcuYh/MnHb/Zph9SGixk3q5HfNYGOhY NrJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="npK/i2L0"; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-107164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107164-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b15-20020a63d80f000000b005dc85635271si9696623pgh.605.2024.03.19.00.28.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 00:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="npK/i2L0"; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-107164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107164-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6E90EB21AE2 for ; Tue, 19 Mar 2024 07:27:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D09FF5465C; Tue, 19 Mar 2024 07:27:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="npK/i2L0" 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 74EA653E28 for ; Tue, 19 Mar 2024 07:27:28 +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=1710833250; cv=none; b=HKaYzjrhAOSxVOr2uuuujQ5EtOzQfk+GVFnmphcpQwIEs0O8jrppweG3DXRCUOzIh5Mho8XEJq3oSMYatBsSo/O2bXxSmvH6I5tMv7nTmSymqiSdV1ggNXm/YrhK8NWipND+KrkezqYZOb38GN+Tkm5Vu+FVPJK3kWHuplW8xtE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710833250; c=relaxed/simple; bh=CKkaIB1VMOnmqCrBsV70ZTXEjY9urL8LUoJA5O5CNOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RwpvRNv4NMQRyWzR1HnqQEF6JBkoEd5A8+jHj5lhNMEXnsOpHInl0gDI2a0oqCkuIoGLthZa0I2yBW9+EBEi3ry/pCZBM7+8uva5+5eXQ9ea0oTgoTUsbx5VkwGsoCA+Qq8tDDTdYCst9sqUk8w1GmgrK54bVrb80FNDF4QbWK0= 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=npK/i2L0; 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.138]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3D8C6C80; Tue, 19 Mar 2024 08:26:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710833220; bh=CKkaIB1VMOnmqCrBsV70ZTXEjY9urL8LUoJA5O5CNOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=npK/i2L0CqGZpHecqJpEEJRaRxfvsgpgfm4LgyvabArFoQex9NcgYeKZpt1NwhrGa WT7ia80p6LAvOJzvLlwC67gsmPTOWi6VCo04zmLsEw+l1F0+MyDzYu5l9UZwGWcDT3 CdTqE3hWq/vd1ape1tthBYDdvc5vdpN8w/IEGk2s= From: Umang Jain To: Alexander Shiyan , Kieran Bingham , Sakari Ailus , open list , Dave Stevenson Cc: Umang Jain , Tommaso Merciai Subject: [PATCH v3 1/6] media: imx335: Support 2 or 4 lane operation modes Date: Tue, 19 Mar 2024 12:57:07 +0530 Message-ID: <20240319072712.133449-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240319072712.133449-1-umang.jain@ideasonboard.com> References: <20240319072712.133449-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