int gsc_fill_addr(struct gsc_ctx *ctx) { struct gsc_frame *s_frame, *d_frame; struct vb2_buffer *vb = NULL; int ret = 0; s_frame = &ctx->s_frame; d_frame = &ctx->d_frame; vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx); if (vb->num_planes != s_frame->fmt->num_planes) { gsc_err(" vb(%p) planes=%d s_frame(%p) planes=%d\n", vb, vb->num_planes, s_frame, s_frame->fmt->num_planes); return -EINVAL; } ret = gsc_prepare_addr(ctx, vb, s_frame, &s_frame->addr); if (ret) return ret; vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); if (vb->num_planes != d_frame->fmt->num_planes) { gsc_err("vb(%p) planes=%d d_frame(%p) planes=%d\n", vb, vb->num_planes, d_frame, d_frame->fmt->num_planes); return -EINVAL; } ret = gsc_prepare_addr(ctx, vb, d_frame, &d_frame->addr); return ret; }
static int gsc_get_bufs(struct gsc_ctx *ctx) { struct gsc_frame *s_frame, *d_frame; struct vb2_v4l2_buffer *src_vb, *dst_vb; int ret; s_frame = &ctx->s_frame; d_frame = &ctx->d_frame; src_vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx); ret = gsc_prepare_addr(ctx, &src_vb->vb2_buf, s_frame, &s_frame->addr); if (ret) return ret; dst_vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); ret = gsc_prepare_addr(ctx, &dst_vb->vb2_buf, d_frame, &d_frame->addr); if (ret) return ret; dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp; return 0; }
static int gsc_get_bufs(struct gsc_ctx *ctx) { struct gsc_frame *s_frame, *d_frame; struct vb2_buffer *src_vb = NULL; struct vb2_buffer *dst_vb = NULL; int ret = 0; s_frame = &ctx->s_frame; d_frame = &ctx->d_frame; src_vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx); ret = gsc_prepare_addr(ctx, src_vb, s_frame, &s_frame->addr); if (ret) return ret; dst_vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); ret = gsc_prepare_addr(ctx, dst_vb, d_frame, &d_frame->addr); memcpy(&dst_vb->v4l2_buf.timestamp, &src_vb->v4l2_buf.timestamp, sizeof(dst_vb->v4l2_buf.timestamp)); return ret; }
static int gsc_capture_set_addr(struct vb2_buffer *vb) { struct gsc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); struct gsc_dev *gsc = ctx->gsc_dev; int ret; ret = gsc_prepare_addr(ctx, vb, &ctx->d_frame, &ctx->d_frame.addr); if (ret) { gsc_err("Prepare G-Scaler address failed\n"); return -EINVAL; } gsc_hw_set_output_addr(gsc, &ctx->d_frame.addr, vb->v4l2_buf.index); return 0; }
static int gsc_cap_set_addr(struct gsc_dev *gsc,struct gsc_ctx *ctx, struct gsc_input_buf *buf, int index) { int ret; ret = gsc_prepare_addr(ctx, &buf->vb, &ctx->d_frame, &ctx->d_frame.addr); if (ret) { gsc_err("Prepare G-Scaler address failed\n"); return -EINVAL; } if (!ctx->d_frame.addr.y) { gsc_err("source address is null"); return -EINVAL; } buf->addr = ctx->d_frame.addr; list_add_tail(&buf->list, &gsc->cap.active_buf_q); gsc_hw_set_output_addr_fixed(gsc, &ctx->d_frame.addr); buf->idx = index; return 0; }