Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b97ae1f1 authored by E V Ravi's avatar E V Ravi Committed by Jeff Bernard
Browse files

msm: ais: Move wait for early camera handoff



Ensure camera driver waits for early camera
handoff from LK to avoid hardware contention.

Change-Id: If301b63b34331285ac3d126543ca3c1d5cae6ba4
Signed-off-by: default avatarE V Ravi <evenka@codeaurora.org>
parent 84da71b2
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "cam_smmu_api.h"
#define CREATE_TRACE_POINTS
#include "trace/events/msm_cam.h"
#include "sensor/cci/msm_early_cam.h"

#define MAX_ISP_V4l2_EVENTS 100
#define MAX_ISP_REG_LIST 100
@@ -2290,6 +2291,9 @@ int msm_isp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
	vfe_dev->isp_raw1_debug = 0;
	vfe_dev->isp_raw2_debug = 0;

	/* Postpone hardware changes until early camera is complete */
	msm_early_camera_wait();

	if (vfe_dev->hw_info->vfe_ops.core_ops.init_hw(vfe_dev) < 0) {
		pr_err("%s: init hardware failed\n", __func__);
		vfe_dev->vfe_open_cnt--;
@@ -2302,7 +2306,6 @@ int msm_isp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
	atomic_set(&vfe_dev->error_info.overflow_state, NO_OVERFLOW);

	vfe_dev->hw_info->vfe_ops.core_ops.clear_status_reg(vfe_dev);

	vfe_dev->vfe_hw_version = msm_camera_io_r(vfe_dev->vfe_base);
	ISP_DBG("%s: HW Version: 0x%x\n", __func__, vfe_dev->vfe_hw_version);
	rc = vfe_dev->hw_info->vfe_ops.core_ops.reset_hw(vfe_dev, 1, 1);
+20 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_platform.h>
#include <linux/iopoll.h>
#include "msm_sd.h"
#include "msm_early_cam.h"
#include "msm_cam_cci_hwreg.h"
@@ -38,6 +39,12 @@
static struct platform_driver msm_early_camera_driver;
static struct early_cam_device *new_early_cam_dev;

#define MMSS_A_VFE_0_BASE 0x00A10000
#define MMSS_A_VFE_0_SIZE 0x1000
#define EARLY_CAMERA_SIGNAL_DONE 0xa5a5a5a5
#define EARLY_CAMERA_SIGNAL_DISABLED 0
#define MMSS_A_VFE_0_SPARE 0xC84

int msm_early_cam_disable_clocks(void)
{
	int rc = 0;
@@ -253,6 +260,19 @@ int msm_ais_disable_clocks(void)
	return 0;

}

void msm_early_camera_wait(void)
{
	u32 val = 0;
	void __iomem *base;

	base = ioremap(MMSS_A_VFE_0_BASE, MMSS_A_VFE_0_SIZE);
	readl_poll_timeout(base + MMSS_A_VFE_0_SPARE, val,
		((val == EARLY_CAMERA_SIGNAL_DONE)
		|| (val == EARLY_CAMERA_SIGNAL_DISABLED)), 0, 0);
	iounmap(base);
}

static int msm_early_cam_probe(struct platform_device *pdev)
{
	int rc = 0;
+1 −0
Original line number Diff line number Diff line
@@ -53,4 +53,5 @@ struct early_cam_device {
int msm_early_cam_disable_clocks(void);
int msm_ais_enable_clocks(void);
int msm_ais_disable_clocks(void);
void msm_early_camera_wait(void);
#endif
+4 −19
Original line number Diff line number Diff line
/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -23,9 +23,6 @@
#undef CDBG
#define CDBG(fmt, args...) pr_debug(fmt, ##args)

#define EARLY_CAMERA_SIGNAL_DONE 0xa5a5a5a5
#define EARLY_CAMERA_SIGNAL_DISABLED 0

static bool early_camera_clock_off;
static struct msm_sensor_init_t *s_init;

@@ -48,14 +45,10 @@ static int msm_sensor_wait_for_probe_done(struct msm_sensor_init_t *s_init)
	return rc;
}

#define MMSS_A_VFE_0_SPARE 0xC84

/* Static function definition */
int32_t msm_sensor_driver_cmd(struct msm_sensor_init_t *s_init, void *arg)
{
	int32_t                      rc = 0;
	u32 val = 0;
	void __iomem *base;
	struct sensor_init_cfg_data *cfg = (struct sensor_init_cfg_data *)arg;

	/* Validate input parameters */
@@ -64,6 +57,8 @@ int32_t msm_sensor_driver_cmd(struct msm_sensor_init_t *s_init, void *arg)
		return -EINVAL;
	}

	/* Postpone hardware changes until early camera is complete */
	msm_early_camera_wait();
	pr_debug("%s : %d", __func__, cfg->cfgtype);
	switch (cfg->cfgtype) {
	case CFG_SINIT_PROBE:
@@ -79,17 +74,7 @@ int32_t msm_sensor_driver_cmd(struct msm_sensor_init_t *s_init, void *arg)

	case CFG_SINIT_PROBE_DONE:
		if (early_camera_clock_off == false) {
			base = ioremap(0x00A10000, 0x1000);
			val = msm_camera_io_r_mb(base + MMSS_A_VFE_0_SPARE);
			while (val != EARLY_CAMERA_SIGNAL_DONE) {
				if (val == EARLY_CAMERA_SIGNAL_DISABLED)
					break;
				msleep(1000);
				val = msm_camera_io_r_mb(
					base + MMSS_A_VFE_0_SPARE);
				pr_err("Waiting for signal from LK val = %u\n",
					val);
			}
			msm_early_camera_wait();
			rc = msm_early_cam_disable_clocks();
			if (rc < 0) {
				pr_err("Failed to disable early camera :%d\n",