Lines Matching refs:ctx
409 static struct vpe_q_data *get_q_data(struct vpe_ctx *ctx, in get_q_data() argument
415 return &ctx->q_data[Q_DATA_SRC]; in get_q_data()
418 return &ctx->q_data[Q_DATA_DST]; in get_q_data()
494 #define GET_OFFSET_TOP(ctx, obj, reg) \ argument
495 ((obj)->res->start - ctx->dev->res->start + reg)
497 #define VPE_SET_MMR_ADB_HDR(ctx, hdr, regs, offset_a) \ argument
498 VPDMA_SET_MMR_ADB_HDR(ctx->mmr_adb, vpe_mmr_adb, hdr, regs, offset_a)
502 static void init_adb_hdrs(struct vpe_ctx *ctx) in init_adb_hdrs() argument
504 VPE_SET_MMR_ADB_HDR(ctx, out_fmt_hdr, out_fmt_reg, VPE_CLK_FORMAT_SELECT); in init_adb_hdrs()
505 VPE_SET_MMR_ADB_HDR(ctx, us1_hdr, us1_regs, VPE_US1_R0); in init_adb_hdrs()
506 VPE_SET_MMR_ADB_HDR(ctx, us2_hdr, us2_regs, VPE_US2_R0); in init_adb_hdrs()
507 VPE_SET_MMR_ADB_HDR(ctx, us3_hdr, us3_regs, VPE_US3_R0); in init_adb_hdrs()
508 VPE_SET_MMR_ADB_HDR(ctx, dei_hdr, dei_regs, VPE_DEI_FRAME_SIZE); in init_adb_hdrs()
509 VPE_SET_MMR_ADB_HDR(ctx, sc_hdr0, sc_regs0, in init_adb_hdrs()
510 GET_OFFSET_TOP(ctx, ctx->dev->sc, CFG_SC0)); in init_adb_hdrs()
511 VPE_SET_MMR_ADB_HDR(ctx, sc_hdr8, sc_regs8, in init_adb_hdrs()
512 GET_OFFSET_TOP(ctx, ctx->dev->sc, CFG_SC8)); in init_adb_hdrs()
513 VPE_SET_MMR_ADB_HDR(ctx, sc_hdr17, sc_regs17, in init_adb_hdrs()
514 GET_OFFSET_TOP(ctx, ctx->dev->sc, CFG_SC17)); in init_adb_hdrs()
515 VPE_SET_MMR_ADB_HDR(ctx, csc_hdr, csc_regs, in init_adb_hdrs()
516 GET_OFFSET_TOP(ctx, ctx->dev->csc, CSC_CSC00)); in init_adb_hdrs()
526 static int realloc_mv_buffers(struct vpe_ctx *ctx, size_t size) in realloc_mv_buffers() argument
528 struct device *dev = ctx->dev->v4l2_dev.dev; in realloc_mv_buffers()
530 if (ctx->mv_buf_size == size) in realloc_mv_buffers()
533 if (ctx->mv_buf[0]) in realloc_mv_buffers()
534 dma_free_coherent(dev, ctx->mv_buf_size, ctx->mv_buf[0], in realloc_mv_buffers()
535 ctx->mv_buf_dma[0]); in realloc_mv_buffers()
537 if (ctx->mv_buf[1]) in realloc_mv_buffers()
538 dma_free_coherent(dev, ctx->mv_buf_size, ctx->mv_buf[1], in realloc_mv_buffers()
539 ctx->mv_buf_dma[1]); in realloc_mv_buffers()
544 ctx->mv_buf[0] = dma_alloc_coherent(dev, size, &ctx->mv_buf_dma[0], in realloc_mv_buffers()
546 if (!ctx->mv_buf[0]) { in realloc_mv_buffers()
547 vpe_err(ctx->dev, "failed to allocate motion vector buffer\n"); in realloc_mv_buffers()
551 ctx->mv_buf[1] = dma_alloc_coherent(dev, size, &ctx->mv_buf_dma[1], in realloc_mv_buffers()
553 if (!ctx->mv_buf[1]) { in realloc_mv_buffers()
554 vpe_err(ctx->dev, "failed to allocate motion vector buffer\n"); in realloc_mv_buffers()
555 dma_free_coherent(dev, size, ctx->mv_buf[0], in realloc_mv_buffers()
556 ctx->mv_buf_dma[0]); in realloc_mv_buffers()
561 ctx->mv_buf_size = size; in realloc_mv_buffers()
562 ctx->src_mv_buf_selector = 0; in realloc_mv_buffers()
567 static void free_mv_buffers(struct vpe_ctx *ctx) in free_mv_buffers() argument
569 realloc_mv_buffers(ctx, 0); in free_mv_buffers()
577 static void free_vbs(struct vpe_ctx *ctx) in free_vbs() argument
579 struct vpe_dev *dev = ctx->dev; in free_vbs()
582 if (ctx->src_vbs[2] == NULL) in free_vbs()
586 if (ctx->src_vbs[2]) { in free_vbs()
587 v4l2_m2m_buf_done(ctx->src_vbs[2], VB2_BUF_STATE_DONE); in free_vbs()
588 v4l2_m2m_buf_done(ctx->src_vbs[1], VB2_BUF_STATE_DONE); in free_vbs()
631 static void set_us_coefficients(struct vpe_ctx *ctx) in set_us_coefficients() argument
633 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr; in set_us_coefficients()
634 struct vpe_q_data *s_q_data = &ctx->q_data[Q_DATA_SRC]; in set_us_coefficients()
653 ctx->load_mmrs = true; in set_us_coefficients()
659 static void set_cfg_and_line_modes(struct vpe_ctx *ctx) in set_cfg_and_line_modes() argument
661 struct vpe_fmt *fmt = ctx->q_data[Q_DATA_SRC].fmt; in set_cfg_and_line_modes()
662 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr; in set_cfg_and_line_modes()
684 vpdma_set_line_mode(ctx->dev->vpdma, line_mode, VPE_CHAN_CHROMA1_IN); in set_cfg_and_line_modes()
685 vpdma_set_line_mode(ctx->dev->vpdma, line_mode, VPE_CHAN_CHROMA2_IN); in set_cfg_and_line_modes()
686 vpdma_set_line_mode(ctx->dev->vpdma, line_mode, VPE_CHAN_CHROMA3_IN); in set_cfg_and_line_modes()
689 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE, in set_cfg_and_line_modes()
691 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE, in set_cfg_and_line_modes()
693 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE, in set_cfg_and_line_modes()
697 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE, in set_cfg_and_line_modes()
699 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE, in set_cfg_and_line_modes()
701 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE, in set_cfg_and_line_modes()
705 vpdma_set_frame_start_event(ctx->dev->vpdma, VPDMA_FSEVENT_CHANNEL_ACTIVE, in set_cfg_and_line_modes()
708 ctx->load_mmrs = true; in set_cfg_and_line_modes()
715 static void set_src_registers(struct vpe_ctx *ctx) in set_src_registers() argument
717 set_us_coefficients(ctx); in set_src_registers()
724 static void set_dst_registers(struct vpe_ctx *ctx) in set_dst_registers() argument
726 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr; in set_dst_registers()
727 enum v4l2_colorspace clrspc = ctx->q_data[Q_DATA_DST].colorspace; in set_dst_registers()
728 struct vpe_fmt *fmt = ctx->q_data[Q_DATA_DST].fmt; in set_dst_registers()
747 ctx->load_mmrs = true; in set_dst_registers()
753 static void set_dei_regs(struct vpe_ctx *ctx) in set_dei_regs() argument
755 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr; in set_dei_regs()
756 struct vpe_q_data *s_q_data = &ctx->q_data[Q_DATA_SRC]; in set_dei_regs()
769 if ((!ctx->deinterlacing && (s_q_data->flags & Q_DATA_INTERLACED)) || in set_dei_regs()
783 ctx->load_mmrs = true; in set_dei_regs()
786 static void set_dei_shadow_registers(struct vpe_ctx *ctx) in set_dei_shadow_registers() argument
788 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr; in set_dei_shadow_registers()
799 ctx->load_mmrs = true; in set_dei_shadow_registers()
806 static int set_srcdst_params(struct vpe_ctx *ctx) in set_srcdst_params() argument
808 struct vpe_q_data *s_q_data = &ctx->q_data[Q_DATA_SRC]; in set_srcdst_params()
809 struct vpe_q_data *d_q_data = &ctx->q_data[Q_DATA_DST]; in set_srcdst_params()
810 struct vpe_mmr_adb *mmr_adb = ctx->mmr_adb.addr; in set_srcdst_params()
818 ctx->sequence = 0; in set_srcdst_params()
819 ctx->field = V4L2_FIELD_TOP; in set_srcdst_params()
838 ctx->deinterlacing = true; in set_srcdst_params()
841 ctx->deinterlacing = false; in set_srcdst_params()
845 free_vbs(ctx); in set_srcdst_params()
847 ret = realloc_mv_buffers(ctx, mv_buf_size); in set_srcdst_params()
851 set_cfg_and_line_modes(ctx); in set_srcdst_params()
852 set_dei_regs(ctx); in set_srcdst_params()
854 csc_set_coeff(ctx->dev->csc, &mmr_adb->csc_regs[0], in set_srcdst_params()
857 sc_set_hs_coeffs(ctx->dev->sc, ctx->sc_coeff_h.addr, src_w, dst_w); in set_srcdst_params()
858 sc_set_vs_coeffs(ctx->dev->sc, ctx->sc_coeff_v.addr, src_h, dst_h); in set_srcdst_params()
860 sc_config_scaler(ctx->dev->sc, &mmr_adb->sc_regs0[0], in set_srcdst_params()
884 struct vpe_ctx *ctx = priv; in job_ready() local
885 int needed = ctx->bufs_per_job; in job_ready()
887 if (ctx->deinterlacing && ctx->src_vbs[2] == NULL) in job_ready()
890 if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < needed) in job_ready()
893 if (v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < needed) in job_ready()
901 struct vpe_ctx *ctx = priv; in job_abort() local
904 ctx->aborting = 1; in job_abort()
912 struct vpe_ctx *ctx = priv; in vpe_lock() local
913 struct vpe_dev *dev = ctx->dev; in vpe_lock()
919 struct vpe_ctx *ctx = priv; in vpe_unlock() local
920 struct vpe_dev *dev = ctx->dev; in vpe_unlock()
987 static void add_out_dtd(struct vpe_ctx *ctx, int port) in add_out_dtd() argument
989 struct vpe_q_data *q_data = &ctx->q_data[Q_DATA_DST]; in add_out_dtd()
991 struct vb2_buffer *vb = ctx->dst_vb; in add_out_dtd()
994 int mv_buf_selector = !ctx->src_mv_buf_selector; in add_out_dtd()
1000 dma_addr = ctx->mv_buf_dma[mv_buf_selector]; in add_out_dtd()
1008 vpe_err(ctx->dev, in add_out_dtd()
1020 vpdma_add_out_dtd(&ctx->desc_list, q_data->width, &q_data->c_rect, in add_out_dtd()
1024 static void add_in_dtd(struct vpe_ctx *ctx, int port) in add_in_dtd() argument
1026 struct vpe_q_data *q_data = &ctx->q_data[Q_DATA_SRC]; in add_in_dtd()
1028 struct vb2_buffer *vb = ctx->src_vbs[p_data->vb_index]; in add_in_dtd()
1031 int mv_buf_selector = ctx->src_mv_buf_selector; in add_in_dtd()
1039 dma_addr = ctx->mv_buf_dma[mv_buf_selector]; in add_in_dtd()
1048 vpe_err(ctx->dev, in add_in_dtd()
1066 vpdma_add_in_dtd(&ctx->desc_list, q_data->width, &q_data->c_rect, in add_in_dtd()
1074 static void enable_irqs(struct vpe_ctx *ctx) in enable_irqs() argument
1076 write_reg(ctx->dev, VPE_INT0_ENABLE0_SET, VPE_INT0_LIST0_COMPLETE); in enable_irqs()
1077 write_reg(ctx->dev, VPE_INT0_ENABLE1_SET, VPE_DEI_ERROR_INT | in enable_irqs()
1080 vpdma_enable_list_complete_irq(ctx->dev->vpdma, 0, true); in enable_irqs()
1083 static void disable_irqs(struct vpe_ctx *ctx) in disable_irqs() argument
1085 write_reg(ctx->dev, VPE_INT0_ENABLE0_CLR, 0xffffffff); in disable_irqs()
1086 write_reg(ctx->dev, VPE_INT0_ENABLE1_CLR, 0xffffffff); in disable_irqs()
1088 vpdma_enable_list_complete_irq(ctx->dev->vpdma, 0, false); in disable_irqs()
1098 struct vpe_ctx *ctx = priv; in device_run() local
1099 struct sc_data *sc = ctx->dev->sc; in device_run()
1100 struct vpe_q_data *d_q_data = &ctx->q_data[Q_DATA_DST]; in device_run()
1102 if (ctx->deinterlacing && ctx->src_vbs[2] == NULL) { in device_run()
1103 ctx->src_vbs[2] = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); in device_run()
1104 WARN_ON(ctx->src_vbs[2] == NULL); in device_run()
1105 ctx->src_vbs[1] = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); in device_run()
1106 WARN_ON(ctx->src_vbs[1] == NULL); in device_run()
1109 ctx->src_vbs[0] = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); in device_run()
1110 WARN_ON(ctx->src_vbs[0] == NULL); in device_run()
1111 ctx->dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); in device_run()
1112 WARN_ON(ctx->dst_vb == NULL); in device_run()
1115 if (ctx->dev->loaded_mmrs != ctx->mmr_adb.dma_addr || ctx->load_mmrs) { in device_run()
1116 vpdma_map_desc_buf(ctx->dev->vpdma, &ctx->mmr_adb); in device_run()
1117 vpdma_add_cfd_adb(&ctx->desc_list, CFD_MMR_CLIENT, &ctx->mmr_adb); in device_run()
1118 ctx->dev->loaded_mmrs = ctx->mmr_adb.dma_addr; in device_run()
1119 ctx->load_mmrs = false; in device_run()
1122 if (sc->loaded_coeff_h != ctx->sc_coeff_h.dma_addr || in device_run()
1124 vpdma_map_desc_buf(ctx->dev->vpdma, &ctx->sc_coeff_h); in device_run()
1125 vpdma_add_cfd_block(&ctx->desc_list, CFD_SC_CLIENT, in device_run()
1126 &ctx->sc_coeff_h, 0); in device_run()
1128 sc->loaded_coeff_h = ctx->sc_coeff_h.dma_addr; in device_run()
1132 if (sc->loaded_coeff_v != ctx->sc_coeff_v.dma_addr || in device_run()
1134 vpdma_map_desc_buf(ctx->dev->vpdma, &ctx->sc_coeff_v); in device_run()
1135 vpdma_add_cfd_block(&ctx->desc_list, CFD_SC_CLIENT, in device_run()
1136 &ctx->sc_coeff_v, SC_COEF_SRAM_SIZE >> 4); in device_run()
1138 sc->loaded_coeff_v = ctx->sc_coeff_v.dma_addr; in device_run()
1143 if (ctx->deinterlacing) in device_run()
1144 add_out_dtd(ctx, VPE_PORT_MV_OUT); in device_run()
1147 add_out_dtd(ctx, VPE_PORT_RGB_OUT); in device_run()
1149 add_out_dtd(ctx, VPE_PORT_LUMA_OUT); in device_run()
1151 add_out_dtd(ctx, VPE_PORT_CHROMA_OUT); in device_run()
1155 if (ctx->deinterlacing) { in device_run()
1156 add_in_dtd(ctx, VPE_PORT_LUMA3_IN); in device_run()
1157 add_in_dtd(ctx, VPE_PORT_CHROMA3_IN); in device_run()
1159 add_in_dtd(ctx, VPE_PORT_LUMA2_IN); in device_run()
1160 add_in_dtd(ctx, VPE_PORT_CHROMA2_IN); in device_run()
1163 add_in_dtd(ctx, VPE_PORT_LUMA1_IN); in device_run()
1164 add_in_dtd(ctx, VPE_PORT_CHROMA1_IN); in device_run()
1166 if (ctx->deinterlacing) in device_run()
1167 add_in_dtd(ctx, VPE_PORT_MV_IN); in device_run()
1170 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, VPE_CHAN_LUMA1_IN); in device_run()
1171 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, VPE_CHAN_CHROMA1_IN); in device_run()
1173 if (ctx->deinterlacing) { in device_run()
1174 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, in device_run()
1176 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, in device_run()
1179 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, in device_run()
1181 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, in device_run()
1184 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, VPE_CHAN_MV_IN); in device_run()
1189 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, in device_run()
1192 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, in device_run()
1195 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, in device_run()
1199 if (ctx->deinterlacing) in device_run()
1200 vpdma_add_sync_on_channel_ctd(&ctx->desc_list, VPE_CHAN_MV_OUT); in device_run()
1202 enable_irqs(ctx); in device_run()
1204 vpdma_map_desc_buf(ctx->dev->vpdma, &ctx->desc_list.buf); in device_run()
1205 vpdma_submit_descs(ctx->dev->vpdma, &ctx->desc_list); in device_run()
1208 static void dei_error(struct vpe_ctx *ctx) in dei_error() argument
1210 dev_warn(ctx->dev->v4l2_dev.dev, in dei_error()
1214 static void ds1_uv_error(struct vpe_ctx *ctx) in ds1_uv_error() argument
1216 dev_warn(ctx->dev->v4l2_dev.dev, in ds1_uv_error()
1223 struct vpe_ctx *ctx; in vpe_irq() local
1242 ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev); in vpe_irq()
1243 if (!ctx) { in vpe_irq()
1251 dei_error(ctx); in vpe_irq()
1255 ds1_uv_error(ctx); in vpe_irq()
1261 vpdma_clear_list_stat(ctx->dev->vpdma); in vpe_irq()
1272 disable_irqs(ctx); in vpe_irq()
1274 vpdma_unmap_desc_buf(dev->vpdma, &ctx->desc_list.buf); in vpe_irq()
1275 vpdma_unmap_desc_buf(dev->vpdma, &ctx->mmr_adb); in vpe_irq()
1276 vpdma_unmap_desc_buf(dev->vpdma, &ctx->sc_coeff_h); in vpe_irq()
1277 vpdma_unmap_desc_buf(dev->vpdma, &ctx->sc_coeff_v); in vpe_irq()
1279 vpdma_reset_desc_list(&ctx->desc_list); in vpe_irq()
1282 ctx->src_mv_buf_selector = !ctx->src_mv_buf_selector; in vpe_irq()
1284 if (ctx->aborting) in vpe_irq()
1287 s_vb = ctx->src_vbs[0]; in vpe_irq()
1288 d_vb = ctx->dst_vb; in vpe_irq()
1298 d_buf->sequence = ctx->sequence; in vpe_irq()
1300 d_q_data = &ctx->q_data[Q_DATA_DST]; in vpe_irq()
1302 d_buf->field = ctx->field; in vpe_irq()
1303 if (ctx->field == V4L2_FIELD_BOTTOM) { in vpe_irq()
1304 ctx->sequence++; in vpe_irq()
1305 ctx->field = V4L2_FIELD_TOP; in vpe_irq()
1307 WARN_ON(ctx->field != V4L2_FIELD_TOP); in vpe_irq()
1308 ctx->field = V4L2_FIELD_BOTTOM; in vpe_irq()
1312 ctx->sequence++; in vpe_irq()
1315 if (ctx->deinterlacing) in vpe_irq()
1316 s_vb = ctx->src_vbs[2]; in vpe_irq()
1323 if (ctx->deinterlacing) { in vpe_irq()
1324 ctx->src_vbs[2] = ctx->src_vbs[1]; in vpe_irq()
1325 ctx->src_vbs[1] = ctx->src_vbs[0]; in vpe_irq()
1328 ctx->bufs_completed++; in vpe_irq()
1329 if (ctx->bufs_completed < ctx->bufs_per_job) { in vpe_irq()
1330 device_run(ctx); in vpe_irq()
1335 vpe_dbg(ctx->dev, "finishing transaction\n"); in vpe_irq()
1336 ctx->bufs_completed = 0; in vpe_irq()
1337 v4l2_m2m_job_finish(dev->m2m_dev, ctx->fh.m2m_ctx); in vpe_irq()
1393 struct vpe_ctx *ctx = file2ctx(file); in vpe_g_fmt() local
1398 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); in vpe_g_fmt()
1402 q_data = get_q_data(ctx, f->type); in vpe_g_fmt()
1415 s_q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); in vpe_g_fmt()
1430 static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f, in __vpe_try_fmt() argument
1439 vpe_err(ctx->dev, "Fourcc format (0x%08x) invalid.\n", in __vpe_try_fmt()
1513 struct vpe_ctx *ctx = file2ctx(file); in vpe_try_fmt() local
1517 return __vpe_try_fmt(ctx, f, fmt, VPE_FMT_TYPE_OUTPUT); in vpe_try_fmt()
1519 return __vpe_try_fmt(ctx, f, fmt, VPE_FMT_TYPE_CAPTURE); in vpe_try_fmt()
1522 static int __vpe_s_fmt(struct vpe_ctx *ctx, struct v4l2_format *f) in __vpe_s_fmt() argument
1530 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); in __vpe_s_fmt()
1535 vpe_err(ctx->dev, "queue busy\n"); in __vpe_s_fmt()
1539 q_data = get_q_data(ctx, f->type); in __vpe_s_fmt()
1566 vpe_dbg(ctx->dev, "Setting format for type %d, wxh: %dx%d, fmt: %d bpl_y %d", in __vpe_s_fmt()
1570 vpe_dbg(ctx->dev, " bpl_uv %d\n", in __vpe_s_fmt()
1579 struct vpe_ctx *ctx = file2ctx(file); in vpe_s_fmt() local
1585 ret = __vpe_s_fmt(ctx, f); in vpe_s_fmt()
1590 set_src_registers(ctx); in vpe_s_fmt()
1592 set_dst_registers(ctx); in vpe_s_fmt()
1594 return set_srcdst_params(ctx); in vpe_s_fmt()
1597 static int __vpe_try_selection(struct vpe_ctx *ctx, struct v4l2_selection *s) in __vpe_try_selection() argument
1605 q_data = get_q_data(ctx, s->type); in __vpe_try_selection()
1635 vpe_err(ctx->dev, "negative values for top and left\n"); in __vpe_try_selection()
1654 struct vpe_ctx *ctx = file2ctx(file); in vpe_g_selection() local
1662 q_data = get_q_data(ctx, s->type); in vpe_g_selection()
1715 struct vpe_ctx *ctx = file2ctx(file); in vpe_s_selection() local
1720 ret = __vpe_try_selection(ctx, &sel); in vpe_s_selection()
1724 q_data = get_q_data(ctx, sel.type); in vpe_s_selection()
1732 vpe_dbg(ctx->dev, in vpe_s_selection()
1739 return set_srcdst_params(ctx); in vpe_s_selection()
1750 struct vpe_ctx *ctx = in vpe_s_ctrl() local
1755 ctx->bufs_per_job = ctrl->val; in vpe_s_ctrl()
1759 vpe_err(ctx->dev, "Invalid control\n"); in vpe_s_ctrl()
1806 struct vpe_ctx *ctx = vb2_get_drv_priv(vq); in vpe_queue_setup() local
1809 q_data = get_q_data(ctx, vq->type); in vpe_queue_setup()
1815 alloc_ctxs[i] = ctx->dev->alloc_ctx; in vpe_queue_setup()
1818 vpe_dbg(ctx->dev, "get %d buffer(s) of size %d", *nbuffers, in vpe_queue_setup()
1821 vpe_dbg(ctx->dev, " and %d\n", sizes[VPE_CHROMA]); in vpe_queue_setup()
1828 struct vpe_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in vpe_buf_prepare() local
1832 vpe_dbg(ctx->dev, "type: %d\n", vb->vb2_queue->type); in vpe_buf_prepare()
1834 q_data = get_q_data(ctx, vb->vb2_queue->type); in vpe_buf_prepare()
1849 vpe_err(ctx->dev, in vpe_buf_prepare()
1865 struct vpe_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in vpe_buf_queue() local
1867 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb); in vpe_buf_queue()
1879 struct vpe_ctx *ctx = vb2_get_drv_priv(q); in vpe_stop_streaming() local
1881 vpe_dump_regs(ctx->dev); in vpe_stop_streaming()
1882 vpdma_dump_regs(ctx->dev->vpdma); in vpe_stop_streaming()
1898 struct vpe_ctx *ctx = priv; in queue_init() local
1899 struct vpe_dev *dev = ctx->dev; in queue_init()
1905 src_vq->drv_priv = ctx; in queue_init()
1919 dst_vq->drv_priv = ctx; in queue_init()
1948 struct vpe_ctx *ctx; in vpe_open() local
1953 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); in vpe_open()
1954 if (!ctx) in vpe_open()
1957 ctx->dev = dev; in vpe_open()
1964 ret = vpdma_create_desc_list(&ctx->desc_list, VPE_DESC_LIST_SIZE, in vpe_open()
1969 ret = vpdma_alloc_desc_buf(&ctx->mmr_adb, sizeof(struct vpe_mmr_adb)); in vpe_open()
1973 ret = vpdma_alloc_desc_buf(&ctx->sc_coeff_h, SC_COEF_SRAM_SIZE); in vpe_open()
1977 ret = vpdma_alloc_desc_buf(&ctx->sc_coeff_v, SC_COEF_SRAM_SIZE); in vpe_open()
1981 init_adb_hdrs(ctx); in vpe_open()
1983 v4l2_fh_init(&ctx->fh, video_devdata(file)); in vpe_open()
1984 file->private_data = &ctx->fh; in vpe_open()
1986 hdl = &ctx->hdl; in vpe_open()
1993 ctx->fh.ctrl_handler = hdl; in vpe_open()
1996 s_q_data = &ctx->q_data[Q_DATA_SRC]; in vpe_open()
2012 ctx->q_data[Q_DATA_DST] = *s_q_data; in vpe_open()
2014 set_dei_shadow_registers(ctx); in vpe_open()
2015 set_src_registers(ctx); in vpe_open()
2016 set_dst_registers(ctx); in vpe_open()
2017 ret = set_srcdst_params(ctx); in vpe_open()
2021 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init); in vpe_open()
2023 if (IS_ERR(ctx->fh.m2m_ctx)) { in vpe_open()
2024 ret = PTR_ERR(ctx->fh.m2m_ctx); in vpe_open()
2028 v4l2_fh_add(&ctx->fh); in vpe_open()
2038 ctx->bufs_per_job = VPE_DEF_BUFS_PER_JOB; in vpe_open()
2040 ctx->load_mmrs = true; in vpe_open()
2043 ctx, ctx->fh.m2m_ctx); in vpe_open()
2050 v4l2_fh_exit(&ctx->fh); in vpe_open()
2051 vpdma_free_desc_buf(&ctx->sc_coeff_v); in vpe_open()
2053 vpdma_free_desc_buf(&ctx->sc_coeff_h); in vpe_open()
2055 vpdma_free_desc_buf(&ctx->mmr_adb); in vpe_open()
2057 vpdma_free_desc_list(&ctx->desc_list); in vpe_open()
2061 kfree(ctx); in vpe_open()
2068 struct vpe_ctx *ctx = file2ctx(file); in vpe_release() local
2070 vpe_dbg(dev, "releasing instance %p\n", ctx); in vpe_release()
2073 free_vbs(ctx); in vpe_release()
2074 free_mv_buffers(ctx); in vpe_release()
2075 vpdma_free_desc_list(&ctx->desc_list); in vpe_release()
2076 vpdma_free_desc_buf(&ctx->mmr_adb); in vpe_release()
2078 v4l2_fh_del(&ctx->fh); in vpe_release()
2079 v4l2_fh_exit(&ctx->fh); in vpe_release()
2080 v4l2_ctrl_handler_free(&ctx->hdl); in vpe_release()
2081 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); in vpe_release()
2083 kfree(ctx); in vpe_release()