* [PATCH 0/3] drm/imx: convey the pixelclk-active and de-active flags to the ipu-di driver
@ 2016-05-20 13:34 Lothar Waßmann
2016-05-20 13:34 ` [PATCH 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT Lothar Waßmann
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-20 13:34 UTC (permalink / raw)
To: David Airlie, Jean-Christophe Plagniol-Villard, Philipp Zabel,
Tomi Valkeinen, dri-devel, linux-fbdev, linux-kernel,
Russell King - ARM Linux, Sascha Hauer, Uwe Kleine-König
The 'de-active' and 'pixelclk-active' DT properties are evaluated
by of_parse_display_timing() called from of_get_drm_display_mode(),
but later lost in the conversion from videomode.flags to
drm_display_mode.flags.
Use an open coded version of of_get_drm_display_mode() to get access
to these flags and make sure they are passed on to the ipu-di driver.
This patch also makes sure, that the 'bus_flags' specified in the
simple-panel driver will be passed on from the ipu-di driver.
The first patch in this series makes sure, the imx-ldb driver honors
the 'native-mode' property in DT (like the parallel-display driver
does already).
The third patch removes some dead code in the parallel-display driver,
hat depends on a variable which is never assigned a non-zero value and
thus can never be reached.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT
2016-05-20 13:34 [PATCH 0/3] drm/imx: convey the pixelclk-active and de-active flags to the ipu-di driver Lothar Waßmann
@ 2016-05-20 13:34 ` Lothar Waßmann
2016-05-20 13:34 ` [PATCH 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-20 13:34 UTC (permalink / raw)
To: David Airlie, Jean-Christophe Plagniol-Villard, Philipp Zabel,
Tomi Valkeinen, dri-devel, linux-fbdev, linux-kernel,
Russell King - ARM Linux, Sascha Hauer, Uwe Kleine-König
Cc: Lothar Waßmann
This patch allows to select a specific video mode from a list of modes
defined in DT by setting the 'native-mode' property appropriately.
This change does not affect the behaviour of existing platforms, since
they either:
- have just one display-timings subnode
- have the native-mode property pointing to the first entry
- let the bootloader select the appropriate timing
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
drivers/gpu/drm/imx/imx-ldb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index a58eee5..b2dc4df 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -25,6 +25,7 @@
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
#include <linux/of_device.h>
#include <linux/of_graph.h>
+#include <video/of_display_timing.h>
#include <video/of_videomode.h>
#include <linux/regmap.h>
#include <linux/videodev2.h>
@@ -600,7 +601,8 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
channel->edid = kmemdup(edidp, channel->edid_len,
GFP_KERNEL);
} else if (!channel->panel) {
- ret = of_get_drm_display_mode(child, &channel->mode, 0);
+ ret = of_get_drm_display_mode(child, &channel->mode,
+ OF_USE_NATIVE_MODE);
if (!ret)
channel->mode_valid = 1;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver
2016-05-20 13:34 [PATCH 0/3] drm/imx: convey the pixelclk-active and de-active flags to the ipu-di driver Lothar Waßmann
2016-05-20 13:34 ` [PATCH 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT Lothar Waßmann
@ 2016-05-20 13:34 ` Lothar Waßmann
2016-05-20 14:31 ` Philipp Zabel
2016-05-20 13:34 ` [PATCH 3/3] drm/imx: remove dead code Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 0/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
3 siblings, 1 reply; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-20 13:34 UTC (permalink / raw)
To: David Airlie, Jean-Christophe Plagniol-Villard, Philipp Zabel,
Tomi Valkeinen, dri-devel, linux-fbdev, linux-kernel,
Russell King - ARM Linux, Sascha Hauer, Uwe Kleine-König
Cc: Lothar Waßmann
Currently these flags are lost in the call
drm_display_mode_from_videomode()
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
drivers/gpu/drm/imx/imx-drm-core.c | 12 +++++++----
drivers/gpu/drm/imx/imx-drm.h | 7 ++++---
drivers/gpu/drm/imx/imx-ldb.c | 37 ++++++++++++++++++++++++++--------
drivers/gpu/drm/imx/ipuv3-crtc.c | 7 ++++---
drivers/gpu/drm/imx/parallel-display.c | 31 ++++++++++++++++++++++++----
drivers/gpu/ipu-v3/ipu-di.c | 14 +++++++------
include/video/imx-ipu-v3.h | 5 +----
7 files changed, 81 insertions(+), 32 deletions(-)
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 2453fb1..51735b1 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -96,7 +96,8 @@ static struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc)
return NULL;
}
-int imx_drm_set_bus_format_pins(struct drm_encoder *encoder, u32 bus_format,
+int imx_drm_set_bus_format_pins(struct drm_encoder *encoder,
+ u32 bus_format, u32 bus_flags,
int hsync_pin, int vsync_pin)
{
struct imx_drm_crtc_helper_funcs *helper;
@@ -109,14 +110,17 @@ int imx_drm_set_bus_format_pins(struct drm_encoder *encoder, u32 bus_format,
helper = &imx_crtc->imx_drm_helper_funcs;
if (helper->set_interface_pix_fmt)
return helper->set_interface_pix_fmt(encoder->crtc,
- bus_format, hsync_pin, vsync_pin);
+ bus_format, bus_flags,
+ hsync_pin, vsync_pin);
return 0;
}
EXPORT_SYMBOL_GPL(imx_drm_set_bus_format_pins);
-int imx_drm_set_bus_format(struct drm_encoder *encoder, u32 bus_format)
+int imx_drm_set_bus_format(struct drm_encoder *encoder, u32 bus_format,
+ u32 bus_flags)
{
- return imx_drm_set_bus_format_pins(encoder, bus_format, 2, 3);
+ return imx_drm_set_bus_format_pins(encoder, bus_format, bus_flags,
+ 2, 3);
}
EXPORT_SYMBOL_GPL(imx_drm_set_bus_format);
diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h
index b0241b9..b74baf7 100644
--- a/drivers/gpu/drm/imx/imx-drm.h
+++ b/drivers/gpu/drm/imx/imx-drm.h
@@ -19,7 +19,8 @@ struct imx_drm_crtc_helper_funcs {
int (*enable_vblank)(struct drm_crtc *crtc);
void (*disable_vblank)(struct drm_crtc *crtc);
int (*set_interface_pix_fmt)(struct drm_crtc *crtc,
- u32 bus_format, int hsync_pin, int vsync_pin);
+ u32 bus_format, u32 bus_flags,
+ int hsync_pin, int vsync_pin);
const struct drm_crtc_helper_funcs *crtc_helper_funcs;
const struct drm_crtc_funcs *crtc_funcs;
};
@@ -42,9 +43,9 @@ void imx_drm_mode_config_init(struct drm_device *drm);
struct drm_gem_cma_object *imx_drm_fb_get_obj(struct drm_framebuffer *fb);
int imx_drm_set_bus_format_pins(struct drm_encoder *encoder,
- u32 bus_format, int hsync_pin, int vsync_pin);
+ u32 bus_format, u32 bus_flags, int hsync_pin, int vsync_pin);
int imx_drm_set_bus_format(struct drm_encoder *encoder,
- u32 bus_format);
+ u32 bus_format, u32 bus_flags);
int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np);
diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index b2dc4df..67706eea 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -27,6 +27,7 @@
#include <linux/of_graph.h>
#include <video/of_display_timing.h>
#include <video/of_videomode.h>
+#include <video/videomode.h>
#include <linux/regmap.h>
#include <linux/videodev2.h>
@@ -65,7 +66,8 @@ struct imx_ldb_channel {
int edid_len;
struct drm_display_mode mode;
int mode_valid;
- int bus_format;
+ u32 bus_format;
+ u32 bus_flags;
};
struct bus_mux {
@@ -102,8 +104,10 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector)
struct drm_display_info *di = &connector->display_info;
num_modes = imx_ldb_ch->panel->funcs->get_modes(imx_ldb_ch->panel);
- if (!imx_ldb_ch->bus_format && di->num_bus_formats)
+ if (!imx_ldb_ch->bus_format && di->num_bus_formats) {
imx_ldb_ch->bus_format = di->bus_formats[0];
+ imx_ldb_ch->bus_flags = di->bus_flags;
+ }
if (num_modes > 0)
return num_modes;
}
@@ -202,7 +206,8 @@ static void imx_ldb_encoder_prepare(struct drm_encoder *encoder)
break;
}
- imx_drm_set_bus_format(encoder, bus_format);
+ imx_drm_set_bus_format(encoder, bus_format,
+ imx_ldb_ch->bus_flags);
}
static void imx_ldb_encoder_commit(struct drm_encoder *encoder)
@@ -558,7 +563,7 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
ret = of_property_read_u32(child, "reg", &i);
if (ret || i < 0 || i > 1)
- return -EINVAL;
+ return ret ?: -EINVAL;
if (dual && i > 0) {
dev_warn(dev, "dual-channel mode, ignoring second output\n");
@@ -601,10 +606,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
channel->edid = kmemdup(edidp, channel->edid_len,
GFP_KERNEL);
} else if (!channel->panel) {
- ret = of_get_drm_display_mode(child, &channel->mode,
- OF_USE_NATIVE_MODE);
- if (!ret)
- channel->mode_valid = 1;
+ struct videomode vm;
+
+ ret = of_get_videomode(child, &vm, OF_USE_NATIVE_MODE);
+ if (ret)
+ return ret;
+
+ drm_display_mode_from_videomode(&vm, &channel->mode);
+
+ if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
+ channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
+ if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
+ channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
+
+ if (vm.flags & DISPLAY_FLAGS_DE_LOW)
+ channel->bus_flags |= DRM_BUS_FLAG_DE_LOW;
+ if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
+ channel->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
+
+ drm_mode_debug_printmodeline(&channel->mode);
+ channel->mode_valid = 1;
}
channel->bus_format = of_get_bus_format(dev, child);
diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index dee8e8b..3fb9ac7 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -66,6 +66,7 @@ struct ipu_crtc {
struct ipu_flip_work *flip_work;
int irq;
u32 bus_format;
+ u32 bus_flags;
int di_hsync_pin;
int di_vsync_pin;
};
@@ -271,9 +272,8 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc,
else
sig_cfg.clkflags = 0;
- sig_cfg.enable_pol = 1;
- sig_cfg.clk_pol = 0;
sig_cfg.bus_format = ipu_crtc->bus_format;
+ sig_cfg.bus_flags = ipu_crtc->bus_flags;
sig_cfg.v_to_h_sync = 0;
sig_cfg.hsync_pin = ipu_crtc->di_hsync_pin;
sig_cfg.vsync_pin = ipu_crtc->di_vsync_pin;
@@ -396,11 +396,12 @@ static void ipu_disable_vblank(struct drm_crtc *crtc)
}
static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc,
- u32 bus_format, int hsync_pin, int vsync_pin)
+ u32 bus_format, u32 bus_flags, int hsync_pin, int vsync_pin)
{
struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
ipu_crtc->bus_format = bus_format;
+ ipu_crtc->bus_flags = bus_flags;
ipu_crtc->di_hsync_pin = hsync_pin;
ipu_crtc->di_vsync_pin = vsync_pin;
diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
index 363e2c7..440f34d 100644
--- a/drivers/gpu/drm/imx/parallel-display.c
+++ b/drivers/gpu/drm/imx/parallel-display.c
@@ -19,9 +19,12 @@
#include <drm/drm_fb_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_panel.h>
+#include <linux/of_graph.h>
#include <linux/videodev2.h>
+#include <video/display_timing.h>
#include <video/of_display_timing.h>
-#include <linux/of_graph.h>
+#include <video/of_videomode.h>
+#include <video/videomode.h>
#include "imx-drm.h"
@@ -35,6 +38,7 @@ struct imx_parallel_display {
void *edid;
int edid_len;
u32 bus_format;
+ u32 bus_flags;
int mode_valid;
struct drm_display_mode mode;
struct drm_panel *panel;
@@ -57,8 +61,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
struct drm_display_info *di = &connector->display_info;
num_modes = imxpd->panel->funcs->get_modes(imxpd->panel);
- if (!imxpd->bus_format && di->num_bus_formats)
+ if (!imxpd->bus_format && di->num_bus_formats) {
imxpd->bus_format = di->bus_formats[0];
+ imxpd->bus_flags = di->bus_flags;
+ }
if (num_modes > 0)
return num_modes;
}
@@ -81,10 +87,27 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
if (np) {
struct drm_display_mode *mode = drm_mode_create(connector->dev);
+ struct videomode vm;
+ int ret;
if (!mode)
return -EINVAL;
- of_get_drm_display_mode(np, &imxpd->mode, OF_USE_NATIVE_MODE);
+
+ ret = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
+ if (ret)
+ return ret;
+ drm_display_mode_from_videomode(&vm, &imxpd->mode);
+ drm_mode_debug_printmodeline(&imxpd->mode);
+
+ if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
+ imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
+ if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
+ imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
+
+ if (vm.flags & DISPLAY_FLAGS_DE_LOW)
+ imxpd->bus_flags |= DRM_BUS_FLAG_DE_LOW;
+ if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
+ imxpd->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
drm_mode_copy(mode, &imxpd->mode);
mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
drm_mode_probed_add(connector, mode);
@@ -116,7 +139,7 @@ static void imx_pd_encoder_prepare(struct drm_encoder *encoder)
{
struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
- imx_drm_set_bus_format(encoder, imxpd->bus_format);
+ imx_drm_set_bus_format(encoder, imxpd->bus_format, imxpd->bus_flags);
}
static void imx_pd_encoder_commit(struct drm_encoder *encoder)
diff --git a/drivers/gpu/ipu-v3/ipu-di.c b/drivers/gpu/ipu-v3/ipu-di.c
index 359268e..bff4701 100644
--- a/drivers/gpu/ipu-v3/ipu-di.c
+++ b/drivers/gpu/ipu-v3/ipu-di.c
@@ -20,6 +20,7 @@
#include <linux/err.h>
#include <linux/platform_device.h>
+#include <drm/drm_crtc.h>
#include <video/imx-ipu-v3.h>
#include "ipu-prv.h"
@@ -622,7 +623,9 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig)
if (sig->mode.flags & DISPLAY_FLAGS_VSYNC_HIGH)
di_gen |= ipu_di_gen_polarity(sig->vsync_pin);
- if (sig->clk_pol)
+ if (sig->bus_flags & DRM_BUS_FLAG_PIXDATA_NEGEDGE)
+ di_gen &= ~DI_GEN_POLARITY_DISP_CLK;
+ else if (sig->bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE)
di_gen |= DI_GEN_POLARITY_DISP_CLK;
ipu_di_write(di, di_gen, DI_GENERAL);
@@ -630,13 +633,12 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig)
ipu_di_write(di, (--vsync_cnt << DI_VSYNC_SEL_OFFSET) | 0x00000002,
DI_SYNC_AS_GEN);
- reg = ipu_di_read(di, DI_POL);
- reg &= ~(DI_POL_DRDY_DATA_POLARITY | DI_POL_DRDY_POLARITY_15);
+ reg = ipu_di_read(di, DI_POL) & ~DI_POL_DRDY_DATA_POLARITY;
- if (sig->enable_pol)
+ if (sig->bus_flags & DRM_BUS_FLAG_DE_HIGH)
reg |= DI_POL_DRDY_POLARITY_15;
- if (sig->data_pol)
- reg |= DI_POL_DRDY_DATA_POLARITY;
+ else if (sig->bus_flags & DRM_BUS_FLAG_DE_LOW)
+ reg &= ~DI_POL_DRDY_POLARITY_15;
ipu_di_write(di, reg, DI_POL);
diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index ad66589..7c64c55 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -33,13 +33,10 @@ enum ipuv3_type {
* Bitfield of Display Interface signal polarities.
*/
struct ipu_di_signal_cfg {
- unsigned data_pol:1; /* true = inverted */
- unsigned clk_pol:1; /* true = rising edge */
- unsigned enable_pol:1;
-
struct videomode mode;
u32 bus_format;
+ u32 bus_flags;
u32 v_to_h_sync;
#define IPU_DI_CLKMODE_SYNC (1 << 0)
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] drm/imx: remove dead code
2016-05-20 13:34 [PATCH 0/3] drm/imx: convey the pixelclk-active and de-active flags to the ipu-di driver Lothar Waßmann
2016-05-20 13:34 ` [PATCH 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT Lothar Waßmann
2016-05-20 13:34 ` [PATCH 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
@ 2016-05-20 13:34 ` Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 0/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
3 siblings, 0 replies; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-20 13:34 UTC (permalink / raw)
To: David Airlie, Jean-Christophe Plagniol-Villard, Philipp Zabel,
Tomi Valkeinen, dri-devel, linux-fbdev, linux-kernel,
Russell King - ARM Linux, Sascha Hauer, Uwe Kleine-König
Cc: Lothar Waßmann
The 'mode_valid' flag is never set in this driver. Remove it and the
code that depends on it.
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
drivers/gpu/drm/imx/parallel-display.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
index 440f34d..e37d0e6 100644
--- a/drivers/gpu/drm/imx/parallel-display.c
+++ b/drivers/gpu/drm/imx/parallel-display.c
@@ -39,7 +39,6 @@ struct imx_parallel_display {
int edid_len;
u32 bus_format;
u32 bus_flags;
- int mode_valid;
struct drm_display_mode mode;
struct drm_panel *panel;
};
@@ -74,17 +73,6 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
num_modes = drm_add_edid_modes(connector, imxpd->edid);
}
- if (imxpd->mode_valid) {
- struct drm_display_mode *mode = drm_mode_create(connector->dev);
-
- if (!mode)
- return -EINVAL;
- drm_mode_copy(mode, &imxpd->mode);
- mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
- drm_mode_probed_add(connector, mode);
- num_modes++;
- }
-
if (np) {
struct drm_display_mode *mode = drm_mode_create(connector->dev);
struct videomode vm;
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver
2016-05-20 13:34 ` [PATCH 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
@ 2016-05-20 14:31 ` Philipp Zabel
0 siblings, 0 replies; 12+ messages in thread
From: Philipp Zabel @ 2016-05-20 14:31 UTC (permalink / raw)
To: Lothar Waßmann
Cc: David Airlie, Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
dri-devel, linux-fbdev, linux-kernel, Russell King - ARM Linux,
Sascha Hauer, Uwe Kleine-König
Hi Lothar,
Am Freitag, den 20.05.2016, 15:34 +0200 schrieb Lothar Waßmann:
> Currently these flags are lost in the call
> drm_display_mode_from_videomode()
>
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
thank you for the patches. The other two look fine to me, could you
rebase this one on top of:
https://patchwork.kernel.org/patch/9113791/ ("drm/imx: use bus_flags for
pixel clock polarity")?
regards
Philipp
> ---
> drivers/gpu/drm/imx/imx-drm-core.c | 12 +++++++----
> drivers/gpu/drm/imx/imx-drm.h | 7 ++++---
> drivers/gpu/drm/imx/imx-ldb.c | 37 ++++++++++++++++++++++++++--------
> drivers/gpu/drm/imx/ipuv3-crtc.c | 7 ++++---
> drivers/gpu/drm/imx/parallel-display.c | 31 ++++++++++++++++++++++++----
> drivers/gpu/ipu-v3/ipu-di.c | 14 +++++++------
> include/video/imx-ipu-v3.h | 5 +----
> 7 files changed, 81 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
> index 2453fb1..51735b1 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -96,7 +96,8 @@ static struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc)
> return NULL;
> }
>
> -int imx_drm_set_bus_format_pins(struct drm_encoder *encoder, u32 bus_format,
> +int imx_drm_set_bus_format_pins(struct drm_encoder *encoder,
> + u32 bus_format, u32 bus_flags,
> int hsync_pin, int vsync_pin)
> {
> struct imx_drm_crtc_helper_funcs *helper;
> @@ -109,14 +110,17 @@ int imx_drm_set_bus_format_pins(struct drm_encoder *encoder, u32 bus_format,
> helper = &imx_crtc->imx_drm_helper_funcs;
> if (helper->set_interface_pix_fmt)
> return helper->set_interface_pix_fmt(encoder->crtc,
> - bus_format, hsync_pin, vsync_pin);
> + bus_format, bus_flags,
> + hsync_pin, vsync_pin);
> return 0;
> }
> EXPORT_SYMBOL_GPL(imx_drm_set_bus_format_pins);
>
> -int imx_drm_set_bus_format(struct drm_encoder *encoder, u32 bus_format)
> +int imx_drm_set_bus_format(struct drm_encoder *encoder, u32 bus_format,
> + u32 bus_flags)
> {
> - return imx_drm_set_bus_format_pins(encoder, bus_format, 2, 3);
> + return imx_drm_set_bus_format_pins(encoder, bus_format, bus_flags,
> + 2, 3);
> }
> EXPORT_SYMBOL_GPL(imx_drm_set_bus_format);
>
> diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h
> index b0241b9..b74baf7 100644
> --- a/drivers/gpu/drm/imx/imx-drm.h
> +++ b/drivers/gpu/drm/imx/imx-drm.h
> @@ -19,7 +19,8 @@ struct imx_drm_crtc_helper_funcs {
> int (*enable_vblank)(struct drm_crtc *crtc);
> void (*disable_vblank)(struct drm_crtc *crtc);
> int (*set_interface_pix_fmt)(struct drm_crtc *crtc,
> - u32 bus_format, int hsync_pin, int vsync_pin);
> + u32 bus_format, u32 bus_flags,
> + int hsync_pin, int vsync_pin);
> const struct drm_crtc_helper_funcs *crtc_helper_funcs;
> const struct drm_crtc_funcs *crtc_funcs;
> };
> @@ -42,9 +43,9 @@ void imx_drm_mode_config_init(struct drm_device *drm);
> struct drm_gem_cma_object *imx_drm_fb_get_obj(struct drm_framebuffer *fb);
>
> int imx_drm_set_bus_format_pins(struct drm_encoder *encoder,
> - u32 bus_format, int hsync_pin, int vsync_pin);
> + u32 bus_format, u32 bus_flags, int hsync_pin, int vsync_pin);
> int imx_drm_set_bus_format(struct drm_encoder *encoder,
> - u32 bus_format);
> + u32 bus_format, u32 bus_flags);
>
> int imx_drm_encoder_parse_of(struct drm_device *drm,
> struct drm_encoder *encoder, struct device_node *np);
> diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
> index b2dc4df..67706eea 100644
> --- a/drivers/gpu/drm/imx/imx-ldb.c
> +++ b/drivers/gpu/drm/imx/imx-ldb.c
> @@ -27,6 +27,7 @@
> #include <linux/of_graph.h>
> #include <video/of_display_timing.h>
> #include <video/of_videomode.h>
> +#include <video/videomode.h>
> #include <linux/regmap.h>
> #include <linux/videodev2.h>
>
> @@ -65,7 +66,8 @@ struct imx_ldb_channel {
> int edid_len;
> struct drm_display_mode mode;
> int mode_valid;
> - int bus_format;
> + u32 bus_format;
> + u32 bus_flags;
> };
>
> struct bus_mux {
> @@ -102,8 +104,10 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector)
> struct drm_display_info *di = &connector->display_info;
>
> num_modes = imx_ldb_ch->panel->funcs->get_modes(imx_ldb_ch->panel);
> - if (!imx_ldb_ch->bus_format && di->num_bus_formats)
> + if (!imx_ldb_ch->bus_format && di->num_bus_formats) {
> imx_ldb_ch->bus_format = di->bus_formats[0];
> + imx_ldb_ch->bus_flags = di->bus_flags;
> + }
> if (num_modes > 0)
> return num_modes;
> }
> @@ -202,7 +206,8 @@ static void imx_ldb_encoder_prepare(struct drm_encoder *encoder)
> break;
> }
>
> - imx_drm_set_bus_format(encoder, bus_format);
> + imx_drm_set_bus_format(encoder, bus_format,
> + imx_ldb_ch->bus_flags);
> }
>
> static void imx_ldb_encoder_commit(struct drm_encoder *encoder)
> @@ -558,7 +563,7 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
>
> ret = of_property_read_u32(child, "reg", &i);
> if (ret || i < 0 || i > 1)
> - return -EINVAL;
> + return ret ?: -EINVAL;
>
> if (dual && i > 0) {
> dev_warn(dev, "dual-channel mode, ignoring second output\n");
> @@ -601,10 +606,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
> channel->edid = kmemdup(edidp, channel->edid_len,
> GFP_KERNEL);
> } else if (!channel->panel) {
> - ret = of_get_drm_display_mode(child, &channel->mode,
> - OF_USE_NATIVE_MODE);
> - if (!ret)
> - channel->mode_valid = 1;
> + struct videomode vm;
> +
> + ret = of_get_videomode(child, &vm, OF_USE_NATIVE_MODE);
> + if (ret)
> + return ret;
> +
> + drm_display_mode_from_videomode(&vm, &channel->mode);
> +
> + if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
> + channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
> + if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
> + channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
> +
> + if (vm.flags & DISPLAY_FLAGS_DE_LOW)
> + channel->bus_flags |= DRM_BUS_FLAG_DE_LOW;
> + if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
> + channel->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
> +
> + drm_mode_debug_printmodeline(&channel->mode);
> + channel->mode_valid = 1;
> }
>
> channel->bus_format = of_get_bus_format(dev, child);
> diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
> index dee8e8b..3fb9ac7 100644
> --- a/drivers/gpu/drm/imx/ipuv3-crtc.c
> +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
> @@ -66,6 +66,7 @@ struct ipu_crtc {
> struct ipu_flip_work *flip_work;
> int irq;
> u32 bus_format;
> + u32 bus_flags;
> int di_hsync_pin;
> int di_vsync_pin;
> };
> @@ -271,9 +272,8 @@ static int ipu_crtc_mode_set(struct drm_crtc *crtc,
> else
> sig_cfg.clkflags = 0;
>
> - sig_cfg.enable_pol = 1;
> - sig_cfg.clk_pol = 0;
> sig_cfg.bus_format = ipu_crtc->bus_format;
> + sig_cfg.bus_flags = ipu_crtc->bus_flags;
> sig_cfg.v_to_h_sync = 0;
> sig_cfg.hsync_pin = ipu_crtc->di_hsync_pin;
> sig_cfg.vsync_pin = ipu_crtc->di_vsync_pin;
> @@ -396,11 +396,12 @@ static void ipu_disable_vblank(struct drm_crtc *crtc)
> }
>
> static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc,
> - u32 bus_format, int hsync_pin, int vsync_pin)
> + u32 bus_format, u32 bus_flags, int hsync_pin, int vsync_pin)
> {
> struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
>
> ipu_crtc->bus_format = bus_format;
> + ipu_crtc->bus_flags = bus_flags;
> ipu_crtc->di_hsync_pin = hsync_pin;
> ipu_crtc->di_vsync_pin = vsync_pin;
>
> diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
> index 363e2c7..440f34d 100644
> --- a/drivers/gpu/drm/imx/parallel-display.c
> +++ b/drivers/gpu/drm/imx/parallel-display.c
> @@ -19,9 +19,12 @@
> #include <drm/drm_fb_helper.h>
> #include <drm/drm_crtc_helper.h>
> #include <drm/drm_panel.h>
> +#include <linux/of_graph.h>
> #include <linux/videodev2.h>
> +#include <video/display_timing.h>
> #include <video/of_display_timing.h>
> -#include <linux/of_graph.h>
> +#include <video/of_videomode.h>
> +#include <video/videomode.h>
>
> #include "imx-drm.h"
>
> @@ -35,6 +38,7 @@ struct imx_parallel_display {
> void *edid;
> int edid_len;
> u32 bus_format;
> + u32 bus_flags;
> int mode_valid;
> struct drm_display_mode mode;
> struct drm_panel *panel;
> @@ -57,8 +61,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
> struct drm_display_info *di = &connector->display_info;
>
> num_modes = imxpd->panel->funcs->get_modes(imxpd->panel);
> - if (!imxpd->bus_format && di->num_bus_formats)
> + if (!imxpd->bus_format && di->num_bus_formats) {
> imxpd->bus_format = di->bus_formats[0];
> + imxpd->bus_flags = di->bus_flags;
> + }
> if (num_modes > 0)
> return num_modes;
> }
> @@ -81,10 +87,27 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
>
> if (np) {
> struct drm_display_mode *mode = drm_mode_create(connector->dev);
> + struct videomode vm;
> + int ret;
>
> if (!mode)
> return -EINVAL;
> - of_get_drm_display_mode(np, &imxpd->mode, OF_USE_NATIVE_MODE);
> +
> + ret = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
> + if (ret)
> + return ret;
> + drm_display_mode_from_videomode(&vm, &imxpd->mode);
> + drm_mode_debug_printmodeline(&imxpd->mode);
> +
> + if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
> + imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
> + if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
> + imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
> +
> + if (vm.flags & DISPLAY_FLAGS_DE_LOW)
> + imxpd->bus_flags |= DRM_BUS_FLAG_DE_LOW;
> + if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
> + imxpd->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
> drm_mode_copy(mode, &imxpd->mode);
> mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
> drm_mode_probed_add(connector, mode);
> @@ -116,7 +139,7 @@ static void imx_pd_encoder_prepare(struct drm_encoder *encoder)
> {
> struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
>
> - imx_drm_set_bus_format(encoder, imxpd->bus_format);
> + imx_drm_set_bus_format(encoder, imxpd->bus_format, imxpd->bus_flags);
> }
>
> static void imx_pd_encoder_commit(struct drm_encoder *encoder)
> diff --git a/drivers/gpu/ipu-v3/ipu-di.c b/drivers/gpu/ipu-v3/ipu-di.c
> index 359268e..bff4701 100644
> --- a/drivers/gpu/ipu-v3/ipu-di.c
> +++ b/drivers/gpu/ipu-v3/ipu-di.c
> @@ -20,6 +20,7 @@
> #include <linux/err.h>
> #include <linux/platform_device.h>
>
> +#include <drm/drm_crtc.h>
> #include <video/imx-ipu-v3.h>
> #include "ipu-prv.h"
>
> @@ -622,7 +623,9 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig)
> if (sig->mode.flags & DISPLAY_FLAGS_VSYNC_HIGH)
> di_gen |= ipu_di_gen_polarity(sig->vsync_pin);
>
> - if (sig->clk_pol)
> + if (sig->bus_flags & DRM_BUS_FLAG_PIXDATA_NEGEDGE)
> + di_gen &= ~DI_GEN_POLARITY_DISP_CLK;
> + else if (sig->bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE)
> di_gen |= DI_GEN_POLARITY_DISP_CLK;
>
> ipu_di_write(di, di_gen, DI_GENERAL);
> @@ -630,13 +633,12 @@ int ipu_di_init_sync_panel(struct ipu_di *di, struct ipu_di_signal_cfg *sig)
> ipu_di_write(di, (--vsync_cnt << DI_VSYNC_SEL_OFFSET) | 0x00000002,
> DI_SYNC_AS_GEN);
>
> - reg = ipu_di_read(di, DI_POL);
> - reg &= ~(DI_POL_DRDY_DATA_POLARITY | DI_POL_DRDY_POLARITY_15);
> + reg = ipu_di_read(di, DI_POL) & ~DI_POL_DRDY_DATA_POLARITY;
>
> - if (sig->enable_pol)
> + if (sig->bus_flags & DRM_BUS_FLAG_DE_HIGH)
> reg |= DI_POL_DRDY_POLARITY_15;
> - if (sig->data_pol)
> - reg |= DI_POL_DRDY_DATA_POLARITY;
> + else if (sig->bus_flags & DRM_BUS_FLAG_DE_LOW)
> + reg &= ~DI_POL_DRDY_POLARITY_15;
>
> ipu_di_write(di, reg, DI_POL);
>
> diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
> index ad66589..7c64c55 100644
> --- a/include/video/imx-ipu-v3.h
> +++ b/include/video/imx-ipu-v3.h
> @@ -33,13 +33,10 @@ enum ipuv3_type {
> * Bitfield of Display Interface signal polarities.
> */
> struct ipu_di_signal_cfg {
> - unsigned data_pol:1; /* true = inverted */
> - unsigned clk_pol:1; /* true = rising edge */
> - unsigned enable_pol:1;
> -
> struct videomode mode;
>
> u32 bus_format;
> + u32 bus_flags;
> u32 v_to_h_sync;
>
> #define IPU_DI_CLKMODE_SYNC (1 << 0)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 0/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver
2016-05-20 13:34 [PATCH 0/3] drm/imx: convey the pixelclk-active and de-active flags to the ipu-di driver Lothar Waßmann
` (2 preceding siblings ...)
2016-05-20 13:34 ` [PATCH 3/3] drm/imx: remove dead code Lothar Waßmann
@ 2016-05-24 6:31 ` Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT Lothar Waßmann
` (2 more replies)
3 siblings, 3 replies; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-24 6:31 UTC (permalink / raw)
To: David Airlie, Philipp Zabel, dri-devel, linux-kernel
The 'de-active' and 'pixelclk-active' DT properties are evaluated
by of_parse_display_timing() called from of_get_drm_display_mode(),
but later lost in the conversion from videomode.flags to
drm_display_mode.flags.
Use an open coded version of of_get_drm_display_mode() to get access
to these flags and make sure they are passed on to the ipu-di driver.
The first patch in this series makes sure, the imx-ldb driver honors
the 'native-mode' property in DT (like the parallel-display driver
does already).
The third patch removes some dead code in the parallel-display driver,
hat depends on a variable which is never assigned a non-zero value and
thus can never be reached.
Changes vs. v1:
- rebased on top of https://patchwork.kernel.org/patch/9113791/ as
per Philipp Zabel's request
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT
2016-05-24 6:31 ` [PATCHv2 0/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
@ 2016-05-24 6:31 ` Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 3/3] drm/imx: remove dead code Lothar Waßmann
2 siblings, 0 replies; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-24 6:31 UTC (permalink / raw)
To: David Airlie, Philipp Zabel, dri-devel, linux-kernel; +Cc: Lothar Waßmann
This patch allows to select a specific video mode from a list of modes
defined in DT by setting the 'native-mode' property appropriately.
This change does not affect the behaviour of existing platforms, since
they either:
- have just one display-timings subnode
- have the native-mode property pointing to the first entry
- let the bootloader select the appropriate timing
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
drivers/gpu/drm/imx/imx-ldb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index a58eee5..b2dc4df 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -25,6 +25,7 @@
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
#include <linux/of_device.h>
#include <linux/of_graph.h>
+#include <video/of_display_timing.h>
#include <video/of_videomode.h>
#include <linux/regmap.h>
#include <linux/videodev2.h>
@@ -600,7 +601,8 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
channel->edid = kmemdup(edidp, channel->edid_len,
GFP_KERNEL);
} else if (!channel->panel) {
- ret = of_get_drm_display_mode(child, &channel->mode, 0);
+ ret = of_get_drm_display_mode(child, &channel->mode,
+ OF_USE_NATIVE_MODE);
if (!ret)
channel->mode_valid = 1;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCHv2 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver
2016-05-24 6:31 ` [PATCHv2 0/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT Lothar Waßmann
@ 2016-05-24 6:31 ` Lothar Waßmann
2016-05-24 14:16 ` Philipp Zabel
2016-05-24 6:31 ` [PATCHv2 3/3] drm/imx: remove dead code Lothar Waßmann
2 siblings, 1 reply; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-24 6:31 UTC (permalink / raw)
To: David Airlie, Philipp Zabel, dri-devel, linux-kernel; +Cc: Lothar Waßmann
Currently these flags are lost in the call
drm_display_mode_from_videomode()
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
drivers/gpu/drm/imx/imx-ldb.c | 37 ++++++++++++++++++++++++++--------
drivers/gpu/drm/imx/parallel-display.c | 31 ++++++++++++++++++++++++----
2 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index b2dc4df..b17a246 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -27,6 +27,7 @@
#include <linux/of_graph.h>
#include <video/of_display_timing.h>
#include <video/of_videomode.h>
+#include <video/videomode.h>
#include <linux/regmap.h>
#include <linux/videodev2.h>
@@ -65,7 +66,8 @@ struct imx_ldb_channel {
int edid_len;
struct drm_display_mode mode;
int mode_valid;
- int bus_format;
+ u32 bus_format;
+ u32 bus_flags;
};
struct bus_mux {
@@ -102,8 +104,10 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector)
struct drm_display_info *di = &connector->display_info;
num_modes = imx_ldb_ch->panel->funcs->get_modes(imx_ldb_ch->panel);
- if (!imx_ldb_ch->bus_format && di->num_bus_formats)
+ if (!imx_ldb_ch->bus_format && di->num_bus_formats) {
imx_ldb_ch->bus_format = di->bus_formats[0];
+ imx_ldb_ch->bus_flags = di->bus_flags;
+ }
if (num_modes > 0)
return num_modes;
}
@@ -202,7 +206,8 @@ static void imx_ldb_encoder_prepare(struct drm_encoder *encoder)
break;
}
- imx_drm_set_bus_format(encoder, bus_format);
+ imx_drm_set_bus_config(encoder, bus_format, 2, 3,
+ imx_ldb_ch->bus_flags);
}
static void imx_ldb_encoder_commit(struct drm_encoder *encoder)
@@ -558,7 +563,7 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
ret = of_property_read_u32(child, "reg", &i);
if (ret || i < 0 || i > 1)
- return -EINVAL;
+ return ret ?: -EINVAL;
if (dual && i > 0) {
dev_warn(dev, "dual-channel mode, ignoring second output\n");
@@ -601,10 +606,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
channel->edid = kmemdup(edidp, channel->edid_len,
GFP_KERNEL);
} else if (!channel->panel) {
- ret = of_get_drm_display_mode(child, &channel->mode,
- OF_USE_NATIVE_MODE);
- if (!ret)
- channel->mode_valid = 1;
+ struct videomode vm;
+
+ ret = of_get_videomode(child, &vm, OF_USE_NATIVE_MODE);
+ if (ret)
+ return ret;
+
+ drm_display_mode_from_videomode(&vm, &channel->mode);
+
+ if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
+ channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
+ if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
+ channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
+
+ if (vm.flags & DISPLAY_FLAGS_DE_LOW)
+ channel->bus_flags |= DRM_BUS_FLAG_DE_LOW;
+ if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
+ channel->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
+
+ drm_mode_debug_printmodeline(&channel->mode);
+ channel->mode_valid = 1;
}
channel->bus_format = of_get_bus_format(dev, child);
diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
index 3db634d..238057b 100644
--- a/drivers/gpu/drm/imx/parallel-display.c
+++ b/drivers/gpu/drm/imx/parallel-display.c
@@ -19,9 +19,12 @@
#include <drm/drm_fb_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_panel.h>
+#include <linux/of_graph.h>
#include <linux/videodev2.h>
+#include <video/display_timing.h>
#include <video/of_display_timing.h>
-#include <linux/of_graph.h>
+#include <video/of_videomode.h>
+#include <video/videomode.h>
#include "imx-drm.h"
@@ -35,6 +38,7 @@ struct imx_parallel_display {
void *edid;
int edid_len;
u32 bus_format;
+ u32 bus_flags;
int mode_valid;
struct drm_display_mode mode;
struct drm_panel *panel;
@@ -57,8 +61,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
struct drm_display_info *di = &connector->display_info;
num_modes = imxpd->panel->funcs->get_modes(imxpd->panel);
- if (!imxpd->bus_format && di->num_bus_formats)
+ if (!imxpd->bus_format && di->num_bus_formats) {
imxpd->bus_format = di->bus_formats[0];
+ imxpd->bus_flags = di->bus_flags;
+ }
if (num_modes > 0)
return num_modes;
}
@@ -81,10 +87,27 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
if (np) {
struct drm_display_mode *mode = drm_mode_create(connector->dev);
+ struct videomode vm;
+ int ret;
if (!mode)
return -EINVAL;
- of_get_drm_display_mode(np, &imxpd->mode, OF_USE_NATIVE_MODE);
+
+ ret = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
+ if (ret)
+ return ret;
+ drm_display_mode_from_videomode(&vm, &imxpd->mode);
+ drm_mode_debug_printmodeline(&imxpd->mode);
+
+ if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
+ imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
+ if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
+ imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
+
+ if (vm.flags & DISPLAY_FLAGS_DE_LOW)
+ imxpd->bus_flags |= DRM_BUS_FLAG_DE_LOW;
+ if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
+ imxpd->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
drm_mode_copy(mode, &imxpd->mode);
mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
drm_mode_probed_add(connector, mode);
@@ -116,7 +139,7 @@ static void imx_pd_encoder_prepare(struct drm_encoder *encoder)
{
struct imx_parallel_display *imxpd = enc_to_imxpd(encoder);
imx_drm_set_bus_config(encoder, imxpd->bus_format, 2, 3,
- imxpd->connector.display_info.bus_flags);
+ imxpd->bus_flags);
}
static void imx_pd_encoder_commit(struct drm_encoder *encoder)
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCHv2 3/3] drm/imx: remove dead code
2016-05-24 6:31 ` [PATCHv2 0/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
@ 2016-05-24 6:31 ` Lothar Waßmann
2 siblings, 0 replies; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-24 6:31 UTC (permalink / raw)
To: David Airlie, Philipp Zabel, dri-devel, linux-kernel; +Cc: Lothar Waßmann
The 'mode_valid' flag is never set in this driver. Remove it and the
code that depends on it.
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
---
drivers/gpu/drm/imx/parallel-display.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
index 238057b..10afba8 100644
--- a/drivers/gpu/drm/imx/parallel-display.c
+++ b/drivers/gpu/drm/imx/parallel-display.c
@@ -39,7 +39,6 @@ struct imx_parallel_display {
int edid_len;
u32 bus_format;
u32 bus_flags;
- int mode_valid;
struct drm_display_mode mode;
struct drm_panel *panel;
};
@@ -74,17 +73,6 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
num_modes = drm_add_edid_modes(connector, imxpd->edid);
}
- if (imxpd->mode_valid) {
- struct drm_display_mode *mode = drm_mode_create(connector->dev);
-
- if (!mode)
- return -EINVAL;
- drm_mode_copy(mode, &imxpd->mode);
- mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
- drm_mode_probed_add(connector, mode);
- num_modes++;
- }
-
if (np) {
struct drm_display_mode *mode = drm_mode_create(connector->dev);
struct videomode vm;
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver
2016-05-24 6:31 ` [PATCHv2 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
@ 2016-05-24 14:16 ` Philipp Zabel
2016-05-25 6:11 ` Lothar Waßmann
0 siblings, 1 reply; 12+ messages in thread
From: Philipp Zabel @ 2016-05-24 14:16 UTC (permalink / raw)
To: Lothar Waßmann; +Cc: David Airlie, dri-devel, linux-kernel
Hi Lothar,
thank you for rebasing. I have applied the other two patches.
With this one, I'd like to avoid the duplicated code. See below:
Am Dienstag, den 24.05.2016, 08:31 +0200 schrieb Lothar Waßmann:
> Currently these flags are lost in the call
> drm_display_mode_from_videomode()
>
> Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
> ---
> drivers/gpu/drm/imx/imx-ldb.c | 37 ++++++++++++++++++++++++++--------
> drivers/gpu/drm/imx/parallel-display.c | 31 ++++++++++++++++++++++++----
> 2 files changed, 56 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
> index b2dc4df..b17a246 100644
> --- a/drivers/gpu/drm/imx/imx-ldb.c
> +++ b/drivers/gpu/drm/imx/imx-ldb.c
[...]
> @@ -601,10 +606,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
> channel->edid = kmemdup(edidp, channel->edid_len,
> GFP_KERNEL);
> } else if (!channel->panel) {
> - ret = of_get_drm_display_mode(child, &channel->mode,
> - OF_USE_NATIVE_MODE);
> - if (!ret)
> - channel->mode_valid = 1;
> + struct videomode vm;
> +
> + ret = of_get_videomode(child, &vm, OF_USE_NATIVE_MODE);
> + if (ret)
> + return ret;
> + drm_display_mode_from_videomode(&vm, &channel->mode);
> +
> + if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
> + channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
> + if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
> + channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
> +
> + if (vm.flags & DISPLAY_FLAGS_DE_LOW)
> + channel->bus_flags |= DRM_BUS_FLAG_DE_LOW;
> + if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
> + channel->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
> +
> + drm_mode_debug_printmodeline(&channel->mode);
> + channel->mode_valid = 1;
[...]
> @@ -81,10 +87,27 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
>
> if (np) {
> struct drm_display_mode *mode = drm_mode_create(connector->dev);
> + struct videomode vm;
> + int ret;
>
> if (!mode)
> return -EINVAL;
> - of_get_drm_display_mode(np, &imxpd->mode, OF_USE_NATIVE_MODE);
> +
> + ret = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
> + if (ret)
> + return ret;
> + drm_display_mode_from_videomode(&vm, &imxpd->mode);
> + drm_mode_debug_printmodeline(&imxpd->mode);
> +
> + if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
> + imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
> + if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
> + imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
> +
> + if (vm.flags & DISPLAY_FLAGS_DE_LOW)
> + imxpd->bus_flags |= DRM_BUS_FLAG_DE_LOW;
> + if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
> + imxpd->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
This could be shared between ldb and parallel drivers if you extended
of_get_drm_display_mode to also return bus_flags, for example. The flags
translation could be put into a drm_bus_flags_from_videomode helper.
regards
Philipp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver
2016-05-24 14:16 ` Philipp Zabel
@ 2016-05-25 6:11 ` Lothar Waßmann
2016-05-25 10:26 ` Philipp Zabel
0 siblings, 1 reply; 12+ messages in thread
From: Lothar Waßmann @ 2016-05-25 6:11 UTC (permalink / raw)
To: Philipp Zabel; +Cc: David Airlie, dri-devel, linux-kernel
Hi,
On Tue, 24 May 2016 16:16:40 +0200 Philipp Zabel wrote:
> Hi Lothar,
>
> thank you for rebasing. I have applied the other two patches.
> With this one, I'd like to avoid the duplicated code. See below:
>
> Am Dienstag, den 24.05.2016, 08:31 +0200 schrieb Lothar Waßmann:
> > Currently these flags are lost in the call
> > drm_display_mode_from_videomode()
> >
> > Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
> > ---
> > drivers/gpu/drm/imx/imx-ldb.c | 37 ++++++++++++++++++++++++++--------
> > drivers/gpu/drm/imx/parallel-display.c | 31 ++++++++++++++++++++++++----
> > 2 files changed, 56 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
> > index b2dc4df..b17a246 100644
> > --- a/drivers/gpu/drm/imx/imx-ldb.c
> > +++ b/drivers/gpu/drm/imx/imx-ldb.c
> [...]
> > @@ -601,10 +606,26 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data)
> > channel->edid = kmemdup(edidp, channel->edid_len,
> > GFP_KERNEL);
> > } else if (!channel->panel) {
> > - ret = of_get_drm_display_mode(child, &channel->mode,
> > - OF_USE_NATIVE_MODE);
> > - if (!ret)
> > - channel->mode_valid = 1;
> > + struct videomode vm;
> > +
> > + ret = of_get_videomode(child, &vm, OF_USE_NATIVE_MODE);
> > + if (ret)
> > + return ret;
> > + drm_display_mode_from_videomode(&vm, &channel->mode);
> > +
> > + if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
> > + channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
> > + if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
> > + channel->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
> > +
> > + if (vm.flags & DISPLAY_FLAGS_DE_LOW)
> > + channel->bus_flags |= DRM_BUS_FLAG_DE_LOW;
> > + if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
> > + channel->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
> > +
> > + drm_mode_debug_printmodeline(&channel->mode);
> > + channel->mode_valid = 1;
> [...]
> > @@ -81,10 +87,27 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
> >
> > if (np) {
> > struct drm_display_mode *mode = drm_mode_create(connector->dev);
> > + struct videomode vm;
> > + int ret;
> >
> > if (!mode)
> > return -EINVAL;
> > - of_get_drm_display_mode(np, &imxpd->mode, OF_USE_NATIVE_MODE);
> > +
> > + ret = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
> > + if (ret)
> > + return ret;
> > + drm_display_mode_from_videomode(&vm, &imxpd->mode);
> > + drm_mode_debug_printmodeline(&imxpd->mode);
> > +
> > + if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
> > + imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
> > + if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
> > + imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
> > +
> > + if (vm.flags & DISPLAY_FLAGS_DE_LOW)
> > + imxpd->bus_flags |= DRM_BUS_FLAG_DE_LOW;
> > + if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
> > + imxpd->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
>
> This could be shared between ldb and parallel drivers if you extended
> of_get_drm_display_mode to also return bus_flags, for example. The flags
> translation could be put into a drm_bus_flags_from_videomode helper.
>
I had that in mind also, but hesitated to change the generic
of_get_drm_display_mode() to implement some i.MX specific functionality.
Lothar Waßmann
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv2 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver
2016-05-25 6:11 ` Lothar Waßmann
@ 2016-05-25 10:26 ` Philipp Zabel
0 siblings, 0 replies; 12+ messages in thread
From: Philipp Zabel @ 2016-05-25 10:26 UTC (permalink / raw)
To: Lothar Waßmann; +Cc: David Airlie, dri-devel, linux-kernel
Am Mittwoch, den 25.05.2016, 08:11 +0200 schrieb Lothar Waßmann:
[...]
> > > @@ -81,10 +87,27 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
> > >
> > > if (np) {
> > > struct drm_display_mode *mode = drm_mode_create(connector->dev);
> > > + struct videomode vm;
> > > + int ret;
> > >
> > > if (!mode)
> > > return -EINVAL;
> > > - of_get_drm_display_mode(np, &imxpd->mode, OF_USE_NATIVE_MODE);
> > > +
> > > + ret = of_get_videomode(np, &vm, OF_USE_NATIVE_MODE);
> > > + if (ret)
> > > + return ret;
> > > + drm_display_mode_from_videomode(&vm, &imxpd->mode);
> > > + drm_mode_debug_printmodeline(&imxpd->mode);
> > > +
> > > + if (vm.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)
> > > + imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_POSEDGE;
> > > + if (vm.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
> > > + imxpd->bus_flags |= DRM_BUS_FLAG_PIXDATA_NEGEDGE;
> > > +
> > > + if (vm.flags & DISPLAY_FLAGS_DE_LOW)
> > > + imxpd->bus_flags |= DRM_BUS_FLAG_DE_LOW;
> > > + if (vm.flags & DISPLAY_FLAGS_DE_HIGH)
> > > + imxpd->bus_flags |= DRM_BUS_FLAG_DE_HIGH;
> >
> > This could be shared between ldb and parallel drivers if you extended
> > of_get_drm_display_mode to also return bus_flags, for example. The flags
> > translation could be put into a drm_bus_flags_from_videomode helper.
> >
> I had that in mind also, but hesitated to change the generic
> of_get_drm_display_mode() to implement some i.MX specific functionality.
Since the videomode obtained from DT includes both the timing and pin
polarity information, and the drm way to express these are
drm_display_mode and bus_flags, respectively, there's nothing i.MX
specific about this.
regards
Philipp
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-05-25 10:27 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20 13:34 [PATCH 0/3] drm/imx: convey the pixelclk-active and de-active flags to the ipu-di driver Lothar Waßmann
2016-05-20 13:34 ` [PATCH 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT Lothar Waßmann
2016-05-20 13:34 ` [PATCH 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
2016-05-20 14:31 ` Philipp Zabel
2016-05-20 13:34 ` [PATCH 3/3] drm/imx: remove dead code Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 0/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 1/3] drm/imx: imx-ldb: honor 'native-mode' property when selecting video mode from DT Lothar Waßmann
2016-05-24 6:31 ` [PATCHv2 2/3] drm/imx: convey the pixelclk-active and de-active flags from DT to the ipu-di driver Lothar Waßmann
2016-05-24 14:16 ` Philipp Zabel
2016-05-25 6:11 ` Lothar Waßmann
2016-05-25 10:26 ` Philipp Zabel
2016-05-24 6:31 ` [PATCHv2 3/3] drm/imx: remove dead code Lothar Waßmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).