Skip to content

Commit 75fa419

Browse files
committed
[imx219] Support 2x2 binning
1 parent 9c5bd53 commit 75fa419

1 file changed

Lines changed: 72 additions & 4 deletions

File tree

drivers/media/i2c/imx219.c

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ struct imx219_mode {
5656
u32 hts_def;
5757
u32 vts_def;
5858
const struct imx219_reg *reg_list;
59+
u8 binning_v; // 0 = no binning, 1 = 2x binning, 2 = 4x binning
60+
u8 binning_h;
5961
};
6062

6163
/* MCLK:24MHz 3280x2464 21.2fps MIPI LANE2 */
@@ -163,6 +165,58 @@ static const struct imx219_reg imx219_init_tab_1920_1080_30fps[] = {
163165
{IMX219_TABLE_END, 0x00}
164166
};
165167

168+
/* MCLK:24MHz 1640x1232 2x2 binning 30fps MIPI LANE2 */
169+
static const struct imx219_reg imx219_init_tab_1640_1232_30fps[] = {
170+
{0x30EB, 0x05}, /* Access Code for address over 0x3000 */
171+
{0x30EB, 0x0C}, /* Access Code for address over 0x3000 */
172+
{0x300A, 0xFF}, /* Access Code for address over 0x3000 */
173+
{0x300B, 0xFF}, /* Access Code for address over 0x3000 */
174+
{0x30EB, 0x05}, /* Access Code for address over 0x3000 */
175+
{0x30EB, 0x09}, /* Access Code for address over 0x3000 */
176+
{0x0114, 0x01}, /* CSI_LANE_MODE[1:0} */
177+
{0x0128, 0x00}, /* DPHY_CNTRL */
178+
{0x012A, 0x18}, /* EXCK_FREQ[15:8] */
179+
{0x012B, 0x00}, /* EXCK_FREQ[7:0] */
180+
{0x015A, 0x01}, /* INTEG TIME[15:8] */
181+
{0x015B, 0xF4}, /* INTEG TIME[7:0] */
182+
{0x0160, 0x06}, /* FRM_LENGTH_A[15:8] */
183+
{0x0161, 0xE6}, /* FRM_LENGTH_A[7:0] */
184+
{0x0162, 0x0D}, /* LINE_LENGTH_A[15:8] */
185+
{0x0163, 0x78}, /* LINE_LENGTH_A[7:0] */
186+
{0x0260, 0x06}, /* FRM_LENGTH_B[15:8] */
187+
{0x0261, 0xE6}, /* FRM_LENGTH_B[7:0] */
188+
{0x0262, 0x0D}, /* LINE_LENGTH_B[15:8] */
189+
{0x0263, 0x78}, /* LINE_LENGTH_B[7:0] */
190+
{0x0170, 0x01}, /* X_ODD_INC_A[2:0] */
191+
{0x0171, 0x01}, /* Y_ODD_INC_A[2:0] */
192+
{0x0270, 0x01}, /* X_ODD_INC_B[2:0] */
193+
{0x0271, 0x01}, /* Y_ODD_INC_B[2:0] */
194+
{0x0174, 0x01}, /* BINNING_MODE_H_A */
195+
{0x0175, 0x01}, /* BINNING_MODE_V_A */
196+
{0x0274, 0x01}, /* BINNING_MODE_H_B */
197+
{0x0275, 0x01}, /* BINNING_MODE_V_B */
198+
{0x018C, 0x0A}, /* CSI_DATA_FORMAT_A[15:8] */
199+
{0x018D, 0x0A}, /* CSI_DATA_FORMAT_A[7:0] */
200+
{0x028C, 0x0A}, /* CSI_DATA_FORMAT_B[15:8] */
201+
{0x028D, 0x0A}, /* CSI_DATA_FORMAT_B[7:0] */
202+
{0x0301, 0x05}, /* VTPXCK_DIV */
203+
{0x0303, 0x01}, /* VTSYCK_DIV */
204+
{0x0304, 0x03}, /* PREPLLCK_VT_DIV[3:0] */
205+
{0x0305, 0x03}, /* PREPLLCK_OP_DIV[3:0] */
206+
{0x0306, 0x00}, /* PLL_VT_MPY[10:8] */
207+
{0x0307, 0x39}, /* PLL_VT_MPY[7:0] */
208+
{0x0309, 0x0A}, /* OPPXCK_DIV[4:0] */
209+
{0x030B, 0x01}, /* OPSYCK_DIV */
210+
{0x030C, 0x00}, /* PLL_OP_MPY[10:8] */
211+
{0x030D, 0x72}, /* PLL_OP_MPY[7:0] */
212+
{0x455E, 0x00}, /* CIS Tuning */
213+
{0x471E, 0x4B}, /* CIS Tuning */
214+
{0x4767, 0x0F}, /* CIS Tuning */
215+
{0x4750, 0x14}, /* CIS Tuning */
216+
{0x47B4, 0x14}, /* CIS Tuning */
217+
{IMX219_TABLE_END, 0x00}
218+
};
219+
166220
static const struct imx219_reg start[] = {
167221
{0x0100, 0x01}, /* mode select streaming on */
168222
{IMX219_TABLE_END, 0x00}
@@ -241,6 +295,8 @@ static const struct imx219_mode supported_modes[] = {
241295
.hts_def = 0x0d78 - IMX219_EXP_LINES_MARGIN,
242296
.vts_def = 0x06E6,
243297
.reg_list = imx219_init_tab_1920_1080_30fps,
298+
.binning_h = 0,
299+
.binning_v = 0,
244300
},
245301
{
246302
.width = 3280,
@@ -249,6 +305,18 @@ static const struct imx219_mode supported_modes[] = {
249305
.hts_def = 0x0d78 - IMX219_EXP_LINES_MARGIN,
250306
.vts_def = 0x09c4,
251307
.reg_list = imx219_init_tab_3280_2464_21fps,
308+
.binning_h = 0,
309+
.binning_v = 0,
310+
},
311+
{
312+
.width = 1640,
313+
.height = 1232,
314+
.max_fps = 30,
315+
.hts_def = 0x0d78 - IMX219_EXP_LINES_MARGIN,
316+
.vts_def = 0x06E6,
317+
.reg_list = imx219_init_tab_1640_1232_30fps,
318+
.binning_h = 1,
319+
.binning_v = 1,
252320
},
253321
};
254322

@@ -666,14 +734,14 @@ static int imx219_set_fmt(struct v4l2_subdev *sd,
666734
pixel_rate, 1, pixel_rate);
667735

668736
/* reset crop window */
669-
priv->crop_rect.left = 1640 - (mode->width / 2);
737+
priv->crop_rect.left = 1640 - ((mode->width << mode->binning_h) / 2);
670738
if (priv->crop_rect.left < 0)
671739
priv->crop_rect.left = 0;
672-
priv->crop_rect.top = 1232 - (mode->height / 2);
740+
priv->crop_rect.top = 1232 - ((mode->height << mode->binning_v) / 2);
673741
if (priv->crop_rect.top < 0)
674742
priv->crop_rect.top = 0;
675-
priv->crop_rect.width = mode->width;
676-
priv->crop_rect.height = mode->height;
743+
priv->crop_rect.width = (mode->width << mode->binning_h);
744+
priv->crop_rect.height = (mode->height << mode->binning_v);
677745

678746
return 0;
679747
}

0 commit comments

Comments
 (0)