Lines Matching refs:vpfe
105 static int __subdev_get_format(struct vpfe_device *vpfe,
107 static int vpfe_calc_format_size(struct vpfe_device *vpfe,
111 static struct vpfe_fmt *find_format_by_code(struct vpfe_device *vpfe, in find_format_by_code() argument
117 for (k = 0; k < vpfe->num_active_fmt; k++) { in find_format_by_code()
118 fmt = vpfe->active_fmt[k]; in find_format_by_code()
126 static struct vpfe_fmt *find_format_by_pix(struct vpfe_device *vpfe, in find_format_by_pix() argument
132 for (k = 0; k < vpfe->num_active_fmt; k++) { in find_format_by_pix()
133 fmt = vpfe->active_fmt[k]; in find_format_by_pix()
141 static unsigned int __get_bytesperpixel(struct vpfe_device *vpfe, in __get_bytesperpixel() argument
144 struct vpfe_subdev_info *sdinfo = vpfe->current_subdev; in __get_bytesperpixel()
255 struct vpfe_device *vpfe = to_vpfe(ccdc); in vpfe_reg_dump() local
257 vpfe_dbg(3, vpfe, "ALAW: 0x%x\n", vpfe_reg_read(ccdc, VPFE_ALAW)); in vpfe_reg_dump()
258 vpfe_dbg(3, vpfe, "CLAMP: 0x%x\n", vpfe_reg_read(ccdc, VPFE_CLAMP)); in vpfe_reg_dump()
259 vpfe_dbg(3, vpfe, "DCSUB: 0x%x\n", vpfe_reg_read(ccdc, VPFE_DCSUB)); in vpfe_reg_dump()
260 vpfe_dbg(3, vpfe, "BLKCMP: 0x%x\n", vpfe_reg_read(ccdc, VPFE_BLKCMP)); in vpfe_reg_dump()
261 vpfe_dbg(3, vpfe, "COLPTN: 0x%x\n", vpfe_reg_read(ccdc, VPFE_COLPTN)); in vpfe_reg_dump()
262 vpfe_dbg(3, vpfe, "SDOFST: 0x%x\n", vpfe_reg_read(ccdc, VPFE_SDOFST)); in vpfe_reg_dump()
263 vpfe_dbg(3, vpfe, "SYN_MODE: 0x%x\n", in vpfe_reg_dump()
265 vpfe_dbg(3, vpfe, "HSIZE_OFF: 0x%x\n", in vpfe_reg_dump()
267 vpfe_dbg(3, vpfe, "HORZ_INFO: 0x%x\n", in vpfe_reg_dump()
269 vpfe_dbg(3, vpfe, "VERT_START: 0x%x\n", in vpfe_reg_dump()
271 vpfe_dbg(3, vpfe, "VERT_LINES: 0x%x\n", in vpfe_reg_dump()
279 struct vpfe_device *vpfe = to_vpfe(ccdc); in vpfe_ccdc_validate_param() local
291 vpfe_dbg(1, vpfe, "Invalid data line select\n"); in vpfe_ccdc_validate_param()
329 struct vpfe_device *vpfe = to_vpfe(ccdc); in vpfe_ccdc_close() local
334 vpfe_dbg(1, vpfe, "VPFE_PCR is still set (%x)", pcr); in vpfe_ccdc_close()
338 vpfe_dbg(1, vpfe, "VPFE_DMA_CNTL_OVERFLOW is still set (%x)", in vpfe_ccdc_close()
353 struct vpfe_device *vpfe = to_vpfe(ccdc); in vpfe_ccdc_set_params() local
362 vpfe_dbg(1, vpfe, in vpfe_ccdc_set_params()
509 struct vpfe_device *vpfe = to_vpfe(ccdc); in vpfe_ccdc_config_raw() local
544 vpfe_dbg(3, vpfe, "\nWriting 0x%x to ALAW...\n", val); in vpfe_ccdc_config_raw()
568 vpfe_dbg(3, vpfe, "Writing %d (%x) to HSIZE_OFF\n", in vpfe_ccdc_config_raw()
614 struct vpfe_device *vpfe = to_vpfe(ccdc); in vpfe_ccdc_set_pixel_format() local
616 vpfe_dbg(1, vpfe, "%s: if_type: %d, pixfmt:%s\n", in vpfe_ccdc_set_pixel_format()
746 struct vpfe_device *vpfe = to_vpfe(ccdc); in vpfe_ccdc_set_hw_if_params() local
768 vpfe_dbg(1, vpfe, "params.bus_width: %d\n", in vpfe_ccdc_set_hw_if_params()
770 vpfe_dbg(1, vpfe, "config_params.data_sz: %d\n", in vpfe_ccdc_set_hw_if_params()
861 static int vpfe_get_ccdc_image_format(struct vpfe_device *vpfe, in vpfe_get_ccdc_image_format() argument
870 vpfe_ccdc_get_image_window(&vpfe->ccdc, &image_win); in vpfe_get_ccdc_image_format()
873 f->fmt.pix.bytesperline = vpfe_ccdc_get_line_length(&vpfe->ccdc); in vpfe_get_ccdc_image_format()
876 buf_type = vpfe_ccdc_get_buftype(&vpfe->ccdc); in vpfe_get_ccdc_image_format()
877 f->fmt.pix.pixelformat = vpfe_ccdc_get_pixel_format(&vpfe->ccdc); in vpfe_get_ccdc_image_format()
878 frm_fmt = vpfe_ccdc_get_frame_format(&vpfe->ccdc); in vpfe_get_ccdc_image_format()
888 vpfe_err(vpfe, "Invalid buf_type\n"); in vpfe_get_ccdc_image_format()
892 vpfe_err(vpfe, "Invalid frm_fmt\n"); in vpfe_get_ccdc_image_format()
898 static int vpfe_config_ccdc_image_format(struct vpfe_device *vpfe) in vpfe_config_ccdc_image_format() argument
904 vpfe_dbg(1, vpfe, "pixelformat: %s\n", in vpfe_config_ccdc_image_format()
905 print_fourcc(vpfe->fmt.fmt.pix.pixelformat)); in vpfe_config_ccdc_image_format()
907 if (vpfe_ccdc_set_pixel_format(&vpfe->ccdc, in vpfe_config_ccdc_image_format()
908 vpfe->fmt.fmt.pix.pixelformat) < 0) { in vpfe_config_ccdc_image_format()
909 vpfe_err(vpfe, "couldn't set pix format in ccdc\n"); in vpfe_config_ccdc_image_format()
914 bpp = __get_bytesperpixel(vpfe, vpfe->current_vpfe_fmt); in vpfe_config_ccdc_image_format()
915 vpfe_ccdc_set_image_window(&vpfe->ccdc, &vpfe->crop, bpp); in vpfe_config_ccdc_image_format()
917 switch (vpfe->fmt.fmt.pix.field) { in vpfe_config_ccdc_image_format()
921 &vpfe->ccdc, in vpfe_config_ccdc_image_format()
932 &vpfe->ccdc, in vpfe_config_ccdc_image_format()
943 return vpfe_ccdc_set_frame_format(&vpfe->ccdc, frm_fmt); in vpfe_config_ccdc_image_format()
956 static int vpfe_config_image_format(struct vpfe_device *vpfe, in vpfe_config_image_format() argument
965 vpfe->std_info.active_pixels = in vpfe_config_image_format()
967 vpfe->std_info.active_lines = in vpfe_config_image_format()
969 vpfe->std_info.frame_format = in vpfe_config_image_format()
971 vpfe->std_index = i; in vpfe_config_image_format()
978 vpfe_err(vpfe, "standard not supported\n"); in vpfe_config_image_format()
982 ret = __subdev_get_format(vpfe, &mbus_fmt); in vpfe_config_image_format()
986 fmt = find_format_by_code(vpfe, mbus_fmt.code); in vpfe_config_image_format()
988 vpfe_dbg(3, vpfe, "mbus code format (0x%08x) not found.\n", in vpfe_config_image_format()
994 v4l2_fill_pix_format(&vpfe->fmt.fmt.pix, &mbus_fmt); in vpfe_config_image_format()
995 vpfe->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in vpfe_config_image_format()
996 vpfe->fmt.fmt.pix.pixelformat = fmt->fourcc; in vpfe_config_image_format()
997 vpfe_calc_format_size(vpfe, fmt, &vpfe->fmt); in vpfe_config_image_format()
998 vpfe->current_vpfe_fmt = fmt; in vpfe_config_image_format()
1001 vpfe->crop.top = 0; in vpfe_config_image_format()
1002 vpfe->crop.left = 0; in vpfe_config_image_format()
1003 vpfe->crop.width = mbus_fmt.width; in vpfe_config_image_format()
1004 vpfe->crop.height = mbus_fmt.height; in vpfe_config_image_format()
1006 return vpfe_config_ccdc_image_format(vpfe); in vpfe_config_image_format()
1009 static int vpfe_initialize_device(struct vpfe_device *vpfe) in vpfe_initialize_device() argument
1014 sdinfo = &vpfe->cfg->sub_devs[0]; in vpfe_initialize_device()
1015 sdinfo->sd = vpfe->sd[0]; in vpfe_initialize_device()
1016 vpfe->current_input = 0; in vpfe_initialize_device()
1017 vpfe->std_index = 0; in vpfe_initialize_device()
1019 ret = vpfe_config_image_format(vpfe, in vpfe_initialize_device()
1020 vpfe_standards[vpfe->std_index].std_id); in vpfe_initialize_device()
1024 ret = pm_runtime_resume_and_get(vpfe->pdev); in vpfe_initialize_device()
1028 vpfe_config_enable(&vpfe->ccdc, 1); in vpfe_initialize_device()
1030 vpfe_ccdc_restore_defaults(&vpfe->ccdc); in vpfe_initialize_device()
1033 vpfe_clear_intr(&vpfe->ccdc, -1); in vpfe_initialize_device()
1046 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_release() local
1050 mutex_lock(&vpfe->lock); in vpfe_release()
1063 vpfe_ccdc_close(&vpfe->ccdc, vpfe->pdev); in vpfe_release()
1065 mutex_unlock(&vpfe->lock); in vpfe_release()
1077 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_open() local
1080 mutex_lock(&vpfe->lock); in vpfe_open()
1084 vpfe_err(vpfe, "v4l2_fh_open failed\n"); in vpfe_open()
1091 if (vpfe_initialize_device(vpfe)) { in vpfe_open()
1097 mutex_unlock(&vpfe->lock); in vpfe_open()
1109 static void vpfe_schedule_next_buffer(struct vpfe_device *vpfe) in vpfe_schedule_next_buffer() argument
1113 spin_lock(&vpfe->dma_queue_lock); in vpfe_schedule_next_buffer()
1114 if (list_empty(&vpfe->dma_queue)) { in vpfe_schedule_next_buffer()
1115 spin_unlock(&vpfe->dma_queue_lock); in vpfe_schedule_next_buffer()
1119 vpfe->next_frm = list_entry(vpfe->dma_queue.next, in vpfe_schedule_next_buffer()
1121 list_del(&vpfe->next_frm->list); in vpfe_schedule_next_buffer()
1122 spin_unlock(&vpfe->dma_queue_lock); in vpfe_schedule_next_buffer()
1124 addr = vb2_dma_contig_plane_dma_addr(&vpfe->next_frm->vb.vb2_buf, 0); in vpfe_schedule_next_buffer()
1125 vpfe_set_sdr_addr(&vpfe->ccdc, addr); in vpfe_schedule_next_buffer()
1128 static inline void vpfe_schedule_bottom_field(struct vpfe_device *vpfe) in vpfe_schedule_bottom_field() argument
1132 addr = vb2_dma_contig_plane_dma_addr(&vpfe->next_frm->vb.vb2_buf, 0) + in vpfe_schedule_bottom_field()
1133 vpfe->field_off; in vpfe_schedule_bottom_field()
1135 vpfe_set_sdr_addr(&vpfe->ccdc, addr); in vpfe_schedule_bottom_field()
1146 static inline void vpfe_process_buffer_complete(struct vpfe_device *vpfe) in vpfe_process_buffer_complete() argument
1148 vpfe->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns(); in vpfe_process_buffer_complete()
1149 vpfe->cur_frm->vb.field = vpfe->fmt.fmt.pix.field; in vpfe_process_buffer_complete()
1150 vpfe->cur_frm->vb.sequence = vpfe->sequence++; in vpfe_process_buffer_complete()
1151 vb2_buffer_done(&vpfe->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); in vpfe_process_buffer_complete()
1152 vpfe->cur_frm = vpfe->next_frm; in vpfe_process_buffer_complete()
1155 static void vpfe_handle_interlaced_irq(struct vpfe_device *vpfe, in vpfe_handle_interlaced_irq() argument
1163 fid = vpfe_ccdc_getfid(&vpfe->ccdc); in vpfe_handle_interlaced_irq()
1166 vpfe->field ^= 1; in vpfe_handle_interlaced_irq()
1167 if (fid == vpfe->field) { in vpfe_handle_interlaced_irq()
1175 if (vpfe->cur_frm != vpfe->next_frm) in vpfe_handle_interlaced_irq()
1176 vpfe_process_buffer_complete(vpfe); in vpfe_handle_interlaced_irq()
1178 if (vpfe->stopping) in vpfe_handle_interlaced_irq()
1187 vpfe_schedule_bottom_field(vpfe); in vpfe_handle_interlaced_irq()
1195 if (vpfe->cur_frm == vpfe->next_frm) in vpfe_handle_interlaced_irq()
1196 vpfe_schedule_next_buffer(vpfe); in vpfe_handle_interlaced_irq()
1203 vpfe->field = fid; in vpfe_handle_interlaced_irq()
1217 struct vpfe_device *vpfe = (struct vpfe_device *)dev; in vpfe_isr() local
1218 enum v4l2_field field = vpfe->fmt.fmt.pix.field; in vpfe_isr()
1219 int intr_status, stopping = vpfe->stopping; in vpfe_isr()
1221 intr_status = vpfe_reg_read(&vpfe->ccdc, VPFE_IRQ_STS); in vpfe_isr()
1225 if (vpfe->cur_frm != vpfe->next_frm) in vpfe_isr()
1226 vpfe_process_buffer_complete(vpfe); in vpfe_isr()
1228 vpfe_handle_interlaced_irq(vpfe, field); in vpfe_isr()
1231 vpfe->stopping = false; in vpfe_isr()
1232 complete(&vpfe->capture_stop); in vpfe_isr()
1238 vpfe->cur_frm == vpfe->next_frm) in vpfe_isr()
1239 vpfe_schedule_next_buffer(vpfe); in vpfe_isr()
1242 vpfe_clear_intr(&vpfe->ccdc, intr_status); in vpfe_isr()
1247 static inline void vpfe_detach_irq(struct vpfe_device *vpfe) in vpfe_detach_irq() argument
1252 frame_format = vpfe_ccdc_get_frame_format(&vpfe->ccdc); in vpfe_detach_irq()
1256 vpfe_reg_write(&vpfe->ccdc, intr, VPFE_IRQ_EN_CLR); in vpfe_detach_irq()
1259 static inline void vpfe_attach_irq(struct vpfe_device *vpfe) in vpfe_attach_irq() argument
1264 frame_format = vpfe_ccdc_get_frame_format(&vpfe->ccdc); in vpfe_attach_irq()
1268 vpfe_reg_write(&vpfe->ccdc, intr, VPFE_IRQ_EN_SET); in vpfe_attach_irq()
1274 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_querycap() local
1279 "platform:%s", vpfe->v4l2_dev.name); in vpfe_querycap()
1284 static int __subdev_get_format(struct vpfe_device *vpfe, in __subdev_get_format() argument
1287 struct v4l2_subdev *sd = vpfe->current_subdev->sd; in __subdev_get_format()
1301 vpfe_dbg(1, vpfe, "%s: %dx%d code:%04X\n", __func__, in __subdev_get_format()
1308 static int __subdev_set_format(struct vpfe_device *vpfe, in __subdev_set_format() argument
1311 struct v4l2_subdev *sd = vpfe->current_subdev->sd; in __subdev_set_format()
1324 vpfe_dbg(1, vpfe, "%s %dx%d code:%04X\n", __func__, in __subdev_set_format()
1330 static int vpfe_calc_format_size(struct vpfe_device *vpfe, in vpfe_calc_format_size() argument
1337 vpfe_dbg(3, vpfe, "No vpfe_fmt provided!\n"); in vpfe_calc_format_size()
1341 bpp = __get_bytesperpixel(vpfe, fmt); in vpfe_calc_format_size()
1348 vpfe_dbg(3, vpfe, "%s: fourcc: %s size: %dx%d bpl:%d img_size:%d\n", in vpfe_calc_format_size()
1359 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_g_fmt() local
1361 *fmt = vpfe->fmt; in vpfe_g_fmt()
1369 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_enum_fmt() local
1373 sdinfo = vpfe->current_subdev; in vpfe_enum_fmt()
1377 if (f->index >= vpfe->num_active_fmt) in vpfe_enum_fmt()
1380 fmt = vpfe->active_fmt[f->index]; in vpfe_enum_fmt()
1384 vpfe_dbg(1, vpfe, "%s: mbus index: %d code: %x pixelformat: %s\n", in vpfe_enum_fmt()
1393 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_try_fmt() local
1394 struct v4l2_subdev *sd = vpfe->current_subdev->sd; in vpfe_try_fmt()
1399 fmt = find_format_by_pix(vpfe, f->fmt.pix.pixelformat); in vpfe_try_fmt()
1402 vpfe_dbg(3, vpfe, "Invalid pixel code: %x, default used instead\n", in vpfe_try_fmt()
1404 fmt = vpfe->active_fmt[0]; in vpfe_try_fmt()
1408 f->fmt.pix.field = vpfe->fmt.fmt.pix.field; in vpfe_try_fmt()
1437 f->fmt.pix.width = vpfe->fmt.fmt.pix.width; in vpfe_try_fmt()
1438 f->fmt.pix.height = vpfe->fmt.fmt.pix.height; in vpfe_try_fmt()
1445 f->fmt.pix.colorspace = vpfe->fmt.fmt.pix.colorspace; in vpfe_try_fmt()
1446 return vpfe_calc_format_size(vpfe, fmt, f); in vpfe_try_fmt()
1452 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_s_fmt() local
1458 if (vb2_is_busy(&vpfe->buffer_queue)) { in vpfe_s_fmt()
1459 vpfe_err(vpfe, "%s device busy\n", __func__); in vpfe_s_fmt()
1467 f = find_format_by_pix(vpfe, fmt->fmt.pix.pixelformat); in vpfe_s_fmt()
1471 ret = __subdev_set_format(vpfe, &mbus_fmt); in vpfe_s_fmt()
1477 vpfe_dbg(3, vpfe, in vpfe_s_fmt()
1483 v4l2_fill_pix_format(&vpfe->fmt.fmt.pix, &mbus_fmt); in vpfe_s_fmt()
1484 vpfe->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in vpfe_s_fmt()
1485 vpfe->fmt.fmt.pix.pixelformat = f->fourcc; in vpfe_s_fmt()
1486 vpfe_calc_format_size(vpfe, f, &vpfe->fmt); in vpfe_s_fmt()
1487 *fmt = vpfe->fmt; in vpfe_s_fmt()
1488 vpfe->current_vpfe_fmt = f; in vpfe_s_fmt()
1491 vpfe->crop.width = fmt->fmt.pix.width; in vpfe_s_fmt()
1492 vpfe->crop.height = fmt->fmt.pix.height; in vpfe_s_fmt()
1495 return vpfe_config_ccdc_image_format(vpfe); in vpfe_s_fmt()
1501 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_enum_size() local
1503 struct v4l2_subdev *sd = vpfe->current_subdev->sd; in vpfe_enum_size()
1508 fmt = find_format_by_pix(vpfe, fsize->pixel_format); in vpfe_enum_size()
1510 vpfe_dbg(3, vpfe, "Invalid pixel code: %x\n", in vpfe_enum_size()
1526 vpfe_dbg(1, vpfe, "%s: index: %d code: %x W:[%d,%d] H:[%d,%d]\n", in vpfe_enum_size()
1534 vpfe_dbg(1, vpfe, "%s: index: %d pixformat: %s size: %dx%d\n", in vpfe_enum_size()
1546 vpfe_get_subdev_input_index(struct vpfe_device *vpfe, in vpfe_get_subdev_input_index() argument
1553 for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) { in vpfe_get_subdev_input_index()
1569 static int vpfe_get_app_input_index(struct vpfe_device *vpfe, in vpfe_get_app_input_index() argument
1572 struct vpfe_config *cfg = vpfe->cfg; in vpfe_get_app_input_index()
1578 curr_client = v4l2_get_subdevdata(vpfe->current_subdev->sd); in vpfe_get_app_input_index()
1579 for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) { in vpfe_get_app_input_index()
1584 if (vpfe->current_input >= 1) in vpfe_get_app_input_index()
1586 *app_input_index = j + vpfe->current_input; in vpfe_get_app_input_index()
1597 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_enum_input() local
1601 if (vpfe_get_subdev_input_index(vpfe, &subdev, &index, in vpfe_enum_input()
1603 vpfe_dbg(1, vpfe, in vpfe_enum_input()
1607 sdinfo = &vpfe->cfg->sub_devs[subdev]; in vpfe_enum_input()
1615 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_g_input() local
1617 return vpfe_get_app_input_index(vpfe, index); in vpfe_g_input()
1621 static int vpfe_set_input(struct vpfe_device *vpfe, unsigned int index) in vpfe_set_input() argument
1630 if (vb2_is_busy(&vpfe->buffer_queue)) { in vpfe_set_input()
1631 vpfe_err(vpfe, "%s device busy\n", __func__); in vpfe_set_input()
1634 ret = vpfe_get_subdev_input_index(vpfe, in vpfe_set_input()
1639 vpfe_err(vpfe, "invalid input index: %d\n", index); in vpfe_set_input()
1643 sdinfo = &vpfe->cfg->sub_devs[subdev_index]; in vpfe_set_input()
1644 sdinfo->sd = vpfe->sd[subdev_index]; in vpfe_set_input()
1653 vpfe_err(vpfe, "s_routing failed\n"); in vpfe_set_input()
1661 vpfe->current_subdev = sdinfo; in vpfe_set_input()
1663 vpfe->v4l2_dev.ctrl_handler = sdinfo->sd->ctrl_handler; in vpfe_set_input()
1664 vpfe->current_input = index; in vpfe_set_input()
1665 vpfe->std_index = 0; in vpfe_set_input()
1668 ret = vpfe_ccdc_set_hw_if_params(&vpfe->ccdc, &sdinfo->vpfe_param); in vpfe_set_input()
1673 return vpfe_config_image_format(vpfe, in vpfe_set_input()
1674 vpfe_standards[vpfe->std_index].std_id); in vpfe_set_input()
1682 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_s_input() local
1684 return vpfe_set_input(vpfe, index); in vpfe_s_input()
1689 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_querystd() local
1692 sdinfo = vpfe->current_subdev; in vpfe_querystd()
1697 return v4l2_device_call_until_err(&vpfe->v4l2_dev, sdinfo->grp_id, in vpfe_querystd()
1703 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_s_std() local
1707 sdinfo = vpfe->current_subdev; in vpfe_s_std()
1712 if (vpfe_standards[vpfe->std_index].std_id == std_id) in vpfe_s_std()
1716 if (vb2_is_busy(&vpfe->buffer_queue)) { in vpfe_s_std()
1717 vpfe_err(vpfe, "%s device busy\n", __func__); in vpfe_s_std()
1722 ret = v4l2_device_call_until_err(&vpfe->v4l2_dev, sdinfo->grp_id, in vpfe_s_std()
1725 vpfe_err(vpfe, "Failed to set standard\n"); in vpfe_s_std()
1728 ret = vpfe_config_image_format(vpfe, std_id); in vpfe_s_std()
1735 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_g_std() local
1738 sdinfo = vpfe->current_subdev; in vpfe_g_std()
1742 *std_id = vpfe_standards[vpfe->std_index].std_id; in vpfe_g_std()
1751 static void vpfe_calculate_offsets(struct vpfe_device *vpfe) in vpfe_calculate_offsets() argument
1755 vpfe_ccdc_get_image_window(&vpfe->ccdc, &image_win); in vpfe_calculate_offsets()
1756 vpfe->field_off = image_win.height * image_win.width; in vpfe_calculate_offsets()
1774 struct vpfe_device *vpfe = vb2_get_drv_priv(vq); in vpfe_queue_setup() local
1775 unsigned size = vpfe->fmt.fmt.pix.sizeimage; in vpfe_queue_setup()
1789 vpfe_dbg(1, vpfe, in vpfe_queue_setup()
1793 vpfe_calculate_offsets(vpfe); in vpfe_queue_setup()
1809 struct vpfe_device *vpfe = vb2_get_drv_priv(vb->vb2_queue); in vpfe_buffer_prepare() local
1811 vb2_set_plane_payload(vb, 0, vpfe->fmt.fmt.pix.sizeimage); in vpfe_buffer_prepare()
1816 vbuf->field = vpfe->fmt.fmt.pix.field; in vpfe_buffer_prepare()
1828 struct vpfe_device *vpfe = vb2_get_drv_priv(vb->vb2_queue); in vpfe_buffer_queue() local
1833 spin_lock_irqsave(&vpfe->dma_queue_lock, flags); in vpfe_buffer_queue()
1834 list_add_tail(&buf->list, &vpfe->dma_queue); in vpfe_buffer_queue()
1835 spin_unlock_irqrestore(&vpfe->dma_queue_lock, flags); in vpfe_buffer_queue()
1838 static void vpfe_return_all_buffers(struct vpfe_device *vpfe, in vpfe_return_all_buffers() argument
1844 spin_lock_irqsave(&vpfe->dma_queue_lock, flags); in vpfe_return_all_buffers()
1845 list_for_each_entry_safe(buf, node, &vpfe->dma_queue, list) { in vpfe_return_all_buffers()
1850 if (vpfe->cur_frm) in vpfe_return_all_buffers()
1851 vb2_buffer_done(&vpfe->cur_frm->vb.vb2_buf, state); in vpfe_return_all_buffers()
1853 if (vpfe->next_frm && vpfe->next_frm != vpfe->cur_frm) in vpfe_return_all_buffers()
1854 vb2_buffer_done(&vpfe->next_frm->vb.vb2_buf, state); in vpfe_return_all_buffers()
1856 vpfe->cur_frm = NULL; in vpfe_return_all_buffers()
1857 vpfe->next_frm = NULL; in vpfe_return_all_buffers()
1858 spin_unlock_irqrestore(&vpfe->dma_queue_lock, flags); in vpfe_return_all_buffers()
1868 struct vpfe_device *vpfe = vb2_get_drv_priv(vq); in vpfe_start_streaming() local
1874 spin_lock_irqsave(&vpfe->dma_queue_lock, flags); in vpfe_start_streaming()
1876 vpfe->field = 0; in vpfe_start_streaming()
1877 vpfe->sequence = 0; in vpfe_start_streaming()
1879 sdinfo = vpfe->current_subdev; in vpfe_start_streaming()
1881 vpfe_attach_irq(vpfe); in vpfe_start_streaming()
1883 vpfe->stopping = false; in vpfe_start_streaming()
1884 init_completion(&vpfe->capture_stop); in vpfe_start_streaming()
1886 if (vpfe->ccdc.ccdc_cfg.if_type == VPFE_RAW_BAYER) in vpfe_start_streaming()
1887 vpfe_ccdc_config_raw(&vpfe->ccdc); in vpfe_start_streaming()
1889 vpfe_ccdc_config_ycbcr(&vpfe->ccdc); in vpfe_start_streaming()
1892 vpfe->next_frm = list_entry(vpfe->dma_queue.next, in vpfe_start_streaming()
1894 vpfe->cur_frm = vpfe->next_frm; in vpfe_start_streaming()
1896 list_del(&vpfe->cur_frm->list); in vpfe_start_streaming()
1897 spin_unlock_irqrestore(&vpfe->dma_queue_lock, flags); in vpfe_start_streaming()
1899 addr = vb2_dma_contig_plane_dma_addr(&vpfe->cur_frm->vb.vb2_buf, 0); in vpfe_start_streaming()
1901 vpfe_set_sdr_addr(&vpfe->ccdc, (unsigned long)(addr)); in vpfe_start_streaming()
1903 vpfe_pcr_enable(&vpfe->ccdc, 1); in vpfe_start_streaming()
1907 vpfe_err(vpfe, "Error in attaching interrupt handle\n"); in vpfe_start_streaming()
1914 vpfe_return_all_buffers(vpfe, VB2_BUF_STATE_QUEUED); in vpfe_start_streaming()
1915 vpfe_pcr_enable(&vpfe->ccdc, 0); in vpfe_start_streaming()
1928 struct vpfe_device *vpfe = vb2_get_drv_priv(vq); in vpfe_stop_streaming() local
1932 vpfe_pcr_enable(&vpfe->ccdc, 0); in vpfe_stop_streaming()
1935 vpfe->stopping = true; in vpfe_stop_streaming()
1936 wait_for_completion_timeout(&vpfe->capture_stop, in vpfe_stop_streaming()
1939 vpfe_detach_irq(vpfe); in vpfe_stop_streaming()
1941 sdinfo = vpfe->current_subdev; in vpfe_stop_streaming()
1944 vpfe_dbg(1, vpfe, "stream off failed in subdev\n"); in vpfe_stop_streaming()
1947 vpfe_return_all_buffers(vpfe, VB2_BUF_STATE_ERROR); in vpfe_stop_streaming()
1953 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_g_pixelaspect() local
1956 vpfe->std_index >= ARRAY_SIZE(vpfe_standards)) in vpfe_g_pixelaspect()
1959 *f = vpfe_standards[vpfe->std_index].pixelaspect; in vpfe_g_pixelaspect()
1967 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_g_selection() local
1970 vpfe->std_index >= ARRAY_SIZE(vpfe_standards)) in vpfe_g_selection()
1978 s->r.width = vpfe_standards[vpfe->std_index].width; in vpfe_g_selection()
1979 s->r.height = vpfe_standards[vpfe->std_index].height; in vpfe_g_selection()
1983 s->r = vpfe->crop; in vpfe_g_selection()
1996 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_s_selection() local
1997 struct v4l2_rect cr = vpfe->crop; in vpfe_s_selection()
2002 if (vb2_is_busy(&vpfe->buffer_queue)) { in vpfe_s_selection()
2003 vpfe_err(vpfe, "%s device busy\n", __func__); in vpfe_s_selection()
2023 s->r = vpfe->crop = r; in vpfe_s_selection()
2025 bpp = __get_bytesperpixel(vpfe, vpfe->current_vpfe_fmt); in vpfe_s_selection()
2026 vpfe_ccdc_set_image_window(&vpfe->ccdc, &r, bpp); in vpfe_s_selection()
2027 vpfe->fmt.fmt.pix.width = r.width; in vpfe_s_selection()
2028 vpfe->fmt.fmt.pix.height = r.height; in vpfe_s_selection()
2029 vpfe->fmt.fmt.pix.bytesperline = in vpfe_s_selection()
2030 vpfe_ccdc_get_line_length(&vpfe->ccdc); in vpfe_s_selection()
2031 vpfe->fmt.fmt.pix.sizeimage = vpfe->fmt.fmt.pix.bytesperline * in vpfe_s_selection()
2032 vpfe->fmt.fmt.pix.height; in vpfe_s_selection()
2034 vpfe_dbg(1, vpfe, "cropped (%d,%d)/%dx%d of %dx%d\n", in vpfe_s_selection()
2043 struct vpfe_device *vpfe = video_drvdata(file); in vpfe_ioctl_default() local
2047 vpfe_err(vpfe, "%s device busy\n", __func__); in vpfe_ioctl_default()
2052 if (vb2_is_busy(&vpfe->buffer_queue)) { in vpfe_ioctl_default()
2053 vpfe_err(vpfe, "%s device busy\n", __func__); in vpfe_ioctl_default()
2059 ret = vpfe_ccdc_set_params(&vpfe->ccdc, (void __user *)param); in vpfe_ioctl_default()
2061 vpfe_dbg(2, vpfe, in vpfe_ioctl_default()
2065 ret = vpfe_get_ccdc_image_format(vpfe, in vpfe_ioctl_default()
2066 &vpfe->fmt); in vpfe_ioctl_default()
2068 vpfe_dbg(2, vpfe, in vpfe_ioctl_default()
2147 struct vpfe_device *vpfe = container_of(notifier->v4l2_dev, in vpfe_async_bound() local
2156 for (i = 0; i < ARRAY_SIZE(vpfe->cfg->asd); i++) { in vpfe_async_bound()
2157 if (vpfe->cfg->asd[i]->match.fwnode == in vpfe_async_bound()
2159 sdinfo = &vpfe->cfg->sub_devs[i]; in vpfe_async_bound()
2160 vpfe->sd[i] = subdev; in vpfe_async_bound()
2161 vpfe->sd[i]->grp_id = sdinfo->grp_id; in vpfe_async_bound()
2168 vpfe_info(vpfe, "sub device (%s) not matched\n", subdev->name); in vpfe_async_bound()
2172 vpfe->video_dev.tvnorms |= sdinfo->inputs[0].std; in vpfe_async_bound()
2174 vpfe->num_active_fmt = 0; in vpfe_async_bound()
2184 vpfe_dbg(3, vpfe, in vpfe_async_bound()
2192 vpfe->active_fmt[i] = fmt; in vpfe_async_bound()
2193 vpfe_dbg(3, vpfe, in vpfe_async_bound()
2196 vpfe->num_active_fmt = ++i; in vpfe_async_bound()
2201 vpfe_err(vpfe, "No suitable format reported by subdev %s\n", in vpfe_async_bound()
2208 static int vpfe_probe_complete(struct vpfe_device *vpfe) in vpfe_probe_complete() argument
2214 spin_lock_init(&vpfe->dma_queue_lock); in vpfe_probe_complete()
2215 mutex_init(&vpfe->lock); in vpfe_probe_complete()
2217 vpfe->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in vpfe_probe_complete()
2220 vpfe->current_subdev = &vpfe->cfg->sub_devs[0]; in vpfe_probe_complete()
2221 vpfe->v4l2_dev.ctrl_handler = vpfe->sd[0]->ctrl_handler; in vpfe_probe_complete()
2223 err = vpfe_set_input(vpfe, 0); in vpfe_probe_complete()
2228 q = &vpfe->buffer_queue; in vpfe_probe_complete()
2231 q->drv_priv = vpfe; in vpfe_probe_complete()
2236 q->lock = &vpfe->lock; in vpfe_probe_complete()
2238 q->dev = vpfe->pdev; in vpfe_probe_complete()
2242 vpfe_err(vpfe, "vb2_queue_init() failed\n"); in vpfe_probe_complete()
2246 INIT_LIST_HEAD(&vpfe->dma_queue); in vpfe_probe_complete()
2248 vdev = &vpfe->video_dev; in vpfe_probe_complete()
2253 vdev->v4l2_dev = &vpfe->v4l2_dev; in vpfe_probe_complete()
2256 vdev->lock = &vpfe->lock; in vpfe_probe_complete()
2259 video_set_drvdata(vdev, vpfe); in vpfe_probe_complete()
2260 err = video_register_device(&vpfe->video_dev, VFL_TYPE_VIDEO, -1); in vpfe_probe_complete()
2262 vpfe_err(vpfe, in vpfe_probe_complete()
2270 v4l2_device_unregister(&vpfe->v4l2_dev); in vpfe_probe_complete()
2276 struct vpfe_device *vpfe = container_of(notifier->v4l2_dev, in vpfe_async_complete() local
2279 return vpfe_probe_complete(vpfe); in vpfe_async_complete()
2288 vpfe_get_pdata(struct vpfe_device *vpfe) in vpfe_get_pdata() argument
2291 struct device *dev = vpfe->pdev; in vpfe_get_pdata()
2300 v4l2_async_nf_init(&vpfe->notifier); in vpfe_get_pdata()
2368 pdata->asd[i] = v4l2_async_nf_add_fwnode(&vpfe->notifier, in vpfe_get_pdata()
2381 v4l2_async_nf_cleanup(&vpfe->notifier); in vpfe_get_pdata()
2394 struct vpfe_device *vpfe; in vpfe_probe() local
2398 vpfe = devm_kzalloc(&pdev->dev, sizeof(*vpfe), GFP_KERNEL); in vpfe_probe()
2399 if (!vpfe) in vpfe_probe()
2402 vpfe->pdev = &pdev->dev; in vpfe_probe()
2404 vpfe_cfg = vpfe_get_pdata(vpfe); in vpfe_probe()
2410 vpfe->cfg = vpfe_cfg; in vpfe_probe()
2411 ccdc = &vpfe->ccdc; in vpfe_probe()
2424 vpfe->irq = ret; in vpfe_probe()
2426 ret = devm_request_irq(vpfe->pdev, vpfe->irq, vpfe_isr, 0, in vpfe_probe()
2427 "vpfe_capture0", vpfe); in vpfe_probe()
2434 ret = v4l2_device_register(&pdev->dev, &vpfe->v4l2_dev); in vpfe_probe()
2436 vpfe_err(vpfe, in vpfe_probe()
2442 platform_set_drvdata(pdev, vpfe); in vpfe_probe()
2449 vpfe_err(vpfe, "Unable to resume device.\n"); in vpfe_probe()
2457 vpfe->sd = devm_kcalloc(&pdev->dev, in vpfe_probe()
2458 ARRAY_SIZE(vpfe->cfg->asd), in vpfe_probe()
2461 if (!vpfe->sd) { in vpfe_probe()
2466 vpfe->notifier.ops = &vpfe_async_ops; in vpfe_probe()
2467 ret = v4l2_async_nf_register(&vpfe->v4l2_dev, &vpfe->notifier); in vpfe_probe()
2469 vpfe_err(vpfe, "Error registering async notifier\n"); in vpfe_probe()
2477 v4l2_device_unregister(&vpfe->v4l2_dev); in vpfe_probe()
2479 v4l2_async_nf_cleanup(&vpfe->notifier); in vpfe_probe()
2488 struct vpfe_device *vpfe = platform_get_drvdata(pdev); in vpfe_remove() local
2492 v4l2_async_nf_unregister(&vpfe->notifier); in vpfe_remove()
2493 v4l2_async_nf_cleanup(&vpfe->notifier); in vpfe_remove()
2494 v4l2_device_unregister(&vpfe->v4l2_dev); in vpfe_remove()
2495 video_unregister_device(&vpfe->video_dev); in vpfe_remove()
2533 struct vpfe_device *vpfe = dev_get_drvdata(dev); in vpfe_suspend() local
2534 struct vpfe_ccdc *ccdc = &vpfe->ccdc; in vpfe_suspend()
2537 if (vb2_start_streaming_called(&vpfe->buffer_queue)) { in vpfe_suspend()
2594 struct vpfe_device *vpfe = dev_get_drvdata(dev); in vpfe_resume() local
2595 struct vpfe_ccdc *ccdc = &vpfe->ccdc; in vpfe_resume()
2598 if (vb2_start_streaming_called(&vpfe->buffer_queue)) { in vpfe_resume()