aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/atomisp/pci/sh_css_mipi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/media/atomisp/pci/sh_css_mipi.c')
-rw-r--r--drivers/staging/media/atomisp/pci/sh_css_mipi.c113
1 files changed, 43 insertions, 70 deletions
diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c
index ef9360d72b04..35cbef5f9f71 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c
@@ -45,8 +45,6 @@ ia_css_mipi_frame_specify(const unsigned int size_mem_words,
return err;
}
-#ifdef ISP2401
-#if defined(USE_INPUT_SYSTEM_VERSION_2) || defined(USE_INPUT_SYSTEM_VERSION_2401)
/*
* Check if a source port or TPG/PRBS ID is valid
*/
@@ -87,9 +85,7 @@ static bool ia_css_mipi_is_source_port_valid(struct ia_css_pipe *pipe,
return ret;
}
-#endif
-#endif
/* Assumptions:
* - A line is multiple of 4 bytes = 1 word.
* - Each frame has SOF and EOF (each 1 word).
@@ -317,10 +313,8 @@ calculate_mipi_buff_size(
enum ia_css_err err = IA_CSS_SUCCESS;
/**
-#ifndef ISP2401
* zhengjie.lu@intel.com
*
-#endif
* NOTE
* - In the struct "ia_css_stream_config", there
* are two members: "input_config" and "isys_config".
@@ -336,10 +330,8 @@ calculate_mipi_buff_size(
/* end of NOTE */
/**
-#ifndef ISP2401
* zhengjie.lu@intel.com
*
-#endif
* NOTE
* - The following code is derived from the
* existing code "ia_css_mipi_frame_calculate_size()".
@@ -396,16 +388,29 @@ calculate_mipi_buff_size(
return err;
}
+static bool buffers_needed(struct ia_css_pipe *pipe)
+{
+ if (!atomisp_hw_is_isp2401) {
+ if (pipe->stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR)
+ return false;
+ else
+ return true;
+ }
+
+ if (pipe->stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR ||
+ pipe->stream->config.mode == IA_CSS_INPUT_MODE_TPG ||
+ pipe->stream->config.mode == IA_CSS_INPUT_MODE_PRBS)
+ return false;
+
+ return true;
+}
+
enum ia_css_err
allocate_mipi_frames(struct ia_css_pipe *pipe,
struct ia_css_stream_info *info) {
#if defined(USE_INPUT_SYSTEM_VERSION_2) || defined(USE_INPUT_SYSTEM_VERSION_2401)
enum ia_css_err err = IA_CSS_ERR_INTERNAL_ERROR;
-#ifndef ISP2401
unsigned int port;
-#else
- unsigned int port = 0;
-#endif
struct ia_css_frame_info mipi_intermediate_info;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
@@ -431,30 +436,22 @@ allocate_mipi_frames(struct ia_css_pipe *pipe,
}
#endif
-#ifndef ISP2401
- if (pipe->stream->config.mode != IA_CSS_INPUT_MODE_BUFFERED_SENSOR)
- {
-#else
- if (!(pipe->stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR ||
- pipe->stream->config.mode == IA_CSS_INPUT_MODE_TPG ||
- pipe->stream->config.mode == IA_CSS_INPUT_MODE_PRBS))
- {
-#endif
+
+ if (!buffers_needed(pipe)) {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
"allocate_mipi_frames(%p) exit: no buffers needed for pipe mode.\n",
pipe);
return IA_CSS_SUCCESS; /* AM TODO: Check */
}
-#ifndef ISP2401
- port = (unsigned int)pipe->stream->config.source.port.port;
+ if (!atomisp_hw_is_isp2401)
+ port = (unsigned int)pipe->stream->config.source.port.port;
+ else
+ err = ia_css_mipi_is_source_port_valid(pipe, &port);
+
assert(port < N_CSI_PORTS);
- if (port >= N_CSI_PORTS)
- {
-#else
- if (!ia_css_mipi_is_source_port_valid(pipe, &port))
- {
-#endif
+
+ if (port >= N_CSI_PORTS || err) {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
"allocate_mipi_frames(%p) exit: error: port is not correct (port=%d).\n",
pipe, port);
@@ -573,11 +570,8 @@ enum ia_css_err
free_mipi_frames(struct ia_css_pipe *pipe) {
#if defined(USE_INPUT_SYSTEM_VERSION_2) || defined(USE_INPUT_SYSTEM_VERSION_2401)
enum ia_css_err err = IA_CSS_ERR_INTERNAL_ERROR;
-#ifndef ISP2401
unsigned int port;
-#else
- unsigned int port = 0;
-#endif
+
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
"free_mipi_frames(%p) enter:\n", pipe);
@@ -592,38 +586,27 @@ free_mipi_frames(struct ia_css_pipe *pipe) {
return IA_CSS_ERR_INVALID_ARGUMENTS;
}
-#ifndef ISP2401
- if (pipe->stream->config.mode != IA_CSS_INPUT_MODE_BUFFERED_SENSOR) {
-#else
- if (!(pipe->stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR ||
- pipe->stream->config.mode == IA_CSS_INPUT_MODE_TPG ||
- pipe->stream->config.mode == IA_CSS_INPUT_MODE_PRBS)) {
-#endif
+ if (!buffers_needed(pipe)) {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
"free_mipi_frames(%p) exit: error: wrong mode.\n",
pipe);
return err;
}
-#ifndef ISP2401
- port = (unsigned int)pipe->stream->config.source.port.port;
+ if (!atomisp_hw_is_isp2401)
+ port = (unsigned int)pipe->stream->config.source.port.port;
+ else
+ err = ia_css_mipi_is_source_port_valid(pipe, &port);
+
assert(port < N_CSI_PORTS);
- if (port >= N_CSI_PORTS) {
-#else
- if (!ia_css_mipi_is_source_port_valid(pipe, &port)) {
-#endif
+
+ if (port >= N_CSI_PORTS || err) {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
-#ifndef ISP2401
"free_mipi_frames(%p, %d) exit: error: pipe port is not correct.\n",
-#else
- "free_mipi_frames(%p) exit: error: pipe port is not correct (port=%d).\n",
-#endif
pipe, port);
return err;
}
-#ifdef ISP2401
-#endif
if (ref_count_mipi_allocation[port] > 0) {
#if defined(USE_INPUT_SYSTEM_VERSION_2)
assert(ref_count_mipi_allocation[port] == 1);
@@ -720,32 +703,22 @@ send_mipi_frames(struct ia_css_pipe *pipe) {
/* multi stream video needs mipi buffers */
/* nothing to be done in other cases. */
-#ifndef ISP2401
- if (pipe->stream->config.mode != IA_CSS_INPUT_MODE_BUFFERED_SENSOR)
- {
-#else
- if (!(pipe->stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR ||
- pipe->stream->config.mode == IA_CSS_INPUT_MODE_TPG ||
- pipe->stream->config.mode == IA_CSS_INPUT_MODE_PRBS))
- {
-#endif
+ if (!buffers_needed(pipe)) {
IA_CSS_LOG("nothing to be done for this mode");
return IA_CSS_SUCCESS;
/* TODO: AM: maybe this should be returning an error. */
}
-#ifndef ISP2401
- port = (unsigned int)pipe->stream->config.source.port.port;
+ if (!atomisp_hw_is_isp2401)
+ port = (unsigned int)pipe->stream->config.source.port.port;
+ else
+ err = ia_css_mipi_is_source_port_valid(pipe, &port);
+
assert(port < N_CSI_PORTS);
- if (port >= N_CSI_PORTS)
- {
- IA_CSS_ERROR("invalid port specified (%d)", port);
-#else
- if (!ia_css_mipi_is_source_port_valid(pipe, &port))
- {
+
+ if (port >= N_CSI_PORTS || err) {
IA_CSS_ERROR("send_mipi_frames(%p) exit: invalid port specified (port=%d).\n",
pipe, port);
-#endif
return err;
}