[Wandcam ov5640] Can't use high resolution modes with width and height biggers than 1024. November 18, 2014 05:08AM |
enum ov5640_mode { ov5640_mode_MIN = 0, ov5640_mode_VGA_640_480 = 0, ov5640_mode_QVGA_320_240 = 1, ov5640_mode_NTSC_720_480 = 2, ov5640_mode_PAL_720_576 = 3, ov5640_mode_720P_1280_720 = 4, ov5640_mode_1080P_1920_1080 = 5, ov5640_mode_QSXGA_2592_1944 = 6, ov5640_mode_QCIF_176_144 = 7, ov5640_mode_XGA_1024_768 = 8, ov5640_mode_MAX = 8, ov5640_mode_INIT = 0xff, /*only for sensor init*/ };
static int _calc_resize_coeffs(struct ipu_soc *ipu, uint32_t inSize, uint32_t outSize, uint32_t *resizeCoeff, uint32_t *downsizeCoeff) { uint32_t tempSize; uint32_t tempDownsize; if (inSize > 4096) { dev_err(ipu->dev, "IC input size(%d) cannot exceed 4096\n", inSize); return -EINVAL; } /* * ----- THE PROBLEM IS HERE! ----- */ if (outSize > 1024) { dev_err(ipu->dev, "IC output size(%d) cannot exceed 1024\n", outSize); return -EINVAL; } if ((outSize << 3) < inSize) { dev_err(ipu->dev, "IC cannot downsize more than 8:1\n" return -EINVAL; } /* Compute downsizing coefficient */ /* Output of downsizing unit cannot be more than 1024 */ tempDownsize = 0; tempSize = inSize; while (((tempSize > 1024) || (tempSize >= outSize * 2)) && (tempDownsize < 2)) { tempSize >>= 1; tempDownsize++; } *downsizeCoeff = tempDownsize; /* compute resizing coefficient using the following equation: resizeCoeff = M*(SI -1)/(SO - 1) where M = 2^13, SI - input size, SO - output size */ *resizeCoeff = (8192L * (tempSize - 1)) / (outSize - 1); if (*resizeCoeff >= 16384L) { dev_err(ipu->dev, "Overflow on IC resize coefficient.\n"
; return -EINVAL; } dev_dbg(ipu->dev, "resizing from %u -> %u pixels, " "downsize=%u, resize=%u.%lu (reg=%u)\n", inSize, outSize, *downsizeCoeff, (*resizeCoeff >= 8192L) ? 1 : 0, ((*resizeCoeff & 0x1FFF) * 10000L) / 8192L, *resizeCoeff); return 0; }