diff options
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/tegra/nvavp/nvavp_dev.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/media/video/tegra/nvavp/nvavp_dev.c b/drivers/media/video/tegra/nvavp/nvavp_dev.c index c593a0ad756b..cfe033249809 100644 --- a/drivers/media/video/tegra/nvavp/nvavp_dev.c +++ b/drivers/media/video/tegra/nvavp/nvavp_dev.c @@ -144,7 +144,6 @@ struct nvavp_info { #if defined(CONFIG_TEGRA_NVAVP_AUDIO) struct miscdevice audio_misc_dev; #endif - atomic_t clock_stay_on_refcount; }; struct nvavp_clientctx { @@ -154,7 +153,7 @@ struct nvavp_clientctx { struct nvmap_handle_ref *gather_mem; int num_relocs; struct nvavp_info *nvavp; - int clock_stay_on; + u32 clk_reqs; int channel_id; }; @@ -273,8 +272,8 @@ static u32 nvavp_check_idle(struct nvavp_info *nvavp) { struct nvavp_channel *channel_info = nvavp_get_channel_info(nvavp, NVAVP_VIDEO_CHANNEL); struct nv_e276_control *control = channel_info->os_control; - return ((control->put == control->get) - && (!atomic_read(&nvavp->clock_stay_on_refcount))) ? 1 : 0; + + return (control->put == control->get) ? 1 : 0; } static void clock_disable_handler(struct work_struct *work) @@ -1246,16 +1245,15 @@ static int nvavp_force_clock_stay_on_ioctl(struct file *filp, unsigned int cmd, return -EINVAL; } - if (clientctx->clock_stay_on == clock.state) - return 0; - - clientctx->clock_stay_on = clock.state; - - if (clientctx->clock_stay_on == NVAVP_CLOCK_STAY_ON_ENABLED) - atomic_inc(&nvavp->clock_stay_on_refcount); - else if (clientctx->clock_stay_on == NVAVP_CLOCK_STAY_ON_DISABLED) - atomic_dec(&nvavp->clock_stay_on_refcount); - + mutex_lock(&nvavp->open_lock); + if (clock.state) { + if (clientctx->clk_reqs++ == 0) + nvavp_clks_enable(nvavp); + } else { + if (--clientctx->clk_reqs == 0) + nvavp_clks_disable(nvavp); + } + mutex_unlock(&nvavp->open_lock); return 0; } @@ -1287,7 +1285,6 @@ static int tegra_nvavp_open(struct inode *inode, struct file *filp, int channel_ clientctx->nvmap = nvavp->nvmap; clientctx->nvavp = nvavp; - clientctx->clock_stay_on = NVAVP_CLOCK_STAY_ON_DISABLED; filp->private_data = clientctx; @@ -1329,8 +1326,10 @@ static int tegra_nvavp_release(struct inode *inode, struct file *filp) goto out; } - if (clientctx->clock_stay_on == NVAVP_CLOCK_STAY_ON_ENABLED) - atomic_dec(&nvavp->clock_stay_on_refcount); + /* if this client had any requests, drop our clk ref */ + if (clientctx->clk_reqs) + nvavp_clks_disable(nvavp); + if (nvavp->refcount > 0) nvavp->refcount--; if (!nvavp->refcount) |