From patchwork Fri Oct 28 16:08:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 620160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAF09FA3743 for ; Fri, 28 Oct 2022 16:15:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbiJ1QPJ (ORCPT ); Fri, 28 Oct 2022 12:15:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbiJ1QOf (ORCPT ); Fri, 28 Oct 2022 12:14:35 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54F3D22D5AE for ; Fri, 28 Oct 2022 09:12:40 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id v1so7189724wrt.11 for ; Fri, 28 Oct 2022 09:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=JeWWFLsBMicTh8QbfZGIQ4Lyp/QBEmA1qJ8tNk4fA4w=; b=l1w8Xz3nH73G79xP1RB7Zipo8S2iWY2GlxvqDwHuJdKDda5K7YljbB8xCMZYL6/vA8 zBoPUiqjXcqeDYByGsHJ3xqtBYfyRXpx7FW8b1jsthqnJtU1vhYRbGi3yltgeUCkENVQ SKoeKaOYOGvigLWaU8eNs+vCjy1SPkbMKPk9vUa7CbVx8p4Xs+XjOVJVdiXsJOXnZgx0 agcUoqP0kVfSz6SHIW7ktXcKpC//7eCdwgBDCYLU8Buh+VHdFr40zEXtqHMBHXSv0GyA vNdCBaNsTp7N9JODGAKWVcLCzAp2S/QiyXQgAJD5qYuApTzRcUvnIRpvzQAROX3m3aF7 ptow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=JeWWFLsBMicTh8QbfZGIQ4Lyp/QBEmA1qJ8tNk4fA4w=; b=gxBwJ8putRce4PWZyFyy4wrig6EN4tGejfGQttldV09HCwNlCeQUbQ4HKMDgxr/1H2 CJu+ba7IfylSkQ6pOVWl4EGz+O4Osq3lHedPvG7sbjhGheIWAAGnGWvq4rOvpEnicclo 79i4rYNIATuqWhhG1JJyxjpVqyAsHUScmjMW025Se6s3SJggareDQi7v1yH5PJTWH49J eEZa2vzRS7xlUpSQYCw/ei9zVxjoL3Ea9++9EoFZjS8qCzSXmdauYuPSPS2CVd/eVY/f 4tFkMsaSt4qckWxlUbthOaYEdSc9yutf1mpV2L06x6i1B5JZooTulM1VkbNbCJyH039u O6IA== X-Gm-Message-State: ACrzQf1aBowcosjmJWH7opn6E4pD7xfg/suEevtp7bVmCDNqbJNNj8Wl eKNBrozsoCp3VBhAewTE8JKmIw== X-Google-Smtp-Source: AMsMyM5Y1j6d+FnPqZtaM+34P8eUYSvh6Gns/eWEqhPw6Ks557qCsOyjI7SKmtIzgcw8/J3nX80f2w== X-Received: by 2002:a05:6000:1b90:b0:236:9701:7ce5 with SMTP id r16-20020a0560001b9000b0023697017ce5mr52229wru.631.1666973558926; Fri, 28 Oct 2022 09:12:38 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:38 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 01/16] media: i2c: ov9282: Remove duplication of registers Date: Fri, 28 Oct 2022 17:08:47 +0100 Message-Id: <20221028160902.2696973-2-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org TIMING_VTS (registers 0x380e/f), EXPOSURE (registers 0x3500/1/2), and GAIN (0x3509) are all set from ov9282_update_exp_gain as part of the control handler, therefore they do not need to be in the main list of registers. Remove them. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index df144a2f6eda..0c604050b4e5 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -163,14 +163,10 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3030, 0x10}, {0x3039, 0x32}, {0x303a, 0x00}, - {0x3500, 0x00}, - {0x3501, 0x5f}, - {0x3502, 0x1e}, {0x3503, 0x08}, {0x3505, 0x8c}, {0x3507, 0x03}, {0x3508, 0x00}, - {0x3509, 0x10}, {0x3610, 0x80}, {0x3611, 0xa0}, {0x3620, 0x6e}, @@ -204,8 +200,6 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x380b, 0xd0}, {0x380c, 0x05}, {0x380d, 0xfa}, - {0x380e, 0x06}, - {0x380f, 0xce}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, From patchwork Fri Oct 28 16:08:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 620156 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C115BFA3743 for ; Fri, 28 Oct 2022 16:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230315AbiJ1QPX (ORCPT ); Fri, 28 Oct 2022 12:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbiJ1QOg (ORCPT ); Fri, 28 Oct 2022 12:14:36 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A719C6562 for ; Fri, 28 Oct 2022 09:12:44 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id v130-20020a1cac88000000b003bcde03bd44so6881075wme.5 for ; Fri, 28 Oct 2022 09:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=kYMzRFBY8rMeXFOhCy9Ay0b//t6qEd1yKgrgKU9jdLY=; b=B0/jGMBzl+XqL3LfUglpUSpcwVgLPkdZJSW4A1KzEqq9eJw+PCWtbWAZ2OBQXOZwhS UT0goyHsOnn6RAvFbAZ/7zLZnfiGkJ6AT86RhA9g5FgTctT4f4bKNgM7pDmnp6TL+Hz9 iuukXTaJQP0AhG/agf5Dbjr2iEPDnlWvtPuUfh7aUe3TOf2C1HxtFYy3kDNf76RY9JxH LqJanWtaF1UI/SVM8syi6ceOSZA2W2HLrt3zby11FK3nwjsDMAx23BqrI4Aul7F27vXG wO0a6KqOzN9q5L+TCUkR/q/iQgbLTUuczg2qKcYM4lAMRDEFj1zpN/D2FCxpoClcH0Hy Nnkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=kYMzRFBY8rMeXFOhCy9Ay0b//t6qEd1yKgrgKU9jdLY=; b=uO4G0X3VL56dPMYUoYafNBC1NTYVJtKRwfwUYjd6+/iuRtmBuG3u9ruxwOxpci2rEo uv2CmRkpxUg1sAITDjX0Cr39MBXBUEJebqNVUPGyEIAwx6kEGMxmCo6ZWrgEXu9vPdwd vZBFgLGFV3/X7jgRpTsPEVgds3AbKS2AvFsCqEBLxFsWigw9jEZzRZW6u6cCkVkY+9pr 5In/le5X0WDqK/oHfyECSvuylE3/w7ur9ncw2JaEWikha7/GpkiwKU9M+y9Ps3iLbTOJ 3uF1GIzO/7NWmwsgVPW6Rmb28jpc07zkB0wa0MGUoi5401s7GO6rPHy6xhSeYKIxl5or 1oNw== X-Gm-Message-State: ACrzQf1NDEJrvtxY8piRu0Zo4+KhS52EjnJ2IwKqxkEeR4tQJnJynNZF 8lpOJ6Iz6cyiq2zwY7aZYd1P1g== X-Google-Smtp-Source: AMsMyM7oHH6Jtios1Hn4idfmzyiuJSx9MAaQV9m6+vO1v6kK328onl/K0mBcfAexOHff907AU72KMQ== X-Received: by 2002:a05:600c:1d87:b0:3cf:543a:4d72 with SMTP id p7-20020a05600c1d8700b003cf543a4d72mr5850130wms.126.1666973563231; Fri, 28 Oct 2022 09:12:43 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:42 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 02/16] media: i2c: ov9282: Split registers into common and mode specific Date: Fri, 28 Oct 2022 17:08:48 +0100 Message-Id: <20221028160902.2696973-3-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently only one mode is supported, so all registers were dropped in one list. In preparation for adding more modes, split out the common registers from those which configure the mode. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 77 +++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 0c604050b4e5..6999ce869a1b 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -147,8 +147,8 @@ static const s64 link_freq[] = { OV9282_LINK_FREQ, }; -/* Sensor mode registers */ -static const struct ov9282_reg mode_1280x720_regs[] = { +/* Common registers */ +static const struct ov9282_reg common_regs[] = { {0x0302, 0x32}, {0x030d, 0x50}, {0x030e, 0x02}, @@ -179,13 +179,49 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x372d, 0x22}, {0x3731, 0x80}, {0x3732, 0x30}, - {0x3778, 0x00}, {0x377d, 0x22}, {0x3788, 0x02}, {0x3789, 0xa4}, {0x378a, 0x00}, {0x378b, 0x4a}, {0x3799, 0x20}, + {0x3881, 0x42}, + {0x38a8, 0x02}, + {0x38a9, 0x80}, + {0x38b1, 0x00}, + {0x38c4, 0x00}, + {0x38c5, 0xc0}, + {0x38c6, 0x04}, + {0x38c7, 0x80}, + {0x3920, 0xff}, + {0x4010, 0x40}, + {0x4043, 0x40}, + {0x4307, 0x30}, + {0x4317, 0x00}, + {0x4501, 0x00}, + {0x450a, 0x08}, + {0x4601, 0x04}, + {0x470f, 0x00}, + {0x4f07, 0x00}, + {0x4800, 0x20}, + {0x5000, 0x9f}, + {0x5001, 0x00}, + {0x5e00, 0x00}, + {0x5d00, 0x07}, + {0x5d01, 0x00}, + {0x0101, 0x01}, + {0x1000, 0x03}, + {0x5a08, 0x84}, +}; + +struct ov9282_reg_list common_regs_list = { + .num_of_regs = ARRAY_SIZE(common_regs), + .regs = common_regs, +}; + +/* Sensor mode registers */ +static const struct ov9282_reg mode_1280x720_regs[] = { + {0x3778, 0x00}, {0x3800, 0x00}, {0x3801, 0x00}, {0x3802, 0x00}, @@ -208,40 +244,13 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3815, 0x11}, {0x3820, 0x3c}, {0x3821, 0x84}, - {0x3881, 0x42}, - {0x38a8, 0x02}, - {0x38a9, 0x80}, - {0x38b1, 0x00}, - {0x38c4, 0x00}, - {0x38c5, 0xc0}, - {0x38c6, 0x04}, - {0x38c7, 0x80}, - {0x3920, 0xff}, {0x4003, 0x40}, {0x4008, 0x02}, {0x4009, 0x05}, {0x400c, 0x00}, {0x400d, 0x03}, - {0x4010, 0x40}, - {0x4043, 0x40}, - {0x4307, 0x30}, - {0x4317, 0x00}, - {0x4501, 0x00}, {0x4507, 0x00}, {0x4509, 0x80}, - {0x450a, 0x08}, - {0x4601, 0x04}, - {0x470f, 0x00}, - {0x4f07, 0x00}, - {0x4800, 0x20}, - {0x5000, 0x9f}, - {0x5001, 0x00}, - {0x5e00, 0x00}, - {0x5d00, 0x07}, - {0x5d01, 0x00}, - {0x0101, 0x01}, - {0x1000, 0x03}, - {0x5a08, 0x84}, }; /* Supported sensor mode configurations */ @@ -653,6 +662,14 @@ static int ov9282_start_streaming(struct ov9282 *ov9282) const struct ov9282_reg_list *reg_list; int ret; + /* Write common registers */ + ret = ov9282_write_regs(ov9282, common_regs_list.regs, + common_regs_list.num_of_regs); + if (ret) { + dev_err(ov9282->dev, "fail to write common registers"); + return ret; + } + /* Write sensor mode registers */ reg_list = &ov9282->cur_mode->reg_list; ret = ov9282_write_regs(ov9282, reg_list->regs, reg_list->num_of_regs); From patchwork Fri Oct 28 16:08:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 619743 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D78D5FA3742 for ; Fri, 28 Oct 2022 16:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbiJ1QPK (ORCPT ); Fri, 28 Oct 2022 12:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbiJ1QOg (ORCPT ); Fri, 28 Oct 2022 12:14:36 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0230DFB6 for ; Fri, 28 Oct 2022 09:12:45 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id az22-20020a05600c601600b003c6b72797fdso4150446wmb.5 for ; Fri, 28 Oct 2022 09:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=/J1qiec3Yxt5b0ju8tgueYhZ2XcpMHPMQXJUPdcOjXQ=; b=cjunyKNmcjzxozkCvnw59YyFJPhKvjnbaJGWVxaRMnufrd9It2H84kEzKtIOYsbnDT iK8KBr0ltQs8+BS+8gPb5Gy51EUQbZEtQCQmunpvsnqrpadP5KEz8fVa217PoSfwA+6G sht30UOQEACMtRjMtaETU8fn9boTKYu/3GYygChlqiAEgEUVs84PJ3vBB/3QmhJpvlbm AJGq5Yzls4/VoBUl5CSZ+qaZE9vPh/CGWEkbnamOHTHJZnVqxyXiRRQwKkvMQvun4HTM oBgleKQiYbDBlWcDBVO3aQG/zTh3ZoKOFrX/iTH2GyBeiGm5xdPNv7SjrvQtb2W/q37g ZM1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/J1qiec3Yxt5b0ju8tgueYhZ2XcpMHPMQXJUPdcOjXQ=; b=y3Xa/a3vt0pSRkYpsYRlBnM8GB24JZ1UjC2Jfvk2ZXbUy6GKF1+yznKvO5nWexmcKm aTvF66iGbJQzUK6ZvjkgQhqGMKRPZOQi87cZpeEcA9sfuDxdyIdRfuwBNsAv81s2K7Qj ANypkXs3h1WVDWo9hZUYltBVlx51HiyCYlbVxycqtPMH09mMyakY73ZBWEDQAwmVNLGO yi6ogNZ6MX7w3+TrorrEyAhi+oZEWMNGdcrIjD0jjivnugtlpCj/GRGHSeCaE/MUTQqq CLD4p/4M3q4zLcpQSxRyHIpeFCbbsbfq2zsbo06jTGzFRc0lNMPZGNrgUtQL4Wj3saBh JqCg== X-Gm-Message-State: ACrzQf2YRcGT2qIMcRRRaOTO0OxuANoSAYG+Q6byOy8fKtHP2Rx7v8L2 vnv7jWIeCH3N8jPiIWSIe5LYGI9/rO4q9Q== X-Google-Smtp-Source: AMsMyM6Fpu+WC51VP/erVsnag8C6QwoF2OqTrJujzihgWjwCtvGd6HJaQ9Ozb5ZnHIExAxnSOZ8cyw== X-Received: by 2002:a05:600c:34c1:b0:3cf:3921:ef22 with SMTP id d1-20020a05600c34c100b003cf3921ef22mr3244wmq.204.1666973564540; Fri, 28 Oct 2022 09:12:44 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:44 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 03/16] media: i2c: ov9282: Remove format code from the mode Date: Fri, 28 Oct 2022 17:08:49 +0100 Message-Id: <20221028160902.2696973-4-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The format code is independent of mode, and each mode could support both Y10 and Y8, so disassociate the code from the mode. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 6999ce869a1b..ead3a4f22ef8 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -79,7 +79,6 @@ struct ov9282_reg_list { * struct ov9282_mode - ov9282 sensor mode structure * @width: Frame width * @height: Frame height - * @code: Format code * @hblank: Horizontal blanking in lines * @vblank: Vertical blanking in lines * @vblank_min: Minimum vertical blanking in lines @@ -91,7 +90,6 @@ struct ov9282_reg_list { struct ov9282_mode { u32 width; u32 height; - u32 code; u32 hblank; u32 vblank; u32 vblank_min; @@ -263,7 +261,6 @@ static const struct ov9282_mode supported_mode = { .vblank_max = 51540, .pclk = 160000000, .link_freq_idx = 0, - .code = MEDIA_BUS_FMT_Y10_1X10, .reg_list = { .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), .regs = mode_1280x720_regs, @@ -513,7 +510,7 @@ static int ov9282_enum_mbus_code(struct v4l2_subdev *sd, if (code->index > 0) return -EINVAL; - code->code = supported_mode.code; + code->code = MEDIA_BUS_FMT_Y10_1X10; return 0; } @@ -533,7 +530,7 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, if (fsize->index > 0) return -EINVAL; - if (fsize->code != supported_mode.code) + if (fsize->code != MEDIA_BUS_FMT_Y10_1X10) return -EINVAL; fsize->min_width = supported_mode.width; @@ -557,7 +554,7 @@ static void ov9282_fill_pad_format(struct ov9282 *ov9282, { fmt->format.width = mode->width; fmt->format.height = mode->height; - fmt->format.code = mode->code; + fmt->format.code = MEDIA_BUS_FMT_Y10_1X10; fmt->format.field = V4L2_FIELD_NONE; fmt->format.colorspace = V4L2_COLORSPACE_RAW; fmt->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; From patchwork Fri Oct 28 16:08:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 619740 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 648C0ECAAA1 for ; Fri, 28 Oct 2022 16:15:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbiJ1QPW (ORCPT ); Fri, 28 Oct 2022 12:15:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbiJ1QOh (ORCPT ); Fri, 28 Oct 2022 12:14:37 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 688121403B for ; Fri, 28 Oct 2022 09:12:47 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id m29-20020a05600c3b1d00b003c6bf423c71so6915554wms.0 for ; Fri, 28 Oct 2022 09:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=hr2TVk4TNRJvSE84hpR4ns23TzYz3TaLu+r26zV4uIQ=; b=qFHJ4x0w67xgjI2Kzr5cTswtW6bZjG2/u1R8tUHazfT7ceDay2MbyCNomPRjVqAWQs a8TwencStdtHP1hgPGIuNcUTuVnZJhMF672w0e41p7IjgHD6PReTzITcj8r2q/QW6G6g FgkcQThFL2wujqaPm6+ETEFQRlC0GLRE9Tky35sWTXFVuCiUsY8bYO1S0j9gLDTWeQSC +IzIaveAfBHyHYFkNmcOSe9S+GbK6aa9OtvjNmdKLX5z+/OI8ayi3iRTt7BZF/KUv/Pz 9Ay5hnJJRJSkihsONNINgNstXu1J6jVoDu+/c67IpsS6DU9gp0pf4ULDK0+j8SEP5Ays tpSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=hr2TVk4TNRJvSE84hpR4ns23TzYz3TaLu+r26zV4uIQ=; b=MFV/uFg0I8p/jWxiAfKdpY5+K64st6WagPCLrwk1GETp4xhLdGTCWwPFNaRlQIhIeE OF1EHPQySfJlcJNpTJFdpQaZzy6X05Wl3A5vM/RfzPF/vqCYgX85oTiC19COVGdCzd0L AKd9f33OoXYg8X6m6PCrXbtnZF3vaNxkwEds5Ak+R4EIooVzVBBlaCcCqPmKGI1sn6s0 C62psX6v/HV+x7i3pcIS41VM0DJ1mupepOlsc2/nRUmhYvYv9zMPNdiHiLw1jb9HGUKl oC2dSOvs5n3Qylc8BVbODs3TjCyJXqIssRxvyTktcEjJKQSLkbjbD00+tqjFGSXp6jTR s/hg== X-Gm-Message-State: ACrzQf1tlYSXW9LsnMwEU9tK2uZuN17a+zU/N8uO/fC0CdRVWbWwI+a7 OUTeHKesVHEgZ8ZlChqC/msmIw== X-Google-Smtp-Source: AMsMyM6fIwVzThA6MdhZ6vRLEc/EyOIFnMQjfO1KzKiGBdY4ZvBDswP0d/cFPx94hw0iziv1DowjcA== X-Received: by 2002:a05:600c:4f0f:b0:3ca:31ba:d77c with SMTP id l15-20020a05600c4f0f00b003ca31bad77cmr10270618wmq.36.1666973566018; Fri, 28 Oct 2022 09:12:46 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:45 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 04/16] media: i2c: ov9282: Remove pixel rate from mode definition Date: Fri, 28 Oct 2022 17:08:50 +0100 Message-Id: <20221028160902.2696973-5-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The pixel rate is determined by the PLL setup in the common registers, not by the mode specific registers, therefore remove it from the mode definition and define it for all modes. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index ead3a4f22ef8..123aa20951b7 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -52,6 +52,10 @@ #define OV9282_LINK_FREQ 400000000 #define OV9282_NUM_DATA_LANES 2 +/* Pixel rate */ +#define OV9282_PIXEL_RATE (OV9282_LINK_FREQ * 2 * \ + OV9282_NUM_DATA_LANES / 10) + #define OV9282_REG_MIN 0x00 #define OV9282_REG_MAX 0xfffff @@ -83,7 +87,6 @@ struct ov9282_reg_list { * @vblank: Vertical blanking in lines * @vblank_min: Minimum vertical blanking in lines * @vblank_max: Maximum vertical blanking in lines - * @pclk: Sensor pixel clock * @link_freq_idx: Link frequency index * @reg_list: Register list for sensor mode */ @@ -94,7 +97,6 @@ struct ov9282_mode { u32 vblank; u32 vblank_min; u32 vblank_max; - u64 pclk; u32 link_freq_idx; struct ov9282_reg_list reg_list; }; @@ -109,7 +111,6 @@ struct ov9282_mode { * @inclk: Sensor input clock * @ctrl_handler: V4L2 control handler * @link_freq_ctrl: Pointer to link frequency control - * @pclk_ctrl: Pointer to pixel clock control * @hblank_ctrl: Pointer to horizontal blanking control * @vblank_ctrl: Pointer to vertical blanking control * @exp_ctrl: Pointer to exposure control @@ -128,7 +129,6 @@ struct ov9282 { struct clk *inclk; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; - struct v4l2_ctrl *pclk_ctrl; struct v4l2_ctrl *hblank_ctrl; struct v4l2_ctrl *vblank_ctrl; struct { @@ -259,7 +259,6 @@ static const struct ov9282_mode supported_mode = { .vblank = 1022, .vblank_min = 151, .vblank_max = 51540, - .pclk = 160000000, .link_freq_idx = 0, .reg_list = { .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), @@ -968,11 +967,9 @@ static int ov9282_init_controls(struct ov9282 *ov9282) 1, mode->vblank); /* Read only controls */ - ov9282->pclk_ctrl = v4l2_ctrl_new_std(ctrl_hdlr, - &ov9282_ctrl_ops, - V4L2_CID_PIXEL_RATE, - mode->pclk, mode->pclk, - 1, mode->pclk); + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_PIXEL_RATE, + OV9282_PIXEL_RATE, OV9282_PIXEL_RATE, 1, + OV9282_PIXEL_RATE); ov9282->link_freq_ctrl = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov9282_ctrl_ops, From patchwork Fri Oct 28 16:08:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 620157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D43FC38A02 for ; Fri, 28 Oct 2022 16:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbiJ1QPV (ORCPT ); Fri, 28 Oct 2022 12:15:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbiJ1QOh (ORCPT ); Fri, 28 Oct 2022 12:14:37 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23129DF68 for ; Fri, 28 Oct 2022 09:12:49 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id y10so3518590wma.0 for ; Fri, 28 Oct 2022 09:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=/je66IiGVgC9A+utpVJnpRaQP1n7ybCAbgw5Pm2x/Wc=; b=lquWS5WOwiyIohW8+EcJ46EZb+7Bg2wlVGPOFnAAQcQV5IE6cWm/IeJpQW1DZeEql3 QqZAhY22wiV7L/7t0jXfWQH84Thi8A+LYVwLbcrgc0uC7hziFFEjXy7S7ORiaRsqbkoj 4T5UiLfLGL6laTXfrSh2YVbnIHkub8bLr3Q7GVx1FFoVkKBCx/fTWox++4Eg0zMdbUiS vKcXmlbGL+Dy+e9rR1VzLzqTSny17m5+aurjPDbHKrnxYrCpOhUesWqXmZI6nOq9wBKv z8oVxU3MFjfFHcKnc6C2/RE13KPlaP3a+mMv2OjhImSlkTOzP1VzSPwLQyvVny82QVHc uXsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/je66IiGVgC9A+utpVJnpRaQP1n7ybCAbgw5Pm2x/Wc=; b=tHqg72K9Q/A4RLc/MZH/+jXxjw7pMQov2kUhLOHYigtr0uLXc+rLsV/Ud8KzBfBb2U kHyYe7fNn+1/PBzayTOO9xJU1HikyNZ2iqI2SYRIZA/ZU2WFeZ3aj86eL+MapiQH1bBJ jy5hBM/SSYbdH5RFmIqVeWBQLYmLvHqfnJJzuBXmMatD2ukgDyQcBc/i8nCmy3kmx31B 2G4zmrK3O/N1dQQbPK9Bayn7/wMO1lUBbh+x//RQPLckqjORPpes14gqlVt0GsJucveJ VA5stlxjkvi+Y7IqX5W6+LAsBMqPu9eguvgRp/SvowuSYESZO8JVmh9T+CZ6tnXobe2z PxRQ== X-Gm-Message-State: ACrzQf2h7ZB6JuxiR2NYRPVlZ0jCDkUloJFnGKYCbJFVG+kmbTGaZzHE UO5MQO63axphIyjQKJ+Bh8OMhQ== X-Google-Smtp-Source: AMsMyM4ul5pkMXo0h38HYfpA5laienDYpPszMB5HtBpaalJi0wSQP7l54u7f3wOzS43dm6EjwhziSg== X-Received: by 2002:a05:600c:3585:b0:3b4:a308:1581 with SMTP id p5-20020a05600c358500b003b4a3081581mr10281089wmq.77.1666973567670; Fri, 28 Oct 2022 09:12:47 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:47 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 05/16] media: i2c: ov9281: Support more than 1 mode. Date: Fri, 28 Oct 2022 17:08:51 +0100 Message-Id: <20221028160902.2696973-6-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The driver currently has multiple assumptions that there is only one supported mode. Convert supported_mode to an array, and fix up all references to correctly look at that array. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 46 +++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 123aa20951b7..1524189cf3e5 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -217,6 +217,10 @@ struct ov9282_reg_list common_regs_list = { .regs = common_regs, }; +#define MODE_1280_720 0 + +#define DEFAULT_MODE MODE_1280_720 + /* Sensor mode registers */ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3778, 0x00}, @@ -252,17 +256,19 @@ static const struct ov9282_reg mode_1280x720_regs[] = { }; /* Supported sensor mode configurations */ -static const struct ov9282_mode supported_mode = { - .width = 1280, - .height = 720, - .hblank = 250, - .vblank = 1022, - .vblank_min = 151, - .vblank_max = 51540, - .link_freq_idx = 0, - .reg_list = { - .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), - .regs = mode_1280x720_regs, +static const struct ov9282_mode supported_modes[] = { + [MODE_1280_720] = { + .width = 1280, + .height = 720, + .hblank = 250, + .vblank = 1022, + .vblank_min = 151, + .vblank_max = 51540, + .link_freq_idx = 0, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), + .regs = mode_1280x720_regs, + }, }, }; @@ -526,15 +532,15 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_frame_size_enum *fsize) { - if (fsize->index > 0) + if (fsize->index >= ARRAY_SIZE(supported_modes)) return -EINVAL; if (fsize->code != MEDIA_BUS_FMT_Y10_1X10) return -EINVAL; - fsize->min_width = supported_mode.width; + fsize->min_width = supported_modes[fsize->index].width; fsize->max_width = fsize->min_width; - fsize->min_height = supported_mode.height; + fsize->min_height = supported_modes[fsize->index].height; fsize->max_height = fsize->min_height; return 0; @@ -609,7 +615,11 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, mutex_lock(&ov9282->mutex); - mode = &supported_mode; + mode = v4l2_find_nearest_size(supported_modes, + ARRAY_SIZE(supported_modes), + width, height, + fmt->format.width, + fmt->format.height); ov9282_fill_pad_format(ov9282, mode, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { @@ -642,7 +652,7 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd, struct v4l2_subdev_format fmt = { 0 }; fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; - ov9282_fill_pad_format(ov9282, &supported_mode, &fmt); + ov9282_fill_pad_format(ov9282, &supported_modes[DEFAULT_MODE], &fmt); return ov9282_set_pad_format(sd, sd_state, &fmt); } @@ -1043,8 +1053,8 @@ static int ov9282_probe(struct i2c_client *client) goto error_power_off; } - /* Set default mode to max resolution */ - ov9282->cur_mode = &supported_mode; + /* Set default mode to first mode */ + ov9282->cur_mode = &supported_modes[DEFAULT_MODE]; ov9282->vblank = ov9282->cur_mode->vblank; ret = ov9282_init_controls(ov9282); From patchwork Fri Oct 28 16:08:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 620159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94038ECAAA1 for ; Fri, 28 Oct 2022 16:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbiJ1QPL (ORCPT ); Fri, 28 Oct 2022 12:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230248AbiJ1QOh (ORCPT ); Fri, 28 Oct 2022 12:14:37 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AA5214087 for ; Fri, 28 Oct 2022 09:12:51 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id g12so7186493wrs.10 for ; Fri, 28 Oct 2022 09:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=MY1mvkyRsT1CB7pwPxBqZXjc4qqLIAEDNuwW2y9MnVM=; b=aIpTtm3oYzBiEOn12tG6S83ibK5bpICo/U1mTVg1CVrbi6lmPHJKGl77UzTJz/7kry R11I8yQJ3HU4suJlUVv6seX7I6WCM4zgZP0B6Mpe1oQoHHps62jhU7ZVY/m+GJKKkG+S w9160P7itn4Au3FbH2cJbiOJVjfyVkF7PqJqtaAl5uAidgiCb5Z4M8oftTcJwsZhdrpS jkX0TfKz59xYOksHc8kZr0yH6BtmJ2Q8NjPQ1R165IfJB+akKaZQubozDyrs+7Yff9Fb hOSMpR30/TjgFgvXNoZFFTF8pbjiB5e0WUIpMDXSEUs/+Mn3/A96Io+Md6sHC8eXubvU shag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=MY1mvkyRsT1CB7pwPxBqZXjc4qqLIAEDNuwW2y9MnVM=; b=e0Mf84TFYT2ZlKEtPMpW85TLu6AFhL8Vp39PDSHSy5DzAVQYO5wkygMuIePtJx7YAA rIKwLTCnVIyMlBi2Xx2R8zvcHzM0wjKPaj/a9EQqYAlGxAmlZqIEQP4Ao387sXP9d2vD 1Bdur3nv6VUZTxs59UsxjRT6AwcfrAfepCJr/fAs9aMqnhI8YeveaFoZQyQPDypPCbO6 p3p2YskfpRPZyBGOC/XtB/scpwiQdrhVDwqAks3keQr0+6/zN1P7iUVyHLNeDBeTrbBP mSEEvUgp/QWS21LASJu1Qx0cB8/C55JGeg6SpOr4Zfn3OEv6i35MH8AZVXcShYcFBIZm l9GQ== X-Gm-Message-State: ACrzQf2ZKOg+YSv+lw5fiN1JnQ6DrgHtwMehOAcHCjP6JIDTRcd+942S b12TOmLUj/7VGqmVWXqdQYFVPQ== X-Google-Smtp-Source: AMsMyM70ofvlmyZu0QVvbCN/pBkR3tl1lYCloAapkrVFcPQzDSqwDMmSfsZfxyaPiGe5ZgwA1qbatw== X-Received: by 2002:adf:ffc2:0:b0:236:61e8:de52 with SMTP id x2-20020adfffc2000000b0023661e8de52mr72435wrs.59.1666973570102; Fri, 28 Oct 2022 09:12:50 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:49 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 06/16] media: i2c: ov9282: Correct HTS register for configured pixel rate Date: Fri, 28 Oct 2022 17:08:52 +0100 Message-Id: <20221028160902.2696973-7-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The calculations from pixel rate, width+hblank, and height+vblank do not give the correct framerate - it's half the speed it should be. The datasheet lists the default for the TIMING_HTS registers (0x380c/d) as being 0x2d8 (728) which is less than the width of the image, so the units clearly can't be pixels. If TIMING_HTS is considered to be units of 2-pixels, then the resulting value of 0x5b0 (1456) makes all the calculations correct. This driver is reporting an HBLANK value of 250, with an image width of 1280, so TIMING_HTS is 1530 (0x5fa) pixels. However it was also setting the register to 0x5fa, thereby not taking into account it being units of 2-pixels. Correct the register value to 0x2fd so that all the timing calculations give the correct results. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 1524189cf3e5..7e0b12b89655 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -236,8 +236,8 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3809, 0x00}, {0x380a, 0x02}, {0x380b, 0xd0}, - {0x380c, 0x05}, - {0x380d, 0xfa}, + {0x380c, 0x02}, + {0x380d, 0xfd}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, From patchwork Fri Oct 28 16:08:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 619742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6E64FA3742 for ; Fri, 28 Oct 2022 16:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230502AbiJ1QPO (ORCPT ); Fri, 28 Oct 2022 12:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230260AbiJ1QOi (ORCPT ); Fri, 28 Oct 2022 12:14:38 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B99D6DAE7 for ; Fri, 28 Oct 2022 09:12:52 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id g12so7186531wrs.10 for ; Fri, 28 Oct 2022 09:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=AsaHuu6Y31yjFurK0y6AWTkf6uxNbvk9C/GSLLGsJoc=; b=lGdWb/I3CcRP1R6nbFZoquN/vaBmUsCHG8k+FKX1zG81FcWlHFF4prnCYx5tOkVhlK 3DG82AsnQg5r9qdUmAtg4eCKSKJTrFr/Vm6Jqa5CTgVFkxZp2TpwbTqP7JR6hZPr9cjH NdYd0NXtPaNmvMJ0iF0xf++KB2/MDIylUYzc9rPdhAzCi38FXSeA8EalvKMQUrOhUAHb bDlCW0ybEZFGu3mTgjYKAh+cP3aDIjW6EjKC+IwI+47MybJ862xLFrd3xyj36btyZ9pZ Fo/EmfT2D5paADKxPCn10DecJJfKILVcaL0j+7P70d2QOuXNDF2fzB2yrIWIU5xsUwp9 hgEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=AsaHuu6Y31yjFurK0y6AWTkf6uxNbvk9C/GSLLGsJoc=; b=0QnqVQustzvKq8Da4QtEMyhPLlZwJpkB2Qig+JNgt8SFCfYaDZZKPrzarzcgNgp/pu 9Bt52Wprt8O/NElCeE5qcV941CLJgVBIjPBEfp0tT7Tu8JcRwmaBnTUk58sRy481l9Da Ktk0vwN7hkRepAdTdsYgT+Vb9QcvIgi2mCptiKSHtufZ6jZ6gLZcZ9A7TyyY+dFzRdvz tM60BpMlLqu8sFGZoTBQD7rJ1mcL6EQovXY8kXn6/v+eeQMC8/cT/SpIrCROP5ODWp05 F6Ej/46RIlQyWQx+/aWUHe7TEtJGK7Jnga8bxEnp0cvySXNkBYxVt4Y70G4IEsHitRrE yg1w== X-Gm-Message-State: ACrzQf3daeVYEzR9eLkpvu+DnCekQCPjDzcuElfexKMz1/syQtinEYzE Kdhu0ZaZ1Ac6aTE+iIEvzMFLZg== X-Google-Smtp-Source: AMsMyM5CTX3ib6azI4ARgsJeoIct8cZyrvBaj4tzddS8VTJox46ZXuv47xqrr5aIlFCb+FfTTuXn3A== X-Received: by 2002:a5d:5081:0:b0:236:75cc:be26 with SMTP id a1-20020a5d5081000000b0023675ccbe26mr63910wrt.379.1666973570754; Fri, 28 Oct 2022 09:12:50 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:50 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 07/16] media: i2c: ov9282: Reduce vblank_min values based on testing Date: Fri, 28 Oct 2022 17:08:53 +0100 Message-Id: <20221028160902.2696973-8-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The configured vblank_min setting of 151 (meaning VTS of 720 + 151 = 871) is far higher than the setting that works on the sensor, and there are no obvious restrictions stated in the datasheet. Reduce the vblank_min to allow for faster frame rates. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 7e0b12b89655..35bc2b0438bc 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -262,7 +262,7 @@ static const struct ov9282_mode supported_modes[] = { .height = 720, .hblank = 250, .vblank = 1022, - .vblank_min = 151, + .vblank_min = 41, .vblank_max = 51540, .link_freq_idx = 0, .reg_list = { From patchwork Fri Oct 28 16:08:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 619741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1C86FA3742 for ; Fri, 28 Oct 2022 16:15:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbiJ1QPT (ORCPT ); Fri, 28 Oct 2022 12:15:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbiJ1QOi (ORCPT ); Fri, 28 Oct 2022 12:14:38 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D351F810C for ; Fri, 28 Oct 2022 09:12:52 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id bp11so7191113wrb.9 for ; Fri, 28 Oct 2022 09:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=WaKoQyrZ2yCkJsSr+WI5a4CPSDINEZrCRWoW1/EHfUg=; b=K4BqX5ToEFU9Qt36Q47lZhVJH7zNHdzFIZyLaTttzpjW9zKD18Cn3ejn74VNlKkQYk lGdYLrg/QV8vVPgmxYGcyexBMS4hTxWCliynb11WYXrqrsBKZheN7/2la8Z0IMB4+QkQ DNoiH71Jfw3jaP0wm23dqVfrnBbmzwrVcNNntOXaJEtEdPYSB+ODjYHsT6u/+H1UCg44 2AYImkgLPZKxXtqGr8ZrYRVUIyhV2+d+3WlqS+j2vAsMmZ8olxPEyUviJ0Xwp8tnyMFf qNt/nS6G96eFT2RW8pxTDrFk4CBFflny5ne94oFt3OtVMEPNHXz+Fo5rVAmW9HX00z8g TsZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=WaKoQyrZ2yCkJsSr+WI5a4CPSDINEZrCRWoW1/EHfUg=; b=GQUSAS4bi6CYbzrgrCkqA+mWmen5QuwmXjwFZRFFKUFCermfKG2GUjrmSaYq6zsy0W uSNmIBd8VwFm/sltFjqaROCO3sUvn5AFovB+9Z/1o244o1W3RXm7zdexCUqeZsYA7Nso XyjwdNEkzkcul5+mlkR5TqejE3VKYMM5J0zW8o6a4txaafnequTvE7vqPYUM44dQwUFh 0IVjP+IJY+5l12q5vt/g7EVBJqJWd8GUSGANA/2FJ4jkFH9xgdDHGCH1Np66kq99wDAh AL3aOt7CTSdz1OrEUTWSdajaxqzGM+QOQLhFuHe9Ef8nnXDotJC8u+97zrJMLbyCHTy2 pwpg== X-Gm-Message-State: ACrzQf3i26JXdlYPErA49h/Je7hgJv5yeuxMAhpFf4nxxz9rSjewQIPf 9psGwaMgEt8WFYb8XAFoAzINJ4qwdplukA== X-Google-Smtp-Source: AMsMyM7S6+M0qXeyrc/LAHB/vuNo3NAeiqCJg1WqxzWKcsSsh5bFDAh03U5WaZsNgqJZFw5TzeXh2g== X-Received: by 2002:adf:fe85:0:b0:236:7cde:a95d with SMTP id l5-20020adffe85000000b002367cdea95dmr57182wrr.531.1666973571503; Fri, 28 Oct 2022 09:12:51 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:51 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 08/16] media: i2c: ov9282: Add selection for CSI2 clock mode Date: Fri, 28 Oct 2022 17:08:54 +0100 Message-Id: <20221028160902.2696973-9-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The sensor supports either having the CSI2 clock lane free running, or gated when there is no packet to transmit. The driver only selected gated (non-continuous) clock mode. Add code to allow fwnode to configure whether the clock is gated or free running. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 35bc2b0438bc..1637cf1177c5 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -45,6 +45,9 @@ /* Group hold register */ #define OV9282_REG_HOLD 0x3308 +#define OV9282_REG_MIPI_CTRL00 0x4800 +#define OV9282_GATED_CLOCK BIT(5) + /* Input clock rate */ #define OV9282_INCLK_RATE 24000000 @@ -136,6 +139,7 @@ struct ov9282 { struct v4l2_ctrl *again_ctrl; }; u32 vblank; + bool noncontinuous_clock; const struct ov9282_mode *cur_mode; struct mutex mutex; bool streaming; @@ -145,7 +149,13 @@ static const s64 link_freq[] = { OV9282_LINK_FREQ, }; -/* Common registers */ +/* + * Common registers + * + * Note: Do NOT include a software reset (0x0103, 0x01) in any of these + * register arrays as some settings are written as part of ov9282_power_on, + * and the reset will clear them. + */ static const struct ov9282_reg common_regs[] = { {0x0302, 0x32}, {0x030d, 0x50}, @@ -201,7 +211,6 @@ static const struct ov9282_reg common_regs[] = { {0x4601, 0x04}, {0x470f, 0x00}, {0x4f07, 0x00}, - {0x4800, 0x20}, {0x5000, 0x9f}, {0x5001, 0x00}, {0x5e00, 0x00}, @@ -835,6 +844,9 @@ static int ov9282_parse_hw_config(struct ov9282 *ov9282) if (ret) return ret; + ov9282->noncontinuous_clock = + bus_cfg.bus.mipi_csi2.flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK; + if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV9282_NUM_DATA_LANES) { dev_err(ov9282->dev, "number of CSI2 data lanes %d is not supported", @@ -903,6 +915,14 @@ static int ov9282_power_on(struct device *dev) usleep_range(400, 600); + ret = ov9282_write_reg(ov9282, OV9282_REG_MIPI_CTRL00, 1, + ov9282->noncontinuous_clock ? + OV9282_GATED_CLOCK : 0); + if (ret) { + dev_err(ov9282->dev, "fail to write MIPI_CTRL00"); + return ret; + } + return 0; error_reset: From patchwork Fri Oct 28 16:08:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 620158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 712D3ECAAA1 for ; Fri, 28 Oct 2022 16:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbiJ1QPR (ORCPT ); Fri, 28 Oct 2022 12:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbiJ1QOi (ORCPT ); Fri, 28 Oct 2022 12:14:38 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95A221EF070 for ; Fri, 28 Oct 2022 09:12:52 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id m29-20020a05600c3b1d00b003c6bf423c71so6915717wms.0 for ; Fri, 28 Oct 2022 09:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=vlkXe+L2h1h18CiDtAzOilVW1h9zgoB/5M7/SaL9hQk=; b=Ny8adNQ89MU6uQfuzEgWi323Wo3LwCB8VN9FJQFV6bAYLFdgHS1KfZ+AtWnCtFemfg B14GJoPYQnMP8bmzJS0pWD4wmNBm8Su7FDgHkM98ioaLevFd15quUIhjD4uEgoK0EstF LdaTZH+SmAXTiWgJFgkL980YFAG4pYLentQ8b1ibjcnstNIuti0VB8zj76DWfTz9ZnPC 2sctOZHSAhsmQsX2s7eoGQs/F+QsathwYWep8pADxar0modluIDWfAOK+2AbLEE3dLKc oas5tkpAPbAQBl+6X4zuWMV8knVCGAQnyOJG+u45XAIQfNvjHlKRK5wnHNOs90RLusYo LSAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=vlkXe+L2h1h18CiDtAzOilVW1h9zgoB/5M7/SaL9hQk=; b=u4UPAIzpyu/Gm1tK60HPIwmX9VX5olHFH/fnlVH4wMZjpyAXvNApJa/ECP5zGKuUU5 vRzfvu6whJT8/BEVwdOocQ4+V/0zBRVeMukc/gFdo+oF0AjPC+RNZueb1pdBO4+3F++u dS+gJtT4+6Qlx8O8ilcDAJ7htGP3l/0CI0aN/c+aJh7FmHyMHaYWDMaYJoP0Fm7cqt7T RRwu7svvuvknXw2Dd0i4JiTq6jzwKrL2yUZZ7/r5KKnaVVr+b9DdWUlhsEBNxHodyl3m VZeyFY+25pYwcGlxYvnU5uKjZgto9CQtE7FoQ157+MtLc+beBpYynxEQ7O06adcADOt4 vBEQ== X-Gm-Message-State: ACrzQf0FUpBw/AJEZ0mk39AbPR2rAf3pQbqhUvzrXl9bdsgPjxDOKIO7 ck2Gpo4F0kuSjDYxUbUyrrXT/g== X-Google-Smtp-Source: AMsMyM7E+/a6RTLSKi+5zmlmUakYzPY/Dfdy8lk6HWgQWIDXQeWazo6Sz7YeePJoynJidOolXUZtIQ== X-Received: by 2002:a05:600c:3d8a:b0:3c6:f241:cb36 with SMTP id bi10-20020a05600c3d8a00b003c6f241cb36mr65746wmb.115.1666973572216; Fri, 28 Oct 2022 09:12:52 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:51 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 09/16] media: i2c: ov9282: Add the properties from fwnode Date: Fri, 28 Oct 2022 17:08:55 +0100 Message-Id: <20221028160902.2696973-10-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use v4l2_ctrl_new_fwnode_properties to add V4L2_CID_CAMERA_ORIENTATION and V4L2_CID_CAMERA_SENSOR_ROTATION. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 1637cf1177c5..889db9d105a2 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -959,10 +959,11 @@ static int ov9282_init_controls(struct ov9282 *ov9282) { struct v4l2_ctrl_handler *ctrl_hdlr = &ov9282->ctrl_handler; const struct ov9282_mode *mode = ov9282->cur_mode; + struct v4l2_fwnode_device_properties props; u32 lpfr; int ret; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 6); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); if (ret) return ret; @@ -1020,7 +1021,14 @@ static int ov9282_init_controls(struct ov9282 *ov9282) if (ov9282->hblank_ctrl) ov9282->hblank_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; - if (ctrl_hdlr->error) { + ret = v4l2_fwnode_device_parse(ov9282->dev, &props); + if (!ret) { + /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ + v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov9282_ctrl_ops, + &props); + } + + if (ctrl_hdlr->error || ret) { dev_err(ov9282->dev, "control init failed: %d", ctrl_hdlr->error); v4l2_ctrl_handler_free(ctrl_hdlr); From patchwork Fri Oct 28 16:08:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 619737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6A00C38A02 for ; Fri, 28 Oct 2022 16:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230419AbiJ1QPf (ORCPT ); Fri, 28 Oct 2022 12:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbiJ1QOx (ORCPT ); Fri, 28 Oct 2022 12:14:53 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8106B10B5D for ; Fri, 28 Oct 2022 09:12:54 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id bh7-20020a05600c3d0700b003c6fb3b2052so4164165wmb.2 for ; Fri, 28 Oct 2022 09:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=Uey9vOhMLVzWfhmJtcLrItGBH6mQHGylv2VgePIXpOI=; b=HOSvTTqzHmIzDF69JWwPSm/hD9MwBHBCtXyKjGg/OVc4o6xmD03oaTG9pKXRMRF3NB 7NYwMawhmwGdltRxlATQQpUgM9tkiO55GT5/eGpdsi/FYfZd1zaB1Q/YgGdmxXNMUUkg ZI8mzaHxc5GAItHJesGI7YawCDJNVpLc2rGiG0A+TzjtoqvhdTnWTDGQXthm+DazwCEA J/mrA7Hhd+TBLj86AyXtUDt2ig2V/9iG3RM1f0UXqS9n+gsPbQ/fGI0L0WaNToVt3uey Q8tHXCKzHEsvEyIH3UCOu8N0odABOTEUjeAToH7DhogrIjwX86wPMCh6nL9GP4HccvB6 C0Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Uey9vOhMLVzWfhmJtcLrItGBH6mQHGylv2VgePIXpOI=; b=J9VvRDxUrZGKuuTlUlDldrafXOtwqcvFDuGtXRtBGKleOxcXlnhLCquVtJqhzTmyE6 2GmB59jRXk5XM45mMoRFcU7bTschszhfLjej/7GZXh8yFuH+jKVL38nkRFeepyJjeV6J JsP30eFVKzz2GpYyNPZM9Mf3L1ojzepOeCFwGalKHHT1FBThJ9BDRvwE7DWLN3znapbk ELqTHXi2OHUhqeoDl30SBFN5R6AbldOpWbQpZxnhxIHpqvSf978WSBmZL+d5xD1CEyYp VLdxFhJNj0AfLDGagSLhcO8cMkeIqA1NO5fbjnUZ3JCjzJrIVQjaykRNAPy+kqH63p3a 5upw== X-Gm-Message-State: ACrzQf2wOzpVaCpZdVS/PfveCq91yGsRJ32myLYl8NoORJu/9VsRmbLH W33SjlzCPBsKpMygmy2I6msvSw== X-Google-Smtp-Source: AMsMyM4Jw7Cy4qfCmBPIsw75X2Gi4bW3rgFc7181BCs6g/SV4AmVBYnRA5QsLdYBZTmI+KJyk6dUZA== X-Received: by 2002:a05:600c:1d2a:b0:3c6:b7be:2879 with SMTP id l42-20020a05600c1d2a00b003c6b7be2879mr10664012wms.84.1666973573059; Fri, 28 Oct 2022 09:12:53 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:52 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 10/16] media: i2c: ov9282: Action CID_VBLANK when set. Date: Fri, 28 Oct 2022 17:08:56 +0100 Message-Id: <20221028160902.2696973-11-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Programming the sensor with TIMING_VTS (aka LPFR) was done when triggered by a change in exposure or gain, but not when V4L2_CID_VBLANK was changed. Dynamic frame rate changes could therefore not be achieved. Separate out programming TIMING_VTS so that it is triggered by set_ctrl(V4L2_CID_VBLANK) Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 889db9d105a2..e964461ff1d3 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -417,22 +417,15 @@ static int ov9282_update_controls(struct ov9282 *ov9282, */ static int ov9282_update_exp_gain(struct ov9282 *ov9282, u32 exposure, u32 gain) { - u32 lpfr; int ret; - lpfr = ov9282->vblank + ov9282->cur_mode->height; - - dev_dbg(ov9282->dev, "Set exp %u, analog gain %u, lpfr %u", - exposure, gain, lpfr); + dev_dbg(ov9282->dev, "Set exp %u, analog gain %u", + exposure, gain); ret = ov9282_write_reg(ov9282, OV9282_REG_HOLD, 1, 1); if (ret) return ret; - ret = ov9282_write_reg(ov9282, OV9282_REG_LPFR, 2, lpfr); - if (ret) - goto error_release_group_hold; - ret = ov9282_write_reg(ov9282, OV9282_REG_EXPOSURE, 3, exposure << 4); if (ret) goto error_release_group_hold; @@ -463,6 +456,7 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) container_of(ctrl->handler, struct ov9282, ctrl_handler); u32 analog_gain; u32 exposure; + u32 lpfr; int ret; switch (ctrl->id) { @@ -480,11 +474,14 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) OV9282_EXPOSURE_OFFSET, 1, OV9282_EXPOSURE_DEFAULT); break; - case V4L2_CID_EXPOSURE: - /* Set controls only if sensor is in power on state */ - if (!pm_runtime_get_if_in_use(ov9282->dev)) - return 0; + } + + /* Set controls only if sensor is in power on state */ + if (!pm_runtime_get_if_in_use(ov9282->dev)) + return 0; + switch (ctrl->id) { + case V4L2_CID_EXPOSURE: exposure = ctrl->val; analog_gain = ov9282->again_ctrl->val; @@ -492,15 +489,18 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) exposure, analog_gain); ret = ov9282_update_exp_gain(ov9282, exposure, analog_gain); - - pm_runtime_put(ov9282->dev); - + break; + case V4L2_CID_VBLANK: + lpfr = ov9282->vblank + ov9282->cur_mode->height; + ret = ov9282_write_reg(ov9282, OV9282_REG_LPFR, 2, lpfr); break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret = -EINVAL; } + pm_runtime_put(ov9282->dev); + return ret; } From patchwork Fri Oct 28 16:08:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 620154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34862ECAAA1 for ; Fri, 28 Oct 2022 16:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbiJ1QPc (ORCPT ); Fri, 28 Oct 2022 12:15:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbiJ1QOx (ORCPT ); Fri, 28 Oct 2022 12:14:53 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AE441DE3F2 for ; Fri, 28 Oct 2022 09:12:55 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id l16-20020a05600c4f1000b003c6c0d2a445so4149054wmq.4 for ; Fri, 28 Oct 2022 09:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=7PQieUrDD2lIc9ALkRj84U8GRwSZ71VOFhAis5UCITI=; b=N3I8VHwEtz39IIV0134f1AMrP2yHLI6f9sYldNBuvXL7ewATsTd4K+UmtT9wlB2jNa X61vX6tMb3NG71uMlmwQVZuvsmJC526oLVdEg7LtYhmPkvZpQCUdTADwYOokaiwlUnpa SM/iclnK/rYJs//4cH6z9XSUpYxLLGs/o+2bbZMOP8MOcq/+TCIfuJnnq+vkfTtLbFk3 Cnn1F9k8e5QHicomw+vr9hY24sDsIno/fY9GiaqM9BydETN96yNMIEBP5ymfhUNPMMDV 5aXzZpKLQcEKA0FyJp41CAEBzK6wVlTPFYTU8oZwO8tMvArgcDj1PAE5Rz7RbFRuwwFE 5CLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=7PQieUrDD2lIc9ALkRj84U8GRwSZ71VOFhAis5UCITI=; b=4oYH/71sCfJuboxKb1SBpa9zUdv3jNTKKBuvXBd8/O38HsaIyE0K3QBRQxg/UlLlwM K5QUGI9HI4m6AHy2j2N0Spv0xTdGj3SdDMpToFPMey43JTXy3zT37zwacDnUwkGxWKGF BlrGcQCVlzQLuujBUmbvzFsbD+dL5bzybsoEMMC5kQPxT2nr6GXR/ts4lA4Z8OmfJdD0 SennS/4BTi6gTHKPwoJ8f/Y5NBl6V0KhB6xu6V6ZBN9R3z8bb+HRfYmAO7QCR1+q7G2s +BGWpL74aKsKBgkPfxrxB6DubI1lW4eWV9YYJEIocZHLnE9NiLtTaNyj1lDEJJmPAot7 SxNQ== X-Gm-Message-State: ACrzQf12EjK0LvTGTyEXhlrC8FueejNjiHD/S9KrkI3gkBggs2bRyHrj efU1gb3czExK/sWIbgOx/cYrIg== X-Google-Smtp-Source: AMsMyM7i5aQjs9/MkRiG+jEVxRHA9sgiCNhj1ZU4a5OsyLEoTwg5waaFjE8aV9xdqBwxJj43w5MYvg== X-Received: by 2002:a1c:f71a:0:b0:3cf:61fd:21f0 with SMTP id v26-20020a1cf71a000000b003cf61fd21f0mr935708wmh.40.1666973573843; Fri, 28 Oct 2022 09:12:53 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:53 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 11/16] media: i2c: ov9282: Add HFLIP and VFLIP support Date: Fri, 28 Oct 2022 17:08:57 +0100 Message-Id: <20221028160902.2696973-12-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Adds support for V4L2_CID_HFLIP and V4L2_CID_VFLIP to allow flipping the image. The driver previously enabled H & V flips in the register table, therefore the controls default to the same settings to avoid changing the behaviour. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 52 +++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index e964461ff1d3..cfb6e72d8931 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -45,6 +45,10 @@ /* Group hold register */ #define OV9282_REG_HOLD 0x3308 +#define OV9282_REG_TIMING_FORMAT_1 0x3820 +#define OV9282_REG_TIMING_FORMAT_2 0x3821 +#define OV9282_FLIP_BIT BIT(2) + #define OV9282_REG_MIPI_CTRL00 0x4800 #define OV9282_GATED_CLOCK BIT(5) @@ -438,6 +442,40 @@ static int ov9282_update_exp_gain(struct ov9282 *ov9282, u32 exposure, u32 gain) return ret; } +static int ov9282_set_ctrl_hflip(struct ov9282 *ov9282, int value) +{ + u32 current_val; + int ret = ov9282_read_reg(ov9282, OV9282_REG_TIMING_FORMAT_2, 1, + ¤t_val); + if (ret) + return ret; + + if (value) + current_val |= OV9282_FLIP_BIT; + else + current_val &= ~OV9282_FLIP_BIT; + + return ov9282_write_reg(ov9282, OV9282_REG_TIMING_FORMAT_2, 1, + current_val); +} + +static int ov9282_set_ctrl_vflip(struct ov9282 *ov9282, int value) +{ + u32 current_val; + int ret = ov9282_read_reg(ov9282, OV9282_REG_TIMING_FORMAT_1, 1, + ¤t_val); + if (ret) + return ret; + + if (value) + current_val |= OV9282_FLIP_BIT; + else + current_val &= ~OV9282_FLIP_BIT; + + return ov9282_write_reg(ov9282, OV9282_REG_TIMING_FORMAT_1, 1, + current_val); +} + /** * ov9282_set_ctrl() - Set subdevice control * @ctrl: pointer to v4l2_ctrl structure @@ -494,6 +532,12 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) lpfr = ov9282->vblank + ov9282->cur_mode->height; ret = ov9282_write_reg(ov9282, OV9282_REG_LPFR, 2, lpfr); break; + case V4L2_CID_HFLIP: + ret = ov9282_set_ctrl_hflip(ov9282, ctrl->val); + break; + case V4L2_CID_VFLIP: + ret = ov9282_set_ctrl_vflip(ov9282, ctrl->val); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret = -EINVAL; @@ -963,7 +1007,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) u32 lpfr; int ret; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10); if (ret) return ret; @@ -997,6 +1041,12 @@ static int ov9282_init_controls(struct ov9282 *ov9282) mode->vblank_max, 1, mode->vblank); + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_VFLIP, + 0, 1, 1, 1); + + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_HFLIP, + 0, 1, 1, 1); + /* Read only controls */ v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_PIXEL_RATE, OV9282_PIXEL_RATE, OV9282_PIXEL_RATE, 1, From patchwork Fri Oct 28 16:08:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 619739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16701FA3742 for ; Fri, 28 Oct 2022 16:15:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230361AbiJ1QPY (ORCPT ); Fri, 28 Oct 2022 12:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbiJ1QOx (ORCPT ); Fri, 28 Oct 2022 12:14:53 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 095C815729 for ; Fri, 28 Oct 2022 09:12:56 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id jb18so3490044wmb.4 for ; Fri, 28 Oct 2022 09:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=5FJ9mleB6XkLTEv65iMsussIL/SXB9Uukk3TmGWfOuw=; b=LgWW38CHE6ju++7MHmXUCWerT5MQMdYh4+G4A1eDB1qx21fG/+0kOTcnsynF8YKMf7 IJ1LUw8y2eJ/KOeP21fgP4PNsdcvCI1Ag0ltjAh5oyyrmP1cjRuyarLfHirpEUeh/P/w E++iRNKvBNaLJlLzFjQn5xOvT9Ks7wlrqn59YVYOzXy6VjTK/OKpex78t/s61jXKc8Rf GXHrB/hU3u8E1rkeZWZWV4Zt1/HF/Ls3s2cL72l0Jvx0127FW4wLUQptTBJWWQTGqdny GaGa9K54ey0ZdsxXlgUADFNm98VLGuXHSXhPT5jDV+LZlNJANWP8pvpBwFfQgCxLKxXy snew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=5FJ9mleB6XkLTEv65iMsussIL/SXB9Uukk3TmGWfOuw=; b=uLkVEPUTRERqhsJUfBKCyHjZfjiNxzYqSkoTE63UYbM938atGbdTe0oqSfST5mc4ks z2Cy0DTiaJpnsb4x+ePG0BFLV2dhjpGsKrBHICI3hN1hCK4l3rYeoesVqC71fm/k0C/X 4katwHUTUB5PwBiIm5Y+SCGkKvP9pMM/enVtcYzedj1EQuJlu4ih1HeB7/iczuEAc646 z2e0MrN3Fz4pzlX3gAxN7DrJZBH7H79SbLMPJTq24WjOoFV0z1AjlaD3krCUE4Qpy4fk qqEuuiQPsnxo18YnhZwjr1Ysij/XMgJcJXTpjhjFdKV+00xHkrsK+QRoojvQ0pKz3odI N0Hw== X-Gm-Message-State: ACrzQf1TkcFi72VNpcE2XW5XOj39AeGVInYAXTDM6LczYchBXBlKFXpp 1aNRNmM9ooYNNj9bHO/+9RqPNQ== X-Google-Smtp-Source: AMsMyM6z7rWNvJOzEvrkhbfu/ZGNo55xFYVEZ/j+bkQRsD3HaxV7HSutTelB3bL8hhBSgkCbl8AyaQ== X-Received: by 2002:a05:600c:34cc:b0:3c6:fb65:24cc with SMTP id d12-20020a05600c34cc00b003c6fb6524ccmr3523wmq.1.1666973574631; Fri, 28 Oct 2022 09:12:54 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:54 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 12/16] media: i2c: ov9282: Make V4L2_CID_HBLANK r/w Date: Fri, 28 Oct 2022 17:08:58 +0100 Message-Id: <20221028160902.2696973-13-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There's no reason why HBLANK has to be read-only as it only changes the TIMING_HTS register in the sensor. Remove the READ_ONLY flag, and add the relevant handling for it. The minimum value also varies based on whether continuous clock mode is being used or not, so allow hblank_min to depend on that. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index cfb6e72d8931..2313d5e717f3 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -21,6 +21,9 @@ #define OV9282_MODE_STANDBY 0x00 #define OV9282_MODE_STREAMING 0x01 +#define OV9282_REG_TIMING_HTS 0x380c +#define OV9282_TIMING_HTS_MAX 0x7fff + /* Lines per frame */ #define OV9282_REG_LPFR 0x380e @@ -90,7 +93,8 @@ struct ov9282_reg_list { * struct ov9282_mode - ov9282 sensor mode structure * @width: Frame width * @height: Frame height - * @hblank: Horizontal blanking in lines + * @hblank_min: Minimum horizontal blanking in lines for non-continuous[0] and + * continuous[1] clock modes * @vblank: Vertical blanking in lines * @vblank_min: Minimum vertical blanking in lines * @vblank_max: Maximum vertical blanking in lines @@ -100,7 +104,7 @@ struct ov9282_reg_list { struct ov9282_mode { u32 width; u32 height; - u32 hblank; + u32 hblank_min[2]; u32 vblank; u32 vblank_min; u32 vblank_max; @@ -249,8 +253,6 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3809, 0x00}, {0x380a, 0x02}, {0x380b, 0xd0}, - {0x380c, 0x02}, - {0x380d, 0xfd}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, @@ -273,7 +275,7 @@ static const struct ov9282_mode supported_modes[] = { [MODE_1280_720] = { .width = 1280, .height = 720, - .hblank = 250, + .hblank_min = { 250, 176 }, .vblank = 1022, .vblank_min = 41, .vblank_max = 51540, @@ -397,13 +399,17 @@ static int ov9282_write_regs(struct ov9282 *ov9282, static int ov9282_update_controls(struct ov9282 *ov9282, const struct ov9282_mode *mode) { + u32 hblank_min; int ret; ret = __v4l2_ctrl_s_ctrl(ov9282->link_freq_ctrl, mode->link_freq_idx); if (ret) return ret; - ret = __v4l2_ctrl_s_ctrl(ov9282->hblank_ctrl, mode->hblank); + hblank_min = mode->hblank_min[ov9282->noncontinuous_clock ? 0 : 1]; + ret = __v4l2_ctrl_modify_range(ov9282->hblank_ctrl, hblank_min, + OV9282_TIMING_HTS_MAX - mode->width, 1, + hblank_min); if (ret) return ret; @@ -538,6 +544,10 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_VFLIP: ret = ov9282_set_ctrl_vflip(ov9282, ctrl->val); break; + case V4L2_CID_HBLANK: + ret = ov9282_write_reg(ov9282, OV9282_REG_TIMING_HTS, 2, + (ctrl->val + ov9282->cur_mode->width) >> 1); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret = -EINVAL; @@ -1004,6 +1014,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) struct v4l2_ctrl_handler *ctrl_hdlr = &ov9282->ctrl_handler; const struct ov9282_mode *mode = ov9282->cur_mode; struct v4l2_fwnode_device_properties props; + u32 hblank_min; u32 lpfr; int ret; @@ -1062,14 +1073,13 @@ static int ov9282_init_controls(struct ov9282 *ov9282) if (ov9282->link_freq_ctrl) ov9282->link_freq_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; + hblank_min = mode->hblank_min[ov9282->noncontinuous_clock ? 0 : 1]; ov9282->hblank_ctrl = v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_HBLANK, - OV9282_REG_MIN, - OV9282_REG_MAX, - 1, mode->hblank); - if (ov9282->hblank_ctrl) - ov9282->hblank_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; + hblank_min, + OV9282_TIMING_HTS_MAX - mode->width, + 1, hblank_min); ret = v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { From patchwork Fri Oct 28 16:08:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 619738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEBD6ECAAA1 for ; Fri, 28 Oct 2022 16:15:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230413AbiJ1QP2 (ORCPT ); Fri, 28 Oct 2022 12:15:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230302AbiJ1QOy (ORCPT ); Fri, 28 Oct 2022 12:14:54 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C14A1FB78F for ; Fri, 28 Oct 2022 09:12:57 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so4172039wmb.0 for ; Fri, 28 Oct 2022 09:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=tLONcpe1wBJCaR5ji2PqPS5DxS7tp+cxzI4V/jr+aEU=; b=qGVxZ0+OFzyPmVbOaWzWvXHZc+UGU71z+vVCzDhu8M8SAquqHzxzlBMIKz0e4XffiJ 6O0SzpgzJ+k6jLCLJ1Fda6fRgLpx7EdPFdaza3fwnpb7vmBA1vcr6XoBaCMkARevK1ks K6hbhaFWjs6yXwDXnJHD2S+pLmJcIhlAR5bKcofQK7LDH/oljm5obGpGSjF8cbjh21Bh s/v8+MNqqK+KaHr/fGR2BGa+GQpIHLSQcQxVRRHRnMQTQEQsvmx2ajYNIcbrYL9jTD9z ulyjZ8hPK/i+Xdi8Hd2RsWCWCtY9qn1eixLwqU039g+RWYxNV21kKSzcmZ6oHwk4EOaI PYqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=tLONcpe1wBJCaR5ji2PqPS5DxS7tp+cxzI4V/jr+aEU=; b=Crxkr0hqn/+3fl71siiFml8Fphs2lopjl8JmLqRDKXbL+cl14YiygMt2D7Vf5gMd/T j+zth6Ji7yFWfarlKuPF9gfCqq6pu5Wbep1kknPH88LC6kZ3lM/LspJa/H3DEFbCsro6 MvlmV5o+xlM7KubXbbh6bvcrzsFJTnqJ6aSnDp08j1dasxKpsy2AXYAT4sp18a0PcmTK 9nnLMQTOg7Efwx9z8phN9HnMeoi0/N6MiMdTwi2eRkJlYolrZU1NdRGMj8zR1W9t6Hhn 7bNB5pdDno4vHV8feCIcNMcimPEXUMis5QCUAAdnHyFuGHNX7uZ2sin4As1VciGQKdwL W/nQ== X-Gm-Message-State: ACrzQf2CSDvlAu8a81NukhpmoG+/opHdNYIkxjOcDZgNFa4/x8YC//BN iF7noKjjO1WEE/sAFRgbwv2ulw== X-Google-Smtp-Source: AMsMyM5VO7rkpJaqUWXnWPQ215Z0U+w2yj9wM8eqHLoYdvWA+s+DNe/07CrcK0KgmVh5ahRIxzovTg== X-Received: by 2002:a05:600c:3d92:b0:3c7:12c6:a99f with SMTP id bi18-20020a05600c3d9200b003c712c6a99fmr11161wmb.136.1666973575506; Fri, 28 Oct 2022 09:12:55 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:54 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 13/16] media: i2c: ov9282: Add selection API calls for cropping info Date: Fri, 28 Oct 2022 17:08:59 +0100 Message-Id: <20221028160902.2696973-14-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As required by libcamera, add the relevant cropping targets to report which portion of the sensor is being read out in any mode. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 2313d5e717f3..a520d9fef0cb 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -66,6 +66,17 @@ #define OV9282_PIXEL_RATE (OV9282_LINK_FREQ * 2 * \ OV9282_NUM_DATA_LANES / 10) +/* + * OV9282 native and active pixel array size. + * 8 dummy rows/columns on each edge of a 1280x800 active array + */ +#define OV9282_NATIVE_WIDTH 1296U +#define OV9282_NATIVE_HEIGHT 816U +#define OV9282_PIXEL_ARRAY_LEFT 8U +#define OV9282_PIXEL_ARRAY_TOP 8U +#define OV9282_PIXEL_ARRAY_WIDTH 1280U +#define OV9282_PIXEL_ARRAY_HEIGHT 800U + #define OV9282_REG_MIN 0x00 #define OV9282_REG_MAX 0xfffff @@ -109,6 +120,7 @@ struct ov9282_mode { u32 vblank_min; u32 vblank_max; u32 link_freq_idx; + struct v4l2_rect crop; struct ov9282_reg_list reg_list; }; @@ -280,6 +292,16 @@ static const struct ov9282_mode supported_modes[] = { .vblank_min = 41, .vblank_max = 51540, .link_freq_idx = 0, + .crop = { + /* + * Note that this mode takes the top 720 lines from the + * 800 of the sensor. It does not take a middle crop. + */ + .left = OV9282_PIXEL_ARRAY_LEFT, + .top = OV9282_PIXEL_ARRAY_TOP, + .width = 1280, + .height = 720 + }, .reg_list = { .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), .regs = mode_1280x720_regs, @@ -720,6 +742,58 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd, return ov9282_set_pad_format(sd, sd_state, &fmt); } +static const struct v4l2_rect * +__ov9282_get_pad_crop(struct ov9282 *ov9282, + struct v4l2_subdev_state *sd_state, + unsigned int pad, enum v4l2_subdev_format_whence which) +{ + switch (which) { + case V4L2_SUBDEV_FORMAT_TRY: + return v4l2_subdev_get_try_crop(&ov9282->sd, sd_state, pad); + case V4L2_SUBDEV_FORMAT_ACTIVE: + return &ov9282->cur_mode->crop; + } + + return NULL; +} + +static int ov9282_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP: { + struct ov9282 *ov9282 = to_ov9282(sd); + + mutex_lock(&ov9282->mutex); + sel->r = *__ov9282_get_pad_crop(ov9282, sd_state, sel->pad, + sel->which); + mutex_unlock(&ov9282->mutex); + + return 0; + } + + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = OV9282_NATIVE_WIDTH; + sel->r.height = OV9282_NATIVE_HEIGHT; + + return 0; + + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = OV9282_PIXEL_ARRAY_TOP; + sel->r.left = OV9282_PIXEL_ARRAY_LEFT; + sel->r.width = OV9282_PIXEL_ARRAY_WIDTH; + sel->r.height = OV9282_PIXEL_ARRAY_HEIGHT; + + return 0; + } + + return -EINVAL; +} + /** * ov9282_start_streaming() - Start sensor stream * @ov9282: pointer to ov9282 device @@ -938,6 +1012,7 @@ static const struct v4l2_subdev_pad_ops ov9282_pad_ops = { .enum_frame_size = ov9282_enum_frame_size, .get_fmt = ov9282_get_pad_format, .set_fmt = ov9282_set_pad_format, + .get_selection = ov9282_get_selection, }; static const struct v4l2_subdev_ops ov9282_subdev_ops = { From patchwork Fri Oct 28 16:09:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 620155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70EA9C38A02 for ; Fri, 28 Oct 2022 16:15:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230398AbiJ1QP0 (ORCPT ); Fri, 28 Oct 2022 12:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbiJ1QOy (ORCPT ); Fri, 28 Oct 2022 12:14:54 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EDFC22C461 for ; Fri, 28 Oct 2022 09:12:57 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id r186-20020a1c44c3000000b003cf4d389c41so4105064wma.3 for ; Fri, 28 Oct 2022 09:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=A6TMFQMv5fFdWCnBKAllpmUgnFPJrPoVSmYxgifBigY=; b=ltGPIAcEo5uavGGBxGu1lgzZaZKe6N1kLEh6Qj4HDfACPkPNjRyYxKjaJMO+cOaKy7 FeOtjAxgrRj4eC5KEHKpPGZqWyDRiMYYDXZO2OEDEkY9NTjpmJisHk6sjB4ciR/MqlNF G1Z0gI1fzAeNt+GkFS9BqNOMtExNfJ8fQ2kv3opEYOy8T4CQPqjBsN9qohxK7RZFe7T0 mqp9mgAyAmAVe5WGTPGseCu1eVtg01Rj/CfcS2XScAiJJKff/a5DB3r9anw1mdVoUYM2 yESV7WWv0uZWlhW1bkRjBI+gPDMayqRuACBL7dTbWVEFPgar+rPqcgNhchP5algdLFek GbSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=A6TMFQMv5fFdWCnBKAllpmUgnFPJrPoVSmYxgifBigY=; b=dn8vwBPt5PgsoCWBpsuB1BCPqBPNNs/sCVkstkxHUhEv+ckFq794Vq6HMzyheuSMcg SYqmPHX9viAHKqEIOGTmq2YlTEfGxeWj1ThOYlabVxMaOpTM/OgnQoRgoLfTtCYehz4m UjeRMGG8DM7UWwp0RWMMIS5aeWtixCWTpnRFbzxn4wqtIIaJvCcXfxXV9IUj9OCHjq+k /ORyqKmGxFbTMZvWezzPmAWgPhFRNpS5ksArMFaMEP2AVJhaa3fAelJkDjPshPGIoejr WvJVZczEPketVB0hPseRXLN9lC/KmLE0FYZwxHAwruYTZg2xmBplY/rAVQWIhKeUf5YB Qc9w== X-Gm-Message-State: ACrzQf2DZTA6zsMxebb6/KzFGxp/H/0KpzBG0hbnZCCEg4y4oVjJYoav WQ8B36TLuoD4YVKtjhlfDV4WwOLu6p4EOg== X-Google-Smtp-Source: AMsMyM6HRGbHcw5RWt8qCGTEQr+1cYO7JiZG9jZ8hUGNrN6Vk6CvcIBY+bVSLCyR1o7UkdyJYZn3Dg== X-Received: by 2002:a05:600c:524a:b0:3c6:f820:fc7c with SMTP id fc10-20020a05600c524a00b003c6f820fc7cmr6023wmb.172.1666973576257; Fri, 28 Oct 2022 09:12:56 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:55 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 14/16] media: i2c: ov9282: Add support for 1280x800 and 640x400 modes Date: Fri, 28 Oct 2022 17:09:00 +0100 Message-Id: <20221028160902.2696973-15-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Adds register settings for additional modes. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 103 ++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index a520d9fef0cb..c169b532ec8b 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -246,11 +246,44 @@ struct ov9282_reg_list common_regs_list = { .regs = common_regs, }; -#define MODE_1280_720 0 +#define MODE_1280_800 0 +#define MODE_1280_720 1 +#define MODE_640_400 2 #define DEFAULT_MODE MODE_1280_720 /* Sensor mode registers */ +static const struct ov9282_reg mode_1280x800_regs[] = { + {0x3778, 0x00}, + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0x05}, + {0x3805, 0x0f}, + {0x3806, 0x03}, + {0x3807, 0x2f}, + {0x3808, 0x05}, + {0x3809, 0x00}, + {0x380a, 0x03}, + {0x380b, 0x20}, + {0x3810, 0x00}, + {0x3811, 0x08}, + {0x3812, 0x00}, + {0x3813, 0x08}, + {0x3814, 0x11}, + {0x3815, 0x11}, + {0x3820, 0x40}, + {0x3821, 0x00}, + {0x4003, 0x40}, + {0x4008, 0x04}, + {0x4009, 0x0b}, + {0x400c, 0x00}, + {0x400d, 0x07}, + {0x4507, 0x00}, + {0x4509, 0x00}, +}; + static const struct ov9282_reg mode_1280x720_regs[] = { {0x3778, 0x00}, {0x3800, 0x00}, @@ -282,8 +315,57 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x4509, 0x80}, }; +static const struct ov9282_reg mode_640x400_regs[] = { + {0x3778, 0x10}, + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0x05}, + {0x3805, 0x0f}, + {0x3806, 0x03}, + {0x3807, 0x2f}, + {0x3808, 0x02}, + {0x3809, 0x80}, + {0x380a, 0x01}, + {0x380b, 0x90}, + {0x3810, 0x00}, + {0x3811, 0x04}, + {0x3812, 0x00}, + {0x3813, 0x04}, + {0x3814, 0x31}, + {0x3815, 0x22}, + {0x3820, 0x60}, + {0x3821, 0x01}, + {0x4008, 0x02}, + {0x4009, 0x05}, + {0x400c, 0x00}, + {0x400d, 0x03}, + {0x4507, 0x03}, + {0x4509, 0x80}, +}; + /* Supported sensor mode configurations */ static const struct ov9282_mode supported_modes[] = { + [MODE_1280_800] = { + .width = 1280, + .height = 800, + .hblank_min = { 250, 176 }, + .vblank = 1022, + .vblank_min = 110, + .vblank_max = 51540, + .link_freq_idx = 0, + .crop = { + .left = OV9282_PIXEL_ARRAY_LEFT, + .top = OV9282_PIXEL_ARRAY_TOP, + .width = 1280, + .height = 800 + }, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_1280x800_regs), + .regs = mode_1280x800_regs, + }, + }, [MODE_1280_720] = { .width = 1280, .height = 720, @@ -307,6 +389,25 @@ static const struct ov9282_mode supported_modes[] = { .regs = mode_1280x720_regs, }, }, + [MODE_640_400] = { + .width = 640, + .height = 400, + .hblank_min = { 890, 816 }, + .vblank = 1022, + .vblank_min = 22, + .vblank_max = 51540, + .link_freq_idx = 0, + .crop = { + .left = OV9282_PIXEL_ARRAY_LEFT, + .top = OV9282_PIXEL_ARRAY_TOP, + .width = 1280, + .height = 800 + }, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_640x400_regs), + .regs = mode_640x400_regs, + }, + }, }; /** From patchwork Fri Oct 28 16:09:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 620153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E33E9FA3742 for ; Fri, 28 Oct 2022 16:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbiJ1QPi (ORCPT ); Fri, 28 Oct 2022 12:15:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbiJ1QOz (ORCPT ); Fri, 28 Oct 2022 12:14:55 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7908F1F8137 for ; Fri, 28 Oct 2022 09:12:58 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id l14-20020a05600c1d0e00b003c6ecc94285so5693952wms.1 for ; Fri, 28 Oct 2022 09:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=GttpLELLpWw2JHGHgE1C0hoW9jnug4HdbMelLQAyY04=; b=kNeDFmdNd1uktBztkWS/M2IAt6fKDK2tVDTT3dmJ5CkSxFJMvuReLK9TYSCr9y9h5r R9XdOhXp3c3Hs+I6jJ3e1Di7rZM8RrHBsqqRQ2kb6+QpemisNs/tglKXThfbqs82Kin4 vqALalky8GE775BSik8Zb1Zbp2+VABcujF59efWcZgjMjvRHlp6VuzIuGxpqLCTkHaqA T5Okp3Qp37evDUNUG0Cc+yg3yG0JdJxcMLx6Vvnbv4lULqkqgJK/WnTIARUp/eHYNM5d EiMjS2QtPkniM7NOwMFRmGz3SUO8e8tFijSAuT2Y4sbrqRavQKx0lDXj5jBTShqhARET 3Trg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=GttpLELLpWw2JHGHgE1C0hoW9jnug4HdbMelLQAyY04=; b=dxZH2mKvlIOoRurRtsDqWDYU7d6en/P7bSf7UWtYvgWN1SDK0pmIVXJP+N5QcoBdln E8M4g+rKJ8UJYVlINF48BkfYzv5m81d8DAKB7SBXfff1xIoz4OjrBS01lCXMnK4+b+xQ 8ltm9m8bjpfco/yCcAUUqt7SWV++LImiuIP1RgqWQCJ6CEml3OqGtdi3J4vq16hEdD2Y ADW4r2yr1mkGb3PK28hNRpwmbdMB9kKA8QyxHLWci0yo6B2wSN7zBtWXPD7O4veBnBz0 ar2dpKnxfnZXNH3O3OwE3pSHWI8k08g04zItdqoYwRUVNpGGlcKaqNqSSmcv59BTiQYb AXew== X-Gm-Message-State: ACrzQf0OpnuFZv/lLeiNnVfEbJroWpsK8rCQmg0uOkJM3ZhATSxWSA82 DEW3sYH7wyzMFmh9zL5qbRkV5w== X-Google-Smtp-Source: AMsMyM5EX2Gjj+fw8VZQCe5oBhvq345/tSyFz1qCcAZaW8EyMHGu3iwno16mAzz2kWsW7lZxHFTCAA== X-Received: by 2002:a1c:3503:0:b0:3c6:fb2a:b115 with SMTP id c3-20020a1c3503000000b003c6fb2ab115mr39356wma.10.1666973577013; Fri, 28 Oct 2022 09:12:57 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:56 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 15/16] media: i2c: ov9282: Add support for 8bit readout Date: Fri, 28 Oct 2022 17:09:01 +0100 Message-Id: <20221028160902.2696973-16-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The sensor supports 8 or 10 bit readout modes, but the driver only supported 10 bit. Add 8 bit readout. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 95 +++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 17 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index c169b532ec8b..e2a98f480b58 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -21,6 +21,10 @@ #define OV9282_MODE_STANDBY 0x00 #define OV9282_MODE_STREAMING 0x01 +#define OV9282_REG_PLL_CTRL_0D 0x030d +#define OV9282_PLL_CTRL_0D_RAW8 0x60 +#define OV9282_PLL_CTRL_0D_RAW10 0x50 + #define OV9282_REG_TIMING_HTS 0x380c #define OV9282_TIMING_HTS_MAX 0x7fff @@ -48,6 +52,10 @@ /* Group hold register */ #define OV9282_REG_HOLD 0x3308 +#define OV9282_REG_ANA_CORE_2 0x3662 +#define OV9282_ANA_CORE2_RAW8 0x07 +#define OV9282_ANA_CORE2_RAW10 0x05 + #define OV9282_REG_TIMING_FORMAT_1 0x3820 #define OV9282_REG_TIMING_FORMAT_2 0x3821 #define OV9282_FLIP_BIT BIT(2) @@ -63,8 +71,10 @@ #define OV9282_NUM_DATA_LANES 2 /* Pixel rate */ -#define OV9282_PIXEL_RATE (OV9282_LINK_FREQ * 2 * \ - OV9282_NUM_DATA_LANES / 10) +#define OV9282_PIXEL_RATE_10BIT (OV9282_LINK_FREQ * 2 * \ + OV9282_NUM_DATA_LANES / 10) +#define OV9282_PIXEL_RATE_8BIT (OV9282_LINK_FREQ * 2 * \ + OV9282_NUM_DATA_LANES / 8) /* * OV9282 native and active pixel array size. @@ -140,6 +150,7 @@ struct ov9282_mode { * @again_ctrl: Pointer to analog gain control * @vblank: Vertical blanking in lines * @cur_mode: Pointer to current selected sensor mode + * @code: Mbus code currently selected * @mutex: Mutex for serializing sensor controls * @streaming: Flag indicating streaming state */ @@ -158,9 +169,11 @@ struct ov9282 { struct v4l2_ctrl *exp_ctrl; struct v4l2_ctrl *again_ctrl; }; + struct v4l2_ctrl *pixel_rate; u32 vblank; bool noncontinuous_clock; const struct ov9282_mode *cur_mode; + u32 code; struct mutex mutex; bool streaming; }; @@ -178,7 +191,6 @@ static const s64 link_freq[] = { */ static const struct ov9282_reg common_regs[] = { {0x0302, 0x32}, - {0x030d, 0x50}, {0x030e, 0x02}, {0x3001, 0x00}, {0x3004, 0x00}, @@ -516,19 +528,29 @@ static int ov9282_write_regs(struct ov9282 *ov9282, * ov9282_update_controls() - Update control ranges based on streaming mode * @ov9282: pointer to ov9282 device * @mode: pointer to ov9282_mode sensor mode + * @fmt: pointer to the requested mode * * Return: 0 if successful, error code otherwise. */ static int ov9282_update_controls(struct ov9282 *ov9282, - const struct ov9282_mode *mode) + const struct ov9282_mode *mode, + const struct v4l2_subdev_format *fmt) { u32 hblank_min; + s64 pixel_rate; int ret; ret = __v4l2_ctrl_s_ctrl(ov9282->link_freq_ctrl, mode->link_freq_idx); if (ret) return ret; + pixel_rate = (fmt->format.code == MEDIA_BUS_FMT_Y10_1X10) ? + OV9282_PIXEL_RATE_10BIT : OV9282_PIXEL_RATE_8BIT; + ret = __v4l2_ctrl_modify_range(ov9282->pixel_rate, pixel_rate, + pixel_rate, 1, pixel_rate); + if (ret) + return ret; + hblank_min = mode->hblank_min[ov9282->noncontinuous_clock ? 0 : 1]; ret = __v4l2_ctrl_modify_range(ov9282->hblank_ctrl, hblank_min, OV9282_TIMING_HTS_MAX - mode->width, 1, @@ -698,10 +720,16 @@ static int ov9282_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) { - if (code->index > 0) + switch (code->index) { + case 0: + code->code = MEDIA_BUS_FMT_Y10_1X10; + break; + case 1: + code->code = MEDIA_BUS_FMT_Y8_1X8; + break; + default: return -EINVAL; - - code->code = MEDIA_BUS_FMT_Y10_1X10; + } return 0; } @@ -721,7 +749,8 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, if (fsize->index >= ARRAY_SIZE(supported_modes)) return -EINVAL; - if (fsize->code != MEDIA_BUS_FMT_Y10_1X10) + if (fsize->code != MEDIA_BUS_FMT_Y10_1X10 && + fsize->code != MEDIA_BUS_FMT_Y8_1X8) return -EINVAL; fsize->min_width = supported_modes[fsize->index].width; @@ -737,15 +766,17 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, * from selected sensor mode * @ov9282: pointer to ov9282 device * @mode: pointer to ov9282_mode sensor mode + * @code: mbus code to be stored * @fmt: V4L2 sub-device format need to be filled */ static void ov9282_fill_pad_format(struct ov9282 *ov9282, const struct ov9282_mode *mode, + u32 code, struct v4l2_subdev_format *fmt) { fmt->format.width = mode->width; fmt->format.height = mode->height; - fmt->format.code = MEDIA_BUS_FMT_Y10_1X10; + fmt->format.code = code; fmt->format.field = V4L2_FIELD_NONE; fmt->format.colorspace = V4L2_COLORSPACE_RAW; fmt->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; @@ -775,7 +806,8 @@ static int ov9282_get_pad_format(struct v4l2_subdev *sd, framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); fmt->format = *framefmt; } else { - ov9282_fill_pad_format(ov9282, ov9282->cur_mode, fmt); + ov9282_fill_pad_format(ov9282, ov9282->cur_mode, ov9282->code, + fmt); } mutex_unlock(&ov9282->mutex); @@ -797,6 +829,7 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, { struct ov9282 *ov9282 = to_ov9282(sd); const struct ov9282_mode *mode; + u32 code; int ret = 0; mutex_lock(&ov9282->mutex); @@ -806,7 +839,12 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, width, height, fmt->format.width, fmt->format.height); - ov9282_fill_pad_format(ov9282, mode, fmt); + if (fmt->format.code == MEDIA_BUS_FMT_Y8_1X8) + code = MEDIA_BUS_FMT_Y8_1X8; + else + code = MEDIA_BUS_FMT_Y10_1X10; + + ov9282_fill_pad_format(ov9282, mode, code, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { struct v4l2_mbus_framefmt *framefmt; @@ -814,9 +852,11 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); *framefmt = fmt->format; } else { - ret = ov9282_update_controls(ov9282, mode); - if (!ret) + ret = ov9282_update_controls(ov9282, mode, fmt); + if (!ret) { ov9282->cur_mode = mode; + ov9282->code = code; + } } mutex_unlock(&ov9282->mutex); @@ -838,7 +878,8 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd, struct v4l2_subdev_format fmt = { 0 }; fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; - ov9282_fill_pad_format(ov9282, &supported_modes[DEFAULT_MODE], &fmt); + ov9282_fill_pad_format(ov9282, &supported_modes[DEFAULT_MODE], + ov9282->code, &fmt); return ov9282_set_pad_format(sd, sd_state, &fmt); } @@ -903,7 +944,17 @@ static int ov9282_get_selection(struct v4l2_subdev *sd, */ static int ov9282_start_streaming(struct ov9282 *ov9282) { + const struct ov9282_reg bitdepth_regs[2][2] = { + { + {OV9282_REG_PLL_CTRL_0D, OV9282_PLL_CTRL_0D_RAW10}, + {OV9282_REG_ANA_CORE_2, OV9282_ANA_CORE2_RAW10}, + }, { + {OV9282_REG_PLL_CTRL_0D, OV9282_PLL_CTRL_0D_RAW8}, + {OV9282_REG_ANA_CORE_2, OV9282_ANA_CORE2_RAW8}, + } + }; const struct ov9282_reg_list *reg_list; + int bitdepth_index; int ret; /* Write common registers */ @@ -914,6 +965,13 @@ static int ov9282_start_streaming(struct ov9282 *ov9282) return ret; } + bitdepth_index = ov9282->code == MEDIA_BUS_FMT_Y10_1X10 ? 0 : 1; + ret = ov9282_write_regs(ov9282, bitdepth_regs[bitdepth_index], 2); + if (ret) { + dev_err(ov9282->dev, "fail to write bitdepth regs"); + return ret; + } + /* Write sensor mode registers */ reg_list = &ov9282->cur_mode->reg_list; ret = ov9282_write_regs(ov9282, reg_list->regs, reg_list->num_of_regs); @@ -1235,9 +1293,11 @@ static int ov9282_init_controls(struct ov9282 *ov9282) 0, 1, 1, 1); /* Read only controls */ - v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_PIXEL_RATE, - OV9282_PIXEL_RATE, OV9282_PIXEL_RATE, 1, - OV9282_PIXEL_RATE); + ov9282->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, + V4L2_CID_PIXEL_RATE, + OV9282_PIXEL_RATE_10BIT, + OV9282_PIXEL_RATE_10BIT, 1, + OV9282_PIXEL_RATE_10BIT); ov9282->link_freq_ctrl = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov9282_ctrl_ops, @@ -1319,6 +1379,7 @@ static int ov9282_probe(struct i2c_client *client) /* Set default mode to first mode */ ov9282->cur_mode = &supported_modes[DEFAULT_MODE]; + ov9282->code = MEDIA_BUS_FMT_Y10_1X10; ov9282->vblank = ov9282->cur_mode->vblank; ret = ov9282_init_controls(ov9282); From patchwork Fri Oct 28 16:09:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 619736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DAEFC38A02 for ; Fri, 28 Oct 2022 16:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231146AbiJ1QPk (ORCPT ); Fri, 28 Oct 2022 12:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230333AbiJ1QOz (ORCPT ); Fri, 28 Oct 2022 12:14:55 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7620026AF5 for ; Fri, 28 Oct 2022 09:12:59 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id z14so7191166wrn.7 for ; Fri, 28 Oct 2022 09:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=UD6YtWjHzYqdhBfSIlIPdI194KwUqnwFe0lqlTST5gU=; b=Ag4jHAVaRfqDyqOw21A4Ca2FBxO+CedejWEKNR9+IK4eho+34cGeDdsdOD0qXrgqaV vnFMd2lr77FA5btBf5WQe6IJEZBrST5xuF4Iuo3UVLnIvSBoR6vVoBw3EdAiVaIXcGJL 8M5xK3vhDaYlU3gIoVFiZA60OjEmb/tye8sfAKr6BNH6L68xrUjgtODc042ieF85wGps S7/xofLkusZ6peanxdn5Pvk+EKfc8pBMfbVxfuDlZk7/7sJwP/S1C62VxXw/ysPuNk6o V6P0ElutMhacnxalVJ4sowYQzmf63WohNEZ6EhNMvuUQwA6c9Z99yyTzAWcrNqJsrnDU nYxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=UD6YtWjHzYqdhBfSIlIPdI194KwUqnwFe0lqlTST5gU=; b=dB69rDv/tmk5gw/cNNL8YmxeDla/9HYqjDI+FNGIog1aHgUlb9d+CkUkqdEfBQCETb KTs+/eP/pcjynWPyx3WKWAE0//ROx4+vF5vryeMnHzZtzEBclZ8Ac9xQpJynNk6XG05f 1ffmapdo4XrsZGwRsjrbooL0QiGB1QlxFgA32UqkcGHVzSFeMdfzz8fV4ziB63AUWkGA OuONr+w4tzJ/Fgt/xPnVTecK3KfcDnhARNYPHY6Kg2I6fxHvXOfAax3C9IesKRk0DEl+ qrPp6euqVGsdr765en55A39hJOZDkqWaVQuhAbb/+aCTcFmfi8nj0V4GMQClQxtl8lCq 243g== X-Gm-Message-State: ACrzQf079XhgON585uHJ0j1Ln81P1w8XWCmESiRr8FDIoVM4TB0ORMFi RbUQTW3qcen1/zeGvrfnHoGvqw== X-Google-Smtp-Source: AMsMyM681y1B5mol+HsAtdmY/u18EwwLDbfbWbBWsjJv8mmHLXibL/WMIS/LJmd4U7gisZ3JYkQ5Lw== X-Received: by 2002:a05:6000:2ae:b0:231:86ac:979a with SMTP id l14-20020a05600002ae00b0023186ac979amr55897wry.611.1666973578062; Fri, 28 Oct 2022 09:12:58 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id bh17-20020a05600c3d1100b003cf47fdead5sm4731928wmb.30.2022.10.28.09.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 09:12:57 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org, sakari.ailus@iki.fi, jacopo@jmondi.org Cc: Dave Stevenson Subject: [PATCH v2 16/16] media: i2c: ov9282: Support event handlers Date: Fri, 28 Oct 2022 17:09:02 +0100 Message-Id: <20221028160902.2696973-17-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> References: <20221028160902.2696973-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As noted in the headers for V4L2_SUBDEV_FL_HAS_EVENTS, "controls can send events, thus drivers exposing controls should set this flag". This driver exposes controls, but didn't reflect that it could generate events. Correct this, and add the default event handler functions. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index e2a98f480b58..f2ec92deb5ec 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -1161,6 +1162,11 @@ static int ov9282_parse_hw_config(struct ov9282 *ov9282) } /* V4l2 subdevice ops */ +static const struct v4l2_subdev_core_ops ov9282_core_ops = { + .subscribe_event = v4l2_ctrl_subdev_subscribe_event, + .unsubscribe_event = v4l2_event_subdev_unsubscribe, +}; + static const struct v4l2_subdev_video_ops ov9282_video_ops = { .s_stream = ov9282_set_stream, }; @@ -1175,6 +1181,7 @@ static const struct v4l2_subdev_pad_ops ov9282_pad_ops = { }; static const struct v4l2_subdev_ops ov9282_subdev_ops = { + .core = &ov9282_core_ops, .video = &ov9282_video_ops, .pad = &ov9282_pad_ops, }; @@ -1389,7 +1396,8 @@ static int ov9282_probe(struct i2c_client *client) } /* Initialize subdev */ - ov9282->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + ov9282->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | + V4L2_SUBDEV_FL_HAS_EVENTS; ov9282->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; /* Initialize source pad */