[PATCH 4/4] media: i2c: imx219: Create DPHY helper function

From: Adam Ford
Date: Tue Apr 12 2022 - 09:56:23 EST


In the table of modes, each mode sets the DPHY to auto.
Create a helper function which does the same thing while
removing the entry for auto DPHY from ever mode entry.

Signed-off-by: Adam Ford <aford173@xxxxxxxxx>
---
drivers/media/i2c/imx219.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 08e7d0e72430..bb0bc1b8d91c 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -35,6 +35,10 @@
#define IMX219_MODE_STANDBY 0x00
#define IMX219_MODE_STREAMING 0x01

+
+#define IMX219_REG_DPHY_CTRL 0x0128
+#define IMX219_DPHY_AUTO 0
+
/* Chip ID */
#define IMX219_REG_CHIP_ID 0x0000
#define IMX219_CHIP_ID 0x0219
@@ -183,7 +187,6 @@ static const struct imx219_reg pll_clk_table[] = {
* 3280x2464 = mode 2, 1920x1080 = mode 1, 1640x1232 = mode 4, 640x480 = mode 7.
*/
static const struct imx219_reg mode_3280x2464_regs[] = {
- {0x0128, 0x00},
{0x012b, 0x00},
{0x0164, 0x00},
{0x0165, 0x00},
@@ -222,7 +225,6 @@ static const struct imx219_reg mode_3280x2464_regs[] = {
};

static const struct imx219_reg mode_1920_1080_regs[] = {
- {0x0128, 0x00},
{0x012b, 0x00},
{0x0162, 0x0d},
{0x0163, 0x78},
@@ -261,7 +263,6 @@ static const struct imx219_reg mode_1920_1080_regs[] = {
};

static const struct imx219_reg mode_1640_1232_regs[] = {
- {0x0128, 0x00},
{0x012b, 0x00},
{0x0164, 0x00},
{0x0165, 0x00},
@@ -300,7 +301,6 @@ static const struct imx219_reg mode_1640_1232_regs[] = {
};

static const struct imx219_reg mode_640_480_regs[] = {
- {0x0128, 0x00},
{0x012b, 0x00},
{0x0162, 0x0d},
{0x0163, 0x78},
@@ -999,6 +999,15 @@ static int imx219_get_selection(struct v4l2_subdev *sd,
return -EINVAL;
}

+static int imx219_enable_dphy(struct imx219 *imx219, u8 mode)
+{
+ int ret;
+
+ ret = imx219_write_reg(imx219, IMX219_REG_DPHY_CTRL,
+ IMX219_REG_VALUE_08BIT, mode);
+ return ret;
+};
+
static int imx219_configure_lanes(struct imx219 *imx219)
{
int ret;
@@ -1081,6 +1090,13 @@ static int imx219_start_streaming(struct imx219 *imx219)
goto err_rpm_put;
}

+ /* Setup DPHY */
+ ret = imx219_enable_dphy(imx219, IMX219_DPHY_AUTO);
+ if (ret) {
+ dev_err(&client->dev, "%s failed to configure dphy\n", __func__);
+ goto err_rpm_put;
+ }
+
/* Configure clock based on reference clock frequency */
imx219_set_exck_freq(imx219);

--
2.34.1