Lines Matching refs:ccdc

32 __ccdc_get_format(struct isp_ccdc_device *ccdc,
66 static void ccdc_print_status(struct isp_ccdc_device *ccdc) in ccdc_print_status() argument
68 struct isp_device *isp = to_isp_device(ccdc); in ccdc_print_status()
113 int omap3isp_ccdc_busy(struct isp_ccdc_device *ccdc) in omap3isp_ccdc_busy() argument
115 struct isp_device *isp = to_isp_device(ccdc); in omap3isp_ccdc_busy()
132 static int ccdc_lsc_validate_config(struct isp_ccdc_device *ccdc, in ccdc_lsc_validate_config() argument
135 struct isp_device *isp = to_isp_device(ccdc); in ccdc_lsc_validate_config()
162 format = __ccdc_get_format(ccdc, NULL, CCDC_PAD_SINK, in ccdc_lsc_validate_config()
196 static void ccdc_lsc_program_table(struct isp_ccdc_device *ccdc, in ccdc_lsc_program_table() argument
199 isp_reg_writel(to_isp_device(ccdc), addr, in ccdc_lsc_program_table()
207 static void ccdc_lsc_setup_regs(struct isp_ccdc_device *ccdc, in ccdc_lsc_setup_regs() argument
210 struct isp_device *isp = to_isp_device(ccdc); in ccdc_lsc_setup_regs()
231 static int ccdc_lsc_wait_prefetch(struct isp_ccdc_device *ccdc) in ccdc_lsc_wait_prefetch() argument
233 struct isp_device *isp = to_isp_device(ccdc); in ccdc_lsc_wait_prefetch()
260 static int __ccdc_lsc_enable(struct isp_ccdc_device *ccdc, int enable) in __ccdc_lsc_enable() argument
262 struct isp_device *isp = to_isp_device(ccdc); in __ccdc_lsc_enable()
264 __ccdc_get_format(ccdc, NULL, CCDC_PAD_SINK, in __ccdc_lsc_enable()
280 if (ccdc_lsc_wait_prefetch(ccdc) < 0) { in __ccdc_lsc_enable()
283 ccdc->lsc.state = LSC_STATE_STOPPED; in __ccdc_lsc_enable()
284 dev_warn(to_device(ccdc), "LSC prefetch timeout\n"); in __ccdc_lsc_enable()
287 ccdc->lsc.state = LSC_STATE_RUNNING; in __ccdc_lsc_enable()
289 ccdc->lsc.state = LSC_STATE_STOPPING; in __ccdc_lsc_enable()
295 static int ccdc_lsc_busy(struct isp_ccdc_device *ccdc) in ccdc_lsc_busy() argument
297 struct isp_device *isp = to_isp_device(ccdc); in ccdc_lsc_busy()
308 static int __ccdc_lsc_configure(struct isp_ccdc_device *ccdc, in __ccdc_lsc_configure() argument
314 if (ccdc_lsc_validate_config(ccdc, &req->config) < 0) { in __ccdc_lsc_configure()
315 dev_dbg(to_device(ccdc), "Discard LSC configuration\n"); in __ccdc_lsc_configure()
319 if (ccdc_lsc_busy(ccdc)) in __ccdc_lsc_configure()
322 ccdc_lsc_setup_regs(ccdc, &req->config); in __ccdc_lsc_configure()
323 ccdc_lsc_program_table(ccdc, req->table.dma); in __ccdc_lsc_configure()
333 static void ccdc_lsc_error_handler(struct isp_ccdc_device *ccdc) in ccdc_lsc_error_handler() argument
335 struct isp_device *isp = to_isp_device(ccdc); in ccdc_lsc_error_handler()
347 ccdc->lsc.state = LSC_STATE_STOPPED; in ccdc_lsc_error_handler()
350 static void ccdc_lsc_free_request(struct isp_ccdc_device *ccdc, in ccdc_lsc_free_request() argument
353 struct isp_device *isp = to_isp_device(ccdc); in ccdc_lsc_free_request()
367 static void ccdc_lsc_free_queue(struct isp_ccdc_device *ccdc, in ccdc_lsc_free_queue() argument
373 spin_lock_irqsave(&ccdc->lsc.req_lock, flags); in ccdc_lsc_free_queue()
376 spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); in ccdc_lsc_free_queue()
377 ccdc_lsc_free_request(ccdc, req); in ccdc_lsc_free_queue()
378 spin_lock_irqsave(&ccdc->lsc.req_lock, flags); in ccdc_lsc_free_queue()
380 spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); in ccdc_lsc_free_queue()
385 struct isp_ccdc_device *ccdc; in ccdc_lsc_free_table_work() local
389 ccdc = container_of(lsc, struct isp_ccdc_device, lsc); in ccdc_lsc_free_table_work()
391 ccdc_lsc_free_queue(ccdc, &lsc->free_queue); in ccdc_lsc_free_table_work()
401 static int ccdc_lsc_config(struct isp_ccdc_device *ccdc, in ccdc_lsc_config() argument
404 struct isp_device *isp = to_isp_device(ccdc); in ccdc_lsc_config()
416 dev_dbg(to_device(ccdc), in ccdc_lsc_config()
462 spin_lock_irqsave(&ccdc->lsc.req_lock, flags); in ccdc_lsc_config()
463 if (ccdc->lsc.request) { in ccdc_lsc_config()
464 list_add_tail(&ccdc->lsc.request->list, &ccdc->lsc.free_queue); in ccdc_lsc_config()
465 schedule_work(&ccdc->lsc.table_work); in ccdc_lsc_config()
467 ccdc->lsc.request = req; in ccdc_lsc_config()
468 spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); in ccdc_lsc_config()
474 ccdc_lsc_free_request(ccdc, req); in ccdc_lsc_config()
479 static inline int ccdc_lsc_is_configured(struct isp_ccdc_device *ccdc) in ccdc_lsc_is_configured() argument
484 spin_lock_irqsave(&ccdc->lsc.req_lock, flags); in ccdc_lsc_is_configured()
485 ret = ccdc->lsc.active != NULL; in ccdc_lsc_is_configured()
486 spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); in ccdc_lsc_is_configured()
491 static int ccdc_lsc_enable(struct isp_ccdc_device *ccdc) in ccdc_lsc_enable() argument
493 struct ispccdc_lsc *lsc = &ccdc->lsc; in ccdc_lsc_enable()
503 if (__ccdc_lsc_configure(ccdc, lsc->request) < 0) { in ccdc_lsc_enable()
504 omap3isp_sbl_disable(to_isp_device(ccdc), in ccdc_lsc_enable()
513 __ccdc_lsc_enable(ccdc, 1); in ccdc_lsc_enable()
533 static void ccdc_configure_clamp(struct isp_ccdc_device *ccdc) in ccdc_configure_clamp() argument
535 struct isp_device *isp = to_isp_device(ccdc); in ccdc_configure_clamp()
538 if (ccdc->obclamp) { in ccdc_configure_clamp()
539 clamp = ccdc->clamp.obgain << ISPCCDC_CLAMP_OBGAIN_SHIFT; in ccdc_configure_clamp()
540 clamp |= ccdc->clamp.oblen << ISPCCDC_CLAMP_OBSLEN_SHIFT; in ccdc_configure_clamp()
541 clamp |= ccdc->clamp.oblines << ISPCCDC_CLAMP_OBSLN_SHIFT; in ccdc_configure_clamp()
542 clamp |= ccdc->clamp.obstpixel << ISPCCDC_CLAMP_OBST_SHIFT; in ccdc_configure_clamp()
545 isp_reg_writel(isp, ccdc->clamp.dcsubval, in ccdc_configure_clamp()
551 ccdc->obclamp ? ISPCCDC_CLAMP_CLAMPEN : 0); in ccdc_configure_clamp()
558 static void ccdc_configure_fpc(struct isp_ccdc_device *ccdc) in ccdc_configure_fpc() argument
560 struct isp_device *isp = to_isp_device(ccdc); in ccdc_configure_fpc()
564 if (!ccdc->fpc_en) in ccdc_configure_fpc()
567 isp_reg_writel(isp, ccdc->fpc.dma, OMAP3_ISP_IOMEM_CCDC, in ccdc_configure_fpc()
570 isp_reg_writel(isp, (ccdc->fpc.fpnum << ISPCCDC_FPC_FPNUM_SHIFT), in ccdc_configure_fpc()
572 isp_reg_writel(isp, (ccdc->fpc.fpnum << ISPCCDC_FPC_FPNUM_SHIFT) | in ccdc_configure_fpc()
580 static void ccdc_configure_black_comp(struct isp_ccdc_device *ccdc) in ccdc_configure_black_comp() argument
582 struct isp_device *isp = to_isp_device(ccdc); in ccdc_configure_black_comp()
585 blcomp = ccdc->blcomp.b_mg << ISPCCDC_BLKCMP_B_MG_SHIFT; in ccdc_configure_black_comp()
586 blcomp |= ccdc->blcomp.gb_g << ISPCCDC_BLKCMP_GB_G_SHIFT; in ccdc_configure_black_comp()
587 blcomp |= ccdc->blcomp.gr_cy << ISPCCDC_BLKCMP_GR_CY_SHIFT; in ccdc_configure_black_comp()
588 blcomp |= ccdc->blcomp.r_ye << ISPCCDC_BLKCMP_R_YE_SHIFT; in ccdc_configure_black_comp()
597 static void ccdc_configure_lpf(struct isp_ccdc_device *ccdc) in ccdc_configure_lpf() argument
599 struct isp_device *isp = to_isp_device(ccdc); in ccdc_configure_lpf()
603 ccdc->lpf ? ISPCCDC_SYN_MODE_LPF : 0); in ccdc_configure_lpf()
610 static void ccdc_configure_alaw(struct isp_ccdc_device *ccdc) in ccdc_configure_alaw() argument
612 struct isp_device *isp = to_isp_device(ccdc); in ccdc_configure_alaw()
616 info = omap3isp_video_format_info(ccdc->formats[CCDC_PAD_SINK].code); in ccdc_configure_alaw()
636 if (ccdc->alaw) in ccdc_configure_alaw()
647 static void ccdc_config_imgattr(struct isp_ccdc_device *ccdc, u32 colptn) in ccdc_config_imgattr() argument
649 struct isp_device *isp = to_isp_device(ccdc); in ccdc_config_imgattr()
663 static int ccdc_config(struct isp_ccdc_device *ccdc, in ccdc_config() argument
666 struct isp_device *isp = to_isp_device(ccdc); in ccdc_config()
669 spin_lock_irqsave(&ccdc->lock, flags); in ccdc_config()
670 ccdc->shadow_update = 1; in ccdc_config()
671 spin_unlock_irqrestore(&ccdc->lock, flags); in ccdc_config()
674 ccdc->alaw = !!(OMAP3ISP_CCDC_ALAW & ccdc_struct->flag); in ccdc_config()
675 ccdc->update |= OMAP3ISP_CCDC_ALAW; in ccdc_config()
679 ccdc->lpf = !!(OMAP3ISP_CCDC_LPF & ccdc_struct->flag); in ccdc_config()
680 ccdc->update |= OMAP3ISP_CCDC_LPF; in ccdc_config()
684 if (copy_from_user(&ccdc->clamp, ccdc_struct->bclamp, in ccdc_config()
685 sizeof(ccdc->clamp))) { in ccdc_config()
686 ccdc->shadow_update = 0; in ccdc_config()
690 ccdc->obclamp = !!(OMAP3ISP_CCDC_BLCLAMP & ccdc_struct->flag); in ccdc_config()
691 ccdc->update |= OMAP3ISP_CCDC_BLCLAMP; in ccdc_config()
695 if (copy_from_user(&ccdc->blcomp, ccdc_struct->blcomp, in ccdc_config()
696 sizeof(ccdc->blcomp))) { in ccdc_config()
697 ccdc->shadow_update = 0; in ccdc_config()
701 ccdc->update |= OMAP3ISP_CCDC_BCOMP; in ccdc_config()
704 ccdc->shadow_update = 0; in ccdc_config()
712 if (ccdc->state != ISP_PIPELINE_STREAM_STOPPED) in ccdc_config()
715 ccdc->fpc_en = !!(OMAP3ISP_CCDC_FPC & ccdc_struct->flag); in ccdc_config()
717 if (ccdc->fpc_en) { in ccdc_config()
742 fpc_old = ccdc->fpc; in ccdc_config()
743 ccdc->fpc = fpc_new; in ccdc_config()
746 ccdc_configure_fpc(ccdc); in ccdc_config()
753 return ccdc_lsc_config(ccdc, ccdc_struct); in ccdc_config()
756 static void ccdc_apply_controls(struct isp_ccdc_device *ccdc) in ccdc_apply_controls() argument
758 if (ccdc->update & OMAP3ISP_CCDC_ALAW) { in ccdc_apply_controls()
759 ccdc_configure_alaw(ccdc); in ccdc_apply_controls()
760 ccdc->update &= ~OMAP3ISP_CCDC_ALAW; in ccdc_apply_controls()
763 if (ccdc->update & OMAP3ISP_CCDC_LPF) { in ccdc_apply_controls()
764 ccdc_configure_lpf(ccdc); in ccdc_apply_controls()
765 ccdc->update &= ~OMAP3ISP_CCDC_LPF; in ccdc_apply_controls()
768 if (ccdc->update & OMAP3ISP_CCDC_BLCLAMP) { in ccdc_apply_controls()
769 ccdc_configure_clamp(ccdc); in ccdc_apply_controls()
770 ccdc->update &= ~OMAP3ISP_CCDC_BLCLAMP; in ccdc_apply_controls()
773 if (ccdc->update & OMAP3ISP_CCDC_BCOMP) { in ccdc_apply_controls()
774 ccdc_configure_black_comp(ccdc); in ccdc_apply_controls()
775 ccdc->update &= ~OMAP3ISP_CCDC_BCOMP; in ccdc_apply_controls()
785 struct isp_ccdc_device *ccdc = &isp->isp_ccdc; in omap3isp_ccdc_restore_context() local
789 ccdc->update = OMAP3ISP_CCDC_ALAW | OMAP3ISP_CCDC_LPF in omap3isp_ccdc_restore_context()
791 ccdc_apply_controls(ccdc); in omap3isp_ccdc_restore_context()
792 ccdc_configure_fpc(ccdc); in omap3isp_ccdc_restore_context()
803 static void ccdc_config_vp(struct isp_ccdc_device *ccdc) in ccdc_config_vp() argument
805 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity); in ccdc_config_vp()
806 struct isp_device *isp = to_isp_device(ccdc); in ccdc_config_vp()
814 format = &ccdc->formats[CCDC_PAD_SOURCE_VP]; in ccdc_config_vp()
835 info = omap3isp_video_format_info(ccdc->formats[CCDC_PAD_SINK].code); in ccdc_config_vp()
884 static void ccdc_config_outlineoffset(struct isp_ccdc_device *ccdc, in ccdc_config_outlineoffset() argument
888 struct isp_device *isp = to_isp_device(ccdc); in ccdc_config_outlineoffset()
921 static void ccdc_set_outaddr(struct isp_ccdc_device *ccdc, u32 addr) in ccdc_set_outaddr() argument
923 struct isp_device *isp = to_isp_device(ccdc); in ccdc_set_outaddr()
935 void omap3isp_ccdc_max_rate(struct isp_ccdc_device *ccdc, in omap3isp_ccdc_max_rate() argument
938 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity); in omap3isp_ccdc_max_rate()
948 if (ccdc->input == CCDC_INPUT_PARALLEL) in omap3isp_ccdc_max_rate()
962 static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc, in ccdc_config_sync_if() argument
966 struct isp_device *isp = to_isp_device(ccdc); in ccdc_config_sync_if()
970 format = &ccdc->formats[CCDC_PAD_SINK]; in ccdc_config_sync_if()
980 if (ccdc->bt656) in ccdc_config_sync_if()
1010 if ((parcfg && parcfg->vs_pol) || ccdc->bt656) in ccdc_config_sync_if()
1031 if (ccdc->bt656) in ccdc_config_sync_if()
1113 static void ccdc_configure(struct isp_ccdc_device *ccdc) in ccdc_configure() argument
1115 struct isp_device *isp = to_isp_device(ccdc); in ccdc_configure()
1135 ccdc->bt656 = false; in ccdc_configure()
1136 ccdc->fields = 0; in ccdc_configure()
1138 pad = media_pad_remote_pad_first(&ccdc->pads[CCDC_PAD_SINK]); in ccdc_configure()
1140 if (ccdc->input == CCDC_INPUT_PARALLEL) { in ccdc_configure()
1142 to_isp_pipeline(&ccdc->subdev.entity)->external; in ccdc_configure()
1150 ccdc->bt656 = parcfg->bt656; in ccdc_configure()
1154 format = &ccdc->formats[CCDC_PAD_SINK]; in ccdc_configure()
1169 if (ccdc->bt656) in ccdc_configure()
1178 omap3isp_configure_bridge(isp, ccdc->input, parcfg, shift, bridge); in ccdc_configure()
1181 ccdc_config_sync_if(ccdc, parcfg, depth_out); in ccdc_configure()
1190 if (ccdc->output & CCDC_OUTPUT_MEMORY) in ccdc_configure()
1195 if (ccdc->output & CCDC_OUTPUT_RESIZER) in ccdc_configure()
1219 ccdc_config_imgattr(ccdc, ccdc_pattern); in ccdc_configure()
1229 format = &ccdc->formats[CCDC_PAD_SOURCE_OF]; in ccdc_configure()
1230 crop = &ccdc->crop; in ccdc_configure()
1237 if (ccdc->bt656) { in ccdc_configure()
1255 ccdc_config_outlineoffset(ccdc, ccdc->video_out.bpl_value, in ccdc_configure()
1262 if (ccdc->formats[CCDC_PAD_SINK].field == V4L2_FIELD_ALTERNATE && in ccdc_configure()
1281 if (omap3isp_video_format_info(format->code)->width <= 8 || ccdc->bt656) in ccdc_configure()
1289 ccdc_config_vp(ccdc); in ccdc_configure()
1292 spin_lock_irqsave(&ccdc->lsc.req_lock, flags); in ccdc_configure()
1293 if (ccdc->lsc.request == NULL) in ccdc_configure()
1296 WARN_ON(ccdc->lsc.active); in ccdc_configure()
1301 if (ccdc->lsc.active == NULL && in ccdc_configure()
1302 __ccdc_lsc_configure(ccdc, ccdc->lsc.request) == 0) { in ccdc_configure()
1303 ccdc->lsc.active = ccdc->lsc.request; in ccdc_configure()
1305 list_add_tail(&ccdc->lsc.request->list, &ccdc->lsc.free_queue); in ccdc_configure()
1306 schedule_work(&ccdc->lsc.table_work); in ccdc_configure()
1309 ccdc->lsc.request = NULL; in ccdc_configure()
1312 spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); in ccdc_configure()
1314 ccdc_apply_controls(ccdc); in ccdc_configure()
1317 static void __ccdc_enable(struct isp_ccdc_device *ccdc, int enable) in __ccdc_enable() argument
1319 struct isp_device *isp = to_isp_device(ccdc); in __ccdc_enable()
1322 if (enable && ccdc->stopping & CCDC_STOP_REQUEST) in __ccdc_enable()
1328 ccdc->running = enable; in __ccdc_enable()
1331 static int ccdc_disable(struct isp_ccdc_device *ccdc) in ccdc_disable() argument
1336 spin_lock_irqsave(&ccdc->lock, flags); in ccdc_disable()
1337 if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS) in ccdc_disable()
1338 ccdc->stopping = CCDC_STOP_REQUEST; in ccdc_disable()
1339 if (!ccdc->running) in ccdc_disable()
1340 ccdc->stopping = CCDC_STOP_FINISHED; in ccdc_disable()
1341 spin_unlock_irqrestore(&ccdc->lock, flags); in ccdc_disable()
1343 ret = wait_event_timeout(ccdc->wait, in ccdc_disable()
1344 ccdc->stopping == CCDC_STOP_FINISHED, in ccdc_disable()
1348 dev_warn(to_device(ccdc), "CCDC stop timeout!\n"); in ccdc_disable()
1351 omap3isp_sbl_disable(to_isp_device(ccdc), OMAP3_ISP_SBL_CCDC_LSC_READ); in ccdc_disable()
1353 mutex_lock(&ccdc->ioctl_lock); in ccdc_disable()
1354 ccdc_lsc_free_request(ccdc, ccdc->lsc.request); in ccdc_disable()
1355 ccdc->lsc.request = ccdc->lsc.active; in ccdc_disable()
1356 ccdc->lsc.active = NULL; in ccdc_disable()
1357 cancel_work_sync(&ccdc->lsc.table_work); in ccdc_disable()
1358 ccdc_lsc_free_queue(ccdc, &ccdc->lsc.free_queue); in ccdc_disable()
1359 mutex_unlock(&ccdc->ioctl_lock); in ccdc_disable()
1361 ccdc->stopping = CCDC_STOP_NOT_REQUESTED; in ccdc_disable()
1366 static void ccdc_enable(struct isp_ccdc_device *ccdc) in ccdc_enable() argument
1368 if (ccdc_lsc_is_configured(ccdc)) in ccdc_enable()
1369 __ccdc_lsc_enable(ccdc, 1); in ccdc_enable()
1370 __ccdc_enable(ccdc, 1); in ccdc_enable()
1384 static int ccdc_sbl_busy(struct isp_ccdc_device *ccdc) in ccdc_sbl_busy() argument
1386 struct isp_device *isp = to_isp_device(ccdc); in ccdc_sbl_busy()
1388 return omap3isp_ccdc_busy(ccdc) in ccdc_sbl_busy()
1404 static int ccdc_sbl_wait_idle(struct isp_ccdc_device *ccdc, in ccdc_sbl_wait_idle() argument
1413 if (!ccdc_sbl_busy(ccdc)) in ccdc_sbl_wait_idle()
1430 static int ccdc_handle_stopping(struct isp_ccdc_device *ccdc, u32 event) in ccdc_handle_stopping() argument
1434 switch ((ccdc->stopping & 3) | event) { in ccdc_handle_stopping()
1436 if (ccdc->lsc.state != LSC_STATE_STOPPED) in ccdc_handle_stopping()
1437 __ccdc_lsc_enable(ccdc, 0); in ccdc_handle_stopping()
1438 __ccdc_enable(ccdc, 0); in ccdc_handle_stopping()
1439 ccdc->stopping = CCDC_STOP_EXECUTED; in ccdc_handle_stopping()
1443 ccdc->stopping |= CCDC_STOP_CCDC_FINISHED; in ccdc_handle_stopping()
1444 if (ccdc->lsc.state == LSC_STATE_STOPPED) in ccdc_handle_stopping()
1445 ccdc->stopping |= CCDC_STOP_LSC_FINISHED; in ccdc_handle_stopping()
1450 ccdc->stopping |= CCDC_STOP_LSC_FINISHED; in ccdc_handle_stopping()
1458 if (ccdc->stopping == CCDC_STOP_FINISHED) { in ccdc_handle_stopping()
1459 wake_up(&ccdc->wait); in ccdc_handle_stopping()
1466 static void ccdc_hs_vs_isr(struct isp_ccdc_device *ccdc) in ccdc_hs_vs_isr() argument
1468 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity); in ccdc_hs_vs_isr()
1469 struct video_device *vdev = ccdc->subdev.devnode; in ccdc_hs_vs_isr()
1487 static void ccdc_lsc_isr(struct isp_ccdc_device *ccdc, u32 events) in ccdc_lsc_isr() argument
1493 to_isp_pipeline(&ccdc->subdev.entity); in ccdc_lsc_isr()
1495 ccdc_lsc_error_handler(ccdc); in ccdc_lsc_isr()
1497 dev_dbg(to_device(ccdc), "lsc prefetch error\n"); in ccdc_lsc_isr()
1507 spin_lock_irqsave(&ccdc->lsc.req_lock, flags); in ccdc_lsc_isr()
1509 if (ccdc->lsc.state == LSC_STATE_STOPPING) in ccdc_lsc_isr()
1510 ccdc->lsc.state = LSC_STATE_STOPPED; in ccdc_lsc_isr()
1512 if (ccdc_handle_stopping(ccdc, CCDC_EVENT_LSC_DONE)) in ccdc_lsc_isr()
1515 if (ccdc->lsc.state != LSC_STATE_RECONFIG) in ccdc_lsc_isr()
1519 ccdc->lsc.state = LSC_STATE_STOPPED; in ccdc_lsc_isr()
1531 if (ccdc->lsc.request == NULL) in ccdc_lsc_isr()
1534 ccdc_lsc_enable(ccdc); in ccdc_lsc_isr()
1537 spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); in ccdc_lsc_isr()
1544 static bool ccdc_has_all_fields(struct isp_ccdc_device *ccdc) in ccdc_has_all_fields() argument
1546 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity); in ccdc_has_all_fields()
1547 struct isp_device *isp = to_isp_device(ccdc); in ccdc_has_all_fields()
1548 enum v4l2_field of_field = ccdc->formats[CCDC_PAD_SOURCE_OF].field; in ccdc_has_all_fields()
1569 ccdc->fields |= field == V4L2_FIELD_BOTTOM in ccdc_has_all_fields()
1572 if (ccdc->fields != CCDC_FIELD_BOTH) in ccdc_has_all_fields()
1583 ccdc->fields = 0; in ccdc_has_all_fields()
1588 static int ccdc_isr_buffer(struct isp_ccdc_device *ccdc) in ccdc_isr_buffer() argument
1590 struct isp_pipeline *pipe = to_isp_pipeline(&ccdc->subdev.entity); in ccdc_isr_buffer()
1591 struct isp_device *isp = to_isp_device(ccdc); in ccdc_isr_buffer()
1600 if (list_empty(&ccdc->video_out.dmaqueue)) in ccdc_isr_buffer()
1607 if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS && ccdc->underrun) { in ccdc_isr_buffer()
1608 ccdc->underrun = 0; in ccdc_isr_buffer()
1613 if (ccdc_sbl_wait_idle(ccdc, 1000)) { in ccdc_isr_buffer()
1615 media_entity_enum_set(&isp->crashed, &ccdc->subdev.entity); in ccdc_isr_buffer()
1621 if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS && in ccdc_isr_buffer()
1622 ccdc->stopping & CCDC_STOP_REQUEST) in ccdc_isr_buffer()
1625 if (!ccdc_has_all_fields(ccdc)) in ccdc_isr_buffer()
1628 buffer = omap3isp_video_buffer_next(&ccdc->video_out); in ccdc_isr_buffer()
1630 ccdc_set_outaddr(ccdc, buffer->dma); in ccdc_isr_buffer()
1634 if (ccdc->state == ISP_PIPELINE_STREAM_SINGLESHOT && in ccdc_isr_buffer()
1648 static void ccdc_vd0_isr(struct isp_ccdc_device *ccdc) in ccdc_vd0_isr() argument
1656 if (ccdc->bt656) { in ccdc_vd0_isr()
1658 to_isp_pipeline(&ccdc->subdev.entity); in ccdc_vd0_isr()
1667 if (ccdc->bt656) { in ccdc_vd0_isr()
1668 spin_lock_irqsave(&ccdc->lock, flags); in ccdc_vd0_isr()
1669 if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS && in ccdc_vd0_isr()
1670 ccdc->output & CCDC_OUTPUT_MEMORY) { in ccdc_vd0_isr()
1671 if (ccdc->lsc.state != LSC_STATE_STOPPED) in ccdc_vd0_isr()
1672 __ccdc_lsc_enable(ccdc, 0); in ccdc_vd0_isr()
1673 __ccdc_enable(ccdc, 0); in ccdc_vd0_isr()
1675 ccdc_handle_stopping(ccdc, CCDC_EVENT_VD1); in ccdc_vd0_isr()
1676 spin_unlock_irqrestore(&ccdc->lock, flags); in ccdc_vd0_isr()
1679 spin_lock_irqsave(&ccdc->lock, flags); in ccdc_vd0_isr()
1680 if (ccdc_handle_stopping(ccdc, CCDC_EVENT_VD0)) { in ccdc_vd0_isr()
1681 spin_unlock_irqrestore(&ccdc->lock, flags); in ccdc_vd0_isr()
1685 if (ccdc->output & CCDC_OUTPUT_MEMORY) in ccdc_vd0_isr()
1686 restart = ccdc_isr_buffer(ccdc); in ccdc_vd0_isr()
1688 if (!ccdc->shadow_update) in ccdc_vd0_isr()
1689 ccdc_apply_controls(ccdc); in ccdc_vd0_isr()
1690 spin_unlock_irqrestore(&ccdc->lock, flags); in ccdc_vd0_isr()
1693 ccdc_enable(ccdc); in ccdc_vd0_isr()
1700 static void ccdc_vd1_isr(struct isp_ccdc_device *ccdc) in ccdc_vd1_isr() argument
1713 if (ccdc->bt656) in ccdc_vd1_isr()
1716 spin_lock_irqsave(&ccdc->lsc.req_lock, flags); in ccdc_vd1_isr()
1728 switch (ccdc->state) { in ccdc_vd1_isr()
1730 ccdc->stopping = CCDC_STOP_REQUEST; in ccdc_vd1_isr()
1734 if (ccdc->output & CCDC_OUTPUT_MEMORY) { in ccdc_vd1_isr()
1735 if (ccdc->lsc.state != LSC_STATE_STOPPED) in ccdc_vd1_isr()
1736 __ccdc_lsc_enable(ccdc, 0); in ccdc_vd1_isr()
1737 __ccdc_enable(ccdc, 0); in ccdc_vd1_isr()
1745 if (ccdc_handle_stopping(ccdc, CCDC_EVENT_VD1)) in ccdc_vd1_isr()
1748 if (ccdc->lsc.request == NULL) in ccdc_vd1_isr()
1755 if (ccdc->lsc.state == LSC_STATE_RUNNING) { in ccdc_vd1_isr()
1756 __ccdc_lsc_enable(ccdc, 0); in ccdc_vd1_isr()
1757 ccdc->lsc.state = LSC_STATE_RECONFIG; in ccdc_vd1_isr()
1762 if (ccdc->lsc.state == LSC_STATE_STOPPED) in ccdc_vd1_isr()
1763 ccdc_lsc_enable(ccdc); in ccdc_vd1_isr()
1766 spin_unlock_irqrestore(&ccdc->lsc.req_lock, flags); in ccdc_vd1_isr()
1774 int omap3isp_ccdc_isr(struct isp_ccdc_device *ccdc, u32 events) in omap3isp_ccdc_isr() argument
1776 if (ccdc->state == ISP_PIPELINE_STREAM_STOPPED) in omap3isp_ccdc_isr()
1780 ccdc_vd1_isr(ccdc); in omap3isp_ccdc_isr()
1782 ccdc_lsc_isr(ccdc, events); in omap3isp_ccdc_isr()
1785 ccdc_vd0_isr(ccdc); in omap3isp_ccdc_isr()
1788 ccdc_hs_vs_isr(ccdc); in omap3isp_ccdc_isr()
1799 struct isp_ccdc_device *ccdc = &video->isp->isp_ccdc; in ccdc_video_queue() local
1803 if (!(ccdc->output & CCDC_OUTPUT_MEMORY)) in ccdc_video_queue()
1806 ccdc_set_outaddr(ccdc, buffer->dma); in ccdc_video_queue()
1814 spin_lock_irqsave(&ccdc->lock, flags); in ccdc_video_queue()
1815 if (ccdc->state == ISP_PIPELINE_STREAM_CONTINUOUS && !ccdc->running && in ccdc_video_queue()
1816 ccdc->bt656) in ccdc_video_queue()
1819 ccdc->underrun = 1; in ccdc_video_queue()
1820 spin_unlock_irqrestore(&ccdc->lock, flags); in ccdc_video_queue()
1823 ccdc_enable(ccdc); in ccdc_video_queue()
1846 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_ioctl() local
1851 mutex_lock(&ccdc->ioctl_lock); in ccdc_ioctl()
1852 ret = ccdc_config(ccdc, arg); in ccdc_ioctl()
1853 mutex_unlock(&ccdc->ioctl_lock); in ccdc_ioctl()
1896 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_set_stream() local
1897 struct isp_device *isp = to_isp_device(ccdc); in ccdc_set_stream()
1900 if (ccdc->state == ISP_PIPELINE_STREAM_STOPPED) { in ccdc_set_stream()
1908 ccdc_configure(ccdc); in ccdc_set_stream()
1910 ccdc_print_status(ccdc); in ccdc_set_stream()
1915 if (ccdc->output & CCDC_OUTPUT_MEMORY) in ccdc_set_stream()
1918 if (ccdc->underrun || !(ccdc->output & CCDC_OUTPUT_MEMORY)) in ccdc_set_stream()
1919 ccdc_enable(ccdc); in ccdc_set_stream()
1921 ccdc->underrun = 0; in ccdc_set_stream()
1925 if (ccdc->output & CCDC_OUTPUT_MEMORY && in ccdc_set_stream()
1926 ccdc->state != ISP_PIPELINE_STREAM_SINGLESHOT) in ccdc_set_stream()
1929 ccdc_enable(ccdc); in ccdc_set_stream()
1933 ret = ccdc_disable(ccdc); in ccdc_set_stream()
1934 if (ccdc->output & CCDC_OUTPUT_MEMORY) in ccdc_set_stream()
1937 ccdc->underrun = 0; in ccdc_set_stream()
1941 ccdc->state = enable; in ccdc_set_stream()
1946 __ccdc_get_format(struct isp_ccdc_device *ccdc, in __ccdc_get_format() argument
1953 return &ccdc->formats[pad]; in __ccdc_get_format()
1957 __ccdc_get_crop(struct isp_ccdc_device *ccdc, in __ccdc_get_crop() argument
1965 return &ccdc->crop; in __ccdc_get_crop()
1976 ccdc_try_format(struct isp_ccdc_device *ccdc, in ccdc_try_format() argument
2013 *fmt = *__ccdc_get_format(ccdc, sd_state, CCDC_PAD_SINK, in ccdc_try_format()
2039 crop = __ccdc_get_crop(ccdc, sd_state, which); in ccdc_try_format()
2056 *fmt = *__ccdc_get_format(ccdc, sd_state, CCDC_PAD_SINK, in ccdc_try_format()
2089 static void ccdc_try_crop(struct isp_ccdc_device *ccdc, in ccdc_try_crop() argument
2137 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_enum_mbus_code() local
2149 format = __ccdc_get_format(ccdc, sd_state, code->pad, in ccdc_enum_mbus_code()
2180 format = __ccdc_get_format(ccdc, sd_state, code->pad, in ccdc_enum_mbus_code()
2203 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_enum_frame_size() local
2212 ccdc_try_format(ccdc, sd_state, fse->pad, &format, fse->which); in ccdc_enum_frame_size()
2222 ccdc_try_format(ccdc, sd_state, fse->pad, &format, fse->which); in ccdc_enum_frame_size()
2244 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_get_selection() local
2257 format = __ccdc_get_format(ccdc, sd_state, CCDC_PAD_SINK, in ccdc_get_selection()
2259 ccdc_try_crop(ccdc, format, &sel->r); in ccdc_get_selection()
2263 sel->r = *__ccdc_get_crop(ccdc, sd_state, sel->which); in ccdc_get_selection()
2288 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_set_selection() local
2296 if (ccdc->state != ISP_PIPELINE_STREAM_STOPPED) in ccdc_set_selection()
2304 sel->r = *__ccdc_get_crop(ccdc, sd_state, sel->which); in ccdc_set_selection()
2308 format = __ccdc_get_format(ccdc, sd_state, CCDC_PAD_SINK, sel->which); in ccdc_set_selection()
2309 ccdc_try_crop(ccdc, format, &sel->r); in ccdc_set_selection()
2310 *__ccdc_get_crop(ccdc, sd_state, sel->which) = sel->r; in ccdc_set_selection()
2313 format = __ccdc_get_format(ccdc, sd_state, CCDC_PAD_SOURCE_OF, in ccdc_set_selection()
2315 ccdc_try_format(ccdc, sd_state, CCDC_PAD_SOURCE_OF, format, in ccdc_set_selection()
2334 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_get_format() local
2337 format = __ccdc_get_format(ccdc, sd_state, fmt->pad, fmt->which); in ccdc_get_format()
2358 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_set_format() local
2362 format = __ccdc_get_format(ccdc, sd_state, fmt->pad, fmt->which); in ccdc_set_format()
2366 ccdc_try_format(ccdc, sd_state, fmt->pad, &fmt->format, fmt->which); in ccdc_set_format()
2372 crop = __ccdc_get_crop(ccdc, sd_state, fmt->which); in ccdc_set_format()
2378 ccdc_try_crop(ccdc, &fmt->format, crop); in ccdc_set_format()
2381 format = __ccdc_get_format(ccdc, sd_state, CCDC_PAD_SOURCE_OF, in ccdc_set_format()
2384 ccdc_try_format(ccdc, sd_state, CCDC_PAD_SOURCE_OF, format, in ccdc_set_format()
2387 format = __ccdc_get_format(ccdc, sd_state, CCDC_PAD_SOURCE_VP, in ccdc_set_format()
2390 ccdc_try_format(ccdc, sd_state, CCDC_PAD_SOURCE_VP, format, in ccdc_set_format()
2431 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_link_validate() local
2440 if (ccdc->input == CCDC_INPUT_PARALLEL) { in ccdc_link_validate()
2539 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); in ccdc_link_setup() local
2540 struct isp_device *isp = to_isp_device(ccdc); in ccdc_link_setup()
2553 ccdc->input = CCDC_INPUT_NONE; in ccdc_link_setup()
2557 if (ccdc->input != CCDC_INPUT_NONE) in ccdc_link_setup()
2561 ccdc->input = CCDC_INPUT_CCP2B; in ccdc_link_setup()
2563 ccdc->input = CCDC_INPUT_CSI2A; in ccdc_link_setup()
2565 ccdc->input = CCDC_INPUT_CSI2C; in ccdc_link_setup()
2567 ccdc->input = CCDC_INPUT_PARALLEL; in ccdc_link_setup()
2581 if (ccdc->output & ~CCDC_OUTPUT_PREVIEW) in ccdc_link_setup()
2583 ccdc->output |= CCDC_OUTPUT_PREVIEW; in ccdc_link_setup()
2585 ccdc->output &= ~CCDC_OUTPUT_PREVIEW; in ccdc_link_setup()
2592 if (ccdc->output & ~CCDC_OUTPUT_MEMORY) in ccdc_link_setup()
2594 ccdc->output |= CCDC_OUTPUT_MEMORY; in ccdc_link_setup()
2596 ccdc->output &= ~CCDC_OUTPUT_MEMORY; in ccdc_link_setup()
2603 if (ccdc->output & ~CCDC_OUTPUT_RESIZER) in ccdc_link_setup()
2605 ccdc->output |= CCDC_OUTPUT_RESIZER; in ccdc_link_setup()
2607 ccdc->output &= ~CCDC_OUTPUT_RESIZER; in ccdc_link_setup()
2624 void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device *ccdc) in omap3isp_ccdc_unregister_entities() argument
2626 v4l2_device_unregister_subdev(&ccdc->subdev); in omap3isp_ccdc_unregister_entities()
2627 omap3isp_video_unregister(&ccdc->video_out); in omap3isp_ccdc_unregister_entities()
2630 int omap3isp_ccdc_register_entities(struct isp_ccdc_device *ccdc, in omap3isp_ccdc_register_entities() argument
2636 ccdc->subdev.dev = vdev->mdev->dev; in omap3isp_ccdc_register_entities()
2637 ret = v4l2_device_register_subdev(vdev, &ccdc->subdev); in omap3isp_ccdc_register_entities()
2641 ret = omap3isp_video_register(&ccdc->video_out, vdev); in omap3isp_ccdc_register_entities()
2648 omap3isp_ccdc_unregister_entities(ccdc); in omap3isp_ccdc_register_entities()
2662 static int ccdc_init_entities(struct isp_ccdc_device *ccdc) in ccdc_init_entities() argument
2664 struct v4l2_subdev *sd = &ccdc->subdev; in ccdc_init_entities()
2665 struct media_pad *pads = ccdc->pads; in ccdc_init_entities()
2669 ccdc->input = CCDC_INPUT_NONE; in ccdc_init_entities()
2675 v4l2_set_subdevdata(sd, ccdc); in ccdc_init_entities()
2690 ccdc->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in ccdc_init_entities()
2691 ccdc->video_out.ops = &ccdc_video_ops; in ccdc_init_entities()
2692 ccdc->video_out.isp = to_isp_device(ccdc); in ccdc_init_entities()
2693 ccdc->video_out.capture_mem = PAGE_ALIGN(4096 * 4096) * 3; in ccdc_init_entities()
2694 ccdc->video_out.bpl_alignment = 32; in ccdc_init_entities()
2696 ret = omap3isp_video_init(&ccdc->video_out, "CCDC"); in ccdc_init_entities()
2717 struct isp_ccdc_device *ccdc = &isp->isp_ccdc; in omap3isp_ccdc_init() local
2720 spin_lock_init(&ccdc->lock); in omap3isp_ccdc_init()
2721 init_waitqueue_head(&ccdc->wait); in omap3isp_ccdc_init()
2722 mutex_init(&ccdc->ioctl_lock); in omap3isp_ccdc_init()
2724 ccdc->stopping = CCDC_STOP_NOT_REQUESTED; in omap3isp_ccdc_init()
2726 INIT_WORK(&ccdc->lsc.table_work, ccdc_lsc_free_table_work); in omap3isp_ccdc_init()
2727 ccdc->lsc.state = LSC_STATE_STOPPED; in omap3isp_ccdc_init()
2728 INIT_LIST_HEAD(&ccdc->lsc.free_queue); in omap3isp_ccdc_init()
2729 spin_lock_init(&ccdc->lsc.req_lock); in omap3isp_ccdc_init()
2731 ccdc->clamp.oblen = 0; in omap3isp_ccdc_init()
2732 ccdc->clamp.dcsubval = 0; in omap3isp_ccdc_init()
2734 ccdc->update = OMAP3ISP_CCDC_BLCLAMP; in omap3isp_ccdc_init()
2735 ccdc_apply_controls(ccdc); in omap3isp_ccdc_init()
2737 ret = ccdc_init_entities(ccdc); in omap3isp_ccdc_init()
2739 mutex_destroy(&ccdc->ioctl_lock); in omap3isp_ccdc_init()
2752 struct isp_ccdc_device *ccdc = &isp->isp_ccdc; in omap3isp_ccdc_cleanup() local
2754 omap3isp_video_cleanup(&ccdc->video_out); in omap3isp_ccdc_cleanup()
2755 media_entity_cleanup(&ccdc->subdev.entity); in omap3isp_ccdc_cleanup()
2760 ccdc_lsc_free_request(ccdc, ccdc->lsc.request); in omap3isp_ccdc_cleanup()
2761 cancel_work_sync(&ccdc->lsc.table_work); in omap3isp_ccdc_cleanup()
2762 ccdc_lsc_free_queue(ccdc, &ccdc->lsc.free_queue); in omap3isp_ccdc_cleanup()
2764 if (ccdc->fpc.addr != NULL) in omap3isp_ccdc_cleanup()
2765 dma_free_coherent(isp->dev, ccdc->fpc.fpnum * 4, ccdc->fpc.addr, in omap3isp_ccdc_cleanup()
2766 ccdc->fpc.dma); in omap3isp_ccdc_cleanup()
2768 mutex_destroy(&ccdc->ioctl_lock); in omap3isp_ccdc_cleanup()