Skip to content

Commit f54e586

Browse files
vvarmaJacopo Mondi
authored and
Jacopo Mondi
committed
media: i2c: imx219: fix binning and rate_factor for 480p and 1232p
At a high FPS with RAW10, there is frame corruption for 480p because the rate_factor of 2 is used with the normal 2x2 bining [1]. This commit ties the rate_factor to the selected binning mode. For the 480p mode, analog 2x2 binning mode with a rate_factor of 2 is always used. For the 1232p mode the normal 2x2 binning mode is used for RAW10 while analog 2x2 binning mode is used for RAW8. [1] #5493 Signed-off-by: Vinay Varma <[email protected]> Reworked due to upstream changes Signed-off-by: Dave Stevenson <[email protected]> Reworked again due to upstream changes Signed-off-by: Jai Luthra <[email protected]>
1 parent 2e16041 commit f54e586

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

drivers/media/i2c/imx219.c

+13-15
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ struct imx219_mode {
163163

164164
/* V-timing */
165165
unsigned int vts_def;
166-
167-
/* Relative pixel clock rate factor for the mode. */
168-
unsigned int rate_factor;
169166
};
170167

171168
static const struct cci_reg_sequence imx219_common_regs[] = {
@@ -301,32 +298,24 @@ static const struct imx219_mode supported_modes[] = {
301298
.width = 3280,
302299
.height = 2464,
303300
.vts_def = 3526,
304-
.rate_factor = 1,
305301
},
306302
{
307303
/* 1080P 30fps cropped */
308304
.width = 1920,
309305
.height = 1080,
310306
.vts_def = 1763,
311-
.rate_factor = 1,
312307
},
313308
{
314309
/* 2x2 binned 30fps mode */
315310
.width = 1640,
316311
.height = 1232,
317312
.vts_def = 1763,
318-
.rate_factor = 1,
319313
},
320314
{
321315
/* 640x480 30fps mode */
322316
.width = 640,
323317
.height = 480,
324318
.vts_def = 1763,
325-
/*
326-
* This mode uses a special 2x2 binning that doubles the
327-
* internal pixel clock rate.
328-
*/
329-
.rate_factor = 2,
330319
},
331320
};
332321

@@ -366,7 +355,7 @@ struct imx219 {
366355
/* Two or Four lanes */
367356
u8 lanes;
368357

369-
/* Rate factor */
358+
/* Relative pixel clock rate factor. */
370359
unsigned int rate_factor;
371360
};
372361

@@ -682,7 +671,9 @@ static int imx219_set_framefmt(struct imx219 *imx219,
682671
bin_h = IMX219_BINNING_NONE;
683672
break;
684673
case 2:
685-
bin_h = bpp == 8 ? IMX219_BINNING_X2_ANALOG : IMX219_BINNING_X2;
674+
bin_h = (bpp == 8 || format->width == 640) ?
675+
IMX219_BINNING_X2_ANALOG :
676+
IMX219_BINNING_X2;
686677
break;
687678
}
688679

@@ -692,7 +683,9 @@ static int imx219_set_framefmt(struct imx219 *imx219,
692683
bin_v = IMX219_BINNING_NONE;
693684
break;
694685
case 2:
695-
bin_v = bpp == 8 ? IMX219_BINNING_X2_ANALOG : IMX219_BINNING_X2;
686+
bin_v = (bpp == 8 || format->height == 480) ?
687+
IMX219_BINNING_X2_ANALOG :
688+
IMX219_BINNING_X2;
696689
break;
697690
}
698691

@@ -1015,7 +1008,12 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
10151008
int hblank;
10161009
int pixel_rate;
10171010

1018-
imx219->rate_factor = mode->rate_factor;
1011+
/* TODO: Set rate_factor and binning mode together */
1012+
if (((crop->height / format->height) == 2) ||
1013+
format->height == 480)
1014+
imx219->rate_factor = 2;
1015+
else
1016+
imx219->rate_factor = 1;
10191017

10201018
/* Update limits and set FPS to default */
10211019
__v4l2_ctrl_modify_range(imx219->vblank, IMX219_VBLANK_MIN,

0 commit comments

Comments
 (0)