aboutsummaryrefslogtreecommitdiff
path: root/drivers/mxc/ipu3/ipu_capture.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mxc/ipu3/ipu_capture.c')
-rw-r--r--drivers/mxc/ipu3/ipu_capture.c163
1 files changed, 20 insertions, 143 deletions
diff --git a/drivers/mxc/ipu3/ipu_capture.c b/drivers/mxc/ipu3/ipu_capture.c
index 88b1a3954ae..2399cb88d35 100644
--- a/drivers/mxc/ipu3/ipu_capture.c
+++ b/drivers/mxc/ipu3/ipu_capture.c
@@ -50,7 +50,6 @@ ipu_csi_init_interface(struct ipu_soc *ipu, uint16_t width, uint16_t height,
{
uint32_t data = 0;
uint32_t csi = cfg_param.csi;
- unsigned long lock_flags;
/* Set SENS_DATA_FORMAT bits (8, 9 and 10)
RGB or YUV444 is 0 which is current value in data so not set
@@ -94,10 +93,9 @@ ipu_csi_init_interface(struct ipu_soc *ipu, uint16_t width, uint16_t height,
cfg_param.force_eof << CSI_SENS_CONF_FORCE_EOF_SHIFT |
cfg_param.data_en_pol << CSI_SENS_CONF_DATA_EN_POL_SHIFT;
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
+ _ipu_get(ipu);
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
+ _ipu_lock(ipu);
ipu_csi_write(ipu, csi, data, CSI_SENS_CONF);
@@ -136,11 +134,10 @@ ipu_csi_init_interface(struct ipu_soc *ipu, uint16_t width, uint16_t height,
ipu_csi_write(ipu, csi, 0x40596, CSI_CCIR_CODE_2);
ipu_csi_write(ipu, csi, 0xFF0000, CSI_CCIR_CODE_3);
} else {
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
dev_err(ipu->dev, "Unsupported CCIR656 interlaced "
"video mode\n");
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
+ _ipu_unlock(ipu);
+ _ipu_put(ipu);
return -EINVAL;
}
_ipu_csi_ccir_err_detection_enable(ipu, csi);
@@ -165,10 +162,9 @@ ipu_csi_init_interface(struct ipu_soc *ipu, uint16_t width, uint16_t height,
dev_dbg(ipu->dev, "CSI_ACT_FRM_SIZE = 0x%08X\n",
ipu_csi_read(ipu, csi, CSI_ACT_FRM_SIZE));
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
+ _ipu_unlock(ipu);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
+ _ipu_put(ipu);
return 0;
}
@@ -254,21 +250,18 @@ EXPORT_SYMBOL(ipu_csi_enable_mclk);
void ipu_csi_get_window_size(struct ipu_soc *ipu, uint32_t *width, uint32_t *height, uint32_t csi)
{
uint32_t reg;
- unsigned long lock_flags;
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
+ _ipu_get(ipu);
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
+ _ipu_lock(ipu);
reg = ipu_csi_read(ipu, csi, CSI_ACT_FRM_SIZE);
*width = (reg & 0xFFFF) + 1;
*height = (reg >> 16 & 0xFFFF) + 1;
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
+ _ipu_unlock(ipu);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
+ _ipu_put(ipu);
}
EXPORT_SYMBOL(ipu_csi_get_window_size);
@@ -282,19 +275,15 @@ EXPORT_SYMBOL(ipu_csi_get_window_size);
*/
void ipu_csi_set_window_size(struct ipu_soc *ipu, uint32_t width, uint32_t height, uint32_t csi)
{
- unsigned long lock_flags;
+ _ipu_get(ipu);
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
+ _ipu_lock(ipu);
ipu_csi_write(ipu, csi, (width - 1) | (height - 1) << 16, CSI_ACT_FRM_SIZE);
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
+ _ipu_unlock(ipu);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
+ _ipu_put(ipu);
}
EXPORT_SYMBOL(ipu_csi_set_window_size);
@@ -309,22 +298,19 @@ EXPORT_SYMBOL(ipu_csi_set_window_size);
void ipu_csi_set_window_pos(struct ipu_soc *ipu, uint32_t left, uint32_t top, uint32_t csi)
{
uint32_t temp;
- unsigned long lock_flags;
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
+ _ipu_get(ipu);
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
+ _ipu_lock(ipu);
temp = ipu_csi_read(ipu, csi, CSI_OUT_FRM_CTRL);
temp &= ~(CSI_HSC_MASK | CSI_VSC_MASK);
temp |= ((top << CSI_VSC_SHIFT) | (left << CSI_HSC_SHIFT));
ipu_csi_write(ipu, csi, temp, CSI_OUT_FRM_CTRL);
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
+ _ipu_unlock(ipu);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
+ _ipu_put(ipu);
}
EXPORT_SYMBOL(ipu_csi_set_window_pos);
@@ -338,21 +324,10 @@ EXPORT_SYMBOL(ipu_csi_set_window_pos);
void _ipu_csi_horizontal_downsize_enable(struct ipu_soc *ipu, uint32_t csi)
{
uint32_t temp;
- unsigned long lock_flags;
-
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
temp = ipu_csi_read(ipu, csi, CSI_OUT_FRM_CTRL);
temp |= CSI_HORI_DOWNSIZE_EN;
ipu_csi_write(ipu, csi, temp, CSI_OUT_FRM_CTRL);
-
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
-
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
}
/*!
@@ -365,21 +340,10 @@ void _ipu_csi_horizontal_downsize_enable(struct ipu_soc *ipu, uint32_t csi)
void _ipu_csi_horizontal_downsize_disable(struct ipu_soc *ipu, uint32_t csi)
{
uint32_t temp;
- unsigned long lock_flags;
-
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
temp = ipu_csi_read(ipu, csi, CSI_OUT_FRM_CTRL);
temp &= ~CSI_HORI_DOWNSIZE_EN;
ipu_csi_write(ipu, csi, temp, CSI_OUT_FRM_CTRL);
-
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
-
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
}
/*!
@@ -392,21 +356,10 @@ void _ipu_csi_horizontal_downsize_disable(struct ipu_soc *ipu, uint32_t csi)
void _ipu_csi_vertical_downsize_enable(struct ipu_soc *ipu, uint32_t csi)
{
uint32_t temp;
- unsigned long lock_flags;
-
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
temp = ipu_csi_read(ipu, csi, CSI_OUT_FRM_CTRL);
temp |= CSI_VERT_DOWNSIZE_EN;
ipu_csi_write(ipu, csi, temp, CSI_OUT_FRM_CTRL);
-
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
-
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
}
/*!
@@ -419,25 +372,14 @@ void _ipu_csi_vertical_downsize_enable(struct ipu_soc *ipu, uint32_t csi)
void _ipu_csi_vertical_downsize_disable(struct ipu_soc *ipu, uint32_t csi)
{
uint32_t temp;
- unsigned long lock_flags;
-
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
temp = ipu_csi_read(ipu, csi, CSI_OUT_FRM_CTRL);
temp &= ~CSI_VERT_DOWNSIZE_EN;
ipu_csi_write(ipu, csi, temp, CSI_OUT_FRM_CTRL);
-
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
-
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
}
/*!
- * ipu_csi_set_test_generator
+ * _ipu_csi_set_test_generator
*
* @param ipu ipu handler
* @param active 1 for active and 0 for inactive
@@ -448,16 +390,10 @@ void _ipu_csi_vertical_downsize_disable(struct ipu_soc *ipu, uint32_t csi)
* @param pixel_clk desired pixel clock frequency in Hz
* @param csi csi 0 or csi 1
*/
-void ipu_csi_set_test_generator(struct ipu_soc *ipu, bool active, uint32_t r_value,
+void _ipu_csi_set_test_generator(struct ipu_soc *ipu, bool active, uint32_t r_value,
uint32_t g_value, uint32_t b_value, uint32_t pix_clk, uint32_t csi)
{
uint32_t temp;
- unsigned long lock_flags;
-
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
temp = ipu_csi_read(ipu, csi, CSI_TST_CTRL);
@@ -476,13 +412,7 @@ void ipu_csi_set_test_generator(struct ipu_soc *ipu, bool active, uint32_t r_val
(b_value << CSI_TEST_GEN_B_SHIFT);
ipu_csi_write(ipu, csi, temp, CSI_TST_CTRL);
}
-
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
-
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
}
-EXPORT_SYMBOL(ipu_csi_set_test_generator);
/*!
* _ipu_csi_ccir_err_detection_en
@@ -496,15 +426,10 @@ void _ipu_csi_ccir_err_detection_enable(struct ipu_soc *ipu, uint32_t csi)
{
uint32_t temp;
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
temp = ipu_csi_read(ipu, csi, CSI_CCIR_CODE_1);
temp |= CSI_CCIR_ERR_DET_EN;
ipu_csi_write(ipu, csi, temp, CSI_CCIR_CODE_1);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
}
/*!
@@ -519,15 +444,10 @@ void _ipu_csi_ccir_err_detection_disable(struct ipu_soc *ipu, uint32_t csi)
{
uint32_t temp;
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
temp = ipu_csi_read(ipu, csi, CSI_CCIR_CODE_1);
temp &= ~CSI_CCIR_ERR_DET_EN;
ipu_csi_write(ipu, csi, temp, CSI_CCIR_CODE_1);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
}
/*!
@@ -544,18 +464,12 @@ int _ipu_csi_set_mipi_di(struct ipu_soc *ipu, uint32_t num, uint32_t di_val, uin
{
uint32_t temp;
int retval = 0;
- unsigned long lock_flags;
if (di_val > 0xFFL) {
retval = -EINVAL;
goto err;
}
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
-
temp = ipu_csi_read(ipu, csi, CSI_MIPI_DI);
switch (num) {
@@ -583,9 +497,6 @@ int _ipu_csi_set_mipi_di(struct ipu_soc *ipu, uint32_t num, uint32_t di_val, uin
retval = -EINVAL;
}
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
err:
return retval;
}
@@ -606,27 +517,18 @@ int _ipu_csi_set_skip_isp(struct ipu_soc *ipu, uint32_t skip, uint32_t max_ratio
{
uint32_t temp;
int retval = 0;
- unsigned long lock_flags;
if (max_ratio > 5) {
retval = -EINVAL;
goto err;
}
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
-
temp = ipu_csi_read(ipu, csi, CSI_SKIP);
temp &= ~(CSI_MAX_RATIO_SKIP_ISP_MASK | CSI_SKIP_ISP_MASK);
temp |= (max_ratio << CSI_MAX_RATIO_SKIP_ISP_SHIFT) |
(skip << CSI_SKIP_ISP_SHIFT);
ipu_csi_write(ipu, csi, temp, CSI_SKIP);
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
err:
return retval;
}
@@ -649,18 +551,12 @@ int _ipu_csi_set_skip_smfc(struct ipu_soc *ipu, uint32_t skip,
{
uint32_t temp;
int retval = 0;
- unsigned long lock_flags;
if (max_ratio > 5 || id > 3) {
retval = -EINVAL;
goto err;
}
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
-
temp = ipu_csi_read(ipu, csi, CSI_SKIP);
temp &= ~(CSI_MAX_RATIO_SKIP_SMFC_MASK | CSI_ID_2_SKIP_MASK |
CSI_SKIP_SMFC_MASK);
@@ -669,10 +565,6 @@ int _ipu_csi_set_skip_smfc(struct ipu_soc *ipu, uint32_t skip,
(skip << CSI_SKIP_SMFC_SHIFT);
ipu_csi_write(ipu, csi, temp, CSI_SKIP);
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
-
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
err:
return retval;
}
@@ -730,12 +622,6 @@ void _ipu_smfc_init(struct ipu_soc *ipu, ipu_channel_t channel, uint32_t mipi_id
void _ipu_smfc_set_wmc(struct ipu_soc *ipu, ipu_channel_t channel, bool set, uint32_t level)
{
uint32_t temp;
- unsigned long lock_flags;
-
- if (!ipu->clk_enabled)
- clk_enable(ipu->ipu_clk);
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
temp = ipu_smfc_read(ipu, SMFC_WMC);
@@ -781,10 +667,6 @@ void _ipu_smfc_set_wmc(struct ipu_soc *ipu, ipu_channel_t channel, bool set, uin
}
ipu_smfc_write(ipu, temp, SMFC_WMC);
-
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
- if (!ipu->clk_enabled)
- clk_disable(ipu->ipu_clk);
}
/*!
@@ -798,9 +680,6 @@ void _ipu_smfc_set_wmc(struct ipu_soc *ipu, ipu_channel_t channel, bool set, uin
void _ipu_smfc_set_burst_size(struct ipu_soc *ipu, ipu_channel_t channel, uint32_t bs)
{
uint32_t temp;
- unsigned long lock_flags;
-
- spin_lock_irqsave(&ipu->ipu_lock, lock_flags);
temp = ipu_smfc_read(ipu, SMFC_BS);
@@ -826,8 +705,6 @@ void _ipu_smfc_set_burst_size(struct ipu_soc *ipu, ipu_channel_t channel, uint32
}
ipu_smfc_write(ipu, temp, SMFC_BS);
-
- spin_unlock_irqrestore(&ipu->ipu_lock, lock_flags);
}
/*!