drm/bridge: lt9611: several fixes and improvements
v2 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 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 | 332 ++++++++++-------------- 1 file changed, 133 insertions(+), 199 deletions(-)
Signature · 1 line
2.39.0
PATCH v2 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
Re: [PATCH v2 01/13] drm/bridge: lt9611: fix sleep mode setup
Quoted 20 lines · Dmitry Baryshkov
On
atomic_post_disablethe 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.Fixes 23278bf54afe ("drm/bridge: Introduce LT9611 DSI to HDMI bridge")Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +0
-1@@ -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 */
drivers/gpu/drm/bridge/lontium-lt9611.c static void lt9611_sleep_setup(struct lt9611 *lt9611) · line 458
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +2
-2+ { 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,
PATCH v2 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
Re: [PATCH v2 02/13] drm/bridge: lt9611: fix HPD reenablement
Quoted 26 lines · Dmitry Baryshkov
The 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.Fixes 23278bf54afe ("drm/bridge: Introduce LT9611 DSI to HDMI bridge")Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +6
-0@@ -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 }, + };
drivers/gpu/drm/bridge/lontium-lt9611.c static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge, · line 873
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +2
-2if (!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; }
PATCH v2 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
Re: [PATCH v2 03/13] drm/bridge: lt9611: fix polarity programming
Quoted 44 lines · Dmitry Baryshkov
Fix programming of hsync and vsync polarities
Fixes 23278bf54afe ("drm/bridge: Introduce LT9611 DSI to HDMI bridge")Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +11
-4@@ -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 :
drivers/gpu/drm/bridge/lontium-lt9611.c static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod · line 249
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-1@@ -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 ; }
PATCH v2 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
Re: [PATCH v2 04/13] drm/bridge: lt9611: fix programming of video modes
Quoted 13 lines · Dmitry Baryshkov
Program the upper part of the
hfront_porchinto the proper register.Fixes 23278bf54afe ("drm/bridge: Introduce LT9611 DSI to HDMI bridge")Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/bridge/lontium-lt9611.c +0
-0
drivers/gpu/drm/bridge/lontium-lt9611.c static void lt9611_mipi_video_setup(struct lt9611 *lt9611, · line 194
Quoted 9 lines
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 )); }
PATCH v2 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
Re: [PATCH v2 05/13] drm/bridge: lt9611: fix clock calculation
Quoted 80 lines · Dmitry Baryshkov
Instead of having several fixed values for the pcr register, calculate it before programming. This allows the bridge to support most of the display modes.
Fixes 23278bf54afe ("drm/bridge: Introduce LT9611 DSI to HDMI bridge")Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 32 +++++++++++-------------- 1 file changed, 14 insertions(+), 18 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +12
-16@@ -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);
drivers/gpu/drm/bridge/lontium-lt9611.c static void lt9611_bridge_mode_set(struct drm_bridge *bridge, · line 904
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +2
-2lt9611_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,
PATCH v2 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
Re: [PATCH v2 06/13] drm/bridge: lt9611: pass a pointer to the of node
Quoted 13 lines · Dmitry Baryshkov
Pass a pointer to the OF node while registering lt9611 MIPI device.
Fixes 23278bf54afe ("drm/bridge: Introduce LT9611 DSI to HDMI bridge")Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/bridge/lontium-lt9611.c +0
-0
drivers/gpu/drm/bridge/lontium-lt9611.c static const struct drm_connector_funcs lt9611_bridge_connector_funcs = { · line 775
Quoted 8 lines
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;
PATCH v2 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
Re: [PATCH v2 07/13] drm/bridge: lt9611: rework the mode_set function
Quoted 97 lines · Dmitry Baryshkov
The
mode_setcallback is deprectated fordrm_bridgesin favour of usingatomic_enablecallback. Move corresponding code into the functionlt9611_bridge_atomic_enable()and turnlt9611_bridge_pre_enable()into the properatomic_pre_enablecallback.Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 61 +++++++++++++++---------- 1 file changed, 36 insertions(+), 25 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +35
-24@@ -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,
drivers/gpu/drm/bridge/lontium-lt9611.c lt9611_atomic_get_input_bus_fmts(struct drm_bridge *bridge, · line 978
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-1.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,
PATCH v2 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
Re: [PATCH v2 08/13] drm/bridge: lt9611: attach to the next bridge
Quoted 185 lines · Dmitry Baryshkov
The 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.
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 99 ++----------------------- 1 file changed, 7 insertions(+), 92 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +6
-91@@ -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) {
drivers/gpu/drm/bridge/lontium-lt9611.c static int lt9611_parse_dt(struct device *dev, · line 916
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-1@@ -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)
PATCH v2 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
Re: [PATCH v2 09/13] drm/bridge: lt9611: fix sync polarity for DVI output
Quoted 33 lines · Dmitry Baryshkov
Attaching DVI sink to the lt9611 requires different setup. Fix the register write to make the DVI displays sync onto the correct sync pulse.
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +5
-2@@ -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 ); }
drivers/gpu/drm/bridge/lontium-lt9611.c lt9611_bridge_atomic_enable(struct drm_bridge *bridge, · line 728
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-1@@ -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 );
PATCH v2 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
Re: [PATCH v2 10/13] drm/bridge: lt9611: simplify video timings programming
Quoted 17 lines · Dmitry Baryshkov
Inline calculated values to simplify the calculation in
lt9611_mipi_video_setup().Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +0
-1@@ -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;
drivers/gpu/drm/bridge/lontium-lt9611.c static void lt9611_mipi_video_setup(struct lt9611 *lt9611, · line 166
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +2
-1+ 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 ));
PATCH v2 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
Re: [PATCH v2 11/13] drm/bridge: lt9611: rework infoframes handling
Quoted 98 lines · Dmitry Baryshkov
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.Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 57 +++++++++++++++++++------ 1 file changed, 44 insertions(+), 13 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +43
-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; -
drivers/gpu/drm/bridge/lontium-lt9611.c lt9611_bridge_atomic_enable(struct drm_bridge *bridge, · line 758
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-0if (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);
PATCH v2 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 | 41 +++---------------------- 1 file changed, 4 insertions(+), 37 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +4 -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,12 @@ 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 &&drm_mode_vrefresh (mode) >=31 ) +return MODE_CLOCK_HIGH ; + +if (mode->hdisplay >2000 && !lt9611->dsi1_node)return MODE_PANEL ;else return MODE_OK ;
Signature · 1 line
2.39.0
Neil Armstrong
maintainerRe: [PATCH v2 12/13] drm/bridge: lt9611: stop filtering modes via the table
Quoted 61 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 | 41 +++---------------------- 1 file changed, 4 insertions(+), 37 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +0
-33@@ -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);
drivers/gpu/drm/bridge/lontium-lt9611.c static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge, · line 804
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-4@@ -832,12 +799,12 @@ 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 &&drm_mode_vrefresh (mode) >=31 )
Isn't 31 a typo ?
Quoted 6 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +3
-0+return MODE_CLOCK_HIGH ; + +if (mode->hdisplay >2000 && !lt9611->dsi1_node)return MODE_PANEL ;else return MODE_OK ;
Re: [PATCH v2 12/13] drm/bridge: lt9611: stop filtering modes via the table
Quoted 67 lines · Neil Armstrong
Quoted 66 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| 41 +++----------------------1 file changed, 4 insertions(+), 37 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +0
-33@@ -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);drivers/gpu/drm/bridge/lontium-lt9611.c +0
-0@@ -832,12 +799,12 @@ 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) {
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611.c static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge, · line 804
Quoted 6 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-4- 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 && drm_mode_vrefresh(mode) >= 31)Isn't 31 a typo ?
Maybe I should change that to drm_mode_vrefresh(mode) > 30. The chip supports 3840x2160-30, but doesn't promise to support anything above that.
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +3
-0+ return MODE_CLOCK_HIGH; + + if (mode->hdisplay > 2000 && !lt9611->dsi1_node) return MODE_PANEL;else
returnMODE_OK;
Signature · 2 lines
With best wishes Dmitry
[email protected]
maintainerRe: [PATCH v2 12/13] drm/bridge: lt9611: stop filtering modes via the table
Quoted 73 lines · Dmitry Baryshkov
Quoted 63 lines · Neil Armstrong
Quoted 62 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| 41 +++----------------------1 file changed, 4 insertions(+), 37 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +0
-33@@ -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,12 @@ 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) {Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611.c static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge, · line 804
Quoted 6 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-4- 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 && drm_mode_vrefresh(mode) >= 31)Isn't 31 a typo ?
Quoted 1 line
Maybe I should change that to
drm_mode_vrefresh(mode)> 30. The chip supports 3840x2160-30, but doesn't promise to support anything above that.
Yep >= 31 is valid, but > 30 seems more logical.
Concerning the hdisplay check, shouldn't be separate ?
You should switch to:
if (mode->hdisplay > 3840)
return MODE_BAD_WIDTH;
if (mode->hdisplay == 3840 && drm_mode_vrefresh(mode) > 30)
return MODE_CLOCK_HIGH;
Isn't there limits on vdisplay aswell ?
Neil
Quoted 10 lines
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +3
-0+ return MODE_CLOCK_HIGH; + + if (mode->hdisplay > 2000 && !lt9611->dsi1_node) return MODE_PANEL;else
returnMODE_OK;
Re: [PATCH v2 12/13] drm/bridge: lt9611: stop filtering modes via the table
Quoted 83 lines · On 12/01/2023 10:43, [email protected] wrote:
Quoted 78 lines · Dmitry Baryshkov
Quoted 68 lines · Neil Armstrong
Quoted 67 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| 41
+++----------------------1 file changed, 4 insertions(+), 37 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +0
-33@@ -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);drivers/gpu/drm/bridge/lontium-lt9611.c +0
-0@@ -832,12 +799,12 @@ 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) {Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611.c static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge, · line 804
Quoted 6 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +1
-4- 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 && drm_mode_vrefresh(mode) >= 31)Isn't 31 a typo ?
Quoted 1 line
Maybe I should change that to
drm_mode_vrefresh(mode)> 30. The chip supports 3840x2160-30, but doesn't promise to support anything above that.Yep >= 31 is valid, but > 30 seems more logical.
Quoted 8 lines
Concerning the hdisplay check, shouldn't be separate ?
You should switch to:
if (mode->hdisplay> 3840)
returnMODE_BAD_WIDTH;if (
mode->hdisplay== 3840 &&drm_mode_vrefresh(mode)> 30)
returnMODE_CLOCK_HIGH;
Good idea, I'll adapt it for v3.
Quoted 2 lines
Isn't there limits on vdisplay aswell ?
I don't see any special limit in the datasheet. HDMI 1.4, 4k@30, that's all. I think I'll just add vdisply > 2160 check next to hdisplay.
Quoted 14 lines
Neil
Quoted 10 lines
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +3
-0+ return MODE_CLOCK_HIGH; + + if (mode->hdisplay > 2000 && !lt9611->dsi1_node) return MODE_PANEL;else
returnMODE_OK;
Signature · 2 lines
With best wishes Dmitry
PATCH v2 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
Re: [PATCH v2 13/13] drm/bridge: lt9611: properly program the dual host mode
Quoted 52 lines · Dmitry Baryshkov
If 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.
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/bridge/lontium-lt9611.c | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-)drivers/gpu/drm/bridge/lontium-lt9611.c +6
-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 ;
drivers/gpu/drm/bridge/lontium-lt9611.c static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod · line 216
Quoted 10 lines
drivers/gpu/drm/bridge/lontium-lt9611.c +7
-0+ 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);