Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2365423pxa; Mon, 24 Aug 2020 12:05:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFgANJ7sDmYiQ6cCJEqE4AnyNqRJaEZ+607WV0f9HRDLLEnU4qiM8f444SM85XNYhJZQYK X-Received: by 2002:aa7:c0d2:: with SMTP id j18mr6584839edp.373.1598295947591; Mon, 24 Aug 2020 12:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598295947; cv=none; d=google.com; s=arc-20160816; b=J1KeS/+aU2WnrGu5R5i1BaROJieQ464gu1iuI43wEEddXZIMP3775BDkPBoK1fttBI 1ttd8Nh0j2TSmmRBxscQZYD2gfgm0GQ+2iljFxOeBhXN/+Bpt+9Xhsid1cKIka9uC9Gv OMPGFQZwzlKB92EiuuYfPAiZTS8XYX/jQ/e/Sx0TGuEn4oHFt1xTJKGBKuREeyWdwqfb gsVjQeX9eaeozbCTUtY/rPws9EukfNSi+6j9Qn6tgRlLfv5F4j33+0PBWaqYzW4a+Enx /RmnnHb1wj5HEIs4CaGkZgztsatA9A7YC7ZM0QYhr+Dmz7jFRFOS56llOIyxt7hZA4RE UN/g== 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; bh=CGQxxGFpMXAlRfVv443HUw+SPGnti8+VeUIGuKyd1qg=; b=LrKB0Y8Dh0ZLodSdhd2a1JleGExkrJtAf3sQwF43CaN9GhMc2G911ZI6U2sI3uMNgz NTMsmh1yLXYvDWJPTAl70xVa7rsa5IC/89BDyVpCOThZdTbOnw03XrY7BoRFiOCVPuNx 06d8YKH/eViYq4YehImIMGAxUxW5POKAD+ftfP7bBq6GY/Nh7kwJJ4GpNDLTpwd7Pm0t m1AH7qHY0BQJvsQ2Ux/so+gaNTpr1qenoDxy1sgaofIKFyC35VgLmciQomer1mbnZ8cI maAMVuvu6hJaDE39/3nJWyj90Xj6CvU5qIuUzcPpfflKnqKhUZlZjI3jI9hdYrKsoFiI rQoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yh22si8689026ejb.583.2020.08.24.12.05.24; Mon, 24 Aug 2020 12:05:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbgHXTEX (ORCPT + 99 others); Mon, 24 Aug 2020 15:04:23 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:47578 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726985AbgHXTEV (ORCPT ); Mon, 24 Aug 2020 15:04:21 -0400 X-IronPort-AV: E=Sophos;i="5.76,349,1592838000"; d="scan'208";a="55179457" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 25 Aug 2020 04:04:20 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 55E6340CDD5F; Tue, 25 Aug 2020 04:04:18 +0900 (JST) From: Lad Prabhakar To: Jacopo Mondi , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lad Prabhakar , Biju Das , Prabhakar Subject: [PATCH v3 2/2] media: i2c: ov772x: Add test pattern control Date: Mon, 24 Aug 2020 20:04:06 +0100 Message-Id: <20200824190406.27478-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200824190406.27478-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20200824190406.27478-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for test pattern control supported by the sensor. Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das --- drivers/media/i2c/ov772x.c | 25 ++++++++++++++++++++++++- include/media/i2c/ov772x.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c index 67764d647526..f267d8abd742 100644 --- a/drivers/media/i2c/ov772x.c +++ b/drivers/media/i2c/ov772x.c @@ -227,7 +227,7 @@ /* COM3 */ #define SWAP_MASK (SWAP_RGB | SWAP_YUV | SWAP_ML) -#define IMG_MASK (VFLIP_IMG | HFLIP_IMG) +#define IMG_MASK (VFLIP_IMG | HFLIP_IMG | SCOLOR_TEST) #define VFLIP_IMG 0x80 /* Vertical flip image ON/OFF selection */ #define HFLIP_IMG 0x40 /* Horizontal mirror image ON/OFF selection */ @@ -425,6 +425,7 @@ struct ov772x_priv { const struct ov772x_win_size *win; struct v4l2_ctrl *vflip_ctrl; struct v4l2_ctrl *hflip_ctrl; + unsigned int test_pattern; /* band_filter = COM8[5] ? 256 - BDBASE : 0 */ struct v4l2_ctrl *band_filter_ctrl; unsigned int fps; @@ -540,6 +541,11 @@ static const struct ov772x_win_size ov772x_win_sizes[] = { }, }; +static const char * const ov772x_test_pattern_menu[] = { + "Disabled", + "Vertical Color Bar Type 1", +}; + /* * frame rate settings lists */ @@ -762,6 +768,13 @@ static int ov772x_s_frame_interval(struct v4l2_subdev *sd, return ret; } +static int ov772x_enable_test_pattern(struct ov772x_priv *priv, u32 pattern) +{ + priv->test_pattern = pattern; + return regmap_update_bits(priv->regmap, COM3, SCOLOR_TEST, + pattern ? SCOLOR_TEST : 0x00); +} + static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl) { struct ov772x_priv *priv = container_of(ctrl->handler, @@ -809,6 +822,8 @@ static int ov772x_s_ctrl(struct v4l2_ctrl *ctrl) } return ret; + case V4L2_CID_TEST_PATTERN: + return ov772x_enable_test_pattern(priv, ctrl->val); } return -EINVAL; @@ -1103,10 +1118,14 @@ static int ov772x_set_params(struct ov772x_priv *priv, val |= VFLIP_IMG; if (priv->info && (priv->info->flags & OV772X_FLAG_HFLIP)) val |= HFLIP_IMG; + if (priv->info && (priv->info->flags & OV772X_FLAG_TEST_PATTERN)) + val |= SCOLOR_TEST; if (priv->vflip_ctrl->val) val ^= VFLIP_IMG; if (priv->hflip_ctrl->val) val ^= HFLIP_IMG; + if (priv->test_pattern) + val ^= SCOLOR_TEST; ret = regmap_update_bits(priv->regmap, COM3, SWAP_MASK | IMG_MASK, val); if (ret < 0) @@ -1404,6 +1423,10 @@ static int ov772x_probe(struct i2c_client *client) priv->band_filter_ctrl = v4l2_ctrl_new_std(&priv->hdl, &ov772x_ctrl_ops, V4L2_CID_BAND_STOP_FILTER, 0, 256, 1, 0); + v4l2_ctrl_new_std_menu_items(&priv->hdl, &ov772x_ctrl_ops, + V4L2_CID_TEST_PATTERN, + ARRAY_SIZE(ov772x_test_pattern_menu) - 1, + 0, 0, ov772x_test_pattern_menu); priv->subdev.ctrl_handler = &priv->hdl; if (priv->hdl.error) { ret = priv->hdl.error; diff --git a/include/media/i2c/ov772x.h b/include/media/i2c/ov772x.h index a1702d420087..65e6f8d2f4bb 100644 --- a/include/media/i2c/ov772x.h +++ b/include/media/i2c/ov772x.h @@ -12,6 +12,7 @@ /* for flags */ #define OV772X_FLAG_VFLIP (1 << 0) /* Vertical flip image */ #define OV772X_FLAG_HFLIP (1 << 1) /* Horizontal flip image */ +#define OV772X_FLAG_TEST_PATTERN (1 << 2) /* Test pattern */ /* * for Edge ctrl -- 2.17.1