Message ID | 20210329153632.17559-4-dafna.hirschfeld@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/mediatek: Don't support hdmi connector creation | expand |
Hi Dafna, Thank you for the patch. On Mon, Mar 29, 2021 at 05:36:32PM +0200, Dafna Hirschfeld wrote: > The mtk_hdmi does not support creating a bridge with a connector. > Therefore the field 'conn' should be removed from the mtk_hdmi struct. > It is replaced with a pointer curr_conn that points to the current > connector which can be access through the global state. > > Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> The patch looks good to me, but I'd squash it with 2/3 otherwise I think you'll break bisection. On the other hand, given that the HDMI support is already broken... :-) Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> But you need to make sure this patch will get backported to stable along 2/3, probably by adding a fixes tag. Or squashing it with 2/3, up to you. > --- > drivers/gpu/drm/mediatek/mtk_hdmi.c | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c > index 1eeb211b1536..0d95d2cfe3de 100644 > --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c > +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c > @@ -153,7 +153,7 @@ struct mtk_hdmi_conf { > struct mtk_hdmi { > struct drm_bridge bridge; > struct drm_bridge *next_bridge; > - struct drm_connector conn; > + struct drm_connector *curr_conn;/* current connector (only valid when 'enabled') */ > struct device *dev; > const struct mtk_hdmi_conf *conf; > struct phy *phy; > @@ -969,7 +969,7 @@ static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi, > ssize_t err; > > err = drm_hdmi_avi_infoframe_from_display_mode(&frame, > - &hdmi->conn, mode); > + hdmi->curr_conn, mode); > if (err < 0) { > dev_err(hdmi->dev, > "Failed to get AVI infoframe from mode: %zd\n", err); > @@ -1049,7 +1049,7 @@ static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi, > ssize_t err; > > err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, > - &hdmi->conn, mode); > + hdmi->curr_conn, mode); > if (err) { > dev_err(hdmi->dev, > "Failed to get vendor infoframe from mode: %zd\n", err); > @@ -1322,6 +1322,8 @@ static void mtk_hdmi_bridge_atomic_disable(struct drm_bridge *bridge, > clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]); > clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); > > + hdmi->curr_conn = NULL; > + > hdmi->enabled = false; > } > > @@ -1385,8 +1387,13 @@ static void mtk_hdmi_send_infoframe(struct mtk_hdmi *hdmi, > static void mtk_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, > struct drm_bridge_state *old_state) > { > + struct drm_atomic_state *state = old_state->base.state; > struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); > > + /* Retrieve the connector through the atomic state. */ > + hdmi->curr_conn = drm_atomic_get_new_connector_for_encoder(state, > + bridge->encoder); > + > mtk_hdmi_output_set_display_mode(hdmi, &hdmi->mode); > clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); > clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]); > @@ -1625,8 +1632,10 @@ static int mtk_hdmi_audio_get_eld(struct device *dev, void *data, uint8_t *buf, > { > struct mtk_hdmi *hdmi = dev_get_drvdata(dev); > > - memcpy(buf, hdmi->conn.eld, min(sizeof(hdmi->conn.eld), len)); > - > + if (hdmi->enabled) > + memcpy(buf, hdmi->curr_conn->eld, min(sizeof(hdmi->curr_conn->eld), len)); > + else > + memset(buf, 0, len); > return 0; > } >
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 1eeb211b1536..0d95d2cfe3de 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -153,7 +153,7 @@ struct mtk_hdmi_conf { struct mtk_hdmi { struct drm_bridge bridge; struct drm_bridge *next_bridge; - struct drm_connector conn; + struct drm_connector *curr_conn;/* current connector (only valid when 'enabled') */ struct device *dev; const struct mtk_hdmi_conf *conf; struct phy *phy; @@ -969,7 +969,7 @@ static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi, ssize_t err; err = drm_hdmi_avi_infoframe_from_display_mode(&frame, - &hdmi->conn, mode); + hdmi->curr_conn, mode); if (err < 0) { dev_err(hdmi->dev, "Failed to get AVI infoframe from mode: %zd\n", err); @@ -1049,7 +1049,7 @@ static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi *hdmi, ssize_t err; err = drm_hdmi_vendor_infoframe_from_display_mode(&frame, - &hdmi->conn, mode); + hdmi->curr_conn, mode); if (err) { dev_err(hdmi->dev, "Failed to get vendor infoframe from mode: %zd\n", err); @@ -1322,6 +1322,8 @@ static void mtk_hdmi_bridge_atomic_disable(struct drm_bridge *bridge, clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]); clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); + hdmi->curr_conn = NULL; + hdmi->enabled = false; } @@ -1385,8 +1387,13 @@ static void mtk_hdmi_send_infoframe(struct mtk_hdmi *hdmi, static void mtk_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_bridge_state *old_state) { + struct drm_atomic_state *state = old_state->base.state; struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); + /* Retrieve the connector through the atomic state. */ + hdmi->curr_conn = drm_atomic_get_new_connector_for_encoder(state, + bridge->encoder); + mtk_hdmi_output_set_display_mode(hdmi, &hdmi->mode); clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]); clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]); @@ -1625,8 +1632,10 @@ static int mtk_hdmi_audio_get_eld(struct device *dev, void *data, uint8_t *buf, { struct mtk_hdmi *hdmi = dev_get_drvdata(dev); - memcpy(buf, hdmi->conn.eld, min(sizeof(hdmi->conn.eld), len)); - + if (hdmi->enabled) + memcpy(buf, hdmi->curr_conn->eld, min(sizeof(hdmi->curr_conn->eld), len)); + else + memset(buf, 0, len); return 0; }
The mtk_hdmi does not support creating a bridge with a connector. Therefore the field 'conn' should be removed from the mtk_hdmi struct. It is replaced with a pointer curr_conn that points to the current connector which can be access through the global state. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)