From patchwork Wed Dec 20 16:33:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10125925 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 B1C7260388 for ; Wed, 20 Dec 2017 16:34:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A51E628A0F for ; Wed, 20 Dec 2017 16:34:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A06F2917C; Wed, 20 Dec 2017 16:34:00 +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 445BE28A0F for ; Wed, 20 Dec 2017 16:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755497AbdLTQd6 (ORCPT ); Wed, 20 Dec 2017 11:33:58 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34943 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753433AbdLTQd5 (ORCPT ); Wed, 20 Dec 2017 11:33:57 -0500 Received: by mail-pg0-f68.google.com with SMTP id q20so12128293pgv.2 for ; Wed, 20 Dec 2017 08:33:57 -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=cUpmVb098bcz/Fyu1papGUaJkvAwf1W14Ju3ZNM2y2Q=; b=iNo47uITGrTXH/shyzZmaB59jjw7qFTwdhGfGaiet7ZzgG0tcYgMACCmOhc/WZqbPu Hl5c0cKkdnwCVYWfe3WteLu8GzHESrjQCxdQivEFt0IIF2KXpqj2elqM2pROMwV7UFQ3 IrtQ+D7G9EYgfbD/lcwCEA4myVHy5iFM7Y0+5PwyQeyt0+u9IpO96xpZBKcrKr1YSnaR nRYd4OI1C7HxMLxKXhL5fRkzLc6JeDNJ8JIDHZO9aoBW7aWKgkxrZ0Kjph2PgzY3pgbI sjQmQQh0GL8MKH1IqxshLQq8O+y1fEDJRYQJYTZ+DJqgSc6p4zwO8P6IqFjQXQrX6NqY p7MA== 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=cUpmVb098bcz/Fyu1papGUaJkvAwf1W14Ju3ZNM2y2Q=; b=qldiQlWxP5WFoTSEMmsv/lgNpVDIUBC0t99h55eYnTN9HTBDhvI5ZenrnYJTYHYKNs pa4IpFvosYuIccsAT+toM2+baKui81aktlokuzbBLMel3Vd3wOCcFV2nVKd5hoozyigc Y7BGP5onTyWOlhgvlE0NYrb7ReUkEQqyaO2lFLO2M7pRdRVYdWQtqN5s/urzq0q+4I5L bPAyuM8TwzJO5hc8TsyAzl4Zz8B/QcTDDFWXmsb+xxLITmoS3/uhosJx/ItXImcFLtFk HPxssoUiuoL4BhWTzkSWu1F70usHrIRrY5z7TV4iz4ZwT3/gOBCGxVlanepr7cZv9s7L UN8A== X-Gm-Message-State: AKGB3mJAQvtx2ZwtqO9BjUqLScL797J0diWzqnhzC6RNRjzNEeWIHfsz ltZZwAS289Urq06anldFYlWkEg== X-Google-Smtp-Source: ACJfBotVNnLSiK86dzsGZagDKmNkinZRoV83sdVzg7l7Z4oyR+eGekFi4gO3kU9PXqDKnxS+0+fj9Q== X-Received: by 10.101.67.140 with SMTP id m12mr6663806pgp.51.1513787637331; Wed, 20 Dec 2017 08:33:57 -0800 (PST) Received: from localhost.localdomain ([240f:4:c2bc:1:6c87:ff94:43ae:eac3]) by smtp.gmail.com with ESMTPSA id m26sm30261286pgv.62.2017.12.20.08.33.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Dec 2017 08:33:56 -0800 (PST) From: Akinobu Mita To: linux-media@vger.kernel.org Cc: Akinobu Mita , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 4/4] meida: mt9m111: add V4L2_CID_TEST_PATTERN control Date: Thu, 21 Dec 2017 01:33:34 +0900 Message-Id: <1513787614-12008-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513787614-12008-1-git-send-email-akinobu.mita@gmail.com> References: <1513787614-12008-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 --- 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;