aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/input/sensors/smi130/modules.order0
-rw-r--r--drivers/media/platform/msm/camera_v2/Kconfig57
-rw-r--r--drivers/media/platform/msm/camera_v2/camera/camera.c10
-rw-r--r--drivers/media/platform/msm/camera_v2/common/cam_soc_api.c7
-rw-r--r--drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.c23
-rw-r--r--drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.h3
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/Makefile9
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c16
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr_32.c1264
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr_32.h203
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp.c70
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp.h16
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp32.c490
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp40.c58
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp44.c35
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp46.c28
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp47.c38
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp47.h3
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp48.c4
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_32.c594
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_32.h599
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c256
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.h1
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util_32.c2083
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util_32.h69
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c9
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util_32.c708
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util_32.h27
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c401
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_util.h17
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_util_32.c1919
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_util_32.h81
-rw-r--r--drivers/media/platform/msm/camera_v2/ispif/Makefile6
-rw-r--r--drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c543
-rw-r--r--drivers/media/platform/msm/camera_v2/ispif/msm_ispif.h3
-rw-r--r--drivers/media/platform/msm/camera_v2/ispif/msm_ispif_32.c1578
-rw-r--r--drivers/media/platform/msm/camera_v2/ispif/msm_ispif_32.h69
-rw-r--r--drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v1.h6
-rw-r--r--drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v2.h8
-rw-r--r--drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v3.h7
-rw-r--r--drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c35
-rw-r--r--drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c126
-rw-r--r--drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.h6
-rw-r--r--drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_hw.c85
-rw-r--r--drivers/media/platform/msm/camera_v2/msm.c144
-rw-r--r--drivers/media/platform/msm/camera_v2/msm.h12
-rw-r--r--drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c9
-rw-r--r--drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c171
-rw-r--r--drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.h3
-rw-r--r--drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c200
-rw-r--r--drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c19
-rw-r--r--drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.h3
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c47
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c72
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h3
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c22
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/csiphy/include/msm_csiphy_3_4_2_hwreg.h70
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c18
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h1
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c30
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/Makefile5
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/adp1660.c217
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.c192
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.h5
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash_gpio.c40
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.c128
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.h97
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_i2c_trigger.c883
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_torch.c82
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_trigger.c329
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/io/Makefile3
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_cci_i2c.c10
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c18
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.h6
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_i2c.h56
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_qup_i2c.c36
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_tz_i2c.c1093
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/ir_cut/msm_ir_cut.c3
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.c126
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.h7
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c49
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/msm_sensor.h4
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c130
-rw-r--r--drivers/media/platform/msm/camera_v2/sensor/ois/msm_ois.c17
-rw-r--r--include/media/msm_cam_sensor.h1
-rw-r--r--include/media/msmb_isp.h17
-rw-r--r--include/uapi/media/msm_cam_sensor.h2
-rw-r--r--include/uapi/media/msm_camsensor_sdk.h4
-rw-r--r--include/uapi/media/msm_jpeg_dma.h8
-rw-r--r--include/uapi/media/msmb_isp.h94
-rw-r--r--include/uapi/media/msmb_ispif.h14
91 files changed, 980 insertions, 15090 deletions
diff --git a/drivers/input/sensors/smi130/modules.order b/drivers/input/sensors/smi130/modules.order
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/drivers/input/sensors/smi130/modules.order
+++ /dev/null
diff --git a/drivers/media/platform/msm/camera_v2/Kconfig b/drivers/media/platform/msm/camera_v2/Kconfig
index db4e15abe7da..b868029336b6 100644
--- a/drivers/media/platform/msm/camera_v2/Kconfig
+++ b/drivers/media/platform/msm/camera_v2/Kconfig
@@ -1,5 +1,5 @@
config MSM_CAMERA_SENSOR
- bool "QTI MSM camera sensor support"
+ bool "Qualcomm MSM camera sensor support"
depends on MSMB_CAMERA
select NEW_LEDS
select LEDS_CLASS
@@ -10,7 +10,7 @@ config MSM_CAMERA_SENSOR
subdev APIs.
config MSM_CPP
- bool "QTI MSM Camera Post Processing Engine support"
+ bool "Qualcomm MSM Camera Post Processing Engine support"
depends on MSMB_CAMERA
---help---
Enable support for Camera Post-processing Engine
@@ -19,7 +19,7 @@ config MSM_CPP
APIs.
config MSM_CCI
- bool "QTI MSM Camera Control Interface support"
+ bool "Qualcomm MSM Camera Control Interface support"
depends on MSMB_CAMERA
---help---
Enable support for Camera Control Interface driver only
@@ -29,7 +29,7 @@ config MSM_CCI
GPIO and data frames.
config MSM_CSI20_HEADER
- bool "QTI MSM CSI 2.0 Header"
+ bool "Qualcomm MSM CSI 2.0 Header"
depends on MSMB_CAMERA
---help---
Enable support for CSI drivers to include 2.0
@@ -39,7 +39,7 @@ config MSM_CSI20_HEADER
8930 and 8064 platforms.
config MSM_CSI22_HEADER
- bool "QTI MSM CSI 2.2 Header"
+ bool "Qualcomm MSM CSI 2.2 Header"
depends on MSMB_CAMERA
---help---
Enable support for CSI drivers to include 2.2
@@ -49,7 +49,7 @@ config MSM_CSI22_HEADER
platform.
config MSM_CSI30_HEADER
- bool "QTI MSM CSI 3.0 Header"
+ bool "Qualcomm MSM CSI 3.0 Header"
depends on MSMB_CAMERA
---help---
Enable support for CSI drivers to include 3.0
@@ -59,7 +59,7 @@ config MSM_CSI30_HEADER
8064 platforms.
config MSM_CSI31_HEADER
- bool "QTI MSM CSI 3.1 Header"
+ bool "Qualcomm MSM CSI 3.1 Header"
depends on MSMB_CAMERA
---help---
Enable support for CSI drivers to include 3.0
@@ -69,7 +69,7 @@ config MSM_CSI31_HEADER
APQ8084 platform.
config MSM_CSIPHY
- bool "QTI MSM Camera Serial Interface Physical receiver support"
+ bool "Qualcomm MSM Camera Serial Interface Physical receiver support"
depends on MSMB_CAMERA
---help---
Enable support for Camera Serial Interface
@@ -78,7 +78,7 @@ config MSM_CSIPHY
signalling.
config MSM_CSID
- bool "QTI MSM Camera Serial Interface decoder support"
+ bool "Qualcomm MSM Camera Serial Interface decoder support"
depends on MSMB_CAMERA
---help---
Enable support for Camera Serial Interface decoder.
@@ -87,7 +87,7 @@ config MSM_CSID
and datatype.
config MSM_EEPROM
- bool "QTI MSM Camera ROM Interface for Calibration support"
+ bool "Qualcomm MSM Camera ROM Interface for Calibration support"
depends on MSMB_CAMERA
---help---
Enable support for ROM Interface for Calibration
@@ -95,17 +95,8 @@ config MSM_EEPROM
and also provides support for writing data in case of FLASH ROM.
Currently supports I2C, CCI and SPI protocol
-config MSM_ISP_V1
- bool "QTI MSM Image Signal Processing interface support"
- depends on MSMB_CAMERA
- ---help---
- Enable support for Image Signal Processing interface module.
- This module acts as a crossbar between CSID and VFE. Output
- of any CID of CSID can be routed to of of pixel or raw
- data interface in VFE.
-
config MSM_ISPIF
- bool "QTI MSM Image Signal Processing interface support"
+ bool "Qualcomm MSM Image Signal Processing interface support"
depends on MSMB_CAMERA
---help---
Enable support for Image Signal Processing interface module.
@@ -114,7 +105,7 @@ config MSM_ISPIF
data interface in VFE.
config MSM_ISPIF_V1
- bool "QTI MSM Image Signal Processing interface support"
+ bool "Qualcomm MSM Image Signal Processing interface support"
depends on MSMB_CAMERA
---help---
Enable support for Image Signal Processing interface module.
@@ -123,7 +114,7 @@ config MSM_ISPIF_V1
or raw data interface in VFE.
config MSM_ISPIF_V2
- bool "QTI MSM Image Signal Processing interface support"
+ bool "Qualcomm MSM Image Signal Processing interface support"
depends on MSMB_CAMERA
---help---
Enable support for Image Signal Processing interface module.
@@ -213,7 +204,7 @@ config OV12830
2 lanes max fps is 18, 4 lanes max fps is 24.
config MSM_V4L2_VIDEO_OVERLAY_DEVICE
- tristate "QTI MSM V4l2 video overlay device"
+ tristate "Qualcomm MSM V4l2 video overlay device"
---help---
Enables support for the MSM V4L2 video
overlay driver. This allows video rendering
@@ -221,7 +212,7 @@ config MSM_V4L2_VIDEO_OVERLAY_DEVICE
APIs, by using /dev/videoX device
config MSMB_JPEG
- tristate "QTI MSM Jpeg Encoder Engine support"
+ tristate "Qualcomm MSM Jpeg Encoder Engine support"
depends on MSMB_CAMERA && (ARCH_MSM8974 || ARCH_MSM8226 || ARCH_APQ8084 || ARCH_MSM8916 || ARCH_MSM8953 || ARCH_MSM)
---help---
Enable support for Jpeg Encoder/Decoder
@@ -230,7 +221,7 @@ config MSMB_JPEG
for the JPEG 1.0 encoder and decoder.
config MSM_GEMINI
- tristate "QTI MSM Gemini JPEG engine support"
+ tristate "Qualcomm MSM Gemini JPEG engine support"
depends on MSMB_CAMERA && (ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_MSM8960)
---help---
Enables support for the Gemini JPEG encoder
@@ -239,30 +230,18 @@ config MSM_GEMINI
for JPEG encoding functionality.
config MSM_FD
- tristate "QTI MSM FD face detection engine support"
+ tristate "Qualcomm MSM FD face detection engine support"
depends on MSMB_CAMERA
---help---
Enables support for the MSM FD face detection engine.
config MSM_JPEGDMA
- tristate "QTI MSM Jpeg dma"
+ tristate "Qualcomm Technologies Inc. MSM Jpeg dma"
depends on MSMB_CAMERA
select V4L2_MEM2MEM_DEV
---help---
Enable support for Jpeg dma engine.
-config MSM_SEC_CCI_TA_NAME
- string "Name of TA to handle Secure CCI transactions"
- depends on MSM_CCI
- default "seccamdemo64"
-
-config MSM_SEC_CCI_DEBUG
- bool "QTI MSM Secure CCI Relay Debug"
- depends on MSM_CCI
- ---help---
- Enables simulation of secure camera for Secure CCI Realy
- debugging.
-
config DEBUG_CAMERA
bool "Enable Camera Debug"
depends on MSMB_CAMERA && DEBUG_FS
diff --git a/drivers/media/platform/msm/camera_v2/camera/camera.c b/drivers/media/platform/msm/camera_v2/camera/camera.c
index 7aa52faebb88..cedf7c49b101 100644
--- a/drivers/media/platform/msm/camera_v2/camera/camera.c
+++ b/drivers/media/platform/msm/camera_v2/camera/camera.c
@@ -458,9 +458,7 @@ static int camera_v4l2_subscribe_event(struct v4l2_fh *fh,
int rc = 0;
struct camera_v4l2_private *sp = fh_to_private(fh);
- mutex_lock(&sp->lock);
rc = v4l2_event_subscribe(&sp->fh, sub, 5, NULL);
- mutex_unlock(&sp->lock);
return rc;
}
@@ -471,9 +469,7 @@ static int camera_v4l2_unsubscribe_event(struct v4l2_fh *fh,
int rc = 0;
struct camera_v4l2_private *sp = fh_to_private(fh);
- mutex_lock(&sp->lock);
rc = v4l2_event_unsubscribe(&sp->fh, sub);
- mutex_unlock(&sp->lock);
return rc;
}
@@ -627,7 +623,6 @@ static int camera_v4l2_open(struct file *filep)
unsigned int opn_idx, idx;
BUG_ON(!pvdev);
- mutex_lock(&pvdev->video_drvdata_mutex);
rc = camera_v4l2_fh_open(filep);
if (rc < 0) {
pr_err("%s : camera_v4l2_fh_open failed Line %d rc %d\n",
@@ -698,7 +693,6 @@ static int camera_v4l2_open(struct file *filep)
idx |= (1 << find_first_zero_bit((const unsigned long *)&opn_idx,
MSM_CAMERA_STREAM_CNT_BITS));
atomic_cmpxchg(&pvdev->opened, opn_idx, idx);
- mutex_unlock(&pvdev->video_drvdata_mutex);
return rc;
@@ -726,7 +720,6 @@ stream_fail:
vb2_q_fail:
camera_v4l2_fh_release(filep);
fh_open_fail:
- mutex_unlock(&pvdev->video_drvdata_mutex);
return rc;
}
@@ -757,7 +750,6 @@ static int camera_v4l2_close(struct file *filep)
if (WARN_ON(!session))
return -EIO;
- mutex_lock(&pvdev->video_drvdata_mutex);
mutex_lock(&session->close_lock);
opn_idx = atomic_read(&pvdev->opened);
mask = (1 << sp->stream_id);
@@ -799,7 +791,6 @@ static int camera_v4l2_close(struct file *filep)
}
camera_v4l2_fh_release(filep);
- mutex_unlock(&pvdev->video_drvdata_mutex);
return 0;
}
@@ -946,7 +937,6 @@ int camera_init_v4l2(struct device *dev, unsigned int *session)
*session = pvdev->vdev->num;
atomic_set(&pvdev->opened, 0);
- mutex_init(&pvdev->video_drvdata_mutex);
video_set_drvdata(pvdev->vdev, pvdev);
device_init_wakeup(&pvdev->vdev->dev, 1);
goto init_end;
diff --git a/drivers/media/platform/msm/camera_v2/common/cam_soc_api.c b/drivers/media/platform/msm/camera_v2/common/cam_soc_api.c
index 2ffeb5234887..7f5e49809a26 100644
--- a/drivers/media/platform/msm/camera_v2/common/cam_soc_api.c
+++ b/drivers/media/platform/msm/camera_v2/common/cam_soc_api.c
@@ -1006,11 +1006,8 @@ uint32_t msm_camera_unregister_bus_client(enum cam_bus_client id)
mutex_destroy(&g_cv[id].lock);
msm_bus_scale_unregister_client(g_cv[id].bus_client);
- g_cv[id].bus_client = 0;
- g_cv[id].num_usecases = 0;
- g_cv[id].num_paths = 0;
- g_cv[id].vector_index = 0;
- g_cv[id].dyn_vote = 0;
+ msm_bus_cl_clear_pdata(g_cv[id].pdata);
+ memset(&g_cv[id], 0, sizeof(struct msm_cam_bus_pscale_data));
return 0;
}
diff --git a/drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.c b/drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.c
index dde1de0dcb91..e1d7dd171c74 100644
--- a/drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.c
+++ b/drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2016, 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
@@ -432,7 +432,6 @@ static int msm_fd_open(struct file *file)
ctx->vb2_q.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
ctx->vb2_q.io_modes = VB2_USERPTR;
ctx->vb2_q.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
- mutex_init(&ctx->lock);
ret = vb2_queue_init(&ctx->vb2_q);
if (ret < 0) {
dev_err(device->dev, "Error queue init\n");
@@ -483,9 +482,7 @@ static int msm_fd_release(struct file *file)
msm_cpp_vbif_register_error_handler((void *)ctx,
VBIF_CLIENT_FD, NULL);
- mutex_lock(&ctx->lock);
vb2_queue_release(&ctx->vb2_q);
- mutex_unlock(&ctx->lock);
vfree(ctx->stats);
@@ -515,9 +512,7 @@ static unsigned int msm_fd_poll(struct file *file,
struct fd_ctx *ctx = msm_fd_ctx_from_fh(file->private_data);
unsigned int ret;
- mutex_lock(&ctx->lock);
ret = vb2_poll(&ctx->vb2_q, file, wait);
- mutex_unlock(&ctx->lock);
if (atomic_read(&ctx->subscribed_for_event)) {
poll_wait(file, &ctx->fh.wait, wait);
@@ -755,9 +750,9 @@ static int msm_fd_reqbufs(struct file *file,
int ret;
struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);
- mutex_lock(&ctx->lock);
+ mutex_lock(&ctx->fd_device->recovery_lock);
ret = vb2_reqbufs(&ctx->vb2_q, req);
- mutex_unlock(&ctx->lock);
+ mutex_unlock(&ctx->fd_device->recovery_lock);
return ret;
}
@@ -773,9 +768,9 @@ static int msm_fd_qbuf(struct file *file, void *fh,
int ret;
struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);
- mutex_lock(&ctx->lock);
+ mutex_lock(&ctx->fd_device->recovery_lock);
ret = vb2_qbuf(&ctx->vb2_q, pb);
- mutex_unlock(&ctx->lock);
+ mutex_unlock(&ctx->fd_device->recovery_lock);
return ret;
}
@@ -792,9 +787,9 @@ static int msm_fd_dqbuf(struct file *file,
int ret;
struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);
- mutex_lock(&ctx->lock);
+ mutex_lock(&ctx->fd_device->recovery_lock);
ret = vb2_dqbuf(&ctx->vb2_q, pb, file->f_flags & O_NONBLOCK);
- mutex_unlock(&ctx->lock);
+ mutex_unlock(&ctx->fd_device->recovery_lock);
return ret;
}
@@ -810,9 +805,7 @@ static int msm_fd_streamon(struct file *file,
struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);
int ret;
- mutex_lock(&ctx->lock);
ret = vb2_streamon(&ctx->vb2_q, buf_type);
- mutex_unlock(&ctx->lock);
if (ret < 0)
dev_err(ctx->fd_device->dev, "Stream on fails\n");
@@ -831,9 +824,7 @@ static int msm_fd_streamoff(struct file *file,
struct fd_ctx *ctx = msm_fd_ctx_from_fh(fh);
int ret;
- mutex_lock(&ctx->lock);
ret = vb2_streamoff(&ctx->vb2_q, buf_type);
- mutex_unlock(&ctx->lock);
if (ret < 0)
dev_err(ctx->fd_device->dev, "Stream off fails\n");
diff --git a/drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.h b/drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.h
index a7615a65d2fc..4155eb8a6faf 100644
--- a/drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.h
+++ b/drivers/media/platform/msm/camera_v2/fd/msm_fd_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2016, 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
@@ -161,7 +161,6 @@ struct fd_ctx {
struct msm_fd_mem_pool mem_pool;
struct msm_fd_stats *stats;
struct msm_fd_buf_handle work_buf;
- struct mutex lock;
};
/*
diff --git a/drivers/media/platform/msm/camera_v2/isp/Makefile b/drivers/media/platform/msm/camera_v2/isp/Makefile
index 4c6586e2616c..621d81d381a1 100644
--- a/drivers/media/platform/msm/camera_v2/isp/Makefile
+++ b/drivers/media/platform/msm/camera_v2/isp/Makefile
@@ -1,10 +1,5 @@
ccflags-y += -Idrivers/media/platform/msm/camera_v2
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor/io
ccflags-y += -Idrivers/media/platform/msm/camera_v2/common/
-ifeq ($(CONFIG_MSM_ISP_V1),y)
-obj-$(CONFIG_MSMB_CAMERA) += msm_isp_32.o msm_buf_mgr_32.o msm_isp_util_32.o msm_isp_axi_util_32.o msm_isp_stats_util_32.o
-obj-$(CONFIG_MSMB_CAMERA) += msm_isp32.o
-else
-obj-$(CONFIG_MSMB_CAMERA) += msm_isp.o msm_buf_mgr.o msm_isp_util.o msm_isp_axi_util.o msm_isp_stats_util.o
-obj-$(CONFIG_MSMB_CAMERA) += msm_isp47.o msm_isp46.o msm_isp44.o msm_isp40.o
-endif
+obj-$(CONFIG_MSMB_CAMERA) += msm_buf_mgr.o msm_isp_util.o msm_isp_axi_util.o msm_isp_stats_util.o
+obj-$(CONFIG_MSMB_CAMERA) += msm_isp48.o msm_isp47.o msm_isp46.o msm_isp44.o msm_isp40.o msm_isp.o
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c b/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c
index 8b5095ac959e..4c6126da401a 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr.c
@@ -20,7 +20,7 @@
#include <linux/proc_fs.h>
#include <linux/videodev2.h>
#include <linux/vmalloc.h>
-
+#include <linux/irqchip/arm-gic.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-ioctl.h>
@@ -750,6 +750,7 @@ static int msm_isp_update_put_buf_cnt(struct msm_isp_buf_mgr *buf_mgr,
if (-ENOTEMPTY == rc) {
pr_err("%s: Error! Uncleared put_buf_mask for pingpong(%d) from vfe %d bufq 0x%x buf_idx %d\n",
__func__, pingpong_bit, id, bufq_handle, buf_index);
+ gic_show_pending_irq();
msm_isp_dump_ping_pong_mismatch();
rc = -EFAULT;
}
@@ -1287,40 +1288,39 @@ static int msm_isp_deinit_isp_buf_mgr(
int msm_isp_proc_buf_cmd(struct msm_isp_buf_mgr *buf_mgr,
unsigned int cmd, void *arg)
{
- int rc = -EINVAL;
switch (cmd) {
case VIDIOC_MSM_ISP_REQUEST_BUF: {
struct msm_isp_buf_request *buf_req = arg;
- rc = buf_mgr->ops->request_buf(buf_mgr, buf_req);
+ buf_mgr->ops->request_buf(buf_mgr, buf_req);
break;
}
case VIDIOC_MSM_ISP_ENQUEUE_BUF: {
struct msm_isp_qbuf_info *qbuf_info = arg;
- rc = buf_mgr->ops->enqueue_buf(buf_mgr, qbuf_info);
+ buf_mgr->ops->enqueue_buf(buf_mgr, qbuf_info);
break;
}
case VIDIOC_MSM_ISP_DEQUEUE_BUF: {
struct msm_isp_qbuf_info *qbuf_info = arg;
- rc = buf_mgr->ops->dequeue_buf(buf_mgr, qbuf_info);
+ buf_mgr->ops->dequeue_buf(buf_mgr, qbuf_info);
break;
}
case VIDIOC_MSM_ISP_RELEASE_BUF: {
struct msm_isp_buf_request *buf_req = arg;
- rc = buf_mgr->ops->release_buf(buf_mgr, buf_req->handle);
+ buf_mgr->ops->release_buf(buf_mgr, buf_req->handle);
break;
}
case VIDIOC_MSM_ISP_UNMAP_BUF: {
struct msm_isp_unmap_buf_req *unmap_req = arg;
- rc = buf_mgr->ops->unmap_buf(buf_mgr, unmap_req->fd);
+ buf_mgr->ops->unmap_buf(buf_mgr, unmap_req->fd);
break;
}
}
- return rc;
+ return 0;
}
static int msm_isp_buf_mgr_debug(struct msm_isp_buf_mgr *buf_mgr,
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr_32.c b/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr_32.c
deleted file mode 100644
index 3203d44b0fba..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr_32.c
+++ /dev/null
@@ -1,1264 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include <linux/videodev2.h>
-#include <linux/proc_fs.h>
-#include <linux/videodev2.h>
-#include <linux/vmalloc.h>
-
-
-#include <media/v4l2-dev.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-device.h>
-#include <media/videobuf2-core.h>
-#include <media/msm_camera.h>
-#include <media/msm_isp.h>
-
-#include <linux/qcom_iommu.h>
-
-#include "msm.h"
-#include "msm_buf_mgr_32.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
-struct msm_isp_bufq *msm_isp_get_bufq(
- struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle)
-{
- struct msm_isp_bufq *bufq = NULL;
- uint32_t bufq_index = bufq_handle & 0xFF;
-
- if ((bufq_handle == 0) ||
- (bufq_index > buf_mgr->num_buf_q) ||
- (bufq_index >= BUF_MGR_NUM_BUF_Q))
- return NULL;
-
- bufq = &buf_mgr->bufq[bufq_index];
- if (bufq->bufq_handle == bufq_handle)
- return bufq;
-
- return NULL;
-}
-
-static struct msm_isp_buffer *msm_isp_get_buf_ptr(
- struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index)
-{
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return buf_info;
- }
-
- if (bufq->num_bufs <= buf_index) {
- pr_err("%s: Invalid buf index\n", __func__);
- return buf_info;
- }
- buf_info = &bufq->bufs[buf_index];
- return buf_info;
-}
-
-static uint32_t msm_isp_get_buf_handle(
- struct msm_isp_buf_mgr *buf_mgr,
- uint32_t session_id, uint32_t stream_id)
-{
- int i;
-
- if ((buf_mgr->buf_handle_cnt << 8) == 0)
- buf_mgr->buf_handle_cnt++;
-
- for (i = 0; i < buf_mgr->num_buf_q; i++) {
- if (buf_mgr->bufq[i].session_id == session_id &&
- buf_mgr->bufq[i].stream_id == stream_id)
- return 0;
- }
-
- for (i = 0; i < buf_mgr->num_buf_q; i++) {
- if (buf_mgr->bufq[i].bufq_handle == 0) {
- memset(&buf_mgr->bufq[i],
- 0, sizeof(struct msm_isp_bufq));
- buf_mgr->bufq[i].bufq_handle =
- (++buf_mgr->buf_handle_cnt) << 8 | i;
- return buf_mgr->bufq[i].bufq_handle;
- }
- }
- return 0;
-}
-
-static int msm_isp_free_buf_handle(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle)
-{
- struct msm_isp_bufq *bufq =
- msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq)
- return -EINVAL;
- memset(bufq, 0, sizeof(struct msm_isp_bufq));
- return 0;
-}
-
-static void msm_isp_copy_planes_from_v4l2_buffer(
- struct msm_isp_qbuf_buffer *qbuf_buf,
- const struct v4l2_buffer *v4l2_buf)
-{
- int i;
-
- qbuf_buf->num_planes = v4l2_buf->length;
- for (i = 0; i < qbuf_buf->num_planes; i++) {
- qbuf_buf->planes[i].addr = v4l2_buf->m.planes[i].m.userptr;
- qbuf_buf->planes[i].offset = v4l2_buf->m.planes[i].data_offset;
- }
-}
-
-static int msm_isp_prepare_isp_buf(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_isp_buffer *buf_info,
- struct msm_isp_qbuf_buffer *qbuf_buf)
-{
- int i, rc = -1;
- struct msm_isp_buffer_mapped_info *mapped_info;
- struct buffer_cmd *buf_pending = NULL;
- int domain_num;
-
- if (buf_mgr->secure_enable == NON_SECURE_MODE)
- domain_num = buf_mgr->iommu_domain_num;
- else
- domain_num = buf_mgr->iommu_domain_num_secure;
-
- for (i = 0; i < qbuf_buf->num_planes; i++) {
- mapped_info = &buf_info->mapped_info[i];
- mapped_info->handle =
- ion_import_dma_buf(buf_mgr->client,
- qbuf_buf->planes[i].addr);
- if (IS_ERR_OR_NULL(mapped_info->handle)) {
- pr_err("%s: buf has null/error ION handle %pK\n",
- __func__, mapped_info->handle);
- goto ion_map_error;
- }
- if (ion_map_iommu(buf_mgr->client, mapped_info->handle,
- domain_num, 0, SZ_4K,
- 0, &(mapped_info->paddr),
- &(mapped_info->len), 0, 0) < 0) {
- rc = -EINVAL;
- pr_err("%s: cannot map address", __func__);
- ion_free(buf_mgr->client, mapped_info->handle);
- goto ion_map_error;
- }
- mapped_info->paddr += qbuf_buf->planes[i].offset;
- CDBG("%s: plane: %d addr:%lu\n",
- __func__, i, (unsigned long)mapped_info->paddr);
-
- buf_pending = kzalloc(sizeof(struct buffer_cmd), GFP_ATOMIC);
- if (!buf_pending)
- return rc;
-
- buf_pending->mapped_info = mapped_info;
- list_add_tail(&buf_pending->list, &buf_mgr->buffer_q);
- }
- buf_info->num_planes = qbuf_buf->num_planes;
- return 0;
-ion_map_error:
- for (--i; i >= 0; i--) {
- mapped_info = &buf_info->mapped_info[i];
- ion_unmap_iommu(buf_mgr->client, mapped_info->handle,
- buf_mgr->iommu_domain_num, 0);
- ion_free(buf_mgr->client, mapped_info->handle);
- }
- return rc;
-}
-
-static void msm_isp_unprepare_v4l2_buf(
- struct msm_isp_buf_mgr *buf_mgr,
- struct msm_isp_buffer *buf_info)
-{
- int i;
- struct msm_isp_buffer_mapped_info *mapped_info;
- struct buffer_cmd *buf_pending = NULL;
- int domain_num;
-
- if (buf_mgr->secure_enable == NON_SECURE_MODE)
- domain_num = buf_mgr->iommu_domain_num;
- else
- domain_num = buf_mgr->iommu_domain_num_secure;
-
- for (i = 0; i < buf_info->num_planes; i++) {
- mapped_info = &buf_info->mapped_info[i];
-
- list_for_each_entry(buf_pending, &buf_mgr->buffer_q, list) {
- if (!buf_pending)
- break;
-
- if (buf_pending->mapped_info == mapped_info) {
- ion_unmap_iommu(buf_mgr->client,
- mapped_info->handle,
- domain_num, 0);
- ion_free(buf_mgr->client, mapped_info->handle);
-
- list_del_init(&buf_pending->list);
- kfree(buf_pending);
- break;
- }
- }
- }
-}
-
-static int msm_isp_buf_prepare(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_isp_qbuf_info *info, struct vb2_buffer *vb2_buf)
-{
- int rc = -1;
- unsigned long flags;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
- struct msm_isp_qbuf_buffer buf;
-
- buf_info = msm_isp_get_buf_ptr(buf_mgr,
- info->handle, info->buf_idx);
- if (!buf_info) {
- pr_err("Invalid buffer prepare\n");
- return rc;
- }
-
- bufq = msm_isp_get_bufq(buf_mgr, buf_info->bufq_handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return rc;
- }
-
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- if (buf_info->state == MSM_ISP_BUFFER_STATE_DIVERTED) {
- rc = buf_info->state;
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
- }
-
- if (buf_info->state != MSM_ISP_BUFFER_STATE_INITIALIZED) {
- pr_err("%s: Invalid buffer state: %d\n",
- __func__, buf_info->state);
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
- }
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
-
- if (vb2_buf) {
- msm_isp_copy_planes_from_v4l2_buffer(&buf, &vb2_buf->v4l2_buf);
- buf_info->vb2_buf = vb2_buf;
- } else {
- buf = info->buffer;
- }
-
- rc = msm_isp_prepare_isp_buf(buf_mgr, buf_info, &buf);
- if (rc < 0) {
- pr_err("%s: Prepare buffer error\n", __func__);
- return rc;
- }
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- buf_info->state = MSM_ISP_BUFFER_STATE_PREPARED;
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
-}
-
-static int msm_isp_buf_unprepare(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t buf_handle)
-{
- int rc = -1, i;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
-
- bufq = msm_isp_get_bufq(buf_mgr, buf_handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return rc;
- }
-
- for (i = 0; i < bufq->num_bufs; i++) {
- buf_info = msm_isp_get_buf_ptr(buf_mgr, buf_handle, i);
- if (!buf_info) {
- pr_err("%s: buf not found\n", __func__);
- return rc;
- }
- if (buf_info->state == MSM_ISP_BUFFER_STATE_UNUSED ||
- buf_info->state ==
- MSM_ISP_BUFFER_STATE_INITIALIZED)
- continue;
-
- if (MSM_ISP_BUFFER_SRC_HAL == BUF_SRC(bufq->stream_id)) {
- if (buf_info->state == MSM_ISP_BUFFER_STATE_DEQUEUED ||
- buf_info->state == MSM_ISP_BUFFER_STATE_DIVERTED)
- buf_mgr->vb2_ops->put_buf(buf_info->vb2_buf,
- bufq->session_id, bufq->stream_id);
- }
- msm_isp_unprepare_v4l2_buf(buf_mgr, buf_info);
- }
- return 0;
-}
-
-static int msm_isp_get_buf_by_index(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index,
- struct msm_isp_buffer **buf_info)
-{
- int rc = -EINVAL;
- unsigned long flags;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *temp_buf_info;
- uint32_t i = 0;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return rc;
- }
-
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- if (buf_index >= bufq->num_bufs) {
- pr_err("%s: Invalid buf index: %d max: %d\n", __func__,
- buf_index, bufq->num_bufs);
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
- }
-
- *buf_info = NULL;
- for (i = 0; bufq->num_bufs; i++) {
- temp_buf_info = &bufq->bufs[i];
- if (temp_buf_info && temp_buf_info->buf_idx == buf_index) {
- *buf_info = temp_buf_info;
- break;
- }
- }
-
- if (*buf_info) {
- pr_debug("Found buf in isp buf mgr");
- rc = 0;
- }
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
-}
-
-
-static int msm_isp_get_buf(struct msm_isp_buf_mgr *buf_mgr, uint32_t id,
- uint32_t bufq_handle, struct msm_isp_buffer **buf_info)
-{
- int rc = -1;
- unsigned long flags;
- struct msm_isp_buffer *temp_buf_info;
- struct msm_isp_bufq *bufq = NULL;
- struct vb2_buffer *vb2_buf = NULL;
- struct buffer_cmd *buf_pending = NULL;
- struct msm_isp_buffer_mapped_info *mped_info_tmp1;
- struct msm_isp_buffer_mapped_info *mped_info_tmp2;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return rc;
- }
- if (!bufq->bufq_handle) {
- pr_err("%s: Invalid bufq handle\n", __func__);
- return rc;
- }
-
- *buf_info = NULL;
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- if (bufq->buf_type == ISP_SHARE_BUF) {
- list_for_each_entry(temp_buf_info,
- &bufq->share_head, share_list) {
- if (!temp_buf_info->buf_used[id]) {
- temp_buf_info->buf_used[id] = 1;
- temp_buf_info->buf_get_count++;
- if (temp_buf_info->buf_get_count ==
- bufq->buf_client_count)
- list_del_init(
- &temp_buf_info->share_list);
- if (temp_buf_info->buf_reuse_flag) {
- kfree(temp_buf_info);
- } else {
- *buf_info = temp_buf_info;
- rc = 0;
- }
- spin_unlock_irqrestore(
- &bufq->bufq_lock, flags);
- return rc;
- }
- }
- }
-
- switch (BUF_SRC(bufq->stream_id)) {
- case MSM_ISP_BUFFER_SRC_NATIVE:
- list_for_each_entry(temp_buf_info, &bufq->head, list) {
- if (temp_buf_info->state ==
- MSM_ISP_BUFFER_STATE_QUEUED) {
-
- list_for_each_entry(buf_pending,
- &buf_mgr->buffer_q, list) {
- if (!buf_pending)
- break;
- mped_info_tmp1 =
- buf_pending->mapped_info;
- mped_info_tmp2 =
- &temp_buf_info->mapped_info[0];
-
- if (mped_info_tmp1 == mped_info_tmp2
- && (mped_info_tmp1->len ==
- mped_info_tmp2->len)
- && (mped_info_tmp1->paddr ==
- mped_info_tmp2->paddr)){
- /* found one buf */
- list_del_init(
- &temp_buf_info->list);
- *buf_info = temp_buf_info;
- break;
- }
- }
- break;
- }
- }
- break;
- case MSM_ISP_BUFFER_SRC_HAL:
- vb2_buf = buf_mgr->vb2_ops->get_buf(
- bufq->session_id, bufq->stream_id);
- if (vb2_buf) {
- if (vb2_buf->v4l2_buf.index < bufq->num_bufs) {
-
- list_for_each_entry(buf_pending,
- &buf_mgr->buffer_q, list) {
- if (!buf_pending)
- break;
- mped_info_tmp1 =
- buf_pending->mapped_info;
- mped_info_tmp2 =
- &bufq->bufs[vb2_buf->v4l2_buf.index]
- .mapped_info[0];
-
- if (mped_info_tmp1 == mped_info_tmp2
- && (mped_info_tmp1->len ==
- mped_info_tmp2->len)
- && (mped_info_tmp1->paddr ==
- mped_info_tmp2->paddr)) {
- *buf_info =
- &bufq->bufs[vb2_buf->v4l2_buf.index];
- (*buf_info)->vb2_buf = vb2_buf;
- break;
- }
- }
- } else {
- pr_err("%s: Incorrect buf index %d\n",
- __func__, vb2_buf->v4l2_buf.index);
- rc = -EINVAL;
- }
- }
- break;
- case MSM_ISP_BUFFER_SRC_SCRATCH:
- /* In scratch buf case we have only on buffer in queue.
- * We return every time same buffer. */
- *buf_info = list_entry(bufq->head.next, typeof(**buf_info),
- list);
- break;
- default:
- pr_err("%s: Incorrect buf source.\n", __func__);
- rc = -EINVAL;
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
- }
-
- if (!(*buf_info)) {
- if (bufq->buf_type == ISP_SHARE_BUF) {
- temp_buf_info = kzalloc(
- sizeof(struct msm_isp_buffer), GFP_ATOMIC);
- if (temp_buf_info) {
- temp_buf_info->buf_reuse_flag = 1;
- temp_buf_info->buf_used[id] = 1;
- temp_buf_info->buf_get_count = 1;
- list_add_tail(&temp_buf_info->share_list,
- &bufq->share_head);
- *buf_info = temp_buf_info;
- } else
- rc = -ENOMEM;
- }
- } else {
- (*buf_info)->state = MSM_ISP_BUFFER_STATE_DEQUEUED;
- if (bufq->buf_type == ISP_SHARE_BUF) {
- memset((*buf_info)->buf_used, 0,
- sizeof(uint8_t) * bufq->buf_client_count);
- (*buf_info)->buf_used[id] = 1;
- (*buf_info)->buf_get_count = 1;
- (*buf_info)->buf_put_count = 0;
- (*buf_info)->buf_reuse_flag = 0;
- list_add_tail(&(*buf_info)->share_list,
- &bufq->share_head);
- }
- rc = 0;
- }
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
-}
-
-static int msm_isp_put_buf(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index)
-{
- int rc = -1;
- unsigned long flags;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return rc;
- }
-
- buf_info = msm_isp_get_buf_ptr(buf_mgr, bufq_handle, buf_index);
- if (!buf_info) {
- pr_err("%s: buf not found\n", __func__);
- return rc;
- }
-
-
- buf_info->buf_get_count = 0;
- buf_info->buf_put_count = 0;
- memset(buf_info->buf_used, 0, sizeof(buf_info->buf_used));
-
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- switch (buf_info->state) {
- case MSM_ISP_BUFFER_STATE_PREPARED:
- if (MSM_ISP_BUFFER_SRC_SCRATCH == BUF_SRC(bufq->stream_id))
- list_add_tail(&buf_info->list, &bufq->head);
- case MSM_ISP_BUFFER_STATE_DEQUEUED:
- case MSM_ISP_BUFFER_STATE_DIVERTED:
- if (MSM_ISP_BUFFER_SRC_NATIVE == BUF_SRC(bufq->stream_id))
- list_add_tail(&buf_info->list, &bufq->head);
- else if (MSM_ISP_BUFFER_SRC_HAL == BUF_SRC(bufq->stream_id))
- buf_mgr->vb2_ops->put_buf(buf_info->vb2_buf,
- bufq->session_id, bufq->stream_id);
- buf_info->state = MSM_ISP_BUFFER_STATE_QUEUED;
- rc = 0;
- break;
- case MSM_ISP_BUFFER_STATE_DISPATCHED:
- buf_info->state = MSM_ISP_BUFFER_STATE_QUEUED;
- rc = 0;
- break;
- case MSM_ISP_BUFFER_STATE_QUEUED:
- rc = 0;
- break;
- default:
- pr_err("%s: incorrect state = %d",
- __func__, buf_info->state);
- break;
- }
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
-
- return rc;
-}
-
-static int msm_isp_put_buf_unsafe(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index)
-{
- int rc = -1;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return rc;
- }
-
- buf_info = msm_isp_get_buf_ptr(buf_mgr, bufq_handle, buf_index);
- if (!buf_info) {
- pr_err("%s: buf not found\n", __func__);
- return rc;
- }
-
- switch (buf_info->state) {
- case MSM_ISP_BUFFER_STATE_PREPARED:
- case MSM_ISP_BUFFER_STATE_DEQUEUED:
- case MSM_ISP_BUFFER_STATE_DIVERTED:
- if (BUF_SRC(bufq->stream_id))
- list_add_tail(&buf_info->list, &bufq->head);
- else
- buf_mgr->vb2_ops->put_buf(buf_info->vb2_buf,
- bufq->session_id, bufq->stream_id);
- buf_info->state = MSM_ISP_BUFFER_STATE_QUEUED;
- rc = 0;
- break;
- case MSM_ISP_BUFFER_STATE_DISPATCHED:
- buf_info->state = MSM_ISP_BUFFER_STATE_QUEUED;
- rc = 0;
- break;
- case MSM_ISP_BUFFER_STATE_QUEUED:
- rc = 0;
- break;
- default:
- pr_err("%s: incorrect state = %d",
- __func__, buf_info->state);
- break;
- }
-
- return rc;
-}
-
-static int msm_isp_buf_done(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index,
- struct timeval *tv, uint32_t frame_id, uint32_t output_format)
-{
- int rc = -1;
- unsigned long flags;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
- enum msm_isp_buffer_state state;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("Invalid bufq\n");
- return rc;
- }
-
- buf_info = msm_isp_get_buf_ptr(buf_mgr, bufq_handle, buf_index);
- if (!buf_info) {
- pr_err("%s: buf not found\n", __func__);
- return rc;
- }
-
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- state = buf_info->state;
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
-
- if (state == MSM_ISP_BUFFER_STATE_DEQUEUED ||
- state == MSM_ISP_BUFFER_STATE_DIVERTED) {
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- if (bufq->buf_type == ISP_SHARE_BUF) {
- buf_info->buf_put_count++;
- if (buf_info->buf_put_count != ISP_SHARE_BUF_CLIENT) {
- rc = buf_info->buf_put_count;
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
- }
- }
- buf_info->state = MSM_ISP_BUFFER_STATE_DISPATCHED;
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- if (MSM_ISP_BUFFER_SRC_HAL == BUF_SRC(bufq->stream_id)) {
- buf_info->vb2_buf->v4l2_buf.timestamp = *tv;
- buf_info->vb2_buf->v4l2_buf.sequence = frame_id;
- buf_info->vb2_buf->v4l2_buf.reserved = output_format;
- buf_mgr->vb2_ops->buf_done(buf_info->vb2_buf,
- bufq->session_id, bufq->stream_id,
- frame_id, tv, output_format);
- } else {
- rc = msm_isp_put_buf(buf_mgr, buf_info->bufq_handle,
- buf_info->buf_idx);
- if (rc < 0) {
- pr_err("%s: Buf put failed\n", __func__);
- return rc;
- }
- }
- }
-
- return 0;
-}
-
-static int msm_isp_flush_buf(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, enum msm_isp_buffer_flush_t flush_type)
-{
- int rc = -1, i;
- unsigned long flags;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("Invalid bufq\n");
- return rc;
- }
-
- for (i = 0; i < bufq->num_bufs; i++) {
- buf_info = msm_isp_get_buf_ptr(buf_mgr, bufq_handle, i);
- if (!buf_info) {
- pr_err("%s: buf not found\n", __func__);
- continue;
- }
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- if (flush_type == MSM_ISP_BUFFER_FLUSH_DIVERTED &&
- buf_info->state == MSM_ISP_BUFFER_STATE_DIVERTED) {
- buf_info->state = MSM_ISP_BUFFER_STATE_QUEUED;
- } else if (flush_type == MSM_ISP_BUFFER_FLUSH_ALL) {
- if (buf_info->state == MSM_ISP_BUFFER_STATE_DIVERTED) {
- CDBG("%s: no need to queue Diverted buffer\n",
- __func__);
- } else if (buf_info->state ==
- MSM_ISP_BUFFER_STATE_DEQUEUED) {
- if (buf_info->buf_get_count ==
- ISP_SHARE_BUF_CLIENT) {
- msm_isp_put_buf_unsafe(buf_mgr,
- bufq_handle, buf_info->buf_idx);
- } else {
- buf_info->state =
- MSM_ISP_BUFFER_STATE_DEQUEUED;
- buf_info->buf_get_count = 0;
- buf_info->buf_put_count = 0;
- memset(buf_info->buf_used, 0,
- sizeof(uint8_t) * 2);
- }
- }
- }
-
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- }
-
- return 0;
-}
-
-static int msm_isp_buf_divert(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index,
- struct timeval *tv, uint32_t frame_id)
-{
- int rc = -1;
- unsigned long flags;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("Invalid bufq\n");
- return rc;
- }
-
- buf_info = msm_isp_get_buf_ptr(buf_mgr, bufq_handle, buf_index);
- if (!buf_info) {
- pr_err("%s: buf not found\n", __func__);
- return rc;
- }
-
- spin_lock_irqsave(&bufq->bufq_lock, flags);
- if (bufq->buf_type == ISP_SHARE_BUF) {
- buf_info->buf_put_count++;
- if (buf_info->buf_put_count != ISP_SHARE_BUF_CLIENT) {
- rc = buf_info->buf_put_count;
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
- return rc;
- }
- }
-
- if (buf_info->state == MSM_ISP_BUFFER_STATE_DEQUEUED) {
- buf_info->state = MSM_ISP_BUFFER_STATE_DIVERTED;
- buf_info->tv = tv;
- buf_info->frame_id = frame_id;
- }
- spin_unlock_irqrestore(&bufq->bufq_lock, flags);
-
- return 0;
-}
-
-static int msm_isp_buf_enqueue(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_isp_qbuf_info *info)
-{
- int rc = -1, buf_state;
- struct msm_isp_bufq *bufq = NULL;
- struct msm_isp_buffer *buf_info = NULL;
-
- buf_state = msm_isp_buf_prepare(buf_mgr, info, NULL);
- if (buf_state < 0) {
- pr_err("%s: Buf prepare failed\n", __func__);
- return -EINVAL;
- }
-
- if (buf_state == MSM_ISP_BUFFER_STATE_DIVERTED) {
- buf_info = msm_isp_get_buf_ptr(buf_mgr,
- info->handle, info->buf_idx);
- if (!buf_info) {
- pr_err("%s: buf not found\n", __func__);
- return rc;
- }
- if (info->dirty_buf) {
- rc = msm_isp_put_buf(buf_mgr,
- info->handle, info->buf_idx);
- } else {
- bufq = msm_isp_get_bufq(buf_mgr, info->handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return rc;
- }
- if (BUF_SRC(bufq->stream_id))
- pr_err("%s: Invalid native buffer state\n",
- __func__);
- else
- rc = msm_isp_buf_done(buf_mgr,
- info->handle, info->buf_idx,
- buf_info->tv, buf_info->frame_id, 0);
- }
- } else {
- bufq = msm_isp_get_bufq(buf_mgr, info->handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return rc;
- }
- if (MSM_ISP_BUFFER_SRC_HAL != BUF_SRC(bufq->stream_id)) {
- rc = msm_isp_put_buf(buf_mgr,
- info->handle, info->buf_idx);
- if (rc < 0) {
- pr_err("%s: Buf put failed\n", __func__);
- return rc;
- }
- }
- }
- return rc;
-}
-
-static int msm_isp_get_bufq_handle(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t session_id, uint32_t stream_id)
-{
- int i;
-
- for (i = 0; i < buf_mgr->num_buf_q; i++) {
- if (buf_mgr->bufq[i].session_id == session_id &&
- buf_mgr->bufq[i].stream_id == stream_id) {
- return buf_mgr->bufq[i].bufq_handle;
- }
- }
- pr_err("%s: No match found 0x%x 0x%x\n", __func__,
- session_id, stream_id);
- return 0;
-}
-
-static int msm_isp_get_buf_src(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t *buf_src)
-{
- struct msm_isp_bufq *bufq = NULL;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("%s: Invalid bufq\n", __func__);
- return -EINVAL;
- }
- *buf_src = BUF_SRC(bufq->stream_id);
-
- return 0;
-}
-
-static int msm_isp_request_bufq(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_isp_buf_request *buf_request)
-{
- int rc = -1, i;
- struct msm_isp_bufq *bufq = NULL;
-
- CDBG("%s: E\n", __func__);
-
- if (!buf_request->num_buf || buf_request->num_buf > VIDEO_MAX_FRAME) {
- pr_err("Invalid buffer request\n");
- return rc;
- }
-
- buf_request->handle = msm_isp_get_buf_handle(buf_mgr,
- buf_request->session_id, buf_request->stream_id);
- if (!buf_request->handle) {
- pr_err("Invalid buffer handle\n");
- return rc;
- }
-
- bufq = msm_isp_get_bufq(buf_mgr, buf_request->handle);
- if (!bufq) {
- pr_err("Invalid buffer queue\n");
- return rc;
- }
-
- bufq->bufs = kzalloc(sizeof(struct msm_isp_buffer) *
- buf_request->num_buf, GFP_KERNEL);
- if (!bufq->bufs) {
- msm_isp_free_buf_handle(buf_mgr, buf_request->handle);
- return rc;
- }
-
- spin_lock_init(&bufq->bufq_lock);
- bufq->bufq_handle = buf_request->handle;
- bufq->session_id = buf_request->session_id;
- bufq->stream_id = buf_request->stream_id;
- bufq->num_bufs = buf_request->num_buf;
- bufq->buf_type = buf_request->buf_type;
- if (bufq->buf_type == ISP_SHARE_BUF)
- bufq->buf_client_count = ISP_SHARE_BUF_CLIENT;
- INIT_LIST_HEAD(&bufq->head);
- INIT_LIST_HEAD(&bufq->share_head);
- for (i = 0; i < buf_request->num_buf; i++) {
- bufq->bufs[i].state = MSM_ISP_BUFFER_STATE_INITIALIZED;
- bufq->bufs[i].bufq_handle = bufq->bufq_handle;
- bufq->bufs[i].buf_idx = i;
- }
-
- return 0;
-}
-
-static int msm_isp_release_bufq(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle)
-{
- struct msm_isp_bufq *bufq = NULL;
- int rc = -1;
-
- bufq = msm_isp_get_bufq(buf_mgr, bufq_handle);
- if (!bufq) {
- pr_err("Invalid bufq release\n");
- return rc;
- }
-
- msm_isp_buf_unprepare(buf_mgr, bufq_handle);
-
- kfree(bufq->bufs);
- msm_isp_free_buf_handle(buf_mgr, bufq_handle);
- return 0;
-}
-
-static void msm_isp_release_all_bufq(
- struct msm_isp_buf_mgr *buf_mgr)
-{
- struct msm_isp_bufq *bufq = NULL;
- int i;
-
- for (i = 0; i < buf_mgr->num_buf_q; i++) {
- bufq = &buf_mgr->bufq[i];
- if (!bufq->bufq_handle)
- continue;
- msm_isp_buf_unprepare(buf_mgr, bufq->bufq_handle);
-
- kfree(bufq->bufs);
- msm_isp_free_buf_handle(buf_mgr, bufq->bufq_handle);
- }
-}
-
-static void msm_isp_register_ctx(struct msm_isp_buf_mgr *buf_mgr,
- struct device **iommu_ctx1, struct device **iommu_ctx2,
- int num_iommu_ctx, int secure_num_iommu_ctx)
-{
- int i;
-
- buf_mgr->num_iommu_ctx = num_iommu_ctx;
- for (i = 0; i < num_iommu_ctx; i++)
- buf_mgr->iommu_ctx[i] = iommu_ctx1[i];
-
- buf_mgr->num_iommu_secure_ctx = secure_num_iommu_ctx;
- for (i = 0; i < secure_num_iommu_ctx; i++)
- buf_mgr->iommu_secure_ctx[i] = iommu_ctx2[i];
-}
-
-static int msm_isp_attach_ctx(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_vfe_smmu_attach_cmd *cmd)
-{
- int rc, i;
-
- if (cmd->security_mode == NON_SECURE_MODE) {
- /*non secure mode*/
- for (i = 0; i < buf_mgr->num_iommu_ctx; i++) {
-
- if (buf_mgr->attach_ref_cnt[NON_SECURE_MODE][i] == 0) {
- /* attach only once */
- rc = iommu_attach_device(
- buf_mgr->iommu_domain,
- buf_mgr->iommu_ctx[i]);
- if (rc) {
- pr_err("%s: non-secure attach error bank: %d, rc : %d\n",
- __func__, i, rc);
- return -EINVAL;
- }
- }
- buf_mgr->attach_ref_cnt[NON_SECURE_MODE][i]++;
- }
- } else {
- /*secure mode*/
- for (i = 0; i < buf_mgr->num_iommu_secure_ctx; i++) {
-
- if (buf_mgr->attach_ref_cnt[SECURE_MODE][i] == 0) {
- /* attach only once */
- rc = iommu_attach_device(
- buf_mgr->iommu_domain_secure,
- buf_mgr->iommu_secure_ctx[i]);
- if (rc) {
- pr_err("%s: secure attach error bank: %d, rc : %d\n",
- __func__, i, rc);
- return -EINVAL;
- }
- }
- buf_mgr->attach_ref_cnt[SECURE_MODE][i]++;
- }
- }
- buf_mgr->attach_state = MSM_ISP_BUF_MGR_ATTACH;
- return 0;
-}
-
-static int msm_isp_detach_ctx(struct msm_isp_buf_mgr *buf_mgr)
-{
- int i;
-
- if (buf_mgr->attach_state == MSM_ISP_BUF_MGR_DETACH ||
- buf_mgr->open_count)
- return 0;
-
- if (buf_mgr->secure_enable == NON_SECURE_MODE) {
- /*non secure mode*/
- for (i = 0; i < buf_mgr->num_iommu_ctx; i++) {
- /*Detach only if ref count is one*/
- if (buf_mgr->attach_ref_cnt[NON_SECURE_MODE][i] == 1) {
- iommu_detach_device(buf_mgr->iommu_domain,
- buf_mgr->iommu_ctx[i]);
- }
- if (buf_mgr->attach_ref_cnt[NON_SECURE_MODE][i] > 0)
- --buf_mgr->attach_ref_cnt[NON_SECURE_MODE][i];
- }
- } else {
- /*secure mode*/
- for (i = 0; i < buf_mgr->num_iommu_secure_ctx; i++) {
- /*Detach only if ref count is one*/
- if (buf_mgr->attach_ref_cnt[SECURE_MODE][i] == 1) {
- iommu_detach_device(
- buf_mgr->iommu_domain_secure,
- buf_mgr->iommu_secure_ctx[i]);
- }
- if (buf_mgr->attach_ref_cnt[SECURE_MODE][i] > 0)
- --buf_mgr->attach_ref_cnt[SECURE_MODE][i];
- }
- }
- buf_mgr->attach_state = MSM_ISP_BUF_MGR_DETACH;
- return 0;
-}
-
-int msm_isp_smmu_attach(struct msm_isp_buf_mgr *buf_mgr,
- void *arg)
-{
- struct msm_vfe_smmu_attach_cmd *cmd = arg;
- int rc = 0;
-
- pr_debug("%s: cmd->security_mode : %d\n", __func__, cmd->security_mode);
- if (cmd->iommu_attach_mode == IOMMU_ATTACH) {
- buf_mgr->secure_enable = cmd->security_mode;
- rc = msm_isp_attach_ctx(buf_mgr, cmd);
- if (rc < 0) {
- pr_err("%s: smmu attach error, rc :%d\n", __func__, rc);
- goto iommu_error;
- }
- } else
- msm_isp_detach_ctx(buf_mgr);
-
-iommu_error:
- return rc;
-}
-
-
-static int msm_isp_init_isp_buf_mgr(
- struct msm_isp_buf_mgr *buf_mgr,
- const char *ctx_name, uint16_t num_buf_q)
-{
- int rc = -1;
-
- if (buf_mgr->open_count++)
- return 0;
-
- if (!num_buf_q) {
- pr_err("Invalid buffer queue number\n");
- return rc;
- }
- CDBG("%s: E\n", __func__);
-
- INIT_LIST_HEAD(&buf_mgr->buffer_q);
- buf_mgr->num_buf_q = num_buf_q;
- buf_mgr->bufq =
- kzalloc(sizeof(struct msm_isp_bufq) * num_buf_q,
- GFP_KERNEL);
- if (!buf_mgr->bufq) {
- pr_err("Bufq malloc error\n");
- goto bufq_error;
- }
- buf_mgr->client = msm_ion_client_create(ctx_name);
- buf_mgr->buf_handle_cnt = 0;
- buf_mgr->pagefault_debug = 0;
- return 0;
-bufq_error:
- return rc;
-}
-
-static int msm_isp_deinit_isp_buf_mgr(
- struct msm_isp_buf_mgr *buf_mgr)
-{
- if (buf_mgr->open_count > 0)
- buf_mgr->open_count--;
-
- if (buf_mgr->open_count)
- return 0;
- msm_isp_release_all_bufq(buf_mgr);
- ion_client_destroy(buf_mgr->client);
- kfree(buf_mgr->bufq);
- buf_mgr->num_buf_q = 0;
- buf_mgr->pagefault_debug = 0;
- msm_isp_detach_ctx(buf_mgr);
- return 0;
-}
-
-int msm_isp_proc_buf_cmd(struct msm_isp_buf_mgr *buf_mgr,
- unsigned int cmd, void *arg)
-{
- switch (cmd) {
- case VIDIOC_MSM_ISP_REQUEST_BUF: {
- struct msm_isp_buf_request *buf_req = arg;
-
- buf_mgr->ops->request_buf(buf_mgr, buf_req);
- break;
- }
- case VIDIOC_MSM_ISP_ENQUEUE_BUF: {
- struct msm_isp_qbuf_info *qbuf_info = arg;
-
- buf_mgr->ops->enqueue_buf(buf_mgr, qbuf_info);
- break;
- }
- case VIDIOC_MSM_ISP_RELEASE_BUF: {
- struct msm_isp_buf_request *buf_req = arg;
-
- buf_mgr->ops->release_buf(buf_mgr, buf_req->handle);
- break;
- }
- }
- return 0;
-}
-
-int msm_isp_buf_mgr_debug(struct msm_isp_buf_mgr *buf_mgr)
-{
- struct msm_isp_buffer *bufs = NULL;
- uint32_t i = 0, j = 0, k = 0, rc = 0;
-
- if (!buf_mgr) {
- pr_err_ratelimited("%s: %d] NULL buf_mgr\n",
- __func__, __LINE__);
- return -EINVAL;
- }
- for (i = 0; i < BUF_MGR_NUM_BUF_Q; i++) {
- if (buf_mgr->bufq[i].bufq_handle != 0) {
- pr_err("%s:%d handle %x\n", __func__, i,
- buf_mgr->bufq[i].bufq_handle);
- pr_err("%s:%d session_id %d, stream_id %x,",
- __func__, i, buf_mgr->bufq[i].session_id,
- buf_mgr->bufq[i].stream_id);
- pr_err("num_bufs %d, handle %x, type %d\n",
- buf_mgr->bufq[i].num_bufs,
- buf_mgr->bufq[i].bufq_handle,
- buf_mgr->bufq[i].buf_type);
- for (j = 0; j < buf_mgr->bufq[i].num_bufs; j++) {
- bufs = &buf_mgr->bufq[i].bufs[j];
- if (!bufs) {
- pr_err("bufs at %d is NULL breaking\n",
- j);
- break;
- }
- pr_err("%s:%d buf_idx %d, frame_id %d,",
- __func__, j, bufs->buf_idx,
- bufs->frame_id);
- pr_err("num_planes %d, state %d\n",
- bufs->num_planes, bufs->state);
- for (k = 0; k < bufs->num_planes; k++) {
- pr_err("%s:%d paddr %x, len %lu,",
- __func__, k, (unsigned int)
- bufs->mapped_info[k].paddr,
- bufs->mapped_info[k].len);
- pr_err(" ion handle %pK\n",
- bufs->mapped_info[k].handle);
- }
- }
- }
- }
- buf_mgr->pagefault_debug = 1;
- return rc;
-}
-
-static struct msm_isp_buf_ops isp_buf_ops = {
- .request_buf = msm_isp_request_bufq,
- .enqueue_buf = msm_isp_buf_enqueue,
- .release_buf = msm_isp_release_bufq,
- .get_bufq_handle = msm_isp_get_bufq_handle,
- .get_buf_src = msm_isp_get_buf_src,
- .get_buf = msm_isp_get_buf,
- .get_buf_by_index = msm_isp_get_buf_by_index,
- .put_buf = msm_isp_put_buf,
- .flush_buf = msm_isp_flush_buf,
- .buf_done = msm_isp_buf_done,
- .buf_divert = msm_isp_buf_divert,
- .register_ctx = msm_isp_register_ctx,
- .buf_mgr_init = msm_isp_init_isp_buf_mgr,
- .buf_mgr_deinit = msm_isp_deinit_isp_buf_mgr,
- .buf_mgr_debug = msm_isp_buf_mgr_debug,
- .get_bufq = msm_isp_get_bufq,
-};
-
-int msm_isp_create_isp_buf_mgr(
- struct msm_isp_buf_mgr *buf_mgr,
- struct msm_sd_req_vb2_q *vb2_ops,
- struct msm_iova_layout *iova_layout)
-{
- int rc = 0;
- int i = 0, j = 0;
-
- if (buf_mgr->init_done)
- return rc;
-
- buf_mgr->iommu_domain_num = msm_register_domain(iova_layout);
- if (buf_mgr->iommu_domain_num < 0) {
- pr_err("%s: Invalid iommu domain number\n", __func__);
- rc = -1;
- goto iommu_domain_error;
- }
-
- buf_mgr->iommu_domain = msm_get_iommu_domain(
- buf_mgr->iommu_domain_num);
- if (!buf_mgr->iommu_domain) {
- pr_err("%s: Invalid iommu domain\n", __func__);
- rc = -1;
- goto iommu_domain_error;
- }
- buf_mgr->ops = &isp_buf_ops;
- buf_mgr->vb2_ops = vb2_ops;
- buf_mgr->open_count = 0;
- buf_mgr->pagefault_debug = 0;
- buf_mgr->secure_enable = NON_SECURE_MODE;
- buf_mgr->attach_state = MSM_ISP_BUF_MGR_DETACH;
-
- for (i = 0; i < MAX_PROTECTION_MODE; i++)
- for (j = 0; j < MAX_IOMMU_CTX; j++)
- buf_mgr->attach_ref_cnt[i][j] = 0;
- return 0;
-iommu_domain_error:
- return rc;
-}
-
-int msm_isp_create_secure_domain(
- struct msm_isp_buf_mgr *buf_mgr,
- struct msm_iova_layout *iova_layout)
-{
- int rc = 0;
-
- if (buf_mgr->init_done)
- return rc;
- buf_mgr->iommu_domain_num_secure = msm_register_domain(iova_layout);
- if (buf_mgr->iommu_domain_num_secure < 0) {
- pr_err("%s: Invalid iommu domain number\n", __func__);
- rc = -1;
- goto iommu_domain_error;
- }
-
- buf_mgr->iommu_domain_secure = msm_get_iommu_domain(
- buf_mgr->iommu_domain_num_secure);
- if (!buf_mgr->iommu_domain_secure) {
- pr_err("%s: Invalid iommu domain\n", __func__);
- rc = -1;
- goto iommu_domain_error;
- }
- return 0;
-iommu_domain_error:
- return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr_32.h b/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr_32.h
deleted file mode 100644
index e1b442ce1208..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_buf_mgr_32.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef _MSM_ISP_BUF_H_
-#define _MSM_ISP_BUF_H_
-
-#include <media/msmb_isp.h>
-#include <linux/msm_iommu_domains.h>
-#include "msm_sd.h"
-
-/* Buffer type could be userspace / HAL.
- * Userspase could provide native or scratch buffer. */
-#define BUF_SRC(id) ( \
- (id & ISP_SCRATCH_BUF_BIT) ? MSM_ISP_BUFFER_SRC_SCRATCH : \
- (id & ISP_NATIVE_BUF_BIT) ? MSM_ISP_BUFFER_SRC_NATIVE : \
- MSM_ISP_BUFFER_SRC_HAL)
-
-#define ISP_SHARE_BUF_CLIENT 2
-#define BUF_MGR_NUM_BUF_Q 28
-#define MAX_IOMMU_CTX 2
-
-struct msm_isp_buf_mgr;
-
-enum msm_isp_buffer_src_t {
- MSM_ISP_BUFFER_SRC_HAL,
- MSM_ISP_BUFFER_SRC_NATIVE,
- MSM_ISP_BUFFER_SRC_SCRATCH,
- MSM_ISP_BUFFER_SRC_MAX,
-};
-
-enum msm_isp_buffer_state {
- MSM_ISP_BUFFER_STATE_UNUSED, /* not used */
- MSM_ISP_BUFFER_STATE_INITIALIZED, /* REQBUF done */
- MSM_ISP_BUFFER_STATE_PREPARED, /* BUF mapped */
- MSM_ISP_BUFFER_STATE_QUEUED, /* buf queued */
- MSM_ISP_BUFFER_STATE_DEQUEUED, /* in use in VFE */
- MSM_ISP_BUFFER_STATE_DIVERTED, /* Sent to other hardware*/
- MSM_ISP_BUFFER_STATE_DISPATCHED, /* Sent to HAL*/
-};
-
-enum msm_isp_buffer_flush_t {
- MSM_ISP_BUFFER_FLUSH_DIVERTED,
- MSM_ISP_BUFFER_FLUSH_ALL,
-};
-
-enum msm_isp_buf_mgr_state {
- MSM_ISP_BUF_MGR_ATTACH,
- MSM_ISP_BUF_MGR_DETACH,
-};
-
-struct msm_isp_buffer_mapped_info {
- unsigned long len;
- dma_addr_t paddr;
- struct ion_handle *handle;
-};
-
-struct buffer_cmd {
- struct list_head list;
- struct msm_isp_buffer_mapped_info *mapped_info;
-};
-
-struct msm_isp_buffer {
- /*Common Data structure*/
- int num_planes;
- struct msm_isp_buffer_mapped_info mapped_info[VIDEO_MAX_PLANES];
- int buf_idx;
- uint32_t bufq_handle;
- uint32_t frame_id;
- struct timeval *tv;
-
- /*Native buffer*/
- struct list_head list;
- enum msm_isp_buffer_state state;
-
- /*Vb2 buffer data*/
- struct vb2_buffer *vb2_buf;
-
- /*Share buffer cache state*/
- struct list_head share_list;
- uint8_t buf_used[ISP_SHARE_BUF_CLIENT];
- uint8_t buf_get_count;
- uint8_t buf_put_count;
- uint8_t buf_reuse_flag;
-};
-
-struct msm_isp_bufq {
- uint32_t session_id;
- uint32_t stream_id;
- uint32_t num_bufs;
- uint32_t bufq_handle;
- enum msm_isp_buf_type buf_type;
- struct msm_isp_buffer *bufs;
- spinlock_t bufq_lock;
-
- /*Native buffer queue*/
- struct list_head head;
- /*Share buffer cache queue*/
- struct list_head share_head;
- uint8_t buf_client_count;
-};
-
-struct msm_isp_buf_ops {
- int (*request_buf)(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_isp_buf_request *buf_request);
-
- int (*enqueue_buf)(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_isp_qbuf_info *info);
-
- int (*release_buf)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle);
-
- int (*get_bufq_handle)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t session_id, uint32_t stream_id);
-
- int (*get_buf_src)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t *buf_src);
-
- int (*get_buf)(struct msm_isp_buf_mgr *buf_mgr, uint32_t id,
- uint32_t bufq_handle, struct msm_isp_buffer **buf_info);
-
- int (*get_buf_by_index)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index,
- struct msm_isp_buffer **buf_info);
-
- int (*put_buf)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index);
-
- int (*flush_buf)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, enum msm_isp_buffer_flush_t flush_type);
-
- int (*buf_done)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index,
- struct timeval *tv, uint32_t frame_id, uint32_t output_format);
- int (*buf_divert)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle, uint32_t buf_index,
- struct timeval *tv, uint32_t frame_id);
- void (*register_ctx)(struct msm_isp_buf_mgr *buf_mgr,
- struct device **iommu_ctx1, struct device **iommu_ctx2,
- int num_iommu_ctx1, int num_iommu_ctx2);
- int (*buf_mgr_init)(struct msm_isp_buf_mgr *buf_mgr,
- const char *ctx_name, uint16_t num_buf_q);
- int (*buf_mgr_deinit)(struct msm_isp_buf_mgr *buf_mgr);
- int (*buf_mgr_debug)(struct msm_isp_buf_mgr *buf_mgr);
- struct msm_isp_bufq * (*get_bufq)(struct msm_isp_buf_mgr *buf_mgr,
- uint32_t bufq_handle);
-};
-
-struct msm_isp_buf_mgr {
- int init_done;
- uint32_t open_count;
- uint32_t pagefault_debug;
- spinlock_t lock;
- uint16_t num_buf_q;
- struct msm_isp_bufq *bufq;
-
- struct ion_client *client;
- struct msm_isp_buf_ops *ops;
- uint32_t buf_handle_cnt;
-
- struct msm_sd_req_vb2_q *vb2_ops;
-
- /*IOMMU specific*/
- int iommu_domain_num;
- struct iommu_domain *iommu_domain;
-
- /*Add secure domain num and domain */
- int iommu_domain_num_secure;
- struct iommu_domain *iommu_domain_secure;
-
- /*Add secure mode*/
- int secure_enable;
-
- int num_iommu_ctx;
- struct device *iommu_ctx[2];
- struct list_head buffer_q;
- int num_iommu_secure_ctx;
- struct device *iommu_secure_ctx[2];
- int attach_ref_cnt[MAX_PROTECTION_MODE][MAX_IOMMU_CTX];
- enum msm_isp_buf_mgr_state attach_state;
-};
-
-int msm_isp_create_isp_buf_mgr(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_sd_req_vb2_q *vb2_ops, struct msm_iova_layout *iova_layout);
-
-int msm_isp_proc_buf_cmd(struct msm_isp_buf_mgr *buf_mgr,
- unsigned int cmd, void *arg);
-
-int msm_isp_create_secure_domain(struct msm_isp_buf_mgr *buf_mgr,
- struct msm_iova_layout *iova_layout);
-
-int msm_isp_smmu_attach(struct msm_isp_buf_mgr *buf_mgr,
- void *arg);
-
-#endif /* _MSM_ISP_BUF_H_ */
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp.c
index 40c343014501..834bb5234bfb 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp.c
@@ -437,69 +437,11 @@ static long msm_isp_v4l2_fops_ioctl(struct file *file, unsigned int cmd,
return video_usercopy(file, cmd, arg, msm_isp_subdev_do_ioctl);
}
-static void isp_vma_open(struct vm_area_struct *vma)
-{
- pr_debug("%s: open called\n", __func__);
-}
-
-static void isp_vma_close(struct vm_area_struct *vma)
-{
- pr_debug("%s: close called\n", __func__);
-}
-
-static int isp_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
-{
- struct page *page;
- struct vfe_device *vfe_dev = vma->vm_private_data;
- struct isp_proc *isp_page = NULL;
-
- isp_page = vfe_dev->isp_page;
-
- pr_debug("%s: vfeid:%d u_virt_addr:0x%lx k_virt_addr:%pK\n",
- __func__, vfe_dev->pdev->id, vma->vm_start,
- (void *)isp_page);
- if (isp_page != NULL) {
- page = virt_to_page(isp_page);
- get_page(page);
- vmf->page = page;
- isp_page->kernel_sofid =
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
- isp_page->vfeid = vfe_dev->pdev->id;
- }
- return 0;
-}
-
-static const struct vm_operations_struct isp_vm_ops = {
- .open = isp_vma_open,
- .close = isp_vma_close,
- .fault = isp_vma_fault,
-};
-
-static int msm_isp_v4l2_fops_mmap(struct file *filep,
- struct vm_area_struct *vma)
-{
- int ret = -EINVAL;
- struct video_device *vdev = video_devdata(filep);
- struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
- struct vfe_device *vfe_dev = v4l2_get_subdevdata(sd);
-
- vma->vm_ops = &isp_vm_ops;
- vma->vm_flags |=
- (unsigned long)(VM_DONTEXPAND | VM_DONTDUMP);
- vma->vm_private_data = vfe_dev;
- isp_vma_open(vma);
- ret = 0;
- pr_debug("%s: isp mmap is called vm_start: 0x%lx\n",
- __func__, vma->vm_start);
- return ret;
-}
-
static struct v4l2_file_operations msm_isp_v4l2_fops = {
#ifdef CONFIG_COMPAT
.compat_ioctl32 = msm_isp_v4l2_fops_ioctl,
#endif
- .unlocked_ioctl = msm_isp_v4l2_fops_ioctl,
- .mmap = msm_isp_v4l2_fops_mmap
+ .unlocked_ioctl = msm_isp_v4l2_fops_ioctl
};
static int vfe_set_common_data(struct platform_device *pdev)
@@ -670,8 +612,6 @@ int vfe_hw_probe(struct platform_device *pdev)
msm_isp_v4l2_fops.compat_ioctl32 =
msm_isp_v4l2_fops_ioctl;
#endif
- msm_isp_v4l2_fops.mmap = msm_isp_v4l2_fops_mmap;
-
vfe_dev->subdev.sd.devnode->fops = &msm_isp_v4l2_fops;
vfe_dev->buf_mgr = &vfe_buf_mgr;
@@ -690,14 +630,6 @@ int vfe_hw_probe(struct platform_device *pdev)
vfe_dev->hw_info->num_iommu_secure_ctx;
vfe_dev->buf_mgr->init_done = 1;
vfe_dev->vfe_open_cnt = 0;
- /*Allocate a page in kernel and map it to camera user process*/
- vfe_dev->isp_page = (struct isp_proc *)get_zeroed_page(GFP_KERNEL);
- if (vfe_dev->isp_page == NULL) {
- pr_err("%s: no enough memory\n", __func__);
- rc = -ENOMEM;
- goto probe_fail3;
- }
- vfe_dev->isp_page->vfeid = vfe_dev->pdev->id;
return rc;
probe_fail3:
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp.h
index f1cf72e53b6d..09fc9c8aaac9 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp.h
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp.h
@@ -134,8 +134,6 @@ struct msm_isp_timestamp {
};
struct msm_vfe_irq_ops {
- void (*read_irq_status_and_clear)(struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1);
void (*read_irq_status)(struct vfe_device *vfe_dev,
uint32_t *irq_status0, uint32_t *irq_status1);
void (*process_reg_update)(struct vfe_device *vfe_dev,
@@ -187,7 +185,6 @@ struct msm_vfe_axi_ops {
struct msm_vfe_axi_stream *stream_info);
void (*clear_wm_irq_mask)(struct vfe_device *vfe_dev,
struct msm_vfe_axi_stream *stream_info);
- void (*clear_irq_mask)(struct vfe_device *vfe_dev);
void (*cfg_wm_reg)(struct vfe_device *vfe_dev,
struct msm_vfe_axi_stream *stream_info,
@@ -448,10 +445,9 @@ struct msm_vfe_axi_stream {
uint32_t runtime_num_burst_capture;
uint32_t runtime_output_format;
- enum msm_stream_rdi_input_type rdi_input_type;
+ enum msm_stream_memory_input_t memory_input;
struct msm_isp_sw_framskip sw_skip;
uint8_t sw_ping_pong_bit;
- uint8_t sw_sof_ping_pong_bit;
};
struct msm_vfe_axi_composite_info {
@@ -468,7 +464,6 @@ enum msm_vfe_camif_state {
struct msm_vfe_src_info {
uint32_t frame_id;
- uint32_t session_id;
uint32_t reg_update_frame_id;
uint8_t active;
uint8_t flag;
@@ -484,6 +479,7 @@ struct msm_vfe_src_info {
enum msm_vfe_dual_hw_type dual_hw_type;
struct msm_vfe_dual_hw_ms_info dual_hw_ms_info;
uint32_t eof_id;
+ bool accept_frame;
};
struct msm_vfe_fetch_engine_info {
@@ -703,11 +699,6 @@ struct msm_vfe_common_subdev {
struct msm_vfe_common_dev_data *common_data;
};
-struct isp_proc {
- uint32_t kernel_sofid;
- uint32_t vfeid;
-};
-
struct vfe_device {
/* Driver private data */
struct platform_device *pdev;
@@ -792,10 +783,7 @@ struct vfe_device {
/* before halt irq info */
uint32_t recovery_irq0_mask;
uint32_t recovery_irq1_mask;
- /* Store the buf_idx for pd stats RDI stream */
- uint8_t pd_buf_idx;
uint32_t ms_frame_id;
- struct isp_proc *isp_page;
};
struct vfe_parent_device {
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp32.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp32.c
index 97c34528868e..a0195a934c83 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp32.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp32.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -12,17 +12,21 @@
#include <linux/module.h>
#include <linux/platform_device.h>
-#include <linux/qcom_iommu.h>
#include "msm_isp32.h"
-#include "msm_isp_util_32.h"
-#include "msm_isp_axi_util_32.h"
-#include "msm_isp_stats_util_32.h"
-#include "msm_isp_32.h"
+#include "msm_isp_util.h"
+#include "msm_isp_axi_util.h"
+#include "msm_isp_stats_util.h"
+#include "msm_isp.h"
#include "msm.h"
#include "msm_camera_io_util.h"
-#define VFE32_BURST_LEN 3
+static const struct platform_device_id msm_vfe32_dev_id[] = {
+ {"msm_vfe32", (kernel_ulong_t) &vfe32_hw_info},
+ {}
+};
+
+#define VFE32_BURST_LEN 2
#define VFE32_UB_SIZE 1024
#define VFE32_UB_SIZE_32KB 2048
#define VFE32_EQUAL_SLICE_UB 194
@@ -32,7 +36,7 @@
#define VFE32_XBAR_BASE(idx) (0x40 + 0x4 * (idx / 4))
#define VFE32_XBAR_SHIFT(idx) ((idx % 4) * 8)
#define VFE32_PING_PONG_BASE(wm, ping_pong) \
- (VFE32_WM_BASE(wm) + 0x4 * (1 + (~(ping_pong >> wm) & 0x1)))
+ (VFE32_WM_BASE(wm) + 0x4 * (1 + ((~ping_pong) & 0x1)))
static uint8_t stats_pingpong_offset_map[] = {
7, 8, 9, 10, 11, 12, 13};
@@ -56,6 +60,16 @@ static struct msm_cam_clk_info msm_vfe32_2_clk_info[] = {
{"csi_vfe_clk", -1},
};
+static uint32_t msm_vfe32_ub_reg_offset(struct vfe_device *vfe_dev, int idx)
+{
+ return (VFE32_WM_BASE(idx) + 0xC);
+}
+
+static uint32_t msm_vfe32_get_ub_size(struct vfe_device *vfe_dev)
+{
+ return MSM_ISP32_TOTAL_WM_UB;
+}
+
static int32_t msm_vfe32_init_qos_parms(struct vfe_device *vfe_dev,
struct msm_vfe_hw_init_parms *qos_parms,
struct msm_vfe_hw_init_parms *ds_parms)
@@ -276,6 +290,8 @@ static int msm_vfe32_init_hardware(struct vfe_device *vfe_dev)
pr_err("%s: vfe ioremap failed\n", __func__);
goto vfe_remap_failed;
}
+ vfe_dev->common_data->dual_vfe_res->vfe_base[vfe_dev->pdev->id] =
+ vfe_dev->vfe_base;
vfe_dev->vfe_vbif_base = ioremap(vfe_dev->vfe_vbif_mem->start,
resource_size(vfe_dev->vfe_vbif_mem));
@@ -320,12 +336,14 @@ bus_scale_register_failed:
static void msm_vfe32_release_hardware(struct vfe_device *vfe_dev)
{
+ msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x1C);
+ msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x20);
+ disable_irq(vfe_dev->vfe_irq->start);
free_irq(vfe_dev->vfe_irq->start, vfe_dev);
tasklet_kill(&vfe_dev->vfe_tasklet);
+ msm_isp_flush_tasklet(vfe_dev);
iounmap(vfe_dev->vfe_vbif_base);
vfe_dev->vfe_vbif_base = NULL;
- iounmap(vfe_dev->vfe_base);
- vfe_dev->vfe_base = NULL;
if (vfe_dev->vfe_clk_idx == 1)
msm_cam_clk_enable(&vfe_dev->pdev->dev,
msm_vfe32_1_clk_info, vfe_dev->vfe_clk,
@@ -334,6 +352,9 @@ static void msm_vfe32_release_hardware(struct vfe_device *vfe_dev)
msm_cam_clk_enable(&vfe_dev->pdev->dev,
msm_vfe32_2_clk_info, vfe_dev->vfe_clk,
ARRAY_SIZE(msm_vfe32_2_clk_info), 0);
+ vfe_dev->common_data->dual_vfe_res->vfe_base[vfe_dev->pdev->id] = NULL;
+ iounmap(vfe_dev->vfe_base);
+ vfe_dev->vfe_base = NULL;
kfree(vfe_dev->vfe_clk);
regulator_disable(vfe_dev->fs_vfe);
msm_isp_deinit_bandwidth_mgr(ISP_VFE0 + vfe_dev->pdev->id);
@@ -366,11 +387,6 @@ static void msm_vfe32_init_hardware_reg(struct vfe_device *vfe_dev)
msm_camera_io_w_mb(0x1CFFFFFF, vfe_dev->vfe_base + 0x20);
msm_camera_io_w(0xFFFFFFFF, vfe_dev->vfe_base + 0x24);
msm_camera_io_w_mb(0x1FFFFFFF, vfe_dev->vfe_base + 0x28);
- msm_camera_io_w(0x0, vfe_dev->vfe_base + 0x6FC);
- msm_camera_io_w(0x10000000, vfe_dev->vfe_base + VFE32_RDI_BASE(1));
- msm_camera_io_w(0x10000000, vfe_dev->vfe_base + VFE32_RDI_BASE(2));
- msm_camera_io_w(0x0, vfe_dev->vfe_base + VFE32_XBAR_BASE(0));
- msm_camera_io_w(0x0, vfe_dev->vfe_base + VFE32_XBAR_BASE(4));
}
@@ -386,30 +402,13 @@ static void msm_vfe32_clear_status_reg(struct vfe_device *vfe_dev)
static void msm_vfe32_process_reset_irq(struct vfe_device *vfe_dev,
uint32_t irq_status0, uint32_t irq_status1)
{
- if (irq_status1 & BIT(23)) {
- if (vfe_dev->vfe_reset_timeout_processed == 1) {
- pr_err("%s:vfe reset was processed.\n", __func__);
- return;
- }
+ if (irq_status1 & BIT(23))
complete(&vfe_dev->reset_complete);
- }
}
static void msm_vfe32_process_halt_irq(struct vfe_device *vfe_dev,
uint32_t irq_status0, uint32_t irq_status1)
{
- if (irq_status1 & (1 << 24))
- msm_camera_io_w_mb(0, vfe_dev->vfe_base + 0x1D8);
-}
-
-static void msm_vfe32_process_epoch_irq(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts)
-{
- if (!(irq_status0 & 0x18))
- return;
- if (irq_status0 & (1 << 3))
- msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_PIX_0, ts);
}
static void msm_vfe32_process_camif_irq(struct vfe_device *vfe_dev,
@@ -425,10 +424,9 @@ static void msm_vfe32_process_camif_irq(struct vfe_device *vfe_dev,
&& vfe_dev->axi_data.src_info[VFE_PIX_0].
pix_stream_count == 0) {
msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_PIX_0, ts);
- if (vfe_dev->axi_data.stream_update)
- msm_isp_axi_stream_update(vfe_dev,
- (1 << VFE_PIX_0));
- msm_isp_update_framedrop_reg(vfe_dev, (1 << VFE_PIX_0));
+ if (vfe_dev->axi_data.stream_update[VFE_PIX_0])
+ msm_isp_axi_stream_update(vfe_dev, VFE_PIX_0);
+ msm_isp_update_framedrop_reg(vfe_dev, VFE_PIX_0);
}
}
}
@@ -493,20 +491,7 @@ static void msm_vfe32_process_violation_status(struct vfe_device *vfe_dev)
static void msm_vfe32_get_overflow_mask(uint32_t *overflow_mask)
{
- *overflow_mask = 0x003FFF7E;
-}
-
-static void msm_vfe32_get_rdi_wm_mask(struct vfe_device *vfe_dev,
- uint32_t *rdi_wm_mask)
-{
- *rdi_wm_mask = vfe_dev->axi_data.rdi_wm_mask;
-}
-
-static void msm_vfe32_get_irq_mask(struct vfe_device *vfe_dev,
- uint32_t *irq0_mask, uint32_t *irq1_mask)
-{
- *irq0_mask = msm_camera_io_r(vfe_dev->vfe_base + 0x1C);
- *irq1_mask = msm_camera_io_r(vfe_dev->vfe_base + 0x20);
+ *overflow_mask = 0x0;
}
static void msm_vfe32_process_error_status(struct vfe_device *vfe_dev)
@@ -614,114 +599,104 @@ static void msm_vfe32_process_reg_update(struct vfe_device *vfe_dev,
uint32_t irq_status0, uint32_t irq_status1,
struct msm_isp_timestamp *ts)
{
- uint8_t input_src = 0x0;
+ uint32_t rdi_status;
+ enum msm_vfe_input_src i;
+
if (!(irq_status0 & 0x20) && !(irq_status1 & 0x1C000000))
return;
if (irq_status0 & BIT(5)) {
- msm_isp_notify(vfe_dev, ISP_EVENT_REG_UPDATE, VFE_PIX_0, ts);
- input_src |= (1 << VFE_PIX_0);
- }
- if (irq_status1 & BIT(26)) {
- msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_RAW_0, ts);
- input_src |= (1 << VFE_RAW_0);
- }
- if (irq_status1 & BIT(27)) {
- msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_RAW_1, ts);
- input_src |= (1 << VFE_RAW_1);
- }
- if (irq_status1 & BIT(28)) {
- msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_RAW_2, ts);
- input_src |= (1 << VFE_RAW_2);
+ msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_PIX_0, ts);
+ vfe_dev->hw_info->vfe_ops.core_ops.reg_update(vfe_dev,
+ VFE_PIX_0);
+ if (vfe_dev->axi_data.stream_update[VFE_PIX_0]) {
+ rdi_status = msm_camera_io_r(vfe_dev->vfe_base +
+ VFE32_XBAR_BASE(0));
+ rdi_status |= msm_camera_io_r(vfe_dev->vfe_base +
+ VFE32_XBAR_BASE(4));
+
+ if ((rdi_status & BIT(7)) && (!(irq_status0 & 0x20)))
+ return;
+ }
+ if (atomic_read(&vfe_dev->stats_data.stats_update))
+ msm_isp_stats_stream_update(vfe_dev);
}
- if (vfe_dev->axi_data.stream_update)
- msm_isp_axi_stream_update(vfe_dev, input_src);
- if (atomic_read(&vfe_dev->stats_data.stats_update))
- msm_isp_stats_stream_update(vfe_dev);
- if (vfe_dev->axi_data.stream_update ||
- atomic_read(&vfe_dev->stats_data.stats_update)) {
- if (input_src & (1 << VFE_PIX_0)) {
- vfe_dev->hw_info->vfe_ops.core_ops.
- reg_update(vfe_dev, (1 << VFE_PIX_0));
+ for (i = VFE_RAW_0; i <= VFE_RAW_2; i++) {
+ if (irq_status1 & BIT(26 + (i - VFE_RAW_0))) {
+ msm_isp_notify(vfe_dev, ISP_EVENT_SOF, i, ts);
+ if (vfe_dev->axi_data.stream_update[i])
+ msm_isp_axi_stream_update(vfe_dev, i);
+ msm_isp_update_framedrop_reg(vfe_dev, i);
+
+ vfe_dev->hw_info->vfe_ops.core_ops.reg_update(vfe_dev,
+ i);
}
}
- msm_isp_update_framedrop_reg(vfe_dev, input_src);
- msm_isp_update_stats_framedrop_reg(vfe_dev);
+
msm_isp_update_error_frame_count(vfe_dev);
- if ((input_src & (1 << VFE_RAW_0)) ||
- (input_src & (1 << VFE_RAW_1)) ||
- (input_src & (1 << VFE_RAW_2))) {
- vfe_dev->hw_info->vfe_ops.core_ops.
- reg_update(vfe_dev, input_src);
- }
return;
}
-static void msm_vfe32_reg_update(
- struct vfe_device *vfe_dev, uint32_t input_src)
+static void msm_vfe32_process_epoch_irq(struct vfe_device *vfe_dev,
+ uint32_t irq_status0, uint32_t irq_status1,
+ struct msm_isp_timestamp *ts)
{
- msm_camera_io_w_mb(input_src, vfe_dev->vfe_base + 0x260);
+ /* Not supported */
}
-static long msm_vfe32_reset_hardware(struct vfe_device *vfe_dev,
- uint32_t first_start, uint32_t blocking)
+static void msm_vfe32_reg_update(struct vfe_device *vfe_dev,
+ enum msm_vfe_input_src frame_src)
{
- long rc = 0;
- uint32_t irq_status1;
-
- if (blocking) {
- init_completion(&vfe_dev->reset_complete);
- msm_camera_io_w_mb(0x3FF, vfe_dev->vfe_base + 0x4);
- vfe_dev->vfe_reset_timeout_processed = 0;
- rc = wait_for_completion_timeout(
- &vfe_dev->reset_complete, msecs_to_jiffies(500));
- } else {
- msm_camera_io_w_mb(0x3FF, vfe_dev->vfe_base + 0x4);
+ if (vfe_dev->is_split && vfe_dev->pdev->id == ISP_VFE1) {
+ msm_camera_io_w_mb(0xF,
+ vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]
+ + 0x260);
+ msm_camera_io_w_mb(0xF, vfe_dev->vfe_base + 0x260);
+ } else if (!vfe_dev->is_split) {
+ msm_camera_io_w_mb(0xF, vfe_dev->vfe_base + 0x260);
}
+}
- if (blocking && rc <= 0) {
- /*read ISP status register*/
- irq_status1 = msm_camera_io_r(vfe_dev->vfe_base + 0x30);
- pr_err("%s: handling vfe reset time out error. irq_status1 0x%x\n",
- __func__, irq_status1);
- if (irq_status1 & BIT(23)) {
- pr_err("%s: vfe reset has done actually\n", __func__);
- vfe_dev->vfe_reset_timeout_processed = 1;
- return 1;
- }
- }
- return rc;
+static long msm_vfe32_reset_hardware(struct vfe_device *vfe_dev,
+ uint32_t first_start, uint32_t blocking)
+{
+ init_completion(&vfe_dev->reset_complete);
+ msm_camera_io_w_mb(0x3FF, vfe_dev->vfe_base + 0x4);
+ return wait_for_completion_timeout(
+ &vfe_dev->reset_complete, msecs_to_jiffies(50));
}
static void msm_vfe32_axi_reload_wm(
- struct vfe_device *vfe_dev, uint32_t reload_mask)
+ struct vfe_device *vfe_dev, void __iomem *vfe_base,
+ uint32_t reload_mask)
{
if (!vfe_dev->pdev->dev.of_node) {
/*vfe32 A-family: 8960*/
- msm_camera_io_w_mb(reload_mask, vfe_dev->vfe_base + 0x38);
+ msm_camera_io_w_mb(reload_mask, vfe_base + 0x38);
} else {
/*vfe32 B-family: 8610*/
- msm_camera_io_w(0x0, vfe_dev->vfe_base + 0x28);
- msm_camera_io_w(0x1C800000, vfe_dev->vfe_base + 0x20);
- msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x18);
- msm_camera_io_w(0x9AAAAAAA , vfe_dev->vfe_base + 0x600);
- msm_camera_io_w(reload_mask, vfe_dev->vfe_base + 0x38);
+ msm_camera_io_w(0x0, vfe_base + 0x24);
+ msm_camera_io_w(0x0, vfe_base + 0x28);
+ msm_camera_io_w(0x0, vfe_base + 0x20);
+ msm_camera_io_w_mb(0x1, vfe_base + 0x18);
+ msm_camera_io_w(0x9AAAAAAA , vfe_base + 0x600);
+ msm_camera_io_w(reload_mask, vfe_base + 0x38);
}
}
-static void msm_vfe32_axi_enable_wm(struct vfe_device *vfe_dev,
+static void msm_vfe32_axi_enable_wm(void __iomem *vfe_base,
uint8_t wm_idx, uint8_t enable)
{
uint32_t val = msm_camera_io_r(
- vfe_dev->vfe_base + VFE32_WM_BASE(wm_idx));
+ vfe_base + VFE32_WM_BASE(wm_idx));
if (enable)
val |= 0x1;
else
val &= ~0x1;
msm_camera_io_w_mb(val,
- vfe_dev->vfe_base + VFE32_WM_BASE(wm_idx));
+ vfe_base + VFE32_WM_BASE(wm_idx));
}
static void msm_vfe32_axi_cfg_comp_mask(struct vfe_device *vfe_dev,
@@ -776,34 +751,22 @@ static void msm_vfe32_axi_clear_wm_irq_mask(struct vfe_device *vfe_dev,
msm_camera_io_w(irq_mask, vfe_dev->vfe_base + 0x1C);
}
-static void msm_vfe32_cfg_framedrop(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info)
+static void msm_vfe32_cfg_framedrop(void __iomem *vfe_base,
+ struct msm_vfe_axi_stream *stream_info, uint32_t framedrop_pattern,
+ uint32_t framedrop_period)
{
- uint32_t framedrop_pattern = 0, framedrop_period = 0;
-
- if (stream_info->runtime_init_frame_drop == 0) {
- framedrop_pattern = stream_info->framedrop_pattern;
- framedrop_period = stream_info->framedrop_period;
- }
-
- if (stream_info->stream_type == BURST_STREAM &&
- stream_info->runtime_burst_frame_count == 0) {
- framedrop_pattern = 0;
- framedrop_period = 0;
- }
-
if (stream_info->stream_src == PIX_ENCODER) {
- msm_camera_io_w(framedrop_period, vfe_dev->vfe_base + 0x504);
- msm_camera_io_w(framedrop_period, vfe_dev->vfe_base + 0x508);
- msm_camera_io_w(framedrop_pattern, vfe_dev->vfe_base + 0x50C);
- msm_camera_io_w(framedrop_pattern, vfe_dev->vfe_base + 0x510);
+ msm_camera_io_w(framedrop_period - 1, vfe_base + 0x504);
+ msm_camera_io_w(framedrop_period - 1, vfe_base + 0x508);
+ msm_camera_io_w(framedrop_pattern, vfe_base + 0x50C);
+ msm_camera_io_w(framedrop_pattern, vfe_base + 0x510);
} else if (stream_info->stream_src == PIX_VIEWFINDER) {
- msm_camera_io_w(framedrop_period, vfe_dev->vfe_base + 0x514);
- msm_camera_io_w(framedrop_period, vfe_dev->vfe_base + 0x518);
- msm_camera_io_w(framedrop_pattern, vfe_dev->vfe_base + 0x51C);
- msm_camera_io_w(framedrop_pattern, vfe_dev->vfe_base + 0x520);
+ msm_camera_io_w(framedrop_period - 1, vfe_base + 0x514);
+ msm_camera_io_w(framedrop_period - 1, vfe_base + 0x518);
+ msm_camera_io_w(framedrop_pattern, vfe_base + 0x51C);
+ msm_camera_io_w(framedrop_pattern, vfe_base + 0x520);
}
- msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x260);
+ msm_camera_io_w_mb(0x1, vfe_base + 0x260);
}
static void msm_vfe32_clear_framedrop(struct vfe_device *vfe_dev,
@@ -967,9 +930,9 @@ static void msm_vfe32_update_camif_state(
if (update_state == ENABLE_CAMIF) {
val = msm_camera_io_r(vfe_dev->vfe_base + 0x1C);
- val |= 0x19;
+ val |= 0x1;
msm_camera_io_w_mb(val, vfe_dev->vfe_base + 0x1C);
- msm_camera_io_w_mb(0xA, vfe_dev->vfe_base + 0x200);
+
val = msm_camera_io_r(vfe_dev->vfe_base + 0x1E4);
bus_en =
((vfe_dev->axi_data.src_info[
@@ -980,7 +943,6 @@ static void msm_vfe32_update_camif_state(
val &= 0xFFFFFF3F;
val = val | bus_en << 7 | vfe_en << 6;
msm_camera_io_w(val, vfe_dev->vfe_base + 0x1E4);
- msm_camera_io_w_mb(0x4, vfe_dev->vfe_base + 0x1E0);
msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x1E0);
vfe_dev->axi_data.src_info[VFE_PIX_0].active = 1;
} else if (update_state == DISABLE_CAMIF) {
@@ -1061,8 +1023,6 @@ static void msm_vfe32_axi_clear_wm_reg(
{
uint32_t val = 0;
uint32_t wm_base = VFE32_WM_BASE(stream_info->wm[plane_idx]);
- /* FRAME BASED */
- msm_camera_io_w(val, vfe_dev->vfe_base + wm_base);
/*WR_IMAGE_SIZE*/
msm_camera_io_w(val, vfe_dev->vfe_base + wm_base + 0x10);
/*WR_BUFFER_CFG*/
@@ -1138,94 +1098,20 @@ static void msm_vfe32_axi_clear_wm_xbar_reg(
msm_camera_io_w(xbar_reg_cfg, vfe_dev->vfe_base + VFE32_XBAR_BASE(wm));
}
-static void msm_vfe32_cfg_axi_ub_equal_default(struct vfe_device *vfe_dev)
-{
- int i;
- uint32_t ub_offset = 0;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- uint32_t total_image_size = 0;
- uint32_t num_used_wms = 0;
- uint32_t prop_size = 0;
- uint32_t wm_ub_size;
- uint64_t delta;
-
- for (i = 0; i < axi_data->hw_info->num_wm; i++) {
- if (axi_data->free_wm[i] > 0) {
- num_used_wms++;
- total_image_size += axi_data->wm_image_size[i];
- }
- }
- prop_size = MSM_ISP32_TOTAL_WM_UB -
- axi_data->hw_info->min_wm_ub * num_used_wms;
- for (i = 0; i < axi_data->hw_info->num_wm; i++) {
- if (axi_data->free_wm[i]) {
- delta =
- (uint64_t)(axi_data->wm_image_size[i] *
- prop_size);
- do_div(delta, total_image_size);
- wm_ub_size = axi_data->hw_info->min_wm_ub +
- (uint32_t)delta;
- msm_camera_io_w(ub_offset << 16 |
- (wm_ub_size - 1), vfe_dev->vfe_base +
- VFE32_WM_BASE(i) + 0xC);
- ub_offset += wm_ub_size;
- } else {
- msm_camera_io_w(0,
- vfe_dev->vfe_base + VFE32_WM_BASE(i) + 0xC);
- }
- }
-}
-
-static void msm_vfe32_cfg_axi_ub_equal_slicing(struct vfe_device *vfe_dev)
-{
- int i;
- uint32_t ub_offset = 0;
- uint32_t final_ub_slice_size;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
-
- for (i = 0; i < axi_data->hw_info->num_wm; i++) {
- if (ub_offset + VFE32_EQUAL_SLICE_UB > VFE32_AXI_SLICE_UB) {
- final_ub_slice_size = VFE32_AXI_SLICE_UB - ub_offset;
- msm_camera_io_w(ub_offset << 16 |
- (final_ub_slice_size - 1), vfe_dev->vfe_base +
- VFE32_WM_BASE(i) + 0xC);
- ub_offset += final_ub_slice_size;
- } else {
- msm_camera_io_w(ub_offset << 16 |
- (VFE32_EQUAL_SLICE_UB - 1), vfe_dev->vfe_base +
- VFE32_WM_BASE(i) + 0xC);
- ub_offset += VFE32_EQUAL_SLICE_UB;
- }
- }
-}
-
-static void msm_vfe32_cfg_axi_ub(struct vfe_device *vfe_dev)
-{
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
-
- axi_data->wm_ub_cfg_policy = MSM_WM_UB_CFG_DEFAULT;
- if (axi_data->wm_ub_cfg_policy == MSM_WM_UB_EQUAL_SLICING)
- msm_vfe32_cfg_axi_ub_equal_slicing(vfe_dev);
- else
- msm_vfe32_cfg_axi_ub_equal_default(vfe_dev);
-}
-
-static void msm_vfe32_update_ping_pong_addr(struct vfe_device *vfe_dev,
- uint8_t wm_idx, uint32_t pingpong_status, dma_addr_t paddr)
+static void msm_vfe32_update_ping_pong_addr(void __iomem *vfe_base,
+ uint8_t wm_idx, uint32_t pingpong_bit, dma_addr_t paddr,
+ int32_t buf_size)
{
uint32_t paddr32 = (paddr & 0xFFFFFFFF);
- msm_camera_io_w(paddr32, vfe_dev->vfe_base +
- VFE32_PING_PONG_BASE(wm_idx, pingpong_status));
+ msm_camera_io_w(paddr32, vfe_base +
+ VFE32_PING_PONG_BASE(wm_idx, pingpong_bit));
}
static int msm_vfe32_axi_halt(struct vfe_device *vfe_dev, uint32_t blocking)
{
+ uint32_t halt_mask;
uint32_t axi_busy_flag = true;
- /* Keep only halt and restart mask */
- msm_camera_io_w(0x01800000, vfe_dev->vfe_base + 0x20);
- /*Clear IRQ Status */
- msm_camera_io_w(0xFE7FFFFF, vfe_dev->vfe_base + 0x28);
msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x1D8);
while (axi_busy_flag) {
if (msm_camera_io_r(
@@ -1233,27 +1119,10 @@ static int msm_vfe32_axi_halt(struct vfe_device *vfe_dev, uint32_t blocking)
axi_busy_flag = false;
}
msm_camera_io_w_mb(0, vfe_dev->vfe_base + 0x1D8);
- return 0;
-}
-
-static int msm_vfe32_axi_restart(struct vfe_device *vfe_dev,
- uint32_t blocking, uint32_t enable_camif)
-{
- vfe_dev->hw_info->vfe_ops.core_ops.restore_irq_mask(vfe_dev);
-
- /*Clear IRQ Status */
- msm_camera_io_w(0xFE7FFFFF, vfe_dev->vfe_base + 0x28);
- msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x1D8);
- msm_camera_io_w_mb(0xA, vfe_dev->vfe_base + 0x200);
- /* Start AXI */
- msm_camera_io_w(0x0, vfe_dev->vfe_base + 0x1D8);
- vfe_dev->hw_info->vfe_ops.core_ops.reg_update(vfe_dev, 0xF);
- memset(&vfe_dev->error_info, 0, sizeof(vfe_dev->error_info));
- atomic_set(&vfe_dev->error_info.overflow_state, NO_OVERFLOW);
- if (enable_camif) {
- vfe_dev->hw_info->vfe_ops.core_ops.
- update_camif_state(vfe_dev, ENABLE_CAMIF);
- }
+ halt_mask = msm_camera_io_r(vfe_dev->vfe_base + 0x20);
+ halt_mask &= 0xFEFFFFFF;
+ /* Disable AXI IRQ */
+ msm_camera_io_w_mb(halt_mask, vfe_dev->vfe_base + 0x20);
return 0;
}
@@ -1307,24 +1176,8 @@ static int msm_vfe32_stats_check_streams(
}
static void msm_vfe32_stats_cfg_comp_mask(struct vfe_device *vfe_dev,
- uint32_t stats_mask, uint8_t enable)
+ uint32_t stats_mask, uint8_t comp_idx, uint8_t enable)
{
- uint32_t i = 0;
- atomic_t *stats_comp;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
-
- stats_mask = stats_mask & 0x7F;
-
- for (i = 0;
- i < vfe_dev->hw_info->stats_hw_info->num_stats_comp_mask; i++) {
- stats_comp = &stats_data->stats_comp_mask[i];
- if (enable)
- atomic_add(stats_mask, stats_comp);
- else
- atomic_sub(stats_mask, stats_comp);
- ISP_DBG("%s: comp_mask: %x\n",
- __func__, atomic_read(&stats_data->stats_comp_mask[i]));
- }
return;
}
@@ -1387,6 +1240,12 @@ static void msm_vfe32_stats_cfg_ub(struct vfe_device *vfe_dev)
return;
}
+static bool msm_vfe32_is_module_cfg_lock_needed(
+ uint32_t reg_offset)
+{
+ return false;
+}
+
static void msm_vfe32_stats_enable_module(struct vfe_device *vfe_dev,
uint32_t stats_mask, uint8_t enable)
{
@@ -1424,13 +1283,13 @@ static void msm_vfe32_stats_enable_module(struct vfe_device *vfe_dev,
msm_camera_io_w(module_cfg, vfe_dev->vfe_base + 0x10);
}
-static void msm_vfe32_stats_update_ping_pong_addr(struct vfe_device *vfe_dev,
+static void msm_vfe32_stats_update_ping_pong_addr(void __iomem *vfe_base,
struct msm_vfe_stats_stream *stream_info, uint32_t pingpong_status,
dma_addr_t paddr)
{
uint32_t paddr32 = (paddr & 0xFFFFFFFF);
int stats_idx = STATS_IDX(stream_info->stream_handle);
- msm_camera_io_w(paddr32, vfe_dev->vfe_base +
+ msm_camera_io_w(paddr32, vfe_base +
VFE32_STATS_PING_PONG_BASE(stats_idx, pingpong_status));
}
@@ -1521,27 +1380,13 @@ static void msm_vfe32_get_error_mask(uint32_t *error_mask0,
*error_mask1 = 0x007FFFFF;
}
-
-static void msm_vfe32_restore_irq_mask(struct vfe_device *vfe_dev)
-{
- msm_camera_io_w(vfe_dev->error_info.overflow_recover_irq_mask0,
- vfe_dev->vfe_base + 0x1C);
- msm_camera_io_w(vfe_dev->error_info.overflow_recover_irq_mask1,
- vfe_dev->vfe_base + 0x20);
-}
-
-static void msm_vfe32_get_halt_restart_mask(uint32_t *irq0_mask,
- uint32_t *irq1_mask)
-{
- *irq1_mask = 0x01800000;
-}
-
struct msm_vfe_axi_hardware_info msm_vfe32_axi_hw_info = {
- .num_wm = 6,
+ .num_wm = 5,
.num_comp_mask = 3,
.num_rdi = 3,
.num_rdi_master = 3,
.min_wm_ub = 64,
+ .scratch_buf_range = SZ_32M,
};
static struct msm_vfe_stats_hardware_info msm_vfe32_stats_hw_info = {
@@ -1553,22 +1398,7 @@ static struct msm_vfe_stats_hardware_info msm_vfe32_stats_hw_info = {
1 << MSM_ISP_STATS_SKIN | 1 << MSM_ISP_STATS_BHIST,
.stats_ping_pong_offset = stats_pingpong_offset_map,
.num_stats_type = VFE32_NUM_STATS_TYPE,
- .num_stats_comp_mask = 1,
-};
-
-static struct v4l2_subdev_core_ops msm_vfe32_subdev_core_ops = {
- .ioctl = msm_isp_ioctl,
- .subscribe_event = msm_isp_subscribe_event,
- .unsubscribe_event = msm_isp_unsubscribe_event,
-};
-
-static struct v4l2_subdev_ops msm_vfe32_subdev_ops = {
- .core = &msm_vfe32_subdev_core_ops,
-};
-
-static struct v4l2_subdev_internal_ops msm_vfe32_internal_ops = {
- .open = msm_isp_open_node,
- .close = msm_isp_close_node,
+ .num_stats_comp_mask = 0,
};
struct msm_vfe_hardware_info vfe32_hw_info = {
@@ -1582,9 +1412,9 @@ struct msm_vfe_hardware_info vfe32_hw_info = {
.process_reset_irq = msm_vfe32_process_reset_irq,
.process_halt_irq = msm_vfe32_process_halt_irq,
.process_reg_update = msm_vfe32_process_reg_update,
- .process_epoch_irq = msm_vfe32_process_epoch_irq,
.process_axi_irq = msm_isp_process_axi_irq,
.process_stats_irq = msm_isp_process_stats_irq,
+ .process_epoch_irq = msm_vfe32_process_epoch_irq,
},
.axi_ops = {
.reload_wm = msm_vfe32_axi_reload_wm,
@@ -1600,14 +1430,15 @@ struct msm_vfe_hardware_info vfe32_hw_info = {
.clear_wm_reg = msm_vfe32_axi_clear_wm_reg,
.cfg_wm_xbar_reg = msm_vfe32_axi_cfg_wm_xbar_reg,
.clear_wm_xbar_reg = msm_vfe32_axi_clear_wm_xbar_reg,
- .cfg_ub = msm_vfe32_cfg_axi_ub,
+ .cfg_ub = msm_vfe47_cfg_axi_ub,
.update_ping_pong_addr =
msm_vfe32_update_ping_pong_addr,
.get_comp_mask = msm_vfe32_get_comp_mask,
.get_wm_mask = msm_vfe32_get_wm_mask,
.get_pingpong_status = msm_vfe32_get_pingpong_status,
.halt = msm_vfe32_axi_halt,
- .restart = msm_vfe32_axi_restart,
+ .ub_reg_offset = msm_vfe32_ub_reg_offset,
+ .get_ub_size = msm_vfe32_get_ub_size,
},
.core_ops = {
.reg_update = msm_vfe32_reg_update,
@@ -1622,13 +1453,11 @@ struct msm_vfe_hardware_info vfe32_hw_info = {
.release_hw = msm_vfe32_release_hardware,
.get_platform_data = msm_vfe32_get_platform_data,
.get_error_mask = msm_vfe32_get_error_mask,
- .get_overflow_mask = msm_vfe32_get_overflow_mask,
- .get_rdi_wm_mask = msm_vfe32_get_rdi_wm_mask,
- .get_irq_mask = msm_vfe32_get_irq_mask,
- .restore_irq_mask = msm_vfe32_restore_irq_mask,
- .get_halt_restart_mask =
- msm_vfe32_get_halt_restart_mask,
.process_error_status = msm_vfe32_process_error_status,
+ .get_overflow_mask = msm_vfe32_get_overflow_mask,
+ .is_module_cfg_lock_needed =
+ msm_vfe32_is_module_cfg_lock_needed,
+ .ahb_clk_cfg = NULL,
},
.stats_ops = {
.get_stats_idx = msm_vfe32_get_stats_idx,
@@ -1646,12 +1475,47 @@ struct msm_vfe_hardware_info vfe32_hw_info = {
.get_wm_mask = msm_vfe32_stats_get_wm_mask,
.get_frame_id = msm_vfe32_stats_get_frame_id,
.get_pingpong_status = msm_vfe32_get_pingpong_status,
+ .enable_stats_wm = NULL,
},
},
.dmi_reg_offset = 0x5A0,
.axi_hw_info = &msm_vfe32_axi_hw_info,
.stats_hw_info = &msm_vfe32_stats_hw_info,
- .subdev_ops = &msm_vfe32_subdev_ops,
- .subdev_internal_ops = &msm_vfe32_internal_ops,
};
EXPORT_SYMBOL(vfe32_hw_info);
+
+static const struct of_device_id msm_vfe32_dt_match[] = {
+ {
+ .compatible = "qcom,vfe32",
+ .data = &vfe32_hw_info,
+ },
+ {}
+};
+
+MODULE_DEVICE_TABLE(of, msm_vfe32_dt_match);
+
+static struct platform_driver vfe32_driver = {
+ .probe = vfe_hw_probe,
+ .driver = {
+ .name = "msm_vfe32",
+ .owner = THIS_MODULE,
+ .of_match_table = msm_vfe32_dt_match,
+ },
+ .id_table = msm_vfe32_dev_id,
+};
+
+static int __init msm_vfe32_init_module(void)
+{
+ return platform_driver_register(&vfe32_driver);
+}
+
+static void __exit msm_vfe32_exit_module(void)
+{
+ platform_driver_unregister(&vfe32_driver);
+}
+
+module_init(msm_vfe32_init_module);
+module_exit(msm_vfe32_exit_module);
+MODULE_DESCRIPTION("MSM VFE32 driver");
+MODULE_LICENSE("GPL v2");
+
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp40.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp40.c
index f55a53cac4c3..fed18d70543e 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp40.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp40.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -34,13 +34,12 @@
#define VFE40_STATS_BURST_LEN_8916_VERSION 2
#define VFE40_FETCH_BURST_LEN 3
#define VFE40_UB_SIZE 1536 /* 1536 * 128 bits = 24KB */
-#define VFE40_STATS_SIZE 392
#define VFE40_UB_SIZE_8952 2048 /* 2048 * 128 bits = 32KB */
#define VFE40_UB_SIZE_8916 3072 /* 3072 * 128 bits = 48KB */
#define VFE40_EQUAL_SLICE_UB 190 /* (UB_SIZE - STATS SIZE)/6 */
#define VFE40_EQUAL_SLICE_UB_8916 236
#define VFE40_TOTAL_WM_UB 1144 /* UB_SIZE - STATS SIZE */
-#define VFE40_TOTAL_WM_UB_8916 2680
+#define VFE40_TOTAL_WM_UB_8916 1656
#define VFE40_WM_BASE(idx) (0x6C + 0x24 * idx)
#define VFE40_RDI_BASE(idx) (0x2E8 + 0x4 * idx)
#define VFE40_XBAR_BASE(idx) (0x58 + 0x4 * (idx / 2))
@@ -104,11 +103,7 @@ static uint32_t msm_vfe40_ub_reg_offset(struct vfe_device *vfe_dev, int idx)
static uint32_t msm_vfe40_get_ub_size(struct vfe_device *vfe_dev)
{
- if (vfe_dev->vfe_hw_version == VFE40_8916_VERSION ||
- vfe_dev->vfe_hw_version == VFE40_8939_VERSION ||
- vfe_dev->vfe_hw_version == VFE40_8937_VERSION ||
- vfe_dev->vfe_hw_version == VFE40_8953_VERSION ||
- vfe_dev->vfe_hw_version == VFE40_8917_VERSION) {
+ if (vfe_dev->vfe_hw_version == VFE40_8916_VERSION) {
vfe_dev->ub_info->wm_ub = VFE40_TOTAL_WM_UB_8916;
return VFE40_TOTAL_WM_UB_8916;
}
@@ -228,12 +223,12 @@ static int32_t msm_vfe40_init_qos_parms(struct vfe_device *vfe_dev,
__func__);
kfree(ds_settings);
kfree(ds_regs);
- } else {
+ } else {
for (i = 0; i < ds_entries; i++)
msm_camera_io_w(ds_settings[i],
vfebase + ds_regs[i]);
- kfree(ds_regs);
- kfree(ds_settings);
+ kfree(ds_regs);
+ kfree(ds_settings);
}
} else {
kfree(ds_regs);
@@ -580,7 +575,7 @@ static void msm_vfe40_process_error_status(struct vfe_device *vfe_dev)
msm_isp_update_last_overflow_ab_ib(vfe_dev);
}
-static void msm_vfe40_read_irq_status_and_clear(struct vfe_device *vfe_dev,
+static void msm_vfe40_read_irq_status(struct vfe_device *vfe_dev,
uint32_t *irq_status0, uint32_t *irq_status1)
{
*irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x38);
@@ -618,13 +613,6 @@ static void msm_vfe40_read_irq_status_and_clear(struct vfe_device *vfe_dev,
}
-static void msm_vfe40_read_irq_status(struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1)
-{
- *irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x38);
- *irq_status1 = msm_camera_io_r(vfe_dev->vfe_base + 0x3C);
-}
-
static void msm_vfe40_process_reg_update(struct vfe_device *vfe_dev,
uint32_t irq_status0, uint32_t irq_status1,
struct msm_isp_timestamp *ts)
@@ -726,12 +714,6 @@ static void msm_vfe40_reg_update(struct vfe_device *vfe_dev,
vfe_dev->reg_update_requested;
if ((vfe_dev->is_split && vfe_dev->pdev->id == ISP_VFE1) &&
((frame_src == VFE_PIX_0) || (frame_src == VFE_SRC_MAX))) {
- if (!vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]) {
- pr_err("%s vfe_base for ISP_VFE0 is NULL\n", __func__);
- spin_unlock_irqrestore(&vfe_dev->reg_update_lock,
- flags);
- return;
- }
msm_camera_io_w_mb(update_mask,
vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]
+ 0x378);
@@ -881,12 +863,6 @@ static void msm_vfe40_axi_clear_wm_irq_mask(struct vfe_device *vfe_dev,
MSM_ISP_IRQ_DISABLE);
}
-static void msm_vfe40_axi_clear_irq_mask(struct vfe_device *vfe_dev)
-{
- msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x28);
- msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x2C);
-}
-
static void msm_vfe40_cfg_framedrop(void __iomem *vfe_base,
struct msm_vfe_axi_stream *stream_info, uint32_t framedrop_pattern,
uint32_t framedrop_period)
@@ -1128,7 +1104,6 @@ static int msm_vfe40_start_fetch_engine_multi_pass(struct vfe_device *vfe_dev,
fe_cfg->stream_id);
vfe_dev->fetch_engine_info.bufq_handle = bufq_handle;
- mutex_lock(&vfe_dev->buf_mgr->lock);
rc = vfe_dev->buf_mgr->ops->get_buf_by_index(
vfe_dev->buf_mgr, bufq_handle, fe_cfg->buf_idx, &buf);
if (rc < 0 || !buf) {
@@ -1237,10 +1212,6 @@ static void msm_vfe40_cfg_fetch_engine(struct vfe_device *vfe_dev,
case V4L2_PIX_FMT_P16GBRG10:
case V4L2_PIX_FMT_P16GRBG10:
case V4L2_PIX_FMT_P16RGGB10:
- case V4L2_PIX_FMT_P16BGGR12:
- case V4L2_PIX_FMT_P16GBRG12:
- case V4L2_PIX_FMT_P16GRBG12:
- case V4L2_PIX_FMT_P16RGGB12:
main_unpack_pattern = 0xB210;
break;
default:
@@ -1821,18 +1792,11 @@ static int msm_vfe40_axi_restart(struct vfe_device *vfe_dev,
memset(&vfe_dev->error_info, 0, sizeof(vfe_dev->error_info));
atomic_set(&vfe_dev->error_info.overflow_state, NO_OVERFLOW);
- if (enable_camif &&
- vfe_dev->axi_data.src_info[VFE_PIX_0].input_mux
- != EXTERNAL_READ){
+ if (enable_camif) {
vfe_dev->hw_info->vfe_ops.core_ops.
update_camif_state(vfe_dev, ENABLE_CAMIF);
}
- if (vfe_dev->fetch_engine_info.is_busy == 1) {
- vfe_dev->fetch_engine_info.is_busy = 0;
- msm_camera_io_w_mb(0x1, vfe_dev->vfe_base + 0x378);
- msm_camera_io_w_mb(0x10000, vfe_dev->vfe_base + 0x4C);
- msm_camera_io_w_mb(0x20000, vfe_dev->vfe_base + 0x4C);
- }
+
return 0;
}
@@ -2230,8 +2194,6 @@ struct msm_vfe_hardware_info vfe40_hw_info = {
.vfe_ops = {
.irq_ops = {
.read_irq_status = msm_vfe40_read_irq_status,
- .read_irq_status_and_clear =
- msm_vfe40_read_irq_status_and_clear,
.process_camif_irq = msm_vfe40_process_input_irq,
.process_reset_irq = msm_vfe40_process_reset_irq,
.process_halt_irq = msm_vfe40_process_halt_irq,
@@ -2251,8 +2213,6 @@ struct msm_vfe_hardware_info vfe40_hw_info = {
.clear_comp_mask = msm_vfe40_axi_clear_comp_mask,
.cfg_wm_irq_mask = msm_vfe40_axi_cfg_wm_irq_mask,
.clear_wm_irq_mask = msm_vfe40_axi_clear_wm_irq_mask,
- .clear_irq_mask =
- msm_vfe40_axi_clear_irq_mask,
.cfg_framedrop = msm_vfe40_cfg_framedrop,
.clear_framedrop = msm_vfe40_clear_framedrop,
.cfg_wm_reg = msm_vfe40_axi_cfg_wm_reg,
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp44.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp44.c
index eec59d454130..fa4f4ee79cc7 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp44.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp44.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -397,7 +397,7 @@ static void msm_vfe44_process_error_status(struct vfe_device *vfe_dev)
}
}
-static void msm_vfe44_read_irq_status_and_clear(struct vfe_device *vfe_dev,
+static void msm_vfe44_read_irq_status(struct vfe_device *vfe_dev,
uint32_t *irq_status0, uint32_t *irq_status1)
{
*irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x38);
@@ -425,13 +425,6 @@ static void msm_vfe44_read_irq_status_and_clear(struct vfe_device *vfe_dev,
}
-static void msm_vfe44_read_irq_status(struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1)
-{
- *irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x38);
- *irq_status1 = msm_camera_io_r(vfe_dev->vfe_base + 0x3C);
-}
-
static void msm_vfe44_process_reg_update(struct vfe_device *vfe_dev,
uint32_t irq_status0, uint32_t irq_status1,
struct msm_isp_timestamp *ts)
@@ -517,13 +510,13 @@ static void msm_vfe44_process_epoch_irq(struct vfe_device *vfe_dev,
msm_isp_update_stats_framedrop_reg(vfe_dev);
msm_isp_update_error_frame_count(vfe_dev);
if (vfe_dev->axi_data.src_info[VFE_PIX_0].raw_stream_count > 0
- && vfe_dev->axi_data.src_info[VFE_PIX_0].
- pix_stream_count == 0) {
+ && vfe_dev->axi_data.src_info[VFE_PIX_0].
+ pix_stream_count == 0) {
ISP_DBG("%s: SOF IRQ\n", __func__);
msm_isp_notify(vfe_dev, ISP_EVENT_SOF, VFE_PIX_0, ts);
if (vfe_dev->axi_data.stream_update[VFE_PIX_0])
msm_isp_axi_stream_update(vfe_dev, VFE_PIX_0);
- vfe_dev->hw_info->vfe_ops.core_ops.reg_update(
+ vfe_dev->hw_info->vfe_ops.core_ops.reg_update(
vfe_dev, VFE_PIX_0);
}
}
@@ -558,12 +551,6 @@ static void msm_vfe44_reg_update(struct vfe_device *vfe_dev,
vfe_dev->reg_update_requested;
if ((vfe_dev->is_split && vfe_dev->pdev->id == ISP_VFE1) &&
((frame_src == VFE_PIX_0) || (frame_src == VFE_SRC_MAX))) {
- if (!vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]) {
- pr_err("%s vfe_base for ISP_VFE0 is NULL\n", __func__);
- spin_unlock_irqrestore(&vfe_dev->reg_update_lock,
- flags);
- return;
- }
msm_camera_io_w_mb(update_mask,
vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]
+ 0x378);
@@ -689,12 +676,6 @@ static void msm_vfe44_axi_clear_wm_irq_mask(struct vfe_device *vfe_dev,
MSM_ISP_IRQ_DISABLE);
}
-static void msm_vfe44_axi_clear_irq_mask(struct vfe_device *vfe_dev)
-{
- msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x28);
- msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x2C);
-}
-
static void msm_vfe44_cfg_framedrop(void __iomem *vfe_base,
struct msm_vfe_axi_stream *stream_info, uint32_t framedrop_pattern,
uint32_t framedrop_period)
@@ -879,8 +860,6 @@ static int msm_vfe44_fetch_engine_start(struct vfe_device *vfe_dev,
vfe_dev->buf_mgr, fe_cfg->session_id,
fe_cfg->stream_id);
vfe_dev->fetch_engine_info.bufq_handle = bufq_handle;
-
- mutex_lock(&vfe_dev->buf_mgr->lock);
rc = vfe_dev->buf_mgr->ops->get_buf_by_index(
vfe_dev->buf_mgr, bufq_handle, fe_cfg->buf_idx, &buf);
if (rc < 0) {
@@ -1795,8 +1774,6 @@ struct msm_vfe_hardware_info vfe44_hw_info = {
.vfe_ops = {
.irq_ops = {
.read_irq_status = msm_vfe44_read_irq_status,
- .read_irq_status_and_clear =
- msm_vfe44_read_irq_status_and_clear,
.process_camif_irq = msm_vfe44_process_input_irq,
.process_reset_irq = msm_vfe44_process_reset_irq,
.process_halt_irq = msm_vfe44_process_halt_irq,
@@ -1816,8 +1793,6 @@ struct msm_vfe_hardware_info vfe44_hw_info = {
.clear_comp_mask = msm_vfe44_axi_clear_comp_mask,
.cfg_wm_irq_mask = msm_vfe44_axi_cfg_wm_irq_mask,
.clear_wm_irq_mask = msm_vfe44_axi_clear_wm_irq_mask,
- .clear_irq_mask =
- msm_vfe44_axi_clear_irq_mask,
.cfg_framedrop = msm_vfe44_cfg_framedrop,
.clear_framedrop = msm_vfe44_clear_framedrop,
.cfg_wm_reg = msm_vfe44_axi_cfg_wm_reg,
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp46.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp46.c
index 8c14e9a33b7d..1bbdcb99a976 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp46.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp46.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -341,7 +341,7 @@ static void msm_vfe46_process_error_status(struct vfe_device *vfe_dev)
pr_err("%s: status bf scale bus overflow\n", __func__);
}
-static void msm_vfe46_read_irq_status_and_clear(struct vfe_device *vfe_dev,
+static void msm_vfe46_read_irq_status(struct vfe_device *vfe_dev,
uint32_t *irq_status0, uint32_t *irq_status1)
{
*irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x6C);
@@ -365,13 +365,6 @@ static void msm_vfe46_read_irq_status_and_clear(struct vfe_device *vfe_dev,
}
-static void msm_vfe46_read_irq_status(struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1)
-{
- *irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x6C);
- *irq_status1 = msm_camera_io_r(vfe_dev->vfe_base + 0x70);
-}
-
static void msm_vfe46_process_reg_update(struct vfe_device *vfe_dev,
uint32_t irq_status0, uint32_t irq_status1,
struct msm_isp_timestamp *ts)
@@ -498,12 +491,6 @@ static void msm_vfe46_reg_update(struct vfe_device *vfe_dev,
vfe_dev->reg_update_requested;
if ((vfe_dev->is_split && vfe_dev->pdev->id == ISP_VFE1) &&
((frame_src == VFE_PIX_0) || (frame_src == VFE_SRC_MAX))) {
- if (!vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]) {
- pr_err("%s vfe_base for ISP_VFE0 is NULL\n", __func__);
- spin_unlock_irqrestore(&vfe_dev->reg_update_lock,
- flags);
- return;
- }
msm_camera_io_w_mb(update_mask,
vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]
+ 0x3D8);
@@ -630,12 +617,6 @@ static void msm_vfe46_axi_clear_wm_irq_mask(struct vfe_device *vfe_dev,
MSM_ISP_IRQ_DISABLE);
}
-static void msm_vfe46_axi_clear_irq_mask(struct vfe_device *vfe_dev)
-{
- msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x5C);
- msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x60);
-}
-
static void msm_vfe46_cfg_framedrop(void __iomem *vfe_base,
struct msm_vfe_axi_stream *stream_info, uint32_t framedrop_pattern,
uint32_t framedrop_period)
@@ -824,7 +805,6 @@ static int msm_vfe46_start_fetch_engine(struct vfe_device *vfe_dev,
fe_cfg->stream_id);
vfe_dev->fetch_engine_info.bufq_handle = bufq_handle;
- mutex_lock(&vfe_dev->buf_mgr->lock);
rc = vfe_dev->buf_mgr->ops->get_buf_by_index(
vfe_dev->buf_mgr, bufq_handle, fe_cfg->buf_idx, &buf);
if (rc < 0 || !buf) {
@@ -1882,8 +1862,6 @@ struct msm_vfe_hardware_info vfe46_hw_info = {
.vfe_ops = {
.irq_ops = {
.read_irq_status = msm_vfe46_read_irq_status,
- .read_irq_status_and_clear =
- msm_vfe46_read_irq_status_and_clear,
.process_camif_irq = msm_vfe46_process_input_irq,
.process_reset_irq = msm_vfe46_process_reset_irq,
.process_halt_irq = msm_vfe46_process_halt_irq,
@@ -1903,8 +1881,6 @@ struct msm_vfe_hardware_info vfe46_hw_info = {
.clear_comp_mask = msm_vfe46_axi_clear_comp_mask,
.cfg_wm_irq_mask = msm_vfe46_axi_cfg_wm_irq_mask,
.clear_wm_irq_mask = msm_vfe46_axi_clear_wm_irq_mask,
- .clear_irq_mask =
- msm_vfe46_axi_clear_irq_mask,
.cfg_framedrop = msm_vfe46_cfg_framedrop,
.clear_framedrop = msm_vfe46_clear_framedrop,
.cfg_wm_reg = msm_vfe46_axi_cfg_wm_reg,
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp47.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp47.c
index b7bf00eebeb1..3ac13234fc91 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp47.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp47.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2017, 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
@@ -53,10 +53,8 @@
#ifdef CONFIG_MSM_CAMERA_AUTOMOTIVE
#define UB_CFG_POLICY MSM_WM_UB_EQUAL_SLICING
-#define VFE47_NUM_WM 4
#else
#define UB_CFG_POLICY MSM_WM_UB_CFG_DEFAULT
-#define VFE47_NUM_WM 7
#endif
static uint32_t stats_base_addr[] = {
@@ -550,7 +548,7 @@ void msm_vfe47_process_error_status(struct vfe_device *vfe_dev)
pr_err("%s: status dsp error\n", __func__);
}
-void msm_vfe47_read_irq_status_and_clear(struct vfe_device *vfe_dev,
+void msm_vfe47_read_irq_status(struct vfe_device *vfe_dev,
uint32_t *irq_status0, uint32_t *irq_status1)
{
*irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x6C);
@@ -575,13 +573,6 @@ void msm_vfe47_read_irq_status_and_clear(struct vfe_device *vfe_dev,
}
-void msm_vfe47_read_irq_status(struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1)
-{
- *irq_status0 = msm_camera_io_r(vfe_dev->vfe_base + 0x6C);
- *irq_status1 = msm_camera_io_r(vfe_dev->vfe_base + 0x70);
-}
-
void msm_vfe47_process_reg_update(struct vfe_device *vfe_dev,
uint32_t irq_status0, uint32_t irq_status1,
struct msm_isp_timestamp *ts)
@@ -680,8 +671,12 @@ void msm_vfe47_process_epoch_irq(struct vfe_device *vfe_dev,
void msm_isp47_process_eof_irq(struct vfe_device *vfe_dev,
uint32_t irq_status0)
{
- if (irq_status0 & BIT(1))
+ if (irq_status0 & BIT(1)) {
vfe_dev->axi_data.src_info[VFE_PIX_0].eof_id++;
+ vfe_dev->axi_data.src_info[VFE_PIX_0].accept_frame = false;
+ }
+ if (irq_status0 & BIT(0))
+ vfe_dev->axi_data.src_info[VFE_PIX_0].accept_frame = true;
}
void msm_vfe47_reg_update(struct vfe_device *vfe_dev,
@@ -714,12 +709,6 @@ void msm_vfe47_reg_update(struct vfe_device *vfe_dev,
vfe_dev->reg_update_requested;
if ((vfe_dev->is_split && vfe_dev->pdev->id == ISP_VFE1) &&
((frame_src == VFE_PIX_0) || (frame_src == VFE_SRC_MAX))) {
- if (!vfe_dev->common_data->dual_vfe_res->vfe_base[ISP_VFE0]) {
- pr_err("%s vfe_base for ISP_VFE0 is NULL\n", __func__);
- spin_unlock_irqrestore(&vfe_dev->reg_update_lock,
- flags);
- return;
- }
msm_camera_io_w_mb(update_mask,
vfe_dev->common_data->dual_vfe_res->
vfe_base[ISP_VFE0] + 0x4AC);
@@ -856,12 +845,6 @@ void msm_vfe47_axi_clear_wm_irq_mask(struct vfe_device *vfe_dev,
MSM_ISP_IRQ_DISABLE);
}
-void msm_vfe47_axi_clear_irq_mask(struct vfe_device *vfe_dev)
-{
- msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x5C);
- msm_camera_io_w_mb(0x0, vfe_dev->vfe_base + 0x60);
-}
-
void msm_vfe47_cfg_framedrop(void __iomem *vfe_base,
struct msm_vfe_axi_stream *stream_info, uint32_t framedrop_pattern,
uint32_t framedrop_period)
@@ -1116,7 +1099,6 @@ int msm_vfe47_start_fetch_engine_multi_pass(struct vfe_device *vfe_dev,
fe_cfg->stream_id);
vfe_dev->fetch_engine_info.bufq_handle = bufq_handle;
- mutex_lock(&vfe_dev->buf_mgr->lock);
rc = vfe_dev->buf_mgr->ops->get_buf_by_index(
vfe_dev->buf_mgr, bufq_handle, fe_cfg->buf_idx, &buf);
if (rc < 0 || !buf) {
@@ -2697,7 +2679,7 @@ void msm_vfe47_get_halt_restart_mask(uint32_t *irq0_mask,
}
static struct msm_vfe_axi_hardware_info msm_vfe47_axi_hw_info = {
- .num_wm = VFE47_NUM_WM,
+ .num_wm = 7,
.num_comp_mask = 3,
.num_rdi = 3,
.num_rdi_master = 3,
@@ -2727,8 +2709,6 @@ struct msm_vfe_hardware_info vfe47_hw_info = {
.vfe_ops = {
.irq_ops = {
.read_irq_status = msm_vfe47_read_irq_status,
- .read_irq_status_and_clear =
- msm_vfe47_read_irq_status_and_clear,
.process_camif_irq = msm_vfe47_process_input_irq,
.process_reset_irq = msm_vfe47_process_reset_irq,
.process_halt_irq = msm_vfe47_process_halt_irq,
@@ -2748,8 +2728,6 @@ struct msm_vfe_hardware_info vfe47_hw_info = {
.clear_comp_mask = msm_vfe47_axi_clear_comp_mask,
.cfg_wm_irq_mask = msm_vfe47_axi_cfg_wm_irq_mask,
.clear_wm_irq_mask = msm_vfe47_axi_clear_wm_irq_mask,
- .clear_irq_mask =
- msm_vfe47_axi_clear_irq_mask,
.cfg_framedrop = msm_vfe47_cfg_framedrop,
.clear_framedrop = msm_vfe47_clear_framedrop,
.cfg_wm_reg = msm_vfe47_axi_cfg_wm_reg,
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp47.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp47.h
index aa23a87e2554..282808250193 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp47.h
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp47.h
@@ -32,8 +32,6 @@ extern struct msm_vfe_hardware_info vfe47_hw_info;
void msm_vfe47_read_irq_status(struct vfe_device *vfe_dev,
uint32_t *irq_status0, uint32_t *irq_status1);
-void msm_vfe47_read_irq_status_and_clear(struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1);
void msm_vfe47_enable_camif_error(struct vfe_device *vfe_dev,
int enable);
void msm_vfe47_process_reg_update(struct vfe_device *vfe_dev,
@@ -60,7 +58,6 @@ void msm_vfe47_axi_cfg_wm_irq_mask(struct vfe_device *vfe_dev,
struct msm_vfe_axi_stream *stream_info);
void msm_vfe47_axi_clear_wm_irq_mask(struct vfe_device *vfe_dev,
struct msm_vfe_axi_stream *stream_info);
-void msm_vfe47_axi_clear_irq_mask(struct vfe_device *vfe_dev);
void msm_vfe47_cfg_framedrop(void __iomem *vfe_base,
struct msm_vfe_axi_stream *stream_info, uint32_t framedrop_pattern,
uint32_t framedrop_period);
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp48.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp48.c
index 67978a2b7607..8f058a86b615 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp48.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp48.c
@@ -227,8 +227,6 @@ struct msm_vfe_hardware_info vfe48_hw_info = {
.vfe_ops = {
.irq_ops = {
.read_irq_status = msm_vfe47_read_irq_status,
- .read_irq_status_and_clear =
- msm_vfe47_read_irq_status_and_clear,
.process_camif_irq = msm_vfe47_process_input_irq,
.process_reset_irq = msm_vfe47_process_reset_irq,
.process_halt_irq = msm_vfe47_process_halt_irq,
@@ -248,8 +246,6 @@ struct msm_vfe_hardware_info vfe48_hw_info = {
.clear_comp_mask = msm_vfe47_axi_clear_comp_mask,
.cfg_wm_irq_mask = msm_vfe47_axi_cfg_wm_irq_mask,
.clear_wm_irq_mask = msm_vfe47_axi_clear_wm_irq_mask,
- .clear_irq_mask =
- msm_vfe47_axi_clear_irq_mask,
.cfg_framedrop = msm_vfe47_cfg_framedrop,
.clear_framedrop = msm_vfe47_clear_framedrop,
.cfg_wm_reg = msm_vfe47_axi_cfg_wm_reg,
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_32.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_32.c
deleted file mode 100644
index 550dc978dc4a..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_32.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/proc_fs.h>
-#include <linux/debugfs.h>
-#include <linux/videodev2.h>
-#include <linux/of_device.h>
-#include <linux/qcom_iommu.h>
-#include <linux/sched_clock.h>
-#include <media/v4l2-subdev.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-event.h>
-
-#include "msm_isp_32.h"
-#include "msm_isp_util_32.h"
-#include "msm_isp_axi_util_32.h"
-#include "msm_isp_stats_util_32.h"
-#include "msm_sd.h"
-#include "msm_isp32.h"
-
-static struct msm_sd_req_vb2_q vfe_vb2_ops;
-
-static const struct of_device_id msm_vfe_dt_match[] = {
- {
- .compatible = "qcom,vfe32",
- .data = &vfe32_hw_info,
- },
- {}
-};
-
-MODULE_DEVICE_TABLE(of, msm_vfe_dt_match);
-
-static const struct platform_device_id msm_vfe_dev_id[] = {
- {"msm_vfe32", (kernel_ulong_t) &vfe32_hw_info},
- {}
-};
-#define MAX_OVERFLOW_COUNTERS 29
-#define OVERFLOW_LENGTH 1024
-#define OVERFLOW_BUFFER_LENGTH 64
-static char stat_line[OVERFLOW_LENGTH];
-
-static struct msm_isp_buf_mgr vfe_buf_mgr;
-struct msm_isp_statistics stats;
-struct msm_isp_ub_info ub_info;
-static int msm_isp_enable_debugfs(struct vfe_device *vfe_dev,
- struct msm_isp_bw_req_info *isp_req_hist);
-static char *stats_str[MAX_OVERFLOW_COUNTERS] = {
- "imgmaster0_overflow_cnt",
- "imgmaster1_overflow_cnt",
- "imgmaster2_overflow_cnt",
- "imgmaster3_overflow_cnt",
- "imgmaster4_overflow_cnt",
- "imgmaster5_overflow_cnt",
- "imgmaster6_overflow_cnt",
- "be_overflow_cnt",
- "bg_overflow_cnt",
- "bf_overflow_cnt",
- "awb_overflow_cnt",
- "rs_overflow_cnt",
- "cs_overflow_cnt",
- "ihist_overflow_cnt",
- "skinbhist_overflow_cnt",
- "bfscale_overflow_cnt",
- "ISP_VFE0_client_info.active",
- "ISP_VFE0_client_info.ab",
- "ISP_VFE0_client_info.ib",
- "ISP_VFE1_client_info.active",
- "ISP_VFE1_client_info.ab",
- "ISP_VFE1_client_info.ib",
- "ISP_CPP_client_info.active",
- "ISP_CPP_client_info.ab",
- "ISP_CPP_client_info.ib",
- "ISP_last_overflow.ab",
- "ISP_last_overflow.ib",
- "ISP_VFE_CLK_RATE",
- "ISP_CPP_CLK_RATE",
-};
-
-#define MAX_DEPTH_BW_REQ_HISTORY 25
-#define MAX_BW_HISTORY_BUFF_LEN 6144
-#define MAX_BW_HISTORY_LINE_BUFF_LEN 512
-
-#define MAX_UB_INFO_BUFF_LEN 1024
-#define MAX_UB_INFO_LINE_BUFF_LEN 256
-
-static struct msm_isp_bw_req_info
- msm_isp_bw_request_history[MAX_DEPTH_BW_REQ_HISTORY];
-static int msm_isp_bw_request_history_idx;
-static char bw_request_history_buff[MAX_BW_HISTORY_BUFF_LEN];
-static char ub_info_buffer[MAX_UB_INFO_BUFF_LEN];
-static spinlock_t req_history_lock;
-static int vfe_debugfs_statistics_open(struct inode *inode, struct file *file)
-{
- file->private_data = inode->i_private;
- return 0;
-}
-
-static ssize_t vfe_debugfs_statistics_read(struct file *t_file, char *t_char,
- size_t t_size_t, loff_t *t_loff_t)
-{
- int i;
- uint64_t *ptr;
- char buffer[OVERFLOW_BUFFER_LENGTH] = {0};
- struct vfe_device *vfe_dev = (struct vfe_device *)
- t_file->private_data;
- struct msm_isp_statistics *stats = vfe_dev->stats;
-
- memset(stat_line, 0, sizeof(stat_line));
- msm_isp_util_get_bandwidth_stats(vfe_dev, stats);
- ptr = (uint64_t *)(stats);
- for (i = 0; i < MAX_OVERFLOW_COUNTERS; i++) {
- strlcat(stat_line, stats_str[i], sizeof(stat_line));
- strlcat(stat_line, " ", sizeof(stat_line));
- snprintf(buffer, sizeof(buffer), "%llu", ptr[i]);
- strlcat(stat_line, buffer, sizeof(stat_line));
- strlcat(stat_line, "\r\n", sizeof(stat_line));
- }
- return simple_read_from_buffer(t_char, t_size_t,
- t_loff_t, stat_line, strlen(stat_line));
-}
-
-static ssize_t vfe_debugfs_statistics_write(struct file *t_file,
- const char *t_char, size_t t_size_t, loff_t *t_loff_t)
-{
- struct vfe_device *vfe_dev = (struct vfe_device *)
- t_file->private_data;
- struct msm_isp_statistics *stats = vfe_dev->stats;
-
- memset(stats, 0, sizeof(struct msm_isp_statistics));
-
- return sizeof(struct msm_isp_statistics);
-}
-
-static int bw_history_open(struct inode *inode, struct file *file)
-{
- file->private_data = inode->i_private;
- return 0;
-}
-
-static ssize_t bw_history_read(struct file *t_file, char *t_char,
- size_t t_size_t, loff_t *t_loff_t)
-{
- int i;
- char *out_buffer = bw_request_history_buff;
- char line_buffer[MAX_BW_HISTORY_LINE_BUFF_LEN] = {0};
- struct msm_isp_bw_req_info *isp_req_hist =
- (struct msm_isp_bw_req_info *) t_file->private_data;
-
- memset(out_buffer, 0, MAX_BW_HISTORY_BUFF_LEN);
-
- snprintf(line_buffer, sizeof(line_buffer),
- "Bus bandwidth request history in chronological order:\n");
- strlcat(out_buffer, line_buffer, sizeof(bw_request_history_buff));
-
- snprintf(line_buffer, sizeof(line_buffer),
- "MSM_ISP_MIN_AB = %u, MSM_ISP_MIN_IB = %u\n\n",
- MSM_ISP_MIN_AB, MSM_ISP_MIN_IB);
- strlcat(out_buffer, line_buffer, sizeof(bw_request_history_buff));
-
- for (i = 0; i < MAX_DEPTH_BW_REQ_HISTORY; i++) {
- snprintf(line_buffer, sizeof(line_buffer),
- "idx = %d, client = %u, timestamp = %llu, ab = %llu, ib = %llu\n"
- "ISP0.active = %x, ISP0.ab = %llu, ISP0.ib = %llu\n"
- "ISP1.active = %x, ISP1.ab = %llu, ISP1.ib = %llu\n"
- "CPP.active = %x, CPP.ab = %llu, CPP.ib = %llu\n\n",
- i, isp_req_hist[i].client, isp_req_hist[i].timestamp,
- isp_req_hist[i].total_ab, isp_req_hist[i].total_ib,
- isp_req_hist[i].client_info[0].active,
- isp_req_hist[i].client_info[0].ab,
- isp_req_hist[i].client_info[0].ib,
- isp_req_hist[i].client_info[1].active,
- isp_req_hist[i].client_info[1].ab,
- isp_req_hist[i].client_info[1].ib,
- isp_req_hist[i].client_info[2].active,
- isp_req_hist[i].client_info[2].ab,
- isp_req_hist[i].client_info[2].ib);
- strlcat(out_buffer, line_buffer,
- sizeof(bw_request_history_buff));
- }
- return simple_read_from_buffer(t_char, t_size_t,
- t_loff_t, out_buffer, strlen(out_buffer));
-}
-
-static ssize_t bw_history_write(struct file *t_file,
- const char *t_char, size_t t_size_t, loff_t *t_loff_t)
-{
- struct msm_isp_bw_req_info *isp_req_hist =
- (struct msm_isp_bw_req_info *) t_file->private_data;
-
- memset(isp_req_hist, 0, sizeof(msm_isp_bw_request_history));
- msm_isp_bw_request_history_idx = 0;
- return sizeof(msm_isp_bw_request_history);
-}
-
-static int ub_info_open(struct inode *inode, struct file *file)
-{
- file->private_data = inode->i_private;
- return 0;
-}
-
-static ssize_t ub_info_read(struct file *t_file, char *t_char,
- size_t t_size_t, loff_t *t_loff_t)
-{
- int i;
- char *out_buffer = ub_info_buffer;
- char line_buffer[MAX_UB_INFO_LINE_BUFF_LEN] = {0};
- struct vfe_device *vfe_dev =
- (struct vfe_device *) t_file->private_data;
- struct msm_isp_ub_info *ub_info = vfe_dev->ub_info;
-
- memset(out_buffer, 0, MAX_UB_INFO_LINE_BUFF_LEN);
- snprintf(line_buffer, sizeof(line_buffer),
- "wm_ub_policy_type = %d\n"
- "num_wm = %d\n"
- "wm_ub = %d\n",
- ub_info->policy, ub_info->num_wm, ub_info->wm_ub);
- strlcat(out_buffer, line_buffer,
- sizeof(ub_info_buffer));
- for (i = 0; i < ub_info->num_wm; i++) {
- snprintf(line_buffer, sizeof(line_buffer),
- "data[%d] = 0x%x, addr[%d] = 0x%llx\n",
- i, ub_info->data[i], i, ub_info->addr[i]);
- strlcat(out_buffer, line_buffer,
- sizeof(ub_info_buffer));
- }
-
- return simple_read_from_buffer(t_char, t_size_t,
- t_loff_t, out_buffer, strlen(out_buffer));
-}
-
-static ssize_t ub_info_write(struct file *t_file,
- const char *t_char, size_t t_size_t, loff_t *t_loff_t)
-{
- struct vfe_device *vfe_dev =
- (struct vfe_device *) t_file->private_data;
- struct msm_isp_ub_info *ub_info = vfe_dev->ub_info;
-
- memset(ub_info, 0, sizeof(struct msm_isp_ub_info));
-
- return sizeof(struct msm_isp_ub_info);
-}
-
-static const struct file_operations vfe_debugfs_error = {
- .open = vfe_debugfs_statistics_open,
- .read = vfe_debugfs_statistics_read,
- .write = vfe_debugfs_statistics_write,
-};
-
-static const struct file_operations bw_history_ops = {
- .open = bw_history_open,
- .read = bw_history_read,
- .write = bw_history_write,
-};
-
-static const struct file_operations ub_info_ops = {
- .open = ub_info_open,
- .read = ub_info_read,
- .write = ub_info_write,
-};
-
-static int msm_isp_enable_debugfs(struct vfe_device *vfe_dev,
- struct msm_isp_bw_req_info *isp_req_hist)
-{
- struct dentry *debugfs_base;
- char dirname[32] = {0};
-
- snprintf(dirname, sizeof(dirname), "msm_isp%d", vfe_dev->pdev->id);
- debugfs_base = debugfs_create_dir(dirname, NULL);
- if (!debugfs_base)
- return -ENOMEM;
- if (!debugfs_create_file("stats", S_IRUGO | S_IWUSR, debugfs_base,
- vfe_dev, &vfe_debugfs_error))
- return -ENOMEM;
-
- if (!debugfs_create_file("bw_req_history", S_IRUGO | S_IWUSR,
- debugfs_base, isp_req_hist, &bw_history_ops))
- return -ENOMEM;
-
- if (!debugfs_create_file("ub_info", S_IRUGO | S_IWUSR,
- debugfs_base, vfe_dev, &ub_info_ops))
- return -ENOMEM;
-
- return 0;
-}
-
-void msm_isp_update_req_history(uint32_t client, uint64_t ab,
- uint64_t ib,
- struct msm_isp_bandwidth_info *client_info,
- unsigned long long ts)
-{
- int i;
-
- spin_lock(&req_history_lock);
- msm_isp_bw_request_history[msm_isp_bw_request_history_idx].client =
- client;
- msm_isp_bw_request_history[msm_isp_bw_request_history_idx].timestamp =
- ts;
- msm_isp_bw_request_history[msm_isp_bw_request_history_idx].total_ab =
- ab;
- msm_isp_bw_request_history[msm_isp_bw_request_history_idx].total_ib =
- ib;
-
- for (i = 0; i < MAX_ISP_CLIENT; i++) {
- msm_isp_bw_request_history[msm_isp_bw_request_history_idx].
- client_info[i].active = client_info[i].active;
- msm_isp_bw_request_history[msm_isp_bw_request_history_idx].
- client_info[i].ab = client_info[i].ab;
- msm_isp_bw_request_history[msm_isp_bw_request_history_idx].
- client_info[i].ib = client_info[i].ib;
- }
-
- msm_isp_bw_request_history_idx = (msm_isp_bw_request_history_idx + 1)
- % MAX_DEPTH_BW_REQ_HISTORY;
- spin_unlock(&req_history_lock);
-}
-
-#ifdef CONFIG_COMPAT
-static long msm_isp_dqevent(struct file *file, struct v4l2_fh *vfh, void *arg)
-{
- long rc;
-
- if (is_compat_task()) {
- struct msm_isp32_event_data32 *event_data32;
- struct msm_isp32_event_data *event_data;
- struct v4l2_event isp_event;
- struct v4l2_event *isp_event_user;
-
- memset(&isp_event, 0, sizeof(isp_event));
- rc = v4l2_event_dequeue(vfh, &isp_event,
- file->f_flags & O_NONBLOCK);
- if (rc)
- return rc;
- event_data = (struct msm_isp32_event_data *)
- isp_event.u.data;
- isp_event_user = (struct v4l2_event *)arg;
- memcpy(isp_event_user, &isp_event,
- sizeof(*isp_event_user));
- event_data32 = (struct msm_isp32_event_data32 *)
- isp_event_user->u.data;
- memset(event_data32, 0,
- sizeof(struct msm_isp32_event_data32));
- event_data32->timestamp.tv_sec =
- event_data->timestamp.tv_sec;
- event_data32->timestamp.tv_usec =
- event_data->timestamp.tv_usec;
- event_data32->mono_timestamp.tv_sec =
- event_data->mono_timestamp.tv_sec;
- event_data32->mono_timestamp.tv_usec =
- event_data->mono_timestamp.tv_usec;
- event_data32->input_intf = event_data->input_intf;
- event_data32->frame_id = event_data->frame_id;
- memcpy(&(event_data32->u), &(event_data->u),
- sizeof(event_data32->u));
- } else {
- rc = v4l2_event_dequeue(vfh, arg,
- file->f_flags & O_NONBLOCK);
- }
- return rc;
-}
-#else
-static long msm_isp_dqevent(struct file *file, struct v4l2_fh *vfh, void *arg)
-{
- return v4l2_event_dequeue(vfh, arg,
- file->f_flags & O_NONBLOCK);
-}
-#endif
-
-static long msm_isp_subdev_do_ioctl(
- struct file *file, unsigned int cmd, void *arg)
-{
- struct video_device *vdev = video_devdata(file);
- struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
- struct v4l2_fh *vfh = file->private_data;
-
- switch (cmd) {
- case VIDIOC_DQEVENT: {
- if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
- return -ENOIOCTLCMD;
- return msm_isp_dqevent(file, vfh, arg);
- }
- break;
- case VIDIOC_SUBSCRIBE_EVENT:
- return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);
-
- case VIDIOC_UNSUBSCRIBE_EVENT:
- return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);
-
- default:
- return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
- }
-}
-
-static long msm_isp_subdev_fops_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- return video_usercopy(file, cmd, arg, msm_isp_subdev_do_ioctl);
-}
-
-static struct v4l2_file_operations msm_isp_v4l2_subdev_fops = {
-#ifdef CONFIG_COMPAT
- .compat_ioctl32 = msm_isp_subdev_fops_ioctl,
-#endif
- .unlocked_ioctl = msm_isp_subdev_fops_ioctl
-};
-
-static int vfe_probe(struct platform_device *pdev)
-{
- struct vfe_device *vfe_dev;
- /*struct msm_cam_subdev_info sd_info;*/
- const struct of_device_id *match_dev;
- int rc = 0;
-
- struct msm_iova_partition vfe_partition = {
- .start = SZ_128K,
- .size = SZ_2G - SZ_128K,
- };
- struct msm_iova_layout vfe_layout = {
- .partitions = &vfe_partition,
- .npartitions = 1,
- .client_name = "vfe",
- .domain_flags = 0,
- };
-
- vfe_dev = kzalloc(sizeof(struct vfe_device), GFP_KERNEL);
- if (!vfe_dev) {
- rc = -ENOMEM;
- goto end;
- }
- vfe_dev->stats = kzalloc(sizeof(struct msm_isp_statistics), GFP_KERNEL);
- if (!vfe_dev->stats) {
- rc = -ENOMEM;
- goto probe_fail1;
- }
-
- vfe_dev->ub_info = kzalloc(sizeof(struct msm_isp_ub_info), GFP_KERNEL);
- if (!vfe_dev->ub_info) {
- rc = -ENOMEM;
- goto probe_fail2;
- }
- if (pdev->dev.of_node) {
- of_property_read_u32((&pdev->dev)->of_node,
- "cell-index", &pdev->id);
- match_dev = of_match_device(msm_vfe_dt_match, &pdev->dev);
- if (!match_dev) {
- pr_err("%s: No vfe hardware info\n", __func__);
- rc = -EINVAL;
- goto probe_fail3;
- }
- vfe_dev->hw_info =
- (struct msm_vfe_hardware_info *) match_dev->data;
- } else {
- vfe_dev->hw_info = (struct msm_vfe_hardware_info *)
- platform_get_device_id(pdev)->driver_data;
- }
-
- if (!vfe_dev->hw_info) {
- pr_err("%s: No vfe hardware info\n", __func__);
- rc = -EINVAL;
- goto probe_fail3;
- }
- ISP_DBG("%s: device id = %d\n", __func__, pdev->id);
-
- vfe_dev->pdev = pdev;
- rc = vfe_dev->hw_info->vfe_ops.core_ops.get_platform_data(vfe_dev);
- if (rc < 0) {
- pr_err("%s: failed to get platform resources\n", __func__);
- rc = -ENOMEM;
- goto probe_fail3;
- }
-
- INIT_LIST_HEAD(&vfe_dev->tasklet_q);
- tasklet_init(&vfe_dev->vfe_tasklet,
- msm_isp_do_tasklet, (unsigned long)vfe_dev);
-
- v4l2_subdev_init(&vfe_dev->subdev.sd, vfe_dev->hw_info->subdev_ops);
- vfe_dev->subdev.sd.internal_ops =
- vfe_dev->hw_info->subdev_internal_ops;
- snprintf(vfe_dev->subdev.sd.name,
- ARRAY_SIZE(vfe_dev->subdev.sd.name),
- "vfe");
- vfe_dev->subdev.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
- vfe_dev->subdev.sd.flags |= V4L2_SUBDEV_FL_HAS_EVENTS;
- v4l2_set_subdevdata(&vfe_dev->subdev.sd, vfe_dev);
- platform_set_drvdata(pdev, &vfe_dev->subdev.sd);
- mutex_init(&vfe_dev->realtime_mutex);
- mutex_init(&vfe_dev->core_mutex);
- spin_lock_init(&vfe_dev->tasklet_lock);
- spin_lock_init(&vfe_dev->shared_data_lock);
- spin_lock_init(&req_history_lock);
- media_entity_init(&vfe_dev->subdev.sd.entity, 0, NULL, 0);
- vfe_dev->subdev.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
- vfe_dev->subdev.sd.entity.group_id = MSM_CAMERA_SUBDEV_VFE;
- vfe_dev->subdev.sd.entity.name = pdev->name;
- vfe_dev->subdev.close_seq = MSM_SD_CLOSE_1ST_CATEGORY | 0x2;
- rc = msm_sd_register(&vfe_dev->subdev);
- if (rc != 0) {
- pr_err("%s: msm_sd_register error = %d\n", __func__, rc);
- goto probe_fail3;
- }
-
- msm_isp_v4l2_subdev_fops.owner = v4l2_subdev_fops.owner;
- msm_isp_v4l2_subdev_fops.open = v4l2_subdev_fops.open;
- msm_isp_v4l2_subdev_fops.release = v4l2_subdev_fops.release;
- msm_isp_v4l2_subdev_fops.poll = v4l2_subdev_fops.poll;
-
- vfe_dev->subdev.sd.devnode->fops = &msm_isp_v4l2_subdev_fops;
-
- vfe_dev->buf_mgr = &vfe_buf_mgr;
- v4l2_subdev_notify(&vfe_dev->subdev.sd,
- MSM_SD_NOTIFY_REQ_CB, &vfe_vb2_ops);
- rc = msm_isp_create_isp_buf_mgr(vfe_dev->buf_mgr,
- &vfe_vb2_ops, &vfe_layout);
- if (rc < 0) {
- pr_err("%s: Unable to create buffer manager\n", __func__);
- rc = -EINVAL;
- goto probe_fail3;
- }
- /* create secure context banks*/
- if (vfe_dev->hw_info->num_iommu_secure_ctx) {
- /*secure vfe layout*/
- struct msm_iova_layout vfe_secure_layout = {
- .partitions = &vfe_partition,
- .npartitions = 1,
- .client_name = "vfe_secure",
- .domain_flags = 0,
- .is_secure = MSM_IOMMU_DOMAIN_SECURE,
- };
- rc = msm_isp_create_secure_domain(vfe_dev->buf_mgr,
- &vfe_secure_layout);
- if (rc < 0) {
- pr_err("%s: fail to create secure domain\n", __func__);
- msm_sd_unregister(&vfe_dev->subdev);
- rc = -EINVAL;
- goto probe_fail3;
- }
- }
- msm_isp_enable_debugfs(vfe_dev, msm_isp_bw_request_history);
- vfe_dev->buf_mgr->ops->register_ctx(vfe_dev->buf_mgr,
- &vfe_dev->iommu_ctx[0], &vfe_dev->iommu_secure_ctx[0],
- vfe_dev->hw_info->num_iommu_ctx,
- vfe_dev->hw_info->num_iommu_secure_ctx);
-
- vfe_dev->buf_mgr->init_done = 1;
- vfe_dev->vfe_open_cnt = 0;
- return rc;
-
-probe_fail3:
- kfree(vfe_dev->ub_info);
-probe_fail2:
- kfree(vfe_dev->stats);
-probe_fail1:
- kfree(vfe_dev);
-end:
- return rc;
-}
-
-static struct platform_driver vfe_driver = {
- .probe = vfe_probe,
- .driver = {
- .name = "msm_vfe",
- .owner = THIS_MODULE,
- .of_match_table = msm_vfe_dt_match,
- },
- .id_table = msm_vfe_dev_id,
-};
-
-static int __init msm_vfe_init_module(void)
-{
- return platform_driver_register(&vfe_driver);
-}
-
-static void __exit msm_vfe_exit_module(void)
-{
- platform_driver_unregister(&vfe_driver);
-}
-
-module_init(msm_vfe_init_module);
-module_exit(msm_vfe_exit_module);
-MODULE_DESCRIPTION("MSM VFE driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_32.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp_32.h
deleted file mode 100644
index 3c94da71d46a..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_32.h
+++ /dev/null
@@ -1,599 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef __MSM_VFE_H__
-#define __MSM_VFE_H__
-
-#include <linux/clk.h>
-#include <linux/interrupt.h>
-#include <linux/completion.h>
-#include <linux/io.h>
-#include <linux/list.h>
-#include <linux/delay.h>
-#include <linux/avtimer_kernel.h>
-#include <media/v4l2-subdev.h>
-#include <media/msmb_isp.h>
-#include <linux/msm-bus.h>
-#include <linux/msm-bus-board.h>
-
-#include "msm_buf_mgr_32.h"
-
-#define VFE40_8974V1_VERSION 0x10000018
-#define VFE40_8974V2_VERSION 0x1001001A
-#define VFE40_8974V3_VERSION 0x1001001B
-#define VFE40_8x26_VERSION 0x20000013
-#define VFE40_8x26V2_VERSION 0x20010014
-#define VFE40_8916_VERSION 0x10030000
-#define VFE40_8939_VERSION 0x10040000
-#define VFE32_8909_VERSION 0x30600
-
-#define MAX_IOMMU_CTX 2
-#define MAX_NUM_WM 7
-#define MAX_NUM_RDI 3
-#define MAX_NUM_RDI_MASTER 3
-#define MAX_NUM_COMPOSITE_MASK 4
-#define MAX_NUM_STATS_COMP_MASK 2
-#define MAX_INIT_FRAME_DROP 31
-#define ISP_Q2 (1 << 2)
-#define ISP_Q10 (1 << 10)
-
-#define VFE_PING_FLAG 0xFFFFFFFF
-#define VFE_PONG_FLAG 0x0
-
-#define VFE_MAX_CFG_TIMEOUT 3000
-#define VFE_CLK_INFO_MAX 16
-#define STATS_COMP_BIT_MASK 0xFF0000
-
-#define MSM_ISP_MIN_AB 11000000
-#define MSM_ISP_MIN_IB 11000000
-
-struct vfe_device;
-struct msm_vfe_axi_stream;
-struct msm_vfe_stats_stream;
-
-struct vfe_subscribe_info {
- struct v4l2_fh *vfh;
- uint32_t active;
-};
-
-enum msm_isp_pack_fmt {
- QCOM,
- MIPI,
- DPCM6,
- DPCM8,
- PLAIN8,
- PLAIN16,
- MAX_ISP_PACK_FMT,
-};
-
-enum msm_isp_camif_update_state {
- NO_UPDATE,
- ENABLE_CAMIF,
- DISABLE_CAMIF,
- DISABLE_CAMIF_IMMEDIATELY
-};
-
-struct msm_isp_timestamp {
- /*Monotonic clock for v4l2 buffer*/
- struct timeval buf_time;
- /*Monotonic clock for VT */
- struct timeval vt_time;
- /*Wall clock for userspace event*/
- struct timeval event_time;
-};
-
-struct msm_vfe_irq_ops {
- void (*read_irq_status)(struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1);
- void (*process_reg_update)(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts);
- void (*process_epoch_irq)(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts);
- void (*process_reset_irq)(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1);
- void (*process_halt_irq)(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1);
- void (*process_camif_irq)(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts);
- void (*process_axi_irq)(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts);
- void (*process_stats_irq)(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts);
-};
-
-struct msm_vfe_axi_ops {
- void (*reload_wm)(struct vfe_device *vfe_dev,
- uint32_t reload_mask);
- void (*enable_wm)(struct vfe_device *vfe_dev,
- uint8_t wm_idx, uint8_t enable);
- int32_t (*cfg_io_format)(struct vfe_device *vfe_dev,
- enum msm_vfe_axi_stream_src stream_src,
- uint32_t io_format);
- void (*cfg_framedrop)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info);
- void (*clear_framedrop)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info);
- void (*cfg_comp_mask)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info);
- void (*clear_comp_mask)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info);
- void (*cfg_wm_irq_mask)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info);
- void (*clear_wm_irq_mask)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info);
-
- void (*cfg_wm_reg)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info,
- uint8_t plane_idx);
- void (*clear_wm_reg)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info, uint8_t plane_idx);
-
- void (*cfg_wm_xbar_reg)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info,
- uint8_t plane_idx);
- void (*clear_wm_xbar_reg)(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info, uint8_t plane_idx);
-
- void (*cfg_ub)(struct vfe_device *vfe_dev);
-
- void (*update_ping_pong_addr)(struct vfe_device *vfe_dev,
- uint8_t wm_idx, uint32_t pingpong_status, dma_addr_t paddr);
-
- uint32_t (*get_wm_mask)(uint32_t irq_status0, uint32_t irq_status1);
- uint32_t (*get_comp_mask)(uint32_t irq_status0, uint32_t irq_status1);
- uint32_t (*get_pingpong_status)(struct vfe_device *vfe_dev);
- int (*halt)(struct vfe_device *vfe_dev, uint32_t blocking);
- int (*restart)(struct vfe_device *vfe_dev, uint32_t blocking,
- uint32_t enable_camif);
- void (*update_cgc_override)(struct vfe_device *vfe_dev,
- uint8_t wm_idx, uint8_t cgc_override);
-};
-
-struct msm_vfe_core_ops {
- void (*reg_update)(struct vfe_device *vfe_dev, uint32_t input_src);
- long (*reset_hw)(struct vfe_device *vfe_dev, uint32_t first_start,
- uint32_t blocking_call);
- int (*init_hw)(struct vfe_device *vfe_dev);
- void (*init_hw_reg)(struct vfe_device *vfe_dev);
- void (*clear_status_reg)(struct vfe_device *vfe_dev);
- void (*release_hw)(struct vfe_device *vfe_dev);
- void (*cfg_input_mux)(struct vfe_device *vfe_dev,
- struct msm_vfe_pix_cfg *pix_cfg);
- int (*start_fetch_eng)(struct vfe_device *vfe_dev,
- void *arg);
- void (*update_camif_state)(struct vfe_device *vfe_dev,
- enum msm_isp_camif_update_state update_state);
- void (*cfg_rdi_reg)(struct vfe_device *vfe_dev,
- struct msm_vfe_rdi_cfg *rdi_cfg,
- enum msm_vfe_input_src input_src);
- int (*get_platform_data)(struct vfe_device *vfe_dev);
- void (*get_error_mask)(uint32_t *error_mask0, uint32_t *error_mask1);
- void (*process_error_status)(struct vfe_device *vfe_dev);
- void (*get_overflow_mask)(uint32_t *overflow_mask);
- void (*get_irq_mask)(struct vfe_device *vfe_dev,
- uint32_t *irq0_mask, uint32_t *irq1_mask);
- void (*restore_irq_mask)(struct vfe_device *vfe_dev);
- void (*get_halt_restart_mask)(uint32_t *irq0_mask,
- uint32_t *irq1_mask);
- void (*get_rdi_wm_mask)(struct vfe_device *vfe_dev,
- uint32_t *rdi_wm_mask);
-};
-struct msm_vfe_stats_ops {
- int (*get_stats_idx)(enum msm_isp_stats_type stats_type);
- int (*check_streams)(struct msm_vfe_stats_stream *stream_info);
- void (*cfg_framedrop)(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info);
- void (*clear_framedrop)(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info);
- void (*cfg_comp_mask)(struct vfe_device *vfe_dev,
- uint32_t stats_mask, uint8_t enable);
- void (*cfg_wm_irq_mask)(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info);
- void (*clear_wm_irq_mask)(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info);
-
- void (*cfg_wm_reg)(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info);
- void (*clear_wm_reg)(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info);
-
- void (*cfg_ub)(struct vfe_device *vfe_dev);
-
- void (*enable_module)(struct vfe_device *vfe_dev,
- uint32_t stats_mask, uint8_t enable);
-
- void (*update_ping_pong_addr)(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info,
- uint32_t pingpong_status, dma_addr_t paddr);
-
- uint32_t (*get_frame_id)(struct vfe_device *vfe_dev);
- uint32_t (*get_wm_mask)(uint32_t irq_status0, uint32_t irq_status1);
- uint32_t (*get_comp_mask)(uint32_t irq_status0, uint32_t irq_status1);
- uint32_t (*get_pingpong_status)(struct vfe_device *vfe_dev);
-
- void (*update_cgc_override)(struct vfe_device *vfe_dev,
- uint32_t stats_mask, uint8_t enable);
-};
-
-struct msm_vfe_ops {
- struct msm_vfe_irq_ops irq_ops;
- struct msm_vfe_axi_ops axi_ops;
- struct msm_vfe_core_ops core_ops;
- struct msm_vfe_stats_ops stats_ops;
-};
-
-struct msm_vfe_hardware_info {
- int num_iommu_ctx;
- /* secure iommu ctx nums */
- int num_iommu_secure_ctx;
- int vfe_clk_idx;
- struct msm_vfe_ops vfe_ops;
- struct msm_vfe_axi_hardware_info *axi_hw_info;
- struct msm_vfe_stats_hardware_info *stats_hw_info;
- struct v4l2_subdev_internal_ops *subdev_internal_ops;
- struct v4l2_subdev_ops *subdev_ops;
- uint32_t dmi_reg_offset;
-};
-
-struct msm_vfe_axi_hardware_info {
- uint8_t num_wm;
- uint8_t num_rdi;
- uint8_t num_rdi_master;
- uint8_t num_comp_mask;
- uint32_t min_wm_ub;
-};
-
-enum msm_vfe_axi_state {
- AVAILABLE,
- INACTIVE,
- ACTIVE,
- PAUSED,
- START_PENDING,
- STOP_PENDING,
- PAUSE_PENDING,
- RESUME_PENDING,
- STARTING,
- STOPPING,
- PAUSING,
- RESUMING,
-};
-
-enum msm_vfe_axi_cfg_update_state {
- NO_AXI_CFG_UPDATE,
- APPLYING_UPDATE_RESUME,
- UPDATE_REQUESTED,
-};
-
-#define VFE_NO_DROP 0xFFFFFFFF
-#define VFE_DROP_EVERY_2FRAME 0x55555555
-#define VFE_DROP_EVERY_4FRAME 0x11111111
-#define VFE_DROP_EVERY_8FRAME 0x01010101
-#define VFE_DROP_EVERY_16FRAME 0x00010001
-#define VFE_DROP_EVERY_32FRAME 0x00000001
-
-enum msm_vfe_axi_stream_type {
- CONTINUOUS_STREAM,
- BURST_STREAM,
-};
-
-struct msm_vfe_axi_stream {
- uint32_t frame_id;
- enum msm_vfe_axi_state state;
- enum msm_vfe_axi_stream_src stream_src;
- uint8_t num_planes;
- uint8_t wm[MAX_PLANES_PER_STREAM];
- uint32_t output_format;/*Planar/RAW/Misc*/
- struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
- uint8_t comp_mask_index;
- struct msm_isp_buffer *buf[2];
- uint32_t session_id;
- uint32_t stream_id;
- uint32_t bufq_handle;
- uint32_t bufq_scratch_handle;
- uint32_t controllable_output;
- uint32_t stream_handle;
- uint32_t request_frm_num;
- uint8_t buf_divert;
- enum msm_vfe_axi_stream_type stream_type;
- uint32_t frame_based;
- enum msm_vfe_frame_skip_pattern frame_skip_pattern;
- uint32_t framedrop_period;
- uint32_t framedrop_pattern;
- uint32_t num_burst_capture;/*number of frame to capture*/
- uint32_t init_frame_drop;
- uint32_t burst_frame_count;/*number of sof before burst stop*/
- uint8_t framedrop_update;
- spinlock_t lock;
-
- /*Bandwidth calculation info*/
- uint32_t max_width;
- /*Based on format plane size in Q2. e.g NV12 = 1.5*/
- uint32_t format_factor;
- uint32_t bandwidth;
-
- /*Run time update variables*/
- uint32_t runtime_init_frame_drop;
- uint32_t runtime_burst_frame_count;/*number of sof before burst stop*/
- uint32_t runtime_num_burst_capture;
- uint8_t runtime_framedrop_update;
- uint8_t runtime_framedrop_update_burst;
- uint32_t runtime_output_format;
- enum msm_stream_memory_input_t memory_input;
-};
-
-struct msm_vfe_axi_composite_info {
- uint32_t stream_handle;
- uint32_t stream_composite_mask;
-};
-
-struct msm_vfe_src_info {
- uint32_t frame_id;
- uint8_t active;
- uint8_t pix_stream_count;
- uint8_t raw_stream_count;
- enum msm_vfe_inputmux input_mux;
- uint32_t width;
- long pixel_clock;
- uint32_t input_format;/*V4L2 pix format with bayer pattern*/
- uint32_t last_updt_frm_id;
-};
-
-struct msm_vfe_fetch_engine_info {
- uint32_t session_id;
- uint32_t stream_id;
- uint32_t bufq_handle;
- uint32_t buf_idx;
- uint8_t is_busy;
-};
-
-enum msm_wm_ub_cfg_type {
- MSM_WM_UB_CFG_DEFAULT,
- MSM_WM_UB_EQUAL_SLICING,
- MSM_WM_UB_CFG_MAX_NUM
-};
-
-struct msm_vfe_axi_shared_data {
- struct msm_vfe_axi_hardware_info *hw_info;
- struct msm_vfe_axi_stream stream_info[VFE_AXI_SRC_MAX];
- uint32_t free_wm[MAX_NUM_WM];
- uint32_t wm_image_size[MAX_NUM_WM];
- enum msm_wm_ub_cfg_type wm_ub_cfg_policy;
- uint8_t num_used_wm;
- uint8_t num_active_stream;
- uint8_t num_rdi_stream;
- uint8_t num_pix_stream;
- uint32_t rdi_wm_mask;
- struct msm_vfe_axi_composite_info
- composite_info[MAX_NUM_COMPOSITE_MASK];
- uint8_t num_used_composite_mask;
- uint32_t stream_update;
- atomic_t axi_cfg_update;
- enum msm_isp_camif_update_state pipeline_update;
- struct msm_vfe_src_info src_info[VFE_SRC_MAX];
- uint16_t stream_handle_cnt;
- uint32_t event_mask;
-};
-
-struct msm_vfe_stats_hardware_info {
- uint32_t stats_capability_mask;
- uint8_t *stats_ping_pong_offset;
- uint8_t num_stats_type;
- uint8_t num_stats_comp_mask;
-};
-
-enum msm_vfe_stats_state {
- STATS_AVAILABLE,
- STATS_INACTIVE,
- STATS_ACTIVE,
- STATS_START_PENDING,
- STATS_STOP_PENDING,
- STATS_STARTING,
- STATS_STOPPING,
-};
-
-struct msm_vfe_stats_stream {
- uint32_t session_id;
- uint32_t stream_id;
- uint32_t stream_handle;
- uint32_t composite_flag;
- enum msm_isp_stats_type stats_type;
- enum msm_vfe_stats_state state;
- uint32_t framedrop_pattern;
- uint32_t framedrop_period;
- uint32_t irq_subsample_pattern;
- uint32_t init_stats_frame_drop;
-
- uint32_t buffer_offset;
- struct msm_isp_buffer *buf[2];
- uint32_t bufq_handle;
-};
-
-struct msm_vfe_stats_shared_data {
- struct msm_vfe_stats_stream stream_info[MSM_ISP_STATS_MAX];
- uint8_t num_active_stream;
- atomic_t stats_comp_mask[MAX_NUM_STATS_COMP_MASK];
- uint32_t reg_mask;
- uint16_t stream_handle_cnt;
- atomic_t stats_update;
-};
-
-struct msm_vfe_tasklet_queue_cmd {
- struct list_head list;
- uint32_t vfeInterruptStatus0;
- uint32_t vfeInterruptStatus1;
- struct msm_isp_timestamp ts;
- uint8_t cmd_used;
-};
-
-#define MSM_VFE_TASKLETQ_SIZE 200
-
-enum msm_vfe_overflow_state {
- NO_OVERFLOW,
- OVERFLOW_DETECTED,
- HALT_REQUESTED,
- RESTART_REQUESTED,
-};
-
-struct msm_vfe_error_info {
- atomic_t overflow_state;
- uint32_t overflow_recover_irq_mask0;
- uint32_t overflow_recover_irq_mask1;
- uint32_t error_mask0;
- uint32_t error_mask1;
- uint32_t violation_status;
- uint32_t camif_status;
- uint32_t stream_framedrop_count[MAX_NUM_STREAM];
- uint32_t stats_framedrop_count[MSM_ISP_STATS_MAX];
- uint32_t info_dump_frame_count;
- uint32_t error_count;
-};
-
-struct msm_isp_statistics {
- int64_t imagemaster0_overflow;
- int64_t imagemaster1_overflow;
- int64_t imagemaster2_overflow;
- int64_t imagemaster3_overflow;
- int64_t imagemaster4_overflow;
- int64_t imagemaster5_overflow;
- int64_t imagemaster6_overflow;
- int64_t be_overflow;
- int64_t bg_overflow;
- int64_t bf_overflow;
- int64_t awb_overflow;
- int64_t rs_overflow;
- int64_t cs_overflow;
- int64_t ihist_overflow;
- int64_t skinbhist_overflow;
- int64_t bfscale_overflow;
-
- int64_t isp_vfe0_active;
- int64_t isp_vfe0_ab;
- int64_t isp_vfe0_ib;
-
- int64_t isp_vfe1_active;
- int64_t isp_vfe1_ab;
- int64_t isp_vfe1_ib;
-
- int64_t isp_cpp_active;
- int64_t isp_cpp_ab;
- int64_t isp_cpp_ib;
-
- int64_t last_overflow_ab;
- int64_t last_overflow_ib;
-
- int64_t vfe_clk_rate;
- int64_t cpp_clk_rate;
-};
-
-enum msm_isp_hw_client {
- ISP_VFE0,
- ISP_VFE1,
- ISP_CPP,
- MAX_ISP_CLIENT,
-};
-
-struct msm_isp_bandwidth_info {
- uint32_t active;
- uint64_t ab;
- uint64_t ib;
-};
-
-struct msm_isp_bw_req_info {
- uint32_t client;
- unsigned long long timestamp;
- uint64_t total_ab;
- uint64_t total_ib;
- struct msm_isp_bandwidth_info client_info[MAX_ISP_CLIENT];
-};
-
-#define MSM_ISP_MAX_WM 7
-struct msm_isp_ub_info {
- enum msm_wm_ub_cfg_type policy;
- uint8_t num_wm;
- uint32_t wm_ub;
- uint32_t data[MSM_ISP_MAX_WM];
- uint64_t addr[MSM_ISP_MAX_WM];
-};
-
-struct msm_vfe_hw_init_parms {
- const char *entries;
- const char *regs;
- const char *settings;
-};
-
-struct vfe_device {
- struct platform_device *pdev;
- struct msm_sd_subdev subdev;
- struct resource *vfe_irq;
- struct resource *vfe_mem;
- struct resource *vfe_vbif_mem;
- struct resource *vfe_io;
- struct resource *vfe_vbif_io;
- void __iomem *vfe_base;
- void __iomem *vfe_vbif_base;
-
- struct device *iommu_ctx[MAX_IOMMU_CTX];
- /*Add secure context banks*/
- struct device *iommu_secure_ctx[MAX_IOMMU_CTX];
-
- struct regulator *fs_vfe;
- struct clk **vfe_clk;
- uint32_t num_clk;
-
- uint32_t bus_perf_client;
-
- struct completion reset_complete;
- struct completion halt_complete;
- struct completion stream_config_complete;
- struct completion stats_config_complete;
- struct mutex realtime_mutex;
- struct mutex core_mutex;
-
- atomic_t irq_cnt;
- uint8_t taskletq_idx;
- spinlock_t tasklet_lock;
- spinlock_t shared_data_lock;
- struct list_head tasklet_q;
- struct tasklet_struct vfe_tasklet;
- struct msm_vfe_tasklet_queue_cmd
- tasklet_queue_cmd[MSM_VFE_TASKLETQ_SIZE];
-
- uint32_t vfe_hw_version;
- struct msm_vfe_hardware_info *hw_info;
- struct msm_vfe_axi_shared_data axi_data;
- struct msm_vfe_stats_shared_data stats_data;
- struct msm_vfe_error_info error_info;
- struct msm_isp_buf_mgr *buf_mgr;
- int dump_reg;
- int vfe_clk_idx;
- uint32_t vfe_open_cnt;
- uint8_t vt_enable;
- uint8_t ignore_error;
- struct msm_isp_statistics *stats;
- struct msm_vfe_fetch_engine_info fetch_engine_info;
- uint64_t msm_isp_last_overflow_ab;
- uint64_t msm_isp_last_overflow_ib;
- uint64_t msm_isp_vfe_clk_rate;
- struct msm_isp_ub_info *ub_info;
- uint32_t vfe_ub_policy;
- uint32_t isp_sof_debug;
- uint8_t reset_pending;
- uint32_t bus_util_factor;
- uint8_t vfe_reset_timeout_processed;
-};
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
index 74d5f1e5cd44..214f6ed1dd8f 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -14,9 +14,8 @@
#include <asm/div64.h>
#include "msm_isp_util.h"
#include "msm_isp_axi_util.h"
-#include "trace/events/msm_cam.h"
-
+#define HANDLE_TO_IDX(handle) (handle & 0xFF)
#define ISP_SOF_DEBUG_COUNT 0
static int msm_isp_update_dual_HW_ms_info_at_start(
struct vfe_device *vfe_dev,
@@ -183,10 +182,6 @@ int msm_isp_validate_axi_request(struct msm_vfe_axi_shared_data *axi_data,
case V4L2_PIX_FMT_P16GBRG10:
case V4L2_PIX_FMT_P16GRBG10:
case V4L2_PIX_FMT_P16RGGB10:
- case V4L2_PIX_FMT_P16BGGR12:
- case V4L2_PIX_FMT_P16GBRG12:
- case V4L2_PIX_FMT_P16GRBG12:
- case V4L2_PIX_FMT_P16RGGB12:
case V4L2_PIX_FMT_JPEG:
case V4L2_PIX_FMT_META:
case V4L2_PIX_FMT_META10:
@@ -253,9 +248,6 @@ int msm_isp_validate_axi_request(struct msm_vfe_axi_shared_data *axi_data,
stream_info->runtime_output_format = stream_info->output_format;
stream_info->stream_src = stream_cfg_cmd->stream_src;
stream_info->frame_based = stream_cfg_cmd->frame_base;
- axi_data->src_info[SRC_TO_INTF(stream_info->stream_src)].session_id =
- stream_cfg_cmd->session_id;
-
return 0;
}
@@ -330,10 +322,6 @@ static uint32_t msm_isp_axi_get_plane_size(
case V4L2_PIX_FMT_P16GBRG10:
case V4L2_PIX_FMT_P16GRBG10:
case V4L2_PIX_FMT_P16RGGB10:
- case V4L2_PIX_FMT_P16BGGR12:
- case V4L2_PIX_FMT_P16GBRG12:
- case V4L2_PIX_FMT_P16GRBG12:
- case V4L2_PIX_FMT_P16RGGB12:
size = plane_cfg[plane_idx].output_height *
plane_cfg[plane_idx].output_width;
break;
@@ -607,7 +595,6 @@ static int msm_isp_check_epoch_status(struct vfe_device **vfe_dev,
vfe_dev_cur->pdev->id,
vfe_dev_cur->common_data->dual_vfe_res->
epoch_sync_mask);
- msm_isp_dump_ping_pong_mismatch();
goto fatal;
}
@@ -686,7 +673,7 @@ void msm_isp_update_framedrop_reg(struct vfe_device *vfe_dev,
MSM_VFE_STREAM_STOP_PERIOD;
}
- if (stream_info->undelivered_request_cnt == 1)
+ if (stream_info->undelivered_request_cnt > 0)
stream_info->current_framedrop_period =
MSM_VFE_STREAM_STOP_PERIOD;
@@ -736,9 +723,8 @@ void msm_isp_reset_framedrop(struct vfe_device *vfe_dev,
stream_info->runtime_num_burst_capture);
}
-static void msm_isp_check_for_output_error(struct vfe_device *vfe_dev,
- struct msm_isp_timestamp *ts, struct msm_isp_sof_info *sof_info,
- enum msm_vfe_input_src frame_src)
+void msm_isp_check_for_output_error(struct vfe_device *vfe_dev,
+ struct msm_isp_timestamp *ts, struct msm_isp_sof_info *sof_info)
{
struct msm_vfe_axi_stream *stream_info;
struct msm_vfe_axi_shared_data *axi_data;
@@ -762,12 +748,10 @@ static void msm_isp_check_for_output_error(struct vfe_device *vfe_dev,
sof_info->regs_not_updated =
vfe_dev->reg_update_requested;
}
-
for (i = 0; i < VFE_AXI_SRC_MAX; i++) {
struct msm_vfe_axi_stream *temp_stream_info;
+
stream_info = &axi_data->stream_info[i];
- if (SRC_TO_INTF(stream_info->stream_src) != frame_src)
- continue;
stream_idx = HANDLE_TO_IDX(stream_info->stream_handle);
/*
@@ -805,20 +789,23 @@ static void msm_isp_check_for_output_error(struct vfe_device *vfe_dev,
sof_info->axi_updating_mask |=
1 << stream_idx;
}
- /* report frame drop per stream */
- i = stream_info->bufq_handle[VFE_BUF_QUEUE_DEFAULT] &
- 0xFF;
- if (vfe_dev->error_info.stream_framedrop_count[i]) {
- ISP_DBG("%s: get buf failed i %d\n", __func__,
- i);
- sof_info->stream_get_buf_fail_mask |= (1 << i);
- vfe_dev->error_info.
- stream_framedrop_count[i] = 0;
- }
}
vfe_dev->reg_updated = 0;
+ /* report frame drop per stream */
+ if (vfe_dev->error_info.framedrop_flag) {
+ for (i = 0; i < BUF_MGR_NUM_BUF_Q; i++) {
+ if (vfe_dev->error_info.stream_framedrop_count[i]) {
+ ISP_DBG("%s: get buf failed i %d\n", __func__,
+ i);
+ sof_info->stream_get_buf_fail_mask |= (1 << i);
+ vfe_dev->error_info.
+ stream_framedrop_count[i] = 0;
+ }
+ }
+ vfe_dev->error_info.framedrop_flag = 0;
+ }
}
void msm_isp_increment_frame_id(struct vfe_device *vfe_dev,
@@ -828,11 +815,13 @@ void msm_isp_increment_frame_id(struct vfe_device *vfe_dev,
struct msm_vfe_sof_info *sof_info = NULL;
enum msm_vfe_dual_hw_type dual_hw_type;
enum msm_vfe_dual_hw_ms_type ms_type;
+#ifdef SOFTWARE_SYNC_SLAVE_FRAME_ID_TO_MASTER
struct msm_vfe_sof_info *master_sof_info = NULL;
- int32_t time, master_time, delta, i;
- uint32_t sof_incr = 0, temp_frame_id;
+ int32_t time, master_time, delta;
+ uint32_t sof_incr = 0;
uint32_t master_last_slave_diff = 0;
uint32_t last_curr_diff = 0;
+#endif
unsigned long flags;
spin_lock_irqsave(&vfe_dev->common_data->common_dev_data_lock, flags);
@@ -841,32 +830,9 @@ void msm_isp_increment_frame_id(struct vfe_device *vfe_dev,
ts);
dual_hw_type =
vfe_dev->axi_data.src_info[frame_src].dual_hw_type;
- ms_type = vfe_dev->axi_data.src_info[frame_src].
- dual_hw_ms_info.dual_hw_ms_type;
- src_info = vfe_dev->axi_data.src_info;
-
- if (src_info[frame_src].frame_id == 0) {
- for (i = VFE_PIX_0; i < VFE_SRC_MAX; i++) {
- if (i == frame_src)
- continue;
-
- if (src_info[frame_src].session_id !=
- src_info[i].session_id)
- continue;
-
- if (src_info[i].active == 0)
- continue;
-
- if (i == VFE_PIX_0)
- temp_frame_id = src_info[i].frame_id - 1;
- else
- temp_frame_id = src_info[i].frame_id;
-
- if (src_info[frame_src].frame_id < temp_frame_id)
- src_info[frame_src].frame_id = temp_frame_id;
- }
- }
-
+ ms_type =
+ vfe_dev->axi_data.src_info[frame_src].
+ dual_hw_ms_info.dual_hw_ms_type;
/*
* Increment frame_id if
* 1. Not Master Slave
@@ -878,6 +844,10 @@ void msm_isp_increment_frame_id(struct vfe_device *vfe_dev,
* If SLAVE and Master active, don't increment slave frame_id.
* Instead use Master frame_id for Slave.
*/
+#ifdef SOFTWARE_SYNC_SLAVE_FRAME_ID_TO_MASTER
+ /*
+ * notice: SOFTWARE_SYNC_SLAVE_FRAME_ID_TO_MASTER is not define
+ */
if ((dual_hw_type == DUAL_HW_MASTER_SLAVE) &&
(ms_type == MS_TYPE_SLAVE) &&
(vfe_dev->common_data->ms_resource.master_active == 1)) {
@@ -922,7 +892,9 @@ void msm_isp_increment_frame_id(struct vfe_device *vfe_dev,
}
vfe_dev->ms_frame_id =
vfe_dev->axi_data.src_info[frame_src].frame_id;
- } else {
+ } else
+#endif
+ {
if (frame_src == VFE_PIX_0) {
vfe_dev->axi_data.src_info[frame_src].frame_id +=
vfe_dev->axi_data.src_info[frame_src].
@@ -947,13 +919,10 @@ void msm_isp_increment_frame_id(struct vfe_device *vfe_dev,
msm_isp_halt_send_error(vfe_dev,
ISP_EVENT_REG_UPDATE_MISSING);
}
+
} else
vfe_dev->axi_data.src_info[frame_src].frame_id++;
}
- if (frame_src == VFE_PIX_0) {
- vfe_dev->isp_page->kernel_sofid =
- vfe_dev->axi_data.src_info[frame_src].frame_id;
- }
sof_info = vfe_dev->axi_data.src_info[frame_src].
dual_hw_ms_info.sof_info;
if (dual_hw_type == DUAL_HW_MASTER_SLAVE &&
@@ -969,42 +938,12 @@ void msm_isp_increment_frame_id(struct vfe_device *vfe_dev,
flags);
}
-static void msm_isp_update_pd_stats_idx(struct vfe_device *vfe_dev,
- enum msm_vfe_input_src frame_src)
-{
- struct msm_vfe_axi_stream *pd_stream_info = NULL;
- uint32_t pingpong_status = 0, pingpong_bit = 0;
- struct msm_isp_buffer *done_buf = NULL;
-
- if (frame_src < VFE_RAW_0 || frame_src > VFE_RAW_2)
- return;
-
- pd_stream_info = &(vfe_dev->common_data->dual_vfe_res->
- axi_data[vfe_dev->pdev->id]->
- stream_info[RDI_INTF_0 + frame_src - VFE_RAW_0]);
-
- if (pd_stream_info && (pd_stream_info->state == ACTIVE) &&
- (pd_stream_info->rdi_input_type ==
- MSM_CAMERA_RDI_PDAF)) {
- pingpong_status = vfe_dev->hw_info->vfe_ops.axi_ops.
- get_pingpong_status(vfe_dev);
- pingpong_bit = ((pingpong_status >>
- pd_stream_info->wm[0]) & 0x1);
- done_buf = pd_stream_info->buf[pingpong_bit];
- if (done_buf)
- vfe_dev->pd_buf_idx = done_buf->buf_idx;
- else
- vfe_dev->pd_buf_idx = 0xF;
- }
-}
-
void msm_isp_notify(struct vfe_device *vfe_dev, uint32_t event_type,
enum msm_vfe_input_src frame_src, struct msm_isp_timestamp *ts)
{
struct msm_isp_event_data event_data;
struct msm_vfe_sof_info *sof_info = NULL, *self_sof = NULL;
enum msm_vfe_dual_hw_ms_type ms_type;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
int i, j;
unsigned long flags;
@@ -1012,15 +951,6 @@ void msm_isp_notify(struct vfe_device *vfe_dev, uint32_t event_type,
switch (event_type) {
case ISP_EVENT_SOF:
- for (i = 0; i < VFE_AXI_SRC_MAX; i++) {
- if (SRC_TO_INTF(axi_data->stream_info[i].stream_src) ==
- frame_src) {
- /* update ping pong bit for controllable */
- /* output */
- axi_data->stream_info[i].sw_sof_ping_pong_bit =
- axi_data->stream_info[i].sw_ping_pong_bit;
- }
- }
if (frame_src == VFE_PIX_0) {
if (vfe_dev->isp_sof_debug < ISP_SOF_DEBUG_COUNT)
pr_err("%s: PIX0 frame id: %u\n", __func__,
@@ -1046,9 +976,6 @@ void msm_isp_notify(struct vfe_device *vfe_dev, uint32_t event_type,
ISP_DBG("%s: vfe %d frame_src %d frame id: %u\n", __func__,
vfe_dev->pdev->id, frame_src,
vfe_dev->axi_data.src_info[frame_src].frame_id);
- trace_msm_cam_isp_bufcount("msm_isp_notify:",
- vfe_dev->pdev->id,
- vfe_dev->axi_data.src_info[frame_src].frame_id, frame_src);
/*
* Cannot support dual_cam and framedrop same time in union.
@@ -1102,15 +1029,9 @@ void msm_isp_notify(struct vfe_device *vfe_dev, uint32_t event_type,
} else {
if (frame_src <= VFE_RAW_2) {
msm_isp_check_for_output_error(vfe_dev, ts,
- &event_data.u.sof_info, frame_src);
+ &event_data.u.sof_info);
}
}
- /*
- * Get and store the buf idx for PD stats
- * this is to send the PD stats buffer address
- * in BF stats done.
- */
- msm_isp_update_pd_stats_idx(vfe_dev, frame_src);
break;
default:
@@ -1274,7 +1195,7 @@ int msm_isp_request_axi_stream(struct vfe_device *vfe_dev, void *arg)
return -EINVAL;
}
- stream_info->rdi_input_type = stream_cfg_cmd->rdi_input_type;
+ stream_info->memory_input = stream_cfg_cmd->memory_input;
vfe_dev->reg_update_requested &=
~(BIT(SRC_TO_INTF(stream_info->stream_src)));
@@ -1558,11 +1479,12 @@ void msm_isp_axi_cfg_update(struct vfe_device *vfe_dev,
{
int i, j;
uint32_t update_state;
- unsigned long flags;
+ unsigned long flags, flags1;
struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
struct msm_vfe_axi_stream *stream_info;
int num_stream = 0;
+ spin_lock_irqsave(&vfe_dev->common_data->common_dev_data_lock, flags);
for (i = 0; i < VFE_AXI_SRC_MAX; i++) {
if (SRC_TO_INTF(axi_data->stream_info[i].stream_src) !=
frame_src) {
@@ -1576,7 +1498,7 @@ void msm_isp_axi_cfg_update(struct vfe_device *vfe_dev,
!stream_info->controllable_output) ||
stream_info->state == AVAILABLE)
continue;
- spin_lock_irqsave(&stream_info->lock, flags);
+ spin_lock_irqsave(&stream_info->lock, flags1);
if (stream_info->state == PAUSING) {
/*AXI Stopped, apply update*/
stream_info->state = PAUSED;
@@ -1590,8 +1512,10 @@ void msm_isp_axi_cfg_update(struct vfe_device *vfe_dev,
} else if (stream_info->state == RESUMING) {
msm_isp_update_dual_HW_axi(vfe_dev, stream_info);
}
- spin_unlock_irqrestore(&stream_info->lock, flags);
+ spin_unlock_irqrestore(&stream_info->lock, flags1);
}
+ spin_unlock_irqrestore(&vfe_dev->common_data->common_dev_data_lock,
+ flags);
if (num_stream)
update_state = atomic_dec_return(
&axi_data->axi_cfg_update[frame_src]);
@@ -2131,10 +2055,6 @@ static int msm_isp_process_done_buf(struct vfe_device *vfe_dev,
}
}
- trace_msm_cam_isp_bufcount("msm_isp_process_done_buf:",
- vfe_dev->pdev->id, frame_id,
- SRC_TO_INTF(stream_info->stream_src));
-
buf_event.frame_id = frame_id;
buf_event.timestamp = *time_stamp;
buf_event.u.buf_done.session_id = stream_info->session_id;
@@ -2339,10 +2259,8 @@ int msm_isp_update_stream_bandwidth(struct vfe_device *vfe_dev,
struct msm_vfe_axi_stream *stream_info;
struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
uint64_t total_pix_bandwidth = 0, total_rdi_bandwidth = 0;
- uint64_t total_fe_bandwidth = 0;
uint32_t num_pix_streams = 0;
uint64_t total_bandwidth = 0;
- int bpp = 0;
for (i = 0; i < VFE_AXI_SRC_MAX; i++) {
stream_info = &axi_data->stream_info[i];
@@ -2366,16 +2284,7 @@ int msm_isp_update_stream_bandwidth(struct vfe_device *vfe_dev,
}
}
- if (axi_data->src_info[VFE_PIX_0].input_mux == EXTERNAL_READ
- && num_pix_streams){
- bpp = msm_isp_get_bit_per_pixel(axi_data->
- src_info[VFE_PIX_0].input_format);
- total_fe_bandwidth =
- (axi_data->src_info[VFE_PIX_0].pixel_clock / 8) * bpp;
- }
-
- total_bandwidth = total_pix_bandwidth + total_rdi_bandwidth +
- total_fe_bandwidth;
+ total_bandwidth = total_pix_bandwidth + total_rdi_bandwidth;
rc = msm_isp_update_bandwidth(ISP_VFE0 + vfe_dev->pdev->id,
(total_bandwidth + vfe_dev->hw_info->min_ab),
(total_bandwidth + vfe_dev->hw_info->min_ib));
@@ -2570,14 +2479,9 @@ int msm_isp_axi_reset(struct vfe_device *vfe_dev,
ISP_EVENT_BUF_FATAL_ERROR);
return rc;
}
- /* Donot update frame_id for FE */
- if (!(SRC_TO_INTF(stream_info->stream_src)
- == VFE_PIX_0 &&
- axi_data->src_info[VFE_PIX_0].input_mux
- == EXTERNAL_READ))
- axi_data->src_info[SRC_TO_INTF(stream_info->
- stream_src)].frame_id = reset_cmd->frame_id;
+ axi_data->src_info[SRC_TO_INTF(stream_info->
+ stream_src)].frame_id = reset_cmd->frame_id;
msm_isp_reset_burst_count_and_frame_drop(vfe_dev,
stream_info);
}
@@ -3111,13 +3015,7 @@ static int msm_isp_stop_axi_stream(struct vfe_device *vfe_dev,
intf < VFE_SRC_MAX) {
vfe_dev->axi_data.src_info[intf].active = 0;
vfe_dev->axi_data.src_info[intf].flag = 0;
- /* reset frame_id for RDI path */
- if (halt) {
- vfe_dev->
- axi_data.src_info[intf].frame_id = 0;
- vfe_dev->
- axi_data.src_info[intf].eof_id = 0;
- }
+
}
} else
src_mask |= (1 << intf);
@@ -3163,13 +3061,6 @@ static int msm_isp_stop_axi_stream(struct vfe_device *vfe_dev,
if (src_mask & (1 << i)) {
vfe_dev->axi_data.src_info[i].active = 0;
vfe_dev->axi_data.src_info[i].flag = 0;
- /* reset frame_id for RDI path */
- if (halt) {
- vfe_dev->
- axi_data.src_info[i].frame_id = 0;
- vfe_dev->
- axi_data.src_info[i].eof_id = 0;
- }
}
}
}
@@ -3385,30 +3276,41 @@ static int msm_isp_request_frame(struct vfe_device *vfe_dev,
}
frame_src = SRC_TO_INTF(stream_info->stream_src);
- trace_msm_cam_isp_bufcount("msm_isp_request_frame:",
- vfe_dev->pdev->id, frame_id, frame_src);
-
+ pingpong_status =
+ vfe_dev->hw_info->vfe_ops.axi_ops.get_pingpong_status(
+ vfe_dev);
+ /*
+ * If PIX stream is active then RDI path uses SOF frame ID of PIX
+ * In case of standalone RDI streaming, SOF are used from
+ * individual intf.
+ */
/*
* If frame_id = 1 then no eof check is needed
*/
- if (((frame_src == VFE_PIX_0) && ((frame_id !=
+ if (vfe_dev->axi_data.src_info[VFE_PIX_0].active &&
+ vfe_dev->axi_data.src_info[VFE_PIX_0].accept_frame == false) {
+ pr_debug("%s:%d invalid time to request frame %d\n",
+ __func__, __LINE__, frame_id);
+ goto error;
+ }
+ if ((vfe_dev->axi_data.src_info[VFE_PIX_0].active && (frame_id !=
vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id + vfe_dev->
- axi_data.src_info[VFE_PIX_0].sof_counter_step))) ||
- ((frame_src != VFE_PIX_0) && (frame_id !=
+ axi_data.src_info[VFE_PIX_0].sof_counter_step)) ||
+ ((!vfe_dev->axi_data.src_info[VFE_PIX_0].active) && (frame_id !=
vfe_dev->axi_data.src_info[frame_src].frame_id + vfe_dev->
- axi_data.src_info[frame_src].sof_counter_step)) ||
- stream_info->undelivered_request_cnt >= MAX_BUFFERS_IN_HW) {
+ axi_data.src_info[frame_src].sof_counter_step))) {
pr_debug("%s:%d invalid request_frame %d cur frame id %d pix %d\n",
__func__, __LINE__, frame_id,
vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id,
vfe_dev->axi_data.src_info[VFE_PIX_0].active);
-
- rc = msm_isp_return_empty_buffer(vfe_dev, stream_info,
- user_stream_id, frame_id, buf_index, frame_src);
- if (rc < 0)
- pr_err("%s:%d failed: return_empty_buffer src %d\n",
- __func__, __LINE__, frame_src);
- return 0;
+ goto error;
+ }
+ if (stream_info->undelivered_request_cnt >= MAX_BUFFERS_IN_HW) {
+ pr_debug("%s:%d invalid undelivered_request_cnt %d frame id %d\n",
+ __func__, __LINE__,
+ stream_info->undelivered_request_cnt,
+ vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id);
+ goto error;
}
if ((frame_src == VFE_PIX_0) && !stream_info->undelivered_request_cnt &&
MSM_VFE_STREAM_STOP_PERIOD !=
@@ -3502,12 +3404,7 @@ static int msm_isp_request_frame(struct vfe_device *vfe_dev,
dual_vfe_res->wm_reload_mask[vfe_id] = 0;
}
stream_info->sw_ping_pong_bit = 0;
- stream_info->sw_sof_ping_pong_bit = 0;
} else if (stream_info->undelivered_request_cnt == 2) {
- if (stream_info->sw_sof_ping_pong_bit)
- pingpong_status = VFE_PING_FLAG;
- else
- pingpong_status = VFE_PONG_FLAG;
rc = msm_isp_cfg_ping_pong_address(vfe_dev,
stream_info, pingpong_status, 0);
if (rc) {
@@ -3533,6 +3430,13 @@ static int msm_isp_request_frame(struct vfe_device *vfe_dev,
spin_unlock_irqrestore(&stream_info->lock, flags);
return rc;
+error:
+ rc = msm_isp_return_empty_buffer(vfe_dev, stream_info,
+ user_stream_id, frame_id, buf_index, frame_src);
+ if (rc < 0)
+ pr_err("%s:%d failed: return_empty_buffer src %d\n",
+ __func__, __LINE__, frame_src);
+ return 0;
}
static int msm_isp_add_buf_queue(struct vfe_device *vfe_dev,
@@ -3919,7 +3823,6 @@ void msm_isp_process_axi_irq_stream(struct vfe_device *vfe_dev,
spin_unlock_irqrestore(&stream_info->lock, flags);
pr_err("%s: Write master ping pong mismatch. Status: 0x%x\n",
__func__, pingpong_status);
- msm_isp_dump_ping_pong_mismatch();
msm_isp_halt_send_error(vfe_dev,
ISP_EVENT_PING_PONG_MISMATCH);
return;
@@ -3997,6 +3900,7 @@ void msm_isp_process_axi_irq_stream(struct vfe_device *vfe_dev,
vfe_dev->error_info.stream_framedrop_count[
stream_info->bufq_handle[
VFE_BUF_QUEUE_DEFAULT] & 0xFF]++;
+ vfe_dev->error_info.framedrop_flag = 1;
}
spin_unlock_irqrestore(&stream_info->lock, flags);
return;
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.h
index f0df70695212..1fb9f4e0b49a 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.h
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.h
@@ -14,7 +14,6 @@
#include "msm_isp.h"
-#define HANDLE_TO_IDX(handle) (handle & 0xFF)
#define SRC_TO_INTF(src) \
((src < RDI_INTF_0 || src == VFE_AXI_SRC_MAX) ? VFE_PIX_0 : \
(VFE_RAW_0 + src - RDI_INTF_0))
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util_32.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util_32.c
deleted file mode 100644
index c7578b587812..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util_32.c
+++ /dev/null
@@ -1,2083 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-#include <asm/div64.h>
-#include "msm_isp_util_32.h"
-#include "msm_isp_axi_util_32.h"
-
-#define SRC_TO_INTF(src) \
- ((src < RDI_INTF_0 || src == VFE_AXI_SRC_MAX) ? VFE_PIX_0 : \
- (VFE_RAW_0 + src - RDI_INTF_0))
-
-#define HANDLE_TO_IDX(handle) (handle & 0xFF)
-
-int msm_isp_axi_create_stream(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe32_axi_stream_request_cmd *stream_cfg_cmd)
-{
- uint32_t i = stream_cfg_cmd->stream_src;
-
- if (i >= VFE_AXI_SRC_MAX) {
- pr_err("%s:%d invalid stream_src %d\n", __func__, __LINE__,
- stream_cfg_cmd->stream_src);
- return -EINVAL;
- }
-
- if ((axi_data->stream_handle_cnt << 8) == 0)
- axi_data->stream_handle_cnt++;
-
- stream_cfg_cmd->axi_stream_handle =
- (++axi_data->stream_handle_cnt) << 8 | i;
-
- memset(&axi_data->stream_info[i], 0,
- sizeof(struct msm_vfe_axi_stream));
- spin_lock_init(&axi_data->stream_info[i].lock);
- axi_data->stream_info[i].session_id = stream_cfg_cmd->session_id;
- axi_data->stream_info[i].stream_id = stream_cfg_cmd->stream_id;
- axi_data->stream_info[i].buf_divert = stream_cfg_cmd->buf_divert;
- axi_data->stream_info[i].state = INACTIVE;
- axi_data->stream_info[i].stream_handle =
- stream_cfg_cmd->axi_stream_handle;
- axi_data->stream_info[i].controllable_output =
- stream_cfg_cmd->controllable_output;
- if (stream_cfg_cmd->controllable_output)
- stream_cfg_cmd->frame_skip_pattern = SKIP_ALL;
- return 0;
-}
-
-void msm_isp_axi_destroy_stream(
- struct msm_vfe_axi_shared_data *axi_data, int stream_idx)
-{
- if (axi_data->stream_info[stream_idx].state != AVAILABLE) {
- axi_data->stream_info[stream_idx].state = AVAILABLE;
- axi_data->stream_info[stream_idx].stream_handle = 0;
- } else {
- pr_err("%s: stream does not exist\n", __func__);
- }
-}
-
-int msm_isp_validate_axi_request(struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe32_axi_stream_request_cmd *stream_cfg_cmd)
-{
- int rc = -1, i;
- struct msm_vfe_axi_stream *stream_info = NULL;
-
- if (HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle) < MAX_NUM_STREAM) {
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle)];
- } else {
- pr_err("%s: Invalid axi_stream_handle\n", __func__);
- return rc;
- }
-
- if (!stream_info) {
- pr_err("%s: Stream info is NULL\n", __func__);
- return -EINVAL;
- }
-
- switch (stream_cfg_cmd->output_format) {
- case V4L2_PIX_FMT_YUYV:
- case V4L2_PIX_FMT_YVYU:
- case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_VYUY:
- case V4L2_PIX_FMT_SBGGR8:
- case V4L2_PIX_FMT_SGBRG8:
- case V4L2_PIX_FMT_SGRBG8:
- case V4L2_PIX_FMT_SRGGB8:
- case V4L2_PIX_FMT_SBGGR10:
- case V4L2_PIX_FMT_SGBRG10:
- case V4L2_PIX_FMT_SGRBG10:
- case V4L2_PIX_FMT_SRGGB10:
- case V4L2_PIX_FMT_SBGGR12:
- case V4L2_PIX_FMT_SGBRG12:
- case V4L2_PIX_FMT_SGRBG12:
- case V4L2_PIX_FMT_SRGGB12:
- case V4L2_PIX_FMT_SBGGR14:
- case V4L2_PIX_FMT_SGBRG14:
- case V4L2_PIX_FMT_SGRBG14:
- case V4L2_PIX_FMT_SRGGB14:
- case V4L2_PIX_FMT_QBGGR8:
- case V4L2_PIX_FMT_QGBRG8:
- case V4L2_PIX_FMT_QGRBG8:
- case V4L2_PIX_FMT_QRGGB8:
- case V4L2_PIX_FMT_QBGGR10:
- case V4L2_PIX_FMT_QGBRG10:
- case V4L2_PIX_FMT_QGRBG10:
- case V4L2_PIX_FMT_QRGGB10:
- case V4L2_PIX_FMT_QBGGR12:
- case V4L2_PIX_FMT_QGBRG12:
- case V4L2_PIX_FMT_QGRBG12:
- case V4L2_PIX_FMT_QRGGB12:
- case V4L2_PIX_FMT_QBGGR14:
- case V4L2_PIX_FMT_QGBRG14:
- case V4L2_PIX_FMT_QGRBG14:
- case V4L2_PIX_FMT_QRGGB14:
- case V4L2_PIX_FMT_P16BGGR10:
- case V4L2_PIX_FMT_P16GBRG10:
- case V4L2_PIX_FMT_P16GRBG10:
- case V4L2_PIX_FMT_P16RGGB10:
- case V4L2_PIX_FMT_JPEG:
- case V4L2_PIX_FMT_META:
- stream_info->num_planes = 1;
- stream_info->format_factor = ISP_Q2;
- break;
- case V4L2_PIX_FMT_NV12:
- case V4L2_PIX_FMT_NV21:
- case V4L2_PIX_FMT_NV14:
- case V4L2_PIX_FMT_NV41:
- case V4L2_PIX_FMT_NV16:
- case V4L2_PIX_FMT_NV61:
- stream_info->num_planes = 2;
- stream_info->format_factor = 1.5 * ISP_Q2;
- break;
- /*TD: Add more image format*/
- default:
- msm_isp_print_fourcc_error(__func__,
- stream_cfg_cmd->output_format);
- return rc;
- }
-
- if (axi_data->hw_info->num_wm - axi_data->num_used_wm <
- stream_info->num_planes) {
- pr_err("%s: No free write masters\n", __func__);
- return rc;
- }
-
- if ((stream_info->num_planes > 1) &&
- (axi_data->hw_info->num_comp_mask -
- axi_data->num_used_composite_mask < 1)) {
- pr_err("%s: No free composite mask\n", __func__);
- return rc;
- }
-
- if (stream_cfg_cmd->init_frame_drop >= MAX_INIT_FRAME_DROP) {
- pr_err("%s: Invalid skip pattern\n", __func__);
- return rc;
- }
-
- if (stream_cfg_cmd->frame_skip_pattern >= MAX_SKIP) {
- pr_err("%s: Invalid skip pattern\n", __func__);
- return rc;
- }
-
- for (i = 0; i < stream_info->num_planes; i++) {
- stream_info->plane_cfg[i] = stream_cfg_cmd->plane_cfg[i];
- stream_info->max_width = max(stream_info->max_width,
- stream_cfg_cmd->plane_cfg[i].output_width);
- }
-
- stream_info->output_format = stream_cfg_cmd->output_format;
- stream_info->runtime_output_format = stream_info->output_format;
- stream_info->stream_src = stream_cfg_cmd->stream_src;
- stream_info->frame_based = stream_cfg_cmd->frame_base;
- return 0;
-}
-
-static uint32_t msm_isp_axi_get_plane_size(
- struct msm_vfe_axi_stream *stream_info, int plane_idx)
-{
- uint32_t size = 0;
- struct msm_vfe_axi_plane_cfg *plane_cfg = stream_info->plane_cfg;
-
- switch (stream_info->output_format) {
- case V4L2_PIX_FMT_YUYV:
- case V4L2_PIX_FMT_YVYU:
- case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_VYUY:
- case V4L2_PIX_FMT_SBGGR8:
- case V4L2_PIX_FMT_SGBRG8:
- case V4L2_PIX_FMT_SGRBG8:
- case V4L2_PIX_FMT_SRGGB8:
- case V4L2_PIX_FMT_QBGGR8:
- case V4L2_PIX_FMT_QGBRG8:
- case V4L2_PIX_FMT_QGRBG8:
- case V4L2_PIX_FMT_QRGGB8:
- case V4L2_PIX_FMT_JPEG:
- case V4L2_PIX_FMT_META:
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- break;
- case V4L2_PIX_FMT_SBGGR10:
- case V4L2_PIX_FMT_SGBRG10:
- case V4L2_PIX_FMT_SGRBG10:
- case V4L2_PIX_FMT_SRGGB10:
- case V4L2_PIX_FMT_QBGGR10:
- case V4L2_PIX_FMT_QGBRG10:
- case V4L2_PIX_FMT_QGRBG10:
- case V4L2_PIX_FMT_QRGGB10:
- /* TODO: fix me */
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- break;
- case V4L2_PIX_FMT_SBGGR12:
- case V4L2_PIX_FMT_SGBRG12:
- case V4L2_PIX_FMT_SGRBG12:
- case V4L2_PIX_FMT_SRGGB12:
- case V4L2_PIX_FMT_QBGGR12:
- case V4L2_PIX_FMT_QGBRG12:
- case V4L2_PIX_FMT_QGRBG12:
- case V4L2_PIX_FMT_QRGGB12:
- case V4L2_PIX_FMT_SBGGR14:
- case V4L2_PIX_FMT_SGBRG14:
- case V4L2_PIX_FMT_SGRBG14:
- case V4L2_PIX_FMT_SRGGB14:
- case V4L2_PIX_FMT_QBGGR14:
- case V4L2_PIX_FMT_QGBRG14:
- case V4L2_PIX_FMT_QGRBG14:
- case V4L2_PIX_FMT_QRGGB14:
- /* TODO: fix me */
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- break;
- case V4L2_PIX_FMT_P16BGGR10:
- case V4L2_PIX_FMT_P16GBRG10:
- case V4L2_PIX_FMT_P16GRBG10:
- case V4L2_PIX_FMT_P16RGGB10:
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- break;
- case V4L2_PIX_FMT_NV12:
- case V4L2_PIX_FMT_NV21:
- if (plane_cfg[plane_idx].output_plane_format == Y_PLANE)
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- else
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- break;
- case V4L2_PIX_FMT_NV14:
- case V4L2_PIX_FMT_NV41:
- if (plane_cfg[plane_idx].output_plane_format == Y_PLANE)
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- else
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- break;
- case V4L2_PIX_FMT_NV16:
- case V4L2_PIX_FMT_NV61:
- size = plane_cfg[plane_idx].output_height *
- plane_cfg[plane_idx].output_width;
- break;
- /*TD: Add more image format*/
- default:
- msm_isp_print_fourcc_error(__func__,
- stream_info->output_format);
- break;
- }
- return size;
-}
-
-void msm_isp_axi_reserve_wm(struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe_axi_stream *stream_info)
-{
- int i, j;
-
- for (i = 0; i < stream_info->num_planes; i++) {
- for (j = 0; j < axi_data->hw_info->num_wm; j++) {
- if (!axi_data->free_wm[j]) {
- axi_data->free_wm[j] =
- stream_info->stream_handle;
- axi_data->wm_image_size[j] =
- msm_isp_axi_get_plane_size(
- stream_info, i);
- axi_data->num_used_wm++;
- break;
- }
- }
- stream_info->wm[i] = j;
- }
-}
-
-void msm_isp_axi_free_wm(struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe_axi_stream *stream_info)
-{
- int i;
-
- for (i = 0; i < stream_info->num_planes; i++) {
- axi_data->free_wm[stream_info->wm[i]] = 0;
- axi_data->num_used_wm--;
- }
- if (stream_info->stream_src <= IDEAL_RAW)
- axi_data->num_pix_stream++;
- else if (stream_info->stream_src < VFE_AXI_SRC_MAX)
- axi_data->num_rdi_stream++;
-}
-
-void msm_isp_axi_reserve_comp_mask(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe_axi_stream *stream_info)
-{
- int i;
- uint8_t comp_mask = 0;
-
- for (i = 0; i < stream_info->num_planes; i++)
- comp_mask |= 1 << stream_info->wm[i];
-
- for (i = 0; i < axi_data->hw_info->num_comp_mask; i++) {
- if (!axi_data->composite_info[i].stream_handle) {
- axi_data->composite_info[i].stream_handle =
- stream_info->stream_handle;
- axi_data->composite_info[i].
- stream_composite_mask = comp_mask;
- axi_data->num_used_composite_mask++;
- break;
- }
- }
- stream_info->comp_mask_index = i;
-}
-
-void msm_isp_axi_free_comp_mask(struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe_axi_stream *stream_info)
-{
- axi_data->composite_info[stream_info->comp_mask_index].
- stream_composite_mask = 0;
- axi_data->composite_info[stream_info->comp_mask_index].
- stream_handle = 0;
- axi_data->num_used_composite_mask--;
-}
-
-int msm_isp_axi_get_bufq_handles(
- struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info)
-{
- int rc = 0;
-
- if (stream_info->stream_id & ISP_SCRATCH_BUF_BIT) {
- stream_info->bufq_handle =
- vfe_dev->buf_mgr->ops->get_bufq_handle(
- vfe_dev->buf_mgr, stream_info->session_id,
- stream_info->stream_id & ~ISP_SCRATCH_BUF_BIT);
- if (stream_info->bufq_handle == 0) {
- pr_err("%s: Stream 0x%x has no valid buffer queue\n",
- __func__, (unsigned int)stream_info->stream_id);
- rc = -EINVAL;
- return rc;
- }
-
- stream_info->bufq_scratch_handle =
- vfe_dev->buf_mgr->ops->get_bufq_handle(
- vfe_dev->buf_mgr, stream_info->session_id,
- stream_info->stream_id);
- if (stream_info->bufq_scratch_handle == 0) {
- pr_err("%s: Stream 0x%x has no valid buffer queue\n",
- __func__, (unsigned int)stream_info->stream_id);
- rc = -EINVAL;
- return rc;
- }
- } else {
- stream_info->bufq_handle =
- vfe_dev->buf_mgr->ops->get_bufq_handle(
- vfe_dev->buf_mgr, stream_info->session_id,
- stream_info->stream_id);
- if (stream_info->bufq_handle == 0) {
- pr_err("%s: Stream 0x%x has no valid buffer queue\n",
- __func__, (unsigned int)stream_info->stream_id);
- rc = -EINVAL;
- return rc;
- }
- }
- return rc;
-}
-
-int msm_isp_axi_check_stream_state(
- struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd)
-{
- int rc = 0, i;
- unsigned long flags;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- struct msm_vfe_axi_stream *stream_info;
- enum msm_vfe_axi_state valid_state =
- (stream_cfg_cmd->cmd == START_STREAM) ? INACTIVE : ACTIVE;
-
- if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM)
- return -EINVAL;
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) >=
- MAX_NUM_STREAM) {
- return -EINVAL;
- }
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])];
- spin_lock_irqsave(&stream_info->lock, flags);
- if (stream_info->state != valid_state) {
- if ((stream_info->state == PAUSING ||
- stream_info->state == PAUSED ||
- stream_info->state == RESUME_PENDING ||
- stream_info->state == RESUMING) &&
- (stream_cfg_cmd->cmd == STOP_STREAM ||
- stream_cfg_cmd->cmd == STOP_IMMEDIATELY)) {
- stream_info->state = ACTIVE;
- } else {
- pr_err("%s: Invalid stream state: %d\n",
- __func__, stream_info->state);
- spin_unlock_irqrestore(
- &stream_info->lock, flags);
- rc = -EINVAL;
- break;
- }
- }
- spin_unlock_irqrestore(&stream_info->lock, flags);
-
- if (stream_cfg_cmd->cmd == START_STREAM) {
- rc = msm_isp_axi_get_bufq_handles(vfe_dev, stream_info);
- if (rc)
- break;
- }
- }
- return rc;
-}
-
-void msm_isp_update_framedrop_reg(struct vfe_device *vfe_dev,
- uint8_t input_src)
-{
- int i;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- struct msm_vfe_axi_stream *stream_info;
-
- for (i = 0; i < MAX_NUM_STREAM; i++) {
- stream_info = &axi_data->stream_info[i];
- if (stream_info->state != ACTIVE)
- continue;
-
- if (stream_info->runtime_framedrop_update) {
- stream_info->runtime_init_frame_drop--;
- if (stream_info->runtime_init_frame_drop == 0) {
- stream_info->runtime_framedrop_update = 0;
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_framedrop(vfe_dev, stream_info);
- }
- }
- if (stream_info->stream_type == BURST_STREAM &&
- ((1 << SRC_TO_INTF(stream_info->stream_src)) &
- input_src)) {
- if (stream_info->runtime_framedrop_update_burst) {
- stream_info->runtime_framedrop_update_burst = 0;
- stream_info->runtime_burst_frame_count =
- stream_info->runtime_init_frame_drop +
- (stream_info->runtime_num_burst_capture -
- 1) *
- (stream_info->framedrop_period + 1) + 1;
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_framedrop(vfe_dev, stream_info);
- } else {
- stream_info->runtime_burst_frame_count--;
- if (stream_info->
- runtime_burst_frame_count == 0) {
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_framedrop(vfe_dev, stream_info);
- }
- }
- }
- }
-}
-
-void msm_isp_reset_framedrop(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info)
-{
- stream_info->runtime_init_frame_drop = stream_info->init_frame_drop;
- stream_info->runtime_burst_frame_count =
- stream_info->burst_frame_count;
- stream_info->runtime_num_burst_capture =
- stream_info->num_burst_capture;
- stream_info->runtime_framedrop_update = stream_info->framedrop_update;
- vfe_dev->hw_info->vfe_ops.axi_ops.cfg_framedrop(vfe_dev, stream_info);
-}
-
-void msm_isp_notify(struct vfe_device *vfe_dev, uint32_t event_type,
- enum msm_vfe_input_src frame_src, struct msm_isp_timestamp *ts)
-{
- struct msm_isp32_event_data event_data;
-
- memset(&event_data, 0, sizeof(event_data));
- switch (event_type) {
- case ISP_EVENT_SOF:
- if ((frame_src == VFE_PIX_0) && (vfe_dev->isp_sof_debug < 5)) {
- pr_err("%s: PIX0 frame id: %u\n", __func__,
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id);
- vfe_dev->isp_sof_debug++;
- }
- vfe_dev->axi_data.src_info[frame_src].frame_id++;
- if (vfe_dev->axi_data.src_info[frame_src].frame_id == 0)
- vfe_dev->axi_data.src_info[frame_src].frame_id = 1;
- ISP_DBG("%s: frame_src %d frame id: %u\n", __func__,
- frame_src,
- vfe_dev->axi_data.src_info[frame_src].frame_id);
- break;
- case ISP_EVENT_REG_UPDATE:
- vfe_dev->axi_data.src_info[frame_src].last_updt_frm_id = 0;
- break;
- default:
- break;
- }
-
- event_data.input_intf = frame_src;
- event_data.frame_id = vfe_dev->axi_data.src_info[frame_src].frame_id;
- event_data.timestamp = ts->event_time;
- event_data.mono_timestamp = ts->buf_time;
- msm_isp_send_event(vfe_dev, event_type | frame_src, &event_data);
-}
-
-void msm_isp_calculate_framedrop(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe32_axi_stream_request_cmd *stream_cfg_cmd)
-{
- uint32_t framedrop_period = 0;
- struct msm_vfe_axi_stream *stream_info = NULL;
-
- if (HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle) < MAX_NUM_STREAM) {
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle)];
- } else {
- pr_err("%s: Invalid stream handle", __func__);
- return;
- }
- if (!stream_info) {
- pr_err("%s: Stream info is NULL\n", __func__);
- return;
- }
-
- framedrop_period = msm_isp_get_framedrop_period(
- stream_cfg_cmd->frame_skip_pattern);
- stream_info->frame_skip_pattern =
- stream_cfg_cmd->frame_skip_pattern;
- if (stream_cfg_cmd->frame_skip_pattern == SKIP_ALL)
- stream_info->framedrop_pattern = 0x0;
- else
- stream_info->framedrop_pattern = 0x1;
- stream_info->framedrop_period = framedrop_period - 1;
-
- if (stream_cfg_cmd->init_frame_drop < framedrop_period) {
- stream_info->framedrop_pattern <<=
- stream_cfg_cmd->init_frame_drop;
- stream_info->init_frame_drop = 0;
- stream_info->framedrop_update = 0;
- } else {
- stream_info->init_frame_drop = stream_cfg_cmd->init_frame_drop;
- stream_info->framedrop_update = 1;
- }
-
- if (stream_cfg_cmd->burst_count > 0) {
- stream_info->stream_type = BURST_STREAM;
- stream_info->num_burst_capture =
- stream_cfg_cmd->burst_count;
- stream_info->burst_frame_count =
- stream_cfg_cmd->init_frame_drop +
- (stream_cfg_cmd->burst_count - 1) *
- framedrop_period + 1;
- } else {
- stream_info->stream_type = CONTINUOUS_STREAM;
- stream_info->burst_frame_count = 0;
- stream_info->num_burst_capture = 0;
- }
-}
-
-void msm_isp_calculate_bandwidth(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe_axi_stream *stream_info)
-{
- int bpp = 0;
-
- if (stream_info->stream_src < RDI_INTF_0) {
- stream_info->bandwidth =
- (axi_data->src_info[VFE_PIX_0].pixel_clock /
- axi_data->src_info[VFE_PIX_0].width) *
- stream_info->max_width;
- stream_info->bandwidth = (unsigned long)stream_info->bandwidth *
- stream_info->format_factor / ISP_Q2;
- } else {
- int rdi = SRC_TO_INTF(stream_info->stream_src);
-
- bpp = msm_isp_get_bit_per_pixel(stream_info->output_format);
- if (rdi < VFE_SRC_MAX)
- stream_info->bandwidth =
- (axi_data->src_info[rdi].pixel_clock / 8) * bpp;
- else
- pr_err("%s: Invalid rdi interface\n", __func__);
- }
-}
-
-#ifdef CONFIG_MSM_AVTIMER
-void msm_isp_start_avtimer(void)
-{
- avcs_core_open();
- avcs_core_disable_power_collapse(1);
-}
-
-static inline void msm_isp_get_avtimer_ts(
- struct msm_isp_timestamp *time_stamp)
-{
- int rc = 0;
- uint32_t avtimer_usec = 0;
- uint64_t avtimer_tick = 0;
-
- rc = avcs_core_query_timer(&avtimer_tick);
- if (rc < 0) {
- pr_err("%s: Error: Invalid AVTimer Tick, rc=%d\n",
- __func__, rc);
- /* In case of error return zero AVTimer Tick Value */
- time_stamp->vt_time.tv_sec = 0;
- time_stamp->vt_time.tv_usec = 0;
- } else {
- avtimer_usec = do_div(avtimer_tick, USEC_PER_SEC);
- time_stamp->vt_time.tv_sec = (uint32_t)(avtimer_tick);
- time_stamp->vt_time.tv_usec = avtimer_usec;
- pr_debug("%s: AVTimer TS = %u:%u\n", __func__,
- (uint32_t)(avtimer_tick), avtimer_usec);
- }
-}
-#else
-void msm_isp_start_avtimer(void)
-{
- pr_err("AV Timer is not supported\n");
-}
-
-static inline void msm_isp_get_avtimer_ts(
- struct msm_isp_timestamp *time_stamp)
-{
- pr_err_ratelimited("%s: Error: AVTimer driver not available\n",
- __func__);
- time_stamp->vt_time.tv_sec = 0;
- time_stamp->vt_time.tv_usec = 0;
-}
-#endif
-
-int msm_isp_request_axi_stream(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0, i;
- uint32_t io_format = 0;
- struct msm_vfe32_axi_stream_request_cmd *stream_cfg_cmd = arg;
- struct msm_vfe_axi_stream *stream_info;
-
- rc = msm_isp_axi_create_stream(
- &vfe_dev->axi_data, stream_cfg_cmd);
- if (rc) {
- pr_err("%s: create stream failed\n", __func__);
- return rc;
- }
-
- rc = msm_isp_validate_axi_request(
- &vfe_dev->axi_data, stream_cfg_cmd);
- if (rc) {
- pr_err("%s: Request validation failed\n", __func__);
- if (HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle) <
- MAX_NUM_STREAM)
- msm_isp_axi_destroy_stream(&vfe_dev->axi_data,
- HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle));
- return rc;
- }
- stream_info = &vfe_dev->axi_data.
- stream_info[HANDLE_TO_IDX(stream_cfg_cmd->axi_stream_handle)];
- if (!stream_info) {
- pr_err("%s: can not find stream handle %x\n", __func__,
- stream_cfg_cmd->axi_stream_handle);
- return -EINVAL;
- }
-
- stream_info->memory_input = stream_cfg_cmd->memory_input;
-
- msm_isp_axi_reserve_wm(&vfe_dev->axi_data, stream_info);
-
- if (stream_info->stream_src < RDI_INTF_0) {
- io_format = vfe_dev->axi_data.src_info[VFE_PIX_0].input_format;
- if (stream_info->stream_src == CAMIF_RAW ||
- stream_info->stream_src == IDEAL_RAW) {
- if (stream_info->stream_src == CAMIF_RAW &&
- io_format != stream_info->output_format)
- pr_debug("%s: Overriding input format\n",
- __func__);
-
- io_format = stream_info->output_format;
- }
- rc = vfe_dev->hw_info->vfe_ops.axi_ops.cfg_io_format(
- vfe_dev, stream_info->stream_src, io_format);
- if (rc) {
- pr_err("%s: cfg io format failed\n", __func__);
- msm_isp_axi_free_wm(&vfe_dev->axi_data,
- stream_info);
- msm_isp_axi_destroy_stream(&vfe_dev->axi_data,
- HANDLE_TO_IDX(
- stream_cfg_cmd->axi_stream_handle));
- return rc;
- }
- }
-
- msm_isp_calculate_framedrop(&vfe_dev->axi_data, stream_cfg_cmd);
- if (stream_cfg_cmd->vt_enable && !vfe_dev->vt_enable) {
- vfe_dev->vt_enable = stream_cfg_cmd->vt_enable;
- msm_isp_start_avtimer();
- }
- if (stream_info->num_planes > 1) {
- msm_isp_axi_reserve_comp_mask(
- &vfe_dev->axi_data, stream_info);
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_comp_mask(vfe_dev, stream_info);
- } else {
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_wm_irq_mask(vfe_dev, stream_info);
- }
-
- for (i = 0; i < stream_info->num_planes; i++) {
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_wm_reg(vfe_dev, stream_info, i);
-
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_wm_xbar_reg(vfe_dev, stream_info, i);
- }
- return rc;
-}
-
-int msm_isp_release_axi_stream(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0, i;
- struct msm_vfe_axi_stream_release_cmd *stream_release_cmd = arg;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_stream_cfg_cmd stream_cfg;
-
-
- if (HANDLE_TO_IDX(stream_release_cmd->stream_handle) >=
- MAX_NUM_STREAM) {
- pr_err("%s: Invalid stream handle\n", __func__);
- return -EINVAL;
- }
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(stream_release_cmd->stream_handle)];
- if (stream_info->state == AVAILABLE) {
- pr_err("%s: Stream already released\n", __func__);
- return -EINVAL;
- } else if (stream_info->state != INACTIVE) {
- stream_cfg.cmd = STOP_STREAM;
- stream_cfg.num_streams = 1;
- stream_cfg.stream_handle[0] = stream_release_cmd->stream_handle;
- msm_isp_cfg_axi_stream(vfe_dev, (void *) &stream_cfg);
- }
-
- for (i = 0; i < stream_info->num_planes; i++) {
- vfe_dev->hw_info->vfe_ops.axi_ops.
- clear_wm_reg(vfe_dev, stream_info, i);
-
- vfe_dev->hw_info->vfe_ops.axi_ops.
- clear_wm_xbar_reg(vfe_dev, stream_info, i);
- }
-
- if (stream_info->num_planes > 1) {
- vfe_dev->hw_info->vfe_ops.axi_ops.
- clear_comp_mask(vfe_dev, stream_info);
- msm_isp_axi_free_comp_mask(&vfe_dev->axi_data, stream_info);
- } else {
- vfe_dev->hw_info->vfe_ops.axi_ops.
- clear_wm_irq_mask(vfe_dev, stream_info);
- }
-
- vfe_dev->hw_info->vfe_ops.axi_ops.clear_framedrop(vfe_dev, stream_info);
- msm_isp_axi_free_wm(axi_data, stream_info);
-
- msm_isp_axi_destroy_stream(&vfe_dev->axi_data,
- HANDLE_TO_IDX(stream_release_cmd->stream_handle));
-
- return rc;
-}
-
-static void msm_isp_axi_stream_enable_cfg(
- struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info)
-{
- int i;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
-
- if (stream_info->state == INACTIVE)
- return;
- for (i = 0; i < stream_info->num_planes; i++) {
- if (stream_info->state == START_PENDING ||
- stream_info->state == RESUME_PENDING) {
- vfe_dev->hw_info->vfe_ops.axi_ops.
- enable_wm(vfe_dev, stream_info->wm[i], 1);
- } else {
- vfe_dev->hw_info->vfe_ops.axi_ops.
- enable_wm(vfe_dev, stream_info->wm[i], 0);
- /* Issue a reg update for Raw Snapshot Case
- * since we dont have reg update ack
- */
- if (stream_info->stream_src == CAMIF_RAW ||
- stream_info->stream_src == IDEAL_RAW) {
- vfe_dev->hw_info->vfe_ops.core_ops.
- reg_update(vfe_dev, (1 << VFE_PIX_0));
- }
- }
- }
-
- if (stream_info->state == START_PENDING)
- axi_data->num_active_stream++;
- else if (stream_info->state == STOP_PENDING)
- axi_data->num_active_stream--;
-}
-
-void msm_isp_axi_stream_update(struct vfe_device *vfe_dev, uint8_t input_src)
-{
- int i;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
-
- for (i = 0; i < MAX_NUM_STREAM; i++) {
- if (axi_data->stream_info[i].state == START_PENDING ||
- axi_data->stream_info[i].state ==
- STOP_PENDING) {
- if ((1 <<
- SRC_TO_INTF(axi_data->stream_info[i].
- stream_src)) &
- input_src) {
- msm_isp_axi_stream_enable_cfg(
- vfe_dev, &axi_data->stream_info[i]);
- axi_data->stream_info[i].state =
- axi_data->stream_info[i].state ==
- START_PENDING ? STARTING : STOPPING;
- }
- } else if (axi_data->stream_info[i].state == STARTING ||
- axi_data->stream_info[i].state == STOPPING) {
- if ((1 <<
- SRC_TO_INTF(axi_data->stream_info[i].
- stream_src)) &
- input_src) {
- axi_data->stream_info[i].state =
- axi_data->stream_info[i].state == STARTING ?
- ACTIVE : INACTIVE;
- vfe_dev->axi_data.stream_update--;
- }
- }
- }
-
- if (vfe_dev->axi_data.pipeline_update == DISABLE_CAMIF ||
- (vfe_dev->axi_data.pipeline_update ==
- DISABLE_CAMIF_IMMEDIATELY)) {
- vfe_dev->hw_info->vfe_ops.stats_ops.
- enable_module(vfe_dev, 0xFF, 0);
- vfe_dev->axi_data.pipeline_update = NO_UPDATE;
- }
-
- if (vfe_dev->axi_data.stream_update == 0)
- complete(&vfe_dev->stream_config_complete);
-}
-
-static void msm_isp_reload_ping_pong_offset(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info)
-{
- int i, j;
- uint32_t flag;
- struct msm_isp_buffer *buf;
-
- for (i = 0; i < 2; i++) {
- buf = stream_info->buf[i];
- if (!buf)
- continue;
- flag = i ? VFE_PONG_FLAG : VFE_PING_FLAG;
- for (j = 0; j < stream_info->num_planes; j++) {
- vfe_dev->hw_info->vfe_ops.axi_ops.update_ping_pong_addr(
- vfe_dev, stream_info->wm[j], flag,
- buf->mapped_info[j].paddr +
- stream_info->plane_cfg[j].plane_addr_offset);
- }
- }
-}
-
-void msm_isp_axi_cfg_update(struct vfe_device *vfe_dev)
-{
- int i, j;
- uint32_t update_state;
- unsigned long flags;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- struct msm_vfe_axi_stream *stream_info;
-
- for (i = 0; i < MAX_NUM_STREAM; i++) {
- stream_info = &axi_data->stream_info[i];
- if (stream_info->stream_type == BURST_STREAM ||
- stream_info->state == AVAILABLE)
- continue;
- spin_lock_irqsave(&stream_info->lock, flags);
- if (stream_info->state == PAUSING) {
- /*AXI Stopped, apply update*/
- stream_info->state = PAUSED;
- msm_isp_reload_ping_pong_offset(vfe_dev, stream_info);
- for (j = 0; j < stream_info->num_planes; j++)
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_wm_reg(vfe_dev, stream_info, j);
- /*Resume AXI*/
- stream_info->state = RESUME_PENDING;
- msm_isp_axi_stream_enable_cfg(
- vfe_dev, &axi_data->stream_info[i]);
- stream_info->state = RESUMING;
- } else if (stream_info->state == RESUMING) {
- stream_info->runtime_output_format =
- stream_info->output_format;
- stream_info->state = ACTIVE;
- }
- spin_unlock_irqrestore(&stream_info->lock, flags);
- }
-
- update_state = atomic_dec_return(&axi_data->axi_cfg_update);
-}
-
-static void msm_isp_cfg_pong_address(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info)
-{
- int i;
- struct msm_isp_buffer *buf = stream_info->buf[0];
-
- for (i = 0; i < stream_info->num_planes; i++)
- vfe_dev->hw_info->vfe_ops.axi_ops.update_ping_pong_addr(
- vfe_dev, stream_info->wm[i],
- VFE_PONG_FLAG, buf->mapped_info[i].paddr +
- stream_info->plane_cfg[i].plane_addr_offset);
- stream_info->buf[1] = buf;
-}
-
-static void msm_isp_get_done_buf(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info, uint32_t pingpong_status,
- struct msm_isp_buffer **done_buf)
-{
- uint32_t pingpong_bit = 0, i;
-
- pingpong_bit = (~(pingpong_status >> stream_info->wm[0]) & 0x1);
- for (i = 0; i < stream_info->num_planes; i++) {
- if (pingpong_bit !=
- (~(pingpong_status >> stream_info->wm[i]) & 0x1)) {
- pr_debug("%s: Write master ping pong mismatch. Status: 0x%x\n",
- __func__, pingpong_status);
- }
- }
-
- *done_buf = stream_info->buf[pingpong_bit];
-
- if (stream_info->controllable_output) {
- stream_info->buf[pingpong_bit] = NULL;
- stream_info->request_frm_num--;
- }
-}
-
-static int msm_isp_cfg_ping_pong_address(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info, uint32_t pingpong_status,
- uint32_t pingpong_bit)
-{
- int i, rc = -1;
- struct msm_isp_buffer *buf = NULL;
- uint32_t bufq_handle = 0, frame_id = 0;
- uint32_t stream_idx = HANDLE_TO_IDX(stream_info->stream_handle);
-
- if (stream_idx >= MAX_NUM_STREAM) {
- pr_err("%s: Invalid stream_idx", __func__);
- return rc;
- }
-
- if (stream_info->controllable_output && !stream_info->request_frm_num)
- return 0;
-
- frame_id = vfe_dev->axi_data.
- src_info[SRC_TO_INTF(stream_info->stream_src)].frame_id;
- if (frame_id && stream_info->frame_id &&
- stream_info->frame_id == frame_id) {
- /* This could happen if reg update ack is delayed */
- pr_err("%s: Duplicate frame streamId:%d stream_fid:%d frame_id:%d\n",
- __func__, stream_info->stream_id, stream_info->frame_id,
- frame_id);
- vfe_dev->error_info.stream_framedrop_count[stream_idx]++;
- return rc;
- }
-
- bufq_handle = stream_info->bufq_handle;
- if (SRC_TO_INTF(stream_info->stream_src) < VFE_SRC_MAX)
- rc = vfe_dev->buf_mgr->ops->get_buf(vfe_dev->buf_mgr,
- vfe_dev->pdev->id, bufq_handle, &buf);
- else {
- pr_err("%s: Invalid stream index\n", __func__);
- rc = -1;
- }
-
- if (rc < 0) {
- vfe_dev->error_info.stream_framedrop_count[stream_idx]++;
- return rc;
- }
-
- if (buf->num_planes != stream_info->num_planes) {
- pr_err("%s: Invalid buffer\n", __func__);
- rc = -EINVAL;
- goto buf_error;
- }
-
- for (i = 0; i < stream_info->num_planes; i++)
- vfe_dev->hw_info->vfe_ops.axi_ops.update_ping_pong_addr(
- vfe_dev, stream_info->wm[i],
- pingpong_status, buf->mapped_info[i].paddr +
- stream_info->plane_cfg[i].plane_addr_offset);
-
- stream_info->buf[pingpong_bit] = buf;
-
- return 0;
-buf_error:
- vfe_dev->buf_mgr->ops->put_buf(vfe_dev->buf_mgr,
- buf->bufq_handle, buf->buf_idx);
- return rc;
-}
-
-static void msm_isp_process_done_buf(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info, struct msm_isp_buffer *buf,
- struct msm_isp_timestamp *ts)
-{
- int rc;
- struct msm_isp32_event_data buf_event;
- struct timeval *time_stamp;
- uint32_t stream_idx = HANDLE_TO_IDX(stream_info->stream_handle);
- uint32_t frame_id;
- uint32_t buf_src;
-
- memset(&buf_event, 0, sizeof(buf_event));
-
- if (stream_idx >= MAX_NUM_STREAM) {
- pr_err("%s: Invalid stream_idx", __func__);
- return;
- }
-
- if (SRC_TO_INTF(stream_info->stream_src) < VFE_SRC_MAX)
- frame_id = vfe_dev->axi_data.
- src_info[SRC_TO_INTF(stream_info->stream_src)].frame_id;
- else {
- pr_err("%s: Invalid stream index, put buf back to vb2 queue\n",
- __func__);
- vfe_dev->buf_mgr->ops->put_buf(vfe_dev->buf_mgr,
- buf->bufq_handle, buf->buf_idx);
- return;
- }
-
- if (buf && ts) {
- if (vfe_dev->vt_enable) {
- msm_isp_get_avtimer_ts(ts);
- time_stamp = &ts->vt_time;
- } else
- time_stamp = &ts->buf_time;
-
- rc = vfe_dev->buf_mgr->ops->get_buf_src(vfe_dev->buf_mgr,
- buf->bufq_handle, &buf_src);
- if (stream_info->buf_divert && rc == 0 &&
- buf_src != MSM_ISP_BUFFER_SRC_SCRATCH) {
- rc = vfe_dev->buf_mgr->ops->buf_divert(vfe_dev->buf_mgr,
- buf->bufq_handle, buf->buf_idx,
- time_stamp, frame_id);
- /* Buf divert return value represent whether the buf
- * can be diverted. A positive return value means
- * other ISP hardware is still processing the frame.
- */
- if (rc == 0) {
- buf_event.input_intf =
- SRC_TO_INTF(stream_info->stream_src);
- buf_event.frame_id = frame_id;
- buf_event.timestamp = *time_stamp;
- buf_event.u.buf_done.session_id =
- stream_info->session_id;
- buf_event.u.buf_done.stream_id =
- stream_info->stream_id;
- buf_event.u.buf_done.handle =
- stream_info->bufq_handle;
- buf_event.u.buf_done.buf_idx = buf->buf_idx;
- buf_event.u.buf_done.output_format =
- stream_info->runtime_output_format;
- msm_isp_send_event(vfe_dev,
- ISP_EVENT_BUF_DIVERT + stream_idx,
- &buf_event);
- }
- } else {
- buf_event.input_intf =
- SRC_TO_INTF(stream_info->stream_src);
- buf_event.frame_id = frame_id;
- buf_event.timestamp = ts->buf_time;
- buf_event.u.buf_done.session_id =
- stream_info->session_id;
- buf_event.u.buf_done.stream_id =
- stream_info->stream_id;
- buf_event.u.buf_done.output_format =
- stream_info->runtime_output_format;
- msm_isp_send_event(vfe_dev,
- ISP_EVENT_BUF_DONE, &buf_event);
- vfe_dev->buf_mgr->ops->buf_done(vfe_dev->buf_mgr,
- buf->bufq_handle, buf->buf_idx,
- time_stamp, frame_id,
- stream_info->runtime_output_format);
- }
- }
-}
-
-static enum msm_isp_camif_update_state
- msm_isp_get_camif_update_state(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd)
-{
- int i;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- uint8_t pix_stream_cnt = 0, cur_pix_stream_cnt;
-
- cur_pix_stream_cnt =
- axi_data->src_info[VFE_PIX_0].pix_stream_count +
- axi_data->src_info[VFE_PIX_0].raw_stream_count;
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- stream_info =
- &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])];
- if (stream_info->stream_src < RDI_INTF_0)
- pix_stream_cnt++;
- }
-
- if ((pix_stream_cnt) &&
- (axi_data->src_info[VFE_PIX_0].input_mux != EXTERNAL_READ)) {
-
- if (cur_pix_stream_cnt == 0 && pix_stream_cnt &&
- stream_cfg_cmd->cmd == START_STREAM)
- return ENABLE_CAMIF;
- else if (cur_pix_stream_cnt &&
- (cur_pix_stream_cnt - pix_stream_cnt) == 0 &&
- stream_cfg_cmd->cmd == STOP_STREAM)
- return DISABLE_CAMIF;
- else if (cur_pix_stream_cnt &&
- (cur_pix_stream_cnt - pix_stream_cnt) == 0 &&
- stream_cfg_cmd->cmd == STOP_IMMEDIATELY)
- return DISABLE_CAMIF_IMMEDIATELY;
- }
-
- return NO_UPDATE;
-}
-
-static void msm_isp_update_camif_output_count(
- struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd)
-{
- int i;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
-
- if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM)
- return;
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) >=
- MAX_NUM_STREAM) {
- return;
- }
- stream_info =
- &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])];
- if (stream_info->stream_src >= RDI_INTF_0)
- continue;
- if (stream_info->stream_src == PIX_ENCODER ||
- stream_info->stream_src == PIX_VIEWFINDER ||
- stream_info->stream_src == PIX_VIDEO ||
- stream_info->stream_src == IDEAL_RAW) {
- if (stream_cfg_cmd->cmd == START_STREAM)
- vfe_dev->axi_data.src_info[VFE_PIX_0].
- pix_stream_count++;
- else
- vfe_dev->axi_data.src_info[VFE_PIX_0].
- pix_stream_count--;
- } else if (stream_info->stream_src == CAMIF_RAW) {
- if (stream_cfg_cmd->cmd == START_STREAM)
- vfe_dev->axi_data.src_info[VFE_PIX_0].
- raw_stream_count++;
- else
- vfe_dev->axi_data.src_info[VFE_PIX_0].
- raw_stream_count--;
- }
- }
-}
-
-
-static void msm_isp_update_rdi_output_count(
- struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd)
-{
- int i;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
-
- if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM)
- return;
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])
- > MAX_NUM_STREAM)
- return;
- stream_info =
- &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])];
- if (stream_info->stream_src < RDI_INTF_0)
- continue;
- if (stream_info->stream_src == RDI_INTF_0) {
- if (stream_cfg_cmd->cmd == START_STREAM)
- vfe_dev->axi_data.src_info[VFE_RAW_0].
- raw_stream_count++;
- else
- vfe_dev->axi_data.src_info[VFE_RAW_0].
- raw_stream_count--;
- } else if (stream_info->stream_src == RDI_INTF_1) {
- if (stream_cfg_cmd->cmd == START_STREAM)
- vfe_dev->axi_data.src_info[VFE_RAW_1].
- raw_stream_count++;
- else
- vfe_dev->axi_data.src_info[VFE_RAW_1].
- raw_stream_count--;
- } else if (stream_info->stream_src == RDI_INTF_2) {
- if (stream_cfg_cmd->cmd == START_STREAM)
- vfe_dev->axi_data.src_info[VFE_RAW_2].
- raw_stream_count++;
- else
- vfe_dev->axi_data.src_info[VFE_RAW_2].
- raw_stream_count--;
- }
-
- }
-}
-
-static uint8_t msm_isp_get_curr_stream_cnt(
- struct vfe_device *vfe_dev)
-{
- uint8_t curr_stream_cnt = 0;
-
- curr_stream_cnt = vfe_dev->axi_data.src_info[VFE_RAW_0].
- raw_stream_count +
- vfe_dev->axi_data.src_info[VFE_RAW_1].
- raw_stream_count +
- vfe_dev->axi_data.src_info[VFE_RAW_2].
- raw_stream_count +
- vfe_dev->axi_data.src_info[VFE_PIX_0].
- pix_stream_count +
- vfe_dev->axi_data.src_info[VFE_PIX_0].
- raw_stream_count;
-
- return curr_stream_cnt;
-}
-
-/*Factor in Q2 format*/
-#define ISP_DEFAULT_FORMAT_FACTOR 6
-#define ISP_BUS_UTILIZATION_FACTOR 1536 /* 1.5 in Q10 format */
-static int msm_isp_update_stream_bandwidth(struct vfe_device *vfe_dev)
-{
- int i, rc = 0;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- uint64_t total_pix_bandwidth = 0, total_rdi_bandwidth = 0;
- uint32_t num_pix_streams = 0;
- uint32_t num_rdi_streams = 0;
- uint32_t total_streams = 0;
- uint64_t total_bandwidth = 0;
- uint32_t bus_util_factor = ISP_BUS_UTILIZATION_FACTOR;
-
- for (i = 0; i < MAX_NUM_STREAM; i++) {
- stream_info = &axi_data->stream_info[i];
- if (stream_info->state == ACTIVE ||
- stream_info->state == START_PENDING) {
- if (stream_info->stream_src < RDI_INTF_0) {
- total_pix_bandwidth += stream_info->bandwidth;
- num_pix_streams++;
- } else {
- total_rdi_bandwidth += stream_info->bandwidth;
- num_rdi_streams++;
- }
- }
- }
- total_bandwidth = total_pix_bandwidth + total_rdi_bandwidth;
- total_streams = num_pix_streams + num_rdi_streams;
- if (vfe_dev->bus_util_factor)
- bus_util_factor = vfe_dev->bus_util_factor;
- ISP_DBG("%s: bus_util_factor = %u\n", __func__, bus_util_factor);
-
- if (total_streams == 1)
- rc = msm_isp_update_bandwidth(ISP_VFE0 + vfe_dev->pdev->id,
- total_bandwidth ,
- (total_bandwidth * bus_util_factor / ISP_Q10));
- else
- rc = msm_isp_update_bandwidth(ISP_VFE0 + vfe_dev->pdev->id,
- (total_bandwidth + MSM_ISP_MIN_AB), (total_bandwidth *
- bus_util_factor / ISP_Q10 + MSM_ISP_MIN_IB));
- if (rc < 0)
- pr_err("%s: update failed\n", __func__);
-
- return rc;
-}
-
-static int msm_isp_axi_wait_for_cfg_done(struct vfe_device *vfe_dev,
- enum msm_isp_camif_update_state camif_update)
-{
- int rc;
- unsigned long flags;
-
- spin_lock_irqsave(&vfe_dev->shared_data_lock, flags);
- init_completion(&vfe_dev->stream_config_complete);
- vfe_dev->axi_data.pipeline_update = camif_update;
- spin_unlock_irqrestore(&vfe_dev->shared_data_lock, flags);
- rc = wait_for_completion_timeout(
- &vfe_dev->stream_config_complete,
- msecs_to_jiffies(VFE_MAX_CFG_TIMEOUT));
- if (rc == 0) {
- pr_err("%s: wait timeout\n", __func__);
- rc = -1;
- } else {
- rc = 0;
- }
- return rc;
-}
-
-static int msm_isp_init_stream_ping_pong_reg(
- struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info)
-{
- int rc = 0;
- /*Set address for both PING & PONG register */
- rc = msm_isp_cfg_ping_pong_address(vfe_dev,
- stream_info, VFE_PING_FLAG, 0);
- if (rc < 0) {
- pr_err("%s: No free buffer for ping\n",
- __func__);
- return rc;
- }
-
- /* For burst stream of one capture, only one buffer
- * is allocated. Duplicate ping buffer address to pong
- * buffer to ensure hardware write to a valid address
- */
- if (stream_info->stream_type == BURST_STREAM &&
- stream_info->runtime_num_burst_capture <= 1) {
- msm_isp_cfg_pong_address(vfe_dev, stream_info);
- } else {
- rc = msm_isp_cfg_ping_pong_address(vfe_dev,
- stream_info, VFE_PONG_FLAG, 1);
- if (rc < 0) {
- pr_err("%s: No free buffer for pong\n",
- __func__);
- return rc;
- }
- }
- return rc;
-}
-
-static void msm_isp_deinit_stream_ping_pong_reg(
- struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info)
-{
- int i;
-
- for (i = 0; i < 2; i++) {
- struct msm_isp_buffer *buf;
-
- buf = stream_info->buf[i];
- if (buf) {
- vfe_dev->buf_mgr->ops->put_buf(vfe_dev->buf_mgr,
- buf->bufq_handle, buf->buf_idx);
- }
- }
-}
-
-static void msm_isp_get_stream_wm_mask(
- struct msm_vfe_axi_stream *stream_info,
- uint32_t *wm_reload_mask)
-{
- int i;
-
- for (i = 0; i < stream_info->num_planes; i++)
- *wm_reload_mask |= (1 << stream_info->wm[i]);
-}
-
-int msm_isp_axi_halt(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_halt_cmd *halt_cmd)
-{
- int rc = 0;
-
- if (halt_cmd->overflow_detected) {
- /*Store current IRQ mask*/
- if (vfe_dev->error_info.overflow_recover_irq_mask0 == 0) {
- vfe_dev->hw_info->vfe_ops.core_ops.get_irq_mask(vfe_dev,
- &vfe_dev->error_info.overflow_recover_irq_mask0,
- &vfe_dev->error_info.overflow_recover_irq_mask1);
- }
- atomic_set(&vfe_dev->error_info.overflow_state,
- OVERFLOW_DETECTED);
- }
-
- rc = vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev, 1);
-
- if (halt_cmd->stop_camif) {
- vfe_dev->hw_info->vfe_ops.core_ops.
- update_camif_state(vfe_dev, DISABLE_CAMIF_IMMEDIATELY);
- }
-
- return rc;
-}
-
-int msm_isp_axi_reset(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_reset_cmd *reset_cmd)
-{
- int rc = 0, i, j;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- struct msm_isp_bufq *bufq = NULL;
-
- if (!reset_cmd) {
- pr_err("%s: NULL pointer reset cmd %pK\n", __func__, reset_cmd);
- rc = -1;
- return rc;
- }
-
- rc = vfe_dev->hw_info->vfe_ops.core_ops.reset_hw(vfe_dev,
- 0, reset_cmd->blocking);
-
- for (i = 0, j = 0; j < axi_data->num_active_stream &&
- i < MAX_NUM_STREAM; i++, j++) {
- stream_info = &axi_data->stream_info[i];
- if (stream_info->stream_src >= VFE_AXI_SRC_MAX) {
- rc = -1;
- pr_err("%s invalid stream src = %d\n", __func__,
- stream_info->stream_src);
- break;
- }
- if (stream_info->state != ACTIVE) {
- j--;
- continue;
- }
-
- bufq = vfe_dev->buf_mgr->ops->get_bufq(vfe_dev->buf_mgr,
- stream_info->bufq_handle);
- if (!bufq) {
- pr_err("%s: bufq null %pK by handle %x\n", __func__,
- bufq, stream_info->bufq_handle);
- continue;
- }
-
- if (bufq->buf_type != ISP_SHARE_BUF) {
- msm_isp_deinit_stream_ping_pong_reg(vfe_dev,
- stream_info);
- } else {
- vfe_dev->buf_mgr->ops->flush_buf(vfe_dev->buf_mgr,
- stream_info->bufq_handle,
- MSM_ISP_BUFFER_FLUSH_ALL);
- }
- axi_data->src_info[SRC_TO_INTF(stream_info->stream_src)].
- frame_id = reset_cmd->frame_id;
- msm_isp_reset_burst_count_and_frame_drop(vfe_dev, stream_info);
- }
-
- if (rc < 0)
- pr_err("%s Error! reset hw Timed out\n", __func__);
-
- return rc;
-}
-
-int msm_isp_axi_restart(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_restart_cmd *restart_cmd)
-{
- int rc = 0, i, j;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- uint32_t wm_reload_mask = 0x0;
-
- for (i = 0, j = 0; j < axi_data->num_active_stream &&
- i < MAX_NUM_STREAM; i++, j++) {
- stream_info = &axi_data->stream_info[i];
- if (stream_info->state != ACTIVE) {
- j--;
- continue;
- }
- msm_isp_get_stream_wm_mask(stream_info, &wm_reload_mask);
- msm_isp_init_stream_ping_pong_reg(vfe_dev, stream_info);
- }
-
- vfe_dev->hw_info->vfe_ops.axi_ops.reload_wm(vfe_dev, wm_reload_mask);
- rc = vfe_dev->hw_info->vfe_ops.axi_ops.restart(vfe_dev, 0,
- restart_cmd->enable_camif);
- if (rc < 0)
- pr_err("%s Error restarting HW\n", __func__);
-
- return rc;
-}
-
-static int msm_isp_axi_update_cgc_override(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd,
- uint8_t cgc_override)
-{
- int i = 0, j = 0;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
-
- if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM)
- return -EINVAL;
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) >=
- MAX_NUM_STREAM) {
- return -EINVAL;
- }
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])];
- for (j = 0; j < stream_info->num_planes; j++) {
- if (vfe_dev->hw_info->vfe_ops.axi_ops.
- update_cgc_override)
- vfe_dev->hw_info->vfe_ops.axi_ops.
- update_cgc_override(vfe_dev,
- stream_info->wm[j], cgc_override);
- }
- }
- return 0;
-}
-
-static int msm_isp_start_axi_stream(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd,
- enum msm_isp_camif_update_state camif_update)
-{
- int i, rc = 0;
- uint8_t src_state, wait_for_complete = 0;
- uint32_t wm_reload_mask = 0x0;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- uint8_t init_frm_drop = 0;
-
- if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM)
- return -EINVAL;
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) >=
- MAX_NUM_STREAM) {
- return -EINVAL;
- }
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])];
- if (SRC_TO_INTF(stream_info->stream_src) < VFE_SRC_MAX)
- src_state = axi_data->src_info[
- SRC_TO_INTF(stream_info->stream_src)].active;
- else {
- pr_err("%s: invalid src info index\n", __func__);
- return -EINVAL;
- }
-
- msm_isp_calculate_bandwidth(axi_data, stream_info);
- msm_isp_reset_framedrop(vfe_dev, stream_info);
- init_frm_drop = stream_info->init_frame_drop;
- msm_isp_get_stream_wm_mask(stream_info, &wm_reload_mask);
- rc = msm_isp_init_stream_ping_pong_reg(vfe_dev, stream_info);
- if (rc < 0) {
- pr_err("%s: No buffer for stream %d\n",
- __func__,
- HANDLE_TO_IDX(
- stream_cfg_cmd->stream_handle[i]));
- return rc;
- }
-
- stream_info->state = START_PENDING;
- if (src_state) {
- wait_for_complete = 1;
- } else {
- if (vfe_dev->dump_reg)
- msm_camera_io_dump_2(vfe_dev->vfe_base, 0x900);
-
- /*Configure AXI start bits to start immediately*/
- msm_isp_axi_stream_enable_cfg(vfe_dev, stream_info);
- stream_info->state = ACTIVE;
- }
- if (SRC_TO_INTF(stream_info->stream_src) != VFE_PIX_0 &&
- stream_info->stream_src < VFE_AXI_SRC_MAX) {
- vfe_dev->axi_data.src_info[SRC_TO_INTF(
- stream_info->stream_src)].frame_id =
- init_frm_drop;
- }
- }
- msm_isp_update_stream_bandwidth(vfe_dev);
- vfe_dev->hw_info->vfe_ops.axi_ops.reload_wm(vfe_dev, wm_reload_mask);
- vfe_dev->hw_info->vfe_ops.core_ops.reg_update(vfe_dev, 0xF);
- msm_isp_update_camif_output_count(vfe_dev, stream_cfg_cmd);
- msm_isp_update_rdi_output_count(vfe_dev, stream_cfg_cmd);
- if (camif_update == ENABLE_CAMIF) {
- atomic_set(&vfe_dev->error_info.overflow_state,
- NO_OVERFLOW);
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id = 0;
- vfe_dev->hw_info->vfe_ops.core_ops.
- update_camif_state(vfe_dev, camif_update);
- }
-
- if (wait_for_complete) {
- vfe_dev->axi_data.stream_update = stream_cfg_cmd->num_streams;
- rc = msm_isp_axi_wait_for_cfg_done(vfe_dev, camif_update);
- }
-
- return rc;
-}
-
-static int msm_isp_stop_axi_stream(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd,
- enum msm_isp_camif_update_state camif_update)
-{
- int i, rc = 0;
- uint8_t wait_for_complete_for_this_stream = 0, cur_stream_cnt = 0;
- uint8_t wait_for_complete = 0;
- struct msm_vfe_axi_stream *stream_info = NULL;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- int ext_read =
- axi_data->src_info[VFE_PIX_0].input_mux == EXTERNAL_READ;
-
- if (stream_cfg_cmd->num_streams > MAX_NUM_STREAM ||
- stream_cfg_cmd->num_streams == 0)
- return -EINVAL;
-
- msm_isp_update_camif_output_count(vfe_dev, stream_cfg_cmd);
- msm_isp_update_rdi_output_count(vfe_dev, stream_cfg_cmd);
- cur_stream_cnt = msm_isp_get_curr_stream_cnt(vfe_dev);
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- if (HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]) >=
- MAX_NUM_STREAM) {
- return -EINVAL;
- }
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])];
- wait_for_complete_for_this_stream = 0;
- stream_info->state = STOP_PENDING;
- if (stream_info->stream_src == CAMIF_RAW ||
- stream_info->stream_src == IDEAL_RAW) {
- /* We dont get reg update IRQ for raw snapshot
- * so frame skip cant be ocnfigured
- */
- if ((camif_update != DISABLE_CAMIF_IMMEDIATELY) &&
- (!ext_read))
- wait_for_complete_for_this_stream = 1;
- } else if (stream_info->stream_type == BURST_STREAM &&
- stream_info->runtime_num_burst_capture == 0) {
- /* Configure AXI writemasters to stop immediately
- * since for burst case, write masters already skip
- * all frames.
- */
- if (stream_info->stream_src == RDI_INTF_0 ||
- stream_info->stream_src == RDI_INTF_1 ||
- stream_info->stream_src == RDI_INTF_2)
- wait_for_complete_for_this_stream = 1;
- } else {
- if ((camif_update != DISABLE_CAMIF_IMMEDIATELY) &&
- (!ext_read) &&
- !(stream_info->stream_src == RDI_INTF_0 ||
- stream_info->stream_src == RDI_INTF_1 ||
- stream_info->stream_src == RDI_INTF_2))
- wait_for_complete_for_this_stream = 1;
- }
- if (!wait_for_complete_for_this_stream) {
- msm_isp_axi_stream_enable_cfg(vfe_dev, stream_info);
- stream_info->state = INACTIVE;
- vfe_dev->hw_info->vfe_ops.core_ops.
- reg_update(vfe_dev, 0xF);
- }
- wait_for_complete |= wait_for_complete_for_this_stream;
- }
- if (wait_for_complete) {
- vfe_dev->axi_data.stream_update = stream_cfg_cmd->num_streams;
- vfe_dev->hw_info->vfe_ops.core_ops.
- reg_update(vfe_dev, 0xF);
- rc = msm_isp_axi_wait_for_cfg_done(vfe_dev, camif_update);
- if (rc < 0) {
- pr_err("%s: wait for config done failed\n", __func__);
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(
- stream_cfg_cmd->stream_handle[i])];
- stream_info->state = STOP_PENDING;
- vfe_dev->hw_info->vfe_ops.core_ops.
- reg_update(vfe_dev, 0xF);
- msm_isp_axi_stream_enable_cfg(
- vfe_dev, stream_info);
- stream_info->state = INACTIVE;
- }
- }
- }
- if (camif_update == DISABLE_CAMIF) {
- vfe_dev->hw_info->vfe_ops.core_ops.
- update_camif_state(vfe_dev, DISABLE_CAMIF);
- } else if ((camif_update == DISABLE_CAMIF_IMMEDIATELY) ||
- (ext_read)) {
- /*during stop immediately, stop output then stop input*/
- if (!ext_read)
- vfe_dev->hw_info->vfe_ops.core_ops.
- update_camif_state(vfe_dev,
- DISABLE_CAMIF_IMMEDIATELY);
- }
- if (cur_stream_cnt == 0) {
- vfe_dev->ignore_error = 1;
- vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev, 1);
- vfe_dev->hw_info->vfe_ops.core_ops.reset_hw(vfe_dev, 1, 1);
- vfe_dev->hw_info->vfe_ops.core_ops.init_hw_reg(vfe_dev);
- vfe_dev->ignore_error = 0;
- }
- msm_isp_update_stream_bandwidth(vfe_dev);
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i])];
- msm_isp_deinit_stream_ping_pong_reg(vfe_dev, stream_info);
- }
-
- return rc;
-}
-
-
-int msm_isp_cfg_axi_stream(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0;
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd = arg;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- enum msm_isp_camif_update_state camif_update;
-
- rc = msm_isp_axi_check_stream_state(vfe_dev, stream_cfg_cmd);
- if (rc < 0) {
- pr_err("%s: Invalid stream state\n", __func__);
- return rc;
- }
-
- if (axi_data->num_active_stream == 0) {
- /*Configure UB*/
- vfe_dev->hw_info->vfe_ops.axi_ops.cfg_ub(vfe_dev);
- }
- camif_update = msm_isp_get_camif_update_state(vfe_dev, stream_cfg_cmd);
-
- if (stream_cfg_cmd->cmd == START_STREAM) {
- msm_isp_axi_update_cgc_override(vfe_dev, stream_cfg_cmd, 1);
-
- rc = msm_isp_start_axi_stream(
- vfe_dev, stream_cfg_cmd, camif_update);
- } else {
- rc = msm_isp_stop_axi_stream(
- vfe_dev, stream_cfg_cmd, camif_update);
-
- msm_isp_axi_update_cgc_override(vfe_dev, stream_cfg_cmd, 0);
- }
-
- if (rc < 0)
- pr_err("%s: start/stop stream failed\n", __func__);
- return rc;
-}
-
-static int msm_isp_request_frame(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info, uint32_t request_frm_num)
-{
- struct msm_vfe32_axi_stream_request_cmd stream_cfg_cmd;
- int rc = 0;
- uint32_t pingpong_status, pingpong_bit, wm_reload_mask = 0x0;
-
- if (!stream_info->controllable_output)
- return 0;
-
- if (!request_frm_num) {
- pr_err("%s: Invalid frame request.\n", __func__);
- return -EINVAL;
- }
-
- stream_info->request_frm_num += request_frm_num;
-
- stream_cfg_cmd.axi_stream_handle = stream_info->stream_handle;
- stream_cfg_cmd.frame_skip_pattern = NO_SKIP;
- stream_cfg_cmd.init_frame_drop = 0;
- stream_cfg_cmd.burst_count = stream_info->request_frm_num;
- msm_isp_calculate_framedrop(&vfe_dev->axi_data, &stream_cfg_cmd);
- msm_isp_reset_framedrop(vfe_dev, stream_info);
-
- if (stream_info->request_frm_num != request_frm_num) {
- pingpong_status =
- vfe_dev->hw_info->vfe_ops.axi_ops.get_pingpong_status(
- vfe_dev);
- pingpong_bit = (~(pingpong_status >> stream_info->wm[0]) & 0x1);
-
- if (!stream_info->buf[pingpong_bit]) {
- rc = msm_isp_cfg_ping_pong_address(vfe_dev, stream_info,
- pingpong_status, pingpong_bit);
- if (rc) {
- pr_err("%s:%d fail to set ping pong address\n",
- __func__, __LINE__);
- return rc;
- }
- }
-
- if (!stream_info->buf[!pingpong_bit] && request_frm_num > 1) {
- rc = msm_isp_cfg_ping_pong_address(vfe_dev, stream_info,
- ~pingpong_status, !pingpong_bit);
- if (rc) {
- pr_err("%s:%d fail to set ping pong address\n",
- __func__, __LINE__);
- return rc;
- }
- }
- } else {
- if (!stream_info->buf[0]) {
- rc = msm_isp_cfg_ping_pong_address(vfe_dev, stream_info,
- VFE_PING_FLAG, 0);
- if (rc) {
- pr_err("%s:%d fail to set ping pong address\n",
- __func__, __LINE__);
- return rc;
- }
- }
-
- if (!stream_info->buf[1] && request_frm_num > 1) {
- rc = msm_isp_cfg_ping_pong_address(vfe_dev, stream_info,
- VFE_PONG_FLAG, 1);
- if (rc) {
- pr_err("%s:%d fail to set ping pong address\n",
- __func__, __LINE__);
- return rc;
- }
- }
-
- msm_isp_get_stream_wm_mask(stream_info, &wm_reload_mask);
- vfe_dev->hw_info->vfe_ops.axi_ops.reload_wm(vfe_dev,
- wm_reload_mask);
- }
-
- return rc;
-}
-
-int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0, i, j;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- struct msm_vfe_axi_stream_update_cmd *update_cmd = arg;
- struct msm_vfe_axi_stream_cfg_update_info *update_info;
-
- if (update_cmd->update_type == UPDATE_STREAM_AXI_CONFIG &&
- atomic_read(&axi_data->axi_cfg_update)) {
- pr_err("%s: AXI stream config updating\n", __func__);
- return -EBUSY;
- }
-
- /*num_stream is uint32 and update_info[] bound by MAX_NUM_STREAM*/
- if (update_cmd->num_streams > MAX_NUM_STREAM)
- return -EINVAL;
-
- for (i = 0; i < update_cmd->num_streams; i++) {
- update_info = &update_cmd->update_info[i];
- /*check array reference bounds*/
- if (HANDLE_TO_IDX(update_info->stream_handle) >=
- MAX_NUM_STREAM) {
- return -EINVAL;
- }
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(update_info->stream_handle)];
- if (stream_info->state != ACTIVE &&
- stream_info->state != INACTIVE) {
- pr_err("%s: Invalid stream state\n", __func__);
- return -EINVAL;
- }
- }
-
- for (i = 0; i < update_cmd->num_streams; i++) {
- update_info = &update_cmd->update_info[i];
- stream_info = &axi_data->stream_info[
- HANDLE_TO_IDX(update_info->stream_handle)];
-
- switch (update_cmd->update_type) {
- case ENABLE_STREAM_BUF_DIVERT:
- stream_info->buf_divert = 1;
- break;
- case DISABLE_STREAM_BUF_DIVERT:
- stream_info->buf_divert = 0;
- vfe_dev->buf_mgr->ops->flush_buf(vfe_dev->buf_mgr,
- stream_info->bufq_handle,
- MSM_ISP_BUFFER_FLUSH_DIVERTED);
- break;
- case UPDATE_STREAM_FRAMEDROP_PATTERN: {
- uint32_t framedrop_period =
- msm_isp_get_framedrop_period(
- update_info->skip_pattern);
- if (update_info->skip_pattern == SKIP_ALL)
- stream_info->framedrop_pattern = 0x0;
- else
- stream_info->framedrop_pattern = 0x1;
- stream_info->framedrop_period = framedrop_period - 1;
- if (stream_info->stream_type == BURST_STREAM) {
- stream_info->runtime_framedrop_update_burst = 1;
- } else {
- stream_info->runtime_init_frame_drop = 0;
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_framedrop(vfe_dev, stream_info);
- }
- break;
- }
- case UPDATE_STREAM_AXI_CONFIG: {
- for (j = 0; j < stream_info->num_planes; j++) {
- stream_info->plane_cfg[j] =
- update_info->plane_cfg[j];
- }
- stream_info->output_format = update_info->output_format;
- if (stream_info->state == ACTIVE) {
- stream_info->state = PAUSE_PENDING;
- msm_isp_axi_stream_enable_cfg(
- vfe_dev, stream_info);
- stream_info->state = PAUSING;
- atomic_set(&axi_data->axi_cfg_update,
- UPDATE_REQUESTED);
- } else {
- for (j = 0; j < stream_info->num_planes; j++)
- vfe_dev->hw_info->vfe_ops.axi_ops.
- cfg_wm_reg(vfe_dev, stream_info, j);
- stream_info->runtime_output_format =
- stream_info->output_format;
- }
- break;
- }
- case UPDATE_STREAM_REQUEST_FRAMES: {
- rc = msm_isp_request_frame(vfe_dev, stream_info,
- update_info->frame_id);
- if (rc)
- pr_err("%s failed to request frame!\n",
- __func__);
- break;
- }
- default:
- pr_err("%s: Invalid update type\n", __func__);
- return -EINVAL;
- }
- }
- return rc;
-}
-
-void msm_isp_process_axi_irq(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts)
-{
- int i, rc = 0;
- struct msm_isp_buffer *done_buf = NULL;
- uint32_t comp_mask = 0, wm_mask = 0;
- uint32_t pingpong_status, stream_idx;
- struct msm_vfe_axi_stream *stream_info;
- struct msm_vfe_axi_composite_info *comp_info;
- struct msm_vfe_axi_shared_data *axi_data = &vfe_dev->axi_data;
- uint32_t pingpong_bit = 0, frame_id = 0;
-
- comp_mask = vfe_dev->hw_info->vfe_ops.axi_ops.
- get_comp_mask(irq_status0, irq_status1);
- wm_mask = vfe_dev->hw_info->vfe_ops.axi_ops.
- get_wm_mask(irq_status0, irq_status1);
- if (!(comp_mask || wm_mask))
- return;
-
- ISP_DBG("%s: status: 0x%x\n", __func__, irq_status0);
- pingpong_status =
- vfe_dev->hw_info->vfe_ops.axi_ops.get_pingpong_status(vfe_dev);
- for (i = 0; i < axi_data->hw_info->num_comp_mask; i++) {
- rc = 0;
- comp_info = &axi_data->composite_info[i];
- if (comp_mask & (1 << i)) {
- stream_idx = HANDLE_TO_IDX(comp_info->stream_handle);
- if ((!comp_info->stream_handle) ||
- (stream_idx >= MAX_NUM_STREAM)) {
- pr_err("%s: Invalid handle for composite irq\n",
- __func__);
- } else {
- stream_idx =
- HANDLE_TO_IDX(comp_info->stream_handle);
- stream_info =
- &axi_data->stream_info[stream_idx];
-
- pingpong_bit = (~(pingpong_status >>
- stream_info->wm[0]) & 0x1);
-
- if (stream_info->stream_type == BURST_STREAM)
- stream_info->
- runtime_num_burst_capture--;
-
- msm_isp_get_done_buf(vfe_dev, stream_info,
- pingpong_status, &done_buf);
- if (stream_info->stream_type ==
- CONTINUOUS_STREAM ||
- stream_info->
- runtime_num_burst_capture > 1) {
- rc = msm_isp_cfg_ping_pong_address(
- vfe_dev, stream_info,
- pingpong_status,
- pingpong_bit);
- }
- frame_id = vfe_dev->axi_data.
- src_info[SRC_TO_INTF(
- stream_info->stream_src)].
- frame_id;
- stream_info->frame_id = frame_id;
- ISP_DBG("%s: stream id:%d frame id:%d\n",
- __func__, stream_info->stream_id,
- stream_info->frame_id);
- if (done_buf && !rc)
- msm_isp_process_done_buf(vfe_dev,
- stream_info, done_buf, ts);
- }
- }
- wm_mask &= ~(comp_info->stream_composite_mask);
- }
-
- for (i = 0; i < axi_data->hw_info->num_wm; i++) {
- if (wm_mask & (1 << i)) {
- stream_idx = HANDLE_TO_IDX(axi_data->free_wm[i]);
- if ((!axi_data->free_wm[i]) ||
- (stream_idx >= MAX_NUM_STREAM)) {
- pr_err("%s: Invalid handle for wm irq\n",
- __func__);
- continue;
- }
- stream_info = &axi_data->stream_info[stream_idx];
-
- pingpong_bit = (~(pingpong_status >>
- stream_info->wm[0]) & 0x1);
-
- if (stream_info->stream_type == BURST_STREAM)
- stream_info->runtime_num_burst_capture--;
-
- msm_isp_get_done_buf(vfe_dev, stream_info,
- pingpong_status, &done_buf);
- if (stream_info->stream_type == CONTINUOUS_STREAM ||
- stream_info->runtime_num_burst_capture > 1) {
- rc = msm_isp_cfg_ping_pong_address(vfe_dev,
- stream_info, pingpong_status,
- pingpong_bit);
- }
- stream_info->frame_id = frame_id;
- ISP_DBG("%s: stream id:%d frame id:%d\n",
- __func__, stream_info->stream_id,
- stream_info->frame_id);
- if (done_buf && !rc)
- msm_isp_process_done_buf(vfe_dev,
- stream_info, done_buf, ts);
- }
- }
-}
-int msm_isp_user_buf_done(struct vfe_device *vfe_dev,
- struct msm_isp32_event_data *buf_cmd)
-{
- int rc = 0;
- struct msm_isp32_event_data buf_event;
-
- memset(&buf_event, 0, sizeof(buf_event));
- buf_event.input_intf = buf_cmd->input_intf;
- buf_event.frame_id = buf_cmd->frame_id;
- buf_event.timestamp = buf_cmd->timestamp;
- buf_event.u.buf_done.session_id =
- buf_cmd->u.buf_done.session_id;
- buf_event.u.buf_done.stream_id =
- buf_cmd->u.buf_done.stream_id;
- buf_event.u.buf_done.output_format =
- buf_cmd->u.buf_done.output_format;
- buf_event.u.buf_done.buf_idx =
- buf_cmd->u.buf_done.buf_idx;
- buf_event.u.buf_done.handle =
- buf_cmd->u.buf_done.handle;
-
- vfe_dev->buf_mgr->ops->buf_done(vfe_dev->buf_mgr,
- buf_event.u.buf_done.handle,
- buf_event.u.buf_done.buf_idx,
- &buf_event.timestamp, buf_event.frame_id,
- buf_event.u.buf_done.output_format);
- return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util_32.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util_32.h
deleted file mode 100644
index 633a14c01f80..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util_32.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-#ifndef __MSM_ISP_AXI_UTIL_H__
-#define __MSM_ISP_AXI_UTIL_H__
-
-#include "msm_isp_32.h"
-
-int msm_isp_axi_create_stream(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe32_axi_stream_request_cmd *stream_cfg_cmd);
-
-void msm_isp_axi_destroy_stream(
- struct msm_vfe_axi_shared_data *axi_data, int stream_idx);
-
-int msm_isp_validate_axi_request(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe32_axi_stream_request_cmd *stream_cfg_cmd);
-
-void msm_isp_axi_reserve_wm(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe_axi_stream *stream_info);
-
-void msm_isp_axi_reserve_comp_mask(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe_axi_stream *stream_info);
-
-int msm_isp_axi_check_stream_state(
- struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream_cfg_cmd *stream_cfg_cmd);
-
-void msm_isp_calculate_framedrop(
- struct msm_vfe_axi_shared_data *axi_data,
- struct msm_vfe32_axi_stream_request_cmd *stream_cfg_cmd);
-void msm_isp_reset_framedrop(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_stream *stream_info);
-
-int msm_isp_request_axi_stream(struct vfe_device *vfe_dev, void *arg);
-int msm_isp_cfg_axi_stream(struct vfe_device *vfe_dev, void *arg);
-int msm_isp_release_axi_stream(struct vfe_device *vfe_dev, void *arg);
-int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg);
-void msm_isp_axi_cfg_update(struct vfe_device *vfe_dev);
-int msm_isp_axi_halt(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_halt_cmd *halt_cmd);
-int msm_isp_axi_reset(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_reset_cmd *reset_cmd);
-int msm_isp_axi_restart(struct vfe_device *vfe_dev,
- struct msm_vfe_axi_restart_cmd *restart_cmd);
-int msm_isp_user_buf_done(struct vfe_device *vfe_dev,
- struct msm_isp32_event_data *buf_cmd);
-void msm_isp_axi_stream_update(struct vfe_device *vfe_dev,
- uint8_t input_src);
-
-void msm_isp_update_framedrop_reg(struct vfe_device *vfe_dev,
- uint8_t input_src);
-void msm_isp_notify(struct vfe_device *vfe_dev, uint32_t event_type,
- enum msm_vfe_input_src frame_src, struct msm_isp_timestamp *ts);
-void msm_isp_process_axi_irq(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts);
-#endif /* __MSM_ISP_AXI_UTIL_H__ */
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c
index 0a4b80e5cbe2..66d4e6ad42b2 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util.c
@@ -250,9 +250,6 @@ static int32_t msm_isp_stats_buf_divert(struct vfe_device *vfe_dev,
*comp_stats_type_mask |=
1 << stream_info->stats_type;
}
- stats_event->pd_stats_idx = 0xF;
- if (stream_info->stats_type == MSM_ISP_STATS_BF)
- stats_event->pd_stats_idx = vfe_dev->pd_buf_idx;
}
return rc;
@@ -896,12 +893,6 @@ int msm_isp_update_stats_stream(struct vfe_device *vfe_dev, void *arg)
struct msm_vfe_axi_stream_cfg_update_info *update_info = NULL;
struct msm_isp_sw_framskip *sw_skip_info = NULL;
- if (update_cmd->num_streams > MSM_ISP_STATS_MAX) {
- pr_err("%s: Invalid num_streams %d\n",
- __func__, update_cmd->num_streams);
- return -EINVAL;
- }
-
/*validate request*/
for (i = 0; i < update_cmd->num_streams; i++) {
update_info = (struct msm_vfe_axi_stream_cfg_update_info *)
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util_32.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util_32.c
deleted file mode 100644
index c896a0ff4660..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util_32.c
+++ /dev/null
@@ -1,708 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-#include <linux/io.h>
-#include <linux/atomic.h>
-#include <media/v4l2-subdev.h>
-#include <media/msmb_isp.h>
-#include "msm_isp_util_32.h"
-#include "msm_isp_stats_util_32.h"
-
-static int msm_isp_stats_cfg_ping_pong_address(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info, uint32_t pingpong_status,
- struct msm_isp_buffer **done_buf)
-{
- int rc = -1;
- struct msm_isp_buffer *buf;
- uint32_t pingpong_bit = 0;
- uint32_t bufq_handle = stream_info->bufq_handle;
- uint32_t stats_pingpong_offset;
- uint32_t stats_idx = STATS_IDX(stream_info->stream_handle);
-
- if (stats_idx >= vfe_dev->hw_info->stats_hw_info->num_stats_type ||
- stats_idx >= MSM_ISP_STATS_MAX) {
- pr_err("%s Invalid stats index %d", __func__, stats_idx);
- return -EINVAL;
- }
-
- stats_pingpong_offset =
- vfe_dev->hw_info->stats_hw_info->stats_ping_pong_offset[
- stats_idx];
-
- pingpong_bit = (~(pingpong_status >> stats_pingpong_offset) & 0x1);
- rc = vfe_dev->buf_mgr->ops->get_buf(vfe_dev->buf_mgr,
- vfe_dev->pdev->id, bufq_handle, &buf);
- if (rc < 0) {
- vfe_dev->error_info.stats_framedrop_count[stats_idx]++;
- return rc;
- }
-
- if (buf->num_planes != 1) {
- pr_err("%s: Invalid buffer\n", __func__);
- rc = -EINVAL;
- goto buf_error;
- }
-
- vfe_dev->hw_info->vfe_ops.stats_ops.update_ping_pong_addr(
- vfe_dev, stream_info,
- pingpong_status, buf->mapped_info[0].paddr +
- stream_info->buffer_offset);
-
- if (stream_info->buf[pingpong_bit] && done_buf)
- *done_buf = stream_info->buf[pingpong_bit];
-
- stream_info->buf[pingpong_bit] = buf;
- return 0;
-buf_error:
- vfe_dev->buf_mgr->ops->put_buf(vfe_dev->buf_mgr,
- buf->bufq_handle, buf->buf_idx);
- return rc;
-}
-
-void msm_isp_process_stats_irq(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts)
-{
- int i, j, rc;
- struct msm_isp32_event_data buf_event;
- struct msm_isp_stats_event *stats_event = &buf_event.u.stats;
- struct msm_isp_buffer *done_buf;
- struct msm_vfe_stats_stream *stream_info = NULL;
- uint32_t pingpong_status;
- uint32_t comp_stats_type_mask = 0, atomic_stats_mask = 0;
- uint32_t stats_comp_mask = 0, stats_irq_mask = 0;
- uint32_t num_stats_comp_mask =
- vfe_dev->hw_info->stats_hw_info->num_stats_comp_mask;
- stats_comp_mask = vfe_dev->hw_info->vfe_ops.stats_ops.
- get_comp_mask(irq_status0, irq_status1);
- stats_irq_mask = vfe_dev->hw_info->vfe_ops.stats_ops.
- get_wm_mask(irq_status0, irq_status1);
- if (!(stats_comp_mask || stats_irq_mask))
- return;
- ISP_DBG("%s: status: 0x%x\n", __func__, irq_status0);
-
- /*
- * If any of composite mask is set, clear irq bits from mask,
- * they will be restored by comp mask
- */
- if (stats_comp_mask) {
- for (j = 0; j < num_stats_comp_mask; j++) {
- stats_irq_mask &= ~atomic_read(
- &vfe_dev->stats_data.stats_comp_mask[j]);
- }
- }
-
- for (j = 0; j < num_stats_comp_mask; j++) {
- atomic_stats_mask = atomic_read(
- &vfe_dev->stats_data.stats_comp_mask[j]);
- if (!stats_comp_mask) {
- stats_irq_mask &= ~atomic_stats_mask;
- } else {
- /* restore irq bits from composite mask */
- if (stats_comp_mask & (1 << j))
- stats_irq_mask |= atomic_stats_mask;
- }
- /* if no irq bits set from this composite mask continue*/
- if (!stats_irq_mask)
- continue;
- memset(&buf_event, 0, sizeof(struct msm_isp32_event_data));
- buf_event.timestamp = ts->event_time;
- buf_event.frame_id =
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
- buf_event.input_intf = VFE_PIX_0;
- pingpong_status = vfe_dev->hw_info->
- vfe_ops.stats_ops.get_pingpong_status(vfe_dev);
-
- for (i = 0; i < vfe_dev->hw_info->stats_hw_info->num_stats_type;
- i++) {
- if (!(stats_irq_mask & (1 << i)))
- continue;
-
- stats_irq_mask &= ~(1 << i);
- stream_info = &vfe_dev->stats_data.stream_info[i];
- done_buf = NULL;
- msm_isp_stats_cfg_ping_pong_address(vfe_dev,
- stream_info, pingpong_status, &done_buf);
- if (done_buf) {
- rc = vfe_dev->buf_mgr->ops->buf_divert(
- vfe_dev->buf_mgr, done_buf->bufq_handle,
- done_buf->buf_idx, &ts->buf_time,
- vfe_dev->axi_data.
- src_info[VFE_PIX_0].frame_id);
- if (rc != 0)
- continue;
-
- stats_event->stats_buf_idxs
- [stream_info->stats_type] =
- done_buf->buf_idx;
- if (!stream_info->composite_flag) {
- stats_event->stats_mask =
- 1 << stream_info->stats_type;
- ISP_DBG("%s: stats frameid: 0x%x %d\n",
- __func__, buf_event.frame_id,
- stream_info->stats_type);
- msm_isp_send_event(vfe_dev,
- ISP_EVENT_STATS_NOTIFY +
- stream_info->stats_type,
- &buf_event);
- } else {
- comp_stats_type_mask |=
- 1 << stream_info->stats_type;
- }
- }
- }
-
- if (comp_stats_type_mask) {
- ISP_DBG("%s: comp_stats frameid: 0x%x, 0x%x\n",
- __func__, buf_event.frame_id,
- comp_stats_type_mask);
- stats_event->stats_mask = comp_stats_type_mask;
- msm_isp_send_event(vfe_dev,
- ISP_EVENT_COMP_STATS_NOTIFY, &buf_event);
- comp_stats_type_mask = 0;
- }
- }
-}
-
-int msm_isp_stats_create_stream(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream_request_cmd *stream_req_cmd)
-{
- int rc = -1;
- struct msm_vfe_stats_stream *stream_info = NULL;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
- uint32_t stats_idx;
-
- if (!(vfe_dev->hw_info->stats_hw_info->stats_capability_mask &
- (1 << stream_req_cmd->stats_type))) {
- pr_err("%s: Stats type not supported\n", __func__);
- return rc;
- }
-
- stats_idx = vfe_dev->hw_info->vfe_ops.stats_ops.
- get_stats_idx(stream_req_cmd->stats_type);
-
- if (stats_idx >= vfe_dev->hw_info->stats_hw_info->num_stats_type) {
- pr_err("%s Invalid stats index %d", __func__, stats_idx);
- return -EINVAL;
- }
-
- stream_info = &stats_data->stream_info[stats_idx];
- if (stream_info->state != STATS_AVAILABLE) {
- pr_err("%s: Stats already requested\n", __func__);
- return rc;
- }
-
- if (stream_req_cmd->framedrop_pattern >= MAX_SKIP) {
- pr_err("%s: Invalid framedrop pattern\n", __func__);
- return rc;
- }
-
- if (stream_req_cmd->irq_subsample_pattern >= MAX_SKIP) {
- pr_err("%s: Invalid irq subsample pattern\n", __func__);
- return rc;
- }
-
- stream_info->session_id = stream_req_cmd->session_id;
- stream_info->stream_id = stream_req_cmd->stream_id;
- stream_info->composite_flag = stream_req_cmd->composite_flag;
- stream_info->stats_type = stream_req_cmd->stats_type;
- stream_info->buffer_offset = stream_req_cmd->buffer_offset;
- stream_info->framedrop_pattern = stream_req_cmd->framedrop_pattern;
- stream_info->init_stats_frame_drop = stream_req_cmd->init_frame_drop;
- stream_info->irq_subsample_pattern =
- stream_req_cmd->irq_subsample_pattern;
- stream_info->state = STATS_INACTIVE;
-
- if ((vfe_dev->stats_data.stream_handle_cnt << 8) == 0)
- vfe_dev->stats_data.stream_handle_cnt++;
-
- stream_req_cmd->stream_handle =
- (++vfe_dev->stats_data.stream_handle_cnt) << 8 | stats_idx;
-
- stream_info->stream_handle = stream_req_cmd->stream_handle;
- return 0;
-}
-
-int msm_isp_request_stats_stream(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = -1;
- struct msm_vfe_stats_stream_request_cmd *stream_req_cmd = arg;
- struct msm_vfe_stats_stream *stream_info = NULL;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
- uint32_t framedrop_period;
- uint32_t stats_idx;
-
- rc = msm_isp_stats_create_stream(vfe_dev, stream_req_cmd);
- if (rc < 0) {
- pr_err("%s: create stream failed\n", __func__);
- return rc;
- }
-
- stats_idx = STATS_IDX(stream_req_cmd->stream_handle);
-
- if (stats_idx >= vfe_dev->hw_info->stats_hw_info->num_stats_type) {
- pr_err("%s Invalid stats index %d", __func__, stats_idx);
- return -EINVAL;
- }
-
- stream_info = &stats_data->stream_info[stats_idx];
-
- framedrop_period = msm_isp_get_framedrop_period(
- stream_req_cmd->framedrop_pattern);
-
- if (stream_req_cmd->framedrop_pattern == SKIP_ALL)
- stream_info->framedrop_pattern = 0x0;
- else
- stream_info->framedrop_pattern = 0x1;
- stream_info->framedrop_period = framedrop_period - 1;
-
- if (!stream_info->composite_flag)
- vfe_dev->hw_info->vfe_ops.stats_ops.
- cfg_wm_irq_mask(vfe_dev, stream_info);
-
- if (stream_info->init_stats_frame_drop == 0)
- vfe_dev->hw_info->vfe_ops.stats_ops.cfg_wm_reg(vfe_dev,
- stream_info);
-
- return rc;
-}
-
-int msm_isp_release_stats_stream(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = -1;
- struct msm_vfe_stats_stream_cfg_cmd stream_cfg_cmd;
- struct msm_vfe_stats_stream_release_cmd *stream_release_cmd = arg;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
- int stats_idx = STATS_IDX(stream_release_cmd->stream_handle);
- struct msm_vfe_stats_stream *stream_info = NULL;
-
- if (stats_idx >= vfe_dev->hw_info->stats_hw_info->num_stats_type) {
- pr_err("%s Invalid stats index %d", __func__, stats_idx);
- return -EINVAL;
- }
-
- stream_info = &stats_data->stream_info[stats_idx];
- if (stream_info->state == STATS_AVAILABLE) {
- pr_err("%s: stream already release\n", __func__);
- return rc;
- } else if (stream_info->state != STATS_INACTIVE) {
- stream_cfg_cmd.enable = 0;
- stream_cfg_cmd.num_streams = 1;
- stream_cfg_cmd.stream_handle[0] =
- stream_release_cmd->stream_handle;
- rc = msm_isp_cfg_stats_stream(vfe_dev, &stream_cfg_cmd);
- }
-
- if (!stream_info->composite_flag)
- vfe_dev->hw_info->vfe_ops.stats_ops.
- clear_wm_irq_mask(vfe_dev, stream_info);
-
- vfe_dev->hw_info->vfe_ops.stats_ops.clear_wm_reg(vfe_dev, stream_info);
- memset(stream_info, 0, sizeof(struct msm_vfe_stats_stream));
- return 0;
-}
-
-static int msm_isp_init_stats_ping_pong_reg(
- struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info)
-{
- int rc = 0;
-
- stream_info->bufq_handle =
- vfe_dev->buf_mgr->ops->get_bufq_handle(
- vfe_dev->buf_mgr, stream_info->session_id,
- stream_info->stream_id);
- if (stream_info->bufq_handle == 0) {
- pr_err("%s: no buf configured for stream: 0x%x\n",
- __func__, stream_info->stream_handle);
- return -EINVAL;
- }
-
- rc = msm_isp_stats_cfg_ping_pong_address(vfe_dev,
- stream_info, VFE_PING_FLAG, NULL);
- if (rc < 0) {
- pr_err("%s: No free buffer for ping\n", __func__);
- return rc;
- }
- rc = msm_isp_stats_cfg_ping_pong_address(vfe_dev,
- stream_info, VFE_PONG_FLAG, NULL);
- if (rc < 0) {
- pr_err("%s: No free buffer for pong\n", __func__);
- return rc;
- }
- return rc;
-}
-
-static void msm_isp_deinit_stats_ping_pong_reg(
- struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream *stream_info)
-{
- int i;
- struct msm_isp_buffer *buf;
-
- for (i = 0; i < 2; i++) {
- buf = stream_info->buf[i];
- if (buf)
- vfe_dev->buf_mgr->ops->put_buf(vfe_dev->buf_mgr,
- buf->bufq_handle, buf->buf_idx);
- }
-}
-
-void msm_isp_update_stats_framedrop_reg(struct vfe_device *vfe_dev)
-{
- int i;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
- struct msm_vfe_stats_stream *stream_info = NULL;
-
- for (i = 0; i < vfe_dev->hw_info->stats_hw_info->num_stats_type; i++) {
- stream_info = &stats_data->stream_info[i];
- if (stream_info->state != STATS_ACTIVE)
- continue;
-
- if (stream_info->init_stats_frame_drop) {
- stream_info->init_stats_frame_drop--;
- if (stream_info->init_stats_frame_drop == 0) {
- vfe_dev->hw_info->vfe_ops.stats_ops.cfg_wm_reg(
- vfe_dev, stream_info);
- }
- }
- }
-}
-
-void msm_isp_stats_stream_update(struct vfe_device *vfe_dev)
-{
- int i;
- uint32_t stats_mask = 0, comp_stats_mask = 0;
- uint32_t enable = 0;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
-
- for (i = 0; i < vfe_dev->hw_info->stats_hw_info->num_stats_type; i++) {
- if (stats_data->stream_info[i].state == STATS_START_PENDING ||
- stats_data->stream_info[i].state ==
- STATS_STOP_PENDING) {
- stats_mask |= i;
- enable = stats_data->stream_info[i].state ==
- STATS_START_PENDING ? 1 : 0;
- stats_data->stream_info[i].state =
- stats_data->stream_info[i].state ==
- STATS_START_PENDING ?
- STATS_STARTING : STATS_STOPPING;
- vfe_dev->hw_info->vfe_ops.stats_ops.enable_module(
- vfe_dev, BIT(i), enable);
- vfe_dev->hw_info->vfe_ops.stats_ops.cfg_comp_mask(
- vfe_dev, BIT(i), enable);
- } else if (stats_data->stream_info[i].state == STATS_STARTING ||
- stats_data->stream_info[i].state == STATS_STOPPING) {
- if (stats_data->stream_info[i].composite_flag)
- comp_stats_mask |= i;
- stats_data->stream_info[i].state =
- stats_data->stream_info[i].state ==
- STATS_STARTING ? STATS_ACTIVE : STATS_INACTIVE;
- }
- }
- atomic_sub(1, &stats_data->stats_update);
- if (!atomic_read(&stats_data->stats_update))
- complete(&vfe_dev->stats_config_complete);
-}
-
-static int msm_isp_stats_wait_for_cfg_done(struct vfe_device *vfe_dev)
-{
- int rc;
-
- init_completion(&vfe_dev->stats_config_complete);
- atomic_set(&vfe_dev->stats_data.stats_update, 2);
- rc = wait_for_completion_timeout(
- &vfe_dev->stats_config_complete,
- msecs_to_jiffies(VFE_MAX_CFG_TIMEOUT));
- if (rc == 0) {
- pr_err("%s: wait timeout\n", __func__);
- rc = -1;
- } else {
- rc = 0;
- }
- return rc;
-}
-
-static int msm_isp_stats_update_cgc_override(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream_cfg_cmd *stream_cfg_cmd)
-{
- int i;
- uint32_t stats_mask = 0, idx;
-
- if (stream_cfg_cmd->num_streams > MSM_ISP_STATS_MAX) {
- pr_err("%s invalid num_streams %d\n", __func__,
- stream_cfg_cmd->num_streams);
- return -EINVAL;
- }
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- idx = STATS_IDX(stream_cfg_cmd->stream_handle[i]);
-
- if (idx >= vfe_dev->hw_info->stats_hw_info->num_stats_type) {
- pr_err("%s Invalid stats index %d", __func__, idx);
- return -EINVAL;
- }
- stats_mask |= 1 << idx;
- }
-
- if (vfe_dev->hw_info->vfe_ops.stats_ops.update_cgc_override) {
- vfe_dev->hw_info->vfe_ops.stats_ops.update_cgc_override(
- vfe_dev, stats_mask, stream_cfg_cmd->enable);
- }
- return 0;
-}
-
-static int msm_isp_start_stats_stream(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream_cfg_cmd *stream_cfg_cmd)
-{
- int i, rc = 0;
- uint32_t stats_mask = 0, idx;
- uint32_t comp_stats_mask[MAX_NUM_STATS_COMP_MASK] = {0};
- uint32_t num_stats_comp_mask = 0;
- struct msm_vfe_stats_stream *stream_info;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
-
- if (stream_cfg_cmd->num_streams > MSM_ISP_STATS_MAX) {
- pr_err("%s invalid num_streams %d\n", __func__,
- stream_cfg_cmd->num_streams);
- return -EINVAL;
- }
-
- num_stats_comp_mask =
- vfe_dev->hw_info->stats_hw_info->num_stats_comp_mask;
- rc = vfe_dev->hw_info->vfe_ops.stats_ops.check_streams(
- stats_data->stream_info);
- if (rc < 0)
- return rc;
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- idx = STATS_IDX(stream_cfg_cmd->stream_handle[i]);
-
- if (idx >= vfe_dev->hw_info->stats_hw_info->num_stats_type) {
- pr_err("%s Invalid stats index %d", __func__, idx);
- return -EINVAL;
- }
-
- stream_info = &stats_data->stream_info[idx];
- if (stream_info->stream_handle !=
- stream_cfg_cmd->stream_handle[i]) {
- pr_err("%s: Invalid stream handle: 0x%x received\n",
- __func__, stream_cfg_cmd->stream_handle[i]);
- continue;
- }
-
- if (stream_info->composite_flag > num_stats_comp_mask) {
- pr_err("%s: comp grp %d exceed max %d\n",
- __func__, stream_info->composite_flag,
- num_stats_comp_mask);
- return -EINVAL;
- }
- rc = msm_isp_init_stats_ping_pong_reg(vfe_dev, stream_info);
- if (rc < 0) {
- pr_err("%s: No buffer for stream%d type:%d stmID:0x%x\n",
- __func__, idx, stream_info->stats_type,
- stream_info->stream_id);
- return rc;
- }
-
- if (vfe_dev->axi_data.src_info[VFE_PIX_0].active)
- stream_info->state = STATS_START_PENDING;
- else
- stream_info->state = STATS_ACTIVE;
-
- stats_data->num_active_stream++;
- stats_mask |= 1 << idx;
-
- if (stream_info->composite_flag > 0)
- comp_stats_mask[stream_info->composite_flag-1] |=
- 1 << idx;
-
- ISP_DBG("%s: stats_mask %x %x active streams %d\n",
- __func__, comp_stats_mask[0],
- comp_stats_mask[1],
- stats_data->num_active_stream);
-
- }
-
- if (vfe_dev->axi_data.src_info[VFE_PIX_0].active) {
- rc = msm_isp_stats_wait_for_cfg_done(vfe_dev);
- } else {
- vfe_dev->hw_info->vfe_ops.stats_ops.enable_module(
- vfe_dev, stats_mask, stream_cfg_cmd->enable);
- for (i = 0; i < num_stats_comp_mask; i++) {
- vfe_dev->hw_info->vfe_ops.stats_ops.cfg_comp_mask(
- vfe_dev, comp_stats_mask[i], 1);
- }
- }
- return rc;
-}
-
-static int msm_isp_stop_stats_stream(struct vfe_device *vfe_dev,
- struct msm_vfe_stats_stream_cfg_cmd *stream_cfg_cmd)
-{
- int i, rc = 0;
- uint32_t stats_mask = 0, idx;
- uint32_t comp_stats_mask[MAX_NUM_STATS_COMP_MASK] = {0};
- uint32_t num_stats_comp_mask = 0;
- struct msm_vfe_stats_stream *stream_info;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
-
- num_stats_comp_mask =
- vfe_dev->hw_info->stats_hw_info->num_stats_comp_mask;
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
-
- idx = STATS_IDX(stream_cfg_cmd->stream_handle[i]);
-
- if (idx >= vfe_dev->hw_info->stats_hw_info->num_stats_type) {
- pr_err("%s Invalid stats index %d", __func__, idx);
- return -EINVAL;
- }
-
- stream_info = &stats_data->stream_info[idx];
- if (stream_info->stream_handle !=
- stream_cfg_cmd->stream_handle[i]) {
- pr_err("%s: Invalid stream handle: 0x%x received\n",
- __func__, stream_cfg_cmd->stream_handle[i]);
- continue;
- }
-
- if (stream_info->composite_flag > num_stats_comp_mask) {
- pr_err("%s: comp grp %d exceed max %d\n",
- __func__, stream_info->composite_flag,
- num_stats_comp_mask);
- return -EINVAL;
- }
-
- if (vfe_dev->axi_data.src_info[VFE_PIX_0].active)
- stream_info->state = STATS_STOP_PENDING;
- else
- stream_info->state = STATS_INACTIVE;
-
- stats_data->num_active_stream--;
- stats_mask |= 1 << idx;
-
- if (stream_info->composite_flag > 0)
- comp_stats_mask[stream_info->composite_flag-1] |=
- 1 << idx;
-
- ISP_DBG("%s: stats_mask %x %x active streams %d\n",
- __func__, comp_stats_mask[0],
- comp_stats_mask[1],
- stats_data->num_active_stream);
- }
-
- if (vfe_dev->axi_data.src_info[VFE_PIX_0].active) {
- rc = msm_isp_stats_wait_for_cfg_done(vfe_dev);
- } else {
- vfe_dev->hw_info->vfe_ops.stats_ops.enable_module(
- vfe_dev, stats_mask, stream_cfg_cmd->enable);
- for (i = 0; i < num_stats_comp_mask; i++) {
- vfe_dev->hw_info->vfe_ops.stats_ops.cfg_comp_mask(
- vfe_dev, comp_stats_mask[i], 0);
- }
- }
-
- for (i = 0; i < stream_cfg_cmd->num_streams; i++) {
- idx = STATS_IDX(stream_cfg_cmd->stream_handle[i]);
-
- if (idx >= vfe_dev->hw_info->stats_hw_info->num_stats_type) {
- pr_err("%s Invalid stats index %d", __func__, idx);
- return -EINVAL;
- }
-
- stream_info = &stats_data->stream_info[idx];
- msm_isp_deinit_stats_ping_pong_reg(vfe_dev, stream_info);
- }
- return rc;
-}
-
-int msm_isp_cfg_stats_stream(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0;
- struct msm_vfe_stats_stream_cfg_cmd *stream_cfg_cmd = arg;
-
- if (vfe_dev->stats_data.num_active_stream == 0)
- vfe_dev->hw_info->vfe_ops.stats_ops.cfg_ub(vfe_dev);
-
- if (stream_cfg_cmd->num_streams > MSM_ISP_STATS_MAX) {
- pr_err("%s invalid num_streams %d\n", __func__,
- stream_cfg_cmd->num_streams);
- return -EINVAL;
- }
-
- if (stream_cfg_cmd->enable) {
- msm_isp_stats_update_cgc_override(vfe_dev, stream_cfg_cmd);
-
- rc = msm_isp_start_stats_stream(vfe_dev, stream_cfg_cmd);
- } else {
- rc = msm_isp_stop_stats_stream(vfe_dev, stream_cfg_cmd);
-
- msm_isp_stats_update_cgc_override(vfe_dev, stream_cfg_cmd);
- }
-
- return rc;
-}
-
-int msm_isp_update_stats_stream(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0, i;
- struct msm_vfe_stats_stream *stream_info;
- struct msm_vfe_stats_shared_data *stats_data = &vfe_dev->stats_data;
- struct msm_vfe_axi_stream_update_cmd *update_cmd = arg;
- struct msm_vfe_axi_stream_cfg_update_info *update_info = NULL;
-
- /*validate request*/
- for (i = 0; i < update_cmd->num_streams; i++) {
- update_info = &update_cmd->update_info[i];
- /*check array reference bounds*/
- if (STATS_IDX(update_info->stream_handle)
- > vfe_dev->hw_info->stats_hw_info->num_stats_type) {
- pr_err("%s: stats idx %d out of bound!", __func__,
- STATS_IDX(update_info->stream_handle));
- return -EINVAL;
- }
- }
-
- for (i = 0; i < update_cmd->num_streams; i++) {
- update_info = &update_cmd->update_info[i];
- stream_info = &stats_data->stream_info[
- STATS_IDX(update_info->stream_handle)];
- if (stream_info->stream_handle !=
- update_info->stream_handle) {
- pr_err("%s: stats stream handle %x %x mismatch!\n",
- __func__, stream_info->stream_handle,
- update_info->stream_handle);
- continue;
- }
-
- switch (update_cmd->update_type) {
- case UPDATE_STREAM_STATS_FRAMEDROP_PATTERN: {
- uint32_t framedrop_period =
- msm_isp_get_framedrop_period(
- update_info->skip_pattern);
- if (update_info->skip_pattern == SKIP_ALL)
- stream_info->framedrop_pattern = 0x0;
- else
- stream_info->framedrop_pattern = 0x1;
- stream_info->framedrop_period = framedrop_period - 1;
- if (stream_info->init_stats_frame_drop == 0)
- vfe_dev->hw_info->vfe_ops.stats_ops.cfg_wm_reg(
- vfe_dev, stream_info);
- break;
- }
-
- default:
- pr_err("%s: Invalid update type\n", __func__);
- return -EINVAL;
- }
- }
- return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util_32.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util_32.h
deleted file mode 100644
index 121d209cb59b..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_stats_util_32.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-#ifndef __MSM_ISP_STATS_UTIL_H__
-#define __MSM_ISP_STATS_UTIL_H__
-
-#include "msm_isp_32.h"
-#define STATS_IDX(idx) (idx & 0xFF)
-
-void msm_isp_process_stats_irq(struct vfe_device *vfe_dev,
- uint32_t irq_status0, uint32_t irq_status1,
- struct msm_isp_timestamp *ts);
-void msm_isp_stats_stream_update(struct vfe_device *vfe_dev);
-int msm_isp_cfg_stats_stream(struct vfe_device *vfe_dev, void *arg);
-int msm_isp_update_stats_stream(struct vfe_device *vfe_dev, void *arg);
-int msm_isp_release_stats_stream(struct vfe_device *vfe_dev, void *arg);
-int msm_isp_request_stats_stream(struct vfe_device *vfe_dev, void *arg);
-void msm_isp_update_stats_framedrop_reg(struct vfe_device *vfe_dev);
-#endif /* __MSM_ISP_STATS_UTIL_H__ */
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
index 4b25dc483968..35c96261dc2c 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2017, 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
@@ -20,8 +20,6 @@
#include "msm_isp_stats_util.h"
#include "msm_camera_io_util.h"
#include "cam_smmu_api.h"
-#define CREATE_TRACE_POINTS
-#include "trace/events/msm_cam.h"
#define MAX_ISP_V4l2_EVENTS 100
#define MAX_ISP_REG_LIST 100
@@ -30,9 +28,6 @@ static struct msm_isp_bandwidth_mgr isp_bandwidth_mgr;
static uint64_t msm_isp_cpp_clk_rate;
static struct dump_ping_pong_state dump_data;
-static struct dump_ping_pong_state tasklet_data;
-static DEFINE_SPINLOCK(dump_irq_lock);
-static DEFINE_SPINLOCK(dump_tasklet_lock);
#define VFE40_8974V2_VERSION 0x1001001A
@@ -355,34 +350,6 @@ int msm_isp_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
return msm_isp_process_event_subscription(fh, sub, false);
}
-static int msm_isp_update_fe_frame_id(struct vfe_device *vfe_dev,
- void *arg)
-{
- struct msm_vfe_update_fe_frame_id *session_frameid = arg;
- int rc = 0;
- /*
- * For Offline VFE, HAL expects same frame id
- * for offline output which it requested in do_reprocess.
- */
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id =
- session_frameid->frame_id;
- return rc;
-}
-
-static int msm_isp_restart_fe(struct vfe_device *vfe_dev,
- void *arg)
-{
- struct msm_vfe_restart_fe_cmd *rst_fe = arg;
- int rc = 0;
- /*
- * In case of overflow recovery
- * restart fetch engine
- */
- if (rst_fe->restart_fe)
- vfe_dev->fetch_engine_info.is_busy = 1;
- return rc;
-}
-
static int msm_isp_start_fetch_engine(struct vfe_device *vfe_dev,
void *arg)
{
@@ -412,9 +379,13 @@ static int msm_isp_start_fetch_engine_multi_pass(struct vfe_device *vfe_dev,
fe_cfg->frame_id;
if (fe_cfg->offline_pass == OFFLINE_SECOND_PASS) {
- stream_info = &vfe_dev->axi_data.stream_info[
- HANDLE_TO_IDX(fe_cfg->output_stream_id)];
- if (!stream_info) {
+ for (i = 0; i < VFE_AXI_SRC_MAX; i++) {
+ stream_info = &vfe_dev->axi_data.stream_info[i];
+ if (stream_info->stream_id == fe_cfg->output_stream_id)
+ break;
+ }
+
+ if (i == VFE_AXI_SRC_MAX) {
pr_err("%s: Couldn't find streamid 0x%X\n", __func__,
fe_cfg->output_stream_id);
return -EINVAL;
@@ -532,9 +503,6 @@ static int msm_isp_cfg_rdi(struct vfe_device *vfe_dev,
return -EINVAL;
}
- vfe_dev->axi_data.
- src_info[input_cfg->input_src].sof_counter_step = 1;
-
vfe_dev->axi_data.src_info[input_cfg->input_src].pixel_clock =
input_cfg->input_pix_clk;
vfe_dev->hw_info->vfe_ops.core_ops.cfg_rdi_reg(
@@ -604,10 +572,13 @@ static int msm_isp_set_dual_HW_master_slave_mode(
}
/* No lock needed here since ioctl lock protects 2 session from race */
- /* Reset master SOF which refer slave in increment_frame_id function */
+ /* reset master SOF which refer slave in increment_frame_id function
+ *
+ */
vfe_dev->common_data->ms_resource.master_sof_info.frame_id = 0;
vfe_dev->common_data->ms_resource.master_sof_info.mono_timestamp_ms = 0;
- /* Reset slave frame_id so that master will not jump */
+ /* we have only 1 slave so reset it frame_id so that master will
+ * not jump*/
vfe_dev->common_data->ms_resource.slave_sof_info[0].frame_id = 0;
if (src_info != NULL &&
dual_hw_ms_cmd->dual_hw_ms_type == MS_TYPE_MASTER) {
@@ -966,19 +937,6 @@ static long msm_isp_ioctl_unlocked(struct v4l2_subdev *sd,
rc = msm_isp_start_fetch_engine_multi_pass(vfe_dev, arg);
mutex_unlock(&vfe_dev->core_mutex);
break;
-
- case VIDIOC_MSM_ISP_RESTART_FE:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_restart_fe(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
-
- case VIDIOC_MSM_ISP_UPDATE_FE_FRAME_ID:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_update_fe_frame_id(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
-
case VIDIOC_MSM_ISP_REG_UPDATE_CMD:
if (arg) {
enum msm_vfe_input_src frame_src =
@@ -1609,10 +1567,6 @@ int msm_isp_cal_word_per_line(uint32_t output_format,
case V4L2_PIX_FMT_P16GBRG10:
case V4L2_PIX_FMT_P16GRBG10:
case V4L2_PIX_FMT_P16RGGB10:
- case V4L2_PIX_FMT_P16BGGR12:
- case V4L2_PIX_FMT_P16GBRG12:
- case V4L2_PIX_FMT_P16GRBG12:
- case V4L2_PIX_FMT_P16RGGB12:
val = CAL_WORD(pixel_per_line, 1, 4);
break;
case V4L2_PIX_FMT_NV24:
@@ -1679,10 +1633,6 @@ enum msm_isp_pack_fmt msm_isp_get_pack_format(uint32_t output_format)
case V4L2_PIX_FMT_P16GBRG10:
case V4L2_PIX_FMT_P16GRBG10:
case V4L2_PIX_FMT_P16RGGB10:
- case V4L2_PIX_FMT_P16BGGR12:
- case V4L2_PIX_FMT_P16GBRG12:
- case V4L2_PIX_FMT_P16GRBG12:
- case V4L2_PIX_FMT_P16RGGB12:
return PLAIN16;
default:
msm_isp_print_fourcc_error(__func__, output_format);
@@ -1767,10 +1717,6 @@ int msm_isp_get_bit_per_pixel(uint32_t output_format)
case V4L2_PIX_FMT_QGRBG12:
case V4L2_PIX_FMT_QRGGB12:
case V4L2_PIX_FMT_Y12:
- case V4L2_PIX_FMT_P16BGGR12:
- case V4L2_PIX_FMT_P16GBRG12:
- case V4L2_PIX_FMT_P16GRBG12:
- case V4L2_PIX_FMT_P16RGGB12:
return 12;
case V4L2_PIX_FMT_SBGGR14:
case V4L2_PIX_FMT_SGBRG14:
@@ -1807,38 +1753,11 @@ void msm_isp_update_error_frame_count(struct vfe_device *vfe_dev)
static int msm_isp_process_iommu_page_fault(struct vfe_device *vfe_dev)
{
int rc = vfe_dev->buf_mgr->pagefault_debug_disable;
- uint32_t irq_status0, irq_status1;
- uint32_t overflow_mask;
- unsigned long irq_flags;
- /* Check if any overflow bit is set */
- vfe_dev->hw_info->vfe_ops.core_ops.
- get_overflow_mask(&overflow_mask);
- vfe_dev->hw_info->vfe_ops.irq_ops.
- read_irq_status(vfe_dev, &irq_status0, &irq_status1);
- overflow_mask &= irq_status1;
- spin_lock_irqsave(
- &vfe_dev->common_data->common_dev_data_lock, irq_flags);
- if (overflow_mask ||
- atomic_read(&vfe_dev->error_info.overflow_state) !=
- NO_OVERFLOW) {
- spin_unlock_irqrestore(
- &vfe_dev->common_data->common_dev_data_lock, irq_flags);
- pr_err_ratelimited("%s: overflow detected during IOMMU\n",
- __func__);
- /* Don't treat the Overflow + Page fault scenario as fatal.
- * Instead try to do a recovery. Using an existing event as
- * as opposed to creating a new event.
- */
- msm_isp_halt_send_error(vfe_dev, ISP_EVENT_PING_PONG_MISMATCH);
- } else {
- spin_unlock_irqrestore(
- &vfe_dev->common_data->common_dev_data_lock, irq_flags);
- pr_err("%s:%d] VFE%d Handle Page fault! vfe_dev %pK\n",
- __func__, __LINE__, vfe_dev->pdev->id, vfe_dev);
- vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev, 0);
- msm_isp_halt_send_error(vfe_dev, ISP_EVENT_IOMMU_P_FAULT);
- }
+ pr_err("%s:%d] VFE%d Handle Page fault! vfe_dev %pK\n", __func__,
+ __LINE__, vfe_dev->pdev->id, vfe_dev);
+
+ msm_isp_halt_send_error(vfe_dev, ISP_EVENT_IOMMU_P_FAULT);
if (vfe_dev->buf_mgr->pagefault_debug_disable == 0) {
vfe_dev->buf_mgr->pagefault_debug_disable = 1;
@@ -1881,8 +1800,6 @@ void msm_isp_process_overflow_irq(
uint32_t force_overflow)
{
uint32_t overflow_mask;
- unsigned long flags;
- struct msm_isp_event_data error_event;
/* if there are no active streams - do not start recovery */
if (!vfe_dev->axi_data.num_active_stream)
@@ -1906,86 +1823,71 @@ void msm_isp_process_overflow_irq(
if (!force_overflow)
overflow_mask &= *irq_status1;
- if (!overflow_mask)
- return;
+ if (overflow_mask) {
+ struct msm_isp_event_data error_event;
- spin_lock_irqsave(&vfe_dev->common_data->common_dev_data_lock,
- flags);
- if (atomic_cmpxchg(&vfe_dev->error_info.overflow_state,
- NO_OVERFLOW, OVERFLOW_DETECTED)) {
- spin_unlock_irqrestore(
- &vfe_dev->common_data->common_dev_data_lock,
- flags);
- return;
- }
- if (vfe_dev->reset_pending == 1) {
- pr_err("%s:%d failed: overflow %x during reset\n",
- __func__, __LINE__, overflow_mask);
- /* Clear overflow bits since reset is pending */
- *irq_status1 &= ~overflow_mask;
- spin_unlock_irqrestore(&vfe_dev->common_data->
- common_dev_data_lock, flags);
- return;
- }
- ISP_DBG("%s: VFE%d Bus overflow detected: start recovery!\n",
- __func__, vfe_dev->pdev->id);
-
- trace_msm_cam_isp_overflow(vfe_dev, *irq_status0, *irq_status1);
-
- /* maks off irq for current vfe */
- vfe_dev->recovery_irq0_mask = vfe_dev->irq0_mask;
- vfe_dev->recovery_irq1_mask = vfe_dev->irq1_mask;
-
- vfe_dev->hw_info->vfe_ops.core_ops.
- set_halt_restart_mask(vfe_dev);
- vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev, 0);
- /* mask off other vfe if dual vfe is used */
- if (vfe_dev->is_split) {
- uint32_t other_vfe_id;
- struct vfe_device *other_vfe_dev;
-
- other_vfe_id = (vfe_dev->pdev->id == ISP_VFE0) ?
- ISP_VFE1 : ISP_VFE0;
- other_vfe_dev = vfe_dev->common_data->
- dual_vfe_res->vfe_dev[other_vfe_id];
- if (other_vfe_dev) {
- other_vfe_dev->recovery_irq0_mask =
- other_vfe_dev->irq0_mask;
- other_vfe_dev->recovery_irq1_mask =
- other_vfe_dev->irq1_mask;
+ if (vfe_dev->reset_pending == 1) {
+ pr_err("%s:%d failed: overflow %x during reset\n",
+ __func__, __LINE__, overflow_mask);
+ /* Clear overflow bits since reset is pending */
+ *irq_status1 &= ~overflow_mask;
+ return;
}
- atomic_cmpxchg(&(vfe_dev->common_data->dual_vfe_res->
- vfe_dev[other_vfe_id]->
- error_info.overflow_state),
+ ISP_DBG("%s: VFE%d Bus overflow detected: start recovery!\n",
+ __func__, vfe_dev->pdev->id);
+
+ /* maks off irq for current vfe */
+ atomic_cmpxchg(&vfe_dev->error_info.overflow_state,
NO_OVERFLOW, OVERFLOW_DETECTED);
+ vfe_dev->recovery_irq0_mask = vfe_dev->irq0_mask;
+ vfe_dev->recovery_irq1_mask = vfe_dev->irq1_mask;
vfe_dev->hw_info->vfe_ops.core_ops.
- set_halt_restart_mask(vfe_dev->common_data->
- dual_vfe_res->vfe_dev[other_vfe_id]);
- if (other_vfe_dev) {
- other_vfe_dev->hw_info->vfe_ops.axi_ops.
- halt(other_vfe_dev, 0);
+ set_halt_restart_mask(vfe_dev);
+
+ /* mask off other vfe if dual vfe is used */
+ if (vfe_dev->is_split) {
+ uint32_t other_vfe_id;
+ struct vfe_device *other_vfe_dev;
+
+ other_vfe_id = (vfe_dev->pdev->id == ISP_VFE0) ?
+ ISP_VFE1 : ISP_VFE0;
+ other_vfe_dev = vfe_dev->common_data->
+ dual_vfe_res->vfe_dev[other_vfe_id];
+ if (other_vfe_dev) {
+ other_vfe_dev->recovery_irq0_mask =
+ other_vfe_dev->irq0_mask;
+ other_vfe_dev->recovery_irq1_mask =
+ other_vfe_dev->irq1_mask;
+ }
+
+ atomic_cmpxchg(&(vfe_dev->common_data->dual_vfe_res->
+ vfe_dev[other_vfe_id]->
+ error_info.overflow_state),
+ NO_OVERFLOW, OVERFLOW_DETECTED);
+
+ vfe_dev->hw_info->vfe_ops.core_ops.
+ set_halt_restart_mask(vfe_dev->common_data->
+ dual_vfe_res->vfe_dev[other_vfe_id]);
}
- }
- /* reset irq status so skip further process */
- *irq_status0 = 0;
- *irq_status1 = 0;
+ /* reset irq status so skip further process */
+ *irq_status0 = 0;
+ *irq_status1 = 0;
- /* send overflow event as needed */
- if (atomic_read(&vfe_dev->error_info.overflow_state)
- != HALT_ENFORCED) {
- memset(&error_event, 0, sizeof(error_event));
- error_event.frame_id =
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
- error_event.u.error_info.err_type =
- ISP_ERROR_BUS_OVERFLOW;
- msm_isp_send_event(vfe_dev,
- ISP_EVENT_ERROR, &error_event);
+ /* send overflow event as needed */
+ if (atomic_read(&vfe_dev->error_info.overflow_state)
+ != HALT_ENFORCED) {
+ memset(&error_event, 0, sizeof(error_event));
+ error_event.frame_id =
+ vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
+ error_event.u.error_info.err_type =
+ ISP_ERROR_BUS_OVERFLOW;
+ msm_isp_send_event(vfe_dev,
+ ISP_EVENT_ERROR, &error_event);
+ }
}
- spin_unlock_irqrestore(&vfe_dev->common_data->
- common_dev_data_lock, flags);
}
void msm_isp_reset_burst_count_and_frame_drop(
@@ -2034,7 +1936,7 @@ irqreturn_t msm_isp_process_irq(int irq_num, void *data)
uint32_t error_mask0, error_mask1;
vfe_dev->hw_info->vfe_ops.irq_ops.
- read_irq_status_and_clear(vfe_dev, &irq_status0, &irq_status1);
+ read_irq_status(vfe_dev, &irq_status0, &irq_status1);
if ((irq_status0 == 0) && (irq_status1 == 0)) {
ISP_DBG("%s:VFE%d irq_status0 & 1 are both 0\n",
@@ -2065,50 +1967,75 @@ irqreturn_t msm_isp_process_irq(int irq_num, void *data)
ISP_DBG("%s: error_mask0/1 & error_count are set!\n", __func__);
return IRQ_HANDLED;
}
- dump_data.vfe_dev = (struct vfe_device *) data;
- if (vfe_dev->is_split &&
- (vfe_dev->common_data->dual_vfe_res->vfe_dev[
+
+ if (vfe_dev->is_split) {
+ if ((vfe_dev->common_data->dual_vfe_res->vfe_dev[
!vfe_dev->pdev->id]) &&
- (vfe_dev->common_data->dual_vfe_res->vfe_dev[
- !vfe_dev->pdev->id]->vfe_open_cnt)) {
- spin_lock(&dump_irq_lock);
- dump_data.arr[dump_data.first].current_vfe_irq.
+ (vfe_dev->common_data->dual_vfe_res->vfe_dev[
+ !vfe_dev->pdev->id]->vfe_open_cnt)){
+ dump_data.arr[dump_data.first].current_vfe_irq.
vfe_id = vfe_dev->pdev->id;
- dump_data.arr[dump_data.first].current_vfe_irq.
+ dump_data.arr[dump_data.first].current_vfe_irq.
irq_status0 = irq_status0;
- dump_data.arr[dump_data.first].current_vfe_irq.
+ dump_data.arr[dump_data.first].current_vfe_irq.
irq_status1 = irq_status1;
- dump_data.arr[dump_data.first].current_vfe_irq.
+ dump_data.arr[dump_data.first].current_vfe_irq.
ping_pong_status = ping_pong_status;
- dump_data.arr[dump_data.first].other_vfe.
- vfe_id = (!vfe_dev->pdev->id);
- vfe_dev->hw_info->vfe_ops.irq_ops.
- read_irq_status(
- vfe_dev->common_data->dual_vfe_res->vfe_dev[
- !vfe_dev->pdev->id],
- &dump_data.arr[dump_data.first].other_vfe.irq_status0,
- &dump_data.arr[dump_data.first].other_vfe.irq_status1);
dump_data.arr[dump_data.first].other_vfe.
- ping_pong_status =
- vfe_dev->hw_info->vfe_ops.axi_ops.
- get_pingpong_status(
- vfe_dev->common_data->dual_vfe_res->vfe_dev[
- !vfe_dev->pdev->id]);
- msm_isp_get_timestamp(&dump_data.arr[dump_data.first].
+ vfe_id = (!vfe_dev->pdev->id);
+ dump_data.arr[dump_data.first].other_vfe.irq_status0 =
+ msm_camera_io_r(vfe_dev->common_data->dual_vfe_res->vfe_base[
+ !vfe_dev->pdev->id] + 0x38);
+ dump_data.arr[dump_data.first].other_vfe.irq_status1 =
+ msm_camera_io_r(vfe_dev->common_data->dual_vfe_res->vfe_base[
+ !vfe_dev->pdev->id] + 0x3C);
+ dump_data.arr[dump_data.first].other_vfe.ping_pong_status =
+ msm_camera_io_r(vfe_dev->common_data->dual_vfe_res->vfe_base[
+ !vfe_dev->pdev->id] + 0x268);
+ msm_isp_get_timestamp(&dump_data.arr[dump_data.first].
other_vfe.ts, vfe_dev);
- dump_data.first =
- (dump_data.first + 1) % MAX_ISP_PING_PONG_DUMP_SIZE;
- dump_data.fill_count++;
- spin_unlock(&dump_irq_lock);
+
+ dump_data.first =
+ (dump_data.first+1)%MAX_ISP_PING_PONG_DUMP_SIZE;
+ dump_data.fill_count++;
+ }
}
+
msm_isp_enqueue_tasklet_cmd(vfe_dev, irq_status0, irq_status1,
ping_pong_status);
return IRQ_HANDLED;
}
+void msm_isp_dump_ping_pong_mismatch(void)
+{
+ int index, count;
-
+ index = dump_data.first-1;
+ if (dump_data.fill_count > MAX_ISP_PING_PONG_DUMP_SIZE)
+ count = MAX_ISP_PING_PONG_DUMP_SIZE-1;
+ else
+ count = dump_data.first;
+ while (count >= 0) {
+ pr_err("vfe_id %d: irq_status0 0x%.8x: irq_status1 0x%.8x:"
+ " ping_pong_status 0x%.8x: ****** othervfe %d : "
+ "irq_status0 0x%.8x: irq_status1 0x%.8x: "
+ "ping_pong_status 0x%.8x: timestamp %u:%u\n",
+ dump_data.arr[index].current_vfe_irq.vfe_id,
+ dump_data.arr[index].current_vfe_irq.irq_status0,
+ dump_data.arr[index].current_vfe_irq.irq_status1,
+ dump_data.arr[index].current_vfe_irq.ping_pong_status,
+ dump_data.arr[index].other_vfe.vfe_id,
+ dump_data.arr[index].other_vfe.irq_status0,
+ dump_data.arr[index].other_vfe.irq_status1,
+ dump_data.arr[index].other_vfe.ping_pong_status,
+ (uint32_t)dump_data.arr[index].other_vfe.ts.buf_time.tv_sec,
+ (uint32_t)dump_data.arr[index].other_vfe.ts.buf_time.tv_usec);
+
+ index = (index+1)%MAX_ISP_PING_PONG_DUMP_SIZE;
+ count--;
+ }
+}
void msm_isp_do_tasklet(unsigned long data)
{
unsigned long flags;
@@ -2144,24 +2071,6 @@ void msm_isp_do_tasklet(unsigned long data)
spin_unlock_irqrestore(&vfe_dev->tasklet_lock, flags);
ISP_DBG("%s: vfe_id %d status0: 0x%x status1: 0x%x\n",
__func__, vfe_dev->pdev->id, irq_status0, irq_status1);
- if (vfe_dev->is_split) {
- spin_lock(&dump_tasklet_lock);
- tasklet_data.arr[tasklet_data.first].
- current_vfe_irq.vfe_id = vfe_dev->pdev->id;
- tasklet_data.arr[tasklet_data.first].
- current_vfe_irq.core = smp_processor_id();
- tasklet_data.arr[tasklet_data.first].
- current_vfe_irq.irq_status0 = irq_status0;
- tasklet_data.arr[tasklet_data.first].
- current_vfe_irq.irq_status1 = irq_status1;
- tasklet_data.arr[tasklet_data.first].
- current_vfe_irq.ping_pong_status = pingpong_status;
- tasklet_data.arr[tasklet_data.first].
- current_vfe_irq.ts = ts;
- tasklet_data.first =
- (tasklet_data.first + 1) % MAX_ISP_PING_PONG_DUMP_SIZE;
- spin_unlock(&dump_tasklet_lock);
- }
irq_ops->process_reset_irq(vfe_dev,
irq_status0, irq_status1);
irq_ops->process_halt_irq(vfe_dev,
@@ -2220,8 +2129,6 @@ static void msm_vfe_iommu_fault_handler(struct iommu_domain *domain,
if (vfe_dev->vfe_open_cnt > 0) {
atomic_set(&vfe_dev->error_info.overflow_state,
HALT_ENFORCED);
- pr_err_ratelimited("%s: fault address is %lx\n",
- __func__, iova);
msm_isp_process_iommu_page_fault(vfe_dev);
} else {
pr_err("%s: no handling, vfe open cnt = %d\n",
@@ -2455,57 +2362,3 @@ void msm_isp_save_framedrop_values(struct vfe_device *vfe_dev,
spin_unlock_irqrestore(&stream_info->lock, flags);
}
}
-
-void msm_isp_dump_irq_debug(void)
-{
- uint32_t index, count, i;
-
- if (dump_data.fill_count > MAX_ISP_PING_PONG_DUMP_SIZE) {
- index = dump_data.first;
- count = MAX_ISP_PING_PONG_DUMP_SIZE;
- } else {
- index = 0;
- count = dump_data.first;
- }
- for (i = 0; i < count; i++) {
- trace_msm_cam_ping_pong_debug_dump(dump_data.arr[index]);
- index = (index + 1) % MAX_ISP_PING_PONG_DUMP_SIZE;
- }
-}
-
-void msm_isp_dump_taskelet_debug(void)
-{
- uint32_t index, count, i;
-
- if (tasklet_data.fill_count > MAX_ISP_PING_PONG_DUMP_SIZE) {
- index = tasklet_data.first;
- count = MAX_ISP_PING_PONG_DUMP_SIZE;
- } else {
- index = 0;
- count = tasklet_data.first;
- }
- for (i = 0; i < count; i++) {
- trace_msm_cam_tasklet_debug_dump(tasklet_data.arr[index]);
- index = (index + 1) % MAX_ISP_PING_PONG_DUMP_SIZE;
- }
-}
-
-void msm_isp_dump_ping_pong_mismatch(void)
-{
- int i;
-
- spin_lock(&dump_tasklet_lock);
- for (i = 0; i < MAX_VFE; i++) {
- dump_data.vfe_dev->hw_info->vfe_ops.axi_ops.
- clear_irq_mask(
- dump_data.vfe_dev->common_data->dual_vfe_res->vfe_dev[i]);
- synchronize_irq(
- (uint32_t)dump_data.vfe_dev->common_data->dual_vfe_res->vfe_dev[
- i]->vfe_irq->start);
- }
- trace_msm_cam_string(" ***** msm_isp_dump_irq_debug ****");
- msm_isp_dump_irq_debug();
- trace_msm_cam_string(" ***** msm_isp_dump_taskelet_debug ****");
- msm_isp_dump_taskelet_debug();
- spin_unlock(&dump_tasklet_lock);
-}
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.h
index 561b9c28d842..39371040d66e 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.h
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.h
@@ -25,30 +25,27 @@
#endif
#define ALT_VECTOR_IDX(x) {x = 3 - x; }
-#define MAX_ISP_PING_PONG_DUMP_SIZE 20
+#define MAX_ISP_PING_PONG_DUMP_SIZE 10
+
struct ping_pong_state {
uint32_t vfe_id;
uint32_t irq_status0;
uint32_t irq_status1;
uint32_t ping_pong_status;
- uint32_t core;
struct msm_isp_timestamp ts;
};
-struct dual_vfe_state {
+struct vfe_other_vfe_state {
struct ping_pong_state current_vfe_irq;
struct ping_pong_state other_vfe;
};
struct dump_ping_pong_state {
- struct dual_vfe_state arr[MAX_ISP_PING_PONG_DUMP_SIZE];
- uint32_t first;
- uint32_t fill_count;
- struct vfe_device *vfe_dev;
+ struct vfe_other_vfe_state arr[MAX_ISP_PING_PONG_DUMP_SIZE];
+ int first;
+ int fill_count;
};
void msm_isp_dump_ping_pong_mismatch(void);
-void msm_isp_get_status(struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1);
-void msm_isp_dump_taskelet_debug(void);
+
uint32_t msm_isp_get_framedrop_period(
enum msm_vfe_frame_skip_pattern frame_skip_pattern);
void msm_isp_reset_burst_count_and_frame_drop(
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util_32.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_util_32.c
deleted file mode 100644
index 54a1bdde0fe5..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util_32.c
+++ /dev/null
@@ -1,1919 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-#include <linux/mutex.h>
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-#include <linux/ratelimit.h>
-
-#include "msm.h"
-#include "msm_isp_util_32.h"
-#include "msm_isp_axi_util_32.h"
-#include "msm_isp_stats_util_32.h"
-#include "msm_camera_io_util.h"
-
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-
-#define MAX_ISP_V4l2_EVENTS 100
-#define MAX_ISP_REG_LIST 100
-static DEFINE_MUTEX(bandwidth_mgr_mutex);
-static struct msm_isp_bandwidth_mgr isp_bandwidth_mgr;
-
-static uint64_t msm_isp_cpp_clk_rate;
-
-#define VFE40_8974V2_VERSION 0x1001001A
-static struct msm_bus_vectors msm_isp_init_vectors[] = {
- {
- .src = MSM_BUS_MASTER_VFE,
- .dst = MSM_BUS_SLAVE_EBI_CH0,
- .ab = 0,
- .ib = 0,
- },
-};
-
-static struct msm_bus_vectors msm_isp_ping_vectors[] = {
- {
- .src = MSM_BUS_MASTER_VFE,
- .dst = MSM_BUS_SLAVE_EBI_CH0,
- .ab = MSM_ISP_MIN_AB,
- .ib = MSM_ISP_MIN_IB,
- },
-};
-
-static struct msm_bus_vectors msm_isp_pong_vectors[] = {
- {
- .src = MSM_BUS_MASTER_VFE,
- .dst = MSM_BUS_SLAVE_EBI_CH0,
- .ab = MSM_ISP_MIN_AB,
- .ib = MSM_ISP_MIN_IB,
- },
-};
-
-static struct msm_bus_paths msm_isp_bus_client_config[] = {
- {
- ARRAY_SIZE(msm_isp_init_vectors),
- msm_isp_init_vectors,
- },
- {
- ARRAY_SIZE(msm_isp_ping_vectors),
- msm_isp_ping_vectors,
- },
- {
- ARRAY_SIZE(msm_isp_pong_vectors),
- msm_isp_pong_vectors,
- },
-};
-
-static struct msm_bus_scale_pdata msm_isp_bus_client_pdata = {
- msm_isp_bus_client_config,
- ARRAY_SIZE(msm_isp_bus_client_config),
- .name = "msm_camera_isp",
-};
-
-
-void msm_camera_io_dump_2(void __iomem *addr, int size)
-{
- char line_str[128], *p_str;
- int i;
- u32 *p = (u32 *) addr;
- u32 data;
-
- pr_err("%s: %pK %d\n", __func__, addr, size);
- line_str[0] = '\0';
- p_str = line_str;
- for (i = 0; i < size/4; i++) {
- if (i % 4 == 0) {
-#ifdef CONFIG_COMPAT
- snprintf(p_str, 20, "%016lx: ", (unsigned long) p);
- p_str += 18;
-#else
- snprintf(p_str, 12, "%08lx: ", (unsigned long) p);
- p_str += 10;
-#endif
- }
- data = readl_relaxed(p++);
- snprintf(p_str, 12, "%08x ", data);
- p_str += 9;
- if ((i + 1) % 4 == 0) {
- pr_err("%s\n", line_str);
- line_str[0] = '\0';
- p_str = line_str;
- }
- }
- if (line_str[0] != '\0')
- pr_err("%s\n", line_str);
-}
-
-void msm_isp_print_fourcc_error(const char *origin, uint32_t fourcc_format)
-{
- int i;
- char text[5];
-
- text[4] = '\0';
- for (i = 0; i < 4; i++) {
- text[i] = (char)(((fourcc_format) >> (i * 8)) & 0xFF);
- if ((text[i] < '0') || (text[i] > 'z')) {
- pr_err("%s: Invalid output format %d (unprintable)\n",
- origin, fourcc_format);
- return;
- }
- }
- pr_err("%s: Invalid output format %s\n",
- origin, text);
-}
-
-int msm_isp_init_bandwidth_mgr(enum msm_isp_hw_client client)
-{
- int rc = 0;
-
- mutex_lock(&bandwidth_mgr_mutex);
- isp_bandwidth_mgr.client_info[client].active = 1;
- if (isp_bandwidth_mgr.use_count++) {
- mutex_unlock(&bandwidth_mgr_mutex);
- return rc;
- }
- isp_bandwidth_mgr.bus_client =
- msm_bus_scale_register_client(&msm_isp_bus_client_pdata);
- if (!isp_bandwidth_mgr.bus_client) {
- pr_err("%s: client register failed\n", __func__);
- mutex_unlock(&bandwidth_mgr_mutex);
- return -EINVAL;
- }
-
- isp_bandwidth_mgr.bus_vector_active_idx = 1;
- msm_bus_scale_client_update_request(
- isp_bandwidth_mgr.bus_client,
- isp_bandwidth_mgr.bus_vector_active_idx);
-
- mutex_unlock(&bandwidth_mgr_mutex);
- return 0;
-}
-
-int msm_isp_update_bandwidth(enum msm_isp_hw_client client,
- uint64_t ab, uint64_t ib)
-{
- int i;
- struct msm_bus_paths *path;
-
- mutex_lock(&bandwidth_mgr_mutex);
- if (!isp_bandwidth_mgr.use_count ||
- !isp_bandwidth_mgr.bus_client) {
- pr_err("%s:error bandwidth manager inactive use_cnt:%d bus_clnt:%d\n",
- __func__, isp_bandwidth_mgr.use_count,
- isp_bandwidth_mgr.bus_client);
- return -EINVAL;
- }
-
- isp_bandwidth_mgr.client_info[client].ab = ab;
- isp_bandwidth_mgr.client_info[client].ib = ib;
- ALT_VECTOR_IDX(isp_bandwidth_mgr.bus_vector_active_idx);
- path =
- &(msm_isp_bus_client_pdata.usecase[
- isp_bandwidth_mgr.bus_vector_active_idx]);
- path->vectors[0].ab = 0;
- path->vectors[0].ib = 0;
- for (i = 0; i < MAX_ISP_CLIENT; i++) {
- if (isp_bandwidth_mgr.client_info[i].active) {
- path->vectors[0].ab +=
- isp_bandwidth_mgr.client_info[i].ab;
- path->vectors[0].ib +=
- isp_bandwidth_mgr.client_info[i].ib;
- }
- }
- ISP_DBG("%s: Total AB = %llu IB = %llu\n", __func__,
- path->vectors[0].ab, path->vectors[0].ib);
- msm_bus_scale_client_update_request(isp_bandwidth_mgr.bus_client,
- isp_bandwidth_mgr.bus_vector_active_idx);
- /* Insert into circular buffer */
- msm_isp_update_req_history(isp_bandwidth_mgr.bus_client,
- path->vectors[0].ab,
- path->vectors[0].ib,
- isp_bandwidth_mgr.client_info,
- sched_clock());
- mutex_unlock(&bandwidth_mgr_mutex);
- return 0;
-}
-
-void msm_isp_deinit_bandwidth_mgr(enum msm_isp_hw_client client)
-{
- if (client >= MAX_ISP_CLIENT) {
- pr_err("invalid Client id %d", client);
- return;
- }
- mutex_lock(&bandwidth_mgr_mutex);
- memset(&isp_bandwidth_mgr.client_info[client], 0,
- sizeof(struct msm_isp_bandwidth_info));
- if (--isp_bandwidth_mgr.use_count) {
- mutex_unlock(&bandwidth_mgr_mutex);
- return;
- }
-
- if (!isp_bandwidth_mgr.bus_client) {
- pr_err("%s:%d error: bus client invalid\n", __func__, __LINE__);
- mutex_unlock(&bandwidth_mgr_mutex);
- return;
- }
-
- msm_bus_scale_client_update_request(
- isp_bandwidth_mgr.bus_client, 0);
- msm_bus_scale_unregister_client(isp_bandwidth_mgr.bus_client);
- isp_bandwidth_mgr.bus_client = 0;
- mutex_unlock(&bandwidth_mgr_mutex);
-}
-
-void msm_isp_util_get_bandwidth_stats(struct vfe_device *vfe_dev,
- struct msm_isp_statistics *stats)
-{
- stats->isp_vfe0_active = isp_bandwidth_mgr.client_info[ISP_VFE0].active;
- stats->isp_vfe0_ab = isp_bandwidth_mgr.client_info[ISP_VFE0].ab;
- stats->isp_vfe0_ib = isp_bandwidth_mgr.client_info[ISP_VFE0].ib;
-
- stats->isp_vfe1_active = isp_bandwidth_mgr.client_info[ISP_VFE1].active;
- stats->isp_vfe1_ab = isp_bandwidth_mgr.client_info[ISP_VFE1].ab;
- stats->isp_vfe1_ib = isp_bandwidth_mgr.client_info[ISP_VFE1].ib;
-
- stats->isp_cpp_active = isp_bandwidth_mgr.client_info[ISP_CPP].active;
- stats->isp_cpp_ab = isp_bandwidth_mgr.client_info[ISP_CPP].ab;
- stats->isp_cpp_ib = isp_bandwidth_mgr.client_info[ISP_CPP].ib;
- stats->last_overflow_ab = vfe_dev->msm_isp_last_overflow_ab;
- stats->last_overflow_ib = vfe_dev->msm_isp_last_overflow_ib;
- stats->vfe_clk_rate = vfe_dev->msm_isp_vfe_clk_rate;
- stats->cpp_clk_rate = msm_isp_cpp_clk_rate;
-}
-
-void msm_isp_util_update_last_overflow_ab_ib(struct vfe_device *vfe_dev)
-{
- struct msm_bus_paths *path;
- path = &(msm_isp_bus_client_pdata.usecase[
- isp_bandwidth_mgr.bus_vector_active_idx]);
- vfe_dev->msm_isp_last_overflow_ab = path->vectors[0].ab;
- vfe_dev->msm_isp_last_overflow_ib = path->vectors[0].ib;
-}
-
-void msm_isp_util_update_clk_rate(long clock_rate)
-{
- msm_isp_cpp_clk_rate = clock_rate;
-}
-
-uint32_t msm_isp_get_framedrop_period(
- enum msm_vfe_frame_skip_pattern frame_skip_pattern)
-{
- switch (frame_skip_pattern) {
- case NO_SKIP:
- case EVERY_2FRAME:
- case EVERY_3FRAME:
- case EVERY_4FRAME:
- case EVERY_5FRAME:
- case EVERY_6FRAME:
- case EVERY_7FRAME:
- case EVERY_8FRAME:
- return frame_skip_pattern + 1;
- case EVERY_16FRAME:
- return 16;
- case EVERY_32FRAME:
- return 32;
- case SKIP_ALL:
- return 1;
- default:
- return 1;
- }
- return 1;
-}
-
-int msm_isp_get_clk_info(struct vfe_device *vfe_dev,
- struct platform_device *pdev, struct msm_cam_clk_info *vfe_clk_info)
-{
- int i, count, rc;
- uint32_t rates[VFE_CLK_INFO_MAX];
-
- struct device_node *of_node;
-
- of_node = pdev->dev.of_node;
-
- count = of_property_count_strings(of_node, "clock-names");
-
- ISP_DBG("count = %d\n", count);
- if (count <= 0) {
- pr_err("no clocks found in device tree, count=%d", count);
- return 0;
- }
-
- if (count > VFE_CLK_INFO_MAX) {
- pr_err("invalid count=%d, max is %d\n", count,
- VFE_CLK_INFO_MAX);
- return -EINVAL;
- }
-
- for (i = 0; i < count; i++) {
- rc = of_property_read_string_index(of_node, "clock-names",
- i, &(vfe_clk_info[i].clk_name));
- ISP_DBG("clock-names[%d] = %s\n", i, vfe_clk_info[i].clk_name);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- return rc;
- }
- }
- rc = of_property_read_u32_array(of_node, "qcom,clock-rates",
- rates, count);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- return rc;
- }
- for (i = 0; i < count; i++) {
- vfe_clk_info[i].clk_rate =
- (rates[i] == 0) ? (long)-1 : rates[i];
- ISP_DBG("clk_rate[%d] = %ld\n", i, vfe_clk_info[i].clk_rate);
- }
- vfe_dev->num_clk = count;
- return 0;
-}
-
-static inline void msm_isp_get_timestamp(struct msm_isp_timestamp *time_stamp)
-{
- struct timespec ts;
-
- ktime_get_ts(&ts);
- time_stamp->buf_time.tv_sec = ts.tv_sec;
- time_stamp->buf_time.tv_usec = ts.tv_nsec/1000;
- do_gettimeofday(&(time_stamp->event_time));
-}
-
-int msm_isp_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub)
-{
- struct vfe_device *vfe_dev = v4l2_get_subdevdata(sd);
- int rc = 0;
-
- rc = v4l2_event_subscribe(fh, sub, MAX_ISP_V4l2_EVENTS, NULL);
- if (rc == 0) {
- if (sub->type == V4L2_EVENT_ALL) {
- int i;
-
- vfe_dev->axi_data.event_mask = 0;
- for (i = 0; i < ISP_EVENT_MAX; i++)
- vfe_dev->axi_data.event_mask |= (1 << i);
- } else {
- int event_idx = sub->type - ISP_EVENT_BASE;
-
- vfe_dev->axi_data.event_mask |= (1 << event_idx);
- }
- }
- return rc;
-}
-
-int msm_isp_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub)
-{
- struct vfe_device *vfe_dev = v4l2_get_subdevdata(sd);
- int rc = 0;
-
- rc = v4l2_event_unsubscribe(fh, sub);
- if (sub->type == V4L2_EVENT_ALL) {
- vfe_dev->axi_data.event_mask = 0;
- } else {
- int event_idx = sub->type - ISP_EVENT_BASE;
-
- vfe_dev->axi_data.event_mask &= ~(1 << event_idx);
- }
- return rc;
-}
-
-static int msm_isp_get_max_clk_rate(struct vfe_device *vfe_dev, long *rate)
-{
- int clk_idx = 0;
- unsigned long max_value = ~0;
- long round_rate = 0;
-
- if (!vfe_dev || !rate) {
- pr_err("%s:%d failed: vfe_dev %pK rate %pK\n",
- __func__, __LINE__, vfe_dev, rate);
- return -EINVAL;
- }
-
- *rate = 0;
- if (!vfe_dev->hw_info) {
- pr_err("%s:%d failed: vfe_dev->hw_info %pK\n", __func__,
- __LINE__, vfe_dev->hw_info);
- return -EINVAL;
- }
-
- clk_idx = vfe_dev->hw_info->vfe_clk_idx;
- if (clk_idx >= vfe_dev->num_clk) {
- pr_err("%s:%d failed: clk_idx %d max array size %d\n",
- __func__, __LINE__, clk_idx,
- vfe_dev->num_clk);
- return -EINVAL;
- }
-
- round_rate = clk_round_rate(vfe_dev->vfe_clk[clk_idx], max_value);
- if (round_rate < 0) {
- pr_err("%s: Invalid vfe clock rate\n", __func__);
- return -EINVAL;
- }
-
- *rate = round_rate;
- return 0;
-}
-
-static int msm_isp_set_clk_rate(struct vfe_device *vfe_dev, long *rate)
-{
- int rc = 0;
- int clk_idx = vfe_dev->hw_info->vfe_clk_idx;
- long round_rate =
- clk_round_rate(vfe_dev->vfe_clk[clk_idx], *rate);
- if (round_rate < 0) {
- pr_err("%s: Invalid vfe clock rate\n", __func__);
- return round_rate;
- }
-
- rc = clk_set_rate(vfe_dev->vfe_clk[clk_idx], round_rate);
- if (rc < 0) {
- pr_err("%s: Vfe set rate error\n", __func__);
- return rc;
- }
- *rate = round_rate;
- vfe_dev->msm_isp_vfe_clk_rate = round_rate;
- return 0;
-}
-
-void msm_isp_fetch_engine_done_notify(struct vfe_device *vfe_dev,
- struct msm_vfe_fetch_engine_info *fetch_engine_info)
-{
- struct msm_isp32_event_data fe_rd_done_event;
-
- if (!fetch_engine_info->is_busy)
- return;
- memset(&fe_rd_done_event, 0, sizeof(struct msm_isp32_event_data));
- fe_rd_done_event.frame_id =
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
- fe_rd_done_event.u.buf_done.session_id = fetch_engine_info->session_id;
- fe_rd_done_event.u.buf_done.stream_id = fetch_engine_info->stream_id;
- fe_rd_done_event.u.buf_done.handle = fetch_engine_info->bufq_handle;
- fe_rd_done_event.u.buf_done.buf_idx = fetch_engine_info->buf_idx;
- ISP_DBG("%s:VFE%d ISP_EVENT_FE_READ_DONE buf_idx %d\n",
- __func__, vfe_dev->pdev->id, fetch_engine_info->buf_idx);
- fetch_engine_info->is_busy = 0;
- msm_isp_send_event(vfe_dev, ISP_EVENT_FE_READ_DONE, &fe_rd_done_event);
-}
-
-int msm_isp_cfg_pix(struct vfe_device *vfe_dev,
- struct msm_vfe_input_cfg *input_cfg)
-{
- int rc = 0;
-
- if (vfe_dev->axi_data.src_info[VFE_PIX_0].active) {
- pr_err("%s: pixel path is active\n", __func__);
- return -EINVAL;
- }
-
- vfe_dev->axi_data.src_info[VFE_PIX_0].pixel_clock =
- input_cfg->input_pix_clk;
- vfe_dev->axi_data.src_info[VFE_PIX_0].input_mux =
- input_cfg->d.pix_cfg.input_mux;
- vfe_dev->axi_data.src_info[VFE_PIX_0].input_format =
- input_cfg->d.pix_cfg.input_format;
-
- rc = msm_isp_set_clk_rate(vfe_dev,
- &vfe_dev->axi_data.src_info[VFE_PIX_0].pixel_clock);
- if (rc < 0) {
- pr_err("%s: clock set rate failed\n", __func__);
- return rc;
- }
-
- ISP_DBG("%s: input mux is %d CAMIF %d io_format 0x%x\n", __func__,
- input_cfg->d.pix_cfg.input_mux, CAMIF,
- input_cfg->d.pix_cfg.input_format);
-
- if (input_cfg->d.pix_cfg.input_mux == CAMIF) {
- vfe_dev->axi_data.src_info[VFE_PIX_0].width =
- input_cfg->d.pix_cfg.camif_cfg.pixels_per_line;
- } else if (input_cfg->d.pix_cfg.input_mux == EXTERNAL_READ) {
- vfe_dev->axi_data.src_info[VFE_PIX_0].width =
- input_cfg->d.pix_cfg.fetch_engine_cfg.buf_stride;
- }
- vfe_dev->hw_info->vfe_ops.core_ops.cfg_input_mux(
- vfe_dev, &input_cfg->d.pix_cfg);
- return rc;
-}
-
-int msm_isp_cfg_rdi(struct vfe_device *vfe_dev,
- struct msm_vfe_input_cfg *input_cfg)
-{
- int rc = 0;
-
- if (vfe_dev->axi_data.src_info[input_cfg->input_src].active) {
- pr_err("%s: RAW%d path is active\n", __func__,
- input_cfg->input_src - VFE_RAW_0);
- return -EINVAL;
- }
-
- vfe_dev->axi_data.src_info[input_cfg->input_src].pixel_clock =
- input_cfg->input_pix_clk;
- vfe_dev->hw_info->vfe_ops.core_ops.cfg_rdi_reg(
- vfe_dev, &input_cfg->d.rdi_cfg, input_cfg->input_src);
- return rc;
-}
-
-int msm_isp_cfg_input(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0;
- struct msm_vfe_input_cfg *input_cfg = arg;
-
- switch (input_cfg->input_src) {
- case VFE_PIX_0:
- rc = msm_isp_cfg_pix(vfe_dev, input_cfg);
- break;
- case VFE_RAW_0:
- case VFE_RAW_1:
- case VFE_RAW_2:
- rc = msm_isp_cfg_rdi(vfe_dev, input_cfg);
- break;
- default:
- pr_err("%s: Invalid input source\n", __func__);
- rc = -EINVAL;
- }
- return rc;
-}
-
-static int msm_isp_proc_cmd_list_unlocked(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0;
- uint32_t count = 0;
- struct msm_vfe_cfg_cmd_list *proc_cmd =
- (struct msm_vfe_cfg_cmd_list *)arg;
- struct msm_vfe_cfg_cmd_list cmd, cmd_next;
- struct msm_vfe_cfg_cmd2 cfg_cmd;
-
- if (!vfe_dev || !arg) {
- pr_err("%s:%d failed: vfe_dev %pK arg %pK", __func__, __LINE__,
- vfe_dev, arg);
- return -EINVAL;
- }
-
- rc = msm_isp_proc_cmd(vfe_dev, &proc_cmd->cfg_cmd);
- if (rc < 0)
- pr_err("%s:%d failed: rc %d", __func__, __LINE__, rc);
-
- cmd = *proc_cmd;
-
- while (cmd.next) {
- if (cmd.next_size != sizeof(struct msm_vfe_cfg_cmd_list)) {
- pr_err("%s:%d failed: next size %u != expected %zu\n",
- __func__, __LINE__, cmd.next_size,
- sizeof(struct msm_vfe_cfg_cmd_list));
- break;
- }
- if (++count >= MAX_ISP_REG_LIST) {
- pr_err("%s:%d Error exceeding the max register count:%u\n",
- __func__, __LINE__, count);
- rc = -EFAULT;
- break;
- }
- if (copy_from_user(&cmd_next, (void __user *)cmd.next,
- sizeof(struct msm_vfe_cfg_cmd_list))) {
- rc = -EFAULT;
- continue;
- }
-
- cfg_cmd = cmd_next.cfg_cmd;
-
- rc = msm_isp_proc_cmd(vfe_dev, &cfg_cmd);
- if (rc < 0)
- pr_err("%s:%d failed: rc %d", __func__, __LINE__, rc);
-
- cmd = cmd_next;
- }
- return rc;
-}
-
-#ifdef CONFIG_COMPAT
-struct msm_vfe_cfg_cmd2_32 {
- uint16_t num_cfg;
- uint16_t cmd_len;
- compat_caddr_t cfg_data;
- compat_caddr_t cfg_cmd;
-};
-
-struct msm_vfe_cfg_cmd_list_32 {
- struct msm_vfe_cfg_cmd2_32 cfg_cmd;
- compat_caddr_t next;
- uint32_t next_size;
-};
-
-#define VIDIOC_MSM_VFE_REG_CFG_COMPAT \
- _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2_32)
-#define VIDIOC_MSM_VFE_REG_LIST_CFG_COMPAT \
- _IOWR('V', BASE_VIDIOC_PRIVATE+14, struct msm_vfe_cfg_cmd_list_32)
-
-static void msm_isp_compat_to_proc_cmd(struct msm_vfe_cfg_cmd2 *proc_cmd,
- struct msm_vfe_cfg_cmd2_32 *proc_cmd_ptr32)
-{
- proc_cmd->num_cfg = proc_cmd_ptr32->num_cfg;
- proc_cmd->cmd_len = proc_cmd_ptr32->cmd_len;
- proc_cmd->cfg_data = compat_ptr(proc_cmd_ptr32->cfg_data);
- proc_cmd->cfg_cmd = compat_ptr(proc_cmd_ptr32->cfg_cmd);
-}
-
-static int msm_isp_proc_cmd_list_compat(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0;
- uint32_t count = 0;
- struct msm_vfe_cfg_cmd_list_32 *proc_cmd =
- (struct msm_vfe_cfg_cmd_list_32 *)arg;
- struct msm_vfe_cfg_cmd_list_32 cmd, cmd_next;
- struct msm_vfe_cfg_cmd2 current_cmd;
-
- if (!vfe_dev || !arg) {
- pr_err("%s:%d failed: vfe_dev %pK arg %pK", __func__, __LINE__,
- vfe_dev, arg);
- return -EINVAL;
- }
- msm_isp_compat_to_proc_cmd(&current_cmd, &proc_cmd->cfg_cmd);
- rc = msm_isp_proc_cmd(vfe_dev, &current_cmd);
- if (rc < 0)
- pr_err("%s:%d failed: rc %d", __func__, __LINE__, rc);
-
- cmd = *proc_cmd;
-
- while (NULL != compat_ptr(cmd.next)) {
- if (cmd.next_size != sizeof(struct msm_vfe_cfg_cmd_list_32)) {
- pr_err("%s:%d failed: next size %u != expected %zu\n",
- __func__, __LINE__, cmd.next_size,
- sizeof(struct msm_vfe_cfg_cmd_list));
- break;
- }
- if (++count >= MAX_ISP_REG_LIST) {
- pr_err("%s:%d Error exceeding the max register count:%u\n",
- __func__, __LINE__, count);
- rc = -EFAULT;
- break;
- }
- if (copy_from_user(&cmd_next, compat_ptr(cmd.next),
- sizeof(struct msm_vfe_cfg_cmd_list_32))) {
- rc = -EFAULT;
- continue;
- }
-
- msm_isp_compat_to_proc_cmd(&current_cmd, &cmd_next.cfg_cmd);
- rc = msm_isp_proc_cmd(vfe_dev, &current_cmd);
- if (rc < 0)
- pr_err("%s:%d failed: rc %d", __func__, __LINE__, rc);
-
- cmd = cmd_next;
- }
- return rc;
-}
-
-static int msm_isp_proc_cmd_list(struct vfe_device *vfe_dev, void *arg)
-{
- if (is_compat_task())
- return msm_isp_proc_cmd_list_compat(vfe_dev, arg);
- else
- return msm_isp_proc_cmd_list_unlocked(vfe_dev, arg);
-}
-#else /* CONFIG_COMPAT */
-static int msm_isp_proc_cmd_list(struct vfe_device *vfe_dev, void *arg)
-{
- return msm_isp_proc_cmd_list_unlocked(vfe_dev, arg);
-}
-#endif /* CONFIG_COMPAT */
-
-
-static long msm_isp_ioctl_unlocked(struct v4l2_subdev *sd,
- unsigned int cmd, void *arg)
-{
- long rc = 0;
- struct vfe_device *vfe_dev = v4l2_get_subdevdata(sd);
-
- if (!vfe_dev || !vfe_dev->vfe_base) {
- pr_err("%s:%d failed: invalid params %pK\n",
- __func__, __LINE__, vfe_dev);
- if (vfe_dev)
- pr_err("%s:%d failed %pK\n", __func__,
- __LINE__, vfe_dev->vfe_base);
- return -EINVAL;
- }
-
- /* use real time mutex for hard real-time ioctls such as
- * buffer operations and register updates.
- * Use core mutex for other ioctls that could take
- * longer time to complete such as start/stop ISP streams
- * which blocks until the hardware start/stop streaming
- */
- ISP_DBG("%s cmd: %d\n", __func__, _IOC_TYPE(cmd));
- switch (cmd) {
- case VIDIOC_MSM_VFE_REG_CFG: {
- mutex_lock(&vfe_dev->realtime_mutex);
- rc = msm_isp_proc_cmd(vfe_dev, arg);
- mutex_unlock(&vfe_dev->realtime_mutex);
- break;
- }
- case VIDIOC_MSM_VFE_REG_LIST_CFG: {
- mutex_lock(&vfe_dev->realtime_mutex);
- rc = msm_isp_proc_cmd_list(vfe_dev, arg);
- mutex_unlock(&vfe_dev->realtime_mutex);
- break;
- }
- case VIDIOC_MSM_ISP_REQUEST_BUF:
- case VIDIOC_MSM_ISP_ENQUEUE_BUF:
- case VIDIOC_MSM_ISP_RELEASE_BUF: {
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_proc_buf_cmd(vfe_dev->buf_mgr, cmd, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- }
- case VIDIOC_MSM_ISP32_REQUEST_STREAM:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_request_axi_stream(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_RELEASE_STREAM:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_release_axi_stream(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_CFG_STREAM:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_cfg_axi_stream(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_AXI_HALT:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_axi_halt(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_AXI_RESET:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_axi_reset(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_AXI_RESTART:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_axi_restart(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_INPUT_CFG:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_cfg_input(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_FETCH_ENG_START:
- mutex_lock(&vfe_dev->core_mutex);
- rc = vfe_dev->hw_info->vfe_ops.core_ops.
- start_fetch_eng(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_REG_UPDATE_CMD:
- if (arg) {
- enum msm_vfe_input_src frame_src =
- *((enum msm_vfe_input_src *)arg);
- vfe_dev->hw_info->vfe_ops.core_ops.
- reg_update(vfe_dev, (1 << frame_src));
- vfe_dev->axi_data.src_info[frame_src].last_updt_frm_id =
- vfe_dev->axi_data.src_info[frame_src].frame_id;
- }
- break;
- case VIDIOC_MSM_ISP_SET_SRC_STATE:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_set_src_state(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_REQUEST_STATS_STREAM:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_request_stats_stream(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_RELEASE_STATS_STREAM:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_release_stats_stream(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_CFG_STATS_STREAM:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_cfg_stats_stream(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_UPDATE_STATS_STREAM:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_update_stats_stream(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_UPDATE_STREAM:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_update_axi_stream(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case VIDIOC_MSM_ISP_SMMU_ATTACH:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_smmu_attach(vfe_dev->buf_mgr, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case MSM_SD_NOTIFY_FREEZE:
- vfe_dev->isp_sof_debug = 0;
- break;
- case VIDIOC_MSM_ISP_BUF_DONE:
- mutex_lock(&vfe_dev->core_mutex);
- rc = msm_isp_user_buf_done(vfe_dev, arg);
- mutex_unlock(&vfe_dev->core_mutex);
- break;
- case MSM_SD_SHUTDOWN:
- while (vfe_dev->vfe_open_cnt != 0)
- msm_isp_close_node(sd, NULL);
- break;
-
- default:
- pr_err_ratelimited("%s: Invalid ISP command\n", __func__);
- rc = -EINVAL;
- }
- return rc;
-}
-
-
-#ifdef CONFIG_COMPAT
-static long msm_isp_ioctl_compat(struct v4l2_subdev *sd,
- unsigned int cmd, void *arg)
-{
- struct vfe_device *vfe_dev = v4l2_get_subdevdata(sd);
- long rc = 0;
-
- if (!vfe_dev || !vfe_dev->vfe_base) {
- pr_err("%s:%d failed: invalid params %pK\n",
- __func__, __LINE__, vfe_dev);
- if (vfe_dev)
- pr_err("%s:%d failed %pK\n", __func__,
- __LINE__, vfe_dev->vfe_base);
- return -EINVAL;
- }
-
- switch (cmd) {
- case VIDIOC_MSM_VFE_REG_CFG_COMPAT: {
- struct msm_vfe_cfg_cmd2 proc_cmd;
-
- mutex_lock(&vfe_dev->realtime_mutex);
- msm_isp_compat_to_proc_cmd(&proc_cmd,
- (struct msm_vfe_cfg_cmd2_32 *) arg);
- rc = msm_isp_proc_cmd(vfe_dev, &proc_cmd);
- mutex_unlock(&vfe_dev->realtime_mutex);
- break;
- }
- case VIDIOC_MSM_VFE_REG_LIST_CFG_COMPAT: {
- mutex_lock(&vfe_dev->realtime_mutex);
- rc = msm_isp_proc_cmd_list(vfe_dev, arg);
- mutex_unlock(&vfe_dev->realtime_mutex);
- break;
- }
- default:
- return msm_isp_ioctl_unlocked(sd, cmd, arg);
- }
-
- return rc;
-}
-
-long msm_isp_ioctl(struct v4l2_subdev *sd,
- unsigned int cmd, void *arg)
-{
- return msm_isp_ioctl_compat(sd, cmd, arg);
-}
-#else /* CONFIG_COMPAT */
-long msm_isp_ioctl(struct v4l2_subdev *sd,
- unsigned int cmd, void *arg)
-{
- return msm_isp_ioctl_unlocked(sd, cmd, arg);
-}
-#endif /* CONFIG_COMPAT */
-
-static int msm_isp_send_hw_cmd(struct vfe_device *vfe_dev,
- struct msm_vfe_reg_cfg_cmd *reg_cfg_cmd,
- uint32_t *cfg_data, uint32_t cmd_len)
-{
- if (!vfe_dev || !reg_cfg_cmd) {
- pr_err("%s:%d failed: vfe_dev %pK reg_cfg_cmd %pK\n", __func__,
- __LINE__, vfe_dev, reg_cfg_cmd);
- return -EINVAL;
- }
- if ((reg_cfg_cmd->cmd_type != VFE_CFG_MASK) &&
- (!cfg_data || !cmd_len)) {
- pr_err("%s:%d failed: cmd type %d cfg_data %pK cmd_len %d\n",
- __func__, __LINE__, reg_cfg_cmd->cmd_type, cfg_data,
- cmd_len);
- return -EINVAL;
- }
-
- /* Validate input parameters */
- switch (reg_cfg_cmd->cmd_type) {
- case VFE_WRITE:
- case VFE_READ:
- case VFE_WRITE_MB: {
- if ((reg_cfg_cmd->u.rw_info.reg_offset >
- (UINT_MAX - reg_cfg_cmd->u.rw_info.len)) ||
- ((reg_cfg_cmd->u.rw_info.reg_offset +
- reg_cfg_cmd->u.rw_info.len) >
- resource_size(vfe_dev->vfe_mem)) ||
- (reg_cfg_cmd->u.rw_info.reg_offset & 0x3)) {
- pr_err("%s:%d reg_offset %d len %d res %d\n",
- __func__, __LINE__,
- reg_cfg_cmd->u.rw_info.reg_offset,
- reg_cfg_cmd->u.rw_info.len,
- (uint32_t)resource_size(vfe_dev->vfe_mem));
- return -EINVAL;
- }
-
- if ((reg_cfg_cmd->u.rw_info.cmd_data_offset >
- (UINT_MAX - reg_cfg_cmd->u.rw_info.len)) ||
- ((reg_cfg_cmd->u.rw_info.cmd_data_offset +
- reg_cfg_cmd->u.rw_info.len) > cmd_len)) {
- pr_err("%s:%d cmd_data_offset %d len %d cmd_len %d\n",
- __func__, __LINE__,
- reg_cfg_cmd->u.rw_info.cmd_data_offset,
- reg_cfg_cmd->u.rw_info.len, cmd_len);
- return -EINVAL;
- }
- break;
- }
-
- case VFE_WRITE_DMI_16BIT:
- case VFE_WRITE_DMI_32BIT:
- case VFE_WRITE_DMI_64BIT:
- case VFE_READ_DMI_16BIT:
- case VFE_READ_DMI_32BIT:
- case VFE_READ_DMI_64BIT: {
- if (reg_cfg_cmd->cmd_type == VFE_WRITE_DMI_64BIT ||
- reg_cfg_cmd->cmd_type == VFE_READ_DMI_64BIT) {
- if ((reg_cfg_cmd->u.dmi_info.hi_tbl_offset <=
- reg_cfg_cmd->u.dmi_info.lo_tbl_offset) ||
- (reg_cfg_cmd->u.dmi_info.hi_tbl_offset -
- reg_cfg_cmd->u.dmi_info.lo_tbl_offset !=
- (sizeof(uint32_t)))) {
- pr_err("%s:%d hi %d lo %d\n",
- __func__, __LINE__,
- reg_cfg_cmd->u.dmi_info.hi_tbl_offset,
- reg_cfg_cmd->u.dmi_info.hi_tbl_offset);
- return -EINVAL;
- }
- if (reg_cfg_cmd->u.dmi_info.len <= sizeof(uint32_t)) {
- pr_err("%s:%d len %d\n",
- __func__, __LINE__,
- reg_cfg_cmd->u.dmi_info.len);
- return -EINVAL;
- }
- if (((UINT_MAX -
- reg_cfg_cmd->u.dmi_info.hi_tbl_offset) <
- (reg_cfg_cmd->u.dmi_info.len -
- sizeof(uint32_t))) ||
- ((reg_cfg_cmd->u.dmi_info.hi_tbl_offset +
- reg_cfg_cmd->u.dmi_info.len -
- sizeof(uint32_t)) > cmd_len)) {
- pr_err("%s:%d hi_tbl_offset %d len %d cmd %d\n",
- __func__, __LINE__,
- reg_cfg_cmd->u.dmi_info.hi_tbl_offset,
- reg_cfg_cmd->u.dmi_info.len, cmd_len);
- return -EINVAL;
- }
- }
- if ((reg_cfg_cmd->u.dmi_info.lo_tbl_offset >
- (UINT_MAX - reg_cfg_cmd->u.dmi_info.len)) ||
- ((reg_cfg_cmd->u.dmi_info.lo_tbl_offset +
- reg_cfg_cmd->u.dmi_info.len) > cmd_len)) {
- pr_err("%s:%d lo_tbl_offset %d len %d cmd_len %d\n",
- __func__, __LINE__,
- reg_cfg_cmd->u.dmi_info.lo_tbl_offset,
- reg_cfg_cmd->u.dmi_info.len, cmd_len);
- return -EINVAL;
- }
- break;
- }
-
- default:
- break;
- }
-
- switch (reg_cfg_cmd->cmd_type) {
- case VFE_WRITE: {
- msm_camera_io_memcpy(vfe_dev->vfe_base +
- reg_cfg_cmd->u.rw_info.reg_offset,
- cfg_data + reg_cfg_cmd->u.rw_info.cmd_data_offset/4,
- reg_cfg_cmd->u.rw_info.len);
- break;
- }
- case VFE_WRITE_MB: {
- msm_camera_io_memcpy_mb(vfe_dev->vfe_base +
- reg_cfg_cmd->u.rw_info.reg_offset,
- cfg_data + reg_cfg_cmd->u.rw_info.cmd_data_offset/4,
- reg_cfg_cmd->u.rw_info.len);
- break;
- }
- case VFE_CFG_MASK: {
- uint32_t temp;
-
- if ((UINT_MAX - sizeof(temp) <
- reg_cfg_cmd->u.mask_info.reg_offset) ||
- (resource_size(vfe_dev->vfe_mem) <
- reg_cfg_cmd->u.mask_info.reg_offset +
- sizeof(temp)) ||
- (reg_cfg_cmd->u.mask_info.reg_offset & 0x3)) {
- pr_err("%s: VFE_CFG_MASK: Invalid length\n", __func__);
- return -EINVAL;
- }
- temp = msm_camera_io_r(vfe_dev->vfe_base +
- reg_cfg_cmd->u.mask_info.reg_offset);
-
- temp &= ~reg_cfg_cmd->u.mask_info.mask;
- temp |= reg_cfg_cmd->u.mask_info.val;
- msm_camera_io_w(temp, vfe_dev->vfe_base +
- reg_cfg_cmd->u.mask_info.reg_offset);
- break;
- }
- case VFE_WRITE_DMI_16BIT:
- case VFE_WRITE_DMI_32BIT:
- case VFE_WRITE_DMI_64BIT: {
- int i;
- uint32_t *hi_tbl_ptr = NULL, *lo_tbl_ptr = NULL;
- uint32_t hi_val, lo_val, lo_val1;
-
- if (reg_cfg_cmd->cmd_type == VFE_WRITE_DMI_64BIT) {
- hi_tbl_ptr = cfg_data +
- reg_cfg_cmd->u.dmi_info.hi_tbl_offset/4;
- }
- lo_tbl_ptr = cfg_data +
- reg_cfg_cmd->u.dmi_info.lo_tbl_offset/4;
- if (reg_cfg_cmd->cmd_type == VFE_WRITE_DMI_64BIT)
- reg_cfg_cmd->u.dmi_info.len =
- reg_cfg_cmd->u.dmi_info.len / 2;
- for (i = 0; i < reg_cfg_cmd->u.dmi_info.len/4; i++) {
- lo_val = *lo_tbl_ptr++;
- if (reg_cfg_cmd->cmd_type == VFE_WRITE_DMI_16BIT) {
- lo_val1 = lo_val & 0x0000FFFF;
- lo_val = (lo_val & 0xFFFF0000)>>16;
- msm_camera_io_w(lo_val1, vfe_dev->vfe_base +
- vfe_dev->hw_info->dmi_reg_offset + 0x4);
- } else if (reg_cfg_cmd->cmd_type ==
- VFE_WRITE_DMI_64BIT) {
- lo_tbl_ptr++;
- hi_val = *hi_tbl_ptr;
- hi_tbl_ptr = hi_tbl_ptr + 2;
- msm_camera_io_w(hi_val, vfe_dev->vfe_base +
- vfe_dev->hw_info->dmi_reg_offset);
- }
- msm_camera_io_w(lo_val, vfe_dev->vfe_base +
- vfe_dev->hw_info->dmi_reg_offset + 0x4);
- }
- break;
- }
- case VFE_READ_DMI_16BIT:
- case VFE_READ_DMI_32BIT:
- case VFE_READ_DMI_64BIT: {
- int i;
- uint32_t *hi_tbl_ptr = NULL, *lo_tbl_ptr = NULL;
- uint32_t hi_val, lo_val, lo_val1;
-
- if (reg_cfg_cmd->cmd_type == VFE_READ_DMI_64BIT) {
- hi_tbl_ptr = cfg_data +
- reg_cfg_cmd->u.dmi_info.hi_tbl_offset/4;
- }
-
- lo_tbl_ptr = cfg_data +
- reg_cfg_cmd->u.dmi_info.lo_tbl_offset/4;
-
- if (reg_cfg_cmd->cmd_type == VFE_READ_DMI_64BIT)
- reg_cfg_cmd->u.dmi_info.len =
- reg_cfg_cmd->u.dmi_info.len / 2;
-
- for (i = 0; i < reg_cfg_cmd->u.dmi_info.len/4; i++) {
- lo_val = msm_camera_io_r(vfe_dev->vfe_base +
- vfe_dev->hw_info->dmi_reg_offset + 0x4);
-
- if (reg_cfg_cmd->cmd_type == VFE_READ_DMI_16BIT) {
- lo_val1 = msm_camera_io_r(vfe_dev->vfe_base +
- vfe_dev->hw_info->dmi_reg_offset + 0x4);
- lo_val |= lo_val1 << 16;
- }
- *lo_tbl_ptr++ = lo_val;
- if (reg_cfg_cmd->cmd_type == VFE_READ_DMI_64BIT) {
- hi_val = msm_camera_io_r(vfe_dev->vfe_base +
- vfe_dev->hw_info->dmi_reg_offset);
- *hi_tbl_ptr = hi_val;
- hi_tbl_ptr += 2;
- lo_tbl_ptr++;
- }
- }
- break;
- }
- case VFE_HW_UPDATE_LOCK: {
- uint32_t update_id =
- vfe_dev->axi_data.src_info[VFE_PIX_0].last_updt_frm_id;
- if (update_id) {
- ISP_DBG("%s hw_update_lock fail cur_id %u,last_id %u\n",
- __func__,
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id,
- update_id);
- return -EINVAL;
- }
- break;
- }
- case VFE_HW_UPDATE_UNLOCK: {
- if (vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id
- != *cfg_data) {
- ISP_DBG("hw_updt over frm bound,strt_id %u end_id %d\n",
- *cfg_data,
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id);
- }
- vfe_dev->axi_data.src_info[VFE_PIX_0].last_updt_frm_id =
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
- break;
- }
- case VFE_READ: {
- int i;
- uint32_t *data_ptr = cfg_data +
- reg_cfg_cmd->u.rw_info.cmd_data_offset/4;
- for (i = 0; i < reg_cfg_cmd->u.rw_info.len/4; i++) {
- if ((data_ptr < cfg_data) ||
- (UINT_MAX / sizeof(*data_ptr) <
- (data_ptr - cfg_data)) ||
- (sizeof(*data_ptr) * (data_ptr - cfg_data) >=
- cmd_len))
- return -EINVAL;
- *data_ptr++ = msm_camera_io_r(vfe_dev->vfe_base +
- reg_cfg_cmd->u.rw_info.reg_offset);
- reg_cfg_cmd->u.rw_info.reg_offset += 4;
- }
- break;
- }
- case GET_MAX_CLK_RATE: {
- int rc = 0;
- unsigned long rate;
-
- if (cmd_len != sizeof(__u32)) {
- pr_err("%s:%d failed: invalid cmd len %u exp %zu\n",
- __func__, __LINE__, cmd_len,
- sizeof(__u32));
- return -EINVAL;
- }
- rc = msm_isp_get_max_clk_rate(vfe_dev, &rate);
- if (rc < 0) {
- pr_err("%s:%d failed: rc %d\n", __func__, __LINE__, rc);
- return -EINVAL;
- }
-
- *(__u32 *)cfg_data = (__u32)rate;
-
- break;
- }
- case GET_ISP_ID: {
- uint32_t *isp_id = NULL;
-
- if (cmd_len < sizeof(uint32_t)) {
- pr_err("%s:%d failed: invalid cmd len %u exp %zu\n",
- __func__, __LINE__, cmd_len,
- sizeof(uint32_t));
- return -EINVAL;
- }
-
- isp_id = (uint32_t *)cfg_data;
- *isp_id = vfe_dev->pdev->id;
- break;
- }
- case SET_WM_UB_SIZE:
- break;
- case SET_UB_POLICY: {
-
- if (cmd_len < sizeof(vfe_dev->vfe_ub_policy)) {
- pr_err("%s:%d failed: invalid cmd len %u exp %zu\n",
- __func__, __LINE__, cmd_len,
- sizeof(vfe_dev->vfe_ub_policy));
- return -EINVAL;
- }
- vfe_dev->vfe_ub_policy = *cfg_data;
- break;
- }
- default:
- break;
- }
- return 0;
-}
-
-int msm_isp_proc_cmd(struct vfe_device *vfe_dev, void *arg)
-{
- int rc = 0, i;
- struct msm_vfe_cfg_cmd2 *proc_cmd = arg;
- struct msm_vfe_reg_cfg_cmd *reg_cfg_cmd;
- uint32_t *cfg_data = NULL;
-
- if (!proc_cmd->num_cfg) {
- pr_err("%s: Passed num_cfg as 0\n", __func__);
- return -EINVAL;
- }
-
- reg_cfg_cmd = kzalloc(sizeof(struct msm_vfe_reg_cfg_cmd)*
- proc_cmd->num_cfg, GFP_KERNEL);
- if (!reg_cfg_cmd) {
- rc = -ENOMEM;
- goto reg_cfg_failed;
- }
-
- if (copy_from_user(reg_cfg_cmd,
- (void __user *)(proc_cmd->cfg_cmd),
- sizeof(struct msm_vfe_reg_cfg_cmd) * proc_cmd->num_cfg)) {
- rc = -EFAULT;
- goto copy_cmd_failed;
- }
-
- if (proc_cmd->cmd_len > 0 &&
- proc_cmd->cmd_len < UINT16_MAX) {
- cfg_data = kzalloc(proc_cmd->cmd_len, GFP_KERNEL);
- if (!cfg_data) {
- pr_err("%s: cfg_data alloc failed\n", __func__);
- rc = -ENOMEM;
- goto cfg_data_failed;
- }
-
- if (copy_from_user(cfg_data,
- (void __user *)(proc_cmd->cfg_data),
- proc_cmd->cmd_len)) {
- rc = -EFAULT;
- goto copy_cmd_failed;
- }
- }
-
- for (i = 0; i < proc_cmd->num_cfg; i++)
- rc = msm_isp_send_hw_cmd(vfe_dev, &reg_cfg_cmd[i],
- cfg_data, proc_cmd->cmd_len);
-
- if (copy_to_user(proc_cmd->cfg_data,
- cfg_data, proc_cmd->cmd_len)) {
- rc = -EFAULT;
- goto copy_cmd_failed;
- }
-
-copy_cmd_failed:
- kfree(cfg_data);
-cfg_data_failed:
- kfree(reg_cfg_cmd);
-reg_cfg_failed:
- return rc;
-}
-
-int msm_isp_send_event(struct vfe_device *vfe_dev,
- uint32_t event_type,
- struct msm_isp32_event_data *event_data)
-{
- struct v4l2_event isp_event;
-
- memset(&isp_event, 0, sizeof(struct v4l2_event));
- isp_event.id = 0;
- isp_event.type = event_type;
-
- memcpy(&isp_event.u.data[0], event_data,
- sizeof(struct msm_isp32_event_data));
- v4l2_event_queue(vfe_dev->subdev.sd.devnode, &isp_event);
- return 0;
-}
-
-#define CAL_WORD(width, M, N) ((width * M + N - 1) / N)
-
-int msm_isp_cal_word_per_line(uint32_t output_format,
- uint32_t pixel_per_line)
-{
- int val = -1;
-
- switch (output_format) {
- case V4L2_PIX_FMT_SBGGR8:
- case V4L2_PIX_FMT_SGBRG8:
- case V4L2_PIX_FMT_SGRBG8:
- case V4L2_PIX_FMT_SRGGB8:
- case V4L2_PIX_FMT_QBGGR8:
- case V4L2_PIX_FMT_QGBRG8:
- case V4L2_PIX_FMT_QGRBG8:
- case V4L2_PIX_FMT_QRGGB8:
- case V4L2_PIX_FMT_JPEG:
- case V4L2_PIX_FMT_META:
- val = CAL_WORD(pixel_per_line, 1, 8);
- break;
- case V4L2_PIX_FMT_SBGGR10:
- case V4L2_PIX_FMT_SGBRG10:
- case V4L2_PIX_FMT_SGRBG10:
- case V4L2_PIX_FMT_SRGGB10:
- val = CAL_WORD(pixel_per_line, 5, 32);
- break;
- case V4L2_PIX_FMT_SBGGR12:
- case V4L2_PIX_FMT_SGBRG12:
- case V4L2_PIX_FMT_SGRBG12:
- case V4L2_PIX_FMT_SRGGB12:
- val = CAL_WORD(pixel_per_line, 3, 16);
- break;
- case V4L2_PIX_FMT_SBGGR14:
- case V4L2_PIX_FMT_SGBRG14:
- case V4L2_PIX_FMT_SGRBG14:
- case V4L2_PIX_FMT_SRGGB14:
- val = CAL_WORD(pixel_per_line, 7, 32);
- break;
- case V4L2_PIX_FMT_QBGGR10:
- case V4L2_PIX_FMT_QGBRG10:
- case V4L2_PIX_FMT_QGRBG10:
- case V4L2_PIX_FMT_QRGGB10:
- val = CAL_WORD(pixel_per_line, 1, 6);
- break;
- case V4L2_PIX_FMT_QBGGR12:
- case V4L2_PIX_FMT_QGBRG12:
- case V4L2_PIX_FMT_QGRBG12:
- case V4L2_PIX_FMT_QRGGB12:
- val = CAL_WORD(pixel_per_line, 1, 5);
- break;
- case V4L2_PIX_FMT_QBGGR14:
- case V4L2_PIX_FMT_QGBRG14:
- case V4L2_PIX_FMT_QGRBG14:
- case V4L2_PIX_FMT_QRGGB14:
- val = CAL_WORD(pixel_per_line, 1, 4);
- break;
- case V4L2_PIX_FMT_NV12:
- case V4L2_PIX_FMT_NV21:
- case V4L2_PIX_FMT_NV14:
- case V4L2_PIX_FMT_NV41:
- case V4L2_PIX_FMT_NV16:
- case V4L2_PIX_FMT_NV61:
- val = CAL_WORD(pixel_per_line, 1, 8);
- break;
- case V4L2_PIX_FMT_YUYV:
- case V4L2_PIX_FMT_YVYU:
- case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_VYUY:
- val = CAL_WORD(pixel_per_line, 2, 8);
- break;
- case V4L2_PIX_FMT_P16BGGR10:
- case V4L2_PIX_FMT_P16GBRG10:
- case V4L2_PIX_FMT_P16GRBG10:
- case V4L2_PIX_FMT_P16RGGB10:
- val = CAL_WORD(pixel_per_line, 1, 4);
- break;
- /*TD: Add more image format*/
- default:
- msm_isp_print_fourcc_error(__func__, output_format);
- break;
- }
- return val;
-}
-
-enum msm_isp_pack_fmt msm_isp_get_pack_format(uint32_t output_format)
-{
- switch (output_format) {
- case V4L2_PIX_FMT_SBGGR8:
- case V4L2_PIX_FMT_SGBRG8:
- case V4L2_PIX_FMT_SGRBG8:
- case V4L2_PIX_FMT_SRGGB8:
- case V4L2_PIX_FMT_SBGGR10:
- case V4L2_PIX_FMT_SGBRG10:
- case V4L2_PIX_FMT_SGRBG10:
- case V4L2_PIX_FMT_SRGGB10:
- case V4L2_PIX_FMT_SBGGR12:
- case V4L2_PIX_FMT_SGBRG12:
- case V4L2_PIX_FMT_SGRBG12:
- case V4L2_PIX_FMT_SRGGB12:
- case V4L2_PIX_FMT_SBGGR14:
- case V4L2_PIX_FMT_SGBRG14:
- case V4L2_PIX_FMT_SGRBG14:
- case V4L2_PIX_FMT_SRGGB14:
- return MIPI;
- case V4L2_PIX_FMT_QBGGR8:
- case V4L2_PIX_FMT_QGBRG8:
- case V4L2_PIX_FMT_QGRBG8:
- case V4L2_PIX_FMT_QRGGB8:
- case V4L2_PIX_FMT_QBGGR10:
- case V4L2_PIX_FMT_QGBRG10:
- case V4L2_PIX_FMT_QGRBG10:
- case V4L2_PIX_FMT_QRGGB10:
- case V4L2_PIX_FMT_QBGGR12:
- case V4L2_PIX_FMT_QGBRG12:
- case V4L2_PIX_FMT_QGRBG12:
- case V4L2_PIX_FMT_QRGGB12:
- case V4L2_PIX_FMT_QBGGR14:
- case V4L2_PIX_FMT_QGBRG14:
- case V4L2_PIX_FMT_QGRBG14:
- case V4L2_PIX_FMT_QRGGB14:
- return QCOM;
- case V4L2_PIX_FMT_P16BGGR10:
- case V4L2_PIX_FMT_P16GBRG10:
- case V4L2_PIX_FMT_P16GRBG10:
- case V4L2_PIX_FMT_P16RGGB10:
- return PLAIN16;
- default:
- msm_isp_print_fourcc_error(__func__, output_format);
- break;
- }
- return -EINVAL;
-}
-
-int msm_isp_get_bit_per_pixel(uint32_t output_format)
-{
- switch (output_format) {
- case V4L2_PIX_FMT_Y4:
- return 4;
- case V4L2_PIX_FMT_Y6:
- return 6;
- case V4L2_PIX_FMT_SBGGR8:
- case V4L2_PIX_FMT_SGBRG8:
- case V4L2_PIX_FMT_SGRBG8:
- case V4L2_PIX_FMT_SRGGB8:
- case V4L2_PIX_FMT_QBGGR8:
- case V4L2_PIX_FMT_QGBRG8:
- case V4L2_PIX_FMT_QGRBG8:
- case V4L2_PIX_FMT_QRGGB8:
- case V4L2_PIX_FMT_JPEG:
- case V4L2_PIX_FMT_META:
- case V4L2_PIX_FMT_NV12:
- case V4L2_PIX_FMT_NV21:
- case V4L2_PIX_FMT_NV14:
- case V4L2_PIX_FMT_NV41:
- case V4L2_PIX_FMT_YVU410:
- case V4L2_PIX_FMT_YVU420:
- case V4L2_PIX_FMT_YUYV:
- case V4L2_PIX_FMT_YYUV:
- case V4L2_PIX_FMT_YVYU:
- case V4L2_PIX_FMT_UYVY:
- case V4L2_PIX_FMT_VYUY:
- case V4L2_PIX_FMT_YUV422P:
- case V4L2_PIX_FMT_YUV411P:
- case V4L2_PIX_FMT_Y41P:
- case V4L2_PIX_FMT_YUV444:
- case V4L2_PIX_FMT_YUV555:
- case V4L2_PIX_FMT_YUV565:
- case V4L2_PIX_FMT_YUV32:
- case V4L2_PIX_FMT_YUV410:
- case V4L2_PIX_FMT_YUV420:
- case V4L2_PIX_FMT_GREY:
- case V4L2_PIX_FMT_PAL8:
- case V4L2_PIX_FMT_UV8:
- case MSM_V4L2_PIX_FMT_META:
- return 8;
- case V4L2_PIX_FMT_SBGGR10:
- case V4L2_PIX_FMT_SGBRG10:
- case V4L2_PIX_FMT_SGRBG10:
- case V4L2_PIX_FMT_SRGGB10:
- case V4L2_PIX_FMT_QBGGR10:
- case V4L2_PIX_FMT_QGBRG10:
- case V4L2_PIX_FMT_QGRBG10:
- case V4L2_PIX_FMT_QRGGB10:
- case V4L2_PIX_FMT_Y10:
- case V4L2_PIX_FMT_Y10BPACK:
- case V4L2_PIX_FMT_P16BGGR10:
- case V4L2_PIX_FMT_P16GBRG10:
- case V4L2_PIX_FMT_P16GRBG10:
- case V4L2_PIX_FMT_P16RGGB10:
- return 10;
- case V4L2_PIX_FMT_SBGGR12:
- case V4L2_PIX_FMT_SGBRG12:
- case V4L2_PIX_FMT_SGRBG12:
- case V4L2_PIX_FMT_SRGGB12:
- case V4L2_PIX_FMT_QBGGR12:
- case V4L2_PIX_FMT_QGBRG12:
- case V4L2_PIX_FMT_QGRBG12:
- case V4L2_PIX_FMT_QRGGB12:
- case V4L2_PIX_FMT_Y12:
- return 12;
- case V4L2_PIX_FMT_SBGGR14:
- case V4L2_PIX_FMT_SGBRG14:
- case V4L2_PIX_FMT_SGRBG14:
- case V4L2_PIX_FMT_SRGGB14:
- case V4L2_PIX_FMT_QBGGR14:
- case V4L2_PIX_FMT_QGBRG14:
- case V4L2_PIX_FMT_QGRBG14:
- case V4L2_PIX_FMT_QRGGB14:
- return 14;
- case V4L2_PIX_FMT_NV16:
- case V4L2_PIX_FMT_NV61:
- case V4L2_PIX_FMT_Y16:
- return 16;
- /*TD: Add more image format*/
- default:
- msm_isp_print_fourcc_error(__func__, output_format);
- pr_err("%s: Invalid output format %x\n",
- __func__, output_format);
- return -EINVAL;
- }
-}
-
-void msm_isp_update_error_frame_count(struct vfe_device *vfe_dev)
-{
- struct msm_vfe_error_info *error_info = &vfe_dev->error_info;
-
- error_info->info_dump_frame_count++;
-}
-
-void msm_isp_process_error_info(struct vfe_device *vfe_dev)
-{
- int i;
- uint8_t num_stats_type =
- vfe_dev->hw_info->stats_hw_info->num_stats_type;
- struct msm_vfe_error_info *error_info = &vfe_dev->error_info;
- static DEFINE_RATELIMIT_STATE(rs,
- DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
- static DEFINE_RATELIMIT_STATE(rs_stats,
- DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
-
- if (error_info->error_count == 1 ||
- !(error_info->info_dump_frame_count % 100)) {
- vfe_dev->hw_info->vfe_ops.core_ops.
- process_error_status(vfe_dev);
- error_info->error_mask0 = 0;
- error_info->error_mask1 = 0;
- error_info->camif_status = 0;
- error_info->violation_status = 0;
- for (i = 0; i < MAX_NUM_STREAM; i++) {
- if (error_info->stream_framedrop_count[i] != 0 &&
- __ratelimit(&rs)) {
- pr_err("%s: Stream[%d]: dropped %d frames\n",
- __func__, i,
- error_info->stream_framedrop_count[i]);
- error_info->stream_framedrop_count[i] = 0;
- }
- }
- for (i = 0; i < num_stats_type; i++) {
- if (error_info->stats_framedrop_count[i] != 0 &&
- __ratelimit(&rs_stats)) {
- pr_err("%s: Stats stream[%d]: dropped %d frames\n",
- __func__, i,
- error_info->stats_framedrop_count[i]);
- error_info->stats_framedrop_count[i] = 0;
- }
- }
- }
-}
-
-static inline void msm_isp_update_error_info(struct vfe_device *vfe_dev,
- uint32_t error_mask0, uint32_t error_mask1)
-{
- vfe_dev->error_info.error_mask0 |= error_mask0;
- vfe_dev->error_info.error_mask1 |= error_mask1;
- vfe_dev->error_info.error_count++;
-}
-
-static void msm_isp_process_overflow_irq(
- struct vfe_device *vfe_dev,
- uint32_t *irq_status0, uint32_t *irq_status1)
-{
- uint32_t overflow_mask;
-
- /* if there are no active streams - do not start recovery */
- if (!vfe_dev->axi_data.num_active_stream)
- return;
-
- /*Mask out all other irqs if recovery is started*/
- if (atomic_read(&vfe_dev->error_info.overflow_state) != NO_OVERFLOW) {
- uint32_t halt_restart_mask0, halt_restart_mask1;
-
- vfe_dev->hw_info->vfe_ops.core_ops.
- get_halt_restart_mask(&halt_restart_mask0,
- &halt_restart_mask1);
- *irq_status0 &= halt_restart_mask0;
- *irq_status1 &= halt_restart_mask1;
-
- return;
- }
-
- /*Check if any overflow bit is set*/
- vfe_dev->hw_info->vfe_ops.core_ops.
- get_overflow_mask(&overflow_mask);
- overflow_mask &= *irq_status1;
-
- if (overflow_mask) {
- struct msm_isp32_event_data error_event;
-
- if (vfe_dev->reset_pending == 1) {
- pr_err("%s:%d failed: overflow %x during reset\n",
- __func__, __LINE__, overflow_mask);
- /* Clear overflow bits since reset is pending */
- *irq_status1 &= ~overflow_mask;
- return;
- }
-
- ISP_DBG("%s: Bus overflow detected: 0x%x, start recovery!\n",
- __func__, overflow_mask);
- atomic_set(&vfe_dev->error_info.overflow_state,
- OVERFLOW_DETECTED);
- /*Store current IRQ mask*/
- vfe_dev->hw_info->vfe_ops.core_ops.get_irq_mask(vfe_dev,
- &vfe_dev->error_info.overflow_recover_irq_mask0,
- &vfe_dev->error_info.overflow_recover_irq_mask1);
-
- /*Halt the hardware & Clear all other IRQ mask*/
- vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev, 0);
-
- /*Stop CAMIF Immediately*/
- vfe_dev->hw_info->vfe_ops.core_ops.
- update_camif_state(vfe_dev, DISABLE_CAMIF_IMMEDIATELY);
-
- /*Update overflow state*/
- *irq_status0 = 0;
- *irq_status1 = 0;
-
- memset(&error_event, 0, sizeof(error_event));
- error_event.frame_id =
- vfe_dev->axi_data.src_info[VFE_PIX_0].frame_id;
- error_event.u.error_info.error_mask = 1 << ISP_WM_BUS_OVERFLOW;
- msm_isp_send_event(vfe_dev,
- ISP_EVENT_WM_BUS_OVERFLOW, &error_event);
- }
-}
-
-void msm_isp_reset_burst_count_and_frame_drop(
- struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info)
-{
- uint32_t framedrop_period = 0;
-
- if (stream_info->state != ACTIVE ||
- stream_info->stream_type != BURST_STREAM) {
- return;
- }
- if (stream_info->num_burst_capture != 0) {
- framedrop_period = msm_isp_get_framedrop_period(
- stream_info->frame_skip_pattern);
- stream_info->burst_frame_count =
- stream_info->init_frame_drop +
- (stream_info->num_burst_capture - 1) *
- framedrop_period + 1;
- msm_isp_reset_framedrop(vfe_dev, stream_info);
- }
-}
-
-irqreturn_t msm_isp_process_irq(int irq_num, void *data)
-{
- unsigned long flags;
- struct msm_vfe_tasklet_queue_cmd *queue_cmd;
- struct vfe_device *vfe_dev = (struct vfe_device *) data;
- uint32_t irq_status0, irq_status1;
- uint32_t error_mask0, error_mask1;
-
- vfe_dev->hw_info->vfe_ops.irq_ops.
- read_irq_status(vfe_dev, &irq_status0, &irq_status1);
-
- if ((irq_status0 == 0) && (irq_status1 == 0)) {
- pr_err_ratelimited("%s:VFE%d irq_status0 & 1 are both 0\n",
- __func__, vfe_dev->pdev->id);
- return IRQ_HANDLED;
- }
-
- msm_isp_process_overflow_irq(vfe_dev,
- &irq_status0, &irq_status1);
-
- vfe_dev->hw_info->vfe_ops.core_ops.
- get_error_mask(&error_mask0, &error_mask1);
- error_mask0 &= irq_status0;
- error_mask1 &= irq_status1;
- irq_status0 &= ~error_mask0;
- irq_status1 &= ~error_mask1;
- if (!vfe_dev->ignore_error &&
- ((error_mask0 != 0) || (error_mask1 != 0)))
- msm_isp_update_error_info(vfe_dev, error_mask0, error_mask1);
-
- if ((irq_status0 == 0) && (irq_status1 == 0) &&
- (!(((error_mask0 != 0) || (error_mask1 != 0)) &&
- vfe_dev->error_info.error_count == 1))) {
- ISP_DBG("%s: error_mask0/1 & error_count are set!\n", __func__);
- return IRQ_HANDLED;
- }
-
- spin_lock_irqsave(&vfe_dev->tasklet_lock, flags);
- queue_cmd = &vfe_dev->tasklet_queue_cmd[vfe_dev->taskletq_idx];
- if (queue_cmd->cmd_used) {
- pr_err_ratelimited("%s: Tasklet queue overflow: %d\n",
- __func__, vfe_dev->pdev->id);
- list_del(&queue_cmd->list);
- } else {
- atomic_add(1, &vfe_dev->irq_cnt);
- }
- queue_cmd->vfeInterruptStatus0 = irq_status0;
- queue_cmd->vfeInterruptStatus1 = irq_status1;
- msm_isp_get_timestamp(&queue_cmd->ts);
- queue_cmd->cmd_used = 1;
- vfe_dev->taskletq_idx =
- (vfe_dev->taskletq_idx + 1) % MSM_VFE_TASKLETQ_SIZE;
- list_add_tail(&queue_cmd->list, &vfe_dev->tasklet_q);
- spin_unlock_irqrestore(&vfe_dev->tasklet_lock, flags);
- tasklet_schedule(&vfe_dev->vfe_tasklet);
- return IRQ_HANDLED;
-}
-
-void msm_isp_do_tasklet(unsigned long data)
-{
- unsigned long flags;
- struct vfe_device *vfe_dev = (struct vfe_device *) data;
- struct msm_vfe_irq_ops *irq_ops = &vfe_dev->hw_info->vfe_ops.irq_ops;
- struct msm_vfe_tasklet_queue_cmd *queue_cmd;
- struct msm_isp_timestamp ts;
- uint32_t irq_status0, irq_status1;
-
- while (atomic_read(&vfe_dev->irq_cnt)) {
- spin_lock_irqsave(&vfe_dev->tasklet_lock, flags);
- queue_cmd = list_first_entry(&vfe_dev->tasklet_q,
- struct msm_vfe_tasklet_queue_cmd, list);
-
- if (!queue_cmd) {
- atomic_set(&vfe_dev->irq_cnt, 0);
- spin_unlock_irqrestore(&vfe_dev->tasklet_lock, flags);
- return;
- }
- atomic_sub(1, &vfe_dev->irq_cnt);
- list_del(&queue_cmd->list);
- queue_cmd->cmd_used = 0;
- irq_status0 = queue_cmd->vfeInterruptStatus0;
- irq_status1 = queue_cmd->vfeInterruptStatus1;
- ts = queue_cmd->ts;
- spin_unlock_irqrestore(&vfe_dev->tasklet_lock, flags);
- ISP_DBG("%s: status0: 0x%x status1: 0x%x\n",
- __func__, irq_status0, irq_status1);
- irq_ops->process_reset_irq(vfe_dev,
- irq_status0, irq_status1);
- irq_ops->process_halt_irq(vfe_dev,
- irq_status0, irq_status1);
- if (atomic_read(&vfe_dev->error_info.overflow_state)
- != NO_OVERFLOW) {
- pr_err("%s: Recovery in processing, Ignore IRQs!!!\n",
- __func__);
- continue;
- }
- msm_isp_process_error_info(vfe_dev);
- irq_ops->process_camif_irq(vfe_dev,
- irq_status0, irq_status1, &ts);
- irq_ops->process_axi_irq(vfe_dev,
- irq_status0, irq_status1, &ts);
- irq_ops->process_stats_irq(vfe_dev,
- irq_status0, irq_status1, &ts);
- irq_ops->process_reg_update(vfe_dev,
- irq_status0, irq_status1, &ts);
- irq_ops->process_epoch_irq(vfe_dev,
- irq_status0, irq_status1, &ts);
- }
-}
-
-int msm_isp_set_src_state(struct vfe_device *vfe_dev, void *arg)
-{
- struct msm_vfe_axi_src_state *src_state = arg;
-
- if (src_state->input_src >= VFE_SRC_MAX)
- return -EINVAL;
- vfe_dev->axi_data.src_info[src_state->input_src].active =
- src_state->src_active;
- vfe_dev->axi_data.src_info[src_state->input_src].frame_id =
- src_state->src_frame_id;
- return 0;
-}
-
-static int msm_vfe_iommu_fault_handler(struct iommu_domain *domain,
- struct device *dev, unsigned long iova, int flags, void *token)
-{
- struct vfe_device *vfe_dev = NULL;
-
- if (token) {
- vfe_dev = (struct vfe_device *)token;
- if (!vfe_dev->buf_mgr || !vfe_dev->buf_mgr->ops) {
- pr_err("%s:%d] buf_mgr %pK\n", __func__,
- __LINE__, vfe_dev->buf_mgr);
- goto end;
- }
- if (!vfe_dev->buf_mgr->pagefault_debug) {
- pr_err("%s:%d] vfe_dev %pK id %d\n", __func__,
- __LINE__, vfe_dev, vfe_dev->pdev->id);
- vfe_dev->buf_mgr->ops->buf_mgr_debug(vfe_dev->buf_mgr);
- }
- } else {
- ISP_DBG("%s:%d] no token received: %pK\n",
- __func__, __LINE__, token);
- goto end;
- }
-end:
- return -ENOSYS;
-}
-
-int msm_isp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
- struct vfe_device *vfe_dev = v4l2_get_subdevdata(sd);
- long rc = 0;
-
- ISP_DBG("%s\n", __func__);
-
- mutex_lock(&vfe_dev->realtime_mutex);
- mutex_lock(&vfe_dev->core_mutex);
-
- if (vfe_dev->vfe_open_cnt++ && vfe_dev->vfe_base) {
- mutex_unlock(&vfe_dev->core_mutex);
- mutex_unlock(&vfe_dev->realtime_mutex);
- return 0;
- }
-
- if (vfe_dev->vfe_base) {
- pr_err("%s:%d invalid params cnt %d base %pK\n", __func__,
- __LINE__, vfe_dev->vfe_open_cnt, vfe_dev->vfe_base);
- vfe_dev->vfe_base = NULL;
- }
-
- vfe_dev->reset_pending = 0;
- vfe_dev->isp_sof_debug = 0;
-
- 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--;
- mutex_unlock(&vfe_dev->core_mutex);
- mutex_unlock(&vfe_dev->realtime_mutex);
- return -EBUSY;
- }
-
- memset(&vfe_dev->error_info, 0, sizeof(vfe_dev->error_info));
- atomic_set(&vfe_dev->error_info.overflow_state, NO_OVERFLOW);
-
- vfe_dev->hw_info->vfe_ops.core_ops.clear_status_reg(vfe_dev);
-
- rc = vfe_dev->hw_info->vfe_ops.core_ops.reset_hw(vfe_dev, 1, 1);
- if (rc <= 0) {
- pr_err("%s: reset timeout\n", __func__);
- vfe_dev->hw_info->vfe_ops.core_ops.release_hw(vfe_dev);
- vfe_dev->vfe_open_cnt--;
- mutex_unlock(&vfe_dev->core_mutex);
- mutex_unlock(&vfe_dev->realtime_mutex);
- return -EINVAL;
- }
- 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);
-
- vfe_dev->hw_info->vfe_ops.core_ops.init_hw_reg(vfe_dev);
-
- vfe_dev->buf_mgr->ops->buf_mgr_init(vfe_dev->buf_mgr,
- "msm_isp", BUF_MGR_NUM_BUF_Q);
-
- memset(&vfe_dev->axi_data, 0, sizeof(struct msm_vfe_axi_shared_data));
- memset(&vfe_dev->stats_data, 0,
- sizeof(struct msm_vfe_stats_shared_data));
- memset(&vfe_dev->error_info, 0, sizeof(vfe_dev->error_info));
- memset(&vfe_dev->fetch_engine_info, 0,
- sizeof(vfe_dev->fetch_engine_info));
- vfe_dev->axi_data.hw_info = vfe_dev->hw_info->axi_hw_info;
- vfe_dev->taskletq_idx = 0;
- vfe_dev->vt_enable = 0;
- vfe_dev->bus_util_factor = 0;
- rc = of_property_read_u32(vfe_dev->pdev->dev.of_node,
- "bus-util-factor", &vfe_dev->bus_util_factor);
- if (rc < 0)
- ISP_DBG("%s: Use default bus utilization factor\n", __func__);
- iommu_set_fault_handler(vfe_dev->buf_mgr->iommu_domain,
- msm_vfe_iommu_fault_handler, vfe_dev);
- mutex_unlock(&vfe_dev->core_mutex);
- mutex_unlock(&vfe_dev->realtime_mutex);
- return 0;
-}
-
-#ifdef CONFIG_MSM_AVTIMER
-void msm_isp_end_avtimer(void)
-{
- avcs_core_disable_power_collapse(0);
-}
-#else
-void msm_isp_end_avtimer(void)
-{
- pr_err("AV Timer is not supported\n");
-}
-#endif
-
-int msm_isp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
- long rc = 0;
- struct vfe_device *vfe_dev = v4l2_get_subdevdata(sd);
-
- ISP_DBG("%s E\n", __func__);
- mutex_lock(&vfe_dev->realtime_mutex);
- mutex_lock(&vfe_dev->core_mutex);
-
- if (!vfe_dev->vfe_open_cnt) {
- pr_err("%s invalid state open cnt %d\n", __func__,
- vfe_dev->vfe_open_cnt);
- mutex_unlock(&vfe_dev->core_mutex);
- mutex_unlock(&vfe_dev->realtime_mutex);
- return -EINVAL;
- }
-
- if (--vfe_dev->vfe_open_cnt) {
- mutex_unlock(&vfe_dev->core_mutex);
- mutex_unlock(&vfe_dev->realtime_mutex);
- return 0;
- }
-
- rc = vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev, 1);
- if (rc < 0)
- pr_err("%s: halt timeout rc=%ld\n", __func__, rc);
-
- vfe_dev->buf_mgr->ops->buf_mgr_deinit(vfe_dev->buf_mgr);
- vfe_dev->hw_info->vfe_ops.core_ops.release_hw(vfe_dev);
- if (vfe_dev->vt_enable) {
- msm_isp_end_avtimer();
- vfe_dev->vt_enable = 0;
- }
- mutex_unlock(&vfe_dev->core_mutex);
- mutex_unlock(&vfe_dev->realtime_mutex);
- return 0;
-}
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util_32.h b/drivers/media/platform/msm/camera_v2/isp/msm_isp_util_32.h
deleted file mode 100644
index 781198517bd6..000000000000
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util_32.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-#ifndef __MSM_ISP_UTIL_H__
-#define __MSM_ISP_UTIL_H__
-
-#include "msm_isp_32.h"
-#include <soc/qcom/camera2.h>
-
-/* #define CONFIG_MSM_ISP_DBG 1 */
-
-#ifdef CONFIG_MSM_ISP_DBG
-#define ISP_DBG(fmt, args...) printk(fmt, ##args)
-#else
-#define ISP_DBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
-
-#define ALT_VECTOR_IDX(x) {x = 3 - x; }
-
-struct msm_isp_bandwidth_mgr {
- uint32_t bus_client;
- uint32_t bus_vector_active_idx;
- uint32_t use_count;
- struct msm_isp_bandwidth_info client_info[MAX_ISP_CLIENT];
-};
-
-uint32_t msm_isp_get_framedrop_period(
- enum msm_vfe_frame_skip_pattern frame_skip_pattern);
-void msm_isp_reset_burst_count_and_frame_drop(
- struct vfe_device *vfe_dev, struct msm_vfe_axi_stream *stream_info);
-
-int msm_isp_init_bandwidth_mgr(enum msm_isp_hw_client client);
-int msm_isp_update_bandwidth(enum msm_isp_hw_client client,
- uint64_t ab, uint64_t ib);
-void msm_isp_util_get_bandwidth_stats(struct vfe_device *vfe_dev,
- struct msm_isp_statistics *stats);
-void msm_isp_util_update_last_overflow_ab_ib(struct vfe_device *vfe_dev);
-void msm_isp_util_update_clk_rate(long clock_rate);
-void msm_isp_update_req_history(uint32_t client, uint64_t ab,
- uint64_t ib,
- struct msm_isp_bandwidth_info *client_info,
- unsigned long long ts);
-void msm_isp_deinit_bandwidth_mgr(enum msm_isp_hw_client client);
-
-int msm_isp_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub);
-
-int msm_isp_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub);
-
-int msm_isp_proc_cmd(struct vfe_device *vfe_dev, void *arg);
-int msm_isp_send_event(struct vfe_device *vfe_dev,
- uint32_t type, struct msm_isp32_event_data *event_data);
-int msm_isp_cal_word_per_line(uint32_t output_format,
- uint32_t pixel_per_line);
-int msm_isp_get_bit_per_pixel(uint32_t output_format);
-enum msm_isp_pack_fmt msm_isp_get_pack_format(uint32_t output_format);
-irqreturn_t msm_isp_process_irq(int irq_num, void *data);
-int msm_isp_set_src_state(struct vfe_device *vfe_dev, void *arg);
-void msm_isp_do_tasklet(unsigned long data);
-void msm_isp_update_error_frame_count(struct vfe_device *vfe_dev);
-void msm_isp_process_error_info(struct vfe_device *vfe_dev);
-int msm_isp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
-int msm_isp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
-long msm_isp_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
-int msm_isp_get_clk_info(struct vfe_device *vfe_dev,
- struct platform_device *pdev, struct msm_cam_clk_info *vfe_clk_info);
-void msm_isp_fetch_engine_done_notify(struct vfe_device *vfe_dev,
- struct msm_vfe_fetch_engine_info *fetch_engine_info);
-void msm_camera_io_dump_2(void __iomem *addr, int size);
-void msm_isp_print_fourcc_error(const char *origin, uint32_t fourcc_format);
-
-#endif /* __MSM_ISP_UTIL_H__ */
diff --git a/drivers/media/platform/msm/camera_v2/ispif/Makefile b/drivers/media/platform/msm/camera_v2/ispif/Makefile
index 7a98fd0334a0..236ec7340c56 100644
--- a/drivers/media/platform/msm/camera_v2/ispif/Makefile
+++ b/drivers/media/platform/msm/camera_v2/ispif/Makefile
@@ -1,8 +1,4 @@
ccflags-y += -Idrivers/media/platform/msm/camera_v2
+ccflags-y += -Idrivers/media/platform/msm/camera_v2/common
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor/io
-ccflags-y += -Idrivers/media/platform/msm/camera_v2/common/
-ifeq ($(CONFIG_MSM_ISP_V1),y)
-obj-$(CONFIG_MSM_CSID) += msm_ispif_32.o
-else
obj-$(CONFIG_MSM_CSID) += msm_ispif.o
-endif \ No newline at end of file
diff --git a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c
index 983a465d19a1..158dca470ae1 100644
--- a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c
+++ b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -47,37 +47,19 @@
#define ISPIF_TIMEOUT_SLEEP_US 1000
#define ISPIF_TIMEOUT_ALL_US 1000000
-#define ISPIF_SOF_DEBUG_COUNT 0
-
-/* 3D Threshold value according guidelines for line width 1280 */
-#define STEREO_DEFAULT_3D_THRESHOLD 0x36
-
-/*
- * Overflows before restarting interface during stereo usecase
- * to give some tolerance for cases when the two sensors sync fails
- * this value is chosen by experiment
- */
-#define MAX_PIX_OVERFLOW_ERROR_COUNT 10
-static int pix_overflow_error_count[VFE_MAX] = { 0 };
+#define ISPIF_SOF_DEBUG_COUNT 0
#undef CDBG
#ifdef CONFIG_MSMB_CAMERA_DEBUG
#define CDBG(fmt, args...) pr_debug(fmt, ##args)
#else
-#define CDBG(fmt, args...)
+#define CDBG(fmt, args...) do { } while (0)
#endif
-/* Backward interface compatibility for 3D THRESHOLD calculation */
-#define ISPIF_USE_DEFAULT_THRESHOLD (0)
-#define ISPIF_CALCULATE_THRESHOLD (1)
-
static int msm_ispif_clk_ahb_enable(struct ispif_device *ispif, int enable);
static int ispif_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
static long msm_ispif_subdev_ioctl_unlocked(struct v4l2_subdev *sd,
unsigned int cmd, void *arg);
-static long msm_ispif_dispatch_cmd(enum ispif_cfg_type_t cmd,
- struct ispif_device *ispif,
- struct msm_ispif_param_data_ext *params);
int msm_ispif_get_clk_info(struct ispif_device *ispif_dev,
struct platform_device *pdev);
@@ -86,12 +68,6 @@ static void msm_ispif_io_dump_reg(struct ispif_device *ispif)
{
if (!ispif->enb_dump_reg)
return;
-
- if (!ispif->base) {
- pr_err("%s: null pointer for the ispif base\n", __func__);
- return;
- }
-
msm_camera_io_dump(ispif->base, 0x250, 0);
}
@@ -272,7 +248,16 @@ static long msm_ispif_cmd_ext(struct v4l2_subdev *sd,
}
mutex_lock(&ispif->mutex);
- rc = msm_ispif_dispatch_cmd(pcdata.cfg_type, ispif, params);
+ switch (pcdata.cfg_type) {
+ case ISPIF_CFG2:
+ rc = msm_ispif_config2(ispif, params);
+ msm_ispif_io_dump_reg(ispif);
+ break;
+ default:
+ pr_err("%s: invalid cfg_type\n", __func__);
+ rc = -EINVAL;
+ break;
+ }
mutex_unlock(&ispif->mutex);
kfree(params);
return rc;
@@ -459,7 +444,7 @@ static int msm_ispif_reset_hw(struct ispif_device *ispif)
/* This is set when device is 8974 */
ispif->clk_idx = 1;
}
- memset(ispif->stereo_configured, 0, sizeof(ispif->stereo_configured));
+
atomic_set(&ispif->reset_trig[VFE0], 1);
/* initiate reset of ISPIF */
msm_camera_io_w(ISPIF_RST_CMD_MASK,
@@ -624,7 +609,7 @@ static int msm_ispif_reset(struct ispif_device *ispif)
ispif->base + ISPIF_VFE_m_INTF_CMD_0(i));
msm_camera_io_w(ISPIF_STOP_INTF_IMMEDIATELY,
ispif->base + ISPIF_VFE_m_INTF_CMD_1(i));
- pr_debug("%s: base %pK", __func__, ispif->base);
+ pr_debug("%s: base %lx", __func__, (unsigned long)ispif->base);
msm_camera_io_w(0, ispif->base +
ISPIF_VFE_m_PIX_INTF_n_CID_MASK(i, 0));
msm_camera_io_w(0, ispif->base +
@@ -649,7 +634,7 @@ static int msm_ispif_reset(struct ispif_device *ispif)
}
static void msm_ispif_sel_csid_core(struct ispif_device *ispif,
- uint8_t intftype, uint8_t csid, enum msm_ispif_vfe_intf vfe_intf)
+ uint8_t intftype, uint8_t csid, uint8_t vfe_intf)
{
uint32_t data;
@@ -689,8 +674,8 @@ static void msm_ispif_sel_csid_core(struct ispif_device *ispif,
}
static void msm_ispif_enable_crop(struct ispif_device *ispif,
- uint8_t intftype, enum msm_ispif_vfe_intf vfe_intf,
- uint16_t start_pixel, uint16_t end_pixel)
+ uint8_t intftype, uint8_t vfe_intf, uint16_t start_pixel,
+ uint16_t end_pixel)
{
uint32_t data;
BUG_ON(!ispif);
@@ -721,8 +706,7 @@ static void msm_ispif_enable_crop(struct ispif_device *ispif,
}
static void msm_ispif_enable_intf_cids(struct ispif_device *ispif,
- uint8_t intftype, uint16_t cid_mask, enum msm_ispif_vfe_intf vfe_intf,
- uint8_t enable)
+ uint8_t intftype, uint16_t cid_mask, uint8_t vfe_intf, uint8_t enable)
{
uint32_t intf_addr, data;
@@ -764,7 +748,7 @@ static void msm_ispif_enable_intf_cids(struct ispif_device *ispif,
}
static int msm_ispif_validate_intf_status(struct ispif_device *ispif,
- uint8_t intftype, enum msm_ispif_vfe_intf vfe_intf)
+ uint8_t intftype, uint8_t vfe_intf)
{
int rc = 0;
uint32_t data = 0;
@@ -804,7 +788,7 @@ static int msm_ispif_validate_intf_status(struct ispif_device *ispif,
}
static void msm_ispif_select_clk_mux(struct ispif_device *ispif,
- uint8_t intftype, uint8_t csid, enum msm_ispif_vfe_intf vfe_intf)
+ uint8_t intftype, uint8_t csid, uint8_t vfe_intf)
{
uint32_t data = 0;
@@ -868,33 +852,15 @@ static uint16_t msm_ispif_get_cids_mask_from_cfg(
return cids_mask;
}
-
-static uint16_t msm_ispif_get_right_cids_mask_from_cfg(
- struct msm_ispif_right_param_entry *entry, int num_cids)
-{
- int i;
- uint16_t cids_mask = 0;
-
- BUG_ON(!entry);
-
- for (i = 0; i < num_cids && i < MAX_CID_CH_v2; i++) {
- if (entry->cids[i] < CID_MAX)
- cids_mask |= (1 << entry->cids[i]);
- }
-
- return cids_mask;
-}
-
static int msm_ispif_config(struct ispif_device *ispif,
void *data)
{
int rc = 0, i = 0;
- uint16_t cid_mask = 0;
- uint16_t cid_right_mask = 0;
+ uint16_t cid_mask;
enum msm_ispif_intftype intftype;
enum msm_ispif_vfe_intf vfe_intf;
- struct msm_ispif_param_data_ext *params =
- (struct msm_ispif_param_data_ext *)data;
+ struct msm_ispif_param_data *params =
+ (struct msm_ispif_param_data *)data;
BUG_ON(!ispif);
BUG_ON(!params);
@@ -944,15 +910,9 @@ static int msm_ispif_config(struct ispif_device *ispif,
return -EINVAL;
}
- if (ispif->csid_version >= CSID_VERSION_V30) {
+ if (ispif->csid_version >= CSID_VERSION_V30)
msm_ispif_select_clk_mux(ispif, intftype,
params->entries[i].csid, vfe_intf);
- if (intftype == PIX0 && params->stereo_enable &&
- params->right_entries[i].csid < CSID_MAX)
- msm_ispif_select_clk_mux(ispif, PIX1,
- params->right_entries[i].csid,
- vfe_intf);
- }
rc = msm_ispif_validate_intf_status(ispif, intftype, vfe_intf);
if (rc) {
@@ -963,26 +923,10 @@ static int msm_ispif_config(struct ispif_device *ispif,
msm_ispif_sel_csid_core(ispif, intftype,
params->entries[i].csid, vfe_intf);
- if (intftype == PIX0 && params->stereo_enable &&
- params->right_entries[i].csid < CSID_MAX)
- /* configure right stereo csid */
- msm_ispif_sel_csid_core(ispif, PIX1,
- params->right_entries[i].csid, vfe_intf);
-
cid_mask = msm_ispif_get_cids_mask_from_cfg(
&params->entries[i]);
msm_ispif_enable_intf_cids(ispif, intftype,
cid_mask, vfe_intf, 1);
- if (params->stereo_enable)
- cid_right_mask = msm_ispif_get_right_cids_mask_from_cfg(
- &params->right_entries[i],
- params->entries[i].num_cids);
- else
- cid_right_mask = 0;
- if (cid_right_mask && params->stereo_enable)
- /* configure right stereo cids */
- msm_ispif_enable_intf_cids(ispif, PIX1,
- cid_right_mask, vfe_intf, 1);
if (params->entries[i].crop_enable)
msm_ispif_enable_crop(ispif, intftype, vfe_intf,
params->entries[i].crop_start_pixel,
@@ -1015,44 +959,8 @@ static int msm_ispif_config(struct ispif_device *ispif,
return rc;
}
-static void msm_ispif_config_stereo(struct ispif_device *ispif,
- struct msm_ispif_param_data_ext *params, int use_line_width) {
-
- int i;
- enum msm_ispif_vfe_intf vfe_intf;
- uint32_t stereo_3d_threshold = STEREO_DEFAULT_3D_THRESHOLD;
-
- if (params->num > MAX_PARAM_ENTRIES)
- return;
-
- for (i = 0; i < params->num; i++) {
- vfe_intf = params->entries[i].vfe_intf;
- if (!msm_ispif_is_intf_valid(ispif->csid_version, vfe_intf)) {
- pr_err("%s: invalid interface type %d\n", __func__,
- vfe_intf);
- return;
- }
- if (params->entries[i].intftype == PIX0 &&
- params->stereo_enable &&
- params->right_entries[i].csid < CSID_MAX &&
- !ispif->stereo_configured[vfe_intf]) {
- msm_camera_io_w_mb(0x3,
- ispif->base + ISPIF_VFE_m_OUTPUT_SEL(vfe_intf));
- if (use_line_width &&
- (params->line_width[vfe_intf] > 0))
- stereo_3d_threshold =
- (params->line_width[vfe_intf] +
- 2 * 6 - 1) / (2 * 6);
- msm_camera_io_w_mb(stereo_3d_threshold,
- ispif->base +
- ISPIF_VFE_m_3D_THRESHOLD(vfe_intf));
- ispif->stereo_configured[vfe_intf] = 1;
- }
- }
-}
-
static void msm_ispif_intf_cmd(struct ispif_device *ispif, uint32_t cmd_bits,
- struct msm_ispif_param_data_ext *params)
+ struct msm_ispif_param_data *params)
{
uint8_t vc;
int i, k;
@@ -1097,19 +1005,6 @@ static void msm_ispif_intf_cmd(struct ispif_device *ispif, uint32_t cmd_bits,
ispif->applied_intf_cmd[vfe_intf].intf_cmd |=
(cmd_bits << (vc * 2 + intf_type * 8));
}
- if (intf_type == PIX0 && params->stereo_enable &&
- params->right_entries[i].cids[k] < CID_MAX) {
- cid = params->right_entries[i].cids[k];
- vc = cid / 4;
-
- /* fill right stereo command */
- /* zero 2 bits */
- ispif->applied_intf_cmd[vfe_intf].intf_cmd &=
- ~(0x3 << (vc * 2 + PIX1 * 8));
- /* set cmd bits */
- ispif->applied_intf_cmd[vfe_intf].intf_cmd |=
- (cmd_bits << (vc * 2 + PIX1 * 8));
- }
}
/* cmd for PIX0, PIX1, RDI0, RDI1 */
if (ispif->applied_intf_cmd[vfe_intf].intf_cmd != 0xFFFFFFFF)
@@ -1126,7 +1021,7 @@ static void msm_ispif_intf_cmd(struct ispif_device *ispif, uint32_t cmd_bits,
}
static int msm_ispif_stop_immediately(struct ispif_device *ispif,
- struct msm_ispif_param_data_ext *params)
+ struct msm_ispif_param_data *params)
{
int i, rc = 0;
uint16_t cid_mask = 0;
@@ -1154,24 +1049,13 @@ static int msm_ispif_stop_immediately(struct ispif_device *ispif,
&params->entries[i]);
msm_ispif_enable_intf_cids(ispif, params->entries[i].intftype,
cid_mask, params->entries[i].vfe_intf, 0);
- if (params->stereo_enable) {
- ispif->stereo_configured[
- params->entries[i].vfe_intf] = 0;
- cid_mask = msm_ispif_get_right_cids_mask_from_cfg(
- &params->right_entries[i],
- params->entries[i].num_cids);
- if (cid_mask)
- msm_ispif_enable_intf_cids(ispif,
- params->entries[i].intftype, cid_mask,
- params->entries[i].vfe_intf, 0);
- }
}
return rc;
}
static int msm_ispif_start_frame_boundary(struct ispif_device *ispif,
- struct msm_ispif_param_data_ext *params)
+ struct msm_ispif_param_data *params)
{
int rc = 0;
@@ -1187,161 +1071,37 @@ static int msm_ispif_start_frame_boundary(struct ispif_device *ispif,
rc = -EINVAL;
return rc;
}
-
- msm_ispif_config_stereo(ispif, params, ISPIF_USE_DEFAULT_THRESHOLD);
msm_ispif_intf_cmd(ispif, ISPIF_INTF_CMD_ENABLE_FRAME_BOUNDARY, params);
return rc;
}
static int msm_ispif_restart_frame_boundary(struct ispif_device *ispif,
- struct msm_ispif_param_data_ext *params)
+ struct msm_ispif_param_data *params)
{
- int rc = 0, i;
- long timeout = 0;
- uint16_t cid_mask;
- enum msm_ispif_intftype intftype;
- enum msm_ispif_vfe_intf vfe_intf;
- uint32_t vfe_mask = 0;
- uint32_t intf_addr;
-
- if (ispif->ispif_state != ISPIF_POWER_UP) {
- pr_err("%s: ispif invalid state %d\n", __func__,
- ispif->ispif_state);
- rc = -EPERM;
- return rc;
- }
- if (params->num > MAX_PARAM_ENTRIES) {
- pr_err("%s: invalid param entries %d\n", __func__,
- params->num);
- rc = -EINVAL;
- return rc;
- }
-
- for (i = 0; i < params->num; i++) {
- vfe_intf = params->entries[i].vfe_intf;
- if (vfe_intf >= VFE_MAX) {
- pr_err("%s: %d invalid i %d vfe_intf %d\n", __func__,
- __LINE__, i, vfe_intf);
- return -EINVAL;
- }
- vfe_mask |= (1 << vfe_intf);
- }
-
- /* Turn ON regulators before enabling the clocks*/
- rc = msm_ispif_set_regulators(ispif->vfe_vdd,
- ispif->vfe_vdd_count, 1);
- if (rc < 0)
- return -EFAULT;
-
- rc = msm_camera_clk_enable(&ispif->pdev->dev,
- ispif->clk_info, ispif->clks,
- ispif->num_clk, 1);
- if (rc < 0)
- goto disable_regulator;
-
- if (vfe_mask & (1 << VFE0)) {
- atomic_set(&ispif->reset_trig[VFE0], 1);
- /* initiate reset of ISPIF */
- msm_camera_io_w(ISPIF_RST_CMD_MASK_RESTART,
- ispif->base + ISPIF_RST_CMD_ADDR);
- timeout = wait_for_completion_timeout(
- &ispif->reset_complete[VFE0], msecs_to_jiffies(500));
- if (timeout <= 0) {
- pr_err("%s: VFE0 reset wait timeout\n", __func__);
- rc = -ETIMEDOUT;
- goto disable_clk;
- }
- }
-
- if (ispif->hw_num_isps > 1 && (vfe_mask & (1 << VFE1))) {
- atomic_set(&ispif->reset_trig[VFE1], 1);
- msm_camera_io_w(ISPIF_RST_CMD_1_MASK_RESTART,
- ispif->base + ISPIF_RST_CMD_1_ADDR);
- timeout = wait_for_completion_timeout(
- &ispif->reset_complete[VFE1],
- msecs_to_jiffies(500));
- if (timeout <= 0) {
- pr_err("%s: VFE1 reset wait timeout\n", __func__);
- rc = -ETIMEDOUT;
- goto disable_clk;
- }
- }
-
- pr_info("%s: ISPIF reset hw done, Restarting", __func__);
- rc = msm_camera_clk_enable(&ispif->pdev->dev,
- ispif->clk_info, ispif->clks,
- ispif->num_clk, 0);
- if (rc < 0)
- goto disable_regulator;
-
- /* Turn OFF regulators after disabling clocks */
- rc = msm_ispif_set_regulators(ispif->vfe_vdd, ispif->vfe_vdd_count, 0);
- if (rc < 0)
- goto end;
-
- for (i = 0; i < params->num; i++) {
- intftype = params->entries[i].intftype;
- vfe_intf = params->entries[i].vfe_intf;
-
- switch (params->entries[0].intftype) {
- case PIX0:
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 0);
- break;
- case RDI0:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 0);
- break;
- case PIX1:
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 1);
- break;
- case RDI1:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 1);
- break;
- case RDI2:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 2);
- break;
- default:
- pr_err("%s: invalid intftype=%d\n", __func__,
- params->entries[i].intftype);
- rc = -EPERM;
- goto end;
- }
-
- msm_ispif_intf_cmd(ispif,
- ISPIF_INTF_CMD_ENABLE_FRAME_BOUNDARY, params);
- }
-
- for (i = 0; i < params->num; i++) {
- intftype = params->entries[i].intftype;
-
- vfe_intf = params->entries[i].vfe_intf;
+ int rc = 0;
+ rc = msm_ispif_reset_hw(ispif);
+ if (!rc)
+ rc = msm_ispif_reset(ispif);
+ if (!rc)
+ rc = msm_ispif_config(ispif, params);
+ if (!rc)
+ rc = msm_ispif_start_frame_boundary(ispif, params);
- cid_mask = msm_ispif_get_cids_mask_from_cfg(
- &params->entries[i]);
+ if (!rc)
+ pr_info("ISPIF restart Successful\n");
+ else
+ pr_info("ISPIF restart Failed\n");
- msm_ispif_enable_intf_cids(ispif, intftype,
- cid_mask, vfe_intf, 1);
- }
- return rc;
-
-disable_clk:
- msm_camera_clk_enable(&ispif->pdev->dev,
- ispif->clk_info, ispif->clks,
- ispif->num_clk, 0);
-disable_regulator:
- /* Turn OFF regulators */
- msm_ispif_set_regulators(ispif->vfe_vdd, ispif->vfe_vdd_count, 0);
-end:
return rc;
}
static int msm_ispif_stop_frame_boundary(struct ispif_device *ispif,
- struct msm_ispif_param_data_ext *params)
+ struct msm_ispif_param_data *params)
{
int i, rc = 0;
uint16_t cid_mask = 0;
- uint16_t cid_right_mask = 0;
uint32_t intf_addr;
enum msm_ispif_vfe_intf vfe_intf;
uint32_t stop_flag = 0;
@@ -1379,13 +1139,6 @@ static int msm_ispif_stop_frame_boundary(struct ispif_device *ispif,
for (i = 0; i < params->num; i++) {
cid_mask =
msm_ispif_get_cids_mask_from_cfg(&params->entries[i]);
- if (params->stereo_enable)
- cid_right_mask =
- msm_ispif_get_right_cids_mask_from_cfg(
- &params->right_entries[i],
- params->entries[i].num_cids);
- else
- cid_right_mask = 0;
vfe_intf = params->entries[i].vfe_intf;
switch (params->entries[i].intftype) {
@@ -1417,26 +1170,10 @@ static int msm_ispif_stop_frame_boundary(struct ispif_device *ispif,
ISPIF_TIMEOUT_ALL_US);
if (rc < 0)
pr_err("ISPIF stop frame boundary timeout\n");
- if (cid_right_mask) {
- ispif->stereo_configured[
- params->entries[i].vfe_intf] = 0;
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 1);
- rc = readl_poll_timeout(ispif->base + intf_addr,
- stop_flag,
- (stop_flag & 0xF) == 0xF,
- ISPIF_TIMEOUT_SLEEP_US,
- ISPIF_TIMEOUT_ALL_US);
- if (rc < 0)
- pr_err("ISPIF stop frame boundary timeout\n");
- }
/* disable CIDs in CID_MASK register */
msm_ispif_enable_intf_cids(ispif, params->entries[i].intftype,
cid_mask, vfe_intf, 0);
- if (cid_right_mask)
- msm_ispif_enable_intf_cids(ispif,
- params->entries[i].intftype, cid_right_mask,
- params->entries[i].vfe_intf, 0);
}
end:
@@ -1457,14 +1194,6 @@ static void ispif_process_irq(struct ispif_device *ispif,
ispif->sof_count[vfe_id].sof_cnt[PIX0]++;
ispif->ispif_sof_debug++;
}
- if (out[vfe_id].ispifIrqStatus1 &
- ISPIF_IRQ_STATUS_PIX_SOF_MASK) {
- if (ispif->ispif_sof_debug < ISPIF_SOF_DEBUG_COUNT*2)
- pr_err("%s: PIX1 frame id: %u\n", __func__,
- ispif->sof_count[vfe_id].sof_cnt[PIX1]);
- ispif->sof_count[vfe_id].sof_cnt[PIX1]++;
- ispif->ispif_sof_debug++;
- }
if (out[vfe_id].ispifIrqStatus0 &
ISPIF_IRQ_STATUS_RDI0_SOF_MASK) {
if (ispif->ispif_rdi0_debug < ISPIF_SOF_DEBUG_COUNT)
@@ -1491,54 +1220,12 @@ static void ispif_process_irq(struct ispif_device *ispif,
}
}
-static int msm_ispif_reconfig_3d_output(struct ispif_device *ispif,
- enum msm_ispif_vfe_intf vfe_id)
-{
- uint32_t reg_data;
-
- BUG_ON(!ispif);
-
- if (!((vfe_id == VFE0) || (vfe_id == VFE1))) {
- pr_err("%s;%d Cannot reconfigure 3D mode for VFE%d", __func__,
- __LINE__ , vfe_id);
- return -EINVAL;
- }
- pr_info("%s;%d Reconfiguring 3D mode for VFE%d", __func__, __LINE__,
- vfe_id);
- reg_data = 0xFFFCFFFC;
- msm_camera_io_w_mb(reg_data, ispif->base +
- ISPIF_VFE_m_INTF_CMD_0(vfe_id));
- msm_camera_io_w_mb(reg_data, ispif->base +
- ISPIF_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-
- if (vfe_id == VFE0) {
- reg_data = 0;
- reg_data |= (PIX_0_VFE_RST_STB | PIX_1_VFE_RST_STB |
- STROBED_RST_EN | PIX_0_CSID_RST_STB |
- PIX_1_CSID_RST_STB | PIX_OUTPUT_0_MISR_RST_STB);
- msm_camera_io_w_mb(reg_data, ispif->base + ISPIF_RST_CMD_ADDR);
- } else {
- reg_data = 0;
- reg_data |= (PIX_0_VFE_RST_STB | PIX_1_VFE_RST_STB |
- STROBED_RST_EN | PIX_0_CSID_RST_STB |
- PIX_1_CSID_RST_STB | PIX_OUTPUT_0_MISR_RST_STB);
- msm_camera_io_w_mb(reg_data, ispif->base +
- ISPIF_RST_CMD_1_ADDR);
- }
-
- reg_data = 0xFFFDFFFD;
- msm_camera_io_w_mb(reg_data, ispif->base +
- ISPIF_VFE_m_INTF_CMD_0(vfe_id));
- return 0;
-}
-
static inline void msm_ispif_read_irq_status(struct ispif_irq_status *out,
void *data)
{
struct ispif_device *ispif = (struct ispif_device *)data;
bool fatal_err = false;
int i = 0;
- uint32_t reg_data;
BUG_ON(!ispif);
BUG_ON(!out);
@@ -1589,12 +1276,6 @@ static inline void msm_ispif_read_irq_status(struct ispif_irq_status *out,
fatal_err = true;
}
- if (out[VFE0].ispifIrqStatus1 & PIX_INTF_1_OVERFLOW_IRQ) {
- pr_err_ratelimited("%s: VFE0 pix1 overflow.\n",
- __func__);
- fatal_err = true;
- }
-
if (out[VFE0].ispifIrqStatus0 & RAW_INTF_0_OVERFLOW_IRQ) {
pr_err_ratelimited("%s: VFE0 rdi0 overflow.\n",
__func__);
@@ -1627,12 +1308,6 @@ static inline void msm_ispif_read_irq_status(struct ispif_irq_status *out,
fatal_err = true;
}
- if (out[VFE1].ispifIrqStatus1 & PIX_INTF_1_OVERFLOW_IRQ) {
- pr_err_ratelimited("%s: VFE1 pix1 overflow.\n",
- __func__);
- fatal_err = true;
- }
-
if (out[VFE1].ispifIrqStatus0 & RAW_INTF_0_OVERFLOW_IRQ) {
pr_err_ratelimited("%s: VFE1 rdi0 overflow.\n",
__func__);
@@ -1654,43 +1329,6 @@ static inline void msm_ispif_read_irq_status(struct ispif_irq_status *out,
ispif_process_irq(ispif, out, VFE1);
}
- if ((out[VFE0].ispifIrqStatus0 & PIX_INTF_0_OVERFLOW_IRQ) ||
- (out[VFE0].ispifIrqStatus1 & PIX_INTF_0_OVERFLOW_IRQ) ||
- (out[VFE0].ispifIrqStatus2 & (L_R_SOF_MISMATCH_ERR_IRQ |
- L_R_EOF_MISMATCH_ERR_IRQ | L_R_SOL_MISMATCH_ERR_IRQ))) {
- reg_data = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_OUTPUT_SEL(VFE0));
- if ((reg_data & 0x03) == VFE_PIX_INTF_SEL_3D) {
- pix_overflow_error_count[VFE0]++;
- if (pix_overflow_error_count[VFE0] >=
- MAX_PIX_OVERFLOW_ERROR_COUNT) {
- msm_ispif_reconfig_3d_output(ispif, VFE0);
- pix_overflow_error_count[VFE0] = 0;
- }
- fatal_err = false;
- }
- }
-
- if (ispif->vfe_info.num_vfe > 1) {
- if ((out[VFE1].ispifIrqStatus0 & PIX_INTF_0_OVERFLOW_IRQ) ||
- (out[VFE1].ispifIrqStatus1 & PIX_INTF_0_OVERFLOW_IRQ) ||
- (out[VFE1].ispifIrqStatus2 & (L_R_SOF_MISMATCH_ERR_IRQ |
- L_R_EOF_MISMATCH_ERR_IRQ | L_R_SOL_MISMATCH_ERR_IRQ))) {
- reg_data = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_OUTPUT_SEL(VFE1));
- if ((reg_data & 0x03) == VFE_PIX_INTF_SEL_3D) {
- pix_overflow_error_count[VFE1]++;
- if (pix_overflow_error_count[VFE1] >=
- MAX_PIX_OVERFLOW_ERROR_COUNT) {
- msm_ispif_reconfig_3d_output(ispif,
- VFE1);
- pix_overflow_error_count[VFE1] = 0;
- }
- }
- fatal_err = false;
- }
- }
-
if (fatal_err == true) {
pr_err_ratelimited("%s: fatal error, stop ispif immediately\n",
__func__);
@@ -1746,11 +1384,6 @@ static int msm_ispif_init(struct ispif_device *ispif,
return rc;
}
- rc = msm_camera_enable_irq(ispif->irq, 1);
- if (rc < 0) {
- pr_err("%s: Error enabling IRQs\n", __func__);
- return rc;
- }
/* can we set to zero? */
ispif->applied_intf_cmd[VFE0].intf_cmd = 0xFFFFFFFF;
ispif->applied_intf_cmd[VFE0].intf_cmd1 = 0xFFFFFFFF;
@@ -1807,100 +1440,61 @@ static void msm_ispif_release(struct ispif_device *ispif)
pr_err("%s: failed to remove vote for AHB\n", __func__);
}
-static long msm_ispif_dispatch_cmd(enum ispif_cfg_type_t cmd,
- struct ispif_device *ispif,
- struct msm_ispif_param_data_ext *params)
+static long msm_ispif_cmd(struct v4l2_subdev *sd, void *arg)
{
long rc = 0;
+ struct ispif_cfg_data *pcdata = (struct ispif_cfg_data *)arg;
+ struct ispif_device *ispif =
+ (struct ispif_device *)v4l2_get_subdevdata(sd);
- switch (cmd) {
+ BUG_ON(!sd);
+ BUG_ON(!pcdata);
+
+ mutex_lock(&ispif->mutex);
+ switch (pcdata->cfg_type) {
+ case ISPIF_ENABLE_REG_DUMP:
+ ispif->enb_dump_reg = pcdata->reg_dump; /* save dump config */
+ break;
+ case ISPIF_INIT:
+ rc = msm_ispif_init(ispif, pcdata->csid_version);
+ msm_ispif_io_dump_reg(ispif);
+ break;
case ISPIF_CFG:
- rc = msm_ispif_config(ispif, params);
+ rc = msm_ispif_config(ispif, &pcdata->params);
msm_ispif_io_dump_reg(ispif);
break;
case ISPIF_START_FRAME_BOUNDARY:
- rc = msm_ispif_start_frame_boundary(ispif, params);
+ rc = msm_ispif_start_frame_boundary(ispif, &pcdata->params);
msm_ispif_io_dump_reg(ispif);
break;
case ISPIF_RESTART_FRAME_BOUNDARY:
- rc = msm_ispif_restart_frame_boundary(ispif, params);
+ rc = msm_ispif_restart_frame_boundary(ispif, &pcdata->params);
msm_ispif_io_dump_reg(ispif);
break;
+
case ISPIF_STOP_FRAME_BOUNDARY:
- rc = msm_ispif_stop_frame_boundary(ispif, params);
+ rc = msm_ispif_stop_frame_boundary(ispif, &pcdata->params);
msm_ispif_io_dump_reg(ispif);
break;
case ISPIF_STOP_IMMEDIATELY:
- rc = msm_ispif_stop_immediately(ispif, params);
+ rc = msm_ispif_stop_immediately(ispif, &pcdata->params);
msm_ispif_io_dump_reg(ispif);
break;
case ISPIF_RELEASE:
msm_ispif_reset(ispif);
msm_ispif_reset_hw(ispif);
break;
- case ISPIF_CFG2:
- rc = msm_ispif_config2(ispif, params);
- msm_ispif_io_dump_reg(ispif);
- break;
- case ISPIF_CFG_STEREO:
- msm_ispif_config_stereo(ispif, params,
- ISPIF_CALCULATE_THRESHOLD);
- break;
- default:
- pr_err("%s: invalid cfg_type\n", __func__);
- rc = -EINVAL;
- break;
- }
- return rc;
-}
-
-static long msm_ispif_cmd(struct v4l2_subdev *sd, void *arg)
-{
- long rc = 0;
- struct ispif_cfg_data *pcdata = (struct ispif_cfg_data *)arg;
- struct ispif_device *ispif =
- (struct ispif_device *)v4l2_get_subdevdata(sd);
- int i;
- struct msm_ispif_param_data_ext params;
-
- BUG_ON(!sd);
- BUG_ON(!pcdata);
- mutex_lock(&ispif->mutex);
- switch (pcdata->cfg_type) {
- case ISPIF_ENABLE_REG_DUMP:
- /* save dump config */
- ispif->enb_dump_reg = pcdata->reg_dump;
- break;
- case ISPIF_INIT:
- rc = msm_ispif_init(ispif, pcdata->csid_version);
- msm_ispif_io_dump_reg(ispif);
- break;
case ISPIF_SET_VFE_INFO:
rc = msm_ispif_set_vfe_info(ispif, &pcdata->vfe_info);
break;
default:
- memset(&params, 0, sizeof(params));
- if (pcdata->params.num > MAX_PARAM_ENTRIES) {
- pr_err("%s: invalid num entries %u\n", __func__,
- pcdata->params.num);
- rc = -EINVAL;
- } else {
- params.num = pcdata->params.num;
- for (i = 0; i < pcdata->params.num; i++)
- memcpy(&params.entries[i],
- &pcdata->params.entries[i],
- sizeof(struct msm_ispif_params_entry));
- params.stereo_enable = 0;
- rc = msm_ispif_dispatch_cmd(pcdata->cfg_type, ispif,
- &params);
- }
+ pr_err("%s: invalid cfg_type\n", __func__);
+ rc = -EINVAL;
break;
}
mutex_unlock(&ispif->mutex);
-
return rc;
}
-
static struct v4l2_file_operations msm_ispif_v4l2_subdev_fops;
static long msm_ispif_subdev_ioctl_unlocked(struct v4l2_subdev *sd,
@@ -1962,6 +1556,9 @@ static int ispif_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
rc = msm_ispif_clk_ahb_enable(ispif, 1);
if (rc)
goto ahb_clk_enable_fail;
+ rc = msm_camera_enable_irq(ispif->irq, 1);
+ if (rc)
+ goto irq_enable_fail;
}
/* mem remap is done in init when the clock is on */
ispif->open_cnt++;
@@ -1969,6 +1566,8 @@ static int ispif_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
return rc;
ahb_clk_enable_fail:
msm_ispif_set_regulators(ispif->ispif_vdd, ispif->ispif_vdd_count, 0);
+irq_enable_fail:
+ msm_ispif_clk_ahb_enable(ispif, 0);
unlock:
mutex_unlock(&ispif->mutex);
return rc;
diff --git a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.h b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.h
index 3e6680c63ee5..61e8f1dd7aff 100644
--- a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.h
+++ b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -77,6 +77,5 @@ struct ispif_device {
int ispif_vdd_count;
struct regulator *vfe_vdd[ISPIF_VFE_VDD_INFO_MAX];
int vfe_vdd_count;
- int stereo_configured[VFE_MAX];
};
#endif
diff --git a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_32.c b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_32.c
deleted file mode 100644
index 7c12fb9af6c4..000000000000
--- a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_32.c
+++ /dev/null
@@ -1,1578 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/delay.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/jiffies.h>
-#include <linux/of.h>
-#include <linux/videodev2.h>
-#include <linux/platform_device.h>
-#include <linux/gpio.h>
-#include <linux/iopoll.h>
-#include <linux/compat.h>
-#include <media/msmb_isp.h>
-
-#include "msm_ispif_32.h"
-#include "msm.h"
-#include "msm_sd.h"
-#include "msm_camera_io_util.h"
-
-#ifdef CONFIG_MSM_ISPIF_V1
-#include "msm_ispif_hwreg_v1.h"
-#else
-#include "msm_ispif_hwreg_v2.h"
-#endif
-
-#define V4L2_IDENT_ISPIF 50001
-#define MSM_ISPIF_DRV_NAME "msm_ispif"
-
-#define ISPIF_INTF_CMD_DISABLE_FRAME_BOUNDARY 0x00
-#define ISPIF_INTF_CMD_ENABLE_FRAME_BOUNDARY 0x01
-#define ISPIF_INTF_CMD_DISABLE_IMMEDIATELY 0x02
-
-#define ISPIF_TIMEOUT_SLEEP_US 1000
-#define ISPIF_TIMEOUT_ALL_US 1000000
-
-#undef CDBG
-#ifdef CONFIG_MSMB_CAMERA_DEBUG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-#else
-#define CDBG(fmt, args...) do { } while (0)
-#endif
-
-static void msm_ispif_io_dump_reg(struct ispif_device *ispif)
-{
- if (!ispif->enb_dump_reg)
- return;
-
- if (!ispif->base) {
- pr_err("%s: null pointer for the ispif base\n", __func__);
- return;
- }
-
- msm_camera_io_dump(ispif->base, 0x250, 0);
-}
-
-
-static inline int msm_ispif_is_intf_valid(uint32_t csid_version,
- uint8_t intf_type)
-{
- return (((csid_version <= CSID_VERSION_V22
- && intf_type != VFE0) ||
- (intf_type >= VFE_MAX))
- ? false : true);
-}
-
-static struct msm_cam_clk_info ispif_8626_reset_clk_info[] = {
- {"ispif_ahb_clk", NO_SET_RATE},
- {"csi0_src_clk", NO_SET_RATE},
- {"csi0_clk", NO_SET_RATE},
- {"csi0_pix_clk", NO_SET_RATE},
- {"csi0_rdi_clk", NO_SET_RATE},
- {"csi1_src_clk", NO_SET_RATE},
- {"csi1_clk", NO_SET_RATE},
- {"csi1_pix_clk", NO_SET_RATE},
- {"csi1_rdi_clk", NO_SET_RATE},
- {"camss_vfe_vfe0_clk", NO_SET_RATE},
- {"camss_csi_vfe0_clk", NO_SET_RATE},
-};
-
-static struct msm_cam_clk_info ispif_8974_ahb_clk_info[ISPIF_CLK_INFO_MAX];
-
-static struct msm_cam_clk_info ispif_8974_reset_clk_info[] = {
- {"csi0_src_clk", INIT_RATE},
- {"csi0_clk", NO_SET_RATE},
- {"csi0_pix_clk", NO_SET_RATE},
- {"csi0_rdi_clk", NO_SET_RATE},
- {"csi1_src_clk", INIT_RATE},
- {"csi1_clk", NO_SET_RATE},
- {"csi1_pix_clk", NO_SET_RATE},
- {"csi1_rdi_clk", NO_SET_RATE},
- {"csi2_src_clk", INIT_RATE},
- {"csi2_clk", NO_SET_RATE},
- {"csi2_pix_clk", NO_SET_RATE},
- {"csi2_rdi_clk", NO_SET_RATE},
- {"csi3_src_clk", INIT_RATE},
- {"csi3_clk", NO_SET_RATE},
- {"csi3_pix_clk", NO_SET_RATE},
- {"csi3_rdi_clk", NO_SET_RATE},
- {"vfe0_clk_src", INIT_RATE},
- {"camss_vfe_vfe0_clk", NO_SET_RATE},
- {"camss_csi_vfe0_clk", NO_SET_RATE},
- {"vfe1_clk_src", INIT_RATE},
- {"camss_vfe_vfe1_clk", NO_SET_RATE},
- {"camss_csi_vfe1_clk", NO_SET_RATE},
-};
-
-static int msm_ispif_reset_hw(struct ispif_device *ispif)
-{
- int rc = 0;
- long timeout = 0;
- struct clk *reset_clk[ARRAY_SIZE(ispif_8974_reset_clk_info)];
- struct clk *reset_clk1[ARRAY_SIZE(ispif_8626_reset_clk_info)];
-
- ispif->clk_idx = 0;
-
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8974_reset_clk_info, reset_clk,
- ARRAY_SIZE(ispif_8974_reset_clk_info), 1);
- if (rc < 0) {
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8626_reset_clk_info, reset_clk1,
- ARRAY_SIZE(ispif_8626_reset_clk_info), 1);
- if (rc < 0) {
- pr_err("%s: cannot enable clock, error = %d",
- __func__, rc);
- } else {
- /* This is set when device is 8x26 */
- ispif->clk_idx = 2;
- }
- } else {
- /* This is set when device is 8974 */
- ispif->clk_idx = 1;
- }
-
- init_completion(&ispif->reset_complete[VFE0]);
- if (ispif->hw_num_isps > 1)
- init_completion(&ispif->reset_complete[VFE1]);
-
- /* initiate reset of ISPIF */
- msm_camera_io_w(ISPIF_RST_CMD_MASK,
- ispif->base + ISPIF_RST_CMD_ADDR);
- if (ispif->hw_num_isps > 1)
- msm_camera_io_w(ISPIF_RST_CMD_1_MASK,
- ispif->base + ISPIF_RST_CMD_1_ADDR);
-
- timeout = wait_for_completion_timeout(
- &ispif->reset_complete[VFE0], msecs_to_jiffies(500));
- CDBG("%s: VFE0 done\n", __func__);
-
- if (timeout <= 0) {
- pr_err("%s: VFE0 reset wait timeout\n", __func__);
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8974_reset_clk_info, reset_clk,
- ARRAY_SIZE(ispif_8974_reset_clk_info), 0);
- if (rc < 0) {
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8626_reset_clk_info, reset_clk1,
- ARRAY_SIZE(ispif_8626_reset_clk_info), 0);
- if (rc < 0)
- pr_err("%s: VFE0 reset wait timeout\n",
- __func__);
- }
- return -ETIMEDOUT;
- }
-
- if (ispif->hw_num_isps > 1) {
- timeout = wait_for_completion_timeout(
- &ispif->reset_complete[VFE1],
- msecs_to_jiffies(500));
- CDBG("%s: VFE1 done\n", __func__);
- if (timeout <= 0) {
- pr_err("%s: VFE1 reset wait timeout\n", __func__);
- msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8974_reset_clk_info, reset_clk,
- ARRAY_SIZE(ispif_8974_reset_clk_info), 0);
- return -ETIMEDOUT;
- }
- }
-
- if (ispif->clk_idx == 1) {
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8974_reset_clk_info, reset_clk,
- ARRAY_SIZE(ispif_8974_reset_clk_info), 0);
- if (rc < 0) {
- pr_err("%s: cannot disable clock, error = %d",
- __func__, rc);
- }
- }
-
- if (ispif->clk_idx == 2) {
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8626_reset_clk_info, reset_clk1,
- ARRAY_SIZE(ispif_8626_reset_clk_info), 0);
- if (rc < 0) {
- pr_err("%s: cannot disable clock, error = %d",
- __func__, rc);
- }
- }
-
- return rc;
-}
-
-int msm_ispif_get_ahb_clk_info(struct ispif_device *ispif_dev,
- struct platform_device *pdev,
- struct msm_cam_clk_info *ahb_clk_info)
-{
- uint32_t num_ahb_clk = 0;
- int i, count, rc;
- uint32_t rates[ISPIF_CLK_INFO_MAX];
-
- struct device_node *of_node;
-
- of_node = pdev->dev.of_node;
-
- count = of_property_count_strings(of_node, "clock-names");
-
- CDBG("count = %d\n", count);
- if (count <= 0) {
- pr_err("no clocks found in device tree, count=%d", count);
- return 0;
- }
-
- if (count > ISPIF_CLK_INFO_MAX) {
- pr_err("invalid count=%d, max is %d\n", count,
- ISPIF_CLK_INFO_MAX);
- return -EINVAL;
- }
-
- rc = of_property_read_u32_array(of_node, "qcom,clock-rates",
- rates, count);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- return rc;
- }
- for (i = 0; i < count; i++) {
- rc = of_property_read_string_index(of_node, "clock-names",
- i, &(ahb_clk_info[num_ahb_clk].clk_name));
- CDBG("clock-names[%d] = %s\n",
- i, ahb_clk_info[i].clk_name);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- return rc;
- }
- if (strnstr(ahb_clk_info[num_ahb_clk].clk_name, "ahb",
- sizeof(ahb_clk_info[num_ahb_clk].clk_name))) {
- ahb_clk_info[num_ahb_clk].clk_rate =
- (rates[i] == 0) ? (long)-1 : rates[i];
- CDBG("clk_rate[%d] = %ld\n", i,
- ahb_clk_info[i].clk_rate);
- num_ahb_clk++;
- }
- }
- ispif_dev->num_ahb_clk = num_ahb_clk;
- return 0;
-}
-
-static int msm_ispif_clk_ahb_enable(struct ispif_device *ispif, int enable)
-{
- int rc = 0;
-
- if (ispif->csid_version < CSID_VERSION_V30) {
- /* Older ISPIF versiond don't need ahb clokc */
- return 0;
- }
-
- rc = msm_ispif_get_ahb_clk_info(ispif, ispif->pdev,
- ispif_8974_ahb_clk_info);
- if (rc < 0) {
- pr_err("%s: msm_isp_get_clk_info() failed", __func__);
- return -EFAULT;
- }
-
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8974_ahb_clk_info, ispif->ahb_clk,
- ispif->num_ahb_clk, enable);
- if (rc < 0) {
- pr_err("%s: cannot enable clock, error = %d",
- __func__, rc);
- }
-
- return rc;
-}
-
-static int msm_ispif_reset(struct ispif_device *ispif)
-{
- int rc = 0;
- int i;
-
- BUG_ON(!ispif);
-
- memset(ispif->sof_count, 0, sizeof(ispif->sof_count));
- for (i = 0; i < ispif->vfe_info.num_vfe; i++) {
-
- msm_camera_io_w(1 << PIX0_LINE_BUF_EN_BIT,
- ispif->base + ISPIF_VFE_m_CTRL_0(i));
- msm_camera_io_w(0, ispif->base + ISPIF_VFE_m_IRQ_MASK_0(i));
- msm_camera_io_w(0, ispif->base + ISPIF_VFE_m_IRQ_MASK_1(i));
- msm_camera_io_w(0, ispif->base + ISPIF_VFE_m_IRQ_MASK_2(i));
- msm_camera_io_w(0xFFFFFFFF, ispif->base +
- ISPIF_VFE_m_IRQ_CLEAR_0(i));
- msm_camera_io_w(0xFFFFFFFF, ispif->base +
- ISPIF_VFE_m_IRQ_CLEAR_1(i));
- msm_camera_io_w(0xFFFFFFFF, ispif->base +
- ISPIF_VFE_m_IRQ_CLEAR_2(i));
-
- msm_camera_io_w(0, ispif->base + ISPIF_VFE_m_INPUT_SEL(i));
-
- msm_camera_io_w(ISPIF_STOP_INTF_IMMEDIATELY,
- ispif->base + ISPIF_VFE_m_INTF_CMD_0(i));
- msm_camera_io_w(ISPIF_STOP_INTF_IMMEDIATELY,
- ispif->base + ISPIF_VFE_m_INTF_CMD_1(i));
- pr_debug("%s: base %pK", __func__, ispif->base);
- msm_camera_io_w(0, ispif->base +
- ISPIF_VFE_m_PIX_INTF_n_CID_MASK(i, 0));
- msm_camera_io_w(0, ispif->base +
- ISPIF_VFE_m_PIX_INTF_n_CID_MASK(i, 1));
- msm_camera_io_w(0, ispif->base +
- ISPIF_VFE_m_RDI_INTF_n_CID_MASK(i, 0));
- msm_camera_io_w(0, ispif->base +
- ISPIF_VFE_m_RDI_INTF_n_CID_MASK(i, 1));
- msm_camera_io_w(0, ispif->base +
- ISPIF_VFE_m_RDI_INTF_n_CID_MASK(i, 2));
-
- msm_camera_io_w(0, ispif->base +
- ISPIF_VFE_m_PIX_INTF_n_CROP(i, 0));
- msm_camera_io_w(0, ispif->base +
- ISPIF_VFE_m_PIX_INTF_n_CROP(i, 1));
- }
-
- msm_camera_io_w_mb(ISPIF_IRQ_GLOBAL_CLEAR_CMD, ispif->base +
- ISPIF_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-
- return rc;
-}
-
-/*
-static int msm_ispif_subdev_g_chip_ident(struct v4l2_subdev *sd,
- struct v4l2_dbg_chip_ident *chip)
-{
- BUG_ON(!chip);
- chip->ident = V4L2_IDENT_ISPIF;
- chip->revision = 0;
- return 0;
-}
-*/
-
-static void msm_ispif_sel_csid_core(struct ispif_device *ispif,
- uint8_t intftype, uint8_t csid, uint8_t vfe_intf)
-{
- uint32_t data;
-
- BUG_ON(!ispif);
-
- if (!msm_ispif_is_intf_valid(ispif->csid_version, vfe_intf)) {
- pr_err("%s: invalid interface type\n", __func__);
- return;
- }
-
- data = msm_camera_io_r(ispif->base + ISPIF_VFE_m_INPUT_SEL(vfe_intf));
- switch (intftype) {
- case PIX0:
- data &= ~(BIT(1) | BIT(0));
- data |= (uint32_t)csid;
- break;
- case RDI0:
- data &= ~(BIT(5) | BIT(4));
- data |= (uint32_t)(csid << 4);
- break;
- case PIX1:
- data &= ~(BIT(9) | BIT(8));
- data |= (uint32_t)(csid << 8);
- break;
- case RDI1:
- data &= ~(BIT(13) | BIT(12));
- data |= (uint32_t)(csid << 12);
- break;
- case RDI2:
- data &= ~(BIT(21) | BIT(20));
- data |= (uint32_t)(csid << 20);
- break;
- }
-
- msm_camera_io_w_mb(data, ispif->base +
- ISPIF_VFE_m_INPUT_SEL(vfe_intf));
-}
-
-static void msm_ispif_enable_crop(struct ispif_device *ispif,
- uint8_t intftype, uint8_t vfe_intf, uint16_t start_pixel,
- uint16_t end_pixel)
-{
- uint32_t data;
-
- BUG_ON(!ispif);
-
- if (!msm_ispif_is_intf_valid(ispif->csid_version, vfe_intf)) {
- pr_err("%s: invalid interface type\n", __func__);
- return;
- }
-
- data = msm_camera_io_r(ispif->base + ISPIF_VFE_m_CTRL_0(vfe_intf));
- data |= (1 << (intftype + 7));
- if (intftype == PIX0)
- data |= 1 << PIX0_LINE_BUF_EN_BIT;
- msm_camera_io_w(data,
- ispif->base + ISPIF_VFE_m_CTRL_0(vfe_intf));
-
- if (intftype == PIX0)
- msm_camera_io_w_mb(start_pixel | (end_pixel << 16),
- ispif->base + ISPIF_VFE_m_PIX_INTF_n_CROP(vfe_intf, 0));
- else if (intftype == PIX1)
- msm_camera_io_w_mb(start_pixel | (end_pixel << 16),
- ispif->base + ISPIF_VFE_m_PIX_INTF_n_CROP(vfe_intf, 1));
- else {
- pr_err("%s: invalid intftype=%d\n", __func__, intftype);
- BUG_ON(1);
- return;
- }
-}
-
-static void msm_ispif_enable_intf_cids(struct ispif_device *ispif,
- uint8_t intftype, uint16_t cid_mask, uint8_t vfe_intf, uint8_t enable)
-{
- uint32_t intf_addr, data;
-
- BUG_ON(!ispif);
-
- if (!msm_ispif_is_intf_valid(ispif->csid_version, vfe_intf)) {
- pr_err("%s: invalid interface type\n", __func__);
- return;
- }
-
- switch (intftype) {
- case PIX0:
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_CID_MASK(vfe_intf, 0);
- break;
- case RDI0:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_CID_MASK(vfe_intf, 0);
- break;
- case PIX1:
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_CID_MASK(vfe_intf, 1);
- break;
- case RDI1:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_CID_MASK(vfe_intf, 1);
- break;
- case RDI2:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_CID_MASK(vfe_intf, 2);
- break;
- default:
- pr_err("%s: invalid intftype=%d\n", __func__, intftype);
- BUG_ON(1);
- return;
- }
-
- data = msm_camera_io_r(ispif->base + intf_addr);
- if (enable)
- data |= (uint32_t)cid_mask;
- else
- data &= ~((uint32_t)cid_mask);
- msm_camera_io_w_mb(data, ispif->base + intf_addr);
-}
-
-static int msm_ispif_validate_intf_status(struct ispif_device *ispif,
- uint8_t intftype, uint8_t vfe_intf)
-{
- int rc = 0;
- uint32_t data = 0;
-
- BUG_ON(!ispif);
-
- if (!msm_ispif_is_intf_valid(ispif->csid_version, vfe_intf)) {
- pr_err("%s: invalid interface type\n", __func__);
- return -EINVAL;
- }
-
- switch (intftype) {
- case PIX0:
- data = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 0));
- break;
- case RDI0:
- data = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 0));
- break;
- case PIX1:
- data = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 1));
- break;
- case RDI1:
- data = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 1));
- break;
- case RDI2:
- data = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 2));
- break;
- }
- if ((data & 0xf) != 0xf)
- rc = -EBUSY;
- return rc;
-}
-
-static void msm_ispif_select_clk_mux(struct ispif_device *ispif,
- uint8_t intftype, uint8_t csid, uint8_t vfe_intf)
-{
- uint32_t data = 0;
-
- switch (intftype) {
- case PIX0:
- data = msm_camera_io_r(ispif->clk_mux_base);
- data &= ~(0xf << (vfe_intf * 8));
- data |= (csid << (vfe_intf * 8));
- msm_camera_io_w(data, ispif->clk_mux_base);
- break;
-
- case RDI0:
- data = msm_camera_io_r(ispif->clk_mux_base +
- ISPIF_RDI_CLK_MUX_SEL_ADDR);
- data &= ~(0xf << (vfe_intf * 12));
- data |= (csid << (vfe_intf * 12));
- msm_camera_io_w(data, ispif->clk_mux_base +
- ISPIF_RDI_CLK_MUX_SEL_ADDR);
- break;
-
- case PIX1:
- data = msm_camera_io_r(ispif->clk_mux_base);
- data &= ~(0xf0 << (vfe_intf * 8));
- data |= (csid << (4 + (vfe_intf * 8)));
- msm_camera_io_w(data, ispif->clk_mux_base);
- break;
-
- case RDI1:
- data = msm_camera_io_r(ispif->clk_mux_base +
- ISPIF_RDI_CLK_MUX_SEL_ADDR);
- data &= ~(0xf << (4 + (vfe_intf * 12)));
- data |= (csid << (4 + (vfe_intf * 12)));
- msm_camera_io_w(data, ispif->clk_mux_base +
- ISPIF_RDI_CLK_MUX_SEL_ADDR);
- break;
-
- case RDI2:
- data = msm_camera_io_r(ispif->clk_mux_base +
- ISPIF_RDI_CLK_MUX_SEL_ADDR);
- data &= ~(0xf << (8 + (vfe_intf * 12)));
- data |= (csid << (8 + (vfe_intf * 12)));
- msm_camera_io_w(data, ispif->clk_mux_base +
- ISPIF_RDI_CLK_MUX_SEL_ADDR);
- break;
- }
- CDBG("%s intftype %d data %x\n", __func__, intftype, data);
- /* ensure clk mux is enabled */
- mb();
-}
-
-static uint16_t msm_ispif_get_cids_mask_from_cfg(
- struct msm_ispif_params_entry *entry)
-{
- int i;
- uint16_t cids_mask = 0;
-
- BUG_ON(!entry);
-
- for (i = 0; i < entry->num_cids && i < MAX_CID_CH_v2; i++)
- cids_mask |= (1 << entry->cids[i]);
-
- return cids_mask;
-}
-
-static int msm_ispif_config(struct ispif_device *ispif,
- struct msm_ispif_param_data *params)
-{
- int rc = 0, i = 0;
- uint16_t cid_mask;
- enum msm_ispif_intftype intftype;
- enum msm_ispif_vfe_intf vfe_intf;
-
- BUG_ON(!ispif);
- BUG_ON(!params);
-
- if (ispif->ispif_state != ISPIF_POWER_UP) {
- pr_err("%s: ispif invalid state %d\n", __func__,
- ispif->ispif_state);
- rc = -EPERM;
- return rc;
- }
- if (params->num > MAX_PARAM_ENTRIES) {
- pr_err("%s: invalid param entries %d\n", __func__,
- params->num);
- rc = -EINVAL;
- return rc;
- }
-
- for (i = 0; i < params->num; i++) {
- vfe_intf = params->entries[i].vfe_intf;
- if (vfe_intf >= VFE_MAX) {
- pr_err("%s: %d invalid i %d vfe_intf %d\n", __func__,
- __LINE__, i, vfe_intf);
- return -EINVAL;
- }
- if (!msm_ispif_is_intf_valid(ispif->csid_version,
- vfe_intf)) {
- pr_err("%s: invalid interface type\n", __func__);
- return -EINVAL;
- }
- msm_camera_io_w(0x0, ispif->base +
- ISPIF_VFE_m_IRQ_MASK_0(vfe_intf));
- msm_camera_io_w(0x0, ispif->base +
- ISPIF_VFE_m_IRQ_MASK_1(vfe_intf));
- msm_camera_io_w_mb(0x0, ispif->base +
- ISPIF_VFE_m_IRQ_MASK_2(vfe_intf));
- }
-
- for (i = 0; i < params->num; i++) {
- intftype = params->entries[i].intftype;
-
- vfe_intf = params->entries[i].vfe_intf;
-
- CDBG("%s intftype %x, vfe_intf %d, csid %d\n", __func__,
- intftype, vfe_intf, params->entries[i].csid);
-
- if ((intftype >= INTF_MAX) ||
- (vfe_intf >= ispif->vfe_info.num_vfe) ||
- (ispif->csid_version <= CSID_VERSION_V22 &&
- (vfe_intf > VFE0))) {
- pr_err("%s: VFEID %d and CSID version %d mismatch\n",
- __func__, vfe_intf, ispif->csid_version);
- return -EINVAL;
- }
-
- if (ispif->csid_version >= CSID_VERSION_V30)
- msm_ispif_select_clk_mux(ispif, intftype,
- params->entries[i].csid, vfe_intf);
-
- rc = msm_ispif_validate_intf_status(ispif, intftype, vfe_intf);
- if (rc) {
- pr_err("%s:validate_intf_status failed, rc = %d\n",
- __func__, rc);
- return rc;
- }
-
- msm_ispif_sel_csid_core(ispif, intftype,
- params->entries[i].csid, vfe_intf);
- cid_mask = msm_ispif_get_cids_mask_from_cfg(
- &params->entries[i]);
- msm_ispif_enable_intf_cids(ispif, intftype,
- cid_mask, vfe_intf, 1);
- if (params->entries[i].crop_enable)
- msm_ispif_enable_crop(ispif, intftype, vfe_intf,
- params->entries[i].crop_start_pixel,
- params->entries[i].crop_end_pixel);
- }
-
- for (vfe_intf = 0; vfe_intf < 2; vfe_intf++) {
- msm_camera_io_w(ISPIF_IRQ_STATUS_MASK, ispif->base +
- ISPIF_VFE_m_IRQ_MASK_0(vfe_intf));
-
- msm_camera_io_w(ISPIF_IRQ_STATUS_MASK, ispif->base +
- ISPIF_VFE_m_IRQ_CLEAR_0(vfe_intf));
-
- msm_camera_io_w(ISPIF_IRQ_STATUS_1_MASK, ispif->base +
- ISPIF_VFE_m_IRQ_MASK_1(vfe_intf));
-
- msm_camera_io_w(ISPIF_IRQ_STATUS_1_MASK, ispif->base +
- ISPIF_VFE_m_IRQ_CLEAR_1(vfe_intf));
-
- msm_camera_io_w(ISPIF_IRQ_STATUS_2_MASK, ispif->base +
- ISPIF_VFE_m_IRQ_MASK_2(vfe_intf));
-
- msm_camera_io_w(ISPIF_IRQ_STATUS_2_MASK, ispif->base +
- ISPIF_VFE_m_IRQ_CLEAR_2(vfe_intf));
- }
-
- msm_camera_io_w_mb(ISPIF_IRQ_GLOBAL_CLEAR_CMD, ispif->base +
- ISPIF_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-
- return rc;
-}
-
-static void msm_ispif_intf_cmd(struct ispif_device *ispif, uint32_t cmd_bits,
- struct msm_ispif_param_data *params)
-{
- uint8_t vc;
- int i, k;
- enum msm_ispif_intftype intf_type;
- enum msm_ispif_cid cid;
- enum msm_ispif_vfe_intf vfe_intf;
-
- BUG_ON(!ispif);
- BUG_ON(!params);
-
- for (i = 0; i < params->num; i++) {
- vfe_intf = params->entries[i].vfe_intf;
- if (!msm_ispif_is_intf_valid(ispif->csid_version, vfe_intf)) {
- pr_err("%s: invalid interface type\n", __func__);
- return;
- }
- if (params->entries[i].num_cids > MAX_CID_CH_v2) {
- pr_err("%s: out of range of cid_num %d\n",
- __func__, params->entries[i].num_cids);
- return;
- }
- }
-
- for (i = 0; i < params->num; i++) {
- intf_type = params->entries[i].intftype;
- vfe_intf = params->entries[i].vfe_intf;
- for (k = 0; k < params->entries[i].num_cids; k++) {
- cid = params->entries[i].cids[k];
- vc = cid / 4;
- if (intf_type == RDI2) {
- /* zero out two bits */
- ispif->applied_intf_cmd[vfe_intf].intf_cmd1 &=
- ~(0x3 << (vc * 2 + 8));
- /* set cmd bits */
- ispif->applied_intf_cmd[vfe_intf].intf_cmd1 |=
- (cmd_bits << (vc * 2 + 8));
- } else {
- /* zero 2 bits */
- ispif->applied_intf_cmd[vfe_intf].intf_cmd &=
- ~(0x3 << (vc * 2 + intf_type * 8));
- /* set cmd bits */
- ispif->applied_intf_cmd[vfe_intf].intf_cmd |=
- (cmd_bits << (vc * 2 + intf_type * 8));
- }
- }
- /* cmd for PIX0, PIX1, RDI0, RDI1 */
- if (ispif->applied_intf_cmd[vfe_intf].intf_cmd != 0xFFFFFFFF)
- msm_camera_io_w_mb(
- ispif->applied_intf_cmd[vfe_intf].intf_cmd,
- ispif->base + ISPIF_VFE_m_INTF_CMD_0(vfe_intf));
-
- /* cmd for RDI2 */
- if (ispif->applied_intf_cmd[vfe_intf].intf_cmd1 != 0xFFFFFFFF)
- msm_camera_io_w_mb(
- ispif->applied_intf_cmd[vfe_intf].intf_cmd1,
- ispif->base + ISPIF_VFE_m_INTF_CMD_1(vfe_intf));
- }
-}
-
-static int msm_ispif_stop_immediately(struct ispif_device *ispif,
- struct msm_ispif_param_data *params)
-{
- int i, rc = 0;
- uint16_t cid_mask = 0;
-
- BUG_ON(!ispif);
- BUG_ON(!params);
-
- if (ispif->ispif_state != ISPIF_POWER_UP) {
- pr_err("%s: ispif invalid state %d\n", __func__,
- ispif->ispif_state);
- rc = -EPERM;
- return rc;
- }
-
- if (params->num > MAX_PARAM_ENTRIES) {
- pr_err("%s: invalid param entries %d\n", __func__,
- params->num);
- rc = -EINVAL;
- return rc;
- }
- msm_ispif_intf_cmd(ispif, ISPIF_INTF_CMD_DISABLE_IMMEDIATELY, params);
-
- /* after stop the interface we need to unmask the CID enable bits */
- for (i = 0; i < params->num; i++) {
- cid_mask = msm_ispif_get_cids_mask_from_cfg(
- &params->entries[i]);
- msm_ispif_enable_intf_cids(ispif, params->entries[i].intftype,
- cid_mask, params->entries[i].vfe_intf, 0);
- }
-
- return rc;
-}
-
-static int msm_ispif_start_frame_boundary(struct ispif_device *ispif,
- struct msm_ispif_param_data *params)
-{
- int rc = 0;
-
- if (ispif->ispif_state != ISPIF_POWER_UP) {
- pr_err("%s: ispif invalid state %d\n", __func__,
- ispif->ispif_state);
- rc = -EPERM;
- return rc;
- }
- if (params->num > MAX_PARAM_ENTRIES) {
- pr_err("%s: invalid param entries %d\n", __func__,
- params->num);
- rc = -EINVAL;
- return rc;
- }
-
- msm_ispif_intf_cmd(ispif, ISPIF_INTF_CMD_ENABLE_FRAME_BOUNDARY, params);
-
- return rc;
-}
-
-static int msm_ispif_restart_frame_boundary(struct ispif_device *ispif,
- struct msm_ispif_param_data *params)
-{
- int rc = 0, i;
- long timeout = 0;
- uint16_t cid_mask;
- enum msm_ispif_intftype intftype;
- enum msm_ispif_vfe_intf vfe_intf;
- uint32_t vfe_mask = 0;
- uint32_t intf_addr;
- struct clk *reset_clk[ARRAY_SIZE(ispif_8974_reset_clk_info)];
- struct clk *reset_clk1[ARRAY_SIZE(ispif_8626_reset_clk_info)];
-
- ispif->clk_idx = 0;
-
- if (ispif->ispif_state != ISPIF_POWER_UP) {
- pr_err("%s: ispif invalid state %d\n", __func__,
- ispif->ispif_state);
- rc = -EPERM;
- return rc;
- }
- if (params->num > MAX_PARAM_ENTRIES) {
- pr_err("%s: invalid param entries %d\n", __func__,
- params->num);
- rc = -EINVAL;
- return rc;
- }
-
- for (i = 0; i < params->num; i++) {
- vfe_intf = params->entries[i].vfe_intf;
- if (vfe_intf >= VFE_MAX) {
- pr_err("%s: %d invalid i %d vfe_intf %d\n", __func__,
- __LINE__, i, vfe_intf);
- return -EINVAL;
- }
- vfe_mask |= (1 << vfe_intf);
- }
-
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8974_reset_clk_info, reset_clk,
- ARRAY_SIZE(ispif_8974_reset_clk_info), 1);
- if (rc < 0) {
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8626_reset_clk_info, reset_clk1,
- ARRAY_SIZE(ispif_8626_reset_clk_info), 1);
- if (rc < 0) {
- pr_err("%s: cannot enable clock, error = %d",
- __func__, rc);
- } else {
- /* This is set when device is 8x26 */
- ispif->clk_idx = 2;
- }
- } else {
- /* This is set when device is 8974 */
- ispif->clk_idx = 1;
- }
-
- if (vfe_mask & (1 << VFE0)) {
- init_completion(&ispif->reset_complete[VFE0]);
- pr_err("%s Init completion VFE0\n", __func__);
- /* initiate reset of ISPIF */
- msm_camera_io_w(0x00001FF9,
- ispif->base + ISPIF_RST_CMD_ADDR);
- }
- if (ispif->hw_num_isps > 1 && (vfe_mask & (1 << VFE1))) {
- init_completion(&ispif->reset_complete[VFE1]);
- pr_err("%s Init completion VFE1\n", __func__);
- msm_camera_io_w(0x00001FF9,
- ispif->base + ISPIF_RST_CMD_1_ADDR);
- }
-
- if (vfe_mask & (1 << VFE0)) {
- timeout = wait_for_completion_timeout(
- &ispif->reset_complete[VFE0], msecs_to_jiffies(500));
- if (timeout <= 0) {
- pr_err("%s: VFE0 reset wait timeout\n", __func__);
- rc = -ETIMEDOUT;
- goto disable_clk;
- }
- }
-
- if (ispif->hw_num_isps > 1 && (vfe_mask & (1 << VFE1))) {
- timeout = wait_for_completion_timeout(
- &ispif->reset_complete[VFE1],
- msecs_to_jiffies(500));
- if (timeout <= 0) {
- pr_err("%s: VFE1 reset wait timeout\n", __func__);
- rc = -ETIMEDOUT;
- goto disable_clk;
- }
- }
-
- pr_info("%s: ISPIF reset hw done", __func__);
-
- if (ispif->clk_idx == 1) {
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8974_reset_clk_info, reset_clk,
- ARRAY_SIZE(ispif_8974_reset_clk_info), 0);
- if (rc < 0) {
- pr_err("%s: cannot disable clock, error = %d",
- __func__, rc);
- goto end;
- }
- }
-
- if (ispif->clk_idx == 2) {
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8626_reset_clk_info, reset_clk1,
- ARRAY_SIZE(ispif_8626_reset_clk_info), 0);
- if (rc < 0) {
- pr_err("%s: cannot disable clock, error = %d",
- __func__, rc);
- goto end;
- }
- }
-
- for (i = 0; i < params->num; i++) {
- intftype = params->entries[i].intftype;
- vfe_intf = params->entries[i].vfe_intf;
-
- switch (params->entries[0].intftype) {
- case PIX0:
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 0);
- break;
- case RDI0:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 0);
- break;
- case PIX1:
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 1);
- break;
- case RDI1:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 1);
- break;
- case RDI2:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 2);
- break;
- default:
- pr_err("%s: invalid intftype=%d\n", __func__,
- params->entries[i].intftype);
- rc = -EPERM;
- goto end;
- }
-
- msm_ispif_intf_cmd(ispif,
- ISPIF_INTF_CMD_ENABLE_FRAME_BOUNDARY, params);
- }
-
- for (i = 0; i < params->num; i++) {
- intftype = params->entries[i].intftype;
-
- vfe_intf = params->entries[i].vfe_intf;
-
-
- cid_mask = msm_ispif_get_cids_mask_from_cfg(
- &params->entries[i]);
-
- msm_ispif_enable_intf_cids(ispif, intftype,
- cid_mask, vfe_intf, 1);
- }
-
-end:
- return rc;
-disable_clk:
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8974_reset_clk_info, reset_clk,
- ARRAY_SIZE(ispif_8974_reset_clk_info), 0);
- if (rc < 0) {
- rc = msm_cam_clk_enable(&ispif->pdev->dev,
- ispif_8626_reset_clk_info, reset_clk1,
- ARRAY_SIZE(ispif_8626_reset_clk_info), 0);
- if (rc < 0)
- pr_err("%s: cannot enable clock, error = %d",
- __func__, rc);
- }
-
- return -ETIMEDOUT;
-}
-
-static int msm_ispif_stop_frame_boundary(struct ispif_device *ispif,
- struct msm_ispif_param_data *params)
-{
- int i, rc = 0;
- uint16_t cid_mask = 0;
- uint32_t intf_addr;
- enum msm_ispif_vfe_intf vfe_intf;
- uint32_t stop_flag = 0;
-
- BUG_ON(!ispif);
- BUG_ON(!params);
-
-
- if (ispif->ispif_state != ISPIF_POWER_UP) {
- pr_err("%s: ispif invalid state %d\n", __func__,
- ispif->ispif_state);
- rc = -EPERM;
- return rc;
- }
-
- if (params->num > MAX_PARAM_ENTRIES) {
- pr_err("%s: invalid param entries %d\n", __func__,
- params->num);
- rc = -EINVAL;
- return rc;
- }
-
- for (i = 0; i < params->num; i++) {
- if (!msm_ispif_is_intf_valid(ispif->csid_version,
- params->entries[i].vfe_intf)) {
- pr_err("%s: invalid interface type\n", __func__);
- rc = -EINVAL;
- goto end;
- }
- }
-
- msm_ispif_intf_cmd(ispif,
- ISPIF_INTF_CMD_DISABLE_FRAME_BOUNDARY, params);
-
- for (i = 0; i < params->num; i++) {
- cid_mask =
- msm_ispif_get_cids_mask_from_cfg(&params->entries[i]);
- vfe_intf = params->entries[i].vfe_intf;
-
- switch (params->entries[i].intftype) {
- case PIX0:
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 0);
- break;
- case RDI0:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 0);
- break;
- case PIX1:
- intf_addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe_intf, 1);
- break;
- case RDI1:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 1);
- break;
- case RDI2:
- intf_addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe_intf, 2);
- break;
- default:
- pr_err("%s: invalid intftype=%d\n", __func__,
- params->entries[i].intftype);
- rc = -EPERM;
- goto end;
- }
-
- rc = readl_poll_timeout(ispif->base + intf_addr, stop_flag,
- (stop_flag & 0xF) == 0xF,
- ISPIF_TIMEOUT_SLEEP_US,
- ISPIF_TIMEOUT_ALL_US);
- if (rc < 0)
- goto end;
-
- /* disable CIDs in CID_MASK register */
- msm_ispif_enable_intf_cids(ispif, params->entries[i].intftype,
- cid_mask, vfe_intf, 0);
- }
-
-end:
- return rc;
-}
-
-static void ispif_process_irq(struct ispif_device *ispif,
- struct ispif_irq_status *out, enum msm_ispif_vfe_intf vfe_id)
-{
- BUG_ON(!ispif);
- BUG_ON(!out);
-
- if (out[vfe_id].ispifIrqStatus0 &
- ISPIF_IRQ_STATUS_PIX_SOF_MASK) {
- if (ispif->ispif_sof_debug < 5)
- pr_err("%s: PIX0 frame id: %u\n", __func__,
- ispif->sof_count[vfe_id].sof_cnt[PIX0]);
- ispif->sof_count[vfe_id].sof_cnt[PIX0]++;
- ispif->ispif_sof_debug++;
- }
- if (out[vfe_id].ispifIrqStatus0 &
- ISPIF_IRQ_STATUS_RDI0_SOF_MASK) {
- ispif->sof_count[vfe_id].sof_cnt[RDI0]++;
- }
- if (out[vfe_id].ispifIrqStatus1 &
- ISPIF_IRQ_STATUS_RDI1_SOF_MASK) {
- ispif->sof_count[vfe_id].sof_cnt[RDI1]++;
- }
- if (out[vfe_id].ispifIrqStatus2 &
- ISPIF_IRQ_STATUS_RDI2_SOF_MASK) {
- ispif->sof_count[vfe_id].sof_cnt[RDI2]++;
- }
-}
-
-static inline void msm_ispif_read_irq_status(struct ispif_irq_status *out,
- void *data)
-{
- struct ispif_device *ispif = (struct ispif_device *)data;
-
- BUG_ON(!ispif);
- BUG_ON(!out);
-
- out[VFE0].ispifIrqStatus0 = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_IRQ_STATUS_0(VFE0));
- msm_camera_io_w(out[VFE0].ispifIrqStatus0,
- ispif->base + ISPIF_VFE_m_IRQ_CLEAR_0(VFE0));
-
- out[VFE0].ispifIrqStatus1 = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_IRQ_STATUS_1(VFE0));
- msm_camera_io_w(out[VFE0].ispifIrqStatus1,
- ispif->base + ISPIF_VFE_m_IRQ_CLEAR_1(VFE0));
-
- out[VFE0].ispifIrqStatus2 = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_IRQ_STATUS_2(VFE0));
- msm_camera_io_w_mb(out[VFE0].ispifIrqStatus2,
- ispif->base + ISPIF_VFE_m_IRQ_CLEAR_2(VFE0));
-
- if (ispif->vfe_info.num_vfe > 1) {
- out[VFE1].ispifIrqStatus0 = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_IRQ_STATUS_0(VFE1));
- msm_camera_io_w(out[VFE1].ispifIrqStatus0,
- ispif->base + ISPIF_VFE_m_IRQ_CLEAR_0(VFE1));
-
- out[VFE1].ispifIrqStatus1 = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_IRQ_STATUS_1(VFE1));
- msm_camera_io_w(out[VFE1].ispifIrqStatus1,
- ispif->base + ISPIF_VFE_m_IRQ_CLEAR_1(VFE1));
-
- out[VFE1].ispifIrqStatus2 = msm_camera_io_r(ispif->base +
- ISPIF_VFE_m_IRQ_STATUS_2(VFE1));
- msm_camera_io_w_mb(out[VFE1].ispifIrqStatus2,
- ispif->base + ISPIF_VFE_m_IRQ_CLEAR_2(VFE1));
- }
- msm_camera_io_w_mb(ISPIF_IRQ_GLOBAL_CLEAR_CMD, ispif->base +
- ISPIF_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-
- if (out[VFE0].ispifIrqStatus0 & ISPIF_IRQ_STATUS_MASK) {
- if (out[VFE0].ispifIrqStatus0 & RESET_DONE_IRQ)
- complete(&ispif->reset_complete[VFE0]);
-
- if (out[VFE0].ispifIrqStatus0 & PIX_INTF_0_OVERFLOW_IRQ)
- pr_err("%s: VFE0 pix0 overflow.\n", __func__);
-
- if (out[VFE0].ispifIrqStatus0 & RAW_INTF_0_OVERFLOW_IRQ)
- pr_err("%s: VFE0 rdi0 overflow.\n", __func__);
-
- if (out[VFE0].ispifIrqStatus1 & RAW_INTF_1_OVERFLOW_IRQ)
- pr_err("%s: VFE0 rdi1 overflow.\n", __func__);
-
- if (out[VFE0].ispifIrqStatus2 & RAW_INTF_2_OVERFLOW_IRQ)
- pr_err("%s: VFE0 rdi2 overflow.\n", __func__);
-
- ispif_process_irq(ispif, out, VFE0);
- }
- if (ispif->hw_num_isps > 1) {
- if (out[VFE1].ispifIrqStatus0 & RESET_DONE_IRQ)
- complete(&ispif->reset_complete[VFE1]);
-
- if (out[VFE1].ispifIrqStatus0 & PIX_INTF_0_OVERFLOW_IRQ)
- pr_err("%s: VFE1 pix0 overflow.\n", __func__);
-
- if (out[VFE1].ispifIrqStatus0 & RAW_INTF_0_OVERFLOW_IRQ)
- pr_err("%s: VFE1 rdi0 overflow.\n", __func__);
-
- if (out[VFE1].ispifIrqStatus1 & RAW_INTF_1_OVERFLOW_IRQ)
- pr_err("%s: VFE1 rdi1 overflow.\n", __func__);
-
- if (out[VFE1].ispifIrqStatus2 & RAW_INTF_2_OVERFLOW_IRQ)
- pr_err("%s: VFE1 rdi2 overflow.\n", __func__);
-
- ispif_process_irq(ispif, out, VFE1);
- }
-}
-
-static irqreturn_t msm_io_ispif_irq(int irq_num, void *data)
-{
- struct ispif_irq_status irq[VFE_MAX];
-
- msm_ispif_read_irq_status(irq, data);
- return IRQ_HANDLED;
-}
-
-static int msm_ispif_set_vfe_info(struct ispif_device *ispif,
- struct msm_ispif_vfe_info *vfe_info)
-{
- if (!vfe_info || (vfe_info->num_vfe <= 0) ||
- ((uint32_t)(vfe_info->num_vfe) > ispif->hw_num_isps)) {
- pr_err("Invalid VFE info: %pK %d\n", vfe_info,
- (vfe_info ? vfe_info->num_vfe:0));
- return -EINVAL;
- }
-
- memcpy(&ispif->vfe_info, vfe_info, sizeof(struct msm_ispif_vfe_info));
-
- return 0;
-}
-
-static int msm_ispif_init(struct ispif_device *ispif,
- uint32_t csid_version)
-{
- int rc = 0;
-
- BUG_ON(!ispif);
-
- if (ispif->ispif_state == ISPIF_POWER_UP) {
- pr_err("%s: ispif already initted state = %d\n", __func__,
- ispif->ispif_state);
- rc = -EPERM;
- return rc;
- }
-
- /* can we set to zero? */
- ispif->applied_intf_cmd[VFE0].intf_cmd = 0xFFFFFFFF;
- ispif->applied_intf_cmd[VFE0].intf_cmd1 = 0xFFFFFFFF;
- ispif->applied_intf_cmd[VFE1].intf_cmd = 0xFFFFFFFF;
- ispif->applied_intf_cmd[VFE1].intf_cmd1 = 0xFFFFFFFF;
- memset(ispif->sof_count, 0, sizeof(ispif->sof_count));
-
- ispif->csid_version = csid_version;
-
- if (ispif->csid_version >= CSID_VERSION_V30) {
- if (!ispif->clk_mux_mem || !ispif->clk_mux_io) {
- pr_err("%s csi clk mux mem %pK io %pK\n", __func__,
- ispif->clk_mux_mem, ispif->clk_mux_io);
- rc = -ENOMEM;
- return rc;
- }
- ispif->clk_mux_base = ioremap(ispif->clk_mux_mem->start,
- resource_size(ispif->clk_mux_mem));
- if (!ispif->clk_mux_base) {
- pr_err("%s: clk_mux_mem ioremap failed\n", __func__);
- rc = -ENOMEM;
- return rc;
- }
- }
-
- ispif->base = ioremap(ispif->mem->start,
- resource_size(ispif->mem));
- if (!ispif->base) {
- rc = -ENOMEM;
- pr_err("%s: nomem\n", __func__);
- goto end;
- }
- rc = request_irq(ispif->irq->start, msm_io_ispif_irq,
- IRQF_TRIGGER_RISING, "ispif", ispif);
- if (rc) {
- pr_err("%s: request_irq error = %d\n", __func__, rc);
- goto error_irq;
- }
-
- rc = msm_ispif_clk_ahb_enable(ispif, 1);
- if (rc) {
- pr_err("%s: ahb_clk enable failed", __func__);
- goto error_ahb;
- }
-
- msm_ispif_reset_hw(ispif);
-
- rc = msm_ispif_reset(ispif);
- if (rc == 0) {
- ispif->ispif_state = ISPIF_POWER_UP;
- CDBG("%s: power up done\n", __func__);
- goto end;
- }
-
-error_ahb:
- free_irq(ispif->irq->start, ispif);
-error_irq:
- iounmap(ispif->base);
-
-end:
- return rc;
-}
-
-static void msm_ispif_release(struct ispif_device *ispif)
-{
- BUG_ON(!ispif);
-
- if (!ispif->base) {
- pr_err("%s: ispif base is NULL\n", __func__);
- return;
- }
-
- if (ispif->ispif_state != ISPIF_POWER_UP) {
- pr_err("%s: ispif invalid state %d\n", __func__,
- ispif->ispif_state);
- return;
- }
-
- /* make sure no streaming going on */
- msm_ispif_reset(ispif);
-
- msm_ispif_clk_ahb_enable(ispif, 0);
-
- free_irq(ispif->irq->start, ispif);
-
- iounmap(ispif->base);
-
- iounmap(ispif->clk_mux_base);
-
- ispif->ispif_state = ISPIF_POWER_DOWN;
-}
-
-static long msm_ispif_cmd(struct v4l2_subdev *sd, void *arg)
-{
- long rc = 0;
- struct ispif_cfg_data *pcdata = (struct ispif_cfg_data *)arg;
- struct ispif_device *ispif =
- (struct ispif_device *)v4l2_get_subdevdata(sd);
-
- BUG_ON(!sd);
- BUG_ON(!pcdata);
-
- mutex_lock(&ispif->mutex);
- switch (pcdata->cfg_type) {
- case ISPIF_ENABLE_REG_DUMP:
- ispif->enb_dump_reg = pcdata->reg_dump; /* save dump config */
- break;
- case ISPIF_INIT:
- rc = msm_ispif_init(ispif, pcdata->csid_version);
- msm_ispif_io_dump_reg(ispif);
- break;
- case ISPIF_CFG:
- rc = msm_ispif_config(ispif, &pcdata->params);
- msm_ispif_io_dump_reg(ispif);
- break;
- case ISPIF_START_FRAME_BOUNDARY:
- rc = msm_ispif_start_frame_boundary(ispif, &pcdata->params);
- msm_ispif_io_dump_reg(ispif);
- break;
- case ISPIF_RESTART_FRAME_BOUNDARY:
- rc = msm_ispif_restart_frame_boundary(ispif, &pcdata->params);
- msm_ispif_io_dump_reg(ispif);
- break;
-
- case ISPIF_STOP_FRAME_BOUNDARY:
- rc = msm_ispif_stop_frame_boundary(ispif, &pcdata->params);
- msm_ispif_io_dump_reg(ispif);
- break;
- case ISPIF_STOP_IMMEDIATELY:
- rc = msm_ispif_stop_immediately(ispif, &pcdata->params);
- msm_ispif_io_dump_reg(ispif);
- break;
- case ISPIF_RELEASE:
- msm_ispif_release(ispif);
- break;
- case ISPIF_SET_VFE_INFO:
- rc = msm_ispif_set_vfe_info(ispif, &pcdata->vfe_info);
- break;
- default:
- pr_err("%s: invalid cfg_type\n", __func__);
- rc = -EINVAL;
- break;
- }
- mutex_unlock(&ispif->mutex);
- return rc;
-}
-static struct v4l2_file_operations msm_ispif_v4l2_subdev_fops;
-
-static long msm_ispif_subdev_ioctl(struct v4l2_subdev *sd,
- unsigned int cmd, void *arg)
-{
- struct ispif_device *ispif =
- (struct ispif_device *)v4l2_get_subdevdata(sd);
-
- switch (cmd) {
- case VIDIOC_MSM_ISPIF_CFG:
- return msm_ispif_cmd(sd, arg);
- case MSM_SD_NOTIFY_FREEZE: {
- ispif->ispif_sof_debug = 0;
- return 0;
- }
- case MSM_SD_SHUTDOWN: {
- struct ispif_device *ispif =
- (struct ispif_device *)v4l2_get_subdevdata(sd);
- if (ispif && ispif->base) {
- mutex_lock(&ispif->mutex);
- msm_ispif_release(ispif);
- mutex_unlock(&ispif->mutex);
- }
- return 0;
- }
- default:
- pr_err_ratelimited("%s: invalid cmd 0x%x received\n",
- __func__, cmd);
- return -ENOIOCTLCMD;
- }
-}
-
-static long msm_ispif_subdev_do_ioctl(
- struct file *file, unsigned int cmd, void *arg)
-{
- struct video_device *vdev = video_devdata(file);
- struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
-
- return msm_ispif_subdev_ioctl(sd, cmd, arg);
-}
-
-static long msm_ispif_subdev_fops_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- return video_usercopy(file, cmd, arg, msm_ispif_subdev_do_ioctl);
-}
-
-static int ispif_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
- struct ispif_device *ispif = v4l2_get_subdevdata(sd);
-
- mutex_lock(&ispif->mutex);
- /* mem remap is done in init when the clock is on */
- ispif->open_cnt++;
- mutex_unlock(&ispif->mutex);
- return 0;
-}
-
-static int ispif_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
- int rc = 0;
- struct ispif_device *ispif = v4l2_get_subdevdata(sd);
-
- if (!ispif) {
- pr_err("%s: invalid input\n", __func__);
- return -EINVAL;
- }
-
- mutex_lock(&ispif->mutex);
- if (ispif->open_cnt == 0) {
- pr_err("%s: Invalid close\n", __func__);
- rc = -ENODEV;
- goto end;
- }
- ispif->open_cnt--;
- if (ispif->open_cnt == 0)
- msm_ispif_release(ispif);
-end:
- mutex_unlock(&ispif->mutex);
- return rc;
-}
-
-static struct v4l2_subdev_core_ops msm_ispif_subdev_core_ops = {
- /* .g_chip_ident = &msm_ispif_subdev_g_chip_ident, */
- .ioctl = &msm_ispif_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_ispif_subdev_ops = {
- .core = &msm_ispif_subdev_core_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_ispif_internal_ops = {
- .open = ispif_open_node,
- .close = ispif_close_node,
-};
-
-static int ispif_probe(struct platform_device *pdev)
-{
- int rc;
- struct ispif_device *ispif;
-
- ispif = kzalloc(sizeof(struct ispif_device), GFP_KERNEL);
- if (!ispif)
- return -ENOMEM;
-
- if (pdev->dev.of_node) {
- of_property_read_u32((&pdev->dev)->of_node,
- "cell-index", &pdev->id);
- rc = of_property_read_u32((&pdev->dev)->of_node,
- "qcom,num-isps", &ispif->hw_num_isps);
- if (rc)
- /* backward compatibility */
- ispif->hw_num_isps = 1;
- /* not an error condition */
- rc = 0;
- }
-
- mutex_init(&ispif->mutex);
- ispif->mem = platform_get_resource_byname(pdev,
- IORESOURCE_MEM, "ispif");
- if (!ispif->mem) {
- pr_err("%s: no mem resource?\n", __func__);
- rc = -ENODEV;
- goto error;
- }
- ispif->irq = platform_get_resource_byname(pdev,
- IORESOURCE_IRQ, "ispif");
- if (!ispif->irq) {
- pr_err("%s: no irq resource?\n", __func__);
- rc = -ENODEV;
- goto error;
- }
- ispif->io = request_mem_region(ispif->mem->start,
- resource_size(ispif->mem), pdev->name);
- if (!ispif->io) {
- pr_err("%s: no valid mem region\n", __func__);
- rc = -EBUSY;
- goto error;
- }
- ispif->clk_mux_mem = platform_get_resource_byname(pdev,
- IORESOURCE_MEM, "csi_clk_mux");
- if (ispif->clk_mux_mem) {
- ispif->clk_mux_io = request_mem_region(
- ispif->clk_mux_mem->start,
- resource_size(ispif->clk_mux_mem),
- ispif->clk_mux_mem->name);
- if (!ispif->clk_mux_io)
- pr_err("%s: no valid csi_mux region\n", __func__);
- }
-
- v4l2_subdev_init(&ispif->msm_sd.sd, &msm_ispif_subdev_ops);
- ispif->msm_sd.sd.internal_ops = &msm_ispif_internal_ops;
- ispif->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-
- snprintf(ispif->msm_sd.sd.name,
- ARRAY_SIZE(ispif->msm_sd.sd.name), MSM_ISPIF_DRV_NAME);
- v4l2_set_subdevdata(&ispif->msm_sd.sd, ispif);
-
- platform_set_drvdata(pdev, &ispif->msm_sd.sd);
-
- media_entity_init(&ispif->msm_sd.sd.entity, 0, NULL, 0);
- ispif->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
- ispif->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_ISPIF;
- ispif->msm_sd.sd.entity.name = pdev->name;
- ispif->msm_sd.close_seq = MSM_SD_CLOSE_1ST_CATEGORY | 0x1;
- rc = msm_sd_register(&ispif->msm_sd);
- if (rc) {
- pr_err("%s: msm_sd_register error = %d\n", __func__, rc);
- goto error;
- }
- msm_ispif_v4l2_subdev_fops.owner = v4l2_subdev_fops.owner;
- msm_ispif_v4l2_subdev_fops.open = v4l2_subdev_fops.open;
- msm_ispif_v4l2_subdev_fops.unlocked_ioctl = msm_ispif_subdev_fops_ioctl;
- msm_ispif_v4l2_subdev_fops.release = v4l2_subdev_fops.release;
- msm_ispif_v4l2_subdev_fops.poll = v4l2_subdev_fops.poll;
-#ifdef CONFIG_COMPAT
- msm_ispif_v4l2_subdev_fops.compat_ioctl32 = msm_ispif_subdev_fops_ioctl;
-#endif
- ispif->msm_sd.sd.devnode->fops = &msm_ispif_v4l2_subdev_fops;
- ispif->pdev = pdev;
- ispif->ispif_state = ISPIF_POWER_DOWN;
- ispif->open_cnt = 0;
- return 0;
-
-error:
- mutex_destroy(&ispif->mutex);
- kfree(ispif);
- return rc;
-}
-
-static const struct of_device_id msm_ispif_dt_match[] = {
- {.compatible = "qcom,ispif"},
- {}
-};
-
-MODULE_DEVICE_TABLE(of, msm_ispif_dt_match);
-
-static struct platform_driver ispif_driver = {
- .probe = ispif_probe,
- .driver = {
- .name = MSM_ISPIF_DRV_NAME,
- .owner = THIS_MODULE,
- .of_match_table = msm_ispif_dt_match,
- },
-};
-
-static int __init msm_ispif_init_module(void)
-{
- return platform_driver_register(&ispif_driver);
-}
-
-static void __exit msm_ispif_exit_module(void)
-{
- platform_driver_unregister(&ispif_driver);
-}
-
-module_init(msm_ispif_init_module);
-module_exit(msm_ispif_exit_module);
-MODULE_DESCRIPTION("MSM ISP Interface driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_32.h b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_32.h
deleted file mode 100644
index f2c0851f18f8..000000000000
--- a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_32.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (c) 2013-2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef MSM_ISPIF_H
-#define MSM_ISPIF_H
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-#include <media/msmb_ispif.h>
-#include "msm_sd.h"
-
-#define ISPIF_CLK_INFO_MAX 24
-
-struct ispif_irq_status {
- uint32_t ispifIrqStatus0;
- uint32_t ispifIrqStatus1;
- uint32_t ispifIrqStatus2;
-};
-
-enum msm_ispif_state_t {
- ISPIF_POWER_UP,
- ISPIF_POWER_DOWN,
-};
-struct ispif_sof_count {
- uint32_t sof_cnt[INTF_MAX];
-};
-
-struct ispif_intf_cmd {
- uint32_t intf_cmd;
- uint32_t intf_cmd1;
-};
-
-struct ispif_device {
- struct platform_device *pdev;
- struct msm_sd_subdev msm_sd;
- struct resource *mem;
- struct resource *clk_mux_mem;
- struct resource *irq;
- struct resource *io;
- struct resource *clk_mux_io;
- void __iomem *base;
- void __iomem *clk_mux_base;
- struct mutex mutex;
- uint8_t start_ack_pending;
- uint32_t csid_version;
- int enb_dump_reg;
- uint32_t open_cnt;
- struct ispif_sof_count sof_count[VFE_MAX];
- struct ispif_intf_cmd applied_intf_cmd[VFE_MAX];
- enum msm_ispif_state_t ispif_state;
- struct msm_ispif_vfe_info vfe_info;
- struct clk *ahb_clk[ISPIF_CLK_INFO_MAX];
- struct completion reset_complete[VFE_MAX];
- uint32_t hw_num_isps;
- uint32_t num_ahb_clk;
- uint32_t clk_idx;
- uint32_t ispif_sof_debug;
-};
-#endif
diff --git a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v1.h b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v1.h
index 49d7d0f7624e..d488ca618537 100644
--- a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v1.h
+++ b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v1.h
@@ -87,12 +87,6 @@
#define MISC_LOGIC_RST_STB BIT(1)
#define STROBED_RST_EN BIT(0)
-#define VFE_PIX_INTF_SEL_3D 0x3
-#define PIX_OUTPUT_0_MISR_RST_STB BIT(16)
-#define L_R_SOF_MISMATCH_ERR_IRQ BIT(16)
-#define L_R_EOF_MISMATCH_ERR_IRQ BIT(17)
-#define L_R_SOL_MISMATCH_ERR_IRQ BIT(18)
-
#define ISPIF_RST_CMD_MASK 0xFE1C77FF
#define ISPIF_RST_CMD_1_MASK 0xFFFFFFFF /* undefined */
diff --git a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v2.h b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v2.h
index 9abf55efc46c..8ae61dc2d4f6 100644
--- a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v2.h
+++ b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v2.h
@@ -22,7 +22,6 @@
#define ISPIF_VFE(m) ((m) * 0x200)
#define ISPIF_VFE_m_CTRL_0(m) (0x200 + ISPIF_VFE(m))
-#define ISPIF_VFE_m_CTRL_1(m) (0x204 + ISPIF_VFE(m))
#define ISPIF_VFE_m_IRQ_MASK_0(m) (0x208 + ISPIF_VFE(m))
#define ISPIF_VFE_m_IRQ_MASK_1(m) (0x20C + ISPIF_VFE(m))
#define ISPIF_VFE_m_IRQ_MASK_2(m) (0x210 + ISPIF_VFE(m))
@@ -72,12 +71,6 @@
#define MISC_LOGIC_RST_STB BIT(1)
#define STROBED_RST_EN BIT(0)
-#define VFE_PIX_INTF_SEL_3D 0x3
-#define PIX_OUTPUT_0_MISR_RST_STB BIT(16)
-#define L_R_SOF_MISMATCH_ERR_IRQ BIT(16)
-#define L_R_EOF_MISMATCH_ERR_IRQ BIT(17)
-#define L_R_SOL_MISMATCH_ERR_IRQ BIT(18)
-
#define ISPIF_RST_CMD_MASK 0xFE0F1FFF
#define ISPIF_RST_CMD_1_MASK 0xFC0F1FF9
@@ -85,7 +78,6 @@
#define ISPIF_RST_CMD_1_MASK_RESTART 0x00001FF9
#define PIX_INTF_0_OVERFLOW_IRQ BIT(12)
-#define PIX_INTF_1_OVERFLOW_IRQ BIT(12)
#define RAW_INTF_0_OVERFLOW_IRQ BIT(25)
#define RAW_INTF_1_OVERFLOW_IRQ BIT(25)
#define RAW_INTF_2_OVERFLOW_IRQ BIT(12)
diff --git a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v3.h b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v3.h
index b18c177572e4..a5c0ad1b5dce 100644
--- a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v3.h
+++ b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif_hwreg_v3.h
@@ -74,12 +74,6 @@
#define MISC_LOGIC_RST_STB BIT(1)
#define STROBED_RST_EN BIT(0)
-#define VFE_PIX_INTF_SEL_3D 0x3
-#define PIX_OUTPUT_0_MISR_RST_STB BIT(16)
-#define L_R_SOF_MISMATCH_ERR_IRQ BIT(16)
-#define L_R_EOF_MISMATCH_ERR_IRQ BIT(17)
-#define L_R_SOL_MISMATCH_ERR_IRQ BIT(18)
-
#define ISPIF_RST_CMD_MASK 0xFE7F1FFF
#define ISPIF_RST_CMD_1_MASK 0xFC7F1FF9
@@ -87,7 +81,6 @@
#define ISPIF_RST_CMD_1_MASK_RESTART 0x7F1FF9
#define PIX_INTF_0_OVERFLOW_IRQ BIT(12)
-#define PIX_INTF_1_OVERFLOW_IRQ BIT(12)
#define RAW_INTF_0_OVERFLOW_IRQ BIT(25)
#define RAW_INTF_1_OVERFLOW_IRQ BIT(25)
#define RAW_INTF_2_OVERFLOW_IRQ BIT(12)
diff --git a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c
index 821833d53905..e40869d41a5d 100644
--- a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c
+++ b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, 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
@@ -903,45 +903,26 @@ int msm_jpeg_hw_exec_cmds(struct msm_jpeg_hw_cmd *hw_cmd_p, uint32_t m_cmds,
void msm_jpeg_io_dump(void *base, int size)
{
- char line_str[128];
+ char line_str[128], *p_str;
void __iomem *addr = (void __iomem *)base;
int i;
u32 *p = (u32 *) addr;
- size_t offset = 0;
- size_t used = 0;
- size_t min_range = 0;
- size_t sizeof_line_str = sizeof(line_str);
u32 data;
JPEG_DBG_HIGH("%s:%d] %pK %d", __func__, __LINE__, addr, size);
line_str[0] = '\0';
+ p_str = line_str;
for (i = 0; i < size/4; i++) {
if (i % 4 == 0) {
- used = snprintf(line_str + offset,
- sizeof_line_str - offset, "%pK ", p);
- if ((used < min_range) ||
- (offset + used >= sizeof_line_str)) {
- JPEG_PR_ERR("%s\n", line_str);
- offset = 0;
- line_str[0] = '\0';
- } else {
- offset += used;
- }
+ snprintf(p_str, 12, "%08lx: ", (unsigned long)p);
+ p_str += 10;
}
data = msm_camera_io_r(p++);
- used = snprintf(line_str + offset,
- sizeof_line_str - offset, "%08x ", data);
- if ((used < min_range) ||
- (offset + used >= sizeof_line_str)) {
- JPEG_PR_ERR("%s\n", line_str);
- offset = 0;
- line_str[0] = '\0';
- } else {
- offset += used;
- }
+ snprintf(p_str, 12, "%08x ", data);
+ p_str += 9;
if ((i + 1) % 4 == 0) {
JPEG_DBG_HIGH("%s\n", line_str);
line_str[0] = '\0';
- offset = 0;
+ p_str = line_str;
}
}
if (line_str[0] != '\0')
diff --git a/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c b/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c
index ebae1501118e..b379f7718515 100644
--- a/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c
+++ b/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2016, 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
@@ -17,6 +17,8 @@
#include <linux/ion.h>
#include <linux/msm_ion.h>
#include <linux/delay.h>
+#include <linux/uaccess.h>
+#include <linux/compat.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-event.h>
#include <media/videobuf2-core.h>
@@ -70,18 +72,31 @@ static struct msm_jpegdma_format formats[] = {
.planes[1] = JPEGDMA_PLANE_TYPE_CBCR,
},
{
- .name = "YUV 4:2:0 planar, YCbCr",
- .fourcc = V4L2_PIX_FMT_YUV420,
+ .name = "YVU 4:2:0 planar, YCrCb",
+ .fourcc = V4L2_PIX_FMT_YVU420,
.depth = 12,
.num_planes = 3,
- .colplane_h = 2,
- .colplane_v = 2,
+ .colplane_h = 1,
+ .colplane_v = 4,
.h_align = 2,
.v_align = 2,
.planes[0] = JPEGDMA_PLANE_TYPE_Y,
.planes[1] = JPEGDMA_PLANE_TYPE_CR,
.planes[2] = JPEGDMA_PLANE_TYPE_CB,
},
+ {
+ .name = "YUV 4:2:0 planar, YCbCr",
+ .fourcc = V4L2_PIX_FMT_YUV420,
+ .depth = 12,
+ .num_planes = 3,
+ .colplane_h = 1,
+ .colplane_v = 4,
+ .h_align = 2,
+ .v_align = 2,
+ .planes[0] = JPEGDMA_PLANE_TYPE_Y,
+ .planes[1] = JPEGDMA_PLANE_TYPE_CB,
+ .planes[2] = JPEGDMA_PLANE_TYPE_CR,
+ },
};
/*
@@ -112,6 +127,21 @@ static inline void msm_jpegdma_schedule_next_config(struct jpegdma_ctx *ctx)
}
/*
+ * msm_jpegdma_cast_long_to_buff_ptr - Cast long to buffer pointer.
+ * @vaddr: vaddr as long
+ * @buff_ptr_head: buffer pointer head
+ */
+static inline void msm_jpegdma_cast_long_to_buff_ptr(unsigned long vaddr,
+ struct msm_jpeg_dma_buff **buff_ptr_head)
+{
+#ifdef CONFIG_COMPAT
+ *buff_ptr_head = compat_ptr(vaddr);
+#else
+ *buff_ptr_head = (struct msm_jpeg_dma_buff *) vaddr;
+#endif
+}
+
+/*
* msm_jpegdma_get_format_idx - Get jpeg dma format lookup index.
* @ctx: Pointer to dma ctx.
* @f: v4l2 format.
@@ -196,7 +226,8 @@ static void msm_jpegdma_align_format(struct v4l2_format *f, int format_idx)
if (formats[format_idx].num_planes > 1)
for (i = 1; i < formats[format_idx].num_planes; i++)
size_image += (f->fmt.pix.bytesperline *
- (f->fmt.pix.height / formats[format_idx].colplane_v));
+ (f->fmt.pix.height /
+ formats[format_idx].colplane_v));
f->fmt.pix.sizeimage = size_image;
f->fmt.pix.field = V4L2_FIELD_NONE;
@@ -250,6 +281,9 @@ static int msm_jpegdma_update_hw_config(struct jpegdma_ctx *ctx)
size.fps = ctx->timeperframe.denominator /
ctx->timeperframe.numerator;
+ size.in_offset = ctx->in_offset;
+ size.out_offset = ctx->out_offset;
+
size.format = formats[ctx->format_idx];
msm_jpegdma_fill_size_from_ctx(ctx, &size);
@@ -362,7 +396,9 @@ static void msm_jpegdma_stop_streaming(struct vb2_queue *q)
dev_err(ctx->jdma_device->dev, "Ctx wait timeout\n");
ret = -ETIME;
}
- msm_jpegdma_hw_put(ctx->jdma_device);
+
+ if (ctx->jdma_device->ref_count > 0)
+ msm_jpegdma_hw_put(ctx->jdma_device);
}
/* Videobuf2 queue callbacks. */
@@ -385,13 +421,31 @@ static void *msm_jpegdma_get_userptr(void *alloc_ctx,
{
struct msm_jpegdma_device *dma = alloc_ctx;
struct msm_jpegdma_buf_handle *buf;
+ struct msm_jpeg_dma_buff __user *up_buff;
+ struct msm_jpeg_dma_buff kp_buff;
int ret;
+ msm_jpegdma_cast_long_to_buff_ptr(vaddr, &up_buff);
+
+ if (!access_ok(VERIFY_READ, up_buff,
+ sizeof(struct msm_jpeg_dma_buff)) ||
+ get_user(kp_buff.fd, &up_buff->fd)) {
+ dev_err(dma->dev, "Error getting user data\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
+ if (!access_ok(VERIFY_WRITE, up_buff,
+ sizeof(struct msm_jpeg_dma_buff)) ||
+ put_user(kp_buff.fd, &up_buff->fd)) {
+ dev_err(dma->dev, "Error putting user data\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
return ERR_PTR(-ENOMEM);
- ret = msm_jpegdma_hw_map_buffer(dma, vaddr, buf);
+ ret = msm_jpegdma_hw_map_buffer(dma, kp_buff.fd, buf);
if (ret < 0 || buf->size < size)
goto error;
@@ -438,7 +492,7 @@ static int msm_jpegdma_queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->drv_priv = ctx;
src_vq->mem_ops = &msm_jpegdma_vb2_mem_ops;
src_vq->ops = &msm_jpegdma_vb2_q_ops;
- src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
+ src_vq->buf_struct_size = sizeof(struct vb2_buffer);
src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(src_vq);
@@ -452,7 +506,7 @@ static int msm_jpegdma_queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->drv_priv = ctx;
dst_vq->mem_ops = &msm_jpegdma_vb2_mem_ops;
dst_vq->ops = &msm_jpegdma_vb2_q_ops;
- dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
+ dst_vq->buf_struct_size = sizeof(struct vb2_buffer);
dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
ret = vb2_queue_init(dst_vq);
@@ -528,7 +582,9 @@ static int msm_jpegdma_release(struct file *file)
struct jpegdma_ctx *ctx = msm_jpegdma_ctx_from_fh(file->private_data);
/* release all the resources */
- msm_jpegdma_hw_put(ctx->jdma_device);
+ if (ctx->jdma_device->ref_count > 0)
+ msm_jpegdma_hw_put(ctx->jdma_device);
+
atomic_set(&ctx->active, 0);
complete_all(&ctx->completion);
v4l2_m2m_ctx_release(ctx->m2m_ctx);
@@ -774,16 +830,50 @@ static int msm_jpegdma_qbuf(struct file *file, void *fh,
struct v4l2_buffer *buf)
{
struct jpegdma_ctx *ctx = msm_jpegdma_ctx_from_fh(fh);
+ struct msm_jpeg_dma_buff __user *up_buff;
+ struct msm_jpeg_dma_buff kp_buff;
int ret;
+ msm_jpegdma_cast_long_to_buff_ptr(buf->m.userptr, &up_buff);
mutex_lock(&ctx->lock);
+ if (!access_ok(VERIFY_READ, up_buff,
+ sizeof(struct msm_jpeg_dma_buff)) ||
+ get_user(kp_buff.fd, &up_buff->fd) ||
+ get_user(kp_buff.offset, &up_buff->offset)) {
+ dev_err(ctx->jdma_device->dev, "Error getting user data\n");
+ mutex_unlock(&ctx->lock);
+ return -EFAULT;
+ }
+
+ if (!access_ok(VERIFY_WRITE, up_buff,
+ sizeof(struct msm_jpeg_dma_buff)) ||
+ put_user(kp_buff.fd, &up_buff->fd) ||
+ put_user(kp_buff.offset, &up_buff->offset)) {
+ dev_err(ctx->jdma_device->dev, "Error putting user data\n");
+ mutex_unlock(&ctx->lock);
+ return -EFAULT;
+ }
+
+ switch (buf->type) {
+ case V4L2_BUF_TYPE_VIDEO_OUTPUT:
+ ctx->in_offset = kp_buff.offset;
+ dev_dbg(ctx->jdma_device->dev, "input buf offset %d\n",
+ ctx->in_offset);
+ break;
+ case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+ ctx->out_offset = kp_buff.offset;
+ dev_dbg(ctx->jdma_device->dev, "output buf offset %d\n",
+ ctx->out_offset);
+ break;
+ }
+
+ if (atomic_read(&ctx->active))
+ ret = msm_jpegdma_update_hw_config(ctx);
ret = v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
if (ret < 0)
dev_err(ctx->jdma_device->dev, "QBuf fail\n");
-
mutex_unlock(&ctx->lock);
-
return ret;
}
@@ -816,14 +906,10 @@ static int msm_jpegdma_streamon(struct file *file,
if (!msm_jpegdma_config_ok(ctx))
return -EINVAL;
- mutex_lock(&ctx->lock);
-
ret = v4l2_m2m_streamon(file, ctx->m2m_ctx, buf_type);
if (ret < 0)
dev_err(ctx->jdma_device->dev, "Stream on fail\n");
- mutex_unlock(&ctx->lock);
-
return ret;
}
@@ -955,13 +1041,10 @@ static int msm_jpegdma_s_crop(struct file *file, void *fh,
return -EINVAL;
mutex_lock(&ctx->lock);
-
ctx->crop = crop->c;
if (atomic_read(&ctx->active))
ret = msm_jpegdma_update_hw_config(ctx);
-
mutex_unlock(&ctx->lock);
-
return ret;
}
@@ -1004,7 +1087,7 @@ static int msm_jpegdma_s_parm(struct file *file, void *fh,
return -EINVAL;
if (!a->parm.output.timeperframe.numerator ||
- !a->parm.output.timeperframe.denominator)
+ !a->parm.output.timeperframe.denominator)
return -EINVAL;
/* Frame rate is not supported during streaming */
@@ -1138,6 +1221,7 @@ void msm_jpegdma_isr_processing_done(struct msm_jpegdma_device *dma)
struct jpegdma_ctx *ctx;
mutex_lock(&dma->lock);
+
ctx = v4l2_m2m_get_curr_priv(dma->m2m_dev);
if (ctx) {
mutex_lock(&ctx->lock);
diff --git a/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.h b/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.h
index adb8b94f098c..98ae6977d896 100644
--- a/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.h
+++ b/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.h
@@ -22,7 +22,7 @@
/* Max number of clocks defined in device tree */
#define MSM_JPEGDMA_MAX_CLK 10
/* Core clock index */
-#define MSM_JPEGDMA_CORE_CLK 0
+#define MSM_JPEGDMA_CORE_CLK "core_clk"
/* Max number of regulators defined in device tree */
#define MSM_JPEGDMA_MAX_REGULATOR_NUM 3
/* Max number of planes supported */
@@ -109,6 +109,8 @@ struct msm_jpegdma_size_config {
struct msm_jpegdma_size out_size;
struct msm_jpegdma_format format;
unsigned int fps;
+ unsigned int in_offset;
+ unsigned int out_offset;
};
/*
@@ -262,6 +264,8 @@ struct jpegdma_ctx {
struct v4l2_format format_out;
struct v4l2_rect crop;
struct v4l2_fract timeperframe;
+ unsigned int in_offset;
+ unsigned int out_offset;
unsigned int config_idx;
struct msm_jpegdma_plane_config plane_config[MSM_JPEGDMA_MAX_CONFIGS];
diff --git a/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_hw.c b/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_hw.c
index f3ceaad21bf5..a1b814b5f475 100644
--- a/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_hw.c
+++ b/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_hw.c
@@ -166,6 +166,23 @@ static int msm_jpegdma_hw_get_num_pipes(struct msm_jpegdma_device *dma)
}
/*
+ * msm_jpegdma_hw_get_clock_index - Get clock index by name
+ * @dma: Pointer to dma device.
+ * @clk_name: clock name.
+ */
+int msm_jpegdma_hw_get_clock_index(struct msm_jpegdma_device *dma,
+ const char *clk_name)
+{
+ uint32_t i = 0;
+
+ for (i = 0; i < dma->num_clk; i++) {
+ if (!strcmp(clk_name, dma->jpeg_clk_info[i].clk_name))
+ return i;
+ }
+ return -EINVAL;
+}
+
+/*
* msm_jpegdma_hw_reset - Reset jpeg dma core.
* @dma: Pointer to dma device.
*/
@@ -782,12 +799,20 @@ static int msm_jpegdma_hw_calc_speed(struct msm_jpegdma_device *dma,
u64 height;
u64 real_clock;
u64 calc_rate;
+ int core_clk_idx;
width = size->in_size.width + size->in_size.left;
height = size->in_size.height + size->in_size.top;
calc_rate = (width * height * size->format.depth * size->fps) / 16;
- real_clock = clk_round_rate(dma->clk[MSM_JPEGDMA_CORE_CLK], calc_rate);
+ core_clk_idx = msm_jpegdma_hw_get_clock_index(dma,
+ MSM_JPEGDMA_CORE_CLK);
+ if (core_clk_idx < 0) {
+ dev_err(dma->dev, "Can get clock index for dma %s\n",
+ MSM_JPEGDMA_CORE_CLK);
+ }
+
+ real_clock = clk_round_rate(dma->clk[core_clk_idx], calc_rate);
if (real_clock < 0) {
dev_err(dma->dev, "Can not round core clock\n");
return -EINVAL;
@@ -817,6 +842,7 @@ static int msm_jpegdma_hw_set_speed(struct msm_jpegdma_device *dma,
struct msm_jpegdma_speed new_sp;
struct msm_jpegdma_size_config new_size;
int ret;
+ int core_clk_idx;
if (dma->active_clock_rate >= speed->core_clock)
return 0;
@@ -830,7 +856,14 @@ static int msm_jpegdma_hw_set_speed(struct msm_jpegdma_device *dma,
return -EINVAL;
}
- ret = clk_set_rate(dma->clk[MSM_JPEGDMA_CORE_CLK], new_sp.core_clock);
+ core_clk_idx = msm_jpegdma_hw_get_clock_index(dma,
+ MSM_JPEGDMA_CORE_CLK);
+ if (core_clk_idx < 0) {
+ dev_err(dma->dev, "Can get clock index for dma %s\n",
+ MSM_JPEGDMA_CORE_CLK);
+ }
+
+ ret = clk_set_rate(dma->clk[core_clk_idx], new_sp.core_clock);
if (ret < 0) {
dev_err(dma->dev, "Fail Core clock rate %d\n", ret);
return -EINVAL;
@@ -1022,13 +1055,20 @@ int msm_jpegdma_hw_set_config(struct msm_jpegdma_device *dma,
plane_cfg->plane[0].active_pipes = dma->hw_num_pipes;
plane_cfg->plane[0].type = size_cfg->format.planes[0];
msm_jpegdma_hw_calc_config(size_cfg, &plane_cfg->plane[0]);
+
+ in_offset = size_cfg->in_offset;
+ out_offset = size_cfg->out_offset;
+
+ msm_jpegdma_hw_add_plane_offset(&plane_cfg->plane[0],
+ in_offset, out_offset);
+
if (size_cfg->format.num_planes == 1)
return 0;
- in_offset = size_cfg->in_size.scanline *
- size_cfg->in_size.stride;
- out_offset = size_cfg->out_size.scanline *
- size_cfg->out_size.stride;
+ in_offset += (size_cfg->in_size.scanline *
+ size_cfg->in_size.stride);
+ out_offset += (size_cfg->out_size.scanline *
+ size_cfg->out_size.stride);
memset(&plane_size, 0x00, sizeof(plane_size));
for (i = 1; i < size_cfg->format.num_planes; i++) {
@@ -1336,7 +1376,8 @@ int msm_jpegdma_hw_get_qos(struct msm_jpegdma_device *dma)
unsigned int cnt;
const void *property;
- property = of_get_property(dma->dev->of_node, "qcom,qos-regs", &cnt);
+ property = of_get_property(dma->dev->of_node,
+ "qcom,qos-reg-settings", &cnt);
if (!property || !cnt) {
dev_dbg(dma->dev, "Missing qos settings\n");
return 0;
@@ -1347,9 +1388,9 @@ int msm_jpegdma_hw_get_qos(struct msm_jpegdma_device *dma)
if (!dma->qos_regs)
return -ENOMEM;
- for (i = 0; i < cnt; i++) {
+ for (i = 0; i < cnt; i = i + 2) {
ret = of_property_read_u32_index(dma->dev->of_node,
- "qcom,qos-regs", i,
+ "qcom,qos-reg-settings", i,
&dma->qos_regs[i].reg);
if (ret < 0) {
dev_err(dma->dev, "can not read qos reg %d\n", i);
@@ -1357,7 +1398,7 @@ int msm_jpegdma_hw_get_qos(struct msm_jpegdma_device *dma)
}
ret = of_property_read_u32_index(dma->dev->of_node,
- "qcom,qos-settings", i,
+ "qcom,qos-reg-settings", i + 1,
&dma->qos_regs[i].val);
if (ret < 0) {
dev_err(dma->dev, "can not read qos setting %d\n", i);
@@ -1397,7 +1438,8 @@ int msm_jpegdma_hw_get_vbif(struct msm_jpegdma_device *dma)
unsigned int cnt;
const void *property;
- property = of_get_property(dma->dev->of_node, "qcom,vbif-regs", &cnt);
+ property = of_get_property(dma->dev->of_node, "qcom,vbif-reg-settings",
+ &cnt);
if (!property || !cnt) {
dev_dbg(dma->dev, "Missing vbif settings\n");
return 0;
@@ -1408,9 +1450,9 @@ int msm_jpegdma_hw_get_vbif(struct msm_jpegdma_device *dma)
if (!dma->vbif_regs)
return -ENOMEM;
- for (i = 0; i < cnt; i++) {
+ for (i = 0; i < cnt; i = i + 2) {
ret = of_property_read_u32_index(dma->dev->of_node,
- "qcom,vbif-regs", i,
+ "qcom,vbif-reg-settings", i,
&dma->vbif_regs[i].reg);
if (ret < 0) {
dev_err(dma->dev, "can not read vbif reg %d\n", i);
@@ -1418,7 +1460,7 @@ int msm_jpegdma_hw_get_vbif(struct msm_jpegdma_device *dma)
}
ret = of_property_read_u32_index(dma->dev->of_node,
- "qcom,vbif-settings", i,
+ "qcom,vbif-reg-settings", i + 1,
&dma->vbif_regs[i].val);
if (ret < 0) {
dev_err(dma->dev, "can not read vbif setting %d\n", i);
@@ -1459,8 +1501,8 @@ int msm_jpegdma_hw_get_prefetch(struct msm_jpegdma_device *dma)
unsigned int cnt;
const void *property;
- property = of_get_property(dma->dev->of_node, "qcom,prefetch-regs",
- &cnt);
+ property = of_get_property(dma->dev->of_node,
+ "qcom,prefetch-reg-settings", &cnt);
if (!property || !cnt) {
dev_dbg(dma->dev, "Missing prefetch settings\n");
return 0;
@@ -1472,9 +1514,9 @@ int msm_jpegdma_hw_get_prefetch(struct msm_jpegdma_device *dma)
if (!dma->prefetch_regs)
return -ENOMEM;
- for (i = 0; i < cnt; i++) {
+ for (i = 0; i < cnt; i = i + 2) {
ret = of_property_read_u32_index(dma->dev->of_node,
- "qcom,prefetch-regs", i,
+ "qcom,prefetch-reg-settings", i,
&dma->prefetch_regs[i].reg);
if (ret < 0) {
dev_err(dma->dev, "can not read prefetch reg %d\n", i);
@@ -1482,7 +1524,7 @@ int msm_jpegdma_hw_get_prefetch(struct msm_jpegdma_device *dma)
}
ret = of_property_read_u32_index(dma->dev->of_node,
- "qcom,prefetch-settings", i,
+ "qcom,prefetch-reg-settings", i + 1,
&dma->prefetch_regs[i].val);
if (ret < 0) {
dev_err(dma->dev, "can not read prefetch setting %d\n",
@@ -1598,6 +1640,9 @@ int msm_jpegdma_hw_get(struct msm_jpegdma_device *dma)
msm_jpegdma_hw_config_qos(dma);
msm_jpegdma_hw_config_vbif(dma);
+ msm_camera_register_threaded_irq(dma->pdev, dma->irq, NULL,
+ msm_jpegdma_hw_irq, IRQF_ONESHOT | IRQF_TRIGGER_RISING,
+ dev_name(&dma->pdev->dev), dma);
msm_jpegdma_hw_enable_irq(dma);
ret = msm_jpegdma_hw_reset(dma);
@@ -1710,6 +1755,7 @@ error:
static void msm_jpegdma_hw_detach_iommu(struct msm_jpegdma_device *dma)
{
mutex_lock(&dma->lock);
+
if (dma->iommu_attached_cnt == 0) {
dev_err(dma->dev, "There is no attached device\n");
mutex_unlock(&dma->lock);
@@ -1720,6 +1766,7 @@ static void msm_jpegdma_hw_detach_iommu(struct msm_jpegdma_device *dma)
cam_smmu_ops(dma->iommu_hndl, CAM_SMMU_DETACH);
cam_smmu_destroy_handle(dma->iommu_hndl);
}
+
mutex_unlock(&dma->lock);
}
diff --git a/drivers/media/platform/msm/camera_v2/msm.c b/drivers/media/platform/msm/camera_v2/msm.c
index 00f6797b683e..ffe1748d7a50 100644
--- a/drivers/media/platform/msm/camera_v2/msm.c
+++ b/drivers/media/platform/msm/camera_v2/msm.c
@@ -32,10 +32,9 @@
#include "cam_hw_ops.h"
#include <media/msmb_generic_buf_mgr.h>
+
static struct v4l2_device *msm_v4l2_dev;
static struct list_head ordered_sd_list;
-static struct mutex ordered_sd_mtx;
-static struct mutex v4l2_event_mtx;
static struct pm_qos_request msm_v4l2_pm_qos_request;
@@ -148,7 +147,7 @@ typedef int (*msm_queue_find_func)(void *d1, void *d2);
#define msm_queue_find(queue, type, member, func, data) ({\
unsigned long flags; \
struct msm_queue_head *__q = (queue); \
- type *node = NULL; \
+ type *node = 0; \
typeof(node) __ret = NULL; \
msm_queue_find_func __f = (func); \
spin_lock_irqsave(&__q->lock, flags); \
@@ -278,50 +277,22 @@ void msm_delete_stream(unsigned int session_id, unsigned int stream_id)
struct msm_session *session = NULL;
struct msm_stream *stream = NULL;
unsigned long flags;
- int try_count = 0;
session = msm_queue_find(msm_session_q, struct msm_session,
list, __msm_queue_find_session, &session_id);
-
if (!session)
return;
- while (1) {
- unsigned long wl_flags;
-
- if (try_count > 5) {
- pr_err("%s : not able to delete stream %d\n",
- __func__, __LINE__);
- break;
- }
-
- write_lock_irqsave(&session->stream_rwlock, wl_flags);
- try_count++;
- stream = msm_queue_find(&session->stream_q, struct msm_stream,
- list, __msm_queue_find_stream, &stream_id);
-
- if (!stream) {
- write_unlock_irqrestore(&session->stream_rwlock,
- wl_flags);
- return;
- }
-
- if (msm_vb2_get_stream_state(stream) != 1) {
- write_unlock_irqrestore(&session->stream_rwlock,
- wl_flags);
- continue;
- }
-
- spin_lock_irqsave(&(session->stream_q.lock), flags);
- list_del_init(&stream->list);
- session->stream_q.len--;
- kfree(stream);
- stream = NULL;
- spin_unlock_irqrestore(&(session->stream_q.lock), flags);
- write_unlock_irqrestore(&session->stream_rwlock, wl_flags);
- break;
- }
-
+ stream = msm_queue_find(&session->stream_q, struct msm_stream,
+ list, __msm_queue_find_stream, &stream_id);
+ if (!stream)
+ return;
+ spin_lock_irqsave(&(session->stream_q.lock), flags);
+ list_del_init(&stream->list);
+ session->stream_q.len--;
+ kfree(stream);
+ stream = NULL;
+ spin_unlock_irqrestore(&(session->stream_q.lock), flags);
}
EXPORT_SYMBOL(msm_delete_stream);
@@ -388,11 +359,6 @@ static void msm_add_sd_in_position(struct msm_sd_subdev *msm_subdev,
struct msm_sd_subdev *temp_sd;
list_for_each_entry(temp_sd, sd_list, list) {
- if (temp_sd == msm_subdev) {
- pr_err("%s :Fail to add the same sd %d\n",
- __func__, __LINE__);
- return;
- }
if (msm_subdev->close_seq < temp_sd->close_seq) {
list_add_tail(&msm_subdev->list, &temp_sd->list);
return;
@@ -409,9 +375,7 @@ int msm_sd_register(struct msm_sd_subdev *msm_subdev)
if (WARN_ON(!msm_v4l2_dev) || WARN_ON(!msm_v4l2_dev->dev))
return -EIO;
- mutex_lock(&ordered_sd_mtx);
msm_add_sd_in_position(msm_subdev, &ordered_sd_list);
- mutex_unlock(&ordered_sd_mtx);
return __msm_sd_register_subdev(&msm_subdev->sd);
}
EXPORT_SYMBOL(msm_sd_register);
@@ -478,7 +442,6 @@ int msm_create_session(unsigned int session_id, struct video_device *vdev)
mutex_init(&session->lock);
mutex_init(&session->lock_q);
mutex_init(&session->close_lock);
- rwlock_init(&session->stream_rwlock);
return 0;
}
EXPORT_SYMBOL(msm_create_session);
@@ -729,19 +692,6 @@ static long msm_private_ioctl(struct file *file, void *fh,
return 0;
}
- if (!event_data)
- return -EINVAL;
-
- switch (cmd) {
- case MSM_CAM_V4L2_IOCTL_NOTIFY:
- case MSM_CAM_V4L2_IOCTL_CMD_ACK:
- case MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG:
- case MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR:
- break;
- default:
- return -ENOTTY;
- }
-
memset(&event, 0, sizeof(struct v4l2_event));
session_id = event_data->session_id;
stream_id = event_data->stream_id;
@@ -810,13 +760,11 @@ static long msm_private_ioctl(struct file *file, void *fh,
__func__);
}
- mutex_lock(&ordered_sd_mtx);
if (!list_empty(&msm_v4l2_dev->subdevs)) {
list_for_each_entry(msm_sd, &ordered_sd_list, list)
__msm_sd_notify_freeze_subdevs(msm_sd,
event_data->status);
}
- mutex_unlock(&ordered_sd_mtx);
}
break;
@@ -838,25 +786,13 @@ static long msm_private_ioctl(struct file *file, void *fh,
static int msm_unsubscribe_event(struct v4l2_fh *fh,
const struct v4l2_event_subscription *sub)
{
- int rc;
-
- mutex_lock(&v4l2_event_mtx);
- rc = v4l2_event_unsubscribe(fh, sub);
- mutex_unlock(&v4l2_event_mtx);
-
- return rc;
+ return v4l2_event_unsubscribe(fh, sub);
}
static int msm_subscribe_event(struct v4l2_fh *fh,
const struct v4l2_event_subscription *sub)
{
- int rc;
-
- mutex_lock(&v4l2_event_mtx);
- rc = v4l2_event_subscribe(fh, sub, 5, NULL);
- mutex_unlock(&v4l2_event_mtx);
-
- return rc;
+ return v4l2_event_subscribe(fh, sub, 5, NULL);
}
static const struct v4l2_ioctl_ops g_msm_ioctl_ops = {
@@ -1013,11 +949,9 @@ static int msm_close(struct file *filep)
struct msm_sd_subdev *msm_sd;
/*stop all hardware blocks immediately*/
- mutex_lock(&ordered_sd_mtx);
if (!list_empty(&msm_v4l2_dev->subdevs))
list_for_each_entry(msm_sd, &ordered_sd_list, list)
__msm_sd_close_subdevs(msm_sd, &sd_close);
- mutex_unlock(&ordered_sd_mtx);
/* remove msm_v4l2_pm_qos_request */
msm_pm_qos_remove_request();
@@ -1096,25 +1030,17 @@ static struct v4l2_file_operations msm_fops = {
#endif
};
-struct msm_session *msm_get_session(unsigned int session_id)
+struct msm_stream *msm_get_stream(unsigned int session_id,
+ unsigned int stream_id)
{
struct msm_session *session;
+ struct msm_stream *stream;
session = msm_queue_find(msm_session_q, struct msm_session,
list, __msm_queue_find_session, &session_id);
if (!session)
return ERR_PTR(-EINVAL);
- return session;
-}
-EXPORT_SYMBOL(msm_get_session);
-
-
-struct msm_stream *msm_get_stream(struct msm_session *session,
- unsigned int stream_id)
-{
- struct msm_stream *stream;
-
stream = msm_queue_find(&session->stream_q, struct msm_stream,
list, __msm_queue_find_stream, &stream_id);
@@ -1171,34 +1097,6 @@ struct msm_stream *msm_get_stream_from_vb2q(struct vb2_queue *q)
}
EXPORT_SYMBOL(msm_get_stream_from_vb2q);
-struct msm_session *msm_get_session_from_vb2q(struct vb2_queue *q)
-{
- struct msm_session *session;
- struct msm_stream *stream;
- unsigned long flags1;
- unsigned long flags2;
-
- spin_lock_irqsave(&msm_session_q->lock, flags1);
- list_for_each_entry(session, &(msm_session_q->list), list) {
- spin_lock_irqsave(&(session->stream_q.lock), flags2);
- list_for_each_entry(
- stream, &(session->stream_q.list), list) {
- if (stream->vb2_q == q) {
- spin_unlock_irqrestore
- (&(session->stream_q.lock), flags2);
- spin_unlock_irqrestore
- (&msm_session_q->lock, flags1);
- return session;
- }
- }
- spin_unlock_irqrestore(&(session->stream_q.lock), flags2);
- }
- spin_unlock_irqrestore(&msm_session_q->lock, flags1);
- return NULL;
-}
-EXPORT_SYMBOL(msm_get_session_from_vb2q);
-
-
#ifdef CONFIG_COMPAT
long msm_copy_camera_private_ioctl_args(unsigned long arg,
struct msm_camera_private_ioctl_arg *k_ioctl,
@@ -1274,7 +1172,7 @@ static ssize_t write_logsync(struct file *file, const char __user *buf,
uint64_t seq_num = 0;
int ret;
- if (copy_from_user(lbuf, buf, sizeof(lbuf) - 1))
+ if (copy_from_user(lbuf, buf, sizeof(lbuf)))
return -EFAULT;
ret = sscanf(lbuf, "%llu", &seq_num);
@@ -1335,8 +1233,8 @@ static int msm_probe(struct platform_device *pdev)
if (WARN_ON(rc < 0))
goto media_fail;
- if (WARN_ON((rc == media_entity_init(&pvdev->vdev->entity,
- 0, NULL, 0)) < 0))
+ rc = media_entity_init(&pvdev->vdev->entity, 0, NULL, 0);
+ if (WARN_ON(rc < 0))
goto entity_fail;
pvdev->vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
@@ -1377,8 +1275,6 @@ static int msm_probe(struct platform_device *pdev)
msm_init_queue(msm_session_q);
spin_lock_init(&msm_eventq_lock);
spin_lock_init(&msm_pid_lock);
- mutex_init(&ordered_sd_mtx);
- mutex_init(&v4l2_event_mtx);
INIT_LIST_HEAD(&ordered_sd_list);
#ifdef CONFIG_DEBUG_CAMERA
diff --git a/drivers/media/platform/msm/camera_v2/msm.h b/drivers/media/platform/msm/camera_v2/msm.h
index 79d70a0fc1c4..2b3576b8edd2 100644
--- a/drivers/media/platform/msm/camera_v2/msm.h
+++ b/drivers/media/platform/msm/camera_v2/msm.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, 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
@@ -29,11 +29,11 @@
#include <media/videobuf2-dma-contig.h>
#include <media/msmb_camera.h>
-/* Setting MAX timeout to 10seconds considering
+/* Setting MAX timeout to 6.5seconds considering
* backend will operate @ .6fps in certain usecases
* like Long exposure usecase and isp needs max of 2 frames
* to stop the hardware which will be around 3 seconds*/
-#define MSM_POST_EVT_TIMEOUT 10000
+#define MSM_POST_EVT_TIMEOUT 6500
#define MSM_POST_EVT_NOTIMEOUT 0xFFFFFFFF
#define MSM_CAMERA_STREAM_CNT_BITS 32
@@ -45,7 +45,6 @@ extern bool is_daemon_status;
struct msm_video_device {
struct video_device *vdev;
atomic_t opened;
- struct mutex video_drvdata_mutex;
};
struct msm_queue_head {
@@ -111,7 +110,6 @@ struct msm_session {
struct mutex lock;
struct mutex lock_q;
struct mutex close_lock;
- rwlock_t stream_rwlock;
};
static inline bool msm_is_daemon_present(void)
@@ -129,13 +127,11 @@ int msm_create_stream(unsigned int session_id,
void msm_delete_stream(unsigned int session_id, unsigned int stream_id);
int msm_create_command_ack_q(unsigned int session_id, unsigned int stream_id);
void msm_delete_command_ack_q(unsigned int session_id, unsigned int stream_id);
-struct msm_session *msm_get_session(unsigned int session_id);
-struct msm_stream *msm_get_stream(struct msm_session *session,
+struct msm_stream *msm_get_stream(unsigned int session_id,
unsigned int stream_id);
struct vb2_queue *msm_get_stream_vb2q(unsigned int session_id,
unsigned int stream_id);
struct msm_stream *msm_get_stream_from_vb2q(struct vb2_queue *q);
-struct msm_session *msm_get_session_from_vb2q(struct vb2_queue *q);
struct msm_session *msm_session_find(unsigned int session_id);
#ifdef CONFIG_COMPAT
long msm_copy_camera_private_ioctl_args(unsigned long arg,
diff --git a/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c b/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
index 620b5046e8a3..ebf7184b899b 100644
--- a/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
+++ b/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
@@ -297,12 +297,11 @@ static void msm_buf_mngr_sd_shutdown(struct msm_buf_mngr_device *dev,
if (!list_empty(&dev->buf_qhead)) {
list_for_each_entry_safe(bufs,
save, &dev->buf_qhead, entry) {
+ pr_info("%s: Delete invalid bufs =%pK, session_id=%u, bufs->ses_id=%d, str_id=%d, idx=%d\n",
+ __func__, (void *)bufs, session->session,
+ bufs->session_id, bufs->stream_id,
+ bufs->index);
if (session->session == bufs->session_id) {
- pr_info("%s: Delete invalid bufs =%pK, session_id=%u, bufs->ses_id=%d, str_id=%d, idx=%d\n",
- __func__, (void *)bufs,
- session->session,
- bufs->session_id, bufs->stream_id,
- bufs->index);
list_del_init(&bufs->entry);
kfree(bufs);
}
diff --git a/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c b/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c
index 69d3a2ba1cba..8bea9efc292b 100644
--- a/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c
+++ b/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, 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
@@ -44,25 +44,16 @@ static int msm_vb2_queue_setup(struct vb2_queue *q,
int msm_vb2_buf_init(struct vb2_buffer *vb)
{
struct msm_stream *stream;
- struct msm_session *session;
struct msm_vb2_buffer *msm_vb2_buf;
- unsigned long rl_flags;
-
- session = msm_get_session_from_vb2q(vb->vb2_queue);
- if (IS_ERR_OR_NULL(session))
- return -EINVAL;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
stream = msm_get_stream_from_vb2q(vb->vb2_queue);
if (!stream) {
pr_err("%s: Couldn't find stream\n", __func__);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return -EINVAL;
}
msm_vb2_buf = container_of(vb, struct msm_vb2_buffer, vb2_buf);
msm_vb2_buf->in_freeq = 0;
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
+
return 0;
}
@@ -70,8 +61,7 @@ static void msm_vb2_buf_queue(struct vb2_buffer *vb)
{
struct msm_vb2_buffer *msm_vb2;
struct msm_stream *stream;
- struct msm_session *session;
- unsigned long flags, rl_flags;
+ unsigned long flags;
msm_vb2 = container_of(vb, struct msm_vb2_buffer, vb2_buf);
@@ -80,50 +70,34 @@ static void msm_vb2_buf_queue(struct vb2_buffer *vb)
return;
}
- session = msm_get_session_from_vb2q(vb->vb2_queue);
- if (IS_ERR_OR_NULL(session))
- return;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
-
stream = msm_get_stream_from_vb2q(vb->vb2_queue);
if (!stream) {
pr_err("%s:%d] NULL stream", __func__, __LINE__);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return;
}
spin_lock_irqsave(&stream->stream_lock, flags);
list_add_tail(&msm_vb2->list, &stream->queued_list);
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
}
static void msm_vb2_buf_finish(struct vb2_buffer *vb)
{
struct msm_vb2_buffer *msm_vb2;
struct msm_stream *stream;
- struct msm_session *session;
- unsigned long flags, rl_flags;
+ unsigned long flags;
struct msm_vb2_buffer *msm_vb2_entry, *temp;
msm_vb2 = container_of(vb, struct msm_vb2_buffer, vb2_buf);
if (!msm_vb2) {
pr_err("%s:%d] vb2_buf NULL", __func__, __LINE__);
- return;
+ return;
}
- session = msm_get_session_from_vb2q(vb->vb2_queue);
- if (IS_ERR_OR_NULL(session))
- return;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
-
stream = msm_get_stream_from_vb2q(vb->vb2_queue);
if (!stream) {
pr_err("%s:%d] NULL stream", __func__, __LINE__);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return;
}
@@ -136,7 +110,6 @@ static void msm_vb2_buf_finish(struct vb2_buffer *vb)
}
}
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return;
}
@@ -144,20 +117,12 @@ static void msm_vb2_stop_stream(struct vb2_queue *q)
{
struct msm_vb2_buffer *msm_vb2, *temp;
struct msm_stream *stream;
- struct msm_session *session;
- unsigned long flags, rl_flags;
+ unsigned long flags;
struct vb2_buffer *vb2_buf;
- session = msm_get_session_from_vb2q(q);
- if (IS_ERR_OR_NULL(session))
- return;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
-
stream = msm_get_stream_from_vb2q(q);
if (!stream) {
pr_err_ratelimited("%s:%d] NULL stream", __func__, __LINE__);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return;
}
@@ -176,28 +141,8 @@ static void msm_vb2_stop_stream(struct vb2_queue *q)
msm_vb2->in_freeq = 0;
}
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
}
-int msm_vb2_get_stream_state(struct msm_stream *stream)
-{
- struct msm_vb2_buffer *msm_vb2, *temp;
- unsigned long flags;
- int rc = 1;
-
- spin_lock_irqsave(&stream->stream_lock, flags);
- list_for_each_entry_safe(msm_vb2, temp, &(stream->queued_list), list) {
- if (msm_vb2->in_freeq != 0) {
- rc = 0;
- break;
- }
- }
- spin_unlock_irqrestore(&stream->stream_lock, flags);
- return rc;
-}
-EXPORT_SYMBOL(msm_vb2_get_stream_state);
-
-
static struct vb2_ops msm_vb2_get_q_op = {
.queue_setup = msm_vb2_queue_setup,
.buf_init = msm_vb2_buf_init,
@@ -251,21 +196,12 @@ static struct vb2_buffer *msm_vb2_get_buf(int session_id,
{
struct msm_stream *stream;
struct vb2_buffer *vb2_buf = NULL;
- struct msm_session *session;
struct msm_vb2_buffer *msm_vb2 = NULL;
- unsigned long flags, rl_flags;
-
- session = msm_get_session(session_id);
- if (IS_ERR_OR_NULL(session))
- return NULL;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
+ unsigned long flags;
- stream = msm_get_stream(session, stream_id);
- if (IS_ERR_OR_NULL(stream)) {
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
+ stream = msm_get_stream(session_id, stream_id);
+ if (IS_ERR_OR_NULL(stream))
return NULL;
- }
spin_lock_irqsave(&stream->stream_lock, flags);
@@ -289,7 +225,6 @@ static struct vb2_buffer *msm_vb2_get_buf(int session_id,
vb2_buf = NULL;
end:
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return vb2_buf;
}
@@ -298,22 +233,12 @@ static struct vb2_buffer *msm_vb2_get_buf_by_idx(int session_id,
{
struct msm_stream *stream;
struct vb2_buffer *vb2_buf = NULL;
- struct msm_session *session;
struct msm_vb2_buffer *msm_vb2 = NULL;
- unsigned long flags, rl_flags;
-
- session = msm_get_session(session_id);
- if (IS_ERR_OR_NULL(session))
- return NULL;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
-
- stream = msm_get_stream(session, stream_id);
+ unsigned long flags;
- if (IS_ERR_OR_NULL(stream)) {
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
+ stream = msm_get_stream(session_id, stream_id);
+ if (IS_ERR_OR_NULL(stream))
return NULL;
- }
spin_lock_irqsave(&stream->stream_lock, flags);
@@ -335,7 +260,6 @@ static struct vb2_buffer *msm_vb2_get_buf_by_idx(int session_id,
vb2_buf = NULL;
end:
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return vb2_buf;
}
@@ -343,23 +267,13 @@ static int msm_vb2_put_buf(struct vb2_buffer *vb, int session_id,
unsigned int stream_id)
{
struct msm_stream *stream;
- struct msm_session *session;
struct msm_vb2_buffer *msm_vb2;
struct vb2_buffer *vb2_buf = NULL;
int rc = 0;
- unsigned long flags, rl_flags;
-
- session = msm_get_session(session_id);
- if (IS_ERR_OR_NULL(session))
- return -EINVAL;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
-
- stream = msm_get_stream(session, stream_id);
- if (IS_ERR_OR_NULL(stream)) {
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
+ unsigned long flags;
+ stream = msm_get_stream(session_id, stream_id);
+ if (IS_ERR_OR_NULL(stream))
return -EINVAL;
- }
spin_lock_irqsave(&stream->stream_lock, flags);
if (vb) {
@@ -372,8 +286,6 @@ static int msm_vb2_put_buf(struct vb2_buffer *vb, int session_id,
pr_err("VB buffer is INVALID vb=%pK, ses_id=%d, str_id=%d\n",
vb, session_id, stream_id);
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock,
- rl_flags);
return -EINVAL;
}
msm_vb2 =
@@ -389,7 +301,6 @@ static int msm_vb2_put_buf(struct vb2_buffer *vb, int session_id,
rc = -EINVAL;
}
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return rc;
}
@@ -397,25 +308,15 @@ static int msm_vb2_buf_done(struct vb2_buffer *vb, int session_id,
unsigned int stream_id, uint32_t sequence,
struct timeval *ts, uint32_t reserved)
{
- unsigned long flags, rl_flags;
+ unsigned long flags;
struct msm_vb2_buffer *msm_vb2;
struct msm_stream *stream;
struct vb2_buffer *vb2_buf = NULL;
- struct msm_session *session;
int rc = 0;
- session = msm_get_session(session_id);
- if (IS_ERR_OR_NULL(session))
+ stream = msm_get_stream(session_id, stream_id);
+ if (IS_ERR_OR_NULL(stream))
return -EINVAL;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
-
- stream = msm_get_stream(session, stream_id);
- if (IS_ERR_OR_NULL(stream)) {
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
- return -EINVAL;
- }
-
spin_lock_irqsave(&stream->stream_lock, flags);
if (vb) {
list_for_each_entry(msm_vb2, &(stream->queued_list), list) {
@@ -427,8 +328,6 @@ static int msm_vb2_buf_done(struct vb2_buffer *vb, int session_id,
pr_err("VB buffer is INVALID ses_id=%d, str_id=%d, vb=%pK\n",
session_id, stream_id, vb);
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock,
- rl_flags);
return -EINVAL;
}
msm_vb2 =
@@ -449,7 +348,6 @@ static int msm_vb2_buf_done(struct vb2_buffer *vb, int session_id,
rc = -EINVAL;
}
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return rc;
}
@@ -458,23 +356,14 @@ long msm_vb2_return_buf_by_idx(int session_id, unsigned int stream_id,
{
struct msm_stream *stream;
struct vb2_buffer *vb2_buf = NULL;
- struct msm_session *session;
struct msm_vb2_buffer *msm_vb2 = NULL;
- unsigned long flags, rl_flags;
+ unsigned long flags;
long rc = -EINVAL;
- session = msm_get_session(session_id);
- if (IS_ERR_OR_NULL(session))
+ stream = msm_get_stream(session_id, stream_id);
+ if (IS_ERR_OR_NULL(stream))
return rc;
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
-
- stream = msm_get_stream(session, stream_id);
- if (IS_ERR_OR_NULL(stream)) {
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
- return -EINVAL;
- }
-
spin_lock_irqsave(&stream->stream_lock, flags);
if (!stream->vb2_q) {
@@ -499,31 +388,20 @@ long msm_vb2_return_buf_by_idx(int session_id, unsigned int stream_id,
end:
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return rc;
}
EXPORT_SYMBOL(msm_vb2_return_buf_by_idx);
static int msm_vb2_flush_buf(int session_id, unsigned int stream_id)
{
- unsigned long flags, rl_flags;
+ unsigned long flags;
struct msm_vb2_buffer *msm_vb2;
struct msm_stream *stream;
struct vb2_buffer *vb2_buf = NULL;
- struct msm_session *session;
-
- session = msm_get_session(session_id);
- if (IS_ERR_OR_NULL(session))
- return -EINVAL;
-
- read_lock_irqsave(&session->stream_rwlock, rl_flags);
- stream = msm_get_stream(session, stream_id);
- if (IS_ERR_OR_NULL(stream)) {
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
+ stream = msm_get_stream(session_id, stream_id);
+ if (IS_ERR_OR_NULL(stream))
return -EINVAL;
- }
-
spin_lock_irqsave(&stream->stream_lock, flags);
list_for_each_entry(msm_vb2, &(stream->queued_list), list) {
vb2_buf = &(msm_vb2->vb2_buf);
@@ -532,7 +410,6 @@ static int msm_vb2_flush_buf(int session_id, unsigned int stream_id)
msm_vb2->in_freeq = 0;
}
spin_unlock_irqrestore(&stream->stream_lock, flags);
- read_unlock_irqrestore(&session->stream_rwlock, rl_flags);
return 0;
}
diff --git a/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.h b/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.h
index 1da89e057b84..066206c62f5f 100644
--- a/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.h
+++ b/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, 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
@@ -67,6 +67,5 @@ struct vb2_mem_ops *msm_vb2_get_q_mem_ops(void);
int msm_vb2_request_cb(struct msm_sd_req_vb2_q *req_sd);
long msm_vb2_return_buf_by_idx(int session_id, unsigned int stream_id,
uint32_t index);
-int msm_vb2_get_stream_state(struct msm_stream *stream);
#endif /*_MSM_VB_H */
diff --git a/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c b/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c
index 71cbc3cec43f..40397a3d739d 100644
--- a/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c
+++ b/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c
@@ -120,8 +120,6 @@ static void msm_cpp_set_micro_irq_mask(struct cpp_device *cpp_dev,
static void msm_cpp_flush_queue_and_release_buffer(struct cpp_device *cpp_dev,
int queue_len);
static int msm_cpp_dump_frame_cmd(struct msm_cpp_frame_info_t *frame_info);
-static int msm_cpp_dump_addr(struct cpp_device *cpp_dev,
- struct msm_cpp_frame_info_t *frame_info);
static int32_t msm_cpp_reset_vbif_and_load_fw(struct cpp_device *cpp_dev);
#if CONFIG_MSM_CPP_DBG
@@ -665,137 +663,6 @@ static int32_t msm_cpp_poll_rx_empty(void __iomem *cpp_base)
return rc;
}
-static int msm_cpp_dump_addr(struct cpp_device *cpp_dev,
- struct msm_cpp_frame_info_t *frame_info)
-{
- int32_t s_base, p_base;
- uint32_t rd_off, wr0_off, wr1_off, wr2_off, wr3_off;
- uint32_t wr0_mdata_off, wr1_mdata_off, wr2_mdata_off, wr3_mdata_off;
- uint32_t rd_ref_off, wr_ref_off;
- uint32_t s_size, p_size;
- uint8_t tnr_enabled, ubwc_enabled, cds_en;
- int32_t i = 0;
- uint32_t *cpp_frame_msg;
-
- cpp_frame_msg = frame_info->cpp_cmd_msg;
-
- /* Update stripe/plane size and base offsets */
- s_base = cpp_dev->payload_params.stripe_base;
- s_size = cpp_dev->payload_params.stripe_size;
- p_base = cpp_dev->payload_params.plane_base;
- p_size = cpp_dev->payload_params.plane_size;
-
- /* Fetch engine Offset */
- rd_off = cpp_dev->payload_params.rd_pntr_off;
- /* Write engine offsets */
- wr0_off = cpp_dev->payload_params.wr_0_pntr_off;
- wr1_off = wr0_off + 1;
- wr2_off = wr1_off + 1;
- wr3_off = wr2_off + 1;
- /* Reference engine offsets */
- rd_ref_off = cpp_dev->payload_params.rd_ref_pntr_off;
- wr_ref_off = cpp_dev->payload_params.wr_ref_pntr_off;
- /* Meta data offsets */
- wr0_mdata_off =
- cpp_dev->payload_params.wr_0_meta_data_wr_pntr_off;
- wr1_mdata_off = (wr0_mdata_off + 1);
- wr2_mdata_off = (wr1_mdata_off + 1);
- wr3_mdata_off = (wr2_mdata_off + 1);
-
- tnr_enabled = ((frame_info->feature_mask & TNR_MASK) >> 2);
- ubwc_enabled = ((frame_info->feature_mask & UBWC_MASK) >> 5);
- cds_en = ((frame_info->feature_mask & CDS_MASK) >> 6);
-
- for (i = 0; i < frame_info->num_strips; i++) {
- pr_err("stripe %d: in %x, out1 %x out2 %x, out3 %x, out4 %x\n",
- i, cpp_frame_msg[s_base + rd_off + i * s_size],
- cpp_frame_msg[s_base + wr0_off + i * s_size],
- cpp_frame_msg[s_base + wr1_off + i * s_size],
- cpp_frame_msg[s_base + wr2_off + i * s_size],
- cpp_frame_msg[s_base + wr3_off + i * s_size]);
-
- if (tnr_enabled) {
- pr_err("stripe %d: read_ref %x, write_ref %x\n", i,
- cpp_frame_msg[s_base + rd_ref_off + i * s_size],
- cpp_frame_msg[s_base + wr_ref_off + i * s_size]
- );
- }
-
- if (cds_en) {
- pr_err("stripe %d:, dsdn_off %x\n", i,
- cpp_frame_msg[s_base + rd_ref_off + i * s_size]
- );
- }
-
- if (ubwc_enabled) {
- pr_err("stripe %d: metadata %x, %x, %x, %x\n", i,
- cpp_frame_msg[s_base + wr0_mdata_off +
- i * s_size],
- cpp_frame_msg[s_base + wr1_mdata_off +
- i * s_size],
- cpp_frame_msg[s_base + wr2_mdata_off +
- i * s_size],
- cpp_frame_msg[s_base + wr3_mdata_off +
- i * s_size]
- );
- }
-
- }
- return 0;
-}
-
-static void msm_cpp_iommu_fault_handler(struct iommu_domain *domain,
- struct device *dev, unsigned long iova, int flags, void *token)
-{
- struct cpp_device *cpp_dev = NULL;
- struct msm_cpp_frame_info_t *processed_frame[MAX_CPP_PROCESSING_FRAME];
- int32_t i = 0, queue_len = 0;
- struct msm_device_queue *queue = NULL;
- int32_t rc = 0;
-
- if (token) {
- cpp_dev = token;
- disable_irq(cpp_dev->irq->start);
- if (atomic_read(&cpp_timer.used)) {
- atomic_set(&cpp_timer.used, 0);
- del_timer_sync(&cpp_timer.cpp_timer);
- }
- mutex_lock(&cpp_dev->mutex);
- tasklet_kill(&cpp_dev->cpp_tasklet);
- rc = cpp_load_fw(cpp_dev, cpp_dev->fw_name_bin);
- if (rc < 0) {
- pr_err("load fw failure %d-retry\n", rc);
- rc = msm_cpp_reset_vbif_and_load_fw(cpp_dev);
- if (rc < 0) {
- msm_cpp_set_micro_irq_mask(cpp_dev, 1, 0x8);
- mutex_unlock(&cpp_dev->mutex);
- return;
- }
- }
- queue = &cpp_timer.data.cpp_dev->processing_q;
- queue_len = queue->len;
- if (!queue_len) {
- pr_err("%s:%d: Invalid queuelen\n", __func__, __LINE__);
- msm_cpp_set_micro_irq_mask(cpp_dev, 1, 0x8);
- mutex_unlock(&cpp_dev->mutex);
- return;
- }
- for (i = 0; i < queue_len; i++) {
- if (cpp_timer.data.processed_frame[i]) {
- processed_frame[i] =
- cpp_timer.data.processed_frame[i];
- pr_err("Fault on identity=0x%x, frame_id=%03d\n",
- processed_frame[i]->identity,
- processed_frame[i]->frame_id);
- msm_cpp_dump_addr(cpp_dev, processed_frame[i]);
- msm_cpp_dump_frame_cmd(processed_frame[i]);
- }
- }
- msm_cpp_flush_queue_and_release_buffer(cpp_dev, queue_len);
- msm_cpp_set_micro_irq_mask(cpp_dev, 1, 0x8);
- mutex_unlock(&cpp_dev->mutex);
- }
-}
static int cpp_init_mem(struct cpp_device *cpp_dev)
{
@@ -812,9 +679,6 @@ static int cpp_init_mem(struct cpp_device *cpp_dev)
return -ENODEV;
cpp_dev->iommu_hdl = iommu_hdl;
- cam_smmu_reg_client_page_fault_handler(
- cpp_dev->iommu_hdl,
- msm_cpp_iommu_fault_handler, cpp_dev);
return 0;
}
@@ -2468,29 +2332,9 @@ static int msm_cpp_cfg_frame(struct cpp_device *cpp_dev,
return -EINVAL;
}
- /* Stripe index starts at zero */
- if ((!new_frame->num_strips) ||
- (new_frame->first_stripe_index >= new_frame->num_strips) ||
- (new_frame->last_stripe_index >= new_frame->num_strips) ||
- (new_frame->first_stripe_index >
- new_frame->last_stripe_index)) {
- pr_err("Invalid frame message, #stripes=%d, stripe indices=[%d,%d]\n",
- new_frame->num_strips,
- new_frame->first_stripe_index,
- new_frame->last_stripe_index);
- return -EINVAL;
- }
-
- if (!stripe_size) {
- pr_err("Invalid frame message, invalid stripe_size (%d)!\n",
- stripe_size);
- return -EINVAL;
- }
-
- if ((stripe_base == UINT_MAX) ||
- (new_frame->num_strips >
- (UINT_MAX - 1 - stripe_base) / stripe_size)) {
- pr_err("Invalid frame message, num_strips %d is large\n",
+ if (stripe_base == UINT_MAX || new_frame->num_strips >
+ (UINT_MAX - 1 - stripe_base) / stripe_size) {
+ pr_err("Invalid frame message,num_strips %d is large\n",
new_frame->num_strips);
return -EINVAL;
}
@@ -2730,14 +2574,13 @@ static int msm_cpp_cfg(struct cpp_device *cpp_dev,
struct msm_cpp_frame_info_t *frame = NULL;
struct msm_cpp_frame_info_t k_frame_info;
int32_t rc = 0;
- uint32_t i = 0;
- uint32_t num_buff = sizeof(k_frame_info.output_buffer_info) /
- sizeof(struct msm_cpp_buffer_info_t);
-
+ int32_t i = 0;
+ int32_t num_buff = sizeof(k_frame_info.output_buffer_info)/
+ sizeof(struct msm_cpp_buffer_info_t);
if (copy_from_user(&k_frame_info,
(void __user *)ioctl_ptr->ioctl_ptr,
sizeof(k_frame_info)))
- return -EFAULT;
+ return -EFAULT;
frame = msm_cpp_get_frame(ioctl_ptr);
if (!frame) {
@@ -2882,15 +2725,13 @@ end:
return rc;
}
-static int msm_cpp_validate_ioctl_input(unsigned int cmd, void *arg,
+static int msm_cpp_validate_input(unsigned int cmd, void *arg,
struct msm_camera_v4l2_ioctl_t **ioctl_ptr)
{
switch (cmd) {
case MSM_SD_SHUTDOWN:
case MSM_SD_NOTIFY_FREEZE:
case MSM_SD_UNNOTIFY_FREEZE:
- case VIDIOC_MSM_CPP_IOMMU_ATTACH:
- case VIDIOC_MSM_CPP_IOMMU_DETACH:
break;
default: {
if (ioctl_ptr == NULL) {
@@ -2899,9 +2740,8 @@ static int msm_cpp_validate_ioctl_input(unsigned int cmd, void *arg,
}
*ioctl_ptr = arg;
- if (((*ioctl_ptr) == NULL) ||
- ((*ioctl_ptr)->ioctl_ptr == NULL) ||
- ((*ioctl_ptr)->len == 0)) {
+ if ((*ioctl_ptr == NULL) ||
+ (*ioctl_ptr)->ioctl_ptr == NULL) {
pr_err("Error invalid ioctl argument cmd %u", cmd);
return -EINVAL;
}
@@ -2933,7 +2773,7 @@ long msm_cpp_subdev_ioctl(struct v4l2_subdev *sd,
return -EINVAL;
}
- rc = msm_cpp_validate_ioctl_input(cmd, arg, &ioctl_ptr);
+ rc = msm_cpp_validate_input(cmd, arg, &ioctl_ptr);
if (rc != 0) {
pr_err("input validation failed\n");
return rc;
@@ -3426,7 +3266,7 @@ STREAM_BUFF_END:
(cpp_dev->stream_cnt == 0)) {
rc = cam_smmu_ops(cpp_dev->iommu_hdl, CAM_SMMU_DETACH);
if (rc < 0) {
- pr_err("%s:%dError iommu detach failed\n",
+ pr_err("%s:%dError iommu atach failed\n",
__func__, __LINE__);
rc = -EINVAL;
break;
@@ -3435,7 +3275,6 @@ STREAM_BUFF_END:
} else {
pr_err("%s:%d IOMMMU attach triggered in invalid state\n",
__func__, __LINE__);
- rc = -EINVAL;
}
break;
}
@@ -4068,8 +3907,7 @@ static long msm_cpp_subdev_fops_compat_ioctl(struct file *file,
default:
pr_err_ratelimited("%s: unsupported compat type :%x LOAD %lu\n",
__func__, cmd, VIDIOC_MSM_CPP_LOAD_FIRMWARE);
- mutex_unlock(&cpp_dev->mutex);
- return -EINVAL;
+ break;
}
mutex_unlock(&cpp_dev->mutex);
@@ -4100,7 +3938,7 @@ static long msm_cpp_subdev_fops_compat_ioctl(struct file *file,
default:
pr_err_ratelimited("%s: unsupported compat type :%d\n",
__func__, cmd);
- return -EINVAL;
+ break;
}
if (is_copytouser_req) {
@@ -4325,7 +4163,7 @@ static int cpp_probe(struct platform_device *pdev)
cpp_dev->state = CPP_STATE_BOOT;
rc = cpp_init_hardware(cpp_dev);
if (rc < 0)
- goto bus_de_init;
+ goto cpp_probe_init_error;
media_entity_init(&cpp_dev->msm_sd.sd.entity, 0, NULL, 0);
cpp_dev->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
@@ -4364,7 +4202,7 @@ static int cpp_probe(struct platform_device *pdev)
if (!cpp_dev->work) {
pr_err("no enough memory\n");
rc = -ENOMEM;
- goto bus_de_init;
+ goto cpp_probe_init_error;
}
INIT_WORK((struct work_struct *)cpp_dev->work, msm_cpp_do_timeout_work);
@@ -4384,12 +4222,6 @@ static int cpp_probe(struct platform_device *pdev)
else
CPP_DBG("FAILED.");
return rc;
-
-bus_de_init:
- if (cpp_dev->bus_master_flag)
- msm_cpp_deinit_bandwidth_mgr(cpp_dev);
- else
- msm_isp_deinit_bandwidth_mgr(ISP_CPP);
cpp_probe_init_error:
media_entity_cleanup(&cpp_dev->msm_sd.sd.entity);
msm_sd_unregister(&cpp_dev->msm_sd);
diff --git a/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c b/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c
index d7fb2449582c..f2f1dca81f18 100644
--- a/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c
+++ b/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015 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
@@ -1054,16 +1054,10 @@ static int vpe_reset(struct vpe_device *vpe_dev)
return rc;
}
-static int vpe_update_scale_coef(struct vpe_device *vpe_dev, uint32_t *p)
+static void vpe_update_scale_coef(struct vpe_device *vpe_dev, uint32_t *p)
{
uint32_t i, offset;
offset = *p;
-
- if (offset > VPE_SCALE_COEFF_MAX_N-VPE_SCALE_COEFF_NUM) {
- pr_err("%s: invalid offset %d passed in", __func__, offset);
- return -EINVAL;
- }
-
for (i = offset; i < (VPE_SCALE_COEFF_NUM + offset); i++) {
VPE_DBG("Setting scale table %d\n", i);
msm_camera_io_w(*(++p),
@@ -1071,8 +1065,6 @@ static int vpe_update_scale_coef(struct vpe_device *vpe_dev, uint32_t *p)
msm_camera_io_w(*(++p),
vpe_dev->base + VPE_SCALE_COEFF_MSBn(i));
}
-
- return 0;
}
static void vpe_input_plane_config(struct vpe_device *vpe_dev, uint32_t *p)
@@ -1110,16 +1102,13 @@ static void vpe_operation_config(struct vpe_device *vpe_dev, uint32_t *p)
*/
static void msm_vpe_transaction_setup(struct vpe_device *vpe_dev, void *data)
{
- int i, rc = 0;
+ int i;
void *iter = data;
vpe_mem_dump("vpe_transaction", data, VPE_TRANSACTION_SETUP_CONFIG_LEN);
for (i = 0; i < VPE_NUM_SCALER_TABLES; ++i) {
- rc = vpe_update_scale_coef(vpe_dev, (uint32_t *)iter);
- if (rc != 0)
- return;
-
+ vpe_update_scale_coef(vpe_dev, (uint32_t *)iter);
iter += VPE_SCALER_CONFIG_LEN;
}
vpe_input_plane_config(vpe_dev, (uint32_t *)iter);
diff --git a/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.h b/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.h
index 0c55ff70309e..f1869a2b9776 100644
--- a/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.h
+++ b/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 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
@@ -70,7 +70,6 @@
#define VPE_SCALE_COEFF_LSBn(n) (0x50400 + 8 * (n))
#define VPE_SCALE_COEFF_MSBn(n) (0x50404 + 8 * (n))
#define VPE_SCALE_COEFF_NUM 32
-#define VPE_SCALE_COEFF_MAX_N 127
/*********** end of register offset ********************/
diff --git a/drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c b/drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c
index 9b2f5f6ab1eb..c02d0d23f9d8 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2017, 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
@@ -60,11 +60,6 @@ static int32_t msm_actuator_piezo_set_default_focus(
struct msm_camera_i2c_reg_setting reg_setting;
CDBG("Enter\n");
- if (a_ctrl->i2c_reg_tbl == NULL) {
- pr_err("failed. i2c reg tabl is NULL");
- return -EFAULT;
- }
-
if (a_ctrl->curr_step_pos != 0) {
a_ctrl->i2c_tbl_index = 0;
a_ctrl->func_tbl->actuator_parse_i2c_params(a_ctrl,
@@ -549,11 +544,6 @@ static int32_t msm_actuator_piezo_move_focus(
return -EFAULT;
}
- if (a_ctrl->i2c_reg_tbl == NULL) {
- pr_err("failed. i2c reg tabl is NULL");
- return -EFAULT;
- }
-
if (dest_step_position > a_ctrl->total_steps) {
pr_err("Step pos greater than total steps = %d\n",
dest_step_position);
@@ -611,11 +601,7 @@ static int32_t msm_actuator_move_focus(
pr_err("Invalid direction = %d\n", dir);
return -EFAULT;
}
- if (a_ctrl->i2c_reg_tbl == NULL) {
- pr_err("failed. i2c reg tabl is NULL");
- return -EFAULT;
- }
- if (dest_step_pos > a_ctrl->total_steps) {
+ if (dest_step_pos >= a_ctrl->total_steps) {
pr_err("Step pos greater than total steps = %d\n",
dest_step_pos);
return -EFAULT;
@@ -649,8 +635,6 @@ static int32_t msm_actuator_move_focus(
a_ctrl->curr_step_pos, dest_step_pos, curr_lens_pos);
while (a_ctrl->curr_step_pos != dest_step_pos) {
- if (a_ctrl->curr_region_index >= a_ctrl->region_size)
- break;
step_boundary =
a_ctrl->region_params[a_ctrl->curr_region_index].
step_bound[dir];
@@ -1196,8 +1180,7 @@ static int32_t msm_actuator_set_position(
}
if (!a_ctrl || !a_ctrl->func_tbl ||
- !a_ctrl->func_tbl->actuator_parse_i2c_params ||
- !a_ctrl->i2c_reg_tbl) {
+ !a_ctrl->func_tbl->actuator_parse_i2c_params) {
pr_err("failed. NULL actuator pointers.");
return -EFAULT;
}
@@ -1370,13 +1353,13 @@ static int32_t msm_actuator_set_param(struct msm_actuator_ctrl_t *a_ctrl,
a_ctrl->region_size = set_info->af_tuning_params.region_size;
a_ctrl->pwd_step = set_info->af_tuning_params.pwd_step;
+ a_ctrl->total_steps = set_info->af_tuning_params.total_steps;
if (copy_from_user(&a_ctrl->region_params,
(void *)set_info->af_tuning_params.region_params,
- a_ctrl->region_size * sizeof(struct region_params_t))) {
- pr_err("Error copying region_params\n");
+ a_ctrl->region_size * sizeof(struct region_params_t)))
return -EFAULT;
- }
+
if (a_ctrl->act_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
cci_client = a_ctrl->i2c_client.cci_client;
cci_client->sid =
@@ -1406,7 +1389,6 @@ static int32_t msm_actuator_set_param(struct msm_actuator_ctrl_t *a_ctrl,
(a_ctrl->i2c_reg_tbl != NULL)) {
kfree(a_ctrl->i2c_reg_tbl);
}
-
a_ctrl->i2c_reg_tbl = NULL;
a_ctrl->i2c_reg_tbl =
kmalloc(sizeof(struct msm_camera_i2c_reg_array) *
@@ -1416,8 +1398,6 @@ static int32_t msm_actuator_set_param(struct msm_actuator_ctrl_t *a_ctrl,
return -ENOMEM;
}
- a_ctrl->total_steps = set_info->af_tuning_params.total_steps;
-
if (copy_from_user(&a_ctrl->reg_tbl,
(void *)set_info->actuator_params.reg_tbl_params,
a_ctrl->reg_tbl_size *
@@ -1843,10 +1823,6 @@ static long msm_actuator_subdev_do_ioctl(
parg = &actuator_data;
break;
}
- break;
- case VIDIOC_MSM_ACTUATOR_CFG:
- pr_err("%s: invalid cmd 0x%x received\n", __func__, cmd);
- return -EINVAL;
}
rc = msm_actuator_subdev_ioctl(sd, cmd, parg);
@@ -2082,16 +2058,15 @@ static int32_t msm_actuator_platform_probe(struct platform_device *pdev)
}
rc = msm_sensor_driver_get_gpio_data(&(msm_actuator_t->gconf),
(&pdev->dev)->of_node);
- if (-ENODEV == rc) {
- pr_notice("No valid actuator GPIOs data\n");
- } else if (rc < 0) {
- pr_err("Error Actuator GPIOs\n");
+ if (rc < 0) {
+ pr_err("%s: No/Error Actuator GPIOs\n", __func__);
} else {
msm_actuator_t->cam_pinctrl_status = 1;
rc = msm_camera_pinctrl_init(
&(msm_actuator_t->pinctrl_info), &(pdev->dev));
if (rc < 0) {
- pr_err("ERR: Error in reading actuator pinctrl\n");
+ pr_err("ERR:%s: Error in reading actuator pinctrl\n",
+ __func__);
msm_actuator_t->cam_pinctrl_status = 0;
}
}
@@ -2181,6 +2156,8 @@ static int __init msm_actuator_init_module(void)
int32_t rc = 0;
CDBG("Enter\n");
rc = platform_driver_register(&msm_actuator_platform_driver);
+ if (!rc)
+ return rc;
CDBG("%s:%d rc %d\n", __func__, __LINE__, rc);
return i2c_add_driver(&msm_actuator_i2c_driver);
diff --git a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
index abaf10aa243d..ac3f2636de65 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, 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
@@ -201,7 +201,6 @@ static int32_t msm_cci_validate_queue(struct cci_device *cci_dev,
enum cci_i2c_queue_t queue)
{
int32_t rc = 0;
- unsigned long flags;
uint32_t read_val = 0;
uint32_t reg_offset = master * 0x200 + queue * 0x100;
read_val = msm_camera_io_r_mb(cci_dev->base +
@@ -224,8 +223,6 @@ static int32_t msm_cci_validate_queue(struct cci_device *cci_dev,
CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR + reg_offset);
reg_val = 1 << ((master * 2) + queue);
CDBG("%s:%d CCI_QUEUE_START_ADDR\n", __func__, __LINE__);
- spin_lock_irqsave(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
atomic_set(&cci_dev->cci_master_info[master].
done_pending[queue], 1);
msm_camera_io_w_mb(reg_val, cci_dev->base +
@@ -233,8 +230,6 @@ static int32_t msm_cci_validate_queue(struct cci_device *cci_dev,
CDBG("%s line %d wait_for_completion_timeout\n",
__func__, __LINE__);
atomic_set(&cci_dev->cci_master_info[master].q_free[queue], 1);
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
rc = wait_for_completion_timeout(&cci_dev->
cci_master_info[master].report_q[queue], CCI_TIMEOUT);
if (rc <= 0) {
@@ -444,17 +439,10 @@ static int32_t msm_cci_wait_report_cmd(struct cci_device *cci_dev,
enum cci_i2c_master_t master,
enum cci_i2c_queue_t queue)
{
- unsigned long flags;
uint32_t reg_val = 1 << ((master * 2) + queue);
msm_cci_load_report_cmd(cci_dev, master, queue);
-
- spin_lock_irqsave(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
atomic_set(&cci_dev->cci_master_info[master].q_free[queue], 1);
atomic_set(&cci_dev->cci_master_info[master].done_pending[queue], 1);
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
-
msm_camera_io_w_mb(reg_val, cci_dev->base +
CCI_QUEUE_START_ADDR);
return msm_cci_wait(cci_dev, master, queue);
@@ -464,21 +452,12 @@ static void msm_cci_process_half_q(struct cci_device *cci_dev,
enum cci_i2c_master_t master,
enum cci_i2c_queue_t queue)
{
- unsigned long flags;
uint32_t reg_val = 1 << ((master * 2) + queue);
-
- spin_lock_irqsave(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
if (0 == atomic_read(&cci_dev->cci_master_info[master].q_free[queue])) {
msm_cci_load_report_cmd(cci_dev, master, queue);
atomic_set(&cci_dev->cci_master_info[master].q_free[queue], 1);
msm_camera_io_w_mb(reg_val, cci_dev->base +
CCI_QUEUE_START_ADDR);
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
- } else {
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
}
}
@@ -487,23 +466,15 @@ static int32_t msm_cci_process_full_q(struct cci_device *cci_dev,
enum cci_i2c_queue_t queue)
{
int32_t rc = 0;
- unsigned long flags;
-
- spin_lock_irqsave(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
if (1 == atomic_read(&cci_dev->cci_master_info[master].q_free[queue])) {
atomic_set(&cci_dev->cci_master_info[master].
done_pending[queue], 1);
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
rc = msm_cci_wait(cci_dev, master, queue);
if (rc < 0) {
pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
return rc;
}
} else {
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
rc = msm_cci_wait_report_cmd(cci_dev, master, queue);
if (rc < 0) {
pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
@@ -531,13 +502,8 @@ static int32_t msm_cci_transfer_end(struct cci_device *cci_dev,
enum cci_i2c_queue_t queue)
{
int32_t rc = 0;
- unsigned long flags;
- spin_lock_irqsave(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
if (0 == atomic_read(&cci_dev->cci_master_info[master].q_free[queue])) {
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
rc = msm_cci_lock_queue(cci_dev, master, queue, 0);
if (rc < 0) {
pr_err("%s failed line %d\n", __func__, __LINE__);
@@ -551,8 +517,6 @@ static int32_t msm_cci_transfer_end(struct cci_device *cci_dev,
} else {
atomic_set(&cci_dev->cci_master_info[master].
done_pending[queue], 1);
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
rc = msm_cci_wait(cci_dev, master, queue);
if (rc < 0) {
pr_err("%s: %d failed rc %d\n", __func__, __LINE__, rc);
@@ -607,7 +571,6 @@ static int32_t msm_cci_data_queue(struct cci_device *cci_dev,
uint32_t reg_offset;
uint32_t val = 0;
uint32_t max_queue_size, queue_size = 0;
- unsigned long flags;
if (i2c_cmd == NULL) {
pr_err("%s:%d Failed line\n", __func__,
@@ -651,11 +614,7 @@ static int32_t msm_cci_data_queue(struct cci_device *cci_dev,
msm_camera_io_w_mb(val, cci_dev->base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
reg_offset);
- spin_lock_irqsave(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
atomic_set(&cci_dev->cci_master_info[master].q_free[queue], 0);
- spin_unlock_irqrestore(&cci_dev->cci_master_info[master].
- lock_q[queue], flags);
max_queue_size = cci_dev->cci_i2c_queue_info[master][queue].
max_queue_size;
@@ -1330,10 +1289,6 @@ static int32_t msm_cci_init(struct v4l2_subdev *sd,
CDBG("%s:%d master %d\n", __func__, __LINE__, master);
if (master < MASTER_MAX && master >= 0) {
mutex_lock(&cci_dev->cci_master_info[master].mutex);
- mutex_lock(&cci_dev->cci_master_info[master].
- mutex_q[PRIORITY_QUEUE]);
- mutex_lock(&cci_dev->cci_master_info[master].
- mutex_q[SYNC_QUEUE]);
flush_workqueue(cci_dev->write_wq[master]);
/* Re-initialize the completion */
reinit_completion(&cci_dev->
@@ -1358,10 +1313,6 @@ static int32_t msm_cci_init(struct v4l2_subdev *sd,
if (rc <= 0)
pr_err("%s:%d wait failed %d\n", __func__,
__LINE__, rc);
- mutex_unlock(&cci_dev->cci_master_info[master].
- mutex_q[SYNC_QUEUE]);
- mutex_unlock(&cci_dev->cci_master_info[master].
- mutex_q[PRIORITY_QUEUE]);
mutex_unlock(&cci_dev->cci_master_info[master].mutex);
}
return 0;
@@ -1692,7 +1643,6 @@ static int32_t msm_cci_config(struct v4l2_subdev *sd,
static irqreturn_t msm_cci_irq(int irq_num, void *data)
{
uint32_t irq;
- unsigned long flags;
struct cci_device *cci_dev = data;
irq = msm_camera_io_r_mb(cci_dev->base + CCI_IRQ_STATUS_0_ADDR);
msm_camera_io_w_mb(irq, cci_dev->base + CCI_IRQ_CLEAR_0_ADDR);
@@ -1719,30 +1669,22 @@ static irqreturn_t msm_cci_irq(int irq_num, void *data)
if (irq & CCI_IRQ_STATUS_0_I2C_M0_Q0_REPORT_BMSK) {
struct msm_camera_cci_master_info *cci_master_info;
cci_master_info = &cci_dev->cci_master_info[MASTER_0];
- spin_lock_irqsave(&cci_dev->cci_master_info[MASTER_0].
- lock_q[QUEUE_0], flags);
atomic_set(&cci_master_info->q_free[QUEUE_0], 0);
cci_master_info->status = 0;
if (atomic_read(&cci_master_info->done_pending[QUEUE_0]) == 1) {
complete(&cci_master_info->report_q[QUEUE_0]);
atomic_set(&cci_master_info->done_pending[QUEUE_0], 0);
}
- spin_unlock_irqrestore(&cci_dev->cci_master_info[MASTER_0].
- lock_q[QUEUE_0], flags);
}
if (irq & CCI_IRQ_STATUS_0_I2C_M0_Q1_REPORT_BMSK) {
struct msm_camera_cci_master_info *cci_master_info;
cci_master_info = &cci_dev->cci_master_info[MASTER_0];
- spin_lock_irqsave(&cci_dev->cci_master_info[MASTER_0].
- lock_q[QUEUE_1], flags);
atomic_set(&cci_master_info->q_free[QUEUE_1], 0);
cci_master_info->status = 0;
if (atomic_read(&cci_master_info->done_pending[QUEUE_1]) == 1) {
complete(&cci_master_info->report_q[QUEUE_1]);
atomic_set(&cci_master_info->done_pending[QUEUE_1], 0);
}
- spin_unlock_irqrestore(&cci_dev->cci_master_info[MASTER_0].
- lock_q[QUEUE_1], flags);
}
if (irq & CCI_IRQ_STATUS_0_I2C_M1_RD_DONE_BMSK) {
cci_dev->cci_master_info[MASTER_1].status = 0;
@@ -1751,30 +1693,22 @@ static irqreturn_t msm_cci_irq(int irq_num, void *data)
if (irq & CCI_IRQ_STATUS_0_I2C_M1_Q0_REPORT_BMSK) {
struct msm_camera_cci_master_info *cci_master_info;
cci_master_info = &cci_dev->cci_master_info[MASTER_1];
- spin_lock_irqsave(&cci_dev->cci_master_info[MASTER_1].
- lock_q[QUEUE_0], flags);
atomic_set(&cci_master_info->q_free[QUEUE_0], 0);
cci_master_info->status = 0;
if (atomic_read(&cci_master_info->done_pending[QUEUE_0]) == 1) {
complete(&cci_master_info->report_q[QUEUE_0]);
atomic_set(&cci_master_info->done_pending[QUEUE_0], 0);
}
- spin_unlock_irqrestore(&cci_dev->cci_master_info[MASTER_1].
- lock_q[QUEUE_0], flags);
}
if (irq & CCI_IRQ_STATUS_0_I2C_M1_Q1_REPORT_BMSK) {
struct msm_camera_cci_master_info *cci_master_info;
cci_master_info = &cci_dev->cci_master_info[MASTER_1];
- spin_lock_irqsave(&cci_dev->cci_master_info[MASTER_1].
- lock_q[QUEUE_1], flags);
atomic_set(&cci_master_info->q_free[QUEUE_1], 0);
cci_master_info->status = 0;
if (atomic_read(&cci_master_info->done_pending[QUEUE_1]) == 1) {
complete(&cci_master_info->report_q[QUEUE_1]);
atomic_set(&cci_master_info->done_pending[QUEUE_1], 0);
}
- spin_unlock_irqrestore(&cci_dev->cci_master_info[MASTER_1].
- lock_q[QUEUE_1], flags);
}
if (irq & CCI_IRQ_STATUS_0_I2C_M0_Q0Q1_HALT_ACK_BMSK) {
cci_dev->cci_master_info[MASTER_0].reset_pending = TRUE;
@@ -1863,9 +1797,7 @@ static void msm_cci_init_cci_params(struct cci_device *new_cci_dev)
mutex_init(&new_cci_dev->cci_master_info[i].mutex_q[j]);
init_completion(&new_cci_dev->
cci_master_info[i].report_q[j]);
- spin_lock_init(&new_cci_dev->
- cci_master_info[i].lock_q[j]);
- }
+ }
}
return;
}
diff --git a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h
index 95bfc20b5561..f83b208b75b6 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, 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
@@ -125,7 +125,6 @@ struct msm_camera_cci_master_info {
struct mutex mutex_q[NUM_QUEUES];
struct completion report_q[NUM_QUEUES];
atomic_t done_pending[NUM_QUEUES];
- spinlock_t lock_q[NUM_QUEUES];
};
struct msm_cci_clk_params_t {
diff --git a/drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c b/drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c
index 9e79c45c600a..ca80ed66cf00 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/csid/msm_csid.c
@@ -234,34 +234,16 @@ static void msm_csid_set_sof_freeze_debug_reg(
static int msm_csid_reset(struct csid_device *csid_dev)
{
int32_t rc = 0;
- uint32_t irq = 0, irq_bitshift;
-
- irq_bitshift = csid_dev->ctrl_reg->csid_reg.csid_rst_done_irq_bitshift;
msm_camera_io_w(csid_dev->ctrl_reg->csid_reg.csid_rst_stb_all,
csid_dev->base +
csid_dev->ctrl_reg->csid_reg.csid_rst_cmd_addr);
rc = wait_for_completion_timeout(&csid_dev->reset_complete,
CSID_TIMEOUT);
- if (rc < 0) {
+ if (rc <= 0) {
pr_err("wait_for_completion in msm_csid_reset fail rc = %d\n",
rc);
- } else if (rc == 0) {
- irq = msm_camera_io_r(csid_dev->base +
- csid_dev->ctrl_reg->csid_reg.csid_irq_status_addr);
- pr_err_ratelimited("%s CSID%d_IRQ_STATUS_ADDR = 0x%x\n",
- __func__, csid_dev->pdev->id, irq);
- if (irq & (0x1 << irq_bitshift)) {
- rc = 1;
- CDBG("%s succeeded", __func__);
- } else {
- rc = 0;
- pr_err("%s reset csid_irq_status failed = 0x%x\n",
- __func__, irq);
- }
if (rc == 0)
rc = -ETIMEDOUT;
- } else {
- CDBG("%s succeeded", __func__);
}
return rc;
}
@@ -327,7 +309,7 @@ static int msm_csid_config(struct csid_device *csid_dev,
if (!msm_csid_find_max_clk_rate(csid_dev))
pr_err("msm_csid_find_max_clk_rate failed\n");
- clk_rate = ((int)csid_params->csi_clk > 0) ?
+ clk_rate = (csid_params->csi_clk > 0) ?
(csid_params->csi_clk) : csid_dev->csid_max_clk;
clk_rate = msm_camera_clk_set_rate(&csid_dev->pdev->dev,
diff --git a/drivers/media/platform/msm/camera_v2/sensor/csiphy/include/msm_csiphy_3_4_2_hwreg.h b/drivers/media/platform/msm/camera_v2/sensor/csiphy/include/msm_csiphy_3_4_2_hwreg.h
index 940436e2baab..aa8a6b9cf3a3 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/csiphy/include/msm_csiphy_3_4_2_hwreg.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/csiphy/include/msm_csiphy_3_4_2_hwreg.h
@@ -25,75 +25,6 @@ struct csiphy_reg_parms_t csiphy_v3_4_2 = {
.combo_clk_mask = 0x10,
};
-#ifdef CONFIG_MOT_CAMERA_ALT_MIPI_TERMINAL_ENABLE
-struct csiphy_reg_3ph_parms_t csiphy_v3_4_2_3ph = {
- /*MIPI CSI PHY registers*/
- {0x814, 0x0},
- {0x818, 0x1},
- {0x188, 0x7F},
- {0x18C, 0x7F},
- {0x190, 0x0},
- {0x104, 0x6},
- {0x108, 0x0},
- {0x10c, 0x0},
- {0x114, 0x20},
- {0x118, 0x3E},
- {0x11c, 0x41},
- {0x120, 0x41},
- {0x124, 0x7F},
- {0x128, 0x0},
- {0x12c, 0x0},
- {0x130, 0x1},
- {0x134, 0x0},
- {0x138, 0x0},
- {0x13C, 0x10},
- {0x140, 0x1},
- {0x144, GLITCH_ELIMINATION_NUM},
- {0x148, 0xFE},
- {0x14C, 0x1},
- {0x154, 0x0},
- {0x15C, 0x33},
- {0x160, ULPM_WAKE_UP_TIMER_MODE},
- {0x164, 0x48},
- {0x168, 0xA0},
- {0x16C, 0x17},
- {0x170, 0x41},
- {0x174, 0x41},
- {0x178, 0x3E},
- {0x17C, 0x0},
- {0x180, 0x0},
- {0x184, 0x7F},
- {0x1cc, 0x10},
- {0x81c, 0x6},
- {0x82c, 0xFF},
- {0x830, 0xFF},
- {0x834, 0xFB},
- {0x838, 0xFF},
- {0x83c, 0x7F},
- {0x840, 0xFF},
- {0x844, 0xFF},
- {0x848, 0xEF},
- {0x84c, 0xFF},
- {0x850, 0xFF},
- {0x854, 0xFF},
- {0x28, 0x0},
- {0x800, 0x2},
- {0x0, 0x8E},
- {0x4, 0x8},
- {0x8, 0x0},
- {0xC, 0xFF},
- {0x10, 0x50},
- {0x2C, 0x1},
- {0x30, 0x0},
- {0x34, 0x3},
- {0x38, 0xfe},
- {0x3C, 0xB8},
- {0x1C, 0xE7},
- {0x14, 0x0},
- {0x14, 0x60},
- {0x700, 0x80}
-};
-#else
struct csiphy_reg_3ph_parms_t csiphy_v3_4_2_3ph = {
/*MIPI CSI PHY registers*/
{0x814, 0x0},
@@ -162,4 +93,3 @@ struct csiphy_reg_3ph_parms_t csiphy_v3_4_2_3ph = {
{0x700, 0x80}
};
#endif
-#endif
diff --git a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
index 91c69263090d..d1bb9af3d8da 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
@@ -483,7 +483,7 @@ static int msm_csiphy_lane_config(struct csiphy_device *csiphy_dev,
return rc;
}
- clk_rate = ((int)csiphy_params->csiphy_clk > 0)
+ clk_rate = (csiphy_params->csiphy_clk > 0)
? csiphy_params->csiphy_clk :
csiphy_dev->csiphy_max_clk;
clk_rate = msm_camera_clk_set_rate(&csiphy_dev->pdev->dev,
@@ -1209,7 +1209,6 @@ static int32_t msm_csiphy_cmd(struct csiphy_device *csiphy_dev, void *arg)
break;
}
csiphy_dev->csiphy_sof_debug = SOF_DEBUG_DISABLE;
- csiphy_dev->is_combo_mode = csiphy_params.combo_mode;
rc = msm_csiphy_lane_config(csiphy_dev, &csiphy_params);
break;
case CSIPHY_RELEASE:
@@ -1220,14 +1219,7 @@ static int32_t msm_csiphy_cmd(struct csiphy_device *csiphy_dev, void *arg)
rc = -EFAULT;
break;
}
- if ((csiphy_dev->is_combo_mode == 1) &&
- (csiphy_dev->ref_count == 2)) {
- /*CSIPHY is running in Combo mode do
- not power down core*/
- csiphy_dev->ref_count--;
- } else {
- rc = msm_csiphy_release(csiphy_dev, &csi_lane_params);
- }
+ rc = msm_csiphy_release(csiphy_dev, &csi_lane_params);
break;
default:
pr_err("%s: %d failed\n", __func__, __LINE__);
@@ -1337,7 +1329,7 @@ static const struct v4l2_subdev_ops msm_csiphy_subdev_ops = {
static int msm_csiphy_get_clk_info(struct csiphy_device *csiphy_dev,
struct platform_device *pdev)
{
- int i, rc = 0;
+ int i, rc;
char *csi_3p_clk_name = "csi_phy_3p_clk";
char *csi_3p_clk_src_name = "csiphy_3p_clk_src";
uint32_t clk_cnt = 0;
@@ -1353,7 +1345,6 @@ static int msm_csiphy_get_clk_info(struct csiphy_device *csiphy_dev,
if (csiphy_dev->num_all_clk > CSIPHY_NUM_CLK_MAX) {
pr_err("%s: invalid count=%zu, max is %d\n", __func__,
csiphy_dev->num_all_clk, CSIPHY_NUM_CLK_MAX);
- rc = -EINVAL;
goto MAX_CLK_ERROR;
}
@@ -1397,14 +1388,13 @@ static int msm_csiphy_get_clk_info(struct csiphy_device *csiphy_dev,
}
csiphy_dev->num_clk = clk_cnt;
- return rc;
MAX_CLK_ERROR:
msm_camera_put_clk_info(csiphy_dev->pdev,
&csiphy_dev->csiphy_all_clk_info,
&csiphy_dev->csiphy_all_clk,
csiphy_dev->num_all_clk);
- return rc;
+ return 0;
}
static int csiphy_probe(struct platform_device *pdev)
diff --git a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h
index eb2310583955..07a08110885b 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h
@@ -169,7 +169,6 @@ struct csiphy_device {
uint8_t num_irq_registers;
uint32_t csiphy_sof_debug;
uint32_t csiphy_sof_debug_count;
- uint32_t is_combo_mode;
struct camera_vreg_t *csiphy_vreg;
struct regulator *csiphy_reg_ptr[MAX_REGULATOR];
int32_t regulator_count;
diff --git a/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c b/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
index 306195fd0050..056fc172f75f 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
@@ -249,8 +249,7 @@ static int msm_get_read_mem_size
}
for (i = 0; i < eeprom_map->memory_map_size; i++) {
if (eeprom_map->mem_settings[i].i2c_operation ==
- MSM_CAM_READ || eeprom_map->mem_settings[i].
- i2c_operation == MSM_CAM_READ_LOOP) {
+ MSM_CAM_READ) {
size += eeprom_map->mem_settings[i].reg_data;
}
}
@@ -521,7 +520,6 @@ static int eeprom_parse_memory_map(struct msm_eeprom_ctrl_t *e_ctrl,
struct msm_eeprom_memory_map_array *eeprom_map_array)
{
int rc = 0, i, j;
- int m;
uint8_t *memptr;
struct msm_eeprom_mem_map_t *eeprom_map;
@@ -561,8 +559,7 @@ static int eeprom_parse_memory_map(struct msm_eeprom_ctrl_t *e_ctrl,
eeprom_map->mem_settings[i].reg_addr,
eeprom_map->mem_settings[i].reg_data,
eeprom_map->mem_settings[i].data_type);
- if (eeprom_map->mem_settings[i].delay > 0)
- msleep(eeprom_map->mem_settings[i].delay);
+ msleep(eeprom_map->mem_settings[i].delay);
if (rc < 0) {
pr_err("%s: page write failed\n",
__func__);
@@ -597,8 +594,7 @@ static int eeprom_parse_memory_map(struct msm_eeprom_ctrl_t *e_ctrl,
eeprom_map->mem_settings[i].reg_addr,
memptr,
eeprom_map->mem_settings[i].reg_data);
- if (eeprom_map->mem_settings[i].delay > 0)
- msleep(eeprom_map->mem_settings[i].delay);
+ msleep(eeprom_map->mem_settings[i].delay);
if (rc < 0) {
pr_err("%s: read failed\n",
__func__);
@@ -607,26 +603,6 @@ static int eeprom_parse_memory_map(struct msm_eeprom_ctrl_t *e_ctrl,
memptr += eeprom_map->mem_settings[i].reg_data;
}
break;
- case MSM_CAM_READ_LOOP: {
- e_ctrl->i2c_client.addr_type =
- eeprom_map->mem_settings[i].addr_type;
- for (m = 0; m < eeprom_map->mem_settings[i].reg_data; m++) {
- rc = e_ctrl->i2c_client.i2c_func_tbl->
- i2c_read(&(e_ctrl->i2c_client),
- eeprom_map->mem_settings[i].reg_addr,
- (uint16_t *)memptr,
- eeprom_map->mem_settings[i].data_type);
- if (rc < 0) {
- pr_err("%s: read failed\n",
- __func__);
- goto clean_up;
- }
- if (eeprom_map->mem_settings[i].delay > 0)
- msleep(eeprom_map->mem_settings[i].delay);
- memptr++;
- }
- }
- break;
default:
pr_err("%s: %d Invalid i2c operation LC:%d\n",
__func__, __LINE__, i);
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/Makefile b/drivers/media/platform/msm/camera_v2/sensor/flash/Makefile
index 78106b414d32..90b9faf2c622 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/Makefile
+++ b/drivers/media/platform/msm/camera_v2/sensor/flash/Makefile
@@ -3,9 +3,4 @@ ccflags-y += -Idrivers/media/platform/msm/camera_v2
ccflags-y += -Idrivers/media/platform/msm/camera_v2/common
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor/io
obj-$(CONFIG_MSMB_CAMERA) += msm_flash.o
-obj-$(CONFIG_MSMB_CAMERA) += msm_led_flash.o
-obj-$(CONFIG_MSMB_CAMERA) += msm_led_trigger.o
-obj-$(CONFIG_MSMB_CAMERA) += msm_led_i2c_trigger.o
-obj-$(CONFIG_MSMB_CAMERA) += adp1660.o
-obj-$(CONFIG_MSMB_CAMERA) += msm_led_torch.o
obj-$(CONFIG_MSMB_CAMERA) += msm_flash_gpio.o
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/adp1660.c b/drivers/media/platform/msm/camera_v2/sensor/flash/adp1660.c
deleted file mode 100644
index 8606fe4441a4..000000000000
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/adp1660.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* Copyright (c) 2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-#include <linux/module.h>
-#include <linux/export.h>
-#include "msm_led_flash.h"
-
-#define FLASH_NAME "qcom,led-flash"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
-static struct msm_led_flash_ctrl_t fctrl;
-static struct i2c_driver adp1660_i2c_driver;
-
-static struct msm_camera_i2c_reg_array adp1660_init_array[] = {
- {0x01, 0x03},
- {0x02, 0x0F},
- {0x09, 0x28},
- {0x03, 0x09},
-};
-
-static struct msm_camera_i2c_reg_array adp1660_off_array[] = {
- {0x0f, 0x00},
-};
-
-static struct msm_camera_i2c_reg_array adp1660_release_array[] = {
- {0x0f, 0x00},
-};
-
-static struct msm_camera_i2c_reg_array adp1660_low_array[] = {
- {0x08, 0x04},
- {0x06, 0x28},
- {0x01, 0xBD},
- {0x0f, 0x01},
-};
-
-static struct msm_camera_i2c_reg_array adp1660_high_array[] = {
- {0x02, 0x4F},
- {0x06, 0x3C},
- {0x09, 0x3C},
- {0x0f, 0x01},
- {0x01, 0xBB},
-};
-
-static void __exit msm_flash_adp1660_i2c_remove(void)
-{
- i2c_del_driver(&adp1660_i2c_driver);
-}
-
-static const struct of_device_id adp1660_trigger_dt_match[] = {
- {.compatible = "qcom,led-flash", .data = &fctrl},
- {}
-};
-
-MODULE_DEVICE_TABLE(of, adp1660_trigger_dt_match);
-
-static const struct i2c_device_id flash_i2c_id[] = {
- {"qcom,led-flash", (kernel_ulong_t)&fctrl},
- { }
-};
-
-static const struct i2c_device_id adp1660_i2c_id[] = {
- {FLASH_NAME, (kernel_ulong_t)&fctrl},
- { }
-};
-
-static int msm_flash_adp1660_i2c_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
-{
- if (!id) {
- pr_err("msm_flash_adp1660_i2c_probe: id is NULL");
- id = adp1660_i2c_id;
- }
-
- return msm_flash_i2c_probe(client, id);
-}
-
-static struct i2c_driver adp1660_i2c_driver = {
- .id_table = adp1660_i2c_id,
- .probe = msm_flash_adp1660_i2c_probe,
- .remove = __exit_p(msm_flash_adp1660_i2c_remove),
- .driver = {
- .name = FLASH_NAME,
- .owner = THIS_MODULE,
- .of_match_table = adp1660_trigger_dt_match,
- },
-};
-
-static int msm_flash_adp1660_platform_probe(struct platform_device *pdev)
-{
- const struct of_device_id *match;
-
- match = of_match_device(adp1660_trigger_dt_match, &pdev->dev);
-
- if (!match)
- return -EFAULT;
- return msm_flash_probe(pdev, match->data);
-}
-
-static struct platform_driver adp1660_platform_driver = {
- .probe = msm_flash_adp1660_platform_probe,
- .driver = {
- .name = "qcom,led-flash",
- .owner = THIS_MODULE,
- .of_match_table = adp1660_trigger_dt_match,
- },
-};
-
-static int __init msm_flash_adp1660_init_module(void)
-{
- int32_t rc = 0;
-
- rc = platform_driver_register(&adp1660_platform_driver);
-
- if (fctrl.pdev != NULL && rc == 0)
- pr_err("adp1660 platform_driver_register success");
- else if (rc != 0)
- pr_err("adp1660 platform_driver_register failed");
- else {
- rc = i2c_add_driver(&adp1660_i2c_driver);
- if (!rc)
- pr_err("adp1660 i2c_add_driver success");
- }
- return rc;
-}
-
-static void __exit msm_flash_adp1660_exit_module(void)
-{
- if (fctrl.pdev)
- platform_driver_unregister(&adp1660_platform_driver);
- else
- i2c_del_driver(&adp1660_i2c_driver);
-}
-
-static struct msm_camera_i2c_client adp1660_i2c_client = {
- .addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
-};
-
-static struct msm_camera_i2c_reg_setting adp1660_init_setting = {
- .reg_setting = adp1660_init_array,
- .size = ARRAY_SIZE(adp1660_init_array),
- .addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
- .data_type = MSM_CAMERA_I2C_BYTE_DATA,
- .delay = 0,
-};
-
-static struct msm_camera_i2c_reg_setting adp1660_off_setting = {
- .reg_setting = adp1660_off_array,
- .size = ARRAY_SIZE(adp1660_off_array),
- .addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
- .data_type = MSM_CAMERA_I2C_BYTE_DATA,
- .delay = 0,
-};
-
-static struct msm_camera_i2c_reg_setting adp1660_release_setting = {
- .reg_setting = adp1660_release_array,
- .size = ARRAY_SIZE(adp1660_release_array),
- .addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
- .data_type = MSM_CAMERA_I2C_BYTE_DATA,
- .delay = 0,
-};
-
-static struct msm_camera_i2c_reg_setting adp1660_low_setting = {
- .reg_setting = adp1660_low_array,
- .size = ARRAY_SIZE(adp1660_low_array),
- .addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
- .data_type = MSM_CAMERA_I2C_BYTE_DATA,
- .delay = 0,
-};
-
-static struct msm_camera_i2c_reg_setting adp1660_high_setting = {
- .reg_setting = adp1660_high_array,
- .size = ARRAY_SIZE(adp1660_high_array),
- .addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
- .data_type = MSM_CAMERA_I2C_BYTE_DATA,
- .delay = 0,
-};
-
-static struct msm_led_flash_reg_t adp1660_regs = {
- .init_setting = &adp1660_init_setting,
- .off_setting = &adp1660_off_setting,
- .low_setting = &adp1660_low_setting,
- .high_setting = &adp1660_high_setting,
- .release_setting = &adp1660_release_setting,
-};
-
-static struct msm_flash_fn_t adp1660_func_tbl = {
- .flash_get_subdev_id = msm_led_i2c_trigger_get_subdev_id,
- .flash_led_config = msm_led_i2c_trigger_config,
- .flash_led_init = msm_flash_led_init,
- .flash_led_release = msm_flash_led_release,
- .flash_led_off = msm_flash_led_off,
- .flash_led_low = msm_flash_led_low,
- .flash_led_high = msm_flash_led_high,
-};
-
-static struct msm_led_flash_ctrl_t fctrl = {
- .flash_i2c_client = &adp1660_i2c_client,
- .reg_setting = &adp1660_regs,
- .func_tbl = &adp1660_func_tbl,
-};
-
-/*subsys_initcall(msm_flash_i2c_add_driver);*/
-module_init(msm_flash_adp1660_init_module);
-module_exit(msm_flash_adp1660_exit_module);
-MODULE_DESCRIPTION("adp1660 FLASH");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.c b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.c
index 42b9d5204393..b24cf529e4e7 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2009-2016, 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
@@ -27,16 +27,6 @@ DEFINE_MSM_MUTEX(msm_flash_mutex);
static struct v4l2_file_operations msm_flash_v4l2_subdev_fops;
static struct led_trigger *torch_trigger;
-static const struct of_device_id msm_flash_i2c_dt_match[] = {
- {.compatible = "qcom,camera-flash"},
- {}
-};
-
-static const struct i2c_device_id msm_flash_i2c_id[] = {
- {"qcom,camera-flash", (kernel_ulong_t)NULL},
- { }
-};
-
static const struct of_device_id msm_flash_dt_match[] = {
{.compatible = "qcom,camera-flash", .data = NULL},
{}
@@ -52,16 +42,6 @@ static struct msm_flash_table *flash_table[] = {
&msm_pmic_flash_table
};
-static struct msm_camera_i2c_fn_t msm_flash_qup_func_tbl = {
- .i2c_read = msm_camera_qup_i2c_read,
- .i2c_read_seq = msm_camera_qup_i2c_read_seq,
- .i2c_write = msm_camera_qup_i2c_write,
- .i2c_write_table = msm_camera_qup_i2c_write_table,
- .i2c_write_seq_table = msm_camera_qup_i2c_write_seq_table,
- .i2c_write_table_w_microdelay =
- msm_camera_qup_i2c_write_table_w_microdelay,
-};
-
static struct msm_camera_i2c_fn_t msm_sensor_cci_func_tbl = {
.i2c_read = msm_camera_cci_i2c_read,
.i2c_read_seq = msm_camera_cci_i2c_read_seq,
@@ -172,12 +152,6 @@ static int32_t msm_flash_i2c_write_table(
conf_array.size = settings->size;
flash_ctrl->flash_i2c_client.addr_type = conf_array.addr_type;
- /* Validate the settings size */
- if ((!conf_array.size) || (conf_array.size > MAX_I2C_REG_SET)) {
- pr_err("failed: invalid size %d", conf_array.size);
- return -EINVAL;
- }
-
return flash_ctrl->flash_i2c_client.i2c_func_tbl->i2c_write_table(
&flash_ctrl->flash_i2c_client, &conf_array);
}
@@ -628,7 +602,7 @@ static int32_t msm_flash_init_prepare(
flash_data_k.cfg.flash_init_info = &flash_init_info;
if (copy_from_user(&flash_init_info,
- (void __user *)(flash_data->cfg.flash_init_info),
+ (void *)(flash_data->cfg.flash_init_info),
sizeof(struct msm_flash_init_info_t))) {
pr_err("%s copy_from_user failed %d\n",
__func__, __LINE__);
@@ -646,6 +620,7 @@ static int32_t msm_flash_init_prepare(
struct msm_flash_cfg_data_t flash_data_k;
struct msm_flash_init_info_t flash_init_info;
int32_t i = 0;
+
flash_data_k.cfg_type = flash_data->cfg_type;
for (i = 0; i < MAX_LED_TRIGGERS; i++) {
flash_data_k.flash_current[i] =
@@ -656,12 +631,12 @@ static int32_t msm_flash_init_prepare(
flash_data_k.cfg.flash_init_info = &flash_init_info;
if (copy_from_user(&flash_init_info,
- (void __user *)(flash_data->cfg.flash_init_info),
- sizeof(struct msm_flash_init_info_t))) {
- pr_err("%s copy_from_user failed %d\n",
- __func__, __LINE__);
- return -EFAULT;
- }
+ (void *)(flash_data->cfg.flash_init_info),
+ sizeof(struct msm_flash_init_info_t))) {
+ pr_err("%s copy_from_user failed %d\n",
+ __func__, __LINE__);
+ return -EFAULT;
+ }
return msm_flash_init(flash_ctrl, &flash_data_k);
#endif
}
@@ -769,6 +744,11 @@ static int32_t msm_flash_release(
struct msm_flash_ctrl_t *flash_ctrl)
{
int32_t rc = 0;
+ if (flash_ctrl->flash_state == MSM_CAMERA_FLASH_RELEASE) {
+ pr_err("%s:%d Invalid flash state = %d",
+ __func__, __LINE__, flash_ctrl->flash_state);
+ return 0;
+ }
rc = flash_ctrl->func_tbl->camera_flash_off(flash_ctrl, NULL);
if (rc < 0) {
@@ -796,49 +776,24 @@ static int32_t msm_flash_config(struct msm_flash_ctrl_t *flash_ctrl,
rc = msm_flash_init_prepare(flash_ctrl, flash_data);
break;
case CFG_FLASH_RELEASE:
- if (flash_ctrl->flash_state != MSM_CAMERA_FLASH_RELEASE) {
+ if (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT)
rc = flash_ctrl->func_tbl->camera_flash_release(
flash_ctrl);
- } else {
- CDBG(pr_fmt("Invalid state : %d\n"),
- flash_ctrl->flash_state);
- }
break;
case CFG_FLASH_OFF:
- if ((flash_ctrl->flash_state != MSM_CAMERA_FLASH_RELEASE) &&
- (flash_ctrl->flash_state != MSM_CAMERA_FLASH_OFF)) {
+ if (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT)
rc = flash_ctrl->func_tbl->camera_flash_off(
flash_ctrl, flash_data);
- if (!rc)
- flash_ctrl->flash_state = MSM_CAMERA_FLASH_OFF;
- } else {
- CDBG(pr_fmt("Invalid state : %d\n"),
- flash_ctrl->flash_state);
- }
break;
case CFG_FLASH_LOW:
- if ((flash_ctrl->flash_state == MSM_CAMERA_FLASH_OFF) ||
- (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT)) {
+ if (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT)
rc = flash_ctrl->func_tbl->camera_flash_low(
flash_ctrl, flash_data);
- if (!rc)
- flash_ctrl->flash_state = MSM_CAMERA_FLASH_LOW;
- } else {
- CDBG(pr_fmt("Invalid state : %d\n"),
- flash_ctrl->flash_state);
- }
break;
case CFG_FLASH_HIGH:
- if ((flash_ctrl->flash_state == MSM_CAMERA_FLASH_OFF) ||
- (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT)) {
+ if (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT)
rc = flash_ctrl->func_tbl->camera_flash_high(
flash_ctrl, flash_data);
- if (!rc)
- flash_ctrl->flash_state = MSM_CAMERA_FLASH_HIGH;
- } else {
- CDBG(pr_fmt("Invalid state : %d\n"),
- flash_ctrl->flash_state);
- }
break;
case CFG_FLASH_READ_I2C:
if (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT)
@@ -1199,11 +1154,9 @@ static int32_t msm_flash_get_dt_data(struct device_node *of_node,
/* Read the gpio information from device tree */
rc = msm_sensor_driver_get_gpio_data(
&(fctrl->power_info.gpio_conf), of_node);
- if (-ENODEV == rc) {
- pr_notice("No valid flash GPIOs data\n");
- rc = 0;
- } else if (rc < 0) {
- pr_err("Error flash GPIOs rc %d\n", rc);
+ if (rc < 0) {
+ pr_err("%s:%d msm_sensor_driver_get_gpio_data failed rc %d\n",
+ __func__, __LINE__, rc);
return rc;
}
@@ -1247,13 +1200,13 @@ static long msm_flash_subdev_do_ioctl(
sd = vdev_to_v4l2_subdev(vdev);
u32 = (struct msm_flash_cfg_data_t32 *)arg;
+ flash_data.cfg_type = u32->cfg_type;
+ for (i = 0; i < MAX_LED_TRIGGERS; i++) {
+ flash_data.flash_current[i] = u32->flash_current[i];
+ flash_data.flash_duration[i] = u32->flash_duration[i];
+ }
switch (cmd) {
case VIDIOC_MSM_FLASH_CFG32:
- flash_data.cfg_type = u32->cfg_type;
- for (i = 0; i < MAX_LED_TRIGGERS; i++) {
- flash_data.flash_current[i] = u32->flash_current[i];
- flash_data.flash_duration[i] = u32->flash_duration[i];
- }
cmd = VIDIOC_MSM_FLASH_CFG;
switch (flash_data.cfg_type) {
case CFG_FLASH_OFF:
@@ -1288,9 +1241,6 @@ static long msm_flash_subdev_do_ioctl(
break;
}
break;
- case VIDIOC_MSM_FLASH_CFG:
- pr_err("invalid cmd 0x%x received\n", cmd);
- return -EINVAL;
default:
return msm_flash_subdev_ioctl(sd, cmd, arg);
}
@@ -1310,75 +1260,6 @@ static long msm_flash_subdev_fops_ioctl(struct file *file,
return video_usercopy(file, cmd, arg, msm_flash_subdev_do_ioctl);
}
#endif
-
-static int msm_camera_flash_i2c_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
-{
- int32_t rc = 0;
- struct msm_flash_ctrl_t *flash_ctrl = NULL;
-
- CDBG("Enter\n");
-
- if (client == NULL) {
- pr_err("msm_flash_i2c_probe: client is null\n");
- return -EINVAL;
- }
-
- flash_ctrl = kzalloc(sizeof(struct msm_flash_ctrl_t), GFP_KERNEL);
- if (!flash_ctrl)
- return -ENOMEM;
-
- memset(flash_ctrl, 0, sizeof(struct msm_flash_ctrl_t));
-
- if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
- pr_err("i2c_check_functionality failed\n");
- kfree(flash_ctrl);
- return -EINVAL;
- }
-
- rc = msm_flash_get_dt_data(client->dev.of_node, flash_ctrl);
- if (rc < 0) {
- pr_err("%s:%d msm_flash_get_dt_data failed\n",
- __func__, __LINE__);
- kfree(flash_ctrl);
- return -EINVAL;
- }
-
- flash_ctrl->flash_state = MSM_CAMERA_FLASH_RELEASE;
- flash_ctrl->power_info.dev = &client->dev;
- flash_ctrl->flash_device_type = MSM_CAMERA_I2C_DEVICE;
- flash_ctrl->flash_mutex = &msm_flash_mutex;
- flash_ctrl->flash_i2c_client.i2c_func_tbl = &msm_flash_qup_func_tbl;
- flash_ctrl->flash_i2c_client.client = client;
-
- /* Initialize sub device */
- v4l2_subdev_init(&flash_ctrl->msm_sd.sd, &msm_flash_subdev_ops);
- v4l2_set_subdevdata(&flash_ctrl->msm_sd.sd, flash_ctrl);
-
- flash_ctrl->msm_sd.sd.internal_ops = &msm_flash_internal_ops;
- flash_ctrl->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
- snprintf(flash_ctrl->msm_sd.sd.name,
- ARRAY_SIZE(flash_ctrl->msm_sd.sd.name),
- "msm_camera_flash");
- media_entity_init(&flash_ctrl->msm_sd.sd.entity, 0, NULL, 0);
- flash_ctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
- flash_ctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_FLASH;
- flash_ctrl->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x1;
- msm_sd_register(&flash_ctrl->msm_sd);
-
- CDBG("%s:%d flash sd name = %s", __func__, __LINE__,
- flash_ctrl->msm_sd.sd.entity.name);
- msm_flash_v4l2_subdev_fops = v4l2_subdev_fops;
-#ifdef CONFIG_COMPAT
- msm_flash_v4l2_subdev_fops.compat_ioctl32 =
- msm_flash_subdev_fops_ioctl;
-#endif
- flash_ctrl->msm_sd.sd.devnode->fops = &msm_flash_v4l2_subdev_fops;
-
- CDBG("probe success\n");
- return rc;
-}
-
static int32_t msm_flash_platform_probe(struct platform_device *pdev)
{
int32_t rc = 0;
@@ -1457,19 +1338,6 @@ static int32_t msm_flash_platform_probe(struct platform_device *pdev)
return rc;
}
-MODULE_DEVICE_TABLE(of, msm_flash_i2c_dt_match);
-
-static struct i2c_driver msm_flash_i2c_driver = {
- .id_table = msm_flash_i2c_id,
- .probe = msm_camera_flash_i2c_probe,
- .remove = __exit_p(msm_camera_flash_i2c_remove),
- .driver = {
- .name = "qcom,camera-flash",
- .owner = THIS_MODULE,
- .of_match_table = msm_flash_i2c_dt_match,
- },
-};
-
MODULE_DEVICE_TABLE(of, msm_flash_dt_match);
static struct platform_driver msm_flash_platform_driver = {
@@ -1486,13 +1354,6 @@ static int __init msm_flash_init_module(void)
int32_t rc = 0;
CDBG("Enter\n");
rc = platform_driver_register(&msm_flash_platform_driver);
- if (!rc)
- return rc;
-
- pr_err("platform probe for flash failed");
-
- /* Perform i2c probe if platform probe fails. */
- rc = i2c_add_driver(&msm_flash_i2c_driver);
if (rc)
pr_err("platform probe for flash failed");
@@ -1502,7 +1363,6 @@ static int __init msm_flash_init_module(void)
static void __exit msm_flash_exit_module(void)
{
platform_driver_unregister(&msm_flash_platform_driver);
- i2c_del_driver(&msm_flash_i2c_driver);
return;
}
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.h b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.h
index 04dd6eb5583e..0947116325ce 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2009-2015, 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
@@ -27,9 +27,6 @@
enum msm_camera_flash_state_t {
MSM_CAMERA_FLASH_INIT,
- MSM_CAMERA_FLASH_OFF,
- MSM_CAMERA_FLASH_LOW,
- MSM_CAMERA_FLASH_HIGH,
MSM_CAMERA_FLASH_RELEASE,
};
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash_gpio.c b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash_gpio.c
index 46cfbded6567..a28fa573de58 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash_gpio.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_flash_gpio.c
@@ -22,13 +22,14 @@
#undef CDBG
#define CDBG(fmt, args...) pr_debug(fmt, ##args)
+enum msm_flash_driver_type flash_type_gpio = FLASH_DRIVER_DEFAULT;
DEFINE_MSM_MUTEX(msm_flash_mutex);
static struct v4l2_file_operations msm_flash_v4l2_subdev_fops;
static DEFINE_MUTEX(flash_lock);
static const struct of_device_id msm_flash_dt_match[] = {
- {.compatible = "qcom,camera-gpio-flash", .data = NULL},
+ {.compatible = "qcom,camera-led-flash", .data = NULL},
{}
};
static int32_t msm_flash_init_gpio_pin_tbl(struct device_node *of_node,
@@ -173,6 +174,7 @@ static int32_t msm_flash_init(
enum msm_flash_driver_type flash_driver_type = FLASH_DRIVER_DEFAULT;
CDBG("Enter");
+ flash_type_gpio = flash_data->cfg.flash_init_info->flash_driver_type;
if (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT) {
pr_err("%s:%d Invalid flash state = %d",
__func__, __LINE__, flash_ctrl->flash_state);
@@ -216,34 +218,6 @@ static int32_t msm_flash_init(
return 0;
}
-static int32_t msm_flash_init_prepare(
- struct msm_flash_ctrl_t *flash_ctrl,
- struct msm_flash_cfg_data_t *flash_data)
-{
- struct msm_flash_cfg_data_t flash_data_k;
- struct msm_flash_init_info_t flash_init_info;
- int32_t i = 0;
- flash_data_k.cfg_type = flash_data->cfg_type;
-
- for (i = 0; i < MAX_LED_TRIGGERS; i++) {
- flash_data_k.flash_current[i] =
- flash_data->flash_current[i];
- flash_data_k.flash_duration[i] =
- flash_data->flash_duration[i];
- }
-
- flash_data_k.cfg.flash_init_info = &flash_init_info;
- if (copy_from_user(&flash_init_info,
- (void __user *)(flash_data->cfg.flash_init_info),
- sizeof(struct msm_flash_init_info_t))) {
- pr_err("%s copy_from_user failed %d\n",
- __func__, __LINE__);
- return -EFAULT;
- }
-
- return msm_flash_init(flash_ctrl, &flash_data_k);
-}
-
static int32_t msm_flash_low(
struct msm_flash_ctrl_t *flash_ctrl,
struct msm_flash_cfg_data_t *flash_data)
@@ -263,7 +237,7 @@ static int32_t msm_flash_low(
gpio_set_value(
power_info->gpio_conf->gpio_num_info->gpio_num[0],
GPIO_OUT_HIGH);
- for (i = 0 ; i <= 9 ; i++) {
+ for (i = 0 ; i <= 14 ; i++) {
gpio_set_value(
power_info->gpio_conf->gpio_num_info->gpio_num[0],
GPIO_OUT_LOW);
@@ -303,7 +277,7 @@ static int32_t msm_flash_high(
gpio_set_value(
power_info->gpio_conf->gpio_num_info->gpio_num[0],
GPIO_OUT_HIGH);
- for (i = 0 ; i <= 1 ; i++) {
+ for (i = 0 ; i <= 10 ; i++) {
gpio_set_value(
power_info->gpio_conf->gpio_num_info->gpio_num[0],
GPIO_OUT_LOW);
@@ -373,7 +347,7 @@ static int32_t msm_flash_config(struct msm_flash_ctrl_t *flash_ctrl,
switch (flash_data->cfg_type) {
case CFG_FLASH_INIT:
- rc = msm_flash_init_prepare(flash_ctrl, flash_data);
+ rc = msm_flash_init(flash_ctrl, flash_data);
break;
case CFG_FLASH_RELEASE:
if (flash_ctrl->flash_state == MSM_CAMERA_FLASH_INIT)
@@ -695,7 +669,7 @@ MODULE_DEVICE_TABLE(of, msm_flash_dt_match);
static struct platform_driver msm_flash_platform_driver = {
.probe = msm_flash_platform_probe,
.driver = {
- .name = "qcom,camera-gpio-flash",
+ .name = "qcom,camera-led-flash",
.owner = THIS_MODULE,
.of_match_table = msm_flash_dt_match,
},
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.c b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.c
deleted file mode 100644
index 2d067a241884..000000000000
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Copyright (c) 2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
-#include "msm_led_flash.h"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_err(fmt, ##args)
-
-static struct v4l2_file_operations msm_led_flash_v4l2_subdev_fops;
-
-static long msm_led_flash_subdev_ioctl(struct v4l2_subdev *sd,
- unsigned int cmd, void *arg)
-{
- struct msm_led_flash_ctrl_t *fctrl = NULL;
- void *argp = (void *)arg;
-
- if (!sd) {
- pr_err("sd NULL\n");
- return -EINVAL;
- }
- fctrl = v4l2_get_subdevdata(sd);
- if (!fctrl) {
- pr_err("fctrl NULL\n");
- return -EINVAL;
- }
- switch (cmd) {
- case VIDIOC_MSM_SENSOR_GET_SUBDEV_ID:
- return fctrl->func_tbl->flash_get_subdev_id(fctrl, argp);
- case VIDIOC_MSM_FLASH_LED_DATA_CFG:
- return fctrl->func_tbl->flash_led_config(fctrl, argp);
- case MSM_SD_NOTIFY_FREEZE:
- return 0;
- case MSM_SD_SHUTDOWN:
- return fctrl->func_tbl->flash_led_release(fctrl);
- default:
- pr_err_ratelimited("invalid cmd %d\n", cmd);
- return -ENOIOCTLCMD;
- }
-}
-
-static struct v4l2_subdev_core_ops msm_flash_subdev_core_ops = {
- .ioctl = msm_led_flash_subdev_ioctl,
-};
-
-static struct v4l2_subdev_ops msm_flash_subdev_ops = {
- .core = &msm_flash_subdev_core_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_flash_internal_ops;
-
-int32_t msm_led_flash_create_v4lsubdev(struct platform_device *pdev, void *data)
-{
- struct msm_led_flash_ctrl_t *fctrl =
- (struct msm_led_flash_ctrl_t *)data;
- CDBG("Enter\n");
-
- if (!fctrl) {
- pr_err("fctrl NULL\n");
- return -EINVAL;
- }
-
- /* Initialize sub device */
- v4l2_subdev_init(&fctrl->msm_sd.sd, &msm_flash_subdev_ops);
- v4l2_set_subdevdata(&fctrl->msm_sd.sd, fctrl);
-
- fctrl->pdev = pdev;
- fctrl->msm_sd.sd.internal_ops = &msm_flash_internal_ops;
- fctrl->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
- snprintf(fctrl->msm_sd.sd.name, ARRAY_SIZE(fctrl->msm_sd.sd.name),
- "msm_flash");
- media_entity_init(&fctrl->msm_sd.sd.entity, 0, NULL, 0);
- fctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
- fctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_FLASH;
- fctrl->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x1;
- msm_sd_register(&fctrl->msm_sd);
-
- msm_led_flash_v4l2_subdev_fops = v4l2_subdev_fops;
-#ifdef CONFIG_COMPAT
- msm_led_flash_v4l2_subdev_fops.compat_ioctl32 =
- msm_led_flash_v4l2_subdev_fops.unlocked_ioctl;
-#endif
- fctrl->msm_sd.sd.devnode->fops = &msm_led_flash_v4l2_subdev_fops;
- CDBG("probe success\n");
- return 0;
-}
-
-int32_t msm_led_i2c_flash_create_v4lsubdev(void *data)
-{
- struct msm_led_flash_ctrl_t *fctrl =
- (struct msm_led_flash_ctrl_t *)data;
- CDBG("Enter\n");
-
- if (!fctrl) {
- pr_err("fctrl NULL\n");
- return -EINVAL;
- }
-
- /* Initialize sub device */
- v4l2_subdev_init(&fctrl->msm_sd.sd, &msm_flash_subdev_ops);
- v4l2_set_subdevdata(&fctrl->msm_sd.sd, fctrl);
-
- fctrl->msm_sd.sd.internal_ops = &msm_flash_internal_ops;
- fctrl->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
- snprintf(fctrl->msm_sd.sd.name, ARRAY_SIZE(fctrl->msm_sd.sd.name),
- "msm_flash");
- media_entity_init(&fctrl->msm_sd.sd.entity, 0, NULL, 0);
- fctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
- fctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_LED_FLASH;
- msm_sd_register(&fctrl->msm_sd);
-
- msm_led_flash_v4l2_subdev_fops = v4l2_subdev_fops;
- fctrl->msm_sd.sd.devnode->fops = &msm_led_flash_v4l2_subdev_fops;
-
- CDBG("probe success\n");
- return 0;
-}
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.h b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.h
deleted file mode 100644
index b954429af6a1..000000000000
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright (c) 2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-#ifndef MSM_LED_FLASH_H
-#define MSM_LED_FLASH_H
-
-#include <linux/leds.h>
-#include <linux/platform_device.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_cam_sensor.h>
-#include <soc/qcom/camera2.h>
-#include "msm_camera_i2c.h"
-#include "msm_sd.h"
-
-
-struct msm_led_flash_ctrl_t;
-
-struct msm_flash_fn_t {
- int32_t (*flash_get_subdev_id)(struct msm_led_flash_ctrl_t *, void *);
- int32_t (*flash_led_config)(struct msm_led_flash_ctrl_t *, void *);
- int32_t (*flash_led_init)(struct msm_led_flash_ctrl_t *);
- int32_t (*flash_led_release)(struct msm_led_flash_ctrl_t *);
- int32_t (*flash_led_off)(struct msm_led_flash_ctrl_t *);
- int32_t (*flash_led_low)(struct msm_led_flash_ctrl_t *);
- int32_t (*flash_led_high)(struct msm_led_flash_ctrl_t *);
-};
-
-struct msm_led_flash_reg_t {
- struct msm_camera_i2c_reg_setting *init_setting;
- struct msm_camera_i2c_reg_setting *off_setting;
- struct msm_camera_i2c_reg_setting *release_setting;
- struct msm_camera_i2c_reg_setting *low_setting;
- struct msm_camera_i2c_reg_setting *high_setting;
-};
-
-struct msm_led_flash_ctrl_t {
- struct msm_camera_i2c_client *flash_i2c_client;
- struct msm_sd_subdev msm_sd;
- struct platform_device *pdev;
- struct msm_flash_fn_t *func_tbl;
- struct msm_camera_sensor_board_info *flashdata;
- struct msm_led_flash_reg_t *reg_setting;
- /* Flash */
- const char *flash_trigger_name[MAX_LED_TRIGGERS];
- struct led_trigger *flash_trigger[MAX_LED_TRIGGERS];
- uint32_t flash_num_sources;
- uint32_t flash_op_current[MAX_LED_TRIGGERS];
- uint32_t flash_max_current[MAX_LED_TRIGGERS];
- uint32_t flash_max_duration[MAX_LED_TRIGGERS];
- /* Torch */
- const char *torch_trigger_name[MAX_LED_TRIGGERS];
- struct led_trigger *torch_trigger[MAX_LED_TRIGGERS];
- uint32_t torch_num_sources;
- uint32_t torch_op_current[MAX_LED_TRIGGERS];
- uint32_t torch_max_current[MAX_LED_TRIGGERS];
-
- void *data;
- enum msm_camera_device_type_t flash_device_type;
- enum cci_i2c_master_t cci_i2c_master;
- enum msm_camera_led_config_t led_state;
- uint32_t subdev_id;
- struct msm_pinctrl_info pinctrl_info;
-};
-
-int msm_flash_i2c_probe(struct i2c_client *client,
- const struct i2c_device_id *id);
-
-int msm_flash_probe(struct platform_device *pdev, const void *data);
-
-int32_t msm_led_flash_create_v4lsubdev(struct platform_device *pdev,
- void *data);
-int32_t msm_led_i2c_flash_create_v4lsubdev(void *data);
-
-int32_t msm_led_i2c_trigger_get_subdev_id(struct msm_led_flash_ctrl_t *fctrl,
- void *arg);
-
-int32_t msm_led_i2c_trigger_config(struct msm_led_flash_ctrl_t *fctrl,
- void *data);
-
-int32_t msm_led_torch_create_classdev(struct platform_device *pdev,
- void *data);
-
-int msm_flash_led_init(struct msm_led_flash_ctrl_t *fctrl);
-int msm_flash_led_release(struct msm_led_flash_ctrl_t *fctrl);
-int msm_flash_led_off(struct msm_led_flash_ctrl_t *fctrl);
-int msm_flash_led_low(struct msm_led_flash_ctrl_t *fctrl);
-int msm_flash_led_high(struct msm_led_flash_ctrl_t *fctrl);
-#endif
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_i2c_trigger.c b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_i2c_trigger.c
deleted file mode 100644
index 68ac3aedcced..000000000000
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_i2c_trigger.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/* Copyright (c) 2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
-#include <linux/module.h>
-#include "msm_led_flash.h"
-#include "msm_camera_io_util.h"
-#include "../msm_sensor.h"
-#include "msm_led_flash.h"
-#include "../cci/msm_cci.h"
-#include <linux/debugfs.h>
-
-#define FLASH_NAME "camera-led-flash"
-#define CAM_FLASH_PINCTRL_STATE_SLEEP "cam_flash_suspend"
-#define CAM_FLASH_PINCTRL_STATE_DEFAULT "cam_flash_default"
-/*#define CONFIG_MSMB_CAMERA_DEBUG*/
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
-static void *g_fctrl;
-int32_t msm_led_i2c_trigger_get_subdev_id(struct msm_led_flash_ctrl_t *fctrl,
- void *arg)
-{
- uint32_t *subdev_id = (uint32_t *)arg;
-
- if (!subdev_id) {
- pr_err("failed\n");
- return -EINVAL;
- }
- *subdev_id = fctrl->subdev_id;
-
- CDBG("subdev_id %d\n", *subdev_id);
- return 0;
-}
-
-int32_t msm_led_i2c_trigger_config(struct msm_led_flash_ctrl_t *fctrl,
- void *data)
-{
- int rc = 0;
- int i = 0;
- struct msm_camera_led_cfg_t *cfg = (struct msm_camera_led_cfg_t *)data;
-
- CDBG("called led_state %d\n", cfg->cfgtype);
-
- if (!fctrl->func_tbl) {
- pr_err("failed\n");
- return -EINVAL;
- }
- switch (cfg->cfgtype) {
-
- case MSM_CAMERA_LED_INIT:
- if (fctrl->func_tbl->flash_led_init)
- rc = fctrl->func_tbl->flash_led_init(fctrl);
- for (i = 0; i < MAX_LED_TRIGGERS; i++) {
- cfg->flash_current[i] =
- fctrl->flash_max_current[i];
- cfg->flash_duration[i] =
- fctrl->flash_max_duration[i];
- cfg->torch_current[i] =
- fctrl->torch_max_current[i];
- }
- break;
-
- case MSM_CAMERA_LED_RELEASE:
- if (fctrl->func_tbl->flash_led_release)
- rc = fctrl->func_tbl->
- flash_led_release(fctrl);
- break;
-
- case MSM_CAMERA_LED_OFF:
- if (fctrl->func_tbl->flash_led_off)
- rc = fctrl->func_tbl->flash_led_off(fctrl);
- break;
-
- case MSM_CAMERA_LED_LOW:
- for (i = 0; i < fctrl->torch_num_sources; i++) {
- if (fctrl->torch_max_current[i] > 0) {
- fctrl->torch_op_current[i] =
- (cfg->torch_current[i] <
- fctrl->torch_max_current[i]) ?
- cfg->torch_current[i] :
- fctrl->torch_max_current[i];
- CDBG("i %d: op_current %d max_current %d\n",
- i, fctrl->torch_op_current[i],
- fctrl->torch_max_current[i]);
- }
- }
- if (fctrl->func_tbl->flash_led_low)
- rc = fctrl->func_tbl->flash_led_low(fctrl);
- break;
-
- case MSM_CAMERA_LED_HIGH:
- for (i = 0; i < fctrl->flash_num_sources; i++) {
- if (fctrl->flash_max_current[i] > 0) {
- fctrl->flash_op_current[i] =
- (cfg->flash_current[i] <
- fctrl->flash_max_current[i]) ?
- cfg->flash_current[i] :
- fctrl->flash_max_current[i];
- CDBG(" i %d: op_current %d max_current %d\n",
- i, fctrl->flash_op_current[i],
- fctrl->flash_max_current[i]);
- }
- }
- if (fctrl->func_tbl->flash_led_high)
- rc = fctrl->func_tbl->flash_led_high(fctrl);
- break;
- default:
- rc = -EFAULT;
- break;
- }
- CDBG("flash_set_led_state: return %d\n", rc);
- return rc;
-}
-static int msm_flash_pinctrl_init(struct msm_led_flash_ctrl_t *ctrl)
-{
- struct msm_pinctrl_info *flash_pctrl = NULL;
-
- flash_pctrl = &ctrl->pinctrl_info;
-
- if (ctrl->pdev != NULL)
- flash_pctrl->pinctrl = devm_pinctrl_get(&ctrl->pdev->dev);
- else
- flash_pctrl->pinctrl = devm_pinctrl_get(&ctrl->
- flash_i2c_client->
- client->dev);
- if (IS_ERR_OR_NULL(flash_pctrl->pinctrl)) {
- pr_err("%s:%d Getting pinctrl handle failed\n",
- __func__, __LINE__);
- return -EINVAL;
- }
- flash_pctrl->gpio_state_active = pinctrl_lookup_state(
- flash_pctrl->pinctrl,
- CAM_FLASH_PINCTRL_STATE_DEFAULT);
-
- if (IS_ERR_OR_NULL(flash_pctrl->gpio_state_active)) {
- pr_err("%s:%d Failed to get the active state pinctrl handle\n",
- __func__, __LINE__);
- return -EINVAL;
- }
- flash_pctrl->gpio_state_suspend = pinctrl_lookup_state(
- flash_pctrl->pinctrl,
- CAM_FLASH_PINCTRL_STATE_SLEEP);
-
- if (IS_ERR_OR_NULL(flash_pctrl->gpio_state_suspend)) {
- pr_err("%s:%d Failed to get the suspend state pinctrl handle\n",
- __func__, __LINE__);
- return -EINVAL;
- }
- return 0;
-}
-
-
-int msm_flash_led_init(struct msm_led_flash_ctrl_t *fctrl)
-{
- int rc = 0;
- struct msm_camera_sensor_board_info *flashdata = NULL;
- struct msm_camera_power_ctrl_t *power_info = NULL;
-
- CDBG("%s:%d called\n", __func__, __LINE__);
-
- flashdata = fctrl->flashdata;
- power_info = &flashdata->power_info;
- fctrl->led_state = MSM_CAMERA_LED_RELEASE;
- if (power_info->gpio_conf->cam_gpiomux_conf_tbl != NULL)
- pr_err("%s:%d mux install\n", __func__, __LINE__);
-
- /* CCI Init */
- if (fctrl->flash_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
- rc = fctrl->flash_i2c_client->i2c_func_tbl->i2c_util(
- fctrl->flash_i2c_client, MSM_CCI_INIT);
- if (rc < 0) {
- pr_err("cci_init failed\n");
- return rc;
- }
- }
- rc = msm_camera_request_gpio_table(
- power_info->gpio_conf->cam_gpio_req_tbl,
- power_info->gpio_conf->cam_gpio_req_tbl_size, 1);
- if (rc < 0) {
- pr_err("%s: request gpio failed\n", __func__);
- return rc;
- }
-
- if (fctrl->pinctrl_info.use_pinctrl == true) {
- CDBG("%s:%d PC:: flash pins setting to active state",
- __func__, __LINE__);
- rc = pinctrl_select_state(fctrl->pinctrl_info.pinctrl,
- fctrl->pinctrl_info.gpio_state_active);
- if (rc < 0) {
- devm_pinctrl_put(fctrl->pinctrl_info.pinctrl);
- pr_err("%s:%d cannot set pin to active state",
- __func__, __LINE__);
- }
- }
- msleep(20);
-
- CDBG("before FL_RESET\n");
- if (power_info->gpio_conf->gpio_num_info->
- valid[SENSOR_GPIO_FL_RESET] == 1)
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_RESET],
- GPIO_OUT_HIGH);
-
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_EN],
- GPIO_OUT_HIGH);
-
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_NOW],
- GPIO_OUT_HIGH);
-
- if (fctrl->flash_i2c_client && fctrl->reg_setting) {
- rc = fctrl->flash_i2c_client->i2c_func_tbl->i2c_write_table(
- fctrl->flash_i2c_client,
- fctrl->reg_setting->init_setting);
- if (rc < 0)
- pr_err("%s:%d failed\n", __func__, __LINE__);
- }
- fctrl->led_state = MSM_CAMERA_LED_INIT;
- return rc;
-}
-
-int msm_flash_led_release(struct msm_led_flash_ctrl_t *fctrl)
-{
- int rc = 0, ret = 0;
- struct msm_camera_sensor_board_info *flashdata = NULL;
- struct msm_camera_power_ctrl_t *power_info = NULL;
-
- CDBG("%s:%d called\n", __func__, __LINE__);
- if (!fctrl) {
- pr_err("%s:%d fctrl NULL\n", __func__, __LINE__);
- return -EINVAL;
- }
- flashdata = fctrl->flashdata;
- power_info = &flashdata->power_info;
-
- if (fctrl->led_state != MSM_CAMERA_LED_INIT) {
- pr_err("%s:%d invalid led state\n", __func__, __LINE__);
- return -EINVAL;
- }
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_EN],
- GPIO_OUT_LOW);
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_NOW],
- GPIO_OUT_LOW);
- if (power_info->gpio_conf->gpio_num_info->
- valid[SENSOR_GPIO_FL_RESET] == 1)
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_RESET],
- GPIO_OUT_LOW);
-
- if (fctrl->pinctrl_info.use_pinctrl == true) {
- ret = pinctrl_select_state(fctrl->pinctrl_info.pinctrl,
- fctrl->pinctrl_info.gpio_state_suspend);
- if (ret < 0) {
- devm_pinctrl_put(fctrl->pinctrl_info.pinctrl);
- pr_err("%s:%d cannot set pin to suspend state",
- __func__, __LINE__);
- }
- }
- rc = msm_camera_request_gpio_table(
- power_info->gpio_conf->cam_gpio_req_tbl,
- power_info->gpio_conf->cam_gpio_req_tbl_size, 0);
- if (rc < 0) {
- pr_err("%s: request gpio failed\n", __func__);
- return rc;
- }
-
- fctrl->led_state = MSM_CAMERA_LED_RELEASE;
- /* CCI deInit */
- if (fctrl->flash_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
- rc = fctrl->flash_i2c_client->i2c_func_tbl->i2c_util(
- fctrl->flash_i2c_client, MSM_CCI_RELEASE);
- if (rc < 0)
- pr_err("cci_deinit failed\n");
- }
-
- return 0;
-}
-
-int msm_flash_led_off(struct msm_led_flash_ctrl_t *fctrl)
-{
- int rc = 0;
- struct msm_camera_sensor_board_info *flashdata = NULL;
- struct msm_camera_power_ctrl_t *power_info = NULL;
-
- if (!fctrl) {
- pr_err("%s:%d fctrl NULL\n", __func__, __LINE__);
- return -EINVAL;
- }
- flashdata = fctrl->flashdata;
- power_info = &flashdata->power_info;
- CDBG("%s:%d called\n", __func__, __LINE__);
- if (fctrl->flash_i2c_client && fctrl->reg_setting) {
- rc = fctrl->flash_i2c_client->i2c_func_tbl->i2c_write_table(
- fctrl->flash_i2c_client,
- fctrl->reg_setting->off_setting);
- if (rc < 0)
- pr_err("%s:%d failed\n", __func__, __LINE__);
- }
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_NOW],
- GPIO_OUT_LOW);
-
- return rc;
-}
-
-int msm_flash_led_low(struct msm_led_flash_ctrl_t *fctrl)
-{
- int rc = 0;
- struct msm_camera_sensor_board_info *flashdata = NULL;
- struct msm_camera_power_ctrl_t *power_info = NULL;
-
- CDBG("%s:%d called\n", __func__, __LINE__);
-
- flashdata = fctrl->flashdata;
- power_info = &flashdata->power_info;
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_EN],
- GPIO_OUT_HIGH);
-
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_NOW],
- GPIO_OUT_HIGH);
-
-
- if (fctrl->flash_i2c_client && fctrl->reg_setting) {
- rc = fctrl->flash_i2c_client->i2c_func_tbl->i2c_write_table(
- fctrl->flash_i2c_client,
- fctrl->reg_setting->low_setting);
- if (rc < 0)
- pr_err("%s:%d failed\n", __func__, __LINE__);
- }
-
- return rc;
-}
-
-int msm_flash_led_high(struct msm_led_flash_ctrl_t *fctrl)
-{
- int rc = 0;
- struct msm_camera_sensor_board_info *flashdata = NULL;
- struct msm_camera_power_ctrl_t *power_info = NULL;
-
- CDBG("%s:%d called\n", __func__, __LINE__);
-
- flashdata = fctrl->flashdata;
- power_info = &flashdata->power_info;
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_EN],
- GPIO_OUT_HIGH);
-
- gpio_set_value_cansleep(
- power_info->gpio_conf->gpio_num_info->
- gpio_num[SENSOR_GPIO_FL_NOW],
- GPIO_OUT_HIGH);
-
- if (fctrl->flash_i2c_client && fctrl->reg_setting) {
- rc = fctrl->flash_i2c_client->i2c_func_tbl->i2c_write_table(
- fctrl->flash_i2c_client,
- fctrl->reg_setting->high_setting);
- if (rc < 0)
- pr_err("%s:%d failed\n", __func__, __LINE__);
- }
-
- return rc;
-}
-
-static int32_t msm_led_get_dt_data(struct device_node *of_node,
- struct msm_led_flash_ctrl_t *fctrl)
-{
- int32_t rc = 0, i = 0;
- struct msm_camera_gpio_conf *gconf = NULL;
- struct device_node *flash_src_node = NULL;
- struct msm_camera_sensor_board_info *flashdata = NULL;
- struct msm_camera_power_ctrl_t *power_info = NULL;
- uint32_t count = 0;
- uint16_t *gpio_array = NULL;
- uint16_t gpio_array_size = 0;
- uint32_t id_info[3];
-
- CDBG("called\n");
-
- if (!of_node) {
- pr_err("of_node NULL\n");
- return -EINVAL;
- }
-
- fctrl->flashdata = kzalloc(sizeof(fctrl->flashdata),
- GFP_KERNEL);
- if (!fctrl->flashdata)
- return -ENOMEM;
-
- flashdata = fctrl->flashdata;
- power_info = &flashdata->power_info;
-
- rc = of_property_read_u32(of_node, "cell-index", &fctrl->subdev_id);
- if (rc < 0) {
- pr_err("failed\n");
- return -EINVAL;
- }
-
- CDBG("subdev id %d\n", fctrl->subdev_id);
-
- rc = of_property_read_string(of_node, "label",
- &flashdata->sensor_name);
- CDBG("%s label %s, rc %d\n", __func__,
- flashdata->sensor_name, rc);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto ERROR1;
- }
-
- rc = of_property_read_u32(of_node, "qcom,cci-master",
- &fctrl->cci_i2c_master);
- CDBG("%s qcom,cci-master %d, rc %d\n", __func__, fctrl->cci_i2c_master,
- rc);
- if (rc < 0) {
- /* Set default master 0 */
- fctrl->cci_i2c_master = MASTER_0;
- rc = 0;
- }
-
- fctrl->pinctrl_info.use_pinctrl = of_property_read_bool(of_node,
- "qcom,enable_pinctrl");
- if (of_get_property(of_node, "qcom,flash-source", &count)) {
- count /= sizeof(uint32_t);
- CDBG("count %d\n", count);
- if (count > MAX_LED_TRIGGERS) {
- pr_err("failed\n");
- return -EINVAL;
- }
- for (i = 0; i < count; i++) {
- flash_src_node = of_parse_phandle(of_node,
- "qcom,flash-source", i);
- if (!flash_src_node) {
- pr_err("flash_src_node NULL\n");
- continue;
- }
-
- rc = of_property_read_string(flash_src_node,
- "linux,default-trigger",
- &fctrl->flash_trigger_name[i]);
- if (rc < 0) {
- pr_err("failed\n");
- of_node_put(flash_src_node);
- continue;
- }
-
- CDBG("default trigger %s\n",
- fctrl->flash_trigger_name[i]);
-
- rc = of_property_read_u32(flash_src_node,
- "qcom,max-current",
- &fctrl->flash_op_current[i]);
- if (rc < 0) {
- pr_err("failed rc %d\n", rc);
- of_node_put(flash_src_node);
- continue;
- }
-
- of_node_put(flash_src_node);
-
- CDBG("max_current[%d] %d\n",
- i, fctrl->flash_op_current[i]);
-
- led_trigger_register_simple(
- fctrl->flash_trigger_name[i],
- &fctrl->flash_trigger[i]);
- }
- } else { /*Handle LED Flash Ctrl by GPIO*/
- power_info->gpio_conf =
- kzalloc(sizeof(struct msm_camera_gpio_conf),
- GFP_KERNEL);
- if (!power_info->gpio_conf)
- return -ENOMEM;
- gconf = power_info->gpio_conf;
-
- gpio_array_size = of_gpio_count(of_node);
- CDBG("%s gpio count %d\n", __func__, gpio_array_size);
-
- if (gpio_array_size) {
- gpio_array =
- kcalloc(gpio_array_size, sizeof(uint16_t),
- GFP_KERNEL);
- if (!gpio_array) {
- rc = -ENOMEM;
- goto ERROR4;
- }
- for (i = 0; i < gpio_array_size; i++) {
- gpio_array[i] = of_get_gpio(of_node, i);
- CDBG("%s gpio_array[%d] = %d\n", __func__, i,
- gpio_array[i]);
- }
-
- rc = msm_camera_get_dt_gpio_req_tbl(of_node, gconf,
- gpio_array, gpio_array_size);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto ERROR4;
- }
-
- rc = msm_camera_get_dt_gpio_set_tbl(of_node, gconf,
- gpio_array, gpio_array_size);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto ERROR5;
- }
-
- rc = msm_camera_init_gpio_pin_tbl(of_node, gconf,
- gpio_array, gpio_array_size);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto ERROR6;
- }
- }
-
- /* Read the max current for an LED if present */
- if (of_get_property(of_node, "qcom,max-current", &count)) {
- count /= sizeof(uint32_t);
-
- if (count > MAX_LED_TRIGGERS) {
- pr_err("failed\n");
- rc = -EINVAL;
- goto ERROR8;
- }
-
- fctrl->flash_num_sources = count;
- fctrl->torch_num_sources = count;
-
- rc = of_property_read_u32_array(of_node,
- "qcom,max-current",
- fctrl->flash_max_current, count);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto ERROR8;
- }
-
- for (; count < MAX_LED_TRIGGERS; count++)
- fctrl->flash_max_current[count] = 0;
-
- for (count = 0; count < MAX_LED_TRIGGERS; count++)
- fctrl->torch_max_current[count] =
- fctrl->flash_max_current[count] >> 1;
- }
-
- /* Read the max duration for an LED if present */
- if (of_get_property(of_node, "qcom,max-duration", &count)) {
- count /= sizeof(uint32_t);
-
- if (count > MAX_LED_TRIGGERS) {
- pr_err("failed\n");
- rc = -EINVAL;
- goto ERROR8;
- }
-
- rc = of_property_read_u32_array(of_node,
- "qcom,max-duration",
- fctrl->flash_max_duration, count);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto ERROR8;
- }
-
- for (; count < MAX_LED_TRIGGERS; count++)
- fctrl->flash_max_duration[count] = 0;
- }
-
- flashdata->slave_info =
- kzalloc(sizeof(struct msm_camera_slave_info),
- GFP_KERNEL);
- if (!flashdata->slave_info) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- rc = -ENOMEM;
- goto ERROR8;
- }
-
- rc = of_property_read_u32_array(of_node, "qcom,slave-id",
- id_info, 3);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto ERROR9;
- }
- fctrl->flashdata->slave_info->sensor_slave_addr = id_info[0];
- fctrl->flashdata->slave_info->sensor_id_reg_addr = id_info[1];
- fctrl->flashdata->slave_info->sensor_id = id_info[2];
-
- kfree(gpio_array);
- return rc;
-ERROR9:
- kfree(fctrl->flashdata->slave_info);
-ERROR8:
- kfree(fctrl->flashdata->power_info.gpio_conf->gpio_num_info);
-ERROR6:
- kfree(gconf->cam_gpio_set_tbl);
-ERROR5:
- kfree(gconf->cam_gpio_req_tbl);
-ERROR4:
- kfree(gconf);
-ERROR1:
- kfree(fctrl->flashdata);
- kfree(gpio_array);
- }
- return rc;
-}
-
-static struct msm_camera_i2c_fn_t msm_sensor_qup_func_tbl = {
- .i2c_read = msm_camera_qup_i2c_read,
- .i2c_read_seq = msm_camera_qup_i2c_read_seq,
- .i2c_write = msm_camera_qup_i2c_write,
- .i2c_write_table = msm_camera_qup_i2c_write_table,
- .i2c_write_seq_table = msm_camera_qup_i2c_write_seq_table,
- .i2c_write_table_w_microdelay =
- msm_camera_qup_i2c_write_table_w_microdelay,
-};
-
-static struct msm_camera_i2c_fn_t msm_sensor_cci_func_tbl = {
- .i2c_read = msm_camera_cci_i2c_read,
- .i2c_read_seq = msm_camera_cci_i2c_read_seq,
- .i2c_write = msm_camera_cci_i2c_write,
- .i2c_write_table = msm_camera_cci_i2c_write_table,
- .i2c_write_seq_table = msm_camera_cci_i2c_write_seq_table,
- .i2c_write_table_w_microdelay =
- msm_camera_cci_i2c_write_table_w_microdelay,
- .i2c_util = msm_sensor_cci_i2c_util,
- .i2c_write_conf_tbl = msm_camera_cci_i2c_write_conf_tbl,
-};
-
-#ifdef CONFIG_DEBUG_FS
-static int set_led_status(void *data, u64 val)
-{
- struct msm_led_flash_ctrl_t *fctrl =
- (struct msm_led_flash_ctrl_t *)data;
- int rc = -1;
-
- pr_debug("set_led_status: Enter val: %llu", val);
- if (!fctrl) {
- pr_err("set_led_status: fctrl is NULL");
- return rc;
- }
- if (!fctrl->func_tbl) {
- pr_err("set_led_status: fctrl->func_tbl is NULL");
- return rc;
- }
- if (val == 0) {
- pr_debug("set_led_status: val is disable");
- rc = msm_flash_led_off(fctrl);
- if (rc < 0) {
- pr_err("%s led_off failed line %d\n",
- __func__, __LINE__);
- return rc;
- }
- rc = msm_flash_led_release(fctrl);
- if (rc < 0) {
- pr_err("%s led_release failed line %d\n",
- __func__, __LINE__);
- return rc;
- }
- } else {
- pr_debug("set_led_status: val is enable");
- rc = msm_flash_led_init(fctrl);
- if (rc < 0) {
- pr_err("%s led_init failed line %d\n",
- __func__, __LINE__);
- return rc;
- }
- rc = msm_flash_led_low(fctrl);
- if (rc < 0) {
- pr_err("%s led_low failed line %d\n",
- __func__, __LINE__);
- return rc;
- }
- }
-
- return rc;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(ledflashdbg_fops,
- NULL, set_led_status, "%llu\n");
-#endif
-
-static void msm_led_i2c_torch_brightness_set(struct led_classdev *led_cdev,
- enum led_brightness value)
-{
- struct msm_led_flash_ctrl_t *fctrl = NULL;
-
- if (g_fctrl == NULL)
- return;
-
- fctrl = (struct msm_led_flash_ctrl_t *) g_fctrl;
-
- if (value > LED_OFF) {
- if (fctrl->func_tbl->flash_led_init)
- fctrl->func_tbl->flash_led_init(fctrl);
- if (fctrl->func_tbl->flash_led_low)
- fctrl->func_tbl->flash_led_low(fctrl);
- } else {
- if (fctrl->func_tbl->flash_led_off)
- fctrl->func_tbl->flash_led_off(fctrl);
- if (fctrl->func_tbl->flash_led_release)
- fctrl->func_tbl->flash_led_release(fctrl);
- }
-};
-
-static struct led_classdev msm_torch_i2c_led = {
- .name = "torch-light",
- .brightness_set = msm_led_i2c_torch_brightness_set,
- .brightness = LED_OFF,
-};
-
-static int32_t msm_i2c_torch_create_classdev(struct device *dev ,
- void *data)
-{
- int rc;
-
- msm_led_i2c_torch_brightness_set(&msm_torch_i2c_led, LED_OFF);
- rc = led_classdev_register(dev, &msm_torch_i2c_led);
- if (rc) {
- pr_err("Failed to register led dev. rc = %d\n", rc);
- return rc;
- }
-
- return 0;
-};
-
-int msm_flash_i2c_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
-{
- int rc = 0;
- struct msm_led_flash_ctrl_t *fctrl = NULL;
-#ifdef CONFIG_DEBUG_FS
- struct dentry *dentry;
-#endif
- if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
- pr_err("i2c_check_functionality failed\n");
- goto probe_failure;
- }
-
- fctrl = (struct msm_led_flash_ctrl_t *)(id->driver_data);
- if (fctrl->flash_i2c_client)
- fctrl->flash_i2c_client->client = client;
- /* Set device type as I2C */
- fctrl->flash_device_type = MSM_CAMERA_I2C_DEVICE;
-
- /* Assign name for sub device */
- snprintf(fctrl->msm_sd.sd.name, sizeof(fctrl->msm_sd.sd.name),
- "%s", id->name);
-
- rc = msm_led_get_dt_data(client->dev.of_node, fctrl);
- if (rc < 0) {
- pr_err("%s failed line %d\n", __func__, __LINE__);
- return rc;
- }
-
- if (fctrl->pinctrl_info.use_pinctrl == true)
- msm_flash_pinctrl_init(fctrl);
-
- if (fctrl->flash_i2c_client != NULL) {
- fctrl->flash_i2c_client->client = client;
- if (fctrl->flashdata->slave_info->sensor_slave_addr)
- fctrl->flash_i2c_client->client->addr =
- fctrl->flashdata->slave_info->
- sensor_slave_addr;
- } else {
- pr_err("%s %s sensor_i2c_client NULL\n",
- __func__, client->name);
- rc = -EFAULT;
- return rc;
- }
-
- if (!fctrl->flash_i2c_client->i2c_func_tbl)
- fctrl->flash_i2c_client->i2c_func_tbl =
- &msm_sensor_qup_func_tbl;
-
- rc = msm_led_i2c_flash_create_v4lsubdev(fctrl);
-#ifdef CONFIG_DEBUG_FS
- dentry = debugfs_create_file("ledflash", S_IRUGO, NULL, (void *)fctrl,
- &ledflashdbg_fops);
- if (!dentry)
- pr_err("Failed to create the debugfs ledflash file");
-#endif
- /* Assign Global flash control struture for local usage */
- g_fctrl = (void *) fctrl;
- rc = msm_i2c_torch_create_classdev(&(client->dev), NULL);
- if (rc) {
- pr_err("%s failed to create classdev %d\n", __func__, __LINE__);
- return rc;
- }
- CDBG("%s:%d probe success\n", __func__, __LINE__);
- return 0;
-
-probe_failure:
- CDBG("%s:%d probe failed\n", __func__, __LINE__);
- return rc;
-}
-
-int msm_flash_probe(struct platform_device *pdev,
- const void *data)
-{
- int rc = 0;
- struct msm_led_flash_ctrl_t *fctrl =
- (struct msm_led_flash_ctrl_t *)data;
- struct device_node *of_node = pdev->dev.of_node;
- struct msm_camera_cci_client *cci_client = NULL;
-
- if (!of_node) {
- pr_err("of_node NULL\n");
- goto probe_failure;
- }
- fctrl->pdev = pdev;
-
- rc = msm_led_get_dt_data(pdev->dev.of_node, fctrl);
- if (rc < 0) {
- pr_err("%s failed line %d rc = %d\n", __func__, __LINE__, rc);
- return rc;
- }
-
- if (fctrl->pinctrl_info.use_pinctrl == true)
- msm_flash_pinctrl_init(fctrl);
-
- /* Assign name for sub device */
- snprintf(fctrl->msm_sd.sd.name, sizeof(fctrl->msm_sd.sd.name),
- "%s", fctrl->flashdata->sensor_name);
- /* Set device type as Platform*/
- fctrl->flash_device_type = MSM_CAMERA_PLATFORM_DEVICE;
-
- if (NULL == fctrl->flash_i2c_client) {
- pr_err("%s flash_i2c_client NULL\n",
- __func__);
- rc = -EFAULT;
- goto probe_failure;
- }
-
- fctrl->flash_i2c_client->cci_client = kzalloc(sizeof(
- struct msm_camera_cci_client), GFP_KERNEL);
- if (!fctrl->flash_i2c_client->cci_client)
- return rc;
-
- cci_client = fctrl->flash_i2c_client->cci_client;
- cci_client->cci_subdev = msm_cci_get_subdev();
- cci_client->cci_i2c_master = fctrl->cci_i2c_master;
- if (fctrl->flashdata->slave_info->sensor_slave_addr)
- cci_client->sid =
- fctrl->flashdata->slave_info->sensor_slave_addr >> 1;
- cci_client->retries = 3;
- cci_client->id_map = 0;
-
- if (!fctrl->flash_i2c_client->i2c_func_tbl)
- fctrl->flash_i2c_client->i2c_func_tbl =
- &msm_sensor_cci_func_tbl;
-
- rc = msm_led_flash_create_v4lsubdev(pdev, fctrl);
-
- CDBG("%s: probe success\n", __func__);
- return 0;
-
-probe_failure:
- CDBG("%s probe failed\n", __func__);
- return rc;
-}
-
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_torch.c b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_torch.c
deleted file mode 100644
index c4ed4fa17805..000000000000
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_torch.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright (c) 2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
-#include <linux/module.h>
-#include "msm_led_flash.h"
-
-static struct led_trigger *torch_trigger;
-
-static void msm_led_torch_brightness_set(struct led_classdev *led_cdev,
- enum led_brightness value)
-{
- if (!torch_trigger) {
- pr_err("No torch trigger found, can't set brightness\n");
- return;
- }
-
- led_trigger_event(torch_trigger, value);
-};
-
-static struct led_classdev msm_torch_led[MAX_LED_TRIGGERS] = {
- {
- .name = "torch-light0",
- .brightness_set = msm_led_torch_brightness_set,
- .brightness = LED_OFF,
- },
- {
- .name = "torch-light1",
- .brightness_set = msm_led_torch_brightness_set,
- .brightness = LED_OFF,
- },
- {
- .name = "torch-light2",
- .brightness_set = msm_led_torch_brightness_set,
- .brightness = LED_OFF,
- },
-};
-
-int32_t msm_led_torch_create_classdev(struct platform_device *pdev,
- void *data)
-{
- int32_t i, rc = 0;
- struct msm_led_flash_ctrl_t *fctrl =
- (struct msm_led_flash_ctrl_t *)data;
-
- if (!fctrl) {
- pr_err("Invalid fctrl\n");
- return -EINVAL;
- }
-
- for (i = 0; i < fctrl->torch_num_sources; i++) {
- if (fctrl->torch_trigger[i]) {
- torch_trigger = fctrl->torch_trigger[i];
- msm_led_torch_brightness_set(&msm_torch_led[i],
- LED_OFF);
-
- rc = led_classdev_register(&pdev->dev,
- &msm_torch_led[i]);
- if (rc) {
- pr_err("Failed to register %d led dev. rc = %d\n",
- i, rc);
- return rc;
- }
- } else {
- pr_err("Invalid fctrl->torch_trigger[%d]\n", i);
- return -EINVAL;
- }
- }
-
- return 0;
-};
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_trigger.c b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_trigger.c
deleted file mode 100644
index ff80801a21cd..000000000000
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_trigger.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/* Copyright (c) 2017, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#define pr_fmt(fmt) "%s:%d " fmt, __func__, __LINE__
-
-#include <linux/module.h>
-#include "msm_led_flash.h"
-
-#define FLASH_NAME "camera-led-flash"
-
-#undef CDBG
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-
-static enum flash_type flashtype;
-static struct msm_led_flash_ctrl_t fctrl;
-
-static int32_t msm_led_trigger_get_subdev_id(struct msm_led_flash_ctrl_t *fctrl,
- void *arg)
-{
- uint32_t *subdev_id = (uint32_t *)arg;
-
- if (!subdev_id) {
- pr_err("%s:%d failed\n", __func__, __LINE__);
- return -EINVAL;
- }
- *subdev_id = fctrl->pdev->id;
- CDBG("%s:%d subdev_id %d\n", __func__, __LINE__, *subdev_id);
- return 0;
-}
-
-static int32_t msm_led_trigger_config(struct msm_led_flash_ctrl_t *fctrl,
- void *data)
-{
- int rc = 0;
- struct msm_camera_led_cfg_t *cfg = (struct msm_camera_led_cfg_t *)data;
- uint32_t i;
- uint32_t curr_l, max_curr_l;
-
- CDBG("called led_state %d\n", cfg->cfgtype);
-
- if (!fctrl) {
- pr_err("failed\n");
- return -EINVAL;
- }
-
- switch (cfg->cfgtype) {
- case MSM_CAMERA_LED_OFF:
- /* Flash off */
- for (i = 0; i < fctrl->flash_num_sources; i++)
- if (fctrl->flash_trigger[i])
- led_trigger_event(fctrl->flash_trigger[i], 0);
- /* Torch off */
- for (i = 0; i < fctrl->torch_num_sources; i++)
- if (fctrl->torch_trigger[i])
- led_trigger_event(fctrl->torch_trigger[i], 0);
- break;
-
- case MSM_CAMERA_LED_LOW:
- for (i = 0; i < fctrl->torch_num_sources; i++)
- if (fctrl->torch_trigger[i]) {
- max_curr_l = fctrl->torch_max_current[i];
- if (cfg->torch_current[i] >= 0 &&
- cfg->torch_current[i] < max_curr_l) {
- curr_l = cfg->torch_current[i];
- } else {
- curr_l = fctrl->torch_op_current[i];
- pr_debug("LED torch %d clamped %d\n",
- i, curr_l);
- }
- led_trigger_event(fctrl->torch_trigger[i],
- curr_l);
- }
- break;
-
- case MSM_CAMERA_LED_HIGH:
- /* Torch off */
- for (i = 0; i < fctrl->torch_num_sources; i++)
- if (fctrl->torch_trigger[i])
- led_trigger_event(fctrl->torch_trigger[i], 0);
-
- for (i = 0; i < fctrl->flash_num_sources; i++)
- if (fctrl->flash_trigger[i]) {
- max_curr_l = fctrl->flash_max_current[i];
- if (cfg->flash_current[i] >= 0 &&
- cfg->flash_current[i] < max_curr_l) {
- curr_l = cfg->flash_current[i];
- } else {
- curr_l = fctrl->flash_op_current[i];
- pr_debug("LED flash %d clamped %d\n",
- i, curr_l);
- }
- led_trigger_event(fctrl->flash_trigger[i],
- curr_l);
- }
- break;
-
- case MSM_CAMERA_LED_INIT:
- case MSM_CAMERA_LED_RELEASE:
- /* Flash off */
- for (i = 0; i < fctrl->flash_num_sources; i++)
- if (fctrl->flash_trigger[i])
- led_trigger_event(fctrl->flash_trigger[i], 0);
- /* Torch off */
- for (i = 0; i < fctrl->torch_num_sources; i++)
- if (fctrl->torch_trigger[i])
- led_trigger_event(fctrl->torch_trigger[i], 0);
- break;
-
- default:
- rc = -EFAULT;
- break;
- }
- CDBG("flash_set_led_state: return %d\n", rc);
- return rc;
-}
-
-static const struct of_device_id msm_led_trigger_dt_match[] = {
- {.compatible = "qcom,camera-led-flash"},
- {}
-};
-
-static int32_t msm_led_trigger_probe(struct platform_device *pdev)
-{
- int32_t rc = 0, rc_1 = 0, i = 0;
- struct device_node *of_node = pdev->dev.of_node;
- struct device_node *flash_src_node = NULL;
- uint32_t count = 0;
- struct led_trigger *temp = NULL;
-
- CDBG("called\n");
-
- if (!of_node) {
- pr_err("of_node NULL\n");
- return -EINVAL;
- }
-
- fctrl.pdev = pdev;
- fctrl.flash_num_sources = 0;
- fctrl.torch_num_sources = 0;
-
- rc = of_property_read_u32(of_node, "cell-index", &pdev->id);
- if (rc < 0) {
- pr_err("failed\n");
- return -EINVAL;
- }
- CDBG("pdev id %d\n", pdev->id);
-
- rc = of_property_read_u32(of_node,
- "qcom,flash-type", &flashtype);
- if (rc < 0) {
- pr_err("flash-type: read failed\n");
- return -EINVAL;
- }
-
- /* Flash source */
- if (of_get_property(of_node, "qcom,flash-source", &count)) {
- count /= sizeof(uint32_t);
- CDBG("qcom,flash-source count %d\n", count);
- if (count > MAX_LED_TRIGGERS) {
- pr_err("invalid count qcom,flash-source %d\n", count);
- return -EINVAL;
- }
- fctrl.flash_num_sources = count;
- for (i = 0; i < fctrl.flash_num_sources; i++) {
- flash_src_node = of_parse_phandle(of_node,
- "qcom,flash-source", i);
- if (!flash_src_node) {
- pr_err("flash_src_node %d NULL\n", i);
- continue;
- }
-
- rc = of_property_read_string(flash_src_node,
- "linux,default-trigger",
- &fctrl.flash_trigger_name[i]);
-
- rc_1 = of_property_read_string(flash_src_node,
- "qcom,default-led-trigger",
- &fctrl.flash_trigger_name[i]);
- if ((rc < 0) && (rc_1 < 0)) {
- pr_err("default-trigger: read failed\n");
- of_node_put(flash_src_node);
- continue;
- }
-
- CDBG("default trigger %s\n",
- fctrl.flash_trigger_name[i]);
-
- if (flashtype == GPIO_FLASH) {
- /* use fake current */
- fctrl.flash_op_current[i] = LED_FULL;
- } else {
- rc = of_property_read_u32(flash_src_node,
- "qcom,current",
- &fctrl.flash_op_current[i]);
- rc_1 = of_property_read_u32(flash_src_node,
- "qcom,max-current",
- &fctrl.flash_max_current[i]);
- if ((rc < 0) || (rc_1 < 0)) {
- pr_err("current: read failed\n");
- of_node_put(flash_src_node);
- continue;
- }
- }
-
- of_node_put(flash_src_node);
-
- CDBG("max_current[%d] %d\n",
- i, fctrl.flash_op_current[i]);
-
- led_trigger_register_simple(fctrl.flash_trigger_name[i],
- &fctrl.flash_trigger[i]);
-
- if (flashtype == GPIO_FLASH)
- if (fctrl.flash_trigger[i])
- temp = fctrl.flash_trigger[i];
- }
-
- }
- /* Torch source */
- if (of_get_property(of_node, "qcom,torch-source", &count)) {
- count /= sizeof(uint32_t);
- CDBG("qcom,torch-source count %d\n", count);
- if (count > MAX_LED_TRIGGERS) {
- pr_err("invalid count qcom,torch-source %d\n", count);
- return -EINVAL;
- }
- fctrl.torch_num_sources = count;
-
- for (i = 0; i < fctrl.torch_num_sources; i++) {
- flash_src_node = of_parse_phandle(of_node,
- "qcom,torch-source", i);
- if (!flash_src_node) {
- pr_err("torch_src_node %d NULL\n", i);
- continue;
- }
-
- rc = of_property_read_string(flash_src_node,
- "linux,default-trigger",
- &fctrl.torch_trigger_name[i]);
-
- rc_1 = of_property_read_string(flash_src_node,
- "qcom,default-led-trigger",
- &fctrl.torch_trigger_name[i]);
- if ((rc < 0) && (rc_1 < 0)) {
- pr_err("default-trigger: read failed\n");
- of_node_put(flash_src_node);
- continue;
- }
-
- CDBG("default trigger %s\n",
- fctrl.torch_trigger_name[i]);
-
- if (flashtype == GPIO_FLASH) {
- /* use fake current */
- fctrl.torch_op_current[i] = LED_HALF;
- } else {
- rc = of_property_read_u32(flash_src_node,
- "qcom,current",
- &fctrl.torch_op_current[i]);
- rc_1 = of_property_read_u32(flash_src_node,
- "qcom,max-current",
- &fctrl.torch_max_current[i]);
- if ((rc < 0) || (rc_1 < 0)) {
- pr_err("current: read failed\n");
- of_node_put(flash_src_node);
- continue;
- }
- }
-
- of_node_put(flash_src_node);
-
- CDBG("torch max_current[%d] %d\n",
- i, fctrl.torch_op_current[i]);
-
- led_trigger_register_simple(fctrl.torch_trigger_name[i],
- &fctrl.torch_trigger[i]);
-
- if (flashtype == GPIO_FLASH)
- if (temp && !fctrl.torch_trigger[i])
- fctrl.torch_trigger[i] = temp;
- }
- }
-
- rc = msm_led_flash_create_v4lsubdev(pdev, &fctrl);
- if (!rc)
- msm_led_torch_create_classdev(pdev, &fctrl);
-
- return rc;
-}
-
-MODULE_DEVICE_TABLE(of, msm_led_trigger_dt_match);
-
-static struct platform_driver msm_led_trigger_driver = {
- .probe = msm_led_trigger_probe,
- .driver = {
- .name = FLASH_NAME,
- .owner = THIS_MODULE,
- .of_match_table = msm_led_trigger_dt_match,
- },
-};
-
-static int __init msm_led_trigger_add_driver(void)
-{
- CDBG("called\n");
- return platform_driver_register(&msm_led_trigger_driver);
-}
-
-static struct msm_flash_fn_t msm_led_trigger_func_tbl = {
- .flash_get_subdev_id = msm_led_trigger_get_subdev_id,
- .flash_led_config = msm_led_trigger_config,
-};
-
-static struct msm_led_flash_ctrl_t fctrl = {
- .func_tbl = &msm_led_trigger_func_tbl,
-};
-
-module_init(msm_led_trigger_add_driver);
-MODULE_DESCRIPTION("LED TRIGGER FLASH");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v2/sensor/io/Makefile b/drivers/media/platform/msm/camera_v2/sensor/io/Makefile
index 549c35a806f7..ec958697ae13 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/io/Makefile
+++ b/drivers/media/platform/msm/camera_v2/sensor/io/Makefile
@@ -2,5 +2,4 @@ ccflags-y += -Idrivers/media/platform/msm/camera_v2/
ccflags-y += -Idrivers/media/platform/msm/camera_v2/common
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor
ccflags-y += -Idrivers/media/platform/msm/camera_v2/sensor/cci
-ccflags-y += -Idrivers/misc/
-obj-$(CONFIG_MSMB_CAMERA) += msm_camera_cci_i2c.o msm_camera_qup_i2c.o msm_camera_spi.o msm_camera_dt_util.o msm_camera_tz_i2c.o
+obj-$(CONFIG_MSMB_CAMERA) += msm_camera_cci_i2c.o msm_camera_qup_i2c.o msm_camera_spi.o msm_camera_dt_util.o
diff --git a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_cci_i2c.c b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_cci_i2c.c
index abc48cb09b8a..d97279d4740c 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_cci_i2c.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_cci_i2c.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2016, 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
@@ -17,15 +17,13 @@
#undef CDBG
#define CDBG(fmt, args...) pr_debug(fmt, ##args)
#define S_I2C_DBG(fmt, args...) pr_debug(fmt, ##args)
-#define MAX_I2C_ADDR_TYPE_SIZE (MSM_CAMERA_I2C_3B_ADDR + 1)
-#define MAX_I2C_DATA_TYPE_SIZE (MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA + 1)
int32_t msm_camera_cci_i2c_read(struct msm_camera_i2c_client *client,
uint32_t addr, uint16_t *data,
enum msm_camera_i2c_data_type data_type)
{
int32_t rc = -EFAULT;
- unsigned char buf[MAX_I2C_ADDR_TYPE_SIZE + MAX_I2C_DATA_TYPE_SIZE];
+ unsigned char buf[client->addr_type+data_type];
struct msm_camera_cci_ctrl cci_ctrl;
if ((client->addr_type != MSM_CAMERA_I2C_BYTE_ADDR
@@ -72,8 +70,8 @@ int32_t msm_camera_cci_i2c_read_seq(struct msm_camera_i2c_client *client,
return rc;
if (num_byte > I2C_REG_DATA_MAX) {
- S_I2C_DBG("%s: Error num_byte:0x%x exceeds 8K max supported:0x%x\n",
- __func__, num_byte, I2C_REG_DATA_MAX);
+ pr_err("%s: Error num_byte:0x%x exceeds 8K max supported:0x%x\n",
+ __func__, num_byte, I2C_REG_DATA_MAX);
return rc;
}
diff --git a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
index ccd27472efc3..3be49df97b90 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -217,10 +217,7 @@ int msm_sensor_get_sub_module_index(struct device_node *of_node,
pr_err("%s failed %d\n", __func__, __LINE__);
goto ERROR;
}
- if (of_device_is_available(src_node))
- sensor_info->subdev_id[SUB_MODULE_ACTUATOR] = val;
- else
- CDBG("%s:%d actuator disabled!\n", __func__, __LINE__);
+ sensor_info->subdev_id[SUB_MODULE_ACTUATOR] = val;
of_node_put(src_node);
src_node = NULL;
}
@@ -1454,7 +1451,7 @@ int32_t msm_sensor_driver_get_gpio_data(
gpio_array_size = of_gpio_count(of_node);
CDBG("gpio count %d\n", gpio_array_size);
if (gpio_array_size <= 0)
- return -ENODEV;
+ return 0;
gconf = kzalloc(sizeof(struct msm_camera_gpio_conf),
GFP_KERNEL);
@@ -1471,7 +1468,6 @@ int32_t msm_sensor_driver_get_gpio_data(
gpio_array[i] = of_get_gpio(of_node, i);
CDBG("gpio_array[%d] = %d", i, gpio_array[i]);
}
-
rc = msm_camera_get_dt_gpio_req_tbl(of_node, gconf, gpio_array,
gpio_array_size);
if (rc < 0) {
@@ -1479,13 +1475,6 @@ int32_t msm_sensor_driver_get_gpio_data(
goto FREE_GPIO_CONF;
}
- rc = msm_camera_get_dt_gpio_set_tbl(of_node, gconf,
- gpio_array, gpio_array_size);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto FREE_GPIO_REQ_TBL;
- }
-
rc = msm_camera_init_gpio_pin_tbl(of_node, gconf, gpio_array,
gpio_array_size);
if (rc < 0) {
@@ -1494,6 +1483,7 @@ int32_t msm_sensor_driver_get_gpio_data(
}
kfree(gpio_array);
return rc;
+
FREE_GPIO_REQ_TBL:
kfree(gconf->cam_gpio_req_tbl);
FREE_GPIO_CONF:
diff --git a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.h b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.h
index 78c34126e95b..220915511cce 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, 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
@@ -36,10 +36,6 @@ int msm_camera_get_dt_power_setting_data(struct device_node *of_node,
struct camera_vreg_t *cam_vreg, int num_vreg,
struct msm_camera_power_ctrl_t *power_info);
-int msm_camera_get_dt_gpio_set_tbl(struct device_node *of_node,
- struct msm_camera_gpio_conf *gconf, uint16_t *gpio_array,
- uint16_t gpio_array_size);
-
int msm_camera_get_dt_gpio_req_tbl(struct device_node *of_node,
struct msm_camera_gpio_conf *gconf, uint16_t *gpio_array,
uint16_t gpio_array_size);
diff --git a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_i2c.h b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_i2c.h
index 785dd54d65e1..0fbe35713d8e 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_i2c.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_i2c.h
@@ -152,60 +152,4 @@ int32_t msm_camera_qup_i2c_poll(struct msm_camera_i2c_client *client,
uint32_t addr, uint16_t data,
enum msm_camera_i2c_data_type data_type, uint32_t delay_ms);
-int32_t msm_camera_tz_i2c_register_sensor(void *s_ctrl_p);
-
-int32_t msm_camera_tz_i2c_power_up(struct msm_camera_i2c_client *client);
-
-int32_t msm_camera_tz_i2c_power_down(struct msm_camera_i2c_client *client);
-
-int32_t msm_camera_tz_i2c_read(struct msm_camera_i2c_client *client,
- uint32_t addr, uint16_t *data,
- enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_camera_tz_i2c_read_seq(struct msm_camera_i2c_client *client,
- uint32_t addr, uint8_t *data, uint32_t num_byte);
-
-int32_t msm_camera_tz_i2c_write(struct msm_camera_i2c_client *client,
- uint32_t addr, uint16_t data,
- enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_camera_tz_i2c_write_seq(struct msm_camera_i2c_client *client,
- uint32_t addr, uint8_t *data, uint32_t num_byte);
-
-int32_t msm_camera_tz_i2c_write_table(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting);
-
-int32_t msm_camera_tz_i2c_write_table_async(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting);
-
-int32_t msm_camera_tz_i2c_write_table_sync(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting);
-
-int32_t msm_camera_tz_i2c_write_table_sync_block(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting);
-
-int32_t msm_camera_tz_i2c_write_seq_table(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_seq_reg_setting *write_setting);
-
-int32_t msm_camera_tz_i2c_write_table_w_microdelay(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting);
-
-int32_t msm_camera_tz_i2c_write_conf_tbl(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_conf *reg_conf_tbl, uint16_t size,
- enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_sensor_tz_i2c_util(struct msm_camera_i2c_client *client,
- uint16_t cci_cmd);
-
-int32_t msm_camera_tz_i2c_poll(struct msm_camera_i2c_client *client,
- uint32_t addr, uint16_t data,
- enum msm_camera_i2c_data_type data_type);
-
#endif
diff --git a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_qup_i2c.c b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_qup_i2c.c
index 37ac08841caa..e2c18c5eaaa3 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_qup_i2c.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_qup_i2c.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011, 2013-2016, 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
@@ -144,14 +144,14 @@ int32_t msm_camera_qup_i2c_read(struct msm_camera_i2c_client *client,
return rc;
if (client->addr_type > UINT_MAX - data_type) {
- S_I2C_DBG("%s: integer overflow prevented\n", __func__);
- return rc;
+ pr_err("%s: integer overflow prevented\n", __func__);
+ return rc;
}
buf = msm_camera_qup_get_rxbuf(client->addr_type+data_type);
if (buf == NULL) {
- S_I2C_DBG("%s: no rx buffer memory\n", __func__);
+ pr_err("%s: no rx buffer memory\n", __func__);
return -ENOMEM;
}
@@ -191,19 +191,19 @@ int32_t msm_camera_qup_i2c_read_seq(struct msm_camera_i2c_client *client,
return rc;
if (num_byte > I2C_REG_DATA_MAX) {
- S_I2C_DBG("%s: Error num_byte:0x%x exceeds 8K max supported:0x%x\n",
- __func__, num_byte, I2C_REG_DATA_MAX);
- return rc;
+ pr_err("%s: Error num_byte:0x%x exceeds 8K max supported:0x%x\n",
+ __func__, num_byte, I2C_REG_DATA_MAX);
+ return rc;
}
if (client->addr_type > UINT_MAX - num_byte) {
- S_I2C_DBG("%s: integer overflow prevented\n", __func__);
- return rc;
+ pr_err("%s: integer overflow prevented\n", __func__);
+ return rc;
}
buf = msm_camera_qup_get_rxbuf(client->addr_type+num_byte);
if (buf == NULL) {
- S_I2C_DBG("%s: no rx buffer memory\n", __func__);
+ pr_err("%s: no rx buffer memory\n", __func__);
return -ENOMEM;
}
@@ -345,7 +345,6 @@ int32_t msm_camera_qup_i2c_write_table(struct msm_camera_i2c_client *client,
int32_t rc = -EFAULT;
struct msm_camera_i2c_reg_array *reg_setting;
uint16_t client_addr_type;
- int retry = 0;
if (!client || !write_setting)
return rc;
@@ -363,20 +362,11 @@ int32_t msm_camera_qup_i2c_write_table(struct msm_camera_i2c_client *client,
for (i = 0; i < write_setting->size; i++) {
CDBG("%s addr 0x%x data 0x%x\n", __func__,
reg_setting->reg_addr, reg_setting->reg_data);
- do {
- rc = msm_camera_qup_i2c_write(client,
- reg_setting->reg_addr, reg_setting->reg_data,
- write_setting->data_type);
- if (rc >= 0)
- break;
- } while (retry++ < 2);
- if (rc < 0) {
- pr_err("FAILED: %s addr 0x%x data 0x%x\n", __func__,
- reg_setting->reg_addr, reg_setting->reg_data);
+ rc = msm_camera_qup_i2c_write(client, reg_setting->reg_addr,
+ reg_setting->reg_data, write_setting->data_type);
+ if (rc < 0)
break;
- }
- retry = 0;
reg_setting++;
}
if (write_setting->delay > 20)
diff --git a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_tz_i2c.c b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_tz_i2c.c
deleted file mode 100644
index 5a330db0f9a5..000000000000
--- a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_tz_i2c.c
+++ /dev/null
@@ -1,1093 +0,0 @@
-/* Copyright (c) 2016, 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
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/ktime.h>
-#include <linux/mutex.h>
-#include <soc/qcom/camera2.h>
-#include "qseecom_kernel.h"
-#include "msm_camera_i2c.h"
-#include "msm_camera_io_util.h"
-#include "msm_cci.h"
-#include "msm_sensor.h"
-
-#define QSEECOM_SBUFF_SIZE SZ_128K
-#define MAX_TA_NAME 32
-#define EMPTY_QSEECOM_HANDLE NULL
-
-#ifndef CONFIG_MSM_SEC_CCI_TA_NAME
- #define CONFIG_MSM_SEC_CCI_TA_NAME "seccamdemo64"
-#endif /* CONFIG_MSM_SEC_CCI_TA_NAME */
-
-/* Update version major number in case the HLOS-TA interface is changed*/
-#define TA_IF_VERSION_MAJ 0
-#define TA_IF_VERSION_MIN 1
-
-#undef CDBG
-#ifdef CONFIG_MSM_SEC_CCI_DEBUG
-
-#define CDBG(fmt, args...) pr_info(CONFIG_MSM_SEC_CCI_TA_NAME "::%s:%d - " fmt,\
- __func__, __LINE__, ##args)
-#define TZ_I2C_FN_RETURN(ret, i2c_fn, ...) \
- ((ret < 0) ? i2c_fn(__VA_ARGS__):ret)
-
-#else /* CONFIG_MSM_SEC_CCI_DEBUG */
-
-#define CDBG(fmt, args...) pr_info("%s:%d - " fmt, __func__, __LINE__, ##args)
-#define TZ_I2C_FN_RETURN(ret, i2c_fn, ...) \
- ((ret < 0) ? -EFAULT:ret)
-
-#endif /* CONFIG_MSM_SEC_CCI_DEBUG */
-
-#pragma pack(push, msm_camera_tz_i2c, 1)
-
-enum msm_camera_tz_i2c_cmd_id_t {
- TZ_I2C_CMD_GET_NONE,
- TZ_I2C_CMD_GET_IF_VERSION,
- TZ_I2C_CMD_POWER_UP,
- TZ_I2C_CMD_POWER_DOWN,
- TZ_I2C_CMD_CCI_GENERIC,
- TZ_I2C_CMD_CCI_READ,
- TZ_I2C_CMD_CCI_READ_SEQ,
- TZ_I2C_CMD_CCI_WRITE,
- TZ_I2C_CMD_CCI_WRITE_SEQ,
- TZ_I2C_CMD_CCI_WRITE_TABLE_ASYNC,
- TZ_I2C_CMD_CCI_WRITE_TABLE_SYNC,
- TZ_I2C_CMD_CCI_WRITE_TABLE_SYNC_BLOCK,
- TZ_I2C_CMD_CCI_WRITE_TABLE,
- TZ_I2C_CMD_CCI_WRITE_SEQ_TABLE,
- TZ_I2C_CMD_CCI_WRITE_TABLE_W_MICRODELAY,
- TZ_I2C_CMD_CCI_POLL,
- TZ_I2C_CMD_CCI_WRITE_CONF_TBL,
- TZ_I2C_CMD_CCI_UTIL,
-};
-
-enum msm_camera_tz_i2c_status_t {
- TZ_I2C_STATUS_SUCCESS = 0,
- TZ_I2C_STATUS_GENERAL_FAILURE = -1,
- TZ_I2C_STATUS_INVALID_INPUT_PARAMS = -2,
- TZ_I2C_STATUS_INVALID_SENSOR_ID = -3,
- TZ_I2C_STATUS_BYPASS = -4,
- TZ_I2C_STATUS_ERR_SIZE = 0x7FFFFFFF
-};
-
-struct msm_camera_tz_i2c_generic_req_t {
- enum msm_camera_tz_i2c_cmd_id_t cmd_id;
-};
-
-struct msm_camera_tz_i2c_generic_rsp_t {
- enum msm_camera_tz_i2c_status_t rc;
-};
-
-#define msm_camera_tz_i2c_get_if_version_req_t msm_camera_tz_i2c_generic_req_t
-
-struct msm_camera_tz_i2c_get_if_version_rsp_t {
- enum msm_camera_tz_i2c_status_t rc;
- uint32_t if_version_maj;
- uint32_t if_version_min;
-};
-
-struct msm_camera_tz_i2c_power_up_req_t {
- enum msm_camera_tz_i2c_cmd_id_t cmd_id;
- int32_t sensor_id;
-};
-
-#define msm_camera_tz_i2c_power_up_rsp_t msm_camera_tz_i2c_generic_rsp_t
-
-struct msm_camera_tz_i2c_power_down_req_t {
- enum msm_camera_tz_i2c_cmd_id_t cmd_id;
- int32_t sensor_id;
-};
-
-#define msm_camera_tz_i2c_power_down_rsp_t msm_camera_tz_i2c_generic_rsp_t
-
-struct msm_camera_tz_i2c_cci_generic_req_t {
- enum msm_camera_tz_i2c_cmd_id_t cmd_id;
- int32_t sensor_id;
- enum msm_camera_tz_i2c_cmd_id_t cci_cmd_id;
- uint32_t cci_i2c_master;
- uint16_t sid;
- uint16_t cid;
-};
-
-#define msm_camera_tz_i2c_cci_generic_rsp_t msm_camera_tz_i2c_generic_rsp_t
-
-struct msm_camera_tz_i2c_cci_read_req_t {
- enum msm_camera_tz_i2c_cmd_id_t cmd_id;
- int32_t sensor_id;
- uint32_t cci_i2c_master;
- uint16_t sid;
- uint16_t cid;
- uint32_t addr;
- uint32_t data_type;
-};
-
-struct msm_camera_tz_i2c_cci_read_rsp_t {
- enum msm_camera_tz_i2c_status_t rc;
- uint16_t data;
-};
-
-struct msm_camera_tz_i2c_cci_write_req_t {
- enum msm_camera_tz_i2c_cmd_id_t cmd_id;
- int32_t sensor_id;
- uint32_t cci_i2c_master;
- uint16_t sid;
- uint16_t cid;
- uint32_t addr;
- uint16_t data;
- uint32_t data_type;
-};
-
-#define msm_camera_tz_i2c_cci_write_rsp_t msm_camera_tz_i2c_generic_rsp_t
-
-struct msm_camera_tz_i2c_cci_util_req_t {
- enum msm_camera_tz_i2c_cmd_id_t cmd_id;
- int32_t sensor_id;
- uint32_t cci_i2c_master;
- uint16_t sid;
- uint16_t cid;
- uint16_t cci_cmd;
-};
-
-#define msm_camera_tz_i2c_cci_util_rsp_t msm_camera_tz_i2c_generic_rsp_t
-
-#pragma pack(pop, msm_camera_tz_i2c)
-
-struct msm_camera_tz_i2c_sensor_info_t {
- struct msm_sensor_ctrl_t *s_ctrl;
- struct msm_camera_i2c_fn_t *saved_sensor_i2c_fn;
- uint32_t secure;
- uint32_t ta_enabled;
- struct qseecom_handle *ta_qseecom_handle;
- const char *ta_name;
-};
-
-struct msm_camera_tz_i2c_ctrl_t {
- struct mutex lock;
- uint32_t lock_ready;
- uint32_t secure_mode;
-};
-
-static struct msm_camera_tz_i2c_ctrl_t msm_camera_tz_i2c_ctrl;
-
-static struct msm_camera_tz_i2c_sensor_info_t sensor_info[MAX_CAMERAS] = {
- {NULL, NULL, 0, 0, NULL, CONFIG_MSM_SEC_CCI_TA_NAME},
- {NULL, NULL, 0, 0, NULL, CONFIG_MSM_SEC_CCI_TA_NAME},
- {NULL, NULL, 0, 0, NULL, CONFIG_MSM_SEC_CCI_TA_NAME},
- {NULL, NULL, 0, 0, NULL, CONFIG_MSM_SEC_CCI_TA_NAME},
-};
-
-static int32_t msm_camera_tz_i2c_is_sensor_secure(
- struct msm_camera_i2c_client *client)
-{
- uint32_t index;
-
- if (client == NULL) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- CDBG("Enter\n");
- for (index = 0; index < MAX_CAMERAS; index++) {
- if ((sensor_info[index].s_ctrl != NULL) &&
- sensor_info[index].secure &&
- (sensor_info[index].s_ctrl->sensor_i2c_client ==
- client)) {
- CDBG("Found secure sensor ID = %d\n",
- sensor_info[index].s_ctrl->id);
- return sensor_info[index].s_ctrl->id;
- }
- }
- return -EINVAL;
-}
-
-static int32_t get_cmd_rsp_buffers(
- struct qseecom_handle *ta_qseecom_handle,
- void **cmd, int *cmd_len,
- void **rsp, int *rsp_len)
-{
-
- CDBG("Enter\n");
- if ((ta_qseecom_handle == NULL) ||
- (cmd == NULL) || (cmd_len == NULL) ||
- (rsp == NULL) || (rsp_len == NULL)) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- if (*cmd_len & QSEECOM_ALIGN_MASK)
- *cmd_len = QSEECOM_ALIGN(*cmd_len);
-
- if (*rsp_len & QSEECOM_ALIGN_MASK)
- *rsp_len = QSEECOM_ALIGN(*rsp_len);
-
- if ((*rsp_len + *cmd_len) > QSEECOM_SBUFF_SIZE) {
- pr_err("%s:%d - Shared buffer too small to hold cmd=%d and rsp=%d\n",
- __func__, __LINE__,
- *cmd_len, *rsp_len);
- return -ENOMEM;
- }
-
- *cmd = ta_qseecom_handle->sbuf;
- *rsp = ta_qseecom_handle->sbuf + *cmd_len;
- return 0;
-}
-
-static int32_t msm_camera_tz_i2c_ta_get_if_version(
- struct qseecom_handle *ta_qseecom_handle,
- uint32_t *if_version_maj,
- uint32_t *if_version_min)
-{
- int32_t cmd_len, rsp_len;
- struct msm_camera_tz_i2c_get_if_version_req_t *cmd;
- struct msm_camera_tz_i2c_get_if_version_rsp_t *rsp;
- int32_t rc = 0;
-
- CDBG("Enter\n");
- if ((ta_qseecom_handle == NULL) ||
- (if_version_maj == NULL) || (if_version_min == NULL)) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- cmd_len = sizeof(struct msm_camera_tz_i2c_get_if_version_req_t);
- rsp_len = sizeof(struct msm_camera_tz_i2c_get_if_version_rsp_t);
-
- rc = get_cmd_rsp_buffers(ta_qseecom_handle,
- (void **)&cmd, &cmd_len, (void **)&rsp, &rsp_len);
- if (!rc) {
- cmd->cmd_id = TZ_I2C_CMD_GET_IF_VERSION;
-
- rc = qseecom_send_command(ta_qseecom_handle,
- (void *)cmd, cmd_len, (void *)rsp, rsp_len);
-
- if (rc < 0) {
- pr_err("%s:%d - Unable to get if version info, rc=%d\n",
- __func__, __LINE__,
- rc);
- return rc;
- }
-
- if (rsp->rc < 0) {
- CDBG("TZ I2C App error, rc=%d\n", rsp->rc);
- rc = -EFAULT;
- } else {
- *if_version_maj = rsp->if_version_maj;
- *if_version_min = rsp->if_version_min;
- CDBG("TZ I2C If version %d.%d\n", *if_version_maj,
- *if_version_min);
- }
- }
- return rc;
-}
-
-static int32_t msm_camera_tz_i2c_ta_power_up(
- struct qseecom_handle *ta_qseecom_handle,
- int32_t sensor_id,
- uint32_t *sensor_secure)
-{
- int32_t cmd_len, rsp_len;
- struct msm_camera_tz_i2c_power_up_req_t *cmd;
- struct msm_camera_tz_i2c_power_up_rsp_t *rsp;
- int32_t rc = 0;
-
- CDBG("Enter\n");
-
- if (sensor_secure == NULL)
- return -EINVAL;
-
- *sensor_secure = 0;
- if ((ta_qseecom_handle == NULL) ||
- (sensor_secure == NULL) ||
- (sensor_id < 0) ||
- (sensor_id >= MAX_CAMERAS)) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- cmd_len = sizeof(struct msm_camera_tz_i2c_power_up_req_t);
- rsp_len = sizeof(struct msm_camera_tz_i2c_power_up_rsp_t);
-
- rc = get_cmd_rsp_buffers(ta_qseecom_handle,
- (void **)&cmd, &cmd_len, (void **)&rsp, &rsp_len);
- if (!rc) {
- cmd->cmd_id = TZ_I2C_CMD_POWER_UP;
- cmd->sensor_id = sensor_id;
-
- rc = qseecom_send_command(ta_qseecom_handle,
- (void *)cmd, cmd_len, (void *)rsp, rsp_len);
-
- if (rc < 0) {
- pr_err("%s:%d - Unable to get sensor secure status, rc=%d\n",
- __func__, __LINE__,
- rc);
- return rc;
- }
-
- if (rsp->rc == TZ_I2C_STATUS_SUCCESS)
- *sensor_secure = 1;
- CDBG("Sensor %d is %s\n", sensor_id,
- (*sensor_secure)?"SECURE":"NON-SECURE");
- }
- return rc;
-}
-
-static int32_t msm_camera_tz_i2c_ta_power_down(
- struct qseecom_handle *ta_qseecom_handle,
- int32_t sensor_id)
-{
- int32_t cmd_len, rsp_len;
- struct msm_camera_tz_i2c_power_down_req_t *cmd;
- struct msm_camera_tz_i2c_power_down_rsp_t *rsp;
- int32_t rc = 0;
-
- CDBG("Enter\n");
-
- if ((ta_qseecom_handle == NULL) ||
- (sensor_id < 0) ||
- (sensor_id >= MAX_CAMERAS)) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- cmd_len = sizeof(struct msm_camera_tz_i2c_power_down_req_t);
- rsp_len = sizeof(struct msm_camera_tz_i2c_power_down_rsp_t);
-
- rc = get_cmd_rsp_buffers(ta_qseecom_handle,
- (void **)&cmd, &cmd_len, (void **)&rsp, &rsp_len);
- if (!rc) {
- cmd->cmd_id = TZ_I2C_CMD_POWER_DOWN;
- cmd->sensor_id = sensor_id;
-
- rc = qseecom_send_command(ta_qseecom_handle,
- (void *)cmd, cmd_len, (void *)rsp, rsp_len);
-
- if (rc < 0) {
- pr_err("%s:%d - Failed: rc=%d\n",
- __func__, __LINE__,
- rc);
- return rc;
- }
- }
- return rc;
-}
-
-static int32_t msm_camera_tz_i2c_ta_cci_generic(
- struct msm_camera_i2c_client *client,
- enum msm_camera_tz_i2c_cmd_id_t cci_cmd_id)
-{
- int32_t cmd_len, rsp_len;
- struct msm_camera_tz_i2c_cci_generic_req_t *cmd;
- struct msm_camera_tz_i2c_cci_generic_rsp_t *rsp;
- int32_t rc = 0;
- struct qseecom_handle *ta_qseecom_handle;
- int32_t sensor_id = msm_camera_tz_i2c_is_sensor_secure(client);
-
- if ((client == NULL) ||
- (sensor_id < 0) ||
- (sensor_id >= MAX_CAMERAS)) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, cci_cmd_id=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid,
- cci_cmd_id);
-
- ta_qseecom_handle = sensor_info[sensor_id].ta_qseecom_handle;
- cmd_len = sizeof(struct msm_camera_tz_i2c_cci_generic_req_t);
- rsp_len = sizeof(struct msm_camera_tz_i2c_cci_generic_rsp_t);
-
- rc = get_cmd_rsp_buffers(ta_qseecom_handle,
- (void **)&cmd, &cmd_len, (void **)&rsp, &rsp_len);
- if (!rc) {
- cmd->cmd_id = TZ_I2C_CMD_CCI_GENERIC;
- cmd->sensor_id = sensor_id;
- cmd->cci_cmd_id = cci_cmd_id;
- cmd->cci_i2c_master = client->cci_client->cci_i2c_master;
- cmd->sid = client->cci_client->sid;
- cmd->cid = client->cci_client->cid;
-
- rc = qseecom_send_command(ta_qseecom_handle,
- (void *)cmd, cmd_len, (void *)rsp, rsp_len);
-
- if (rc < 0) {
- pr_err("%s:%d - Failed: rc=%d\n",
- __func__, __LINE__,
- rc);
- return rc;
- }
- rc = rsp->rc;
- CDBG("Done: rc=%d, cci_cmd_id=%d\n", rc, cci_cmd_id);
- }
- return rc;
-}
-
-static int32_t msm_camera_tz_i2c_ta_cci_read(
- struct msm_camera_i2c_client *client,
- uint32_t addr,
- uint16_t *data,
- enum msm_camera_i2c_data_type data_type)
-{
- int32_t cmd_len, rsp_len;
- struct msm_camera_tz_i2c_cci_read_req_t *cmd;
- struct msm_camera_tz_i2c_cci_read_rsp_t *rsp;
- int32_t rc = 0;
- struct qseecom_handle *ta_qseecom_handle;
- int32_t sensor_id = msm_camera_tz_i2c_is_sensor_secure(client);
-
- if ((client == NULL) ||
- (data == NULL) ||
- (sensor_id < 0) ||
- (sensor_id >= MAX_CAMERAS)) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, Addr=0x%X, Type=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid,
- addr,
- data_type);
-
- ta_qseecom_handle = sensor_info[sensor_id].ta_qseecom_handle;
- cmd_len = sizeof(struct msm_camera_tz_i2c_cci_read_req_t);
- rsp_len = sizeof(struct msm_camera_tz_i2c_cci_read_rsp_t);
-
- rc = get_cmd_rsp_buffers(ta_qseecom_handle,
- (void **)&cmd, &cmd_len, (void **)&rsp, &rsp_len);
- if (!rc) {
- cmd->cmd_id = TZ_I2C_CMD_CCI_READ;
- cmd->sensor_id = sensor_id;
- cmd->cci_i2c_master = client->cci_client->cci_i2c_master;
- cmd->sid = client->cci_client->sid;
- cmd->cid = client->cci_client->cid;
- cmd->addr = addr;
- cmd->data_type = data_type;
-
- rc = qseecom_send_command(ta_qseecom_handle,
- (void *)cmd, cmd_len, (void *)rsp, rsp_len);
-
- if (rc < 0) {
- pr_err("%s:%d - Failed: rc=%d\n",
- __func__, __LINE__,
- rc);
- return rc;
- }
- rc = rsp->rc;
- *data = rsp->data;
-
- CDBG("Done: rc=%d, addr=0x%X, data=0x%X\n", rc,
- addr, *data);
- }
- return rc;
-}
-
-static int32_t msm_camera_tz_i2c_ta_cci_write(
- struct msm_camera_i2c_client *client,
- uint32_t addr,
- uint16_t data,
- enum msm_camera_i2c_data_type data_type)
-{
- int32_t cmd_len, rsp_len;
- struct msm_camera_tz_i2c_cci_write_req_t *cmd;
- struct msm_camera_tz_i2c_cci_write_rsp_t *rsp;
- int32_t rc = 0;
- struct qseecom_handle *ta_qseecom_handle;
- int32_t sensor_id = msm_camera_tz_i2c_is_sensor_secure(client);
-
- if ((client == NULL) ||
- (sensor_id < 0) ||
- (sensor_id >= MAX_CAMERAS)) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, Addr=0x%X, Data=0x%X Type=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid,
- addr,
- data,
- data_type);
-
- ta_qseecom_handle = sensor_info[sensor_id].ta_qseecom_handle;
- cmd_len = sizeof(struct msm_camera_tz_i2c_cci_write_req_t);
- rsp_len = sizeof(struct msm_camera_tz_i2c_cci_write_rsp_t);
-
- rc = get_cmd_rsp_buffers(ta_qseecom_handle,
- (void **)&cmd, &cmd_len, (void **)&rsp, &rsp_len);
- if (!rc) {
- cmd->cmd_id = TZ_I2C_CMD_CCI_WRITE;
- cmd->sensor_id = sensor_id;
- cmd->cci_i2c_master = client->cci_client->cci_i2c_master;
- cmd->sid = client->cci_client->sid;
- cmd->cid = client->cci_client->cid;
- cmd->addr = addr;
- cmd->data = data;
- cmd->data_type = data_type;
-
- rc = qseecom_send_command(ta_qseecom_handle,
- (void *)cmd, cmd_len, (void *)rsp, rsp_len);
-
- if (rc < 0) {
- pr_err("%s:%d - Failed:, rc=%d\n",
- __func__, __LINE__,
- rc);
- return rc;
- }
- rc = rsp->rc;
-
- CDBG("Done: rc=%d, addr=0x%X, data=0x%X\n", rc,
- addr, data);
- }
- return rc;
-}
-
-static int32_t msm_camera_tz_i2c_ta_cci_util(
- struct msm_camera_i2c_client *client,
- uint16_t cci_cmd)
-{
- int32_t cmd_len, rsp_len;
- struct msm_camera_tz_i2c_cci_util_req_t *cmd;
- struct msm_camera_tz_i2c_cci_util_rsp_t *rsp;
- int32_t rc = 0;
- struct qseecom_handle *ta_qseecom_handle;
- int32_t sensor_id = msm_camera_tz_i2c_is_sensor_secure(client);
-
- if ((client == NULL) ||
- (sensor_id < 0) ||
- (sensor_id >= MAX_CAMERAS)) {
- pr_err("%s:%d - Bad parameters\n",
- __func__, __LINE__);
- return -EINVAL;
- }
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, cci_cmd=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid,
- cci_cmd);
-
- ta_qseecom_handle = sensor_info[sensor_id].ta_qseecom_handle;
- cmd_len = sizeof(struct msm_camera_tz_i2c_cci_util_req_t);
- rsp_len = sizeof(struct msm_camera_tz_i2c_cci_util_rsp_t);
-
- rc = get_cmd_rsp_buffers(ta_qseecom_handle,
- (void **)&cmd, &cmd_len, (void **)&rsp, &rsp_len);
- if (!rc) {
- cmd->cmd_id = TZ_I2C_CMD_CCI_UTIL;
- cmd->sensor_id = sensor_id;
- cmd->cci_i2c_master = client->cci_client->cci_i2c_master;
- cmd->sid = client->cci_client->sid;
- cmd->cid = client->cci_client->cid;
- cmd->cci_cmd = cci_cmd;
-
- rc = qseecom_send_command(ta_qseecom_handle,
- (void *)cmd, cmd_len, (void *)rsp, rsp_len);
-
- if (rc < 0) {
- pr_err("%s:%d - Failed: rc=%d\n",
- __func__, __LINE__,
- rc);
- return rc;
- }
- rc = rsp->rc;
- CDBG("Done: rc=%d, cci_cmd=%d\n", rc, cci_cmd);
- }
- return rc;
-}
-
-static int32_t msm_camera_tz_i2c_ta_probe(
- struct msm_camera_i2c_client *client)
-{
- int32_t sensor_id = -1;
-
- CDBG("Enter\n");
- sensor_id = msm_camera_tz_i2c_is_sensor_secure(client);
- if ((sensor_id >= 0) && sensor_info[sensor_id].ta_enabled
- && msm_camera_tz_i2c_ctrl.lock_ready) {
- mutex_lock(&msm_camera_tz_i2c_ctrl.lock);
- return sensor_id;
- }
- return -EINVAL;
-}
-
-static int32_t msm_camera_tz_i2c_ta_done(void)
-{
- int32_t rc = 0;
-
- CDBG("Enter\n");
- if (msm_camera_tz_i2c_ctrl.lock_ready)
- mutex_unlock(&msm_camera_tz_i2c_ctrl.lock);
- return rc;
-}
-
-int32_t msm_camera_tz_i2c_power_up(
- struct msm_camera_i2c_client *client)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_is_sensor_secure(client);
-
- if (!msm_camera_tz_i2c_ctrl.lock_ready) {
- msm_camera_tz_i2c_ctrl.lock_ready = 1;
- mutex_init(&msm_camera_tz_i2c_ctrl.lock);
- }
-
- CDBG("Enter (sensor_id=%d)\n", sensor_id);
- if (sensor_id >= 0) {
- ktime_t startTime;
-
- mutex_lock(&msm_camera_tz_i2c_ctrl.lock);
- if (msm_camera_tz_i2c_ctrl.secure_mode) {
- mutex_unlock(&msm_camera_tz_i2c_ctrl.lock);
- return rc;
- }
- startTime = ktime_get();
-
- CDBG("Switch to secure mode (secure sensor=%d)\n",
- sensor_id);
- /* Start the TA */
- if ((sensor_info[sensor_id].ta_qseecom_handle == NULL)
- && (sensor_info[sensor_id].ta_name != NULL) &&
- ('\0' != sensor_info[sensor_id].ta_name[0])) {
- uint32_t if_version_maj = 0;
- uint32_t if_version_min = 0;
-
- sensor_info[sensor_id].ta_enabled = 0;
- rc = qseecom_start_app(
- &sensor_info[sensor_id].ta_qseecom_handle,
- (char *)sensor_info[sensor_id].ta_name,
- QSEECOM_SBUFF_SIZE);
- if (!rc) {
- rc = msm_camera_tz_i2c_ta_get_if_version(
- sensor_info[sensor_id].
- ta_qseecom_handle,
- &if_version_maj, &if_version_min);
- }
-
- if (!rc) {
- if (if_version_maj != TA_IF_VERSION_MAJ) {
- CDBG("TA ver mismatch %d.%d != %d.%d\n",
- if_version_maj, if_version_min,
- TA_IF_VERSION_MAJ,
- TA_IF_VERSION_MIN);
- rc = qseecom_shutdown_app(
- &sensor_info[sensor_id].
- ta_qseecom_handle);
- sensor_info[sensor_id].ta_qseecom_handle
- = EMPTY_QSEECOM_HANDLE;
- rc = -EFAULT;
- } else {
- uint32_t sensor_secure = 0;
- /*Notify TA & get sensor secure status*/
- rc = msm_camera_tz_i2c_ta_power_up(
- sensor_info[sensor_id].
- ta_qseecom_handle,
- sensor_id,
- &sensor_secure);
- if (!rc && sensor_secure)
- /* Sensor validated by TA*/
- sensor_info[sensor_id].
- ta_enabled = 1;
- else {
- qseecom_shutdown_app(
- &sensor_info[sensor_id].
- ta_qseecom_handle);
- sensor_info[sensor_id].
- ta_qseecom_handle
- = EMPTY_QSEECOM_HANDLE;
- rc = -EFAULT;
- }
- }
- }
- }
- CDBG("Init TA %s - %s(%d) - %llu\n",
- sensor_info[sensor_id].ta_name,
- (sensor_info[sensor_id].ta_enabled)?"Ok" :
- "Failed", rc, ktime_us_delta(ktime_get(),
- startTime));
- if (!rc)
- msm_camera_tz_i2c_ctrl.secure_mode++;
- mutex_unlock(&msm_camera_tz_i2c_ctrl.lock);
- }
- return rc;
-}
-
-int32_t msm_camera_tz_i2c_power_down(
- struct msm_camera_i2c_client *client)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_is_sensor_secure(client);
-
- if (!msm_camera_tz_i2c_ctrl.lock_ready) {
- msm_camera_tz_i2c_ctrl.lock_ready = 1;
- mutex_init(&msm_camera_tz_i2c_ctrl.lock);
- }
-
- CDBG("Enter (sensor_id=%d)\n", sensor_id);
- if ((sensor_id >= 0) && (msm_camera_tz_i2c_ctrl.secure_mode != 0)) {
- mutex_lock(&msm_camera_tz_i2c_ctrl.lock);
- if (msm_camera_tz_i2c_ctrl.secure_mode == 1) {
- ktime_t startTime = ktime_get();
-
- CDBG("Switch to non-secure mode (secure sensor=%d)\n",
- sensor_id);
- /* Shutdown the TA */
- if (sensor_info[sensor_id].ta_qseecom_handle != NULL) {
- msm_camera_tz_i2c_ta_power_down(
- sensor_info[sensor_id].
- ta_qseecom_handle,
- sensor_id);
- rc = qseecom_shutdown_app(&sensor_info[
- sensor_id].ta_qseecom_handle);
- sensor_info[sensor_id].ta_qseecom_handle
- = EMPTY_QSEECOM_HANDLE;
- }
- CDBG("Unload TA %s - %s(%d) - %llu\n",
- sensor_info[sensor_id].ta_name,
- (!rc)?"Ok":"Failed", rc,
- ktime_us_delta(ktime_get(), startTime));
- }
- msm_camera_tz_i2c_ctrl.secure_mode--;
- mutex_unlock(&msm_camera_tz_i2c_ctrl.lock);
- }
- return rc;
-}
-
-int32_t msm_camera_tz_i2c_register_sensor(
- void *s_ctrl_p)
-{
- struct msm_sensor_ctrl_t *s_ctrl = (struct msm_sensor_ctrl_t *)s_ctrl_p;
-
- if (s_ctrl == NULL) {
- pr_err("%s:%d - invalid parameter)\n",
- __func__, __LINE__);
- return -EINVAL;
- }
- if (s_ctrl->id >= MAX_CAMERAS) {
- pr_err("%s:%d - invalid ID: %d\n",
- __func__, __LINE__, s_ctrl->id);
- return -EINVAL;
- }
-
- CDBG("id=%d, client=%pK\n", s_ctrl->id, s_ctrl);
- sensor_info[s_ctrl->id].s_ctrl = s_ctrl;
- sensor_info[s_ctrl->id].secure = s_ctrl->is_secure;
- return 0;
-}
-
-int32_t msm_camera_tz_i2c_read(struct msm_camera_i2c_client *client,
- uint32_t addr, uint16_t *data,
- enum msm_camera_i2c_data_type data_type)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, addr=0x%08X\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid,
- addr);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_read(
- client, addr, data, data_type);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_read, client, addr, data, data_type);
-}
-
-int32_t msm_camera_tz_i2c_read_seq(struct msm_camera_i2c_client *client,
- uint32_t addr, uint8_t *data, uint32_t num_byte)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, addr=0x%08X, num=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid,
- addr,
- num_byte);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_READ_SEQ);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_read_seq, client, addr, data, num_byte);
-}
-
-int32_t msm_camera_tz_i2c_write(struct msm_camera_i2c_client *client,
- uint32_t addr, uint16_t data,
- enum msm_camera_i2c_data_type data_type)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, addr=0x%08X\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid,
- addr);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_write(
- client, addr, data, data_type);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write, client, addr, data, data_type);
-}
-
-int32_t msm_camera_tz_i2c_write_seq(struct msm_camera_i2c_client *client,
- uint32_t addr, uint8_t *data, uint32_t num_byte)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, addr=0x%08X, num=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid,
- addr,
- num_byte);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_WRITE_SEQ);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write_seq, client, addr, data, num_byte);
-}
-
-int32_t msm_camera_tz_i2c_write_table_async(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_WRITE_TABLE_ASYNC);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write_table_async, client, write_setting);
-}
-
-int32_t msm_camera_tz_i2c_write_table_sync(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_WRITE_TABLE_SYNC);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write_table_sync, client, write_setting);
-}
-
-int32_t msm_camera_tz_i2c_write_table_sync_block(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_WRITE_TABLE_SYNC_BLOCK);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write_table_sync_block, client,
- write_setting);
-}
-
-int32_t msm_camera_tz_i2c_write_table(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_WRITE_TABLE);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write_table, client, write_setting);
-}
-
-int32_t msm_camera_tz_i2c_write_seq_table(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_seq_reg_setting *write_setting)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_WRITE_SEQ_TABLE);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write_seq_table, client, write_setting);
-}
-
-int32_t msm_camera_tz_i2c_write_table_w_microdelay(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_setting *write_setting)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_WRITE_TABLE_W_MICRODELAY);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write_table_w_microdelay, client,
- write_setting);
-}
-
-int32_t msm_camera_tz_i2c_poll(struct msm_camera_i2c_client *client,
- uint32_t addr, uint16_t data,
- enum msm_camera_i2c_data_type data_type)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_POLL);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_poll, client, addr, data, data_type);
-}
-
-int32_t msm_camera_tz_i2c_write_conf_tbl(
- struct msm_camera_i2c_client *client,
- struct msm_camera_i2c_reg_conf *reg_conf_tbl, uint16_t size,
- enum msm_camera_i2c_data_type data_type)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_generic(
- client, TZ_I2C_CMD_CCI_WRITE_CONF_TBL);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_camera_cci_i2c_write_conf_tbl, client, reg_conf_tbl, size,
- data_type);
-}
-
-int32_t msm_sensor_tz_i2c_util(struct msm_camera_i2c_client *client,
- uint16_t cci_cmd)
-{
- int32_t rc = -EFAULT;
- int32_t sensor_id = msm_camera_tz_i2c_ta_probe(client);
-
- CDBG("Sensor=%d, MS=%d, SID=%d, CID=%d, cci_cmd=%d\n",
- sensor_id,
- client->cci_client->cci_i2c_master,
- client->cci_client->sid,
- client->cci_client->cid, cci_cmd);
-
- if (sensor_id >= 0) {
- rc = msm_camera_tz_i2c_ta_cci_util(client, cci_cmd);
- msm_camera_tz_i2c_ta_done();
- }
- return TZ_I2C_FN_RETURN(rc,
- msm_sensor_cci_i2c_util, client, cci_cmd);
-}
diff --git a/drivers/media/platform/msm/camera_v2/sensor/ir_cut/msm_ir_cut.c b/drivers/media/platform/msm/camera_v2/sensor/ir_cut/msm_ir_cut.c
index 9a5023ac167f..e8f74f8beb1b 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/ir_cut/msm_ir_cut.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/ir_cut/msm_ir_cut.c
@@ -83,6 +83,7 @@ static int32_t msm_ir_cut_release(
return 0;
}
+ rc = ir_cut_ctrl->func_tbl->camera_ir_cut_on(ir_cut_ctrl, NULL);
if (rc < 0) {
pr_err("%s:%d camera_ir_cut_on failed rc = %d",
__func__, __LINE__, rc);
@@ -269,6 +270,8 @@ static int32_t msm_ir_cut_handle_init(
return -EINVAL;
}
+ rc = ir_cut_ctrl->func_tbl->camera_ir_cut_init(
+ ir_cut_ctrl, ir_cut_data);
if (rc < 0) {
pr_err("%s:%d camera_ir_cut_init failed rc = %d",
__func__, __LINE__, rc);
diff --git a/drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.c b/drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.c
index 70b4b8dce2be..cfcdb124f44f 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.c
@@ -15,7 +15,6 @@
#include <linux/module.h>
#include <linux/pwm.h>
-#include <linux/delay.h>
#include "msm_ir_led.h"
#include "msm_camera_dt_util.h"
@@ -42,6 +41,7 @@ static int32_t msm_ir_led_get_subdev_id(
{
uint32_t *subdev_id = (uint32_t *)arg;
+ CDBG("Enter\n");
if (!subdev_id) {
pr_err("subdevice ID is not valid\n");
return -EINVAL;
@@ -54,6 +54,7 @@ static int32_t msm_ir_led_get_subdev_id(
*subdev_id = ir_led_ctrl->pdev->id;
CDBG("subdev_id %d\n", *subdev_id);
+ CDBG("Exit\n");
return 0;
}
@@ -63,64 +64,45 @@ static int32_t msm_ir_led_init(
{
int32_t rc = 0;
+ CDBG("Enter\n");
+
rc = ir_led_ctrl->func_tbl->camera_ir_led_off(ir_led_ctrl, ir_led_data);
+ CDBG("Exit\n");
return rc;
}
static int32_t msm_ir_led_release(
- struct msm_ir_led_ctrl_t *ir_led_ctrl,
- struct msm_ir_led_cfg_data_t *ir_led_data)
+ struct msm_ir_led_ctrl_t *ir_led_ctrl)
{
- int32_t rc = -EFAULT;
+ int32_t rc = 0;
if (ir_led_ctrl->ir_led_state == MSM_CAMERA_IR_LED_RELEASE) {
pr_err("Invalid ir_led state = %d\n",
ir_led_ctrl->ir_led_state);
- return rc;
+ return 0;
}
- rc = ir_led_ctrl->func_tbl->camera_ir_led_off(ir_led_ctrl, ir_led_data);
+ rc = ir_led_ctrl->func_tbl->camera_ir_led_off(ir_led_ctrl, NULL);
if (rc < 0) {
pr_err("camera_ir_led_off failed (%d)\n", rc);
return rc;
}
ir_led_ctrl->ir_led_state = MSM_CAMERA_IR_LED_RELEASE;
-
- return rc;
+ return 0;
}
static int32_t msm_ir_led_off(struct msm_ir_led_ctrl_t *ir_led_ctrl,
struct msm_ir_led_cfg_data_t *ir_led_data)
{
- int32_t rc = 0;
-
- CDBG("pwm duty on(ns) %d, pwm period(ns) %d\n",
- ir_led_data->pwm_duty_on_ns, ir_led_data->pwm_period_ns);
-
- if (ir_led_data->pwm_period_ns <= 0)
- ir_led_data->pwm_period_ns = DEFAULT_PWM_TIME_PERIOD_NS;
-
- if (ir_led_data->pwm_duty_on_ns != 0)
- ir_led_data->pwm_duty_on_ns = DEFAULT_PWM_DUTY_CYCLE_NS;
-
- if (ir_led_ctrl->pwm_dev) {
- rc = pwm_config(ir_led_ctrl->pwm_dev,
- ir_led_data->pwm_duty_on_ns,
- ir_led_data->pwm_period_ns);
-
- if (rc) {
- pr_err("PWM config failed (%d)\n", rc);
- return rc;
- }
- /*workaround to disable pwm_module*/
- udelay(50);
+ CDBG("Enter\n");
+ if (ir_led_ctrl->pwm_dev)
pwm_disable(ir_led_ctrl->pwm_dev);
- } else {
- CDBG("pwm device is null\n");
- }
+ else
+ pr_err("pwm device is null\n");
+ CDBG("Exit\n");
return 0;
}
@@ -128,7 +110,7 @@ static int32_t msm_ir_led_on(
struct msm_ir_led_ctrl_t *ir_led_ctrl,
struct msm_ir_led_cfg_data_t *ir_led_data)
{
- int32_t rc = 0;
+ int rc;
CDBG("pwm duty on(ns) %d, pwm period(ns) %d\n",
ir_led_data->pwm_duty_on_ns, ir_led_data->pwm_period_ns);
@@ -147,9 +129,9 @@ static int32_t msm_ir_led_on(
pr_err("PWM enable failed(%d)\n", rc);
return rc;
}
- } else {
- CDBG("pwm device is null\n");
- }
+ } else
+ pr_err("pwm device is null\n");
+
return 0;
}
@@ -162,10 +144,12 @@ static int32_t msm_ir_led_handle_init(
enum msm_ir_led_driver_type ir_led_driver_type =
ir_led_ctrl->ir_led_driver_type;
+ CDBG("Enter\n");
+
if (ir_led_ctrl->ir_led_state == MSM_CAMERA_IR_LED_INIT) {
pr_err("Invalid ir_led state = %d\n",
ir_led_ctrl->ir_led_state);
- return rc;
+ return 0;
}
for (i = 0; i < ARRAY_SIZE(ir_led_table); i++) {
@@ -191,8 +175,8 @@ static int32_t msm_ir_led_handle_init(
ir_led_ctrl->ir_led_state = MSM_CAMERA_IR_LED_INIT;
- CDBG("IR LED STATE intialised Successfully\n");
- return rc;
+ CDBG("Exit\n");
+ return 0;
}
static int32_t msm_ir_led_config(struct msm_ir_led_ctrl_t *ir_led_ctrl,
@@ -202,10 +186,10 @@ static int32_t msm_ir_led_config(struct msm_ir_led_ctrl_t *ir_led_ctrl,
struct msm_ir_led_cfg_data_t *ir_led_data =
(struct msm_ir_led_cfg_data_t *) argp;
- CDBG("type %d\n", ir_led_data->cfg_type);
-
mutex_lock(ir_led_ctrl->ir_led_mutex);
+ CDBG("type %d\n", ir_led_data->cfg_type);
+
switch (ir_led_data->cfg_type) {
case CFG_IR_LED_INIT:
rc = msm_ir_led_handle_init(ir_led_ctrl, ir_led_data);
@@ -213,7 +197,7 @@ static int32_t msm_ir_led_config(struct msm_ir_led_ctrl_t *ir_led_ctrl,
case CFG_IR_LED_RELEASE:
if (ir_led_ctrl->ir_led_state == MSM_CAMERA_IR_LED_INIT)
rc = ir_led_ctrl->func_tbl->camera_ir_led_release(
- ir_led_ctrl, ir_led_data);
+ ir_led_ctrl);
break;
case CFG_IR_LED_OFF:
if (ir_led_ctrl->ir_led_state == MSM_CAMERA_IR_LED_INIT)
@@ -232,7 +216,7 @@ static int32_t msm_ir_led_config(struct msm_ir_led_ctrl_t *ir_led_ctrl,
mutex_unlock(ir_led_ctrl->ir_led_mutex);
- CDBG("Exit (%d): type %d\n", rc, ir_led_data->cfg_type);
+ CDBG("Exit: type %d\n", ir_led_data->cfg_type);
return rc;
}
@@ -242,7 +226,8 @@ static long msm_ir_led_subdev_ioctl(struct v4l2_subdev *sd,
{
struct msm_ir_led_ctrl_t *fctrl = NULL;
void __user *argp = (void __user *)arg;
- struct msm_ir_led_cfg_data_t ir_led_data = {0};
+
+ CDBG("Enter\n");
if (!sd) {
pr_err(" v4l2 ir led subdevice is NULL\n");
@@ -265,13 +250,13 @@ static long msm_ir_led_subdev_ioctl(struct v4l2_subdev *sd,
pr_err("No call back funcions\n");
return -EINVAL;
} else {
- return fctrl->func_tbl->camera_ir_led_release(fctrl,
- &ir_led_data);
+ return fctrl->func_tbl->camera_ir_led_release(fctrl);
}
default:
pr_err_ratelimited("invalid cmd %d\n", cmd);
return -ENOIOCTLCMD;
}
+ CDBG("Exit\n");
}
static struct v4l2_subdev_core_ops msm_ir_led_subdev_core_ops = {
@@ -282,13 +267,39 @@ static struct v4l2_subdev_ops msm_ir_led_subdev_ops = {
.core = &msm_ir_led_subdev_core_ops,
};
-static const struct v4l2_subdev_internal_ops msm_ir_led_internal_ops;
+static int msm_ir_led_close(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh) {
+
+ int rc = 0;
+ struct msm_ir_led_ctrl_t *ir_led_ctrl = v4l2_get_subdevdata(sd);
+
+ if (!ir_led_ctrl) {
+ pr_err("v4l2 subdevice data read failed\n");
+ return -EINVAL;
+ }
+
+ CDBG("Enter\n");
+
+ if (ir_led_ctrl->ir_led_state == MSM_CAMERA_IR_LED_INIT)
+ rc = ir_led_ctrl->func_tbl->camera_ir_led_release(
+ ir_led_ctrl);
+
+ CDBG("Exit (%d)\n", rc);
+
+ return rc;
+}
+
+static const struct v4l2_subdev_internal_ops msm_ir_led_internal_ops = {
+ .close = msm_ir_led_close,
+};
static int32_t msm_ir_led_get_dt_data(struct device_node *of_node,
struct msm_ir_led_ctrl_t *fctrl)
{
int32_t rc = 0;
+ CDBG("called\n");
+
/* Read the sub device */
rc = of_property_read_u32(of_node, "cell-index", &fctrl->pdev->id);
if (rc < 0) {
@@ -312,6 +323,7 @@ static long msm_ir_led_subdev_do_ioctl(
(struct msm_ir_led_cfg_data_t32 *)arg;
struct msm_ir_led_cfg_data_t ir_led_data;
+ CDBG("Enter\n");
ir_led_data.cfg_type = u32->cfg_type;
ir_led_data.pwm_duty_on_ns = u32->pwm_duty_on_ns;
ir_led_data.pwm_period_ns = u32->pwm_period_ns;
@@ -326,6 +338,7 @@ static long msm_ir_led_subdev_do_ioctl(
rc = msm_ir_led_subdev_ioctl(sd, cmd, &ir_led_data);
+ CDBG("Exit\n");
return rc;
}
@@ -341,6 +354,7 @@ static int32_t msm_ir_led_platform_probe(struct platform_device *pdev)
int32_t rc = 0;
struct msm_ir_led_ctrl_t *ir_led_ctrl = NULL;
+ CDBG("Enter\n");
if (!pdev->dev.of_node) {
pr_err("IR LED device node is not present in device tree\n");
return -EINVAL;
@@ -356,20 +370,16 @@ static int32_t msm_ir_led_platform_probe(struct platform_device *pdev)
/* Reading PWM device node */
ir_led_ctrl->pwm_dev = of_pwm_get(pdev->dev.of_node, NULL);
- if (PTR_ERR(ir_led_ctrl->pwm_dev) == -EPROBE_DEFER) {
- pr_info("Deferring probe...Cannot get PWM device\n");
- return -EPROBE_DEFER;
- }
-
if (IS_ERR(ir_led_ctrl->pwm_dev)) {
rc = PTR_ERR(ir_led_ctrl->pwm_dev);
- CDBG("Cannot get PWM device (%d)\n", rc);
+ pr_err("Cannot get PWM device (%d)\n", rc);
ir_led_ctrl->pwm_dev = NULL;
}
rc = msm_ir_led_get_dt_data(pdev->dev.of_node, ir_led_ctrl);
if (rc < 0) {
pr_err("msm_ir_led_get_dt_data failed\n");
+ devm_kfree(&pdev->dev, ir_led_ctrl);
return -EINVAL;
}
@@ -391,12 +401,7 @@ static int32_t msm_ir_led_platform_probe(struct platform_device *pdev)
ir_led_ctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
ir_led_ctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_IR_LED;
ir_led_ctrl->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x1;
-
- rc = msm_sd_register(&ir_led_ctrl->msm_sd);
- if (rc < 0) {
- pr_err("sub dev register failed for ir_led device\n");
- return rc;
- }
+ msm_sd_register(&ir_led_ctrl->msm_sd);
CDBG("ir_led sd name = %s\n",
ir_led_ctrl->msm_sd.sd.entity.name);
@@ -426,6 +431,7 @@ static int __init msm_ir_led_init_module(void)
{
int32_t rc = 0;
+ CDBG("Enter\n");
rc = platform_driver_register(&msm_ir_led_platform_driver);
if (!rc)
return rc;
diff --git a/drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.h b/drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.h
index 240c7cba5b75..a0923ffc81da 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/ir_led/msm_ir_led.h
@@ -24,10 +24,6 @@
#define DEFINE_MSM_MUTEX(mutexname) \
static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
-/* Default frequency is taken as 15KHz*/
-#define DEFAULT_PWM_TIME_PERIOD_NS 66667
-#define DEFAULT_PWM_DUTY_CYCLE_NS 0
-
enum msm_camera_ir_led_state_t {
MSM_CAMERA_IR_LED_INIT,
MSM_CAMERA_IR_LED_RELEASE,
@@ -43,8 +39,7 @@ struct msm_ir_led_ctrl_t;
struct msm_ir_led_func_t {
int32_t (*camera_ir_led_init)(struct msm_ir_led_ctrl_t *,
struct msm_ir_led_cfg_data_t *);
- int32_t (*camera_ir_led_release)(struct msm_ir_led_ctrl_t *,
- struct msm_ir_led_cfg_data_t *);
+ int32_t (*camera_ir_led_release)(struct msm_ir_led_ctrl_t *);
int32_t (*camera_ir_led_off)(struct msm_ir_led_ctrl_t *,
struct msm_ir_led_cfg_data_t *);
int32_t (*camera_ir_led_on)(struct msm_ir_led_ctrl_t *,
diff --git a/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c b/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c
index 7c9b1006a314..1949a3f61d28 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2016, 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
@@ -22,9 +22,6 @@
#undef CDBG
#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-static struct msm_camera_i2c_fn_t msm_sensor_cci_func_tbl;
-static struct msm_camera_i2c_fn_t msm_sensor_secure_func_tbl;
-
static void msm_sensor_adjust_mclk(struct msm_camera_power_ctrl_t *ctrl)
{
int idx;
@@ -89,7 +86,6 @@ int32_t msm_sensor_free_sensor_data(struct msm_sensor_ctrl_t *s_ctrl)
kfree(s_ctrl->sensordata->actuator_info);
kfree(s_ctrl->sensordata->power_info.gpio_conf->gpio_num_info);
kfree(s_ctrl->sensordata->power_info.gpio_conf->cam_gpio_req_tbl);
- kfree(s_ctrl->sensordata->power_info.gpio_conf->cam_gpio_set_tbl);
kfree(s_ctrl->sensordata->power_info.gpio_conf);
kfree(s_ctrl->sensordata->power_info.cam_vreg);
kfree(s_ctrl->sensordata->power_info.power_setting);
@@ -137,11 +133,6 @@ int msm_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl)
__func__, __LINE__, power_info, sensor_i2c_client);
return -EINVAL;
}
-
- /* Power down secure session if it exist*/
- if (s_ctrl->is_secure)
- msm_camera_tz_i2c_power_down(sensor_i2c_client);
-
if (s_ctrl && s_ctrl->msm_sd.sd.devnode &&
s_ctrl->sensordata->sensor_info &&
s_ctrl->sensordata->sensor_info->is_rear_prox_interfering) {
@@ -189,27 +180,7 @@ int msm_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
if (s_ctrl->set_mclk_23880000)
msm_sensor_adjust_mclk(power_info);
- CDBG("Sensor %d tagged as %s\n", s_ctrl->id,
- (s_ctrl->is_secure)?"SECURE":"NON-SECURE");
-
for (retry = 0; retry < 3; retry++) {
- if (s_ctrl->is_secure) {
- rc = msm_camera_tz_i2c_power_up(sensor_i2c_client);
- if (rc < 0) {
-#ifdef CONFIG_MSM_SEC_CCI_DEBUG
- CDBG("Secure Sensor %d use cci\n", s_ctrl->id);
- /* session is not secure */
- s_ctrl->sensor_i2c_client->i2c_func_tbl =
- &msm_sensor_cci_func_tbl;
-#else /* CONFIG_MSM_SEC_CCI_DEBUG */
- return rc;
-#endif /* CONFIG_MSM_SEC_CCI_DEBUG */
- } else {
- /* session is secure */
- s_ctrl->sensor_i2c_client->i2c_func_tbl =
- &msm_sensor_secure_func_tbl;
- }
- }
rc = msm_camera_power_up(power_info, s_ctrl->sensor_device_type,
sensor_i2c_client);
if (rc < 0)
@@ -1558,21 +1529,6 @@ static struct msm_camera_i2c_fn_t msm_sensor_qup_func_tbl = {
.i2c_write_table_sync_block = msm_camera_qup_i2c_write_table,
};
-static struct msm_camera_i2c_fn_t msm_sensor_secure_func_tbl = {
- .i2c_read = msm_camera_tz_i2c_read,
- .i2c_read_seq = msm_camera_tz_i2c_read_seq,
- .i2c_write = msm_camera_tz_i2c_write,
- .i2c_write_table = msm_camera_tz_i2c_write_table,
- .i2c_write_seq_table = msm_camera_tz_i2c_write_seq_table,
- .i2c_write_table_w_microdelay =
- msm_camera_tz_i2c_write_table_w_microdelay,
- .i2c_util = msm_sensor_tz_i2c_util,
- .i2c_write_conf_tbl = msm_camera_tz_i2c_write_conf_tbl,
- .i2c_write_table_async = msm_camera_tz_i2c_write_table_async,
- .i2c_write_table_sync = msm_camera_tz_i2c_write_table_sync,
- .i2c_write_table_sync_block = msm_camera_tz_i2c_write_table_sync_block,
-};
-
int32_t msm_sensor_init_default_params(struct msm_sensor_ctrl_t *s_ctrl)
{
struct msm_camera_cci_client *cci_client = NULL;
@@ -1606,9 +1562,6 @@ int32_t msm_sensor_init_default_params(struct msm_sensor_ctrl_t *s_ctrl)
/* Get CCI subdev */
cci_client->cci_subdev = msm_cci_get_subdev();
- if (s_ctrl->is_secure)
- msm_camera_tz_i2c_register_sensor((void *)s_ctrl);
-
/* Update CCI / I2C function table */
if (!s_ctrl->sensor_i2c_client->i2c_func_tbl)
s_ctrl->sensor_i2c_client->i2c_func_tbl =
diff --git a/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.h b/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.h
index 05158b67b8d7..ed8918fb4b04 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2015, 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
@@ -88,8 +88,6 @@ struct msm_sensor_ctrl_t {
enum msm_camera_stream_type_t camera_stream_type;
uint32_t set_mclk_23880000;
uint8_t is_csid_tg_mode;
- uint32_t is_secure;
- uint8_t bypass_video_node_creation;
uint32_t no_hw_strobe;
};
diff --git a/drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c b/drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c
index 04b5f5712e3c..46b3eec0f0b1 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c
@@ -10,7 +10,7 @@
* GNU General Public License for more details.
*/
-#define SENSOR_DRIVER_I2C "camera"
+#define SENSOR_DRIVER_I2C "i2c_camera"
/* Header file declaration */
#include "msm_sensor.h"
#include "msm_sd.h"
@@ -89,14 +89,11 @@ static int32_t msm_sensor_driver_create_i2c_v4l_subdev
struct i2c_client *client = s_ctrl->sensor_i2c_client->client;
CDBG("%s %s I2c probe succeeded\n", __func__, client->name);
- if (0 == s_ctrl->bypass_video_node_creation) {
- rc = camera_init_v4l2(&client->dev, &session_id);
- if (rc < 0) {
- pr_err("failed: camera_init_i2c_v4l2 rc %d", rc);
- return rc;
- }
+ rc = camera_init_v4l2(&client->dev, &session_id);
+ if (rc < 0) {
+ pr_err("failed: camera_init_i2c_v4l2 rc %d", rc);
+ return rc;
}
-
CDBG("%s rc %d session_id %d\n", __func__, rc, session_id);
snprintf(s_ctrl->msm_sd.sd.name,
sizeof(s_ctrl->msm_sd.sd.name), "%s",
@@ -111,11 +108,7 @@ static int32_t msm_sensor_driver_create_i2c_v4l_subdev
s_ctrl->msm_sd.sd.entity.name = s_ctrl->msm_sd.sd.name;
s_ctrl->sensordata->sensor_info->session_id = session_id;
s_ctrl->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x3;
- rc = msm_sd_register(&s_ctrl->msm_sd);
- if (rc < 0) {
- pr_err("failed: msm_sd_register rc %d", rc);
- return rc;
- }
+ msm_sd_register(&s_ctrl->msm_sd);
msm_sensor_v4l2_subdev_fops = v4l2_subdev_fops;
#ifdef CONFIG_COMPAT
msm_sensor_v4l2_subdev_fops.compat_ioctl32 =
@@ -133,14 +126,11 @@ static int32_t msm_sensor_driver_create_v4l_subdev
int32_t rc = 0;
uint32_t session_id = 0;
- if (0 == s_ctrl->bypass_video_node_creation) {
- rc = camera_init_v4l2(&s_ctrl->pdev->dev, &session_id);
- if (rc < 0) {
- pr_err("failed: camera_init_v4l2 rc %d", rc);
- return rc;
- }
+ rc = camera_init_v4l2(&s_ctrl->pdev->dev, &session_id);
+ if (rc < 0) {
+ pr_err("failed: camera_init_v4l2 rc %d", rc);
+ return rc;
}
-
CDBG("rc %d session_id %d", rc, session_id);
s_ctrl->sensordata->sensor_info->session_id = session_id;
@@ -155,11 +145,7 @@ static int32_t msm_sensor_driver_create_v4l_subdev
s_ctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_SENSOR;
s_ctrl->msm_sd.sd.entity.name = s_ctrl->msm_sd.sd.name;
s_ctrl->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x3;
- rc = msm_sd_register(&s_ctrl->msm_sd);
- if (rc < 0) {
- pr_err("failed: msm_sd_register rc %d", rc);
- return rc;
- }
+ msm_sd_register(&s_ctrl->msm_sd);
msm_cam_copy_v4l2_subdev_fops(&msm_sensor_v4l2_subdev_fops);
#ifdef CONFIG_COMPAT
msm_sensor_v4l2_subdev_fops.compat_ioctl32 =
@@ -347,42 +333,6 @@ static int32_t msm_sensor_fill_ois_subdevid_by_name(
return rc;
}
-static int32_t msm_sensor_fill_flash_subdevid_by_name(
- struct msm_sensor_ctrl_t *s_ctrl)
-{
- int32_t rc = 0;
- struct device_node *src_node = NULL;
- uint32_t val = 0;
- int32_t *flash_subdev_id;
- struct msm_sensor_info_t *sensor_info;
- struct device_node *of_node = s_ctrl->of_node;
-
- if (!of_node)
- return -EINVAL;
-
- sensor_info = s_ctrl->sensordata->sensor_info;
- flash_subdev_id = &sensor_info->subdev_id[SUB_MODULE_LED_FLASH];
-
- *flash_subdev_id = -1;
-
- src_node = of_parse_phandle(of_node, "qcom,led-flash-src", 0);
- if (!src_node) {
- CDBG("%s:%d src_node NULL\n", __func__, __LINE__);
- } else {
- rc = of_property_read_u32(src_node, "cell-index", &val);
- CDBG("%s qcom,flash cell index %d, rc %d\n", __func__,
- val, rc);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- return -EINVAL;
- }
- *flash_subdev_id = val;
- of_node_put(src_node);
- src_node = NULL;
- }
- return rc;
-}
-
static int32_t msm_sensor_fill_slave_info_init_params(
struct msm_camera_sensor_slave_info *slave_info,
struct msm_sensor_info_t *sensor_info)
@@ -760,8 +710,6 @@ int32_t msm_sensor_driver_probe(void *setting,
slave_info32->sensor_init_params;
slave_info->output_format =
slave_info32->output_format;
- slave_info->bypass_video_node_creation =
- !!slave_info32->bypass_video_node_creation;
kfree(slave_info32);
} else
#endif
@@ -774,21 +722,6 @@ int32_t msm_sensor_driver_probe(void *setting,
}
}
- if (strlen(slave_info->sensor_name) >= MAX_SENSOR_NAME ||
- strlen(slave_info->eeprom_name) >= MAX_SENSOR_NAME ||
- strlen(slave_info->actuator_name) >= MAX_SENSOR_NAME ||
- strlen(slave_info->ois_name) >= MAX_SENSOR_NAME) {
- pr_err("failed: name len greater than 32.\n");
- pr_err("sensor name len:%zu, eeprom name len: %zu.\n",
- strlen(slave_info->sensor_name),
- strlen(slave_info->eeprom_name));
- pr_err("actuator name len: %zu, ois name len:%zu.\n",
- strlen(slave_info->actuator_name),
- strlen(slave_info->ois_name));
- rc = -EINVAL;
- goto free_slave_info;
- }
-
/* Print slave info */
CDBG("camera id %d Slave addr 0x%X addr_type %d\n",
slave_info->camera_id, slave_info->slave_addr,
@@ -804,8 +737,6 @@ int32_t msm_sensor_driver_probe(void *setting,
slave_info->sensor_init_params.position);
CDBG("mount %d",
slave_info->sensor_init_params.sensor_mount_angle);
- CDBG("bypass video node creation %d",
- slave_info->bypass_video_node_creation);
/* Validate camera id */
if (slave_info->camera_id >= MAX_CAMERAS) {
pr_err("failed: invalid camera id %d max %d",
@@ -833,12 +764,9 @@ int32_t msm_sensor_driver_probe(void *setting,
*/
if (slave_info->sensor_id_info.sensor_id ==
s_ctrl->sensordata->cam_slave_info->
- sensor_id_info.sensor_id &&
- !(strcmp(slave_info->sensor_name,
- s_ctrl->sensordata->cam_slave_info->sensor_name))) {
- pr_err("slot%d: sensor name: %s sensor id%d already probed\n",
+ sensor_id_info.sensor_id) {
+ pr_err("slot%d: sensor id%d already probed\n",
slave_info->camera_id,
- slave_info->sensor_name,
s_ctrl->sensordata->cam_slave_info->
sensor_id_info.sensor_id);
msm_sensor_fill_sensor_info(s_ctrl,
@@ -940,7 +868,6 @@ CSID_TG:
s_ctrl->sensordata->eeprom_name = slave_info->eeprom_name;
s_ctrl->sensordata->actuator_name = slave_info->actuator_name;
s_ctrl->sensordata->ois_name = slave_info->ois_name;
- s_ctrl->sensordata->flash_name = slave_info->flash_name;
/* Save Sensor Info */
s_ctrl->sensordata->cam_slave_info = slave_info;
/*
@@ -966,12 +893,6 @@ CSID_TG:
goto free_camera_info;
}
- rc = msm_sensor_fill_flash_subdevid_by_name(s_ctrl);
- if (rc < 0) {
- pr_err("%s failed %d\n", __func__, __LINE__);
- goto free_camera_info;
- }
-
/* Power up and probe sensor */
rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
if (rc < 0) {
@@ -981,8 +902,11 @@ CSID_TG:
pr_err("%s probe succeeded", slave_info->sensor_name);
- s_ctrl->bypass_video_node_creation =
- slave_info->bypass_video_node_creation;
+ /*
+ Set probe succeeded flag to 1 so that no other camera shall
+ * probed on this slot
+ */
+ s_ctrl->is_probe_succeed = 1;
/*
* Update the subdevice id of flash-src based on availability in kernel.
@@ -1024,7 +948,7 @@ CSID_TG:
}
/* Update sensor mount angle and position in media entity flag */
is_yuv = (slave_info->output_format == MSM_SENSOR_YCBCR) ? 1 : 0;
- mount_pos = ((s_ctrl->is_secure & 0x1) << 26) | is_yuv << 25 |
+ mount_pos = is_yuv << 25 |
(s_ctrl->sensordata->sensor_info->position << 16) |
((s_ctrl->sensordata->
sensor_info->sensor_mount_angle / 90) << 8);
@@ -1033,11 +957,6 @@ CSID_TG:
msm_sensor_fill_sensor_info(s_ctrl, probed_info, entity_name);
- /*
- * Set probe succeeded flag to 1 so that no other camera shall
- * probed on this slot
- */
- s_ctrl->is_probe_succeed = 1;
return rc;
camera_power_down:
@@ -1117,16 +1036,6 @@ static int32_t msm_sensor_driver_get_dt_data(struct msm_sensor_ctrl_t *s_ctrl)
goto FREE_VREG_DATA;
}
- /* Get custom mode */
- rc = of_property_read_u32(of_node, "qcom,secure",
- &s_ctrl->is_secure);
- CDBG("qcom,secure = %d, rc %d", s_ctrl->is_secure, rc);
- if (rc < 0) {
- /* Set default to non-secure mode */
- s_ctrl->is_secure = 0;
- rc = 0;
- }
-
/* Get CCI master */
rc = of_property_read_u32(of_node, "qcom,cci-master",
&s_ctrl->cci_i2c_master);
@@ -1259,7 +1168,6 @@ static int32_t msm_sensor_driver_parse(struct msm_sensor_ctrl_t *s_ctrl)
FREE_DT_DATA:
kfree(s_ctrl->sensordata->power_info.gpio_conf->gpio_num_info);
kfree(s_ctrl->sensordata->power_info.gpio_conf->cam_gpio_req_tbl);
- kfree(s_ctrl->sensordata->power_info.gpio_conf->cam_gpio_set_tbl);
kfree(s_ctrl->sensordata->power_info.gpio_conf);
kfree(s_ctrl->sensordata->power_info.cam_vreg);
kfree(s_ctrl->sensordata);
diff --git a/drivers/media/platform/msm/camera_v2/sensor/ois/msm_ois.c b/drivers/media/platform/msm/camera_v2/sensor/ois/msm_ois.c
index 80f57e1a6da7..820e67f5d749 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/ois/msm_ois.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/ois/msm_ois.c
@@ -832,10 +832,11 @@ static long msm_ois_subdev_do_ioctl(
u32 = (struct msm_ois_cfg_data32 *)arg;
parg = arg;
+ ois_data.cfgtype = u32->cfgtype;
+
switch (cmd) {
case VIDIOC_MSM_OIS_CFG32:
cmd = VIDIOC_MSM_OIS_CFG;
- ois_data.cfgtype = u32->cfgtype;
switch (u32->cfgtype) {
case CFG_OIS_CONTROL:
@@ -869,6 +870,7 @@ static long msm_ois_subdev_do_ioctl(
settings.reg_setting =
compat_ptr(settings32.reg_setting);
+ ois_data.cfgtype = u32->cfgtype;
ois_data.cfg.settings = &settings;
parg = &ois_data;
break;
@@ -876,10 +878,6 @@ static long msm_ois_subdev_do_ioctl(
parg = &ois_data;
break;
}
- break;
- case VIDIOC_MSM_OIS_CFG:
- pr_err("%s: invalid cmd 0x%x received\n", __func__, cmd);
- return -EINVAL;
}
rc = msm_ois_subdev_ioctl(sd, cmd, parg);
@@ -949,16 +947,15 @@ static int32_t msm_ois_platform_probe(struct platform_device *pdev)
rc = msm_sensor_driver_get_gpio_data(&(msm_ois_t->gconf),
(&pdev->dev)->of_node);
- if (-ENODEV == rc) {
- pr_notice("No valid OIS GPIOs data\n");
- } else if (rc < 0) {
- pr_err("Error OIS GPIO\n");
+ if (rc < 0) {
+ pr_err("%s: No/Error OIS GPIO\n", __func__);
} else {
msm_ois_t->cam_pinctrl_status = 1;
rc = msm_camera_pinctrl_init(
&(msm_ois_t->pinctrl_info), &(pdev->dev));
if (rc < 0) {
- pr_err("ERR: Error in reading OIS pinctrl\n");
+ pr_err("ERR:%s: Error in reading OIS pinctrl\n",
+ __func__);
msm_ois_t->cam_pinctrl_status = 0;
}
}
diff --git a/include/media/msm_cam_sensor.h b/include/media/msm_cam_sensor.h
index b4613de02ab5..f3431c9cd75f 100644
--- a/include/media/msm_cam_sensor.h
+++ b/include/media/msm_cam_sensor.h
@@ -42,7 +42,6 @@ struct msm_camera_sensor_slave_info32 {
uint8_t is_init_params_valid;
struct msm_sensor_init_params sensor_init_params;
enum msm_sensor_output_format_t output_format;
- uint8_t bypass_video_node_creation;
};
struct msm_camera_csid_lut_params32 {
diff --git a/include/media/msmb_isp.h b/include/media/msmb_isp.h
index 085bd7038094..22e90462573c 100644
--- a/include/media/msmb_isp.h
+++ b/include/media/msmb_isp.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2016, 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
@@ -28,18 +28,7 @@ struct msm_isp_event_data32 {
struct msm_isp_sof_info sof_info;
} u;
};
-
-struct msm_isp32_event_data32 {
- struct compat_timeval timestamp;
- struct compat_timeval mono_timestamp;
- enum msm_vfe_input_src input_intf;
- uint32_t frame_id;
- union {
- struct msm_isp_stats_event stats;
- struct msm_isp_buf_event buf_done;
- struct msm_isp32_error_info error_info;
- } u;
-};
+#endif
#endif
-#endif /* __MSMB_ISP__ */
+
diff --git a/include/uapi/media/msm_cam_sensor.h b/include/uapi/media/msm_cam_sensor.h
index 52bdc0d0fddb..d2bfb6cba870 100644
--- a/include/uapi/media/msm_cam_sensor.h
+++ b/include/uapi/media/msm_cam_sensor.h
@@ -331,7 +331,7 @@ struct msm_eeprom_cfg_data {
enum eeprom_cfg_type_t cfgtype;
uint8_t is_supported;
union {
- char eeprom_name[MAX_SENSOR_NAME];
+ char eeprom_name[MAX_EEPROM_NAME];
struct eeprom_get_t get_data;
struct eeprom_read_t read_data;
struct eeprom_write_t write_data;
diff --git a/include/uapi/media/msm_camsensor_sdk.h b/include/uapi/media/msm_camsensor_sdk.h
index 3022e0079da2..24cd42e1f480 100644
--- a/include/uapi/media/msm_camsensor_sdk.h
+++ b/include/uapi/media/msm_camsensor_sdk.h
@@ -48,8 +48,6 @@
#define MSM_EEPROM_MEMORY_MAP_MAX_SIZE 100
#define MSM_EEPROM_MAX_MEM_MAP_CNT 8
-#define MSM_SENSOR_BYPASS_VIDEO_NODE 1
-
enum msm_sensor_camera_id_t {
CAMERA_0,
CAMERA_1,
@@ -258,7 +256,6 @@ enum msm_camera_i2c_operation {
MSM_CAM_POLL,
MSM_CAM_READ,
MSM_CAM_POLL_STRICT,
- MSM_CAM_READ_LOOP,
};
struct msm_sensor_i2c_sync_params {
@@ -323,7 +320,6 @@ struct msm_camera_sensor_slave_info {
unsigned char is_init_params_valid;
struct msm_sensor_init_params sensor_init_params;
enum msm_sensor_output_format_t output_format;
- uint8_t bypass_video_node_creation;
};
struct msm_camera_i2c_reg_array {
diff --git a/include/uapi/media/msm_jpeg_dma.h b/include/uapi/media/msm_jpeg_dma.h
index 44fa4ed8af52..df3c7ee5b7cf 100644
--- a/include/uapi/media/msm_jpeg_dma.h
+++ b/include/uapi/media/msm_jpeg_dma.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2016, 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
@@ -18,4 +18,10 @@
/* msm jpeg dma control ID's */
#define V4L2_CID_JPEG_DMA_SPEED (V4L2_CID_PRIVATE_BASE)
+/* msm_jpeg_dma_buf */
+struct msm_jpeg_dma_buff {
+ int32_t fd;
+ uint32_t offset;
+};
+
#endif /* __UAPI_MSM_JPEG_DMA__ */
diff --git a/include/uapi/media/msmb_isp.h b/include/uapi/media/msmb_isp.h
index 429e35339a0a..72d40d3837d8 100644
--- a/include/uapi/media/msmb_isp.h
+++ b/include/uapi/media/msmb_isp.h
@@ -17,7 +17,6 @@
#define ISP1_BIT (0x10000 << 2)
#define ISP_META_CHANNEL_BIT (0x10000 << 3)
#define ISP_SCRATCH_BUF_BIT (0x10000 << 4)
-#define ISP_PDAF_CHANNEL_BIT (0x10000 << 5)
#define ISP_OFFLINE_STATS_BIT (0x10000 << 5)
#define ISP_SVHDR_IN_BIT (0x10000 << 6) /* RDI hw stream for SVHDR */
#define ISP_SVHDR_OUT_BIT (0x10000 << 7) /* SVHDR output bufq stream*/
@@ -300,12 +299,6 @@ enum msm_stream_memory_input_t {
MEMORY_INPUT_ENABLED
};
-enum msm_stream_rdi_input_type {
- MSM_CAMERA_RDI_MIN,
- MSM_CAMERA_RDI_PDAF,
- MSM_CAMERA_RDI_MAX,
-};
-
struct msm_vfe_axi_stream_request_cmd {
uint32_t session_id;
uint32_t stream_id;
@@ -326,29 +319,6 @@ struct msm_vfe_axi_stream_request_cmd {
uint32_t controllable_output;
uint32_t burst_len;
/* Flag indicating memory input stream */
- enum msm_stream_rdi_input_type rdi_input_type;
-};
-
-struct msm_vfe32_axi_stream_request_cmd {
- uint32_t session_id;
- uint32_t stream_id;
- uint32_t vt_enable;
- uint32_t output_format;/*Planar/RAW/Misc*/
- enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/
- struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
-
- uint32_t burst_count;
- uint32_t hfr_mode;
- uint8_t frame_base;
-
- uint32_t init_frame_drop; /*MAX 31 Frames*/
- enum msm_vfe_frame_skip_pattern frame_skip_pattern;
- uint8_t buf_divert; /* if TRUE no vb2 buf done. */
- /*Return values*/
- uint32_t axi_stream_handle;
- uint32_t controllable_output;
- uint32_t burst_len;
- /* Flag indicating memory input stream */
enum msm_stream_memory_input_t memory_input;
};
@@ -356,11 +326,6 @@ struct msm_vfe_axi_stream_release_cmd {
uint32_t stream_handle;
};
-struct msm_vfe_update_fe_frame_id {
- uint32_t frame_id;
-};
-
-
enum msm_vfe_axi_stream_cmd {
STOP_STREAM,
START_STREAM,
@@ -439,10 +404,6 @@ struct msm_vfe_axi_restart_cmd {
uint32_t enable_camif;
};
-struct msm_vfe_restart_fe_cmd {
- uint32_t restart_fe;
-};
-
struct msm_vfe_axi_stream_update_cmd {
uint32_t num_streams;
enum msm_vfe_axi_stream_update_type update_type;
@@ -711,9 +672,7 @@ enum msm_isp_event_idx {
ISP_PING_PONG_MISMATCH = 12,
ISP_REG_UPDATE_MISSING = 13,
ISP_BUF_FATAL_ERROR = 14,
- ISP_EVENT_MAX = 15,
- ISP_WM_BUS_OVERFLOW = 16,
- ISP_CAMIF_ERROR = 17
+ ISP_EVENT_MAX = 15
};
#define ISP_EVENT_OFFSET 8
@@ -743,8 +702,6 @@ enum msm_isp_event_idx {
#define ISP_EVENT_REG_UPDATE_MISSING (ISP_EVENT_BASE + ISP_REG_UPDATE_MISSING)
#define ISP_EVENT_BUF_FATAL_ERROR (ISP_EVENT_BASE + ISP_BUF_FATAL_ERROR)
#define ISP_EVENT_STREAM_UPDATE_DONE (ISP_STREAM_EVENT_BASE)
-#define ISP_EVENT_CAMIF_ERROR (ISP_EVENT_BASE + ISP_CAMIF_ERROR)
-#define ISP_EVENT_WM_BUS_OVERFLOW (ISP_EVENT_BASE + ISP_WM_BUS_OVERFLOW)
/* The msm_v4l2_event_data structure should match the
* v4l2_event.u.data field.
@@ -768,7 +725,6 @@ struct msm_isp_fetch_eng_event {
struct msm_isp_stats_event {
uint32_t stats_mask; /* 4 bytes */
uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
- uint8_t pd_stats_idx;
};
struct msm_isp_stream_ack {
@@ -793,11 +749,6 @@ struct msm_isp_error_info {
uint32_t stream_id_mask;
};
-struct msm_isp32_error_info {
- /* 1 << msm_isp_event_idx */
- uint32_t error_mask;
-};
-
/* This structure reports delta between master and slave */
struct msm_isp_ms_delta_info {
uint8_t num_delta_info;
@@ -866,25 +817,6 @@ struct msm_isp_event_data {
} u; /* union can have max 52 bytes */
};
-struct msm_isp32_event_data {
- /*Wall clock except for buffer divert events
- *which use monotonic clock
- */
- struct timeval timestamp;
- /* Monotonic timestamp since bootup */
- struct timeval mono_timestamp;
- enum msm_vfe_input_src input_intf;
- uint32_t frame_id;
- union {
- /* Sent for Stats_Done event */
- struct msm_isp_stats_event stats;
- /* Sent for Buf_Divert event */
- struct msm_isp_buf_event buf_done;
- struct msm_isp32_error_info error_info;
- } u; /* union can have max 52 bytes */
- uint32_t is_skip_pproc;
-};
-
enum msm_vfe_ahb_clk_vote {
MSM_ISP_CAMERA_AHB_SVS_VOTE = 1,
MSM_ISP_CAMERA_AHB_TURBO_VOTE = 2,
@@ -917,10 +849,6 @@ struct msm_isp_ahb_clk_cfg {
#define V4L2_PIX_FMT_P16GBRG10 v4l2_fourcc('P', 'G', 'B', '0')
#define V4L2_PIX_FMT_P16GRBG10 v4l2_fourcc('P', 'G', 'R', '0')
#define V4L2_PIX_FMT_P16RGGB10 v4l2_fourcc('P', 'R', 'G', '0')
-#define V4L2_PIX_FMT_P16BGGR12 v4l2_fourcc('P', 'B', 'G', '2')
-#define V4L2_PIX_FMT_P16GBRG12 v4l2_fourcc('P', 'G', 'B', '2')
-#define V4L2_PIX_FMT_P16GRBG12 v4l2_fourcc('P', 'G', 'R', '2')
-#define V4L2_PIX_FMT_P16RGGB12 v4l2_fourcc('P', 'R', 'G', '2')
#define V4L2_PIX_FMT_NV14 v4l2_fourcc('N', 'V', '1', '4')
#define V4L2_PIX_FMT_NV41 v4l2_fourcc('N', 'V', '4', '1')
#define V4L2_PIX_FMT_META v4l2_fourcc('Q', 'M', 'E', 'T')
@@ -960,9 +888,6 @@ enum msm_isp_ioctl_cmd_code {
MSM_ISP_MAP_BUF_START_MULTI_PASS_FE,
MSM_ISP_CFG_HW_STATE,
MSM_ISP_AHB_CLK_CFG,
- MSM_ISP_UPDATE_FE_FRAME_ID,
- MSM_ISP_RESTART_FE,
- MSM_ISP32_REQUEST_STREAM,
};
#define VIDIOC_MSM_VFE_REG_CFG \
@@ -985,10 +910,6 @@ enum msm_isp_ioctl_cmd_code {
_IOWR('V', MSM_ISP_REQUEST_STREAM, \
struct msm_vfe_axi_stream_request_cmd)
-#define VIDIOC_MSM_ISP32_REQUEST_STREAM \
- _IOWR('V', MSM_ISP32_REQUEST_STREAM, \
- struct msm_vfe32_axi_stream_request_cmd)
-
#define VIDIOC_MSM_ISP_CFG_STREAM \
_IOWR('V', MSM_ISP_CFG_STREAM, \
struct msm_vfe_axi_stream_cfg_cmd)
@@ -1049,10 +970,6 @@ enum msm_isp_ioctl_cmd_code {
_IOWR('V', MSM_ISP_AXI_RESTART, \
struct msm_vfe_axi_restart_cmd)
-#define VIDIOC_MSM_ISP_RESTART_FE \
- _IOWR('V', MSM_ISP_RESTART_FE,\
- struct msm_vfe_restart_fe_cmd)
-
#define VIDIOC_MSM_ISP_FETCH_ENG_START \
_IOWR('V', MSM_ISP_FETCH_ENG_START, \
struct msm_vfe_fetch_eng_start)
@@ -1069,10 +986,6 @@ enum msm_isp_ioctl_cmd_code {
_IOWR('V', MSM_ISP_MAP_BUF_START_FE, \
struct msm_vfe_fetch_eng_start)
-#define VIDIOC_MSM_ISP_UPDATE_FE_FRAME_ID \
- _IOWR('V', MSM_ISP_UPDATE_FE_FRAME_ID, \
- struct msm_vfe_update_fe_frame_id)
-
#define VIDIOC_MSM_ISP_UNMAP_BUF \
_IOWR('V', MSM_ISP_UNMAP_BUF, \
struct msm_isp_unmap_buf_req)
@@ -1091,8 +1004,5 @@ enum msm_isp_ioctl_cmd_code {
#define VIDIOC_MSM_ISP_AHB_CLK_CFG \
_IOWR('V', MSM_ISP_AHB_CLK_CFG, struct msm_isp_ahb_clk_cfg)
+#endif /* __MSMB_ISP__ */
-#define VIDIOC_MSM_ISP_BUF_DONE \
- _IOWR('V', BASE_VIDIOC_PRIVATE+21, struct msm_isp32_event_data)
-
-#endif/* __MSMB_ISP__ */
diff --git a/include/uapi/media/msmb_ispif.h b/include/uapi/media/msmb_ispif.h
index 19b68d7807ac..dd8bb44576af 100644
--- a/include/uapi/media/msmb_ispif.h
+++ b/include/uapi/media/msmb_ispif.h
@@ -36,6 +36,7 @@ enum msm_ispif_intftype {
#define RDI1_MASK (1 << RDI1)
#define RDI2_MASK (1 << RDI2)
+
enum msm_ispif_vc {
VC0,
VC1,
@@ -101,18 +102,10 @@ struct msm_ispif_params_entry {
uint16_t crop_end_pixel;
};
-struct msm_ispif_right_param_entry {
- enum msm_ispif_cid cids[MAX_CID_CH_v2];
- enum msm_ispif_csid csid;
-};
-
struct msm_ispif_param_data_ext {
uint32_t num;
struct msm_ispif_params_entry entries[MAX_PARAM_ENTRIES];
struct msm_ispif_pack_cfg pack_cfg[CID_MAX];
- struct msm_ispif_right_param_entry right_entries[MAX_PARAM_ENTRIES];
- uint32_t stereo_enable;
- uint16_t line_width[VFE_MAX];
};
struct msm_ispif_param_data {
@@ -144,7 +137,6 @@ enum ispif_cfg_type_t {
ISPIF_ENABLE_REG_DUMP,
ISPIF_SET_VFE_INFO,
ISPIF_CFG2,
- ISPIF_CFG_STEREO,
};
struct ispif_cfg_data {
@@ -165,10 +157,6 @@ struct ispif_cfg_data_ext {
#define ISPIF_RDI_PACK_MODE_SUPPORT 1
-#define ISPIF_3D_SUPPORT 1
-
-#define ISPIF_LINE_WIDTH_SUPPORT 1
-
#define VIDIOC_MSM_ISPIF_CFG \
_IOWR('V', BASE_VIDIOC_PRIVATE, struct ispif_cfg_data)