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: 182148 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp835585iln; Thu, 19 Dec 2019 10:22:59 -0800 (PST) X-Google-Smtp-Source: APXvYqxpIwu4rJMq6LwDDnQDPnu5Cy4rxVPkB7l8IkUqK1wquz+SjoQBm/MgY7bEZf8bfE9zpds3 X-Received: by 2002:a54:488d:: with SMTP id r13mr2733863oic.115.1576779779218; Thu, 19 Dec 2019 10:22:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576779779; cv=none; d=google.com; s=arc-20160816; b=prhch7VPP3VtM0/wMy/hLtlJxaNZjkFSn0M4po73fqOM9iShxeSejN7WUO+KQwKAE/ OdTLmSltIc4lRHE8IwuJCxrxEisb2GqtHwCjhaQRiVJN6HmazoCjD3M1BJ9xSoVW+AXY hUnKfut3ziXrMy/ghSA87+TORnY4T7LJRDAzs8XITrFtgnAyDnIanp44P/xBNZ7K2O2n ZeMiGLPvQt3JVZKkeLuPNbdv227O1TaZ4w1N8TnLup+rGehmYpaZDlATwQuWDG3CqGqL HkIfPTq0H5/TxC+oUEQG7+5Y3yAaRNvcBWlwWqPRHj53SluLZqf9UgK8SbxFnmrl6/fd w+9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=KMxyNKrwFiypU+Za0PvdEdroSKdNRbPMZobhgZUY7nE=; b=n4OvpFh++N8JRROpcurKNdVtTuyi/tUSCWrod1BKnvTQg41z4NmreImtb+cSklp5SL sAa+lwhw0nJHvNs54ZGfp3IaKMoHs87Sa/r8EZYoOway5uLO5aIVTEq3JGmEubf7UH4Y pcU5AkNI2GFbIIr6gMCLwY03TwHC6MlMPn/1c/0GZsGx5/x77mIis4EJCielF+tAIV2P oWjDU0mmQ3yGRFjIKjLfkEcl2Tu6CIiPHbjziCbc/yetrU/xTDJSGyW/v6TXhoFcdFT7 JL0aLVdMZoFokgDHek6em01JgHPj6M3MEUQU5pvGtr4v2yKVTYOE3zVtK8aqgTMpf51U 5JJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iyymSRkQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e25si638225oie.146.2019.12.19.10.22.58; Thu, 19 Dec 2019 10:22:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iyymSRkQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727063AbfLSSW5 (ORCPT + 27 others); Thu, 19 Dec 2019 13:22:57 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38269 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726998AbfLSSW4 (ORCPT ); Thu, 19 Dec 2019 13:22:56 -0500 Received: by mail-pf1-f194.google.com with SMTP id x185so3728970pfc.5 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=oHY0kHi+WBBCwRqn0ma7By3Yn4vkfDEBv5Yzn/nNbKLwJRHy/CWioYhMe/rT/JqU++ E11KtaxUeFIcfKTsaCVP6RTnORlDJex1hyJUvQyZt6gego+EdOClwt1Maqv8XaCGTBGm XS2pL+7vesTBRDpRUmFN4U8ztRQPcxD+OkHJuzMQ9+aU9pXRQiJeLd63dnTe6TxH8tg2 MQqd+AMjmOMDZU1/pIvsZL+h9b5uQVf66qr7+VaNtuevJGyMvb/g6WMCjeQ15xIWHx7n TuMAdtoTSjf/KJylpSmRzJXeA+b0fnj952d/VKxulwnFwkNXCQUth5t7+o4BrRR6AviZ J2PA== X-Gm-Message-State: APjAAAVPZBO7wKw84j+T0RngLnOu0xfOcS9OiUEJ9Yd1Xzx0FMLytX62 nvINiSQwK5TBHb1ZNfucwC1t 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 Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, c.barrett@framos.com, a.brela@framos.com, peter.griffin@linaro.org, Manivannan Sadhasivam 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(-) -- 2.17.1 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) {