Skip to content

Commit 579b122

Browse files
committed
media: imx477: Compute line_length_pix based on link frequency
As we now support variable link frequency, compute the minimum line_length value that the sensor will work with, and set V4L2_CID_HBLANK based on that number. Signed-off-by: Dave Stevenson <[email protected]>
1 parent cb505be commit 579b122

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

drivers/media/i2c/imx477.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ struct imx477_mode {
154154
/* Frame height */
155155
unsigned int height;
156156

157-
/* H-timing in pixels */
158-
unsigned int line_length_pix;
159-
160157
/* Analog crop rectangle. */
161158
struct v4l2_rect crop;
162159

@@ -857,7 +854,6 @@ static const struct imx477_mode supported_modes_12bit[] = {
857854
/* 12MPix 10fps mode */
858855
.width = 4056,
859856
.height = 3040,
860-
.line_length_pix = 24000,
861857
.crop = {
862858
.left = IMX477_PIXEL_ARRAY_LEFT,
863859
.top = IMX477_PIXEL_ARRAY_TOP,
@@ -874,7 +870,6 @@ static const struct imx477_mode supported_modes_12bit[] = {
874870
/* 12MPix cropped 16:9 mode */
875871
.width = 4056,
876872
.height = 2160,
877-
.line_length_pix = 24000,
878873
.crop = {
879874
.left = IMX477_PIXEL_ARRAY_LEFT,
880875
.top = IMX477_PIXEL_ARRAY_TOP + 440,
@@ -891,7 +886,6 @@ static const struct imx477_mode supported_modes_12bit[] = {
891886
/* 2x2 binned 40fps mode */
892887
.width = 2028,
893888
.height = 1520,
894-
.line_length_pix = 12740,
895889
.crop = {
896890
.left = IMX477_PIXEL_ARRAY_LEFT,
897891
.top = IMX477_PIXEL_ARRAY_TOP,
@@ -908,7 +902,6 @@ static const struct imx477_mode supported_modes_12bit[] = {
908902
/* 1080p 50fps cropped mode */
909903
.width = 2028,
910904
.height = 1080,
911-
.line_length_pix = 12740,
912905
.crop = {
913906
.left = IMX477_PIXEL_ARRAY_LEFT,
914907
.top = IMX477_PIXEL_ARRAY_TOP + 440,
@@ -928,7 +921,6 @@ static const struct imx477_mode supported_modes_10bit[] = {
928921
/* 120fps. 2x2 binned and cropped */
929922
.width = 1332,
930923
.height = 990,
931-
.line_length_pix = 6664,
932924
.crop = {
933925
/*
934926
* FIXME: the analog crop rectangle is actually
@@ -1412,6 +1404,7 @@ static int imx477_get_pad_format(struct v4l2_subdev *sd,
14121404
static void imx477_set_framing_limits(struct imx477 *imx477)
14131405
{
14141406
unsigned int hblank_min;
1407+
u64 line_length_min;
14151408
const struct imx477_mode *mode = imx477->mode;
14161409

14171410
/* Default to no long exposure multiplier. */
@@ -1428,7 +1421,11 @@ static void imx477_set_framing_limits(struct imx477 *imx477)
14281421
__v4l2_ctrl_s_ctrl(imx477->vblank,
14291422
mode->frm_length_default - mode->height);
14301423

1431-
hblank_min = mode->line_length_pix - mode->width;
1424+
line_length_min = mode->width * 12 /*BPP*/ * (u64)IMX477_PIXEL_RATE;
1425+
do_div(line_length_min, imx477->link_freq_value * 2 * 2 /*LANES*/);
1426+
line_length_min += 500; /* Allow for HS<>LP transitions */
1427+
1428+
hblank_min = line_length_min - mode->width;
14321429
__v4l2_ctrl_modify_range(imx477->hblank, hblank_min,
14331430
IMX477_LINE_LENGTH_MAX, 1, hblank_min);
14341431
__v4l2_ctrl_s_ctrl(imx477->hblank, hblank_min);

0 commit comments

Comments
 (0)