Merge "msm: camera: Synchronize jpeg ISR and userspace call"
This commit is contained in:
commit
14c4731417
2 changed files with 12 additions and 3 deletions
|
@ -537,6 +537,7 @@ static int msm_jpegdma_open(struct file *file)
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
mutex_init(&ctx->lock);
|
||||||
ctx->jdma_device = device;
|
ctx->jdma_device = device;
|
||||||
dev_dbg(ctx->jdma_device->dev, "Jpeg v4l2 dma open\n");
|
dev_dbg(ctx->jdma_device->dev, "Jpeg v4l2 dma open\n");
|
||||||
/* Set ctx defaults */
|
/* Set ctx defaults */
|
||||||
|
@ -835,12 +836,13 @@ static int msm_jpegdma_qbuf(struct file *file, void *fh,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
msm_jpegdma_cast_long_to_buff_ptr(buf->m.userptr, &up_buff);
|
msm_jpegdma_cast_long_to_buff_ptr(buf->m.userptr, &up_buff);
|
||||||
|
mutex_lock(&ctx->lock);
|
||||||
if (!access_ok(VERIFY_READ, up_buff,
|
if (!access_ok(VERIFY_READ, up_buff,
|
||||||
sizeof(struct msm_jpeg_dma_buff)) ||
|
sizeof(struct msm_jpeg_dma_buff)) ||
|
||||||
get_user(kp_buff.fd, &up_buff->fd) ||
|
get_user(kp_buff.fd, &up_buff->fd) ||
|
||||||
get_user(kp_buff.offset, &up_buff->offset)) {
|
get_user(kp_buff.offset, &up_buff->offset)) {
|
||||||
dev_err(ctx->jdma_device->dev, "Error getting user data\n");
|
dev_err(ctx->jdma_device->dev, "Error getting user data\n");
|
||||||
|
mutex_unlock(&ctx->lock);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,6 +851,7 @@ static int msm_jpegdma_qbuf(struct file *file, void *fh,
|
||||||
put_user(kp_buff.fd, &up_buff->fd) ||
|
put_user(kp_buff.fd, &up_buff->fd) ||
|
||||||
put_user(kp_buff.offset, &up_buff->offset)) {
|
put_user(kp_buff.offset, &up_buff->offset)) {
|
||||||
dev_err(ctx->jdma_device->dev, "Error putting user data\n");
|
dev_err(ctx->jdma_device->dev, "Error putting user data\n");
|
||||||
|
mutex_unlock(&ctx->lock);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,7 +874,7 @@ static int msm_jpegdma_qbuf(struct file *file, void *fh,
|
||||||
ret = v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
|
ret = v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(ctx->jdma_device->dev, "QBuf fail\n");
|
dev_err(ctx->jdma_device->dev, "QBuf fail\n");
|
||||||
|
mutex_unlock(&ctx->lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,10 +1035,11 @@ static int msm_jpegdma_s_crop(struct file *file, void *fh,
|
||||||
if (crop->c.height % formats[ctx->format_idx].v_align)
|
if (crop->c.height % formats[ctx->format_idx].v_align)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
mutex_lock(&ctx->lock);
|
||||||
ctx->crop = crop->c;
|
ctx->crop = crop->c;
|
||||||
if (atomic_read(&ctx->active))
|
if (atomic_read(&ctx->active))
|
||||||
ret = msm_jpegdma_update_hw_config(ctx);
|
ret = msm_jpegdma_update_hw_config(ctx);
|
||||||
|
mutex_unlock(&ctx->lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1240,12 +1244,14 @@ void msm_jpegdma_isr_processing_done(struct msm_jpegdma_device *dma)
|
||||||
|
|
||||||
ctx = v4l2_m2m_get_curr_priv(dma->m2m_dev);
|
ctx = v4l2_m2m_get_curr_priv(dma->m2m_dev);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
|
mutex_lock(&ctx->lock);
|
||||||
ctx->plane_idx++;
|
ctx->plane_idx++;
|
||||||
if (ctx->plane_idx >= formats[ctx->format_idx].num_planes) {
|
if (ctx->plane_idx >= formats[ctx->format_idx].num_planes) {
|
||||||
src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
|
src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
|
||||||
dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
|
dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
|
||||||
if (src_buf == NULL || dst_buf == NULL) {
|
if (src_buf == NULL || dst_buf == NULL) {
|
||||||
dev_err(ctx->jdma_device->dev, "Error, buffer list empty\n");
|
dev_err(ctx->jdma_device->dev, "Error, buffer list empty\n");
|
||||||
|
mutex_unlock(&ctx->lock);
|
||||||
mutex_unlock(&dma->lock);
|
mutex_unlock(&dma->lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1261,11 +1267,13 @@ void msm_jpegdma_isr_processing_done(struct msm_jpegdma_device *dma)
|
||||||
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
|
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
|
||||||
if (src_buf == NULL || dst_buf == NULL) {
|
if (src_buf == NULL || dst_buf == NULL) {
|
||||||
dev_err(ctx->jdma_device->dev, "Error, buffer list empty\n");
|
dev_err(ctx->jdma_device->dev, "Error, buffer list empty\n");
|
||||||
|
mutex_unlock(&ctx->lock);
|
||||||
mutex_unlock(&dma->lock);
|
mutex_unlock(&dma->lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
msm_jpegdma_process_buffers(ctx, src_buf, dst_buf);
|
msm_jpegdma_process_buffers(ctx, src_buf, dst_buf);
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&ctx->lock);
|
||||||
}
|
}
|
||||||
mutex_unlock(&dma->lock);
|
mutex_unlock(&dma->lock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,6 +254,7 @@ struct msm_jpegdma_buf_handle {
|
||||||
* @format_idx: Current format index.
|
* @format_idx: Current format index.
|
||||||
*/
|
*/
|
||||||
struct jpegdma_ctx {
|
struct jpegdma_ctx {
|
||||||
|
struct mutex lock;
|
||||||
struct msm_jpegdma_device *jdma_device;
|
struct msm_jpegdma_device *jdma_device;
|
||||||
atomic_t active;
|
atomic_t active;
|
||||||
struct completion completion;
|
struct completion completion;
|
||||||
|
|
Loading…
Add table
Reference in a new issue