}
EXPORT_SYMBOL_GPL(ipu_get_soc);
-void _ipu_lock(struct ipu_soc *ipu)
-{
- /*TODO:remove in_irq() condition after v4l2 driver rewrite*/
- if (!in_irq() && !in_softirq())
- mutex_lock(&ipu->mutex_lock);
-}
-
-void _ipu_unlock(struct ipu_soc *ipu)
-{
- /*TODO:remove in_irq() condition after v4l2 driver rewrite*/
- if (!in_irq() && !in_softirq())
- mutex_unlock(&ipu->mutex_lock);
-}
-
void _ipu_get(struct ipu_soc *ipu)
{
int ret;
ipu = &ipu_array[pdev->id];
memset(ipu, 0, sizeof(struct ipu_soc));
- spin_lock_init(&ipu->spin_lock);
+ spin_lock_init(&ipu->int_reg_spin_lock);
+ spin_lock_init(&ipu->rdy_reg_spin_lock);
mutex_init(&ipu->mutex_lock);
g_ipu_hw_rev = plat_data->rev;
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
/* Re-enable error interrupts every time a channel is initialized */
ipu_cm_write(ipu, 0xFFFFFFFF, IPU_INT_CTRL(5));
ipu_cm_write(ipu, ipu_conf, IPU_CONF);
err:
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return ret;
}
EXPORT_SYMBOL(ipu_init_channel);
uint32_t ipu_conf;
uint32_t dc_chan = 0;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
if ((ipu->channel_init_mask & (1L << IPU_CHAN_ID(channel))) == 0) {
dev_dbg(ipu->dev, "Channel already uninitialized %d\n",
IPU_CHAN_ID(channel));
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return;
}
dev_err(ipu->dev,
"Channel %d is not disabled, disable first\n",
IPU_CHAN_ID(channel));
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return;
}
if (_ipu_is_primary_disp_chan(in_dma))
clk_disable(&ipu->pixel_clk[ipu->dc_di_assignment[dc_chan]]);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
return -EINVAL;
}
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
/* Build parameter memory data for DMA channel */
_ipu_ch_param_init(ipu, dma_chan, pixel_fmt, width, height, stride, u, v, 0,
}
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return 0;
}
uint32_t reg;
int ret = 0;
uint32_t dma_chan = channel_2_dma(channel, type);
+ unsigned long lock_flags;
if (dma_chan == IDMA_CHAN_INVALID)
return -EINVAL;
- _ipu_lock(ipu);
-
+ spin_lock_irqsave(&ipu->rdy_reg_spin_lock, lock_flags);
if (bufNum == 0)
reg = ipu_cm_read(ipu, IPU_CHA_BUF0_RDY(dma_chan));
else if (bufNum == 1)
_ipu_ch_param_set_buffer(ipu, dma_chan, bufNum, phyaddr);
else
ret = -EACCES;
-
- _ipu_unlock(ipu);
+ spin_unlock_irqrestore(&ipu->rdy_reg_spin_lock, lock_flags);
return ret;
}
if ((2 > band_height) || (8 < band_height))
return -EINVAL;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
reg = ipu_idmac_read(ipu, IDMAC_BAND_EN(dma_chan));
reg |= 1 << (dma_chan % 32);
_ipu_ch_param_set_bandmode(ipu, dma_chan, band_height);
dev_dbg(ipu->dev, "dma_chan:%d, band_height:%d.\n\n",
dma_chan, 1 << band_height);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return ret;
}
{
int ret = 0;
uint32_t dma_chan = channel_2_dma(channel, type);
+ unsigned long lock_flags;
if (dma_chan == IDMA_CHAN_INVALID)
return -EINVAL;
- _ipu_lock(ipu);
-
+ spin_lock_irqsave(&ipu->rdy_reg_spin_lock, lock_flags);
if ((ipu_cm_read(ipu, IPU_CHA_BUF0_RDY(dma_chan)) & idma_mask(dma_chan)) ||
(ipu_cm_read(ipu, IPU_CHA_BUF1_RDY(dma_chan)) & idma_mask(dma_chan)) ||
((ipu_cm_read(ipu, IPU_CHA_BUF2_RDY(dma_chan)) & idma_mask(dma_chan)) &&
else
_ipu_ch_offset_update(ipu, dma_chan, pixel_fmt, width, height, stride,
u, v, 0, vertical_offset, horizontal_offset);
+ spin_unlock_irqrestore(&ipu->rdy_reg_spin_lock, lock_flags);
- _ipu_unlock(ipu);
return ret;
}
EXPORT_SYMBOL(ipu_update_channel_offset);
ipu_buffer_t type, uint32_t bufNum)
{
uint32_t dma_chan = channel_2_dma(channel, type);
+ unsigned long lock_flags;
if (dma_chan == IDMA_CHAN_INVALID)
return -EINVAL;
+ spin_lock_irqsave(&ipu->rdy_reg_spin_lock, lock_flags);
/* Mark buffer to be ready. */
- _ipu_lock(ipu);
if (bufNum == 0)
ipu_cm_write(ipu, idma_mask(dma_chan),
IPU_CHA_BUF0_RDY(dma_chan));
else
ipu_cm_write(ipu, idma_mask(dma_chan),
IPU_CHA_BUF2_RDY(dma_chan));
- _ipu_unlock(ipu);
+ spin_unlock_irqrestore(&ipu->rdy_reg_spin_lock, lock_flags);
+
return 0;
}
EXPORT_SYMBOL(ipu_select_buffer);
idma_mask(channel_2_dma(MEM_VDI_PRP_VF_MEM_P, IPU_INPUT_BUFFER))|
idma_mask(dma_chan)|
idma_mask(channel_2_dma(MEM_VDI_PRP_VF_MEM_N, IPU_INPUT_BUFFER));
+ unsigned long lock_flags;
+ spin_lock_irqsave(&ipu->rdy_reg_spin_lock, lock_flags);
/* Mark buffers to be ready. */
- _ipu_lock(ipu);
if (bufNum == 0)
ipu_cm_write(ipu, mask_bit, IPU_CHA_BUF0_RDY(dma_chan));
else
ipu_cm_write(ipu, mask_bit, IPU_CHA_BUF1_RDY(dma_chan));
- _ipu_unlock(ipu);
+ spin_unlock_irqrestore(&ipu->rdy_reg_spin_lock, lock_flags);
+
return 0;
}
EXPORT_SYMBOL(ipu_select_multi_vdi_buffer);
uint32_t fs_proc_flow3;
uint32_t fs_disp_flow1;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
fs_proc_flow1 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
fs_proc_flow2 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW2);
ipu_cm_write(ipu, fs_disp_flow1, IPU_FS_DISP_FLOW1);
err:
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return retval;
}
EXPORT_SYMBOL(ipu_link_channels);
uint32_t fs_proc_flow3;
uint32_t fs_disp_flow1;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
fs_proc_flow1 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW1);
fs_proc_flow2 = ipu_cm_read(ipu, IPU_FS_PROC_FLOW2);
ipu_cm_write(ipu, fs_disp_flow1, IPU_FS_DISP_FLOW1);
err:
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return retval;
}
EXPORT_SYMBOL(ipu_unlink_channels);
uint32_t sec_dma;
uint32_t thrd_dma;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
if (ipu->channel_enable_mask & (1L << IPU_CHAN_ID(channel))) {
dev_err(ipu->dev, "Warning: channel already enabled %d\n",
IPU_CHAN_ID(channel));
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return -EACCES;
}
ipu->channel_enable_mask |= 1L << IPU_CHAN_ID(channel);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return 0;
}
{
uint32_t dma_chan = channel_2_dma(channel, type);
uint32_t reg;
+ unsigned long lock_flags;
if (dma_chan == IDMA_CHAN_INVALID)
return -EINVAL;
+ spin_lock_irqsave(&ipu->rdy_reg_spin_lock, lock_flags);
if (bufNum == 0)
reg = ipu_cm_read(ipu, IPU_CHA_BUF0_RDY(dma_chan));
else if (bufNum == 1)
reg = ipu_cm_read(ipu, IPU_CHA_BUF1_RDY(dma_chan));
else
reg = ipu_cm_read(ipu, IPU_CHA_BUF2_RDY(dma_chan));
+ spin_unlock_irqrestore(&ipu->rdy_reg_spin_lock, lock_flags);
if (reg & idma_mask(dma_chan))
return 1;
void ipu_clear_buffer_ready(struct ipu_soc *ipu, ipu_channel_t channel, ipu_buffer_t type,
uint32_t bufNum)
{
- _ipu_lock(ipu);
+ unsigned long lock_flags;
+
+ spin_lock_irqsave(&ipu->rdy_reg_spin_lock, lock_flags);
_ipu_clear_buffer_ready(ipu, channel, type, bufNum);
- _ipu_unlock(ipu);
+ spin_unlock_irqrestore(&ipu->rdy_reg_spin_lock, lock_flags);
}
EXPORT_SYMBOL(ipu_clear_buffer_ready);
uint32_t sec_dma = NO_DMA;
uint32_t thrd_dma = NO_DMA;
uint16_t fg_pos_x, fg_pos_y;
+ unsigned long lock_flags;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
if ((ipu->channel_enable_mask & (1L << IPU_CHAN_ID(channel))) == 0) {
dev_dbg(ipu->dev, "Channel already disabled %d\n",
IPU_CHAN_ID(channel));
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return -EACCES;
}
!idma_is_set(ipu, IDMAC_CHA_EN, in_dma))
&& (idma_is_valid(out_dma) &&
!idma_is_set(ipu, IDMAC_CHA_EN, out_dma))) {
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return -EINVAL;
}
if (channel == MEM_FG_SYNC)
_ipu_disp_set_window_pos(ipu, channel, fg_pos_x, fg_pos_y);
+ spin_lock_irqsave(&ipu->rdy_reg_spin_lock, lock_flags);
/* Set channel buffers NOT to be ready */
if (idma_is_valid(in_dma)) {
_ipu_clear_buffer_ready(ipu, channel, IPU_VIDEO_IN_BUFFER, 0);
_ipu_clear_buffer_ready(ipu, channel, IPU_ALPHA_IN_BUFFER, 0);
_ipu_clear_buffer_ready(ipu, channel, IPU_ALPHA_IN_BUFFER, 1);
}
+ spin_unlock_irqrestore(&ipu->rdy_reg_spin_lock, lock_flags);
ipu->channel_enable_mask &= ~(1L << IPU_CHAN_ID(channel));
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return 0;
}
}
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
ipu->csi_use_count[csi]++;
if (ipu->csi_use_count[csi] == 1) {
else
ipu_cm_write(ipu, reg | IPU_CONF_CSI1_EN, IPU_CONF);
}
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
return 0;
}
return -EINVAL;
}
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
ipu->csi_use_count[csi]--;
if (ipu->csi_use_count[csi] == 0) {
reg = ipu_cm_read(ipu, IPU_CONF);
else
ipu_cm_write(ipu, reg & ~IPU_CONF_CSI1_EN, IPU_CONF);
}
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
return 0;
}
const int err_reg[] = { 5, 6, 9, 10, 0 };
const int int_reg[] = { 1, 2, 3, 4, 11, 12, 13, 14, 15, 0 };
- spin_lock(&ipu->spin_lock);
+ spin_lock(&ipu->int_reg_spin_lock);
for (i = 0;; i++) {
if (err_reg[i] == 0)
}
}
- spin_unlock(&ipu->spin_lock);
+ spin_unlock(&ipu->int_reg_spin_lock);
return result;
}
_ipu_get(ipu);
- spin_lock_irqsave(&ipu->spin_lock, lock_flags);
+ spin_lock_irqsave(&ipu->int_reg_spin_lock, lock_flags);
reg = ipu_cm_read(ipu, IPUIRQ_2_CTRLREG(irq));
reg |= IPUIRQ_2_MASK(irq);
ipu_cm_write(ipu, reg, IPUIRQ_2_CTRLREG(irq));
- spin_unlock_irqrestore(&ipu->spin_lock, lock_flags);
+ spin_unlock_irqrestore(&ipu->int_reg_spin_lock, lock_flags);
_ipu_put(ipu);
}
_ipu_get(ipu);
- spin_lock_irqsave(&ipu->spin_lock, lock_flags);
+ spin_lock_irqsave(&ipu->int_reg_spin_lock, lock_flags);
reg = ipu_cm_read(ipu, IPUIRQ_2_CTRLREG(irq));
reg &= ~IPUIRQ_2_MASK(irq);
ipu_cm_write(ipu, reg, IPUIRQ_2_CTRLREG(irq));
- spin_unlock_irqrestore(&ipu->spin_lock, lock_flags);
+ spin_unlock_irqrestore(&ipu->int_reg_spin_lock, lock_flags);
_ipu_put(ipu);
}
_ipu_get(ipu);
- spin_lock_irqsave(&ipu->spin_lock, lock_flags);
+ spin_lock_irqsave(&ipu->int_reg_spin_lock, lock_flags);
ipu_cm_write(ipu, IPUIRQ_2_MASK(irq), IPUIRQ_2_STATREG(irq));
- spin_unlock_irqrestore(&ipu->spin_lock, lock_flags);
+ spin_unlock_irqrestore(&ipu->int_reg_spin_lock, lock_flags);
_ipu_put(ipu);
}
_ipu_get(ipu);
- spin_lock_irqsave(&ipu->spin_lock, lock_flags);
+ spin_lock_irqsave(&ipu->int_reg_spin_lock, lock_flags);
reg = ipu_cm_read(ipu, IPUIRQ_2_STATREG(irq));
- spin_unlock_irqrestore(&ipu->spin_lock, lock_flags);
+ spin_unlock_irqrestore(&ipu->int_reg_spin_lock, lock_flags);
_ipu_put(ipu);
_ipu_get(ipu);
- spin_lock_irqsave(&ipu->spin_lock, lock_flags);
+ spin_lock_irqsave(&ipu->int_reg_spin_lock, lock_flags);
if (ipu->irq_list[irq].handler != NULL) {
dev_err(ipu->dev,
"handler already installed on irq %d\n", irq);
- spin_unlock_irqrestore(&ipu->spin_lock, lock_flags);
+ spin_unlock_irqrestore(&ipu->int_reg_spin_lock, lock_flags);
return -EINVAL;
}
reg |= IPUIRQ_2_MASK(irq);
ipu_cm_write(ipu, reg, IPUIRQ_2_CTRLREG(irq));
- spin_unlock_irqrestore(&ipu->spin_lock, lock_flags);
+ spin_unlock_irqrestore(&ipu->int_reg_spin_lock, lock_flags);
_ipu_put(ipu);
_ipu_get(ipu);
- spin_lock_irqsave(&ipu->spin_lock, lock_flags);
+ spin_lock_irqsave(&ipu->int_reg_spin_lock, lock_flags);
/* disable the interrupt */
reg = ipu_cm_read(ipu, IPUIRQ_2_CTRLREG(irq));
if (ipu->irq_list[irq].dev_id == dev_id)
memset(&ipu->irq_list[irq], 0, sizeof(ipu->irq_list[irq]));
- spin_unlock_irqrestore(&ipu->spin_lock, lock_flags);
+ spin_unlock_irqrestore(&ipu->int_reg_spin_lock, lock_flags);
_ipu_put(ipu);
}
uint32_t dma_status;
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
dma_status = ipu_is_channel_busy(ipu, channel);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
dev_dbg(ipu->dev, "%s, dma_status:%d.\n", __func__, dma_status);
int32_t ipu_swap_channel(struct ipu_soc *ipu, ipu_channel_t from_ch, ipu_channel_t to_ch)
{
uint32_t reg;
-
+ unsigned long lock_flags;
int from_dma = channel_2_dma(from_ch, IPU_INPUT_BUFFER);
int to_dma = channel_2_dma(to_ch, IPU_INPUT_BUFFER);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
/* enable target channel */
reg = ipu_idmac_read(ipu, IDMAC_CHA_EN(to_dma));
ipu->channel_enable_mask &= ~(1L << IPU_CHAN_ID(from_ch));
+ spin_lock_irqsave(&ipu->rdy_reg_spin_lock, lock_flags);
_ipu_clear_buffer_ready(ipu, from_ch, IPU_VIDEO_IN_BUFFER, 0);
_ipu_clear_buffer_ready(ipu, from_ch, IPU_VIDEO_IN_BUFFER, 1);
_ipu_clear_buffer_ready(ipu, from_ch, IPU_VIDEO_IN_BUFFER, 2);
+ spin_unlock_irqrestore(&ipu->rdy_reg_spin_lock, lock_flags);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return 0;
}
/* Get integer portion of divider */
div = clk_get_rate(clk_get_parent(&ipu->pixel_clk[disp])) / rounded_pixel_clk;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
_ipu_di_data_wave_config(ipu, disp, SYNC_WAVE, div - 1, div - 1);
_ipu_di_data_pin_config(ipu, disp, SYNC_WAVE, DI_PIN15, 3, 0, div * 2);
map = _ipu_pixfmt_to_map(pixel_fmt);
if (map < 0) {
dev_dbg(ipu->dev, "IPU_DISP: No MAP\n");
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return -EINVAL;
}
ipu_dc_write(ipu, width, DC_DISP_CONF2(DC_DISP_ID_SYNC(disp)));
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return 0;
}
if ((disp != 0) || (disp != 1))
return;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
di_gen = ipu_di_read(ipu, disp, DI_GENERAL);
di_gen |= 0x3ff | DI_GEN_POLARITY_DISP_CLK;
reg |= 0x3ffffff;
ipu_di_write(ipu, disp, reg, DI_POL);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
}
EXPORT_SYMBOL(ipu_uninit_sync_panel);
if (map < 0)
return -EINVAL;
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
if (type == IPU_PANEL_SERIAL) {
ipu_di_write(ipu, disp, (div << 24) | ((sig.ifc_width - 1) << 4),
ipu_di_write(ipu, disp, ser_conf, DI_SER_CONF);
}
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
return 0;
}
EXPORT_SYMBOL(ipu_init_async_panel);
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
if (bg_chan) {
reg = ipu_dp_read(ipu, DP_COM_CONF(flow));
reg = ipu_cm_read(ipu, IPU_SRM_PRI2) | 0x8;
ipu_cm_write(ipu, reg, IPU_SRM_PRI2);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
ipu->color_key_4rgb = true;
/* Transform color key from rgb to yuv if CSC is enabled */
reg = ipu_cm_read(ipu, IPU_SRM_PRI2) | 0x8;
ipu_cm_write(ipu, reg, IPU_SRM_PRI2);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
for (i = 0; i < 8; i++)
ipu_dp_write(ipu, (constk[2*i] & 0x1ff) | ((constk[2*i+1] & 0x1ff) << 16), DP_GAMMA_C(flow, i));
reg = ipu_cm_read(ipu, IPU_SRM_PRI2) | 0x8;
ipu_cm_write(ipu, reg, IPU_SRM_PRI2);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
int ret;
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
ret = _ipu_disp_set_window_pos(ipu, channel, x_pos, y_pos);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
return ret;
}
int ret;
_ipu_get(ipu);
- _ipu_lock(ipu);
+ mutex_lock(&ipu->mutex_lock);
ret = _ipu_disp_get_window_pos(ipu, channel, x_pos, y_pos);
- _ipu_unlock(ipu);
+ mutex_unlock(&ipu->mutex_lock);
_ipu_put(ipu);
return ret;
}