From patchwork Mon Nov 12 16:00:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10678903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F0A6139B for ; Mon, 12 Nov 2018 16:01:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F10AF2A1DA for ; Mon, 12 Nov 2018 16:01:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5AA42A1E0; Mon, 12 Nov 2018 16:01:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 828BD2A1B3 for ; Mon, 12 Nov 2018 16:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729531AbeKMBzI (ORCPT ); Mon, 12 Nov 2018 20:55:08 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45107 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbeKMBzI (ORCPT ); Mon, 12 Nov 2018 20:55:08 -0500 Received: by mail-pl1-f193.google.com with SMTP id r3-v6so3810166pls.12 for ; Mon, 12 Nov 2018 08:01:17 -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=yhUiDrEzvUj09wyq7BdC3fVDwb1/iNbP/fkqW+mPUAw=; b=DJWiQX9SjWbfum07RGyStqSH18axpmchtAs76+FApmKgiFnts5Fi99aKolMzw/I7CE guC7mxCYqq8C/o0EpKWH4wr+0sLD2lnnxr4iVWUYZCk7KFTyQVXx2kx9E8/BVrDsZ0uo +Ci9L11pNmH1WSHCDkfggVNY49es8kDwHOdvh2Dojg9CcGr9rku7G8gRo2mw8KychMo6 Bzfrh1BjueC78zRKgYE2OpCiWK0Asg0hyc17b159yXOcdIBDPOjLPhrKRUkLcq2VLB2e ccDzb1tgEnvfwDqx0+cbQuZGgmSUNe5Ggp8mkZF9MT7wiem0adMz9rkCfuPihhSJxDDt xjCA== 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=yhUiDrEzvUj09wyq7BdC3fVDwb1/iNbP/fkqW+mPUAw=; b=BaBGCsjdgQ+2Zdec1gYd3icRTVBvpLmN0ydmOT5w4ZuWkF0dn/ex74KAlj0qszvO8X 2cKXC252TQwNuAtXV3KUES5RoRcLSY9qF8KTAkkty5wpYVrC7oRMs9tS00kmJk03uPDt ZqQkDJHEt2adKmfwptlylPQdo/GqExsvY/9h3+/8dVCmcgdnY3JMOuQRPc2BJbc5Tiz9 t5YkM3VO3CBERKw3p9YPkHtmuJi1F4gE8z5HQBaMfONJd/rASdfmVyNTRfGbQ/QW+mU2 DmDvejckD1ciBzbT4QtELgEdmlaizhKJiPdp9ebdTdNY4NiZfL0U0uekJ5gsDaOgaK1O 2iEQ== X-Gm-Message-State: AGRZ1gKSX2IMF6AaF9gbIPpIdkjN+xAX4q/XiT+7egdYHAHQ4uRZqxvU XCVPqAKhAWDQqQ/0XodPbb/ElboI X-Google-Smtp-Source: AJdET5f9Z8tL+lL01xhEU8m/48yRVGXEBi/IN8//ZtQb2ML2fSJq7M3QnMisaudXtQnaOHbjoX2KIg== X-Received: by 2002:a17:902:9a07:: with SMTP id v7-v6mr1428977plp.14.1542038476464; Mon, 12 Nov 2018 08:01:16 -0800 (PST) Received: from mita-MS-7A45.lan ([240f:34:212d:1:4c9:76a6:795e:e9ef]) by smtp.gmail.com with ESMTPSA id v74-v6sm26777610pfk.12.2018.11.12.08.01.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Nov 2018 08:01:15 -0800 (PST) From: Akinobu Mita To: linux-media@vger.kernel.org Cc: Akinobu Mita , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 2/7] media: mt9m111: add V4L2_CID_COLORFX control Date: Tue, 13 Nov 2018 01:00:49 +0900 Message-Id: <1542038454-20066-3-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542038454-20066-1-git-send-email-akinobu.mita@gmail.com> References: <1542038454-20066-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 special camera effects feature. This makes use of it through V4L2_CID_COLORFX control. Cc: Sakari Ailus Cc: Mauro Carvalho Chehab Signed-off-by: Akinobu Mita --- drivers/media/i2c/mt9m111.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c index f4fc459..58d134d 100644 --- a/drivers/media/i2c/mt9m111.c +++ b/drivers/media/i2c/mt9m111.c @@ -102,6 +102,7 @@ #define MT9M111_REDUCER_XSIZE_A 0x1a7 #define MT9M111_REDUCER_YZOOM_A 0x1a9 #define MT9M111_REDUCER_YSIZE_A 0x1aa +#define MT9M111_EFFECTS_MODE 0x1e2 #define MT9M111_OUTPUT_FORMAT_CTRL2_A 0x13a #define MT9M111_OUTPUT_FORMAT_CTRL2_B 0x19b @@ -127,6 +128,7 @@ #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) +#define MT9M111_EFFECTS_MODE_MASK GENMASK(2, 0) /* * Camera control register addresses (0x200..0x2ff not implemented) @@ -727,6 +729,29 @@ static int mt9m111_set_test_pattern(struct mt9m111 *mt9m111, int val) MT9M111_TPG_SEL_MASK); } +static int mt9m111_set_colorfx(struct mt9m111 *mt9m111, int val) +{ + struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); + static const struct v4l2_control colorfx[] = { + { V4L2_COLORFX_NONE, 0 }, + { V4L2_COLORFX_BW, 1 }, + { V4L2_COLORFX_SEPIA, 2 }, + { V4L2_COLORFX_NEGATIVE, 3 }, + { V4L2_COLORFX_SOLARIZATION, 4 }, + }; + int i; + + for (i = 0; i < ARRAY_SIZE(colorfx); i++) { + if (colorfx[i].id == val) { + return mt9m111_reg_mask(client, MT9M111_EFFECTS_MODE, + colorfx[i].value, + MT9M111_EFFECTS_MODE_MASK); + } + } + + return -EINVAL; +} + static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl) { struct mt9m111 *mt9m111 = container_of(ctrl->handler, @@ -747,6 +772,8 @@ static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl) return mt9m111_set_autowhitebalance(mt9m111, ctrl->val); case V4L2_CID_TEST_PATTERN: return mt9m111_set_test_pattern(mt9m111, ctrl->val); + case V4L2_CID_COLORFX: + return mt9m111_set_colorfx(mt9m111, ctrl->val); } return -EINVAL; @@ -983,7 +1010,7 @@ static int mt9m111_probe(struct i2c_client *client, mt9m111->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; - v4l2_ctrl_handler_init(&mt9m111->hdl, 5); + v4l2_ctrl_handler_init(&mt9m111->hdl, 7); v4l2_ctrl_new_std(&mt9m111->hdl, &mt9m111_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); v4l2_ctrl_new_std(&mt9m111->hdl, &mt9m111_ctrl_ops, @@ -999,6 +1026,14 @@ static int mt9m111_probe(struct i2c_client *client, &mt9m111_ctrl_ops, V4L2_CID_TEST_PATTERN, ARRAY_SIZE(mt9m111_test_pattern_menu) - 1, 0, 0, mt9m111_test_pattern_menu); + v4l2_ctrl_new_std_menu(&mt9m111->hdl, &mt9m111_ctrl_ops, + V4L2_CID_COLORFX, V4L2_COLORFX_SOLARIZATION, + ~(BIT(V4L2_COLORFX_NONE) | + BIT(V4L2_COLORFX_BW) | + BIT(V4L2_COLORFX_SEPIA) | + BIT(V4L2_COLORFX_NEGATIVE) | + BIT(V4L2_COLORFX_SOLARIZATION)), + V4L2_COLORFX_NONE); mt9m111->subdev.ctrl_handler = &mt9m111->hdl; if (mt9m111->hdl.error) { ret = mt9m111->hdl.error;