Lines Matching refs:fimc
33 static int fimc_capture_hw_init(struct fimc_dev *fimc) in fimc_capture_hw_init() argument
35 struct fimc_source_info *si = &fimc->vid_cap.source_config; in fimc_capture_hw_init()
36 struct fimc_ctx *ctx = fimc->vid_cap.ctx; in fimc_capture_hw_init()
44 ret = fimc_hw_camblk_cfg_writeback(fimc); in fimc_capture_hw_init()
49 spin_lock_irqsave(&fimc->slock, flags); in fimc_capture_hw_init()
53 fimc_hw_set_camera_polarity(fimc, si); in fimc_capture_hw_init()
54 fimc_hw_set_camera_type(fimc, si); in fimc_capture_hw_init()
55 fimc_hw_set_camera_source(fimc, si); in fimc_capture_hw_init()
56 fimc_hw_set_camera_offset(fimc, &ctx->s_frame); in fimc_capture_hw_init()
68 if (fimc->drv_data->alpha_color) in fimc_capture_hw_init()
70 clear_bit(ST_CAPT_APPLY_CFG, &fimc->state); in fimc_capture_hw_init()
72 spin_unlock_irqrestore(&fimc->slock, flags); in fimc_capture_hw_init()
84 static int fimc_capture_state_cleanup(struct fimc_dev *fimc, bool suspend) in fimc_capture_state_cleanup() argument
86 struct fimc_vid_cap *cap = &fimc->vid_cap; in fimc_capture_state_cleanup()
91 spin_lock_irqsave(&fimc->slock, flags); in fimc_capture_state_cleanup()
92 streaming = fimc->state & (1 << ST_CAPT_ISP_STREAM); in fimc_capture_state_cleanup()
94 fimc->state &= ~(1 << ST_CAPT_RUN | 1 << ST_CAPT_SHUT | in fimc_capture_state_cleanup()
97 fimc->state |= (1 << ST_CAPT_SUSPENDED); in fimc_capture_state_cleanup()
99 fimc->state &= ~(1 << ST_CAPT_PEND | 1 << ST_CAPT_SUSPENDED); in fimc_capture_state_cleanup()
115 fimc_hw_reset(fimc); in fimc_capture_state_cleanup()
118 spin_unlock_irqrestore(&fimc->slock, flags); in fimc_capture_state_cleanup()
126 static int fimc_stop_capture(struct fimc_dev *fimc, bool suspend) in fimc_stop_capture() argument
130 if (!fimc_capture_active(fimc)) in fimc_stop_capture()
133 spin_lock_irqsave(&fimc->slock, flags); in fimc_stop_capture()
134 set_bit(ST_CAPT_SHUT, &fimc->state); in fimc_stop_capture()
135 fimc_deactivate_capture(fimc); in fimc_stop_capture()
136 spin_unlock_irqrestore(&fimc->slock, flags); in fimc_stop_capture()
138 wait_event_timeout(fimc->irq_queue, in fimc_stop_capture()
139 !test_bit(ST_CAPT_SHUT, &fimc->state), in fimc_stop_capture()
142 return fimc_capture_state_cleanup(fimc, suspend); in fimc_stop_capture()
155 struct fimc_dev *fimc = ctx->fimc_dev; in fimc_capture_config_update() local
158 fimc_hw_set_camera_offset(fimc, &ctx->s_frame); in fimc_capture_config_update()
171 if (fimc->drv_data->alpha_color) in fimc_capture_config_update()
174 clear_bit(ST_CAPT_APPLY_CFG, &fimc->state); in fimc_capture_config_update()
178 void fimc_capture_irq_handler(struct fimc_dev *fimc, int deq_buf) in fimc_capture_irq_handler() argument
180 struct fimc_vid_cap *cap = &fimc->vid_cap; in fimc_capture_irq_handler()
186 if (test_and_clear_bit(ST_CAPT_SHUT, &fimc->state)) { in fimc_capture_irq_handler()
187 wake_up(&fimc->irq_queue); in fimc_capture_irq_handler()
192 test_bit(ST_CAPT_RUN, &fimc->state) && deq_buf) { in fimc_capture_irq_handler()
204 fimc_hw_set_output_addr(fimc, &v_buf->paddr, cap->buf_index); in fimc_capture_irq_handler()
211 fimc_hw_get_frame_index(fimc), v_buf->index); in fimc_capture_irq_handler()
223 s32 index = fimc_hw_get_frame_index(fimc); in fimc_capture_irq_handler()
238 clear_bit(ST_CAPT_RUN, &fimc->state); in fimc_capture_irq_handler()
243 set_bit(ST_CAPT_RUN, &fimc->state); in fimc_capture_irq_handler()
246 if (test_bit(ST_CAPT_APPLY_CFG, &fimc->state)) in fimc_capture_irq_handler()
250 fimc_deactivate_capture(fimc); in fimc_capture_irq_handler()
251 clear_bit(ST_CAPT_STREAM, &fimc->state); in fimc_capture_irq_handler()
255 fimc_hw_get_frame_index(fimc), cap->active_buf_cnt); in fimc_capture_irq_handler()
262 struct fimc_dev *fimc = ctx->fimc_dev; in start_streaming() local
263 struct fimc_vid_cap *vid_cap = &fimc->vid_cap; in start_streaming()
269 ret = fimc_capture_hw_init(fimc); in start_streaming()
271 fimc_capture_state_cleanup(fimc, false); in start_streaming()
275 set_bit(ST_CAPT_PEND, &fimc->state); in start_streaming()
277 min_bufs = fimc->vid_cap.reqbufs_count > 1 ? 2 : 1; in start_streaming()
280 !test_and_set_bit(ST_CAPT_STREAM, &fimc->state)) { in start_streaming()
283 if (!test_and_set_bit(ST_CAPT_ISP_STREAM, &fimc->state)) in start_streaming()
293 struct fimc_dev *fimc = ctx->fimc_dev; in stop_streaming() local
295 if (!fimc_capture_active(fimc)) in stop_streaming()
298 fimc_stop_capture(fimc, false); in stop_streaming()
301 int fimc_capture_suspend(struct fimc_dev *fimc) in fimc_capture_suspend() argument
303 bool suspend = fimc_capture_busy(fimc); in fimc_capture_suspend()
305 int ret = fimc_stop_capture(fimc, suspend); in fimc_capture_suspend()
308 return fimc_pipeline_call(&fimc->vid_cap.ve, close); in fimc_capture_suspend()
313 int fimc_capture_resume(struct fimc_dev *fimc) in fimc_capture_resume() argument
315 struct fimc_vid_cap *vid_cap = &fimc->vid_cap; in fimc_capture_resume()
320 if (!test_and_clear_bit(ST_CAPT_SUSPENDED, &fimc->state)) in fimc_capture_resume()
323 INIT_LIST_HEAD(&fimc->vid_cap.active_buf_q); in fimc_capture_resume()
326 fimc_capture_hw_init(fimc); in fimc_capture_resume()
328 clear_bit(ST_CAPT_SUSPENDED, &fimc->state); in fimc_capture_resume()
406 struct fimc_dev *fimc = ctx->fimc_dev; in buffer_queue() local
407 struct fimc_vid_cap *vid_cap = &fimc->vid_cap; in buffer_queue()
412 spin_lock_irqsave(&fimc->slock, flags); in buffer_queue()
415 if (!test_bit(ST_CAPT_SUSPENDED, &fimc->state) && in buffer_queue()
416 !test_bit(ST_CAPT_STREAM, &fimc->state) && in buffer_queue()
422 fimc_hw_set_output_addr(fimc, &buf->paddr, buf_id); in buffer_queue()
437 !test_and_set_bit(ST_CAPT_STREAM, &fimc->state)) { in buffer_queue()
441 spin_unlock_irqrestore(&fimc->slock, flags); in buffer_queue()
443 if (test_and_set_bit(ST_CAPT_ISP_STREAM, &fimc->state)) in buffer_queue()
451 spin_unlock_irqrestore(&fimc->slock, flags); in buffer_queue()
464 static int fimc_capture_set_default_format(struct fimc_dev *fimc);
468 struct fimc_dev *fimc = video_drvdata(file); in fimc_capture_open() local
469 struct fimc_vid_cap *vc = &fimc->vid_cap; in fimc_capture_open()
473 dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); in fimc_capture_open()
475 mutex_lock(&fimc->lock); in fimc_capture_open()
477 if (fimc_m2m_active(fimc)) in fimc_capture_open()
480 set_bit(ST_CAPT_BUSY, &fimc->state); in fimc_capture_open()
481 ret = pm_runtime_get_sync(&fimc->pdev->dev); in fimc_capture_open()
483 pm_runtime_put_sync(&fimc->pdev->dev); in fimc_capture_open()
489 pm_runtime_put_sync(&fimc->pdev->dev); in fimc_capture_open()
504 ret = fimc_capture_set_default_format(fimc); in fimc_capture_open()
507 clear_bit(ST_CAPT_BUSY, &fimc->state); in fimc_capture_open()
508 pm_runtime_put_sync(&fimc->pdev->dev); in fimc_capture_open()
513 mutex_unlock(&fimc->lock); in fimc_capture_open()
519 struct fimc_dev *fimc = video_drvdata(file); in fimc_capture_release() local
520 struct fimc_vid_cap *vc = &fimc->vid_cap; in fimc_capture_release()
524 dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); in fimc_capture_release()
526 mutex_lock(&fimc->lock); in fimc_capture_release()
536 clear_bit(ST_CAPT_BUSY, &fimc->state); in fimc_capture_release()
538 clear_bit(ST_CAPT_SUSPENDED, &fimc->state); in fimc_capture_release()
545 pm_runtime_put_sync(&fimc->pdev->dev); in fimc_capture_release()
546 mutex_unlock(&fimc->lock); in fimc_capture_release()
569 struct fimc_dev *fimc = ctx->fimc_dev; in fimc_capture_try_format() local
570 const struct fimc_variant *var = fimc->variant; in fimc_capture_try_format()
646 struct fimc_dev *fimc = ctx->fimc_dev; in fimc_capture_try_selection() local
647 const struct fimc_variant *var = fimc->variant; in fimc_capture_try_selection()
718 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_querycap() local
720 __fimc_vidioc_querycap(&fimc->pdev->dev, cap); in fimc_cap_querycap()
765 struct fimc_dev *fimc = ctx->fimc_dev; in fimc_pipeline_try_format() local
766 struct fimc_pipeline *p = to_fimc_pipeline(fimc->vid_cap.ve.pipe); in fimc_pipeline_try_format()
798 while (me != &fimc->vid_cap.subdev.entity) { in fimc_pipeline_try_format()
894 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_g_fmt_mplane() local
896 __fimc_get_format(&fimc->vid_cap.ctx->d_frame, f); in fimc_cap_g_fmt_mplane()
905 static int __video_try_or_set_format(struct fimc_dev *fimc, in __video_try_or_set_format() argument
911 struct fimc_vid_cap *vc = &fimc->vid_cap; in __video_try_or_set_format()
949 mf = try ? &mbus_fmt : &fimc->vid_cap.ci_fmt; in __video_try_or_set_format()
989 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_try_fmt_mplane() local
992 return __video_try_or_set_format(fimc, f, true, &inp_fmt, &out_fmt); in fimc_cap_try_fmt_mplane()
1009 static int __fimc_capture_set_format(struct fimc_dev *fimc, in __fimc_capture_set_format() argument
1012 struct fimc_vid_cap *vc = &fimc->vid_cap; in __fimc_capture_set_format()
1019 if (vb2_is_busy(&fimc->vid_cap.vbq)) in __fimc_capture_set_format()
1022 ret = __video_try_or_set_format(fimc, f, false, &inp_fmt, &ff->fmt); in __fimc_capture_set_format()
1054 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_s_fmt_mplane() local
1056 return __fimc_capture_set_format(fimc, f); in fimc_cap_s_fmt_mplane()
1062 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_enum_input() local
1063 struct exynos_video_entity *ve = &fimc->vid_cap.ve; in fimc_cap_enum_input()
1098 static int fimc_pipeline_validate(struct fimc_dev *fimc) in fimc_pipeline_validate() argument
1101 struct fimc_vid_cap *vc = &fimc->vid_cap; in fimc_pipeline_validate()
1179 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_streamon() local
1180 struct fimc_vid_cap *vc = &fimc->vid_cap; in fimc_cap_streamon()
1186 if (fimc_capture_active(fimc)) in fimc_cap_streamon()
1211 ret = fimc_pipeline_validate(fimc); in fimc_cap_streamon()
1230 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_streamoff() local
1231 struct fimc_vid_cap *vc = &fimc->vid_cap; in fimc_cap_streamoff()
1249 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_reqbufs() local
1255 fimc->vid_cap.reqbufs_count = reqbufs->count; in fimc_cap_reqbufs()
1263 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_g_selection() local
1264 struct fimc_ctx *ctx = fimc->vid_cap.ctx; in fimc_cap_g_selection()
1300 struct fimc_dev *fimc = video_drvdata(file); in fimc_cap_s_selection() local
1301 struct fimc_ctx *ctx = fimc->vid_cap.ctx; in fimc_cap_s_selection()
1327 spin_lock_irqsave(&fimc->slock, flags); in fimc_cap_s_selection()
1330 spin_unlock_irqrestore(&fimc->slock, flags); in fimc_cap_s_selection()
1332 set_bit(ST_CAPT_APPLY_CFG, &fimc->state); in fimc_cap_s_selection()
1369 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); in fimc_link_setup() local
1370 struct fimc_vid_cap *vc = &fimc->vid_cap; in fimc_link_setup()
1376 if (WARN_ON(fimc == NULL)) in fimc_link_setup()
1381 fimc->vid_cap.input); in fimc_link_setup()
1384 fimc->vid_cap.input = 0; in fimc_link_setup()
1428 struct fimc_dev *fimc; in fimc_sensor_notify() local
1439 fimc = si ? source_to_sensor_info(si)->host : NULL; in fimc_sensor_notify()
1441 if (fimc && arg && notification == S5P_FIMC_TX_END_NOTIFY && in fimc_sensor_notify()
1442 test_bit(ST_CAPT_PEND, &fimc->state)) { in fimc_sensor_notify()
1444 spin_lock_irqsave(&fimc->slock, irq_flags); in fimc_sensor_notify()
1445 if (!list_empty(&fimc->vid_cap.active_buf_q)) { in fimc_sensor_notify()
1446 buf = list_entry(fimc->vid_cap.active_buf_q.next, in fimc_sensor_notify()
1451 fimc_capture_irq_handler(fimc, 1); in fimc_sensor_notify()
1452 fimc_deactivate_capture(fimc); in fimc_sensor_notify()
1453 spin_unlock_irqrestore(&fimc->slock, irq_flags); in fimc_sensor_notify()
1475 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); in fimc_subdev_get_fmt() local
1476 struct fimc_ctx *ctx = fimc->vid_cap.ctx; in fimc_subdev_get_fmt()
1487 mutex_lock(&fimc->lock); in fimc_subdev_get_fmt()
1498 *mf = fimc->vid_cap.wb_fmt; in fimc_subdev_get_fmt()
1502 *mf = fimc->vid_cap.ci_fmt; in fimc_subdev_get_fmt()
1506 mutex_unlock(&fimc->lock); in fimc_subdev_get_fmt()
1516 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); in fimc_subdev_set_fmt() local
1518 struct fimc_vid_cap *vc = &fimc->vid_cap; in fimc_subdev_set_fmt()
1529 mutex_lock(&fimc->lock); in fimc_subdev_set_fmt()
1532 mutex_unlock(&fimc->lock); in fimc_subdev_set_fmt()
1557 mutex_lock(&fimc->lock); in fimc_subdev_set_fmt()
1574 mutex_unlock(&fimc->lock); in fimc_subdev_set_fmt()
1582 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); in fimc_subdev_get_selection() local
1583 struct fimc_ctx *ctx = fimc->vid_cap.ctx; in fimc_subdev_get_selection()
1591 mutex_lock(&fimc->lock); in fimc_subdev_get_selection()
1602 mutex_unlock(&fimc->lock); in fimc_subdev_get_selection()
1613 mutex_unlock(&fimc->lock); in fimc_subdev_get_selection()
1630 mutex_unlock(&fimc->lock); in fimc_subdev_get_selection()
1638 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); in fimc_subdev_set_selection() local
1639 struct fimc_ctx *ctx = fimc->vid_cap.ctx; in fimc_subdev_set_selection()
1648 mutex_lock(&fimc->lock); in fimc_subdev_set_selection()
1660 mutex_unlock(&fimc->lock); in fimc_subdev_set_selection()
1667 spin_lock_irqsave(&fimc->slock, flags); in fimc_subdev_set_selection()
1669 set_bit(ST_CAPT_APPLY_CFG, &fimc->state); in fimc_subdev_set_selection()
1672 spin_unlock_irqrestore(&fimc->slock, flags); in fimc_subdev_set_selection()
1678 mutex_unlock(&fimc->lock); in fimc_subdev_set_selection()
1695 static int fimc_capture_set_default_format(struct fimc_dev *fimc) in fimc_capture_set_default_format() argument
1708 return __fimc_capture_set_format(fimc, &fmt); in fimc_capture_set_default_format()
1712 static int fimc_register_capture_device(struct fimc_dev *fimc, in fimc_register_capture_device() argument
1715 struct video_device *vfd = &fimc->vid_cap.ve.vdev; in fimc_register_capture_device()
1716 struct vb2_queue *q = &fimc->vid_cap.vbq; in fimc_register_capture_device()
1726 ctx->fimc_dev = fimc; in fimc_register_capture_device()
1734 snprintf(vfd->name, sizeof(vfd->name), "fimc.%d.capture", fimc->id); in fimc_register_capture_device()
1742 vfd->lock = &fimc->lock; in fimc_register_capture_device()
1745 video_set_drvdata(vfd, fimc); in fimc_register_capture_device()
1746 vid_cap = &fimc->vid_cap; in fimc_register_capture_device()
1762 q->lock = &fimc->lock; in fimc_register_capture_device()
1763 q->dev = &fimc->pdev->dev; in fimc_register_capture_device()
1814 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); in fimc_capture_subdev_registered() local
1817 if (fimc == NULL) in fimc_capture_subdev_registered()
1820 ret = fimc_register_m2m_device(fimc, sd->v4l2_dev); in fimc_capture_subdev_registered()
1824 fimc->vid_cap.ve.pipe = v4l2_get_subdev_hostdata(sd); in fimc_capture_subdev_registered()
1826 ret = fimc_register_capture_device(fimc, sd->v4l2_dev); in fimc_capture_subdev_registered()
1828 fimc_unregister_m2m_device(fimc); in fimc_capture_subdev_registered()
1829 fimc->vid_cap.ve.pipe = NULL; in fimc_capture_subdev_registered()
1837 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); in fimc_capture_subdev_unregistered() local
1840 if (fimc == NULL) in fimc_capture_subdev_unregistered()
1843 mutex_lock(&fimc->lock); in fimc_capture_subdev_unregistered()
1845 fimc_unregister_m2m_device(fimc); in fimc_capture_subdev_unregistered()
1846 vdev = &fimc->vid_cap.ve.vdev; in fimc_capture_subdev_unregistered()
1851 fimc_ctrls_delete(fimc->vid_cap.ctx); in fimc_capture_subdev_unregistered()
1852 fimc->vid_cap.ve.pipe = NULL; in fimc_capture_subdev_unregistered()
1854 kfree(fimc->vid_cap.ctx); in fimc_capture_subdev_unregistered()
1855 fimc->vid_cap.ctx = NULL; in fimc_capture_subdev_unregistered()
1857 mutex_unlock(&fimc->lock); in fimc_capture_subdev_unregistered()
1865 int fimc_initialize_capture_subdev(struct fimc_dev *fimc) in fimc_initialize_capture_subdev() argument
1867 struct v4l2_subdev *sd = &fimc->vid_cap.subdev; in fimc_initialize_capture_subdev()
1872 snprintf(sd->name, sizeof(sd->name), "FIMC.%d", fimc->id); in fimc_initialize_capture_subdev()
1874 fimc->vid_cap.sd_pads[FIMC_SD_PAD_SINK_CAM].flags = MEDIA_PAD_FL_SINK; in fimc_initialize_capture_subdev()
1875 fimc->vid_cap.sd_pads[FIMC_SD_PAD_SINK_FIFO].flags = MEDIA_PAD_FL_SINK; in fimc_initialize_capture_subdev()
1876 fimc->vid_cap.sd_pads[FIMC_SD_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; in fimc_initialize_capture_subdev()
1878 fimc->vid_cap.sd_pads); in fimc_initialize_capture_subdev()
1885 v4l2_set_subdevdata(sd, fimc); in fimc_initialize_capture_subdev()
1889 void fimc_unregister_capture_subdev(struct fimc_dev *fimc) in fimc_unregister_capture_subdev() argument
1891 struct v4l2_subdev *sd = &fimc->vid_cap.subdev; in fimc_unregister_capture_subdev()