28 #include <linux/device.h>
30 #include <linux/module.h>
40 #define CCP2_LCx_CHANS_NUM 3
42 #define ISPCCP2_DAT_START_MIN 0
43 #define ISPCCP2_DAT_START_MAX 4095
44 #define ISPCCP2_DAT_SIZE_MIN 0
45 #define ISPCCP2_DAT_SIZE_MAX 4095
46 #define ISPCCP2_VPCLK_FRACDIV 65536
47 #define ISPCCP2_LCx_CTRL_FORMAT_RAW8_DPCM10_VP 0x12
48 #define ISPCCP2_LCx_CTRL_FORMAT_RAW10_VP 0x16
50 #define ISPCCP2_LCM_HSIZE_COUNT_MIN 16
51 #define ISPCCP2_LCM_HSIZE_COUNT_MAX 8191
52 #define ISPCCP2_LCM_HSIZE_SKIP_MIN 0
53 #define ISPCCP2_LCM_HSIZE_SKIP_MAX 8191
54 #define ISPCCP2_LCM_VSIZE_MIN 1
55 #define ISPCCP2_LCM_VSIZE_MAX 8191
56 #define ISPCCP2_LCM_HWORDS_MIN 1
57 #define ISPCCP2_LCM_HWORDS_MAX 4095
58 #define ISPCCP2_LCM_CTRL_BURST_SIZE_32X 5
59 #define ISPCCP2_LCM_CTRL_READ_THROTTLE_FULL 0
60 #define ISPCCP2_LCM_CTRL_SRC_DECOMPR_DPCM10 2
61 #define ISPCCP2_LCM_CTRL_SRC_FORMAT_RAW8 2
62 #define ISPCCP2_LCM_CTRL_SRC_FORMAT_RAW10 3
63 #define ISPCCP2_LCM_CTRL_DST_FORMAT_RAW10 3
64 #define ISPCCP2_LCM_CTRL_DST_PORT_VP 0
65 #define ISPCCP2_LCM_CTRL_DST_PORT_MEM 1
68 #define BIT_SET(var, shift, mask, val) \
70 var = ((var) & ~((mask) << (shift))) \
71 | ((val) << (shift)); \
77 #define CCP2_PRINT_REGISTER(isp, name)\
78 dev_dbg(isp->dev, "###CCP2 " #name "=0x%08x\n", \
79 isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_##name))
85 dev_dbg(isp->
dev,
"-------------CCP2 Register dump-------------\n");
116 dev_dbg(isp->
dev,
"--------------------------------------------\n");
136 "omap3_isp: timeout waiting for ccp2 reset\n");
194 ccp2_if_enable(ccp2, 0);
233 dev_warn(isp->
dev,
"OMAP3 CCP2 bus not available\n");
257 unsigned int vpclk_div)
267 vpclk_div =
clamp_t(
unsigned int, vpclk_div, 1, 65536);
272 vpclk_div =
clamp_t(
unsigned int, vpclk_div, 1, 4);
355 struct v4l2_mbus_framefmt *
format;
367 ret = ccp2_phyif_config(ccp2, &pdata->
bus.
ccp2);
371 ccp2_vp_config(ccp2, pdata->
bus.
ccp2.vpclk_div + 1);
377 ccp2->
if_cfg.data_start = lines;
379 ccp2->
if_cfg.format = format->code;
380 ccp2->
if_cfg.data_size = format->height;
382 ccp2_lcx_config(ccp2, &ccp2->
if_cfg);
392 unsigned long l3_ick = pipe->
l3_ick;
394 unsigned int vpclk_div = 2;
413 area = ofmt->width * ofmt->height;
417 vpclk_div =
max_t(
unsigned int, l3_ick / value, vpclk_div);
420 dev_dbg(isp->
dev,
"%s: minimum clock divisor = %u\n", __func__,
441 unsigned int dpcm_decompress = 0;
444 if (sink_pixcode != source_pixcode &&
459 if (ccp2->
video_in.bpl_padding == 0)
471 if (dpcm_decompress) {
508 ccp2_vp_config(ccp2, ccp2_adjust_bandwidth(ccp2));
546 ccp2_set_inaddr(ccp2, buffer->
isp_addr);
551 if (isp_pipeline_ready(pipe))
567 static const u32 ISPCCP2_LC01_ERROR =
574 u32 lcx_irqstatus, lcm_irqstatus;
587 if (lcx_irqstatus & ISPCCP2_LC01_ERROR) {
589 dev_dbg(isp->
dev,
"CCP2 err:%x\n", lcx_irqstatus);
595 dev_dbg(isp->
dev,
"CCP2 OCP err:%x\n", lcm_irqstatus);
603 ccp2_isr_buffer(ccp2);
610 static const unsigned int ccp2_fmts[] = {
623 static struct v4l2_mbus_framefmt *
628 return v4l2_subdev_get_try_format(fh, pad);
643 struct v4l2_mbus_framefmt *
fmt,
646 struct v4l2_mbus_framefmt *
format;
677 memcpy(fmt, format,
sizeof(*fmt));
695 struct v4l2_subdev_mbus_code_enum *
code)
698 struct v4l2_mbus_framefmt *
format;
704 code->code = ccp2_fmts[code->index];
706 if (code->index != 0)
711 code->code = format->code;
717 static int ccp2_enum_frame_size(
struct v4l2_subdev *sd,
719 struct v4l2_subdev_frame_size_enum *fse)
722 struct v4l2_mbus_framefmt format;
727 format.code = fse->code;
731 fse->min_width = format.width;
732 fse->min_height = format.height;
734 if (format.code != fse->code)
737 format.code = fse->code;
741 fse->max_width = format.width;
742 fse->max_height = format.height;
758 struct v4l2_mbus_framefmt *
format;
760 format = __ccp2_get_format(ccp2, fh, fmt->
pad, fmt->
which);
779 struct v4l2_mbus_framefmt *
format;
781 format = __ccp2_get_format(ccp2, fh, fmt->
pad, fmt->
which);
812 memset(&format, 0,
sizeof(format));
816 format.format.width = 4096;
817 format.format.height = 4096;
818 ccp2_set_format(sd, fh, &format);
829 static int ccp2_s_stream(
struct v4l2_subdev *sd,
int enable)
850 ccp2_if_configure(ccp2);
851 ccp2_print_status(ccp2);
854 ccp2_if_enable(ccp2, 1);
859 struct v4l2_mbus_framefmt *
format;
863 ccp2->
mem_cfg.hsize_count = format->width;
864 ccp2->
mem_cfg.vsize_count = format->height;
867 ccp2_mem_configure(ccp2, &ccp2->
mem_cfg);
869 ccp2_print_status(ccp2);
871 ccp2_mem_enable(ccp2, 1);
877 dev_dbg(dev,
"%s: module stop timeout.\n", sd->
name);
879 ccp2_mem_enable(ccp2, 0);
883 ccp2_if_enable(ccp2, 0);
896 .s_stream = ccp2_s_stream,
901 .enum_mbus_code = ccp2_enum_mbus_code,
902 .enum_frame_size = ccp2_enum_frame_size,
903 .get_fmt = ccp2_get_format,
904 .set_fmt = ccp2_set_format,
909 .video = &ccp2_sd_video_ops,
910 .pad = &ccp2_sd_pad_ops,
915 .open = ccp2_init_formats,
932 ccp2_set_inaddr(ccp2, buffer->
isp_addr);
937 .queue = ccp2_video_queue,
959 switch (local->
index | media_entity_type(remote->
entity)) {
974 if (flags & MEDIA_LNK_FL_ENABLED) {
985 if (flags & MEDIA_LNK_FL_ENABLED)
1000 .link_setup = ccp2_link_setup,
1001 .link_validate = v4l2_subdev_link_validate,
1065 v4l2_set_subdevdata(sd, ccp2);
1071 me->
ops = &ccp2_media_ops;
1076 ccp2_init_formats(sd,
NULL);
1091 ccp2->
video_in.bpl_max = 0xffffffe0;
1093 ccp2->
video_in.ops = &ccp2_video_ops;
1142 "Could not get regulator vdds_csib\n");
1149 ret = ccp2_init_entities(ccp2);