drm/bridge: tc358767: Fix odd pixel alignment
Subsystems (3)
PATCH 1/1 drm/bridge: tc358767: Fix odd pixel alignment
Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register bitfields description state "These bits must be multiple of even pixel". It is not possible to simply align every bitfield to the nearest even pixel, because that would unalign the line width and cause visible distortion. Instead, attempt to re-align the timings such that the hardware requirement is fulfilled without changing the line width if at all possible.
Warn the user in case a panel with odd active pixel width or full line width is used, this is not possible to support with this one bridge.
---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
--- drivers/gpu/drm/bridge/tc358767.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/tc358767.c +60 -3
@@ -901,6 +901,63 @@ static int tc_set_common_video_mode(struct tc_data *tc,int vsync_len = mode->vsync_end - mode->vsync_start;int ret; +/* +* Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register +* bitfields description state "These bits must be multiple of even +* pixel". It is not possible to simply align every bitfield to the +* nearest even pixel, because that would unalign the line width. +* Instead, attempt to re-align the timings. +*/ + +/* Panels with odd active pixel count are not supported by the bridge */ +if (mode->hdisplay &1 ) +dev_warn (tc->dev,"Panels with odd pixel count per active line are not supported.\n" ); + +/* HPW is odd */ +if (hsync_len &1 ) { +/* Make sure there is some margin left */ +if (left_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + left_margin--; + }else if (right_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + right_margin--; + }else if (hsync_len >2 ) { +/* Align HPW down as last-resort option */ + hsync_len--; + left_margin++; + }else { +dev_warn (tc->dev,"HPW is odd, not enough margins to compensate.\n" ); + } + } + +/* HBP is odd (HPW is surely even now) */ +if (left_margin &1 ) { +/* Make sure there is some margin left */ +if (right_margin >=2 ) { +/* Align HBP up */ + left_margin++; + right_margin--; + }else if (hsync_len >2 ) { +/* HPW is surely even and > 2, which means at least 4 */ + hsync_len -=2 ; +/* +* Subtract 2 from sync pulse and distribute it between +* margins. This aligns HBP and keeps HPW aligned. +*/ + left_margin++; + right_margin++; + }else { +dev_warn (tc->dev,"HBP is odd, not enough pixels to compensate.\n" ); + } + } + +/* HFP is odd (HBP and HPW is surely even now) */ +if (right_margin &1 ) +dev_warn (tc->dev,"HFP is odd, panels with odd pixel count per full line are not supported.\n" ); +dev_dbg (tc->dev,"set mode %dx%d\n" , mode->hdisplay, mode->vdisplay); dev_dbg(tc->dev, "H margin %d,%d sync %d\n",
@@ -922,14 +979,14 @@ static int tc_set_common_video_mode(struct tc_data *tc,return ret; ret =regmap_write (tc->regmap,HTIM01 , -FIELD_PREP (HBPR ,ALIGN (left_margin,2 )) | -FIELD_PREP (HPW ,ALIGN (hsync_len,2 ))); +FIELD_PREP (HBPR , left_margin) | +FIELD_PREP (HPW , hsync_len));if (ret)return ret; ret =regmap_write (tc->regmap,HTIM02 ,FIELD_PREP (HDISPR ,ALIGN (mode->hdisplay,2 )) | -FIELD_PREP (HFPR ,ALIGN (right_margin,2 ))); +FIELD_PREP (HFPR , right_margin));if (ret)return ret;
Signature · 1 line
2.45.2
Maxime Ripard
maintainerQuoted 85 lines · Marek Vasut
Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register bitfields description state "These bits must be multiple of even pixel". It is not possible to simply align every bitfield to the nearest even pixel, because that would unalign the line width and cause visible distortion. Instead, attempt to re-align the timings such that the hardware requirement is fulfilled without changing the line width if at all possible.
Warn the user in case a panel with odd active pixel width or full line width is used, this is not possible to support with this one bridge.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]--- drivers/gpu/drm/bridge/tc358767.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358767.c +47
-0@@ -901,6 +901,63 @@ static int tc_set_common_video_mode(struct tc_data *tc,int vsync_len = mode->vsync_end - mode->vsync_start;int ret; +/* +* Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register +* bitfields description state "These bits must be multiple of even +* pixel". It is not possible to simply align every bitfield to the +* nearest even pixel, because that would unalign the line width. +* Instead, attempt to re-align the timings. +*/ + +/* Panels with odd active pixel count are not supported by the bridge */ +if (mode->hdisplay &1 ) +dev_warn (tc->dev,"Panels with odd pixel count per active line are not supported.\n" ); + +/* HPW is odd */ +if (hsync_len &1 ) { +/* Make sure there is some margin left */ +if (left_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + left_margin--; + }else if (right_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + right_margin--; + }else if (hsync_len >2 ) { +/* Align HPW down as last-resort option */ + hsync_len--; + left_margin++; + }else { +dev_warn (tc->dev,"HPW is odd, not enough margins to compensate.\n" ); + } + } + +/* HBP is odd (HPW is surely even now) */ +if (left_margin &1 ) { +/* Make sure there is some margin left */ +if (right_margin >=2 ) { +/* Align HBP up */ + left_margin++; + right_margin--; + }else if (hsync_len >2 ) { +/* HPW is surely even and > 2, which means at least 4 */ + hsync_len -=2 ; +/* +* Subtract 2 from sync pulse and distribute it between +* margins. This aligns HBP and keeps HPW aligned. +*/ + left_margin++;
drivers/gpu/drm/bridge/tc358767.c static int tc_set_common_video_mode(struct tc_data *tc, · line 960
Quoted 10 lines
drivers/gpu/drm/bridge/tc358767.c +10
-0+ right_margin++; + }else { +dev_warn (tc->dev,"HBP is odd, not enough pixels to compensate.\n" ); + } + } + +/* HFP is odd (HBP and HPW is surely even now) */ +if (right_margin &1 ) +dev_warn (tc->dev,"HFP is odd, panels with odd pixel count per full line are not supported.\n" ); +
This should all happen in atomic_check, and reject modes that can't be supported.
Maxime
Quoted 90 lines · Maxime Ripard
Quoted 89 lines · Marek Vasut
Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register bitfields description state "These bits must be multiple of even pixel". It is not possible to simply align every bitfield to the nearest even pixel, because that would unalign the line width and cause visible distortion. Instead, attempt to re-align the timings such that the hardware requirement is fulfilled without changing the line width if at all possible.
Warn the user in case a panel with odd active pixel width or full line width is used, this is not possible to support with this one bridge.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]--- drivers/gpu/drm/bridge/tc358767.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358767.c +51
-0@@ -901,6 +901,63 @@ static int tc_set_common_video_mode(struct tc_data *tc,int vsync_len = mode->vsync_end - mode->vsync_start;int ret; +/* +* Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register +* bitfields description state "These bits must be multiple of even +* pixel". It is not possible to simply align every bitfield to the +* nearest even pixel, because that would unalign the line width. +* Instead, attempt to re-align the timings. +*/ + +/* Panels with odd active pixel count are not supported by the bridge */ +if (mode->hdisplay &1 ) +dev_warn (tc->dev,"Panels with odd pixel count per active line are not supported.\n" ); + +/* HPW is odd */ +if (hsync_len &1 ) { +/* Make sure there is some margin left */ +if (left_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + left_margin--; + }else if (right_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + right_margin--; + }else if (hsync_len >2 ) { +/* Align HPW down as last-resort option */ + hsync_len--; + left_margin++; + }else { +dev_warn (tc->dev,"HPW is odd, not enough margins to compensate.\n" ); + } + } + +/* HBP is odd (HPW is surely even now) */ +if (left_margin &1 ) { +/* Make sure there is some margin left */ +if (right_margin >=2 ) { +/* Align HBP up */ + left_margin++; + right_margin--; + }else if (hsync_len >2 ) { +/* HPW is surely even and > 2, which means at least 4 */ + hsync_len -=2 ; +/* +* Subtract 2 from sync pulse and distribute it between +* margins. This aligns HBP and keeps HPW aligned. +*/ + left_margin++; + right_margin++; + }else { +dev_warn (tc->dev,"HBP is odd, not enough pixels to compensate.\n" ); + }
Quoted 8 lines
drivers/gpu/drm/bridge/tc358767.c static int tc_set_common_video_mode(struct tc_data *tc, · line 960
Quoted 6 lines
drivers/gpu/drm/bridge/tc358767.c +6
-0+ } + +/* HFP is odd (HBP and HPW is surely even now) */ +if (right_margin &1 ) +dev_warn (tc->dev,"HFP is odd, panels with odd pixel count per full line are not supported.\n" ); +This should all happen in
atomic_check, and reject modes that can't be supported.
No, that would reject panels I need to support and which can be supported by this bridge.
Maxime Ripard
maintainerQuoted 100 lines · Marek Vasut
Quoted 90 lines · Maxime Ripard
Quoted 89 lines · Marek Vasut
Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register bitfields description state "These bits must be multiple of even pixel". It is not possible to simply align every bitfield to the nearest even pixel, because that would unalign the line width and cause visible distortion. Instead, attempt to re-align the timings such that the hardware requirement is fulfilled without changing the line width if at all possible.
Warn the user in case a panel with odd active pixel width or full line width is used, this is not possible to support with this one bridge.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]--- drivers/gpu/drm/bridge/tc358767.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358767.c +52
-0@@ -901,6 +901,63 @@ static int tc_set_common_video_mode(struct tc_data *tc,int vsync_len = mode->vsync_end - mode->vsync_start;int ret; +/* +* Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register +* bitfields description state "These bits must be multiple of even +* pixel". It is not possible to simply align every bitfield to the +* nearest even pixel, because that would unalign the line width. +* Instead, attempt to re-align the timings. +*/ + +/* Panels with odd active pixel count are not supported by the bridge */ +if (mode->hdisplay &1 ) +dev_warn (tc->dev,"Panels with odd pixel count per active line are not supported.\n" ); + +/* HPW is odd */ +if (hsync_len &1 ) { +/* Make sure there is some margin left */ +if (left_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + left_margin--; + }else if (right_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + right_margin--; + }else if (hsync_len >2 ) { +/* Align HPW down as last-resort option */ + hsync_len--; + left_margin++; + }else { +dev_warn (tc->dev,"HPW is odd, not enough margins to compensate.\n" ); + } + } + +/* HBP is odd (HPW is surely even now) */ +if (left_margin &1 ) { +/* Make sure there is some margin left */ +if (right_margin >=2 ) { +/* Align HBP up */ + left_margin++; + right_margin--; + }else if (hsync_len >2 ) { +/* HPW is surely even and > 2, which means at least 4 */ + hsync_len -=2 ; +/* +* Subtract 2 from sync pulse and distribute it between +* margins. This aligns HBP and keeps HPW aligned. +*/ + left_margin++; + right_margin++; + }else { +dev_warn (tc->dev,"HBP is odd, not enough pixels to compensate.\n" ); + } + }Quoted 8 lines
drivers/gpu/drm/bridge/tc358767.c static int tc_set_common_video_mode(struct tc_data *tc, · line 960
Quoted 5 lines
drivers/gpu/drm/bridge/tc358767.c +5
-0+ +/* HFP is odd (HBP and HPW is surely even now) */ +if (right_margin &1 ) +dev_warn (tc->dev,"HFP is odd, panels with odd pixel count per full line are not supported.\n" ); +This should all happen in
atomic_check, and reject modes that can't be supported.
Quoted 2 lines
No, that would reject panels I need to support and which can be supported by this bridge.
Then drop the warnings, either you support it or you don't.
Maxime
Maxime Ripard
maintainerQuoted 101 lines · Maxime Ripard
Quoted 99 lines · Marek Vasut
Quoted 98 lines · Maxime Ripard
Quoted 84 lines · Marek Vasut
Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register bitfields description state "These bits must be multiple of even pixel". It is not possible to simply align every bitfield to the nearest even pixel, because that would unalign the line width and cause visible distortion. Instead, attempt to re-align the timings such that the hardware requirement is fulfilled without changing the line width if at all possible.
Warn the user in case a panel with odd active pixel width or full line width is used, this is not possible to support with this one bridge.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]--- drivers/gpu/drm/bridge/tc358767.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358767.c +47
-0@@ -901,6 +901,63 @@ static int tc_set_common_video_mode(struct tc_data *tc,int vsync_len = mode->vsync_end - mode->vsync_start;int ret; +/* +* Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register +* bitfields description state "These bits must be multiple of even +* pixel". It is not possible to simply align every bitfield to the +* nearest even pixel, because that would unalign the line width. +* Instead, attempt to re-align the timings. +*/ + +/* Panels with odd active pixel count are not supported by the bridge */ +if (mode->hdisplay &1 ) +dev_warn (tc->dev,"Panels with odd pixel count per active line are not supported.\n" ); + +/* HPW is odd */ +if (hsync_len &1 ) { +/* Make sure there is some margin left */ +if (left_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + left_margin--; + }else if (right_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + right_margin--; + }else if (hsync_len >2 ) { +/* Align HPW down as last-resort option */ + hsync_len--; + left_margin++; + }else { +dev_warn (tc->dev,"HPW is odd, not enough margins to compensate.\n" ); + } + } + +/* HBP is odd (HPW is surely even now) */ +if (left_margin &1 ) { +/* Make sure there is some margin left */ +if (right_margin >=2 ) { +/* Align HBP up */ + left_margin++; + right_margin--; + }else if (hsync_len >2 ) { +/* HPW is surely even and > 2, which means at least 4 */ + hsync_len -=2 ; +/* +* Subtract 2 from sync pulse and distribute it between +* margins. This aligns HBP and keeps HPW aligned. +*/ + left_margin++;drivers/gpu/drm/bridge/tc358767.c static int tc_set_common_video_mode(struct tc_data *tc, · line 959
Quoted 10 lines
drivers/gpu/drm/bridge/tc358767.c +10
-0+ right_margin++; + }else { +dev_warn (tc->dev,"HBP is odd, not enough pixels to compensate.\n" ); + } + } + +/* HFP is odd (HBP and HPW is surely even now) */ +if (right_margin &1 ) +dev_warn (tc->dev,"HFP is odd, panels with odd pixel count per full line are not supported.\n" ); +This should all happen in
atomic_check, and reject modes that can't be supported.
Quoted 4 lines
Quoted 2 lines
No, that would reject panels I need to support and which can be supported by this bridge.
Then drop the warnings, either you support it or you don't.
Oh, and update the commit log, because so far it claims that you can't support those panels.
Maxime
Quoted 101 lines · Maxime Ripard
Quoted 99 lines · Marek Vasut
Quoted 98 lines · Maxime Ripard
Quoted 84 lines · Marek Vasut
Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register bitfields description state "These bits must be multiple of even pixel". It is not possible to simply align every bitfield to the nearest even pixel, because that would unalign the line width and cause visible distortion. Instead, attempt to re-align the timings such that the hardware requirement is fulfilled without changing the line width if at all possible.
Warn the user in case a panel with odd active pixel width or full line width is used, this is not possible to support with this one bridge.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]--- drivers/gpu/drm/bridge/tc358767.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358767.c +47
-0@@ -901,6 +901,63 @@ static int tc_set_common_video_mode(struct tc_data *tc,int vsync_len = mode->vsync_end - mode->vsync_start;int ret; +/* +* Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register +* bitfields description state "These bits must be multiple of even +* pixel". It is not possible to simply align every bitfield to the +* nearest even pixel, because that would unalign the line width. +* Instead, attempt to re-align the timings. +*/ + +/* Panels with odd active pixel count are not supported by the bridge */ +if (mode->hdisplay &1 ) +dev_warn (tc->dev,"Panels with odd pixel count per active line are not supported.\n" ); + +/* HPW is odd */ +if (hsync_len &1 ) { +/* Make sure there is some margin left */ +if (left_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + left_margin--; + }else if (right_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + right_margin--; + }else if (hsync_len >2 ) { +/* Align HPW down as last-resort option */ + hsync_len--; + left_margin++; + }else { +dev_warn (tc->dev,"HPW is odd, not enough margins to compensate.\n" ); + } + } + +/* HBP is odd (HPW is surely even now) */ +if (left_margin &1 ) { +/* Make sure there is some margin left */ +if (right_margin >=2 ) { +/* Align HBP up */ + left_margin++; + right_margin--; + }else if (hsync_len >2 ) { +/* HPW is surely even and > 2, which means at least 4 */ + hsync_len -=2 ; +/* +* Subtract 2 from sync pulse and distribute it between +* margins. This aligns HBP and keeps HPW aligned. +*/ + left_margin++;drivers/gpu/drm/bridge/tc358767.c static int tc_set_common_video_mode(struct tc_data *tc, · line 959
Quoted 10 lines
drivers/gpu/drm/bridge/tc358767.c +10
-0+ right_margin++; + }else { +dev_warn (tc->dev,"HBP is odd, not enough pixels to compensate.\n" ); + } + } + +/* HFP is odd (HBP and HPW is surely even now) */ +if (right_margin &1 ) +dev_warn (tc->dev,"HFP is odd, panels with odd pixel count per full line are not supported.\n" ); +This should all happen in
atomic_check, and reject modes that can't be supported.
Quoted 4 lines
Quoted 2 lines
No, that would reject panels I need to support and which can be supported by this bridge.
Then drop the warnings, either you support it or you don't.
These warnings are useful to notify users that something is not right. I find them useful when bringing up systems with this bridge.
Maxime Ripard
maintainerQuoted 102 lines · Marek Vasut
Quoted 101 lines · Maxime Ripard
Quoted 99 lines · Marek Vasut
Quoted 98 lines · Maxime Ripard
Quoted 84 lines · Marek Vasut
Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register bitfields description state "These bits must be multiple of even pixel". It is not possible to simply align every bitfield to the nearest even pixel, because that would unalign the line width and cause visible distortion. Instead, attempt to re-align the timings such that the hardware requirement is fulfilled without changing the line width if at all possible.
Warn the user in case a panel with odd active pixel width or full line width is used, this is not possible to support with this one bridge.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]--- drivers/gpu/drm/bridge/tc358767.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358767.c +47
-0@@ -901,6 +901,63 @@ static int tc_set_common_video_mode(struct tc_data *tc,int vsync_len = mode->vsync_end - mode->vsync_start;int ret; +/* +* Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register +* bitfields description state "These bits must be multiple of even +* pixel". It is not possible to simply align every bitfield to the +* nearest even pixel, because that would unalign the line width. +* Instead, attempt to re-align the timings. +*/ + +/* Panels with odd active pixel count are not supported by the bridge */ +if (mode->hdisplay &1 ) +dev_warn (tc->dev,"Panels with odd pixel count per active line are not supported.\n" ); + +/* HPW is odd */ +if (hsync_len &1 ) { +/* Make sure there is some margin left */ +if (left_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + left_margin--; + }else if (right_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + right_margin--; + }else if (hsync_len >2 ) { +/* Align HPW down as last-resort option */ + hsync_len--; + left_margin++; + }else { +dev_warn (tc->dev,"HPW is odd, not enough margins to compensate.\n" ); + } + } + +/* HBP is odd (HPW is surely even now) */ +if (left_margin &1 ) { +/* Make sure there is some margin left */ +if (right_margin >=2 ) { +/* Align HBP up */ + left_margin++; + right_margin--; + }else if (hsync_len >2 ) { +/* HPW is surely even and > 2, which means at least 4 */ + hsync_len -=2 ; +/* +* Subtract 2 from sync pulse and distribute it between +* margins. This aligns HBP and keeps HPW aligned. +*/ + left_margin++;drivers/gpu/drm/bridge/tc358767.c static int tc_set_common_video_mode(struct tc_data *tc, · line 959
Quoted 10 lines
drivers/gpu/drm/bridge/tc358767.c +10
-0+ right_margin++; + }else { +dev_warn (tc->dev,"HBP is odd, not enough pixels to compensate.\n" ); + } + } + +/* HFP is odd (HBP and HPW is surely even now) */ +if (right_margin &1 ) +dev_warn (tc->dev,"HFP is odd, panels with odd pixel count per full line are not supported.\n" ); +This should all happen in
atomic_check, and reject modes that can't be supported.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
No, that would reject panels I need to support and which can be supported by this bridge.
Then drop the warnings, either you support it or you don't.
These warnings are useful to notify users that something is not right. I find them useful when bringing up systems with this bridge.
Yeah, because you know what to do about them.
Unfortunately, you're not the only audience of those messages, and the vast majority of the users will have no idea what these warnings are about, and no way to fix them.
Maxime
Quoted 108 lines · Maxime Ripard
Quoted 107 lines · Marek Vasut
Quoted 105 lines · Maxime Ripard
Quoted 100 lines · Marek Vasut
Quoted 90 lines · Maxime Ripard
Quoted 89 lines · Marek Vasut
Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register bitfields description state "These bits must be multiple of even pixel". It is not possible to simply align every bitfield to the nearest even pixel, because that would unalign the line width and cause visible distortion. Instead, attempt to re-align the timings such that the hardware requirement is fulfilled without changing the line width if at all possible.
Warn the user in case a panel with odd active pixel width or full line width is used, this is not possible to support with this one bridge.
Signed-off-by Marek Vasut <[email protected]>---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]--- drivers/gpu/drm/bridge/tc358767.c | 63 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/tc358767.c +52
-0@@ -901,6 +901,63 @@ static int tc_set_common_video_mode(struct tc_data *tc,int vsync_len = mode->vsync_end - mode->vsync_start;int ret; +/* +* Horizontal Timing Control0 Register 1/2 (HTIM01/HTIM02) Register +* bitfields description state "These bits must be multiple of even +* pixel". It is not possible to simply align every bitfield to the +* nearest even pixel, because that would unalign the line width. +* Instead, attempt to re-align the timings. +*/ + +/* Panels with odd active pixel count are not supported by the bridge */ +if (mode->hdisplay &1 ) +dev_warn (tc->dev,"Panels with odd pixel count per active line are not supported.\n" ); + +/* HPW is odd */ +if (hsync_len &1 ) { +/* Make sure there is some margin left */ +if (left_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + left_margin--; + }else if (right_margin >=2 ) { +/* Align HPW up */ + hsync_len++; + right_margin--; + }else if (hsync_len >2 ) { +/* Align HPW down as last-resort option */ + hsync_len--; + left_margin++; + }else { +dev_warn (tc->dev,"HPW is odd, not enough margins to compensate.\n" ); + } + } + +/* HBP is odd (HPW is surely even now) */ +if (left_margin &1 ) { +/* Make sure there is some margin left */ +if (right_margin >=2 ) { +/* Align HBP up */ + left_margin++; + right_margin--; + }else if (hsync_len >2 ) { +/* HPW is surely even and > 2, which means at least 4 */ + hsync_len -=2 ; +/* +* Subtract 2 from sync pulse and distribute it between +* margins. This aligns HBP and keeps HPW aligned. +*/ + left_margin++; + right_margin++; + }else { +dev_warn (tc->dev,"HBP is odd, not enough pixels to compensate.\n" ); + } + }Quoted 8 lines
drivers/gpu/drm/bridge/tc358767.c static int tc_set_common_video_mode(struct tc_data *tc, · line 960
Quoted 5 lines
drivers/gpu/drm/bridge/tc358767.c +5
-0+ +/* HFP is odd (HBP and HPW is surely even now) */ +if (right_margin &1 ) +dev_warn (tc->dev,"HFP is odd, panels with odd pixel count per full line are not supported.\n" ); +This should all happen in
atomic_check, and reject modes that can't be supported.Quoted 2 lines
No, that would reject panels I need to support and which can be supported by this bridge.
Then drop the warnings, either you support it or you don't.
Quoted 8 lines
Quoted 2 lines
These warnings are useful to notify users that something is not right. I find them useful when bringing up systems with this bridge.
Yeah, because you know what to do about them.
Unfortunately, you're not the only audience of those messages, and the vast majority of the users will have no idea what these warnings are about, and no way to fix them.
The net result of removing these warnings will be -- it will be harder for me to debug problems with this driver, and the rest of the audience will not be able to provide meaningful error reports because the warnings will not be present. That does not seem helpful.