Received: by 2002:ac8:6d01:0:b0:423:7e07:f8e4 with SMTP id o1csp6902116qtt; Mon, 18 Dec 2023 09:47:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHU3xiAnw26XUm+NzlAeK1i+MpwVB9ihh0DkA8jWm4fWDizzDKQE51vn+zH3S8DepgJyGWW X-Received: by 2002:a05:6a21:609:b0:18c:42ab:fced with SMTP id ll9-20020a056a21060900b0018c42abfcedmr16706019pzb.47.1702921675250; Mon, 18 Dec 2023 09:47:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702921675; cv=none; d=google.com; s=arc-20160816; b=OB1IS0zhoQ6wzzMJxkTZDjl5c5OXNix3JY8via5H3jRGNTBjmW8lKFiiUBWIpckxgx oBK/0uYL77vDWhvm3POYbF1DNpgHm3lDfSbynoiZRx8MkJ27gwfVQ72ju0PAKVY54tBG RQdxdLMA3xy7iPtLuDUcUwSa3kENoEdwpKDdVLWTlU1rfqMnlTMgJSKcmOqe4VnjFZwV H5uqlqGVAoZtxvzNEZsSWpw9repJ1+h4OwCEyue558GV7A3aNRz3nTkU7Vx7xchU6uNK mI8bGGbA96MLYW2I0cFE8XFFD3G7yCVEpQjZ68W0w0ImaQPw2wATrH1fcMWFBS23jnga gE9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7dk2TKVbYraAu74v7NaSM1t18f6z4SZSFZ1EWmH7B+A=; fh=Ft8dYvEuFIKwnehVwpL0WG7QMIrRLMi0wgN4ll940k8=; b=KeJrAxvV9jrGTIYgJ21w062+nLajPuH19kQ8B+VQsGMeeFF21o18eLbt/LT602iKou H+MRSCbYmTWKm8xhLdSUqL4WRaV2861iae6tg/i9hOLakJlSt241inez93FtHLtidcTT j+aqoEuUQkMGVKYh6+1kxP4e8KOBqN8+58g35CrELkwlvyCrq5KqLQecP/LTwatdjI5Z l5QHe47mpt/FQbTxZ+slJO4vt20oy7kdL8aqK9Fv5FS5raoavYDBc084h+Te6jp/tywN GfNstURpKd5yMD3cdwXM1AR/TonSP6USy4eyUE2/p1S55fIKTSlCAhsGMvL5JZIliq2R jfpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CDib+SPD; spf=pass (google.com: domain of linux-kernel+bounces-4199-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4199-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 37-20020a17090a09a800b0028b62d1ec14si3669247pjo.103.2023.12.18.09.47.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:47:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4199-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CDib+SPD; spf=pass (google.com: domain of linux-kernel+bounces-4199-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4199-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0828EB2379A for ; Mon, 18 Dec 2023 17:46:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 604647BF07; Mon, 18 Dec 2023 17:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CDib+SPD" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E28BC740BC; Mon, 18 Dec 2023 17:41:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2cc4e15605aso39825581fa.0; Mon, 18 Dec 2023 09:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702921276; x=1703526076; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7dk2TKVbYraAu74v7NaSM1t18f6z4SZSFZ1EWmH7B+A=; b=CDib+SPD87rYhO6EsoDjcOkOa9D5nY3ajlJLmrSUA0wyDAIf6YousNX5lf1isnD/d2 ZmmGogeQoyj+JEcE2c9U/K/4j/WYgJfNWsCkgq74f8QMaO9Vbco6QeYyCvC0b8IIll9M 1ooU2RrDH3ci9apPmbbno5VzK1241YK4MM7UFzN0RfcsG92av9ddt+8iJYPsUUeqhiKM 1AOFGqGOICeHEuB5WOy/2V503t2nlGcPLYXn9CIAuAuO/L71cG8jwFma829vE/gSJvY0 31Gw/yKPGPpe8A4yrpKZ3jfKFM/cgzwWN4LFpZ7pB38hqEFhFfVvAjZes1V/kz2IEjE9 haeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702921276; x=1703526076; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7dk2TKVbYraAu74v7NaSM1t18f6z4SZSFZ1EWmH7B+A=; b=pDYOZAdKJj052vjHI8ZNN43oUdtnSzPG4yc95OH/TkUei9QiBvj1evXE+P0yP0TTws Y2oQrGPxc536h2FOQEZKiYgNwkfuiD9KUODwEgIy+MGjVry49CewiTuCip3fuLOBGtNQ GJ2usShDtuF5omwl5lUv3tM1KVIsaRwZ5jixuVNtNPAw3OeBnXrRXYBofObS+OObUHS6 qEArH3VEM5xQDe5hNa2kShXxFElPkJuljzjTa03TY1R6Gh2rd3Sq8PV499gl96vC5YLu 5XP2EtV+yd+QNmIWl8MEcJaO43ywS9FiwZQkvNi1tVOwCQxNiozWW7A/Ffxr2LMYMR8n SXtw== X-Gm-Message-State: AOJu0YzfwLhjDCGQuSeNSFRX1QcVaWNdkFoZla+9ZVs+nRUgKLDtUI15 QF9SbwAguXOzPACnRwimQu7sSgWA6dbfJg== X-Received: by 2002:a2e:998f:0:b0:2cc:4547:1892 with SMTP id w15-20020a2e998f000000b002cc45471892mr3267791lji.34.1702921275695; Mon, 18 Dec 2023 09:41:15 -0800 (PST) Received: from localhost ([83.149.246.185]) by smtp.gmail.com with ESMTPSA id d8-20020a05651c01c800b002ca34ad9e8bsm3563871ljn.138.2023.12.18.09.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 09:41:15 -0800 (PST) From: Mikhail Rudenko To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sakari Ailus , Laurent Pinchart , Jacopo Mondi , Tommaso Merciai , Christophe JAILLET , Dave Stevenson , Mauro Carvalho Chehab , Mikhail Rudenko Subject: [PATCH v2 14/20] media: i2c: ov4689: Implement manual color balance controls Date: Mon, 18 Dec 2023 20:40:35 +0300 Message-ID: <20231218174042.794012-15-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218174042.794012-1-mike.rudenko@gmail.com> References: <20231218174042.794012-1-mike.rudenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The OV4689 sensor has separate red and blue gain settings (up to 4x). Implement appropriate controls in the driver. Default gain values are not modified. Signed-off-by: Mikhail Rudenko --- drivers/media/i2c/ov4689.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c index 579362570ba4..b43fb1d7b15f 100644 --- a/drivers/media/i2c/ov4689.c +++ b/drivers/media/i2c/ov4689.c @@ -56,6 +56,13 @@ #define OV4689_TIMING_FLIP_BOTH (OV4689_TIMING_FLIP_ARRAY |\ OV4689_TIMING_FLIP_DIGITAL) +#define OV4689_REG_WB_GAIN_RED CCI_REG16(0x500c) +#define OV4689_REG_WB_GAIN_BLUE CCI_REG16(0x5010) +#define OV4689_WB_GAIN_MIN 1 +#define OV4689_WB_GAIN_MAX 0xfff +#define OV4689_WB_GAIN_STEP 1 +#define OV4689_WB_GAIN_DEFAULT 0x400 + #define OV4689_REG_TEST_PATTERN CCI_REG8(0x5040) #define OV4689_TEST_PATTERN_ENABLE 0x80 #define OV4689_TEST_PATTERN_DISABLE 0x0 @@ -632,6 +639,12 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_DIGITAL_GAIN: cci_write(regmap, OV4689_REG_DIG_GAIN, ctrl->val, &ret); break; + case V4L2_CID_RED_BALANCE: + cci_write(regmap, OV4689_REG_WB_GAIN_RED, ctrl->val, &ret); + break; + case V4L2_CID_BLUE_BALANCE: + cci_write(regmap, OV4689_REG_WB_GAIN_BLUE, ctrl->val, &ret); + break; default: dev_warn(dev, "%s Unhandled id:0x%x, val:0x%x\n", __func__, ctrl->id, ctrl->val); @@ -662,7 +675,7 @@ static int ov4689_initialize_controls(struct ov4689 *ov4689) handler = &ov4689->ctrl_handler; mode = ov4689->cur_mode; - ret = v4l2_ctrl_handler_init(handler, 13); + ret = v4l2_ctrl_handler_init(handler, 15); if (ret) return ret; @@ -709,6 +722,14 @@ static int ov4689_initialize_controls(struct ov4689 *ov4689) OV4689_DIG_GAIN_MIN, OV4689_DIG_GAIN_MAX, OV4689_DIG_GAIN_STEP, OV4689_DIG_GAIN_DEFAULT); + v4l2_ctrl_new_std(handler, &ov4689_ctrl_ops, V4L2_CID_RED_BALANCE, + OV4689_WB_GAIN_MIN, OV4689_WB_GAIN_MAX, + OV4689_WB_GAIN_STEP, OV4689_WB_GAIN_DEFAULT); + + v4l2_ctrl_new_std(handler, &ov4689_ctrl_ops, V4L2_CID_BLUE_BALANCE, + OV4689_WB_GAIN_MIN, OV4689_WB_GAIN_MAX, + OV4689_WB_GAIN_STEP, OV4689_WB_GAIN_DEFAULT); + if (handler->error) { ret = handler->error; dev_err(ov4689->dev, "Failed to init controls(%d)\n", ret); -- 2.43.0