MLK-19252-1 drm/bridge: sec-dsim: move PLL check to DSIM Encoder
authorFancy Fang <chen.fang@nxp.com>
Wed, 15 Aug 2018 01:28:09 +0000 (09:28 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Defer the PLL output check to the SEC DSIM Encoder's atomic check
from SEC DSIM Bridge's mode_fixup(), since in the attached DSI
device Bridge's mode_fixup(), it may change the data lanes number,
and this change is done after the SEC DSIM Bridge's mode_fixup().
And the DSIM Encoder's atomic check is the ideal place to do this
PLL check, since it happens after all the Bridges' mode_fixup()
done.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit c9bce66fed982383dde189c428d4c2ee2c2fc623)
(cherry picked from commit ead3666313e552296da7e7b5094579b47dbdc364)
(cherry picked from commit 6a8fa239b31eca24f32b350e3c7e3118684b7323)

drivers/gpu/drm/bridge/sec-dsim.c
drivers/gpu/drm/imx/sec_mipi_dsim-imx.c
include/drm/bridge/sec_mipi_dsim.h

index 928469a..70e4e1a 100644 (file)
@@ -938,11 +938,12 @@ static void sec_mipi_dsim_set_standby(struct sec_mipi_dsim *dsim,
        dsim_write(dsim, mdresol, DSIM_MDRESOL);
 }
 
-static int sec_mipi_dsim_check_pll_out(struct sec_mipi_dsim *dsim,
-                                      const struct drm_display_mode *mode)
+int sec_mipi_dsim_check_pll_out(void *driver_private,
+                               const struct drm_display_mode *mode)
 {
        int bpp;
        uint64_t pix_clk, bit_clk, ref_clk;
+       struct sec_mipi_dsim *dsim = driver_private;
        const struct sec_mipi_dsim_plat_data *pdata = dsim->pdata;
 
        bpp = mipi_dsi_pixel_format_to_bpp(dsim->format);
@@ -973,6 +974,7 @@ static int sec_mipi_dsim_check_pll_out(struct sec_mipi_dsim *dsim,
 
        return 0;
 }
+EXPORT_SYMBOL(sec_mipi_dsim_check_pll_out);
 
 static void sec_mipi_dsim_bridge_enable(struct drm_bridge *bridge)
 {
@@ -1093,13 +1095,9 @@ static bool sec_mipi_dsim_bridge_mode_fixup(struct drm_bridge *bridge,
                                            const struct drm_display_mode *mode,
                                            struct drm_display_mode *adjusted_mode)
 {
-       int ret, private_flags;
+       int private_flags;
        struct sec_mipi_dsim *dsim = bridge->driver_private;
 
-       ret = sec_mipi_dsim_check_pll_out(dsim, mode);
-       if (ret)
-               return false;
-
        /* Since mipi dsi cannot do color conversion,
         * so the pixel format output by mipi dsi should
         * be the same with the pixel format recieved by
index 2776f11..7bab0fd 100644 (file)
@@ -132,10 +132,11 @@ static int imx_sec_dsim_encoder_helper_atomic_check(struct drm_encoder *encoder,
                                                    struct drm_crtc_state *crtc_state,
                                                    struct drm_connector_state *conn_state)
 {
-       int i;
+       int i, ret;
        u32 bus_format;
        unsigned int num_bus_formats;
        struct imx_sec_dsim_device *dsim_dev = enc_to_dsim(encoder);
+       struct drm_bridge *bridge = encoder->bridge;
        struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
        struct imx_crtc_state *imx_crtc_state = to_imx_crtc_state(crtc_state);
        struct drm_display_info *display_info = &conn_state->connector->display_info;
@@ -157,6 +158,12 @@ static int imx_sec_dsim_encoder_helper_atomic_check(struct drm_encoder *encoder,
                return -EINVAL;
        }
 
+       /* check pll out */
+       ret = sec_mipi_dsim_check_pll_out(bridge->driver_private,
+                                         adjusted_mode);
+       if (ret)
+               return ret;
+
        /* sec dsim can only accept active hight DE */
        imx_crtc_state->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
 
index b112d43..911513a 100644 (file)
@@ -25,6 +25,8 @@ struct sec_mipi_dsim_plat_data {
                                           struct drm_display_mode *mode);
 };
 
+int sec_mipi_dsim_check_pll_out(void *driver_private,
+                               const struct drm_display_mode *mode);
 int sec_mipi_dsim_bind(struct device *dev, struct device *master, void *data,
                       struct drm_encoder *encoder, struct resource *res,
                       int irq, const struct sec_mipi_dsim_plat_data *pdata);