From patchwork Fri Dec 15 08:24:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommaso Merciai X-Patchwork-Id: 98022 Received: from ny.mirrors.kernel.org ([147.75.199.223]) by www.linuxtv.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rE3VY-008CWo-OS for patchwork@linuxtv.org; Fri, 15 Dec 2023 08:25:21 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AEA601C22626 for ; Fri, 15 Dec 2023 08:25:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 670BC171B4; Fri, 15 Dec 2023 08:25:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eTIHG7CN" X-Original-To: linux-media@vger.kernel.org Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BE1212E40; Fri, 15 Dec 2023 08:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a22f2a28c16so52157466b.0; Fri, 15 Dec 2023 00:24:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702628697; x=1703233497; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LiWcmWF3ECN1EHsWLphg963xq61PlotZ875/+bCwtkY=; b=eTIHG7CNtuTIsy1p9b1EshQ96WasPGw4TqF7QoA5XUD2Xv03oE9q64e+jofRcPmY1K MdBvIFMmAmd/vWkpGjSvmFTMd1lawoC2O+6CFbNAVyjze9wQ4LgRDNAAg4ejrlEDbziM ayVptMppyXLNZXrpH+vqg1NUCtxtb+d5jRP1EhStHkC6b0MC3hchaoC1BFjzelFg27Wp CPXbQC2tdhYvUPW68lfuM2SPwjULVcMZslDH2+ErN+BuVNXWwZz95yt9I8eHxTJHYH6A 18dYoY2bd3rhuQpSYOaePjtkY46GL76c8cgu6CIqPAzq3y2BJxhNOD/pFbpbWQpPhpfv c6jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702628697; x=1703233497; 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=LiWcmWF3ECN1EHsWLphg963xq61PlotZ875/+bCwtkY=; b=lM7HoP7AD+Sp6xZ5CrS6FWaitvnUgbVqrkuYPCGUXBMwnOhcpdr2Zi0wCDJW2b7I01 2RokihiGrjgZhgmlh5qoqU0TPhWS8ZQKDNiwmZOxQOhMhwzeekLVAuyw7LcD1GyeKNOt ER/2yCpkoSH4JW4qE7jRMQZ0CJ0rDpf6YBPi4ugCQ11yTk3HRx00ckZk3fjyTnhVm3tQ OiymE/iuV0dQO1kPvBZ4I64uQIeW5fReZXUAeJvk59r5Z+S9eOdI4+gSeGXgvZ5LcqHp sLgpEoRKt5de/VENoNtBEJGy3lCh1JDdyZD9SEw8/GqHDvQoQ0HECKdfIjJLu1Htj243 VcMQ== X-Gm-Message-State: AOJu0YxFNTKV84hrDN/TbRQD6PBjtTVDHlP37u5pg+v6aNPYzv9T988V guJ856tYLRfGUJLWb/9cKvQ= X-Google-Smtp-Source: AGHT+IGo5SfWEhbBQyTNURRiTXDMeP5uROQfe2ogLhMjzmtSPlpiB02zE+JFb0Ki5lLBfP72bbpwGQ== X-Received: by 2002:a17:907:7e8c:b0:a10:f087:ba43 with SMTP id qb12-20020a1709077e8c00b00a10f087ba43mr4299846ejc.43.1702628696676; Fri, 15 Dec 2023 00:24:56 -0800 (PST) Received: from tom-HP-ZBook-Fury-15-G7-Mobile-Workstation.station (net-188-217-59-229.cust.vodafonedsl.it. [188.217.59.229]) by smtp.gmail.com with ESMTPSA id un7-20020a170907cb8700b00a1b65249053sm10395951ejc.128.2023.12.15.00.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 00:24:56 -0800 (PST) From: Tommaso Merciai To: Cc: linuxfancy@googlegroups.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, tomm.merciai@gmail.com, Martin Hecht , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] media: i2c: alvium: removal of dft_fr, min_fr and max_fr Date: Fri, 15 Dec 2023 09:24:50 +0100 Message-Id: <20231215082452.1720481-2-tomm.merciai@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231215082452.1720481-1-tomm.merciai@gmail.com> References: <20231215082452.1720481-1-tomm.merciai@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no Remove driver private data dft_fr, min_fr and max_fr. Those are used only in alvium_set_frame_interval function. Use local ones instead. Signed-off-by: Tommaso Merciai --- drivers/media/i2c/alvium-csi2.c | 45 +++++++++++++++------------------ drivers/media/i2c/alvium-csi2.h | 3 --- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c index 34ff7fad3877..c4b7851045a1 100644 --- a/drivers/media/i2c/alvium-csi2.c +++ b/drivers/media/i2c/alvium-csi2.c @@ -1170,40 +1170,36 @@ static int alvium_set_bayer_pattern(struct alvium_dev *alvium, return 0; } -static int alvium_get_frame_interval(struct alvium_dev *alvium) +static int alvium_get_frame_interval(struct alvium_dev *alvium, + u64 *dft_fr, u64 *min_fr, u64 *max_fr) { - u64 dft_fr, min_fr, max_fr; int ret = 0; alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW, - &dft_fr, &ret); + dft_fr, &ret); alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MIN_R, - &min_fr, &ret); + min_fr, &ret); alvium_read(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_MAX_R, - &max_fr, &ret); + max_fr, &ret); if (ret) return ret; - alvium->dft_fr = dft_fr; - alvium->min_fr = min_fr; - alvium->max_fr = max_fr; - return 0; } -static int alvium_set_frame_rate(struct alvium_dev *alvium) +static int alvium_set_frame_rate(struct alvium_dev *alvium, u64 fr) { struct device *dev = &alvium->i2c_client->dev; int ret; ret = alvium_write_hshake(alvium, REG_BCRM_ACQUISITION_FRAME_RATE_RW, - alvium->fr); + fr); if (ret) { dev_err(dev, "Fail to set frame rate lanes reg\n"); return ret; } - dev_dbg(dev, "set frame rate: %llu us\n", alvium->fr); + dev_dbg(dev, "set frame rate: %llu us\n", fr); return 0; } @@ -1667,36 +1663,36 @@ static int alvium_g_frame_interval(struct v4l2_subdev *sd, } static int alvium_set_frame_interval(struct alvium_dev *alvium, - struct v4l2_subdev_frame_interval *fi) + struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_interval *fi, + u64 *req_fr) { struct device *dev = &alvium->i2c_client->dev; - u64 req_fr, min_fr, max_fr; + u64 dft_fr, min_fr, max_fr; int ret; if (fi->interval.denominator == 0) return -EINVAL; - ret = alvium_get_frame_interval(alvium); + ret = alvium_get_frame_interval(alvium, &dft_fr, &min_fr, &max_fr); if (ret) { dev_err(dev, "Fail to get frame interval\n"); return ret; } - min_fr = alvium->min_fr; - max_fr = alvium->max_fr; - dev_dbg(dev, "fi->interval.numerator = %d\n", fi->interval.numerator); dev_dbg(dev, "fi->interval.denominator = %d\n", fi->interval.denominator); - req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) / + *req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) / fi->interval.numerator); - if (req_fr >= max_fr && req_fr <= min_fr) - req_fr = alvium->dft_fr; + if (*req_fr >= max_fr && *req_fr <= min_fr) + *req_fr = dft_fr; - alvium->fr = req_fr; + alvium->fr = *req_fr; alvium->frame_interval.numerator = fi->interval.numerator; alvium->frame_interval.denominator = fi->interval.denominator; @@ -1708,6 +1704,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, struct v4l2_subdev_frame_interval *fi) { struct alvium_dev *alvium = sd_to_alvium(sd); + u64 req_fr; int ret; /* @@ -1720,9 +1717,9 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, if (alvium->streaming) return -EBUSY; - ret = alvium_set_frame_interval(alvium, fi); + ret = alvium_set_frame_interval(alvium, sd, sd_state, fi, &req_fr); if (!ret) - ret = alvium_set_frame_rate(alvium); + ret = alvium_set_frame_rate(alvium, req_fr); return ret; } diff --git a/drivers/media/i2c/alvium-csi2.h b/drivers/media/i2c/alvium-csi2.h index 8b554bffdc39..a6529b28e7dd 100644 --- a/drivers/media/i2c/alvium-csi2.h +++ b/drivers/media/i2c/alvium-csi2.h @@ -443,9 +443,6 @@ struct alvium_dev { struct alvium_mode mode; struct v4l2_fract frame_interval; - u64 dft_fr; - u64 min_fr; - u64 max_fr; u64 fr; u8 h_sup_csi_lanes; From patchwork Fri Dec 15 08:24:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommaso Merciai X-Patchwork-Id: 98023 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by www.linuxtv.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rE3Vr-008CXn-4P for patchwork@linuxtv.org; Fri, 15 Dec 2023 08:25:39 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6CFD9284225 for ; Fri, 15 Dec 2023 08:25:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F336171A6; Fri, 15 Dec 2023 08:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YnkV30fS" X-Original-To: linux-media@vger.kernel.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6E64171D6; Fri, 15 Dec 2023 08:25:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a1d93da3eb7so44806966b.0; Fri, 15 Dec 2023 00:25:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702628699; x=1703233499; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KXavCEOPr4iSD0C6FGudUMpba9nYCcbhn+aT3MsQBmU=; b=YnkV30fShGc0OWirWhG8DX/e3A/gPD/t7Ht7+4ebZ1aaUSgJXZNcfd7sV7NvBIn0hf VLLMc6IOgXISQ4nOwiqovyMsM/EFvF/MOtNGDAVwerZ4xQb1AE0c/740agRFrwPF2hI+ 4WP6E9JwVq+IsfcEchrcOnNCf2zNTcfbhommopPIUCLi26jMdmJOA3xMGVnFNJZx5pKY bpSTSwNzicLVDGRAPqkIqfyiey5keTUx9m2A9hdVYsoGrecqgFFgLH36as60vrjdT79j yynwTRwuOOmrTbrmYXep3Mmd2Mz/Zgh6nlrbtVCvNeUXmvs1ctn9xy8T2qCGIFxkgEBi knAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702628699; x=1703233499; 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=KXavCEOPr4iSD0C6FGudUMpba9nYCcbhn+aT3MsQBmU=; b=lOV9I+1cMSB1BPQ8Dy9vXxWBCFx6Ld/a3PLbFYDvZbHyx6Rks6brPHBCZUhIbR7Hkz RDV+1O6lSUaT6VRCSuHmLIqIj5F96bWYbW8C0xiKH4eVtw7tpAbuE85lnlJ5+hVn+Z6g ScKZO9mZaA8CNaAtXJ/Pj/txlNx08GExn70/EBPtyIVKqMYEd/dMbgfyKPE7I1umsg9W I6foa0hSObRcn0LK91knFw1aGKX/wm+FtJoxJU0aji7U1wYgkqCZUy5eKjn/vWqeVBCE Evh+bdWM0yDPS+S0KtGZoKZK4RWB2G+eF0QDUiPfzulwWmMeZktcnc3eY7Lkw6pFVR8E FEsA== X-Gm-Message-State: AOJu0YyWzdWsvwLXgiCW2ymTv9BnWFsvUwGbGhGM8IDHn+ZSW3XI0FXQ AjJJjibBrD6comU4VGMGTno= X-Google-Smtp-Source: AGHT+IGl3C8K5Cey16qOIp2+DSDUrXM2P0vgoy5y9p/ZYLInnc7buNdYQYPbC7AkTYhNOrygMRURxw== X-Received: by 2002:a17:907:503:b0:9c4:b8c9:1bf4 with SMTP id wj3-20020a170907050300b009c4b8c91bf4mr4291794ejb.19.1702628698533; Fri, 15 Dec 2023 00:24:58 -0800 (PST) Received: from tom-HP-ZBook-Fury-15-G7-Mobile-Workstation.station (net-188-217-59-229.cust.vodafonedsl.it. [188.217.59.229]) by smtp.gmail.com with ESMTPSA id un7-20020a170907cb8700b00a1b65249053sm10395951ejc.128.2023.12.15.00.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 00:24:58 -0800 (PST) From: Tommaso Merciai To: Cc: linuxfancy@googlegroups.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, tomm.merciai@gmail.com, Martin Hecht , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] media: i2c: alvium: inline set_frame_interval into s_frame_interval Date: Fri, 15 Dec 2023 09:24:51 +0100 Message-Id: <20231215082452.1720481-3-tomm.merciai@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231215082452.1720481-1-tomm.merciai@gmail.com> References: <20231215082452.1720481-1-tomm.merciai@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=unavailable autolearn_force=no Inline alvium_s_frame_interval function into alvium_s_frame_interval. This to clean the driver code. Signed-off-by: Tommaso Merciai --- drivers/media/i2c/alvium-csi2.c | 56 ++++++++++++--------------------- 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c index c4b7851045a1..fde456357be1 100644 --- a/drivers/media/i2c/alvium-csi2.c +++ b/drivers/media/i2c/alvium-csi2.c @@ -1662,16 +1662,25 @@ static int alvium_g_frame_interval(struct v4l2_subdev *sd, return 0; } -static int alvium_set_frame_interval(struct alvium_dev *alvium, - struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_frame_interval *fi, - u64 *req_fr) +static int alvium_s_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_interval *fi) { + struct alvium_dev *alvium = sd_to_alvium(sd); struct device *dev = &alvium->i2c_client->dev; - u64 dft_fr, min_fr, max_fr; + u64 req_fr, dft_fr, min_fr, max_fr; int ret; + /* + * FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2 + * subdev active state API. + */ + if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE) + return -EINVAL; + + if (alvium->streaming) + return -EBUSY; + if (fi->interval.denominator == 0) return -EINVAL; @@ -1686,42 +1695,17 @@ static int alvium_set_frame_interval(struct alvium_dev *alvium, dev_dbg(dev, "fi->interval.denominator = %d\n", fi->interval.denominator); - *req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) / + req_fr = (u64)((fi->interval.denominator * USEC_PER_SEC) / fi->interval.numerator); - if (*req_fr >= max_fr && *req_fr <= min_fr) - *req_fr = dft_fr; + if (req_fr >= max_fr && req_fr <= min_fr) + req_fr = dft_fr; - alvium->fr = *req_fr; + alvium->fr = req_fr; alvium->frame_interval.numerator = fi->interval.numerator; alvium->frame_interval.denominator = fi->interval.denominator; - return 0; -} - -static int alvium_s_frame_interval(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_frame_interval *fi) -{ - struct alvium_dev *alvium = sd_to_alvium(sd); - u64 req_fr; - int ret; - - /* - * FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2 - * subdev active state API. - */ - if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE) - return -EINVAL; - - if (alvium->streaming) - return -EBUSY; - - ret = alvium_set_frame_interval(alvium, sd, sd_state, fi, &req_fr); - if (!ret) - ret = alvium_set_frame_rate(alvium, req_fr); - - return ret; + return alvium_set_frame_rate(alvium, req_fr); } static int alvium_enum_mbus_code(struct v4l2_subdev *sd, From patchwork Fri Dec 15 08:24:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommaso Merciai X-Patchwork-Id: 98024 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by www.linuxtv.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rE3W9-008CZK-L0 for patchwork@linuxtv.org; Fri, 15 Dec 2023 08:25:58 +0000 Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DB737284321 for ; Fri, 15 Dec 2023 08:25:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7602915AC2; Fri, 15 Dec 2023 08:25:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CRCyBPsI" X-Original-To: linux-media@vger.kernel.org Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24CE9179BE; Fri, 15 Dec 2023 08:25:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a1f0616a15bso44121466b.2; Fri, 15 Dec 2023 00:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702628700; x=1703233500; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=he8fe2wC1JFZq/a+xpBUGEzXjsc2JCt6WRN6YaAZE7s=; b=CRCyBPsI1pfnsrQfwrwLJIGSAgdVINdvG3BChTidKwtK8deYRu/FdPCzvrbzPuy6n7 CfOgydB7waM29XVdj43iRdDjGpSXdLaBqsxnLwYHfz5eYdarJsuxulZiHv7x2MBzhtQd Nl0HG5gmv/XfCtF8DtQxxbMIxL8tq9/OvcBE1is/T0xpB5t2kcgWXsSZt/IcEp5AaWwg 0I8yAUedAK0BgdiLxO2l9aQ5nmamFvc8Nut70OufK/rCTkZNlYtZkLpi38YI9sz8nqWr 7TTBPOucYKfX4OEwzKv8fzAgAGnRyMklTkp8MANTvPz457cs+KtcXxDa7LXCEGshyALY tM6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702628700; x=1703233500; 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=he8fe2wC1JFZq/a+xpBUGEzXjsc2JCt6WRN6YaAZE7s=; b=EgfrY9NzZeZtctYArgMmmbpqDq0GqrdSKvc2vfUCsnawmAlzB4LVBGLAi39etTxody aAuNcBSbpjbtMrNjdJMjnvHyU1EYJYx2vZphnXrdlUmqlH89oEdUh0qBAEKoYxFoh40o F5vwxlmTdHqDt+XDyJTtE7t7oM6Jm2uVf/UKpwAYfpVe5r+hPEChA/hc1/UXbEQMPuVq CKuNdXeo9CaJQscBZoFCO/hwRHo7/fSDZUc5h6hZjKc2+eeWW3pCRNzdF2cQwRHMCJSB IBSDAFEKJFe9do5CRmAkJwVo8gMafrG2kd91Ymk6en51tBbwQ+AJvHvRQ45vGu/oTpot 0Ajw== X-Gm-Message-State: AOJu0Yxnou+R8+f1LRiKmENwg9/MNehiK02xIjzidCnw4wrmoTIEhA7q PsK8ZuAqq3jU0fL/ASHiQRU= X-Google-Smtp-Source: AGHT+IHLtBfg1gK/5KXl5Ho6USY1DozZC7NUbaaIbFzD3YmEDcZ4+o4KYKsvfms1pqBmrDg6laPh5Q== X-Received: by 2002:a17:906:225d:b0:a1d:251a:4056 with SMTP id 29-20020a170906225d00b00a1d251a4056mr5815033ejr.8.1702628700333; Fri, 15 Dec 2023 00:25:00 -0800 (PST) Received: from tom-HP-ZBook-Fury-15-G7-Mobile-Workstation.station (net-188-217-59-229.cust.vodafonedsl.it. [188.217.59.229]) by smtp.gmail.com with ESMTPSA id un7-20020a170907cb8700b00a1b65249053sm10395951ejc.128.2023.12.15.00.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 00:24:59 -0800 (PST) From: Tommaso Merciai To: Cc: linuxfancy@googlegroups.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, tomm.merciai@gmail.com, Martin Hecht , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] media: i2c: alvium: store frame interval in subdev state Date: Fri, 15 Dec 2023 09:24:52 +0100 Message-Id: <20231215082452.1720481-4-tomm.merciai@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231215082452.1720481-1-tomm.merciai@gmail.com> References: <20231215082452.1720481-1-tomm.merciai@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-LSpam-Score: -4.8 (----) X-LSpam-Report: No, score=-4.8 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,FREEMAIL_FORGED_FROMDOMAIN=0.001,FREEMAIL_FROM=0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3 autolearn=unavailable autolearn_force=no Use the newly added storage for frame interval in the subdev state to simplify the driver. Signed-off-by: Tommaso Merciai --- drivers/media/i2c/alvium-csi2.c | 40 ++++++++++----------------------- drivers/media/i2c/alvium-csi2.h | 2 -- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/drivers/media/i2c/alvium-csi2.c b/drivers/media/i2c/alvium-csi2.c index fde456357be1..81f683b3c849 100644 --- a/drivers/media/i2c/alvium-csi2.c +++ b/drivers/media/i2c/alvium-csi2.c @@ -1643,25 +1643,6 @@ static int alvium_hw_init(struct alvium_dev *alvium) } /* --------------- Subdev Operations --------------- */ - -static int alvium_g_frame_interval(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_frame_interval *fi) -{ - struct alvium_dev *alvium = sd_to_alvium(sd); - - /* - * FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2 - * subdev active state API. - */ - if (fi->which != V4L2_SUBDEV_FORMAT_ACTIVE) - return -EINVAL; - - fi->interval = alvium->frame_interval; - - return 0; -} - static int alvium_s_frame_interval(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_frame_interval *fi) @@ -1669,6 +1650,7 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, struct alvium_dev *alvium = sd_to_alvium(sd); struct device *dev = &alvium->i2c_client->dev; u64 req_fr, dft_fr, min_fr, max_fr; + struct v4l2_fract *interval; int ret; /* @@ -1701,9 +1683,10 @@ static int alvium_s_frame_interval(struct v4l2_subdev *sd, if (req_fr >= max_fr && req_fr <= min_fr) req_fr = dft_fr; - alvium->fr = req_fr; - alvium->frame_interval.numerator = fi->interval.numerator; - alvium->frame_interval.denominator = fi->interval.denominator; + interval = v4l2_subdev_state_get_interval(sd_state, 0); + + interval->numerator = fi->interval.numerator; + interval->denominator = fi->interval.denominator; return alvium_set_frame_rate(alvium, req_fr); } @@ -1853,6 +1836,7 @@ static int alvium_init_state(struct v4l2_subdev *sd, { struct alvium_dev *alvium = sd_to_alvium(sd); struct alvium_mode *mode = &alvium->mode; + struct v4l2_fract *interval; struct v4l2_subdev_format sd_fmt = { .which = V4L2_SUBDEV_FORMAT_TRY, .format = alvium_csi2_default_fmt, @@ -1870,6 +1854,11 @@ static int alvium_init_state(struct v4l2_subdev *sd, *v4l2_subdev_state_get_crop(state, 0) = sd_crop.rect; *v4l2_subdev_state_get_format(state, 0) = sd_fmt.format; + /* Setup initial frame interval*/ + interval = v4l2_subdev_state_get_interval(state, 0); + interval->numerator = 1; + interval->denominator = ALVIUM_DEFAULT_FR_HZ; + return 0; } @@ -2239,7 +2228,7 @@ static const struct v4l2_subdev_pad_ops alvium_pad_ops = { .set_fmt = alvium_set_fmt, .get_selection = alvium_get_selection, .set_selection = alvium_set_selection, - .get_frame_interval = alvium_g_frame_interval, + .get_frame_interval = v4l2_subdev_get_frame_interval, .set_frame_interval = alvium_s_frame_interval, }; @@ -2260,11 +2249,6 @@ static int alvium_subdev_init(struct alvium_dev *alvium) struct v4l2_subdev *sd = &alvium->sd; int ret; - /* Setup initial frame interval*/ - alvium->frame_interval.numerator = 1; - alvium->frame_interval.denominator = ALVIUM_DEFAULT_FR_HZ; - alvium->fr = ALVIUM_DEFAULT_FR_HZ; - /* Setup the initial mode */ alvium->mode.fmt = alvium_csi2_default_fmt; alvium->mode.width = alvium_csi2_default_fmt.width; diff --git a/drivers/media/i2c/alvium-csi2.h b/drivers/media/i2c/alvium-csi2.h index a6529b28e7dd..f5e26257b042 100644 --- a/drivers/media/i2c/alvium-csi2.h +++ b/drivers/media/i2c/alvium-csi2.h @@ -442,8 +442,6 @@ struct alvium_dev { s32 inc_sharp; struct alvium_mode mode; - struct v4l2_fract frame_interval; - u64 fr; u8 h_sup_csi_lanes; u64 link_freq;