int msm_jpeg_hw_exec_cmds(struct msm_jpeg_hw_cmd *hw_cmd_p, uint32_t m_cmds, uint32_t max_size, void *base) { int is_copy_to_user = 0; uint32_t data; while (m_cmds--) { if (hw_cmd_p->offset >= max_size) { JPEG_PR_ERR("%s:%d] %d exceed hw region %d\n", __func__, __LINE__, hw_cmd_p->offset, max_size); return -EFAULT; } if (hw_cmd_p->offset & 0x3) { JPEG_PR_ERR("%s:%d] %d Invalid alignment\n", __func__, __LINE__, hw_cmd_p->offset); return -EFAULT; } switch (hw_cmd_p->type) { case MSM_JPEG_HW_CMD_TYPE_READ: hw_cmd_p->data = msm_jpeg_hw_read(hw_cmd_p, base); is_copy_to_user = 1; break; case MSM_JPEG_HW_CMD_TYPE_WRITE: msm_jpeg_hw_write(hw_cmd_p, base); break; case MSM_JPEG_HW_CMD_TYPE_WRITE_OR: data = msm_jpeg_hw_read(hw_cmd_p, base); hw_cmd_p->data = (hw_cmd_p->data & hw_cmd_p->mask) | data; msm_jpeg_hw_write(hw_cmd_p, base); break; case MSM_JPEG_HW_CMD_TYPE_UWAIT: msm_jpeg_hw_wait(hw_cmd_p, 1, base); break; case MSM_JPEG_HW_CMD_TYPE_MWAIT: msm_jpeg_hw_wait(hw_cmd_p, 1000, base); break; case MSM_JPEG_HW_CMD_TYPE_UDELAY: msm_jpeg_hw_delay(hw_cmd_p, 1); break; case MSM_JPEG_HW_CMD_TYPE_MDELAY: msm_jpeg_hw_delay(hw_cmd_p, 1000); break; default: JPEG_PR_ERR("wrong hw command type\n"); break; } hw_cmd_p++; } return is_copy_to_user; }
int msm_jpeg_hw_irq_get_status(void) { uint32_t n_irq_status = 0; rmb(); n_irq_status = msm_jpeg_hw_read(&hw_cmd_irq_get_status[0]); rmb(); return n_irq_status; }
long msm_jpeg_hw_encode_output_size(void) { uint32_t encode_output_size = 0; encode_output_size = msm_jpeg_hw_read(&hw_cmd_encode_output_size[0]); return encode_output_size; }
int msm_jpeg_hw_wait(struct msm_jpeg_hw_cmd *hw_cmd_p, int m_us) { int tm = hw_cmd_p->n; uint32_t data; uint32_t wait_data = hw_cmd_p->data & hw_cmd_p->mask; data = msm_jpeg_hw_read(hw_cmd_p); if (data != wait_data) { while (tm) { udelay(m_us); data = msm_jpeg_hw_read(hw_cmd_p); if (data == wait_data) break; tm--; } } hw_cmd_p->data = data; return tm; }
int msm_jpeg_hw_irq_get_status(void *base) { uint32_t n_irq_status = 0; n_irq_status = msm_jpeg_hw_read(&hw_cmd_irq_get_status[0], base); return n_irq_status; }