drm/panel: simple: Add mode support to devicetree
Subsystems (4)
v6 cover drm/panel: simple: Add mode support to devicetree
I'm reviving Sean Paul's old patchset to get mode support in device tree. The cover letter for his v3 is at:
https://lists.freedesktop.org/archives/dri-devel/2018-February/165162.html
v6 of this patch is just a repost of the 3 DRM patches in v5 rebased atop drm-misc. A few notes:
- I've dropped the bindings patch. Commit 821a1f7171ae ("dt-bindings:
display: Convert common panel bindings to DT schema") has landed and Rob H said [1] that when that landed the bindings were implicitly supported.
- Since the bindings patch was dropped I am assuming that Heiko can just pick up the .dts patches from the v5 series. I double-checked with him and he confirmed this is fine. Thus I have left the device tree patches out of this version.
There were some coding style discussions on v5 of the path but it's been agreed that we can land this series as-is and after it lands we can address the minor style issues.
[1] https://lkml.kernel.org/r/CAL_JsqJGtUTpJL+SDEKi09aDT4yDzY4x9KwYmz08NaZcn=nHfA@mail.gmail.com
Changes in v6:
- Rebased to drm-misc next
- Added tags
Changes in v5:
- Added Heiko's Tested-by
Changes in v4:
- Don't add mode from timing if override was specified (Thierry)
- Add warning if timing and fixed mode was specified (Thierry)
- Don't add fixed mode if timing was specified (Thierry)
- Refactor/rename a bit to avoid extra indentation from "if" tests
- i should be unsigned (Thierry)
- Add annoying WARN_ONs for some cases (Thierry)
- Simplify 'No display_timing found' handling (Thierry)
- Rename to panel_simple_parse_override_mode() (Thierry)
- display_timing for Innolux n116bge new for v4.
- display_timing for AUO b101ean01 new for v4.
Changes in v3:
- No longer parse display-timings subnode, use panel-timing (Rob)
Changes in v2:
- Parse the full display-timings node (using the native-mode) (Rob)
Douglas Anderson (2):
drm/panel: simple: Use display_timing for Innolux n116bge drm/panel: simple: Use display_timing for AUO b101ean01
Sean Paul (1):
drm/panel: simple: Add ability to override typical timing
drivers/gpu/drm/panel/panel-simple.c | 171 ++++++++++++++++++++++----- 1 file changed, 139 insertions(+), 32 deletions(-)
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
PATCH v6 1/3 drm/panel: simple: Add ability to override typical timing
From: Sean Paul <[email protected]>
This patch adds the ability to override the typical display timing for a given panel. This is useful for devices which have timing constraints that do not apply across the entire display driver (eg: to avoid crosstalk between panel and digitizer on certain laptops). The rules are as follows:
- panel must not specify fixed mode (since the override mode will either be the same as the fixed mode, or we'll be unable to check the bounds of the overried)
- panel must specify at least one display_timing range which will be used to ensure the override mode fits within its bounds
Changes in v2:
- Parse the full display-timings node (using the native-mode) (Rob)
Changes in v3:
- No longer parse display-timings subnode, use panel-timing (Rob)
Changes in v4:
- Don't add mode from timing if override was specified (Thierry)
- Add warning if timing and fixed mode was specified (Thierry)
- Don't add fixed mode if timing was specified (Thierry)
- Refactor/rename a bit to avoid extra indentation from "if" tests
- i should be unsigned (Thierry)
- Add annoying WARN_ONs for some cases (Thierry)
- Simplify 'No display_timing found' handling (Thierry)
- Rename to panel_simple_parse_override_mode() (Thierry)
Changes in v5:
- Added Heiko's Tested-by
Changes in v6:
- Rebased to drm-misc next
- Added tags
---
drivers/gpu/drm/panel/panel-simple.c | 109 +++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 5 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +104 -5
@@ -30,6 +30,7 @@#include <linux/regulator/consumer.h> #include <video/display_timing.h> +#include <video/of_display_timing.h> #include <video/videomode.h> #include <drm/drm_crtc.h>
@@ -92,6 +93,8 @@ struct panel_simple {struct i2c_adapter *ddc;struct gpio_desc *enable_gpio; + +struct drm_display_mode override_mode; };static inline struct panel_simple *to_panel_simple (struct drm_panel *panel)
@@ -99,16 +102,13 @@ static inline struct panel_simple *to_panel_simple(struct drm_panel *panel) return container_of(panel, struct panel_simple, base); } -static int panel_simple_get_fixed_modes (struct panel_simple *panel) +static unsigned int panel_simple_get_timings_modes (struct panel_simple *panel) {struct drm_connector *connector = panel->base.connector;struct drm_device *drm = panel->base.drm;struct drm_display_mode *mode;unsigned int i, num =0 ; -if (!panel->desc) -return 0 ; -for (i =0 ; i < panel->desc->num_timings; i++) {const struct display_timing *dt = &panel->desc->timings[i];struct videomode vm;
@@ -132,6 +132,16 @@ static int panel_simple_get_fixed_modes(struct panel_simple *panel) num++; } +return num; +} + +static unsigned int panel_simple_get_fixed_modes (struct panel_simple *panel) +{ +struct drm_connector *connector = panel->base.connector; +struct drm_device *drm = panel->base.drm; +struct drm_display_mode *mode; +unsigned int i, num =0 ; +for (i =0 ; i < panel->desc->num_modes; i++) {const struct drm_display_mode *m = &panel->desc->modes[i];
@@ -153,6 +163,44 @@ static int panel_simple_get_fixed_modes(struct panel_simple *panel) num++; } +return num; +} + +static int panel_simple_get_non_edid_modes (struct panel_simple *panel) +{ +struct drm_connector *connector = panel->base.connector; +struct drm_device *drm = panel->base.drm; +struct drm_display_mode *mode; +bool has_override = panel->override_mode.type; +unsigned int num =0 ; + +if (!panel->desc) +return 0 ; + +if (has_override) { + mode =drm_mode_duplicate (drm, &panel->override_mode); +if (mode) { +drm_mode_probed_add (connector, mode); + num =1 ; + }else { +dev_err (drm->dev,"failed to add override mode\n" ); + } + } + +/* Only add timings if override was not there or failed to validate */ +if (num ==0 && panel->desc->num_timings) + num =panel_simple_get_timings_modes (panel); + +/* +* Only add fixed modes if timings/override added no mode. +* +* We should only ever have either the display timings specified +* or a fixed mode. Anything else is rather bogus. +*/ +WARN_ON (panel->desc->num_timings && panel->desc->num_modes); +if (num ==0 ) + num =panel_simple_get_fixed_modes (panel); + connector->display_info.bpc = panel->desc->bpc; connector->display_info.width_mm = panel->desc->size.width; connector->display_info.height_mm = panel->desc->size.height;
@@ -269,7 +317,7 @@ static int panel_simple_get_modes(struct drm_panel *panel) }/* add hard-coded panel modes */ - num +=panel_simple_get_fixed_modes (p); + num +=panel_simple_get_non_edid_modes (p);return num; }
@@ -300,10 +348,58 @@ static const struct drm_panel_funcs panel_simple_funcs = { .get_timings = panel_simple_get_timings, }; +#define PANEL_SIMPLE_BOUNDS_CHECK (to_check, bounds, field) \ + (to_check->field.typ >= bounds->field.min && \ + to_check->field.typ <= bounds->field.max) +static void panel_simple_parse_override_mode (struct device *dev, +struct panel_simple *panel, +const struct display_timing *ot) +{ +const struct panel_desc *desc = panel->desc; +struct videomode vm; +unsigned int i; + +if (WARN_ON (desc->num_modes)) { +dev_err (dev,"Reject override mode: panel has a fixed mode\n" ); +return ; + } +if (WARN_ON (!desc->num_timings)) { +dev_err (dev,"Reject override mode: no timings specified\n" ); +return ; + } + +for (i =0 ; i < panel->desc->num_timings; i++) { +const struct display_timing *dt = &panel->desc->timings[i]; + +if (!PANEL_SIMPLE_BOUNDS_CHECK (ot, dt, hactive) || + !PANEL_SIMPLE_BOUNDS_CHECK (ot, dt, hfront_porch) || + !PANEL_SIMPLE_BOUNDS_CHECK (ot, dt, hback_porch) || + !PANEL_SIMPLE_BOUNDS_CHECK (ot, dt, hsync_len) || + !PANEL_SIMPLE_BOUNDS_CHECK (ot, dt, vactive) || + !PANEL_SIMPLE_BOUNDS_CHECK (ot, dt, vfront_porch) || + !PANEL_SIMPLE_BOUNDS_CHECK (ot, dt, vback_porch) || + !PANEL_SIMPLE_BOUNDS_CHECK (ot, dt, vsync_len)) +continue ; + +if (ot->flags != dt->flags) +continue ; + +videomode_from_timing (ot, &vm); +drm_display_mode_from_videomode (&vm, &panel->override_mode); + panel->override_mode.type |=DRM_MODE_TYPE_DRIVER | +DRM_MODE_TYPE_PREFERRED ; +break ; + } + +if (WARN_ON (!panel->override_mode.type)) +dev_err (dev,"Reject override mode: No display_timing found\n" ); +} +static int panel_simple_probe (struct device *dev,const struct panel_desc *desc) {struct device_node *backlight, *ddc;struct panel_simple *panel; +struct display_timing dt;int err; panel =devm_kzalloc (dev,sizeof (*panel),GFP_KERNEL );
@@ -349,6 +445,9 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) } } +if (!of_get_display_timing (dev->of_node,"panel-timing" , &dt)) +panel_simple_parse_override_mode (dev, panel, &dt); +drm_panel_init (&panel->base); panel->base.dev = dev; panel->base.funcs = &panel_simple_funcs;
Signature · 7 lines
2.22.0.410.gd8fdbe21b5-goog _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v6 2/3 drm/panel: simple: Use display_timing for Innolux n116bge
In reply to Douglas AndersonConvert the Innolux n116bge from using a fixed mode to specifying a display timing with min/typ/max values.
Note that the n116bge's datasheet doesn't fit too well into DRM's way of specifying things. Specifically the panel's datasheet just specifies the vertical blanking period and horizontal blanking period and doesn't break things out. For now we'll leave everything as a fixed value but just allow adjusting the pixel clock. I've added a comment on what the datasheet claims so someone could later expand things to fit their needs if they wanted to test other blanking periods.
The goal here is to be able to specify the panel timings in the device tree for several rk3288 Chromebooks (like rk3288-veryon-jerry). These Chromebooks have all been running in the downstream kernel with the standard porches and sync lengths but just with a slightly slower pixel clock because the 76.42 MHz clock is not achievable from the fixed PLL that was available. These Chromebooks only achieve a refresh rate of ~58 Hz. While it's probable that we could adjust the timings to achieve 60 Hz it's probably wisest to match what's been running on these devices all these years.
I'll note that though the upstream kernel has always tried to achieve 76.42 MHz, it has actually been running at 74.25 MHz also since the video processor is parented off the same fixed PLL.
Changes in v4:
- display_timing for Innolux n116bge new for v4.
Changes in v5:
- Added Heiko's Tested-by
Changes in v6:
- Rebased to drm-misc next
- Added tags
---
drivers/gpu/drm/panel/panel-simple.c | 37 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +23 -14
@@ -1702,23 +1702,32 @@ static const struct panel_desc innolux_g121x1_l03 = { }, }; -static const struct drm_display_mode innolux_n116bge_mode = { - .clock =76420 , - .hdisplay =1366 , - .hsync_start =1366 +136 , - .hsync_end =1366 +136 +30 , - .htotal =1366 +136 +30 +60 , - .vdisplay =768 , - .vsync_start =768 +8 , - .vsync_end =768 +8 +12 , - .vtotal =768 +8 +12 +12 , - .vrefresh =60 , - .flags =DRM_MODE_FLAG_NHSYNC |DRM_MODE_FLAG_NVSYNC , +/* +* Datasheet specifies that at 60 Hz refresh rate: +* - total horizontal time: { 1506, 1592, 1716 } +* - total vertical time: { 788, 800, 868 } +* +* ...but doesn't go into exactly how that should be split into a front +* porch, back porch, or sync length. For now we'll leave a single setting +* here which allows a bit of tweaking of the pixel clock at the expense of +* refresh rate. +*/ +static const struct display_timing innolux_n116bge_timing = { + .pixelclock = {72600000 ,76420000 ,80240000 }, + .hactive = {1366 ,1366 ,1366 }, + .hfront_porch = {136 ,136 ,136 }, + .hback_porch = {60 ,60 ,60 }, + .hsync_len = {30 ,30 ,30 }, + .vactive = {768 ,768 ,768 }, + .vfront_porch = {8 ,8 ,8 }, + .vback_porch = {12 ,12 ,12 }, + .vsync_len = {12 ,12 ,12 }, + .flags =DISPLAY_FLAGS_VSYNC_LOW |DISPLAY_FLAGS_HSYNC_LOW , };static const struct panel_desc innolux_n116bge = { - .modes = &innolux_n116bge_mode, - .num_modes =1 , + .timings = &innolux_n116bge_timing, + .num_timings =1 , .bpc =6 , .size = { .width =256 ,
Signature · 6 lines
2.22.0.410.gd8fdbe21b5-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v6 3/3 drm/panel: simple: Use display_timing for AUO b101ean01
In reply to Douglas AndersonConvert the AUO b101ean01 from using a fixed mode to specifying a display timing with min/typ/max values.
The AUO b101ean01's datasheet says:
* Vertical blanking min is 12
* Horizontal blanking min is 60
* Pixel clock is between 65.3 MHz and 75 MHz
The goal here is to be able to specify the proper timing in device tree to use on rk3288-veyron-minnie to match what the downstream kernel is using so that it can used the fixed PLL.
Changes in v4:
- display_timing for AUO b101ean01 new for v4.
Changes in v6:
- Rebased to drm-misc next
- Added tags
---
drivers/gpu/drm/panel/panel-simple.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +12 -13
@@ -595,22 +595,21 @@ static const struct panel_desc auo_b101aw03 = { }, }; -static const struct drm_display_mode auo_b101ean01_mode = { - .clock =72500 , - .hdisplay =1280 , - .hsync_start =1280 +119 , - .hsync_end =1280 +119 +32 , - .htotal =1280 +119 +32 +21 , - .vdisplay =800 , - .vsync_start =800 +4 , - .vsync_end =800 +4 +20 , - .vtotal =800 +4 +20 +8 , - .vrefresh =60 , +static const struct display_timing auo_b101ean01_timing = { + .pixelclock = {65300000 ,72500000 ,75000000 }, + .hactive = {1280 ,1280 ,1280 }, + .hfront_porch = {18 ,119 ,119 }, + .hback_porch = {21 ,21 ,21 }, + .hsync_len = {32 ,32 ,32 }, + .vactive = {800 ,800 ,800 }, + .vfront_porch = {4 ,4 ,4 }, + .vback_porch = {8 ,8 ,8 }, + .vsync_len = {18 ,20 ,20 }, };static const struct panel_desc auo_b101ean01 = { - .modes = &auo_b101ean01_mode, - .num_modes =1 , + .timings = &auo_b101ean01_timing, + .num_timings =1 , .bpc =6 , .size = { .width =217 ,
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
Hi Doug.
Quoted 19 lines · Douglas Anderson
I'm reviving Sean Paul's old patchset to get mode support in device tree. The cover letter for his v3 is at:
https://lists.freedesktop.org/archives/dri-devel/2018-February/165162.htmlv6 of this patch is just a repost of the 3 DRM patches in v5 rebased atop drm-misc. A few notes:
- I've dropped the bindings patch. Commit821a1f7171ae("dt-bindings:
display: Convert common panel bindings to DT schema") has landed and Rob H said [1] that when that landed the bindings were implicitly supported.
- Since the bindings patch was dropped I am assuming that Heiko can just pick up the .dts patches from the v5 series. I double-checked with him and he confirmed this is fine. Thus I have left the device tree patches out of this version.There were some coding style discussions on v5 of the path but it's been agreed that we can land this series as-is and after it lands we can address the minor style issues.
Quoted 5 lines
Changes in v6:
- Rebased to drm-misc next
- Added tags
...
Thanks for your patience with this.
Applied to drm-misc-next and pushed out.
Sam
Hi,
Quoted 25 lines · Sam Ravnborg
Hi Doug.
Quoted 21 lines · Douglas Anderson
I'm reviving Sean Paul's old patchset to get mode support in device tree. The cover letter for his v3 is at:
https://lists.freedesktop.org/archives/dri-devel/2018-February/165162.htmlv6 of this patch is just a repost of the 3 DRM patches in v5 rebased atop drm-misc. A few notes:
- I've dropped the bindings patch. Commit821a1f7171ae("dt-bindings:
display: Convert common panel bindings to DT schema") has landed and Rob H said [1] that when that landed the bindings were implicitly supported.
- Since the bindings patch was dropped I am assuming that Heiko can just pick up the .dts patches from the v5 series. I double-checked with him and he confirmed this is fine. Thus I have left the device tree patches out of this version.There were some coding style discussions on v5 of the path but it's been agreed that we can land this series as-is and after it lands we can address the minor style issues.
[1] https://lkml.kernel.org/r/CAL_JsqJGtUTpJL+SDEKi09aDT4yDzY4x9KwYmz08NaZcn=nHfA@mail.gmail.com
Quoted 7 lines
Quoted 3 lines
Changes in v6:
- Rebased to drm-misc next
- Added tags...
Thanks for your patience with this.
Applied to drm-misc-next and pushed out.
As promised, posted the follow-up patch addressing the style concerns / suggestions. I didn't CC every last person here, but it's on LKML and I'm happy for anyone to review it that is interested:
https://lkml.kernel.org/r/[email protected]
-Doug
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel