static int tegra_camera_open(struct inode *inode, struct file *file)
{
	struct miscdevice *miscdev = file->private_data;
	struct tegra_camera_dev *dev = container_of(miscdev,
						struct tegra_camera_dev,
						misc_dev);
	int ret = 0;

	dev_info(dev->dev, "%s\n", __func__);

	if (atomic_xchg(&dev->in_use, 1))
		return -EBUSY;

	file->private_data = dev;

	mutex_lock(&dev->tegra_camera_lock);
	/* turn on CSI regulator */
	ret = tegra_camera_power_on(dev);
	if (ret)
		goto open_exit;
	/* set EMC request */
	ret = tegra_camera_enable_emc(dev);
	if (ret)
		goto open_exit;
	/* enable camera HW clock */
	ret = tegra_camera_enable_clk(dev);
	if (ret)
		goto open_exit;
open_exit:
	mutex_unlock(&dev->tegra_camera_lock);
	return ret;
}
Esempio n. 2
0
static int tegra_camera_open(struct inode *inode, struct file *file)
{
	struct miscdevice *miscdev = file->private_data;
	struct tegra_camera_dev *dev = container_of(miscdev,
						struct tegra_camera_dev,
						misc_dev);
	dev_info(dev->dev, "%s\n", __func__);
	file->private_data = dev;

	tegra_camera_enable_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;
}