From patchwork Wed Jan 31 05:52:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 194499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1693045dyb; Tue, 30 Jan 2024 21:55:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGa+KHQzjPXyzlgdv/FzvtSuLxC1bBiUJ/cOqWI3qX65Fkam1tDqK1W+Ne1cfwhyQKzxGO7 X-Received: by 2002:a17:902:db11:b0:1d9:e2b:db9d with SMTP id m17-20020a170902db1100b001d90e2bdb9dmr821925plx.48.1706680553305; Tue, 30 Jan 2024 21:55:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706680553; cv=pass; d=google.com; s=arc-20160816; b=PXaNchf2hGjKscjBC1KYEn4pE64SeFE36R15Pn0m49uSnAOlHPuN/HLCXkfTtvCsyy oFHMESCpRYTdMNGGxy01fRmR/cHaK5oVzTqzIp3gR6hnIl24hRhkV7RVwtVeB4t0k6EM gjM0I2cS86SL8dDqU7H+5ryhfvY4BnlN6zvMqSndAExNsvNElKctWPNuEizrW9UIrf2R DWswgLWIybI4TQu5yCtsknmRxIWc6HU+/U0uokZVA+xRgS7Jh5gpKc/re3cGnckO4cVb eSy9/78F3br/txbzed7eBBdYnIIV/kSf42qpOGmp4pJlFH+tFGq9fYqrl2hyF5YANAWB T6UA== 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=B4dFBmaaS/0kbMd0qf/hL+eR1glOEOV9MeHD9U1G9Q8=; fh=ZnkTONEC4ArKhDM5gjXajMYZqUWJ8/aePXQFnXuGHUU=; b=ya1BM/zWXVBU2QkpLG66zG7yLa1lcYZPuBAnHysWWN2H5Zrxo4EpzHM9AJ3AX4NOVp uRCO26zJeqON0ablRBUaBzW6FOa9srLcUdfC0R2g4wXxerfpxDst8Da4gYfGGMqgOaxm kwysoIEjFOiS2T5CuNlzZfbHL9ciZXmfPh7lXhwsmMoVSBXj48ihpUgHl/qScLgsoy+7 qQ3ept/YVJx1ifDPpjLj978vUodz3aVAOnNiWht4AvfYrXYVIo4sTwHW7wp7p+v3v6fz gTrxpjEPDlO6W9Ezcjx98DU18Lb+6swjZghbuYKv8HdSk2QHENF3mIq0klO/ZHn9/0D+ Klgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=KK8UGB3I; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45790-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45790-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUei7DWkxFWCSqJW86G/dgBvCzkyitAv6DBrKPeiyIEay1BkRmfOOna4VL/5oviSGCcAs7iay5F0leF3sU4SjloKB8P3w== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y6-20020a170902700600b001d76f1ef460si8815426plk.175.2024.01.30.21.55.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:55:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45790-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=KK8UGB3I; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45790-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45790-ouuuleilei=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 9E2C6B26568 for ; Wed, 31 Jan 2024 05:54:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 044F4405F7; Wed, 31 Jan 2024 05:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KK8UGB3I" 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 60D143F8F0; Wed, 31 Jan 2024 05:52:25 +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=1706680348; cv=none; b=D9J8PaiiwLENOb+PPZoEzSUSV265Xq7/XXFaP7an49eqq+8ivKpYwoQoHP1S/psyDRJ02PWZjyouaXw5nn8+cC49+NvOumzrBH5AWwOYW7E8bAEH7mtAoEjNpueVNHAiDclKs4/Bt2+ckoARiRCGUDgIg9Hy+a01J0XUZYuuu1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706680348; c=relaxed/simple; bh=ma7dEcFPhHPYt1lVJga9B1+IwD8cgjTRXMmLiGdj1yk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aEeLK0CuOCGt0aXcMNJEtjH90i+vgrSUvQYtERmV1sYVVfyqoK/tH7kc3Zcv0Fdg1hVyPq+D3DYBRmCVmjYHMWBa3zPp1aWMTcC0V1/1bYuwJ8Q99XHtxWYwBrvwF45/VE5asWB/ntjbX/2HhS4mBOWi6kSOSz864z7JI/VWHhg= 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=KK8UGB3I; 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.206]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E9BD416CF; Wed, 31 Jan 2024 06:50:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706680259; bh=ma7dEcFPhHPYt1lVJga9B1+IwD8cgjTRXMmLiGdj1yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KK8UGB3Irw1MXc6ihmRj8+LXP785j+aMCvxV4oHT+OjOwK4t5uIWhO45N95cFGF3w GylscYeJ2N4vKGklOsTafsVM8ScyB4i21m3ku+po4NLqQ08CWGUpuic4KKBGWKLOU/ zozF4Yk20bJThpacHJzc89qR5Zqdd6AKZBB5kDc0= From: Umang Jain To: linux-media@vger.kernel.org Cc: Kieran Bingham , Mauro Carvalho Chehab , open list , Sakari Ailus , Umang Jain Subject: [PATCH v2 1/5] media: i2c: imx335: Drop setting of 0x3a00 register Date: Wed, 31 Jan 2024 11:22:04 +0530 Message-ID: <20240131055208.170934-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240131055208.170934-1-umang.jain@ideasonboard.com> References: <20240131055208.170934-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789584267543660265 X-GMAIL-MSGID: 1789584267543660265 Register 0x3a00 is a reserved field as per the IMX335 datasheet, hence shouldn't be set by the driver. Signed-off-by: Umang Jain --- drivers/media/i2c/imx335.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index 7a37eb327ff4..927b4806a5d7 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -249,7 +249,6 @@ static const struct imx335_reg mode_2592x1940_regs[] = { {0x3794, 0x7a}, {0x3796, 0xa1}, {0x37b0, 0x36}, - {0x3a00, 0x01}, }; static const struct imx335_reg raw10_framefmt_regs[] = { From patchwork Wed Jan 31 05:52:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 194502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1693873dyb; Tue, 30 Jan 2024 21:58:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyi7NZm2HBeDX6Kh86qUFDU4eT9c5vS5ECxs5jG3OGdI/Zcp4bIUWPGd2Jklmg1R0GizV6 X-Received: by 2002:a05:6830:1506:b0:6e1:14e7:c1b2 with SMTP id k6-20020a056830150600b006e114e7c1b2mr610662otp.31.1706680738103; Tue, 30 Jan 2024 21:58:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706680738; cv=pass; d=google.com; s=arc-20160816; b=isB+iMPegya53hA/4RMyMT9MLTGiETzTapDVGpaBZDfnjA3N8CuZ3wGmuc24y+NdK3 mDtg5JwUtpE1BgE1TwXeqWatUqYqwbpDi9FJMFAMkr57zLfu+2kP6fapTZeUo+3F1T6S ND0btyeUH2YfZvvqyr0+EOZKmj+JzX+RP4b0E5wGynSaG+EPHb97ig/xHevf5KI33rvE 3UWuOvsQD5eTkGXxWeCGR6M2kqRf7dDJSRkNAkCym7nEERD57CTZ5jzND+xBkdc15UT2 C7cemcF6D2lQBmWURJU0vBbFoPT/48SMTIIswMepAtZibIhIs1F2hND4e5Nwv3NREamk Ka+A== 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=hvBF3JpqAERoRRI9DvgFWT0ChKagTdW/qYyg8EahkjE=; fh=tLWoE25t4GLv+kbHK3ClVLiSmMqmDXc4h7n2UM+IYdA=; b=cDac1TKXAsbS4w7Hh5Jyn6G6W+P4G5Q/S3OIWvvgtgCC0vEl16Swr5vn0+1FzUSr0W x8W2KE9D+aaVNKI8eqhQ8VAqfS1/TjmIEofDctaUM7qflI7MjU2i43QLRNG5lhHcTvpM /UX9Cdyh4lgUOVbW2MKyZiTw5pJwLCrx7/4dIlGwi1nOhj3CEcWfRUtNrlHcDzc8SnTw xaPmZrNWgGaOrPizEiPu2+Yb4iyYPQX8hluBHTG59pOQspCe2ImgCHe+wAjQL08tJZlf WsPpIo/m1kHujVK01Eaq8IZ3fgebfkxDZ7mtdkMDUIJU0UAooLHw0s7IHPhbRwuu02E0 DyNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=XxR8jA1k; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45791-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45791-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVuLaDsY7b7Tq2UkfSxYqYfPFoZET9rIUGXDrtQKV9RDyuahP+i12CySu8Bi9Gcm1+dUq8W+NHmj2nuFkNTBl7axRzCmQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e17-20020a656791000000b005d5d32bf0cdsi8834299pgr.256.2024.01.30.21.58.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:58:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45791-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=XxR8jA1k; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45791-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45791-ouuuleilei=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 AC53FB2548C for ; Wed, 31 Jan 2024 05:54:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5287B40BF0; Wed, 31 Jan 2024 05:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XxR8jA1k" 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 B87643FB10; Wed, 31 Jan 2024 05:52:27 +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=1706680349; cv=none; b=VrEpYACJCdMvC2fMrE1otntYoHGV6/DlWCf7iK9LVbPocJJmoMMT55x6pKVM7G5fYK8I98f7ArLvZHAcUdMNpxL8Mre0dYNuzEhidnFY3KjEldR16CGrrOBJCns98xDwU8OcBhdpaPcjiJ6667mADvCzBQBliEOw+B/ReGCFp4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706680349; c=relaxed/simple; bh=KVoYFTXgiQEorCS81o3nouTGpkktg/UDGZx3Jyex/DM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oqaJxKq3qbWrZYybCukCxs4WOadlDxn/Sr9mdyT4xabhRfWQAcnOE0iEeBr/CW0L1r6oa8x3yLIp4IdqH7iC5bjZyc7UJ3u9U9p5ytaORGe3p8aLnmbtSfKg7Q7Xfuknc+xIF0AH3Lfdc7kMbh9Ou+bXoER8l5WsrXTNFR6YXAo= 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=XxR8jA1k; 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.206]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 26C211803; Wed, 31 Jan 2024 06:50:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706680261; bh=KVoYFTXgiQEorCS81o3nouTGpkktg/UDGZx3Jyex/DM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XxR8jA1kVtrydQiLOoWH6ZqGHfUV+pgXjLp09MfHYs9xDAO6sURVwXvW2anSd5Cj+ ixh/nVCrfkcqaVP3p2VANjXlhLKt3zUB3PDZ+XfKIYrQzq5Qe5DC9GEYvV1BvjzgJv U8+XPvYxmjyFWjhAHS/AUa6gcZLysnexNpmQXgZ8= From: Umang Jain To: linux-media@vger.kernel.org Cc: Kieran Bingham , Mauro Carvalho Chehab , open list , Sakari Ailus , Umang Jain Subject: [PATCH v2 2/5] media: imx335: Use v4l2_link_freq_to_bitmap helper Date: Wed, 31 Jan 2024 11:22:05 +0530 Message-ID: <20240131055208.170934-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240131055208.170934-1-umang.jain@ideasonboard.com> References: <20240131055208.170934-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789584461804072781 X-GMAIL-MSGID: 1789584461804072781 Use the v4l2_link_freq_to_bitmap() helper to figure out which driver-supported link frequencies can be used on a given system. Signed-off-by: Umang Jain --- drivers/media/i2c/imx335.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index 927b4806a5d7..73691069556f 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -49,7 +49,7 @@ #define IMX335_INCLK_RATE 24000000 /* CSI2 HW configuration */ -#define IMX335_LINK_FREQ 594000000 +#define IMX335_LINK_FREQ 594000000LL #define IMX335_NUM_DATA_LANES 4 #define IMX335_REG_MIN 0x00 @@ -134,6 +134,7 @@ struct imx335_mode { * @vblank: Vertical blanking in lines * @cur_mode: Pointer to current selected sensor mode * @mutex: Mutex for serializing sensor controls + * @link_freq_bitmap: Menu bitmap for link_freq_ctrl * @cur_mbus_code: Currently selected media bus format code */ struct imx335 { @@ -157,6 +158,7 @@ struct imx335 { u32 vblank; const struct imx335_mode *cur_mode; struct mutex mutex; + unsigned long link_freq_bitmap; u32 cur_mbus_code; }; @@ -404,7 +406,8 @@ static int imx335_update_controls(struct imx335 *imx335, { int ret; - ret = __v4l2_ctrl_s_ctrl(imx335->link_freq_ctrl, mode->link_freq_idx); + ret = __v4l2_ctrl_s_ctrl(imx335->link_freq_ctrl, + __ffs(imx335->link_freq_bitmap)); if (ret) return ret; @@ -690,6 +693,13 @@ static int imx335_init_state(struct v4l2_subdev *sd, fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; imx335_fill_pad_format(imx335, &supported_mode, &fmt); + mutex_lock(&imx335->mutex); + __v4l2_ctrl_modify_range(imx335->link_freq_ctrl, 0, + __fls(imx335->link_freq_bitmap), + ~(imx335->link_freq_bitmap), + __ffs(imx335->link_freq_bitmap)); + mutex_unlock(&imx335->mutex); + return imx335_set_pad_format(sd, sd_state, &fmt); } @@ -938,19 +948,10 @@ static int imx335_parse_hw_config(struct imx335 *imx335) goto done_endpoint_free; } - if (!bus_cfg.nr_of_link_frequencies) { - dev_err(imx335->dev, "no link frequencies defined\n"); - ret = -EINVAL; - goto done_endpoint_free; - } - - for (i = 0; i < bus_cfg.nr_of_link_frequencies; i++) - if (bus_cfg.link_frequencies[i] == IMX335_LINK_FREQ) - goto done_endpoint_free; - - dev_err(imx335->dev, "no compatible link frequencies found\n"); - - ret = -EINVAL; + ret = v4l2_link_freq_to_bitmap(imx335->dev, bus_cfg.link_frequencies, + bus_cfg.nr_of_link_frequencies, + link_freq, ARRAY_SIZE(link_freq), + &imx335->link_freq_bitmap); done_endpoint_free: v4l2_fwnode_endpoint_free(&bus_cfg); @@ -1098,9 +1099,8 @@ static int imx335_init_controls(struct imx335 *imx335) imx335->link_freq_ctrl = v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx335_ctrl_ops, V4L2_CID_LINK_FREQ, - ARRAY_SIZE(link_freq) - - 1, - mode->link_freq_idx, + __fls(imx335->link_freq_bitmap), + __ffs(imx335->link_freq_bitmap), link_freq); if (imx335->link_freq_ctrl) imx335->link_freq_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; From patchwork Wed Jan 31 05:52:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 194496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1693001dyb; Tue, 30 Jan 2024 21:55:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmGDtlouLbG3yITNGd10O9pE+6zS6WcxN2MRT6HId1AgreepZKjAevvRBToxzTo11iczb8 X-Received: by 2002:a05:622a:1007:b0:42a:b360:fcce with SMTP id d7-20020a05622a100700b0042ab360fccemr1123392qte.23.1706680543467; Tue, 30 Jan 2024 21:55:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706680543; cv=pass; d=google.com; s=arc-20160816; b=rFKkTmlOJz3ieQyrA55mogJC9KrPZ9/ugnpzIr+3dyN9C9m10OgMHCarFz26LtEdXv KMKIm0xYe9HV8sIEuR+Za5JjE2O1LMPWcBiOyH67XIaTZu9zpd+2c++wFEOsDOktC/te Kw0ibJbpXuTh7RHzEFTozHevcXS9/9AwsFTDLunrDA1Bvu2IZyZm57GvCBpTm0IhU0HL AP1Jrm0plkVrhNZOWMZx5mIvf5hMA+s/qa20ggajxRqsjgkJN7ySmBOMru7kEH+jmg8x UUd2ePj3kAliKFai5JHU/MLS9td4FtkHFmQRV5Mgb6vsHdRDK4lv/pJwWEge2q3wSJ11 oMeA== 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=RAf1ErCpKJ4uUX39f74sRVA4wR2Icog9ebe4aXCJ5VU=; fh=N/isyBZilzv4oK/4Xrw8Tt0b+9+6lXbtiIQe+m5pw18=; b=sZuYq3Uq6CGojWj4LtjK55ECMYnrwIiZxTZmiMWAykDAhno+EMBuiFK9qb6OfafsZ/ WHG+fWYBh/sAbzwCO+IcQHpgMDcm1U9QxUK9VNZeScpmrR7VqeDsvW7Eh24l6mtj9vRT HmMPJcbBHm6sZhVHrxHZZ+RUGXgQhdaWlKnTBbJlBO05v25UTA3m4eSz2WaFiqxzfd+7 OwdPHWQ6n8GjTotg3B+UUxQbzgYokZS35yQdFIZg1hGMDHEa+EMqOSZTDD/wg9CqcFFC tAcqFMVsA+e40lvVRnud8ollSZuYfjDqioGx6LsuEUMnE9JSKVJNWpJhz194tZfTCz1i KigA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=oI4lxaXY; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45793-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45793-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVVic4cH0JQ+8noxCMvP23KJA6rV7gw0hJDz25xHKssRYFwtnh/pbR2bnPXCLuAsKLanC1Pkn+3VnW/fEYY36MZQXbIbQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v18-20020a05622a015200b0042be5d2455csi840953qtw.303.2024.01.30.21.55.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:55:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45793-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=oI4lxaXY; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45793-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45793-ouuuleilei=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 2CD4E1C24879 for ; Wed, 31 Jan 2024 05:55:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC19245007; Wed, 31 Jan 2024 05:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oI4lxaXY" 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 E143C3EA6B; Wed, 31 Jan 2024 05:52:29 +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=1706680351; cv=none; b=ebA/CmK6xB2d6eUstjAUGudpXIMhsuD12L7RPhLtkueIjT0subarDNc0Ontnt0yJcf4MS5tjuZkyF7jZrr1FqpgpYepDkss8nZ4neQjzIk0mU/YE+syAZ8DMNnNWRNb7cE6im99n29Hd/fO0nq2K6196vwTEaHQA4QoJA6S1Yy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706680351; c=relaxed/simple; bh=+81kCPpzrGbUT4UrtdbXKXI39jv/j4e7Ovmg+k42eK8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SllVXT6jsctywFfmp3YqBpp0D33y+ivGtpG37/piAAk/hkOHfvlt1sU88b8vkRO4XEHaGz36jBl6X0qtZa6zsjDj5LXSE7a/caU0U856whQuHDcysAN8gJ39tDP0lOPX0Cbj3+np6aTss3o5F4gSe0r8itAOLBvsJENQC18HLF0= 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=oI4lxaXY; 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.206]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 48DA0605A; Wed, 31 Jan 2024 06:51:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706680263; bh=+81kCPpzrGbUT4UrtdbXKXI39jv/j4e7Ovmg+k42eK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oI4lxaXYFWgDVlELgBOBp4JXz787CjI69XGZa5yywA3+oHVXhir93xn+2XGR50IXw SQi8SRNrOfbwWu5EIA46JUWRSyxnLOK+dT+8YPsoALjTu2kDYN7ED+S2EsFVgoPiDn 4ckuAdKhW1JTCk9Fx81N+mLkswpZCjd3kZ5pX2Jg= From: Umang Jain To: linux-media@vger.kernel.org Cc: Kieran Bingham , Mauro Carvalho Chehab , open list , Sakari Ailus , Umang Jain Subject: [PATCH v2 3/5] media: i2c: imx335: Support multiple link frequency Date: Wed, 31 Jan 2024 11:22:06 +0530 Message-ID: <20240131055208.170934-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240131055208.170934-1-umang.jain@ideasonboard.com> References: <20240131055208.170934-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789584257377927258 X-GMAIL-MSGID: 1789584257377927258 Support link frequency of 445MHz in addition to 594MHz. Break out the register set specific to each data lane rate and also add the general timing register set corresponding to the each data lane rate. Signed-off-by: Umang Jain --- drivers/media/i2c/imx335.c | 84 +++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index 73691069556f..ca3eab50f714 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -49,7 +49,9 @@ #define IMX335_INCLK_RATE 24000000 /* CSI2 HW configuration */ -#define IMX335_LINK_FREQ 594000000LL +#define IMX335_LINK_FREQ_594MHz 594000000LL +#define IMX335_LINK_FREQ_445MHz 445500000LL + #define IMX335_NUM_DATA_LANES 4 #define IMX335_REG_MIN 0x00 @@ -99,7 +101,6 @@ static const char * const imx335_supply_name[] = { * @vblank_min: Minimum vertical blanking in lines * @vblank_max: Maximum vertical blanking in lines * @pclk: Sensor pixel clock - * @link_freq_idx: Link frequency index * @reg_list: Register list for sensor mode */ struct imx335_mode { @@ -111,7 +112,6 @@ struct imx335_mode { u32 vblank_min; u32 vblank_max; u64 pclk; - u32 link_freq_idx; struct imx335_reg_list reg_list; }; @@ -162,16 +162,10 @@ struct imx335 { u32 cur_mbus_code; }; -static const s64 link_freq[] = { - IMX335_LINK_FREQ, -}; - /* Sensor mode registers */ static const struct imx335_reg mode_2592x1940_regs[] = { {0x3000, 0x01}, {0x3002, 0x00}, - {0x300c, 0x3b}, - {0x300d, 0x2a}, {0x3018, 0x04}, {0x302c, 0x3c}, {0x302e, 0x20}, @@ -179,10 +173,6 @@ static const struct imx335_reg mode_2592x1940_regs[] = { {0x3074, 0xc8}, {0x3076, 0x28}, {0x304c, 0x00}, - {0x314c, 0xc6}, - {0x315a, 0x02}, - {0x3168, 0xa0}, - {0x316a, 0x7e}, {0x31a1, 0x00}, {0x3288, 0x21}, {0x328a, 0x02}, @@ -267,6 +257,65 @@ static const struct imx335_reg raw12_framefmt_regs[] = { {0x341d, 0x00}, }; +static const struct imx335_reg mipi_data_rate_1188Mbps[] = { + {0x300c, 0x3b}, + {0x300d, 0x2a}, + {0x314c, 0xc6}, + {0x314d, 0x00}, + {0x315a, 0x02}, + {0x3168, 0xa0}, + {0x316a, 0x7e}, + {0x319e, 0x01}, + {0x3a18, 0x8f}, + {0x3a1a, 0x4f}, + {0x3a1c, 0x47}, + {0x3a1e, 0x37}, + {0x3a1f, 0x01}, + {0x3a20, 0x4f}, + {0x3a22, 0x87}, + {0x3a24, 0x4f}, + {0x3a26, 0x7f}, + {0x3a28, 0x3f}, +}; + +static const struct imx335_reg mipi_data_rate_891Mbps[] = { + {0x300c, 0x3b}, + {0x300d, 0x2a}, + {0x314c, 0x29}, + {0x314d, 0x01}, + {0x315a, 0x06}, + {0x3168, 0xa0}, + {0x316a, 0x7e}, + {0x319e, 0x02}, + {0x3a18, 0x7f}, + {0x3a1a, 0x37}, + {0x3a1c, 0x37}, + {0x3a1e, 0xf7}, + {0x3a20, 0x3f}, + {0x3a22, 0x6f}, + {0x3a24, 0x3f}, + {0x3a26, 0x5f}, + {0x3a28, 0x2f}, +}; + +static const s64 link_freq[] = { + /* Corresponds to 1188Mbps data lane rate */ + IMX335_LINK_FREQ_594MHz, + /* Corresponds to 891Mbps data lane rate */ + IMX335_LINK_FREQ_445MHz, +}; + +static const struct imx335_reg_list link_freq_reglist[] = { + { + .num_of_regs = ARRAY_SIZE(mipi_data_rate_1188Mbps), + .regs = mipi_data_rate_1188Mbps, + }, + { + .num_of_regs = ARRAY_SIZE(mipi_data_rate_891Mbps), + .regs = mipi_data_rate_891Mbps, + }, +}; + static const u32 imx335_mbus_codes[] = { MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB10_1X10, @@ -281,7 +330,6 @@ static const struct imx335_mode supported_mode = { .vblank_min = 2560, .vblank_max = 133060, .pclk = 396000000, - .link_freq_idx = 0, .reg_list = { .num_of_regs = ARRAY_SIZE(mode_2592x1940_regs), .regs = mode_2592x1940_regs, @@ -764,6 +812,14 @@ static int imx335_start_streaming(struct imx335 *imx335) const struct imx335_reg_list *reg_list; int ret; + /* Setup PLL */ + reg_list = &link_freq_reglist[__ffs(imx335->link_freq_bitmap)]; + ret = imx335_write_regs(imx335, reg_list->regs, reg_list->num_of_regs); + if (ret) { + dev_err(imx335->dev, "%s failed to set plls\n", __func__); + return ret; + } + /* Write sensor mode registers */ reg_list = &imx335->cur_mode->reg_list; ret = imx335_write_regs(imx335, reg_list->regs, From patchwork Wed Jan 31 05:52:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 194495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1692861dyb; Tue, 30 Jan 2024 21:55:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzRmBFq9y9Gdugn2qJoivSlacamlEHT9EZlfRdfqQfgcp07Zx83qtH7A8ChEmfN2T7Smx9 X-Received: by 2002:a81:72c2:0:b0:5fb:da77:af07 with SMTP id n185-20020a8172c2000000b005fbda77af07mr496362ywc.32.1706680512326; Tue, 30 Jan 2024 21:55:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706680512; cv=pass; d=google.com; s=arc-20160816; b=DqmgGOVkoiSKmy59kDOWImni4VFkDJNKCWjFHvQRJjXdxFeWc0X5DfQ4vMWXX+27cX q5QFQhs43PbmmthCanYlPoTqqWYpCV9tDIfdFTQXi3IptQP5/JzF60UGGDUA05J7FKJ7 BfPFIG2/eeqt08LjFV8yDb4ufi/3l8z83V6Gp8CGHu0Enf+Y5jcJaNS+0D0o6YG9YxxH Bn7a/MB1kARPILJK8hkRv7OdZUacyCGaaoDti4cfRNgcfUceNagz6RsdcJEOXBivu4ZV 4w4VCUKDc10X/1asQtlPrNrL0ko3qoE+MDFpYi+mZwaVKjePkThRgcgUhRpL2T/XkkN9 alAg== 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=ftbLP5hAGtYHA2CennUXgBypmGvFUddMtohhylnbJ9I=; fh=uMoo6AE94P/xAsYMqdDxJBeqW1iBLd8ufc7bdFOmgfM=; b=HiY3sQJbmQX13CUVcNwfjq9VmLXRhPJl+2EZJDxKEphDMLDpbjoEhq+s2KxYxfF3ny foK86vgjh7Awyn3aTYZLyqjC2eGdteSmVpf6by67oIj9QoEkd/pmAYoBJw4BU5zDumuz KOdPNxwTdchhyeFRLbNisVJY5YjPF7CRWmaBMB42cIKW/CjQslfSQ9T0s5bc//EWHcW6 cJyrxzyeqccfyIYBXYX+1FjlkSWuasbBR0mgb9JsuZXsWQrhZK9KZeuR0eYeduHMurMi m9XwKdzG1KkraXG3XYSbTULl9pbDCFn7RcDzsniQlSLlMEIKYd4bFFTyo/vhgzwVPcKg 9z9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Q6A6S9nu; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45794-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45794-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUC5fFrzPaY7ZKr6W8HXW4kUnN1MaH2pPeIDdnkDSQZ4mlvbyG/fxD9sHkjpptWAUeC+dxO+K/LL6ZqrVvPkJO7/Nr+bg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d30-20020a63735e000000b005d8c2880a7fsi5870469pgn.59.2024.01.30.21.55.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:55:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45794-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=Q6A6S9nu; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45794-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45794-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1484E281FD9 for ; Wed, 31 Jan 2024 05:55:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A48B45BED; Wed, 31 Jan 2024 05:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Q6A6S9nu" 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 DC0B43FB14; Wed, 31 Jan 2024 05:52:30 +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=1706680352; cv=none; b=qKWf1PNmilGFaFmtF8GZ+T991mHMlGZqhA1dffCiAfLyXqsi+qOA8Tj7QAYIsD51g0zB8tclC+jhLQ7JylRVkIt7lGpZ3gZhihOX0YiVcPcubLEh6x3PqgN7NqB5tL2jsjTuSUHgtYFy6wyORpEeP9mg1HYPsiRMyO1UrAuramg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706680352; c=relaxed/simple; bh=vdKoqMvA7LSgk/e2WNUBvI9QcKVaD8d7AAKwOmSxsjM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DagYPte9GoseZmiakUi2PPZAHjXfXtYsXc/2VjtdiCwT1Wai6myK+yDTZ2KfC2q9JIgXAjxAowdzSs8pummhoV5E3iNALqmnpFlO7mDy5ssyzHframuGxzghPNwpg0vFRhJYWL4/obJ2PAm5FZNxbWyLHdLntvZU8DKwhfUVfWs= 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=Q6A6S9nu; 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.206]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 716C6613C; Wed, 31 Jan 2024 06:51:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706680266; bh=vdKoqMvA7LSgk/e2WNUBvI9QcKVaD8d7AAKwOmSxsjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6A6S9nu04THOw1LPI+7w0Haoocb3VyKrhOGuNiOodzrEKkipxJdhFtg/1GIJtbH4 LeXABsvHztmnAh/JuJRIVxFPmbCieK/VL8ci02cmAyvimeL5hjhjedlSV5EYIfdkBI s7dl5dYzU4UqR3r5xtT6eLSvAtlgKkoJ9d3VfhAc= From: Umang Jain To: linux-media@vger.kernel.org Cc: Kieran Bingham , Mauro Carvalho Chehab , open list , Sakari Ailus , Umang Jain Subject: [PATCH v2 4/5] media: i2c: imx335: Refactor power sequence to set controls Date: Wed, 31 Jan 2024 11:22:07 +0530 Message-ID: <20240131055208.170934-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240131055208.170934-1-umang.jain@ideasonboard.com> References: <20240131055208.170934-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789584224921525352 X-GMAIL-MSGID: 1789584224921525352 Additional controls might require the sensor to be powered up to set the control value. Currently, only the exposure control powers up the sensor. Move the power up sequence out of the switch-case block. In a subsequent patch, test pattern control will be added that needs the sensor to be powered up. Hence, refactor the power sequence to be present outside the switch-case block. The VBLANK control is also moved out of the switch-case in order to be handled early on, to propagate the changes to other controls. Signed-off-by: Umang Jain --- drivers/media/i2c/imx335.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index ca3eab50f714..250b7136048d 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -526,26 +526,31 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) u32 exposure; int ret; - switch (ctrl->id) { - case V4L2_CID_VBLANK: + /* Propagate change of current control to all related controls */ + if (ctrl->id == V4L2_CID_VBLANK) { imx335->vblank = imx335->vblank_ctrl->val; dev_dbg(imx335->dev, "Received vblank %u, new lpfr %u\n", imx335->vblank, imx335->vblank + imx335->cur_mode->height); - ret = __v4l2_ctrl_modify_range(imx335->exp_ctrl, - IMX335_EXPOSURE_MIN, - imx335->vblank + - imx335->cur_mode->height - - IMX335_EXPOSURE_OFFSET, - 1, IMX335_EXPOSURE_DEFAULT); - break; - case V4L2_CID_EXPOSURE: - /* Set controls only if sensor is in power on state */ - if (!pm_runtime_get_if_in_use(imx335->dev)) - return 0; + return __v4l2_ctrl_modify_range(imx335->exp_ctrl, + IMX335_EXPOSURE_MIN, + imx335->vblank + + imx335->cur_mode->height - + IMX335_EXPOSURE_OFFSET, + 1, IMX335_EXPOSURE_DEFAULT); + } + + /* + * Applying V4L2 control value only happens + * when power is up for streaming. + */ + if (pm_runtime_get_if_in_use(imx335->dev) == 0) + return 0; + switch (ctrl->id) { + case V4L2_CID_EXPOSURE: exposure = ctrl->val; analog_gain = imx335->again_ctrl->val; @@ -554,14 +559,14 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) ret = imx335_update_exp_gain(imx335, exposure, analog_gain); - pm_runtime_put(imx335->dev); - break; default: dev_err(imx335->dev, "Invalid control %d\n", ctrl->id); ret = -EINVAL; } + pm_runtime_put(imx335->dev); + return ret; } From patchwork Wed Jan 31 05:52:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 194498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1693034dyb; Tue, 30 Jan 2024 21:55:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4kDiITWlwZuYNu6TF8XT1Bc240yJs4aIg0bV/6HKU9pSJ+k/wlp+g4y6nrNb4JHbwLXoD X-Received: by 2002:ac8:5842:0:b0:42a:9aa9:8f92 with SMTP id h2-20020ac85842000000b0042a9aa98f92mr886952qth.60.1706680549297; Tue, 30 Jan 2024 21:55:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706680549; cv=pass; d=google.com; s=arc-20160816; b=M+oxNyu0etii9Q2NAR07oTdqtvxnt9EIC9XYZuVnM39wC8eBAfQEUoIrb1fQ5TbqUE fMzV3flKrUTBhjzvIulNOfVfXzLh6fYptiMJ+l0SjguGyOTVJ0kOrHFNRA6GUFmBxkWH q+Jrd7GJHMmnBwz+MtpmreIozZeACE2Iceg54wpbEX3z6SOtqlqgWNUM+A8tow1DOW06 f81Z+G0QeY/KVxZp/eRQrhzDm/6QcYvVGP/FlzPGblWggsPLRl9wElKdQi8tPBi3GCJI SaXht68gaDKP+43LjMUvxpMPJ601eIzWEgB6cBKsZ4j0TP5cfMsoKSi9k6FCuOkDZ2mP QTWQ== 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=VLku7+AVr6Li7ZzkoTyR3r6vgSuSzwq+av76aYTKZ5E=; fh=/wk/TOUC780vyHaH2NTkzTCHVEz6Cxd0PmcRCglqwTs=; b=D5d5ym3N70pCMJLQVkgia/7nLcYkRIJTf+kcA4/9G6uhPFb9NNdrZfA1n8rwGBc7ap 50SGLqxjDuQkGe592AfhYe7TwwjKpY3OZFKym1/NSEQR362qL6J+SMCjpZZMMFBXWn2u 6O9HsN0WPceAE0LXa3Sdu72cePAkYQwi6RIMKaBCdwcANG9RUirQWn077cLAGA+gxlM9 CFlQton07UR2ATI3qu+QkKPVuncM4Gkl9WZrzyEMdYPSPFaYhojPjbH9GUYsymj5zYXJ R8sqlh6Cn6seTmXiBGZ4zrMV3V/bopiNijkf/yiPG3w2XDBvI5vYjUXPEBcbGF5Ey3T+ 3jeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=VbhW2nqf; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45795-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45795-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXUZK1CY11y8zKfLm0kTg1ljbyGBjmosSqeHWIb6ae9wIklf4npJx6EiiPBuzJ9Qq77H3jxsLX54P7RTujbqKhkGtZ6Ow== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j22-20020ac85c56000000b0042aa2da4293si6573761qtj.117.2024.01.30.21.55.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:55:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45795-ouuuleilei=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=VbhW2nqf; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-45795-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45795-ouuuleilei=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 D94501C2682E for ; Wed, 31 Jan 2024 05:55:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77F3B46521; Wed, 31 Jan 2024 05:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VbhW2nqf" 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 8439541766; Wed, 31 Jan 2024 05:52:33 +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=1706680355; cv=none; b=ot1fQHholw1LRkDJ0MnOn3mxzJAMhI+IIPAs7c9gwnv7Djgy8NTU8C2wDWlhLa25+m4Ln8vb5BZWv8LC53Q905fgYz7M0HjyPkmxfW3iEojFdtjXK3IspiDPI4dUyFT3/iKn/C2zzZLy/0ZAUooheNsGqr7PMGY1tthrdWGWYwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706680355; c=relaxed/simple; bh=yXS+KNTgFczxaukcxvwvOc9qcDyw663NWCmbbQpW/j4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VU70tMfBm3uBorYBIuEYG3CUjeJjysWsPV1JytsKV4+gt8LTj54LK8TM8TnAEb3A8ifo4BQ+HusllnICCngAG0ZYEFz8btqbR1pQr1R2f8JCmhIDsxVi3oQFuAAzjlzT4v5mrjdPjaD739oErel1FG/0CBuSmsy58eltmHqAw5I= 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=VbhW2nqf; 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.206]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 91DBA6057; Wed, 31 Jan 2024 06:51:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1706680268; bh=yXS+KNTgFczxaukcxvwvOc9qcDyw663NWCmbbQpW/j4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VbhW2nqfiEHQA4Ml3Yad1FAvJLC/072RJWw073uZMtLOv0RvJ8nBMSlBSwlQw2PVi f7TwLNjw1XwiLPwMSaXuuR608GMkQpNu8YE7qnISmtTinCVBftvkLFnRSVBJHYAW1m LDtL8Bt1Zs87NHp9Yo9ffcXGFlJbqBxlK97kUcoE= From: Umang Jain To: linux-media@vger.kernel.org Cc: Kieran Bingham , Mauro Carvalho Chehab , open list , Sakari Ailus , Matthias Fend , Umang Jain Subject: [PATCH v2 5/5] media: i2c: imx335: Add support for test pattern generator Date: Wed, 31 Jan 2024 11:22:08 +0530 Message-ID: <20240131055208.170934-6-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240131055208.170934-1-umang.jain@ideasonboard.com> References: <20240131055208.170934-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789584263705036291 X-GMAIL-MSGID: 1789584263705036291 From: Matthias Fend Add support for the sensor's test pattern generator. Signed-off-by: Matthias Fend Signed-off-by: Kieran Bingham Signed-off-by: Umang Jain --- drivers/media/i2c/imx335.c | 102 ++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index 250b7136048d..a003da8a81b1 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -45,6 +45,21 @@ /* Group hold register */ #define IMX335_REG_HOLD 0x3001 +/* Test pattern generator */ +#define IMX335_REG_TPG 0x329e +#define IMX335_TPG_ALL_000 0 +#define IMX335_TPG_ALL_FFF 1 +#define IMX335_TPG_ALL_555 2 +#define IMX335_TPG_ALL_AAA 3 +#define IMX335_TPG_TOG_555_AAA 4 +#define IMX335_TPG_TOG_AAA_555 5 +#define IMX335_TPG_TOG_000_555 6 +#define IMX335_TPG_TOG_555_000 7 +#define IMX335_TPG_TOG_000_FFF 8 +#define IMX335_TPG_TOG_FFF_000 9 +#define IMX335_TPG_H_COLOR_BARS 10 +#define IMX335_TPG_V_COLOR_BARS 11 + /* Input clock rate */ #define IMX335_INCLK_RATE 24000000 @@ -162,6 +177,38 @@ struct imx335 { u32 cur_mbus_code; }; +static const char * const imx335_tpg_menu[] = { + "Disabled", + "All 000h", + "All FFFh", + "All 555h", + "All AAAh", + "Toggle 555/AAAh", + "Toggle AAA/555h", + "Toggle 000/555h", + "Toggle 555/000h", + "Toggle 000/FFFh", + "Toggle FFF/000h", + "Horizontal color bars", + "Vertical color bars", +}; + +static const int imx335_tpg_val[] = { + IMX335_TPG_ALL_000, + IMX335_TPG_ALL_000, + IMX335_TPG_ALL_FFF, + IMX335_TPG_ALL_555, + IMX335_TPG_ALL_AAA, + IMX335_TPG_TOG_555_AAA, + IMX335_TPG_TOG_AAA_555, + IMX335_TPG_TOG_000_555, + IMX335_TPG_TOG_555_000, + IMX335_TPG_TOG_000_FFF, + IMX335_TPG_TOG_FFF_000, + IMX335_TPG_H_COLOR_BARS, + IMX335_TPG_V_COLOR_BARS, +}; + /* Sensor mode registers */ static const struct imx335_reg mode_2592x1940_regs[] = { {0x3000, 0x01}, @@ -506,6 +553,49 @@ static int imx335_update_exp_gain(struct imx335 *imx335, u32 exposure, u32 gain) return ret; } +static int imx335_update_test_pattern(struct imx335 *imx335, u32 pattern_index) +{ + int ret; + + if (pattern_index >= ARRAY_SIZE(imx335_tpg_val)) + return -EINVAL; + + if (pattern_index) { + const struct imx335_reg tpg_enable_regs[] = { + { 0x3148, 0x10 }, + { 0x3280, 0x00 }, + { 0x329c, 0x01 }, + { 0x32a0, 0x11 }, + { 0x3302, 0x00 }, + { 0x3303, 0x00 }, + { 0x336c, 0x00 }, + }; + + ret = imx335_write_reg(imx335, IMX335_REG_TPG, 1, + imx335_tpg_val[pattern_index]); + if (ret) + return ret; + + ret = imx335_write_regs(imx335, tpg_enable_regs, + ARRAY_SIZE(tpg_enable_regs)); + } else { + const struct imx335_reg tpg_disable_regs[] = { + { 0x3148, 0x00 }, + { 0x3280, 0x01 }, + { 0x329c, 0x00 }, + { 0x32a0, 0x10 }, + { 0x3302, 0x32 }, + { 0x3303, 0x00 }, + { 0x336c, 0x01 }, + }; + + ret = imx335_write_regs(imx335, tpg_disable_regs, + ARRAY_SIZE(tpg_disable_regs)); + } + + return ret; +} + /** * imx335_set_ctrl() - Set subdevice control * @ctrl: pointer to v4l2_ctrl structure @@ -559,6 +649,10 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl) ret = imx335_update_exp_gain(imx335, exposure, analog_gain); + break; + case V4L2_CID_TEST_PATTERN: + ret = imx335_update_test_pattern(imx335, ctrl->val); + break; default: dev_err(imx335->dev, "Invalid control %d\n", ctrl->id); @@ -1116,7 +1210,7 @@ static int imx335_init_controls(struct imx335 *imx335) u32 lpfr; int ret; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 6); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 7); if (ret) return ret; @@ -1150,6 +1244,12 @@ static int imx335_init_controls(struct imx335 *imx335) mode->vblank_max, 1, mode->vblank); + v4l2_ctrl_new_std_menu_items(ctrl_hdlr, + &imx335_ctrl_ops, + V4L2_CID_TEST_PATTERN, + ARRAY_SIZE(imx335_tpg_menu) - 1, + 0, 0, imx335_tpg_menu); + /* Read only controls */ imx335->pclk_ctrl = v4l2_ctrl_new_std(ctrl_hdlr, &imx335_ctrl_ops,