Lines Matching full:ccp2

5  * TI OMAP3 ISP - CCP2 module
28 /* Max/Min size for CCP2 video port */
36 /* Max/Min size for CCP2 memory channel */
62 * ccp2_print_status - Print current CCP2 module register values.
65 dev_dbg(isp->dev, "###CCP2 " #name "=0x%08x\n", \
68 static void ccp2_print_status(struct isp_ccp2_device *ccp2) in ccp2_print_status() argument
70 struct isp_device *isp = to_isp_device(ccp2); in ccp2_print_status()
72 dev_dbg(isp->dev, "-------------CCP2 Register dump-------------\n"); in ccp2_print_status()
107 * ccp2_reset - Reset the CCP2
108 * @ccp2: pointer to ISP CCP2 device
110 static void ccp2_reset(struct isp_ccp2_device *ccp2) in ccp2_reset() argument
112 struct isp_device *isp = to_isp_device(ccp2); in ccp2_reset()
123 "omap3_isp: timeout waiting for ccp2 reset\n"); in ccp2_reset()
131 * @ccp2: pointer to ISP CCP2 device
133 static void ccp2_pwr_cfg(struct isp_ccp2_device *ccp2) in ccp2_pwr_cfg() argument
135 struct isp_device *isp = to_isp_device(ccp2); in ccp2_pwr_cfg()
144 * ccp2_if_enable - Enable CCP2 interface.
145 * @ccp2: pointer to ISP CCP2 device
148 static int ccp2_if_enable(struct isp_ccp2_device *ccp2, u8 enable) in ccp2_if_enable() argument
150 struct isp_device *isp = to_isp_device(ccp2); in ccp2_if_enable()
154 if (enable && ccp2->vdds_csib) { in ccp2_if_enable()
155 ret = regulator_enable(ccp2->vdds_csib); in ccp2_if_enable()
166 /* Enable/Disable ccp2 interface in ccp2 mode */ in ccp2_if_enable()
171 if (!enable && ccp2->vdds_csib) in ccp2_if_enable()
172 regulator_disable(ccp2->vdds_csib); in ccp2_if_enable()
178 * ccp2_mem_enable - Enable CCP2 memory interface.
179 * @ccp2: pointer to ISP CCP2 device
182 static void ccp2_mem_enable(struct isp_ccp2_device *ccp2, u8 enable) in ccp2_mem_enable() argument
184 struct isp_device *isp = to_isp_device(ccp2); in ccp2_mem_enable()
187 ccp2_if_enable(ccp2, 0); in ccp2_mem_enable()
189 /* Enable/Disable ccp2 interface in ccp2 mode */ in ccp2_mem_enable()
199 * ccp2_phyif_config - Initialize CCP2 phy interface config
200 * @ccp2: Pointer to ISP CCP2 device
201 * @buscfg: CCP2 platform data
203 * Configure the CCP2 physical interface module from platform data.
207 static int ccp2_phyif_config(struct isp_ccp2_device *ccp2, in ccp2_phyif_config() argument
210 struct isp_device *isp = to_isp_device(ccp2); in ccp2_phyif_config()
229 dev_warn(isp->dev, "OMAP3 CCP2 bus not available\n"); in ccp2_phyif_config()
231 /* Strobe mode requires CCP2 */ in ccp2_phyif_config()
239 * ccp2_vp_config - Initialize CCP2 video port interface.
240 * @ccp2: Pointer to ISP CCP2 device
243 * Configure the CCP2 video port with the given clock divisor. The valid divisor
252 static void ccp2_vp_config(struct isp_ccp2_device *ccp2, in ccp2_vp_config() argument
255 struct isp_device *isp = to_isp_device(ccp2); in ccp2_vp_config()
277 * ccp2_lcx_config - Initialize CCP2 logical channel interface.
278 * @ccp2: Pointer to ISP CCP2 device
282 * and configure CSI1/CCP2 logical channel
285 static void ccp2_lcx_config(struct isp_ccp2_device *ccp2, in ccp2_lcx_config() argument
288 struct isp_device *isp = to_isp_device(ccp2); in ccp2_lcx_config()
343 * ccp2_if_configure - Configure ccp2 with data from sensor
344 * @ccp2: Pointer to ISP CCP2 device
348 static int ccp2_if_configure(struct isp_ccp2_device *ccp2) in ccp2_if_configure() argument
350 struct isp_pipeline *pipe = to_isp_pipeline(&ccp2->subdev.entity); in ccp2_if_configure()
358 ccp2_pwr_cfg(ccp2); in ccp2_if_configure()
360 pad = media_pad_remote_pad_first(&ccp2->pads[CCP2_PAD_SINK]); in ccp2_if_configure()
366 ret = ccp2_phyif_config(ccp2, &buscfg->bus.ccp2); in ccp2_if_configure()
370 ccp2_vp_config(ccp2, buscfg->bus.ccp2.vpclk_div + 1); in ccp2_if_configure()
374 format = &ccp2->formats[CCP2_PAD_SINK]; in ccp2_if_configure()
376 ccp2->if_cfg.data_start = lines; in ccp2_if_configure()
377 ccp2->if_cfg.crc = buscfg->bus.ccp2.crc; in ccp2_if_configure()
378 ccp2->if_cfg.format = format->code; in ccp2_if_configure()
379 ccp2->if_cfg.data_size = format->height; in ccp2_if_configure()
381 ccp2_lcx_config(ccp2, &ccp2->if_cfg); in ccp2_if_configure()
386 static int ccp2_adjust_bandwidth(struct isp_ccp2_device *ccp2) in ccp2_adjust_bandwidth() argument
388 struct isp_pipeline *pipe = to_isp_pipeline(&ccp2->subdev.entity); in ccp2_adjust_bandwidth()
389 struct isp_device *isp = to_isp_device(ccp2); in ccp2_adjust_bandwidth()
390 const struct v4l2_mbus_framefmt *ofmt = &ccp2->formats[CCP2_PAD_SOURCE]; in ccp2_adjust_bandwidth()
426 * ccp2_mem_configure - Initialize CCP2 memory input/output interface
427 * @ccp2: Pointer to ISP CCP2 device
432 * CSI1/CCP2 memory input.
434 static void ccp2_mem_configure(struct isp_ccp2_device *ccp2, in ccp2_mem_configure() argument
437 struct isp_device *isp = to_isp_device(ccp2); in ccp2_mem_configure()
438 u32 sink_pixcode = ccp2->formats[CCP2_PAD_SINK].code; in ccp2_mem_configure()
439 u32 source_pixcode = ccp2->formats[CCP2_PAD_SOURCE].code; in ccp2_mem_configure()
447 ccp2_pwr_cfg(ccp2); in ccp2_mem_configure()
458 if (ccp2->video_in.bpl_padding == 0) in ccp2_mem_configure()
461 config->src_ofst = ccp2->video_in.bpl_value; in ccp2_mem_configure()
507 ccp2_vp_config(ccp2, ccp2_adjust_bandwidth(ccp2)); in ccp2_mem_configure()
522 * @ccp2: Pointer to ISP CCP2 device
527 static void ccp2_set_inaddr(struct isp_ccp2_device *ccp2, u32 addr) in ccp2_set_inaddr() argument
529 struct isp_device *isp = to_isp_device(ccp2); in ccp2_set_inaddr()
538 static void ccp2_isr_buffer(struct isp_ccp2_device *ccp2) in ccp2_isr_buffer() argument
540 struct isp_pipeline *pipe = to_isp_pipeline(&ccp2->subdev.entity); in ccp2_isr_buffer()
543 buffer = omap3isp_video_buffer_next(&ccp2->video_in); in ccp2_isr_buffer()
545 ccp2_set_inaddr(ccp2, buffer->dma); in ccp2_isr_buffer()
549 if (ccp2->state == ISP_PIPELINE_STREAM_SINGLESHOT) { in ccp2_isr_buffer()
557 * omap3isp_ccp2_isr - Handle ISP CCP2 interrupts
558 * @ccp2: Pointer to ISP CCP2 device
560 * This will handle the CCP2 interrupts
562 void omap3isp_ccp2_isr(struct isp_ccp2_device *ccp2) in omap3isp_ccp2_isr() argument
564 struct isp_pipeline *pipe = to_isp_pipeline(&ccp2->subdev.entity); in omap3isp_ccp2_isr()
565 struct isp_device *isp = to_isp_device(ccp2); in omap3isp_ccp2_isr()
588 dev_dbg(isp->dev, "CCP2 err:%x\n", lcx_irqstatus); in omap3isp_ccp2_isr()
594 dev_dbg(isp->dev, "CCP2 OCP err:%x\n", lcm_irqstatus); in omap3isp_ccp2_isr()
597 if (omap3isp_module_sync_is_stopping(&ccp2->wait, &ccp2->stopping)) in omap3isp_ccp2_isr()
602 ccp2_isr_buffer(ccp2); in omap3isp_ccp2_isr()
615 * __ccp2_get_format - helper function for getting ccp2 format
616 * @ccp2 : Pointer to ISP CCP2 device
623 __ccp2_get_format(struct isp_ccp2_device *ccp2, in __ccp2_get_format() argument
630 return &ccp2->formats[pad]; in __ccp2_get_format()
635 * @ccp2 : Pointer to ISP CCP2 device
641 static void ccp2_try_format(struct isp_ccp2_device *ccp2, in ccp2_try_format() argument
654 if (ccp2->input == CCP2_INPUT_SENSOR) { in ccp2_try_format()
661 } else if (ccp2->input == CCP2_INPUT_MEMORY) { in ccp2_try_format()
673 * to SGRBG10_1X10 as we don't support CCP2 write to memory. in ccp2_try_format()
674 * When CCP2 write to memory feature will be added this in ccp2_try_format()
677 format = __ccp2_get_format(ccp2, sd_state, CCP2_PAD_SINK, in ccp2_try_format()
699 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); in ccp2_enum_mbus_code() local
711 format = __ccp2_get_format(ccp2, sd_state, CCP2_PAD_SINK, in ccp2_enum_mbus_code()
723 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); in ccp2_enum_frame_size() local
732 ccp2_try_format(ccp2, sd_state, fse->pad, &format, fse->which); in ccp2_enum_frame_size()
742 ccp2_try_format(ccp2, sd_state, fse->pad, &format, fse->which); in ccp2_enum_frame_size()
760 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); in ccp2_get_format() local
763 format = __ccp2_get_format(ccp2, sd_state, fmt->pad, fmt->which); in ccp2_get_format()
782 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); in ccp2_set_format() local
785 format = __ccp2_get_format(ccp2, sd_state, fmt->pad, fmt->which); in ccp2_set_format()
789 ccp2_try_format(ccp2, sd_state, fmt->pad, &fmt->format, fmt->which); in ccp2_set_format()
794 format = __ccp2_get_format(ccp2, sd_state, CCP2_PAD_SOURCE, in ccp2_set_format()
797 ccp2_try_format(ccp2, sd_state, CCP2_PAD_SOURCE, format, in ccp2_set_format()
806 * @sd: ISP CCP2 V4L2 subdevice
829 * ccp2_s_stream - Enable/Disable streaming on ccp2 subdev
836 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); in ccp2_s_stream() local
837 struct isp_device *isp = to_isp_device(ccp2); in ccp2_s_stream()
838 struct device *dev = to_device(ccp2); in ccp2_s_stream()
841 if (ccp2->state == ISP_PIPELINE_STREAM_STOPPED) { in ccp2_s_stream()
844 atomic_set(&ccp2->stopping, 0); in ccp2_s_stream()
849 if (ccp2->phy) { in ccp2_s_stream()
850 ret = omap3isp_csiphy_acquire(ccp2->phy, &sd->entity); in ccp2_s_stream()
855 ccp2_if_configure(ccp2); in ccp2_s_stream()
856 ccp2_print_status(ccp2); in ccp2_s_stream()
858 /* Enable CSI1/CCP2 interface */ in ccp2_s_stream()
859 ret = ccp2_if_enable(ccp2, 1); in ccp2_s_stream()
861 if (ccp2->phy) in ccp2_s_stream()
862 omap3isp_csiphy_release(ccp2->phy); in ccp2_s_stream()
868 if (ccp2->state != ISP_PIPELINE_STREAM_SINGLESHOT) { in ccp2_s_stream()
871 format = &ccp2->formats[CCP2_PAD_SINK]; in ccp2_s_stream()
873 ccp2->mem_cfg.hsize_count = format->width; in ccp2_s_stream()
874 ccp2->mem_cfg.vsize_count = format->height; in ccp2_s_stream()
875 ccp2->mem_cfg.src_ofst = 0; in ccp2_s_stream()
877 ccp2_mem_configure(ccp2, &ccp2->mem_cfg); in ccp2_s_stream()
879 ccp2_print_status(ccp2); in ccp2_s_stream()
881 ccp2_mem_enable(ccp2, 1); in ccp2_s_stream()
885 if (omap3isp_module_sync_idle(&sd->entity, &ccp2->wait, in ccp2_s_stream()
886 &ccp2->stopping)) in ccp2_s_stream()
888 if (ccp2->input == CCP2_INPUT_MEMORY) { in ccp2_s_stream()
889 ccp2_mem_enable(ccp2, 0); in ccp2_s_stream()
891 } else if (ccp2->input == CCP2_INPUT_SENSOR) { in ccp2_s_stream()
892 /* Disable CSI1/CCP2 interface */ in ccp2_s_stream()
893 ccp2_if_enable(ccp2, 0); in ccp2_s_stream()
894 if (ccp2->phy) in ccp2_s_stream()
895 omap3isp_csiphy_release(ccp2->phy); in ccp2_s_stream()
900 ccp2->state = enable; in ccp2_s_stream()
929 * ISP ccp2 video device node
940 struct isp_ccp2_device *ccp2 = &video->isp->isp_ccp2; in ccp2_video_queue() local
942 ccp2_set_inaddr(ccp2, buffer->dma); in ccp2_video_queue()
955 * ccp2_link_setup - Setup ccp2 connections.
967 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); in ccp2_link_setup() local
978 if (ccp2->input == CCP2_INPUT_SENSOR) in ccp2_link_setup()
980 ccp2->input = CCP2_INPUT_MEMORY; in ccp2_link_setup()
982 if (ccp2->input == CCP2_INPUT_MEMORY) in ccp2_link_setup()
983 ccp2->input = CCP2_INPUT_NONE; in ccp2_link_setup()
990 if (ccp2->input == CCP2_INPUT_MEMORY) in ccp2_link_setup()
992 ccp2->input = CCP2_INPUT_SENSOR; in ccp2_link_setup()
994 if (ccp2->input == CCP2_INPUT_SENSOR) in ccp2_link_setup()
995 ccp2->input = CCP2_INPUT_NONE; in ccp2_link_setup()
1001 ccp2->output = CCP2_OUTPUT_CCDC; in ccp2_link_setup()
1003 ccp2->output = CCP2_OUTPUT_NONE; in ccp2_link_setup()
1021 * @ccp2: Pointer to ISP CCP2 device
1023 void omap3isp_ccp2_unregister_entities(struct isp_ccp2_device *ccp2) in omap3isp_ccp2_unregister_entities() argument
1025 v4l2_device_unregister_subdev(&ccp2->subdev); in omap3isp_ccp2_unregister_entities()
1026 omap3isp_video_unregister(&ccp2->video_in); in omap3isp_ccp2_unregister_entities()
1031 * @ccp2: Pointer to ISP CCP2 device
1036 int omap3isp_ccp2_register_entities(struct isp_ccp2_device *ccp2, in omap3isp_ccp2_register_entities() argument
1042 ccp2->subdev.dev = vdev->mdev->dev; in omap3isp_ccp2_register_entities()
1043 ret = v4l2_device_register_subdev(vdev, &ccp2->subdev); in omap3isp_ccp2_register_entities()
1047 ret = omap3isp_video_register(&ccp2->video_in, vdev); in omap3isp_ccp2_register_entities()
1054 omap3isp_ccp2_unregister_entities(ccp2); in omap3isp_ccp2_register_entities()
1059 * ISP ccp2 initialisation and cleanup
1063 * ccp2_init_entities - Initialize ccp2 subdev and media entity.
1064 * @ccp2: Pointer to ISP CCP2 device
1067 static int ccp2_init_entities(struct isp_ccp2_device *ccp2) in ccp2_init_entities() argument
1069 struct v4l2_subdev *sd = &ccp2->subdev; in ccp2_init_entities()
1070 struct media_pad *pads = ccp2->pads; in ccp2_init_entities()
1074 ccp2->input = CCP2_INPUT_NONE; in ccp2_init_entities()
1075 ccp2->output = CCP2_OUTPUT_NONE; in ccp2_init_entities()
1079 strscpy(sd->name, "OMAP3 ISP CCP2", sizeof(sd->name)); in ccp2_init_entities()
1081 v4l2_set_subdevdata(sd, ccp2); in ccp2_init_entities()
1096 * The CCP2 has weird line alignment requirements, possibly caused by in ccp2_init_entities()
1106 ccp2->video_in.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; in ccp2_init_entities()
1107 ccp2->video_in.bpl_alignment = 32; in ccp2_init_entities()
1108 ccp2->video_in.bpl_max = 0xffffffe0; in ccp2_init_entities()
1109 ccp2->video_in.isp = to_isp_device(ccp2); in ccp2_init_entities()
1110 ccp2->video_in.ops = &ccp2_video_ops; in ccp2_init_entities()
1111 ccp2->video_in.capture_mem = PAGE_ALIGN(4096 * 4096) * 3; in ccp2_init_entities()
1113 ret = omap3isp_video_init(&ccp2->video_in, "CCP2"); in ccp2_init_entities()
1120 media_entity_cleanup(&ccp2->subdev.entity); in ccp2_init_entities()
1125 * omap3isp_ccp2_init - CCP2 initialization.
1131 struct isp_ccp2_device *ccp2 = &isp->isp_ccp2; in omap3isp_ccp2_init() local
1134 init_waitqueue_head(&ccp2->wait); in omap3isp_ccp2_init()
1141 * On the OMAP36xx, the CCP2 uses the CSI PHY1 or PHY2, shared with in omap3isp_ccp2_init()
1148 ccp2->vdds_csib = devm_regulator_get(isp->dev, "vdds_csib"); in omap3isp_ccp2_init()
1149 if (IS_ERR(ccp2->vdds_csib)) { in omap3isp_ccp2_init()
1150 if (PTR_ERR(ccp2->vdds_csib) == -EPROBE_DEFER) { in omap3isp_ccp2_init()
1157 ccp2->vdds_csib = NULL; in omap3isp_ccp2_init()
1159 ccp2->phy = &isp->isp_csiphy2; in omap3isp_ccp2_init()
1161 ccp2->phy = &isp->isp_csiphy1; in omap3isp_ccp2_init()
1164 ret = ccp2_init_entities(ccp2); in omap3isp_ccp2_init()
1168 ccp2_reset(ccp2); in omap3isp_ccp2_init()
1173 * omap3isp_ccp2_cleanup - CCP2 un-initialization
1178 struct isp_ccp2_device *ccp2 = &isp->isp_ccp2; in omap3isp_ccp2_cleanup() local
1180 omap3isp_video_cleanup(&ccp2->video_in); in omap3isp_ccp2_cleanup()
1181 media_entity_cleanup(&ccp2->subdev.entity); in omap3isp_ccp2_cleanup()