From patchwork Wed Jan 3 18:22:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10142783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 463066035E for ; Wed, 3 Jan 2018 18:23:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F8AC29109 for ; Wed, 3 Jan 2018 18:23:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3439C2919D; Wed, 3 Jan 2018 18:23:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F88E29109 for ; Wed, 3 Jan 2018 18:23:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751062AbeACSXd (ORCPT ); Wed, 3 Jan 2018 13:23:33 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33794 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750864AbeACSXa (ORCPT ); Wed, 3 Jan 2018 13:23:30 -0500 Received: by mail-pl0-f66.google.com with SMTP id d21so1729587pll.1 for ; Wed, 03 Jan 2018 10:23:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JH70FUKs/H5xc0SqDSr3TwuUIC5X1UMcDxHZPLyC8+c=; b=lOZ9KCIQRFypHppRmxkpkY03M7Bbr7+9pL/2AY3qAcMxbORpPVt3GNSVSBG3JwnjLE 7+YnGecDH3l+i74dwerjSMD8E8IP3rIREU66E/QA7qqp4PCMgFvsg9WsHgJFk/7Iecq/ cGqs0SJE+bYGVfApgOtnELzK5YAiti72+VywiOQfMvxxv2j/S9qtLqPx7H2xlj0gB+sQ IkEB+RMxyOWgLDSSNol2vFb6Z73m08VFQHWxcJe0n+602YngVGiiXH7I+9e3qCBUoeaf ztd2mTj03JaC9LEa3EEMjE+c2/5I/wBpaPtqc2rqXkTDPk4iwDfCkk/guMk97XLAptQc ES4A== 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=JH70FUKs/H5xc0SqDSr3TwuUIC5X1UMcDxHZPLyC8+c=; b=HSRZnya5c1fDKZ0+nWxdWNBS8s7PAyjLajyEbpmqBzq5voqlmPeUkMSHA4SH8/s3wz ieEYExGIMd2GTTyg+o2uFx2dwWXU+Cx4xe5WvNZ1D6oEacAi4wPBqYAFN6tQU4hUynlq ggZl3lgHUotYPfnW7uDdi8IpsHxI5XKRWCVRz8H8ESdPJD2bOONjOo2yPlDN332qxoDI EaIh4lkmOomUK2ZMm48ZOBLEszzQWVbo/3waA5wl0uV64c9bOje9WRhzJ9Pk7cVt1ZVm KVb14Qp42Y0jwPBO9U8L5RzsdA+vKdmvm4mqUMGXxxo5HHURQWC4vskYBNqN1EadCQSA /RPA== X-Gm-Message-State: AKGB3mKe/DPZQAaaqC0tKt4Dtdxea0VVWGlPHlh7fIHXpsf13WwnjTan njwV/2UPiFKGihdtibyJM51Pqw== X-Google-Smtp-Source: ACJfBoubjd/75zMTliS3WrhtedIqkbkxf4ba2fD5tT2fH7D8+F/r6CK95OL1B6xsmfkTqopTktsjRA== X-Received: by 10.84.240.203 with SMTP id l11mr2127065plt.211.1515003810014; Wed, 03 Jan 2018 10:23:30 -0800 (PST) Received: from localhost.localdomain ([240f:4:c2bc:1:609a:ff0a:6b9e:a233]) by smtp.gmail.com with ESMTPSA id s81sm4276325pfg.60.2018.01.03.10.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jan 2018 10:23:29 -0800 (PST) From: Akinobu Mita To: linux-media@vger.kernel.org Cc: Akinobu Mita , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH v2 4/4] media: mt9m111: add V4L2_CID_TEST_PATTERN control Date: Thu, 4 Jan 2018 03:22:47 +0900 Message-Id: <1515003767-12006-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515003767-12006-1-git-send-email-akinobu.mita@gmail.com> References: <1515003767-12006-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The mt9m111 has the test pattern generator features. This makes use of it through V4L2_CID_TEST_PATTERN control. Cc: Sakari Ailus Cc: Mauro Carvalho Chehab Signed-off-by: Akinobu Mita --- * Changelog v2 - Fix typo s/meida/media/ in the patch title, noticed by Sakari Ailus drivers/media/i2c/mt9m111.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c index e1d5032..d74f254 100644 --- a/drivers/media/i2c/mt9m111.c +++ b/drivers/media/i2c/mt9m111.c @@ -92,6 +92,7 @@ */ #define MT9M111_OPER_MODE_CTRL 0x106 #define MT9M111_OUTPUT_FORMAT_CTRL 0x108 +#define MT9M111_TPG_CTRL 0x148 #define MT9M111_REDUCER_XZOOM_B 0x1a0 #define MT9M111_REDUCER_XSIZE_B 0x1a1 #define MT9M111_REDUCER_YZOOM_B 0x1a3 @@ -124,6 +125,7 @@ #define MT9M111_OUTFMT_AVG_CHROMA (1 << 2) #define MT9M111_OUTFMT_SWAP_YCbCr_C_Y_RGB_EVEN (1 << 1) #define MT9M111_OUTFMT_SWAP_YCbCr_Cb_Cr_RGB_R_B (1 << 0) +#define MT9M111_TPG_SEL_MASK GENMASK(2, 0) /* * Camera control register addresses (0x200..0x2ff not implemented) @@ -706,6 +708,25 @@ static int mt9m111_set_autowhitebalance(struct mt9m111 *mt9m111, int on) return reg_clear(OPER_MODE_CTRL, MT9M111_OPMODE_AUTOWHITEBAL_EN); } +static const char * const mt9m111_test_pattern_menu[] = { + "Disabled", + "Vertical monochrome gradient", + "Flat color type 1", + "Flat color type 2", + "Flat color type 3", + "Flat color type 4", + "Flat color type 5", + "Color bar", +}; + +static int mt9m111_set_test_pattern(struct mt9m111 *mt9m111, int val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); + + return mt9m111_reg_mask(client, MT9M111_TPG_CTRL, val, + MT9M111_TPG_SEL_MASK); +} + static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl) { struct mt9m111 *mt9m111 = container_of(ctrl->handler, @@ -724,6 +745,8 @@ static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl) return mt9m111_set_autoexposure(mt9m111, ctrl->val); case V4L2_CID_AUTO_WHITE_BALANCE: return mt9m111_set_autowhitebalance(mt9m111, ctrl->val); + case V4L2_CID_TEST_PATTERN: + return mt9m111_set_test_pattern(mt9m111, ctrl->val); } return -EINVAL; @@ -968,6 +991,10 @@ static int mt9m111_probe(struct i2c_client *client, v4l2_ctrl_new_std_menu(&mt9m111->hdl, &mt9m111_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, V4L2_EXPOSURE_AUTO); + v4l2_ctrl_new_std_menu_items(&mt9m111->hdl, + &mt9m111_ctrl_ops, V4L2_CID_TEST_PATTERN, + ARRAY_SIZE(mt9m111_test_pattern_menu) - 1, 0, 0, + mt9m111_test_pattern_menu); mt9m111->subdev.ctrl_handler = &mt9m111->hdl; if (mt9m111->hdl.error) { ret = mt9m111->hdl.error;