static int tegra_camera_release(struct inode *inode, struct file *file) { int ret = 0; struct tegra_camera_dev *dev = file->private_data; dev_info(dev->dev, "%s\n", __func__); mutex_lock(&dev->tegra_camera_lock); /* disable HW clock */ ret = tegra_camera_disable_clk(dev); if (ret) goto release_exit; /* nullify EMC request */ ret = tegra_camera_disable_emc(dev); if (ret) goto release_exit; /* turn off CSI regulator */ tegra_camera_power_off(dev); if (ret) goto release_exit; release_exit: mutex_unlock(&dev->tegra_camera_lock); WARN_ON(!atomic_xchg(&dev->in_use, 0)); return 0; }
static int tegra_camera_release(struct inode *inode, struct file *file) { int i, err; struct tegra_camera_dev *dev = file->private_data; dev_info(dev->dev, "%s\n", __func__); for (i = 0; i < ARRAY_SIZE(tegra_camera_block); i++) if (tegra_camera_block[i].is_enabled) { tegra_camera_block[i].disable(dev); tegra_camera_block[i].is_enabled = false; } /* If camera blocks are not powergated yet, do it now */ if (dev->power_refcnt > 0) { mutex_lock(&dev->tegra_camera_lock); #ifndef CONFIG_ARCH_TEGRA_2x_SOC err = tegra_powergate_partition(TEGRA_POWERGATE_VENC); if (err) dev_err(dev->dev, "%s: powergate failed.\n", __func__); #endif dev->power_refcnt = 0; mutex_unlock(&dev->tegra_camera_lock); } tegra_camera_disable_emc(dev); return 0; }
static int tegra_camera_open(struct inode *inode, struct file *file) { int ret; struct miscdevice *miscdev = file->private_data; struct tegra_camera *camera = container_of(miscdev, struct tegra_camera, misc_dev); dev_info(camera->dev, "%s: ++\n", __func__); if (atomic_xchg(&camera->in_use, 1)) return -EBUSY; file->private_data = camera; mutex_lock(&camera->tegra_camera_lock); /* turn on CSI regulator */ ret = tegra_camera_power_on(camera); if (ret) goto power_on_fail; /* set EMC request */ ret = tegra_camera_enable_emc(camera); if (ret) goto enable_emc_fail; /* read initial clock info */ tegra_camera_init_clk(camera, clock_init); /* enable camera HW clock */ ret = tegra_camera_enable_clk(camera); if (ret) goto enable_clk_fail; mutex_unlock(&camera->tegra_camera_lock); return 0; enable_clk_fail: tegra_camera_disable_emc(camera); enable_emc_fail: tegra_camera_power_off(camera); power_on_fail: mutex_unlock(&camera->tegra_camera_lock); return ret; }
static int tegra_camera_release(struct inode *inode, struct file *file) { int i; struct tegra_camera_dev *dev = file->private_data; dev_info(dev->dev, "%s\n", __func__); for (i = 0; i < ARRAY_SIZE(tegra_camera_block); i++) if (tegra_camera_block[i].is_enabled) { tegra_camera_block[i].disable(dev); tegra_camera_block[i].is_enabled = false; } /* If camera blocks are not powergated yet, do it now */ if (dev->power_refcnt > 0) { mutex_lock(&dev->tegra_camera_lock); dev->power_refcnt = 1; tegra_camera_power_off(dev); mutex_unlock(&dev->tegra_camera_lock); } tegra_camera_disable_avp(dev); tegra_camera_disable_emc(dev); return 0; }