int fimc_is_resource_put(struct fimc_is_resourcemgr *resourcemgr, u32 rsc_type) { int ret = 0; u32 rsccount; struct fimc_is_resource *resource; struct fimc_is_core *core; BUG_ON(!resourcemgr); BUG_ON(!resourcemgr->private_data); BUG_ON(rsc_type >= RESOURCE_TYPE_MAX); resource = GET_RESOURCE(resourcemgr, rsc_type); core = (struct fimc_is_core *)resourcemgr->private_data; rsccount = atomic_read(&core->rsccount); if (!core->pdev) { err("[RSC] pdev is NULL"); ret = -EMFILE; goto p_err; } if (rsccount == 0) { err("[RSC] Invalid rsccount(%d)\n", rsccount); ret = -EMFILE; goto p_err; } /* local update */ if (atomic_read(&resource->rsccount) == 1) { /* clear hal version, default 1.0 */ resourcemgr->hal_version = IS_HAL_VER_1_0; switch (rsc_type) { case RESOURCE_TYPE_COMPANION: #if defined(CONFIG_PM_RUNTIME) pm_runtime_put_sync(&resource->pdev->dev); #else fimc_is_companion_runtime_suspend(&resource->pdev->dev); #endif clear_bit(FIMC_IS_RM_COM_POWER_ON, &resourcemgr->state); break; case RESOURCE_TYPE_SENSOR0: #if defined(CONFIG_PM_RUNTIME) pm_runtime_put_sync(&resource->pdev->dev); #else fimc_is_sensor_runtime_suspend(&resource->pdev->dev); #endif clear_bit(FIMC_IS_RM_SS0_POWER_ON, &resourcemgr->state); break; case RESOURCE_TYPE_SENSOR1: #if defined(CONFIG_PM_RUNTIME) pm_runtime_put_sync(&resource->pdev->dev); #else fimc_is_sensor_runtime_suspend(&resource->pdev->dev); #endif clear_bit(FIMC_IS_RM_SS1_POWER_ON, &resourcemgr->state); break; case RESOURCE_TYPE_ISCHAIN: ret = fimc_is_itf_power_down(&core->interface); if (ret) err("power down cmd is fail(%d)", ret); ret = fimc_is_ischain_power(&core->ischain[0], 0); if (ret) err("fimc_is_ischain_power is fail(%d)", ret); ret = fimc_is_interface_close(&core->interface); if (ret) err("fimc_is_interface_close is fail(%d)", ret); ret = fimc_is_debug_close(); if (ret) err("fimc_is_debug_close is fail(%d)", ret); #ifndef ENABLE_RESERVED_MEM ret = fimc_is_resourcemgr_deinitmem(resourcemgr); if (ret) err("fimc_is_resourcemgr_deinitmem is fail(%d)", ret); #endif clear_bit(FIMC_IS_RM_ISC_POWER_ON, &resourcemgr->state); break; default: err("[RSC] resource type(%d) is invalid", rsc_type); BUG(); break; } } /* global update */ if (atomic_read(&core->rsccount) == 1) { u32 current_min, current_max; current_min = (resourcemgr->cluster0 & CLUSTER_MIN_MASK) >> CLUSTER_MIN_SHIFT; current_max = (resourcemgr->cluster0 & CLUSTER_MAX_MASK) >> CLUSTER_MAX_SHIFT; if (current_min) { C0MIN_QOS_DEL(); warn("[RSC] cluster0 minfreq is not removed(%dMhz)\n", current_min); } if (current_max) { C0MAX_QOS_DEL(); warn("[RSC] cluster0 maxfreq is not removed(%dMhz)\n", current_max); } current_min = (resourcemgr->cluster1 & CLUSTER_MIN_MASK) >> CLUSTER_MIN_SHIFT; current_max = (resourcemgr->cluster1 & CLUSTER_MAX_MASK) >> CLUSTER_MAX_SHIFT; if (current_min) { C1MIN_QOS_DEL(); warn("[RSC] cluster1 minfreq is not removed(%dMhz)\n", current_min); } if (current_max) { C1MAX_QOS_DEL(); warn("[RSC] cluster1 maxfreq is not removed(%dMhz)\n", current_max); } resourcemgr->cluster0 = 0; resourcemgr->cluster1 = 0; ret = fimc_is_runtime_suspend_post(NULL); if (ret) err("fimc_is_runtime_suspend_post is fail(%d)", ret); pm_relax(&core->pdev->dev); clear_bit(FIMC_IS_RM_POWER_ON, &resourcemgr->state); }
int fimc_is_resource_put(struct fimc_is_resourcemgr *resourcemgr, u32 rsc_type) { int ret = 0; u32 rsccount; struct fimc_is_resource *resource; struct fimc_is_core *core; BUG_ON(!resourcemgr); BUG_ON(!resourcemgr->private_data); BUG_ON(rsc_type >= RESOURCE_TYPE_MAX); resource = GET_RESOURCE(resourcemgr, rsc_type); core = (struct fimc_is_core *)resourcemgr->private_data; rsccount = atomic_read(&core->rsccount); if (rsccount == 0) { err("[RSC] Invalid rsccount(%d)\n", rsccount); ret = -EMFILE; goto p_err; } /* local update */ if (atomic_read(&resource->rsccount) == 1) { /* clear hal version, default 1.0 */ resourcemgr->hal_version = IS_HAL_VER_1_0; switch (rsc_type) { case RESOURCE_TYPE_COMPANION: #if defined(CONFIG_PM_RUNTIME) pm_runtime_put_sync(&resource->pdev->dev); #else #if defined(CONFIG_COMPANION_USE) fimc_is_companion_runtime_suspend(&resource->pdev->dev); #endif #endif clear_bit(FIMC_IS_RM_COM_POWER_ON, &resourcemgr->state); break; case RESOURCE_TYPE_SENSOR0: #if defined(CONFIG_PM_RUNTIME) pm_runtime_put_sync(&resource->pdev->dev); #else fimc_is_sensor_runtime_suspend(&resource->pdev->dev); #endif clear_bit(FIMC_IS_RM_SS0_POWER_ON, &resourcemgr->state); break; case RESOURCE_TYPE_SENSOR1: #if defined(CONFIG_PM_RUNTIME) pm_runtime_put_sync(&resource->pdev->dev); #else fimc_is_sensor_runtime_suspend(&resource->pdev->dev); #endif clear_bit(FIMC_IS_RM_SS1_POWER_ON, &resourcemgr->state); break; case RESOURCE_TYPE_ISCHAIN: ret = fimc_is_itf_power_down(&core->interface); if (ret) err("power down cmd is fail(%d)", ret); ret = fimc_is_ischain_power(&core->ischain[0], 0); if (ret) err("fimc_is_ischain_power is fail(%d)", ret); ret = fimc_is_interface_close(&core->interface); if (ret) err("fimc_is_interface_close is fail(%d)", ret); ret = fimc_is_debug_close(); if (ret) err("fimc_is_debug_close is fail(%d)", ret); #ifndef ENABLE_RESERVED_MEM ret = fimc_is_resourcemgr_deinitmem(resourcemgr); if (ret) err("fimc_is_resourcemgr_deinitmem is fail(%d)", ret); #endif clear_bit(FIMC_IS_RM_ISC_POWER_ON, &resourcemgr->state); break; default: err("[RSC] resource type(%d) is invalid", rsc_type); BUG(); break; } } /* global update */ if (atomic_read(&core->rsccount) == 1) { ret = fimc_is_runtime_suspend_post(NULL); if (ret) err("fimc_is_runtime_suspend_post is fail(%d)", ret); clear_bit(FIMC_IS_RM_POWER_ON, &resourcemgr->state); } atomic_dec(&resource->rsccount); atomic_dec(&core->rsccount); p_err: info("[RSC] rsctype : %d, rsccount : %d\n", rsc_type, rsccount - 1); return ret; }