Merge tag 'i2c-for-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / bridge / lontium-lt8912b.c
index 374db57..be533d2 100644 (file)
@@ -188,7 +188,7 @@ static int lt8912_write_lvds_config(struct lt8912 *lt)
                {0x03, 0xff},
        };
 
-       return regmap_multi_reg_write(lt->regmap[I2C_CEC_DSI], seq, ARRAY_SIZE(seq));
+       return regmap_multi_reg_write(lt->regmap[I2C_MAIN], seq, ARRAY_SIZE(seq));
 };
 
 static inline struct lt8912 *bridge_to_lt8912(struct drm_bridge *b)
@@ -268,7 +268,7 @@ static int lt8912_video_setup(struct lt8912 *lt)
        u32 hactive, h_total, hpw, hfp, hbp;
        u32 vactive, v_total, vpw, vfp, vbp;
        u8 settle = 0x08;
-       int ret;
+       int ret, hsync_activehigh, vsync_activehigh;
 
        if (!lt)
                return -EINVAL;
@@ -278,12 +278,14 @@ static int lt8912_video_setup(struct lt8912 *lt)
        hpw = lt->mode.hsync_len;
        hbp = lt->mode.hback_porch;
        h_total = hactive + hfp + hpw + hbp;
+       hsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_HSYNC_HIGH;
 
        vactive = lt->mode.vactive;
        vfp = lt->mode.vfront_porch;
        vpw = lt->mode.vsync_len;
        vbp = lt->mode.vback_porch;
        v_total = vactive + vfp + vpw + vbp;
+       vsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_VSYNC_HIGH;
 
        if (vactive <= 600)
                settle = 0x04;
@@ -317,6 +319,13 @@ static int lt8912_video_setup(struct lt8912 *lt)
        ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3e, hfp & 0xff);
        ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3f, hfp >> 8);
 
+       ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(0),
+                                 vsync_activehigh ? BIT(0) : 0);
+       ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1),
+                                 hsync_activehigh ? BIT(1) : 0);
+       ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xb2, BIT(0),
+                                 lt->connector.display_info.is_hdmi ? BIT(0) : 0);
+
        return ret;
 }