[PATCH 7/7] drm/sun4i: hdmi: Move PAD_CTRL1 setting to mode_set function

2017-10-13 Thread Chen-Yu Tsai
Initially we configured the PAD_CTRL1 register at probe/bind time.
However it seems the HDMI controller will modify some of the bits
in this register by itself. On the A10 it is particularly annoying
as it toggles the output invert bits, which inverts the colors on
the display output.

The U-boot driver this driver is based on sets this register twice,
though it seems it's only needed for actual display output. Hence
we move it to the mode_set function.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 26 --
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c 
b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index 027b5608dbe6..6ca6e6a74c4a 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -144,6 +144,22 @@ static void sun4i_hdmi_mode_set(struct drm_encoder 
*encoder,
writel(SUN4I_HDMI_UNKNOWN_INPUT_SYNC,
   hdmi->base + SUN4I_HDMI_UNKNOWN_REG);
 
+   /*
+* Setup output pad (?) controls
+*
+* This is done here instead of at probe/bind time because
+* the controller seems to toggle some of the bits on its own.
+*
+* We can't just initialize the register there, we need to
+* protect the clock bits that have already been read out and
+* cached by the clock framework.
+*/
+   val = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
+   val &= SUN4I_HDMI_PAD_CTRL1_HALVE_CLK;
+   val |= hdmi->variant->pad_ctrl1_init_val;
+   writel(val, hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
+   val = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
+
/* Setup timing registers */
writel(SUN4I_HDMI_VID_TIMING_X(mode->hdisplay) |
   SUN4I_HDMI_VID_TIMING_Y(mode->vdisplay),
@@ -489,16 +505,6 @@ static int sun4i_hdmi_bind(struct device *dev, struct 
device *master,
writel(hdmi->variant->pad_ctrl0_init_val,
   hdmi->base + SUN4I_HDMI_PAD_CTRL0_REG);
 
-   /*
-* We can't just initialize the register there, we need to
-* protect the clock bits that have already been read out and
-* cached by the clock framework.
-*/
-   reg = readl(hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
-   reg &= SUN4I_HDMI_PAD_CTRL1_HALVE_CLK;
-   reg |= hdmi->variant->pad_ctrl1_init_val;
-   writel(reg, hdmi->base + SUN4I_HDMI_PAD_CTRL1_REG);
-
reg = readl(hdmi->base + SUN4I_HDMI_PLL_CTRL_REG);
reg &= SUN4I_HDMI_PLL_CTRL_DIV_MASK;
reg |= hdmi->variant->pll_ctrl_init_val;
-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/7] drm/sun4i: More cleanups

2017-10-13 Thread Chen-Yu Tsai
Hi,

Here's another bunch of cleanups for sun4i-drm. Most of these were
found while working on A10/A20 DRM and HDMI support. To be clear,
nothing was broken before these patches.

Patch 1 trims the sun4i-drm probe sequence by not adding repeating
components. The component can deal with duplicates, but it leads
to excessive debug logs which is confusing for developers not in
the know.

Patch 2 moves regmap creation to a point where access is actually
possible, i.e. clocks enabled and reset controls deasserted.

Patch 3 moves to the new drm_fb_cma_get_gem_addr() helper instead
of open coding the same thing.

Patch 4 expands the comment explaining why we clear the backend
registers explicitly.

Patch 5 fixes the buffer address programmed into the backend layer
registers. This issue only hits devices with more than 1GB RAM.

Patch 6 documents some newly discovered but unused register bits
in the HDMI controller.

Patch 7 delays setting of the PAD_CTRL1 register in the HDMI controller
to the mode_set function. The main reason to do this is that between
probe time and when the display is actually setup, the controller itself
toggles some of the bits in this register. In particular, on the A10
it toggles the invert bits documented in the previous patch. This
causes the color to be completed inverted.

Please have a look.

Regards
ChenYu

Chen-Yu Tsai (7):
  drm/sun4i: don't add components that are already in the queue
  drm/sun4i: backend: Create regmap after access is possible
  drm/sun4i: backend: Use drm_fb_cma_get_gem_addr() to get display
memory
  drm/sun4i: backend: Add comment explaining why registers are cleared
  drm/sun4i: backend: Offset layer buffer address by DRAM starting
address
  drm/sun4i: hdmi: Document PAD_CTRL1 output invert bits
  drm/sun4i: hdmi: Move PAD_CTRL1 setting to mode_set function

 drivers/gpu/drm/sun4i/sun4i_backend.c  | 45 ++
 drivers/gpu/drm/sun4i/sun4i_drv.c  | 16 
 drivers/gpu/drm/sun4i/sun4i_hdmi.h |  5 
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 26 
 4 files changed, 61 insertions(+), 31 deletions(-)

-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/7] drm/sun4i: backend: Offset layer buffer address by DRAM starting address

2017-10-13 Thread Chen-Yu Tsai
The display backend, as well as other peripherals that have a DRAM
clock gate and access DRAM directly, bypassing the system bus,
address the DRAM starting from 0x0, while physical addresses the
system uses starts from 0x4000 (or 0x2000 in A80's case).

Correct the address configured into the backend layer registers
by PHYS_OFFSET to account for this.

Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c 
b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 4fefd8add714..d18d7e88d511 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -216,6 +216,13 @@ int sun4i_backend_update_layer_buffer(struct sun4i_backend 
*backend,
paddr = drm_fb_cma_get_gem_addr(fb, state, 0);
DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", );
 
+   /*
+* backend DMA accesses DRAM directly, bypassing the system
+* bus. As such, the address range is different and the buffer
+* address needs to be corrected.
+*/
+   paddr -= PHYS_OFFSET;
+
/* Write the 32 lower bits of the address (in bits) */
lo_paddr = paddr << 3;
DRM_DEBUG_DRIVER("Setting address lower bits to 0x%x\n", lo_paddr);
-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/7] drm/sun4i: backend: Create regmap after access is possible

2017-10-13 Thread Chen-Yu Tsai
The backend has various clocks and reset controls that need to be
enabled and deasserted before register access is possible.

Move the creation of the regmap to after the clocks and reset controls
have been configured where it makes more sense.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c 
b/drivers/gpu/drm/sun4i/sun4i_backend.c
index ec5943627aa5..1cc1780f5091 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -369,13 +369,6 @@ static int sun4i_backend_bind(struct device *dev, struct 
device *master,
if (IS_ERR(regs))
return PTR_ERR(regs);
 
-   backend->engine.regs = devm_regmap_init_mmio(dev, regs,
-
_backend_regmap_config);
-   if (IS_ERR(backend->engine.regs)) {
-   dev_err(dev, "Couldn't create the backend regmap\n");
-   return PTR_ERR(backend->engine.regs);
-   }
-
backend->reset = devm_reset_control_get(dev, NULL);
if (IS_ERR(backend->reset)) {
dev_err(dev, "Couldn't get our reset line\n");
@@ -421,6 +414,13 @@ static int sun4i_backend_bind(struct device *dev, struct 
device *master,
}
}
 
+   backend->engine.regs = devm_regmap_init_mmio(dev, regs,
+
_backend_regmap_config);
+   if (IS_ERR(backend->engine.regs)) {
+   dev_err(dev, "Couldn't create the backend regmap\n");
+   return PTR_ERR(backend->engine.regs);
+   }
+
list_add_tail(>engine.list, >engine_list);
 
/* Reset the registers */
-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/7] drm/sun4i: don't add components that are already in the queue

2017-10-13 Thread Chen-Yu Tsai
Even though the components framework can handle duplicate entries,
the extra entries cause a lot more debug messages to be generated,
which would be confusing to developers not familiar with our driver
and the framework in general.

Instead, we can scan the relatively small queue and check if the
component to be added is already queued up. Since the display
pipelines are symmetrical (not considering the third display
pipeline on the A80), and we add components level by level, when
we get to the second instance at the same level, any shared downstream
components would already be in the queue.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
b/drivers/gpu/drm/sun4i/sun4i_drv.c
index a2012638d5f7..b5879d4620d8 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -226,6 +226,18 @@ struct endpoint_list {
struct list_head list;
 };
 
+static bool node_is_in_list(struct list_head *endpoints,
+   struct device_node *node)
+{
+   struct endpoint_list *endpoint;
+
+   list_for_each_entry(endpoint, endpoints, list)
+   if (endpoint->node == node)
+   return true;
+
+   return false;
+}
+
 static int sun4i_drv_add_endpoints(struct device *dev,
   struct list_head *endpoints,
   struct component_match **match,
@@ -292,6 +304,10 @@ static int sun4i_drv_add_endpoints(struct device *dev,
}
}
 
+   /* skip downstream node if it is already in the queue */
+   if (node_is_in_list(endpoints, remote))
+   continue;
+
/* Add downstream nodes to the queue */
endpoint = kzalloc(sizeof(*endpoint), GFP_KERNEL);
if (!endpoint) {
-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 6/7] drm/sun4i: hdmi: Document PAD_CTRL1 output invert bits

2017-10-13 Thread Chen-Yu Tsai
While debugging inverted color from the HDMI output on the A10, I
found that the lowest 3 bits were set. These were cleared on A20
boards that had normal display output. By manually toggling these
bits the mapping of the color components to these bits was found.

While these are not used anywhere, it would be nice to document
them somewhere.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_hdmi.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi.h 
b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
index 9b97da39927e..b685ee11623d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
@@ -72,6 +72,11 @@
 #define SUN4I_HDMI_PAD_CTRL1_HALVE_CLK BIT(6)
 #define SUN4I_HDMI_PAD_CTRL1_REG_AMP(n)(((n) & 7) << 3)
 
+/* These bits seem to invert the TMDS data channels */
+#define SUN4I_HDMI_PAD_CTRL1_INVERT_R  BIT(2)
+#define SUN4I_HDMI_PAD_CTRL1_INVERT_G  BIT(1)
+#define SUN4I_HDMI_PAD_CTRL1_INVERT_B  BIT(0)
+
 #define SUN4I_HDMI_PLL_CTRL_REG0x208
 #define SUN4I_HDMI_PLL_CTRL_PLL_EN BIT(31)
 #define SUN4I_HDMI_PLL_CTRL_BWSBIT(30)
-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/7] drm/sun4i: backend: Use drm_fb_cma_get_gem_addr() to get display memory

2017-10-13 Thread Chen-Yu Tsai
Commit 4636ce93d5b2 ("drm/fb-cma-helper: Add drm_fb_cma_get_gem_addr()")
adds a new helper, which covers fetching a drm_framebuffer's GEM object
and calculating the buffer address for a given plane.

This patch uses this helper to replace our own open coded version of the
same function.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c 
b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 1cc1780f5091..243ddfdc9403 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -209,22 +209,11 @@ int sun4i_backend_update_layer_buffer(struct 
sun4i_backend *backend,
 {
struct drm_plane_state *state = plane->state;
struct drm_framebuffer *fb = state->fb;
-   struct drm_gem_cma_object *gem;
u32 lo_paddr, hi_paddr;
dma_addr_t paddr;
-   int bpp;
-
-   /* Get the physical address of the buffer in memory */
-   gem = drm_fb_cma_get_gem_obj(fb, 0);
-
-   DRM_DEBUG_DRIVER("Using GEM @ %pad\n", >paddr);
-
-   /* Compute the start of the displayed memory */
-   bpp = fb->format->cpp[0];
-   paddr = gem->paddr + fb->offsets[0];
-   paddr += (state->src_x >> 16) * bpp;
-   paddr += (state->src_y >> 16) * fb->pitches[0];
 
+   /* Get the start of the displayed memory */
+   paddr = drm_fb_cma_get_gem_addr(fb, state, 0);
DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", );
 
/* Write the 32 lower bits of the address (in bits) */
-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 4/7] drm/sun4i: backend: Add comment explaining why registers are cleared

2017-10-13 Thread Chen-Yu Tsai
Many of the backend's layer configuration registers have undefined
default values. This poses a risk as we use regmap_update_bits in
some places, and don't overwrite the whole register.

At probe/bind time we explicitly clear all the control registers
by writing 0 to them. This patch adds a more detailed explanation
on why we're doing this.

Signed-off-by: Chen-Yu Tsai 
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c 
b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 243ddfdc9403..4fefd8add714 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -412,7 +412,14 @@ static int sun4i_backend_bind(struct device *dev, struct 
device *master,
 
list_add_tail(>engine.list, >engine_list);
 
-   /* Reset the registers */
+   /*
+* Many of the backend's layer configuration registers have
+* undefined default values. This poses a risk as we use
+* regmap_update_bits in some places, and don't overwrite
+* the whole register.
+*
+* Clear the registers here to have something predictable.
+*/
for (i = 0x800; i < 0x1000; i += 4)
regmap_write(backend->engine.regs, i, 0);
 
-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm/vc4: Fix sleeps during the IRQ handler for DSI transactions.

2017-10-13 Thread Eric Anholt
VC4's DSI1 has a bug where the AXI connection is broken for 32-bit
writes from the CPU, so we use the DMA engine to DMA 32-bit values
into registers instead.  That sleeps, so we can't do it from the top
half.

As a solution, use an interrupt thread so that all our writes happen
when sleeping is is allowed.

v2: Use IRQF_ONESHOT (suggested by Boris)

Signed-off-by: Eric Anholt 
---

Boris, that cleanup ended up working and it looks great.  Thanks!

 drivers/gpu/drm/vc4/vc4_dsi.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
index 554605af344e..3b74fda5662d 100644
--- a/drivers/gpu/drm/vc4/vc4_dsi.c
+++ b/drivers/gpu/drm/vc4/vc4_dsi.c
@@ -1360,6 +1360,25 @@ static void dsi_handle_error(struct vc4_dsi *dsi,
*ret = IRQ_HANDLED;
 }
 
+/* Initial handler for port 1 where we need the reg_dma workaround.
+ * The register DMA writes sleep, so we can't do it in the top half.
+ * Instead we use IRQF_ONESHOT so that the IRQ gets disabled in the
+ * parent interrupt contrller until our interrupt thread is done.
+ */
+static irqreturn_t vc4_dsi_irq_defer_to_thread_handler(int irq, void *data)
+{
+   struct vc4_dsi *dsi = data;
+   u32 stat = DSI_PORT_READ(INT_STAT);
+
+   if (!stat)
+   return IRQ_NONE;
+
+   return IRQ_WAKE_THREAD;
+}
+
+/* Normal IRQ handler for port 0, or the threaded IRQ handler for port
+ * 1 where we need the reg_dma workaround.
+ */
 static irqreturn_t vc4_dsi_irq_handler(int irq, void *data)
 {
struct vc4_dsi *dsi = data;
@@ -1539,8 +1558,16 @@ static int vc4_dsi_bind(struct device *dev, struct 
device *master, void *data)
/* Clear any existing interrupt state. */
DSI_PORT_WRITE(INT_STAT, DSI_PORT_READ(INT_STAT));
 
-   ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
-  vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
+   if (dsi->reg_dma_mem) {
+   ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0),
+   
vc4_dsi_irq_defer_to_thread_handler,
+   vc4_dsi_irq_handler,
+   IRQF_ONESHOT,
+   "vc4 dsi", dsi);
+   } else {
+   ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
+  vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
+   }
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get interrupt: %d\n", ret);
-- 
2.14.2

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] drm fixes for v4.14-rc5

2017-10-13 Thread Dave Airlie
Hi Linus,

Couple of the arm people seem to wake up so this has imx and msm
fixes, along with a bunch of i915 stable bounds fixes and an amdgpu
regression fix.

All seems pretty okay for now.

Dave.

The following changes since commit 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f:

  Linux 4.14-rc4 (2017-10-08 20:53:29 -0700)

are available in the git repository at:

  git://people.freedesktop.org/~airlied/linux tags/drm-fixes-for-v4.14-rc5

for you to fetch changes up to a480f30846d19b50106b3243d9d48683d2966249:

  Merge tag 'drm-intel-fixes-2017-10-11' of
git://anongit.freedesktop.org/drm/drm-intel into drm-fixes (2017-10-14
09:59:20 +1000)


drm: msm, i915, amdgpu, imx and sync_file fixes


Archit Taneja (2):
  drm/msm/dsi: Use correct pm_runtime_put variant during host_init
  drm/msm/mdp5: Remove extra pm_runtime_put call in mdp5_crtc_cursor_set()

Chris Wilson (2):
  drm/i915: Silence compiler warning for hsw_power_well_enable()
  drm/i915: Order two completing nop_submit_request

Christian König (1):
  drm/amdgpu: fix placement flags in amdgpu_ttm_bind

Dave Airlie (5):
  Merge tag 'drm-misc-fixes-2017-10-11' of
git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
  Merge branch 'drm-fixes-4.14' of
git://people.freedesktop.org/~agd5f/linux into drm-fixes
  Merge tag 'imx-drm-fixes-2017-10-12' of
git://git.pengutronix.de/git/pza/linux into drm-fixes
  Merge branch 'msm-fixes-4.14-rc4' of
git://people.freedesktop.org/~robclark/linux into drm-fixes
  Merge tag 'drm-intel-fixes-2017-10-11' of
git://anongit.freedesktop.org/drm/drm-intel into drm-fixes

Jani Nikula (1):
  drm/i915/bios: parse DDI ports also for CHV for HDMI DDC pin and
DP AUX channel

Jeffy Chen (1):
  drm/atomic: Unref duplicated drm_atomic_state in
drm_atomic_helper_resume()

John Einar Reitan (1):
  sync_file: Return consistent status in SYNC_IOC_FILE_INFO

Lucas Stach (2):
  gpu: ipu-v3: prg: wait for double buffers to be filled on channel startup
  gpu: ipu-v3: pre: implement workaround for ERR009624

Maarten Lankhorst (1):
  drm/i915: Use crtc_state_is_legacy_gamma in intel_color_check

Manasi Navare (2):
  drm/i915/edp: Get the Panel Power Off timestamp after panel is off
  drm/i915/edp: Increase the T12 delay quirk to 1300ms

Philipp Zabel (1):
  gpu: ipu-v3: Allow channel burst locking on i.MX6 only

Rob Clark (4):
  drm/msm/mdp5: add missing max size for 8x74 v1
  drm/msm: use proper memory barriers for updating tail/head
  drm/msm: fix error path cleanup
  drm/msm: fix _NO_IMPLICIT fencing case

Ville Syrjälä (1):
  drm/i915: Read timings from the correct transcoder in
intel_crtc_mode_get()

Wei Yongjun (1):
  drm/msm: fix return value check in _msm_gem_kernel_new()

 drivers/dma-buf/sync_file.c  | 17 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c  |  2 +-
 drivers/gpu/drm/drm_atomic_helper.c  |  1 +
 drivers/gpu/drm/i915/i915_gem.c  |  7 ++-
 drivers/gpu/drm/i915/intel_bios.c|  2 +-
 drivers/gpu/drm/i915/intel_color.c   | 16 +++-
 drivers/gpu/drm/i915/intel_display.c | 14 +-
 drivers/gpu/drm/i915/intel_dp.c  |  4 ++--
 drivers/gpu/drm/i915/intel_runtime_pm.c  |  2 +-
 drivers/gpu/drm/msm/dsi/dsi_host.c   |  2 +-
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c  |  2 ++
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c |  2 --
 drivers/gpu/drm/msm/msm_gem.c| 15 ++-
 drivers/gpu/drm/msm/msm_gem_submit.c | 24 ++--
 drivers/gpu/drm/msm/msm_gpu.c|  3 ++-
 drivers/gpu/drm/msm/msm_rd.c | 12 ++--
 drivers/gpu/ipu-v3/ipu-common.c  |  8 
 drivers/gpu/ipu-v3/ipu-pre.c | 29 +
 drivers/gpu/ipu-v3/ipu-prg.c |  7 +++
 19 files changed, 119 insertions(+), 50 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Outreachy kernel] [PATCH v13 2/3] drm/tinydrm: Move tinydrm_of_find_backlight to backlight.c

2017-10-13 Thread Rob Clark
On Fri, Oct 13, 2017 at 4:25 PM, Sean Paul  wrote:
> On Fri, Oct 13, 2017 at 04:11:43PM +0530, Meghana Madhyastha wrote:
>> Rename tinydrm_of_find_backlight to backlight_get and move it
>> to linux/backlight.c so that it can be used by other drivers.
>
> [apologies if this has been brought up in previous versions, I haven't been
> following closely]
>
> I don't think "backlight_get" is a good name for this function. How about
> of_find_backlight_by_name (since there's already of_find_backlight_by_node)?
>
>>
>> Signed-off-by: Meghana Madhyastha 
>> ---
>> Changes in v13:
>>  -Add backlight_put to backlight.h in this patch
>>
>>  drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 
>> --
>>  drivers/gpu/drm/tinydrm/mi0283qt.c |  3 +-
>>  drivers/video/backlight/backlight.c| 37 
>>  include/drm/tinydrm/tinydrm-helpers.h  |  2 --
>>  include/linux/backlight.h  | 19 
>>  5 files changed, 58 insertions(+), 43 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c 
>> b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
>> index a42dee6..cb1a01a 100644
>> --- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
>> +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
>> @@ -236,46 +236,6 @@ void tinydrm_xrgb_to_gray8(u8 *dst, void *vaddr, 
>> struct drm_framebuffer *fb,
>>  }
>>  EXPORT_SYMBOL(tinydrm_xrgb_to_gray8);
>>
>> -/**
>> - * tinydrm_of_find_backlight - Find backlight device in device-tree
>> - * @dev: Device
>> - *
>> - * This function looks for a DT node pointed to by a property named 
>> 'backlight'
>> - * and uses of_find_backlight_by_node() to get the backlight device.
>> - * Additionally if the brightness property is zero, it is set to
>> - * max_brightness.
>> - *
>> - * Returns:
>> - * NULL if there's no backlight property.
>> - * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight 
>> device
>> - * is found.
>> - * If the backlight device is found, a pointer to the structure is returned.
>> - */
>> -struct backlight_device *tinydrm_of_find_backlight(struct device *dev)
>> -{
>> - struct backlight_device *backlight;
>> - struct device_node *np;
>> -
>> - np = of_parse_phandle(dev->of_node, "backlight", 0);
>> - if (!np)
>> - return NULL;
>> -
>> - backlight = of_find_backlight_by_node(np);
>> - of_node_put(np);
>> -
>> - if (!backlight)
>> - return ERR_PTR(-EPROBE_DEFER);
>> -
>> - if (!backlight->props.brightness) {
>> - backlight->props.brightness = backlight->props.max_brightness;
>> - DRM_DEBUG_KMS("Backlight brightness set to %d\n",
>> -   backlight->props.brightness);
>> - }
>> -
>> - return backlight;
>> -}
>> -EXPORT_SYMBOL(tinydrm_of_find_backlight);
>> -
>>  #if IS_ENABLED(CONFIG_SPI)
>>
>>  /**
>> diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
>> b/drivers/gpu/drm/tinydrm/mi0283qt.c
>> index 7fd2691..a932185 100644
>> --- a/drivers/gpu/drm/tinydrm/mi0283qt.c
>> +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
>> @@ -12,6 +12,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -188,7 +189,7 @@ static int mi0283qt_probe(struct spi_device *spi)
>>   if (IS_ERR(mipi->regulator))
>>   return PTR_ERR(mipi->regulator);
>>
>> - mipi->backlight = tinydrm_of_find_backlight(dev);
>> + mipi->backlight = backlight_get(dev);
>>   if (IS_ERR(mipi->backlight))
>>   return PTR_ERR(mipi->backlight);
>>
>> diff --git a/drivers/video/backlight/backlight.c 
>> b/drivers/video/backlight/backlight.c
>> index 8049e76..c4e94d0 100644
>> --- a/drivers/video/backlight/backlight.c
>> +++ b/drivers/video/backlight/backlight.c
>> @@ -580,6 +580,43 @@ struct backlight_device 
>> *of_find_backlight_by_node(struct device_node *node)
>>  EXPORT_SYMBOL(of_find_backlight_by_node);
>>  #endif
>>
>> +/**
>> + * backlight_get - Get backlight device
>> + * @dev: Device
>> + *
>> + * This function looks for a property named 'backlight' on the DT node
>> + * connected to @dev and looks up the backlight device.
>> + *
>> + * Call backlight_put() to drop the reference on the backlight device.
>> + *
>> + * Returns:
>> + * A pointer to the backlight device if found.
>> + * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
>> + * device is found.
>> + * NULL if there's no backlight property.
>> + */
>> +struct backlight_device *backlight_get(struct device *dev)
>> +{
>> + struct backlight_device *bd = NULL;
>> + struct device_node *np;
>> +
>> + if (!dev)
>> + return NULL;
>> +
>> + if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
>
> I'm not really used to seeing IS_ENABLED(CONFIG_BLAH) inline. The common
> patterns seems to be wrapping the actual implementation in #if
> 

[Bug 102809] Rust shadows(?) flash random colours

2017-10-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102809

--- Comment #12 from bugzilla.i...@spamgourmet.com ---
Using the patch I now no longer have the flashes occurring in game. (In reply
to Nicolai Hähnle from comment #11)
> Created attachment 134808 [details] [review]
> possible fix
> 
> Please try the attached patch. It fixes the issue in the trace for me.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Outreachy kernel] [PATCH v13 2/3] drm/tinydrm: Move tinydrm_of_find_backlight to backlight.c

2017-10-13 Thread Noralf Trønnes


Den 13.10.2017 22.25, skrev Sean Paul:

On Fri, Oct 13, 2017 at 04:11:43PM +0530, Meghana Madhyastha wrote:

Rename tinydrm_of_find_backlight to backlight_get and move it
to linux/backlight.c so that it can be used by other drivers.

[apologies if this has been brought up in previous versions, I haven't been
following closely]

I don't think "backlight_get" is a good name for this function. How about
of_find_backlight_by_name (since there's already of_find_backlight_by_node)?


I came up with that name modelled after gpiod_get() and gpiod_put() and I
deliberately kept the of_ part out of the name like the gpio functions.
gpiod_get() checks OF, ACPI and platform for gpios and calling it
backlight_get() would keep the door open for other ways of connecting
backlight devices in the future, other than Device Tree.

I think of_find_backlight() would be better than *_by_name(), since
'backlight' is the common DT property name, so it wouldn't make much sense
to require every caller to pass in the same name.

Either way is fine with me.

Noralf.



Signed-off-by: Meghana Madhyastha 
---
Changes in v13:
  -Add backlight_put to backlight.h in this patch

  drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 --
  drivers/gpu/drm/tinydrm/mi0283qt.c |  3 +-
  drivers/video/backlight/backlight.c| 37 
  include/drm/tinydrm/tinydrm-helpers.h  |  2 --
  include/linux/backlight.h  | 19 
  5 files changed, 58 insertions(+), 43 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
index a42dee6..cb1a01a 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
@@ -236,46 +236,6 @@ void tinydrm_xrgb_to_gray8(u8 *dst, void *vaddr, 
struct drm_framebuffer *fb,
  }
  EXPORT_SYMBOL(tinydrm_xrgb_to_gray8);
  
-/**

- * tinydrm_of_find_backlight - Find backlight device in device-tree
- * @dev: Device
- *
- * This function looks for a DT node pointed to by a property named 'backlight'
- * and uses of_find_backlight_by_node() to get the backlight device.
- * Additionally if the brightness property is zero, it is set to
- * max_brightness.
- *
- * Returns:
- * NULL if there's no backlight property.
- * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device
- * is found.
- * If the backlight device is found, a pointer to the structure is returned.
- */
-struct backlight_device *tinydrm_of_find_backlight(struct device *dev)
-{
-   struct backlight_device *backlight;
-   struct device_node *np;
-
-   np = of_parse_phandle(dev->of_node, "backlight", 0);
-   if (!np)
-   return NULL;
-
-   backlight = of_find_backlight_by_node(np);
-   of_node_put(np);
-
-   if (!backlight)
-   return ERR_PTR(-EPROBE_DEFER);
-
-   if (!backlight->props.brightness) {
-   backlight->props.brightness = backlight->props.max_brightness;
-   DRM_DEBUG_KMS("Backlight brightness set to %d\n",
- backlight->props.brightness);
-   }
-
-   return backlight;
-}
-EXPORT_SYMBOL(tinydrm_of_find_backlight);
-
  #if IS_ENABLED(CONFIG_SPI)
  
  /**

diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 7fd2691..a932185 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -12,6 +12,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -188,7 +189,7 @@ static int mi0283qt_probe(struct spi_device *spi)
if (IS_ERR(mipi->regulator))
return PTR_ERR(mipi->regulator);
  
-	mipi->backlight = tinydrm_of_find_backlight(dev);

+   mipi->backlight = backlight_get(dev);
if (IS_ERR(mipi->backlight))
return PTR_ERR(mipi->backlight);
  
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c

index 8049e76..c4e94d0 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -580,6 +580,43 @@ struct backlight_device *of_find_backlight_by_node(struct 
device_node *node)
  EXPORT_SYMBOL(of_find_backlight_by_node);
  #endif
  
+/**

+ * backlight_get - Get backlight device
+ * @dev: Device
+ *
+ * This function looks for a property named 'backlight' on the DT node
+ * connected to @dev and looks up the backlight device.
+ *
+ * Call backlight_put() to drop the reference on the backlight device.
+ *
+ * Returns:
+ * A pointer to the backlight device if found.
+ * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
+ * device is found.
+ * NULL if there's no backlight property.
+ */
+struct backlight_device *backlight_get(struct device *dev)
+{
+   struct backlight_device *bd = NULL;
+   struct device_node *np;
+
+   if (!dev)
+ 

[Bug 102820] [bisected] commit ebbf7337e2daacacef3e01114e6be68a2a4f11b4 prevents X11 from starting

2017-10-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=102820

--- Comment #6 from dwagner  ---
Just as an update: This very bug still occurs with
https://cgit.freedesktop.org/~agd5f/linux/log/?h=amd-staging-drm-next as of
today, and it is still fixed by reverting commit
ebbf7337e2daacacef3e01114e6be68a2a4f11b4

Could somebody comment what this commit is good for, given that it seems to
only prevent X11 from running with certain 4k HDMI displays?

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 196125] [Regression] AMD Radeon RX 480 flickering on HDMI port with Linux 4.11.4

2017-10-13 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=196125

--- Comment #7 from cont...@florentflament.com ---
I haven't experienced any flickering for a while (be it with Wayland or Xorg,
one monitor connected to a HDMI port and one another to a DisplayPort). This
seems to have been fixed.

$ cat /etc/fedora-release 
Fedora release 26 (Twenty Six)
$ uname -a
Linux amn 4.13.5-200.fc26.x86_64 #1 SMP Thu Oct 5 16:53:13 UTC 2017 x86_64
x86_64 x86_64 GNU/Linux

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/9] drm/panel: simple: make it possible to override LCD bus format

2017-10-13 Thread Rob Herring
On Wed, Oct 11, 2017 at 01:23:35PM +0200, Lothar Waßmann wrote:
> The baseboards for the Ka-Ro electronics series of i.MX modules
> use a 24bit LCD interface, no matter what LCD bus width the SoC on the
> module provides and what the LCD panel expects. LCDs with 6bit per color
> will ignore the 2 LSBs of each color lane, and modules using a SoC
> that provides only 6bit per color, drive the display information on the
> 6 MSBs of each color lane and tie the 2 LSBs of each color lane to GND.
> 
> Thus, no matter what combination of LCD and SoC is used, the LCD port
> can be used without shuffling bit lanes by always configuring the LCD
> output to 24bit mode.

Thanks for providing good reasoning as to why this is needed.

> 
> Add a function to handle certain quirks of the LCD interface to the
> panel driver to be able to override the bus format specified in a
> panel's display_mode.
> 
> Signed-off-by: Lothar Waßmann 
> ---
>  .../bindings/display/panel/simple-panel.txt|  2 ++
>  drivers/gpu/drm/panel/panel-simple.c   | 40 
> +-
>  2 files changed, 41 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/display/panel/simple-panel.txt 
> b/Documentation/devicetree/bindings/display/panel/simple-panel.txt
> index 1341bbf..e2308c3 100644
> --- a/Documentation/devicetree/bindings/display/panel/simple-panel.txt
> +++ b/Documentation/devicetree/bindings/display/panel/simple-panel.txt
> @@ -7,6 +7,8 @@ Optional properties:
>  - ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
>  - enable-gpios: GPIO pin to enable or disable the panel
>  - backlight: phandle of the backlight device attached to the panel
> +- bus-format-override: override the bus_format setting of the panel's
> +  display_mode settings

You need to define valid values here.

However, we also have this proposal[1]. Please align to a common one. 
BTW, we don't need another common panel binding file that [1] added. We 
already have panel-dpi.txt for parallel interface panels. And 
personally, I'd like to see simple-panel.txt disappear.

Rob

[1] https://patchwork.ozlabs.org/patch/823104/
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 196615] amdgpu - resume from suspend is no longer working on rx480

2017-10-13 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=196615

cont...@florentflament.com changed:

   What|Removed |Added

 CC||cont...@florentflament.com

--- Comment #25 from cont...@florentflament.com ---
Hi,
Same issue here. OS freezing after resume from suspend with an AMD RX480 GPU.

$ cat /etc/redhat-release 
Fedora release 26 (Twenty Six)
$ uname -a
Linux amn 4.13.4-200.fc26.x86_64 #1 SMP Thu Sep 28 20:46:39 UTC 2017 x86_64
x86_64 x86_64 GNU/Linux
$ journalctl -k -b -2 | grep amdgpu | tail -5
Oct 12 01:46:06 amn kernel: [drm] Initialized amdgpu 3.18.0 20150101 for
:01:00.0 on minor 0
Oct 12 23:16:29 amn kernel: [drm:amdgpu_vce_ring_test_ring [amdgpu]] *ERROR*
amdgpu: ring 14 test failed
Oct 12 23:16:29 amn kernel: [drm:amdgpu_resume_phase2 [amdgpu]] *ERROR* resume
of IP block  failed -110
Oct 12 23:16:29 amn kernel: [drm:amdgpu_device_resume [amdgpu]] *ERROR*
amdgpu_resume failed (-110).
Oct 12 23:16:30 amn kernel: amdgpu :01:00.0: 9514d9161800 unpin not
necessary

Regards

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Andrey Grodzovsky



On 10/13/2017 05:01 PM, Leo wrote:



On 2017-10-13 04:36 PM, Andrey Grodzovsky wrote:



On 10/13/2017 03:29 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li" 

Use the correct for_each_new/old_* iterators instead of for_each_*

The following functions were considered:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
 - Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
 - drm_atomic_helper_duplicate_state is called during suspend to
   cache the state
 - It sets 'state' within the state triplet to 'new_state'

amdgpu_dm_commit_planes: use for_each_old
 - Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
 - Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
 - Called after the state was swapped

dm_update_crtcs_state: use for_each_new
 - Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
 - Called before the state is swapped

v2: Split out typo fixes to a new patch.

v3: Say "functions considered" instead of "affected functions". The
 latter implies that changes are made to each.

Signed-off-by: Leo (Sunpeng) Li 
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 
---

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
  2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
  struct amdgpu_dm_connector 
*amdgpu_dm_find_first_crct_matching_connector(

  struct drm_atomic_state *state,
-struct drm_crtc *crtc,
-bool from_state_var)
+struct drm_crtc *crtc)
  {
  uint32_t i;
  struct drm_connector_state *conn_state;
  struct drm_connector *connector;
  struct drm_crtc *crtc_from_state;
-for_each_new_connector_in_state(
-state,
-connector,
-conn_state,
-i) {
-crtc_from_state =
-from_state_var ?
-conn_state->crtc :
-connector->state->crtc;
+for_each_new_connector_in_state(state, connector, conn_state, i) {
+crtc_from_state = conn_state->crtc;
  if (crtc_from_state == crtc)
  return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,

  unsigned long flags;
  /* update planes when needed */
-for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+for_each_old_plane_in_state(state, plane, old_plane_state, i) {
  struct drm_plane_state *plane_state = plane->state;
  struct drm_crtc *crtc = plane_state->crtc;
  struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
  dm_state = to_dm_atomic_state(state);
  /* update changed items */
-for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {


Better just use for_each_new_old here, so you can get both old and 
new from the iterator.



  struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
  struct drm_crtc_state *new_state = crtc->state;
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(
  new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);

  new_stream = new_acrtc_state->stream;
-aconnector =
-amdgpu_dm_find_first_crct_matching_connector(
+aconnector = amdgpu_dm_find_first_crct_matching_connector(
  state,
-_crtcs[i]->base,
-false);
+_crtcs[i]->base);
  if (!aconnector) {
  DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
connector for acrtc id:%d "

   "skipping freesync init\n",
@@ -4151,7 +4141,7 @@ void amdgpu_dm_atomic_commit_tail(
  }
  /* Handle scaling and undersacn changes*/
-for_each_new_connector_in_state(state, connector, 
old_conn_state, i) {
+for_each_old_connector_in_state(state, connector, 
old_conn_state, i) {
  struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);

  struct dm_connector_state *con_new_state =
to_dm_connector_state(aconnector->base.state);
@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail(
  }
  /* update planes when needed per crtc*/
-for_each_new_crtc_in_state(state, pcrtc, old_crtc_state, j) {
+for_each_old_crtc_in_state(state, pcrtc, old_crtc_state, j) {
  new_acrtc_state = 

Re: [PATCH v3 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Leo



On 2017-10-13 04:36 PM, Andrey Grodzovsky wrote:



On 10/13/2017 03:29 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li" 

Use the correct for_each_new/old_* iterators instead of for_each_*

The following functions were considered:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
 - Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
 - drm_atomic_helper_duplicate_state is called during suspend to
   cache the state
 - It sets 'state' within the state triplet to 'new_state'

amdgpu_dm_commit_planes: use for_each_old
 - Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
 - Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
 - Called after the state was swapped

dm_update_crtcs_state: use for_each_new
 - Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
 - Called before the state is swapped

v2: Split out typo fixes to a new patch.

v3: Say "functions considered" instead of "affected functions". The
 latter implies that changes are made to each.

Signed-off-by: Leo (Sunpeng) Li 
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 
---

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
  2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
  struct amdgpu_dm_connector 
*amdgpu_dm_find_first_crct_matching_connector(

  struct drm_atomic_state *state,
-    struct drm_crtc *crtc,
-    bool from_state_var)
+    struct drm_crtc *crtc)
  {
  uint32_t i;
  struct drm_connector_state *conn_state;
  struct drm_connector *connector;
  struct drm_crtc *crtc_from_state;
-    for_each_new_connector_in_state(
-    state,
-    connector,
-    conn_state,
-    i) {
-    crtc_from_state =
-    from_state_var ?
-    conn_state->crtc :
-    connector->state->crtc;
+    for_each_new_connector_in_state(state, connector, conn_state, i) {
+    crtc_from_state = conn_state->crtc;
  if (crtc_from_state == crtc)
  return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,

  unsigned long flags;
  /* update planes when needed */
-    for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+    for_each_old_plane_in_state(state, plane, old_plane_state, i) {
  struct drm_plane_state *plane_state = plane->state;
  struct drm_crtc *crtc = plane_state->crtc;
  struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
  dm_state = to_dm_atomic_state(state);
  /* update changed items */
-    for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+    for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {


Better just use for_each_new_old here, so you can get both old and new 
from the iterator.



  struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
  struct drm_crtc_state *new_state = crtc->state;
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(
  new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);

  new_stream = new_acrtc_state->stream;
-    aconnector =
-    amdgpu_dm_find_first_crct_matching_connector(
+    aconnector = amdgpu_dm_find_first_crct_matching_connector(
  state,
-    _crtcs[i]->base,
-    false);
+    _crtcs[i]->base);
  if (!aconnector) {
  DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
connector for acrtc id:%d "

   "skipping freesync init\n",
@@ -4151,7 +4141,7 @@ void amdgpu_dm_atomic_commit_tail(
  }
  /* Handle scaling and undersacn changes*/
-    for_each_new_connector_in_state(state, connector, old_conn_state, 
i) {
+    for_each_old_connector_in_state(state, connector, old_conn_state, 
i) {
  struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);

  struct dm_connector_state *con_new_state =
  to_dm_connector_state(aconnector->base.state);
@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail(
  }
  /* update planes when needed per crtc*/
-    for_each_new_crtc_in_state(state, pcrtc, old_crtc_state, j) {
+    for_each_old_crtc_in_state(state, pcrtc, old_crtc_state, j) {
  new_acrtc_state = to_dm_crtc_state(pcrtc->state);


Why did you 

Re: [Outreachy kernel] [PATCH v3] drm/amd/powerplay: Remove unnecessary cast on void pointer

2017-10-13 Thread Julia Lawall


On Sat, 14 Oct 2017, Harsha Sharma wrote:

> Done with following coccinelle patch
>
> @r@
> expression x;
> void* e;
> type T;
> identifier f;
> @@
> (
>   *((T *)e)
> |
>   ((T *)x)[...]
> |
>   ((T*)x)->f
> |
>
> - (T*)
>   e
> )
>
> Signed-off-by: Harsha Sharma 
> ---
> Changes in v3:
>  -Removed unnecessary lines
>  -Remove more useless casts
> Changes in v2:
>  -Remove unnecessary parentheses
>  -Remove one more useless cast
>
>  drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c |   6 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c|   8 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c   |   2 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c |   6 +-
>  .../gpu/drm/amd/powerplay/hwmgr/processpptables.c  |   2 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c   | 177 
> ++---
>  drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c |   4 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  22 +--
>  .../gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c   |   2 +-
>  9 files changed, 107 insertions(+), 122 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> index bc839ff0bdd0..f22104c78dcb 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> @@ -474,7 +474,7 @@ static int cz_tf_upload_pptable_to_smu(struct pp_hwmgr 
> *hwmgr, void *input,
>   PP_ASSERT_WITH_CODE((0 == ret && NULL != table),
>   "Fail to get clock table from SMU!", return 
> -EINVAL;);
>
> - clock_table = (struct SMU8_Fusion_ClkTable *)table;
> + clock_table = table;
>
>   /* patch clock table */
>   PP_ASSERT_WITH_CODE((vddc_table->count <= CZ_MAX_HARDWARE_POWERLEVELS),
> @@ -868,8 +868,8 @@ static int cz_tf_update_low_mem_pstate(struct pp_hwmgr 
> *hwmgr,
>  {
>   bool disable_switch;
>   bool enable_low_mem_state;
> - struct cz_hwmgr *hw_data = (struct cz_hwmgr *)(hwmgr->backend);
> - const struct phm_set_power_state_input *states = (struct 
> phm_set_power_state_input *)input;
> + struct cz_hwmgr *hw_data = hwmgr->backend;
> + const struct phm_set_power_state_input *states = input;
>   const struct cz_power_state *pnew_state = 
> cast_const_PhwCzPowerState(states->pnew_state);
>
>   if (hw_data->sys_info.nb_dpm_enable) {
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
> index 9547f265a8bb..5d63a1b18b39 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
> @@ -469,7 +469,7 @@ int phm_reset_single_dpm_table(void *table,
>  {
>   int i;
>
> - struct vi_dpm_table *dpm_table = (struct vi_dpm_table *)table;
> + struct vi_dpm_table *dpm_table = table;
>
>   dpm_table->count = count > max ? max : count;
>
> @@ -484,7 +484,7 @@ void phm_setup_pcie_table_entry(
>   uint32_t index, uint32_t pcie_gen,
>   uint32_t pcie_lanes)
>  {
> - struct vi_dpm_table *dpm_table = (struct vi_dpm_table *)table;
> + struct vi_dpm_table *dpm_table = table;
>   dpm_table->dpm_level[index].value = pcie_gen;
>   dpm_table->dpm_level[index].param1 = pcie_lanes;
>   dpm_table->dpm_level[index].enabled = 1;
> @@ -494,7 +494,7 @@ int32_t phm_get_dpm_level_enable_mask_value(void *table)
>  {
>   int32_t i;
>   int32_t mask = 0;
> - struct vi_dpm_table *dpm_table = (struct vi_dpm_table *)table;
> + struct vi_dpm_table *dpm_table = table;
>
>   for (i = dpm_table->count; i > 0; i--) {
>   mask = mask << 1;
> @@ -566,7 +566,7 @@ int phm_find_boot_level(void *table,
>  {
>   int result = -EINVAL;
>   uint32_t i;
> - struct vi_dpm_table *dpm_table = (struct vi_dpm_table *)table;
> + struct vi_dpm_table *dpm_table = table;
>
>   for (i = 0; i < dpm_table->count; i++) {
>   if (value == dpm_table->dpm_level[i].value) {
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
> index 953e0c9ad7cd..676f2e8bb2ee 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
> @@ -579,7 +579,7 @@ static ATOM_GPIO_PIN_LUT *get_gpio_lookup_table(void 
> *device)
>   PP_ASSERT_WITH_CODE((NULL != table_address),
>   "Error retrieving BIOS Table Address!", return NULL;);
>
> - return (ATOM_GPIO_PIN_LUT *)table_address;
> + return table_address;
>  }
>
>  /**
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
> index c062844b15f3..05e3f5302994 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
> @@ -66,7 +66,7 @@ static struct atom_voltage_objects_info_v4_1 
> 

Re: [PATCH v3 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Andrey Grodzovsky



On 10/13/2017 03:29 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li" 

Use the correct for_each_new/old_* iterators instead of for_each_*

The following functions were considered:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
 - Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
 - drm_atomic_helper_duplicate_state is called during suspend to
   cache the state
 - It sets 'state' within the state triplet to 'new_state'

amdgpu_dm_commit_planes: use for_each_old
 - Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
 - Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
 - Called after the state was swapped

dm_update_crtcs_state: use for_each_new
 - Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
 - Called before the state is swapped

v2: Split out typo fixes to a new patch.

v3: Say "functions considered" instead of "affected functions". The
 latter implies that changes are made to each.

Signed-off-by: Leo (Sunpeng) Li 
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 ---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
  2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
  
  struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector(

struct drm_atomic_state *state,
-   struct drm_crtc *crtc,
-   bool from_state_var)
+   struct drm_crtc *crtc)
  {
uint32_t i;
struct drm_connector_state *conn_state;
struct drm_connector *connector;
struct drm_crtc *crtc_from_state;
  
-	for_each_new_connector_in_state(

-   state,
-   connector,
-   conn_state,
-   i) {
-   crtc_from_state =
-   from_state_var ?
-   conn_state->crtc :
-   connector->state->crtc;
+   for_each_new_connector_in_state(state, connector, conn_state, i) {
+   crtc_from_state = conn_state->crtc;
  
  		if (crtc_from_state == crtc)

return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,
unsigned long flags;
  
  	/* update planes when needed */

-   for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+   for_each_old_plane_in_state(state, plane, old_plane_state, i) {
struct drm_plane_state *plane_state = plane->state;
struct drm_crtc *crtc = plane_state->crtc;
struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
dm_state = to_dm_atomic_state(state);
  
  	/* update changed items */

-   for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+   for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {


Better just use for_each_new_old here, so you can get both old and new 
from the iterator.



struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
struct drm_crtc_state *new_state = crtc->state;
  
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(

new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);
  
  			new_stream = new_acrtc_state->stream;

-   aconnector =
-   amdgpu_dm_find_first_crct_matching_connector(
+   aconnector = 
amdgpu_dm_find_first_crct_matching_connector(
state,
-   _crtcs[i]->base,
-   false);
+   _crtcs[i]->base);
if (!aconnector) {
DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
connector for acrtc id:%d "
 "skipping freesync init\n",
@@ -4151,7 +4141,7 @@ void amdgpu_dm_atomic_commit_tail(
}
  
  	/* Handle scaling and undersacn changes*/

-   for_each_new_connector_in_state(state, connector, old_conn_state, i) {
+   for_each_old_connector_in_state(state, connector, old_conn_state, i) {
struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);
struct dm_connector_state *con_new_state =
to_dm_connector_state(aconnector->base.state);
@@ -4205,7 

Re: [Outreachy kernel] [PATCH v13 3/3] drm/tinydrm: Add devres versions of backlight_get

2017-10-13 Thread Sean Paul
On Fri, Oct 13, 2017 at 04:12:55PM +0530, Meghana Madhyastha wrote:
> Add devm_backlight_get and the corresponding release
> function because some drivers use devres versions of functions
> for requiring device resources.
> 

This patch looks fine, just update the names to be consistent with the previous
version and account for backlight_put not being present.

Sean

> Signed-off-by: Meghana Madhyastha 
> ---
> Changes in v13:
>  -Add devm_backlight_put to backlight.c
> 
>  drivers/gpu/drm/tinydrm/mi0283qt.c  |  2 +-
>  drivers/video/backlight/backlight.c | 31 +++
>  include/linux/backlight.h   |  6 ++
>  3 files changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
> b/drivers/gpu/drm/tinydrm/mi0283qt.c
> index a932185..e3e7583 100644
> --- a/drivers/gpu/drm/tinydrm/mi0283qt.c
> +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
> @@ -189,7 +189,7 @@ static int mi0283qt_probe(struct spi_device *spi)
>   if (IS_ERR(mipi->regulator))
>   return PTR_ERR(mipi->regulator);
>  
> - mipi->backlight = backlight_get(dev);
> + mipi->backlight = devm_backlight_get(dev);
>   if (IS_ERR(mipi->backlight))
>   return PTR_ERR(mipi->backlight);
>  
> diff --git a/drivers/video/backlight/backlight.c 
> b/drivers/video/backlight/backlight.c
> index c4e94d0..b6c505a 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -617,6 +617,37 @@ struct backlight_device *backlight_get(struct device 
> *dev)
>  }
>  EXPORT_SYMBOL(backlight_get);
>  
> +static void devm_backlight_put(void *data)
> +{
> + backlight_put(data);
> +}
> +
> +/**
> + * devm_backlight_get - Resource-managed backlight_get()
> + * @dev: Device
> + *
> + * Device managed version of backlight_get(). The reference on the backlight
> + * device is automatically dropped on driver detach.
> + */
> +struct backlight_device *devm_backlight_get(struct device *dev)
> +{
> + struct backlight_device *bd;
> + int ret;
> +
> + bd = backlight_get(dev);
> + if (!bd)
> + return NULL;
> +
> + ret = devm_add_action(dev, devm_backlight_put, bd);
> + if (ret) {
> + backlight_put(bd);
> + return ERR_PTR(ret);
> + }
> +
> + return bd;
> +}
> +EXPORT_SYMBOL(devm_backlight_get);
> +
>  static void __exit backlight_class_exit(void)
>  {
>   class_destroy(backlight_class);
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 987a6d7..8db9ba9 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -214,11 +214,17 @@ of_find_backlight_by_node(struct device_node *node)
>  
>  #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
>  struct backlight_device *backlight_get(struct device *dev);
> +struct backlight_device *devm_backlight_get(struct device *dev);
>  #else
>  static inline struct backlight_device *backlight_get(struct device *dev)
>  {
>   return NULL;
>  }
> +
> +static inline struct backlight_device *devm_backlight_get(struct device *dev)
> +{
> + return NULL;
> +}
>  #endif
>  
>  #endif
> -- 
> 2.7.4
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/4b1acbfbddd2a123001e035a62801456891276d5.1507890285.git.meghana.madhyastha%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
Sean Paul, Software Engineer, Google / Chromium OS
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Outreachy kernel] [PATCH v13 2/3] drm/tinydrm: Move tinydrm_of_find_backlight to backlight.c

2017-10-13 Thread Sean Paul
On Fri, Oct 13, 2017 at 04:11:43PM +0530, Meghana Madhyastha wrote:
> Rename tinydrm_of_find_backlight to backlight_get and move it
> to linux/backlight.c so that it can be used by other drivers.

[apologies if this has been brought up in previous versions, I haven't been
following closely]

I don't think "backlight_get" is a good name for this function. How about
of_find_backlight_by_name (since there's already of_find_backlight_by_node)?

> 
> Signed-off-by: Meghana Madhyastha 
> ---
> Changes in v13:
>  -Add backlight_put to backlight.h in this patch
> 
>  drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 
> --
>  drivers/gpu/drm/tinydrm/mi0283qt.c |  3 +-
>  drivers/video/backlight/backlight.c| 37 
>  include/drm/tinydrm/tinydrm-helpers.h  |  2 --
>  include/linux/backlight.h  | 19 
>  5 files changed, 58 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c 
> b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> index a42dee6..cb1a01a 100644
> --- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> +++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
> @@ -236,46 +236,6 @@ void tinydrm_xrgb_to_gray8(u8 *dst, void *vaddr, 
> struct drm_framebuffer *fb,
>  }
>  EXPORT_SYMBOL(tinydrm_xrgb_to_gray8);
>  
> -/**
> - * tinydrm_of_find_backlight - Find backlight device in device-tree
> - * @dev: Device
> - *
> - * This function looks for a DT node pointed to by a property named 
> 'backlight'
> - * and uses of_find_backlight_by_node() to get the backlight device.
> - * Additionally if the brightness property is zero, it is set to
> - * max_brightness.
> - *
> - * Returns:
> - * NULL if there's no backlight property.
> - * Error pointer -EPROBE_DEFER if the DT node is found, but no backlight 
> device
> - * is found.
> - * If the backlight device is found, a pointer to the structure is returned.
> - */
> -struct backlight_device *tinydrm_of_find_backlight(struct device *dev)
> -{
> - struct backlight_device *backlight;
> - struct device_node *np;
> -
> - np = of_parse_phandle(dev->of_node, "backlight", 0);
> - if (!np)
> - return NULL;
> -
> - backlight = of_find_backlight_by_node(np);
> - of_node_put(np);
> -
> - if (!backlight)
> - return ERR_PTR(-EPROBE_DEFER);
> -
> - if (!backlight->props.brightness) {
> - backlight->props.brightness = backlight->props.max_brightness;
> - DRM_DEBUG_KMS("Backlight brightness set to %d\n",
> -   backlight->props.brightness);
> - }
> -
> - return backlight;
> -}
> -EXPORT_SYMBOL(tinydrm_of_find_backlight);
> -
>  #if IS_ENABLED(CONFIG_SPI)
>  
>  /**
> diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
> b/drivers/gpu/drm/tinydrm/mi0283qt.c
> index 7fd2691..a932185 100644
> --- a/drivers/gpu/drm/tinydrm/mi0283qt.c
> +++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
> @@ -12,6 +12,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -188,7 +189,7 @@ static int mi0283qt_probe(struct spi_device *spi)
>   if (IS_ERR(mipi->regulator))
>   return PTR_ERR(mipi->regulator);
>  
> - mipi->backlight = tinydrm_of_find_backlight(dev);
> + mipi->backlight = backlight_get(dev);
>   if (IS_ERR(mipi->backlight))
>   return PTR_ERR(mipi->backlight);
>  
> diff --git a/drivers/video/backlight/backlight.c 
> b/drivers/video/backlight/backlight.c
> index 8049e76..c4e94d0 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -580,6 +580,43 @@ struct backlight_device 
> *of_find_backlight_by_node(struct device_node *node)
>  EXPORT_SYMBOL(of_find_backlight_by_node);
>  #endif
>  
> +/**
> + * backlight_get - Get backlight device
> + * @dev: Device
> + *
> + * This function looks for a property named 'backlight' on the DT node
> + * connected to @dev and looks up the backlight device.
> + *
> + * Call backlight_put() to drop the reference on the backlight device.
> + *
> + * Returns:
> + * A pointer to the backlight device if found.
> + * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
> + * device is found.
> + * NULL if there's no backlight property.
> + */
> +struct backlight_device *backlight_get(struct device *dev)
> +{
> + struct backlight_device *bd = NULL;
> + struct device_node *np;
> +
> + if (!dev)
> + return NULL;
> +
> + if (IS_ENABLED(CONFIG_OF) && dev->of_node) {

I'm not really used to seeing IS_ENABLED(CONFIG_BLAH) inline. The common
patterns seems to be wrapping the actual implementation in #if
IS_ENABLED(CONFIG_BLAH) and then sticking a stub implementation in the #else.

I see below that you already have a stub if backlight is not enabled, so expand
that #if to include CONFIG_OF as well.

> + np 

Re: [PATCH v3 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Harry Wentland
On 2017-10-13 03:29 PM, sunpeng...@amd.com wrote:
> From: "Leo (Sunpeng) Li" 
> 
> Use the correct for_each_new/old_* iterators instead of for_each_*
> 
> The following functions were considered:
> 
> amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
> - Old from_state_var flag was always choosing the new state
> 
> amdgpu_dm_display_resume: use for_each_new
> - drm_atomic_helper_duplicate_state is called during suspend to
>   cache the state
> - It sets 'state' within the state triplet to 'new_state'
> 
> amdgpu_dm_commit_planes: use for_each_old
> - Called after the state was swapped (via atomic commit tail)
> 
> amdgpu_dm_atomic_commit: use for_each_new
> - Called before the state is swapped
> 
> amdgpu_dm_atomic_commit_tail: use for_each_old
> - Called after the state was swapped
> 
> dm_update_crtcs_state: use for_each_new
> - Called before the state is swapped (via atomic check)
> 
> amdgpu_dm_atomic_check: use for_each_new
> - Called before the state is swapped
> 
> v2: Split out typo fixes to a new patch.
> 
> v3: Say "functions considered" instead of "affected functions". The
> latter implies that changes are made to each.
> 
> Signed-off-by: Leo (Sunpeng) Li 

Patches 1-2 (v3) are also
Reviewed-by: Harry Wentland 

Harry

> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
>  2 files changed, 12 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 9bfe1f9..cc024ab 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
>  
>  struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector(
>   struct drm_atomic_state *state,
> - struct drm_crtc *crtc,
> - bool from_state_var)
> + struct drm_crtc *crtc)
>  {
>   uint32_t i;
>   struct drm_connector_state *conn_state;
>   struct drm_connector *connector;
>   struct drm_crtc *crtc_from_state;
>  
> - for_each_new_connector_in_state(
> - state,
> - connector,
> - conn_state,
> - i) {
> - crtc_from_state =
> - from_state_var ?
> - conn_state->crtc :
> - connector->state->crtc;
> + for_each_new_connector_in_state(state, connector, conn_state, i) {
> + crtc_from_state = conn_state->crtc;
>  
>   if (crtc_from_state == crtc)
>   return to_amdgpu_dm_connector(connector);
> @@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
> drm_atomic_state *state,
>   unsigned long flags;
>  
>   /* update planes when needed */
> - for_each_new_plane_in_state(state, plane, old_plane_state, i) {
> + for_each_old_plane_in_state(state, plane, old_plane_state, i) {
>   struct drm_plane_state *plane_state = plane->state;
>   struct drm_crtc *crtc = plane_state->crtc;
>   struct drm_framebuffer *fb = plane_state->fb;
> @@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
>   dm_state = to_dm_atomic_state(state);
>  
>   /* update changed items */
> - for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
> + for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
>   struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
>   struct drm_crtc_state *new_state = crtc->state;
>  
> @@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(
>   new_acrtc_state = 
> to_dm_crtc_state(new_crtcs[i]->base.state);
>  
>   new_stream = new_acrtc_state->stream;
> - aconnector =
> - amdgpu_dm_find_first_crct_matching_connector(
> + aconnector = 
> amdgpu_dm_find_first_crct_matching_connector(
>   state,
> - _crtcs[i]->base,
> - false);
> + _crtcs[i]->base);
>   if (!aconnector) {
>   DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
> connector for acrtc id:%d "
>"skipping freesync init\n",
> @@ -4151,7 +4141,7 @@ void amdgpu_dm_atomic_commit_tail(
>   }
>  
>   /* Handle scaling and undersacn changes*/
> - for_each_new_connector_in_state(state, connector, old_conn_state, i) {
> + for_each_old_connector_in_state(state, connector, old_conn_state, i) {
>   struct amdgpu_dm_connector *aconnector = 
> to_amdgpu_dm_connector(connector);
> 

[Bug 103102] Cannot wake-up with an AMD RX 480 on Linux 4.13 and Linux 4.14

2017-10-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=103102

--- Comment #10 from Hadrien  ---
I built v4.12.5 from
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git instead
of using a prebuilt kernel from
http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.12.5/ and I unexpectedly faced
the problem.

I wonder why I cannot reproduce the problem with Ubuntu's version of kernel
4.12.5. Maybe there are some Ubuntu specific patches that hide the problem?

Anyway, I rebuilt v4.2.5 again but this time I removed the code from the commit
referenced on kernel.org Bugzilla:

--
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index c0a806280257..f862e3d9cd93 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -838,9 +838,10 @@ static int amdgpu_cgs_get_active_displays_info(struct
cgs_device *cgs_device,
return -EINVAL;

mode_info = info->mode_info;
+
if (mode_info) {
/* if the displays are off, vblank time is max */
-   mode_info->vblank_time_us = 0x;
+   /*mode_info->vblank_time_us = 0x;*/
/* always set the reference clock */
mode_info->ref_clock = adev->clock.spll.reference_freq;
}

--

And I cannot reproduce the problem anymore. So I guess this is actually the
same problem than https://bugzilla.kernel.org/show_bug.cgi?id=196615

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/amd/display: fix ifnullfree.cocci warnings

2017-10-13 Thread Harry Wentland
On 2017-10-12 07:17 PM, kbuild test robot wrote:
> drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c:134:3-8: 
> WARNING: NULL check before freeing functions like kfree, debugfs_remove, 
> debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider 
> reorganizing relevant code to avoid passing NULL values.
> drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c:175:4-9: 
> WARNING: NULL check before freeing functions like kfree, debugfs_remove, 
> debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider 
> reorganizing relevant code to avoid passing NULL values.
> 
>  NULL check before some freeing functions is not needed.
> 
>  Based on checkpatch warning
>  "kfree(NULL) is safe this check is probably not required"
>  and kfreeaddr.cocci by Julia Lawall.
> 
> Generated by: scripts/coccinelle/free/ifnullfree.cocci
> 
> Fixes: f09cd1f46388 ("drm/amd/display: Use kernel alloc/free")
> Signed-off-by: Fengguang Wu 

Reviewed-by: Harry Wentland 

Harry

> ---
> 
>  gpio_service.c |6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> --- a/drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c
> +++ b/drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c
> @@ -130,8 +130,7 @@ failure_2:
>  
>   slot = service->busyness[index_of_id];
>  
> - if (slot)
> - kfree(slot);
> + kfree(slot);
>   };
>  
>  failure_1:
> @@ -171,8 +170,7 @@ void dal_gpio_service_destroy(
>   do {
>   uint32_t *slot = (*ptr)->busyness[index_of_id];
>  
> - if (slot)
> - kfree(slot);
> + kfree(slot);
>  
>   ++index_of_id;
>   } while (index_of_id < GPIO_ID_COUNT);
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[pull] amdgpu drm-next-4.15-dc

2017-10-13 Thread Alex Deucher
Hi Dave,

Updates for DC against your drm-next-amd-dc-staging branch.
- Fix for iterator changes
- Misc cleanups

The following changes since commit e7b8e99bed73e9c42f1c074ad6009cb59a79bd52:

  amdgpu/dc: fixup for new apis - probably wrong (2017-10-09 11:22:07 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~agd5f/linux drm-next-4.15-dc

for you to fetch changes up to b175d392cfb28a9d260904bbb330917efe039331:

  drm/amd/display: drop unused dm_delay_in_microseconds (2017-10-13 15:49:42 
-0400)


Alex Deucher (12):
  drm/amd/display: fix typo in function name
  drm/amd/display: whitespace cleanup in amdgpu_dm.c/h
  drm/amd/display: make a bunch of stuff in amdgpu_dm.c static
  drm/amd/display: drop unused functions in amdgpu_dm.c
  drm/amd/display: drop unused functions in amdgpu_dm_services.c
  drm/amd/display: whitespace cleanup in amdgpu_dm_mst_types.c/h
  drm/amd/display: make log_dpcd static
  drm/amd/display: whitespace cleanup in amdgpu_dm_irq.c/h
  drm/amd/display: remove unused functions in amdgpu_dm_irq.c
  drm/amd/display: make amdgpu_dm_irq_handler static
  drm/amd/display/dc: drop dm_delay_in_microseconds
  drm/amd/display: drop unused dm_delay_in_microseconds

Leo (Sunpeng) Li (6):
  drm/amd/display: Use DRM new-style object iterators.
  drm/amd/display: Use new DRM API where possible
  drm/amd/display: Unify DRM state variable namings.
  drm/amd/display: Unify amdgpu_dm state variable namings.
  drm/amd/display: Fix typo
  drm/amd/display: Remove useless pcrtc pointer

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 812 ++---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h  | 122 +---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c  | 163 ++---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.h  |  38 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_mst_types.c|  41 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_mst_types.h|   5 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_services.c |  60 --
 drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c |   4 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c  |   4 +-
 drivers/gpu/drm/amd/display/dc/dm_services.h   |   3 -
 10 files changed, 472 insertions(+), 780 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm: Replace kzalloc with kcalloc

2017-10-13 Thread Sean Paul
On Fri, Oct 13, 2017 at 10:58:33AM +0300, Jani Nikula wrote:
> On Fri, 13 Oct 2017, Harsha Sharma  wrote:
> > Prefer kcalloc over kzalloc to allocate an array.
> > This patch fixes checkcpatch issue.
> >
> > Signed-off-by: Harsha Sharma 
> 
> Reviewed-by: Jani Nikula 
> 

Applied to -misc-next, thanks!

Sean

> 
> > ---
> > Changes in v2:
> >  -kcalloc will take 3 arguments
> >
> >  drivers/gpu/drm/drm_crtc_helper.c  | 4 ++--
> >  drivers/gpu/drm/drm_fb_helper.c| 2 +-
> >  drivers/gpu/drm/drm_plane_helper.c | 2 +-
> >  3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_crtc_helper.c 
> > b/drivers/gpu/drm/drm_crtc_helper.c
> > index eab36a460638..5a84c3bc915d 100644
> > --- a/drivers/gpu/drm/drm_crtc_helper.c
> > +++ b/drivers/gpu/drm/drm_crtc_helper.c
> > @@ -562,12 +562,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set 
> > *set,
> >  * Allocate space for the backup of all (non-pointer) encoder and
> >  * connector data.
> >  */
> > -   save_encoder_crtcs = kzalloc(dev->mode_config.num_encoder *
> > +   save_encoder_crtcs = kcalloc(dev->mode_config.num_encoder,
> > sizeof(struct drm_crtc *), GFP_KERNEL);
> > if (!save_encoder_crtcs)
> > return -ENOMEM;
> >  
> > -   save_connector_encoders = kzalloc(dev->mode_config.num_connector *
> > +   save_connector_encoders = kcalloc(dev->mode_config.num_connector,
> > sizeof(struct drm_encoder *), GFP_KERNEL);
> > if (!save_connector_encoders) {
> > kfree(save_encoder_crtcs);
> > diff --git a/drivers/gpu/drm/drm_fb_helper.c 
> > b/drivers/gpu/drm/drm_fb_helper.c
> > index 1b8f013ffa65..de31e52ab9cb 100644
> > --- a/drivers/gpu/drm/drm_fb_helper.c
> > +++ b/drivers/gpu/drm/drm_fb_helper.c
> > @@ -2266,7 +2266,7 @@ static int drm_pick_crtcs(struct drm_fb_helper 
> > *fb_helper,
> > if (modes[n] == NULL)
> > return best_score;
> >  
> > -   crtcs = kzalloc(fb_helper->connector_count *
> > +   crtcs = kcalloc(fb_helper->connector_count,
> > sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL);
> > if (!crtcs)
> > return best_score;
> > diff --git a/drivers/gpu/drm/drm_plane_helper.c 
> > b/drivers/gpu/drm/drm_plane_helper.c
> > index 06aee1741e96..759ed93f4ba8 100644
> > --- a/drivers/gpu/drm/drm_plane_helper.c
> > +++ b/drivers/gpu/drm/drm_plane_helper.c
> > @@ -354,7 +354,7 @@ int drm_primary_helper_update(struct drm_plane *plane, 
> > struct drm_crtc *crtc,
> > /* Find current connectors for CRTC */
> > num_connectors = get_connectors_for_crtc(crtc, NULL, 0);
> > BUG_ON(num_connectors == 0);
> > -   connector_list = kzalloc(num_connectors * sizeof(*connector_list),
> > +   connector_list = kcalloc(num_connectors, sizeof(*connector_list),
> >  GFP_KERNEL);
> > if (!connector_list)
> > return -ENOMEM;
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center

-- 
Sean Paul, Software Engineer, Google / Chromium OS
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 101900] No HDMI HBR audio on Polaris (no TrueHD, no Atmos, no Neo:X, no HD Master audio)

2017-10-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=101900

--- Comment #11 from Harry Wentland  ---
So, unbeknowst to me, we never supported HBR audio (i.e. TrueHD, etc.) with DC.
We would like to enable it but it's not top priority right now.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/amd/dc: fix semicolon.cocci warnings

2017-10-13 Thread Harry Wentland
On 2017-10-12 07:35 PM, kbuild test robot wrote:
> drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c:134:2-3: 
> Unneeded semicolon
> 
> 
>  Remove unneeded semicolon.
> 
> Generated by: scripts/coccinelle/misc/semicolon.cocci
> 
> Fixes: 80be23c57868 ("drm/amd/dc: Add dc display driver (v2)")
> CC: Harry Wentland 
> Signed-off-by: Fengguang Wu 

Reviewed-by: Harry Wentland 

Harry

> ---
> 
>  gpio_service.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c
> +++ b/drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c
> @@ -131,7 +131,7 @@ failure_2:
>  
>   if (slot)
>   dm_free(slot);
> - };
> + }
>  
>  failure_1:
>   dm_free(service);
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread sunpeng.li
From: "Leo (Sunpeng) Li" 

Use the correct for_each_new/old_* iterators instead of for_each_*

The following functions were considered:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
- Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
- drm_atomic_helper_duplicate_state is called during suspend to
  cache the state
- It sets 'state' within the state triplet to 'new_state'

amdgpu_dm_commit_planes: use for_each_old
- Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
- Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
- Called after the state was swapped

dm_update_crtcs_state: use for_each_new
- Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
- Called before the state is swapped

v2: Split out typo fixes to a new patch.

v3: Say "functions considered" instead of "affected functions". The
latter implies that changes are made to each.

Signed-off-by: Leo (Sunpeng) Li 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 ---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
 
 struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector(
struct drm_atomic_state *state,
-   struct drm_crtc *crtc,
-   bool from_state_var)
+   struct drm_crtc *crtc)
 {
uint32_t i;
struct drm_connector_state *conn_state;
struct drm_connector *connector;
struct drm_crtc *crtc_from_state;
 
-   for_each_new_connector_in_state(
-   state,
-   connector,
-   conn_state,
-   i) {
-   crtc_from_state =
-   from_state_var ?
-   conn_state->crtc :
-   connector->state->crtc;
+   for_each_new_connector_in_state(state, connector, conn_state, i) {
+   crtc_from_state = conn_state->crtc;
 
if (crtc_from_state == crtc)
return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,
unsigned long flags;
 
/* update planes when needed */
-   for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+   for_each_old_plane_in_state(state, plane, old_plane_state, i) {
struct drm_plane_state *plane_state = plane->state;
struct drm_crtc *crtc = plane_state->crtc;
struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
dm_state = to_dm_atomic_state(state);
 
/* update changed items */
-   for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+   for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
struct drm_crtc_state *new_state = crtc->state;
 
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(
new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);
 
new_stream = new_acrtc_state->stream;
-   aconnector =
-   amdgpu_dm_find_first_crct_matching_connector(
+   aconnector = 
amdgpu_dm_find_first_crct_matching_connector(
state,
-   _crtcs[i]->base,
-   false);
+   _crtcs[i]->base);
if (!aconnector) {
DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
connector for acrtc id:%d "
 "skipping freesync init\n",
@@ -4151,7 +4141,7 @@ void amdgpu_dm_atomic_commit_tail(
}
 
/* Handle scaling and undersacn changes*/
-   for_each_new_connector_in_state(state, connector, old_conn_state, i) {
+   for_each_old_connector_in_state(state, connector, old_conn_state, i) {
struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);
struct dm_connector_state *con_new_state =
to_dm_connector_state(aconnector->base.state);
@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail(
}
 
/* update planes when needed per crtc*/
-   

Re: [PATCH 2/6] drm/amd/display: Use new DRM API where possible

2017-10-13 Thread Harry Wentland
On 2017-10-13 01:26 PM, Andrey Grodzovsky wrote:
> 
> 
> On 10/13/2017 12:18 PM, Harry Wentland wrote:
>> On 2017-10-12 05:15 PM, sunpeng...@amd.com wrote:
>>> From: "Leo (Sunpeng) Li" 
>>>
>>> To conform to DRM's new API, we should not be accessing a DRM object's
>>> internal state directly. Rather, the DRM for_each_old/new_* iterators,
>>> and drm_atomic_get_old/new_* interface should be used.
>>>
>>> This is an ongoing process. For now, update the DRM-facing atomic
>>> functions, where the atomic state object is given.
>>>
>>> Signed-off-by: Leo (Sunpeng) Li 
>>> ---
>>>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 131 
>>> +++---
>>>   1 file changed, 66 insertions(+), 65 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
>>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> index cc024ab..d4426b3 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> @@ -3873,28 +3873,31 @@ static void amdgpu_dm_commit_planes(struct 
>>> drm_atomic_state *state,
>>>   {
>>>   uint32_t i;
>>>   struct drm_plane *plane;
>>> -    struct drm_plane_state *old_plane_state;
>>> +    struct drm_plane_state *old_plane_state, *new_plane_state;
>>>   struct dc_stream_state *dc_stream_attach;
>>>   struct dc_plane_state *plane_states_constructed[MAX_SURFACES];
>>>   struct amdgpu_crtc *acrtc_attach = to_amdgpu_crtc(pcrtc);
>>> -    struct dm_crtc_state *acrtc_state = to_dm_crtc_state(pcrtc->state);
>>> +    struct drm_crtc_state *new_pcrtc_state =
>>> +    drm_atomic_get_new_crtc_state(state, pcrtc);
>>> +    struct dm_crtc_state *acrtc_state = to_dm_crtc_state(new_pcrtc_state);
>>>   int planes_count = 0;
>>>   unsigned long flags;
>>>     /* update planes when needed */
>>> -    for_each_old_plane_in_state(state, plane, old_plane_state, i) {
>>> -    struct drm_plane_state *plane_state = plane->state;
>>> -    struct drm_crtc *crtc = plane_state->crtc;
>>> -    struct drm_framebuffer *fb = plane_state->fb;
>>> +    for_each_oldnew_plane_in_state(state, plane, old_plane_state, 
>>> new_plane_state, i) {
>>> +    struct drm_crtc *crtc = new_plane_state->crtc;
>>> +    struct drm_crtc_state *new_crtc_state =
>>> +    drm_atomic_get_new_crtc_state(state, crtc);
>>> +    struct drm_framebuffer *fb = new_plane_state->fb;
>>>   bool pflip_needed;
>>> -    struct dm_plane_state *dm_plane_state = 
>>> to_dm_plane_state(plane_state);
>>> +    struct dm_plane_state *dm_plane_state = 
>>> to_dm_plane_state(new_plane_state);
>>>     if (plane->type == DRM_PLANE_TYPE_CURSOR) {
>>>   handle_cursor_update(plane, old_plane_state);
>>>   continue;
>>>   }
>>>   -    if (!fb || !crtc || pcrtc != crtc || !crtc->state->active)
>>> +    if (!fb || !crtc || pcrtc != crtc || !new_crtc_state->active)
>>>   continue;
>>>     pflip_needed = !state->allow_modeset;
>>> @@ -3918,13 +3921,13 @@ static void amdgpu_dm_commit_planes(struct 
>>> drm_atomic_state *state,
>>>   dc_stream_attach = acrtc_state->stream;
>>>   planes_count++;
>>>   -    } else if (crtc->state->planes_changed) {
>>> +    } else if (new_crtc_state->planes_changed) {
>>>   /* Assume even ONE crtc with immediate flip means
>>>    * entire can't wait for VBLANK
>>>    * TODO Check if it's correct
>>>    */
>>>   *wait_for_vblank =
>>> -    pcrtc->state->pageflip_flags & 
>>> DRM_MODE_PAGE_FLIP_ASYNC ?
>>> +    new_pcrtc_state->pageflip_flags & 
>>> DRM_MODE_PAGE_FLIP_ASYNC ?
>>>   false : true;
>>>     /* TODO: Needs rework for multiplane flip */
>>> @@ -3942,7 +3945,7 @@ static void amdgpu_dm_commit_planes(struct 
>>> drm_atomic_state *state,
>>>   if (planes_count) {
>>>   unsigned long flags;
>>>   -    if (pcrtc->state->event) {
>>> +    if (new_pcrtc_state->event) {
>>>     drm_crtc_vblank_get(pcrtc);
>>>   @@ -3968,7 +3971,7 @@ int amdgpu_dm_atomic_commit(
>>>   bool nonblock)
>>>   {
>>>   struct drm_crtc *crtc;
>>> -    struct drm_crtc_state *new_state;
>>> +    struct drm_crtc_state *old_crtc_state, *new_state;
>>>   struct amdgpu_device *adev = dev->dev_private;
>>>   int i;
>>>   @@ -3979,8 +3982,8 @@ int amdgpu_dm_atomic_commit(
>>>    * it will update crtc->dm_crtc_state->stream pointer which is used in
>>>    * the ISRs.
>>>    */
>>> -    for_each_new_crtc_in_state(state, crtc, new_state, i) {
>>> -    struct dm_crtc_state *old_acrtc_state = 
>>> to_dm_crtc_state(crtc->state);
>>> +    for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_state, 
>>> i) {
>>> +    struct dm_crtc_state *old_acrtc_state = 
>>> 

Re: [PATCH v2 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Andrey Grodzovsky



On 10/13/2017 12:35 PM, Leo wrote:



On 2017-10-13 11:56 AM, Andrey Grodzovsky wrote:



On 10/13/2017 11:41 AM, Leo wrote:



On 2017-10-13 11:03 AM, Andrey Grodzovsky wrote:



On 10/12/2017 05:15 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li"

Use the correct for_each_new/old_* iterators instead of for_each_*

List of affected functions:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
 - Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
 - drm_atomic_helper_duplicate_state is called during suspend to
   cache the state
 - It sets 'state' within the state triplet to 'new_state'


It seems to me you missed that one.

Thanks,
Andrey



Good catch, seems like that change was stripped out while I was cp-ing
from the internal tree. Some changes in this function have not been 
promoted to Dave's branch yet.


I'll remove this comment for now, I think it makes sense to have a 
follow-up patch to this after more changes have been promoted.


Thanks,
Leo


With that fixed the change is Reviewed-by: Andrey Grodzovsky 



On second look, this comment is addressing the change within Dave's
patch, on which this series apply. I was trying to justify all the 
changes made, including the ones already done by Dave. See here:


https://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next-amd-dc-staging=e7b8e99bed73e9c42f1c074ad6009cb59a79bd52 



I think changing "List of affected functions" to "The following 
functions were considered" would make it less confusing, and will

still make sense if it gets squashed with Dave's patch.

Leo


Makes sense to me to.

Thanks,
Andrey







amdgpu_dm_commit_planes: use for_each_old
 - Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
 - Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
 - Called after the state was swapped

dm_update_crtcs_state: use for_each_new
 - Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
 - Called before the state is swapped

v2: Split out typo fixes to a new patch.

Signed-off-by: Leo (Sunpeng) Li
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 
---

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
  2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
  struct amdgpu_dm_connector 
*amdgpu_dm_find_first_crct_matching_connector(

  struct drm_atomic_state *state,
-struct drm_crtc *crtc,
-bool from_state_var)
+struct drm_crtc *crtc)
  {
  uint32_t i;
  struct drm_connector_state *conn_state;
  struct drm_connector *connector;
  struct drm_crtc *crtc_from_state;
-for_each_new_connector_in_state(
-state,
-connector,
-conn_state,
-i) {
-crtc_from_state =
-from_state_var ?
-conn_state->crtc :
-connector->state->crtc;
+for_each_new_connector_in_state(state, connector, conn_state, 
i) {

+crtc_from_state = conn_state->crtc;
  if (crtc_from_state == crtc)
  return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,

  unsigned long flags;
  /* update planes when needed */
-for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+for_each_old_plane_in_state(state, plane, old_plane_state, i) {
  struct drm_plane_state *plane_state = plane->state;
  struct drm_crtc *crtc = plane_state->crtc;
  struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
  dm_state = to_dm_atomic_state(state);
  /* update changed items */
-for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
  struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
  struct drm_crtc_state *new_state = crtc->state;
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(
  new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);

  new_stream = new_acrtc_state->stream;
-aconnector =
- amdgpu_dm_find_first_crct_matching_connector(
+aconnector = 
amdgpu_dm_find_first_crct_matching_connector(

  state,
-_crtcs[i]->base,
-false);
+_crtcs[i]->base);
  if (!aconnector) {
  

Re: [Outreachy kernel] [PATCH v2] drm/amd/powerplay: Remove unnecessary cast on void pointer

2017-10-13 Thread Julia Lawall
> @@ -3400,7 +3400,7 @@ static int smu7_read_sensor(struct pp_hwmgr *hwmgr, int 
> idx,
>  static int smu7_find_dpm_states_clocks_in_dpm_table(struct pp_hwmgr *hwmgr, 
> const void *input)
>  {
>   const struct phm_set_power_state_input *states =
> - (const struct phm_set_power_state_input *)input;
> + input;

Actually, there are some more cleanup opportunities heer and in some other
cases.  There is no need for the newline before input.

julia
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 0/6] Use new DRM API where possible, and cleanups.

2017-10-13 Thread Maarten Lankhorst
Op 12-10-17 om 23:15 schreef sunpeng...@amd.com:
> From: "Leo (Sunpeng) Li" 
>
> Hi Dave,
>
> This series reworks the previous patch. Patch 1 is a v2 of the previous,
> and additional patches are from the feedback received. They apply on top
> of your drm-next-amd-dc-staging branch.
>
> Thanks,
> Leo
>
> Leo (Sunpeng) Li (6):
>   drm/amd/display: Use DRM new-style object iterators.
>   drm/amd/display: Use new DRM API where possible
>   drm/amd/display: Unify DRM state variable namings.
>   drm/amd/display: Unify amdgpu_dm state variable namings.
>   drm/amd/display: Fix typo
>   drm/amd/display: Remove useless pcrtc pointer
>
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 320 
> +++---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   3 +-
>  2 files changed, 156 insertions(+), 167 deletions(-)
>
Better, only scanned through the series but

Reviewed-by: Maarten Lankhorst 

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/6] drm/amd/display: Use new DRM API where possible

2017-10-13 Thread Andrey Grodzovsky



On 10/13/2017 12:18 PM, Harry Wentland wrote:

On 2017-10-12 05:15 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li" 

To conform to DRM's new API, we should not be accessing a DRM object's
internal state directly. Rather, the DRM for_each_old/new_* iterators,
and drm_atomic_get_old/new_* interface should be used.

This is an ongoing process. For now, update the DRM-facing atomic
functions, where the atomic state object is given.

Signed-off-by: Leo (Sunpeng) Li 
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 131 +++---
  1 file changed, 66 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index cc024ab..d4426b3 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3873,28 +3873,31 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,
  {
uint32_t i;
struct drm_plane *plane;
-   struct drm_plane_state *old_plane_state;
+   struct drm_plane_state *old_plane_state, *new_plane_state;
struct dc_stream_state *dc_stream_attach;
struct dc_plane_state *plane_states_constructed[MAX_SURFACES];
struct amdgpu_crtc *acrtc_attach = to_amdgpu_crtc(pcrtc);
-   struct dm_crtc_state *acrtc_state = to_dm_crtc_state(pcrtc->state);
+   struct drm_crtc_state *new_pcrtc_state =
+   drm_atomic_get_new_crtc_state(state, pcrtc);
+   struct dm_crtc_state *acrtc_state = to_dm_crtc_state(new_pcrtc_state);
int planes_count = 0;
unsigned long flags;
  
  	/* update planes when needed */

-   for_each_old_plane_in_state(state, plane, old_plane_state, i) {
-   struct drm_plane_state *plane_state = plane->state;
-   struct drm_crtc *crtc = plane_state->crtc;
-   struct drm_framebuffer *fb = plane_state->fb;
+   for_each_oldnew_plane_in_state(state, plane, old_plane_state, 
new_plane_state, i) {
+   struct drm_crtc *crtc = new_plane_state->crtc;
+   struct drm_crtc_state *new_crtc_state =
+   drm_atomic_get_new_crtc_state(state, crtc);
+   struct drm_framebuffer *fb = new_plane_state->fb;
bool pflip_needed;
-   struct dm_plane_state *dm_plane_state = 
to_dm_plane_state(plane_state);
+   struct dm_plane_state *dm_plane_state = 
to_dm_plane_state(new_plane_state);
  
  		if (plane->type == DRM_PLANE_TYPE_CURSOR) {

handle_cursor_update(plane, old_plane_state);
continue;
}
  
-		if (!fb || !crtc || pcrtc != crtc || !crtc->state->active)

+   if (!fb || !crtc || pcrtc != crtc || !new_crtc_state->active)
continue;
  
  		pflip_needed = !state->allow_modeset;

@@ -3918,13 +3921,13 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,
dc_stream_attach = acrtc_state->stream;
planes_count++;
  
-		} else if (crtc->state->planes_changed) {

+   } else if (new_crtc_state->planes_changed) {
/* Assume even ONE crtc with immediate flip means
 * entire can't wait for VBLANK
 * TODO Check if it's correct
 */
*wait_for_vblank =
-   pcrtc->state->pageflip_flags & 
DRM_MODE_PAGE_FLIP_ASYNC ?
+   new_pcrtc_state->pageflip_flags & 
DRM_MODE_PAGE_FLIP_ASYNC ?
false : true;
  
  			/* TODO: Needs rework for multiplane flip */

@@ -3942,7 +3945,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,
if (planes_count) {
unsigned long flags;
  
-		if (pcrtc->state->event) {

+   if (new_pcrtc_state->event) {
  
  			drm_crtc_vblank_get(pcrtc);
  
@@ -3968,7 +3971,7 @@ int amdgpu_dm_atomic_commit(

bool nonblock)
  {
struct drm_crtc *crtc;
-   struct drm_crtc_state *new_state;
+   struct drm_crtc_state *old_crtc_state, *new_state;
struct amdgpu_device *adev = dev->dev_private;
int i;
  
@@ -3979,8 +3982,8 @@ int amdgpu_dm_atomic_commit(

 * it will update crtc->dm_crtc_state->stream pointer which is used in
 * the ISRs.
 */
-   for_each_new_crtc_in_state(state, crtc, new_state, i) {
-   struct dm_crtc_state *old_acrtc_state = 
to_dm_crtc_state(crtc->state);
+   for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_state, 
i) {
+   struct dm_crtc_state *old_acrtc_state = 
to_dm_crtc_state(old_crtc_state);
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
  
  		if 

[PATCH] drm: panel: simple: add Toshiba LT089AC19000

2017-10-13 Thread Lucas Stach
Only exposes a single mode and not a complete display timing, as
the datasheet is rather vague about the minimum/maximum values.

Signed-off-by: Lucas Stach 
---
 .../display/panel/toshiba,lt089ac29000.txt |  8 +++
 drivers/gpu/drm/panel/panel-simple.c   | 26 ++
 2 files changed, 34 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/toshiba,lt089ac29000.txt

diff --git 
a/Documentation/devicetree/bindings/display/panel/toshiba,lt089ac29000.txt 
b/Documentation/devicetree/bindings/display/panel/toshiba,lt089ac29000.txt
new file mode 100644
index ..e5cb1ad23cd5
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/toshiba,lt089ac29000.txt
@@ -0,0 +1,8 @@
+Toshiba 8.4" WXGA (1280x768) TFT LCD panel
+
+Required properties:
+- compatible: should be "toshiba,lt089ac29000.txt"
+- power-supply: as specified in the base binding
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 474fa759e06e..cabd8ea06d8b 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1831,6 +1831,29 @@ static const struct panel_desc tianma_tm070jdhg30 = {
.bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
 };
 
+static const struct drm_display_mode toshiba_lt089ac29000_mode = {
+   .clock = 79500,
+   .hdisplay = 1280,
+   .hsync_start = 1280 + 192,
+   .hsync_end = 1280 + 192 + 128,
+   .htotal = 1280 + 192 + 128 + 64,
+   .vdisplay = 768,
+   .vsync_start = 768 + 20,
+   .vsync_end = 768 + 20 + 7,
+   .vtotal = 768 + 20 + 7 + 3,
+   .vrefresh = 60,
+};
+
+static const struct panel_desc toshiba_lt089ac29000 = {
+   .modes = _lt089ac29000_mode,
+   .num_modes = 1,
+   .size = {
+   .width = 194,
+   .height = 116,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
+};
+
 static const struct drm_display_mode tpk_f07a_0102_mode = {
.clock = 33260,
.hdisplay = 800,
@@ -2113,6 +2136,9 @@ static const struct of_device_id platform_of_match[] = {
.compatible = "tianma,tm070jdhg30",
.data = _tm070jdhg30,
}, {
+   .compatible = "toshiba,lt089ac29000",
+   .data = _lt089ac29000,
+   }, {
.compatible = "tpk,f07a-0102",
.data = _f07a_0102,
}, {
-- 
2.11.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Leo



On 2017-10-13 11:56 AM, Andrey Grodzovsky wrote:



On 10/13/2017 11:41 AM, Leo wrote:



On 2017-10-13 11:03 AM, Andrey Grodzovsky wrote:



On 10/12/2017 05:15 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li"

Use the correct for_each_new/old_* iterators instead of for_each_*

List of affected functions:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
 - Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
 - drm_atomic_helper_duplicate_state is called during suspend to
   cache the state
 - It sets 'state' within the state triplet to 'new_state'


It seems to me you missed that one.

Thanks,
Andrey



Good catch, seems like that change was stripped out while I was cp-ing
from the internal tree. Some changes in this function have not been 
promoted to Dave's branch yet.


I'll remove this comment for now, I think it makes sense to have a 
follow-up patch to this after more changes have been promoted.


Thanks,
Leo


With that fixed the change is Reviewed-by: Andrey Grodzovsky 



On second look, this comment is addressing the change within Dave's
patch, on which this series apply. I was trying to justify all the 
changes made, including the ones already done by Dave. See here:


https://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next-amd-dc-staging=e7b8e99bed73e9c42f1c074ad6009cb59a79bd52

I think changing "List of affected functions" to "The following 
functions were considered" would make it less confusing, and will

still make sense if it gets squashed with Dave's patch.

Leo





amdgpu_dm_commit_planes: use for_each_old
 - Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
 - Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
 - Called after the state was swapped

dm_update_crtcs_state: use for_each_new
 - Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
 - Called before the state is swapped

v2: Split out typo fixes to a new patch.

Signed-off-by: Leo (Sunpeng) Li
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 
---

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
  2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
  struct amdgpu_dm_connector 
*amdgpu_dm_find_first_crct_matching_connector(

  struct drm_atomic_state *state,
-    struct drm_crtc *crtc,
-    bool from_state_var)
+    struct drm_crtc *crtc)
  {
  uint32_t i;
  struct drm_connector_state *conn_state;
  struct drm_connector *connector;
  struct drm_crtc *crtc_from_state;
-    for_each_new_connector_in_state(
-    state,
-    connector,
-    conn_state,
-    i) {
-    crtc_from_state =
-    from_state_var ?
-    conn_state->crtc :
-    connector->state->crtc;
+    for_each_new_connector_in_state(state, connector, conn_state, i) {
+    crtc_from_state = conn_state->crtc;
  if (crtc_from_state == crtc)
  return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,

  unsigned long flags;
  /* update planes when needed */
-    for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+    for_each_old_plane_in_state(state, plane, old_plane_state, i) {
  struct drm_plane_state *plane_state = plane->state;
  struct drm_crtc *crtc = plane_state->crtc;
  struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
  dm_state = to_dm_atomic_state(state);
  /* update changed items */
-    for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+    for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
  struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
  struct drm_crtc_state *new_state = crtc->state;
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(
  new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);

  new_stream = new_acrtc_state->stream;
-    aconnector =
-    amdgpu_dm_find_first_crct_matching_connector(
+    aconnector = amdgpu_dm_find_first_crct_matching_connector(
  state,
-    _crtcs[i]->base,
-    false);
+    _crtcs[i]->base);
  if (!aconnector) {
  DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
connector for acrtc 

Re: [PATCH v2 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Andrey Grodzovsky



On 10/12/2017 05:15 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li"

Use the correct for_each_new/old_* iterators instead of for_each_*

List of affected functions:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
 - Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
 - drm_atomic_helper_duplicate_state is called during suspend to
   cache the state
 - It sets 'state' within the state triplet to 'new_state'


It seems to me you missed that one.

Thanks,
Andrey



amdgpu_dm_commit_planes: use for_each_old
 - Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
 - Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
 - Called after the state was swapped

dm_update_crtcs_state: use for_each_new
 - Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
 - Called before the state is swapped

v2: Split out typo fixes to a new patch.

Signed-off-by: Leo (Sunpeng) Li
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 ---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
  2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
  
  struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector(

struct drm_atomic_state *state,
-   struct drm_crtc *crtc,
-   bool from_state_var)
+   struct drm_crtc *crtc)
  {
uint32_t i;
struct drm_connector_state *conn_state;
struct drm_connector *connector;
struct drm_crtc *crtc_from_state;
  
-	for_each_new_connector_in_state(

-   state,
-   connector,
-   conn_state,
-   i) {
-   crtc_from_state =
-   from_state_var ?
-   conn_state->crtc :
-   connector->state->crtc;
+   for_each_new_connector_in_state(state, connector, conn_state, i) {
+   crtc_from_state = conn_state->crtc;
  
  		if (crtc_from_state == crtc)

return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,
unsigned long flags;
  
  	/* update planes when needed */

-   for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+   for_each_old_plane_in_state(state, plane, old_plane_state, i) {
struct drm_plane_state *plane_state = plane->state;
struct drm_crtc *crtc = plane_state->crtc;
struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
dm_state = to_dm_atomic_state(state);
  
  	/* update changed items */

-   for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+   for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
struct drm_crtc_state *new_state = crtc->state;
  
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(

new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);
  
  			new_stream = new_acrtc_state->stream;

-   aconnector =
-   amdgpu_dm_find_first_crct_matching_connector(
+   aconnector = 
amdgpu_dm_find_first_crct_matching_connector(
state,
-   _crtcs[i]->base,
-   false);
+   _crtcs[i]->base);
if (!aconnector) {
DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
connector for acrtc id:%d "
 "skipping freesync init\n",
@@ -4151,7 +4141,7 @@ void amdgpu_dm_atomic_commit_tail(
}
  
  	/* Handle scaling and undersacn changes*/

-   for_each_new_connector_in_state(state, connector, old_conn_state, i) {
+   for_each_old_connector_in_state(state, connector, old_conn_state, i) {
struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);
struct dm_connector_state *con_new_state =
to_dm_connector_state(aconnector->base.state);
@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail(
}
  
  	/* update planes when needed per crtc*/

-   for_each_new_crtc_in_state(state, pcrtc, old_crtc_state, j) {
+   

Re: [PATCH 0/6] Use new DRM API where possible, and cleanups.

2017-10-13 Thread Harry Wentland
Patches 3-6 are
Reviewed-by: Harry Wentland 

Harry

On 2017-10-12 05:15 PM, sunpeng...@amd.com wrote:
> From: "Leo (Sunpeng) Li" 
> 
> Hi Dave,
> 
> This series reworks the previous patch. Patch 1 is a v2 of the previous,
> and additional patches are from the feedback received. They apply on top
> of your drm-next-amd-dc-staging branch.
> 
> Thanks,
> Leo
> 
> Leo (Sunpeng) Li (6):
>   drm/amd/display: Use DRM new-style object iterators.
>   drm/amd/display: Use new DRM API where possible
>   drm/amd/display: Unify DRM state variable namings.
>   drm/amd/display: Unify amdgpu_dm state variable namings.
>   drm/amd/display: Fix typo
>   drm/amd/display: Remove useless pcrtc pointer
> 
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 320 
> +++---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   3 +-
>  2 files changed, 156 insertions(+), 167 deletions(-)
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 6/6] drm/amd/display: Remove useless pcrtc pointer

2017-10-13 Thread Alex Deucher
On Thu, Oct 12, 2017 at 5:15 PM,   wrote:
> From: "Leo (Sunpeng) Li" 
>
> in amdgpu_dm_atomic_commit_tail. Just use crtc instead.
>
> Signed-off-by: Leo (Sunpeng) Li 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 67222ff..f9b5769 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4004,7 +4004,7 @@ void amdgpu_dm_atomic_commit_tail(
> struct dm_atomic_state *dm_state;
> uint32_t i, j;
> uint32_t new_crtcs_count = 0;
> -   struct drm_crtc *crtc, *pcrtc;
> +   struct drm_crtc *crtc;
> struct drm_crtc_state *old_crtc_state, *new_crtc_state;
> struct amdgpu_crtc *new_crtcs[MAX_STREAMS];
> struct dc_stream_state *new_stream = NULL;
> @@ -4200,11 +4200,11 @@ void amdgpu_dm_atomic_commit_tail(
> }
>
> /* update planes when needed per crtc*/
> -   for_each_new_crtc_in_state(state, pcrtc, new_crtc_state, j) {
> +   for_each_new_crtc_in_state(state, crtc, new_crtc_state, j) {
> dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
>
> if (dm_new_crtc_state->stream)
> -   amdgpu_dm_commit_planes(state, dev, dm, pcrtc, 
> _for_vblank);
> +   amdgpu_dm_commit_planes(state, dev, dm, crtc, 
> _for_vblank);
> }
>
>
> --
> 2.7.4
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 5/6] drm/amd/display: Fix typo

2017-10-13 Thread Alex Deucher
On Thu, Oct 12, 2017 at 5:15 PM,   wrote:
> From: "Leo (Sunpeng) Li" 
>
> undersacn -> underscan
>
> Signed-off-by: Leo (Sunpeng) Li 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index de88ee1..67222ff 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4144,7 +4144,7 @@ void amdgpu_dm_atomic_commit_tail(
> }
> }
>
> -   /* Handle scaling and undersacn changes*/
> +   /* Handle scaling and underscan changes*/
> for_each_oldnew_connector_in_state(state, connector, old_con_state, 
> new_con_state, i) {
> struct dm_connector_state *dm_new_con_state = 
> to_dm_connector_state(new_con_state);
> struct dm_connector_state *dm_old_con_state = 
> to_dm_connector_state(old_con_state);
> @@ -4707,7 +4707,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
>  if (ret)
>  goto fail;
>
> -   /* Check scaling and undersacn changes*/
> +   /* Check scaling and underscan changes*/
> /*TODO Removed scaling changes validation due to inability to commit
>  * new stream into context w\o causing full reset. Need to
>  * decide how to handle.
> --
> 2.7.4
>
> ___
> amd-gfx mailing list
> amd-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/6] drm/amd/display: Use new DRM API where possible

2017-10-13 Thread Harry Wentland
On 2017-10-12 05:15 PM, sunpeng...@amd.com wrote:
> From: "Leo (Sunpeng) Li" 
> 
> To conform to DRM's new API, we should not be accessing a DRM object's
> internal state directly. Rather, the DRM for_each_old/new_* iterators,
> and drm_atomic_get_old/new_* interface should be used.
> 
> This is an ongoing process. For now, update the DRM-facing atomic
> functions, where the atomic state object is given.
> 
> Signed-off-by: Leo (Sunpeng) Li 
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 131 
> +++---
>  1 file changed, 66 insertions(+), 65 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index cc024ab..d4426b3 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -3873,28 +3873,31 @@ static void amdgpu_dm_commit_planes(struct 
> drm_atomic_state *state,
>  {
>   uint32_t i;
>   struct drm_plane *plane;
> - struct drm_plane_state *old_plane_state;
> + struct drm_plane_state *old_plane_state, *new_plane_state;
>   struct dc_stream_state *dc_stream_attach;
>   struct dc_plane_state *plane_states_constructed[MAX_SURFACES];
>   struct amdgpu_crtc *acrtc_attach = to_amdgpu_crtc(pcrtc);
> - struct dm_crtc_state *acrtc_state = to_dm_crtc_state(pcrtc->state);
> + struct drm_crtc_state *new_pcrtc_state =
> + drm_atomic_get_new_crtc_state(state, pcrtc);
> + struct dm_crtc_state *acrtc_state = to_dm_crtc_state(new_pcrtc_state);
>   int planes_count = 0;
>   unsigned long flags;
>  
>   /* update planes when needed */
> - for_each_old_plane_in_state(state, plane, old_plane_state, i) {
> - struct drm_plane_state *plane_state = plane->state;
> - struct drm_crtc *crtc = plane_state->crtc;
> - struct drm_framebuffer *fb = plane_state->fb;
> + for_each_oldnew_plane_in_state(state, plane, old_plane_state, 
> new_plane_state, i) {
> + struct drm_crtc *crtc = new_plane_state->crtc;
> + struct drm_crtc_state *new_crtc_state =
> + drm_atomic_get_new_crtc_state(state, crtc);
> + struct drm_framebuffer *fb = new_plane_state->fb;
>   bool pflip_needed;
> - struct dm_plane_state *dm_plane_state = 
> to_dm_plane_state(plane_state);
> + struct dm_plane_state *dm_plane_state = 
> to_dm_plane_state(new_plane_state);
>  
>   if (plane->type == DRM_PLANE_TYPE_CURSOR) {
>   handle_cursor_update(plane, old_plane_state);
>   continue;
>   }
>  
> - if (!fb || !crtc || pcrtc != crtc || !crtc->state->active)
> + if (!fb || !crtc || pcrtc != crtc || !new_crtc_state->active)
>   continue;
>  
>   pflip_needed = !state->allow_modeset;
> @@ -3918,13 +3921,13 @@ static void amdgpu_dm_commit_planes(struct 
> drm_atomic_state *state,
>   dc_stream_attach = acrtc_state->stream;
>   planes_count++;
>  
> - } else if (crtc->state->planes_changed) {
> + } else if (new_crtc_state->planes_changed) {
>   /* Assume even ONE crtc with immediate flip means
>* entire can't wait for VBLANK
>* TODO Check if it's correct
>*/
>   *wait_for_vblank =
> - pcrtc->state->pageflip_flags & 
> DRM_MODE_PAGE_FLIP_ASYNC ?
> + new_pcrtc_state->pageflip_flags & 
> DRM_MODE_PAGE_FLIP_ASYNC ?
>   false : true;
>  
>   /* TODO: Needs rework for multiplane flip */
> @@ -3942,7 +3945,7 @@ static void amdgpu_dm_commit_planes(struct 
> drm_atomic_state *state,
>   if (planes_count) {
>   unsigned long flags;
>  
> - if (pcrtc->state->event) {
> + if (new_pcrtc_state->event) {
>  
>   drm_crtc_vblank_get(pcrtc);
>  
> @@ -3968,7 +3971,7 @@ int amdgpu_dm_atomic_commit(
>   bool nonblock)
>  {
>   struct drm_crtc *crtc;
> - struct drm_crtc_state *new_state;
> + struct drm_crtc_state *old_crtc_state, *new_state;
>   struct amdgpu_device *adev = dev->dev_private;
>   int i;
>  
> @@ -3979,8 +3982,8 @@ int amdgpu_dm_atomic_commit(
>* it will update crtc->dm_crtc_state->stream pointer which is used in
>* the ISRs.
>*/
> - for_each_new_crtc_in_state(state, crtc, new_state, i) {
> - struct dm_crtc_state *old_acrtc_state = 
> to_dm_crtc_state(crtc->state);
> + for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_state, 
> i) {
> + struct dm_crtc_state *old_acrtc_state = 
> 

Re: [PATCH v2 0/9] Exynos DRM: rewrite IPP subsystem and userspace API

2017-10-13 Thread Tobias Jakobi
Hello everyone,

I have finished some first (working) version of my mpv video backend for IPPv2.

You can find the tree here:
https://github.com/tobiasjakobi/mpv

I've also created some RFC pull request upstream, to get some input on the
current patches:
https://github.com/mpv-player/mpv/pull/4986

As you can see, a lot is currently missing, but at least the video presentation
(for YUV420) already works and shows good performance.

I have also cleaned up my ippv2 libdrm branch. Now it should just contain the
IPPv2 bits:
https://github.com/tobiasjakobi/libdrm/tree/ippv2

With best wishes,
Tobias



Marek Szyprowski wrote:
> Dear all,
> 
> This patchset performs complete rewrite of Exynos DRM IPP subsystem and
> its userspace API.
> 
> Why such rewrite is needed? Exynos DRM IPP API is over-engineered in
> general, but not really extensible on the other side. It is also buggy,
> with significant design flaws:
> - Userspace API covers memory-2-memory picture operations together with
>   CRTC writeback and duplicating features, which belongs to video plane.
> - Lack of support of the all required image formats (for example NV12
>   Samsung-tiled cannot be used due to lack of pixel format modifier
>   support).
> - Userspace API designed only to mimic hardware behaviour, not easy to
>   understand.
> - Lack of proper input validation in the core, drivers also didn't do that
>   correctly, so it was possible to set incorrect parameters and easil
>   trigger IOMMU fault or memory trash.
> - Drivers were partially disfunctional or supported only a subset of modes.
> 
> Due to the above limitations and issues the Exynos DRM IPP API was not
> used by any of the open-source projects. I assume that it is safe to remove
> this broken API without any damage to open-source community. All remaining
> users (mainly Tizen project related) will be updated to the new version.
> 
> This patchset changes Exynos DRM IPP subsystem to something useful. The
> userspace API is much simpler, state-less and easy to understand. Also
> the code of the core and driver is significantly smaller and easier to
> understand.
> 
> Patches were tested on Exynos4412 based Odroid U3 and Exynos5422
> Odroid XU3 boards, on top of Linux next-20170928 kernel.
> 
> Best regards
> Marek Szyprowski
> Samsung R Institute Poland
> 
> 
> Changelog:
> 
> v2:
> - fixed minor issues pointed by other developers:
>   * fixed possible null pointer dereferrence (Tobias)
>   * changed limits_size to limits_count (Tobias)
>   * renamed struct exynos_drm_ipp_format to drm_exynos_ipp_format (Andrzej)
>   * added proper return value from exynos_drm_ipp_get_res_ioctl when no IPP
> driver is present (Andrzej)
>   * properly aligned all uapi structures to be 32/64 bit safe (Emil)
>   * properly initialize all strucutres
> - added new Exynos Scaler driver from Andrzej Pietrasiewicz
> 
> v1: https://www.spinics.net/lists/linux-samsung-soc/msg60492.html
> - initial version of IPP v2
> 
> My previous works in this area:
> 
> "[RFC v2 0/2] Exynos DRM: add Picture Processor extension"
> https://www.spinics.net/lists/dri-devel/msg140669.html
> - removed usage of DRM objects and properties - replaced them with simple
>   list of parameters with predefined IDs
> 
> "[RFC 0/4] Exynos DRM: add Picture Processor extension"
> https://www.spinics.net/lists/linux-samsung-soc/msg59323.html
> - moved this feature from DRM core to Exynos DRM driver
> - changed name from framebuffer processor to picture processor
> - simplified code to cover only things needed by Exynos drivers
> - implemented simple fifo task scheduler
> - cleaned up rotator driver conversion (removed IPP remainings)
> 
> "[RFC 0/2] New feature: Framebuffer processors"
> https://www.spinics.net/lists/linux-samsung-soc/msg54810.html
> - generic approach implemented in DRM core, rejected
> 
> 
> Patch summary:
> 
> Andrzej Pietrasiewicz (3):
>   drm/exynos: Add driver for Exynos Scaler module
>   drivers: clk: samsung: Fix m2m scaler clock on Exynos542x
>   ARM: dts: exynos: Add mem-2-mem Scaler devices
> 
> Marek Szyprowski (6):
>   drm/exynos: ipp: Remove Exynos DRM IPP subsystem
>   drm/exynos: ipp: Add IPP v2 framework
>   drm/exynos: rotator: Convert driver to IPP v2 core API
>   drm/exynos: gsc: Convert driver to IPP v2 core API
>   drm/exynos: Add generic support for devices shared with V4L2 subsystem
>   drm/exynos: fimc: Convert driver to IPP v2 core API
> 
>  .../devicetree/bindings/gpu/samsung-scaler.txt |   25 +
>  arch/arm/boot/dts/exynos5420.dtsi  |   35 +
>  drivers/clk/samsung/clk-exynos5420.c   |2 +-
>  drivers/gpu/drm/exynos/Kconfig |   18 +-
>  drivers/gpu/drm/exynos/Makefile|1 +
>  drivers/gpu/drm/exynos/exynos_drm_drv.c|   36 +-
>  drivers/gpu/drm/exynos/exynos_drm_drv.h|5 +-
>  drivers/gpu/drm/exynos/exynos_drm_fimc.c   |  893 +++-
>  drivers/gpu/drm/exynos/exynos_drm_fimc.h   

Re: [PATCH v2 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Andrey Grodzovsky



On 10/13/2017 11:41 AM, Leo wrote:



On 2017-10-13 11:03 AM, Andrey Grodzovsky wrote:



On 10/12/2017 05:15 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li"

Use the correct for_each_new/old_* iterators instead of for_each_*

List of affected functions:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
 - Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
 - drm_atomic_helper_duplicate_state is called during suspend to
   cache the state
 - It sets 'state' within the state triplet to 'new_state'


It seems to me you missed that one.

Thanks,
Andrey



Good catch, seems like that change was stripped out while I was cp-ing
from the internal tree. Some changes in this function have not been 
promoted to Dave's branch yet.


I'll remove this comment for now, I think it makes sense to have a 
follow-up patch to this after more changes have been promoted.


Thanks,
Leo


With that fixed the change is Reviewed-by: Andrey Grodzovsky 





amdgpu_dm_commit_planes: use for_each_old
 - Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
 - Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
 - Called after the state was swapped

dm_update_crtcs_state: use for_each_new
 - Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
 - Called before the state is swapped

v2: Split out typo fixes to a new patch.

Signed-off-by: Leo (Sunpeng) Li
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 
---

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
  2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
  struct amdgpu_dm_connector 
*amdgpu_dm_find_first_crct_matching_connector(

  struct drm_atomic_state *state,
-struct drm_crtc *crtc,
-bool from_state_var)
+struct drm_crtc *crtc)
  {
  uint32_t i;
  struct drm_connector_state *conn_state;
  struct drm_connector *connector;
  struct drm_crtc *crtc_from_state;
-for_each_new_connector_in_state(
-state,
-connector,
-conn_state,
-i) {
-crtc_from_state =
-from_state_var ?
-conn_state->crtc :
-connector->state->crtc;
+for_each_new_connector_in_state(state, connector, conn_state, i) {
+crtc_from_state = conn_state->crtc;
  if (crtc_from_state == crtc)
  return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,

  unsigned long flags;
  /* update planes when needed */
-for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+for_each_old_plane_in_state(state, plane, old_plane_state, i) {
  struct drm_plane_state *plane_state = plane->state;
  struct drm_crtc *crtc = plane_state->crtc;
  struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
  dm_state = to_dm_atomic_state(state);
  /* update changed items */
-for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
  struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
  struct drm_crtc_state *new_state = crtc->state;
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(
  new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);

  new_stream = new_acrtc_state->stream;
-aconnector =
-amdgpu_dm_find_first_crct_matching_connector(
+aconnector = amdgpu_dm_find_first_crct_matching_connector(
  state,
-_crtcs[i]->base,
-false);
+_crtcs[i]->base);
  if (!aconnector) {
  DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
connector for acrtc id:%d "

   "skipping freesync init\n",
@@ -4151,7 +4141,7 @@ void amdgpu_dm_atomic_commit_tail(
  }
  /* Handle scaling and undersacn changes*/
-for_each_new_connector_in_state(state, connector, 
old_conn_state, i) {
+for_each_old_connector_in_state(state, connector, 
old_conn_state, i) {
  struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);

  struct dm_connector_state *con_new_state =
to_dm_connector_state(aconnector->base.state);
@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail(

Re: [Outreachy kernel] [PATCH] drm/amd/powerplay: Remove unnecessary cast on void pointer

2017-10-13 Thread Julia Lawall


On Fri, 13 Oct 2017, Harsha Sharma wrote:

> Done with following coccinelle patch
>
> @r@
> expression x;
> void* e;
> type T;
> identifier f;
> @@
> (
>   *((T *)e)
> |
>   ((T *)x)[...]
> |
>   ((T*)x)->f
> |
>
> - (T*)
>   e
> )
>
> Signed-off-by: Harsha Sharma 
> ---
>  drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c|  6 +++---
>  drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c   |  8 
>  drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c  |  2 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c|  6 +++---
>  drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c |  2 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c  | 18 +-
>  drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c|  4 ++--
>  drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c| 12 ++--
>  drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c  |  2 +-
>  9 files changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> index bc839ff0bdd0..897f22f3 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
> @@ -474,7 +474,7 @@ static int cz_tf_upload_pptable_to_smu(struct pp_hwmgr 
> *hwmgr, void *input,
>   PP_ASSERT_WITH_CODE((0 == ret && NULL != table),
>   "Fail to get clock table from SMU!", return 
> -EINVAL;);
>
> - clock_table = (struct SMU8_Fusion_ClkTable *)table;
> + clock_table = table;
>
>   /* patch clock table */
>   PP_ASSERT_WITH_CODE((vddc_table->count <= CZ_MAX_HARDWARE_POWERLEVELS),
> @@ -868,8 +868,8 @@ static int cz_tf_update_low_mem_pstate(struct pp_hwmgr 
> *hwmgr,
>  {
>   bool disable_switch;
>   bool enable_low_mem_state;
> - struct cz_hwmgr *hw_data = (struct cz_hwmgr *)(hwmgr->backend);
> - const struct phm_set_power_state_input *states = (struct 
> phm_set_power_state_input *)input;
> + struct cz_hwmgr *hw_data = (hwmgr->backend);
> + const struct phm_set_power_state_input *states = input;
>   const struct cz_power_state *pnew_state = 
> cast_const_PhwCzPowerState(states->pnew_state);
>
>   if (hw_data->sys_info.nb_dpm_enable) {
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
> index 9547f265a8bb..5d63a1b18b39 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
> @@ -469,7 +469,7 @@ int phm_reset_single_dpm_table(void *table,
>  {
>   int i;
>
> - struct vi_dpm_table *dpm_table = (struct vi_dpm_table *)table;
> + struct vi_dpm_table *dpm_table = table;
>
>   dpm_table->count = count > max ? max : count;
>
> @@ -484,7 +484,7 @@ void phm_setup_pcie_table_entry(
>   uint32_t index, uint32_t pcie_gen,
>   uint32_t pcie_lanes)
>  {
> - struct vi_dpm_table *dpm_table = (struct vi_dpm_table *)table;
> + struct vi_dpm_table *dpm_table = table;
>   dpm_table->dpm_level[index].value = pcie_gen;
>   dpm_table->dpm_level[index].param1 = pcie_lanes;
>   dpm_table->dpm_level[index].enabled = 1;
> @@ -494,7 +494,7 @@ int32_t phm_get_dpm_level_enable_mask_value(void *table)
>  {
>   int32_t i;
>   int32_t mask = 0;
> - struct vi_dpm_table *dpm_table = (struct vi_dpm_table *)table;
> + struct vi_dpm_table *dpm_table = table;
>
>   for (i = dpm_table->count; i > 0; i--) {
>   mask = mask << 1;
> @@ -566,7 +566,7 @@ int phm_find_boot_level(void *table,
>  {
>   int result = -EINVAL;
>   uint32_t i;
> - struct vi_dpm_table *dpm_table = (struct vi_dpm_table *)table;
> + struct vi_dpm_table *dpm_table = table;
>
>   for (i = 0; i < dpm_table->count; i++) {
>   if (value == dpm_table->dpm_level[i].value) {
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
> index 953e0c9ad7cd..676f2e8bb2ee 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomctrl.c
> @@ -579,7 +579,7 @@ static ATOM_GPIO_PIN_LUT *get_gpio_lookup_table(void 
> *device)
>   PP_ASSERT_WITH_CODE((NULL != table_address),
>   "Error retrieving BIOS Table Address!", return NULL;);
>
> - return (ATOM_GPIO_PIN_LUT *)table_address;
> + return table_address;
>  }
>
>  /**
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c 
> b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
> index c062844b15f3..05e3f5302994 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
> @@ -66,7 +66,7 @@ static struct atom_voltage_objects_info_v4_1 
> *pp_atomfwctrl_get_voltage_info_tab
>  "Error retrieving BIOS Table Address!",
>  return NULL);
>
> -return (struct 

Re: [PATCH] drm/tinydrm: Remove explicit .best_encoder assignment

2017-10-13 Thread Noralf Trønnes


Den 10.10.2017 22.58, skrev Haneen Mohammed:

Since the driver is relying on the atomic helpers, remove the explicit
.best_encoder assignment and let the core call
drm_atomic_helper_best_encoder().

Signed-off-by: Haneen Mohammed 
---


Thanks, applied to drm-misc.

Noralf.


  drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c | 1 -
  1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c 
b/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
index 177e9d8..bc55de2 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-pipe.c
@@ -50,7 +50,6 @@ static int tinydrm_connector_get_modes(struct drm_connector 
*connector)
  
  static const struct drm_connector_helper_funcs tinydrm_connector_hfuncs = {

.get_modes = tinydrm_connector_get_modes,
-   .best_encoder = drm_atomic_helper_best_encoder,
  };
  
  static enum drm_connector_status


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3] drm/tinydrm: Replace dev_error with DRM_DEV_ERROR

2017-10-13 Thread Noralf Trønnes


Den 07.10.2017 00.17, skrev Harsha Sharma:

Convert instances of dev_error to DRM_DEV_ERROR as we have
DRM_DEV_ERROR variants of drm print macros.

Signed-off-by: Harsha Sharma 
---


Thanks, applied to drm-misc.

Noralf.


Changes in v3:
  -Solve merge conflicts
Changes in v2:
  -Fix alignment issues
  drivers/gpu/drm/tinydrm/mi0283qt.c |  8 
  drivers/gpu/drm/tinydrm/repaper.c  | 28 +---
  drivers/gpu/drm/tinydrm/st7586.c   |  6 +++---
  3 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c 
b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 7e5bb7d6f655..7dded506ba8c 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -31,7 +31,7 @@ static int mi0283qt_init(struct mipi_dbi *mipi)
  
  	ret = regulator_enable(mipi->regulator);

if (ret) {
-   dev_err(dev, "Failed to enable regulator %d\n", ret);
+   DRM_DEV_ERROR(dev, "Failed to enable regulator %d\n", ret);
return ret;
}
  
@@ -42,7 +42,7 @@ static int mi0283qt_init(struct mipi_dbi *mipi)

mipi_dbi_hw_reset(mipi);
ret = mipi_dbi_command(mipi, MIPI_DCS_SOFT_RESET);
if (ret) {
-   dev_err(dev, "Error sending command %d\n", ret);
+   DRM_DEV_ERROR(dev, "Error sending command %d\n", ret);
regulator_disable(mipi->regulator);
return ret;
}
@@ -175,13 +175,13 @@ static int mi0283qt_probe(struct spi_device *spi)
  
  	mipi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);

if (IS_ERR(mipi->reset)) {
-   dev_err(dev, "Failed to get gpio 'reset'\n");
+   DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n");
return PTR_ERR(mipi->reset);
}
  
  	dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW);

if (IS_ERR(dc)) {
-   dev_err(dev, "Failed to get gpio 'dc'\n");
+   DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n");
return PTR_ERR(dc);
}
  
diff --git a/drivers/gpu/drm/tinydrm/repaper.c b/drivers/gpu/drm/tinydrm/repaper.c

index 30dc97b3ff21..028d428d4ab9 100644
--- a/drivers/gpu/drm/tinydrm/repaper.c
+++ b/drivers/gpu/drm/tinydrm/repaper.c
@@ -473,8 +473,7 @@ static void repaper_get_temperature(struct repaper_epd *epd)
  
  	ret = thermal_zone_get_temp(epd->thermal, );

if (ret) {
-   dev_err(>spi->dev, "Failed to get temperature (%d)\n",
-   ret);
+   DRM_DEV_ERROR(>spi->dev, "Failed to get temperature 
(%d)\n", ret);
return;
}
  
@@ -629,7 +628,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,

mutex_unlock(>dirty_lock);
  
  	if (ret)

-   dev_err(fb->dev->dev, "Failed to update display (%d)\n", ret);
+   DRM_DEV_ERROR(fb->dev->dev, "Failed to update display (%d)\n", 
ret);
kfree(buf);
  
  	return ret;

@@ -703,7 +702,7 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
}
  
  	if (!i) {

-   dev_err(dev, "timeout waiting for panel to become ready.\n");
+   DRM_DEV_ERROR(dev, "timeout waiting for panel to become 
ready.\n");
power_off(epd);
return;
}
@@ -725,9 +724,9 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
ret = repaper_read_val(spi, 0x0f);
if (ret < 0 || !(ret & 0x80)) {
if (ret < 0)
-   dev_err(dev, "failed to read chip (%d)\n", ret);
+   DRM_DEV_ERROR(dev, "failed to read chip (%d)\n", ret);
else
-   dev_err(dev, "panel is reported broken\n");
+   DRM_DEV_ERROR(dev, "panel is reported broken\n");
power_off(epd);
return;
}
@@ -767,7 +766,7 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
/* check DC/DC */
ret = repaper_read_val(spi, 0x0f);
if (ret < 0) {
-   dev_err(dev, "failed to read chip (%d)\n", ret);
+   DRM_DEV_ERROR(dev, "failed to read chip (%d)\n", ret);
power_off(epd);
return;
}
@@ -779,7 +778,7 @@ static void repaper_pipe_enable(struct 
drm_simple_display_pipe *pipe,
}
  
  	if (!dc_ok) {

-   dev_err(dev, "dc/dc failed\n");
+   DRM_DEV_ERROR(dev, "dc/dc failed\n");
power_off(epd);
return;
}
@@ -959,7 +958,7 @@ static int repaper_probe(struct spi_device *spi)
if (IS_ERR(epd->panel_on)) {
ret = PTR_ERR(epd->panel_on);
if (ret != -EPROBE_DEFER)
-   dev_err(dev, "Failed to get gpio 'panel-on'\n");
+   

Re: [PATCH v2 1/6] drm/amd/display: Use DRM new-style object iterators.

2017-10-13 Thread Leo



On 2017-10-13 11:03 AM, Andrey Grodzovsky wrote:



On 10/12/2017 05:15 PM, sunpeng...@amd.com wrote:

From: "Leo (Sunpeng) Li"

Use the correct for_each_new/old_* iterators instead of for_each_*

List of affected functions:

amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
 - Old from_state_var flag was always choosing the new state

amdgpu_dm_display_resume: use for_each_new
 - drm_atomic_helper_duplicate_state is called during suspend to
   cache the state
 - It sets 'state' within the state triplet to 'new_state'


It seems to me you missed that one.

Thanks,
Andrey



Good catch, seems like that change was stripped out while I was cp-ing
from the internal tree. Some changes in this function have not been 
promoted to Dave's branch yet.


I'll remove this comment for now, I think it makes sense to have a 
follow-up patch to this after more changes have been promoted.


Thanks,
Leo



amdgpu_dm_commit_planes: use for_each_old
 - Called after the state was swapped (via atomic commit tail)

amdgpu_dm_atomic_commit: use for_each_new
 - Called before the state is swapped

amdgpu_dm_atomic_commit_tail: use for_each_old
 - Called after the state was swapped

dm_update_crtcs_state: use for_each_new
 - Called before the state is swapped (via atomic check)

amdgpu_dm_atomic_check: use for_each_new
 - Called before the state is swapped

v2: Split out typo fixes to a new patch.

Signed-off-by: Leo (Sunpeng) Li
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 
---

  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 +--
  2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 9bfe1f9..cc024ab 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -570,23 +570,15 @@ static int dm_suspend(void *handle)
  struct amdgpu_dm_connector 
*amdgpu_dm_find_first_crct_matching_connector(

  struct drm_atomic_state *state,
-    struct drm_crtc *crtc,
-    bool from_state_var)
+    struct drm_crtc *crtc)
  {
  uint32_t i;
  struct drm_connector_state *conn_state;
  struct drm_connector *connector;
  struct drm_crtc *crtc_from_state;
-    for_each_new_connector_in_state(
-    state,
-    connector,
-    conn_state,
-    i) {
-    crtc_from_state =
-    from_state_var ?
-    conn_state->crtc :
-    connector->state->crtc;
+    for_each_new_connector_in_state(state, connector, conn_state, i) {
+    crtc_from_state = conn_state->crtc;
  if (crtc_from_state == crtc)
  return to_amdgpu_dm_connector(connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct 
drm_atomic_state *state,

  unsigned long flags;
  /* update planes when needed */
-    for_each_new_plane_in_state(state, plane, old_plane_state, i) {
+    for_each_old_plane_in_state(state, plane, old_plane_state, i) {
  struct drm_plane_state *plane_state = plane->state;
  struct drm_crtc *crtc = plane_state->crtc;
  struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail(
  dm_state = to_dm_atomic_state(state);
  /* update changed items */
-    for_each_new_crtc_in_state(state, crtc, old_crtc_state, i) {
+    for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
  struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
  struct drm_crtc_state *new_state = crtc->state;
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail(
  new_acrtc_state = 
to_dm_crtc_state(new_crtcs[i]->base.state);

  new_stream = new_acrtc_state->stream;
-    aconnector =
-    amdgpu_dm_find_first_crct_matching_connector(
+    aconnector = amdgpu_dm_find_first_crct_matching_connector(
  state,
-    _crtcs[i]->base,
-    false);
+    _crtcs[i]->base);
  if (!aconnector) {
  DRM_DEBUG_DRIVER("Atomic commit: Failed to find 
connector for acrtc id:%d "

   "skipping freesync init\n",
@@ -4151,7 +4141,7 @@ void amdgpu_dm_atomic_commit_tail(
  }
  /* Handle scaling and undersacn changes*/
-    for_each_new_connector_in_state(state, connector, old_conn_state, 
i) {
+    for_each_old_connector_in_state(state, connector, old_conn_state, 
i) {
  struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);

  struct dm_connector_state *con_new_state =
  to_dm_connector_state(aconnector->base.state);
@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail(
  }
  /* update planes when needed per crtc*/
-    for_each_new_crtc_in_state(state, pcrtc, old_crtc_state, 

Re: tracing, dma-buf: Remove unused trace event dma_fence_annotate_wait_on

2017-10-13 Thread Christian König

Am 13.10.2017 um 16:06 schrieb Steven Rostedt:

From: Steven Rostedt (VMware) 

Commit e941759c74 ("fence: dma-buf cross-device synchronization") added
trace event fence_annotate_wait_on, but never used it. It was renamed
to dma_fence_annotate_wait_on by commit f54d186700 ("dma-buf: Rename
struct fence to dma_fence") but still not used. As defined trace events
have data structures and functions created for them, it is a waste of
memory if they are not used. Remove the unused trace event.

Signed-off-by: Steven Rostedt (VMware) 


Reviewed-by: Christian König 


---
Index: linux-trace.git/drivers/dma-buf/dma-fence.c
===
--- linux-trace.git.orig/drivers/dma-buf/dma-fence.c
+++ linux-trace.git/drivers/dma-buf/dma-fence.c
@@ -27,7 +27,6 @@
  #define CREATE_TRACE_POINTS
  #include 
  
-EXPORT_TRACEPOINT_SYMBOL(dma_fence_annotate_wait_on);

  EXPORT_TRACEPOINT_SYMBOL(dma_fence_emit);
  EXPORT_TRACEPOINT_SYMBOL(dma_fence_enable_signal);
  
Index: linux-trace.git/include/trace/events/dma_fence.h

===
--- linux-trace.git.orig/include/trace/events/dma_fence.h
+++ linux-trace.git/include/trace/events/dma_fence.h
@@ -8,46 +8,6 @@
  
  struct dma_fence;
  
-TRACE_EVENT(dma_fence_annotate_wait_on,

-
-   /* fence: the fence waiting on f1, f1: the fence to be waited on. */
-   TP_PROTO(struct dma_fence *fence, struct dma_fence *f1),
-
-   TP_ARGS(fence, f1),
-
-   TP_STRUCT__entry(
-   __string(driver, fence->ops->get_driver_name(fence))
-   __string(timeline, fence->ops->get_timeline_name(fence))
-   __field(unsigned int, context)
-   __field(unsigned int, seqno)
-
-   __string(waiting_driver, f1->ops->get_driver_name(f1))
-   __string(waiting_timeline, f1->ops->get_timeline_name(f1))
-   __field(unsigned int, waiting_context)
-   __field(unsigned int, waiting_seqno)
-   ),
-
-   TP_fast_assign(
-   __assign_str(driver, fence->ops->get_driver_name(fence))
-   __assign_str(timeline, fence->ops->get_timeline_name(fence))
-   __entry->context = fence->context;
-   __entry->seqno = fence->seqno;
-
-   __assign_str(waiting_driver, f1->ops->get_driver_name(f1))
-   __assign_str(waiting_timeline, f1->ops->get_timeline_name(f1))
-   __entry->waiting_context = f1->context;
-   __entry->waiting_seqno = f1->seqno;
-
-   ),
-
-   TP_printk("driver=%s timeline=%s context=%u seqno=%u "\
- "waits on driver=%s timeline=%s context=%u seqno=%u",
- __get_str(driver), __get_str(timeline), __entry->context,
- __entry->seqno,
- __get_str(waiting_driver), __get_str(waiting_timeline),
- __entry->waiting_context, __entry->waiting_seqno)
-);
-
  DECLARE_EVENT_CLASS(dma_fence,
  
  	TP_PROTO(struct dma_fence *fence),

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/2] drm/udl: Reading all edid blocks in DRM/UDL driver

2017-10-13 Thread Alex Deucher
On Thu, Oct 12, 2017 at 8:13 PM, Robert Tarasov
 wrote:
> Now DRM/UDL driver retreives all edid data blocks instead of only base one.
> Previous approch could lead to improper initialization of video mode with
> certain monitors.
>
> Signed-off-by: Robert Tarasov 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/udl/udl_connector.c | 106 
> +++-
>  1 file changed, 68 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/udl/udl_connector.c 
> b/drivers/gpu/drm/udl/udl_connector.c
> index 6a9250ac8f29..c3dc1fd20cb4 100644
> --- a/drivers/gpu/drm/udl/udl_connector.c
> +++ b/drivers/gpu/drm/udl/udl_connector.c
> @@ -17,42 +17,79 @@
>  #include "udl_connector.h"
>  #include "udl_drv.h"
>
> -/* dummy connector to just get EDID,
> -   all UDL appear to have a DVI-D */
> -
> -static u8 *udl_get_edid(struct udl_device *udl)
> +static bool udl_get_edid_block(struct udl_device *udl, int block_idx,
> +  u8 *buff)
>  {
> -   u8 *block;
> -   char *rbuf;
> int ret, i;
> +   u8 *read_buff;
>
> -   block = kmalloc(EDID_LENGTH, GFP_KERNEL);
> -   if (block == NULL)
> -   return NULL;
> -
> -   rbuf = kmalloc(2, GFP_KERNEL);
> -   if (rbuf == NULL)
> -   goto error;
> +   read_buff = kmalloc(2, GFP_KERNEL);
> +   if (!read_buff)
> +   return false;
>
> for (i = 0; i < EDID_LENGTH; i++) {
> +   int bval = (i + block_idx * EDID_LENGTH) << 8;
> ret = usb_control_msg(udl->udev,
> - usb_rcvctrlpipe(udl->udev, 0), (0x02),
> - (0x80 | (0x02 << 5)), i << 8, 0xA1, 
> rbuf, 2,
> - HZ);
> + usb_rcvctrlpipe(udl->udev, 0),
> + (0x02), (0x80 | (0x02 << 5)), bval,
> + 0xA1, read_buff, 2, HZ);
> if (ret < 1) {
> DRM_ERROR("Read EDID byte %d failed err %x\n", i, 
> ret);
> -   goto error;
> +   kfree(read_buff);
> +   return false;
> }
> -   block[i] = rbuf[1];
> +   buff[i] = read_buff[1];
> }
>
> -   kfree(rbuf);
> -   return block;
> +   kfree(read_buff);
> +   return true;
> +}
>
> -error:
> -   kfree(block);
> -   kfree(rbuf);
> -   return NULL;
> +static bool udl_get_edid(struct udl_device *udl, u8 **result_buff,
> +int *result_buff_size)
> +{
> +   int i, extensions;
> +   u8 *block_buff = NULL, *buff_ptr;
> +
> +   block_buff = kmalloc(EDID_LENGTH, GFP_KERNEL);
> +   if (block_buff == NULL)
> +   return false;
> +
> +   if (udl_get_edid_block(udl, 0, block_buff) &&
> +   memchr_inv(block_buff, 0, EDID_LENGTH)) {
> +   extensions = ((struct edid *)block_buff)->extensions;
> +   if (extensions > 0) {
> +   /* we have to read all extensions one by one */
> +   *result_buff_size = EDID_LENGTH * (extensions + 1);
> +   *result_buff = kmalloc(*result_buff_size, GFP_KERNEL);
> +   buff_ptr = *result_buff;
> +   if (buff_ptr == NULL) {
> +   kfree(block_buff);
> +   return false;
> +   }
> +   memcpy(buff_ptr, block_buff, EDID_LENGTH);
> +   kfree(block_buff);
> +   buff_ptr += EDID_LENGTH;
> +   for (i = 1; i < extensions; ++i) {
> +   if (udl_get_edid_block(udl, i, buff_ptr)) {
> +   buff_ptr += EDID_LENGTH;
> +   } else {
> +   kfree(*result_buff);
> +   *result_buff = NULL;
> +   return false;
> +   }
> +   }
> +   return true;
> +   }
> +   /* we have only base edid block */
> +   *result_buff = block_buff;
> +   *result_buff_size = EDID_LENGTH;
> +   return true;
> +   }
> +
> +   kfree(block_buff);
> +
> +   return false;
>  }
>
>  static int udl_get_modes(struct drm_connector *connector)
> @@ -84,33 +121,26 @@ static int udl_mode_valid(struct drm_connector 
> *connector,
>  static enum drm_connector_status
>  udl_detect(struct drm_connector *connector, bool force)
>  {
> -   struct edid *edid;
> +   u8 *edid_buff = NULL;
> +   int edid_buff_size = 0;
> 

Re: [PATCH 1/2] drm/udl: Fixed problem with UDL adpater reconnection

2017-10-13 Thread Alex Deucher
On Thu, Oct 12, 2017 at 8:13 PM, Robert Tarasov
 wrote:
> Fixed problem with DisplayLink and DisplayLink certified adapers in drm/udl
> driver when adapter doesn't want to work if it was initialized with
> disconnected DVI cable by enabling drm connectot polling and updating
> current connector's state.
>
> Signed-off-by: Robert Tarasov 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/udl/udl_connector.c | 76 
> -
>  drivers/gpu/drm/udl/udl_connector.h | 13 +++
>  drivers/gpu/drm/udl/udl_drv.c   |  4 ++
>  drivers/gpu/drm/udl/udl_main.c  |  5 +++
>  4 files changed, 72 insertions(+), 26 deletions(-)
>  create mode 100644 drivers/gpu/drm/udl/udl_connector.h
>
> diff --git a/drivers/gpu/drm/udl/udl_connector.c 
> b/drivers/gpu/drm/udl/udl_connector.c
> index 091ca81658eb..6a9250ac8f29 100644
> --- a/drivers/gpu/drm/udl/udl_connector.c
> +++ b/drivers/gpu/drm/udl/udl_connector.c
> @@ -14,6 +14,7 @@
>  #include 
>  #include 
>  #include 
> +#include "udl_connector.h"
>  #include "udl_drv.h"
>
>  /* dummy connector to just get EDID,
> @@ -56,28 +57,15 @@ static u8 *udl_get_edid(struct udl_device *udl)
>
>  static int udl_get_modes(struct drm_connector *connector)
>  {
> -   struct udl_device *udl = connector->dev->dev_private;
> -   struct edid *edid;
> -   int ret;
> -
> -   edid = (struct edid *)udl_get_edid(udl);
> -   if (!edid) {
> -   drm_mode_connector_update_edid_property(connector, NULL);
> -   return 0;
> -   }
> -
> -   /*
> -* We only read the main block, but if the monitor reports extension
> -* blocks then the drm edid code expects them to be present, so patch
> -* the extension count to 0.
> -*/
> -   edid->checksum += edid->extensions;
> -   edid->extensions = 0;
> -
> -   drm_mode_connector_update_edid_property(connector, edid);
> -   ret = drm_add_edid_modes(connector, edid);
> -   kfree(edid);
> -   return ret;
> +   struct udl_drm_connector *udl_connector =
> +   container_of(connector,
> +   struct udl_drm_connector,
> +   connector);
> +
> +   drm_mode_connector_update_edid_property(connector, 
> udl_connector->edid);
> +   if (udl_connector->edid)
> +   return drm_add_edid_modes(connector, udl_connector->edid);
> +   return 0;
>  }
>
>  static int udl_mode_valid(struct drm_connector *connector,
> @@ -96,8 +84,33 @@ static int udl_mode_valid(struct drm_connector *connector,
>  static enum drm_connector_status
>  udl_detect(struct drm_connector *connector, bool force)
>  {
> -   if (drm_dev_is_unplugged(connector->dev))
> +   struct edid *edid;
> +   struct udl_device *udl = connector->dev->dev_private;
> +   struct udl_drm_connector *udl_connector =
> +   container_of(connector,
> +   struct udl_drm_connector,
> +   connector);
> +
> +   if (udl_connector->edid != NULL) {
> +   kfree(udl_connector->edid);
> +   udl_connector->edid = NULL;
> +   }
> +
> +   edid = (struct edid *)udl_get_edid(udl);
> +   if (!edid || !memchr_inv(edid, 0, EDID_LENGTH))
> return connector_status_disconnected;
> +
> +   udl_connector->edid = edid;
> +
> +   /*
> +* We only read the main block, but if the monitor reports extension
> +* blocks then the drm edid code expects them to be present, so patch
> +* the extension count to 0.
> +*/
> +   udl_connector->edid->checksum +=
> +   udl_connector->edid->extensions;
> +   udl_connector->edid->extensions = 0;
> +
> return connector_status_connected;
>  }
>
> @@ -117,8 +130,14 @@ static int udl_connector_set_property(struct 
> drm_connector *connector,
>
>  static void udl_connector_destroy(struct drm_connector *connector)
>  {
> +   struct udl_drm_connector *udl_connector =
> +   container_of(connector,
> +   struct udl_drm_connector,
> +   connector);
> +
> drm_connector_unregister(connector);
> drm_connector_cleanup(connector);
> +   kfree(udl_connector->edid);
> kfree(connector);
>  }
>
> @@ -138,17 +157,22 @@ static const struct drm_connector_funcs 
> udl_connector_funcs = {
>
>  int udl_connector_init(struct drm_device *dev, struct drm_encoder *encoder)
>  {
> +   struct udl_drm_connector *udl_connector;
> struct drm_connector *connector;
>
> -   connector = kzalloc(sizeof(struct drm_connector), GFP_KERNEL);
> -   if (!connector)
> +   udl_connector = kzalloc(sizeof(struct 

[PATCH 48/48] drm: omapdrm: dss: Store the registered plls array in struct dss_device

2017-10-13 Thread Laurent Pinchart
As part of an effort to remove the usage of global variables in the
driver, store the registered plls array in the dss_device structure
instead of a global variable.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c |  4 ++--
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 17 +++---
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  3 +--
 drivers/gpu/drm/omapdrm/dss/dss.h   | 12 +-
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  |  3 +--
 drivers/gpu/drm/omapdrm/dss/pll.c   | 40 +
 drivers/gpu/drm/omapdrm/dss/video-pll.c |  3 +--
 7 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 5eacf4cdac54..181a8ea072b1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -3252,7 +3252,7 @@ static unsigned long dispc_fclk_rate(struct dispc_device 
*dispc)
struct dss_pll *pll;
unsigned int clkout_idx;
 
-   pll = dss_pll_find_by_src(src);
+   pll = dss_pll_find_by_src(dispc->dss, src);
clkout_idx = dss_pll_get_clkout_idx_for_src(src);
 
r = pll->cinfo.clkout[clkout_idx];
@@ -3280,7 +3280,7 @@ static unsigned long dispc_mgr_lclk_rate(struct 
dispc_device *dispc,
struct dss_pll *pll;
unsigned int clkout_idx;
 
-   pll = dss_pll_find_by_src(src);
+   pll = dss_pll_find_by_src(dispc->dss, src);
clkout_idx = dss_pll_get_clkout_idx_for_src(src);
 
r = pll->cinfo.clkout[clkout_idx];
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 66183fc77bb2..2fb9406d2059 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -60,7 +60,8 @@ static struct dpi_data *dpi_get_data_from_dssdev(struct 
omap_dss_device *dssdev)
return container_of(dssdev, struct dpi_data, output);
 }
 
-static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel)
+static enum dss_clk_source dpi_get_clk_src_dra7xx(struct dpi_data *dpi,
+ enum omap_channel channel)
 {
/*
 * Possible clock sources:
@@ -72,23 +73,23 @@ static enum dss_clk_source dpi_get_clk_src_dra7xx(enum 
omap_channel channel)
switch (channel) {
case OMAP_DSS_CHANNEL_LCD:
{
-   if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_1))
+   if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_1))
return DSS_CLK_SRC_PLL1_1;
break;
}
case OMAP_DSS_CHANNEL_LCD2:
{
-   if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3))
+   if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3))
return DSS_CLK_SRC_PLL1_3;
-   if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_3))
+   if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL2_3))
return DSS_CLK_SRC_PLL2_3;
break;
}
case OMAP_DSS_CHANNEL_LCD3:
{
-   if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_1))
+   if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL2_1))
return DSS_CLK_SRC_PLL2_1;
-   if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3))
+   if (dss_pll_find_by_src(dpi->dss, DSS_CLK_SRC_PLL1_3))
return DSS_CLK_SRC_PLL1_3;
break;
}
@@ -135,7 +136,7 @@ static enum dss_clk_source dpi_get_clk_src(struct dpi_data 
*dpi)
}
 
case DSS_MODEL_DRA7:
-   return dpi_get_clk_src_dra7xx(channel);
+   return dpi_get_clk_src_dra7xx(dpi, channel);
 
default:
return DSS_CLK_SRC_FCK;
@@ -603,7 +604,7 @@ static void dpi_init_pll(struct dpi_data *dpi)
 
dpi->clk_src = dpi_get_clk_src(dpi);
 
-   pll = dss_pll_find_by_src(dpi->clk_src);
+   pll = dss_pll_find_by_src(dpi->dss, dpi->clk_src);
if (!pll)
return;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 48ea5285cf20..bc9d6b7ce6a9 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5226,9 +5226,8 @@ static int dsi_init_pll_data(struct dss_device *dss, 
struct dsi_data *dsi)
pll->base = dsi->pll_base;
pll->hw = dsi->data->pll_hw;
pll->ops = _pll_ops;
-   pll->dss = dss;
 
-   r = dss_pll_register(pll);
+   r = dss_pll_register(dss, pll);
if (r)
return r;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 76a2561dfd22..9ca4391624cc 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -276,8 +276,9 @@ struct dss_device {

[PATCH 44/48] drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations

2017-10-13 Thread Laurent Pinchart
This removes the need to access the global DISPC private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DISPC private data dynamically).

In order to allow the omapdrm side to call the dispc_ops with a DISPC
pointer, we also introduce a new function dss_get_dispc() to retrieve
the DISPC corresponding to the DSS.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c   | 221 +++---
 drivers/gpu/drm/omapdrm/dss/dpi.c |   6 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c |   4 +-
 drivers/gpu/drm/omapdrm/dss/dss.c |   7 +-
 drivers/gpu/drm/omapdrm/dss/dss.h |   7 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   |   7 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   |   7 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  91 --
 drivers/gpu/drm/omapdrm/dss/sdi.c |   6 +-
 drivers/gpu/drm/omapdrm/dss/venc.c|   4 +-
 drivers/gpu/drm/omapdrm/omap_crtc.c   |  31 +++--
 drivers/gpu/drm/omapdrm/omap_drv.c|  18 +--
 drivers/gpu/drm/omapdrm/omap_drv.h|   5 +-
 drivers/gpu/drm/omapdrm/omap_irq.c|  32 ++---
 drivers/gpu/drm/omapdrm/omap_plane.c  |  12 +-
 15 files changed, 261 insertions(+), 197 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 912957c471ce..1bca5785b8a8 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -164,7 +164,7 @@ struct dispc_features {
 #define DISPC_MAX_NR_FIFOS 5
 #define DISPC_MAX_CHANNEL_GAMMA 4
 
-static struct {
+struct dispc_device {
struct platform_device *pdev;
void __iomem*base;
struct dss_device *dss;
@@ -196,7 +196,9 @@ static struct {
 
/* DISPC_CONTROL & DISPC_CONFIG lock*/
spinlock_t control_lock;
-} dispc;
+};
+
+static struct dispc_device dispc;
 
 enum omap_color_component {
/* used for all color formats for OMAP3 and earlier
@@ -363,9 +365,7 @@ static unsigned long dispc_mgr_pclk_rate(enum omap_channel 
channel);
 static unsigned long dispc_plane_pclk_rate(enum omap_plane_id plane);
 static unsigned long dispc_plane_lclk_rate(enum omap_plane_id plane);
 
-static void dispc_clear_irqstatus(u32 mask);
-static bool dispc_mgr_is_enabled(enum omap_channel channel);
-static void dispc_clear_irqstatus(u32 mask);
+static void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
 
 static inline void dispc_write_reg(const u16 idx, u32 val)
 {
@@ -398,14 +398,14 @@ static void mgr_fld_write(enum omap_channel channel,
spin_unlock_irqrestore(_lock, flags);
 }
 
-static int dispc_get_num_ovls(void)
+static int dispc_get_num_ovls(struct dispc_device *dispc)
 {
-   return dispc.feat->num_ovls;
+   return dispc->feat->num_ovls;
 }
 
-static int dispc_get_num_mgrs(void)
+static int dispc_get_num_mgrs(struct dispc_device *dispc)
 {
-   return dispc.feat->num_mgrs;
+   return dispc->feat->num_mgrs;
 }
 
 static void dispc_get_reg_field(enum dispc_feat_reg_field id,
@@ -457,7 +457,7 @@ static void dispc_save_context(void)
SR(CONFIG3);
}
 
-   for (i = 0; i < dispc_get_num_mgrs(); i++) {
+   for (i = 0; i < dispc_get_num_mgrs(); i++) {
SR(DEFAULT_COLOR(i));
SR(TRANS_COLOR(i));
SR(SIZE_MGR(i));
@@ -479,7 +479,7 @@ static void dispc_save_context(void)
}
}
 
-   for (i = 0; i < dispc_get_num_ovls(); i++) {
+   for (i = 0; i < dispc_get_num_ovls(); i++) {
SR(OVL_BA0(i));
SR(OVL_BA1(i));
SR(OVL_POSITION(i));
@@ -563,7 +563,7 @@ static void dispc_restore_context(void)
if (dispc_has_feature(FEAT_MGR_LCD3))
RR(CONFIG3);
 
-   for (i = 0; i < dispc_get_num_mgrs(); i++) {
+   for (i = 0; i < dispc_get_num_mgrs(); i++) {
RR(DEFAULT_COLOR(i));
RR(TRANS_COLOR(i));
RR(SIZE_MGR(i));
@@ -585,7 +585,7 @@ static void dispc_restore_context(void)
}
}
 
-   for (i = 0; i < dispc_get_num_ovls(); i++) {
+   for (i = 0; i < dispc_get_num_ovls(); i++) {
RR(OVL_BA0(i));
RR(OVL_BA1(i));
RR(OVL_POSITION(i));
@@ -650,7 +650,7 @@ static void dispc_restore_context(void)
if (dispc_has_feature(FEAT_MGR_LCD3))
RR(CONTROL3);
/* clear spurious SYNC_LOST_DIGIT interrupts */
-   dispc_clear_irqstatus(DISPC_IRQ_SYNC_LOST_DIGIT);
+   dispc_clear_irqstatus(, DISPC_IRQ_SYNC_LOST_DIGIT);
 
/*
 * enable last so IRQs won't trigger before
@@ -664,41 +664,44 @@ static void dispc_restore_context(void)
 #undef SR
 #undef RR
 
-int dispc_runtime_get(void)
+int dispc_runtime_get(struct dispc_device *dispc)
 {
int r;
 
DSSDBG("dispc_runtime_get\n");
 
-   r = pm_runtime_get_sync(>dev);
+   r = 

[PATCH 42/48] drm: omapdrm: dss: Remove unused functions prototypes

2017-10-13 Thread Laurent Pinchart
The omap_dss_register_driver(), omap_dss_unregister_driver() and
dispc_enable_gamma_table() functions don't exist anymore, remove their
prototypes.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.h | 1 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 ---
 2 files changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 6950f5d61b6c..5d6f8afca49d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -388,7 +388,6 @@ void dispc_disable_sidle(void);
 void dispc_lcd_enable_signal(bool enable);
 void dispc_pck_free_enable(bool enable);
 void dispc_enable_fifomerge(bool enable);
-void dispc_enable_gamma_table(bool enable);
 
 typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
unsigned long pck, void *data);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 8024680e8d57..32c5944b0bea 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -583,9 +583,6 @@ struct omap_dss_driver {
const struct hdmi_avi_infoframe *avi);
 };
 
-int omap_dss_register_driver(struct omap_dss_driver *);
-void omap_dss_unregister_driver(struct omap_dss_driver *);
-
 int omapdss_register_display(struct omap_dss_device *dssdev);
 void omapdss_unregister_display(struct omap_dss_device *dssdev);
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 45/48] drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API functions

2017-10-13 Thread Laurent Pinchart
This removes the need to access the global DISPC private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DISPC private data dynamically).

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 101 
 drivers/gpu/drm/omapdrm/dss/dpi.c   |  12 +++--
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  22 
 drivers/gpu/drm/omapdrm/dss/dss.c   |  14 ++---
 drivers/gpu/drm/omapdrm/dss/dss.h   |  74 ++
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |   6 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |   6 ++-
 drivers/gpu/drm/omapdrm/dss/sdi.c   |  13 +++--
 drivers/gpu/drm/omapdrm/dss/venc.c  |   2 +-
 9 files changed, 139 insertions(+), 111 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 1bca5785b8a8..180ad55bbdec 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -706,7 +706,7 @@ static u32 dispc_mgr_get_sync_lost_irq(struct dispc_device 
*dispc,
return mgr_desc[channel].sync_lost_irq;
 }
 
-u32 dispc_wb_get_framedone_irq(void)
+u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc)
 {
return DISPC_IRQ_FRAMEDONEWB;
 }
@@ -741,12 +741,12 @@ static void dispc_mgr_go(struct dispc_device *dispc, enum 
omap_channel channel)
mgr_fld_write(channel, DISPC_MGR_FLD_GO, 1);
 }
 
-bool dispc_wb_go_busy(void)
+bool dispc_wb_go_busy(struct dispc_device *dispc)
 {
return REG_GET(DISPC_CONTROL2, 6, 6) == 1;
 }
 
-void dispc_wb_go(void)
+void dispc_wb_go(struct dispc_device *dispc)
 {
enum omap_plane_id plane = OMAP_DSS_WB;
bool enable, go;
@@ -1198,7 +1198,8 @@ static enum omap_channel dispc_ovl_get_channel_out(enum 
omap_plane_id plane)
}
 }
 
-void dispc_wb_set_channel_in(enum dss_writeback_channel channel)
+void dispc_wb_set_channel_in(struct dispc_device *dispc,
+enum dss_writeback_channel channel)
 {
enum omap_plane_id plane = OMAP_DSS_WB;
 
@@ -1373,10 +1374,10 @@ static void dispc_init_fifos(void)
const bool use_fifomerge = false;
const bool manual_update = false;
 
-   dispc_ovl_compute_fifo_thresholds(i, , ,
+   dispc_ovl_compute_fifo_thresholds(, i, , ,
use_fifomerge, manual_update);
 
-   dispc_ovl_set_fifo_threshold(i, low, high);
+   dispc_ovl_set_fifo_threshold(, i, low, high);
}
 
if (dispc.feat->has_writeback) {
@@ -1384,10 +1385,11 @@ static void dispc_init_fifos(void)
const bool use_fifomerge = false;
const bool manual_update = false;
 
-   dispc_ovl_compute_fifo_thresholds(OMAP_DSS_WB, , ,
-   use_fifomerge, manual_update);
+   dispc_ovl_compute_fifo_thresholds(, OMAP_DSS_WB,
+ , ,
+ use_fifomerge, manual_update);
 
-   dispc_ovl_set_fifo_threshold(OMAP_DSS_WB, low, high);
+   dispc_ovl_set_fifo_threshold(, OMAP_DSS_WB, low, high);
}
 }
 
@@ -1404,13 +1406,14 @@ static u32 dispc_ovl_get_fifo_size(enum omap_plane_id 
plane)
return size;
 }
 
-void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
- u32 high)
+void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
+ enum omap_plane_id plane,
+ u32 low, u32 high)
 {
u8 hi_start, hi_end, lo_start, lo_end;
u32 unit;
 
-   unit = dispc.feat->buffer_size_unit;
+   unit = dispc->feat->buffer_size_unit;
 
WARN_ON(low % unit != 0);
WARN_ON(high % unit != 0);
@@ -1438,12 +1441,12 @@ void dispc_ovl_set_fifo_threshold(enum omap_plane_id 
plane, u32 low,
 * large for the preload field, set the threshold to the maximum value
 * that can be held by the preload register
 */
-   if (dispc_has_feature(FEAT_PRELOAD) && dispc.feat->set_max_preload &&
+   if (dispc_has_feature(FEAT_PRELOAD) && dispc->feat->set_max_preload &&
plane != OMAP_DSS_WB)
dispc_write_reg(DISPC_OVL_PRELOAD(plane), min(high, 0xfffu));
 }
 
-void dispc_enable_fifomerge(bool enable)
+void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable)
 {
if (!dispc_has_feature(FEAT_FIFO_MERGE)) {
WARN_ON(enable);
@@ -1454,15 +1457,16 @@ void dispc_enable_fifomerge(bool enable)
REG_FLD_MOD(DISPC_CONFIG, enable ? 1 : 0, 14, 14);
 }
 
-void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
-   u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
-   bool manual_update)
+void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
+ 

[PATCH 47/48] drm: omapdrm: dss: Store the debugfs root directory in struct dss_device

2017-10-13 Thread Laurent Pinchart
As part of an effort to remove the usage of global variables in the
driver, store the debugfs root directory in the dss_device structure
instead of a global variable.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  8 
 drivers/gpu/drm/omapdrm/dss/dss.c   | 39 +++--
 drivers/gpu/drm/omapdrm/dss/dss.h   |  9 ++---
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  3 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  3 ++-
 drivers/gpu/drm/omapdrm/dss/venc.c  |  3 ++-
 7 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index aaf7396f0273..5eacf4cdac54 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -4772,7 +4772,7 @@ static int dispc_bind(struct device *dev, struct device 
*master, void *data)
dispc_set_ops(_ops);
dss->dispc = dispc;
 
-   dispc->debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
+   dispc->debugfs = dss_debugfs_create_file(dss, "dispc", dispc_dump_regs,
 dispc);
 
return 0;
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c7700dfccc08..48ea5285cf20 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5453,20 +5453,20 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
dsi_runtime_put(dsi);
 
if (dsi->module_id == 0)
-   dsi->debugfs.regs = dss_debugfs_create_file("dsi1_regs",
+   dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi1_regs",
dsi1_dump_regs,
);
else
-   dsi->debugfs.regs = dss_debugfs_create_file("dsi2_regs",
+   dsi->debugfs.regs = dss_debugfs_create_file(dss, "dsi2_regs",
dsi2_dump_regs,
);
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
if (dsi->module_id == 0)
-   dsi->debugfs.irqs = dss_debugfs_create_file("dsi1_irqs",
+   dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi1_irqs",
dsi1_dump_irqs,
);
else
-   dsi->debugfs.irqs = dss_debugfs_create_file("dsi2_irqs",
+   dsi->debugfs.irqs = dss_debugfs_create_file(dss, "dsi2_irqs",
dsi2_dump_irqs,
);
 #endif
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 5d927dfe0a7f..f4e15850cc9d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -906,25 +906,23 @@ static int dss_debug_dump_clocks(struct seq_file *s, void 
*p)
return 0;
 }
 
-static struct dentry *dss_debugfs_dir;
-
 static int dss_initialize_debugfs(struct dss_device *dss)
 {
-   dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
-   if (IS_ERR(dss_debugfs_dir)) {
-   int err = PTR_ERR(dss_debugfs_dir);
+   static struct dentry *dir;
 
-   dss_debugfs_dir = NULL;
-   return err;
-   }
+   dir = debugfs_create_dir("omapdss", NULL);
+   if (IS_ERR(dir))
+   return PTR_ERR(dir);
+
+   dss->debugfs.root = dir;
 
return 0;
 }
 
-static void dss_uninitialize_debugfs(void)
+static void dss_uninitialize_debugfs(struct dss_device *dss)
 {
-   if (dss_debugfs_dir)
-   debugfs_remove_recursive(dss_debugfs_dir);
+   if (dss->debugfs.root)
+   debugfs_remove_recursive(dss->debugfs.root);
 }
 
 struct dss_debugfs_entry {
@@ -947,8 +945,10 @@ static const struct file_operations dss_debug_fops = {
.release= single_release,
 };
 
-struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
-   int (*show_fn)(struct seq_file *s, void *data), void *data)
+struct dss_debugfs_entry *
+dss_debugfs_create_file(struct dss_device *dss, const char *name,
+   int (*show_fn)(struct seq_file *s, void *data),
+   void *data)
 {
struct dss_debugfs_entry *entry;
struct dentry *d;
@@ -960,7 +960,7 @@ struct dss_debugfs_entry *dss_debugfs_create_file(const 
char *name,
entry->show_fn = show_fn;
entry->data = data;
 
-   d = debugfs_create_file(name, 0444, dss_debugfs_dir, entry,
+   d = debugfs_create_file(name, 0444, dss->debugfs.root, entry,
_debug_fops);
if (IS_ERR(d)) {
  

[PATCH 39/48] drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data

2017-10-13 Thread Laurent Pinchart
The dsi_data structure stores a pointer to a struct platform_device. The
driver only uses the dev member of the platform device structure. Store
the struct device pointer instead and use it directly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 4f67dd70f279..9be26eb262f3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -332,7 +332,7 @@ struct dsi_of_data {
 };
 
 struct dsi_data {
-   struct platform_device *pdev;
+   struct device *dev;
void __iomem *proto_base;
void __iomem *phy_base;
void __iomem *pll_base;
@@ -1146,7 +1146,7 @@ static int dsi_runtime_get(struct dsi_data *dsi)
 
DSSDBG("dsi_runtime_get\n");
 
-   r = pm_runtime_get_sync(>pdev->dev);
+   r = pm_runtime_get_sync(dsi->dev);
WARN_ON(r < 0);
return r < 0 ? r : 0;
 }
@@ -1157,7 +1157,7 @@ static void dsi_runtime_put(struct dsi_data *dsi)
 
DSSDBG("dsi_runtime_put\n");
 
-   r = pm_runtime_put_sync(>pdev->dev);
+   r = pm_runtime_put_sync(dsi->dev);
WARN_ON(r < 0 && r != -ENOSYS);
 }
 
@@ -1168,7 +1168,7 @@ static int dsi_regulator_init(struct dsi_data *dsi)
if (dsi->vdds_dsi_reg != NULL)
return 0;
 
-   vdds_dsi = devm_regulator_get(>pdev->dev, "vdd");
+   vdds_dsi = devm_regulator_get(dsi->dev, "vdd");
 
if (IS_ERR(vdds_dsi)) {
if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER)
@@ -4953,7 +4953,7 @@ static int dsi_get_clocks(struct dsi_data *dsi)
 {
struct clk *clk;
 
-   clk = devm_clk_get(>pdev->dev, "fck");
+   clk = devm_clk_get(dsi->dev, "fck");
if (IS_ERR(clk)) {
DSSERR("can't get fck\n");
return PTR_ERR(clk);
@@ -5048,7 +5048,7 @@ static void dsi_init_output(struct dsi_data *dsi)
 {
struct omap_dss_device *out = >output;
 
-   out->dev = >pdev->dev;
+   out->dev = dsi->dev;
out->id = dsi->module_id == 0 ?
OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
 
@@ -5070,7 +5070,7 @@ static void dsi_uninit_output(struct dsi_data *dsi)
 
 static int dsi_probe_of(struct dsi_data *dsi)
 {
-   struct device_node *node = dsi->pdev->dev.of_node;
+   struct device_node *node = dsi->dev->of_node;
struct property *prop;
u32 lane_arr[10];
int len, num_pins;
@@ -5084,7 +5084,7 @@ static int dsi_probe_of(struct dsi_data *dsi)
 
prop = of_find_property(ep, "lanes", );
if (prop == NULL) {
-   dev_err(>pdev->dev, "failed to find lane data\n");
+   dev_err(dsi->dev, "failed to find lane data\n");
r = -EINVAL;
goto err;
}
@@ -5093,14 +5093,14 @@ static int dsi_probe_of(struct dsi_data *dsi)
 
if (num_pins < 4 || num_pins % 2 != 0 ||
num_pins > dsi->num_lanes_supported * 2) {
-   dev_err(>pdev->dev, "bad number of lanes\n");
+   dev_err(dsi->dev, "bad number of lanes\n");
r = -EINVAL;
goto err;
}
 
r = of_property_read_u32_array(ep, "lanes", lane_arr, num_pins);
if (r) {
-   dev_err(>pdev->dev, "failed to read lane data\n");
+   dev_err(dsi->dev, "failed to read lane data\n");
goto err;
}
 
@@ -5110,7 +5110,7 @@ static int dsi_probe_of(struct dsi_data *dsi)
 
r = dsi_configure_pins(>output, _cfg);
if (r) {
-   dev_err(>pdev->dev, "failed to configure pins");
+   dev_err(dsi->dev, "failed to configure pins");
goto err;
}
 
@@ -5216,7 +5216,7 @@ static int dsi_init_pll_data(struct dss_device *dss, 
struct dsi_data *dsi)
struct clk *clk;
int r;
 
-   clk = devm_clk_get(>pdev->dev, "sys_clk");
+   clk = devm_clk_get(dsi->dev, "sys_clk");
if (IS_ERR(clk)) {
DSSERR("can't get sys_clk\n");
return PTR_ERR(clk);
@@ -5320,7 +5320,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
return -ENOMEM;
 
dsi->dss = dss;
-   dsi->pdev = pdev;
+   dsi->dev = dev;
dev_set_drvdata(dev, dsi);
 
spin_lock_init(>irq_lock);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 38/48] drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function

2017-10-13 Thread Laurent Pinchart
The dsi_bind() function receives a pointer to a struct device that it
casts to a struct platform_device, only to use the platform device's dev
field through the code. Use the dev pointer directly.

While at it rename the struct platform_device pointer dsidev to pdev to
make it more explicit.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a763ab7ed657..4f67dd70f279 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5302,9 +5302,10 @@ static const struct soc_device_attribute 
dsi_soc_devices[] = {
{ .machine = "AM35*",   .data = _of_data_omap34xx },
{ /* sentinel */ }
 };
+
 static int dsi_bind(struct device *dev, struct device *master, void *data)
 {
-   struct platform_device *dsidev = to_platform_device(dev);
+   struct platform_device *pdev = to_platform_device(dev);
struct dss_device *dss = dss_get_device(master);
const struct soc_device_attribute *soc;
const struct dsi_module_id_data *d;
@@ -5314,13 +5315,13 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
struct resource *dsi_mem;
struct resource *res;
 
-   dsi = devm_kzalloc(>dev, sizeof(*dsi), GFP_KERNEL);
+   dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
if (!dsi)
return -ENOMEM;
 
dsi->dss = dss;
-   dsi->pdev = dsidev;
-   dev_set_drvdata(>dev, dsi);
+   dsi->pdev = pdev;
+   dev_set_drvdata(dev, dsi);
 
spin_lock_init(>irq_lock);
spin_lock_init(>errors_lock);
@@ -5343,29 +5344,29 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
dsi->te_timer.data = 0;
 #endif
 
-   dsi_mem = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "proto");
-   dsi->proto_base = devm_ioremap_resource(>dev, dsi_mem);
+   dsi_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "proto");
+   dsi->proto_base = devm_ioremap_resource(dev, dsi_mem);
if (IS_ERR(dsi->proto_base))
return PTR_ERR(dsi->proto_base);
 
-   res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "phy");
-   dsi->phy_base = devm_ioremap_resource(>dev, res);
+   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy");
+   dsi->phy_base = devm_ioremap_resource(dev, res);
if (IS_ERR(dsi->phy_base))
return PTR_ERR(dsi->phy_base);
 
-   res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "pll");
-   dsi->pll_base = devm_ioremap_resource(>dev, res);
+   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pll");
+   dsi->pll_base = devm_ioremap_resource(dev, res);
if (IS_ERR(dsi->pll_base))
return PTR_ERR(dsi->pll_base);
 
-   dsi->irq = platform_get_irq(dsi->pdev, 0);
+   dsi->irq = platform_get_irq(pdev, 0);
if (dsi->irq < 0) {
DSSERR("platform_get_irq failed\n");
return -ENODEV;
}
 
-   r = devm_request_irq(>dev, dsi->irq, omap_dsi_irq_handler,
-IRQF_SHARED, dev_name(>dev), dsi);
+   r = devm_request_irq(dev, dsi->irq, omap_dsi_irq_handler,
+IRQF_SHARED, dev_name(dev), dsi);
if (r < 0) {
DSSERR("request_irq failed\n");
return r;
@@ -5419,14 +5420,14 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
 
dsi_init_pll_data(dss, dsi);
 
-   pm_runtime_enable(>dev);
+   pm_runtime_enable(dev);
 
r = dsi_runtime_get(dsi);
if (r)
goto err_runtime_get;
 
rev = dsi_read_reg(dsi, DSI_REVISION);
-   dev_dbg(>dev, "OMAP DSI rev %d.%d\n",
+   dev_dbg(dev, "OMAP DSI rev %d.%d\n",
   FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0));
 
/* DSI on OMAP3 doesn't have register DSI_GNQ, set number
@@ -5447,7 +5448,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
goto err_probe_of;
}
 
-   r = of_platform_populate(dsidev->dev.of_node, NULL, NULL, >dev);
+   r = of_platform_populate(dev->of_node, NULL, NULL, dev);
if (r)
DSSERR("Failed to populate DSI child devices: %d\n", r);
 
@@ -5479,7 +5480,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
dsi_runtime_put(dsi);
 
 err_runtime_get:
-   pm_runtime_disable(>dev);
+   pm_runtime_disable(dev);
return r;
 }
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 33/48] drm: omapdrm: venc: Allocate the venc private data structure dynamically

2017-10-13 Thread Laurent Pinchart
The venc private data structure is currently stored as a global
variable. While no platform with multiple VENC encoders currently exists
nor is planned, this doesn't comply with the kernel device model and
should thus be fixed.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/venc.c | 425 -
 1 file changed, 228 insertions(+), 197 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c 
b/drivers/gpu/drm/omapdrm/dss/venc.c
index 179ef73a5564..7acdbfefe397 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -321,7 +321,7 @@ static enum venc_videomode venc_get_videomode(const struct 
videomode *vm)
return VENC_MODE_UNKNOWN;
 }
 
-static struct {
+struct venc_device {
struct platform_device *pdev;
void __iomem *base;
struct mutex venc_lock;
@@ -339,81 +339,87 @@ static struct {
bool requires_tv_dac_clk;
 
struct omap_dss_device output;
-} venc;
+};
+
+#define dssdev_to_venc(dssdev) container_of(dssdev, struct venc_device, output)
 
-static inline void venc_write_reg(int idx, u32 val)
+static inline void venc_write_reg(struct venc_device *venc, int idx, u32 val)
 {
-   __raw_writel(val, venc.base + idx);
+   __raw_writel(val, venc->base + idx);
 }
 
-static inline u32 venc_read_reg(int idx)
+static inline u32 venc_read_reg(struct venc_device *venc, int idx)
 {
-   u32 l = __raw_readl(venc.base + idx);
+   u32 l = __raw_readl(venc->base + idx);
return l;
 }
 
-static void venc_write_config(const struct venc_config *config)
+static void venc_write_config(struct venc_device *venc,
+ const struct venc_config *config)
 {
DSSDBG("write venc conf\n");
 
-   venc_write_reg(VENC_LLEN, config->llen);
-   venc_write_reg(VENC_FLENS, config->flens);
-   venc_write_reg(VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr);
-   venc_write_reg(VENC_C_PHASE, config->c_phase);
-   venc_write_reg(VENC_GAIN_U, config->gain_u);
-   venc_write_reg(VENC_GAIN_V, config->gain_v);
-   venc_write_reg(VENC_GAIN_Y, config->gain_y);
-   venc_write_reg(VENC_BLACK_LEVEL, config->black_level);
-   venc_write_reg(VENC_BLANK_LEVEL, config->blank_level);
-   venc_write_reg(VENC_M_CONTROL, config->m_control);
-   venc_write_reg(VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
-   venc.wss_data);
-   venc_write_reg(VENC_S_CARR, config->s_carr);
-   venc_write_reg(VENC_L21__WC_CTL, config->l21__wc_ctl);
-   venc_write_reg(VENC_SAVID__EAVID, config->savid__eavid);
-   venc_write_reg(VENC_FLEN__FAL, config->flen__fal);
-   venc_write_reg(VENC_LAL__PHASE_RESET, config->lal__phase_reset);
-   venc_write_reg(VENC_HS_INT_START_STOP_X, config->hs_int_start_stop_x);
-   venc_write_reg(VENC_HS_EXT_START_STOP_X, config->hs_ext_start_stop_x);
-   venc_write_reg(VENC_VS_INT_START_X, config->vs_int_start_x);
-   venc_write_reg(VENC_VS_INT_STOP_X__VS_INT_START_Y,
+   venc_write_reg(venc, VENC_LLEN, config->llen);
+   venc_write_reg(venc, VENC_FLENS, config->flens);
+   venc_write_reg(venc, VENC_CC_CARR_WSS_CARR, config->cc_carr_wss_carr);
+   venc_write_reg(venc, VENC_C_PHASE, config->c_phase);
+   venc_write_reg(venc, VENC_GAIN_U, config->gain_u);
+   venc_write_reg(venc, VENC_GAIN_V, config->gain_v);
+   venc_write_reg(venc, VENC_GAIN_Y, config->gain_y);
+   venc_write_reg(venc, VENC_BLACK_LEVEL, config->black_level);
+   venc_write_reg(venc, VENC_BLANK_LEVEL, config->blank_level);
+   venc_write_reg(venc, VENC_M_CONTROL, config->m_control);
+   venc_write_reg(venc, VENC_BSTAMP_WSS_DATA, config->bstamp_wss_data |
+  venc->wss_data);
+   venc_write_reg(venc, VENC_S_CARR, config->s_carr);
+   venc_write_reg(venc, VENC_L21__WC_CTL, config->l21__wc_ctl);
+   venc_write_reg(venc, VENC_SAVID__EAVID, config->savid__eavid);
+   venc_write_reg(venc, VENC_FLEN__FAL, config->flen__fal);
+   venc_write_reg(venc, VENC_LAL__PHASE_RESET, config->lal__phase_reset);
+   venc_write_reg(venc, VENC_HS_INT_START_STOP_X,
+  config->hs_int_start_stop_x);
+   venc_write_reg(venc, VENC_HS_EXT_START_STOP_X,
+  config->hs_ext_start_stop_x);
+   venc_write_reg(venc, VENC_VS_INT_START_X, config->vs_int_start_x);
+   venc_write_reg(venc, VENC_VS_INT_STOP_X__VS_INT_START_Y,
   config->vs_int_stop_x__vs_int_start_y);
-   venc_write_reg(VENC_VS_INT_STOP_Y__VS_EXT_START_X,
+   venc_write_reg(venc, VENC_VS_INT_STOP_Y__VS_EXT_START_X,
   config->vs_int_stop_y__vs_ext_start_x);
-   venc_write_reg(VENC_VS_EXT_STOP_X__VS_EXT_START_Y,
+   venc_write_reg(venc, VENC_VS_EXT_STOP_X__VS_EXT_START_Y,
   config->vs_ext_stop_x__vs_ext_start_y);
-   

[PATCH 43/48] drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops

2017-10-13 Thread Laurent Pinchart
The dss_mgr_ops operations implemented by the omapdrm side have to look
up the omap_crtc objects from global variables as they are only passed a
channel number. In order to remove global variables pass the
omap_drm_private pointer to the dss_mgr_ops. This requires storing a
pointer to the dss_device in the omap_dss_device structure to allow
looking up the omap_drm_private in the dss_mgr_*() functions.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c |  1 +
 drivers/gpu/drm/omapdrm/dss/dsi.c |  1 +
 drivers/gpu/drm/omapdrm/dss/dss.c | 37 -
 drivers/gpu/drm/omapdrm/dss/dss.h | 37 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   |  1 +
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   |  1 +
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 39 ++-
 drivers/gpu/drm/omapdrm/dss/output.c  | 23 +
 drivers/gpu/drm/omapdrm/dss/sdi.c |  1 +
 drivers/gpu/drm/omapdrm/dss/venc.c|  1 +
 drivers/gpu/drm/omapdrm/omap_crtc.c   | 27 ++--
 11 files changed, 98 insertions(+), 71 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 3894e53ff58d..ae43ba81eb96 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -727,6 +727,7 @@ static void dpi_init_output_port(struct dpi_data *dpi, 
struct device_node *port)
}
 
out->dev = >pdev->dev;
+   out->dss = dpi->dss;
out->id = OMAP_DSS_OUTPUT_DPI;
out->output_type = OMAP_DISPLAY_TYPE_DPI;
out->dispc_channel = dpi_get_channel(dpi, port_num);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 512625ed03e2..eafea72998dd 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5044,6 +5044,7 @@ static void dsi_init_output(struct dsi_data *dsi)
struct omap_dss_device *out = >output;
 
out->dev = dsi->dev;
+   out->dss = dsi->dss;
out->id = dsi->module_id == 0 ?
OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 8fec9bf6f06f..0e8c70591308 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -49,9 +49,6 @@
 
 #include "omapdss.h"
 #include "dss.h"
-#include "../omap_drv.h"
-
-#define DSS_SZ_REGSSZ_512
 
 struct dss_reg {
u16 idx;
@@ -96,40 +93,6 @@ struct dss_features {
bool has_lcd_clk_src;
 };
 
-struct dss_device {
-   struct platform_device *pdev;
-   struct omap_drm_private drm;
-
-   void __iomem*base;
-   struct regmap   *syscon_pll_ctrl;
-   u32 syscon_pll_ctrl_offset;
-
-   struct clk  *parent_clk;
-   struct clk  *dss_clk;
-   unsigned long   dss_clk_rate;
-
-   unsigned long   cache_req_pck;
-   unsigned long   cache_prate;
-   struct dispc_clock_info cache_dispc_cinfo;
-
-   enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
-   enum dss_clk_source dispc_clk_source;
-   enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
-
-   boolctx_valid;
-   u32 ctx[DSS_SZ_REGS / sizeof(u32)];
-
-   const struct dss_features *feat;
-
-   struct {
-   struct dss_debugfs_entry *clk;
-   struct dss_debugfs_entry *dss;
-   } debugfs;
-
-   struct dss_pll  *video1_pll;
-   struct dss_pll  *video2_pll;
-};
-
 static const char * const dss_generic_clk_source_names[] = {
[DSS_CLK_SRC_FCK]   = "FCK",
[DSS_CLK_SRC_PLL1_1]= "PLL1:1",
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 5d6f8afca49d..cda2cbd888f0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -26,6 +26,7 @@
 #include 
 
 #include "omapdss.h"
+#include "../omap_drv.h"
 
 struct dentry;
 struct dss_debugfs_entry;
@@ -241,6 +242,42 @@ struct dss_lcd_mgr_config {
int lcden_sig_polarity;
 };
 
+#define DSS_SZ_REGSSZ_512
+
+struct dss_device {
+   struct platform_device *pdev;
+   struct omap_drm_private drm;
+
+   void __iomem*base;
+   struct regmap   *syscon_pll_ctrl;
+   u32 syscon_pll_ctrl_offset;
+
+   struct clk  *parent_clk;
+   struct clk  *dss_clk;
+   unsigned long   dss_clk_rate;
+
+   unsigned long   cache_req_pck;
+   unsigned long   cache_prate;
+   struct dispc_clock_info cache_dispc_cinfo;
+
+   enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
+   enum dss_clk_source dispc_clk_source;
+   enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
+
+   boolctx_valid;
+   u32 ctx[DSS_SZ_REGS / sizeof(u32)];
+
+   const struct 

[PATCH 40/48] drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions

2017-10-13 Thread Laurent Pinchart
The dsi_display_init_dispc() and dsi_display_uninit_dispc() functions
take a channel argument that is reduntant as it is always identical to
the dsi->output.dispc_channel. Remove the argument and use the field
directly in the functions to avoid misuse.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 9be26eb262f3..d1cc036ed280 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -217,10 +217,8 @@ struct dsi_reg { u16 module; u16 idx; };
 typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
 struct dsi_data;
 
-static int dsi_display_init_dispc(struct dsi_data *dsi,
-   enum omap_channel channel);
-static void dsi_display_uninit_dispc(struct dsi_data *dsi,
-   enum omap_channel channel);
+static int dsi_display_init_dispc(struct dsi_data *dsi);
+static void dsi_display_uninit_dispc(struct dsi_data *dsi);
 
 static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
 
@@ -3847,7 +3845,7 @@ static int dsi_enable_video_output(struct omap_dss_device 
*dssdev, int channel)
return -ENODEV;
}
 
-   r = dsi_display_init_dispc(dsi, dispc_channel);
+   r = dsi_display_init_dispc(dsi);
if (r)
goto err_init_dispc;
 
@@ -3897,7 +3895,7 @@ static int dsi_enable_video_output(struct omap_dss_device 
*dssdev, int channel)
dsi_vc_enable(dsi, channel, false);
}
 err_pix_fmt:
-   dsi_display_uninit_dispc(dsi, dispc_channel);
+   dsi_display_uninit_dispc(dsi);
 err_init_dispc:
return r;
 }
@@ -3920,7 +3918,7 @@ static void dsi_disable_video_output(struct 
omap_dss_device *dssdev, int channel
 
dss_mgr_disable(dispc_channel);
 
-   dsi_display_uninit_dispc(dsi, dispc_channel);
+   dsi_display_uninit_dispc(dsi);
 }
 
 static void dsi_update_screen_dispc(struct dsi_data *dsi)
@@ -4106,9 +4104,9 @@ static int dsi_configure_dispc_clocks(struct dsi_data 
*dsi)
return 0;
 }
 
-static int dsi_display_init_dispc(struct dsi_data *dsi,
- enum omap_channel channel)
+static int dsi_display_init_dispc(struct dsi_data *dsi)
 {
+   enum omap_channel channel = dsi->output.dispc_channel;
int r;
 
dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
@@ -4169,9 +4167,10 @@ static int dsi_display_init_dispc(struct dsi_data *dsi,
return r;
 }
 
-static void dsi_display_uninit_dispc(struct dsi_data *dsi,
-enum omap_channel channel)
+static void dsi_display_uninit_dispc(struct dsi_data *dsi)
 {
+   enum omap_channel channel = dsi->output.dispc_channel;
+
if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
dss_mgr_unregister_framedone_handler(channel,
dsi_framedone_irq_callback, dsi);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 29/48] drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function

2017-10-13 Thread Laurent Pinchart
The function is unused, remove it.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 14 --
 drivers/gpu/drm/omapdrm/dss/dss.h |  1 -
 2 files changed, 15 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 98a0da32f217..8b83bdcde6e2 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -775,20 +775,6 @@ void dss_select_hdmi_venc_clk_source(struct dss_device 
*dss,
REG_FLD_MOD(DSS_CONTROL, src, 15, 15);  /* VENC_HDMI_SWITCH */
 }
 
-enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void)
-{
-   enum omap_dss_output_id outputs;
-
-   outputs = dss.feat->outputs[OMAP_DSS_CHANNEL_DIGIT];
-   if ((outputs & OMAP_DSS_OUTPUT_HDMI) == 0)
-   return DSS_VENC_TV_CLK;
-
-   if ((outputs & OMAP_DSS_OUTPUT_VENC) == 0)
-   return DSS_HDMI_M_PCLK;
-
-   return REG_GET(DSS_CONTROL, 15, 15);
-}
-
 static int dss_dpi_select_source_omap2_omap3(struct dss_device *dss, int port,
 enum omap_channel channel)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 2641d5c6a32a..6950f5d61b6c 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -292,7 +292,6 @@ int dss_dpi_select_source(struct dss_device *dss, int port,
  enum omap_channel channel);
 void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
 enum dss_hdmi_venc_clk_source_select src);
-enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
 const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
 
 /* DSS VIDEO PLL */
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 27/48] drm: omapdrm: dss: Pass DSS pointer to dss clock functions

2017-10-13 Thread Laurent Pinchart
This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c |  8 
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 14 --
 drivers/gpu/drm/omapdrm/dss/dss.c   | 37 ++---
 drivers/gpu/drm/omapdrm/dss/dss.h   | 10 +-
 drivers/gpu/drm/omapdrm/dss/sdi.c   |  5 +++--
 5 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 723828f97196..7b74c8ee9372 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -3120,7 +3120,7 @@ static unsigned long dispc_fclk_rate(void)
src = dss_get_dispc_clk_source(dispc.dss);
 
if (src == DSS_CLK_SRC_FCK) {
-   r = dss_get_dispc_clk_rate();
+   r = dss_get_dispc_clk_rate(dispc.dss);
} else {
struct dss_pll *pll;
unsigned int clkout_idx;
@@ -3147,7 +3147,7 @@ static unsigned long dispc_mgr_lclk_rate(enum 
omap_channel channel)
src = dss_get_lcd_clk_source(dispc.dss, channel);
 
if (src == DSS_CLK_SRC_FCK) {
-   r = dss_get_dispc_clk_rate();
+   r = dss_get_dispc_clk_rate(dispc.dss);
} else {
struct dss_pll *pll;
unsigned int clkout_idx;
@@ -3505,7 +3505,7 @@ bool dispc_div_calc(unsigned long dispc_freq,
pckd_hw_min = dispc.feat->min_pcd;
pckd_hw_max = 255;
 
-   lck_max = dss_get_max_fck_rate();
+   lck_max = dss_get_max_fck_rate(dispc.dss);
 
pck_min = pck_min ? pck_min : 1;
pck_max = pck_max ? pck_max : ULONG_MAX;
@@ -4455,7 +4455,7 @@ static void dispc_errata_i734_wa(void)
 
/* Set up and enable display manager for LCD1 */
dispc_mgr_setup(OMAP_DSS_CHANNEL_LCD, );
-   dispc_calc_clock_rates(dss_get_dispc_clk_rate(),
+   dispc_calc_clock_rates(dss_get_dispc_clk_rate(dispc.dss),
   _conf.clock_info);
dispc_mgr_set_lcd_config(OMAP_DSS_CHANNEL_LCD, _conf);
dispc_mgr_set_timings(OMAP_DSS_CHANNEL_LCD, );
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 38a4c037783a..b0f890a3c8db 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -209,7 +209,7 @@ static bool dpi_calc_pll_cb(int n, int m, unsigned long 
fint,
ctx->pll_cinfo.clkdco = clkdco;
 
return dss_pll_hsdiv_calc_a(ctx->pll, clkdco,
-   ctx->pck_min, dss_get_max_fck_rate(),
+   ctx->pck_min, dss_get_max_fck_rate(ctx->pll->dss),
dpi_calc_hsdiv_cb, ctx);
 }
 
@@ -258,7 +258,8 @@ static bool dpi_pll_clk_calc(struct dpi_data *dpi, unsigned 
long pck,
}
 }
 
-static bool dpi_dss_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx)
+static bool dpi_dss_clk_calc(struct dpi_data *dpi, unsigned long pck,
+struct dpi_clk_calc_ctx *ctx)
 {
int i;
 
@@ -279,7 +280,8 @@ static bool dpi_dss_clk_calc(unsigned long pck, struct 
dpi_clk_calc_ctx *ctx)
ctx->pck_min = 0;
ctx->pck_max = pck + 1000 * i * i * i;
 
-   ok = dss_div_calc(pck, ctx->pck_min, dpi_calc_dss_cb, ctx);
+   ok = dss_div_calc(dpi->dss, pck, ctx->pck_min,
+ dpi_calc_dss_cb, ctx);
if (ok)
return ok;
}
@@ -323,11 +325,11 @@ static int dpi_set_dispc_clk(struct dpi_data *dpi, 
unsigned long pck_req,
int r;
bool ok;
 
-   ok = dpi_dss_clk_calc(pck_req, );
+   ok = dpi_dss_clk_calc(dpi, pck_req, );
if (!ok)
return -EINVAL;
 
-   r = dss_set_fck_rate(ctx.fck);
+   r = dss_set_fck_rate(dpi->dss, ctx.fck);
if (r)
return r;
 
@@ -532,7 +534,7 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
 
fck = ctx.pll_cinfo.clkout[ctx.clkout_idx];
} else {
-   ok = dpi_dss_clk_calc(vm->pixelclock, );
+   ok = dpi_dss_clk_calc(dpi, vm->pixelclock, );
if (!ok)
return -EINVAL;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index ba7a2bf1ec09..24237ed0557f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -634,8 +634,8 @@ enum dss_clk_source dss_get_lcd_clk_source(struct 
dss_device *dss,
}
 }
 
-bool dss_div_calc(unsigned long pck, unsigned long fck_min,
-   dss_div_calc_func func, void *data)
+bool dss_div_calc(struct dss_device *dss, unsigned long pck,
+ unsigned long fck_min, dss_div_calc_func func, void 

[PATCH 41/48] drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*() functions

2017-10-13 Thread Laurent Pinchart
The dss_mgr_*() functions take a channel argument to identify the
channel they operate on. This prevents the functions from accessing
driver data structures without resorting to global variables. In an
effort to remove global variables, pass the omap_dss_device pointer
associated with the channel instead. This will be used to look up the
omap_drm_private data structure to pass to the dss_mgr_ops.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 32 ++
 drivers/gpu/drm/omapdrm/dss/dsi.c | 30 +++--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c   | 20 +++--
 drivers/gpu/drm/omapdrm/dss/hdmi5.c   | 20 +++--
 drivers/gpu/drm/omapdrm/dss/omapdss.h | 22 +-
 drivers/gpu/drm/omapdrm/dss/output.c  | 42 ++-
 drivers/gpu/drm/omapdrm/dss/sdi.c | 27 +-
 drivers/gpu/drm/omapdrm/dss/venc.c| 18 ++-
 8 files changed, 92 insertions(+), 119 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index b0f890a3c8db..3894e53ff58d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -344,8 +344,6 @@ static int dpi_set_dispc_clk(struct dpi_data *dpi, unsigned 
long pck_req,
 
 static int dpi_set_mode(struct dpi_data *dpi)
 {
-   struct omap_dss_device *out = >output;
-   enum omap_channel channel = out->dispc_channel;
struct videomode *vm = >vm;
int lck_div = 0, pck_div = 0;
unsigned long fck = 0;
@@ -353,8 +351,8 @@ static int dpi_set_mode(struct dpi_data *dpi)
int r = 0;
 
if (dpi->pll)
-   r = dpi_set_pll_clk(dpi, channel, vm->pixelclock, ,
-   _div, _div);
+   r = dpi_set_pll_clk(dpi, dpi->output.dispc_channel,
+   vm->pixelclock, , _div, _div);
else
r = dpi_set_dispc_clk(dpi, vm->pixelclock, ,
_div, _div);
@@ -370,16 +368,13 @@ static int dpi_set_mode(struct dpi_data *dpi)
vm->pixelclock = pck;
}
 
-   dss_mgr_set_timings(channel, vm);
+   dss_mgr_set_timings(>output, vm);
 
return 0;
 }
 
 static void dpi_config_lcd_manager(struct dpi_data *dpi)
 {
-   struct omap_dss_device *out = >output;
-   enum omap_channel channel = out->dispc_channel;
-
dpi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 
dpi->mgr_config.stallmode = false;
@@ -389,14 +384,13 @@ static void dpi_config_lcd_manager(struct dpi_data *dpi)
 
dpi->mgr_config.lcden_sig_polarity = 0;
 
-   dss_mgr_set_lcd_config(channel, >mgr_config);
+   dss_mgr_set_lcd_config(>output, >mgr_config);
 }
 
 static int dpi_display_enable(struct omap_dss_device *dssdev)
 {
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
struct omap_dss_device *out = >output;
-   enum omap_channel channel = out->dispc_channel;
int r;
 
mutex_lock(>lock);
@@ -417,7 +411,7 @@ static int dpi_display_enable(struct omap_dss_device 
*dssdev)
if (r)
goto err_get_dispc;
 
-   r = dss_dpi_select_source(dpi->dss, out->port_num, channel);
+   r = dss_dpi_select_source(dpi->dss, out->port_num, out->dispc_channel);
if (r)
goto err_src_sel;
 
@@ -435,7 +429,7 @@ static int dpi_display_enable(struct omap_dss_device 
*dssdev)
 
mdelay(2);
 
-   r = dss_mgr_enable(channel);
+   r = dss_mgr_enable(>output);
if (r)
goto err_mgr_enable;
 
@@ -462,14 +456,14 @@ static int dpi_display_enable(struct omap_dss_device 
*dssdev)
 static void dpi_display_disable(struct omap_dss_device *dssdev)
 {
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-   enum omap_channel channel = dpi->output.dispc_channel;
 
mutex_lock(>lock);
 
-   dss_mgr_disable(channel);
+   dss_mgr_disable(>output);
 
if (dpi->pll) {
-   dss_select_lcd_clk_source(dpi->dss, channel, DSS_CLK_SRC_FCK);
+   dss_select_lcd_clk_source(dpi->dss, dpi->output.dispc_channel,
+ DSS_CLK_SRC_FCK);
dss_pll_disable(dpi->pll);
}
 
@@ -659,7 +653,6 @@ static int dpi_connect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
 {
struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-   enum omap_channel channel = dpi->output.dispc_channel;
int r;
 
r = dpi_init_regulator(dpi);
@@ -668,7 +661,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
 
dpi_init_pll(dpi);
 
-   r = dss_mgr_connect(channel, dssdev);
+   r = dss_mgr_connect(>output, dssdev);
if (r)
return r;
 
@@ -676,7 +669,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,

[PATCH 36/48] drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions

2017-10-13 Thread Laurent Pinchart
Internal dsi functions take a pointer to the DSI platform_device and
then cast it to a dsi_data pointer. That's pointless as the caller
already has the dsi_data pointer. Pass it directly instead of the
platform_device pointer.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 1228 +
 1 file changed, 564 insertions(+), 664 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index c94bb6404a69..312804104ad3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -121,11 +121,11 @@ struct dsi_reg { u16 module; u16 idx; };
 #define DSI_PLL_CONFIGURATION1 DSI_REG(DSI_PLL, 0x000C)
 #define DSI_PLL_CONFIGURATION2 DSI_REG(DSI_PLL, 0x0010)
 
-#define REG_GET(dsidev, idx, start, end) \
-   FLD_GET(dsi_read_reg(dsidev, idx), start, end)
+#define REG_GET(dsi, idx, start, end) \
+   FLD_GET(dsi_read_reg(dsi, idx), start, end)
 
-#define REG_FLD_MOD(dsidev, idx, val, start, end) \
-   dsi_write_reg(dsidev, idx, FLD_MOD(dsi_read_reg(dsidev, idx), val, 
start, end))
+#define REG_FLD_MOD(dsi, idx, val, start, end) \
+   dsi_write_reg(dsi, idx, FLD_MOD(dsi_read_reg(dsi, idx), val, start, 
end))
 
 /* Global interrupts */
 #define DSI_IRQ_VC0(1 << 0)
@@ -215,13 +215,14 @@ struct dsi_reg { u16 module; u16 idx; };
 DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5)
 
 typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
+struct dsi_data;
 
-static int dsi_display_init_dispc(struct platform_device *dsidev,
+static int dsi_display_init_dispc(struct dsi_data *dsi,
enum omap_channel channel);
-static void dsi_display_uninit_dispc(struct platform_device *dsidev,
+static void dsi_display_uninit_dispc(struct dsi_data *dsi,
enum omap_channel channel);
 
-static int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel);
+static int dsi_vc_send_null(struct dsi_data *dsi, int channel);
 
 /* DSI PLL HSDIV indices */
 #define HSDIV_DISPC0
@@ -284,7 +285,7 @@ struct dsi_isr_tables {
 };
 
 struct dsi_clk_calc_ctx {
-   struct platform_device *dsidev;
+   struct dsi_data *dsi;
struct dss_pll *pll;
 
/* inputs */
@@ -431,7 +432,7 @@ struct dsi_data {
 };
 
 struct dsi_packet_sent_handler_data {
-   struct platform_device *dsidev;
+   struct dsi_data *dsi;
struct completion *completion;
 };
 
@@ -450,7 +451,7 @@ static inline struct platform_device 
*dsi_get_dsidev_from_dssdev(struct omap_dss
return to_platform_device(dssdev->dev);
 }
 
-static struct platform_device *dsi_get_dsidev_from_id(int module)
+static struct dsi_data *dsi_get_dsi_from_id(int module)
 {
struct omap_dss_device *out;
enum omap_dss_output_id id;
@@ -468,13 +469,12 @@ static struct platform_device *dsi_get_dsidev_from_id(int 
module)
 
out = omap_dss_get_output(id);
 
-   return out ? to_platform_device(out->dev) : NULL;
+   return out ? dsi_get_dsidrv_data(to_platform_device(out->dev)) : NULL;
 }
 
-static inline void dsi_write_reg(struct platform_device *dsidev,
-   const struct dsi_reg idx, u32 val)
+static inline void dsi_write_reg(struct dsi_data *dsi,
+const struct dsi_reg idx, u32 val)
 {
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
void __iomem *base;
 
switch(idx.module) {
@@ -487,10 +487,8 @@ static inline void dsi_write_reg(struct platform_device 
*dsidev,
__raw_writel(val, base + idx.idx);
 }
 
-static inline u32 dsi_read_reg(struct platform_device *dsidev,
-   const struct dsi_reg idx)
+static inline u32 dsi_read_reg(struct dsi_data *dsi, const struct dsi_reg idx)
 {
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
void __iomem *base;
 
switch(idx.module) {
@@ -519,10 +517,8 @@ static void dsi_bus_unlock(struct omap_dss_device *dssdev)
up(>bus_lock);
 }
 
-static bool dsi_bus_is_locked(struct platform_device *dsidev)
+static bool dsi_bus_is_locked(struct dsi_data *dsi)
 {
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
return dsi->bus_lock.count == 0;
 }
 
@@ -531,8 +527,9 @@ static void dsi_completion_handler(void *data, u32 mask)
complete((struct completion *)data);
 }
 
-static inline bool wait_for_bit_change(struct platform_device *dsidev,
-   const struct dsi_reg idx, int bitnum, int value)
+static inline bool wait_for_bit_change(struct dsi_data *dsi,
+  const struct dsi_reg idx,
+  int bitnum, int value)
 {
unsigned long timeout;
ktime_t wait;
@@ -541,14 +538,14 @@ static inline bool wait_for_bit_change(struct 
platform_device *dsidev,
/* first busyloop to see if the bit changes right away */
t = 100;
while (t-- > 0) {
-  

[PATCH 37/48] drm: omapdrm: dsi: Combine two commonly used inline functions

2017-10-13 Thread Laurent Pinchart
The dsi_get_dsidrv_data() and dsi_get_dsidev_from_dssdev() inline
functions convert a struct omap_dss_device pointer to the corresponding
struct platform_device, and a struct platform_device pointer to the
corresponding struct dsi_data. They are nearly always called together
without any use of the intermediate platform_device, so combine them
into a single function.

In the three locations where only dsi_get_dsidrv_data() is used, call
dev_get_drvdata() directly.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 90 +--
 1 file changed, 30 insertions(+), 60 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 312804104ad3..a763ab7ed657 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -441,14 +441,9 @@ static bool dsi_perf;
 module_param(dsi_perf, bool, 0644);
 #endif
 
-static inline struct dsi_data *dsi_get_dsidrv_data(struct platform_device 
*dsidev)
+static inline struct dsi_data *to_dsi_data(struct omap_dss_device *dssdev)
 {
-   return dev_get_drvdata(>dev);
-}
-
-static inline struct platform_device *dsi_get_dsidev_from_dssdev(struct 
omap_dss_device *dssdev)
-{
-   return to_platform_device(dssdev->dev);
+   return dev_get_drvdata(dssdev->dev);
 }
 
 static struct dsi_data *dsi_get_dsi_from_id(int module)
@@ -469,7 +464,7 @@ static struct dsi_data *dsi_get_dsi_from_id(int module)
 
out = omap_dss_get_output(id);
 
-   return out ? dsi_get_dsidrv_data(to_platform_device(out->dev)) : NULL;
+   return out ? to_dsi_data(out) : NULL;
 }
 
 static inline void dsi_write_reg(struct dsi_data *dsi,
@@ -503,16 +498,14 @@ static inline u32 dsi_read_reg(struct dsi_data *dsi, 
const struct dsi_reg idx)
 
 static void dsi_bus_lock(struct omap_dss_device *dssdev)
 {
-   struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   struct dsi_data *dsi = to_dsi_data(dssdev);
 
down(>bus_lock);
 }
 
 static void dsi_bus_unlock(struct omap_dss_device *dssdev)
 {
-   struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   struct dsi_data *dsi = to_dsi_data(dssdev);
 
up(>bus_lock);
 }
@@ -2536,8 +2529,7 @@ static int dsi_vc_config_source(struct dsi_data *dsi, int 
channel,
 static void dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
bool enable)
 {
-   struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   struct dsi_data *dsi = to_dsi_data(dssdev);
 
DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable);
 
@@ -2660,8 +2652,7 @@ static int dsi_vc_send_bta(struct dsi_data *dsi, int 
channel)
 
 static int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel)
 {
-   struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   struct dsi_data *dsi = to_dsi_data(dssdev);
DECLARE_COMPLETION_ONSTACK(completion);
int r = 0;
u32 err;
@@ -2863,8 +2854,7 @@ static int dsi_vc_write_nosync_common(struct dsi_data 
*dsi, int channel,
 static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
u8 *data, int len)
 {
-   struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   struct dsi_data *dsi = to_dsi_data(dssdev);
 
return dsi_vc_write_nosync_common(dsi, channel, data, len,
DSS_DSI_CONTENT_DCS);
@@ -2873,8 +2863,7 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device 
*dssdev, int channel,
 static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int 
channel,
u8 *data, int len)
 {
-   struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   struct dsi_data *dsi = to_dsi_data(dssdev);
 
return dsi_vc_write_nosync_common(dsi, channel, data, len,
DSS_DSI_CONTENT_GENERIC);
@@ -2884,8 +2873,7 @@ static int dsi_vc_write_common(struct omap_dss_device 
*dssdev,
   int channel, u8 *data, int len,
   enum dss_dsi_content_type type)
 {
-   struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   struct dsi_data *dsi = to_dsi_data(dssdev);
int r;
 
r = dsi_vc_write_nosync_common(dsi, channel, data, len, type);
@@ -3090,8 +3078,7 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int 
channel, u8 *buf,
 static int dsi_vc_dcs_read(struct omap_dss_device 

[PATCH 30/48] drm: omapdrm: dss: Allocate the DSS private data structure dynamically

2017-10-13 Thread Laurent Pinchart
The DSS private data structure is currently stored as a global variable.
While no platform with multiple DSS devices currently exists nor is
planned, this doesn't comply with the kernel device model and should
thus be fixed.

As a first step to the fix, allocate the DSS private data structure
dynamically for each DSS instance. The pointer still needs to be stored
in a global variable as many functions exposed outside of the dss module
don't have access to the DSS private data structure. This will be fixed
in subsequent steps.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 385 +-
 1 file changed, 209 insertions(+), 176 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 8b83bdcde6e2..8fec9bf6f06f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -67,11 +67,12 @@ struct dss_reg {
 #define DSS_PLL_CONTROLDSS_REG(0x0048)
 #define DSS_SDI_STATUS DSS_REG(0x005C)
 
-#define REG_GET(idx, start, end) \
-   FLD_GET(dss_read_reg(idx), start, end)
+#define REG_GET(dss, idx, start, end) \
+   FLD_GET(dss_read_reg(dss, idx), start, end)
 
-#define REG_FLD_MOD(idx, val, start, end) \
-   dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
+#define REG_FLD_MOD(dss, idx, val, start, end) \
+   dss_write_reg(dss, idx, \
+ FLD_MOD(dss_read_reg(dss, idx), val, start, end))
 
 struct dss_ops {
int (*dpi_select_source)(struct dss_device *dss, int port,
@@ -129,8 +130,6 @@ struct dss_device {
struct dss_pll  *video2_pll;
 };
 
-static struct dss_device dss;
-
 static const char * const dss_generic_clk_source_names[] = {
[DSS_CLK_SRC_FCK]   = "FCK",
[DSS_CLK_SRC_PLL1_1]= "PLL1:1",
@@ -142,49 +141,50 @@ static const char * const dss_generic_clk_source_names[] 
= {
[DSS_CLK_SRC_HDMI_PLL]  = "HDMI PLL",
 };
 
-static inline void dss_write_reg(const struct dss_reg idx, u32 val)
+static inline void dss_write_reg(struct dss_device *dss,
+const struct dss_reg idx, u32 val)
 {
-   __raw_writel(val, dss.base + idx.idx);
+   __raw_writel(val, dss->base + idx.idx);
 }
 
-static inline u32 dss_read_reg(const struct dss_reg idx)
+static inline u32 dss_read_reg(struct dss_device *dss, const struct dss_reg 
idx)
 {
-   return __raw_readl(dss.base + idx.idx);
+   return __raw_readl(dss->base + idx.idx);
 }
 
-#define SR(reg) \
-   dss.ctx[(DSS_##reg).idx / sizeof(u32)] = dss_read_reg(DSS_##reg)
-#define RR(reg) \
-   dss_write_reg(DSS_##reg, dss.ctx[(DSS_##reg).idx / sizeof(u32)])
+#define SR(dss, reg) \
+   dss->ctx[(DSS_##reg).idx / sizeof(u32)] = dss_read_reg(dss, DSS_##reg)
+#define RR(dss, reg) \
+   dss_write_reg(dss, DSS_##reg, dss->ctx[(DSS_##reg).idx / sizeof(u32)])
 
-static void dss_save_context(void)
+static void dss_save_context(struct dss_device *dss)
 {
DSSDBG("dss_save_context\n");
 
-   SR(CONTROL);
+   SR(dss, CONTROL);
 
-   if (dss.feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
-   SR(SDI_CONTROL);
-   SR(PLL_CONTROL);
+   if (dss->feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
+   SR(dss, SDI_CONTROL);
+   SR(dss, PLL_CONTROL);
}
 
-   dss.ctx_valid = true;
+   dss->ctx_valid = true;
 
DSSDBG("context saved\n");
 }
 
-static void dss_restore_context(void)
+static void dss_restore_context(struct dss_device *dss)
 {
DSSDBG("dss_restore_context\n");
 
-   if (!dss.ctx_valid)
+   if (!dss->ctx_valid)
return;
 
-   RR(CONTROL);
+   RR(dss, CONTROL);
 
-   if (dss.feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
-   RR(SDI_CONTROL);
-   RR(PLL_CONTROL);
+   if (dss->feat->outputs[OMAP_DSS_CHANNEL_LCD] & OMAP_DSS_OUTPUT_SDI) {
+   RR(dss, SDI_CONTROL);
+   RR(dss, PLL_CONTROL);
}
 
DSSDBG("context restored\n");
@@ -223,12 +223,13 @@ void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable)
   1 << shift, val << shift);
 }
 
-static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
-   enum omap_channel channel)
+static int dss_ctrl_pll_set_control_mux(struct dss_device *dss,
+   enum dss_clk_source clk_src,
+   enum omap_channel channel)
 {
unsigned int shift, val;
 
-   if (!dss.syscon_pll_ctrl)
+   if (!dss->syscon_pll_ctrl)
return -EINVAL;
 
switch (channel) {
@@ -283,7 +284,7 @@ static int dss_ctrl_pll_set_control_mux(enum dss_clk_source 
clk_src,
return -EINVAL;
}
 
-   regmap_update_bits(dss.syscon_pll_ctrl, 

[PATCH 32/48] drm: omapdrm: hdmi5: Allocate the omap_hdmi data structure dynamically

2017-10-13 Thread Laurent Pinchart
The omap_hdmi private data structure is currently stored as a global
variable. While no platform with multiple HDMI5 encoders currently
exists nor is planned, this doesn't comply with the kernel device model
and should thus be fixed.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/hdmi5.c | 345 +++-
 1 file changed, 184 insertions(+), 161 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index c28fe184a7ad..ed8a2bd2a035 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -46,15 +46,13 @@
 #include "hdmi5_core.h"
 #include "dss.h"
 
-static struct omap_hdmi hdmi;
-
-static int hdmi_runtime_get(void)
+static int hdmi_runtime_get(struct omap_hdmi *hdmi)
 {
int r;
 
DSSDBG("hdmi_runtime_get\n");
 
-   r = pm_runtime_get_sync(>dev);
+   r = pm_runtime_get_sync(>pdev->dev);
WARN_ON(r < 0);
if (r < 0)
return r;
@@ -62,19 +60,20 @@ static int hdmi_runtime_get(void)
return 0;
 }
 
-static void hdmi_runtime_put(void)
+static void hdmi_runtime_put(struct omap_hdmi *hdmi)
 {
int r;
 
DSSDBG("hdmi_runtime_put\n");
 
-   r = pm_runtime_put_sync(>dev);
+   r = pm_runtime_put_sync(>pdev->dev);
WARN_ON(r < 0 && r != -ENOSYS);
 }
 
 static irqreturn_t hdmi_irq_handler(int irq, void *data)
 {
-   struct hdmi_wp_data *wp = data;
+   struct omap_hdmi *hdmi = data;
+   struct hdmi_wp_data *wp = >wp;
u32 irqstatus;
 
irqstatus = hdmi_wp_get_irqstatus(wp);
@@ -97,17 +96,17 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
 * setting the PHY to LDOON. To ignore those, we force the RXDET
 * line to 0 until the PHY power state has been changed.
 */
-   v = hdmi_read_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL);
+   v = hdmi_read_reg(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL);
v = FLD_MOD(v, 1, 15, 15); /* FORCE_RXDET_HIGH */
v = FLD_MOD(v, 0, 14, 7); /* RXDET_LINE */
-   hdmi_write_reg(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v);
+   hdmi_write_reg(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL, v);
 
hdmi_wp_set_irqstatus(wp, HDMI_IRQ_LINK_CONNECT |
HDMI_IRQ_LINK_DISCONNECT);
 
hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_LDOON);
 
-   REG_FLD_MOD(hdmi.phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15);
+   REG_FLD_MOD(hdmi->phy.base, HDMI_TXPHY_PAD_CFG_CTRL, 0, 15, 15);
 
} else if (irqstatus & HDMI_IRQ_LINK_CONNECT) {
hdmi_wp_set_phy_pwr(wp, HDMI_PHYPWRCMD_TXON);
@@ -118,70 +117,70 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
return IRQ_HANDLED;
 }
 
-static int hdmi_init_regulator(void)
+static int hdmi_init_regulator(struct omap_hdmi *hdmi)
 {
struct regulator *reg;
 
-   if (hdmi.vdda_reg != NULL)
+   if (hdmi->vdda_reg != NULL)
return 0;
 
-   reg = devm_regulator_get(>dev, "vdda");
+   reg = devm_regulator_get(>pdev->dev, "vdda");
if (IS_ERR(reg)) {
DSSERR("can't get VDDA regulator\n");
return PTR_ERR(reg);
}
 
-   hdmi.vdda_reg = reg;
+   hdmi->vdda_reg = reg;
 
return 0;
 }
 
-static int hdmi_power_on_core(struct omap_dss_device *dssdev)
+static int hdmi_power_on_core(struct omap_hdmi *hdmi)
 {
int r;
 
-   r = regulator_enable(hdmi.vdda_reg);
+   r = regulator_enable(hdmi->vdda_reg);
if (r)
return r;
 
-   r = hdmi_runtime_get();
+   r = hdmi_runtime_get(hdmi);
if (r)
goto err_runtime_get;
 
/* Make selection of HDMI in DSS */
-   dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
+   dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK);
 
-   hdmi.core_enabled = true;
+   hdmi->core_enabled = true;
 
return 0;
 
 err_runtime_get:
-   regulator_disable(hdmi.vdda_reg);
+   regulator_disable(hdmi->vdda_reg);
 
return r;
 }
 
-static void hdmi_power_off_core(struct omap_dss_device *dssdev)
+static void hdmi_power_off_core(struct omap_hdmi *hdmi)
 {
-   hdmi.core_enabled = false;
+   hdmi->core_enabled = false;
 
-   hdmi_runtime_put();
-   regulator_disable(hdmi.vdda_reg);
+   hdmi_runtime_put(hdmi);
+   regulator_disable(hdmi->vdda_reg);
 }
 
-static int hdmi_power_on_full(struct omap_dss_device *dssdev)
+static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 {
int r;
struct videomode *vm;
-   enum omap_channel channel = dssdev->dispc_channel;
+   enum omap_channel channel = hdmi->output.dispc_channel;
struct dss_pll_clock_info hdmi_cinfo = { 0 };
unsigned int pc;
 
-   r = 

[PATCH 34/48] drm: omapdrm: sdi: Allocate the sdi private data structure dynamically

2017-10-13 Thread Laurent Pinchart
The sdi private data structure is currently stored as a global
variable. While no platform with multiple SDI encoders currently exists
nor is planned, this doesn't comply with the kernel device model and
should thus be fixed.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/sdi.c | 122 +-
 1 file changed, 69 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
b/drivers/gpu/drm/omapdrm/dss/sdi.c
index ac436826914a..a35dc51c5a6a 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -31,7 +31,7 @@
 #include "omapdss.h"
 #include "dss.h"
 
-static struct {
+struct sdi_device {
struct platform_device *pdev;
struct dss_device *dss;
 
@@ -43,9 +43,9 @@ static struct {
int datapairs;
 
struct omap_dss_device output;
+};
 
-   bool port_initialized;
-} sdi;
+#define dssdev_to_sdi(dssdev) container_of(dssdev, struct sdi_device, output)
 
 struct sdi_clk_calc_ctx {
unsigned long pck_min, pck_max;
@@ -77,9 +77,9 @@ static bool dpi_calc_dss_cb(unsigned long fck, void *data)
dpi_calc_dispc_cb, ctx);
 }
 
-static int sdi_calc_clock_div(unsigned long pclk,
-   unsigned long *fck,
-   struct dispc_clock_info *dispc_cinfo)
+static int sdi_calc_clock_div(struct sdi_device *sdi, unsigned long pclk,
+ unsigned long *fck,
+ struct dispc_clock_info *dispc_cinfo)
 {
int i;
struct sdi_clk_calc_ctx ctx;
@@ -101,7 +101,7 @@ static int sdi_calc_clock_div(unsigned long pclk,
ctx.pck_min = 0;
ctx.pck_max = pclk + 1000 * i * i * i;
 
-   ok = dss_div_calc(sdi.dss, pclk, ctx.pck_min,
+   ok = dss_div_calc(sdi->dss, pclk, ctx.pck_min,
  dpi_calc_dss_cb, );
if (ok) {
*fck = ctx.fck;
@@ -113,26 +113,27 @@ static int sdi_calc_clock_div(unsigned long pclk,
return -EINVAL;
 }
 
-static void sdi_config_lcd_manager(struct omap_dss_device *dssdev)
+static void sdi_config_lcd_manager(struct sdi_device *sdi)
 {
-   enum omap_channel channel = dssdev->dispc_channel;
+   enum omap_channel channel = sdi->output.dispc_channel;
 
-   sdi.mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
+   sdi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 
-   sdi.mgr_config.stallmode = false;
-   sdi.mgr_config.fifohandcheck = false;
+   sdi->mgr_config.stallmode = false;
+   sdi->mgr_config.fifohandcheck = false;
 
-   sdi.mgr_config.video_port_width = 24;
-   sdi.mgr_config.lcden_sig_polarity = 1;
+   sdi->mgr_config.video_port_width = 24;
+   sdi->mgr_config.lcden_sig_polarity = 1;
 
-   dss_mgr_set_lcd_config(channel, _config);
+   dss_mgr_set_lcd_config(channel, >mgr_config);
 }
 
 static int sdi_display_enable(struct omap_dss_device *dssdev)
 {
-   struct omap_dss_device *out = 
+   struct sdi_device *sdi = dssdev_to_sdi(dssdev);
+   struct omap_dss_device *out = >output;
enum omap_channel channel = dssdev->dispc_channel;
-   struct videomode *vm = 
+   struct videomode *vm = >vm;
unsigned long fck;
struct dispc_clock_info dispc_cinfo;
unsigned long pck;
@@ -143,7 +144,7 @@ static int sdi_display_enable(struct omap_dss_device 
*dssdev)
return -ENODEV;
}
 
-   r = regulator_enable(sdi.vdds_sdi_reg);
+   r = regulator_enable(sdi->vdds_sdi_reg);
if (r)
goto err_reg_enable;
 
@@ -154,11 +155,11 @@ static int sdi_display_enable(struct omap_dss_device 
*dssdev)
/* 15.5.9.1.2 */
vm->flags |= DISPLAY_FLAGS_PIXDATA_POSEDGE | DISPLAY_FLAGS_SYNC_POSEDGE;
 
-   r = sdi_calc_clock_div(vm->pixelclock, , _cinfo);
+   r = sdi_calc_clock_div(sdi, vm->pixelclock, , _cinfo);
if (r)
goto err_calc_clock_div;
 
-   sdi.mgr_config.clock_info = dispc_cinfo;
+   sdi->mgr_config.clock_info = dispc_cinfo;
 
pck = fck / dispc_cinfo.lck_div / dispc_cinfo.pck_div;
 
@@ -172,11 +173,11 @@ static int sdi_display_enable(struct omap_dss_device 
*dssdev)
 
dss_mgr_set_timings(channel, vm);
 
-   r = dss_set_fck_rate(sdi.dss, fck);
+   r = dss_set_fck_rate(sdi->dss, fck);
if (r)
goto err_set_dss_clock_div;
 
-   sdi_config_lcd_manager(dssdev);
+   sdi_config_lcd_manager(sdi);
 
/*
 * LCLK and PCLK divisors are located in shadow registers, and we
@@ -189,10 +190,10 @@ static int sdi_display_enable(struct omap_dss_device 
*dssdev)
 * need to care about the shadow register mechanism for pck-free. The
 * exact reason for this is unknown.
 */
-   dispc_mgr_set_clock_div(channel, _config.clock_info);
+   

[PATCH 35/48] drm: omapdrm: dsi: Make wait_for_bit_change() return a status

2017-10-13 Thread Laurent Pinchart
The wait_for_bit_change() function returns the value of the bit it
polls. This requires the caller to compare the return value to the
expected bit value. As all the existing callers need is to check whether
the bit has reached the expected value, it's easier to return a boolean
status from the function.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c | 31 +++
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 7fb048023fd0..c94bb6404a69 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -531,7 +531,7 @@ static void dsi_completion_handler(void *data, u32 mask)
complete((struct completion *)data);
 }
 
-static inline int wait_for_bit_change(struct platform_device *dsidev,
+static inline bool wait_for_bit_change(struct platform_device *dsidev,
const struct dsi_reg idx, int bitnum, int value)
 {
unsigned long timeout;
@@ -542,21 +542,21 @@ static inline int wait_for_bit_change(struct 
platform_device *dsidev,
t = 100;
while (t-- > 0) {
if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
-   return value;
+   return true;
}
 
/* then loop for 500ms, sleeping for 1ms in between */
timeout = jiffies + msecs_to_jiffies(500);
while (time_before(jiffies, timeout)) {
if (REG_GET(dsidev, idx, bitnum, bitnum) == value)
-   return value;
+   return true;
 
wait = ns_to_ktime(1000 * 1000);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_hrtimeout(, HRTIMER_MODE_REL);
}
 
-   return !value;
+   return false;
 }
 
 static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
@@ -1259,9 +1259,9 @@ static inline int dsi_if_enable(struct platform_device 
*dsidev, bool enable)
enable = enable ? 1 : 0;
REG_FLD_MOD(dsidev, DSI_CTRL, enable, 0, 0); /* IF_EN */
 
-   if (wait_for_bit_change(dsidev, DSI_CTRL, 0, enable) != enable) {
-   DSSERR("Failed to set dsi_if_enable to %d\n", enable);
-   return -EIO;
+   if (!wait_for_bit_change(dsidev, DSI_CTRL, 0, enable)) {
+   DSSERR("Failed to set dsi_if_enable to %d\n", enable);
+   return -EIO;
}
 
return 0;
@@ -1450,7 +1450,7 @@ static int dsi_pll_enable(struct dss_pll *pll)
/* XXX PLL does not come out of reset without this... */
dispc_pck_free_enable(1);
 
-   if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1) != 1) {
+   if (!wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1)) {
DSSERR("PLL not coming out of reset.\n");
r = -ENODEV;
dispc_pck_free_enable(0);
@@ -2200,7 +2200,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
 * I/O. */
dsi_read_reg(dsidev, DSI_DSIPHY_CFG5);
 
-   if (wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1) != 1) {
+   if (!wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1)) {
DSSERR("CIO SCP Clock domain not coming out of reset.\n");
r = -EIO;
goto err_scp_clk_dom;
@@ -2248,7 +2248,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
if (r)
goto err_cio_pwr;
 
-   if (wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1) != 1) {
+   if (!wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1)) {
DSSERR("CIO PWR clock domain not coming out of reset.\n");
r = -ENODEV;
goto err_cio_pwr_dom;
@@ -2389,7 +2389,7 @@ static int dsi_force_tx_stop_mode_io(struct 
platform_device *dsidev)
r = FLD_MOD(r, 1, 15, 15);  /* FORCE_TX_STOP_MODE_IO */
dsi_write_reg(dsidev, DSI_TIMING1, r);
 
-   if (wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0) != 0) {
+   if (!wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0)) {
DSSERR("TX_STOP bit not going down\n");
return -EIO;
}
@@ -2531,10 +2531,9 @@ static int dsi_vc_enable(struct platform_device *dsidev, 
int channel,
 
REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 0, 0);
 
-   if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel),
-   0, enable) != enable) {
-   DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
-   return -EIO;
+   if (!wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 0, enable)) {
+   DSSERR("Failed to set dsi_vc_enable to %d\n", enable);
+   return -EIO;
}
 
return 0;
@@ -2586,7 +2585,7 @@ static int dsi_vc_config_source(struct platform_device 
*dsidev, int channel,
dsi_vc_enable(dsidev, channel, 0);
 
   

[PATCH 31/48] drm: omapdrm: hdmi4: Allocate the omap_hdmi data structure dynamically

2017-10-13 Thread Laurent Pinchart
The omap_hdmi private data structure is currently stored as a global
variable. While no platform with multiple HDMI4 encoders currently
exists nor is planned, this doesn't comply with the kernel device model
and should thus be fixed.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/hdmi.h   |   2 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c  | 337 +--
 drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c  |   4 +-
 drivers/gpu/drm/omapdrm/dss/hdmi4_core.h |   4 +-
 4 files changed, 188 insertions(+), 159 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h 
b/drivers/gpu/drm/omapdrm/dss/hdmi.h
index fa2fbdaa427c..3aeb4cabd59f 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi.h
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h
@@ -389,4 +389,6 @@ struct omap_hdmi {
bool display_enabled;
 };
 
+#define dssdev_to_hdmi(dssdev) container_of(dssdev, struct omap_hdmi, output)
+
 #endif
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 5806587fd89a..f0a30b248a7d 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -44,15 +44,13 @@
 #include "dss.h"
 #include "hdmi.h"
 
-static struct omap_hdmi hdmi;
-
-static int hdmi_runtime_get(void)
+static int hdmi_runtime_get(struct omap_hdmi *hdmi)
 {
int r;
 
DSSDBG("hdmi_runtime_get\n");
 
-   r = pm_runtime_get_sync(>dev);
+   r = pm_runtime_get_sync(>pdev->dev);
WARN_ON(r < 0);
if (r < 0)
return r;
@@ -60,13 +58,13 @@ static int hdmi_runtime_get(void)
return 0;
 }
 
-static void hdmi_runtime_put(void)
+static void hdmi_runtime_put(struct omap_hdmi *hdmi)
 {
int r;
 
DSSDBG("hdmi_runtime_put\n");
 
-   r = pm_runtime_put_sync(>dev);
+   r = pm_runtime_put_sync(>pdev->dev);
WARN_ON(r < 0 && r != -ENOSYS);
 }
 
@@ -109,14 +107,14 @@ static irqreturn_t hdmi_irq_handler(int irq, void *data)
return IRQ_HANDLED;
 }
 
-static int hdmi_init_regulator(void)
+static int hdmi_init_regulator(struct omap_hdmi *hdmi)
 {
struct regulator *reg;
 
-   if (hdmi.vdda_reg != NULL)
+   if (hdmi->vdda_reg != NULL)
return 0;
 
-   reg = devm_regulator_get(>dev, "vdda");
+   reg = devm_regulator_get(>pdev->dev, "vdda");
 
if (IS_ERR(reg)) {
if (PTR_ERR(reg) != -EPROBE_DEFER)
@@ -124,64 +122,64 @@ static int hdmi_init_regulator(void)
return PTR_ERR(reg);
}
 
-   hdmi.vdda_reg = reg;
+   hdmi->vdda_reg = reg;
 
return 0;
 }
 
-static int hdmi_power_on_core(struct omap_dss_device *dssdev)
+static int hdmi_power_on_core(struct omap_hdmi *hdmi)
 {
int r;
 
-   if (hdmi.core.core_pwr_cnt++)
+   if (hdmi->core.core_pwr_cnt++)
return 0;
 
-   r = regulator_enable(hdmi.vdda_reg);
+   r = regulator_enable(hdmi->vdda_reg);
if (r)
goto err_reg_enable;
 
-   r = hdmi_runtime_get();
+   r = hdmi_runtime_get(hdmi);
if (r)
goto err_runtime_get;
 
-   hdmi4_core_powerdown_disable();
+   hdmi4_core_powerdown_disable(>core);
 
/* Make selection of HDMI in DSS */
-   dss_select_hdmi_venc_clk_source(hdmi.dss, DSS_HDMI_M_PCLK);
+   dss_select_hdmi_venc_clk_source(hdmi->dss, DSS_HDMI_M_PCLK);
 
-   hdmi.core_enabled = true;
+   hdmi->core_enabled = true;
 
return 0;
 
 err_runtime_get:
-   regulator_disable(hdmi.vdda_reg);
+   regulator_disable(hdmi->vdda_reg);
 err_reg_enable:
-   hdmi.core.core_pwr_cnt--;
+   hdmi->core.core_pwr_cnt--;
 
return r;
 }
 
-static void hdmi_power_off_core(struct omap_dss_device *dssdev)
+static void hdmi_power_off_core(struct omap_hdmi *hdmi)
 {
-   if (--hdmi.core.core_pwr_cnt)
+   if (--hdmi->core.core_pwr_cnt)
return;
 
-   hdmi.core_enabled = false;
+   hdmi->core_enabled = false;
 
-   hdmi_runtime_put();
-   regulator_disable(hdmi.vdda_reg);
+   hdmi_runtime_put(hdmi);
+   regulator_disable(hdmi->vdda_reg);
 }
 
-static int hdmi_power_on_full(struct omap_dss_device *dssdev)
+static int hdmi_power_on_full(struct omap_hdmi *hdmi)
 {
int r;
struct videomode *vm;
-   enum omap_channel channel = dssdev->dispc_channel;
-   struct hdmi_wp_data *wp = 
+   enum omap_channel channel = hdmi->output.dispc_channel;
+   struct hdmi_wp_data *wp = >wp;
struct dss_pll_clock_info hdmi_cinfo = { 0 };
unsigned int pc;
 
-   r = hdmi_power_on_core(dssdev);
+   r = hdmi_power_on_core(hdmi);
if (r)
return r;
 
@@ -189,7 +187,7 @@ static int hdmi_power_on_full(struct omap_dss_device 
*dssdev)
hdmi_wp_clear_irqenable(wp, ~HDMI_IRQ_CORE);
hdmi_wp_set_irqstatus(wp, ~HDMI_IRQ_CORE);
 
-   vm = 
+   vm = >cfg.vm;
 

[PATCH 20/48] drm: omapdrm: Merge the omapdrm and omapdss drivers

2017-10-13 Thread Laurent Pinchart
The split between the omapdss and omapdrm driver is historic and was due
to other userspace APIs (FBDEV and V4L2) being supported in addition to
DRM/KMS. Now that the drivers only supports the DRM/KMS API, there is no
need to keep them separate anymore.

Merge the two drivers and remove the now unneeded omapdrm virtual
platform device.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/Kconfig  |  5 +-
 drivers/gpu/drm/omapdrm/Makefile | 25 ++
 drivers/gpu/drm/omapdrm/dss/Kconfig  | 12 -
 drivers/gpu/drm/omapdrm/dss/Makefile | 25 --
 drivers/gpu/drm/omapdrm/dss/base.c   | 13 -
 drivers/gpu/drm/omapdrm/dss/core.c   | 14 ++
 drivers/gpu/drm/omapdrm/dss/dss.c| 23 -
 drivers/gpu/drm/omapdrm/dss/omapdss.h|  4 --
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 12 -
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.h |  3 +-
 drivers/gpu/drm/omapdrm/omap_drv.c   | 82 ++--
 drivers/gpu/drm/omapdrm/omap_drv.h   |  4 ++
 12 files changed, 74 insertions(+), 148 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index b3d08c5f41d4..7e5080e45b16 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -2,8 +2,11 @@ config DRM_OMAP
tristate "OMAP DRM"
depends on DRM
depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
-   select OMAP2_DSS
select DRM_KMS_HELPER
+   select HDMI
+   select OMAP2_DSS
+   select OMAP2_DSS_INIT
+   select VIDEOMODE_HELPERS
default n
help
  DRM display driver for OMAP2/3/4 based boards.
diff --git a/drivers/gpu/drm/omapdrm/Makefile b/drivers/gpu/drm/omapdrm/Makefile
index b391be7ecb6c..1dafa51ca00e 100644
--- a/drivers/gpu/drm/omapdrm/Makefile
+++ b/drivers/gpu/drm/omapdrm/Makefile
@@ -21,4 +21,29 @@ omapdrm-y := omap_drv.o \
 
 omapdrm-$(CONFIG_DRM_FBDEV_EMULATION) += omap_fbdev.o
 
+# Core DSS files
+omapdrm-y += \
+   dss/base.o \
+   dss/core.o \
+   dss/dispc.o \
+   dss/dispc_coefs.o \
+   dss/display.o \
+   dss/dss.o \
+   dss/dss-of.o \
+   dss/output.o \
+   dss/pll.o \
+   dss/video-pll.o
+
+omapdrm-$(CONFIG_OMAP2_DSS_DPI) += dss/dpi.o
+omapdrm-$(CONFIG_OMAP2_DSS_VENC) += dss/venc.o
+omapdrm-$(CONFIG_OMAP2_DSS_SDI) += dss/sdi.o
+omapdrm-$(CONFIG_OMAP2_DSS_DSI) += dss/dsi.o
+omapdrm-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += dss/hdmi_common.o dss/hdmi_wp.o \
+   dss/hdmi_pll.o dss/hdmi_phy.o
+omapdrm-$(CONFIG_OMAP4_DSS_HDMI) += dss/hdmi4.o dss/hdmi4_core.o
+omapdrm-$(CONFIG_OMAP4_DSS_HDMI_CEC) += dss/hdmi4_cec.o
+omapdrm-$(CONFIG_OMAP5_DSS_HDMI) += dss/hdmi5.o dss/hdmi5_core.o
+
+ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
+
 obj-$(CONFIG_DRM_OMAP) += omapdrm.o
diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig 
b/drivers/gpu/drm/omapdrm/dss/Kconfig
index 39a30a64448a..157c5601e4be 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -1,16 +1,6 @@
 config OMAP2_DSS_INIT
bool
 
-menuconfig OMAP2_DSS
-tristate "OMAP2+ Display Subsystem support"
-   select VIDEOMODE_HELPERS
-   select OMAP2_DSS_INIT
-   select HDMI
-help
- OMAP2+ Display Subsystem support.
-
-if OMAP2_DSS
-
 config OMAP2_DSS_DEBUG
bool "Debug support"
default n
@@ -126,5 +116,3 @@ config OMAP2_DSS_SLEEP_AFTER_VENC_RESET
 
  This option enables the sleep, and is enabled by default. You can
  disable the sleep if it doesn't cause problems on your platform.
-
-endif
diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile 
b/drivers/gpu/drm/omapdrm/dss/Makefile
index 531b4d8075e5..3db4bf31aeaf 100644
--- a/drivers/gpu/drm/omapdrm/dss/Makefile
+++ b/drivers/gpu/drm/omapdrm/dss/Makefile
@@ -1,26 +1 @@
 obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
-obj-$(CONFIG_OMAP2_DSS) += omapdss.o
-
-# Core DSS files
-omapdss-y := \
-   base.o \
-   display.o \
-   dss-of.o \
-   output.o \
-   core.o \
-   dss.o \
-   dispc.o \
-   dispc_coefs.o \
-   pll.o \
-   video-pll.o
-
-omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
-omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
-omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
-omapdss-$(CONFIG_OMAP2_DSS_DSI) += dsi.o
-omapdss-$(CONFIG_OMAP2_DSS_HDMI_COMMON) += hdmi_common.o hdmi_wp.o hdmi_pll.o \
-   hdmi_phy.o
-omapdss-$(CONFIG_OMAP4_DSS_HDMI) += hdmi4.o hdmi4_core.o
-omapdss-$(CONFIG_OMAP4_DSS_HDMI_CEC) += hdmi4_cec.o
-omapdss-$(CONFIG_OMAP5_DSS_HDMI) += hdmi5.o hdmi5_core.o
-ccflags-$(CONFIG_OMAP2_DSS_DEBUG) += -DDEBUG
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index eff427dd3297..5729f8244bf9 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -5,7 +5,6 @@
 #include 
 #include "omapdss.h"
 
-static bool dss_initialized;
 static const struct 

[PATCH 28/48] drm: omapdrm: dss: Pass DSS pointer to remaining dss functions

2017-10-13 Thread Laurent Pinchart
This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/dss.c   |  9 +
 drivers/gpu/drm/omapdrm/dss/dss.h   |  7 ---
 drivers/gpu/drm/omapdrm/dss/venc.c  | 11 +++
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 7b74c8ee9372..912957c471ce 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -2737,7 +2737,7 @@ static int dispc_ovl_enable(enum omap_plane_id plane, 
bool enable)
 
 static enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum 
omap_channel channel)
 {
-   return dss_get_supported_outputs(channel);
+   return dss_get_supported_outputs(dispc.dss, channel);
 }
 
 static void dispc_lcd_enable_signal_polarity(bool act_high)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 24237ed0557f..98a0da32f217 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -706,9 +706,10 @@ unsigned long dss_get_max_fck_rate(struct dss_device *dss)
return dss->feat->fck_freq_max;
 }
 
-enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel)
+enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
+ enum omap_channel channel)
 {
-   return dss.feat->outputs[channel];
+   return dss->feat->outputs[channel];
 }
 
 static int dss_setup_default_clock(void)
@@ -737,7 +738,7 @@ static int dss_setup_default_clock(void)
return 0;
 }
 
-void dss_set_venc_output(enum omap_dss_venc_type type)
+void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type)
 {
int l = 0;
 
@@ -752,7 +753,7 @@ void dss_set_venc_output(enum omap_dss_venc_type type)
REG_FLD_MOD(DSS_CONTROL, l, 6, 6);
 }
 
-void dss_set_dac_pwrdn_bgz(bool enable)
+void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable)
 {
REG_FLD_MOD(DSS_CONTROL, enable, 5, 5); /* DAC Power-Down Control */
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index cb257ffc8a54..2641d5c6a32a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -286,7 +286,8 @@ void dss_runtime_put(struct dss_device *dss);
 
 unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
 unsigned long dss_get_max_fck_rate(struct dss_device *dss);
-enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
+enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
+ enum omap_channel channel);
 int dss_dpi_select_source(struct dss_device *dss, int port,
  enum omap_channel channel);
 void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
@@ -317,8 +318,8 @@ enum dss_clk_source dss_get_dsi_clk_source(struct 
dss_device *dss,
 enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
   enum omap_channel channel);
 
-void dss_set_venc_output(enum omap_dss_venc_type type);
-void dss_set_dac_pwrdn_bgz(bool enable);
+void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type);
+void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable);
 
 int dss_set_fck_rate(struct dss_device *dss, unsigned long rate);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c 
b/drivers/gpu/drm/omapdrm/dss/venc.c
index 68035c1acf1f..179ef73a5564 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -327,6 +327,7 @@ static struct {
struct mutex venc_lock;
u32 wss_data;
struct regulator *vdda_dac_reg;
+   struct dss_device *dss;
 
struct dss_debugfs_entry *debugfs;
 
@@ -472,8 +473,8 @@ static int venc_power_on(struct omap_dss_device *dssdev)
venc_reset();
venc_write_config(venc_timings_to_config());
 
-   dss_set_venc_output(venc.type);
-   dss_set_dac_pwrdn_bgz(1);
+   dss_set_venc_output(venc.dss, venc.type);
+   dss_set_dac_pwrdn_bgz(venc.dss, 1);
 
l = 0;
 
@@ -503,7 +504,7 @@ static int venc_power_on(struct omap_dss_device *dssdev)
regulator_disable(venc.vdda_dac_reg);
 err1:
venc_write_reg(VENC_OUTPUT_CONTROL, 0);
-   dss_set_dac_pwrdn_bgz(0);
+   dss_set_dac_pwrdn_bgz(venc.dss, 0);
 
venc_runtime_put();
 err0:
@@ -515,7 +516,7 @@ static void venc_power_off(struct omap_dss_device *dssdev)
enum omap_channel channel = dssdev->dispc_channel;
 
venc_write_reg(VENC_OUTPUT_CONTROL, 0);
-   dss_set_dac_pwrdn_bgz(0);
+   

[PATCH 23/48] drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable()

2017-10-13 Thread Laurent Pinchart
This will allow accessing the PLL data to get the DSS device pointer,
removing the need to access the global DSS private data.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.c   | 13 +++--
 drivers/gpu/drm/omapdrm/dss/dss.h   |  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  |  4 ++--
 drivers/gpu/drm/omapdrm/dss/video-pll.c |  6 +++---
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index a83277ebe1ef..7179d02e7451 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -191,17 +191,17 @@ static void dss_restore_context(void)
 #undef SR
 #undef RR
 
-void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable)
+void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable)
 {
unsigned int shift;
unsigned int val;
 
-   if (!dss.syscon_pll_ctrl)
+   if (!pll->dss->syscon_pll_ctrl)
return;
 
val = !enable;
 
-   switch (pll_id) {
+   switch (pll->id) {
case DSS_PLL_VIDEO1:
shift = 0;
break;
@@ -212,12 +212,13 @@ void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool 
enable)
shift = 2;
break;
default:
-   DSSERR("illegal DSS PLL ID %d\n", pll_id);
+   DSSERR("illegal DSS PLL ID %d\n", pll->id);
return;
}
 
-   regmap_update_bits(dss.syscon_pll_ctrl, dss.syscon_pll_ctrl_offset,
-   1 << shift, val << shift);
+   regmap_update_bits(pll->dss->syscon_pll_ctrl,
+  pll->dss->syscon_pll_ctrl_offset,
+  1 << shift, val << shift);
 }
 
 static int dss_ctrl_pll_set_control_mux(enum dss_clk_source clk_src,
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 009b7ef200cd..0b8facf258cf 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -298,7 +298,7 @@ struct dss_pll *dss_video_pll_init(struct dss_device *dss,
   struct regulator *regulator);
 void dss_video_pll_uninit(struct dss_pll *pll);
 
-void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable);
+void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
 
 void dss_sdi_init(int datapairs);
 int dss_sdi_enable(void);
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c 
b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
index 9915354b66c9..4da32c261c30 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c
@@ -48,7 +48,7 @@ static int hdmi_pll_enable(struct dss_pll *dsspll)
r = pm_runtime_get_sync(>pdev->dev);
WARN_ON(r < 0);
 
-   dss_ctrl_pll_enable(DSS_PLL_HDMI, true);
+   dss_ctrl_pll_enable(dsspll, true);
 
r = hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_BOTHON_ALLCLKS);
if (r)
@@ -65,7 +65,7 @@ static void hdmi_pll_disable(struct dss_pll *dsspll)
 
hdmi_wp_set_pll_pwr(wp, HDMI_PLLPWRCMD_ALLOFF);
 
-   dss_ctrl_pll_enable(DSS_PLL_HDMI, false);
+   dss_ctrl_pll_enable(dsspll, false);
 
r = pm_runtime_put_sync(>pdev->dev);
WARN_ON(r < 0 && r != -ENOSYS);
diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c 
b/drivers/gpu/drm/omapdrm/dss/video-pll.c
index 7ef30f61c52b..989a5ee4433a 100644
--- a/drivers/gpu/drm/omapdrm/dss/video-pll.c
+++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c
@@ -66,7 +66,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
if (r)
return r;
 
-   dss_ctrl_pll_enable(pll->id, true);
+   dss_ctrl_pll_enable(pll, true);
 
dss_dpll_enable_scp_clk(vpll);
 
@@ -80,7 +80,7 @@ static int dss_video_pll_enable(struct dss_pll *pll)
 
 err_reset:
dss_dpll_disable_scp_clk(vpll);
-   dss_ctrl_pll_enable(pll->id, false);
+   dss_ctrl_pll_enable(pll, false);
dss_runtime_put(pll->dss);
 
return r;
@@ -94,7 +94,7 @@ static void dss_video_pll_disable(struct dss_pll *pll)
 
dss_dpll_disable_scp_clk(vpll);
 
-   dss_ctrl_pll_enable(pll->id, false);
+   dss_ctrl_pll_enable(pll, false);
 
dss_runtime_put(pll->dss);
 }
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 26/48] drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source()

2017-10-13 Thread Laurent Pinchart
This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 11 +++
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  8 +---
 drivers/gpu/drm/omapdrm/dss/dss.c   | 18 ++
 drivers/gpu/drm/omapdrm/dss/dss.h   |  8 +---
 4 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 1afd2802e807..723828f97196 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -167,6 +167,7 @@ struct dispc_features {
 static struct {
struct platform_device *pdev;
void __iomem*base;
+   struct dss_device *dss;
 
struct dss_debugfs_entry *debugfs;
 
@@ -3116,7 +3117,7 @@ static unsigned long dispc_fclk_rate(void)
unsigned long r;
enum dss_clk_source src;
 
-   src = dss_get_dispc_clk_source();
+   src = dss_get_dispc_clk_source(dispc.dss);
 
if (src == DSS_CLK_SRC_FCK) {
r = dss_get_dispc_clk_rate();
@@ -3143,7 +3144,7 @@ static unsigned long dispc_mgr_lclk_rate(enum 
omap_channel channel)
if (!dss_mgr_is_lcd(channel))
return dispc_fclk_rate();
 
-   src = dss_get_lcd_clk_source(channel);
+   src = dss_get_lcd_clk_source(dispc.dss, channel);
 
if (src == DSS_CLK_SRC_FCK) {
r = dss_get_dispc_clk_rate();
@@ -3223,7 +3224,7 @@ static void dispc_dump_clocks_channel(struct seq_file *s, 
enum omap_channel chan
 
seq_printf(s, "- %s -\n", mgr_desc[channel].name);
 
-   lcd_clk_src = dss_get_lcd_clk_source(channel);
+   lcd_clk_src = dss_get_lcd_clk_source(dispc.dss, channel);
 
seq_printf(s, "%s clk source = %s\n", mgr_desc[channel].name,
dss_get_clk_source_name(lcd_clk_src));
@@ -3240,7 +3241,7 @@ void dispc_dump_clocks(struct seq_file *s)
 {
int lcd;
u32 l;
-   enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source();
+   enum dss_clk_source dispc_clk_src = dss_get_dispc_clk_source(dispc.dss);
 
if (dispc_runtime_get())
return;
@@ -4542,12 +4543,14 @@ static int dispc_bind(struct device *dev, struct device 
*master, void *data)
 {
struct platform_device *pdev = to_platform_device(dev);
const struct soc_device_attribute *soc;
+   struct dss_device *dss = dss_get_device(master);
u32 rev;
int r = 0;
struct resource *dispc_mem;
struct device_node *np = pdev->dev.of_node;
 
dispc.pdev = pdev;
+   dispc.dss = dss;
 
spin_lock_init(_lock);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 6d60882dfd10..7fb048023fd0 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -1292,8 +1292,10 @@ static unsigned long dsi_fclk_rate(struct 
platform_device *dsidev)
 {
unsigned long r;
struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   enum dss_clk_source source;
 
-   if (dss_get_dsi_clk_source(dsi->module_id) == DSS_CLK_SRC_FCK) {
+   source = dss_get_dsi_clk_source(dsi->dss, dsi->module_id);
+   if (source == DSS_CLK_SRC_FCK) {
/* DSI FCLK source is DSS_CLK_FCK */
r = clk_get_rate(dsi->dss_clk);
} else {
@@ -1512,8 +1514,8 @@ static void dsi_dump_dsidev_clocks(struct platform_device 
*dsidev,
int dsi_module = dsi->module_id;
struct dss_pll *pll = >pll;
 
-   dispc_clk_src = dss_get_dispc_clk_source();
-   dsi_clk_src = dss_get_dsi_clk_source(dsi_module);
+   dispc_clk_src = dss_get_dispc_clk_source(dsi->dss);
+   dsi_clk_src = dss_get_dsi_clk_source(dsi->dss, dsi_module);
 
if (dsi_runtime_get(dsidev))
return;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index bd8f7abf0450..ba7a2bf1ec09 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -610,25 +610,27 @@ void dss_select_lcd_clk_source(struct dss_device *dss,
dss->lcd_clk_source[idx] = clk_src;
 }
 
-enum dss_clk_source dss_get_dispc_clk_source(void)
+enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss)
 {
-   return dss.dispc_clk_source;
+   return dss->dispc_clk_source;
 }
 
-enum dss_clk_source dss_get_dsi_clk_source(int dsi_module)
+enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
+  int dsi_module)
 {
-   return dss.dsi_clk_source[dsi_module];
+   return dss->dsi_clk_source[dsi_module];
 }
 
-enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel)
+enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,

[PATCH 22/48] drm: omapdrm: dss: Pass DSS private structure to runtime PM functions

2017-10-13 Thread Laurent Pinchart
To prepare for the removal of the global variable storing DSS private
data, pass its pointer to the dss_runtime_{get,put}() functions.

As this requires getting hold of the DSS private structure in the
callers, we expose the structure through an opaque pointer that can be
retrieved through a new dss_device_get() function. The function
currently returns a pointer to the global data structure, and will later
be updated to get the pointer from device driver data when the DSS
private structure will be allocated dynamically.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dsi.c   |  7 +--
 drivers/gpu/drm/omapdrm/dss/dss.c   | 37 -
 drivers/gpu/drm/omapdrm/dss/dss.h   | 13 
 drivers/gpu/drm/omapdrm/dss/hdmi.h  |  6 --
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  3 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  3 ++-
 drivers/gpu/drm/omapdrm/dss/hdmi_pll.c  | 10 +
 drivers/gpu/drm/omapdrm/dss/video-pll.c | 12 ++-
 8 files changed, 58 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index a64e6a39ebf1..1dab308c9bc1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5333,7 +5333,8 @@ static const struct dss_pll_hw dss_omap5_dsi_pll_hw = {
.has_refsel = true,
 };
 
-static int dsi_init_pll_data(struct platform_device *dsidev)
+static int dsi_init_pll_data(struct dss_device *dss,
+struct platform_device *dsidev)
 {
struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
struct dss_pll *pll = >pll;
@@ -5352,6 +5353,7 @@ static int dsi_init_pll_data(struct platform_device 
*dsidev)
pll->base = dsi->pll_base;
pll->hw = dsi->data->pll_hw;
pll->ops = _pll_ops;
+   pll->dss = dss;
 
r = dss_pll_register(pll);
if (r)
@@ -5428,6 +5430,7 @@ static const struct soc_device_attribute 
dsi_soc_devices[] = {
 static int dsi_bind(struct device *dev, struct device *master, void *data)
 {
struct platform_device *dsidev = to_platform_device(dev);
+   struct dss_device *dss = dss_get_device(master);
const struct soc_device_attribute *soc;
const struct dsi_module_id_data *d;
u32 rev;
@@ -5538,7 +5541,7 @@ static int dsi_bind(struct device *dev, struct device 
*master, void *data)
if (r)
return r;
 
-   dsi_init_pll_data(dsidev);
+   dsi_init_pll_data(dss, dsidev);
 
pm_runtime_enable(>dev);
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index b45641f6a844..a83277ebe1ef 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -93,7 +93,7 @@ struct dss_features {
bool has_lcd_clk_src;
 };
 
-static struct {
+struct dss_device {
struct platform_device *pdev;
struct omap_drm_private drm;
 
@@ -125,7 +125,9 @@ static struct {
 
struct dss_pll  *video1_pll;
struct dss_pll  *video2_pll;
-} dss;
+};
+
+static struct dss_device dss;
 
 static const char * const dss_generic_clk_source_names[] = {
[DSS_CLK_SRC_FCK]   = "FCK",
@@ -382,7 +384,7 @@ static void dss_dump_clocks(struct seq_file *s)
const char *fclk_name;
unsigned long fclk_rate;
 
-   if (dss_runtime_get())
+   if (dss_runtime_get())
return;
 
seq_printf(s, "- DSS -\n");
@@ -394,7 +396,7 @@ static void dss_dump_clocks(struct seq_file *s)
fclk_name,
fclk_rate);
 
-   dss_runtime_put();
+   dss_runtime_put();
 }
 #endif
 
@@ -402,7 +404,7 @@ static int dss_dump_regs(struct seq_file *s, void *p)
 {
 #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dss_read_reg(r))
 
-   if (dss_runtime_get())
+   if (dss_runtime_get())
return 0;
 
DUMPREG(DSS_REVISION);
@@ -416,7 +418,7 @@ static int dss_dump_regs(struct seq_file *s, void *p)
DUMPREG(DSS_SDI_STATUS);
}
 
-   dss_runtime_put();
+   dss_runtime_put();
 #undef DUMPREG
return 0;
 }
@@ -889,27 +891,32 @@ static void dss_put_clocks(void)
clk_put(dss.parent_clk);
 }
 
-int dss_runtime_get(void)
+int dss_runtime_get(struct dss_device *dss)
 {
int r;
 
DSSDBG("dss_runtime_get\n");
 
-   r = pm_runtime_get_sync(>dev);
+   r = pm_runtime_get_sync(>pdev->dev);
WARN_ON(r < 0);
return r < 0 ? r : 0;
 }
 
-void dss_runtime_put(void)
+void dss_runtime_put(struct dss_device *dss)
 {
int r;
 
DSSDBG("dss_runtime_put\n");
 
-   r = pm_runtime_put_sync(>dev);
+   r = pm_runtime_put_sync(>pdev->dev);
WARN_ON(r < 0 && r != -ENOSYS && r != -EBUSY);
 }
 
+struct dss_device *dss_get_device(struct device *dev)
+{
+   return 
+}
+
 /* DEBUGFS */
 #if 

[PATCH 24/48] drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions

2017-10-13 Thread Laurent Pinchart
This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.c |  8 
 drivers/gpu/drm/omapdrm/dss/dss.h | 14 --
 drivers/gpu/drm/omapdrm/dss/sdi.c | 13 -
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 7179d02e7451..f8b71e24a07d 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -287,7 +287,7 @@ static int dss_ctrl_pll_set_control_mux(enum dss_clk_source 
clk_src,
return 0;
 }
 
-void dss_sdi_init(int datapairs)
+void dss_sdi_init(struct dss_device *dss, int datapairs)
 {
u32 l;
 
@@ -306,7 +306,7 @@ void dss_sdi_init(int datapairs)
dss_write_reg(DSS_PLL_CONTROL, l);
 }
 
-int dss_sdi_enable(void)
+int dss_sdi_enable(struct dss_device *dss)
 {
unsigned long timeout;
 
@@ -364,7 +364,7 @@ int dss_sdi_enable(void)
return -ETIMEDOUT;
 }
 
-void dss_sdi_disable(void)
+void dss_sdi_disable(struct dss_device *dss)
 {
dispc_lcd_enable_signal(0);
 
@@ -1226,7 +1226,7 @@ static int dss_init_ports(struct platform_device *pdev)
dpi_init_port(pdev, port, dss.feat->model);
break;
case OMAP_DISPLAY_TYPE_SDI:
-   sdi_init_port(pdev, port);
+   sdi_init_port(, pdev, port);
break;
default:
break;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index 0b8facf258cf..08651f101518 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -300,9 +300,9 @@ void dss_video_pll_uninit(struct dss_pll *pll);
 
 void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
 
-void dss_sdi_init(int datapairs);
-int dss_sdi_enable(void);
-void dss_sdi_disable(void);
+void dss_sdi_init(struct dss_device *dss, int datapairs);
+int dss_sdi_enable(struct dss_device *dss);
+void dss_sdi_disable(struct dss_device *dss);
 
 void dss_select_dsi_clk_source(int dsi_module,
enum dss_clk_source clk_src);
@@ -323,11 +323,13 @@ bool dss_div_calc(unsigned long pck, unsigned long 
fck_min,
 
 /* SDI */
 #ifdef CONFIG_OMAP2_DSS_SDI
-int sdi_init_port(struct platform_device *pdev, struct device_node *port);
+int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
+ struct device_node *port);
 void sdi_uninit_port(struct device_node *port);
 #else
-static inline int sdi_init_port(struct platform_device *pdev,
-   struct device_node *port)
+static inline int sdi_init_port(struct dss_device *dss,
+   struct platform_device *pdev,
+   struct device_node *port)
 {
return 0;
 }
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
b/drivers/gpu/drm/omapdrm/dss/sdi.c
index d18ad58c5a19..39cb5c8af0dc 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -33,6 +33,7 @@
 
 static struct {
struct platform_device *pdev;
+   struct dss_device *dss;
 
bool update_enabled;
struct regulator *vdds_sdi_reg;
@@ -189,8 +190,8 @@ static int sdi_display_enable(struct omap_dss_device 
*dssdev)
 */
dispc_mgr_set_clock_div(channel, _config.clock_info);
 
-   dss_sdi_init(sdi.datapairs);
-   r = dss_sdi_enable();
+   dss_sdi_init(sdi.dss, sdi.datapairs);
+   r = dss_sdi_enable(sdi.dss);
if (r)
goto err_sdi_enable;
mdelay(2);
@@ -202,7 +203,7 @@ static int sdi_display_enable(struct omap_dss_device 
*dssdev)
return 0;
 
 err_mgr_enable:
-   dss_sdi_disable();
+   dss_sdi_disable(sdi.dss);
 err_sdi_enable:
 err_set_dss_clock_div:
 err_calc_clock_div:
@@ -219,7 +220,7 @@ static void sdi_display_disable(struct omap_dss_device 
*dssdev)
 
dss_mgr_disable(channel);
 
-   dss_sdi_disable();
+   dss_sdi_disable(sdi.dss);
 
dispc_runtime_put();
 
@@ -347,7 +348,8 @@ static void sdi_uninit_output(struct platform_device *pdev)
omapdss_unregister_output(out);
 }
 
-int sdi_init_port(struct platform_device *pdev, struct device_node *port)
+int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
+ struct device_node *port)
 {
struct device_node *ep;
u32 datapairs;
@@ -364,6 +366,7 @@ int sdi_init_port(struct platform_device *pdev, struct 
device_node *port)
}
 
sdi.datapairs = datapairs;
+   sdi.dss = dss;
 
of_node_put(ep);
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list

[PATCH 25/48] drm: omapdrm: dss: Pass DSS pointer to dss_ops operations

2017-10-13 Thread Laurent Pinchart
This removes the need to access the global DSS private data in those
functions (both for the current accesses and the future ones that will
be introduced when allocating the DSS device dynamically).

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c   | 12 ---
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 18 +-
 drivers/gpu/drm/omapdrm/dss/dss.c   | 68 ++---
 drivers/gpu/drm/omapdrm/dss/dss.h   | 25 --
 drivers/gpu/drm/omapdrm/dss/hdmi.h  |  1 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  3 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  3 +-
 7 files changed, 77 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index c7346df60929..38a4c037783a 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -40,6 +40,7 @@
 struct dpi_data {
struct platform_device *pdev;
enum dss_model dss_model;
+   struct dss_device *dss;
 
struct regulator *vdds_dsi_reg;
enum dss_clk_source clk_src;
@@ -304,7 +305,7 @@ static int dpi_set_pll_clk(struct dpi_data *dpi, enum 
omap_channel channel,
if (r)
return r;
 
-   dss_select_lcd_clk_source(channel, dpi->clk_src);
+   dss_select_lcd_clk_source(dpi->dss, channel, dpi->clk_src);
 
dpi->mgr_config.clock_info = ctx.dispc_cinfo;
 
@@ -414,7 +415,7 @@ static int dpi_display_enable(struct omap_dss_device 
*dssdev)
if (r)
goto err_get_dispc;
 
-   r = dss_dpi_select_source(out->port_num, channel);
+   r = dss_dpi_select_source(dpi->dss, out->port_num, channel);
if (r)
goto err_src_sel;
 
@@ -466,7 +467,7 @@ static void dpi_display_disable(struct omap_dss_device 
*dssdev)
dss_mgr_disable(channel);
 
if (dpi->pll) {
-   dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
+   dss_select_lcd_clk_source(dpi->dss, channel, DSS_CLK_SRC_FCK);
dss_pll_disable(dpi->pll);
}
 
@@ -750,8 +751,8 @@ static void dpi_uninit_output_port(struct device_node *port)
omapdss_unregister_output(out);
 }
 
-int dpi_init_port(struct platform_device *pdev, struct device_node *port,
- enum dss_model dss_model)
+int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
+ struct device_node *port, enum dss_model dss_model)
 {
struct dpi_data *dpi;
struct device_node *ep;
@@ -778,6 +779,7 @@ int dpi_init_port(struct platform_device *pdev, struct 
device_node *port,
 
dpi->pdev = pdev;
dpi->dss_model = dss_model;
+   dpi->dss = dss;
port->data = dpi;
 
mutex_init(>lock);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 1dab308c9bc1..6d60882dfd10 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -345,6 +345,7 @@ struct dsi_data {
 
struct clk *dss_clk;
struct regmap *syscon;
+   struct dss_device *dss;
 
struct dispc_clock_info user_dispc_cinfo;
struct dss_pll_clock_info user_dsi_cinfo;
@@ -4217,7 +4218,7 @@ static int dsi_display_init_dispc(struct platform_device 
*dsidev,
struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
int r;
 
-   dss_select_lcd_clk_source(channel, dsi->module_id == 0 ?
+   dss_select_lcd_clk_source(dsi->dss, channel, dsi->module_id == 0 ?
DSS_CLK_SRC_PLL1_1 :
DSS_CLK_SRC_PLL2_1);
 
@@ -4271,7 +4272,7 @@ static int dsi_display_init_dispc(struct platform_device 
*dsidev,
dss_mgr_unregister_framedone_handler(channel,
dsi_framedone_irq_callback, dsidev);
 err:
-   dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
+   dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
return r;
 }
 
@@ -4284,7 +4285,7 @@ static void dsi_display_uninit_dispc(struct 
platform_device *dsidev,
dss_mgr_unregister_framedone_handler(channel,
dsi_framedone_irq_callback, dsidev);
 
-   dss_select_lcd_clk_source(channel, DSS_CLK_SRC_FCK);
+   dss_select_lcd_clk_source(dsi->dss, channel, DSS_CLK_SRC_FCK);
 }
 
 static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
@@ -4317,9 +4318,9 @@ static int dsi_display_init_dsi(struct platform_device 
*dsidev)
if (r)
goto err1;
 
-   dss_select_dsi_clk_source(dsi->module_id, dsi->module_id == 0 ?
-   DSS_CLK_SRC_PLL1_2 :
-   DSS_CLK_SRC_PLL2_2);
+   dss_select_dsi_clk_source(dsi->dss, dsi->module_id,
+ dsi->module_id == 0 ?
+ DSS_CLK_SRC_PLL1_2 : DSS_CLK_SRC_PLL2_2);
 
DSSDBG("PLL OK\n");
 
@@ -4351,7 +4352,7 @@ static int 

[PATCH 19/48] drm: omapdrm: displays: Get encoder source at connect time

2017-10-13 Thread Laurent Pinchart
The encoder drivers need a handle to the source they are connected to in
order to control the source.

All drivers get that handle at probe time, resulting in probe deferral
when the source hasn't been probed yet. However they don't need the
handle until their connect handler is called.

Move retrieval of the source handle to the connect handler to avoid
probe deferrals.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c  | 35 ++--
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c  | 36 ++--
 .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c   | 66 --
 3 files changed, 54 insertions(+), 83 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index b28ec62267b1..b3bb64b477fa 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -36,7 +36,7 @@ static int opa362_connect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *in;
int r;
 
dev_dbg(dssdev->dev, "connect\n");
@@ -44,13 +44,22 @@ static int opa362_connect(struct omap_dss_device *dssdev,
if (omapdss_device_is_connected(dssdev))
return -EBUSY;
 
+   in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+   if (IS_ERR(in)) {
+   dev_err(dssdev->dev, "failed to find video source\n");
+   return PTR_ERR(in);
+   }
+
r = in->ops.atv->connect(in, dssdev);
-   if (r)
+   if (r) {
+   omap_dss_put_device(in);
return r;
+   }
 
dst->src = dssdev;
dssdev->dst = dst;
 
+   ddata->in = in;
return 0;
 }
 
@@ -74,6 +83,9 @@ static void opa362_disconnect(struct omap_dss_device *dssdev,
dssdev->dst = NULL;
 
in->ops.atv->disconnect(in, >dssdev);
+
+   omap_dss_put_device(in);
+   ddata->in = NULL;
 }
 
 static int opa362_enable(struct omap_dss_device *dssdev)
@@ -171,9 +183,8 @@ static const struct omapdss_atv_ops opa362_atv_ops = {
 
 static int opa362_probe(struct platform_device *pdev)
 {
-   struct device_node *node = pdev->dev.of_node;
struct panel_drv_data *ddata;
-   struct omap_dss_device *dssdev, *in;
+   struct omap_dss_device *dssdev;
struct gpio_desc *gpio;
int r;
 
@@ -191,14 +202,6 @@ static int opa362_probe(struct platform_device *pdev)
 
ddata->enable_gpio = gpio;
 
-   in = omapdss_of_find_source_for_first_ep(node);
-   if (IS_ERR(in)) {
-   dev_err(>dev, "failed to find video source\n");
-   return PTR_ERR(in);
-   }
-
-   ddata->in = in;
-
dssdev = >dssdev;
dssdev->ops.atv = _atv_ops;
dssdev->dev = >dev;
@@ -209,20 +212,16 @@ static int opa362_probe(struct platform_device *pdev)
r = omapdss_register_output(dssdev);
if (r) {
dev_err(>dev, "Failed to register output\n");
-   goto err_reg;
+   return r;
}
 
return 0;
-err_reg:
-   omap_dss_put_device(ddata->in);
-   return r;
 }
 
 static int __exit opa362_remove(struct platform_device *pdev)
 {
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
-   struct omap_dss_device *in = ddata->in;
 
omapdss_unregister_output(>dssdev);
 
@@ -234,8 +233,6 @@ static int __exit opa362_remove(struct platform_device 
*pdev)
if (omapdss_device_is_connected(dssdev))
opa362_disconnect(dssdev, dssdev->dst);
 
-   omap_dss_put_device(in);
-
return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index 9e0ab4e77366..0d640f8c0689 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -32,19 +32,28 @@ static int tfp410_connect(struct omap_dss_device *dssdev,
struct omap_dss_device *dst)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *in;
int r;
 
if (omapdss_device_is_connected(dssdev))
return -EBUSY;
 
+   in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+   if (IS_ERR(in)) {
+   dev_err(dssdev->dev, "failed to find video source\n");
+   return PTR_ERR(in);
+   }
+
r = in->ops.dpi->connect(in, dssdev);
-   if (r)
+   if (r) {
+   omap_dss_put_device(in);
return r;
+   }
 
dst->src = dssdev;
dssdev->dst = dst;
 
+   ddata->in = in;

[PATCH 21/48] drm: omapdrm: dss: Support passing private data to debugfs show handlers

2017-10-13 Thread Laurent Pinchart
To simplify implementation of debugfs seq_file show handlers, the driver
passes the pointer to the show function through the debugfs_create_file
data pointer. This prevents using the pointer to pass driver private
data to the show handler, and requires all handlers to use global
variables to access private data.

To prepare for the removal of global private data in the driver, rework
the debugfs infrastructure to allow passing a private data pointer to
show handlers.

The price to pay is explicit removal of debugfs files to free the
internally allocated memory. This is desirable anyway as debugfs entries
should be removed when a component driver is unbound, otherwise crashes
will occur due to access to freed memory when the components will be
dynamically allocated instead of stored in global variables.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dispc.c | 13 --
 drivers/gpu/drm/omapdrm/dss/dsi.c   | 40 +++-
 drivers/gpu/drm/omapdrm/dss/dss.c   | 92 +
 drivers/gpu/drm/omapdrm/dss/dss.h   | 27 +++
 drivers/gpu/drm/omapdrm/dss/hdmi.h  |  2 +
 drivers/gpu/drm/omapdrm/dss/hdmi4.c |  9 ++--
 drivers/gpu/drm/omapdrm/dss/hdmi5.c |  9 ++--
 drivers/gpu/drm/omapdrm/dss/venc.c  | 11 +++--
 8 files changed, 140 insertions(+), 63 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index f0ae6be36a4e..1afd2802e807 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -168,6 +168,8 @@ static struct {
struct platform_device *pdev;
void __iomem*base;
 
+   struct dss_debugfs_entry *debugfs;
+
int irq;
irq_handler_t user_handler;
void *user_data;
@@ -3269,7 +3271,7 @@ void dispc_dump_clocks(struct seq_file *s)
dispc_runtime_put();
 }
 
-static void dispc_dump_regs(struct seq_file *s)
+static int dispc_dump_regs(struct seq_file *s, void *p)
 {
int i, j;
const char *mgr_names[] = {
@@ -3290,7 +3292,7 @@ static void dispc_dump_regs(struct seq_file *s)
 #define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
 
if (dispc_runtime_get())
-   return;
+   return 0;
 
/* DISPC common registers */
DUMPREG(DISPC_REVISION);
@@ -3462,6 +3464,8 @@ static void dispc_dump_regs(struct seq_file *s)
 
 #undef DISPC_REG
 #undef DUMPREG
+
+   return 0;
 }
 
 /* calculate clock rates using dividers in cinfo */
@@ -4606,7 +4610,8 @@ static int dispc_bind(struct device *dev, struct device 
*master, void *data)
 
dispc_set_ops(_ops);
 
-   dss_debugfs_create_file("dispc", dispc_dump_regs);
+   dispc.debugfs = dss_debugfs_create_file("dispc", dispc_dump_regs,
+   );
 
return 0;
 
@@ -4618,6 +4623,8 @@ static int dispc_bind(struct device *dev, struct device 
*master, void *data)
 static void dispc_unbind(struct device *dev, struct device *master,
   void *data)
 {
+   dss_debugfs_remove_file(dispc.debugfs);
+
dispc_set_ops(NULL);
 
pm_runtime_disable(dev);
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c 
b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 6a1569149453..a64e6a39ebf1 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -402,6 +402,10 @@ struct dsi_data {
 #endif
int debug_read;
int debug_write;
+   struct {
+   struct dss_debugfs_entry *irqs;
+   struct dss_debugfs_entry *regs;
+   } debugfs;
 
 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
spinlock_t irq_stats_lock;
@@ -1659,18 +1663,20 @@ static void dsi_dump_dsidev_irqs(struct platform_device 
*dsidev,
 #undef PIS
 }
 
-static void dsi1_dump_irqs(struct seq_file *s)
+static int dsi1_dump_irqs(struct seq_file *s, void *p)
 {
struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
 
dsi_dump_dsidev_irqs(dsidev, s);
+   return 0;
 }
 
-static void dsi2_dump_irqs(struct seq_file *s)
+static int dsi2_dump_irqs(struct seq_file *s, void *p)
 {
struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
 
dsi_dump_dsidev_irqs(dsidev, s);
+   return 0;
 }
 #endif
 
@@ -1758,18 +1764,20 @@ static void dsi_dump_dsidev_regs(struct platform_device 
*dsidev,
 #undef DUMPREG
 }
 
-static void dsi1_dump_regs(struct seq_file *s)
+static int dsi1_dump_regs(struct seq_file *s, void *p)
 {
struct platform_device *dsidev = dsi_get_dsidev_from_id(0);
 
dsi_dump_dsidev_regs(dsidev, s);
+   return 0;
 }
 
-static void dsi2_dump_regs(struct seq_file *s)
+static int dsi2_dump_regs(struct seq_file *s, void *p)
 {
struct platform_device *dsidev = dsi_get_dsidev_from_id(1);
 
dsi_dump_dsidev_regs(dsidev, s);
+   return 0;
 }
 
 enum dsi_cio_power_state {
@@ -5567,15 +5575,22 @@ static int 

[PATCH 16/48] drm: omapdrm: displays: Remove OF node check in panel drivers

2017-10-13 Thread Laurent Pinchart
No panel is instantiated through platform data anymore, there is no
need to check for OF node presence.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c| 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c  | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c | 3 ---
 drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c | 3 ---
 8 files changed, 24 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index e065f7e10cca..6468a765f3d1 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -231,9 +231,6 @@ static int panel_dpi_probe(struct platform_device *pdev)
struct omap_dss_device *dssdev;
int r;
 
-   if (!pdev->dev.of_node)
-   return -ENODEV;
-
ddata = devm_kzalloc(>dev, sizeof(*ddata), GFP_KERNEL);
if (ddata == NULL)
return -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index bdc0e8a3832d..aac14f399657 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -1168,9 +1168,6 @@ static int dsicm_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ddata);
ddata->pdev = pdev;
 
-   if (!pdev->dev.of_node)
-   return -ENODEV;
-
r = dsicm_probe_of(pdev);
if (r)
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c 
b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
index 74d13969b9ca..b955aa615a5f 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
@@ -268,9 +268,6 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
 
ddata->spi = spi;
 
-   if (!spi->dev.of_node)
-   return -ENODEV;
-
r = lb035q02_probe_of(spi);
if (r)
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c 
b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
index df8132d3b9c6..70fa5a04c00e 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
@@ -277,9 +277,6 @@ static int nec_8048_probe(struct spi_device *spi)
 
ddata->spi = spi;
 
-   if (!spi->dev.of_node)
-   return -ENODEV;
-
r = nec_8048_probe_of(spi);
if (r)
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c 
b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
index 98d170aecaba..99048e430871 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
@@ -268,9 +268,6 @@ static int sharp_ls_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, ddata);
 
-   if (!pdev->dev.of_node)
-   return -ENODEV;
-
r = sharp_ls_probe_of(pdev);
if (r)
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
index 06d7d8362a73..cc5e9a68726a 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
@@ -720,9 +720,6 @@ static int acx565akm_probe(struct spi_device *spi)
 
dev_dbg(>dev, "%s\n", __func__);
 
-   if (!spi->dev.of_node)
-   return -ENODEV;
-
spi->mode = SPI_MODE_3;
 
ddata = devm_kzalloc(>dev, sizeof(*ddata), GFP_KERNEL);
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c 
b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
index 0a38a0e8c925..34d8f42fefbe 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
@@ -404,9 +404,6 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
 
ddata->spi_dev = spi;
 
-   if (!spi->dev.of_node)
-   return -ENODEV;
-
r = td028ttec1_probe_of(spi);
if (r)
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c 
b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
index ac4a6d4d134c..06fb5a995002 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
@@ -509,9 +509,6 @@ static int 

[PATCH 14/48] drm: omapdrm: displays: Remove OF node check in connector drivers

2017-10-13 Thread Laurent Pinchart
No connector is instantiated through platform data anymore, there is no
need to check for OF node presence.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c | 3 ---
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   | 3 ---
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  | 3 ---
 3 files changed, 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index d3611233e264..44c7d9238b54 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -196,9 +196,6 @@ static int tvc_probe(struct platform_device *pdev)
struct omap_dss_device *dssdev;
int r;
 
-   if (!pdev->dev.of_node)
-   return -ENODEV;
-
ddata = devm_kzalloc(>dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
return -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 05fa24a518c8..7728b5425d19 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -275,9 +275,6 @@ static int dvic_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, ddata);
 
-   if (!pdev->dev.of_node)
-   return -ENODEV;
-
r = dvic_probe_of(pdev);
if (r)
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
index 4600d3841c25..b8d74fba4f45 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
@@ -336,9 +336,6 @@ static int hdmic_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ddata);
ddata->dev = >dev;
 
-   if (!pdev->dev.of_node)
-   return -ENODEV;
-
r = hdmic_probe_of(pdev);
if (r)
return r;
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 15/48] drm: omapdrm: displays: Remove OF node check in encoder drivers

2017-10-13 Thread Laurent Pinchart
No encoder is instantiated through platform data anymore, there is no
need to check for OF node presence.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/encoder-opa362.c| 5 -
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c| 3 ---
 drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 3 ---
 3 files changed, 11 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
index b1f6aa09f699..b28ec62267b1 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
@@ -179,11 +179,6 @@ static int opa362_probe(struct platform_device *pdev)
 
dev_dbg(>dev, "probe\n");
 
-   if (node == NULL) {
-   dev_err(>dev, "Unable to find device tree\n");
-   return -EINVAL;
-   }
-
ddata = devm_kzalloc(>dev, sizeof(*ddata), GFP_KERNEL);
if (!ddata)
return -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index b8e420c7d680..9e0ab4e77366 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -201,9 +201,6 @@ static int tfp410_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, ddata);
 
-   if (!pdev->dev.of_node)
-   return -ENODEV;
-
r = tfp410_probe_of(pdev);
if (r)
return r;
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
index e3d98d78fc40..6c478140a52e 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
@@ -299,9 +299,6 @@ static int tpd_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, ddata);
 
-   if (!pdev->dev.of_node)
-   return -ENODEV;
-
r = tpd_probe_of(pdev);
if (r)
return r;
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 18/48] drm: omapdrm: displays: Get panel source at connect time

2017-10-13 Thread Laurent Pinchart
The connector drivers need a handle to the source they are connected to
in order to control the source.

All drivers get that handle at probe time, resulting in probe deferral
when the source hasn't been probed yet. However they don't need the
handle until their connect handler is called.

Move retrieval of the source handle to the connect handler to avoid
probe deferrals.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/panel-dpi.c   | 35 +++-
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c| 27 +++--
 .../omapdrm/displays/panel-lgphilips-lb035q02.c| 35 +++-
 .../drm/omapdrm/displays/panel-nec-nl8048hl11.c| 39 --
 .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c | 35 +++-
 .../drm/omapdrm/displays/panel-sony-acx565akm.c| 26 ++--
 .../drm/omapdrm/displays/panel-tpo-td028ttec1.c| 46 +++---
 .../drm/omapdrm/displays/panel-tpo-td043mtea1.c| 29 +++---
 8 files changed, 119 insertions(+), 153 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
index 6468a765f3d1..e48c4a7d5276 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c
@@ -38,16 +38,25 @@ struct panel_drv_data {
 static int panel_dpi_connect(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *in;
int r;
 
if (omapdss_device_is_connected(dssdev))
return 0;
 
+   in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+   if (IS_ERR(in)) {
+   dev_err(dssdev->dev, "failed to find video source\n");
+   return PTR_ERR(in);
+   }
+
r = in->ops.dpi->connect(in, dssdev);
-   if (r)
+   if (r) {
+   omap_dss_put_device(in);
return r;
+   }
 
+   ddata->in = in;
return 0;
 }
 
@@ -60,6 +69,9 @@ static void panel_dpi_disconnect(struct omap_dss_device 
*dssdev)
return;
 
in->ops.dpi->disconnect(in, dssdev);
+
+   omap_dss_put_device(in);
+   ddata->in = NULL;
 }
 
 static int panel_dpi_enable(struct omap_dss_device *dssdev)
@@ -165,7 +177,6 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct device_node *node = pdev->dev.of_node;
struct device_node *bl_node;
-   struct omap_dss_device *in;
int r;
struct display_timing timing;
struct gpio_desc *gpio;
@@ -207,15 +218,6 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
 
videomode_from_timing(, >vm);
 
-   in = omapdss_of_find_source_for_first_ep(node);
-   if (IS_ERR(in)) {
-   dev_err(>dev, "failed to find video source\n");
-   r = PTR_ERR(in);
-   goto error_free_backlight;
-   }
-
-   ddata->in = in;
-
return 0;
 
 error_free_backlight:
@@ -251,29 +253,22 @@ static int panel_dpi_probe(struct platform_device *pdev)
r = omapdss_register_display(dssdev);
if (r) {
dev_err(>dev, "Failed to register panel\n");
-   goto err_reg;
+   return r;
}
 
return 0;
-
-err_reg:
-   omap_dss_put_device(ddata->in);
-   return r;
 }
 
 static int __exit panel_dpi_remove(struct platform_device *pdev)
 {
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
-   struct omap_dss_device *in = ddata->in;
 
omapdss_unregister_display(dssdev);
 
panel_dpi_disable(dssdev);
panel_dpi_disconnect(dssdev);
 
-   omap_dss_put_device(in);
-
if (ddata->backlight)
put_device(>backlight->dev);
 
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index aac14f399657..1262b7b08ba2 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -703,17 +703,23 @@ static int dsicm_panel_reset(struct panel_drv_data *ddata)
 static int dsicm_connect(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
struct device *dev = >pdev->dev;
+   struct omap_dss_device *in;
int r;
 
if (omapdss_device_is_connected(dssdev))
return 0;
 
+   in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+   if (IS_ERR(in)) {
+   dev_err(dssdev->dev, "failed to find video source\n");
+   return PTR_ERR(in);
+   }
+
r = in->ops.dsi->connect(in, dssdev);
if (r) {

[PATCH 17/48] drm: omapdrm: displays: Get connector source at connect time

2017-10-13 Thread Laurent Pinchart
The connector drivers need a handle to the source they are connected to
in order to control the source.

All drivers get that handle at probe time, resulting in probe deferral
when the source hasn't been probed yet. However they don't need the
handle until their connect handler is called.

Move retrieval of the source handle to the connect handler to avoid
probe deferrals.

Signed-off-by: Laurent Pinchart 
---
 .../gpu/drm/omapdrm/displays/connector-analog-tv.c | 45 --
 drivers/gpu/drm/omapdrm/displays/connector-dvi.c   | 31 +++
 drivers/gpu/drm/omapdrm/displays/connector-hdmi.c  | 37 --
 3 files changed, 46 insertions(+), 67 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 44c7d9238b54..f07546b8e8dd 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -45,7 +45,7 @@ static const struct videomode tvc_pal_vm = {
 static int tvc_connect(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *in;
int r;
 
dev_dbg(ddata->dev, "connect\n");
@@ -53,10 +53,19 @@ static int tvc_connect(struct omap_dss_device *dssdev)
if (omapdss_device_is_connected(dssdev))
return 0;
 
+   in = omapdss_of_find_source_for_first_ep(ddata->dev->of_node);
+   if (IS_ERR(in)) {
+   dev_err(ddata->dev, "failed to find video source\n");
+   return PTR_ERR(in);
+   }
+
r = in->ops.atv->connect(in, dssdev);
-   if (r)
+   if (r) {
+   omap_dss_put_device(in);
return r;
+   }
 
+   ddata->in = in;
return 0;
 }
 
@@ -71,6 +80,9 @@ static void tvc_disconnect(struct omap_dss_device *dssdev)
return;
 
in->ops.atv->disconnect(in, dssdev);
+
+   omap_dss_put_device(in);
+   ddata->in = NULL;
 }
 
 static int tvc_enable(struct omap_dss_device *dssdev)
@@ -173,23 +185,6 @@ static struct omap_dss_driver tvc_driver = {
.set_wss= tvc_set_wss,
 };
 
-static int tvc_probe_of(struct platform_device *pdev)
-{
-   struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-   struct device_node *node = pdev->dev.of_node;
-   struct omap_dss_device *in;
-
-   in = omapdss_of_find_source_for_first_ep(node);
-   if (IS_ERR(in)) {
-   dev_err(>dev, "failed to find video source\n");
-   return PTR_ERR(in);
-   }
-
-   ddata->in = in;
-
-   return 0;
-}
-
 static int tvc_probe(struct platform_device *pdev)
 {
struct panel_drv_data *ddata;
@@ -203,10 +198,6 @@ static int tvc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ddata);
ddata->dev = >dev;
 
-   r = tvc_probe_of(pdev);
-   if (r)
-   return r;
-
ddata->vm = tvc_pal_vm;
 
dssdev = >dssdev;
@@ -219,28 +210,22 @@ static int tvc_probe(struct platform_device *pdev)
r = omapdss_register_display(dssdev);
if (r) {
dev_err(>dev, "Failed to register panel\n");
-   goto err_reg;
+   return r;
}
 
return 0;
-err_reg:
-   omap_dss_put_device(ddata->in);
-   return r;
 }
 
 static int __exit tvc_remove(struct platform_device *pdev)
 {
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *dssdev = >dssdev;
-   struct omap_dss_device *in = ddata->in;
 
omapdss_unregister_display(>dssdev);
 
tvc_disable(dssdev);
tvc_disconnect(dssdev);
 
-   omap_dss_put_device(in);
-
return 0;
 }
 
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c 
b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
index 7728b5425d19..ad915860b7fd 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c
@@ -51,16 +51,25 @@ struct panel_drv_data {
 static int dvic_connect(struct omap_dss_device *dssdev)
 {
struct panel_drv_data *ddata = to_panel_data(dssdev);
-   struct omap_dss_device *in = ddata->in;
+   struct omap_dss_device *in;
int r;
 
if (omapdss_device_is_connected(dssdev))
return 0;
 
+   in = omapdss_of_find_source_for_first_ep(dssdev->dev->of_node);
+   if (IS_ERR(in)) {
+   dev_err(dssdev->dev, "failed to find video source\n");
+   return PTR_ERR(in);
+   }
+
r = in->ops.dvi->connect(in, dssdev);
-   if (r)
+   if (r) {
+   omap_dss_put_device(in);
return r;
+   }
 
+   ddata->in = in;
return 0;
 }
 
@@ -73,6 +82,9 @@ static void dvic_disconnect(struct omap_dss_device *dssdev)
 

[PATCH 11/48] drm: omapdrm: Use unsigned int type

2017-10-13 Thread Laurent Pinchart
The kernel favours 'unsigned int' over plain 'unsigned'. Replace all
occurences of the latter by the former. This avoid lots of checkpatch
complaints in patches that touch lines where a plain 'unsigned' is used.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c|  8 +-
 .../drm/omapdrm/displays/panel-sony-acx565akm.c|  6 +-
 drivers/gpu/drm/omapdrm/dss/dispc.c| 25 +++---
 drivers/gpu/drm/omapdrm/dss/dpi.c  |  2 +-
 drivers/gpu/drm/omapdrm/dss/dsi.c  | 98 +++---
 drivers/gpu/drm/omapdrm/dss/dss.c  | 12 +--
 drivers/gpu/drm/omapdrm/dss/dss.h  | 12 +--
 drivers/gpu/drm/omapdrm/dss/hdmi4.c|  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5.c|  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi5_core.c   | 24 +++---
 drivers/gpu/drm/omapdrm/dss/hdmi_phy.c |  2 +-
 drivers/gpu/drm/omapdrm/dss/hdmi_wp.c  |  2 +-
 drivers/gpu/drm/omapdrm/dss/omapdss.h  |  4 +-
 drivers/gpu/drm/omapdrm/dss/pll.c  |  4 +-
 14 files changed, 102 insertions(+), 101 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
index 92c556ac22c7..bdc0e8a3832d 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
@@ -78,7 +78,7 @@ struct panel_drv_data {
struct workqueue_struct *workqueue;
 
bool ulps_enabled;
-   unsigned ulps_timeout;
+   unsigned int ulps_timeout;
struct delayed_work ulps_work;
 };
 
@@ -483,7 +483,7 @@ static ssize_t dsicm_show_ulps(struct device *dev,
 {
struct platform_device *pdev = to_platform_device(dev);
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-   unsigned t;
+   unsigned int t;
 
mutex_lock(>lock);
t = ddata->ulps_enabled;
@@ -530,7 +530,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev,
 {
struct platform_device *pdev = to_platform_device(dev);
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-   unsigned t;
+   unsigned int t;
 
mutex_lock(>lock);
t = ddata->ulps_timeout;
@@ -1004,7 +1004,7 @@ static int dsicm_memory_read(struct omap_dss_device 
*dssdev,
int r;
int first = 1;
int plen;
-   unsigned buf_used = 0;
+   unsigned int buf_used = 0;
 
if (size < w * h * 3)
return -ENOMEM;
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c 
b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
index 8e5bff4e5226..06d7d8362a73 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
@@ -289,7 +289,7 @@ static void enable_backlight_ctrl(struct panel_drv_data 
*ddata, int enable)
acx565akm_write(ddata, MIPID_CMD_WRITE_CTRL_DISP, (u8 *), 2);
 }
 
-static void set_cabc_mode(struct panel_drv_data *ddata, unsigned mode)
+static void set_cabc_mode(struct panel_drv_data *ddata, unsigned int mode)
 {
u16 cabc_ctrl;
 
@@ -303,12 +303,12 @@ static void set_cabc_mode(struct panel_drv_data *ddata, 
unsigned mode)
acx565akm_write(ddata, MIPID_CMD_WRITE_CABC, (u8 *)_ctrl, 2);
 }
 
-static unsigned get_cabc_mode(struct panel_drv_data *ddata)
+static unsigned int get_cabc_mode(struct panel_drv_data *ddata)
 {
return ddata->cabc_mode;
 }
 
-static unsigned get_hw_cabc_mode(struct panel_drv_data *ddata)
+static unsigned int get_hw_cabc_mode(struct panel_drv_data *ddata)
 {
u8 cabc_ctrl;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c 
b/drivers/gpu/drm/omapdrm/dss/dispc.c
index 0f4fdb221498..f0ae6be36a4e 100644
--- a/drivers/gpu/drm/omapdrm/dss/dispc.c
+++ b/drivers/gpu/drm/omapdrm/dss/dispc.c
@@ -971,7 +971,7 @@ static void dispc_ovl_set_pre_mult_alpha(enum omap_plane_id 
plane,
 static void dispc_ovl_setup_global_alpha(enum omap_plane_id plane,
enum omap_overlay_caps caps, u8 global_alpha)
 {
-   static const unsigned shifts[] = { 0, 8, 16, 24, };
+   static const unsigned int shifts[] = { 0, 8, 16, 24, };
int shift;
 
if ((caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0)
@@ -1199,7 +1199,7 @@ void dispc_wb_set_channel_in(enum dss_writeback_channel 
channel)
 static void dispc_ovl_set_burst_size(enum omap_plane_id plane,
enum omap_burst_size burst_size)
 {
-   static const unsigned shifts[] = { 6, 14, 14, 14, 14, };
+   static const unsigned int shifts[] = { 6, 14, 14, 14, 14, };
int shift;
 
shift = shifts[plane];
@@ -1287,7 +1287,7 @@ static void dispc_ovl_set_vid_color_conv(enum 
omap_plane_id plane,
 static void dispc_ovl_enable_replication(enum omap_plane_id plane,
enum omap_overlay_caps caps, bool enable)
 {
-   static const 

[PATCH 13/48] drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward declaration

2017-10-13 Thread Laurent Pinchart
The tvc_of_match variable is never referenced before its definition.
Remove the forward declaration.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c 
b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
index 542a76503fbd..d3611233e264 100644
--- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
+++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
@@ -40,8 +40,6 @@ static const struct videomode tvc_pal_vm = {
  DISPLAY_FLAGS_VSYNC_LOW,
 };
 
-static const struct of_device_id tvc_of_match[];
-
 #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
 
 static int tvc_connect(struct omap_dss_device *dssdev)
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 12/48] drm: omapdrm: Split init and cleanup from probe and remove functions

2017-10-13 Thread Laurent Pinchart
When merging the omapdrm and omapdss drivers there will be not omapdrm
platform device anymore, and thus no associated probe and remove
functions. To prepare for that, split all the initialization code from
the probe function to make it usable without a platform device.
Similarly, split the cleanup code from the remove function.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 83 +++---
 drivers/gpu/drm/omapdrm/omap_drv.h |  2 +
 2 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 2d15ea1d6c92..cbca70f80d8e 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -542,24 +542,16 @@ static const struct soc_device_attribute 
omapdrm_soc_devices[] = {
{ /* sentinel */ }
 };
 
-static int pdev_probe(struct platform_device *pdev)
+static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 {
const struct soc_device_attribute *soc;
-   struct omap_drm_private *priv;
struct drm_device *ddev;
unsigned int i;
int ret;
 
-   DBG("%s", pdev->name);
-
-   if (omapdss_is_initialized() == false)
-   return -EPROBE_DEFER;
+   DBG("%s", dev_name(dev));
 
-   ret = dma_set_coherent_mask(>dev, DMA_BIT_MASK(32));
-   if (ret) {
-   dev_err(>dev, "Failed to set the DMA mask\n");
-   return ret;
-   }
+   priv->dev = dev;
 
omap_crtc_pre_init();
 
@@ -567,13 +559,6 @@ static int pdev_probe(struct platform_device *pdev)
if (ret)
goto err_crtc_uninit;
 
-   /* Allocate and initialize the driver private structure. */
-   priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-   if (!priv) {
-   ret = -ENOMEM;
-   goto err_disconnect_dssdevs;
-   }
-
priv->dispc_ops = dispc_get_ops();
 
soc = soc_device_match(omapdrm_soc_devices);
@@ -584,27 +569,27 @@ static int pdev_probe(struct platform_device *pdev)
INIT_LIST_HEAD(>obj_list);
 
/* Allocate and initialize the DRM device. */
-   ddev = drm_dev_alloc(_drm_driver, >dev);
+   ddev = drm_dev_alloc(_drm_driver, priv->dev);
if (IS_ERR(ddev)) {
ret = PTR_ERR(ddev);
-   goto err_free_priv;
+   goto err_destroy_wq;
}
 
+   priv->ddev = ddev;
ddev->dev_private = priv;
-   platform_set_drvdata(pdev, ddev);
 
omap_gem_init(ddev);
 
ret = omap_modeset_init(ddev);
if (ret) {
-   dev_err(>dev, "omap_modeset_init failed: ret=%d\n", ret);
+   dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
goto err_free_drm_dev;
}
 
/* Initialize vblank handling, start with all CRTCs disabled. */
ret = drm_vblank_init(ddev, priv->num_crtcs);
if (ret) {
-   dev_err(>dev, "could not init vblank\n");
+   dev_err(priv->dev, "could not init vblank\n");
goto err_cleanup_modeset;
}
 
@@ -637,20 +622,17 @@ static int pdev_probe(struct platform_device *pdev)
 err_free_drm_dev:
omap_gem_deinit(ddev);
drm_dev_unref(ddev);
-err_free_priv:
+err_destroy_wq:
destroy_workqueue(priv->wq);
-   kfree(priv);
-err_disconnect_dssdevs:
omap_disconnect_dssdevs();
 err_crtc_uninit:
omap_crtc_pre_uninit();
return ret;
 }
 
-static int pdev_remove(struct platform_device *pdev)
+static void omapdrm_cleanup(struct omap_drm_private *priv)
 {
-   struct drm_device *ddev = platform_get_drvdata(pdev);
-   struct omap_drm_private *priv = ddev->dev_private;
+   struct drm_device *ddev = priv->ddev;
 
DBG("");
 
@@ -672,10 +654,45 @@ static int pdev_remove(struct platform_device *pdev)
drm_dev_unref(ddev);
 
destroy_workqueue(priv->wq);
-   kfree(priv);
 
omap_disconnect_dssdevs();
omap_crtc_pre_uninit();
+}
+
+static int pdev_probe(struct platform_device *pdev)
+{
+   struct omap_drm_private *priv;
+   int ret;
+
+   if (omapdss_is_initialized() == false)
+   return -EPROBE_DEFER;
+
+   ret = dma_set_coherent_mask(>dev, DMA_BIT_MASK(32));
+   if (ret) {
+   dev_err(>dev, "Failed to set the DMA mask\n");
+   return ret;
+   }
+
+   /* Allocate and initialize the driver private structure. */
+   priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+   if (!priv)
+   return -ENOMEM;
+
+   platform_set_drvdata(pdev, priv);
+
+   ret = omapdrm_init(priv, >dev);
+   if (ret < 0)
+   kfree(priv);
+
+   return ret;
+}
+
+static int pdev_remove(struct platform_device *pdev)
+{
+   struct omap_drm_private *priv = platform_get_drvdata(pdev);
+
+   omapdrm_cleanup(priv);
+   

[PATCH 09/48] drm: omapdrm: Deconstruct the omap_drv.h header.

2017-10-13 Thread Laurent Pinchart
The number of function declarations in the omap_drv.h degrades
readability. To fix it, create new header files for each part of the
driver and move the related functions.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_connector.h |  37 +
 drivers/gpu/drm/omapdrm/omap_crtc.h  |  43 ++
 drivers/gpu/drm/omapdrm/omap_drv.h   | 133 +++
 drivers/gpu/drm/omapdrm/omap_encoder.h   |  33 
 drivers/gpu/drm/omapdrm/omap_fb.h|  46 +++
 drivers/gpu/drm/omapdrm/omap_fbdev.h |  39 +
 drivers/gpu/drm/omapdrm/omap_gem.h   |  99 +++
 drivers/gpu/drm/omapdrm/omap_irq.h   |  39 +
 drivers/gpu/drm/omapdrm/omap_plane.h |  37 +
 9 files changed, 386 insertions(+), 120 deletions(-)
 create mode 100644 drivers/gpu/drm/omapdrm/omap_connector.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_crtc.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_encoder.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_fb.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_fbdev.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_gem.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_irq.h
 create mode 100644 drivers/gpu/drm/omapdrm/omap_plane.h

diff --git a/drivers/gpu/drm/omapdrm/omap_connector.h 
b/drivers/gpu/drm/omapdrm/omap_connector.h
new file mode 100644
index ..98bbc779b302
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_connector.h
@@ -0,0 +1,37 @@
+/*
+ * omap_connector.h -- OMAP DRM Connector
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+#ifndef __OMAPDRM_CONNECTOR_H__
+#define __OMAPDRM_CONNECTOR_H__
+
+#include 
+
+struct drm_connector;
+struct drm_device;
+struct drm_encoder;
+struct omap_dss_device;
+
+struct drm_connector *omap_connector_init(struct drm_device *dev,
+   int connector_type, struct omap_dss_device *dssdev,
+   struct drm_encoder *encoder);
+struct drm_encoder *omap_connector_attached_encoder(
+   struct drm_connector *connector);
+bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
+
+#endif /* __OMAPDRM_CONNECTOR_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h 
b/drivers/gpu/drm/omapdrm/omap_crtc.h
new file mode 100644
index ..ad7b007c6174
--- /dev/null
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
@@ -0,0 +1,43 @@
+/*
+ * omap_crtc.h -- OMAP DRM CRTC
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+#ifndef __OMAPDRM_CRTC_H__
+#define __OMAPDRM_CRTC_H__
+
+#include 
+
+enum omap_channel;
+
+struct drm_crtc;
+struct drm_device;
+struct drm_plane;
+struct omap_dss_device;
+struct videomode;
+
+struct videomode *omap_crtc_timings(struct drm_crtc *crtc);
+enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);
+void omap_crtc_pre_init(void);
+void omap_crtc_pre_uninit(void);
+struct drm_crtc *omap_crtc_init(struct drm_device *dev,
+   struct drm_plane *plane, struct omap_dss_device *dssdev);
+int omap_crtc_wait_pending(struct drm_crtc *crtc);
+void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
+void omap_crtc_vblank_irq(struct drm_crtc *crtc);
+
+#endif /* __OMAPDRM_CRTC_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index 04f35f74f80c..afb2a5a96278 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -17,8 +17,8 @@
  * this program.  If not, see .
  */
 
-#ifndef __OMAP_DRV_H__
-#define __OMAP_DRV_H__
+#ifndef __OMAPDRM_DRV_H__
+#define __OMAPDRM_DRV_H__
 
 #include 
 #include 
@@ -31,6 +31,15 @@
 
 #include "dss/omapdss.h"
 
+#include "omap_connector.h"

[PATCH 10/48] drm: omapdrm: Use kernel integer types

2017-10-13 Thread Laurent Pinchart
The standard kernel integer types are [us]{8,16,32}. Use them instead of
the u?int{8,16,32}_t types.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c  | 12 -
 drivers/gpu/drm/omapdrm/omap_crtc.h  |  2 +-
 drivers/gpu/drm/omapdrm/omap_dmm_priv.h  | 10 +++
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 46 
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.h | 22 +++
 drivers/gpu/drm/omapdrm/omap_drv.h   |  4 +--
 drivers/gpu/drm/omapdrm/omap_fb.c| 18 ++---
 drivers/gpu/drm/omapdrm/omap_gem.c   | 41 +++-
 drivers/gpu/drm/omapdrm/omap_gem.h   | 16 +--
 drivers/gpu/drm/omapdrm/omap_irq.c   |  6 ++---
 drivers/gpu/drm/omapdrm/omap_irq.h   |  2 +-
 drivers/gpu/drm/omapdrm/omap_plane.c |  4 +--
 drivers/gpu/drm/omapdrm/tcm-sita.c   | 12 -
 drivers/gpu/drm/omapdrm/tcm.h|  4 +--
 14 files changed, 101 insertions(+), 98 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index cc85c16cbc2a..f78eac4a8b34 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -273,7 +273,7 @@ static const struct dss_mgr_ops mgr_ops = {
  * Setup, Flush and Page Flip
  */
 
-void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus)
+void omap_crtc_error_irq(struct drm_crtc *crtc, u32 irqstatus)
 {
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
@@ -458,7 +458,7 @@ static int omap_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_plane_state *pri_state;
 
if (state->color_mgmt_changed && state->gamma_lut) {
-   uint length = state->gamma_lut->length /
+   unsigned int length = state->gamma_lut->length /
sizeof(struct drm_color_lut);
 
if (length < 2)
@@ -492,7 +492,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 
if (crtc->state->color_mgmt_changed) {
struct drm_color_lut *lut = NULL;
-   uint length = 0;
+   unsigned int length = 0;
 
if (crtc->state->gamma_lut) {
lut = (struct drm_color_lut *)
@@ -523,7 +523,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
 static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
 struct drm_crtc_state *state,
 struct drm_property *property,
-uint64_t val)
+u64 val)
 {
struct omap_drm_private *priv = crtc->dev->dev_private;
struct drm_plane_state *plane_state;
@@ -551,7 +551,7 @@ static int omap_crtc_atomic_set_property(struct drm_crtc 
*crtc,
 static int omap_crtc_atomic_get_property(struct drm_crtc *crtc,
 const struct drm_crtc_state *state,
 struct drm_property *property,
-uint64_t *val)
+u64 *val)
 {
struct omap_drm_private *priv = crtc->dev->dev_private;
struct omap_crtc_state *omap_state = to_omap_crtc_state(state);
@@ -697,7 +697,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 * gamma table is not supprted.
 */
if (priv->dispc_ops->mgr_gamma_size(channel)) {
-   uint gamma_lut_size = 256;
+   unsigned int gamma_lut_size = 256;
 
drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size);
drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size);
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.h 
b/drivers/gpu/drm/omapdrm/omap_crtc.h
index ad7b007c6174..7f01e730a050 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.h
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.h
@@ -37,7 +37,7 @@ void omap_crtc_pre_uninit(void);
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
struct drm_plane *plane, struct omap_dss_device *dssdev);
 int omap_crtc_wait_pending(struct drm_crtc *crtc);
-void omap_crtc_error_irq(struct drm_crtc *crtc, uint32_t irqstatus);
+void omap_crtc_error_irq(struct drm_crtc *crtc, u32 irqstatus);
 void omap_crtc_vblank_irq(struct drm_crtc *crtc);
 
 #endif /* __OMAPDRM_CRTC_H__ */
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_priv.h 
b/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
index 9f32a83ca507..80fc850212a3 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_priv.h
@@ -102,10 +102,10 @@ struct pat_ctrl {
 };
 
 struct pat {
-   uint32_t next_pa;
+   u32 next_pa;
struct pat_area area;
struct pat_ctrl ctrl;
-   uint32_t data_pa;
+   u32 data_pa;
 };
 
 #define DMM_FIXED_RETRY_COUNT 1000
@@ -129,7 +129,7 @@ struct dmm_txn {
void *engine_handle;

[PATCH 05/48] drm: omapdrm: dss: Set the DMA coherent mask

2017-10-13 Thread Laurent Pinchart
When merging the omapdrm and omapdss drivers the omapdrm virtual
platform device will disappear, and the omapdss platform device will be
used for DMA memory allocation. To prepare for that, set the DMA
coherent mask for the device.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index d1755f12236b..6ce26a4b93b3 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -23,6 +23,7 @@
 #define DSS_SUBSYS_NAME "DSS"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1441,6 +1442,12 @@ static int dss_probe(struct platform_device *pdev)
 
dss.pdev = pdev;
 
+   r = dma_set_coherent_mask(>dev, DMA_BIT_MASK(32));
+   if (r) {
+   dev_err(>dev, "Failed to set the DMA mask\n");
+   return r;
+   }
+
/*
 * The various OMAP3-based SoCs can't be told apart using the compatible
 * string, use SoC device matching.
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 08/48] drm: omapdrm: venc: Return error code on OF parsing failure

2017-10-13 Thread Laurent Pinchart
The venc_probe_of() function has an error cleanup path that returns
success instead of an error code. Fix it.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/venc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c 
b/drivers/gpu/drm/omapdrm/dss/venc.c
index d58da6f32693..1b0fa952b494 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -857,10 +857,10 @@ static int venc_probe_of(struct platform_device *pdev)
of_node_put(ep);
 
return 0;
+
 err:
of_node_put(ep);
-
-   return 0;
+   return r;
 }
 
 /* VENC HW IP initialisation */
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 06/48] drm: omapdrm: dss: Make dss_dump_clocks() function static

2017-10-13 Thread Laurent Pinchart
The function isn't used outside of its compilation unit, make it static.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 4 +++-
 drivers/gpu/drm/omapdrm/dss/dss.h | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c 
b/drivers/gpu/drm/omapdrm/dss/dss.c
index 6ce26a4b93b3..0d447eddf4d6 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -368,7 +368,8 @@ const char *dss_get_clk_source_name(enum dss_clk_source 
clk_src)
return dss_generic_clk_source_names[clk_src];
 }
 
-void dss_dump_clocks(struct seq_file *s)
+#if defined(CONFIG_OMAP2_DSS_DEBUGFS)
+static void dss_dump_clocks(struct seq_file *s)
 {
const char *fclk_name;
unsigned long fclk_rate;
@@ -387,6 +388,7 @@ void dss_dump_clocks(struct seq_file *s)
 
dss_runtime_put();
 }
+#endif
 
 static void dss_dump_regs(struct seq_file *s)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h 
b/drivers/gpu/drm/omapdrm/dss/dss.h
index ed465572491e..0d7f2b08b7ff 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.h
+++ b/drivers/gpu/drm/omapdrm/dss/dss.h
@@ -277,7 +277,6 @@ int dss_dpi_select_source(int port, enum omap_channel 
channel);
 void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
 enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
 const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
-void dss_dump_clocks(struct seq_file *s);
 
 /* DSS VIDEO PLL */
 struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id,
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 07/48] drm: omapdrm: dpi: Remove dpi_data port_initialized field

2017-10-13 Thread Laurent Pinchart
The dpi_data structure port_initialized field is used to check in the
cleanup path whether the DPI has been initialized. This can be performed
through the associated device_node data field instead. Remove the
port_initialized field.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index daf286fc8a40..ce9b27978f48 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -52,8 +52,6 @@ struct dpi_data {
int data_lines;
 
struct omap_dss_device output;
-
-   bool port_initialized;
 };
 
 static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device 
*dssdev)
@@ -786,8 +784,6 @@ int dpi_init_port(struct platform_device *pdev, struct 
device_node *port,
 
dpi_init_output_port(dpi, port);
 
-   dpi->port_initialized = true;
-
return 0;
 
 err_datalines:
@@ -800,7 +796,7 @@ void dpi_uninit_port(struct device_node *port)
 {
struct dpi_data *dpi = port->data;
 
-   if (!dpi->port_initialized)
+   if (!dpi)
return;
 
dpi_uninit_output_port(port);
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 04/48] drm: omapdrm: Merge the omapdss and omapdss-base modules

2017-10-13 Thread Laurent Pinchart
There's no need for the omapdss-base code to be part of a separate
module. Merge it with the omapdss module. This allows removing the
exports for internal symbols.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/Kconfig   |  4 
 drivers/gpu/drm/omapdrm/dss/Makefile  | 19 +--
 drivers/gpu/drm/omapdrm/dss/base.c|  7 ---
 drivers/gpu/drm/omapdrm/dss/display.c |  2 --
 drivers/gpu/drm/omapdrm/dss/dss-of.c  |  2 --
 drivers/gpu/drm/omapdrm/dss/output.c  | 14 --
 6 files changed, 13 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig 
b/drivers/gpu/drm/omapdrm/dss/Kconfig
index f24ebf7f61dd..39a30a64448a 100644
--- a/drivers/gpu/drm/omapdrm/dss/Kconfig
+++ b/drivers/gpu/drm/omapdrm/dss/Kconfig
@@ -1,12 +1,8 @@
 config OMAP2_DSS_INIT
bool
 
-config OMAP_DSS_BASE
-   tristate
-
 menuconfig OMAP2_DSS
 tristate "OMAP2+ Display Subsystem support"
-   select OMAP_DSS_BASE
select VIDEOMODE_HELPERS
select OMAP2_DSS_INIT
select HDMI
diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile 
b/drivers/gpu/drm/omapdrm/dss/Makefile
index 3c5644c3fc38..531b4d8075e5 100644
--- a/drivers/gpu/drm/omapdrm/dss/Makefile
+++ b/drivers/gpu/drm/omapdrm/dss/Makefile
@@ -1,12 +1,19 @@
 obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
-
-obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o
-omapdss-base-y := base.o display.o dss-of.o output.o
-
 obj-$(CONFIG_OMAP2_DSS) += omapdss.o
+
 # Core DSS files
-omapdss-y := core.o dss.o dispc.o dispc_coefs.o \
-   pll.o video-pll.o
+omapdss-y := \
+   base.o \
+   display.o \
+   dss-of.o \
+   output.o \
+   core.o \
+   dss.o \
+   dispc.o \
+   dispc_coefs.o \
+   pll.o \
+   video-pll.o
+
 omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
 omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
 omapdss-$(CONFIG_OMAP2_DSS_SDI) += sdi.o
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 13e91faaf7a6..eff427dd3297 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -20,7 +20,6 @@ void omapdss_set_is_initialized(bool set)
 {
dss_initialized = set;
 }
-EXPORT_SYMBOL(omapdss_set_is_initialized);
 
 bool omapdss_is_initialized(void)
 {
@@ -32,7 +31,6 @@ void dispc_set_ops(const struct dispc_ops *o)
 {
ops = o;
 }
-EXPORT_SYMBOL(dispc_set_ops);
 
 const struct dispc_ops *dispc_get_ops(void)
 {
@@ -108,7 +106,6 @@ void omapdss_gather_components(struct device *dev)
omapdss_walk_device(dev, child, true);
}
 }
-EXPORT_SYMBOL(omapdss_gather_components);
 
 static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp)
 {
@@ -134,7 +131,3 @@ bool omapdss_stack_is_ready(void)
return true;
 }
 EXPORT_SYMBOL(omapdss_stack_is_ready);
-
-MODULE_AUTHOR("Tomi Valkeinen ");
-MODULE_DESCRIPTION("OMAP Display Subsystem Base");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index 8c77a2d20969..a86471f73094 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -35,7 +35,6 @@ void omapdss_default_get_timings(struct omap_dss_device 
*dssdev,
 {
*vm = dssdev->panel.vm;
 }
-EXPORT_SYMBOL(omapdss_default_get_timings);
 
 static LIST_HEAD(panel_list);
 static DEFINE_MUTEX(panel_list_mutex);
@@ -104,7 +103,6 @@ bool omapdss_component_is_display(struct device_node *node)
mutex_unlock(_list_mutex);
return found;
 }
-EXPORT_SYMBOL(omapdss_component_is_display);
 
 struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev)
 {
diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c 
b/drivers/gpu/drm/omapdrm/dss/dss-of.c
index c6b86f348a5c..d3a19a5dfd35 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
@@ -44,7 +44,6 @@ struct device_node *dss_of_port_get_parent_device(struct 
device_node *port)
 
return NULL;
 }
-EXPORT_SYMBOL_GPL(dss_of_port_get_parent_device);
 
 u32 dss_of_port_get_port_number(struct device_node *port)
 {
@@ -57,7 +56,6 @@ u32 dss_of_port_get_port_number(struct device_node *port)
 
return reg;
 }
-EXPORT_SYMBOL_GPL(dss_of_port_get_port_number);
 
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c 
b/drivers/gpu/drm/omapdrm/dss/output.c
index 3c572b699ed3..a84ab0337a91 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -58,7 +58,6 @@ int omapdss_output_set_device(struct omap_dss_device *out,
 
return r;
 }
-EXPORT_SYMBOL(omapdss_output_set_device);
 
 int omapdss_output_unset_device(struct omap_dss_device *out)
 {
@@ -92,7 +91,6 @@ int omapdss_output_unset_device(struct omap_dss_device *out)
 
return r;
 }

[PATCH 02/48] drm: omapdrm: Pass drm_device to omap_gem_resume()

2017-10-13 Thread Laurent Pinchart
The omap_gem_resume() function is internal to the driver. Pass it a
drm_device pointer that the caller already has instead of looking it up
from device data.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 2 +-
 drivers/gpu/drm/omapdrm/omap_drv.h | 2 +-
 drivers/gpu/drm/omapdrm/omap_gem.c | 7 +++
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index cdf5b0601eba..2d15ea1d6c92 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -740,7 +740,7 @@ static int omap_drm_resume(struct device *dev)
 
drm_kms_helper_poll_enable(drm_dev);
 
-   return omap_gem_resume(dev);
+   return omap_gem_resume(drm_dev);
 }
 #endif
 
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index 4bd1e9070b31..04f35f74f80c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -94,7 +94,7 @@ void omap_gem_describe_objects(struct list_head *list, struct 
seq_file *m);
 #endif
 
 #ifdef CONFIG_PM
-int omap_gem_resume(struct device *dev);
+int omap_gem_resume(struct drm_device *dev);
 #endif
 
 int omap_irq_enable_vblank(struct drm_crtc *crtc);
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c 
b/drivers/gpu/drm/omapdrm/omap_gem.c
index 5c5c86ddd6f4..fd81396baaf9 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -996,10 +996,9 @@ void *omap_gem_vaddr(struct drm_gem_object *obj)
 
 #ifdef CONFIG_PM
 /* re-pin objects in DMM in resume path: */
-int omap_gem_resume(struct device *dev)
+int omap_gem_resume(struct drm_device *dev)
 {
-   struct drm_device *drm_dev = dev_get_drvdata(dev);
-   struct omap_drm_private *priv = drm_dev->dev_private;
+   struct omap_drm_private *priv = dev->dev_private;
struct omap_gem_object *omap_obj;
int ret = 0;
 
@@ -1012,7 +1011,7 @@ int omap_gem_resume(struct device *dev)
omap_obj->pages, npages,
omap_obj->roll, true);
if (ret) {
-   dev_err(dev, "could not repin: %d\n", ret);
+   dev_err(dev->dev, "could not repin: %d\n", ret);
return ret;
}
}
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 00/48] omapdrm: Merge omapdrm and omapdss

2017-10-13 Thread Laurent Pinchart
Hello,

This patch series merges the omapdrm and omapdss drivers into a single driver
called omapdrm. The split in two drivers was historical, in order to support
the FBDEV, V4L2 and DRM/KMS APIs. Now that the driver supports DRM/KMS only
there's no need to keep two seperate drivers.

The series starts with a few cleanups (01/48 to 03/48) and quickly proceeds to
merging the omapdss and omapdss-base modules (04/48). It then prepares the
omapdss code (05/48 to 08/48), perform a few more cleanups (09/48 to 11/48)
and prepares the omapdrm code (12/48).

Patches 13/48 to 19/48 prepare the connector, encoder and panel drivers. All
those drivers defer probing when their video source can't be found at probe
time. This would cause endless probe deferral when merging omapdrm and omapdss
as the drivers need omapdss to be fully initialized to probe successfully, but
cause omapdrm to defer probing when they're not available.

Patch 20/48 merges the omapdrm and omapdss drivers.

The next patches are added bonuses that start removal of global variables from
the driver. The code relies heavily on global variables for objects that are
instance-specific, and should thus be dynamically allocated. Most of the
patches change internal APIs to pass objects to driver functions (21/48 to
28/48, 36/48, 39/48 to 41/38, 43/48 to 45/48) with a few miscellaneous
cleanups (29/48, 35/48, 37/48, 38/48, 42/48). Patches 30/48 to 34/48 and 46/48
then allocate instance objects dynamically to replace global variables, and
patches 47/48 and 48/48 move global variables to existing instance objects.

The series has been tested on a Pandaboard with the DVI and HDMI output.

Laurent Pinchart (48):
  drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error
  drm: omapdrm: Pass drm_device to omap_gem_resume()
  drm: omapdrm: Remove unused omap_dss_find_device() function
  drm: omapdrm: Merge the omapdss and omapdss-base modules
  drm: omapdrm: dss: Set the DMA coherent mask
  drm: omapdrm: dss: Make dss_dump_clocks() function static
  drm: omapdrm: dpi: Remove dpi_data port_initialized field
  drm: omapdrm: venc: Return error code on OF parsing failure
  drm: omapdrm: Deconstruct the omap_drv.h header.
  drm: omapdrm: Use kernel integer types
  drm: omapdrm: Use unsigned int type
  drm: omapdrm: Split init and cleanup from probe and remove functions
  drm: omapdrm: connector-analog-tv: Remove tvc_of_match forward
declaration
  drm: omapdrm: displays: Remove OF node check in connector drivers
  drm: omapdrm: displays: Remove OF node check in encoder drivers
  drm: omapdrm: displays: Remove OF node check in panel drivers
  drm: omapdrm: displays: Get connector source at connect time
  drm: omapdrm: displays: Get panel source at connect time
  drm: omapdrm: displays: Get encoder source at connect time
  drm: omapdrm: Merge the omapdrm and omapdss drivers
  drm: omapdrm: dss: Support passing private data to debugfs show
handlers
  drm: omapdrm: dss: Pass DSS private structure to runtime PM functions
  drm: omapdrm: dss: Pass PLL pointer to dss_ctrl_pll_enable()
  drm: omapdrm: sdi: Pass DSS pointer to dss_sdi_*() functions
  drm: omapdrm: dss: Pass DSS pointer to dss_ops operations
  drm: omapdrm: dss: Pass DSS pointer to dss_get_*_clk_source()
  drm: omapdrm: dss: Pass DSS pointer to dss clock functions
  drm: omapdrm: dss: Pass DSS pointer to remaining dss functions
  drm: omapdrm: dss: Remove dss_get_hdmi_venc_clk_source() function
  drm: omapdrm: dss: Allocate the DSS private data structure dynamically
  drm: omapdrm: hdmi4: Allocate the omap_hdmi data structure dynamically
  drm: omapdrm: hdmi5: Allocate the omap_hdmi data structure dynamically
  drm: omapdrm: venc: Allocate the venc private data structure
dynamically
  drm: omapdrm: sdi: Allocate the sdi private data structure dynamically
  drm: omapdrm: dsi: Make wait_for_bit_change() return a status
  drm: omapdrm: dsi: Pass the dsi_data pointer to internal functions
  drm: omapdrm: dsi: Combine two commonly used inline functions
  drm: omapdrm: dsi: Use dev pointer directly in dsi_bind() function
  drm: omapdrm: dsi: Store the struct device pointer in struct dsi_data
  drm: omapdrm: dsi: Don't pass channel to dispc init/uninit functions
  drm: omapdrm: dss: Pass omap_dss_device pointer to dss_mgr_*()
functions
  drm: omapdrm: dss: Remove unused functions prototypes
  drm: omapdrm: dss: Pass omap_drm_private pointer to dss_mgr_ops
  drm: omapdrm: dispc: Pass DISPC pointer to dispc_ops operations
  drm: omapdrm: dispc: Pass DISPC pointer to remaining dispc API
functions
  drm: omapdrm: dispc: Allocate the dispc private data structure
dynamically
  drm: omapdrm: dss: Store the debugfs root directory in struct
dss_device
  drm: omapdrm: dss: Store the registered plls array in struct
dss_device

 drivers/gpu/drm/omapdrm/Kconfig|5 +-
 drivers/gpu/drm/omapdrm/Makefile   |   25 +
 

[PATCH 03/48] drm: omapdrm: Remove unused omap_dss_find_device() function

2017-10-13 Thread Laurent Pinchart
The omap_dss_find_device() function is unused. Remove it.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/dss/display.c | 14 --
 drivers/gpu/drm/omapdrm/dss/omapdss.h |  3 ---
 2 files changed, 17 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/display.c 
b/drivers/gpu/drm/omapdrm/dss/display.c
index 42279933790e..8c77a2d20969 100644
--- a/drivers/gpu/drm/omapdrm/dss/display.c
+++ b/drivers/gpu/drm/omapdrm/dss/display.c
@@ -175,17 +175,3 @@ struct omap_dss_device *omap_dss_get_next_device(struct 
omap_dss_device *from)
return dssdev;
 }
 EXPORT_SYMBOL(omap_dss_get_next_device);
-
-struct omap_dss_device *omap_dss_find_device(void *data,
-   int (*match)(struct omap_dss_device *dssdev, void *data))
-{
-   struct omap_dss_device *dssdev = NULL;
-
-   while ((dssdev = omap_dss_get_next_device(dssdev)) != NULL) {
-   if (match(dssdev, data))
-   return dssdev;
-   }
-
-   return NULL;
-}
-EXPORT_SYMBOL(omap_dss_find_device);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h 
b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index 990422b35784..6f7dc8384055 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -595,9 +595,6 @@ struct omap_dss_device *omap_dss_get_device(struct 
omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
 #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
 struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
-struct omap_dss_device *omap_dss_find_device(void *data,
-   int (*match)(struct omap_dss_device *dssdev, void *data));
-
 
 int omap_dss_get_num_overlay_managers(void);
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 01/48] drm: omapdrm: dpi: Don't treat GPIO probe deferral as an error

2017-10-13 Thread Laurent Pinchart
There's no need to print an error message on probe deferral, that's a
normal situation. Probe deferral debugging can be performed by enabling
the related debug messages in the drivers core.

Signed-off-by: Laurent Pinchart 
---
 drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c 
b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index 947295f9e30f..b8e420c7d680 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -173,7 +173,8 @@ static int tfp410_probe_of(struct platform_device *pdev)
if (gpio_is_valid(gpio) || gpio == -ENOENT) {
ddata->pd_gpio = gpio;
} else {
-   dev_err(>dev, "failed to parse PD gpio\n");
+   if (gpio != -EPROBE_DEFER)
+   dev_err(>dev, "failed to parse PD gpio\n");
return gpio;
}
 
-- 
Regards,

Laurent Pinchart

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >