drm/bridge: lt9611: rework infoframes handling
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Wed, 18 Jan 2023 08:16:56 +0000 (10:16 +0200)
committerNeil Armstrong <neil.armstrong@linaro.org>
Wed, 18 Jan 2023 14:27:09 +0000 (15:27 +0100)
Rework handling infoframes:
- Write full HDMI AVI infoframe instead of just fixing the VIC value
- Also send the HDMI Vendor Specific infoframe, as recommended by the
  HDMI spec.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230118081658.2198520-12-dmitry.baryshkov@linaro.org
drivers/gpu/drm/bridge/lontium-lt9611.c

index cd980906ff4d7dacfa4646e91e23af61b6aaa166..d0ee5ee400da9e390db09c3566b664b3ce9ffcbd 100644 (file)
@@ -59,7 +59,6 @@ struct lt9611 {
        enum drm_connector_status status;
 
        u8 edid_buf[EDID_SEG_SIZE];
-       u32 vic;
 };
 
 #define LT9611_PAGE_CONTROL    0xff
@@ -353,12 +352,51 @@ end:
        return temp;
 }
 
-static void lt9611_hdmi_tx_digital(struct lt9611 *lt9611, bool is_hdmi)
+static void lt9611_hdmi_set_infoframes(struct lt9611 *lt9611,
+                                      struct drm_connector *connector,
+                                      struct drm_display_mode *mode)
 {
-       regmap_write(lt9611->regmap, 0x8443, 0x46 - lt9611->vic);
-       regmap_write(lt9611->regmap, 0x8447, lt9611->vic);
-       regmap_write(lt9611->regmap, 0x843d, 0x0a); /* UD1 infoframe */
+       union hdmi_infoframe infoframe;
+       ssize_t len;
+       u8 iframes = 0x0a; /* UD1 infoframe */
+       u8 buf[32];
+       int ret;
+       int i;
+
+       ret = drm_hdmi_avi_infoframe_from_display_mode(&infoframe.avi,
+                                                      connector,
+                                                      mode);
+       if (ret < 0)
+               goto out;
+
+       len = hdmi_infoframe_pack(&infoframe, buf, sizeof(buf));
+       if (len < 0)
+               goto out;
+
+       for (i = 0; i < len; i++)
+               regmap_write(lt9611->regmap, 0x8440 + i, buf[i]);
+
+       ret = drm_hdmi_vendor_infoframe_from_display_mode(&infoframe.vendor.hdmi,
+                                                         connector,
+                                                         mode);
+       if (ret < 0)
+               goto out;
+
+       len = hdmi_infoframe_pack(&infoframe, buf, sizeof(buf));
+       if (len < 0)
+               goto out;
 
+       for (i = 0; i < len; i++)
+               regmap_write(lt9611->regmap, 0x8474 + i, buf[i]);
+
+       iframes |= 0x20;
+
+out:
+       regmap_write(lt9611->regmap, 0x843d, iframes); /* UD1 infoframe */
+}
+
+static void lt9611_hdmi_tx_digital(struct lt9611 *lt9611, bool is_hdmi)
+{
        if (is_hdmi)
                regmap_write(lt9611->regmap, 0x82d6, 0x8c);
        else
@@ -688,9 +726,7 @@ lt9611_bridge_atomic_enable(struct drm_bridge *bridge,
        struct drm_connector_state *conn_state;
        struct drm_crtc_state *crtc_state;
        struct drm_display_mode *mode;
-       struct hdmi_avi_infoframe avi_frame;
        unsigned int postdiv;
-       int ret;
 
        connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
        if (WARN_ON(!connector))
@@ -711,18 +747,13 @@ lt9611_bridge_atomic_enable(struct drm_bridge *bridge,
        lt9611_mipi_video_setup(lt9611, mode);
        lt9611_pcr_setup(lt9611, mode, postdiv);
 
-       ret = drm_hdmi_avi_infoframe_from_display_mode(&avi_frame,
-                                                      connector,
-                                                      mode);
-       if (!ret)
-               lt9611->vic = avi_frame.video_code;
-
        if (lt9611_power_on(lt9611)) {
                dev_err(lt9611->dev, "power on failed\n");
                return;
        }
 
        lt9611_mipi_input_analog(lt9611);
+       lt9611_hdmi_set_infoframes(lt9611, connector, mode);
        lt9611_hdmi_tx_digital(lt9611, connector->display_info.is_hdmi);
        lt9611_hdmi_tx_phy(lt9611);