From patchwork Thu Jul 18 03:28:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13735981 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2109.outbound.protection.partner.outlook.cn [139.219.17.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4663376EC; Thu, 18 Jul 2024 03:28:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.17.109 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721273341; cv=fail; b=V3+JM9x5Dr5zDweLcZgnSCDGDjeUUeqg6wAnj54HGjbuLICqdGsmME+lxRi3YDRH9PLYJpt+gohVSiA1pRN+Xwhn/iU4g3D1kQzwtX8OcNFKFOkgit2XZBWh6WYojBcgJdWAcFq8OF6IdII6Ep6ZOndmNLY6XvVZAdhgycBtiRA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721273341; c=relaxed/simple; bh=dqu7hmhSBPnG469y5RLSUWvufEJwjkxufPZpia3Scvk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tvtyWsPJTZLIiFZY1y2nRatbqwkQi//zPtxNF98ku0UTwbxF55xZAg9mLyqAgrKYZoTBnyX+E7xd73xp+ssR6rTG3nYWjhwBqxg2A/DjZWBxmXl9VkjmpC/WMKWIVJ/7gqb7cGwlAUlD5dPfBLGSxMKREzOxcVnrM1bkHnyUj2k= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.17.109 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J3QqFoOyRVo9qyFgmSal3SEbeYphGHT7S3gxEJ0BBq7vSZpeIGfqKFj33QJccyHIQrntnlGk1GTV9Bm72Q5IntQ5bfFLavy6wNu1AKtPsbSCFjMiIAW4B9CyuFEjTuNLJ4mRegg1W0rA1MJWC51v0uvgy4G1ZU7gG8gxUlVU20pqMUy2jNCKLkaZAXxnnDc/y4ju6jRhuL0P3UUK7fDOSUskgj7bIGOoEMbbaJPuuJpLd3PJ6D9+PlhNLdH1vZn+j9BLvf3cIB4Z/zWDi9nfmp5DNUPEmW3eRlm6uBtgR10mAl8VTvH/L0ujT6NTUK5NoPcIwk39rEiEdllFTUPyQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Elm6+5syzmno/M8taC3nAEbxa3IwawV1r+Q/2JLkkq4=; b=jUbL6p4ZXGVoVLvGj9pm/LXOFYvlV5OCFoTHcCVWbIRbuuEqLL9AjlljxXgGgS3ZOi8my3WTdK2Y8G7VNHX4Mk0vkLa0KzElA0G9+9dpMImszK05Rv9sBOsZfwJoh3atWdrVp5wFpVYrhq2PbwR6py2Tm0Sx7sy/K/dAov81Whfrza1+yg5vdfYvQTQRrH2y0YZbkLdBHtHq9AfnC/dGqd8UZn1xDrFijBnwXHNGT2NtIp6BT3Dy8Lk5Q0RjCQyoK8oUSZiwBPJGiTDYZG6Rtiye7dfaTZfXRzkjkq4QXC4/K/r3W0S3L9lhIIREJ9EFjX/LDPhYKZk460QWghSxhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1238.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.46; Thu, 18 Jul 2024 03:28:42 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.044; Thu, 18 Jul 2024 03:28:42 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Maxime Ripard , Greg Kroah-Hartman , Hans Verkuil Cc: Jacopo Mondi , Laurent Pinchart , Tomi Valkeinen , Jack Zhu , Keith Zhao , Changhuang Liang , Jayshri Pawar , Jai Luthra , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 1/5] media: cadence: csi2rx: Support runtime PM Date: Wed, 17 Jul 2024 20:28:30 -0700 Message-Id: <20240718032834.53876-2-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240718032834.53876-1-changhuang.liang@starfivetech.com> References: <20240718032834.53876-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:c::14) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1238:EE_ X-MS-Office365-Filtering-Correlation-Id: d5c91ca0-4bdd-4b55-8903-08dca6d9b931 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|41320700013|7416014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 55GVb0dicpbuEqVrgBV5ofPgH7ZQOhue1zUhe0BuJKnBo29dPCxrmpyRCqKbnQsocLU49ks8wwK8KJdcgmvyh+/ajRNC9x5rOMoJ84Noq/o1qBP6D8h9ByeI5tpdbR09fhHEiyfnso1n7eoPodgotjH/hu5ieVsOtei5efHA6N+Za07LEP8O2eYEaW7asB2zb1MndyXQlgyL+oZZxJCm8X9OMnZO+gMCbUlrt9SYf85dPH3H6RRXrKw0zmXa+K4+L6Mw2fwzE7xFUP/einm1VGprVTDoHOqAfAEKeRHsor9D6B+pxDm7gKJjhZj4kEe1NHO7Y8zeQVSB5e+9JqHZ1TGHmtc1CRBJAACRRfrgb0PwSOVCx9BIAbGs1VjtUtfgNphzpQXUOnguu7fvv1/CaSIq/RlWvDtEtq/E3F4mW3ThjXLUHYjRL/a59UiI3xQ43docivlguUvyVVYFRYeZYcm6jY0du9ptm64/W3qqvioODARio1CXIfL7T0gQ8IKeJhkICzPdPw7tiIgdsI8bCtGMjEJYIxwN+pEtauldhkiE7o03IgmnBy3ERLorHgZFisWdiNHR4WP+G+eHyUA0F3NWPBCFB0gayJJPjFY5quw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(52116014)(366016)(41320700013)(7416014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MO7EEKsI+sUSAeFMqBERhZK8YK2MYvt3eUQo1cSrnev1hHZeM/bGJwQ3MXdV9pbUsZX5fd36geVV5z4pqt5m1SmqLGlZ2G7v0NTd3j/+tySBBtA18MmMW9FRTa8xXjAlLTpXsuWi9w2pmsGh/d76EvOWK2PiMxbPpEMP/nJZIWueerw2EU7Q2sX65PHu/MBaskbHKOIcAIEocKS6F04bfUNr2PQ292DI9ERq6xUnspUce53/JNtEkQ1IEN7/s0Ruo9ybvfGGgmBDwsDPVEUDLtj5Ofp9TffFwgBRx1rkIBTsBgk0Cx5OxdH2R+Q2kBqilS9AGqSmp0idrH2ImoVyiw07h3pvz82BNcBj6R9CpT1buwFCJ74vD0IaX8xiaKJFPHRW6oci+gE7tv1SOA845L4PXjNSE2c2YXdENK52jlCdyTwVl3la/RlIKGbJSfedj3vmPVqiSMuK9ytFIkVxoTBQSZRzCebjjoK6cGcjGviVHnLxE61NepMLtgjBCPDZ+3VxSY4D3szoSX6ocBxKfhYMEVZk52x+SvveStpqKmbjlpiDCWxKKG3B5IINLAmxnmAd1vobrHHh2kBANlqf9PwW7VQv7Y1hFA3H+jyVyrSyjrITHavs4ukSpemiUK2wLZsy5AhN6gbtrCxmTjgiAr5hKafLrvJ8ve/Bi8ujfZhPC1SDBo4+C7lofKY/Tq9O6W0KhMvLGhPC2lbRnJzKY75z4BCyhQUDdE4UqOYWNU8a4rTYTyKcUrug6FmEva9vniBXV8LOYyjBW1bi6ZtgES15ZrJvaAGxefFRmx45pmZfq7HKTcG8z0P7FzqIfyOZLZpfjxLBZuiYcS6B9dMSYweYoKmPjHyw7LRCa95LPSZgZgyfw4ZiXCtPBVhUhQJr57/15ISC6o5PjMBrZ6XtZ6hED3XwF+AbGKFKEdPc4YOh4zb/LrlFYo8tLTV3241Ul5PjloEFDeGUC8vsJPdI7qNZjqQraS71W5gY9ty2N8AL+E9JqIt+rrFKVjqk3ycZ2WqNgsJCco0jjcGLDlfnFXnUIG/cAtSQsZyLjfdod03R7a0Z2btTI1vfALjEvJZkhaX6Htxr8dLSlZWJfWy3mS5dA/AOLjy8nIq0TIGbjP3hGPByTzCegwXrkygxAP2m6VFOyu7zVcIdAAF1sVWgT6ri+cyg6zBcrydZFEkasDXr3ScxJq49MK1CWoHNLUdTqIkVDwaQflfen5pT9E23mxyaRxXL8SYzmRydB22NVWHzOr3omd0KtMPRbuVS7Xsh/9IkWmPmPNwvBG2VlmXCKZ0zOv6SfcfZZBMUxF2ANZG/s5kM/NM3R04XpyyoNwcm3WSEtsyNmb3VbNvk0KLweEyRIhaVKSeiHwpJCyUw6xlVdBGYNJY09ckcJbb+KzBdNo5qbuumgMnhHDHzdodVRpz2aSXxJ3SFYVVJalXJOHjLFRLXp7b2IIbEbWt8r1dr3RrlewsGXr3qRIoMf9+oL9wVMuAT0MhUaCbiTh+XApx63wE+0S03b2duSYUxnWQpHVq+j6/3IsYNuaEp3GIwoW4Bl3kLa6v4uhEWO7BafE838/Am+lO0D3pbuWEF+C+ZTQmxJW/7XEbyezViY2RSLZSDxvQHyFG8wNf/SI0MnU0= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5c91ca0-4bdd-4b55-8903-08dca6d9b931 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 03:28:42.6108 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nVL4/OyNvH3UaRHQi7O1EPb4fWSLivsJA9j9XthOi/t9aY/Yu2LgZ+iZydzG9t29yv2jyACFDWRXqs/VI72EFHcXOgMTRZlY4vyd1gQNdwmJHffyNwBR4liZPbV95Htl X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1238 Use runtime power management hooks to save power when CSI-RX is not in use. Signed-off-by: Changhuang Liang --- drivers/media/platform/cadence/cdns-csi2rx.c | 121 ++++++++++++------- 1 file changed, 80 insertions(+), 41 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 6f7d27a48eff..981819adbb3a 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -211,11 +211,6 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) u32 reg; int ret; - ret = clk_prepare_enable(csi2rx->p_clk); - if (ret) - return ret; - - reset_control_deassert(csi2rx->p_rst); csi2rx_reset(csi2rx); reg = csi2rx->num_lanes << 8; @@ -253,7 +248,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) if (ret) { dev_err(csi2rx->dev, "Failed to configure external DPHY: %d\n", ret); - goto err_disable_pclk; + return ret; } } @@ -268,11 +263,6 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) * hence the reference counting. */ for (i = 0; i < csi2rx->max_streams; i++) { - ret = clk_prepare_enable(csi2rx->pixel_clk[i]); - if (ret) - goto err_disable_pixclk; - - reset_control_deassert(csi2rx->pixel_rst[i]); writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF, csi2rx->base + CSI2RX_STREAM_CFG_REG(i)); @@ -288,34 +278,18 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx) csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); } - ret = clk_prepare_enable(csi2rx->sys_clk); - if (ret) - goto err_disable_pixclk; - - reset_control_deassert(csi2rx->sys_rst); ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true); if (ret) - goto err_disable_sysclk; - - clk_disable_unprepare(csi2rx->p_clk); + goto err_phy_power_off; return 0; -err_disable_sysclk: - clk_disable_unprepare(csi2rx->sys_clk); -err_disable_pixclk: - for (; i > 0; i--) { - reset_control_assert(csi2rx->pixel_rst[i - 1]); - clk_disable_unprepare(csi2rx->pixel_clk[i - 1]); - } - +err_phy_power_off: if (csi2rx->dphy) { writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG); phy_power_off(csi2rx->dphy); } -err_disable_pclk: - clk_disable_unprepare(csi2rx->p_clk); return ret; } @@ -326,10 +300,6 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) u32 val; int ret; - clk_prepare_enable(csi2rx->p_clk); - reset_control_assert(csi2rx->sys_rst); - clk_disable_unprepare(csi2rx->sys_clk); - for (i = 0; i < csi2rx->max_streams; i++) { writel(CSI2RX_STREAM_CTRL_STOP, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i)); @@ -342,14 +312,8 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx) if (ret) dev_warn(csi2rx->dev, "Failed to stop streaming on pad%u\n", i); - - reset_control_assert(csi2rx->pixel_rst[i]); - clk_disable_unprepare(csi2rx->pixel_clk[i]); } - reset_control_assert(csi2rx->p_rst); - clk_disable_unprepare(csi2rx->p_clk); - if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false)) dev_warn(csi2rx->dev, "Couldn't disable our subdev\n"); @@ -374,9 +338,15 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable) * enable the whole controller. */ if (!csi2rx->count) { + ret = pm_runtime_resume_and_get(csi2rx->dev); + if (ret < 0) + goto out; + ret = csi2rx_start(csi2rx); - if (ret) + if (ret) { + pm_runtime_put(csi2rx->dev); goto out; + } } csi2rx->count++; @@ -386,8 +356,10 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable) /* * Let the last user turn off the lights. */ - if (!csi2rx->count) + if (!csi2rx->count) { csi2rx_stop(csi2rx); + pm_runtime_put(csi2rx->dev); + } } out: @@ -707,6 +679,7 @@ static int csi2rx_probe(struct platform_device *pdev) if (ret) goto err_cleanup; + pm_runtime_enable(csi2rx->dev); ret = v4l2_async_register_subdev(&csi2rx->subdev); if (ret < 0) goto err_free_state; @@ -721,6 +694,7 @@ static int csi2rx_probe(struct platform_device *pdev) err_free_state: v4l2_subdev_cleanup(&csi2rx->subdev); + pm_runtime_disable(csi2rx->dev); err_cleanup: v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); @@ -739,9 +713,73 @@ static void csi2rx_remove(struct platform_device *pdev) v4l2_async_unregister_subdev(&csi2rx->subdev); v4l2_subdev_cleanup(&csi2rx->subdev); media_entity_cleanup(&csi2rx->subdev.entity); + pm_runtime_disable(csi2rx->dev); kfree(csi2rx); } +static int csi2rx_runtime_suspend(struct device *dev) +{ + struct csi2rx_priv *csi2rx = dev_get_drvdata(dev); + unsigned int i; + + reset_control_assert(csi2rx->sys_rst); + clk_disable_unprepare(csi2rx->sys_clk); + + for (i = 0; i < csi2rx->max_streams; i++) { + reset_control_assert(csi2rx->pixel_rst[i]); + clk_disable_unprepare(csi2rx->pixel_clk[i]); + } + + reset_control_assert(csi2rx->p_rst); + clk_disable_unprepare(csi2rx->p_clk); + + return 0; +} + +static int csi2rx_runtime_resume(struct device *dev) +{ + struct csi2rx_priv *csi2rx = dev_get_drvdata(dev); + unsigned int i; + int ret; + + ret = clk_prepare_enable(csi2rx->p_clk); + if (ret) + return ret; + + reset_control_deassert(csi2rx->p_rst); + + for (i = 0; i < csi2rx->max_streams; i++) { + ret = clk_prepare_enable(csi2rx->pixel_clk[i]); + if (ret) + goto err_disable_pixclk; + + reset_control_deassert(csi2rx->pixel_rst[i]); + } + + ret = clk_prepare_enable(csi2rx->sys_clk); + if (ret) + goto err_disable_pixclk; + + reset_control_deassert(csi2rx->sys_rst); + + return ret; + +err_disable_pixclk: + for (; i > 0; i--) { + reset_control_assert(csi2rx->pixel_rst[i - 1]); + clk_disable_unprepare(csi2rx->pixel_clk[i - 1]); + } + + reset_control_assert(csi2rx->p_rst); + clk_disable_unprepare(csi2rx->p_clk); + + return ret; +} + +static const struct dev_pm_ops csi2rx_pm_ops = { + SET_RUNTIME_PM_OPS(csi2rx_runtime_suspend, csi2rx_runtime_resume, NULL) +}; + static const struct of_device_id csi2rx_of_table[] = { { .compatible = "starfive,jh7110-csi2rx" }, { .compatible = "cdns,csi2rx" }, @@ -756,6 +794,7 @@ static struct platform_driver csi2rx_driver = { .driver = { .name = "cdns-csi2rx", .of_match_table = csi2rx_of_table, + .pm = &csi2rx_pm_ops, }, }; module_platform_driver(csi2rx_driver); From patchwork Thu Jul 18 03:28:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13736012 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2135.outbound.protection.partner.outlook.cn [139.219.146.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CC2629A1; Thu, 18 Jul 2024 04:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.135 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721275248; cv=fail; b=UvRZNOBbVbnVz/s/K2jSsWujyNoq4Yx3xTe2wAZHFcxBAYuuermlTrrilmUS4KhfsAecQeiAecQx/PLYNfjZp8gRhD973lanoDyujTXWzAQVrcACYPooRdP5EpeyQE+6IyWpoW3mYQKiJdT+xw7nHp+MT0bWucRBv4u5BhR16CQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721275248; c=relaxed/simple; bh=HIciiOD7hp+BcewcEPvoUXiLMrTywFcCkDf5a9hIbB0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nMsOLAELOZJGknEJGsMaiC8kJ0aAyVXaxmv3ofuuQ8z6HAZQ/dVk12X/52vP4v8uO/nOgbPNy1bkthxlBXWWLspr/F6a8kvx01X8yUTMM/0KjPsJg4ftW4I7sW9ipOPOYlVPbyUHWl03Lo9MnKGkXl8ZN68bGO3DS7XzcLoiAtk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MNJ86a/Jt/IuZn91ThTDLLz3dkLn6rWFvQS/DIhYvu0NACMsavb1YJL7iGUy1oQnvoxstbm77B/+EYf8EPgibpp/c+dlxdLijcyo3UCYHkJnQYhi9fWfALdVVSK6CuurtDXk6kWaPTCP8lRLyyiO5E/t2GezoZrU83eX7K6B69gSCxC9EjDGZCmdFDxuNin/iPEAF8Zur031tNy2FdnQGftb5d7A3lHuhgipQafKrakfmF6S8LM+6wlymPsz5QADguLA4gqvIkgqqwgevWgCPcAbRf1OQOsv82cAw+2CECb6PUog37IZHUwyuI07HAeO85hf0B4ayv4AlGHP3arTRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ddjJ1l1tFX8PlnZ2moNGBlgsm9lxfZM595j++Kw0u+0=; b=cl1PrjrbKCkQgbhxGAWbkjlT+q7AEMbyOMsaRyXOjx7VRwYWWVHlHCXYo1P0BUoMErnUuj5E3b9ycFrZpn7xGjOYQbV4WtXhOv0fMhqBp61VMkuaJOAue72EBalxbfGpxRIKr23yr8+NBQfwmHiAJZPy2TicxnstWweGfOj8Tnk9SaLK8f19SzHw/Cope8TSH8JJJr12a5eUeq3Axt1YwjKX6blZfN0UzKVBJ8PRO4nEvK5ZH5khco3q4ejHx2nHVHK9zIw56iFv9NRzMknN5TilfHPeZhRcn0oIm4Y32u4hSTCmpnksM2p3lJljcz55wiibuvdQFOAP65kz3iADvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1046.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36; Thu, 18 Jul 2024 03:28:43 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.044; Thu, 18 Jul 2024 03:28:43 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Maxime Ripard , Greg Kroah-Hartman , Hans Verkuil Cc: Jacopo Mondi , Laurent Pinchart , Tomi Valkeinen , Jack Zhu , Keith Zhao , Changhuang Liang , Jayshri Pawar , Jai Luthra , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 2/5] media: cadence: csi2rx: Add system PM support Date: Wed, 17 Jul 2024 20:28:31 -0700 Message-Id: <20240718032834.53876-3-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240718032834.53876-1-changhuang.liang@starfivetech.com> References: <20240718032834.53876-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:c::14) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1046:EE_ X-MS-Office365-Filtering-Correlation-Id: 663452da-dd46-45c4-2f21-08dca6d9b9ee X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|52116014|41320700013|366016|38350700014; X-Microsoft-Antispam-Message-Info: 22rUrY8pge3un0ZLhD/DEC+rrotOWbE9Z7hBWCV1etkEDnH5M9L1Kwi2qbbQqcSpBSKnbGFkMjHyyyWvKwoseE09Ms23rOe6OgmT1x5KO9X/Odu5FN/zokFllX8YH1f1vNIhttf8TVRF4afFUE7qsmq/o4rwS9HQo9MY0c0QE+5bKgYpVmWsiTqI1ybljdYgV+P7Im/BhLIQVsvn1Qxjrrpa3upuLMv8uU6L/Bejnu/RVNwKJuFKTRn5aPKdkh9S+X1VCr80D1JYfCiM5MlFlLROrwCKOxgZ54BEOYIbHhr+0L91yAqKA+dmHNUfUYy8xQIv8pcZBE12n+dbOiOwni+0fnEtqHbmCriSXdQukgtx/5LWlpQKyz1W7eaq/dEw2d+lqBqfxqErWwq4mrvYysxMHQocik9W5fNqchn4FcrrLkEJheTh1YIRCnIZBkDxERgMuATuXe5gbuomXqkc6VRdEoBFmkIaokHkk3t4UxejQIHmMKvBdOm0dOVRRYySl7bDBRoeQxwLBBkAn0WS1c8NfF2ZS7fXBT3P0XwOxe+b1yNA/aR6uYSxr7FMO3tUQ0EIxytY4TGD9MnJPHI38Pf4hOP3Fybg22POKybL4pokn2VHwDgDuvZX4NqwddWT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(52116014)(41320700013)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c1fLn69RH4ctQ2zN6ymZcr1KmXj+8BNld91YohbDwEnmeKpZZ+WF7GFp7wrcxImwR/HBMzyFslwiveO8wOb8ODtvHwzj3eT3eyQjNvWmDL7LFxtlwxf8v7LOr1QGTsw4+kCz6RvDa9tWV4hVKjUCX4IK13nOQOxoylJNzjP0xdlSf+mSBvIEtt9nHLcPuMYsso5YlXLb7E5sZZtbizhg4vobx60pbIwp6bOZoijuX9CaInRO6N+k4JIsEZgSHaPoEiBV2d0JctazPf0zS2d0cp2ORdEwqHt3x1xpJLJMZNduI8ipF9NiDnhd8WAR3C0ygHOfcUwtk5NSwCxceDIEPI68WVY1QrwTxZx7hr3Pem5qfgsiZ5ddvcsAN5BZObOFvEdRjfOainUKOiw5q+z1wFDl00GzEGl/bhIRsLg73UQelRYfuKzHvQnHQ7Sdvgh0IrViatpAAHx3LA5aR6DcajRMWXD2YBg0EoVNjKoDnnmUbwxc4VcBlW81qnkiFqm+lCz9NJ8o2guTxHT90ds5kYtdx3nb4L2vCgR5VJiM/ky44E6DlrAB78MrAOfQTyRS7kTPF8BERM2mY1Fg/sYeZuUDlq9NV9+EVHpru+zVBvVXD3DlbvNke1MIRLT2CtGWorzXk9zo5MO9KBqDSk1dEx+HDz91/xRNXuUy81ROE093U/8LM+cc9TJ0npyTmsiDPY319ELHOndSDFBcBocQa9dQQYUXrYVvuN48WpM4RTBA07faO/HZzGiQkUptTVA6mN2ev0toFsnTUXTnRlOaufyNPUjbxa22rMBpLDoOa+HTGmJFBPuzilyYuaGXpad+ATTMwmlLrxYyFV9FP+5Aw52CFdjcsCEvHXQg3wbBkCZo9N2/tkabSYNh6P2RL5u9sL7ASfRcEi2UPbF5XnM65vjcpJEYW1QnCjamoNG5fRT0yDRnMutCrIux+/vVHEZf75uV7OnPsIetI5tq3TxvEtSy+gDNa3b4r/M8O0xsyedHMkCgC0XzdTNBr2/Ar+5byDG69biDjCTiY/+iNQMcBOV18hW+9HRuZt+sPnQodNGLERc1tX8FLC81NtCCYxtqMVu11VVZLZ+dfKV9ASH1PuM5AIn37YAnABTPv95tGgOKObVNSwMtNfUI25OTleWLODGtT7l8ITAlLkF2WH/3n7VcstOnS2si+EDJo8pj6ZrqohpFkQwlIs+BVPQWG44u/+i4VITOYhPmY7axu/t6sZkuixoi35ZsfWScauAs7ftyUSGXw+jOwN/Z1u8esCEWr9/WsW9QWNGRh7lRYHRjcOnCNYlHjuuCyImpHB9CM4cSBu0S2WFUqGbz5RZfRQZrz6+wR6hY+fFcBujk8wLsl3s9IrXJ8eDNQW3h6obE8V0HcWNaswOrGbpv5egNl6M2UUQKwy0m+H9PBTGEOM6oLtk9sU/iIrsSpzVHnclUpjIcTLOSh+NduzODl7QSmRP7wxbHLZRm7IFkq3GA2qABPtiSLVKsP8c8UPWK9qIvqTSbzgxp8PNGsoE6zC01y+y2LBfuU06VcRv5PrnOC4kSFnsgxgQrU3gZso0icJW1KLGwS3G2k+8Dq9tRKIiGOVLevzKpmvqPq5MrhNx4aq+MFOhHmTiQDoNqgyHiTtWqCaU= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 663452da-dd46-45c4-2f21-08dca6d9b9ee X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 03:28:43.8229 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: extmWOJYAqiEGvwmT9V7o0UfbyUNC2LG9kKdxj/l4FzhvuepXRZUiak251y23Pb432d7vxur/rF4jXuphQijLyUTSvXYbqqxwBVtr12uE5jdR0JfyTqK78f5YZECtzam X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1046 Add system PM support make it stopping streaming at system suspend time, and restarting streaming at system resume time. Signed-off-by: Changhuang Liang Reviewed-by: Jacopo Mondi --- drivers/media/platform/cadence/cdns-csi2rx.c | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 981819adbb3a..81e90b31e9f8 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -776,8 +776,40 @@ static int csi2rx_runtime_resume(struct device *dev) return ret; } +static int __maybe_unused csi2rx_suspend(struct device *dev) +{ + struct csi2rx_priv *csi2rx = dev_get_drvdata(dev); + + mutex_lock(&csi2rx->lock); + if (csi2rx->count) + csi2rx_stop(csi2rx); + mutex_unlock(&csi2rx->lock); + + pm_runtime_force_suspend(dev); + + return 0; +} + +static int __maybe_unused csi2rx_resume(struct device *dev) +{ + struct csi2rx_priv *csi2rx = dev_get_drvdata(dev); + int ret; + + ret = pm_runtime_force_resume(dev); + if (ret < 0) + return ret; + + mutex_lock(&csi2rx->lock); + if (csi2rx->count) + csi2rx_start(csi2rx); + mutex_unlock(&csi2rx->lock); + + return 0; +} + static const struct dev_pm_ops csi2rx_pm_ops = { SET_RUNTIME_PM_OPS(csi2rx_runtime_suspend, csi2rx_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(csi2rx_suspend, csi2rx_resume) }; static const struct of_device_id csi2rx_of_table[] = { From patchwork Thu Jul 18 03:28:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13736026 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2108.outbound.protection.partner.outlook.cn [139.219.146.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E949939FE4; Thu, 18 Jul 2024 05:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.108 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721278974; cv=fail; b=P5wEQer5pxi0Oeia/EFVlHBHY4dEw/jG4G6n+/tZhxeS9SXA1+FbXK5wEXF0T6Jy4xNlLrPEjekAcfmOveCaljZtwRi7Xu03aNN/YxCkaxfUMvVZ6FQGiqb+wp61niigSKc6c+AjM58xsq5GyKqUVF54qjYkltSEo9GiACP2RKA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721278974; c=relaxed/simple; bh=2s1F7eZ8Q9lQopQGZP8ofOFFunuU+GbKf6rfeagap6c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cTRCqdAgQh0iWpS/fhbxKazAH+iUMKyMCZyx/+33mbW6Mp5cUNXd8k4Nqwvf8B8kfMZlMwByFGIabkqAU1VVLjgKNAJrjS+IQat/xSz9EhnL2jB+4dJ9axj9FtpdCCcbSfhbEyI1QsZFxxw46xcObA+egvvjZRaCVv5WPPR4U1I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GODVCWjsyzJ66m4zhr5X0Fd3tARoai66g/Sr0eNIII6D9GBSpO/Zydf2iNT1s4JTeDYF1XdxwKn6WapXnVMkvdgCJX7zO4zxZ7oGpPdEJhqzdrBnkmw+5FHERCIX85YdMw5RPDDXDHsMdhVgq0vWB7V9dyYbi3L6/RFtwUXaq7hxlRJbFcFWHtB7kdouEFDb4XfEqhMjHOfFNSVSKh/07DkbK+ik+7IElE3u4gxW7mWeJUEdERQ/7YleLLytmZCw5wYniYTebgfF/bcp+mVvorxQuvHQTJ0E8ro9wB3XyDWGDv6o0xlnXwcFmZbqZiX1Prq2OxxOhoa99hdaKsPJNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Rx1XDLmsNv+KjI1/LhlUqD/tXJ4Z7DH5SC9QgQ6CVRQ=; b=L+xsNg+Q8y/8in7YGd0XBXq0SW7NMkgQEtGGckoZzI/HlvghX40BoVuibhwSQvw33WO/nv89TB0xxDdGVDhzwxDv/WU2PXg7M/Ky9dtxw5O+kC+Gk3Q6euCYlqYVEkZxrFhy8hvgERAY+9l7fPJuUPtwb2GY9+W5T6KCWF1T96x/lMiuGNy7li46KCgM4t7B8oMV/5N2TUWVIqfDjULrZ6dvZfqHal/NFH3pJB1XNkGgxdzlFVqjge6ZLviAiLT2PWhC0PsJmp/cp13rcU4oygSjAGoQrqTQ269opr/XOX027XyEADzyVt7+5qblrUcDECu3sX1J3DOxPBNZtneWBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1046.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36; Thu, 18 Jul 2024 03:28:45 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.044; Thu, 18 Jul 2024 03:28:45 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Maxime Ripard , Greg Kroah-Hartman , Hans Verkuil Cc: Jacopo Mondi , Laurent Pinchart , Tomi Valkeinen , Jack Zhu , Keith Zhao , Changhuang Liang , Jayshri Pawar , Jai Luthra , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 3/5] staging: media: starfive: Extract the ISP stream on as a helper function Date: Wed, 17 Jul 2024 20:28:32 -0700 Message-Id: <20240718032834.53876-4-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240718032834.53876-1-changhuang.liang@starfivetech.com> References: <20240718032834.53876-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:c::14) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1046:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d944c08-60ed-4d3f-433f-08dca6d9baa7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|52116014|41320700013|366016|38350700014; X-Microsoft-Antispam-Message-Info: Fw84wif0y3Iny0kibhuiY3CYkBzRzP8rdGDKu4rezGcaZh9OZjXKbLMhs77LqIkwEhrPYmHnTWWhjYgcV7YuBpg1F0k9Ta6GPH8f71rN9znScHGv5OD7GPoi2IHJAPYtGY+OwqaEyHvBsc+VB2BMq9lfYV36QRA/2red5+2HkJgYaNsaBBXX/DaNANamV+hAlnh5RR+TwdqiEOqXJteeM8HYnS2b9Ty2kPZNDhkclrmFPeL/kPLAS3F5nTE9emqIUTLMSCqADek0rsvaLy1vH8bSFUGXyaYkBLo1BnTgIN4M6n8bffZ32jScPDlPYo5HQ2L9QiU7FfAdo5bGZiwTN5MnnCNBqm60BEvT8ZV/CyQFG1cgGBAzd89CEyGgJx8OX7ElHZrGQB8566Mbjhj+q8gg/nHTPHB+JM2cuNprBD+OaUfg0L3q5y8yjpKSk/xvOaBw8J1J4y6AewstJRpUT2V4FC9SVndgehzjieaYMGTGB9WYhg7g2aQ72TRtIqqN5fLkRLuqxQ55YnlXYkmb3NTFfs+L0vnfsizk+JaCsdIBU+tPi6prTmKqYA+sgRImBJnzlmBVQqB+UCHsijJFcQHvvw1EaH4gLdlOc9lWDiOm6FLwPybOJSPL9ebro+cV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(52116014)(41320700013)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uygQNIOuFZ86SaRqpFwPiCOD/wAKjWflaUR0l4G5uS6aBPrvzeSihBAWQgbSjiQhRIJjyU9cwNwAjHZ/a1Yym/fLMOPHBlbRbSLpu7EgA4gMs3MqOe0NYnI3uyc/coh8XQFgWMfn0Vsd+8mvF86VZ2j/vYLT/8FU/WqpETSpgjQrlwLMwY/mh65Rl9dUazsmO/GeuEmJ3Fs5OR/fitHDXsS15crhSU//FdehVqReLR9+VzYcea3z3SPpWSC0iWW74EqSmsRKc6X62hGmH/cs1FPYUXT0fC7W5Rx7wLCLLTCH/Z1XGjlNf9mo59TXGqlVN8jK2R/U1FX2q+OyfSC118W7N0MzKQNRXpVL5HlnV72c+oTGdMS60zbx3ikxT7BQ+49BFvsFXFg7saqOylfe7aGkz9Vwyhokm4C64VnJasze6LCrovGgqn967Kjl68MiQwOM916UfKwl3Z3U4fniF+0+JklnKktyPPWeOM3w2lJWwZC/OvKcRPSOe7sEzSAsJY2sEUXfnw39J8MzJKj+a6pJLeQaFM+dM45YIo0PentNJmJyY9D1/2Nn31xBcvPWcakopfNhOqnyg4yRFtCED8BeuplcroqUPA3OG3EiZJ6DIv70s8QpncmRCcAT4dlaDTXAZXU4SpwRiM3pmj5RDqq5OEScJiDWcfR6rZo516V7nDZPcyBiFyOxTBmcp1xcW5ubga2ffArjTSh5b1dUVSwpWk2DfNlQ286QT9lgzMW4S+fXMYqvAE6TGii+4+o/HBLRQYtr/U+Nz4U0kzdM64Pogrp3uMbelqLhAq8USBqYLZjYtVLdoijEL4scO1KY1KO9bXeG6z+G+w/iZlKIx9Sa4d1o/fKhrn3iSmqsCp/GPzQL24lHvpLVbeoFE8jiMPT+SDFSJ2jQI+J/yk+OZE67vOJ/TX1bUXOauaYkYeJy3fjb08n4ukFg78lqRnmaTOvSvY3n2OG+47kp/m4cJvWhdADfU+0la4zHlv/w5hPtH1D6zxvZJXyVOfbaL7p4KMVbaqQmrXH+5FnnnoqGf2TLVL94vEReoQsQ8H7mdTIGnBQ5w49Uh6C1vG3XmA3lZfHBZ5heFLlSNIGrAV43mA1YRcCNsgDf4P4UQNWAUdYS0OqCxK7UhwIgYpvDTEwgdpzTO2xzHPL8euL7VEJXwd4hib9pWgRbzYayZcak86dbjs/YTY6q8KfbnnxLWklRLBaJwdiKAVSBEyn8mjS1ut7geiPIozL5NfNSArEqSPxvxLpf13zNr1Z3dTG3RzeG123/ewvTs2gTNzDiT1CPzVN29AIzUctL8BoQQD5NBefhTJS84dlyX4r3uhhLDGVdKf2BLMlhIYvsnvhCP7GSs0YuhhwkbaZBkyq1FjirNOy1SdFEWwk0J2xdN7sv9P7end2t+BSAeQRlt0+S5YDj0VJ1e6cOwQC/6s20qYlIbl6bgQBB4c8B9tE1oD3qEzLCv2fhXaPfPPfIQhS+zGR9OwiXGEGHtYn0ugpiVUDX1iq6o7RdogRgKQou+yTG0sk2e6g4fODCtMmBZ3ZgSHBhKTdDGQx3OL4IW87diwoy4oVEsknn1edffnAvvnpP2zwWxHrTTmQOtACkWZqejUGvSI6z2RWMivR+7SoczeZ8VfI= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d944c08-60ed-4d3f-433f-08dca6d9baa7 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 03:28:45.0350 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fFkDnph6ZOVO+pEUzRQ3ARs1n5Ep0GPVNR7njxGHU5bGbr5biC1zW6+b/oUWPSY4LH57g3eLjJxwQUzcylDU0KVdVepenFNZcBFIwXeuBoejpX4U8mP888C7wmwjgIs/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1046 Extract the ISP stream on as a helper function and open it, Let the other files can use it. Signed-off-by: Changhuang Liang --- .../staging/media/starfive/camss/stf-isp.c | 27 ++++++++++++------- .../staging/media/starfive/camss/stf-isp.h | 2 ++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c index 4e6e26736852..8c6388edf049 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.c +++ b/drivers/staging/media/starfive/camss/stf-isp.c @@ -55,23 +55,30 @@ int stf_isp_init(struct stfcamss *stfcamss) return 0; } -static int isp_set_stream(struct v4l2_subdev *sd, int enable) +void stf_isp_stream_on(struct stf_isp_dev *isp_dev, + struct v4l2_subdev_state *sd_state) { - struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd); - struct v4l2_subdev_state *sd_state; struct v4l2_mbus_framefmt *fmt; struct v4l2_rect *crop; - sd_state = v4l2_subdev_lock_and_get_active_state(sd); fmt = v4l2_subdev_state_get_format(sd_state, STF_ISP_PAD_SINK); crop = v4l2_subdev_state_get_crop(sd_state, STF_ISP_PAD_SRC); - if (enable) { - stf_isp_reset(isp_dev); - stf_isp_init_cfg(isp_dev); - stf_isp_settings(isp_dev, crop, fmt->code); - stf_isp_stream_set(isp_dev); - } + stf_isp_reset(isp_dev); + stf_isp_init_cfg(isp_dev); + stf_isp_settings(isp_dev, crop, fmt->code); + stf_isp_stream_set(isp_dev); +} + +static int isp_set_stream(struct v4l2_subdev *sd, int enable) +{ + struct stf_isp_dev *isp_dev = v4l2_get_subdevdata(sd); + struct v4l2_subdev_state *sd_state; + + sd_state = v4l2_subdev_lock_and_get_active_state(sd); + + if (enable) + stf_isp_stream_on(isp_dev, sd_state); v4l2_subdev_call(isp_dev->source_subdev, video, s_stream, enable); diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index 955cbb048363..1a3e8cf7859c 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -421,6 +421,8 @@ void stf_isp_init_cfg(struct stf_isp_dev *isp_dev); void stf_isp_settings(struct stf_isp_dev *isp_dev, struct v4l2_rect *crop, u32 mcode); void stf_isp_stream_set(struct stf_isp_dev *isp_dev); +void stf_isp_stream_on(struct stf_isp_dev *isp_dev, + struct v4l2_subdev_state *sd_state); int stf_isp_init(struct stfcamss *stfcamss); int stf_isp_register(struct stf_isp_dev *isp_dev, struct v4l2_device *v4l2_dev); int stf_isp_unregister(struct stf_isp_dev *isp_dev); From patchwork Thu Jul 18 03:28:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13736013 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2110.outbound.protection.partner.outlook.cn [139.219.146.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8035328366; Thu, 18 Jul 2024 04:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.110 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721275276; cv=fail; b=VSvu1Zeau73OORuk5tNFLSmKEyJrinJvxbP3KHXls/Ev6ZPV6H7nG18pwDn+2c3HchW7HvOS183E8BZlUCrocd7LQ/Yysd/UsIALfIPVb6LtYIXhU4+HGc4aiwi2RzQFCA9TgQdeIeMQX1EYzkO5DzWoyeWmAtMhBKD9qeUfOsY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721275276; c=relaxed/simple; bh=oHnhrOBFfd6JOM6QcOedN0vteZsv7jxNwPs0DqzJqYk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QLsfbKH971hSsNzg71BgTW5ktvJGvzHq69gnubqdQKUfFxxHBPVZqXc8vkOUXTtnuSV+sWiJ6c+EPdF7zykv3FuU5R9n2Cf3vGty9IDbhUZabNGi6bsnD3C43NxLKELXtJIwLNO+39IT9xRuZHRUlmbw7s5kueIpZpttete2B5o= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.110 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dK0Vw7z4H3ciAbovjqO4Ohd73kkcdlJNTQAnAkjC1pS4EF7aMxi4dTzHUck0KZ0i4yt6pPYYUTEojnzmS1THlN0F4I2G3UDhZFMozgjj7CB2SGPYgSGEMcZNG1Xt6AGVj3lv/hhdhjh+NUF14pWJb0Sz7jyKyPck/hflhdHDxRM9pmKt6wNHd4buBkEl0kJRDQ8y3DkhJ+xNxh/+VjI0pef2EfkRCWAjZcshk8LzTPhttrX0LIoXS4aw3E2Lspk7AcFlCdp5NHaDj8+eliBiJ8SYaw1/wMAjRtc/EeGo+7bpkqCo1FITeBvWIbUANCHmLiIv16duJLrvQjcW25eHoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gSrFOBGfbgCUI+unAuWZ1XrSPb4kJg5v+m4cXld/C+Y=; b=C4a0OrAkKNN78HRrLMJ2xcGPoAxRMGA0lvArLqQUrrSoS1vXXcj/Nv8T4uURgriLUBAIQxOyICK3PcQphPFfoNx31ndoPAmISOTlctm08GPhGtBTLGQ5LeWsVBw1fcBDN22eqrpGa9ZMY3vJMGpUDFxNa5Kd07Tm21zUsjQAkgzALa2MTDDVeA2N3BlQYeEjUXUL/Xw4VlYaMPIfMxAdDP/Y1ICHZS/Us7CaN1jySOGkeKHncBP7+7M7O9DASEhRWrl9+nZV/KcijRvf4sLcxDqTciAUBBSqvh9ToOFG9EyPSl4HpMLec06+o9Q771sOk2lE1Hk4ts9X6oobgLdZvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1046.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36; Thu, 18 Jul 2024 03:28:46 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.044; Thu, 18 Jul 2024 03:28:46 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Maxime Ripard , Greg Kroah-Hartman , Hans Verkuil Cc: Jacopo Mondi , Laurent Pinchart , Tomi Valkeinen , Jack Zhu , Keith Zhao , Changhuang Liang , Jayshri Pawar , Jai Luthra , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 4/5] staging: media: starfive: Introduce streaming for ISP subdev Date: Wed, 17 Jul 2024 20:28:33 -0700 Message-Id: <20240718032834.53876-5-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240718032834.53876-1-changhuang.liang@starfivetech.com> References: <20240718032834.53876-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:c::14) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1046:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d7bde85-deb8-44a2-178a-08dca6d9bb62 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|52116014|41320700013|366016|38350700014; X-Microsoft-Antispam-Message-Info: 0DY95Jjqulq8K+xVvx7pxwCNxq+0X1LrpKxMWOeoVU+HkmqIBW09Q2XXgVl3moH2hn7XS5NfoyWDSe7cLroRv5sE3SYQVRbXAlAu/OP8u/Jvnj1dbrlyLmVIWgYDcBN7pUXfrk6/1LJ/Mx1vBRtHpRjnYDO5sp4Mknkn6xeNeUobM+7//XkwXUGgzl4UqeAbx77NCyyvdX/Z9Dpb4rQXX5soo6XbFN/VDGb2J6UPf3qy3qYoEwt4nMYL0yMaoY5TdKSKtE7nIQq9Lw/qBgaOm/praxDkUUX8D0bBpREyFhvk09UnNqV1SnscIUIKHRN6xYNpGI91vK56s3il51oWU3baDKpWp6uY7dWstRlFKPsKRlQin0bhZSCxyO5G1+Ttr6eMY3dim6bHJGAJmJzFY4T6vW9ssFZncv0VQrnx3i1tk0kMn3lIQmLOLQwQk7Tz6cD+1oiWV6O2GkWFb2ZP7bN7SuumjLaX24vGrZsEz/ypDMVVF4itJZc8xmDDXa7mpxJa3UzCbxAhAdH9LSF2SrjNe+eBaggEd2lB0m5CHaDLjgRLgtnFvSSGBip2BkLm+di3KdGmq9qRf6QAPeerXmHdDCSbOuaYRKwwKP6O1EYA+m1a9wp9y3zCPeYnbyRs X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(52116014)(41320700013)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: negYN2tdQppCtqr8/Fa7xKaGjbVz5THdkotyGK92F4uPcUI8UzCRLy6Xx1UuAJcAMfYPMJRmUCqNcGsBqwpvQX6ghcSktD7g3v0U7835hPmd+4mIamPecVglSNabiB9C9BjUocptcT/UipOfqCfl3x3l3k/avy5869k9Z7jLAbOIXkGbl0c1EPzfm2vetAqn/XmO0wjMA8A2HNTJ33Q6VOAsArmmaHAMPDgWC9vIFLTZvWmVFbC6jTQbjQxtFDbKKsZXpbx527yzVjl2AUyPNigasVX4WdxtSHTdWypiGKBZZCuwrw5rPXroA/AJVAVSWDJtZ1hevtoQkl+JTUOAfaO13rIQEKlpovMORwAm1P7YDXsgYar6ouYkARHlgVv2Ypfuzs2yx9EueTWTDt3acx6/Vy2QMNgMDPMxRwvh4B4pVLg3tVd0wUd2kzG4wZphL35Cxug5Rbzwu0DZhJyETuXbLV6oG474V5ojnDyON2+kf2hL358IrlUu1SPp48mvRg3e3vGOBBqnYM8OzsQfllCSnMAJ3ktPfe2f4BwVkfmeJ6KpSGcelX+sIKU00siIRJTIXpvmZhlbYJAO8CYsH/FJGej6x2q5Qo9BKYdNOEFsLoVry62DUBYVvIGIhQ5GJYtvcX42nfD1juTJW6GHU00JWo4d9y++PpxsIyiOruBQWN6xjfHuX+d9hqUda0WUUqoVckQhGneArdMiVpp4va3m1kzdcfTz+XQxxddNBUQNkPLNEDf3jip7ADVG7EYkE9P2rEdUSbFwghogrP/xx07JQuKGy2G3CkTeOC/9QGY8RUzYT66l0eS3L8QPpgPejs0wYmlnYw+FSvnSCrsskDpjRURKdL9GjV4lfiRiT0gbvlAMKQKQ/j68TQolM5a1iRrEp//GXu1Z6bq5CfFrlKd7brqzkFpxeS1B1O4sWRnDHFKqx/Ub0TtlGdvwE18FlNro8Bzr29mNsU7N0XIr1FMr0BeMswkRHhKWuETvoNHYgpRwTAjYcUgsc6ItfOaqdCiQk00BnQG1scFaD/cRruBXcBYwQXFbhZ6aLOj08nxaDaV6Rfc+IfO7gfRrITlw1aCzxrOkYOONK/TcazlIS8lntEI0NkTEjQsihHMAO11+1El74cF/SUrilkDnetfNc3qqk78R3oYaEiQPnO0arSlfd8vQ8ldaXmzRTUwIPzqebAGUixTxFyM+oS6sUhYV3LsJSeQhqYZmo+WMNQSqYPlU2GouA7jP8PJ1CqXXvbOrH42MsZKGZ27ycJAKNhvmBTq8fQt/lFyYM0P0VZeVnPbzA47TsVd5xHndNLHFw8SrzKxwBD8N0nbFSkoQGDk526y2jOg31DIQ3LixgiD778g2FaOKX7dxtNbQ8Llh8OGZiPh2D3fwyZfQcyx9LNPlKDaVMfi0KQU2TcFTdZL9ZE3d5TzzVS557ggCDKcGASKLkMELDT6EiWj9qbwl/5TaCk2Bjdpgc+JahnuGrc5NalnVFHv9P0W9yOOLjWNHCWyxUx8+8UvmvOtwQBz7OUAz1UwOsnR62LUf3ZZyvQ1ZYQcyINitey6t0EEsdVm6yI5tVjf5JkjILnjTA770aKSQ3UYfyr8LdmkNGpY4hHlbApEjSGuUbI4hTyMLurErs3o= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d7bde85-deb8-44a2-178a-08dca6d9bb62 X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 03:28:46.2403 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XfV9cMm0sUR5zwLt5ZD4JvkF9xuhSYd+6ZQ7sI9x0QlpcZSYl9l2DgVGG05ZWfGL6KpN2xCtB/qbdf4XhaA/kOquAlI0Y7tmoZ/3Dx6BRSTg8zhPMtQ7rPj75R6NVw+x X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1046 Use "streaming" to indicate whether the ISP is in the streaming state. Signed-off-by: Changhuang Liang --- drivers/staging/media/starfive/camss/stf-isp.c | 6 +++++- drivers/staging/media/starfive/camss/stf-isp.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c index 8c6388edf049..d71b95ebd3d3 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.c +++ b/drivers/staging/media/starfive/camss/stf-isp.c @@ -77,8 +77,12 @@ static int isp_set_stream(struct v4l2_subdev *sd, int enable) sd_state = v4l2_subdev_lock_and_get_active_state(sd); - if (enable) + if (enable) { + isp_dev->streaming = true; stf_isp_stream_on(isp_dev, sd_state); + } else { + isp_dev->streaming = false; + } v4l2_subdev_call(isp_dev->source_subdev, video, s_stream, enable); diff --git a/drivers/staging/media/starfive/camss/stf-isp.h b/drivers/staging/media/starfive/camss/stf-isp.h index 1a3e8cf7859c..85ca1c210639 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.h +++ b/drivers/staging/media/starfive/camss/stf-isp.h @@ -414,6 +414,7 @@ struct stf_isp_dev { unsigned int nformats; struct v4l2_subdev *source_subdev; const struct stf_isp_format *current_fmt; + bool streaming; }; int stf_isp_reset(struct stf_isp_dev *isp_dev); From patchwork Thu Jul 18 03:28:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changhuang Liang X-Patchwork-Id: 13736027 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2108.outbound.protection.partner.outlook.cn [139.219.146.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D871C41C7F; Thu, 18 Jul 2024 05:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=139.219.146.108 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721278976; cv=fail; b=cObrTrN+08PyLodqvmK0iNXeXUcDnSBtlypaOGoAykn6kcn94/yhoEsbQ3F6+gysVNSMxxzdhsQ+xv1iaeR83CMWyVOyUMOuGpdBH5VkSZRQYBLkrNym+JtbghI7AGI818rLm/AN7LgkYlTh6JYwM7oFR0q0og6GkdR928oPuHI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721278976; c=relaxed/simple; bh=3ALIIwaquQs4Ms4Lp4N9MuFsYbjraB6dnxG6CEfEyF4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=DQe3SrA0bva3DTgjry4qsXZzuhBK0CyL7NaGhzRk3CdV7QZvzBKkNyfUEvby3Nq4hO7J+GiV1U5R+KrWJW0HNoMP/Xb0kB3ofUnyxCQSaF54D1vnkEUdovXYYovc2aaGDsktwTQvILMnb1zMGgeBUbRX9CjOdktPw2a+ckKkFms= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=fail smtp.client-ip=139.219.146.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oM5Z+qbRJrCnTrm/QU989AJyEIeZ3b8PvqCWBfoTWbZ37no6m4USshcDCmCmBbuvczxw4DF5pEJ7x1zTbuL4Ps3c6d+mDSFbtQD9ABXZgtgNbFPPdA1KMjUdYLuV+Xx0d/I/xuwE0Z6GxfAMNBBLKe59NT85rPM+O35vN3Kbtu4S3Wp29vxNLWkve7Z7pKJXOQ9yTIxI6FEVh3ns3ZEo3NZneO8FcneaLqhLZwKp6tvaZ8g4IqX4PuwMs76HvrDnGIO0ub+R/PJ6ZFW6cEK7eRd+AsfTnXyKCKQLJphXg/4oIgQ4tJRTtAC5ulTsZiOsK8N3DbM3y7mqbaZrQIzfbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=51NUMLFUOslcX5PgbS299VUsPDMwW+amx2sRqAl03fQ=; b=EYa8I9l5oP50RqNgqXFgEH0t7lJtHCvfdBIJdPdwGilQ4R5zesNGStY5W5XTpc96CBHJ7pM+3wWHok+FclQ8lpo7ARza7YAMdME1G9mONXYNOnyPLNhFXZaG32RF3PKgQRsXFjlnyPON2vwyN7F/JDaPdc7DflUNLks1fcn93RBrdItuJ26e2oxsz/KkVdG3cs7v3a2qiK1qBEb4DINN4Zm4pNKoCYCNZMoMbSey4AjsV8mt9cI+LXJIl/Gj3NG/ozi7Dh3BmNzGeksd7O1gUPMMYOxDAHYVgSHerKP3N3J3sAcML7kxf11ZLjgsBwDc0adY5Q1ihaUTYT2zzlUdWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) by ZQ0PR01MB1046.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36; Thu, 18 Jul 2024 03:28:47 +0000 Received: from ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa]) by ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn ([fe80::64c5:50d8:4f2c:59aa%6]) with mapi id 15.20.7741.044; Thu, 18 Jul 2024 03:28:47 +0000 From: Changhuang Liang To: Mauro Carvalho Chehab , Maxime Ripard , Greg Kroah-Hartman , Hans Verkuil Cc: Jacopo Mondi , Laurent Pinchart , Tomi Valkeinen , Jack Zhu , Keith Zhao , Changhuang Liang , Jayshri Pawar , Jai Luthra , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v2 5/5] staging: media: starfive: Add system PM support Date: Wed, 17 Jul 2024 20:28:34 -0700 Message-Id: <20240718032834.53876-6-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240718032834.53876-1-changhuang.liang@starfivetech.com> References: <20240718032834.53876-1-changhuang.liang@starfivetech.com> X-ClientProxiedBy: NT0PR01CA0031.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:c::14) To ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:1b::9) Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: ZQ0PR01MB1302:EE_|ZQ0PR01MB1046:EE_ X-MS-Office365-Filtering-Correlation-Id: 00fe384c-a902-4976-4716-08dca6d9bc1a X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|52116014|41320700013|366016|38350700014; X-Microsoft-Antispam-Message-Info: 81rzuWjzaYgsvPdhEzC/RfB1iEE11XZKkurrP0Wsm9Wzo4Xj1EuW2H5opsraTBfncfvZjpX5Nyj5+8AmHzrG5SA8YZPo4gaLRR33QFCs1aZupqsGrp3xbvGOKcqx8TUN0qfj52GZmhMXGh6Ep/euaQpq+5RhCQ9yNlD6pAMblSmKpovlp1rp7wHNUpk14Xu/niK59eVph3KC2ru62f1g+W0GwwsW7ERgcYhEJ2l00WIjcz51b0Cdcz2x0eupE+FkyelV2FpnzxQsxrrQWPbj2coSvO/tfuPaB0qFPfngRolHD2FRNEjVW6FLZwAOWkW9Us2ZnQxensewbkmWH/Pu4kLBiovEiA4VOFsRD04aBQ1CN9/uqk8UVmM4hEHyq3oUkiiHqzSFOQWNXujV392Wn3blIriQNRlGTFja0nkdibxvdcAnc7jsiDE15heQVvbIqSpAvr6HcJU/1kuInV4BqPscFtieF9agwGdnDIkSP49l1eBWNgJG547bDAPkq3s97mYC062QZIz1f347UqgyKU9NwhcNgJGn6B+JwB3yptoZouob6qg4NoD71pwMmWAI7Uvm6XaAa3lBFBxk3Fx8Zit5OUmi2Juafg/Q5HME7P0SgAVDHa8gEHvzvoixv3aO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(52116014)(41320700013)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: whqkQN7gAsT3TJ4u02KlUZy68hEDIsY2/+JxsmqX3gbtffwq8/WqC7DmGHPb3BmB3n2jU1ljqOlW1PLFcMW6WkYvvKPIH9wYxuQDVuO8HndJEBy06ZMXpeecmwqEcusfu9vWtMUvueK1OY+xyppVn41fsIL0n8Go7F+tOB5uQh0Uey+bkHhcPGucRXCbLt98QfCPOXcwuup2p8V6kwLgX+JPutNU00PdAQR5j3Mot646ohg8CrDZ+nuL1zyJ5waZQNcfaaokLE/23FGTJ93tRJJfZ1AoN1VsMqyGBQrrh74WONZ9j5iXKcmB8K0EBcBtZ6n5wFSlGWzLM+TDENUvPGMd0fUsSgtxH4lL4Qotu5jYyvjYb9xGpcWw3Wu1fnqTWUxT3C0+b+jkfkBW/aBtz6uQpPu5LoCv5ClmWd172Js1amBvKWxphUz+ixufYh6S7JJzFPofeULZvk2+1UL3VfCzBGN0guOfb45NtOITHByhj0w581YRjpE/7euPOfStPdO2TtE2zu51+oX+5pz5qxfYQgf+ET9nO6KBiDeup0klf7RKDyumHWI2cPACLWH6MLGRuBsaJHMHAtvuhqXvhoUwcbLx7GHNx4cmBYaUx4epDFHxI9eXvxJhg6vtgbFYxpWKBdyvVU49vpfozKNMULuT7PM3w/p+NKabS5i9zJZ4UxDRUr0v+LSYPitwSIY7TStZ43Po08yBzd4a6QXwFM2ALuNbYVZMEoybRd5zRXbaOZAuKgfmdmvJAj0h85qL58m8ED9Fxx6FoA7aBL4ziduKFDcwll0OhqkFymUPxPTub2g+riH4NrlExpcisM5vKU5TvJF4uq00rTFFH46j9O/EpsMCZL2Is8B/7ldNO3roIX37co48FtMiLc6d+aTBOSs3GZi5MwdFIoKhHrln6A0Vqcd4yBi6rSF9UyJq5dY5gNHV9VhCylzxTER/W1iUqM3jvNABpIRydTkmhJQO7bMgznUWtrPVWu0/RHfRb69XSy9Qq25Q8MtzzWJ9M0ex3fBig71yBJTvlpA8DIsjhRz7mVgxcYDfsR2RyyaHhw2Gg7vc/TCVstPoXKE9nw7iRqg9q32iij2aNZ7im0wF/rIOl8sG+mUXAcj+cuvmCKPH5aLygXJpWqYCfrrd6yGbkV8fSgYGufqN3mAo4BM3U1ZPEdoHYdbcQ/fCeZzQ1ggNZTPNynkF7/Kw23Ryo0DQeAUhUxqqdjC8to5m9NBxOREvWWjEuILRf7rcMhxfDpiRFE1kkjhos+JryDsOySUG5/vILinjehpddbIKFpvB/1ntGA2srBAgiWcGHRmmpN0WqYHhM3AdDHshrTUUMwbo2bgqG6domObPBnAXCu8xXO781OoHnhFJE8/cPH5SwFp1+6FAvW0WE/GzAAKZWc4wF1U8fvIUhhoJqZ+3q5E08/U4hjMby9YtyrcGnbMlaRZgGFhroytIK5W4+fU7o4GQFkS/zVY77XZsPKhRiGD0Y1bz2WJUvwwuQtRYkUuXl26rjujtitTksnFRcmApDTKaqsAL8Z3QmipU6GnWP6fdseTcLc9fvAEGYdI1UPN5S6cl+fIyOxuE1HH8LXBpfUlnFV+zaedd6db58r9Z6N/r8tsKHbJ60ZHFEBmc+Pr1FrI= X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00fe384c-a902-4976-4716-08dca6d9bc1a X-MS-Exchange-CrossTenant-AuthSource: ZQ0PR01MB1302.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 03:28:47.4993 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eTMJcpFQyHjwPh5ob1ouEaAME9wa6NN544I0QKOECbZArCdjwzxe8z0W6n+WID4caOcEoqmlLvOt/N/zgR2vwfkMtTTv34JCrG8bHhU6gMwmyG1wuMmVRE1A9aJXwthr X-MS-Exchange-Transport-CrossTenantHeadersStamped: ZQ0PR01MB1046 This patch implements system suspend and system resume operation for StarFive Camera Subsystem. It supports hibernation during streaming and restarts streaming at system resume time. Signed-off-by: Changhuang Liang --- .../staging/media/starfive/camss/stf-camss.c | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/staging/media/starfive/camss/stf-camss.c b/drivers/staging/media/starfive/camss/stf-camss.c index fecd3e67c7a1..8dcd35aef69d 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.c +++ b/drivers/staging/media/starfive/camss/stf-camss.c @@ -416,10 +416,59 @@ static int __maybe_unused stfcamss_runtime_resume(struct device *dev) return 0; } +static int __maybe_unused stfcamss_suspend(struct device *dev) +{ + struct stfcamss *stfcamss = dev_get_drvdata(dev); + struct stfcamss_video *video; + unsigned int i; + + for (i = 0; i < STF_CAPTURE_NUM; ++i) { + video = &stfcamss->captures[i].video; + if (video->vb2_q.streaming) { + video->ops->stop_streaming(video); + video->ops->flush_buffers(video, VB2_BUF_STATE_ERROR); + } + } + + return pm_runtime_force_suspend(dev); +} + +static int __maybe_unused stfcamss_resume(struct device *dev) +{ + struct stfcamss *stfcamss = dev_get_drvdata(dev); + struct stf_isp_dev *isp_dev = &stfcamss->isp_dev; + struct v4l2_subdev_state *sd_state; + struct stfcamss_video *video; + unsigned int i; + int ret; + + ret = pm_runtime_force_resume(dev); + if (ret < 0) { + dev_err(dev, "Failed to resume\n"); + return ret; + } + + sd_state = v4l2_subdev_lock_and_get_active_state(&isp_dev->subdev); + + if (isp_dev->streaming) + stf_isp_stream_on(isp_dev, sd_state); + + v4l2_subdev_unlock_state(sd_state); + + for (i = 0; i < STF_CAPTURE_NUM; ++i) { + video = &stfcamss->captures[i].video; + if (video->vb2_q.streaming) + video->ops->start_streaming(video); + } + + return 0; +} + static const struct dev_pm_ops stfcamss_pm_ops = { SET_RUNTIME_PM_OPS(stfcamss_runtime_suspend, stfcamss_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(stfcamss_suspend, stfcamss_resume) }; static struct platform_driver stfcamss_driver = {