Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp274905lqb; Tue, 16 Apr 2024 15:48:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4M17FEZtkTtKlBGyqGyTl3iYiz1jUWx9hmQ/koFllwhTXK0I2VCBS635jFgwEntXH4x37Ujk9gRFhOAFn2XsHoI1dgpEMh+8w4WFkaA== X-Google-Smtp-Source: AGHT+IEIKDOZe4UV3ctgHWd7e0RB3ermaOOWQXGYV2l9Ur8W2yYZAZlbsu0tqhSjPC7viuratODZ X-Received: by 2002:a05:620a:1365:b0:78d:6168:e759 with SMTP id d5-20020a05620a136500b0078d6168e759mr14470695qkl.26.1713307718679; Tue, 16 Apr 2024 15:48:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713307718; cv=pass; d=google.com; s=arc-20160816; b=wWB4EVyVflqUtN+XRTHTYYVzbR/YMkC58r2Ykm8hAlmwg+G12jqalC/2gnoPP+wvtW ZGEaBeYIQoPbJVvFIaFij2RucEXXryGp7FQ/GZWI9O0u0XrdJ9yIoSkkR4rT6LOrwKwt JVS6EE2zvyHrFsWMiZwXj5una4cIiuhqzZep+u6OLxodnAReSZ9ZL74yWu7KclTnv1y6 UWz+9DW7UqoY3qyS9mD6GkYR0DYwv6SeLP9opVSBeFoIsuVtBJ1cDN1aTQIa5cdRFIbJ EB4KRiD4F5304+91XrJxZSZlVR0/IdEmBGhyh6dfnjoDaHkgRZneA1xPW0LLTp5edcOQ e6Lg== ARC-Message-Signature: i=2; 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=lfYWLG20tWLCctmjoEIlSfMzY43ed7+aAxJ9RfPojYc=; fh=+KXifZopFNtS/oeVLCNsMoPyGwtJvbxqFCpIc4edyJs=; b=DzYArmGQaqIdFMwSM9L9+TJ0lMsEID8TiGPhdwR24EtxEIZ0VtK7VoCpczVtF/pnwJ ANKiRZWEZy6J6mGQLsLfwf3VlZvxZWKL75Hnnczphd6XFa6noGdqB5fpmlCNTNhlNgFy /c9vnhJLOpvWflFQ5RbsKtHmZwnGY7lbSlu3BTq/DnbmKsDeWB96q1TXEruQoNj2orpw siB3gJZNJiiiWa80rel9TBfGUGCWc9RnYSb/e+5wKUv9Zvx1DtP955kHQOhNAd6ug1Zk Q/z1ZvqWfOo9F0Jd/XzLFtGj8oD53y0j7szoTegvZctfl+2z+/UQple9dQE78dhDEW5V TAGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hoLxRmHZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-147713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147713-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ou6-20020a05620a620600b0078edf0c16c5si7038200qkn.534.2024.04.16.15.48.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 15:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hoLxRmHZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-147713-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147713-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B7A7B1C22C54 for ; Tue, 16 Apr 2024 22:48:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00C3613A3E8; Tue, 16 Apr 2024 22:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hoLxRmHZ" Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 6B86D13CA9E; Tue, 16 Apr 2024 22:45:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713307549; cv=none; b=XFHgjRsQDhbT/x/eh4WAPZh9xfaEXaCuzWJ84624OZnQgxm6lEYblD0a3UuKyCguTCPMumyX3m7fe4HiWzLyeBR4CJNgAgRVtPWw6gjNGSD42p3PYFP/o9l+8W8iVQFuP4kvFnE0FMNG7KmIgh26KOqdGqMHHLJAHgZpfY/mFIw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713307549; c=relaxed/simple; bh=nQLaOOi1m3INUw8IYeGsWUSR1Y5F/FcGFOzChmGZ6gQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qn8amzr+g1+189PlDh9xGwT68gKdSIlaR+g1u9LGY2TvcKmk/JDSnzlIe85y8y/iFzrnHSMMnqb254B8nsGdeGWyN2jZpyHIGjG2VAj7I0J4Lx4wDfB0LGJqRr/m618DjwvLnAL7H4F9tO78kG2CHS+vESrpL3lWpzRmlaE3UWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hoLxRmHZ; arc=none smtp.client-ip=209.85.167.51 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-lf1-f51.google.com with SMTP id 2adb3069b0e04-518f8a69f82so2907013e87.2; Tue, 16 Apr 2024 15:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713307545; x=1713912345; 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=lfYWLG20tWLCctmjoEIlSfMzY43ed7+aAxJ9RfPojYc=; b=hoLxRmHZqBRIgxPvpIdrN7Ba5ct5GH5g+/JS0Vqn2KiT+J/gsTH9LFx5JzHAEdAH1h QM/lc/muiQxfJBZ+lvW/qYIh1mAPGFSAy5ymwscXnDk7Eyx/fU+NjwpNtF3ttWIsuy99 VAwS5rLw3Bm/tDZR7uLH/U6oKyyldN29qu5ohHyUIGiLz+wfz0yIeRM3PjuMjzWGbSkA v9dPN9lO/pg6HPs6ZrBeZrage3vhROlghDoZP7WRikCzb89B3lxilnyjjthmvuBiHZyL qALOyF9L4Y2lzBoSpbCRc+mavJ8A6vcDOgfmOkjJxGRHEx4d3ONg516LF/T/Rp0PteUb EGFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713307545; x=1713912345; 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=lfYWLG20tWLCctmjoEIlSfMzY43ed7+aAxJ9RfPojYc=; b=DggCiFziFVQup3d63kKsynbQTUnLg6j0tFAi7emCfKp4ZJ+r1JXvakGzzgjrwcJeqE 1/OXqK8AhUK8GryTGQsKLlSC3ZzsmeoQ1q+sdagTsJMZhDnHwyfnmoUArXJnJe1P/epR ZlQC08V2epkOVuwY4PRDugYaH8i2g0+cq8bTehwDlrXJbqtGHuimft+p/ZSAI+iwHQ61 YAtl7pzWvVRuFmQyYMzeBk0As2ss1A70T8uKCzwuTtOFxbKngp8EHm/s7WZRvhAYmF0O 3X5HDuIwjdK1EKrKKS48IyrK3s3Be1qCRKplBs9S8e/4EiAInkQtXYk9W5VcBYNZXUpt XZqg== X-Forwarded-Encrypted: i=1; AJvYcCWfU8nfmkE7lor0HPF+4c/nh/gMjfekhQ0gJgSAaSE0Q+oH8Ul4GPbLsXPt0WL9feo1SvyUZnpTL+ZPgIsT0Iy8v3aVi6Npw2DVkNQN X-Gm-Message-State: AOJu0YxBFSx4swRn+WO6sClxuTaMi1AKfKVLj3F1a/h3Xaeo5OgRj7W/ kD8Y5ZOtTzrtZdgyF+OSmaEbjHwamrAUv7Bhx5VmS7bmPTwg1bXmQhdjtmWyPKs= X-Received: by 2002:a19:7510:0:b0:518:c7e5:d1ba with SMTP id y16-20020a197510000000b00518c7e5d1bamr5931604lfe.63.1713307545291; Tue, 16 Apr 2024 15:45:45 -0700 (PDT) Received: from localhost (95-24-153-47.broadband.corbina.ru. [95.24.153.47]) by smtp.gmail.com with ESMTPSA id y5-20020a196405000000b00515d407aaa0sm1756270lfb.252.2024.04.16.15.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 15:45:44 -0700 (PDT) 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 , Kieran Bingham Subject: [PATCH v5 12/16] media: i2c: ov4689: Implement vflip/hflip controls Date: Wed, 17 Apr 2024 01:45:20 +0300 Message-ID: <20240416224524.1511357-13-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240416224524.1511357-1-mike.rudenko@gmail.com> References: <20240416224524.1511357-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 supports horizontal and vertical flipping. Add appropriate controls to the driver. Toggling both array flip and digital flip bits allows to achieve flipping while maintaining output Bayer order. Note that the default value of hflip control corresponds to both bits set, as it was before this patch. Signed-off-by: Mikhail Rudenko Reviewed-by: Kieran Bingham --- drivers/media/i2c/ov4689.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c index e478c1f7a8c2..aed87a1b6141 100644 --- a/drivers/media/i2c/ov4689.c +++ b/drivers/media/i2c/ov4689.c @@ -42,6 +42,14 @@ #define OV4689_REG_VTS CCI_REG16(0x380e) #define OV4689_VTS_MAX 0x7fff +#define OV4689_REG_TIMING_FORMAT1 CCI_REG8(0x3820) /* Vertical */ +#define OV4689_REG_TIMING_FORMAT2 CCI_REG8(0x3821) /* Horizontal */ +#define OV4689_TIMING_FLIP_MASK GENMASK(2, 1) +#define OV4689_TIMING_FLIP_ARRAY BIT(1) +#define OV4689_TIMING_FLIP_DIGITAL BIT(2) +#define OV4689_TIMING_FLIP_BOTH (OV4689_TIMING_FLIP_ARRAY |\ + OV4689_TIMING_FLIP_DIGITAL) + #define OV4689_REG_TEST_PATTERN CCI_REG8(0x5040) #define OV4689_TEST_PATTERN_ENABLE 0x80 #define OV4689_TEST_PATTERN_DISABLE 0x0 @@ -183,7 +191,6 @@ static const struct cci_reg_sequence ov4689_2688x1520_regs[] = { { CCI_REG8(0x3811), 0x08 }, /* H_WIN_OFF_L h_win_off[7:0] = 0x08*/ { CCI_REG8(0x3813), 0x04 }, /* V_WIN_OFF_L v_win_off[7:0] = 0x04 */ { CCI_REG8(0x3819), 0x01 }, /* VSYNC_END_L vsync_end_point[7:0] = 0x01 */ - { CCI_REG8(0x3821), 0x06 }, /* TIMING_FORMAT2 array_h_mirror = 1, digital_h_mirror = 1 */ /* OTP control */ { CCI_REG8(0x3d85), 0x36 }, /* OTP_REG85 OTP_power_up_load_setting_enable = 1, @@ -607,6 +614,16 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl) (ctrl->val + ov4689->cur_mode->width) / OV4689_HTS_DIVIDER, &ret); break; + case V4L2_CID_VFLIP: + cci_update_bits(regmap, OV4689_REG_TIMING_FORMAT1, + OV4689_TIMING_FLIP_MASK, + ctrl->val ? OV4689_TIMING_FLIP_BOTH : 0, &ret); + break; + case V4L2_CID_HFLIP: + cci_update_bits(regmap, OV4689_REG_TIMING_FORMAT2, + OV4689_TIMING_FLIP_MASK, + ctrl->val ? 0 : OV4689_TIMING_FLIP_BOTH, &ret); + break; default: dev_warn(dev, "%s Unhandled id:0x%x, val:0x%x\n", __func__, ctrl->id, ctrl->val); @@ -637,7 +654,7 @@ static int ov4689_initialize_controls(struct ov4689 *ov4689) handler = &ov4689->ctrl_handler; mode = ov4689->cur_mode; - ret = v4l2_ctrl_handler_init(handler, 10); + ret = v4l2_ctrl_handler_init(handler, 12); if (ret) return ret; @@ -677,6 +694,9 @@ static int ov4689_initialize_controls(struct ov4689 *ov4689) ARRAY_SIZE(ov4689_test_pattern_menu) - 1, 0, 0, ov4689_test_pattern_menu); + v4l2_ctrl_new_std(handler, &ov4689_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); + v4l2_ctrl_new_std(handler, &ov4689_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); + if (handler->error) { ret = handler->error; dev_err(ov4689->dev, "Failed to init controls(%d)\n", ret); -- 2.44.0