drm/bridge: lt9611: several fixes and improvements
cover drm/bridge: lt9611: several fixes and improvements
A series of patches to fix mode programming for the Lontium lt9611 DSI-to-HDMI bridge (found e.g. on the Thundercomm RB3/Dragonboard845c platform).
Changes since v2:
- Rewrote mode_valid callback to be more explicit.
Changes since v1:
- Fixed the double-DSI check to look for the lt9611->dsi1_node rather than lt9611->dsi1, modesetting happens before lt9611->dsi1 is set.
- Added full dual-DSI support, properly enabling the 4k modes on RB3.
Dmitry Baryshkov (13):
drm/bridge: lt9611: fix sleep mode setup drm/bridge: lt9611: fix HPD reenablement drm/bridge: lt9611: fix polarity programming drm/bridge: lt9611: fix programming of video modes drm/bridge: lt9611: fix clock calculation drm/bridge: lt9611: pass a pointer to the of node drm/bridge: lt9611: rework the mode_set function drm/bridge: lt9611: attach to the next bridge drm/bridge: lt9611: fix sync polarity for DVI output drm/bridge: lt9611: simplify video timings programming drm/bridge: lt9611: rework infoframes handling drm/bridge: lt9611: stop filtering modes via the table drm/bridge: lt9611: properly program the dual host mode
drivers/gpu/drm/bridge/lontium-lt9611.c | 340 ++++++++++-------------- 1 file changed, 141 insertions(+), 199 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/13 drm/bridge: lt9611: fix sleep mode setup
On atomic_post_disable the bridge goes to the low power state. However the code disables too much of the chip, so the HPD event is not being detected and delivered to the host. Reduce the power saving in order to get the HPD event.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +2 -3
@@ -448,12 +448,11 @@ static void lt9611_sleep_setup(struct lt9611 *lt9611) { 0x8023, 0x01 }, { 0x8157, 0x03 }, /* set addr pin as output */ { 0x8149, 0x0b }, - { 0x8151, 0x30 }, /* disable IRQ */ + { 0x8102, 0x48 }, /* MIPI Rx power down */ { 0x8123, 0x80 }, { 0x8130, 0x00 }, - { 0x8100, 0x01 }, /* bandgap power down */ - { 0x8101, 0x00 }, /* system clk power down */ + { 0x8011, 0x0a }, }; regmap_multi_reg_write(lt9611->regmap,
Signature · 1 line
2.39.0
PATCH 2/13 drm/bridge: lt9611: fix HPD reenablement
In reply to Dmitry BaryshkovThe driver will reset the bridge in the atomic_pre_enable(). However this will also drop the HPD interrupt state. Instead of resetting the bridge, properly wake it up. This fixes the HPD interrupt delivery after the disable/enable cycle.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +8 -2
@@ -856,12 +856,18 @@ static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge,static void lt9611_bridge_pre_enable (struct drm_bridge *bridge) {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge); +static const struct reg_sequence reg_cfg[] = { + {0x8102 ,0x12 }, + {0x8123 ,0x40 }, + {0x8130 ,0xea }, + {0x8011 ,0xfa }, + };if (!lt9611->sleep)return ; -lt9611_reset (lt9611); -regmap_write (lt9611->regmap,0x80ee ,0x01 ); +regmap_multi_reg_write (lt9611->regmap, + reg_cfg,ARRAY_SIZE (reg_cfg)); lt9611->sleep = false; }
Signature · 1 line
2.39.0
PATCH 3/13 drm/bridge: lt9611: fix polarity programming
In reply to Dmitry BaryshkovFix programming of hsync and vsync polarities
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +12 -5
@@ -207,7 +207,6 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod/* stage 2 */ { 0x834a, 0x40 }, - { 0x831d, 0x10 },/* MK limit */ { 0x832d, 0x38 },
@@ -222,11 +221,19 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod { 0x8325, 0x00 }, { 0x832a, 0x01 }, { 0x834a, 0x10 }, - { 0x831d, 0x10 }, - { 0x8326, 0x37 }, }; +u8 pol =0x10 ; -regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg)); +if (mode->flags &DRM_MODE_FLAG_NHSYNC ) + pol |=0x2 ; +if (mode->flags &DRM_MODE_FLAG_NVSYNC ) + pol |=0x1 ; +regmap_write (lt9611->regmap,0x831d , pol); + +if (mode->hdisplay ==3840 ) +regmap_multi_reg_write (lt9611->regmap, reg_cfg2,ARRAY_SIZE (reg_cfg2)); +else +regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg));switch (mode->hdisplay) {case 640 :
@@ -236,7 +243,7 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_modregmap_write (lt9611->regmap,0x8326 ,0x37 );break ;case 3840 : -regmap_multi_reg_write (lt9611->regmap, reg_cfg2,ARRAY_SIZE (reg_cfg2)); +regmap_write (lt9611->regmap,0x8326 ,0x37 );break ; }
Signature · 1 line
2.39.0
PATCH 4/13 drm/bridge: lt9611: fix programming of video modes
In reply to Dmitry BaryshkovProgram the upper part of the hfront_porch into the proper register.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +2 -1
@@ -187,7 +187,8 @@ static void lt9611_mipi_video_setup(struct lt9611 *lt9611,regmap_write (lt9611->regmap,0x8319 , (u8)(hfront_porch %256 )); -regmap_write (lt9611->regmap,0x831a , (u8)(hsync_porch /256 )); +regmap_write (lt9611->regmap,0x831a , (u8)(hsync_porch /256 ) | + ((hfront_porch /256 ) <<4 ));regmap_write (lt9611->regmap,0x831b , (u8)(hsync_porch %256 )); }
Signature · 1 line
2.39.0
PATCH 5/13 drm/bridge: lt9611: fix clock calculation
In reply to Dmitry BaryshkovInstead of having several fixed values for the pcr register, calculate it before programming. This allows the bridge to support most of the display modes.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 32 +++++++++++-------------- 1 file changed, 14 insertions(+), 18 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +14 -18
@@ -192,8 +192,9 @@ static void lt9611_mipi_video_setup(struct lt9611 *lt9611,regmap_write (lt9611->regmap,0x831b , (u8)(hsync_porch %256 )); } -static void lt9611_pcr_setup (struct lt9611 *lt9611,const struct drm_display_mode *mode) +static void lt9611_pcr_setup (struct lt9611 *lt9611,const struct drm_display_mode *mode,unsigned int postdiv) { +unsigned int pcr_m = mode->clock *5 * postdiv /27000 ;const struct reg_sequence reg_cfg[] = { {0x830b ,0x01 }, {0x830c ,0x10 },
@@ -236,24 +237,14 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_modelse regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg)); -switch (mode->hdisplay) { -case 640 : -regmap_write (lt9611->regmap,0x8326 ,0x14 ); -break ; -case 1920 : -regmap_write (lt9611->regmap,0x8326 ,0x37 ); -break ; -case 3840 : -regmap_write (lt9611->regmap,0x8326 ,0x37 ); -break ; - } +regmap_write (lt9611->regmap,0x8326 , pcr_m);/* pcr rst */ regmap_write (lt9611->regmap,0x8011 ,0x5a );regmap_write (lt9611->regmap,0x8011 ,0xfa ); } -static int lt9611_pll_setup (struct lt9611 *lt9611,const struct drm_display_mode *mode) +static int lt9611_pll_setup (struct lt9611 *lt9611,const struct drm_display_mode *mode,unsigned int *postdiv) {unsigned int pclk = mode->clock; const struct reg_sequence reg_cfg[] = {
@@ -271,12 +262,16 @@ static int lt9611_pll_setup(struct lt9611 *lt9611, const struct drm_display_moderegmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg)); -if (pclk >150000 ) +if (pclk >150000 ) {regmap_write (lt9611->regmap,0x812d ,0x88 ); -else if (pclk >70000 ) + *postdiv =1 ; + }else if (pclk >70000 ) {regmap_write (lt9611->regmap,0x812d ,0x99 ); -else + *postdiv =2 ; + }else {regmap_write (lt9611->regmap,0x812d ,0xaa ); + *postdiv =4 ; + }/* * first divide pclk by 2 first
@@ -895,14 +890,15 @@ static void lt9611_bridge_mode_set(struct drm_bridge *bridge, {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge);struct hdmi_avi_infoframe avi_frame; +unsigned int postdiv;int ret;lt9611_bridge_pre_enable (bridge);lt9611_mipi_input_digital (lt9611, mode); -lt9611_pll_setup (lt9611, mode); +lt9611_pll_setup (lt9611, mode, &postdiv);lt9611_mipi_video_setup (lt9611, mode); -lt9611_pcr_setup (lt9611, mode); +lt9611_pcr_setup (lt9611, mode, postdiv); ret = drm_hdmi_avi_infoframe_from_display_mode(&avi_frame, <9611->connector,
Signature · 1 line
2.39.0
PATCH 6/13 drm/bridge: lt9611: pass a pointer to the of node
In reply to Dmitry BaryshkovPass a pointer to the OF node while registering lt9611 MIPI device.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +1 -1
@@ -769,7 +769,7 @@ static const struct drm_connector_funcs lt9611_bridge_connector_funcs = {static struct mipi_dsi_device *lt9611_attach_dsi (struct lt9611 *lt9611,struct device_node *dsi_node) { -const struct mipi_dsi_device_info info = {"lt9611" ,0 ,NULL }; +const struct mipi_dsi_device_info info = {"lt9611" ,0 , lt9611->dev->of_node};struct mipi_dsi_device *dsi;struct mipi_dsi_host *host;struct device *dev = lt9611->dev;
Signature · 1 line
2.39.0
PATCH 7/13 drm/bridge: lt9611: rework the mode_set function
In reply to Dmitry BaryshkovThe mode_set callback is deprectated for drm_bridges in favour of using atomic_enable callback. Move corresponding code into the function lt9611_bridge_atomic_enable() and turn lt9611_bridge_pre_enable() into the proper atomic_pre_enable callback.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 61 +++++++++++++++---------- 1 file changed, 36 insertions(+), 25 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +36 -25
@@ -713,6 +713,39 @@ lt9611_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_bridge_state *old_bridge_state) {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge); +struct drm_atomic_state *state = old_bridge_state->base.state; +struct drm_connector *connector; +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)) +return ; + + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (WARN_ON (!conn_state)) +return ; + + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); +if (WARN_ON (!crtc_state)) +return ; + + mode = &crtc_state->adjusted_mode; + +lt9611_mipi_input_digital (lt9611, mode); +lt9611_pll_setup (lt9611, mode, &postdiv); +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" );
@@ -856,7 +889,8 @@ static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge,return MODE_OK ; } -static void lt9611_bridge_pre_enable (struct drm_bridge *bridge) +static void lt9611_bridge_atomic_pre_enable (struct drm_bridge *bridge, +struct drm_bridge_state *old_bridge_state) {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge);static const struct reg_sequence reg_cfg[] = {
@@ -884,29 +918,6 @@ lt9611_bridge_atomic_post_disable(struct drm_bridge *bridge,lt9611_sleep_setup (lt9611); } -static void lt9611_bridge_mode_set (struct drm_bridge *bridge, -const struct drm_display_mode *mode, -const struct drm_display_mode *adj_mode) -{ -struct lt9611 *lt9611 =bridge_to_lt9611 (bridge); -struct hdmi_avi_infoframe avi_frame; -unsigned int postdiv; -int ret; - -lt9611_bridge_pre_enable (bridge); - -lt9611_mipi_input_digital (lt9611, mode); -lt9611_pll_setup (lt9611, mode, &postdiv); -lt9611_mipi_video_setup (lt9611, mode); -lt9611_pcr_setup (lt9611, mode, postdiv); - - ret =drm_hdmi_avi_infoframe_from_display_mode (&avi_frame, - <9611->connector, - mode); -if (!ret) - lt9611->vic = avi_frame.video_code; -} -static enum drm_connector_status lt9611_bridge_detect (struct drm_bridge *bridge) {return __lt9611_detect (bridge_to_lt9611 (bridge));
@@ -957,11 +968,11 @@ lt9611_atomic_get_input_bus_fmts(struct drm_bridge *bridge,static const struct drm_bridge_funcs lt9611_bridge_funcs = { .attach = lt9611_bridge_attach, .mode_valid = lt9611_bridge_mode_valid, - .mode_set = lt9611_bridge_mode_set, .detect = lt9611_bridge_detect, .get_edid = lt9611_bridge_get_edid, .hpd_enable = lt9611_bridge_hpd_enable, + .atomic_pre_enable = lt9611_bridge_atomic_pre_enable, .atomic_enable = lt9611_bridge_atomic_enable, .atomic_disable = lt9611_bridge_atomic_disable, .atomic_post_disable = lt9611_bridge_atomic_post_disable,
Signature · 1 line
2.39.0
PATCH 8/13 drm/bridge: lt9611: attach to the next bridge
In reply to Dmitry BaryshkovThe bindings require that there is a next bridge after the lt9611. If nothing else it can be the hdmi-connector (as used on the RB3 platform, see sdm845-db845c.dts).
Bring in the next bridge into the drm bridges chain and attach to it.
Since lt9611 is not anymore the last bridge in the chain, this also allows us to drop all the !DRM_BRIDGE_ATTACH_NO_CONNECTOR functionality.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 99 ++----------------------- 1 file changed, 7 insertions(+), 92 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +7 -92
@@ -19,6 +19,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_bridge.h> #include <drm/drm_mipi_dsi.h> +#include <drm/drm_of.h> #include <drm/drm_print.h> #include <drm/drm_probe_helper.h>
@@ -33,7 +34,7 @@struct lt9611 {struct device *dev;struct drm_bridge bridge; -struct drm_connector connector; +struct drm_bridge *next_bridge;struct regmap *regmap;
@@ -107,11 +108,6 @@ static struct lt9611 *bridge_to_lt9611(struct drm_bridge *bridge) return container_of(bridge, struct lt9611, bridge); } -static struct lt9611 *connector_to_lt9611 (struct drm_connector *connector) -{ - return container_of(connector, struct lt9611, connector); -} -static int lt9611_mipi_input_analog (struct lt9611 *lt9611) {const struct reg_sequence reg_cfg[] = {
@@ -581,9 +577,9 @@ static struct lt9611_mode *lt9611_find_mode(const struct drm_display_mode *mode)return NULL ; } -/* connector funcs */ -static enum drm_connector_status __lt9611_detect (struct lt9611 *lt9611) +static enum drm_connector_status lt9611_bridge_detect (struct drm_bridge *bridge) { +struct lt9611 *lt9611 =bridge_to_lt9611 (bridge);unsigned int reg_val =0 ;int connected =0 ;
@@ -596,12 +592,6 @@ static enum drm_connector_status __lt9611_detect(struct lt9611 *lt9611)return lt9611->status; } -static enum drm_connector_status -lt9611_connector_detect (struct drm_connector *connector,bool force) -{ -return __lt9611_detect (connector_to_lt9611 (connector)); -} -static int lt9611_read_edid (struct lt9611 *lt9611) {unsigned int temp;
@@ -683,30 +673,6 @@ lt9611_get_edid_block(void *data, u8 *buf, unsigned int block, size_t len)return 0 ; } -static int lt9611_connector_get_modes (struct drm_connector *connector) -{ -struct lt9611 *lt9611 =connector_to_lt9611 (connector); -unsigned int count; -struct edid *edid; - -lt9611_power_on (lt9611); - edid =drm_do_get_edid (connector, lt9611_get_edid_block, lt9611); -drm_connector_update_edid_property (connector, edid); - count =drm_add_edid_modes (connector, edid); -kfree (edid); - -return count; -} - -static enum drm_mode_status -lt9611_connector_mode_valid (struct drm_connector *connector, -struct drm_display_mode *mode) -{ -struct lt9611_mode *lt9611_mode =lt9611_find_mode (mode); - -return lt9611_mode ?MODE_OK :MODE_BAD ; -} -/* bridge funcs */ static void lt9611_bridge_atomic_enable(struct drm_bridge *bridge,
@@ -784,21 +750,6 @@ lt9611_bridge_atomic_disable(struct drm_bridge *bridge, } } -static struct -drm_connector_helper_funcs lt9611_bridge_connector_helper_funcs = { - .get_modes = lt9611_connector_get_modes, - .mode_valid = lt9611_connector_mode_valid, -}; - -static const struct drm_connector_funcs lt9611_bridge_connector_funcs = { - .fill_modes = drm_helper_probe_single_connector_modes, - .detect = lt9611_connector_detect, - .destroy = drm_connector_cleanup, - .reset = drm_atomic_helper_connector_reset, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, -}; -static struct mipi_dsi_device *lt9611_attach_dsi (struct lt9611 *lt9611,struct device_node *dsi_node) {
@@ -834,44 +785,13 @@ static struct mipi_dsi_device *lt9611_attach_dsi(struct lt9611 *lt9611,return dsi; } -static int lt9611_connector_init (struct drm_bridge *bridge,struct lt9611 *lt9611) -{ -int ret; - - ret =drm_connector_init (bridge->dev, <9611->connector, - <9611_bridge_connector_funcs, -DRM_MODE_CONNECTOR_HDMIA ); -if (ret) { -DRM_ERROR ("Failed to initialize connector with drm\n" ); -return ret; - } - -drm_connector_helper_add (<9611->connector, - <9611_bridge_connector_helper_funcs); - -if (!bridge->encoder) { -DRM_ERROR ("Parent encoder object not found" ); -return -ENODEV ; - } - -drm_connector_attach_encoder (<9611->connector, bridge->encoder); - -return 0 ; -} -static int lt9611_bridge_attach (struct drm_bridge *bridge,enum drm_bridge_attach_flags flags) {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge); -int ret; - -if (!(flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR )) { - ret =lt9611_connector_init (bridge, lt9611); -if (ret <0 ) -return ret; - } -return 0 ; +return drm_bridge_attach (bridge->encoder, lt9611->next_bridge, + bridge, flags); } static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge,
@@ -918,11 +838,6 @@ lt9611_bridge_atomic_post_disable(struct drm_bridge *bridge,lt9611_sleep_setup (lt9611); } -static enum drm_connector_status lt9611_bridge_detect (struct drm_bridge *bridge) -{ -return __lt9611_detect (bridge_to_lt9611 (bridge)); -} -static struct edid *lt9611_bridge_get_edid (struct drm_bridge *bridge,struct drm_connector *connector) {
@@ -995,7 +910,7 @@ static int lt9611_parse_dt(struct device *dev, lt9611->ac_mode =of_property_read_bool (dev->of_node,"lt,ac-mode" ); -return 0 ; +return drm_of_find_panel_or_bridge (dev->of_node,2 ,-1 ,NULL , <9611->next_bridge); }static int lt9611_gpio_init (struct lt9611 *lt9611)
Signature · 1 line
2.39.0
PATCH 9/13 drm/bridge: lt9611: fix sync polarity for DVI output
In reply to Dmitry BaryshkovAttaching DVI sink to the lt9611 requires different setup. Fix the register write to make the DVI displays sync onto the correct sync pulse.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +6 -3
@@ -352,13 +352,16 @@ static int lt9611_video_check(struct lt9611 *lt9611)return temp; } -static void lt9611_hdmi_tx_digital (struct lt9611 *lt9611) +static void lt9611_hdmi_tx_digital (struct lt9611 *lt9611,bool is_hdmi) {regmap_write (lt9611->regmap,0x8443 ,0x46 - lt9611->vic);regmap_write (lt9611->regmap,0x8447 , lt9611->vic);regmap_write (lt9611->regmap,0x843d ,0x0a );/* UD1 infoframe */ -regmap_write (lt9611->regmap,0x82d6 ,0x8c ); +if (is_hdmi) +regmap_write (lt9611->regmap,0x82d6 ,0x8c ); +else +regmap_write (lt9611->regmap,0x82d6 ,0x0c );regmap_write (lt9611->regmap,0x82d7 ,0x04 ); }
@@ -719,7 +722,7 @@ lt9611_bridge_atomic_enable(struct drm_bridge *bridge, }lt9611_mipi_input_analog (lt9611); -lt9611_hdmi_tx_digital (lt9611); +lt9611_hdmi_tx_digital (lt9611, connector->display_info.is_hdmi);lt9611_hdmi_tx_phy (lt9611);msleep (500 );
Signature · 1 line
2.39.0
PATCH 10/13 drm/bridge: lt9611: simplify video timings programming
In reply to Dmitry BaryshkovInline calculated values to simplify the calculation in lt9611_mipi_video_setup().
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +2 -2
@@ -155,12 +155,12 @@ static void lt9611_mipi_video_setup(struct lt9611 *lt9611, hactive = mode->hdisplay; hsync_len = mode->hsync_end - mode->hsync_start; hfront_porch = mode->hsync_start - mode->hdisplay; - hsync_porch = hsync_len + mode->htotal - mode->hsync_end; + hsync_porch = mode->htotal - mode->hsync_start; vactive = mode->vdisplay; vsync_len = mode->vsync_end - mode->vsync_start; vfront_porch = mode->vsync_start - mode->vdisplay; - vsync_porch = vsync_len + mode->vtotal - mode->vsync_end; + vsync_porch = mode->vtotal - mode->vsync_start;regmap_write (lt9611->regmap,0x830d , (u8)(v_total /256 ));regmap_write (lt9611->regmap,0x830e , (u8)(v_total %256 ));
Signature · 1 line
2.39.0
PATCH 11/13 drm/bridge: lt9611: rework infoframes handling
In reply to Dmitry BaryshkovRework 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.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 57 +++++++++++++++++++------ 1 file changed, 44 insertions(+), 13 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +44 -13
@@ -59,7 +59,6 @@ struct lt9611 {enum drm_connector_status status;u8 edid_buf[EDID_SEG_SIZE ]; -u32 vic; };#define LT9611_PAGE_CONTROL 0xff
@@ -352,12 +351,51 @@ static int lt9611_video_check(struct lt9611 *lt9611)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
@@ -687,9 +725,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))
@@ -710,18 +746,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);
Signature · 1 line
2.39.0
PATCH 12/13 drm/bridge: lt9611: stop filtering modes via the table
In reply to Dmitry BaryshkovThe lt9611 bridge can support different modes, it makes no sense to list them in the table. Drop the table and check the number of interfaces using the fixed value.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 49 ++++++------------------- 1 file changed, 12 insertions(+), 37 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +12 -37
@@ -84,24 +84,6 @@ static const struct regmap_config lt9611_regmap_config = { .num_ranges = ARRAY_SIZE(lt9611_ranges), }; -struct lt9611_mode { -u16 hdisplay; -u16 vdisplay; -u8 vrefresh; -u8 lanes; -u8 intfs; -}; - -static struct lt9611_mode lt9611_modes[] = { - {3840 ,2160 ,30 ,4 ,2 },/* 3840x2160 24bit 30Hz 4Lane 2ports */ - {1920 ,1080 ,60 ,4 ,1 },/* 1080P 24bit 60Hz 4lane 1port */ - {1920 ,1080 ,30 ,3 ,1 },/* 1080P 24bit 30Hz 3lane 1port */ - {1920 ,1080 ,24 ,3 ,1 }, - {720 ,480 ,60 ,4 ,1 }, - {720 ,576 ,50 ,2 ,1 }, - {640 ,480 ,60 ,2 ,1 }, -}; -static struct lt9611 *bridge_to_lt9611 (struct drm_bridge *bridge) { return container_of(bridge, struct lt9611, bridge);
@@ -603,21 +585,6 @@ static int lt9611_regulator_enable(struct lt9611 *lt9611)return 0 ; } -static struct lt9611_mode *lt9611_find_mode (const struct drm_display_mode *mode) -{ -int i; - -for (i =0 ; i <ARRAY_SIZE (lt9611_modes); i++) { -if (lt9611_modes[i].hdisplay == mode->hdisplay && - lt9611_modes[i].vdisplay == mode->vdisplay && - lt9611_modes[i].vrefresh ==drm_mode_vrefresh (mode)) { -return <9611_modes[i]; - } - } - -return NULL ; -} -static enum drm_connector_status lt9611_bridge_detect (struct drm_bridge *bridge) {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge);
@@ -832,12 +799,20 @@ static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge,const struct drm_display_info *info, const struct drm_display_mode *mode) { - struct lt9611_mode *lt9611_mode = lt9611_find_mode(mode); struct lt9611 *lt9611 = bridge_to_lt9611(bridge); -if (!lt9611_mode) -return MODE_BAD ; -else if (lt9611_mode->intfs >1 && !lt9611->dsi1) +if (mode->hdisplay >3840 ) +return MODE_BAD_HVALUE ; + +if (mode->vdisplay >2160 ) +return MODE_BAD_VVALUE ; + +if (mode->hdisplay ==3840 && + mode->vdisplay ==2160 && +drm_mode_vrefresh (mode) >30 ) +return MODE_CLOCK_HIGH ; + +if (mode->hdisplay >2000 && !lt9611->dsi1_node)return MODE_PANEL ;else return MODE_OK ;
Signature · 1 line
2.39.0
Re: [PATCH 12/13] drm/bridge: lt9611: stop filtering modes via the table
Quoted 75 lines · Dmitry Baryshkov
The lt9611 bridge can support different modes, it makes no sense to list them in the table. Drop the table and check the number of interfaces using the fixed value.
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 49 ++++++------------------- 1 file changed, 12 insertions(+), 37 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +5
-37@@ -84,24 +84,6 @@ static const struct regmap_config lt9611_regmap_config = { .num_ranges = ARRAY_SIZE(lt9611_ranges), }; -struct lt9611_mode { -u16 hdisplay; -u16 vdisplay; -u8 vrefresh; -u8 lanes; -u8 intfs; -}; - -static struct lt9611_mode lt9611_modes[] = { - {3840 ,2160 ,30 ,4 ,2 },/* 3840x2160 24bit 30Hz 4Lane 2ports */ - {1920 ,1080 ,60 ,4 ,1 },/* 1080P 24bit 60Hz 4lane 1port */ - {1920 ,1080 ,30 ,3 ,1 },/* 1080P 24bit 30Hz 3lane 1port */ - {1920 ,1080 ,24 ,3 ,1 }, - {720 ,480 ,60 ,4 ,1 }, - {720 ,576 ,50 ,2 ,1 }, - {640 ,480 ,60 ,2 ,1 }, -}; -static struct lt9611 *bridge_to_lt9611 (struct drm_bridge *bridge) { return container_of(bridge, struct lt9611, bridge);@@ -603,21 +585,6 @@ static int lt9611_regulator_enable(struct lt9611 *lt9611)return 0 ; } -static struct lt9611_mode *lt9611_find_mode (const struct drm_display_mode *mode) -{ -int i; - -for (i =0 ; i <ARRAY_SIZE (lt9611_modes); i++) { -if (lt9611_modes[i].hdisplay == mode->hdisplay && - lt9611_modes[i].vdisplay == mode->vdisplay && - lt9611_modes[i].vrefresh ==drm_mode_vrefresh (mode)) { -return <9611_modes[i]; - } - } - -return NULL ; -} -static enum drm_connector_status lt9611_bridge_detect (struct drm_bridge *bridge) {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge);@@ -832,12 +799,20 @@ static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge,const struct drm_display_info *info, const struct drm_display_mode *mode) { - struct lt9611_mode *lt9611_mode = lt9611_find_mode(mode); struct lt9611 *lt9611 = bridge_to_lt9611(bridge); -if (!lt9611_mode) -return MODE_BAD ; -else if (lt9611_mode->intfs >1 && !lt9611->dsi1) +if (mode->hdisplay >3840 ) +return MODE_BAD_HVALUE ; + +if (mode->vdisplay >2160 ) +return MODE_BAD_VVALUE ;
drivers/gpu/drm/bridge/lontium-lt9611.c static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge, · line 818
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +7
-0+ +if (mode->hdisplay ==3840 && + mode->vdisplay ==2160 && +drm_mode_vrefresh (mode) >30 ) +return MODE_CLOCK_HIGH ; + +if (mode->hdisplay >2000 && !lt9611->dsi1_node)return MODE_PANEL ;else return MODE_OK ;
PATCH 13/13 drm/bridge: lt9611: properly program the dual host mode
In reply to Dmitry BaryshkovIf the bridge is connected using both DSI ports, the driver should use both of them all the time. Correct programming sequence to always use dual-port mode if both dsi0 and dsi1 are connected.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +13 -15
@@ -118,7 +118,7 @@ static int lt9611_mipi_input_digital(struct lt9611 *lt9611, { 0x8306, 0x0a }, }; -if (mode->hdisplay ==3840 ) +if (lt9611->dsi1_node) reg_cfg[1 ].def =0x03 ;return regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg));
@@ -191,16 +191,6 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod { 0x832d, 0x38 }, { 0x8331, 0x08 }, }; -const struct reg_sequence reg_cfg2[] = { - {0x830b ,0x03 }, - {0x830c ,0xd0 }, - {0x8348 ,0x03 }, - {0x8349 ,0xe0 }, - {0x8324 ,0x72 }, - {0x8325 ,0x00 }, - {0x832a ,0x01 }, - {0x834a ,0x10 }, - };u8 pol =0x10 ;if (mode->flags &DRM_MODE_FLAG_NHSYNC )
@@ -209,10 +199,18 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod pol |=0x1 ;regmap_write (lt9611->regmap,0x831d , pol); -if (mode->hdisplay ==3840 ) -regmap_multi_reg_write (lt9611->regmap, reg_cfg2,ARRAY_SIZE (reg_cfg2)); -else -regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg)); +regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg)); +if (lt9611->dsi1_node) { +unsigned int hact = mode->hdisplay; + + hact >>=2 ; + hact +=0x50 ; + hact =min (hact,0x3e0U ); +regmap_write (lt9611->regmap,0x830b , hact /256 ); +regmap_write (lt9611->regmap,0x830c , hact %256 ); +regmap_write (lt9611->regmap,0x8348 , hact /256 ); +regmap_write (lt9611->regmap,0x8349 , hact %256 ); + }regmap_write (lt9611->regmap,0x8326 , pcr_m);
Signature · 1 line
2.39.0
Hi,
Quoted 8 lines · Dmitry Baryshkov
A series of patches to fix mode programming for the Lontium lt9611 DSI-to-HDMI bridge (found e.g. on the Thundercomm RB3/Dragonboard845c platform).
Changes since v2:
- Rewrotemode_validcallback to be more explicit.[...]
Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-next)
[01/13] drm/bridge: lt9611: fix sleep mode setup
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=ae2d329f104b75a0a78dcaded29fe6283289cdf9 [02/13] drm/bridge: lt9611: fix HPD reenablement https://cgit.freedesktop.org/drm/drm-misc/commit/?id=a7790f6bd38f3642b60ae3504a2c749135b89451 [03/13] drm/bridge: lt9611: fix polarity programming https://cgit.freedesktop.org/drm/drm-misc/commit/?id=0b157efa384ea417304b1da284ee2f603c607fc3 [04/13] drm/bridge: lt9611: fix programming of video modes https://cgit.freedesktop.org/drm/drm-misc/commit/?id=ad188aa47edaa033a270e1a3efae43836ff47569 [05/13] drm/bridge: lt9611: fix clock calculation https://cgit.freedesktop.org/drm/drm-misc/commit/?id=2576eb26494eb0509dd9ceb0cd27771a7a5e3674 [06/13] drm/bridge: lt9611: pass a pointer to the of node https://cgit.freedesktop.org/drm/drm-misc/commit/?id=b0a7f8736789935f62d6df32d441cdf05a5c05d2 [07/13] drm/bridge: lt9611: rework the mode_set function https://cgit.freedesktop.org/drm/drm-misc/commit/?id=fad97f2811933085adb3dc3b13b2e1cf985295b1 [08/13] drm/bridge: lt9611: attach to the next bridge https://cgit.freedesktop.org/drm/drm-misc/commit/?id=0c3997b0fec74a828ef258851e2fb260e3e7620c [09/13] drm/bridge: lt9611: fix sync polarity for DVI output https://cgit.freedesktop.org/drm/drm-misc/commit/?id=0c7474694849b44cfdf4e22b41e8f3eb85d78709 [10/13] drm/bridge: lt9611: simplify video timings programming https://cgit.freedesktop.org/drm/drm-misc/commit/?id=6b089d5e35d6daf3d348a3fbd8974d4ed896a231 [11/13] drm/bridge: lt9611: rework infoframes handling https://cgit.freedesktop.org/drm/drm-misc/commit/?id=84cf74d99f88bc476678254310baffddfba68bb6 [12/13] drm/bridge: lt9611: stop filtering modes via the table https://cgit.freedesktop.org/drm/drm-misc/commit/?id=4914cbc4fbadf0a3bcad9b0b09b3d8005a3dcd9e [13/13] drm/bridge: lt9611: properly program the dual host mode https://cgit.freedesktop.org/drm/drm-misc/commit/?id=5e83f359d9805b3561f160afafddfa7572155d1c
Signature · 1 line
Neil