int sprd_fence_wait(int fence_fd) { int ret = 0; struct sync_fence *fence = NULL; if (fence_fd < 0) { printk(KERN_ERR "sprd_wait_fence input parameters is NULL\n"); return -EFAULT; } fence = sync_fence_fdget(fence_fd); if (fence == NULL) { printk(KERN_ERR "sprd_fence_wait failed fence == NULL\n"); return -EFAULT; } ret = sync_fence_wait(fence, WAIT_FENCE_TIMEOUT); sync_fence_put(fence); if (ret < 0) { printk(KERN_ERR "sync_fence_wait failed, ret = %x\n", ret); } pr_debug("sprd_wait_fence wait fence: %p done\n", (void *)fence); return ret; }
static int buffer_fence_wait(struct mxr_device *mdev, struct mxr_buffer *buffer) { struct sync_fence *fence; int ret = 0; fence = buffer->vb.acquire_fence; if (!fence) return 0; ret = sync_fence_wait(fence, 1000); if (ret == -ETIME) { mxr_warn(mdev, "sync_fence_wait timeout"); ret = sync_fence_wait(fence, -1); } if (ret) mxr_warn(mdev, "sync_fence_wait error"); buffer->vb.acquire_fence = NULL; sync_fence_put(fence); return ret; }
static void gsc_m2m_fence_work(struct work_struct *work) { struct gsc_ctx *ctx = container_of(work, struct gsc_ctx, fence_work); struct v4l2_m2m_buffer *buffer; struct sync_fence *fence; unsigned long flags; int ret; spin_lock_irqsave(&ctx->slock, flags); while (!list_empty(&ctx->fence_wait_list)) { buffer = list_first_entry(&ctx->fence_wait_list, struct v4l2_m2m_buffer, wait); list_del(&buffer->wait); spin_unlock_irqrestore(&ctx->slock, flags); fence = buffer->vb.acquire_fence; if (fence) { buffer->vb.acquire_fence = NULL; ret = sync_fence_wait(fence, 1000); if (ret == -ETIME) { gsc_warn("sync_fence_wait() timeout"); ret = sync_fence_wait(fence, 10 * MSEC_PER_SEC); } if (ret) gsc_warn("sync_fence_wait() error"); sync_fence_put(fence); } if (ctx->m2m_ctx) { v4l2_m2m_buf_queue(ctx->m2m_ctx, &buffer->vb); v4l2_m2m_try_schedule(ctx->m2m_ctx); } spin_lock_irqsave(&ctx->slock, flags); } spin_unlock_irqrestore(&ctx->slock, flags); }
int k3fb_buf_sync_wait(int fence_fd) { int ret = 0; struct sync_fence *fence = NULL; fence = sync_fence_fdget(fence_fd); if (fence == NULL){ K3_FB_ERR("sync_fence_fdget failed!\n"); return -EINVAL; } ret = sync_fence_wait(fence, BUF_SYNC_TIMEOUT_MSEC); if (ret == -ETIME) ret = sync_fence_wait(fence, BUF_SYNC_TIMEOUT_MSEC); if (ret < 0) K3_FB_WARNING("error waiting on fence: 0x%x\n", ret); sync_fence_put(fence); return ret; }
inline int fence_wait(struct sync_fence *fence, int timeout) { return sync_fence_wait(fence, timeout); }
static void gsc_capture_buf_queue(struct vb2_buffer *vb) { struct gsc_input_buf *buf = container_of(vb, struct gsc_input_buf, vb); struct vb2_queue *q = vb->vb2_queue; struct gsc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); struct gsc_dev *gsc = ctx->gsc_dev; int ret; if (vb->acquire_fence) { gsc_dbg("acquire fence has.."); ret = sync_fence_wait(vb->acquire_fence, 100); sync_fence_put(vb->acquire_fence); vb->acquire_fence = NULL; if (ret < 0) { gsc_err("synce_fence_wait() timeout"); return; } } if (!q->streaming) { gsc_info("gsc-wb initialize"); INIT_LIST_HEAD(&gsc->cap.active_buf_q); ret = v4l2_subdev_call(gsc->cap.sd, video, s_stream, 1); if (ret) { gsc_err("gsc s_stream failed"); return; } } ret = gsc_cap_set_addr(gsc, ctx, buf, vb->v4l2_buf.index); if (ret) { gsc_err("Failed to prepare output addr"); return; } if (!test_and_set_bit(ST_CAPT_RUN, &gsc->state)) { ret = gsc_set_scaler_info(ctx); if (ret) { gsc_err("Scaler setup error"); return; } gsc_hw_set_in_size(ctx); gsc_hw_set_out_size(ctx); gsc_hw_set_prescaler(ctx); gsc_hw_set_mainscaler(ctx); gsc_hw_set_h_coef(ctx); gsc_hw_set_v_coef(ctx); gsc_hw_set_output_rotation(ctx); gsc_hw_set_global_alpha(ctx); if (is_rotation) { ret = gsc_check_rotation_size(ctx); if (ret < 0) { gsc_err("Scaler setup error"); return; } } gsc_hw_set_sfr_update(ctx); gsc_hw_enable_control(gsc, true); ret = gsc_wait_operating(gsc); if (ret < 0) { gsc_err("gscaler wait operating timeout"); return; } gsc_dbg("gsc-wb start"); } else { gsc_err(); } }
int sde_sync_wait(void *fence, long timeout_ms) { if (!fence) return -EINVAL; return sync_fence_wait(fence, timeout_ms); }