From patchwork Thu Dec 19 18:22:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11304237 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16DE6921 for ; Thu, 19 Dec 2019 18:23:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CEF72222C2 for ; Thu, 19 Dec 2019 18:23:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jzS7xc+K"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LkFxJRzp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEF72222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=y+tLa8ZqS9UcXJx5Kqw58DEIDJvBQi7Ao/i8RNGCfwY=; b=jzS7xc+KDZZP7RmUp2i0v/a2K8 1alAvIuje+tM05iWZD+63eAntPMeU2YFpjckqwZQtU9nbh52GFnQU6BRRbdadPxUx6KSozcY4Pq6A gLOtqfMahmT/FMUKLVybdXoyDg1nTgmgdA6lZrZgP7gR+lFkFhkfQ33aQnyBwoINspbatuhWQuInG S/Ac4iTatiF+BTrYNQvNCv7Z1rk49gHnW0ZC/XQX+MWA/9xvrhmvINeL8UO1K1dpCRkynqNik3cE0 EoBX1fjdpHSMGv0rW68x24nOW6xPfloWaLw6SNCZUZvZq3kDQ4wi8soiGrhDiLm3rXPeh1edUklXK xOaMYlcw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0S1-00014d-0s; Thu, 19 Dec 2019 18:23:05 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0Rn-0000rJ-Lv for linux-arm-kernel@lists.infradead.org; Thu, 19 Dec 2019 18:22:53 +0000 Received: by mail-pj1-x1044.google.com with SMTP id t101so2916109pjb.4 for ; Thu, 19 Dec 2019 10:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zwGoLngI+NuehCxqLPOV9F/7m9EMr7gKWrCKtqW4Jcw=; b=LkFxJRzpxgrqWkDu9NIq14PtAkP7KD2Ey8PxhUOdqF3q1prp7GYNBZmv8MSO/qEczZ 2u9Kg15va+H8l5/rAO/6/yc9XvNmBHw23WDrKmXwASTEOPCYS9BJXNNc49UoVjdF/f/9 WDmz+ZLfwMnyUgxinx7JSl2NztqCZoYDQxIdElK2CJxoQd5ES0NyFZttBLxQdxKgVEEn iBbngNy+1we0hSM0CN0Bmss0lX3gKOtDzIiynlVWFUAS2o0RtcJWB0MA5utzG8J5F80g nQHh6BelnPRRBNkJE7Bk0EduSn/Lfn3bWiLMUxXvH/XrkIB/KZaFSkKB62LX00h1pjjf pdLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zwGoLngI+NuehCxqLPOV9F/7m9EMr7gKWrCKtqW4Jcw=; b=daIEAzWu/aPVcTuoO5dxWRS1rbKwM1XNcPZZN03JModmFiKvVwCHF4ZQqQaDPqfhNB 2cPrZTnupchR2WDs2tPFYapWQqS807rhFUPLAnljcBML6gjOnUSV/gLUdy5ALuJ+Sriy boyrH4lx15/U3K4yjIbq5pAf0NtAij/pyRLYrLSVMPBEMg7d4/RJYcFNbHP/aYg/NaG8 4Morc7O8KT7fgRtOW+9HcbUvIJBSlUfHr84EwEFhHSlN/45sa/peH4RLIoS5nXGVgiOj r0N8iTW6bV3nK+lz5alpbIdNyZ0b1OtYTx9DzWl4ytM46fkxUrZYf0a+b+uWlMIUYsRV W7XQ== X-Gm-Message-State: APjAAAVwg/1NVLYEvbsIRe+GeWPnIor7aVd9tlKYM3BZ+43FzPEGBCG0 XuSUO8FiCk+BtdOWRzmKWimI X-Google-Smtp-Source: APXvYqyb7xWtO84LNcduE9P+8gbPVmoywmz8cPKNB4mh63fy6fYYi3B2jHmXFEVxxjscDbCAGjClTQ== X-Received: by 2002:a17:902:409:: with SMTP id 9mr10523602ple.245.1576779770781; Thu, 19 Dec 2019 10:22:50 -0800 (PST) Received: from localhost.localdomain ([2409:4072:6010:65a5:a416:e9bd:178a:9286]) by smtp.gmail.com with ESMTPSA id i3sm9085735pfg.94.2019.12.19.10.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 10:22:50 -0800 (PST) From: Manivannan Sadhasivam To: mchehab@kernel.org, sakari.ailus@iki.fi Subject: [PATCH v2 1/6] media: i2c: imx290: Add support for 2 data lanes Date: Thu, 19 Dec 2019 23:52:17 +0530 Message-Id: <20191219182222.18961-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> References: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191219_102251_733679_9AA35695 X-CRM114-Status: GOOD ( 19.67 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, c.barrett@framos.com, linux-kernel@vger.kernel.org, a.brela@framos.com, peter.griffin@linaro.org, Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The IMX290 sensor can output frames with 2/4 CSI2 data lanes. This commit adds support for 2 lane mode in addition to the 4 lane and also configuring the data lane settings in the driver based on system configuration. Signed-off-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 133 ++++++++++++++++++++++++++++++++++--- 1 file changed, 124 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index f7678e5a5d87..532ad488b801 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -25,7 +25,18 @@ #define IMX290_STANDBY 0x3000 #define IMX290_REGHOLD 0x3001 #define IMX290_XMSTA 0x3002 +#define IMX290_FR_FDG_SEL 0x3009 #define IMX290_GAIN 0x3014 +#define IMX290_HMAX_LOW 0x301c +#define IMX290_HMAX_HIGH 0x301d +#define IMX290_PHY_LANE_NUM 0x3407 +#define IMX290_CSI_LANE_MODE 0x3443 + +/* HMAX fields */ +#define IMX290_HMAX_2_1920 0x1130 +#define IMX290_HMAX_4_1920 0x0898 +#define IMX290_HMAX_2_720 0x19C8 +#define IMX290_HMAX_4_720 0x0CE4 #define IMX290_DEFAULT_LINK_FREQ 445500000 @@ -56,6 +67,7 @@ struct imx290 { struct device *dev; struct clk *xclk; struct regmap *regmap; + u8 nlanes; struct v4l2_subdev sd; struct v4l2_fwnode_endpoint ep; @@ -89,14 +101,11 @@ static const struct regmap_config imx290_regmap_config = { static const struct imx290_regval imx290_global_init_settings[] = { { 0x3007, 0x00 }, - { 0x3009, 0x00 }, { 0x3018, 0x65 }, { 0x3019, 0x04 }, { 0x301a, 0x00 }, - { 0x3443, 0x03 }, { 0x3444, 0x20 }, { 0x3445, 0x25 }, - { 0x3407, 0x03 }, { 0x303a, 0x0c }, { 0x3040, 0x00 }, { 0x3041, 0x00 }, @@ -169,7 +178,6 @@ static const struct imx290_regval imx290_1080p_settings[] = { { 0x3164, 0x1a }, { 0x3480, 0x49 }, /* data rate settings */ - { 0x3009, 0x01 }, { 0x3405, 0x10 }, { 0x3446, 0x57 }, { 0x3447, 0x00 }, @@ -187,8 +195,6 @@ static const struct imx290_regval imx290_1080p_settings[] = { { 0x3453, 0x00 }, { 0x3454, 0x17 }, { 0x3455, 0x00 }, - { 0x301c, 0x98 }, - { 0x301d, 0x08 }, }; static const struct imx290_regval imx290_720p_settings[] = { @@ -210,7 +216,6 @@ static const struct imx290_regval imx290_720p_settings[] = { { 0x3164, 0x1a }, { 0x3480, 0x49 }, /* data rate settings */ - { 0x3009, 0x01 }, { 0x3405, 0x10 }, { 0x3446, 0x4f }, { 0x3447, 0x00 }, @@ -228,8 +233,6 @@ static const struct imx290_regval imx290_720p_settings[] = { { 0x3453, 0x00 }, { 0x3454, 0x17 }, { 0x3455, 0x00 }, - { 0x301c, 0xe4 }, - { 0x301d, 0x0c }, }; static const struct imx290_regval imx290_10bit_settings[] = { @@ -522,6 +525,25 @@ static int imx290_write_current_format(struct imx290 *imx290, return 0; } +static int imx290_set_hmax(struct imx290 *imx290, u32 val) +{ + int ret; + + ret = imx290_write_reg(imx290, IMX290_HMAX_LOW, (val & 0xff)); + if (ret) { + dev_err(imx290->dev, "Error setting HMAX register\n"); + return ret; + } + + ret = imx290_write_reg(imx290, IMX290_HMAX_HIGH, ((val >> 8) & 0xff)); + if (ret) { + dev_err(imx290->dev, "Error setting HMAX register\n"); + return ret; + } + + return 0; +} + /* Start streaming */ static int imx290_start_streaming(struct imx290 *imx290) { @@ -551,6 +573,40 @@ static int imx290_start_streaming(struct imx290 *imx290) return ret; } + switch (imx290->nlanes) { + case 2: + if (imx290->current_mode->width == 1920) { + ret = imx290_set_hmax(imx290, IMX290_HMAX_2_1920); + if (ret < 0) + return ret; + } else { + ret = imx290_set_hmax(imx290, IMX290_HMAX_2_720); + if (ret < 0) + return ret; + } + + break; + case 4: + if (imx290->current_mode->width == 1920) { + ret = imx290_set_hmax(imx290, IMX290_HMAX_4_1920); + if (ret < 0) + return ret; + } else { + ret = imx290_set_hmax(imx290, IMX290_HMAX_4_720); + if (ret < 0) + return ret; + } + + break; + default: + /* + * We should never hit this since the data lane count is + * validated in probe itself + */ + dev_err(imx290->dev, "Lane configuration not supported\n"); + return -EINVAL; + } + /* Apply customized values from user */ ret = v4l2_ctrl_handler_setup(imx290->sd.ctrl_handler); if (ret) { @@ -607,6 +663,49 @@ static int imx290_get_regulators(struct device *dev, struct imx290 *imx290) imx290->supplies); } +static int imx290_set_data_lanes(struct imx290 *imx290) +{ + int ret = 0, laneval, frsel; + + switch (imx290->nlanes) { + case 2: + laneval = 0x01; + frsel = 0x02; + break; + case 4: + laneval = 0x03; + frsel = 0x01; + break; + default: + /* + * We should never hit this since the data lane count is + * validated in probe itself + */ + dev_err(imx290->dev, "Lane configuration not supported\n"); + ret = -EINVAL; + goto exit; + } + + ret = imx290_write_reg(imx290, IMX290_PHY_LANE_NUM, laneval); + if (ret) { + dev_err(imx290->dev, "Error setting Physical Lane number register\n"); + goto exit; + } + + ret = imx290_write_reg(imx290, IMX290_CSI_LANE_MODE, laneval); + if (ret) { + dev_err(imx290->dev, "Error setting CSI Lane mode register\n"); + goto exit; + } + + ret = imx290_write_reg(imx290, IMX290_FR_FDG_SEL, frsel); + if (ret) + dev_err(imx290->dev, "Error setting FR/FDG SEL register\n"); + +exit: + return ret; +} + static int imx290_power_on(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -631,6 +730,9 @@ static int imx290_power_on(struct device *dev) gpiod_set_value_cansleep(imx290->rst_gpio, 1); usleep_range(30000, 31000); + /* Set data lane count */ + imx290_set_data_lanes(imx290); + return 0; } @@ -703,6 +805,16 @@ static int imx290_probe(struct i2c_client *client) goto free_err; } + /* Get number of data lanes */ + imx290->nlanes = imx290->ep.bus.mipi_csi2.num_data_lanes; + if (imx290->nlanes != 2 && imx290->nlanes != 4) { + dev_err(dev, "Invalid data lanes: %d\n", imx290->nlanes); + ret = -EINVAL; + goto free_err; + } + + dev_dbg(dev, "Using %u data lanes\n", imx290->nlanes); + if (!imx290->ep.nr_of_link_frequencies) { dev_err(dev, "link-frequency property not found in DT\n"); ret = -EINVAL; @@ -822,6 +934,9 @@ static int imx290_probe(struct i2c_client *client) goto free_entity; } + /* Set data lane count */ + imx290_set_data_lanes(imx290); + pm_runtime_set_active(dev); pm_runtime_enable(dev); pm_runtime_idle(dev); From patchwork Thu Dec 19 18:22:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11304245 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED8CB14F6 for ; Thu, 19 Dec 2019 18:23:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A6D9D222C2 for ; Thu, 19 Dec 2019 18:23:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BalCluZ7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iyymSRkQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6D9D222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zFfz+11v7iRYXRNReD1AonBzdTiSIE5uiXrJqeQLKH4=; b=BalCluZ76tO4wMrYarY+QzPa3f Kz9bo8c8rhhzJfVNKbYskwsnVIyGCVJ5qM63V03+UjD7fcwsbyPW1TfTBsoJHliJjII+yMucF/7p9 N/keAa+CPzrnmJOQWNaxbK1Kw+EyYYaO2fB0gikvhR7/CfnCBPchy4QwlcaIB62JPtkSymMk/KXnf mjucWnXgwy4nPkjZpVO/cuwyKMp1IhvmXubtrV+2ddIywNgDLPSXGDiglXoJPFrEOewKdFoPp7e7i x4u5FpwFrcFfvcSlQLx29s3W2GnqO/fl99A3a25NDNC3LIQKzuPXA5YL2wWslXNEeXC4ADKbyuhbE DEYPmtag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0SJ-0001JX-PA; Thu, 19 Dec 2019 18:23:23 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0Ru-0000wk-Cf for linux-arm-kernel@lists.infradead.org; Thu, 19 Dec 2019 18:22:59 +0000 Received: by mail-pg1-x544.google.com with SMTP id l24so3563103pgk.2 for ; Thu, 19 Dec 2019 10:22:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KMxyNKrwFiypU+Za0PvdEdroSKdNRbPMZobhgZUY7nE=; b=iyymSRkQTNB324vLkBnS7VSoRJkH72UREfXNbeNFSewtHmL0P6PHfBuqx+np20dLqm pJ0UJ/u1YkgyAvj4pYJv/wqfSaOgFM+Qim1/y54eNZ5aso+wYDF5/Nz0PpuuesrXE7/X TTkPdjkg9GSOr/mm75SMnBp0I2RQ+6Xx8l40WBW1aAZMibF19pO8lgqE+TV2gQ1RKP6L FA/F1iSK1BoFbeDtd+/nAVjUuK2CvoU9QsVitgon4SPe7Z+PoCUOz0aAFVLOStTz5g+j 11Ha1A2n2+j/45Zxe76ZG5GIhQFe2FoZvdJZjOnFbMexUGqXshCUAg0v2hzJVXVGZxVC 4cAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KMxyNKrwFiypU+Za0PvdEdroSKdNRbPMZobhgZUY7nE=; b=Js1SiWhm3WG8wyKwbtzIhKiWibV4I54De+bLqW6cJiLqlOcgj61saaY1B+H2rQ1nwO CG9/oPZoc8D1YYSQQTaZ5fSKqoMERQ94bGx9gl0b8uozt1K5z+tXarZ3b2z8Fcc/NuS1 f+/5UV1kpFLL4nbcNTlgVVe/J1oAp17YXuq+FGSGw522HRCo7vN9/GTq3bKjzsncGsL2 2SvtwzWBhOAmSaRkJtd6UgEp4RdMwi74pZLejLluAN1U6zHJmWqG78J25BJN8M2J3L6r W6kpeayMHpbS5+ykpSeMxYqYdBv+3sUj13sl8ZEr5ntZgbq3zqtHfFzqpMDhLrXqzYLP UtPQ== X-Gm-Message-State: APjAAAVLFiTwdtDuyT4Jl26qGbHYsWtNvROaHxk6+tk4nTtpUviAyW4c IhPIVXNZuvm7vxi6JmFLDDGAWD3x8g== X-Google-Smtp-Source: APXvYqzG1vcXDyCDAjAHlqsGirk7Ni9aKqXLQ+RzNVSCFt0yvdRP9IcU/BWFVEohbUy0NUYg5RcGmA== X-Received: by 2002:a63:f551:: with SMTP id e17mr10230035pgk.162.1576779775598; Thu, 19 Dec 2019 10:22:55 -0800 (PST) Received: from localhost.localdomain ([2409:4072:6010:65a5:a416:e9bd:178a:9286]) by smtp.gmail.com with ESMTPSA id i3sm9085735pfg.94.2019.12.19.10.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 10:22:55 -0800 (PST) From: Manivannan Sadhasivam To: mchehab@kernel.org, sakari.ailus@iki.fi Subject: [PATCH v2 2/6] media: i2c: imx290: Add support for test pattern generation Date: Thu, 19 Dec 2019 23:52:18 +0530 Message-Id: <20191219182222.18961-3-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> References: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191219_102258_474460_F90EF93A X-CRM114-Status: GOOD ( 13.16 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, c.barrett@framos.com, linux-kernel@vger.kernel.org, a.brela@framos.com, peter.griffin@linaro.org, Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add support for generating following test patterns by IMX290: * Sequence Pattern 1 * Horizontal Color-bar Chart * Vertical Color-bar Chart * Sequence Pattern 2 * Gradation Pattern 1 * Gradation Pattern 2 * 000/555h Toggle Pattern Signed-off-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 41 +++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 532ad488b801..96eea0aafd3e 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -26,12 +26,19 @@ #define IMX290_REGHOLD 0x3001 #define IMX290_XMSTA 0x3002 #define IMX290_FR_FDG_SEL 0x3009 +#define IMX290_BLKLEVEL_LOW 0x300a +#define IMX290_BLKLEVEL_HIGH 0x300b #define IMX290_GAIN 0x3014 #define IMX290_HMAX_LOW 0x301c #define IMX290_HMAX_HIGH 0x301d +#define IMX290_PGCTRL 0x308c #define IMX290_PHY_LANE_NUM 0x3407 #define IMX290_CSI_LANE_MODE 0x3443 +#define IMX290_PGCTRL_REGEN BIT(0) +#define IMX290_PGCTRL_THRU BIT(1) +#define IMX290_PGCTRL_MODE(n) ((n) << 4) + /* HMAX fields */ #define IMX290_HMAX_2_1920 0x1130 #define IMX290_HMAX_4_1920 0x0898 @@ -99,6 +106,17 @@ static const struct regmap_config imx290_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +static const char * const imx290_test_pattern_menu[] = { + "Disabled", + "Sequence Pattern 1", + "Horizontal Color-bar Chart", + "Vertical Color-bar Chart", + "Sequence Pattern 2", + "Gradation Pattern 1", + "Gradation Pattern 2", + "000/555h Toggle Pattern", +}; + static const struct imx290_regval imx290_global_init_settings[] = { { 0x3007, 0x00 }, { 0x3018, 0x65 }, @@ -394,6 +412,22 @@ static int imx290_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_GAIN: ret = imx290_set_gain(imx290, ctrl->val); break; + case V4L2_CID_TEST_PATTERN: + if (ctrl->val) { + imx290_write_reg(imx290, IMX290_BLKLEVEL_LOW, 0x00); + imx290_write_reg(imx290, IMX290_BLKLEVEL_HIGH, 0x00); + msleep(10); + imx290_write_reg(imx290, IMX290_PGCTRL, + (u8)(IMX290_PGCTRL_REGEN | + IMX290_PGCTRL_THRU | + IMX290_PGCTRL_MODE(ctrl->val))); + } else { + imx290_write_reg(imx290, IMX290_PGCTRL, 0x00); + msleep(10); + imx290_write_reg(imx290, IMX290_BLKLEVEL_LOW, 0x3c); + imx290_write_reg(imx290, IMX290_BLKLEVEL_HIGH, 0x00); + } + break; default: ret = -EINVAL; break; @@ -881,7 +915,7 @@ static int imx290_probe(struct i2c_client *client) mutex_init(&imx290->lock); - v4l2_ctrl_handler_init(&imx290->ctrls, 3); + v4l2_ctrl_handler_init(&imx290->ctrls, 4); v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops, V4L2_CID_GAIN, 0, 72, 1, 0); @@ -899,6 +933,11 @@ static int imx290_probe(struct i2c_client *client) INT_MAX, 1, imx290_modes[0].pixel_rate); + v4l2_ctrl_new_std_menu_items(&imx290->ctrls, &imx290_ctrl_ops, + V4L2_CID_TEST_PATTERN, + ARRAY_SIZE(imx290_test_pattern_menu) - 1, + 0, 0, imx290_test_pattern_menu); + imx290->sd.ctrl_handler = &imx290->ctrls; if (imx290->ctrls.error) { From patchwork Thu Dec 19 18:22:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11304247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A42E921 for ; Thu, 19 Dec 2019 18:23:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D3E3C222C2 for ; Thu, 19 Dec 2019 18:23:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kBFuexqf"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kmDLD54W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3E3C222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Io7tqSYn++hdQqmg373I4yxlPj7AHgf9witrY1IAOqA=; b=kBFuexqfrlYKxHa/Bs404lhhVp 56LI1BKwtzYpzG/vsLfWlN4fMvxVk5Rf7Iia1lhItxQ1BeeKr5fuOIXsJgGUk86vvqGSigzvAPKG1 GZQKHZFvoFJGDdJt/qSJ10EbNHgj2KG5gZvvxH6a/3NsFEWbyEn6GGxlzMyvzxqWMlcKeBWcqo5tW N4UNhgDmx/p95sHx0N/UIaOYU5XGVwXdSw7vtOpp4gYrQCE0SdrJSu/MeUNK7tsRxPJdG2lCV80JW HWKL/EOsKc6FltdDLEiCGUp/xMa4KwODEB8V5YByEDzElfi7BTZaKXEmelXuHtEm9CkSGwFPo0qoA VPiTCqGA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0Se-0001Z0-7B; Thu, 19 Dec 2019 18:23:44 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0Rx-000127-UK for linux-arm-kernel@lists.infradead.org; Thu, 19 Dec 2019 18:23:03 +0000 Received: by mail-pj1-x1042.google.com with SMTP id ep17so2898902pjb.4 for ; Thu, 19 Dec 2019 10:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AFvgHo+YGqFoje0Tn82GYQJ1a/RGDe/xy+Kyh3iTfBI=; b=kmDLD54Wg3ujI/AZ5o82fQsFYrDiuccUSsctI4Y7S7mXX6MyEfNbDjjW9+s6zcVUKS nygmXBu+d+VM9XCAAmQ3nbV9d3I72uZUIsjZ2SF8TFVUHPw9QRjNM6Jw+1BRPLeBXvp1 cBNCRZIY/A1kpYJfHUDMOI8ai1nkGnezL24ODwAzUUPH7TiHct5j6i/A08jdpjRE3R5J pQvdnIciCIRAL3pDWcp2YfwuPzLAraQHzAVxWEuuc2oUYwHjmUQ7vD7F4aLl++6gwKFt mqL2MxBLFXllu3VhBGuTZzEB+Xzt4jE5lsgOpSSCUES1bflOqdaIw4CudFV4w25Q/kpG sIbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AFvgHo+YGqFoje0Tn82GYQJ1a/RGDe/xy+Kyh3iTfBI=; b=T9uPiyhz+1j90oUAAv/B6ZD4frRVeGRS1qKTrp4qACpNpMhF7m4PF3g1desLbSpf/5 voXZZiBbTs5AQBbElnF+TRwlM6rXU0kUkor+RkLD9yUCPstW4ikhNC2WSA8W0joB5R8P jSC9EXrLBlVA2DVEj18MtnQT1LlIj0dpk0RATnM65cKXwV6CIVTOGmua5QEM5qDvn39E p+y+9t4DNMh4GMtceojL2eKRNSFQeIKRqO54xDwwgnhgkq2Ib68rXQMsPNymDOKcPLFP Aly/aW0ftDhy2vq5K/vrKjM4RTdXeyAH05Tdh0SxFsCIPBfiYzGyPvDklGM7ahJjd19R hasw== X-Gm-Message-State: APjAAAWLHHxjAE9lEi0IQwrX56NoXeXE89fT2L3xFlqeWEVkc51TSziH c+uJ7LRnjRpIWbuTXkmEcYdB X-Google-Smtp-Source: APXvYqzXfMn0kZmuBjpUAbmkAgP2/fMJH486K6UgeYhEJzoLI3sQVo78zCN+SN0jVd3rtq83ZuxG7Q== X-Received: by 2002:a17:902:bd93:: with SMTP id q19mr8338103pls.134.1576779780558; Thu, 19 Dec 2019 10:23:00 -0800 (PST) Received: from localhost.localdomain ([2409:4072:6010:65a5:a416:e9bd:178a:9286]) by smtp.gmail.com with ESMTPSA id i3sm9085735pfg.94.2019.12.19.10.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 10:23:00 -0800 (PST) From: Manivannan Sadhasivam To: mchehab@kernel.org, sakari.ailus@iki.fi Subject: [PATCH v2 3/6] media: i2c: imx290: Add RAW12 mode support Date: Thu, 19 Dec 2019 23:52:19 +0530 Message-Id: <20191219182222.18961-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> References: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191219_102302_157498_C79E9917 X-CRM114-Status: GOOD ( 13.47 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, c.barrett@framos.com, linux-kernel@vger.kernel.org, a.brela@framos.com, peter.griffin@linaro.org, Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org IMX290 is capable of outputting frames in both Raw Bayer (packed) 10 and 12 bit formats. Since the driver already supports RAW10 mode, let's add the missing RAW12 mode as well. Signed-off-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 96eea0aafd3e..b6eeca56d3c9 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -75,6 +75,7 @@ struct imx290 { struct clk *xclk; struct regmap *regmap; u8 nlanes; + u8 bpp; struct v4l2_subdev sd; struct v4l2_fwnode_endpoint ep; @@ -98,6 +99,7 @@ struct imx290_pixfmt { static const struct imx290_pixfmt imx290_formats[] = { { MEDIA_BUS_FMT_SRGGB10_1X10 }, + { MEDIA_BUS_FMT_SRGGB12_1X12 }, }; static const struct regmap_config imx290_regmap_config = { @@ -265,6 +267,18 @@ static const struct imx290_regval imx290_10bit_settings[] = { { 0x300b, 0x00}, }; +static const struct imx290_regval imx290_12bit_settings[] = { + { 0x3005, 0x01 }, + { 0x3046, 0x01 }, + { 0x3129, 0x00 }, + { 0x317c, 0x00 }, + { 0x31ec, 0x0e }, + { 0x3441, 0x0c }, + { 0x3442, 0x0c }, + { 0x300a, 0xf0 }, + { 0x300b, 0x00 }, +}; + /* supported link frequencies */ static const s64 imx290_link_freq[] = { IMX290_DEFAULT_LINK_FREQ, @@ -550,6 +564,21 @@ static int imx290_write_current_format(struct imx290 *imx290, dev_err(imx290->dev, "Could not set format registers\n"); return ret; } + + imx290->bpp = 10; + + break; + case MEDIA_BUS_FMT_SRGGB12_1X12: + ret = imx290_set_register_array(imx290, imx290_12bit_settings, + ARRAY_SIZE( + imx290_12bit_settings)); + if (ret < 0) { + dev_err(imx290->dev, "Could not set format registers\n"); + return ret; + } + + imx290->bpp = 12; + break; default: dev_err(imx290->dev, "Unknown pixel format\n"); @@ -913,6 +942,9 @@ static int imx290_probe(struct i2c_client *client) goto free_err; } + /* Default bits per pixel value */ + imx290->bpp = 10; + mutex_init(&imx290->lock); v4l2_ctrl_handler_init(&imx290->ctrls, 4); From patchwork Thu Dec 19 18:22:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11304249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C47314F6 for ; Thu, 19 Dec 2019 18:24:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 48ACA222C2 for ; Thu, 19 Dec 2019 18:24:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kk9JaAn/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gQ8G1RAe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48ACA222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zgOWEmV1GGHMnxJQ2a8LLCel7rqiZrW7LlydoCx9kv0=; b=kk9JaAn/P+bGeu/T1LHBABXdDE oMBoL925y7VPfLCfIIU/6R5lopzi245tbgjdcOPxUF39Gm0NxtaFKWCKz/io32g7m7N6arrMgOok8 lu9ElhRSSnaoExOynjGsewBV/vOShTZXMsf9pLhmtUxm9EFgADZcen4TPow5sYXMfegKCkBOYvPmK h3Npp2BBbtzNPyVY3mT8q7NVlsffMi9veGrZng0zAbsENH60bWA6b4vAiXAxgKqfpf2HcmUDxMrtY 5BJZulTjM+Ilnjzew71h/6OvBQRK8KCXNgctZmj2MaOqkwKe2gnafVc35OsrWrtFV6qEU53ugR80p hPyQ4IAg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0Sw-0001rp-Pt; Thu, 19 Dec 2019 18:24:02 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0S2-00015l-FA for linux-arm-kernel@lists.infradead.org; Thu, 19 Dec 2019 18:23:07 +0000 Received: by mail-pj1-x1042.google.com with SMTP id l35so2918711pje.3 for ; Thu, 19 Dec 2019 10:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2o+AG3RvUH+GxTzi1IbYJSvnHQRcuO5FLTvuUuElWHc=; b=gQ8G1RAeBnSBMUz9vxx63vb4M+B8ZgAkiKSSzFgs7w5UGWiXl6ndClyr3rfdt0ukjV pBwFrlIdO6Lk3XgBiB6b3zA6FNde+Nwrkr2b3+Wxe3nyxUFGxFN7vb0qaA65jtXetc5A p7Dpr8fva+rX4v9D9hpA1+FNcW+sgJk2hFWLQI0Q5oblXjF3DkXyJLYTFOu4VTLS1TQi U0W327PywietOTD3gTTtx8SKJLPVpea8lYTjEBHvs1D7poJhOFEHjkUixb4pz/9MVOv0 UVNTPvJNXkh/jXwXv7JuRsiIUh1cREVBP0c4C6GEjefuJqSC2pOQNG6GfhK6OEy4dAAu sjYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2o+AG3RvUH+GxTzi1IbYJSvnHQRcuO5FLTvuUuElWHc=; b=t5ItTLtYyBmUlGMUBztJ8YQ+dgjmNszKbGxeCsuCxNGzqjJ+gI6Wm3Vsnynerl77jg fXrgOw+IvUTcHAzLUAtI/y3ZC6iy8UcbGQTuzAtl0tMzJ9v9rYnyocTDTMeYxRGyLMOD 1VqN24+8XLtocGT0xoFeURF7jrkGEI9E0FYiGd61/qB9RfwQiCARiH64kygtzNTUTsGg vkS6wQDm2G/mUk6qnRZFgbpF7ExK1o0HEe3quJx5p9FeEr20fGu1WQZPZHciNJVFvhgs jaden1ff7zgGgwXpyOAJlvrjo5jRzQghVjhAY/yGoKXAinsFHgittkAFm8mvATR3GoTh GvEw== X-Gm-Message-State: APjAAAUYzTOw9vLX53ZN7+nK0Az6lwo3s8toEaqCXOW8Mm9CD3aWpQgE 3Ivo5DC42JWln4JG76M5wN9G X-Google-Smtp-Source: APXvYqyzVnZODv06yR3mjE0LzOn3l+hcZpCkDYMSSVHn9s9fFrnBf0tRvxzqCDRbMLZlsMAYZMYNuw== X-Received: by 2002:a17:902:421:: with SMTP id 30mr10707013ple.324.1576779785449; Thu, 19 Dec 2019 10:23:05 -0800 (PST) Received: from localhost.localdomain ([2409:4072:6010:65a5:a416:e9bd:178a:9286]) by smtp.gmail.com with ESMTPSA id i3sm9085735pfg.94.2019.12.19.10.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 10:23:04 -0800 (PST) From: Manivannan Sadhasivam To: mchehab@kernel.org, sakari.ailus@iki.fi Subject: [PATCH v2 4/6] media: i2c: imx290: Add support to enumerate all frame sizes Date: Thu, 19 Dec 2019 23:52:20 +0530 Message-Id: <20191219182222.18961-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> References: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191219_102306_550834_EE90B21C X-CRM114-Status: GOOD ( 11.61 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, c.barrett@framos.com, linux-kernel@vger.kernel.org, a.brela@framos.com, peter.griffin@linaro.org, Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add support to enumerate all frame sizes supported by IMX290. This is required for using with userspace tools such as libcamera. Signed-off-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index b6eeca56d3c9..a1974340e6fa 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -468,6 +468,25 @@ static int imx290_enum_mbus_code(struct v4l2_subdev *sd, return 0; } +static int imx290_enum_frame_size(struct v4l2_subdev *subdev, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) +{ + if ((fse->code != imx290_formats[0].code) && + (fse->code != imx290_formats[1].code)) + return -EINVAL; + + if (fse->index >= ARRAY_SIZE(imx290_modes)) + return -EINVAL; + + fse->min_width = imx290_modes[fse->index].width; + fse->max_width = imx290_modes[fse->index].width; + fse->min_height = imx290_modes[fse->index].height; + fse->max_height = imx290_modes[fse->index].height; + + return 0; +} + static int imx290_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) @@ -823,6 +842,7 @@ static const struct v4l2_subdev_video_ops imx290_video_ops = { static const struct v4l2_subdev_pad_ops imx290_pad_ops = { .init_cfg = imx290_entity_init_cfg, .enum_mbus_code = imx290_enum_mbus_code, + .enum_frame_size = imx290_enum_frame_size, .get_fmt = imx290_get_fmt, .set_fmt = imx290_set_fmt, }; From patchwork Thu Dec 19 18:22:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11304253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2343A921 for ; Thu, 19 Dec 2019 18:24:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E61F4222C2 for ; Thu, 19 Dec 2019 18:24:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bNiGjkYW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ktngylax" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E61F4222C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=e3WKB6zVhSgz9v3E2ZB/ey4i2tYDRVxs0FIrEVHCJPk=; b=bNiGjkYWpuZYuk5kNYxVTuiEBP pKgu7hIPhWRL+PM8vIfIbSIjHD/i9WXIAcHGrKnmuWhgVh8UqoWXdMGJgBdHZX8R8ci+GP7Jgo2Vq R1AGw1TExMAUPggRYxKmtuJuluQ72bq9W8AvrLh7YosdFeNLtyLgGV1GAae8coCywWN8BM4Vktt6T c1E2eCd094ySnCkygFyEFj3+IoDXik5EDTyoT1DtTJbMq+vbdxtwxhDgSQ7LSCBjBpRkvinGauqAk wFLtH5R9P1pJBtTr1O3TvmExOVX0ko7DvBWTPi30Ly4BqwpWm0b7WI7KGOkX7c/f+PORrXad47ozU M13JM91A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0TC-00027d-GO; Thu, 19 Dec 2019 18:24:18 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0S9-0001AZ-0m for linux-arm-kernel@lists.infradead.org; Thu, 19 Dec 2019 18:23:16 +0000 Received: by mail-pg1-x541.google.com with SMTP id k3so3561281pgc.3 for ; Thu, 19 Dec 2019 10:23:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aaDVa/wefW6dA8diuFKX+4suKAqDWuzG8PZTPRvOWpY=; b=ktngylaxtKSioChZycCEfiuuOBC8AjMEYRKHWc/M721x2N3gAquly/ClC9d8QYVaQN 9La3xsIMwqbfMPVqbJOXb7kcVAI70ZuSqaxozMic7t/3SxI6KC971hsIG+mZAH3nEu+v /8Nuh0o499INctRWB4mngQ1pfdgNdtBUczImb69bdlr2EFSAZTPWwVWEeYRjKa9vWAWX WVQanIaFSPtKgFcjYNzGwbhNw84vxtApXwN3582KmNAvRLs1BnPag03PnyVkPGFGi+C9 lOjZIzckv6WWQAPIFrh5n1Lxb7wedKgw3TsdZp7SyjIKi23mSBnvIpNkksdLtzmPumco efAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aaDVa/wefW6dA8diuFKX+4suKAqDWuzG8PZTPRvOWpY=; b=nZklvn5NUxiFQH1ukUcoxPXJAsdYlAJsIlgVnnyqDWuswjLVfPx58NeBQ1WsvrSkr7 PHAQt1dwKB3hhv+JaGomlYILXOWuUNsGYkEtGFfs3gaK9e5m3VjcMpvtjadQqouAXqhX QnUpZ+PGFB1U7Q7bBSKipRgXw6WdI95KUOezvahKHnAcg8GOWPV+2RCPwcPH8nzc61BZ 8kWBFzgCRSTZYK4BvH1/AdQy833zRUK4qS8vpN0HlldNxOxcyAFurMQVx1Kt0KPne0nQ NUDOkrzR0LMVPW4OxaQWs6iIZfUWFrInfQrjYNT9SQreCYagQvqQBwS9ODl7S4QC4Bgx Agkg== X-Gm-Message-State: APjAAAU6HwdEB3jaeWNgr8h6OaXTFh5vzCKu4c8vTRH5oVSPGvWjSyXE rgC7XypABmTEYSJ7oXLyqecH X-Google-Smtp-Source: APXvYqxSiczLugu1KuiupJ4vitxISwQqt0DMQ8ArRRicC1ia4IvZgJNuHOUDYf7f2qkxhXxIvXIiyg== X-Received: by 2002:a62:a21e:: with SMTP id m30mr3583773pff.56.1576779791625; Thu, 19 Dec 2019 10:23:11 -0800 (PST) Received: from localhost.localdomain ([2409:4072:6010:65a5:a416:e9bd:178a:9286]) by smtp.gmail.com with ESMTPSA id i3sm9085735pfg.94.2019.12.19.10.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 10:23:11 -0800 (PST) From: Manivannan Sadhasivam To: mchehab@kernel.org, sakari.ailus@iki.fi Subject: [PATCH v2 5/6] media: i2c: imx290: Add configurable link frequency and pixel rate Date: Thu, 19 Dec 2019 23:52:21 +0530 Message-Id: <20191219182222.18961-6-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> References: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191219_102313_113886_017D616B X-CRM114-Status: GOOD ( 18.27 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, c.barrett@framos.com, linux-kernel@vger.kernel.org, a.brela@framos.com, peter.griffin@linaro.org, Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org IMX290 operates with multiple link frequency and pixel rate combinations. The initial driver used a single setting for both but since we now have the lane count support in place, let's add configurable link frequency and pixel rate. Signed-off-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 155 +++++++++++++++++++++---------------- 1 file changed, 89 insertions(+), 66 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index a1974340e6fa..52f1e470b507 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -45,8 +45,6 @@ #define IMX290_HMAX_2_720 0x19C8 #define IMX290_HMAX_4_720 0x0CE4 -#define IMX290_DEFAULT_LINK_FREQ 445500000 - static const char * const imx290_supply_name[] = { "vdda", "vddd", @@ -63,8 +61,6 @@ struct imx290_regval { struct imx290_mode { u32 width; u32 height; - u32 pixel_rate; - u32 link_freq_index; const struct imx290_regval *data; u32 data_size; @@ -281,7 +277,10 @@ static const struct imx290_regval imx290_12bit_settings[] = { /* supported link frequencies */ static const s64 imx290_link_freq[] = { - IMX290_DEFAULT_LINK_FREQ, + 891000000, /* 1920x1080 - 2 lane */ + 445500000, /* 1920x1080 - 4 lane */ + 594000000, /* 1280x720 - 2 lane */ + 297000000, /* 1280x720 - 4 lane */ }; /* Mode configs */ @@ -291,16 +290,12 @@ static const struct imx290_mode imx290_modes[] = { .height = 1080, .data = imx290_1080p_settings, .data_size = ARRAY_SIZE(imx290_1080p_settings), - .pixel_rate = 178200000, - .link_freq_index = 0, }, { .width = 1280, .height = 720, .data = imx290_720p_settings, .data_size = ARRAY_SIZE(imx290_720p_settings), - .pixel_rate = 178200000, - .link_freq_index = 0, }, }; @@ -509,6 +504,73 @@ static int imx290_get_fmt(struct v4l2_subdev *sd, return 0; } +static s64 imx290_get_link_freq_index(struct imx290 *imx290) +{ + const struct imx290_mode *cur_mode = imx290->current_mode; + u8 index; + + if (cur_mode->width == 1920) + index = imx290->nlanes / 4; + else + index = (imx290->nlanes / 4) + 2; + + return index; +} + +static s64 imx290_get_link_freq(struct imx290 *imx290) +{ + u8 index = imx290_get_link_freq_index(imx290); + + return imx290_link_freq[index]; +} + +static u64 imx290_calc_pixel_rate(struct imx290 *imx290) +{ + s64 link_freq = imx290_get_link_freq(imx290); + u8 nlanes = imx290->nlanes; + + /* pixel rate = link_freq * 2 * nr_of_lanes / bits_per_sample */ + return (link_freq * 2 * nlanes / imx290->bpp); +} + +static int imx290_write_current_format(struct imx290 *imx290, + struct v4l2_mbus_framefmt *format) +{ + int ret; + + switch (format->code) { + case MEDIA_BUS_FMT_SRGGB10_1X10: + ret = imx290_set_register_array(imx290, imx290_10bit_settings, + ARRAY_SIZE( + imx290_10bit_settings)); + if (ret < 0) { + dev_err(imx290->dev, "Could not set format registers\n"); + return ret; + } + + imx290->bpp = 10; + + break; + case MEDIA_BUS_FMT_SRGGB12_1X12: + ret = imx290_set_register_array(imx290, imx290_12bit_settings, + ARRAY_SIZE( + imx290_12bit_settings)); + if (ret < 0) { + dev_err(imx290->dev, "Could not set format registers\n"); + return ret; + } + + imx290->bpp = 12; + + break; + default: + dev_err(imx290->dev, "Unknown pixel format\n"); + return -EINVAL; + } + + return 0; +} + static int imx290_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) @@ -517,6 +579,7 @@ static int imx290_set_fmt(struct v4l2_subdev *sd, const struct imx290_mode *mode; struct v4l2_mbus_framefmt *format; unsigned int i; + int ret = 0; mutex_lock(&imx290->lock); @@ -542,17 +605,27 @@ static int imx290_set_fmt(struct v4l2_subdev *sd, format = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); } else { format = &imx290->current_format; - __v4l2_ctrl_s_ctrl(imx290->link_freq, mode->link_freq_index); - __v4l2_ctrl_s_ctrl_int64(imx290->pixel_rate, mode->pixel_rate); - imx290->current_mode = mode; + + /* Set current frame format */ + ret = imx290_write_current_format(imx290, &fmt->format); + if (ret < 0) { + dev_err(imx290->dev, "Could not set frame format\n"); + goto err_out; + } + + __v4l2_ctrl_s_ctrl(imx290->link_freq, + imx290_get_link_freq_index(imx290)); + __v4l2_ctrl_s_ctrl_int64(imx290->pixel_rate, + imx290_calc_pixel_rate(imx290)); } *format = fmt->format; +err_out: mutex_unlock(&imx290->lock); - return 0; + return ret; } static int imx290_entity_init_cfg(struct v4l2_subdev *subdev, @@ -569,44 +642,6 @@ static int imx290_entity_init_cfg(struct v4l2_subdev *subdev, return 0; } -static int imx290_write_current_format(struct imx290 *imx290, - struct v4l2_mbus_framefmt *format) -{ - int ret; - - switch (format->code) { - case MEDIA_BUS_FMT_SRGGB10_1X10: - ret = imx290_set_register_array(imx290, imx290_10bit_settings, - ARRAY_SIZE( - imx290_10bit_settings)); - if (ret < 0) { - dev_err(imx290->dev, "Could not set format registers\n"); - return ret; - } - - imx290->bpp = 10; - - break; - case MEDIA_BUS_FMT_SRGGB12_1X12: - ret = imx290_set_register_array(imx290, imx290_12bit_settings, - ARRAY_SIZE( - imx290_12bit_settings)); - if (ret < 0) { - dev_err(imx290->dev, "Could not set format registers\n"); - return ret; - } - - imx290->bpp = 12; - - break; - default: - dev_err(imx290->dev, "Unknown pixel format\n"); - return -EINVAL; - } - - return 0; -} - static int imx290_set_hmax(struct imx290 *imx290, u32 val) { int ret; @@ -640,13 +675,6 @@ static int imx290_start_streaming(struct imx290 *imx290) return ret; } - /* Set current frame format */ - ret = imx290_write_current_format(imx290, &imx290->current_format); - if (ret < 0) { - dev_err(imx290->dev, "Could not set frame format\n"); - return ret; - } - /* Apply default values of current mode */ ret = imx290_set_register_array(imx290, imx290->current_mode->data, imx290->current_mode->data_size); @@ -904,12 +932,6 @@ static int imx290_probe(struct i2c_client *client) goto free_err; } - if (imx290->ep.link_frequencies[0] != IMX290_DEFAULT_LINK_FREQ) { - dev_err(dev, "Unsupported link frequency\n"); - ret = -EINVAL; - goto free_err; - } - /* Only CSI2 is supported for now */ if (imx290->ep.bus_type != V4L2_MBUS_CSI2_DPHY) { dev_err(dev, "Unsupported bus type, should be CSI2\n"); @@ -976,14 +998,15 @@ static int imx290_probe(struct i2c_client *client) &imx290_ctrl_ops, V4L2_CID_LINK_FREQ, ARRAY_SIZE(imx290_link_freq) - 1, - 0, imx290_link_freq); + (imx290->nlanes / 4), + imx290_link_freq); if (imx290->link_freq) imx290->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; imx290->pixel_rate = v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops, V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, - imx290_modes[0].pixel_rate); + imx290_calc_pixel_rate(imx290)); v4l2_ctrl_new_std_menu_items(&imx290->ctrls, &imx290_ctrl_ops, V4L2_CID_TEST_PATTERN, From patchwork Thu Dec 19 18:22:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 11304255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F05C14F6 for ; Thu, 19 Dec 2019 18:24:38 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3C00824672 for ; Thu, 19 Dec 2019 18:24:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sRGYPs+J"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gUtZSwI5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C00824672 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ycZNczdfY/+u8tTdFayggmNk0dz6dEV5I+zHzWa6UEA=; b=sRGYPs+JjVIajukcfzOmbbZ+xe E6vPM4W2OaKQhR0sHYUB5jJ2c1ACQBySdVJa2QvZ/PqDG5TIBBkeImsDUiTVTgYuegBhKw6GVGABG N7Aw0lGIz2GufMY7b7pslliDS7R7EouisKoAPXwAzHHlVSw1ogQcohUyNoEfp+Ou+TuMAz8O2aKY8 uTvCOfZvCHEkOOlcyqHuGA3HOaWxzIFqnNsJb6zv24DVyxgjgLnA3t4lLLZ7YucujLuYI9XH9TkU4 +UsbKdadqOV72cOqckBfuI/7psWvWL0zIEQCZSZPPrb50KVjHUt5g1dZc9k3qPbWnHt2f/6ssnYmM 4PQZhjRA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0TV-0002NC-3M; Thu, 19 Dec 2019 18:24:37 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ii0SD-0001E1-Dq for linux-arm-kernel@lists.infradead.org; Thu, 19 Dec 2019 18:23:19 +0000 Received: by mail-pl1-x642.google.com with SMTP id bd4so2925972plb.8 for ; Thu, 19 Dec 2019 10:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gPMrMi1zLN6OA6/X7P7gnmwAhoOj6bYlyFbNpwO69Qo=; b=gUtZSwI5Ulzsmc54LykF+cv8X0Jm7Kfs0WesiUq0DuTQnyoBmI/riCz285oek9SAJG p8V+AqewtM6MuinpONWRY9UqrOZCI3wcAp7DBhj8JS4DQTdiSrOLwRGRj/mQuohbSG83 vYk2w01/bsKxzy+QiBpNlxXiTNiUGUlNAPiB5xnDFX90vcVlcMlFZVmZYkr5TYtHjQP3 MQheafVzi8xnyP8NoAbWCD0ZxYh6PnvPmBgSvwYRvyFzE0wZDwrlyD1q3KpDplaTs90i TVGECp5NmtJo22/ecbdc1F3qfAk4oDAz2LFAXQmLNCdtQSmvn9SxirD0PyOhFISwXhKN t3xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gPMrMi1zLN6OA6/X7P7gnmwAhoOj6bYlyFbNpwO69Qo=; b=RhEXdAqWQc5+cbkDTVxGvdPPuR+bAsNXV05fOnZEmfrvizzY4jmaWgNKFqdVxAvTpT IDB5Sp/LiYg4lRf4Q0AC3Ny+z5p+sLQbCsccirn0m5Sj8lsiUsW0eHIiF0pd/1Zz2UGi kypEvqMSF+kbk5hbPqm2ukLkAmUlpLw+49PDpc7jhOxFrnFcYy0IA4cnNl5ImvzRmOVT vDAKxUqlnS15Dy0FJTTT5y5gYOVrLs/tb5zI52Ywf/MVkSZ3WWCqW56io9tCAasKAPMt bIsOkZbL8khRWwRkofI/PDAsCttW41G1rbEbVth1yJjz+S9+xet74v5e7SsrkMMNKuBF SqDQ== X-Gm-Message-State: APjAAAXNj81Iz81oW1U+AmOBRHxkY3AayFIvV7vyM21w5DqYnUQkUawl wVE9Uc+zcRguYqvOpOLJtIk+ X-Google-Smtp-Source: APXvYqxh/cPkFck6sf3vfEQMX1np7F99b/uUWokTEajJPRHT+C0oBMl9tibCAQmI8m6PYTrdepN4Vw== X-Received: by 2002:a17:90a:9f04:: with SMTP id n4mr11080250pjp.76.1576779796548; Thu, 19 Dec 2019 10:23:16 -0800 (PST) Received: from localhost.localdomain ([2409:4072:6010:65a5:a416:e9bd:178a:9286]) by smtp.gmail.com with ESMTPSA id i3sm9085735pfg.94.2019.12.19.10.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 10:23:16 -0800 (PST) From: Manivannan Sadhasivam To: mchehab@kernel.org, sakari.ailus@iki.fi Subject: [PATCH v2 6/6] media: i2c: imx290: Move the settle time delay out of loop Date: Thu, 19 Dec 2019 23:52:22 +0530 Message-Id: <20191219182222.18961-7-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> References: <20191219182222.18961-1-manivannan.sadhasivam@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191219_102317_521232_6CCA38AE X-CRM114-Status: GOOD ( 13.95 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, c.barrett@framos.com, linux-kernel@vger.kernel.org, a.brela@framos.com, peter.griffin@linaro.org, Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The 10ms settle time is needed only at the end of all consecutive register writes. So move the delay to outside of the for loop of imx290_set_register_array(). Signed-off-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 52f1e470b507..fb6d3f649a5a 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -344,11 +344,11 @@ static int imx290_set_register_array(struct imx290 *imx290, ret = imx290_write_reg(imx290, settings->reg, settings->val); if (ret < 0) return ret; - - /* Settle time is 10ms for all registers */ - msleep(10); } + /* Provide 10ms settle time */ + msleep(10); + return 0; }