40 static void csi2_if_enable(
struct isp_device *isp,
56 static void csi2_recv_config(
struct isp_device *isp,
90 static const unsigned int csi2_input_fmts[] = {
112 static const u16 __csi2_fmt_map[3][2][2][2] = {
181 int fmtidx, destidx, is_3630;
200 WARN(1,
KERN_ERR "CSI2: pixel format %08x unsupported!\n",
217 return __csi2_fmt_map[fmtidx][destidx][csi2->
dpcm_decompress][is_3630];
251 return (format_id & 0x40) ? 1 : 0;
260 static void csi2_ctx_enable(
struct isp_device *isp,
264 unsigned int skip = 0;
292 static void csi2_ctx_config(
struct isp_device *isp,
334 if (is_usr_def_mapping(ctx->
format_id)) {
349 reg = isp_reg_readl(isp, csi2->
regs1,
353 isp_reg_writel(isp, reg, csi2->
regs1,
367 static void csi2_timing_config(
struct isp_device *isp,
401 static void csi2_irq_ctx_set(
struct isp_device *isp,
406 for (i = 0; i < 8; i++) {
422 static void csi2_irq_complexio1_set(
struct isp_device *isp,
465 static void csi2_irq_status_set(
struct isp_device *isp,
496 u8 soft_reset_retries = 0;
503 if (csi2->
phy->phy_in_use)
514 soft_reset_retries++;
515 if (soft_reset_retries < 5)
517 }
while (soft_reset_retries < 5);
519 if (soft_reset_retries == 5) {
539 "CSI2: Reset for CSI2_96M_FCLK domain Failed!\n");
553 ISPCSI2_SYSCONFIG_AUTO_IDLE,
583 csi2->
ctrl.vp_out_ctrl = pdata->
bus.
csi2.vpclk_div;
604 csi2->
contexts[0].format_id = csi2_ctx_map_format(csi2);
621 csi2_irq_complexio1_set(isp, csi2, 1);
622 csi2_irq_ctx_set(isp, csi2, 1);
623 csi2_irq_status_set(isp, csi2, 1);
626 csi2_timing_config(isp, csi2, timing);
627 csi2_recv_config(isp, csi2, &csi2->
ctrl);
628 csi2_ctx_config(isp, csi2, &csi2->
contexts[0]);
636 #define CSI2_PRINT_REGISTER(isp, regs, name)\
637 dev_dbg(isp->dev, "###CSI2 " #name "=0x%08x\n", \
638 isp_reg_readl(isp, regs, ISPCSI2_##name))
647 dev_dbg(isp->
dev,
"-------------CSI2 Register dump-------------\n");
671 dev_dbg(isp->
dev,
"--------------------------------------------\n");
687 csi2_ctx_enable(isp, csi2, 0, 0);
698 csi2_set_outaddr(csi2, buffer->
isp_addr);
699 csi2_ctx_enable(isp, csi2, 0, 1);
728 ctx->
format_id = csi2_ctx_map_format(csi2);
729 csi2_ctx_config(isp, csi2, ctx);
730 csi2_ctx_enable(isp, csi2, n, 1);
736 csi2_isr_buffer(csi2);
745 u32 csi2_irqstatus, cpxio1_irqstatus;
756 cpxio1_irqstatus = isp_reg_readl(isp, csi2->
regs1,
758 isp_reg_writel(isp, cpxio1_irqstatus,
760 dev_dbg(isp->
dev,
"CSI2: ComplexIO Error IRQ "
761 "%x\n", cpxio1_irqstatus);
795 csi2_isr_ctx(csi2, &csi2->
contexts[0]);
798 dev_dbg(isp->
dev,
"CSI2: ECC correction done\n");
815 csi2_set_outaddr(csi2, buffer->
isp_addr);
825 csi2_if_enable(isp, csi2, 1);
826 csi2_ctx_enable(isp, csi2, 0, 1);
827 isp_video_dmaqueue_flags_clr(&csi2->
video_out);
841 static struct v4l2_mbus_framefmt *
846 return v4l2_subdev_get_try_format(fh, pad);
853 unsigned int pad,
struct v4l2_mbus_framefmt *fmt,
857 struct v4l2_mbus_framefmt *
format;
864 for (i = 0; i <
ARRAY_SIZE(csi2_input_fmts); i++) {
865 if (fmt->code == csi2_input_fmts[i])
873 fmt->width =
clamp_t(
u32, fmt->width, 1, 8191);
874 fmt->height =
clamp_t(
u32, fmt->height, 1, 8191);
881 pixelcode = fmt->code;
883 memcpy(fmt, format,
sizeof(*fmt));
891 fmt->code = pixelcode;
909 struct v4l2_subdev_mbus_code_enum *
code)
912 struct v4l2_mbus_framefmt *
format;
916 if (code->index >=
ARRAY_SIZE(csi2_input_fmts))
919 code->code = csi2_input_fmts[code->index];
923 switch (code->index) {
926 code->code = format->code;
944 static int csi2_enum_frame_size(
struct v4l2_subdev *sd,
946 struct v4l2_subdev_frame_size_enum *fse)
949 struct v4l2_mbus_framefmt format;
954 format.code = fse->code;
958 fse->min_width = format.width;
959 fse->min_height = format.height;
961 if (format.code != fse->code)
964 format.code = fse->code;
968 fse->max_width = format.width;
969 fse->max_height = format.height;
985 struct v4l2_mbus_framefmt *
format;
987 format = __csi2_get_format(csi2, fh, fmt->
pad, fmt->
which);
1006 struct v4l2_mbus_framefmt *
format;
1008 format = __csi2_get_format(csi2, fh, fmt->
pad, fmt->
which);
1039 memset(&format, 0,
sizeof(format));
1043 format.format.width = 4096;
1044 format.format.height = 4096;
1045 csi2_set_format(sd, fh, &format);
1057 static int csi2_set_stream(
struct v4l2_subdev *sd,
int enable)
1069 csi2_configure(csi2);
1070 csi2_print_status(csi2);
1083 csi2_ctx_enable(isp, csi2, 0, 1);
1084 csi2_if_enable(isp, csi2, 1);
1085 isp_video_dmaqueue_flags_clr(video_out);
1093 dev_dbg(isp->
dev,
"%s: module stop timeout.\n",
1095 csi2_ctx_enable(isp, csi2, 0, 0);
1096 csi2_if_enable(isp, csi2, 0);
1097 csi2_irq_ctx_set(isp, csi2, 0);
1099 isp_video_dmaqueue_flags_clr(video_out);
1110 .s_stream = csi2_set_stream,
1115 .enum_mbus_code = csi2_enum_mbus_code,
1116 .enum_frame_size = csi2_enum_frame_size,
1117 .get_fmt = csi2_get_format,
1118 .set_fmt = csi2_set_format,
1123 .video = &csi2_video_ops,
1124 .pad = &csi2_pad_ops,
1129 .open = csi2_init_formats,
1144 static int csi2_link_setup(
struct media_entity *entity,
1157 switch (local->
index | media_entity_type(remote->
entity)) {
1169 if (flags & MEDIA_LNK_FL_ENABLED) {
1192 .link_setup = csi2_link_setup,
1193 .link_validate = v4l2_subdev_link_validate,
1244 v4l2_set_subdevdata(sd, csi2);
1250 me->
ops = &csi2_media_ops;
1255 csi2_init_formats(sd,
NULL);
1259 csi2->
video_out.ops = &csi2_ispvideo_ops;
1302 ret = csi2_init_entities(csi2a);