[PATCH 3/3] drm/panel: sitronix-st7789v: fix display size for jt240mhqs_hwt_ek_e3 panel
This is a portrait mode display. Change the dimensions accordingly. Signed-off-by: Gerald Loacker --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index c7e3f1280404..e8f385b9c618 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -289,8 +289,8 @@ static const struct drm_display_mode jt240mhqs_hwt_ek_e3_mode = { .vsync_start = 280 + 48, .vsync_end = 280 + 48 + 4, .vtotal = 280 + 48 + 4 + 4, - .width_mm = 43, - .height_mm = 37, + .width_mm = 37, + .height_mm = 43, .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC, }; -- 2.37.2
[PATCH 2/3] drm/panel: sitronix-st7789v: tweak timing for jt240mhqs_hwt_ek_e3 panel
Use the default timing parameters to get a refresh rate of about 60 Hz for a clock of 6 MHz. Signed-off-by: Gerald Loacker --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 32e5c0348038..c7e3f1280404 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -282,9 +282,9 @@ static const struct drm_display_mode et028013dma_mode = { static const struct drm_display_mode jt240mhqs_hwt_ek_e3_mode = { .clock = 6000, .hdisplay = 240, - .hsync_start = 240 + 28, - .hsync_end = 240 + 28 + 10, - .htotal = 240 + 28 + 10 + 10, + .hsync_start = 240 + 38, + .hsync_end = 240 + 38 + 10, + .htotal = 240 + 38 + 10 + 10, .vdisplay = 280, .vsync_start = 280 + 48, .vsync_end = 280 + 48 + 4, -- 2.37.2
[PATCH 1/3] drm/panel: sitronix-st7789v: fix timing for jt240mhqs_hwt_ek_e3 panel
Flickering was observed when using partial mode. Moving the vsync to the same position as used by the default sitronix-st7789v timing resolves this issue. Signed-off-by: Gerald Loacker --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 88e80fe98112..32e5c0348038 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -286,9 +286,9 @@ static const struct drm_display_mode jt240mhqs_hwt_ek_e3_mode = { .hsync_end = 240 + 28 + 10, .htotal = 240 + 28 + 10 + 10, .vdisplay = 280, - .vsync_start = 280 + 8, - .vsync_end = 280 + 8 + 4, - .vtotal = 280 + 8 + 4 + 4, + .vsync_start = 280 + 48, + .vsync_end = 280 + 48 + 4, + .vtotal = 280 + 48 + 4 + 4, .width_mm = 43, .height_mm = 37, .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC, -- 2.37.2
[PATCH 0/3] drm/panel: sitronix-st7789v: fixes for jt240mhqs_hwt_ek_e3 panel
At the jt240mhqs_hwt_ek_e3 panel, noticeable flickering occurs. This is addressed by patch 1, which adjusts the vertical timing. Patch 2 and 3 are two more minor fixes for timing and dimension. Signed-off-by: Gerald Loacker --- Gerald Loacker (3): drm/panel: sitronix-st7789v: fix timing for jt240mhqs_hwt_ek_e3 panel drm/panel: sitronix-st7789v: tweak timing for jt240mhqs_hwt_ek_e3 panel drm/panel: sitronix-st7789v: fix display size for jt240mhqs_hwt_ek_e3 panel drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) --- base-commit: fec50db7033ea478773b159e0e2efb135270e3b7 change-id: 20240409-bugfix-jt240mhqs_hwt_ek_e3-timing-d26983703b27 Best regards, -- Gerald Loacker
Re: [PATCH 0/7] Add timing override to sitronix,st7789v
Hi, Besides dt-bindings, there has been no feedback on this series yet. How to proceed? For clarification: Besides adjusting panel parameters, we need the panel-timing to add a partial display mode later. Regards, Gerald Am 14.03.2023 um 12:56 schrieb Gerald Loacker: > This patch set adds additional functionality to the sitronix,st7789v > driver. > > Patches 1,3 and 4 propagate useful flags to the drm subsystem. > Patch 2 adds the orientation property. > Patch 5 parses the device tree for a panel-timing and makes it possible to > override the default timing. > Patches 6 and 7 add the new properties to the dt-bindings. > > Gerald Loacker (4): > drm/panel: sitronix-st7789v: propagate h/v-sync polarity > drm/panel: sitronix-st7789v: add bus_flags to connector > drm/panel: sitronix-st7789v: parse device tree to override timing mode > dt-bindings: display: add panel-timing property to sitronix,st7789v > > Michael Riesch (3): > drm/panel: sitronix-st7789v: propagate RGB666 format > drm/panel: sitronix-st7789v: add panel orientation support > dt-bindings: display: add rotation property to sitronix,st7789v > > .../display/panel/sitronix,st7789v.yaml | 19 ++ > .../gpu/drm/panel/panel-sitronix-st7789v.c| 204 +++--- > 2 files changed, 191 insertions(+), 32 deletions(-) >
[PATCH 5/7] drm/panel: sitronix-st7789v: parse device tree to override timing mode
Parse device tree for panel-timing and allow to override the typical timing. This requires the timing to be defined as display_timing instead of drm_display_mode. Signed-off-by: Gerald Loacker --- .../gpu/drm/panel/panel-sitronix-st7789v.c| 174 +++--- 1 file changed, 144 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 1ca04585aff2..ebde8a70deee 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -10,6 +10,9 @@ #include #include +#include +#include +#include #include #include @@ -28,6 +31,8 @@ #define ST7789V_RGBCTRL_CMD0xb1 #define ST7789V_RGBCTRL_WO BIT(7) #define ST7789V_RGBCTRL_RCM(n) (((n) & 3) << 5) +#define ST7789V_RGBCTRL_RCM_DE 2 +#define ST7789V_RGBCTRL_RCM_HV 3 #define ST7789V_RGBCTRL_VSYNC_HIGH BIT(3) #define ST7789V_RGBCTRL_HSYNC_HIGH BIT(2) #define ST7789V_RGBCTRL_PCLK_HIGH BIT(1) @@ -117,6 +122,7 @@ struct st7789v { struct spi_device *spi; struct gpio_desc *reset; struct regulator *power; + struct drm_display_mode override_mode; enum drm_panel_orientation orientation; }; @@ -157,39 +163,84 @@ static int st7789v_write_data(struct st7789v *ctx, u8 cmd) return st7789v_spi_write(ctx, ST7789V_DATA, cmd); } -static const struct drm_display_mode default_mode = { - .clock = 7000, - .hdisplay = 240, - .hsync_start = 240 + 38, - .hsync_end = 240 + 38 + 10, - .htotal = 240 + 38 + 10 + 10, - .vdisplay = 320, - .vsync_start = 320 + 8, - .vsync_end = 320 + 8 + 4, - .vtotal = 320 + 8 + 4 + 4, - .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC, +static const struct display_timing st7789v_timing = { + .pixelclock = { 1, 700, 833 }, + .hactive = { 240, 240, 240 }, + .hfront_porch = { 2, 38, 500 }, + .hback_porch = { 4, 10, 21 }, + .hsync_len = { 2, 10, 10 }, + .vactive = { 320, 320, 320 }, + .vfront_porch = { 8, 8, 500 }, + .vback_porch = { 4, 4, 117 }, + .vsync_len = { 4, 4, 10 }, + .flags = DISPLAY_FLAGS_HSYNC_HIGH | DISPLAY_FLAGS_VSYNC_HIGH | +DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE | +DISPLAY_FLAGS_SYNC_POSEDGE, }; -static int st7789v_get_modes(struct drm_panel *panel, -struct drm_connector *connector) +struct panel_desc { + u32 bus_format; + u32 bus_flags; +}; + +static struct panel_desc st7789v_desc = { + .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE, + .bus_format = MEDIA_BUS_FMT_RGB666_1X18, +}; + +static unsigned int st7789v_get_timings_modes(struct drm_panel *panel, + struct drm_connector *connector) { - struct st7789v *ctx = panel_to_st7789v(panel); struct drm_display_mode *mode; - u32 bus_format = MEDIA_BUS_FMT_RGB666_1X18; - mode = drm_mode_duplicate(connector->dev, _mode); + const struct display_timing *dt = _timing; + struct videomode vm; + + videomode_from_timing(dt, ); + mode = drm_mode_create(connector->dev); if (!mode) { - dev_err(panel->dev, "failed to add mode %ux%ux@%u\n", - default_mode.hdisplay, default_mode.vdisplay, - drm_mode_vrefresh(_mode)); - return -ENOMEM; + dev_err(panel->dev, "failed to add timing %ux%ux\n", + dt->hactive.typ, dt->vactive.typ); + return 0; } - drm_mode_set_name(mode); + drm_display_mode_from_videomode(, mode); + + mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; - mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; drm_mode_probed_add(connector, mode); + return 1; +} + +static int st7789v_get_modes(struct drm_panel *panel, +struct drm_connector *connector) +{ + struct st7789v *ctx = panel_to_st7789v(panel); + struct drm_display_mode *mode; + bool has_override = ctx->override_mode.type; + u32 bus_format = MEDIA_BUS_FMT_RGB666_1X18; + unsigned int num; + + if (has_override) { + mode = drm_mode_duplicate(connector->dev, >override_mode); + if (!mode) { + dev_err(panel->dev, "failed to add mode %ux%ux@%u\n", + ctx->override_mode.hdisplay, + ctx->override_mode.vdisplay, + drm_mode_vrefresh(>override_mode)); + return 0; +
[PATCH 4/7] drm/panel: sitronix-st7789v: add bus_flags to connector
Propagate pixel clock sampling edge and data enable polarity. Both are hardcoded. Signed-off-by: Gerald Loacker --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 24636722c2ff..1ca04585aff2 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -195,6 +195,8 @@ static int st7789v_get_modes(struct drm_panel *panel, drm_display_info_set_bus_formats(>display_info, _format, 1); + connector->display_info.bus_flags = DRM_BUS_FLAG_DE_HIGH | + DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE; /* * TODO: Remove once all drm drivers call -- 2.37.2
[PATCH 3/7] drm/panel: sitronix-st7789v: propagate h/v-sync polarity
Adds h/v sync polarity, which is hardcoded in display prepare, to drm_display_mode. Signed-off-by: Gerald Loacker --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 5d4542c12f44..24636722c2ff 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -167,6 +167,7 @@ static const struct drm_display_mode default_mode = { .vsync_start = 320 + 8, .vsync_end = 320 + 8 + 4, .vtotal = 320 + 8 + 4 + 4, + .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC, }; static int st7789v_get_modes(struct drm_panel *panel, -- 2.37.2
[PATCH 6/7] dt-bindings: display: add rotation property to sitronix, st7789v
From: Michael Riesch The sitronix-st7789v driver now considers the rotation property. Add the property to the documentation. Signed-off-by: Michael Riesch Signed-off-by: Gerald Loacker --- .../devicetree/bindings/display/panel/sitronix,st7789v.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml b/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml index d984b59daa4a..ed942cd3620f 100644 --- a/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml +++ b/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml @@ -22,6 +22,7 @@ properties: power-supply: true backlight: true port: true + rotation: true spi-cpha: true spi-cpol: true @@ -48,6 +49,7 @@ examples: reset-gpios = < 6 11 GPIO_ACTIVE_LOW>; backlight = <_bl>; power-supply = <>; +rotation = <180>; spi-max-frequency = <10>; spi-cpol; spi-cpha; -- 2.37.2
[PATCH 7/7] dt-bindings: display: add panel-timing property to sitronix, st7789v
The sitronix-st7789v driver now considers the panel-timing property. Add the property to the documentation. Signed-off-by: Gerald Loacker --- .../display/panel/sitronix,st7789v.yaml | 17 + 1 file changed, 17 insertions(+) diff --git a/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml b/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml index ed942cd3620f..8810f123dedf 100644 --- a/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml +++ b/Documentation/devicetree/bindings/display/panel/sitronix,st7789v.yaml @@ -21,6 +21,7 @@ properties: reset-gpios: true power-supply: true backlight: true + panel-timing: true port: true rotation: true @@ -54,6 +55,22 @@ examples: spi-cpol; spi-cpha; +panel-timing { +clock-frequency = <700>; +hactive = <240>; +vactive = <320>; +hfront-porch = <38>; +hback-porch = <10>; +hsync-len = <10>; +vfront-porch = <8>; +vback-porch = <4>; +vsync-len = <4>; +hsync-active = <1>; +vsync-active = <1>; +de-active = <1>; +pixelclk-active = <1>; +}; + port { panel_input: endpoint { remote-endpoint = <_out_panel>; -- 2.37.2
[PATCH 2/7] drm/panel: sitronix-st7789v: add panel orientation support
From: Michael Riesch Determine the orientation of the display based on the device tree and propagate it. Signed-off-by: Michael Riesch Signed-off-by: Gerald Loacker --- .../gpu/drm/panel/panel-sitronix-st7789v.c| 28 +++ 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index 9535437271d3..5d4542c12f44 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -117,6 +117,7 @@ struct st7789v { struct spi_device *spi; struct gpio_desc *reset; struct regulator *power; + enum drm_panel_orientation orientation; }; enum st7789v_prefix { @@ -171,6 +172,7 @@ static const struct drm_display_mode default_mode = { static int st7789v_get_modes(struct drm_panel *panel, struct drm_connector *connector) { + struct st7789v *ctx = panel_to_st7789v(panel); struct drm_display_mode *mode; u32 bus_format = MEDIA_BUS_FMT_RGB666_1X18; @@ -193,9 +195,22 @@ static int st7789v_get_modes(struct drm_panel *panel, drm_display_info_set_bus_formats(>display_info, _format, 1); + /* +* TODO: Remove once all drm drivers call +* drm_connector_set_orientation_from_panel() +*/ + drm_connector_set_panel_orientation(connector, ctx->orientation); + return 1; } +static enum drm_panel_orientation st7789v_get_orientation(struct drm_panel *p) +{ + struct st7789v *ctx = panel_to_st7789v(p); + + return ctx->orientation; +} + static int st7789v_prepare(struct drm_panel *panel) { struct st7789v *ctx = panel_to_st7789v(panel); @@ -351,11 +366,12 @@ static int st7789v_unprepare(struct drm_panel *panel) } static const struct drm_panel_funcs st7789v_drm_funcs = { - .disable= st7789v_disable, - .enable = st7789v_enable, - .get_modes = st7789v_get_modes, - .prepare= st7789v_prepare, - .unprepare = st7789v_unprepare, + .disable = st7789v_disable, + .enable = st7789v_enable, + .get_modes = st7789v_get_modes, + .get_orientation = st7789v_get_orientation, + .prepare = st7789v_prepare, + .unprepare = st7789v_unprepare, }; static int st7789v_probe(struct spi_device *spi) @@ -387,6 +403,8 @@ static int st7789v_probe(struct spi_device *spi) if (ret) return ret; + of_drm_get_panel_orientation(spi->dev.of_node, >orientation); + drm_panel_add(>panel); return 0; -- 2.37.2
[PATCH 1/7] drm/panel: sitronix-st7789v: propagate RGB666 format
From: Michael Riesch The ST7789V display is operated in RGB666 (18-bit) mode. Propagate this format via the display info. Signed-off-by: Michael Riesch Signed-off-by: Gerald Loacker --- drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c index bbc4569cbcdc..9535437271d3 100644 --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -171,6 +172,7 @@ static int st7789v_get_modes(struct drm_panel *panel, struct drm_connector *connector) { struct drm_display_mode *mode; + u32 bus_format = MEDIA_BUS_FMT_RGB666_1X18; mode = drm_mode_duplicate(connector->dev, _mode); if (!mode) { @@ -188,6 +190,9 @@ static int st7789v_get_modes(struct drm_panel *panel, connector->display_info.width_mm = 61; connector->display_info.height_mm = 103; + drm_display_info_set_bus_formats(>display_info, _format, +1); + return 1; } -- 2.37.2
[PATCH 0/7] Add timing override to sitronix,st7789v
This patch set adds additional functionality to the sitronix,st7789v driver. Patches 1,3 and 4 propagate useful flags to the drm subsystem. Patch 2 adds the orientation property. Patch 5 parses the device tree for a panel-timing and makes it possible to override the default timing. Patches 6 and 7 add the new properties to the dt-bindings. Gerald Loacker (4): drm/panel: sitronix-st7789v: propagate h/v-sync polarity drm/panel: sitronix-st7789v: add bus_flags to connector drm/panel: sitronix-st7789v: parse device tree to override timing mode dt-bindings: display: add panel-timing property to sitronix,st7789v Michael Riesch (3): drm/panel: sitronix-st7789v: propagate RGB666 format drm/panel: sitronix-st7789v: add panel orientation support dt-bindings: display: add rotation property to sitronix,st7789v .../display/panel/sitronix,st7789v.yaml | 19 ++ .../gpu/drm/panel/panel-sitronix-st7789v.c| 204 +++--- 2 files changed, 191 insertions(+), 32 deletions(-) -- 2.37.2
[PATCH] drm/rockchip: vop2: add polarity flags to RGB output
Use h/v-sync and pixel clock polarity flags for RGB output. For all other outputs this is already implemented. Signed-off-by: Gerald Loacker --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index 8cecf81a5ae0..e8b61973ade2 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -1435,6 +1435,8 @@ static void rk3568_set_intf_mux(struct vop2_video_port *vp, int id, die &= ~RK3568_SYS_DSP_INFACE_EN_RGB_MUX; die |= RK3568_SYS_DSP_INFACE_EN_RGB | FIELD_PREP(RK3568_SYS_DSP_INFACE_EN_RGB_MUX, vp->id); + dip &= ~RK3568_DSP_IF_POL__RGB_LVDS_PIN_POL; + dip |= FIELD_PREP(RK3568_DSP_IF_POL__RGB_LVDS_PIN_POL, polflags); if (polflags & POLFLAG_DCLK_INV) regmap_write(vop2->grf, RK3568_GRF_VO_CON1, BIT(3 + 16) | BIT(3)); else -- 2.37.2