Skip to content

Commit a390f7f

Browse files
committed
media: imx708: Compute pixel rate multiplier
Removing more duplication between register tables and mode descriptors, compute the pixel rate registers rather than hard coding the PLL multipliers in the register tables. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 52bd4fb commit a390f7f

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

drivers/media/i2c/imx708.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ MODULE_PARM_DESC(qbc_adjust, "Quad Bayer broken line correction strength [0,2-5]
4747
#define IMX708_EXCLK_FREQ 0x1800
4848
#define IMX708_INCLK_FREQ 24000000
4949

50+
#define IMX708_REG_IVT_PXCK_DIV CCI_REG8(0x0301)
51+
#define IMX708_IVT_PXCK_DIV 0x05
52+
#define IMX708_REG_IVT_SYSCK_DIV CCI_REG8(0x0303)
53+
#define IMX708_IVT_SYSCK_DIV 0x02
5054
#define IMX708_REG_IVT_PREDIV CCI_REG8(0x0305)
5155
#define IMX708_IVT_PREDIV 0x02
5256
#define IMX708_REG_IVT_MPY CCI_REG16(0x0306)
@@ -295,10 +299,8 @@ static const struct cci_reg_sequence mode_4608x2592_regs[] = {
295299
{CCI_REG8(0x034D), 0x00},
296300
{CCI_REG8(0x034E), 0x0A},
297301
{CCI_REG8(0x034F), 0x20},
298-
{CCI_REG8(0x0301), 0x05},
299-
{CCI_REG8(0x0303), 0x02},
300-
{CCI_REG8(0x0306), 0x00},
301-
{CCI_REG8(0x0307), 0x7C},
302+
{IMX708_REG_IVT_PXCK_DIV, IMX708_IVT_PXCK_DIV},
303+
{IMX708_REG_IVT_SYSCK_DIV, IMX708_IVT_SYSCK_DIV},
302304
{CCI_REG8(0x0310), 0x01},
303305
{CCI_REG8(0x3CA0), 0x00},
304306
{CCI_REG8(0x3CA1), 0x64},
@@ -376,10 +378,8 @@ static const struct cci_reg_sequence mode_2x2binned_regs[] = {
376378
{CCI_REG8(0x034D), 0x00},
377379
{CCI_REG8(0x034E), 0x05},
378380
{CCI_REG8(0x034F), 0x10},
379-
{CCI_REG8(0x0301), 0x05},
380-
{CCI_REG8(0x0303), 0x02},
381-
{CCI_REG8(0x0306), 0x00},
382-
{CCI_REG8(0x0307), 0x7A},
381+
{IMX708_REG_IVT_PXCK_DIV, IMX708_IVT_PXCK_DIV},
382+
{IMX708_REG_IVT_SYSCK_DIV, IMX708_IVT_SYSCK_DIV},
383383
{CCI_REG8(0x0310), 0x01},
384384
{CCI_REG8(0x3CA0), 0x00},
385385
{CCI_REG8(0x3CA1), 0x3C},
@@ -457,10 +457,8 @@ static const struct cci_reg_sequence mode_2x2binned_720p_regs[] = {
457457
{CCI_REG8(0x034D), 0x00},
458458
{CCI_REG8(0x034E), 0x03},
459459
{CCI_REG8(0x034F), 0x60},
460-
{CCI_REG8(0x0301), 0x05},
461-
{CCI_REG8(0x0303), 0x02},
462-
{CCI_REG8(0x0306), 0x00},
463-
{CCI_REG8(0x0307), 0x76},
460+
{IMX708_REG_IVT_PXCK_DIV, IMX708_IVT_PXCK_DIV},
461+
{IMX708_REG_IVT_SYSCK_DIV, IMX708_IVT_SYSCK_DIV},
464462
{CCI_REG8(0x0310), 0x01},
465463
{CCI_REG8(0x3CA0), 0x00},
466464
{CCI_REG8(0x3CA1), 0x3C},
@@ -538,10 +536,8 @@ static const struct cci_reg_sequence mode_hdr_regs[] = {
538536
{CCI_REG8(0x034D), 0x00},
539537
{CCI_REG8(0x034E), 0x05},
540538
{CCI_REG8(0x034F), 0x10},
541-
{CCI_REG8(0x0301), 0x05},
542-
{CCI_REG8(0x0303), 0x02},
543-
{CCI_REG8(0x0306), 0x00},
544-
{CCI_REG8(0x0307), 0xA2},
539+
{IMX708_REG_IVT_PXCK_DIV, IMX708_IVT_PXCK_DIV},
540+
{IMX708_REG_IVT_SYSCK_DIV, IMX708_IVT_SYSCK_DIV},
545541
{CCI_REG8(0x0310), 0x01},
546542
{CCI_REG8(0x3CA0), 0x00},
547543
{CCI_REG8(0x3CA1), 0x00},
@@ -1317,6 +1313,16 @@ static int imx708_get_selection(struct v4l2_subdev *sd,
13171313
return -EINVAL;
13181314
}
13191315

1316+
static void imx708_set_pixel_rate_pll(struct imx708 *imx708, int *ret)
1317+
{
1318+
u64 mpy = (imx708->mode->pixel_rate * IMX708_IVT_PREDIV *
1319+
IMX708_IVT_PXCK_DIV * IMX708_IVT_SYSCK_DIV);
1320+
1321+
do_div(mpy, IMX708_INCLK_FREQ * 4);
1322+
1323+
cci_write(imx708->regmap, IMX708_REG_IVT_MPY, mpy, ret);
1324+
}
1325+
13201326
/* Start streaming */
13211327
static int imx708_start_streaming(struct imx708 *imx708)
13221328
{
@@ -1361,6 +1367,8 @@ static int imx708_start_streaming(struct imx708 *imx708)
13611367
imx708->lanes == 2 ? IMX708_CSI_2_LANE_MODE :
13621368
IMX708_CSI_4_LANE_MODE, NULL);
13631369

1370+
imx708_set_pixel_rate_pll(imx708, &ret);
1371+
13641372
/* Apply default values of current mode */
13651373
reg_list = &imx708->mode->reg_list;
13661374
ret = cci_multi_reg_write(imx708->regmap, reg_list->regs,

0 commit comments

Comments
 (0)